@workit-dev/pi 2.7.0 → 2.7.2

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
@@ -9841,12 +9841,17 @@ var JUDGE_VERBS = {
9841
9841
  dir: true,
9842
9842
  help: true,
9843
9843
  "test-audit": true,
9844
- ledger: ["verdict", "finding", "list", "check", "ruling"],
9844
+ ledger: ["verdict", "list", "check", "ruling", "show"],
9845
+ finding: ["record", "list"],
9845
9846
  pr: ["status"],
9846
9847
  ci: ["wait", "logs"],
9847
9848
  fanout: ["status", "brief"],
9848
9849
  models: ["show"],
9849
- lock: ["status"]
9850
+ lock: ["status"],
9851
+ lease: ["status"],
9852
+ grant: ["show"],
9853
+ task: ["show", "list"],
9854
+ doctor: ["--json"]
9850
9855
  };
9851
9856
  var JUDGE_JOB = Object.entries(JUDGE_VERBS).map(([verb, subs]) => `workit ${verb}${subs === true ? "" : ` ${subs.join("|")}`}`).join(", ");
9852
9857
 
package/dist/workit.js CHANGED
@@ -26142,6 +26142,12 @@ var isConfigDir = (file) => configDirs().some((dir) => canonical4(dir) === canon
26142
26142
  var isRoot = (file) => isConfigDir(file) || /^(?:issued[^\\/]*|approvals)$/.test(path41.relative(canonical4(resolveStateDir()), canonical4(file)));
26143
26143
  var READ_CALLS = /^(?:print|log|info|warn|error|debug|puts|readdir(?:Sync)?|listdir|scandir|iterdir|glob|l?stat(?:Sync)?|exists(?:Sync)?|isdir|isfile|is_dir|is_file|access(?:Sync)?|realpath(?:Sync)?|dirname|basename|relative|str|repr|len)$/;
26144
26144
  var MUTATING_CALLS = /^(?:renames?(?:Sync)?|move|copy(?:2|file|tree|File)?(?:Sync)?|cp(?:Sync)?|rm(?:tree|dir|Sync|dirSync)?|unlink(?:Sync)?|remove(?:dirs)?|mkdirs?(?:Sync)?|makedirs|mkdtemp(?:Sync)?|(?:sym|hard)?link(?:Sync|_to)?|write\w*|append\w*|truncate(?:Sync)?|ch(?:mod|own)(?:Sync)?|touch|open(?:Sync)?|dump|save|extractall|unpack_archive|put_contents|mv|FileUtils)$/;
26145
+ var SPAWNS = /subprocess|child_process|WriteStream|tempfile|sqlite|inplace|getattr|spawn|\bvm\b|Function\s*\(|FileIO|ZipFile|tarfile|shelve|FileHandler|filename\s*=|savefig|utime|ch(?:mod|own)|mkfifo|mknod|\.(?:delete|to_\w+)\s*\(|Path\b.*\.replace\(|Bun\.\$|O_(?:WR|RDW|CR|AP|TR)|(?:PYTHON|NODE_)\w*=|-r\b|--(?:require|import|[\w-]*loader)|\bos\.replace|\b(?:system|popen|exec\w*|fork|eval|shutil|(?:unlink|rename|remove)\w*)\b|\]\s*\(|\brequire\s*\(\s*(?!(['"])(?:(?![a-zA-Z]:)[\w@][^'"]*|[^'"]*\.json)\1)/;
26146
+ var FREE_OPEN = /\bopen\w*\s*\(\s*(?:(['"])(?![rbtUwax+]*\1)[^'"]*\1|[\w.]+)?\s*(?:,\s*(?:(['"])[rbt]*\2|encoding\s*=\s*(['"])[\w-]+\3)\s*)*\)/g;
26147
+ var writesIn = (text) => {
26148
+ const bare = text.replace(FREE_OPEN, "").replace(/std(?:out|err)\.write|(?<![fF][rR]?)(['"])(?:\\.|(?!\1)[^\\\n])*\1/g, "");
26149
+ return SPAWNS.test(text) || /['"]/.test(bare) || /\$\{|\\[ux]|(?:^|[(,=:;!&|?{}[\s])\/(?![/*])[^/\n]*['"]/.test(text) || [...bare.matchAll(/[\w$]+/g)].some(([word]) => !/^(?:append|copy)$/.test(word) && MUTATING_CALLS.test(word));
26150
+ };
26145
26151
  var PATH_CALLS = /^(?:join|resolve|normalize|abspath|expanduser|expandvars|Path|PurePath|fspath)$/;
26146
26152
  var rootUse = (text, at) => {
26147
26153
  let call;
@@ -26216,11 +26222,14 @@ var shellScript2 = (words) => {
26216
26222
  };
26217
26223
  var XARGS_VALUE = /^-[IinLPdsEa]$/;
26218
26224
  var runsWriter = (words) => {
26219
- const filled = [...words.filter((word) => word !== "{}" && word !== ";" && word !== "+"), "x"];
26225
+ const filled = [
26226
+ ...words.filter((word) => word !== ";" && word !== "+").map((word) => word.includes("{}") ? "eval" : word),
26227
+ "eval"
26228
+ ];
26220
26229
  const edits = editsOf(filled);
26221
26230
  return edits === null || edits.length > 0 || opaqueWrites(filled) !== null;
26222
26231
  };
26223
- var opaqueWrites = (input, scriptOf = (index) => input[index]) => {
26232
+ var opaqueWrites = (input, scriptOf = (index) => input[index], fed) => {
26224
26233
  let words = input;
26225
26234
  while (words.length && (PREFIXES2.has(words[0]) || /^\w+=/.test(words[0]))) {
26226
26235
  if (words[0] === "xargs") {
@@ -26277,17 +26286,17 @@ var opaqueWrites = (input, scriptOf = (index) => input[index]) => {
26277
26286
  }
26278
26287
  const inline = (flag) => {
26279
26288
  const at = args.findIndex((arg) => flag.test(arg));
26280
- if (at < 0)
26289
+ if (at < 0 && (fed === undefined || !/^(?:-|\/dev\/stdin)?$/.test(scriptArgs(name, args).named ?? "")))
26281
26290
  return null;
26282
26291
  const runs = input.length - args.length - 1;
26283
- return [
26292
+ const texts = input.map((word, index) => index === runs || index < runs && !/^\w+=/.test(word) ? "" : scriptOf(index));
26293
+ return /^(?:python[\d.]*|node|bun)$/.test(name) && [
26294
+ at < 0 ? fed : texts[runs + at + 2],
26295
+ ...texts.slice(0, runs + 1 + (at < 0 ? args.length : at))
26296
+ ].every((text) => text !== undefined && text !== null && !writesIn(text)) ? null : [
26284
26297
  ".",
26285
- ...input.flatMap((word, index) => {
26286
- if (index === runs || index < runs && !/^\w+=/.test(word))
26287
- return [];
26288
- const text = scriptOf(index);
26289
- return text === undefined ? [unknownVarTarget(word)] : pathsIn(text);
26290
- })
26298
+ ...pathsIn(fed ?? ""),
26299
+ ...texts.flatMap((text, index) => text === undefined ? [unknownVarTarget(input[index])] : pathsIn(text))
26291
26300
  ];
26292
26301
  };
26293
26302
  if (name === "curl")
@@ -26410,6 +26419,7 @@ var configWrites = (rest) => {
26410
26419
  named++;
26411
26420
  return named > 1;
26412
26421
  };
26422
+ var plainFetch = (rest) => /^(?:\w[\w.-]*(?: [^-+:\s][^:\s]*)?)?$/.test(rest.filter((arg) => !/^-[qv]$|^--(?:quiet|verbose)$/.test(arg)).join(" "));
26413
26423
  var GIT_VALUE = /^(?:-[Ccbouj]|--(?:git-dir|work-tree|namespace|config-env|branch|origin|config|depth|reference(?:-if-able)?|template|separate-git-dir|upload-pack|jobs|filter|initial-branch|object-format))$/;
26414
26424
  var gitOutputs = (args) => {
26415
26425
  let at = 0;
@@ -26451,7 +26461,7 @@ var gitOutputs = (args) => {
26451
26461
  if (sub === "config" && configWrites(rest))
26452
26462
  files.push(has(/^--global$/) ? "~/.gitconfig" : has(/^--system$/) ? "/etc/gitconfig" : valueOf(rest, /^(?:-f|--file=?)(.*)$/s) ?? ".");
26453
26463
  const branchWrite = has(/^-[a-zA-Z]*[dDfmMcCu]|^--(?:delete|force|move|copy|set-upstream|unset-upstream|edit)/) || names.length > 0 && !has(/^-[a-zA-Z]*[lavr]|^--(?:list|all|remotes|verbose|show|contains|no-contains|merged|no-merged|points-at|format|sort)/);
26454
- if (sub === "fetch" || sub === "gc" || sub === "branch" && branchWrite)
26464
+ if (sub === "fetch" && !plainFetch(rest) || sub === "gc" || sub === "branch" && branchWrite)
26455
26465
  files.push(".");
26456
26466
  if (base === undefined)
26457
26467
  return files.length ? files : null;
@@ -26880,6 +26890,8 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
26880
26890
  const made = mktempPath(value, dir);
26881
26891
  if (made !== null)
26882
26892
  return made;
26893
+ if (/^(?:\$\(\s*pwd\s*\)|`pwd`)$/.test(value) && !redefined && dir !== UNKNOWN_DIR)
26894
+ return dir ?? null;
26883
26895
  const all = expansions(value, vars, loops).map(homeExpanded);
26884
26896
  return all.length === 1 && unresolvedRefs(all[0]).length === 0 ? all[0] : null;
26885
26897
  };
@@ -27066,6 +27078,8 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
27066
27078
  for (const sub of depth < 4 ? segment.subs ?? [] : [])
27067
27079
  targets.push(...segmentTargets(runIn, sub, dialect, depth + 1, strict, vars));
27068
27080
  const expanding = new Set(segment.expands ?? []);
27081
+ const stdin = segment.stdin?.join(`
27082
+ `);
27069
27083
  const scriptOf = (index) => {
27070
27084
  const word = body[index];
27071
27085
  if (word === undefined || !expanding.has(keywords + index))
@@ -27074,7 +27088,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
27074
27088
  return all.some((text) => unresolvedRefs(text).some(unescaped)) ? undefined : all.join(`
27075
27089
  `);
27076
27090
  };
27077
- const opaque = segment.unanalyzable ? ["."] : inner === null ? opaqueWrites(body, scriptOf) : null;
27091
+ const opaque = segment.unanalyzable ? ["."] : inner === null ? opaqueWrites(body, scriptOf, stdin && (/[$`]/.test(stdin) && /<<-?[ \t]*[^'"\\\s]/.test(command.replaceAll("\\\n", "")) ? null : stdin)) : null;
27078
27092
  const ran = words.findIndex((word) => word === "xargs" || !PREFIXES2.has(word));
27079
27093
  const runner = words[ran];
27080
27094
  if (runner !== undefined && expanding.has(keywords + lead + ran) && unresolvedRefs(homeExpanded(runner)).length > 0)
@@ -27090,15 +27104,13 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
27090
27104
  if (ln >= 0 && words.slice(0, ln).every((word) => PREFIXES2.has(word)) && (strict !== "registry" || !lnArgs.some((arg) => /^-[a-zA-Z]*s|^--symbolic$/.test(arg))))
27091
27105
  targets.push(...linkSources(lnArgs, at));
27092
27106
  }
27093
- for (const file of segment.redirects)
27094
- if (!/^\/dev\/(?:null|stdout|stderr|tty)$/.test(file))
27095
- targets.push(...atAll(file));
27096
27107
  const edits = editsOf(body);
27097
27108
  if (edits === null) {
27098
27109
  if (dir !== undefined)
27099
27110
  targets.push(placeholderIn(dir, DIR_TARGET));
27100
- } else
27101
- for (const file of edits)
27111
+ }
27112
+ for (const file of [...segment.redirects, ...edits ?? []])
27113
+ if (!/^\/dev\/(?:null|stdout|stderr|tty)$/.test(file))
27102
27114
  targets.push(...atAll(file));
27103
27115
  if (dir !== undefined)
27104
27116
  for (const invocation of workitInvocations(body.map(quoteWord2).join(" "), "posix")) {
@@ -28886,6 +28898,7 @@ function neededChecks(lane, configured) {
28886
28898
  // packages/workit-core/src/hooks/worktree-confine.ts
28887
28899
  import { createHash as createHash22 } from "node:crypto";
28888
28900
  import fs29 from "node:fs";
28901
+ import os10 from "node:os";
28889
28902
  import path47 from "node:path";
28890
28903
  var FANOUT_TOKEN_FILE = "workit-fanout-token";
28891
28904
  var NONE5 = { kind: "none" };
@@ -29077,10 +29090,10 @@ var unknownVarDeny = (input, worktree, targets, command) => {
29077
29090
  const wt = worktree ?? "<worktree>";
29078
29091
  const literal = literalForm(text, refs.filter((ref) => /^[$`]/.test(ref)));
29079
29092
  const retry = command === undefined || literal === command ? "" : ` ${first.length ? `${first.join(" ")} retry` : "Retry"} as: \`${literal}\`.`;
29080
- const unblock = `Spell the path out instead of ${refs.join(", ")}: Workit follows only a plain \`NAME=<literal>\` set earlier in the same command, \`$(mktemp …)\`, \`$PWD\` after a literal \`cd\` and a \`for\` over literal words.${retry} Write under ${wt} (\`workit git --cwd ${wt} …\`, \`workit check --cwd ${wt} …\`) or a temp dir.`;
29093
+ 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.`;
29081
29094
  return {
29082
29095
  kind: "deny",
29083
- reason: `workit worktree confinement: implementer ${input.session.agentId} writes to a path built from ${named.join(", ")}, which Workit cannot resolve (a command substitution, a loop over unknown or split words, a conditional, a binder such as read or eval, or an options file sets it), so it cannot tell whether the write stays in its worktree. ${unblock}`,
29096
+ 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}`,
29084
29097
  unblock
29085
29098
  };
29086
29099
  };
@@ -29206,7 +29219,8 @@ var inScratch = (real, repo) => {
29206
29219
  if (path47.basename(dir) !== SCRATCH)
29207
29220
  continue;
29208
29221
  const root = path47.dirname(dir);
29209
- if (checkoutOf2(root)?.root === root && (repo === null || commonDir(root) === repo))
29222
+ const checkout = checkoutOf2(root);
29223
+ if (checkout?.root === root && (repo === null || checkout.workit || commonDir(root) === repo))
29210
29224
  return true;
29211
29225
  }
29212
29226
  return false;
@@ -29419,7 +29433,7 @@ var remoteIn = (dir, name, repo) => {
29419
29433
  const url = configEntries(fs29.readFileSync(path47.join(shared, "config"), "utf8")).find(([key]) => key === `remote.${name}.url`.toLowerCase())?.[1];
29420
29434
  return url !== undefined && literalIn(url, repo, true);
29421
29435
  };
29422
- var judgeGit = (command, repo, depth = 0) => {
29436
+ var judgeGit = (command, repo, cwd, depth = 0) => {
29423
29437
  const runsGit = /\bgit\b/.test(command);
29424
29438
  for (const segment of segmentsOf(command)) {
29425
29439
  const words = segment.words;
@@ -29468,7 +29482,10 @@ var judgeGit = (command, repo, depth = 0) => {
29468
29482
  const args = words[index] === "--version" ? ["version"] : words.slice(index);
29469
29483
  if (!why && start >= 0) {
29470
29484
  const local = (source, remote) => remote && /^[\w-][\w.-]*$/.test(source) ? remoteIn(dir, source, repo) : literalIn(source, repo, true);
29471
- if (!gitKind(args, local))
29485
+ const runsIn = path47.isAbsolute(dir) ? dir : cwd && path47.resolve(cwd, dir);
29486
+ const home = runsIn && checkoutOf2(runsIn);
29487
+ const fetches = args[0] === "fetch" && plainFetch(args.slice(1)) && home && (home.workit || commonDir(home.root) === repo) && !words.some((word) => /^--[gw]/.test(word));
29488
+ if (!fetches && !gitKind(args, local))
29472
29489
  why = `\`git ${args.slice(0, 2).join(" ")}\` is not allowed`;
29473
29490
  else if (args[0] === "status" && !unlocked) {
29474
29491
  const dirs = path47.isAbsolute(dir) ? gitDirsAt(canonical5(dir), repo) : null;
@@ -29484,7 +29501,7 @@ var judgeGit = (command, repo, depth = 0) => {
29484
29501
  if (shell > at && scripts.some((script) => /git/.test(script)) && (!/^(?:timeout|nice|time|command)$/.test(name) || words.slice(at + 1, shell).some((word) => !/^(?:-[\w-]+|\d[\w.]*)$/.test(word))))
29485
29502
  why ??= `\`${name}\` runs git`;
29486
29503
  for (const script of [...segment.subs ?? [], ...scripts])
29487
- why ??= depth < 4 ? judgeGit(script, repo, depth + 1) : "scripts nest too deep for Workit to read";
29504
+ why ??= depth < 4 ? judgeGit(script, repo, cwd, depth + 1) : "scripts nest too deep for Workit to read";
29488
29505
  if (why)
29489
29506
  return why;
29490
29507
  }
@@ -29495,12 +29512,17 @@ var JUDGE_VERBS = {
29495
29512
  dir: true,
29496
29513
  help: true,
29497
29514
  "test-audit": true,
29498
- ledger: ["verdict", "finding", "list", "check", "ruling"],
29515
+ ledger: ["verdict", "list", "check", "ruling", "show"],
29516
+ finding: ["record", "list"],
29499
29517
  pr: ["status"],
29500
29518
  ci: ["wait", "logs"],
29501
29519
  fanout: ["status", "brief"],
29502
29520
  models: ["show"],
29503
- lock: ["status"]
29521
+ lock: ["status"],
29522
+ lease: ["status"],
29523
+ grant: ["show"],
29524
+ task: ["show", "list"],
29525
+ doctor: ["--json"]
29504
29526
  };
29505
29527
  var HELP = /^(?:--help|-h)$/;
29506
29528
  var judgeVerbRefused = (args) => {
@@ -29511,8 +29533,7 @@ var judgeVerbRefused = (args) => {
29511
29533
  if (verb === undefined || verb === "--version" || HELP.test(verb) || HELP.test(sub))
29512
29534
  return null;
29513
29535
  const allowed = Object.hasOwn(JUDGE_VERBS, verb) ? JUDGE_VERBS[verb] : [];
29514
- const ok = allowed === true ? !(verb === "test-audit" && call.some((arg) => /^--mutate(?:=|$)/.test(arg))) : allowed.includes(sub);
29515
- return ok ? null : `workit ${call.join(" ")}`;
29536
+ return (allowed === true || allowed.includes(sub)) && (verb !== "doctor" || call.length < 3) && !call.some((arg) => /^--(?:mutate|fix)\b/.test(arg)) ? null : `workit ${call.join(" ")}`;
29516
29537
  };
29517
29538
  var CLI_RUNNERS = /^(?:npx|bunx|pnpx|npm|pnpm|yarn|bun|node|nodejs|deno|tsx|ts-node)$/;
29518
29539
  var CLI_ENTRY = /(?:^|[=\\/])(?:workit(?:\.(?:exe|cmd|[cm]?js))?|@workit-dev\/cli(?:@\S*)?)$|(?:workit-cli|@workit-dev[\\/]cli)[\\/](?:src[\\/](?:index|main)|dist[\\/]index)\.[cm]?[jt]sx?$/;
@@ -29591,7 +29612,7 @@ var judgeRefusal = (command, fed, depth = 0) => {
29591
29612
  }
29592
29613
  if (INTERPRETERS2.test(name) && !args.some((arg) => INLINE.test(arg))) {
29593
29614
  const operand = args.find((arg, index) => (arg === "-" || !arg.startsWith("-")) && !VALUED.test(args[index - 1] ?? ""));
29594
- if (FED.test(operand ?? "") || operand === undefined && !/^(?:bun|deno)$/.test(name))
29615
+ if ((FED.test(operand ?? "") || operand === undefined && !/^(?:bun|deno)$/.test(name)) && !(segment.stdin?.length && /^(?:-|\/dev\/stdin)?$/.test(operand ?? "")))
29595
29616
  return unseen;
29596
29617
  }
29597
29618
  const tail = workitCheckTail(words.slice(at));
@@ -29632,7 +29653,7 @@ var judgeDeny = (input, what, target) => {
29632
29653
  const candidate = target ? checkoutOf2(target)?.root : undefined;
29633
29654
  const also = root && candidate && candidate !== root && commonDir(candidate) === commonDir(root) ? ` or ${path47.join(candidate, SCRATCH)}` : "";
29634
29655
  const scratch = root ? `${path47.join(root, SCRATCH)}${also}` : `${SCRATCH}/ at the root of the checkout you judge`;
29635
- 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\` and \`workit ledger verdict|finding\` stay allowed; a change the candidate needs is a finding, not an edit.`;
29656
+ 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.`;
29636
29657
  return {
29637
29658
  kind: "deny",
29638
29659
  reason: `workit scratch confinement: ${role} ${input.session.agentId} may write only in its scratch dir ${scratch}, and ${what}. ${unblock}`,
@@ -29645,6 +29666,10 @@ function confineJudge(input, targets, placeholders = placeholdersOf(targets)) {
29645
29666
  return NONE5;
29646
29667
  const judged = checkoutOf2(input.cwd);
29647
29668
  const repo = judged ? commonDir(judged.root) : null;
29669
+ const scratch = (real) => inScratch(real, repo) || [os10.tmpdir(), "/tmp"].some((dir) => {
29670
+ const [host, , session] = path47.relative(canonical5(dir), real).split(path47.sep);
29671
+ return /^claude-\d+$/.test(host) && session === input.session.id;
29672
+ });
29648
29673
  for (const target of targets) {
29649
29674
  const resolved = path47.resolve(target);
29650
29675
  if (within(resolved, UNKNOWN_VAR) || within(resolved, UNKNOWN_DIR))
@@ -29654,7 +29679,7 @@ function confineJudge(input, targets, placeholders = placeholdersOf(targets)) {
29654
29679
  const gitDirs = runsGit ? gitDirsAt(path47.dirname(real), repo) : [];
29655
29680
  if (gitDirs === null)
29656
29681
  return judgeDeny(input, `git in ${shown(target)} uses a git dir or config Workit cannot check`);
29657
- if (runsGit ? gitDirs.length > 0 ? gitDirs.every((dir) => inScratch(dir, repo)) : inScratch(real, repo) : inScratch(real, repo) && !inGitDir(real))
29682
+ if (runsGit ? gitDirs.length > 0 ? gitDirs.every(scratch) : scratch(real) : scratch(real) && !inGitDir(real))
29658
29683
  continue;
29659
29684
  const runner = runnerAt(target);
29660
29685
  return judgeDeny(input, runner === null ? `${shown(target)} is outside it` : `\`${runner}\` runs in ${shown(target)}, outside it`, target);
@@ -29678,7 +29703,7 @@ function confineJudgeShell(input, command, dialect = "posix") {
29678
29703
  if (!refused && dialect === "posix") {
29679
29704
  const judged = checkoutOf2(input.cwd);
29680
29705
  try {
29681
- const why = judgeGit(command, judged ? commonDir(judged.root) : null);
29706
+ const why = judgeGit(command, judged ? commonDir(judged.root) : null, /\b(?:cd|chdir|pushd|popd)\b/.test(command) ? null : input.cwd);
29682
29707
  if (why)
29683
29708
  refused = `${why}: ${JUDGE_GIT}`;
29684
29709
  } catch {
@@ -29687,11 +29712,11 @@ function confineJudgeShell(input, command, dialect = "posix") {
29687
29712
  }
29688
29713
  if (refused)
29689
29714
  return judgeDeny(input, refused);
29690
- if (dialect === "posix" && substitutingHeredoc(command))
29715
+ if (dialect === "posix" && substitutingHeredoc(command.replaceAll("\\\n", "")))
29691
29716
  return judgeDeny(input, "an unquoted heredoc runs the `$(…)` or backtick command in its body: quote the delimiter (<<'EOF')");
29692
29717
  let git = [];
29693
29718
  try {
29694
- git = rawInvocations(command, dialect).flatMap(({ tool, dir, args }) => tool === "git" && (args[0] === "push" || leadOwnedGit(args) || gitKind(args) === "write" && !/^(?:init|clone)$/.test(args[0])) ? [
29719
+ 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)))) ? [
29695
29720
  path47.join(dir === undefined ? UNKNOWN_DIR : path47.resolve(input.cwd, dir ?? "."), `${OPAQUE_TARGET}git`)
29696
29721
  ] : []);
29697
29722
  } catch {}
@@ -29957,7 +29982,7 @@ var cdWorkitSplit = (command) => {
29957
29982
 
29958
29983
  // packages/workit-core/src/hooks/model-limit.ts
29959
29984
  import { closeSync as closeSync3, openSync as openSync3, readdirSync as readdirSync7, readSync, statSync as statSync5 } from "node:fs";
29960
- import os10 from "node:os";
29985
+ import os11 from "node:os";
29961
29986
  import path49 from "node:path";
29962
29987
  var MONTHS = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
29963
29988
  var WEEKDAYS = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"];
@@ -30163,7 +30188,7 @@ var listDir = (dir) => {
30163
30188
  };
30164
30189
  var SCAN_MS = 30 * 60000;
30165
30190
  var scanClaudeTranscripts = (cwd, env, now = new Date) => {
30166
- const projects = path49.join(env.CLAUDE_CONFIG_DIR || path49.join(env.HOME || os10.homedir(), ".claude"), "projects");
30191
+ const projects = path49.join(env.CLAUDE_CONFIG_DIR || path49.join(env.HOME || os11.homedir(), ".claude"), "projects");
30167
30192
  const project = path49.join(projects, claudeProjectSlug(cwd));
30168
30193
  const notes = [];
30169
30194
  const files = listDir(project).flatMap((entry) => entry.endsWith(".jsonl") ? [{ file: entry, worker: false }] : listDir(path49.join(entry, "subagents")).filter((file) => file.endsWith(".jsonl")).map((file) => ({ file, worker: true })));
@@ -30814,6 +30839,7 @@ var usageLimitOnStop = (input, agentId, text) => {
30814
30839
  };
30815
30840
  var subagentSession = (session, agentId) => [session, agentId].filter((part) => Boolean(part)).join(":").replace(/[^A-Za-z0-9_.:@/+-]/g, "-").slice(0, 128);
30816
30841
  var isolatedGit = (cwd) => `Run git as plain, separate commands inside your worktree (\`git switch -c <branch> <base>\`, ${workspaceTrailers(cwd).enabled ? '`git commit --trailer "Workit-Session=<your session>"`, `git push`; `workit doctor --fix` can install a prepare-commit-msg hook that adds the trailer' : "`git commit` (this workspace sets trailers: false: add no Workit-Session trailer), `git push`"}; add Co-Authored-By with \`git commit --trailer\` in the same commit, never by amending), never \`workit git …\`: Claude Code's worktree isolation refuses a command that wraps git and cannot be turned off (https://code.claude.com/docs/en/worktrees#how-claude-code-enforces-isolation). Never dodge that check by renaming or re-wrapping git. Use workit for the non-git verbs (\`workit check\`, \`workit ledger\`, \`workit pr\`).`;
30842
+ var JUDGE_CWD = " Add `--cwd <candidate worktree>` when your shell is elsewhere.";
30817
30843
  var subagentStartText = (input, descriptor, event) => {
30818
30844
  const session = input.session.id ?? null;
30819
30845
  const { role, isolated, git } = agentSteering(descriptor, input.cwd, {
@@ -30840,12 +30866,12 @@ ${subagentStartText({ ...input, cwd: "" }, descriptor, event)}`;
30840
30866
  const checks = judgeChecksLine(cwd);
30841
30867
  const checksText = checks ? ` ${checks}` : "";
30842
30868
  if (descriptor.host === "codex_cli" || descriptor.host === "codex_desktop")
30843
- return `${readOnly} Its shell already acts as its own Workit session, so the ledger tells its verdicts apart from the author's. Record the verdict with exactly this command (pick the result${pick}, name the candidate branch if it differs, say what you ran): \`${verdictCommand({ branch, judge })}\`. Add no session or token option to it, and never set WORKIT_SESSION_ID by hand.${checksText}`;
30869
+ return `${readOnly} Its shell already acts as its own Workit session, so the ledger tells its verdicts apart from the author's. Record the verdict with exactly this command (pick the result${pick}, name the candidate branch if it differs, say what you ran): \`${verdictCommand({ branch, judge })}\`.${JUDGE_CWD} Add no session or token option to it, and never set WORKIT_SESSION_ID by hand.${checksText}`;
30844
30870
  const token = session ? recordIssuedSession(cwd, session, own) : null;
30845
30871
  if (session && !token)
30846
30872
  return `${readOnly} ${own} was already issued to an earlier subagent, so no token is handed out again and a verdict under it would be refused (unbound_session). Record no verdict as ${own}: spawn a fresh verifier or reviewer, which gets its own session and token.`;
30847
30873
  const line = verdictCommand({ branch, judge, session: own, token });
30848
- return `${readOnly} Its own Workit session is ${own}, so the ledger tells its verdicts apart from the author's. Record the verdict with exactly this command (pick the result${pick}, name the candidate branch if it differs, say what you ran): \`${line}\`.${token ? " The token is this subagent's alone: never write it into a report, a file or a commit. --token needs a workit CLI at least as new as this plugin; if the CLI answers that --token is an unknown option, update the workit CLI (workit upgrade --cli) and record again." : ""}${checksText}`;
30874
+ return `${readOnly} Its own Workit session is ${own}, so the ledger tells its verdicts apart from the author's. Record the verdict with exactly this command (pick the result${pick}, name the candidate branch if it differs, say what you ran): \`${line}\`.${JUDGE_CWD}${token ? " The token is this subagent's alone: never write it into a report, a file or a commit. --token needs a workit CLI at least as new as this plugin; if the CLI answers that --token is an unknown option, update the workit CLI (workit upgrade --cli) and record again." : ""}${checksText}`;
30849
30875
  };
30850
30876
  var PRE_TOOL = new Set(["shell.pre", "write.pre", "tool.pre"]);
30851
30877
  function handleHook(input, deps) {
@@ -31561,7 +31587,7 @@ var skillPromptNudge = (prompt, ctx) => process.env.WORKIT_PI_WORKER_SESSION ? n
31561
31587
 
31562
31588
  // packages/workit-pi/src/launches.ts
31563
31589
  import { mkdirSync as mkdirSync7, readFileSync as readFileSync16, readdirSync as readdirSync8, rmSync as rmSync4, writeFileSync as writeFileSync6 } from "node:fs";
31564
- import os11 from "node:os";
31590
+ import os12 from "node:os";
31565
31591
  import path51 from "node:path";
31566
31592
  var launchDir = (root) => {
31567
31593
  const location = resolveStore(root);
@@ -31577,7 +31603,7 @@ var recordLaunch = (root, attempt) => {
31577
31603
  writeFileSync6(fileFor(dir, attempt.workerId), JSON.stringify({
31578
31604
  ...attempt,
31579
31605
  pid: process.pid,
31580
- host: os11.hostname(),
31606
+ host: os12.hostname(),
31581
31607
  at: new Date().toISOString()
31582
31608
  }), { flag: "wx" });
31583
31609
  return true;
@@ -31591,7 +31617,7 @@ var clearLaunch = (root, workerId) => {
31591
31617
  rmSync4(fileFor(dir, workerId), { force: true });
31592
31618
  };
31593
31619
  var alive = (attempt) => {
31594
- if (attempt.host !== os11.hostname())
31620
+ if (attempt.host !== os12.hostname())
31595
31621
  return true;
31596
31622
  try {
31597
31623
  process.kill(attempt.pid, 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/pi",
3
- "version": "2.7.0",
3
+ "version": "2.7.2",
4
4
  "description": "Workit native extension for Pi — tools, method skills, and session continuity",
5
5
  "keywords": [
6
6
  "agentic-coding",