@workit-dev/pi 2.11.0 → 2.11.1

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/dist/worker.js CHANGED
@@ -9783,78 +9783,6 @@ var MUTATING_REMOTE = new Set([
9783
9783
  "set-branches",
9784
9784
  "prune"
9785
9785
  ]);
9786
- var GIT_VERBS = {
9787
- log: "@d@l|@d @l",
9788
- show: "@d@l|@d @l",
9789
- diff: "@d|@d cached staged merge-base no-index",
9790
- "diff-tree": "@drtcm|@d root stdin no-commit-id",
9791
- "diff-index": "@dm|@d cached merge-base",
9792
- status: "sbu?zv|short branch porcelain? long untracked-files? ignored? ignore-submodules? show-stash ahead-behind no-ahead-behind renames no-renames find-renames? column? no-column null verbose",
9793
- "rev-parse": "q|verify short? abbrev-ref? symbolic symbolic-full-name show-toplevel show-prefix git-dir git-common-dir absolute-git-dir is-inside-work-tree is-inside-git-dir is-bare-repository show-cdup quiet all branches? tags? remotes? since= until= default= path-format= sq-quote",
9794
- "rev-list": "@l|@l count objects? left-only right-only",
9795
- "ls-files": "cdmoiskuvtzfx:X:|cached deleted modified others ignored stage unmerged killed directory no-empty-directory exclude-standard exclude= exclude-from= full-name abbrev? error-unmatch with-tree= eol deduplicate format= recurse-submodules sparse",
9796
- "ls-tree": "rdtlz|long name-only name-status object-only full-name full-tree abbrev? format=",
9797
- "cat-file": "tsepz|batch? batch-check? batch-all-objects follow-symlinks unordered buffer allow-unknown-type mailmap use-mailmap",
9798
- blame: "L:lstfnepwbcM?C?|porcelain line-porcelain incremental root show-stats show-name show-number show-email abbrev= reverse= first-parent date= ignore-rev= ignore-revs-file= minimal contents=",
9799
- describe: "|tags all long abbrev= contains always dirty? broken? match= exclude= first-parent exact-match candidates= debug",
9800
- "merge-base": "a|all octopus independent is-ancestor fork-point",
9801
- "for-each-ref": "|count= sort= format= color? shell perl python tcl points-at= merged? no-merged? contains? no-contains? ignore-case omit-empty exclude=",
9802
- shortlog: "@lsnec|@l summary numbered email committer group= format=",
9803
- "show-ref": "dsq|head verify heads tags branches hash? abbrev? quiet dereference exists",
9804
- "name-rev": "|tags refs= exclude= all annotate-stdin name-only no-undefined always",
9805
- grep: "aiIvnhHcEGFPlLzoWqwe:A:B:C:m:f:|cached untracked no-index no-exclude-standard exclude-standard recurse-submodules text ignore-case word-regexp invert-match line-number column count full-name extended-regexp basic-regexp fixed-strings perl-regexp files-with-matches name-only files-without-match null only-matching heading break show-function function-context max-depth= threads= and or not all-match quiet after-context= before-context= context= max-count= color? no-color",
9806
- "format-patch": "@do:nNks|@d stdout output-directory= numbered no-numbered start-number= subject-prefix= root cover-letter thread? signoff attach? inline? suffix= base=",
9807
- reflog: "@l|@l all expire= expire-unreachable= rewrite updateref stale-fix dry-run verbose",
9808
- "count-objects": "vH|verbose human-readable",
9809
- "check-ignore": "qvnz|quiet verbose stdin non-matching no-index",
9810
- var: "l|",
9811
- version: "|build-options",
9812
- "ls-remote": "htbq|heads tags branches refs quiet exit-code get-url symref sort=",
9813
- remote: "v|verbose",
9814
- config: "lz|get get-all get-regexp list local name-only null type= default=",
9815
- worktree: "fdqvzb:B:|force detach lock reason= orphan no-checkout checkout quiet track no-track guess-remote porcelain expire= verbose",
9816
- branch: "dDmMcCfvraliu:|delete move copy force list all remotes verbose contains? merged? no-merged? points-at= show-current set-upstream-to= unset-upstream track? no-track sort= format= color? column? ignore-case create-reflog",
9817
- tag: "lam:dfF:n?|list annotate message= file= delete force sort= format= contains? merged? no-merged? points-at= column? create-reflog ignore-case",
9818
- init: "+qb:|quiet bare initial-branch= object-format= ref-format= shared? separate-git-dir=",
9819
- add: "+AunNvf|all update intent-to-add force dry-run verbose ignore-errors ignore-removal no-all renormalize chmod= sparse",
9820
- commit: "+m:aqsnF:C:ouv|message= all amend no-edit allow-empty allow-empty-message author= date= signoff no-verify quiet file= reuse-message= fixup= squash= only include dry-run no-gpg-sign untracked-files? cleanup= reset-author verbose",
9821
- checkout: "+b:B:fqm|detach force orphan= quiet track? no-track merge ours theirs",
9822
- switch: "+c:C:dfqm|create= force-create= detach discard-changes force orphan= quiet track? no-track merge",
9823
- restore: "+s:SWq|source= staged worktree ours theirs merge quiet overlay no-overlay",
9824
- reset: "+qN|soft mixed hard merge keep quiet no-refresh",
9825
- rm: "+rfnq|cached force dry-run quiet ignore-unmatch",
9826
- mv: "+fnkv|force dry-run verbose",
9827
- merge: "+m:qvnX:|no-ff ff ff-only squash no-squash commit no-commit message= no-edit abort continue quit allow-unrelated-histories stat no-stat quiet verbose no-verify signoff strategy-option=",
9828
- stash: "+m:ukqa|message= include-untracked keep-index quiet all index staged",
9829
- apply: "+p:C:R3qv|check stat numstat summary index cached 3way reverse reject allow-empty exclude= include= verbose quiet whitespace= recount",
9830
- am: "+skq3|signoff keep 3way quiet abort continue skip quit whitespace= reject",
9831
- fetch: "+fqvptn|all depth= deepen= shallow-since= unshallow tags no-tags prune force quiet verbose dry-run update-shallow refmap=",
9832
- clone: "+nqlsb:o:|bare no-checkout depth= branch= origin= single-branch no-single-branch no-tags quiet shared local no-local filter= separate-git-dir=",
9833
- "cherry-pick": "+nm:sxX:|no-commit mainline= signoff abort continue skip quit allow-empty keep-redundant-commits ff strategy-option=",
9834
- revert: "+nm:sX:|no-commit mainline= signoff abort continue skip quit strategy-option= no-edit",
9835
- rebase: "+qvfnX:|onto= root abort continue skip quit keep-base no-ff force-rebase autosquash no-autosquash autostash no-autostash update-refs signoff quiet verbose stat no-stat committer-date-is-author-date reset-author-date rebase-merges? no-rebase-merges empty= strategy-option= apply merge",
9836
- clean: "+dfnqxXe:|dry-run force quiet exclude=",
9837
- bisect: "+|term-old= term-new= no-checkout first-parent"
9838
- };
9839
- var JUDGE_GIT = `a judge runs git ${Object.keys(GIT_VERBS).join(" ")} with the options each documents (no abbreviations), writing only in a scratch repo; no -c, no wrapper but timeout, nice, time, command, no env but PAGER=cat, GIT_PAGER=cat, GIT_OPTIONAL_LOCKS=0, LC_*, LANG, TZ; status outside scratch needs --no-optional-locks`;
9840
- var JUDGE_VERBS = {
9841
- check: true,
9842
- dir: true,
9843
- help: true,
9844
- "test-audit": true,
9845
- ledger: ["verdict", "list", "check", "ruling", "show"],
9846
- finding: ["record", "list"],
9847
- pr: ["status"],
9848
- ci: ["wait", "logs"],
9849
- fanout: ["status", "brief"],
9850
- models: ["show"],
9851
- lock: ["status"],
9852
- lease: ["status"],
9853
- grant: ["show"],
9854
- task: ["show", "list"],
9855
- doctor: ["--json"]
9856
- };
9857
- var JUDGE_JOB = Object.entries(JUDGE_VERBS).map(([verb, subs]) => `workit ${verb}${subs === true ? "" : ` ${subs.join("|")}`}`).join(", ");
9858
9786
 
9859
9787
  // packages/workit-core/src/hooks/steering.ts
9860
9788
  var ROLES = {
package/dist/workit.js CHANGED
@@ -26439,8 +26439,10 @@ var opaqueWrites = (input, scriptOf = (index) => input[index], fed) => {
26439
26439
  return curlOutputs(args);
26440
26440
  if (name === "perl")
26441
26441
  return inline(/^-[a-zA-Z]*[eE]$/);
26442
+ if (name.startsWith("python") && args.some((arg, at) => arg === "-m" && args[at + 1] !== "json.tool"))
26443
+ return [".", ...args.flatMap(pathsIn)];
26442
26444
  if (/^(?:python[\d.]*|node|bun|deno|ruby|php)$/.test(name))
26443
- return inline(/^-[a-zA-Z]*[ce]$|^--eval$|^-p$/);
26445
+ return inline(/^-[a-zA-Z]*[cep]$|^--(?:eval|print)$/);
26444
26446
  return shellScript2(words) === null ? null : ["."];
26445
26447
  };
26446
26448
  var CURL_LONG = [
@@ -27173,7 +27175,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
27173
27175
  shells.push(...read(named));
27174
27176
  shells.push(...preloads.flatMap(read));
27175
27177
  } else if (INTERPRETERS.test(verb)) {
27176
- const code = args.findIndex((arg) => /^-[a-zA-Z]*[ce]$|^--eval$/.test(arg));
27178
+ const code = args.findIndex((arg) => /^-[a-zA-Z]*[cep]$|^--(?:eval|print)$/.test(arg));
27177
27179
  if (code >= 0)
27178
27180
  others.push(...expansions(args[code + 1] ?? "", vars, loops));
27179
27181
  others.push(...named === undefined ? [...segment.stdin ?? [], ...inputs.flatMap(read), ...piped] : read(named), ...preloads.flatMap(read));
@@ -29171,50 +29173,38 @@ var shown = (target) => {
29171
29173
  const named = /^\.workit-(?:live-target$|runs-)/.test(path47.basename(target)) ? path47.dirname(target) : target;
29172
29174
  return path47.sep === "\\" ? named.replaceAll("/", "\\") : named;
29173
29175
  };
29174
- var unboundDeny = (input, target) => {
29175
- const unblock = "Work only in the worktree your brief names, which the lead made with `workit fanout worktree create <slice>`: edit files under it and run one verb per call against it (`workit git --cwd <worktree> commit -m … -- <paths>`, `workit check --cwd <worktree> <name>`). If your brief names no worktree, stop and report that to the lead.";
29176
- return {
29177
- kind: "deny",
29178
- reason: `workit worktree confinement: implementer ${input.session.agentId} is not working in a Workit worktree yet, and ${shown(target)} is outside every worktree \`workit fanout worktree create\` made, so it would change the lead's checkout. ${unblock}`,
29179
- unblock
29180
- };
29181
- };
29182
- var outsideDeny = (input, worktree, target) => {
29176
+ var runFrom = (dir, command) => `cd ${dir} && ${command.replace(/^\s*cd\s+\S+\s*(?:&&|;)\s*/, "")}`;
29177
+ var deny2 = (what, unblock) => ({
29178
+ kind: "deny",
29179
+ reason: `${what}.
29180
+ ${unblock}`,
29181
+ unblock
29182
+ });
29183
+ var unboundDeny = (input, target) => deny2(`workit worktree confinement: implementer ${input.session.agentId} is not working in a Workit worktree yet, and ${shown(target)} is outside every one`, "Why: work only in your brief's worktree (`workit fanout worktree create <slice>`); with none, tell the lead.");
29184
+ var outsideDeny = (input, worktree, target, command) => {
29183
29185
  const runner = runnerAt(target);
29184
- const unblock = `${runner === null ? "" : `Run \`${runner}\` from your worktree: \`cd ${worktree} && …\`. `}Edit only under ${worktree} and run git there, one verb per call: \`workit git --cwd ${worktree} commit -m … -- <paths>\`, \`workit check --cwd ${worktree} <name>\` (or \`git -C ${worktree} …\`); a command whose writes Workit cannot see is judged by the directory it runs in. Anything outside it is a follow-up for your report.`;
29185
- return {
29186
- kind: "deny",
29187
- reason: `workit worktree confinement: implementer ${input.session.agentId} is bound to the worktree ${worktree}, and ${runner === null ? `${shown(target)} is` : `\`${runner}\` runs in ${shown(target)},`} outside it. ${unblock}`,
29188
- unblock
29189
- };
29190
- };
29191
- var unknownDirDeny = (input, worktree) => {
29192
- const wt = worktree ?? "<worktree>";
29193
- const unblock = `Workit cannot resolve \`cd -\`, \`cd "$X"\` or \`popd\`: write by absolute path, \`git -C ${wt}\` or \`workit <verb> --cwd ${wt}\`.`;
29194
- return {
29195
- kind: "deny",
29196
- reason: `workit worktree confinement: implementer ${input.session.agentId} writes after an unknown directory change. ${unblock}`,
29197
- unblock
29198
- };
29186
+ return deny2(`workit worktree confinement: implementer ${input.session.agentId} is bound to the worktree ${worktree}, and ${runner === null ? `${shown(target)} is` : `\`${runner}\` runs in ${shown(target)},`} outside it`, runner !== null && command ? `Retry as: ${runFrom(worktree, command)}` : `Why: edit only under ${worktree}, git one verb per call (\`workit git --cwd ${worktree} commit -m … -- <paths>\`); the rest is a follow-up.`);
29199
29187
  };
29188
+ var unknownDirDeny = (input, worktree) => deny2(`workit worktree confinement: implementer ${input.session.agentId} writes after a directory change Workit cannot resolve (\`cd -\`, \`cd "$X"\`, \`popd\`)`, `Why: write by absolute path, \`git -C ${worktree ?? "<worktree>"}\` or \`workit <verb> --cwd\`.`);
29189
+ var refsOf = (targets) => [
29190
+ ...new Set(targets.flatMap((target) => path47.relative(UNKNOWN_VAR, path47.resolve(target)).split(path47.sep)[0].split("+").filter(Boolean).map(decodeURIComponent)))
29191
+ ];
29200
29192
  var literalForm = (command, refs) => {
29201
29193
  let text = command;
29202
- for (const ref of refs) {
29194
+ for (const ref of refs.filter((one) => /^[$`]/.test(one))) {
29203
29195
  const placeholder = `<absolute path of ${ref}>`;
29204
29196
  const name = /^\$(\w+)$/.exec(ref)?.[1];
29205
29197
  text = name ? text.replace(new RegExp(`\\$\\{${name}[^}]*\\}|\\$${name}(?!\\w)`, "g"), placeholder) : text.replaceAll(ref, placeholder);
29206
29198
  }
29207
29199
  return text.length > 600 ? `${text.slice(0, 600)}…` : text;
29208
29200
  };
29209
- var unknownVarDeny = (input, worktree, targets, command) => {
29210
- const refs = [
29211
- ...new Set(targets.flatMap((target) => path47.relative(UNKNOWN_VAR, path47.resolve(target)).split(path47.sep)[0].split("+").filter(Boolean).map(decodeURIComponent)))
29212
- ];
29201
+ var unknownVarDeny = (input, targets, command) => {
29202
+ const refs = refsOf(targets);
29213
29203
  let text = command ?? "";
29214
29204
  const first = [];
29215
29205
  const named = refs.map((ref) => {
29216
29206
  const name = /^\$(\w+)$/.exec(ref)?.[1];
29217
- const set = name ? new RegExp(`(^|[\\s;&|(])${name}=("?)(\\$\\([^()]*\\)|\`[^\`]*\`)\\2[ \\t]*(?:&&|;|\\n)?[ \\t]*`).exec(text) : null;
29207
+ const set = name ? new RegExp(`(^|[\\s;&|(])${name}=("?)(\\$\\([^()]*\\)|\`[^\`]*\`)\\2[ \\t]*(?:&&|;|\\n|$)[ \\t]*`).exec(text) : null;
29218
29208
  const sub = set?.[3] ?? (/^(?:\$\(|`)/.test(ref) ? ref : null);
29219
29209
  if (sub === null)
29220
29210
  return ref;
@@ -29223,15 +29213,8 @@ var unknownVarDeny = (input, worktree, targets, command) => {
29223
29213
  first.push(`Run \`${sub.slice(sub.startsWith("`") ? 1 : 2, -1).trim()}\` first, then`);
29224
29214
  return sub === ref ? ref : `${ref} (set by \`${sub}\`)`;
29225
29215
  });
29226
- const wt = worktree ?? "<worktree>";
29227
- const literal = literalForm(text, refs.filter((ref) => /^[$`]/.test(ref)));
29228
- const retry = command === undefined || literal === command ? "" : ` ${first.length ? `${first.join(" ")} retry` : "Retry"} as: \`${literal}\`.`;
29229
- const unblock = `Spell the path out instead of ${refs.join(", ")}: Workit follows only \`NAME=<literal>\`, \`$(mktemp …)\`, \`$(pwd)\`, \`$PWD\` after a literal \`cd\` and a \`for\` over literal words.${retry} Write under ${wt} or a temp dir.`;
29230
- return {
29231
- kind: "deny",
29232
- reason: `workit worktree confinement: implementer ${input.session.agentId} writes to a path built from ${named.join(", ")}, which Workit cannot resolve, so it cannot tell whether the write stays in its worktree. ${unblock}`,
29233
- unblock
29234
- };
29216
+ const literal = literalForm(text, refs);
29217
+ return deny2(`workit worktree confinement: implementer ${input.session.agentId} writes to a path built from ${named.join(", ")}, which Workit cannot resolve`, command === undefined || literal === command ? `Why: spell the path out; Workit follows only \`NAME=<literal>\`, \`$(pwd)\` and literal \`for\` words.` : first.length ? `${first.join(" ")} retry as: \`${literal}\`` : `Retry as: ${literal}`);
29235
29218
  };
29236
29219
  function confineImplementer(input, targets, command) {
29237
29220
  try {
@@ -29239,7 +29222,7 @@ function confineImplementer(input, targets, command) {
29239
29222
  return NONE5;
29240
29223
  const unresolved = targets.filter((target) => within(path47.resolve(target), UNKNOWN_VAR));
29241
29224
  if (unresolved.length > 0)
29242
- return unknownVarDeny(input, boundWorktree(input), unresolved, command);
29225
+ return unknownVarDeny(input, unresolved, command);
29243
29226
  if (targets.some((target) => within(path47.resolve(target), UNKNOWN_DIR)))
29244
29227
  return unknownDirDeny(input, boundWorktree(input));
29245
29228
  const bindings = canonical5(bindingDir());
@@ -29259,7 +29242,7 @@ function confineImplementer(input, targets, command) {
29259
29242
  }
29260
29243
  const root = canonical5(worktree);
29261
29244
  const outside = judged.find(({ real }) => !within(real, root) || within(real, bindings));
29262
- return outside ? outsideDeny(input, worktree, outside.named) : NONE5;
29245
+ return outside ? outsideDeny(input, worktree, outside.named, command) : NONE5;
29263
29246
  } catch {
29264
29247
  return NONE5;
29265
29248
  }
@@ -29324,14 +29307,7 @@ var leadOwnedWorkit = (args) => !args.includes("--help") && args.some((_, start)
29324
29307
  const [verb, sub] = skipWorkitGlobals(args.slice(start)).rest;
29325
29308
  return verb === "fanout" && /^(?:plan|worktree)$/.test(sub ?? "");
29326
29309
  });
29327
- var leadOwnedDeny = (input, command) => {
29328
- const unblock = "Worktrees, branches other than your own, refs, tags, remotes, git config, the shared stash and the fan-out plan belong to the lead: report what you need changed as a follow-up instead.";
29329
- return {
29330
- kind: "deny",
29331
- reason: `workit worktree confinement: implementer ${input.session.agentId} may not run \`${command.slice(0, 160)}\`. ${unblock}`,
29332
- unblock
29333
- };
29334
- };
29310
+ var leadOwnedDeny = (input, command) => deny2(`workit worktree confinement: implementer ${input.session.agentId} may not run \`${command.slice(0, 160)}\``, "Why: worktrees, other branches, refs, remotes, git config, the stash and the fan-out plan belong to the lead: a follow-up.");
29335
29311
  function confineImplementerShell(input, command, dialect = "posix") {
29336
29312
  try {
29337
29313
  if (!input.session.agentId || hostIsolated(input.cwd, input.session.agentId))
@@ -29341,6 +29317,9 @@ function confineImplementerShell(input, command, dialect = "posix") {
29341
29317
  } catch {}
29342
29318
  return confineImplementer(input, shellMutationTargets(input.cwd, command, dialect, true), command);
29343
29319
  }
29320
+ var LITERAL_SET = /^\s*([A-Za-z_]\w*)=(['"]?)((?:[\w@%+=:./\\-]|(?<=[^\s:=])~)*)\2[ \t]*(?:;|&&|\n)\s*/;
29321
+ var SPELLED = /^(?:[A-Za-z]|wt|wd|dir|repo|root|base|sha|ref|branch|file|out|scratch|worktree|WT|WD|DIR|REPO|ROOT|BASE|SHA|REF|BRANCH|FILE|OUT|SCRATCH|WORKTREE)$/;
29322
+ var ENV_READ = /^(?:GIT_|LD_|DYLD_|NODE_|PYTHON|PERL|RUBY|BASH|EPOCH|(?:ENV|IFS|CDPATH|PS\d|PWD|OLDPWD|REPLY|OPTARG|OPTIND|MAPFILE|S?RANDOM|SECONDS|LINENO|E?UID|PPID|_|HOSTNAME|HISTCMD)$)/;
29344
29323
  var SCRATCH = ".workit-scratch";
29345
29324
  var SHELL_NAMES = /^(?:sh|bash|zsh|dash|ksh|mksh|ash)$/;
29346
29325
  var INTERPRETERS2 = /^(?:python[\d.]*|node|bun|deno|ruby|perl|php)$/;
@@ -29458,7 +29437,8 @@ var GIT_VERBS = {
29458
29437
  var: "l|",
29459
29438
  version: "|build-options",
29460
29439
  "ls-remote": "htbq|heads tags branches refs quiet exit-code get-url symref sort=",
29461
- remote: "v|verbose",
29440
+ remote: "v|verbose push all",
29441
+ "range-diff": "@d|@d creation-factor= no-dual-color left-only right-only",
29462
29442
  config: "lz|get get-all get-regexp list local name-only null type= default=",
29463
29443
  worktree: "fdqvzb:B:|force detach lock reason= orphan no-checkout checkout quiet track no-track guess-remote porcelain expire= verbose",
29464
29444
  branch: "dDmMcCfvraliu:|delete move copy force list all remotes verbose contains? merged? no-merged? points-at= show-current set-upstream-to= unset-upstream track? no-track sort= format= color? column? ignore-case create-reflog",
@@ -29544,7 +29524,7 @@ var gitKind = (args, local = () => true) => {
29544
29524
  case "worktree":
29545
29525
  return first === "list" ? "read" : /^(?:add|remove)$/.test(first) ? "write" : null;
29546
29526
  case "remote":
29547
- return !first || first === "show" && named.length === 2 && local(second, true) ? "read" : null;
29527
+ return !first || first === "get-url" || first === "show" && named.length === 2 && local(second, true) ? "read" : null;
29548
29528
  case "ls-remote":
29549
29529
  return local(first || "origin", true) ? "read" : null;
29550
29530
  case "bisect":
@@ -29561,7 +29541,6 @@ var gitKind = (args, local = () => true) => {
29561
29541
  }
29562
29542
  return GIT_VERBS[verb].startsWith("+") ? "write" : "read";
29563
29543
  };
29564
- var JUDGE_GIT = `a judge runs git ${Object.keys(GIT_VERBS).join(" ")} with the options each documents (no abbreviations), writing only in a scratch repo; no -c, no wrapper but timeout, nice, time, command, no env but PAGER=cat, GIT_PAGER=cat, GIT_OPTIONAL_LOCKS=0, LC_*, LANG, TZ; status outside scratch needs --no-optional-locks`;
29565
29544
  var remoteIn = (dir, name, repo) => {
29566
29545
  const shared = path47.isAbsolute(dir) ? gitDirsAt(canonical5(dir), repo, false)?.[1] : undefined;
29567
29546
  if (!shared)
@@ -29604,14 +29583,12 @@ var judgeGit = (command, repo, cwd, depth = 0) => {
29604
29583
  why ??= `\`${word}\` is not allowed`;
29605
29584
  let index = start < 0 ? words.length : start + 1;
29606
29585
  let dir = "";
29607
- let unlocked = lead.includes("GIT_OPTIONAL_LOCKS=0");
29608
29586
  for (;!why && words[index]?.startsWith("-") && words[index] !== "--version"; index++) {
29609
29587
  const word = words[index];
29610
29588
  const flag = /^--(git-dir|work-tree)(?:=([\s\S]*))?$/.exec(word);
29611
29589
  const value = flag?.[2] ?? (/^(?:-C|--git-dir|--work-tree)$/.test(word) ? words[++index] : "");
29612
29590
  if (word === "-C")
29613
29591
  dir = value;
29614
- unlocked ||= word === "--no-optional-locks";
29615
29592
  if (flag ? !literalIn(value, repo) : !/^(?:-C|-P|--no-pager|--no-optional-locks)$/.test(word))
29616
29593
  why = `\`${word}\` is not allowed`;
29617
29594
  }
@@ -29623,11 +29600,6 @@ var judgeGit = (command, repo, cwd, depth = 0) => {
29623
29600
  const fetches = args[0] === "fetch" && plainFetch(args.slice(1)) && home && (home.workit || commonDir(home.root) === repo) && !words.some((word) => /^--[gw]/.test(word));
29624
29601
  if (!fetches && !gitKind(args, local))
29625
29602
  why = `\`git ${args.slice(0, 2).join(" ")}\` is not allowed`;
29626
- else if (args[0] === "status" && !unlocked) {
29627
- const dirs = path47.isAbsolute(dir) ? gitDirsAt(canonical5(dir), repo) : null;
29628
- if (!dirs?.length || !dirs.every((gitDir) => inScratch(gitDir, repo)))
29629
- why = "`git status` refreshes the index outside scratch: add --no-optional-locks";
29630
- }
29631
29603
  }
29632
29604
  const shell = /^(?:grep|egrep|rg|echo|printf|cat)$/.test(name) ? -1 : words.findIndex((word) => /^(?:sh|bash|zsh|dash|ksh|mksh|ash)$/.test(path47.basename(word)));
29633
29605
  const scripts = [
@@ -29693,7 +29665,6 @@ var workitCalls = (command, depth = 0, aliases = new Map) => depth > 4 ? [] : co
29693
29665
  at++;
29694
29666
  return [words.slice(at + 1)];
29695
29667
  });
29696
- var JUDGE_JOB = Object.entries(JUDGE_VERBS).map(([verb, subs]) => `workit ${verb}${subs === true ? "" : ` ${subs.join("|")}`}`).join(", ");
29697
29668
  var judgeRefusal = (command, fed, depth = 0) => {
29698
29669
  let moved = false;
29699
29670
  for (const segment of segmentsOf(command)) {
@@ -29715,6 +29686,9 @@ var judgeRefusal = (command, fed, depth = 0) => {
29715
29686
  moved = true;
29716
29687
  if (name === "eval" || (name === "source" || name === ".") && FED.test(args[0] ?? ""))
29717
29688
  return unseen;
29689
+ const set = words.find((word) => /^(?:NODE_OPTIONS|PYTHON(?:STARTUP|PATH|HOME)|PERL5(?:OPT|LIB)|RUBY(?:OPT|LIB)|LD_\w+|DYLD_\w+|REPLY|OPTARG|OPTIND|MAPFILE|READLINE_\w+|S?RANDOM|SECONDS|LINENO|E?UID|PPID|OLDPWD|_|HOSTNAME|HISTCMD|EPOCH\w*)=/.test(word));
29690
+ if (set)
29691
+ return `\`${set.slice(0, 80)}\` sets a loader or shell-set name`;
29718
29692
  if (SHELL_NAMES.test(name)) {
29719
29693
  let operand;
29720
29694
  let stdin = false;
@@ -29761,7 +29735,7 @@ var judgeRefusal = (command, fed, depth = 0) => {
29761
29735
  for (const args of workitCalls(command)) {
29762
29736
  const call = judgeVerbRefused(args);
29763
29737
  if (call)
29764
- return `\`${call}\` is not a judge's job: a judge runs only ${JUDGE_JOB}`;
29738
+ return `\`${call}\` is not a judge's job: a judge runs only read-only workit verbs`;
29765
29739
  }
29766
29740
  return null;
29767
29741
  };
@@ -29783,20 +29757,31 @@ var substitutingHeredoc = (command) => {
29783
29757
  }
29784
29758
  return false;
29785
29759
  };
29786
- var judgeDeny = (input, what, target) => {
29760
+ var judgeDeny = (input, what, target, retry) => {
29787
29761
  const role = input.session.agentType?.endsWith("reviewer") ? "reviewer" : "verifier";
29788
29762
  const root = checkoutOf2(input.cwd)?.root;
29789
29763
  const candidate = target ? checkoutOf2(target)?.root : undefined;
29790
- const also = root && candidate && candidate !== root && commonDir(candidate) === commonDir(root) ? ` or ${path47.join(candidate, SCRATCH)}` : "";
29791
- const scratch = root ? `${path47.join(root, SCRATCH)}${also}` : `${SCRATCH}/ at the root of the checkout you judge`;
29792
- const unblock = `Write only under ${scratch} (mkdir -p it): put a generated case in a file there with a quoted heredoc (<<'EOF') and never run it in the shell. Reads, \`workit check\`, \`workit ledger verdict\` and \`workit finding record\` stay allowed; a change the candidate needs is a finding, not an edit.`;
29764
+ const other = root && candidate && candidate !== root && commonDir(candidate) === commonDir(root) ? path47.join(candidate, SCRATCH) : undefined;
29765
+ const scratch = root ? `${path47.join(root, SCRATCH)}${other ? ` or ${other}` : ""}` : `${SCRATCH}/ at the root of the checkout you judge`;
29766
+ const call = root ? retry?.((other ?? path47.join(root, SCRATCH)).replaceAll("\\", "/")) : null;
29767
+ const unblock = call ? `Retry as: ${call}` : "Why: write only there (mkdir -p it); a fix the candidate needs is a finding (`workit finding record`).";
29793
29768
  return {
29794
29769
  kind: "deny",
29795
- reason: `workit scratch confinement: ${role} ${input.session.agentId} may write only in its scratch dir ${scratch}, and ${what}. ${unblock}`,
29770
+ reason: `workit scratch confinement: ${role} ${input.session.agentId} may write only in its scratch dir ${scratch}, and ${what}.
29771
+ ${unblock}`,
29796
29772
  unblock
29797
29773
  };
29798
29774
  };
29799
- function confineJudge(input, targets, placeholders = placeholdersOf(targets)) {
29775
+ var movedInto = (command, cwd, target, dir) => {
29776
+ for (const { words, redirects } of segmentsOf(command))
29777
+ for (const word of [...redirects, ...path47.basename(words[0] ?? "") === "tee" ? words : []])
29778
+ if (path47.resolve(cwd, word) === path47.resolve(cwd, target)) {
29779
+ const moved = command.replace(new RegExp(`((?:>>?\\|?|\\btee(?:\\s+-a)?)\\s*)(['"]?)${word.replace(/[$()*+.?[\\\]^{|}]/g, "\\$&")}\\2(?![^\\s;&|)])`), (_, lead) => `${lead}${dir}/${path47.basename(word)}`);
29780
+ return moved === command ? null : moved;
29781
+ }
29782
+ return null;
29783
+ };
29784
+ function confineJudge(input, targets, placeholders = placeholdersOf(targets), command) {
29800
29785
  try {
29801
29786
  if (!input.session.agentId)
29802
29787
  return NONE5;
@@ -29809,7 +29794,10 @@ function confineJudge(input, targets, placeholders = placeholdersOf(targets)) {
29809
29794
  for (const target of targets) {
29810
29795
  const resolved = path47.resolve(target);
29811
29796
  if (within(resolved, UNKNOWN_VAR) || within(resolved, UNKNOWN_DIR))
29812
- return judgeDeny(input, "it writes to a path Workit cannot resolve (a variable, a command substitution or `cd -`): spell the path out");
29797
+ return judgeDeny(input, "it writes to a path Workit cannot resolve", undefined, () => {
29798
+ const literal = command && literalForm(command, refsOf([target]));
29799
+ return literal === command ? null : literal;
29800
+ });
29813
29801
  const real = canonical5(target);
29814
29802
  const runsGit = placeholders.has(target) && /^\.workit-(?:runs-git|live-target)$/.test(path47.basename(target));
29815
29803
  const gitDirs = runsGit ? gitDirsAt(path47.dirname(real), repo) : [];
@@ -29818,17 +29806,43 @@ function confineJudge(input, targets, placeholders = placeholdersOf(targets)) {
29818
29806
  if (runsGit ? gitDirs.length > 0 ? gitDirs.every(scratch) : scratch(real) : scratch(real) && !inGitDir(real))
29819
29807
  continue;
29820
29808
  const runner = runnerAt(target);
29821
- return judgeDeny(input, runner === null ? `${shown(target)} is outside it` : `\`${runner}\` runs in ${shown(target)}, outside it`, target);
29809
+ return judgeDeny(input, runner === null ? `${shown(target)} is outside it` : `\`${runner}\` runs in ${shown(target)}, outside it`, target, (dir) => !command || runsGit ? null : runner === null ? movedInto(command, input.cwd, target, dir) : runFrom(dir, command));
29822
29810
  }
29823
29811
  return NONE5;
29824
29812
  } catch {
29825
29813
  return NONE5;
29826
29814
  }
29827
29815
  }
29816
+ var spelledIn = (text, name, value) => text.replace(new RegExp(`\\$(?:${name}(?!\\w)|\\{${name}\\})`, "g"), () => value);
29817
+ var variableRefusal = (command) => {
29818
+ let rest = command;
29819
+ const sets = [];
29820
+ for (let set;set = LITERAL_SET.exec(rest); rest = rest.slice(set[0].length))
29821
+ sets.push([set[1], set[3]]);
29822
+ const loop = /^\s*for\s+(\w+)\s+in\s+([\w@%+=:./ \t-]*?)\s*[;\n]\s*do\s([\s\S]*?);?\s*done\s*$/.exec(rest);
29823
+ for (const name of [...sets.map(([one]) => one), ...loop ? [loop[1]] : []])
29824
+ if (new RegExp(`\\$(?:${name}(?!\\w)|\\{${name}(?![\\w}])|\\{${name}\\})(?![\\s/";&|)]|$)`).test(rest))
29825
+ return { why: `\`$${name}\` has a modifier, subscript or suffix Workit does not spell in` };
29826
+ const odd = [...sets.map(([one]) => one), ...loop ? [loop[1]] : []].find((name) => !SPELLED.test(name) || process.env[name] !== undefined || ENV_READ.test(name));
29827
+ const used = sets.filter(([name]) => name === odd || new RegExp(`\\$\\{?${name}(?!\\w)`).test(rest));
29828
+ if (used.length)
29829
+ return {
29830
+ why: odd ? `\`${odd}=\` sets a name the shell, zsh or git reads itself` : `\`$${used[0][0]}\` is a path from a variable, which Workit does not follow for a judge`,
29831
+ retry: used.reduce((text, [name, value]) => spelledIn(text, name, value), rest)
29832
+ };
29833
+ const items = loop?.[2].split(/\s+/).filter(Boolean) ?? [];
29834
+ return loop && (loop[1] === odd || new RegExp(`\\$\\{?${loop[1]}(?!\\w)`).test(loop[3])) ? {
29835
+ why: `\`$${loop[1]}\` is a loop variable, which Workit does not follow for a judge`,
29836
+ retry: items.length > 16 ? undefined : items.map((item) => spelledIn(loop[3].trim(), loop[1], item)).join("; ")
29837
+ } : null;
29838
+ };
29828
29839
  function confineJudgeShell(input, command, dialect = "posix") {
29829
29840
  try {
29830
29841
  if (!input.session.agentId)
29831
29842
  return NONE5;
29843
+ const variable = dialect === "posix" ? variableRefusal(command) : null;
29844
+ if (variable)
29845
+ return judgeDeny(input, variable.why, undefined, () => variable.retry);
29832
29846
  const fed = [];
29833
29847
  let refused;
29834
29848
  try {
@@ -29840,8 +29854,7 @@ function confineJudgeShell(input, command, dialect = "posix") {
29840
29854
  const judged = checkoutOf2(input.cwd);
29841
29855
  try {
29842
29856
  const why = judgeGit(command, judged ? commonDir(judged.root) : null, /\b(?:cd|chdir|pushd|popd)\b/.test(command) ? null : input.cwd);
29843
- if (why)
29844
- refused = `${why}: ${JUDGE_GIT}`;
29857
+ refused = why;
29845
29858
  } catch {
29846
29859
  refused = "Workit cannot read this command: split it into simpler ones";
29847
29860
  }
@@ -29849,7 +29862,7 @@ function confineJudgeShell(input, command, dialect = "posix") {
29849
29862
  if (refused)
29850
29863
  return judgeDeny(input, refused);
29851
29864
  if (dialect === "posix" && substitutingHeredoc(command.replaceAll("\\\n", "")))
29852
- return judgeDeny(input, "an unquoted heredoc runs the `$(…)` or backtick command in its body: quote the delimiter (<<'EOF')");
29865
+ return judgeDeny(input, "an unquoted heredoc runs the `$(…)` or backtick command in its body: quote the delimiter (<<'EOF')", undefined, () => command.replace(/<<(-?)[ \t]*(\w+)/g, "<<$1'$2'"));
29853
29866
  let git = [];
29854
29867
  try {
29855
29868
  git = rawInvocations(command, dialect).flatMap(({ tool, dir, args }) => tool === "git" && (args[0] === "push" || leadOwnedGit(args) || gitKind(args) === "write" && !/^(?:init|clone)$/.test(args[0]) && !(args[0] === "fetch" && plainFetch(args.slice(1)))) ? [
@@ -29860,7 +29873,7 @@ function confineJudgeShell(input, command, dialect = "posix") {
29860
29873
  shellMutationTargets(input.cwd, command, dialect, true),
29861
29874
  ...fed.map((body) => shellMutationTargets(input.cwd, body, "posix", true))
29862
29875
  ];
29863
- return confineJudge(input, [...lists.flat(), ...git], new Set([...git, ...lists.flatMap((list) => [...placeholdersOf(list)])]));
29876
+ return confineJudge(input, [...lists.flat(), ...git], new Set([...git, ...lists.flatMap((list) => [...placeholdersOf(list)])]), command);
29864
29877
  } catch {
29865
29878
  return NONE5;
29866
29879
  }
@@ -30984,9 +30997,11 @@ var ytrackGate = (cwd, command, dialect, ask) => {
30984
30997
  const run = calls.length ? ` Run ${calls.join(", then ")} instead, each as its own plain call: it asks the user first.` : "";
30985
30998
  const user = bare.length ? ask ? ` For ${bare.join(", ")}, run it as its own plain call: the host asks the user.` : ` For ${bare.join(", ")}, the user decides: ask the user, and if they agree they run it in their own terminal.` : "";
30986
30999
  const rerun = writes.some((write) => write.gap === NOT_PLAIN.gap) ? " To get the named workit youtrack call instead, rerun the ytrack call as one plain command, with no wrapper, loop, substitution or script around it." : "";
31000
+ const retry = writes.find((write) => write.workit)?.workit ?? (rerun ? writes.find((write) => write.gap === NOT_PLAIN.gap)?.command : undefined);
30987
31001
  return {
30988
31002
  kind: "deny",
30989
- reason: `${why}${run}${user}${rerun}`,
31003
+ reason: `${why}${run}${user}${rerun}${retry ? `
31004
+ Retry as: ${retry}` : ""}`,
30990
31005
  unblock: writes[0]?.workit ?? null
30991
31006
  };
30992
31007
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/pi",
3
- "version": "2.11.0",
3
+ "version": "2.11.1",
4
4
  "description": "Workit native extension for Pi — tools, method skills, and session continuity",
5
5
  "keywords": [
6
6
  "agentic-coding",