@brainervirus/workit-pi 1.2.0 → 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({
@@ -7602,6 +7617,7 @@ var workerSchema = object({
7602
7617
  assignment: assignmentSchema,
7603
7618
  state: _enum(["assigned", "dispatching", "running", "cancelling", "stopped", "unknown"]),
7604
7619
  session: refSchema.nullable(),
7620
+ coordinator: refSchema.optional(),
7605
7621
  report: workerReportSchema.nullable()
7606
7622
  }).strict();
7607
7623
  var ownerSchema = object({
@@ -7713,6 +7729,7 @@ var taskSummarySchema = object({
7713
7729
  requirements: array(requirementEvaluationSchema),
7714
7730
  writer: workspaceRecordSchema.shape.writer
7715
7731
  }).strict();
7732
+ var taskListItemSchema = taskSummarySchema.omit({ policy: true, requirements: true }).extend({ source: provenanceSchema.pick({ host: true, kind: true }) }).strict();
7716
7733
  var exportBundleSchema = object({
7717
7734
  schemaVersion: literal(1),
7718
7735
  exportedAt: utc,
@@ -7734,11 +7751,16 @@ var taskOperations = {
7734
7751
  expectedWorkspaceRevision: revision.nullable().optional(),
7735
7752
  intent: intentSchema
7736
7753
  }),
7737
- list: operation({ action: literal("list") }),
7754
+ list: operation({
7755
+ action: literal("list"),
7756
+ status: _enum(["open", "closed", "all"]).optional(),
7757
+ query: string2().trim().min(1).max(200).optional(),
7758
+ limit: number2().int().min(1).max(50).optional()
7759
+ }),
7738
7760
  inspect: operation({
7739
7761
  action: literal("inspect"),
7740
7762
  ...taskId,
7741
- view: _enum(["summary", "full"])
7763
+ view: _enum(["summary", "full"]).optional()
7742
7764
  }),
7743
7765
  revise: operation({
7744
7766
  action: literal("revise"),
@@ -7766,7 +7788,7 @@ var taskOperations = {
7766
7788
  ...taskId,
7767
7789
  ...revisions,
7768
7790
  expectedWorkspaceRevision: revision.optional(),
7769
- authorityRefs: array(refSchema)
7791
+ authorityRefs: array(refSchema).optional()
7770
7792
  }),
7771
7793
  close: operation({
7772
7794
  action: literal("close"),
@@ -7985,6 +8007,7 @@ function candidateDigest(input) {
7985
8007
  });
7986
8008
  }
7987
8009
  // packages/workit-core/src/core/task-store.ts
8010
+ import { AsyncLocalStorage } from "node:async_hooks";
7988
8011
  var processEvidenceSchema = object({
7989
8012
  state: _enum(["stopped", "accounted_for"]),
7990
8013
  pid: number2().int().nonnegative(),
@@ -7995,8 +8018,13 @@ var metadataLockSchema = object({
7995
8018
  pid: number2().int().nonnegative().safe(),
7996
8019
  processStart: string2().nullable(),
7997
8020
  host: string2().min(1),
7998
- nonce: string2().min(1)
8021
+ nonce: string2().min(1),
8022
+ externalAction: literal(true).optional()
7999
8023
  }).strict();
8024
+ var externalActionLockRoots = new AsyncLocalStorage;
8025
+ // packages/workit-core/src/core/workspaces.ts
8026
+ import path from "node:path";
8027
+
8000
8028
  // packages/workit-core/src/core/config.ts
8001
8029
  var PRESETS = {
8002
8030
  gitflow: {
@@ -8018,10 +8046,141 @@ var DEFAULTS = {
8018
8046
  },
8019
8047
  commitPolicy: { preset: "conventional" }
8020
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();
8021
8175
 
8022
8176
  // packages/workit-core/src/core/authority.ts
8023
8177
  var verifiedAuthorities = new WeakMap;
8024
8178
  // packages/workit-core/src/core/external-action.ts
8179
+ var chainStepSchema = union([
8180
+ string2().min(1),
8181
+ object({ branch: string2().min(1) }).strict(),
8182
+ object({ pr: literal(true) }).strict()
8183
+ ]);
8025
8184
  var externalActionSchema = discriminatedUnion("operation", [
8026
8185
  object({
8027
8186
  operation: literal("git.branch_setup"),
@@ -8029,20 +8188,22 @@ var externalActionSchema = discriminatedUnion("operation", [
8029
8188
  action: _enum(["setup", "reapply_stash"]).optional(),
8030
8189
  sdd_dir: string2().optional(),
8031
8190
  target_branch: string2().optional(),
8032
- stash: _enum(["yes", "no"]).optional()
8191
+ stash: _enum(["yes", "no"]).optional(),
8192
+ cwd: string2().min(1).optional()
8033
8193
  }).strict()
8034
8194
  }).strict(),
8035
8195
  object({
8036
8196
  operation: literal("git.commit"),
8037
8197
  payload: object({
8038
8198
  message: string2().min(1).optional(),
8039
- plan_steps: array(string2().min(1)).optional(),
8040
- plan_branch: string2().min(1).optional()
8199
+ plan_steps: array(chainStepSchema).min(1).max(32).optional(),
8200
+ plan_branch: string2().min(1).optional(),
8201
+ cwd: string2().min(1).optional()
8041
8202
  }).strict()
8042
8203
  }).strict(),
8043
8204
  object({
8044
8205
  operation: literal("git.push"),
8045
- payload: object({ branch: string2().min(1).optional() }).strict()
8206
+ payload: object({ branch: string2().min(1).optional(), cwd: string2().min(1).optional() }).strict()
8046
8207
  }).strict(),
8047
8208
  object({
8048
8209
  operation: literal("hosting.pull_request"),
@@ -8051,16 +8212,22 @@ var externalActionSchema = discriminatedUnion("operation", [
8051
8212
  body: string2().optional(),
8052
8213
  draft: boolean2().optional(),
8053
8214
  target_branch: string2().optional(),
8054
- babysit: boolean2().optional()
8215
+ babysit: boolean2().optional(),
8216
+ cwd: string2().min(1).optional()
8055
8217
  }).strict()
8056
8218
  }).strict(),
8057
8219
  object({
8058
8220
  operation: literal("hosting.merge"),
8059
8221
  payload: object({
8060
8222
  target_branch: string2().min(1).optional(),
8061
- source_branch: string2().min(1).optional()
8223
+ source_branch: string2().min(1).optional(),
8224
+ cwd: string2().min(1).optional()
8062
8225
  }).strict()
8063
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(),
8064
8231
  object({
8065
8232
  operation: literal("youtrack.update"),
8066
8233
  payload: object({
@@ -8116,7 +8283,8 @@ var externalActionSchema = discriminatedUnion("operation", [
8116
8283
  issueRef: string2().optional(),
8117
8284
  mode: string2().optional(),
8118
8285
  specPath: string2().optional(),
8119
- planPath: string2().optional()
8286
+ planPath: string2().optional(),
8287
+ cwd: string2().min(1).optional()
8120
8288
  }).strict()
8121
8289
  }).strict()
8122
8290
  ]);