@brainervirus/workit-pi 1.2.1 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -20,5 +20,7 @@ resolves extension packages in your setup.
20
20
  ## Notes
21
21
 
22
22
  - Only an observed child process may acquire the shared writer; cancellation or restart uncertainty blocks replacement ownership.
23
- - The extension is a workflow control, not an OS sandbox: shell writes stay agent-guided.
23
+ - The extension is a workflow control, not an OS sandbox: a supported literal
24
+ branch-creation command is checked against workspace naming policy; other
25
+ shell forms stay under the host's native permission rules.
24
26
  - Approval uses native `ctx.ui.confirm`, or `needs_input` when headless.
package/dist/worker.js CHANGED
@@ -5307,6 +5307,17 @@ function _array(Class, element, params) {
5307
5307
  ...normalizeParams(params)
5308
5308
  });
5309
5309
  }
5310
+ function _custom(Class, fn, _params) {
5311
+ const norm = normalizeParams(_params);
5312
+ norm.abort ?? (norm.abort = true);
5313
+ const schema = new Class({
5314
+ type: "custom",
5315
+ check: "custom",
5316
+ fn,
5317
+ ...norm
5318
+ });
5319
+ return schema;
5320
+ }
5310
5321
  function _refine(Class, fn, _params) {
5311
5322
  const schema = new Class({
5312
5323
  type: "custom",
@@ -7237,6 +7248,9 @@ var ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
7237
7248
  ZodType.init(inst, def);
7238
7249
  inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx, json, params);
7239
7250
  });
7251
+ function custom(fn, _params) {
7252
+ return _custom(ZodCustom, fn ?? (() => true), _params);
7253
+ }
7240
7254
  function refine(fn, _params = {}) {
7241
7255
  return _refine(ZodCustom, fn, _params);
7242
7256
  }
@@ -7571,7 +7585,8 @@ var decisionSchema = object({
7571
7585
  consumption: object({
7572
7586
  state: _enum(["reserved", "consumed", "uncertain"]),
7573
7587
  at: utc,
7574
- actionRef: refSchema
7588
+ actionRef: refSchema,
7589
+ historicalActionId: text.optional()
7575
7590
  }).strict().nullable()
7576
7591
  }).strict();
7577
7592
  var findingSchema = object({
@@ -7714,7 +7729,7 @@ var taskSummarySchema = object({
7714
7729
  requirements: array(requirementEvaluationSchema),
7715
7730
  writer: workspaceRecordSchema.shape.writer
7716
7731
  }).strict();
7717
- var taskListItemSchema = taskSummarySchema.omit({ policy: true, requirements: true });
7732
+ var taskListItemSchema = taskSummarySchema.omit({ policy: true, requirements: true }).extend({ source: provenanceSchema.pick({ host: true, kind: true }) }).strict();
7718
7733
  var exportBundleSchema = object({
7719
7734
  schemaVersion: literal(1),
7720
7735
  exportedAt: utc,
@@ -7739,6 +7754,7 @@ var taskOperations = {
7739
7754
  list: operation({
7740
7755
  action: literal("list"),
7741
7756
  status: _enum(["open", "closed", "all"]).optional(),
7757
+ query: string2().trim().min(1).max(200).optional(),
7742
7758
  limit: number2().int().min(1).max(50).optional()
7743
7759
  }),
7744
7760
  inspect: operation({
@@ -7991,6 +8007,7 @@ function candidateDigest(input) {
7991
8007
  });
7992
8008
  }
7993
8009
  // packages/workit-core/src/core/task-store.ts
8010
+ import { AsyncLocalStorage } from "node:async_hooks";
7994
8011
  var processEvidenceSchema = object({
7995
8012
  state: _enum(["stopped", "accounted_for"]),
7996
8013
  pid: number2().int().nonnegative(),
@@ -8001,8 +8018,13 @@ var metadataLockSchema = object({
8001
8018
  pid: number2().int().nonnegative().safe(),
8002
8019
  processStart: string2().nullable(),
8003
8020
  host: string2().min(1),
8004
- nonce: string2().min(1)
8021
+ nonce: string2().min(1),
8022
+ externalAction: literal(true).optional()
8005
8023
  }).strict();
8024
+ var externalActionLockRoots = new AsyncLocalStorage;
8025
+ // packages/workit-core/src/core/workspaces.ts
8026
+ import path from "node:path";
8027
+
8006
8028
  // packages/workit-core/src/core/config.ts
8007
8029
  var PRESETS = {
8008
8030
  gitflow: {
@@ -8024,6 +8046,132 @@ var DEFAULTS = {
8024
8046
  },
8025
8047
  commitPolicy: { preset: "conventional" }
8026
8048
  };
8049
+ var COMMIT_PRESETS = [
8050
+ "conventional",
8051
+ "gitmoji",
8052
+ "ticket-prefix",
8053
+ "freeform",
8054
+ "custom",
8055
+ "auto"
8056
+ ];
8057
+
8058
+ // packages/workit-core/src/core/workspaces.ts
8059
+ var nonBlank = string2().refine((value) => value.trim().length > 0, "must not be blank");
8060
+ var branchPreset = custom((value) => typeof value === "string" && Object.hasOwn(PRESETS, value), "unsupported branch preset");
8061
+ var commitPreset = custom((value) => typeof value === "string" && COMMIT_PRESETS.includes(value), "unsupported commit preset");
8062
+ var workspaceBranchPolicySchema = object({
8063
+ preset: branchPreset,
8064
+ developBranch: nonBlank.optional(),
8065
+ prefixes: object({
8066
+ feature: nonBlank,
8067
+ bugfix: nonBlank,
8068
+ release: nonBlank,
8069
+ hotfix: nonBlank
8070
+ }).passthrough().optional(),
8071
+ allowed: array(nonBlank).optional(),
8072
+ protected: array(nonBlank).optional(),
8073
+ integration: _enum(["pr", "merge"]).optional()
8074
+ }).strict();
8075
+ var workspaceCommitPolicySchema = object({ preset: commitPreset, pattern: string2().optional() }).strict();
8076
+ var workspaceProfileSchema = object({
8077
+ branchPolicy: workspaceBranchPolicySchema.optional(),
8078
+ commitPolicy: workspaceCommitPolicySchema.optional()
8079
+ }).strict().refine((profile) => profile.branchPolicy !== undefined || profile.commitPolicy !== undefined, {
8080
+ message: "a profile must define branchPolicy or commitPolicy"
8081
+ });
8082
+ var versionSourceSchema = discriminatedUnion("kind", [
8083
+ object({
8084
+ kind: literal("package-json"),
8085
+ path: nonBlank,
8086
+ field: nonBlank
8087
+ }).strict(),
8088
+ object({ kind: literal("git-tag") }).strict(),
8089
+ object({ kind: literal("manual") }).strict()
8090
+ ]);
8091
+ var releaseTrackSchema = object({
8092
+ strategy: branchPreset,
8093
+ productionBranch: nonBlank,
8094
+ integrationBranch: nonBlank,
8095
+ naming: object({ feature: nonBlank, release: nonBlank, hotfix: nonBlank }).strict(),
8096
+ baseBranch: nonBlank,
8097
+ mergeBackBranches: array(nonBlank),
8098
+ pullRequestTarget: nonBlank,
8099
+ tagNamespace: string2(),
8100
+ versionSource: versionSourceSchema,
8101
+ requiredChecks: array(nonBlank)
8102
+ }).strict().superRefine((track, context) => {
8103
+ for (const [field, values] of [
8104
+ ["mergeBackBranches", track.mergeBackBranches],
8105
+ ["requiredChecks", track.requiredChecks]
8106
+ ]) {
8107
+ if (new Set(values).size !== values.length) {
8108
+ context.addIssue({ code: "custom", path: [field], message: "entries must be unique" });
8109
+ }
8110
+ }
8111
+ if (track.versionSource.kind === "package-json" && (path.posix.isAbsolute(track.versionSource.path.replaceAll("\\", "/")) || /^[A-Za-z]:\//u.test(track.versionSource.path.replaceAll("\\", "/")) || track.versionSource.path.replaceAll("\\", "/").split("/").includes(".."))) {
8112
+ context.addIssue({
8113
+ code: "custom",
8114
+ path: ["versionSource", "path"],
8115
+ message: "must stay inside the repository"
8116
+ });
8117
+ }
8118
+ });
8119
+ var workspaceConfigSchema = object({
8120
+ name: nonBlank,
8121
+ glob: nonBlank,
8122
+ vcs: object({
8123
+ provider: _enum(["gitlab", "github"]),
8124
+ defaultTargetBranch: nonBlank.optional(),
8125
+ tokenFile: nonBlank.optional(),
8126
+ account: nonBlank.optional()
8127
+ }).passthrough().optional(),
8128
+ autoApprove: union([boolean2(), array(nonBlank)]).optional(),
8129
+ youtrack: object({ baseUrl: nonBlank.optional(), link_issues: boolean2().optional() }).passthrough().optional(),
8130
+ issues: object({ provider: literal("github").optional(), link_on_pr: boolean2().optional() }).passthrough().optional(),
8131
+ branchPolicy: workspaceBranchPolicySchema.optional(),
8132
+ commitPolicy: workspaceCommitPolicySchema.optional(),
8133
+ defaultProfile: nonBlank.optional(),
8134
+ profiles: record(nonBlank, workspaceProfileSchema).optional(),
8135
+ releaseTracks: record(nonBlank, releaseTrackSchema).optional()
8136
+ }).passthrough().superRefine((workspace, context) => {
8137
+ if (workspace.youtrack && workspace.vcs?.provider !== "gitlab") {
8138
+ context.addIssue({
8139
+ code: "custom",
8140
+ path: ["youtrack"],
8141
+ message: `YouTrack issue linking requires the gitlab provider, got ${workspace.vcs?.provider ?? "unset"}`
8142
+ });
8143
+ }
8144
+ if (workspace.issues && workspace.vcs?.provider !== "github") {
8145
+ context.addIssue({
8146
+ code: "custom",
8147
+ path: ["issues"],
8148
+ message: `GitHub issue linking requires the github provider, got ${workspace.vcs?.provider ?? "unset"}`
8149
+ });
8150
+ }
8151
+ if (workspace.defaultProfile !== undefined && !Object.hasOwn(workspace.profiles ?? {}, workspace.defaultProfile)) {
8152
+ context.addIssue({
8153
+ code: "custom",
8154
+ path: ["defaultProfile"],
8155
+ message: `does not name a configured profile`
8156
+ });
8157
+ }
8158
+ });
8159
+ var workspacesFileSchema = object({ workspaces: array(workspaceConfigSchema).optional() }).passthrough().superRefine((file, context) => {
8160
+ const names = new Set;
8161
+ for (const [index, workspace] of (file.workspaces ?? []).entries()) {
8162
+ if (names.has(workspace.name)) {
8163
+ context.addIssue({
8164
+ code: "custom",
8165
+ path: ["workspaces", index, "name"],
8166
+ message: `duplicate workspace name ${JSON.stringify(workspace.name)}`
8167
+ });
8168
+ }
8169
+ names.add(workspace.name);
8170
+ }
8171
+ });
8172
+ var runtimeWorkspaceIndexSchema = object({
8173
+ workspaces: array(object({ name: nonBlank, glob: nonBlank }).passthrough()).optional()
8174
+ }).passthrough();
8027
8175
 
8028
8176
  // packages/workit-core/src/core/authority.ts
8029
8177
  var verifiedAuthorities = new WeakMap;
@@ -8040,7 +8188,8 @@ var externalActionSchema = discriminatedUnion("operation", [
8040
8188
  action: _enum(["setup", "reapply_stash"]).optional(),
8041
8189
  sdd_dir: string2().optional(),
8042
8190
  target_branch: string2().optional(),
8043
- stash: _enum(["yes", "no"]).optional()
8191
+ stash: _enum(["yes", "no"]).optional(),
8192
+ cwd: string2().min(1).optional()
8044
8193
  }).strict()
8045
8194
  }).strict(),
8046
8195
  object({
@@ -8048,12 +8197,13 @@ var externalActionSchema = discriminatedUnion("operation", [
8048
8197
  payload: object({
8049
8198
  message: string2().min(1).optional(),
8050
8199
  plan_steps: array(chainStepSchema).min(1).max(32).optional(),
8051
- plan_branch: string2().min(1).optional()
8200
+ plan_branch: string2().min(1).optional(),
8201
+ cwd: string2().min(1).optional()
8052
8202
  }).strict()
8053
8203
  }).strict(),
8054
8204
  object({
8055
8205
  operation: literal("git.push"),
8056
- payload: object({ branch: string2().min(1).optional() }).strict()
8206
+ payload: object({ branch: string2().min(1).optional(), cwd: string2().min(1).optional() }).strict()
8057
8207
  }).strict(),
8058
8208
  object({
8059
8209
  operation: literal("hosting.pull_request"),
@@ -8062,16 +8212,22 @@ var externalActionSchema = discriminatedUnion("operation", [
8062
8212
  body: string2().optional(),
8063
8213
  draft: boolean2().optional(),
8064
8214
  target_branch: string2().optional(),
8065
- babysit: boolean2().optional()
8215
+ babysit: boolean2().optional(),
8216
+ cwd: string2().min(1).optional()
8066
8217
  }).strict()
8067
8218
  }).strict(),
8068
8219
  object({
8069
8220
  operation: literal("hosting.merge"),
8070
8221
  payload: object({
8071
8222
  target_branch: string2().min(1).optional(),
8072
- source_branch: string2().min(1).optional()
8223
+ source_branch: string2().min(1).optional(),
8224
+ cwd: string2().min(1).optional()
8073
8225
  }).strict()
8074
8226
  }).strict(),
8227
+ object({
8228
+ operation: literal("hosting.delete_branch"),
8229
+ payload: object({ branch: string2().min(1), cwd: string2().min(1).optional() }).strict()
8230
+ }).strict(),
8075
8231
  object({
8076
8232
  operation: literal("youtrack.update"),
8077
8233
  payload: object({
@@ -8127,7 +8283,8 @@ var externalActionSchema = discriminatedUnion("operation", [
8127
8283
  issueRef: string2().optional(),
8128
8284
  mode: string2().optional(),
8129
8285
  specPath: string2().optional(),
8130
- planPath: string2().optional()
8286
+ planPath: string2().optional(),
8287
+ cwd: string2().min(1).optional()
8131
8288
  }).strict()
8132
8289
  }).strict()
8133
8290
  ]);