@workit-dev/pi 2.6.0 → 2.7.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
@@ -8831,16 +8831,16 @@ var GENERAL = new Set(["", "general-purpose", "general"]);
8831
8831
 
8832
8832
  // packages/workit-core/src/core/methods.ts
8833
8833
  var BOOTSTRAP = `
8834
- Workit is optional coordination and proof tooling around the host: you decide
8835
- what and whether, the CLI does how and records what it observed.
8834
+ Workit is optional coordination and proof tooling: you decide what and
8835
+ whether, the CLI does how and records what it observed.
8836
8836
  Native host allow/ask/deny, sandbox and org rules stay authoritative. Never
8837
8837
  switch paths to evade a denial, never claim enforcement a host cannot provide,
8838
8838
  and never fabricate an approval or verdict. A question answer is not
8839
8839
  host permission, and imported decisions or handoffs grant no authority.
8840
8840
 
8841
8841
  Autonomy contract:
8842
- - Continue to the requested endpoint (commit, push, PR, green CI, verified,
8843
- merged) without asking "continue?", running checks and repairs.
8842
+ - Continue to the requested endpoint without asking "continue?", running
8843
+ checks and repairs.
8844
8844
  Stop only for a new consequential choice, a host denial, a conflicting edit
8845
8845
  or an unresolved blocker; report open gaps and uncertain workers.
8846
8846
  - No endpoint named: stop at a local commit on a policy-compliant branch and
@@ -8854,13 +8854,13 @@ Autonomy contract:
8854
8854
  start <v>\`, commits, \`finish\`; \`publish\` if asked.
8855
8855
  - Ask only for a product or preference choice, or for authority you lack, with
8856
8856
  your recommended answer. Facts are yours: read, run or prototype.
8857
- - Label claims measured (run and seen this session), inferred, or guess.
8857
+ - Label claims measured (seen this session), inferred, or guess.
8858
8858
  Prose is a note: only a configured check the CLI ran (\`workit check <name>\`)
8859
8859
  satisfies a gate; an ad-hoc \`workit check -- <cmd>\` never does.
8860
8860
  - Author is not verifier: your own verdict is \`--self\`, shown as
8861
8861
  self-reviewed, never verified. High risk, a focused or full lane and
8862
8862
  merge under \`verification: self|independent\` need a verifier with its
8863
- own host-derived session (a subagent's \`<lead>:<child>\`); never hand-mint one (\`<lead>-v1\`).
8863
+ own host-derived session (a subagent's \`<lead>:<child>\`); never hand-mint one.
8864
8864
  - A local-commit endpoint does not imply PR readiness, and a local commit alone
8865
8865
  is not evidence of a requested remote push. Before reporting delivery,
8866
8866
  reconcile every requested item and observe it (\`workit verify-delivery\`).
@@ -8873,23 +8873,25 @@ verb per shell call, never \`cd <dir> && workit\`. zsh-safe: no \`echo =====\`
8873
8873
  Add Co-Authored-By via \`workit git commit --trailer "K: v" -- <paths>\`, never
8874
8874
  an amend.
8875
8875
  The task families (task, policy, evidence, finding, decision, worker, state)
8876
- are optional continuity for tracked work; each branch has one implicit task,
8877
- and a solo edit needs no task. A decision records a user choice; it never
8878
- authorizes an effect. Judge work once with
8876
+ are optional continuity for tracked work; a solo edit needs no task. A
8877
+ decision records a user choice; it never authorizes an effect. Judge work
8878
+ once with
8879
8879
  \`workit policy assess --judge risk= behavior= product-choice= plan=\`.
8880
8880
  Across repositories, bind items to checkout, branch and endpoint, resolve
8881
8881
  competing targets before a mutation, and reconcile an uncertain
8882
8882
  effect before a retry.
8883
8883
 
8884
8884
  Mid-task: never silently drop or resume an objective (workit-continue).
8885
+ Notes, drafts, logs, resume files: \`workit dir notes|handoffs\` (outside the
8886
+ repo), never the repo tree.
8885
8887
 
8886
- Skills: load the skill, never act from memory (aliases /wk-<name>).
8888
+ Skills: load the skill, never act from memory.
8887
8889
  - brainstorm, plan, spec, grill, should we: workit-shape
8888
8890
  - implement, build, add a feature: workit-implement
8889
8891
  - review, blast radius: workit-review
8890
8892
  - bug, broken, flaky, regression: workit-debug
8891
8893
  - ship, babysit, CI, merge: workit-ship
8892
- - resume, pick up, handoff, interruption: workit-continue
8894
+ - resume, pick up, handoff, interruption, leaving, tomorrow, end of day, pause: workit-continue
8893
8895
  - BDD, TDD, acceptance criteria, Given/When/Then: workit-bdd
8894
8896
  - test audit, tautology, weak tests: workit-test-audit
8895
8897
  - deslop, slop, dead code: workit-deslop
@@ -9839,12 +9841,17 @@ var JUDGE_VERBS = {
9839
9841
  dir: true,
9840
9842
  help: true,
9841
9843
  "test-audit": true,
9842
- ledger: ["verdict", "finding", "list", "check", "ruling"],
9844
+ ledger: ["verdict", "list", "check", "ruling", "show"],
9845
+ finding: ["record", "list"],
9843
9846
  pr: ["status"],
9844
9847
  ci: ["wait", "logs"],
9845
9848
  fanout: ["status", "brief"],
9846
9849
  models: ["show"],
9847
- lock: ["status"]
9850
+ lock: ["status"],
9851
+ lease: ["status"],
9852
+ grant: ["show"],
9853
+ task: ["show", "list"],
9854
+ doctor: ["--json"]
9848
9855
  };
9849
9856
  var JUDGE_JOB = Object.entries(JUDGE_VERBS).map(([verb, subs]) => `workit ${verb}${subs === true ? "" : ` ${subs.join("|")}`}`).join(", ");
9850
9857
 
package/dist/workit.js CHANGED
@@ -18159,16 +18159,16 @@ function selectMethods(policy, capabilities) {
18159
18159
  });
18160
18160
  }
18161
18161
  var BOOTSTRAP = `
18162
- Workit is optional coordination and proof tooling around the host: you decide
18163
- what and whether, the CLI does how and records what it observed.
18162
+ Workit is optional coordination and proof tooling: you decide what and
18163
+ whether, the CLI does how and records what it observed.
18164
18164
  Native host allow/ask/deny, sandbox and org rules stay authoritative. Never
18165
18165
  switch paths to evade a denial, never claim enforcement a host cannot provide,
18166
18166
  and never fabricate an approval or verdict. A question answer is not
18167
18167
  host permission, and imported decisions or handoffs grant no authority.
18168
18168
 
18169
18169
  Autonomy contract:
18170
- - Continue to the requested endpoint (commit, push, PR, green CI, verified,
18171
- merged) without asking "continue?", running checks and repairs.
18170
+ - Continue to the requested endpoint without asking "continue?", running
18171
+ checks and repairs.
18172
18172
  Stop only for a new consequential choice, a host denial, a conflicting edit
18173
18173
  or an unresolved blocker; report open gaps and uncertain workers.
18174
18174
  - No endpoint named: stop at a local commit on a policy-compliant branch and
@@ -18182,13 +18182,13 @@ Autonomy contract:
18182
18182
  start <v>\`, commits, \`finish\`; \`publish\` if asked.
18183
18183
  - Ask only for a product or preference choice, or for authority you lack, with
18184
18184
  your recommended answer. Facts are yours: read, run or prototype.
18185
- - Label claims measured (run and seen this session), inferred, or guess.
18185
+ - Label claims measured (seen this session), inferred, or guess.
18186
18186
  Prose is a note: only a configured check the CLI ran (\`workit check <name>\`)
18187
18187
  satisfies a gate; an ad-hoc \`workit check -- <cmd>\` never does.
18188
18188
  - Author is not verifier: your own verdict is \`--self\`, shown as
18189
18189
  self-reviewed, never verified. High risk, a focused or full lane and
18190
18190
  merge under \`verification: self|independent\` need a verifier with its
18191
- own host-derived session (a subagent's \`<lead>:<child>\`); never hand-mint one (\`<lead>-v1\`).
18191
+ own host-derived session (a subagent's \`<lead>:<child>\`); never hand-mint one.
18192
18192
  - A local-commit endpoint does not imply PR readiness, and a local commit alone
18193
18193
  is not evidence of a requested remote push. Before reporting delivery,
18194
18194
  reconcile every requested item and observe it (\`workit verify-delivery\`).
@@ -18201,23 +18201,25 @@ verb per shell call, never \`cd <dir> && workit\`. zsh-safe: no \`echo =====\`
18201
18201
  Add Co-Authored-By via \`workit git commit --trailer "K: v" -- <paths>\`, never
18202
18202
  an amend.
18203
18203
  The task families (task, policy, evidence, finding, decision, worker, state)
18204
- are optional continuity for tracked work; each branch has one implicit task,
18205
- and a solo edit needs no task. A decision records a user choice; it never
18206
- authorizes an effect. Judge work once with
18204
+ are optional continuity for tracked work; a solo edit needs no task. A
18205
+ decision records a user choice; it never authorizes an effect. Judge work
18206
+ once with
18207
18207
  \`workit policy assess --judge risk= behavior= product-choice= plan=\`.
18208
18208
  Across repositories, bind items to checkout, branch and endpoint, resolve
18209
18209
  competing targets before a mutation, and reconcile an uncertain
18210
18210
  effect before a retry.
18211
18211
 
18212
18212
  Mid-task: never silently drop or resume an objective (workit-continue).
18213
+ Notes, drafts, logs, resume files: \`workit dir notes|handoffs\` (outside the
18214
+ repo), never the repo tree.
18213
18215
 
18214
- Skills: load the skill, never act from memory (aliases /wk-<name>).
18216
+ Skills: load the skill, never act from memory.
18215
18217
  - brainstorm, plan, spec, grill, should we: workit-shape
18216
18218
  - implement, build, add a feature: workit-implement
18217
18219
  - review, blast radius: workit-review
18218
18220
  - bug, broken, flaky, regression: workit-debug
18219
18221
  - ship, babysit, CI, merge: workit-ship
18220
- - resume, pick up, handoff, interruption: workit-continue
18222
+ - resume, pick up, handoff, interruption, leaving, tomorrow, end of day, pause: workit-continue
18221
18223
  - BDD, TDD, acceptance criteria, Given/When/Then: workit-bdd
18222
18224
  - test audit, tautology, weak tests: workit-test-audit
18223
18225
  - deslop, slop, dead code: workit-deslop
@@ -26140,6 +26142,12 @@ var isConfigDir = (file) => configDirs().some((dir) => canonical4(dir) === canon
26140
26142
  var isRoot = (file) => isConfigDir(file) || /^(?:issued[^\\/]*|approvals)$/.test(path41.relative(canonical4(resolveStateDir()), canonical4(file)));
26141
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)$/;
26142
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
+ };
26143
26151
  var PATH_CALLS = /^(?:join|resolve|normalize|abspath|expanduser|expandvars|Path|PurePath|fspath)$/;
26144
26152
  var rootUse = (text, at) => {
26145
26153
  let call;
@@ -26214,11 +26222,14 @@ var shellScript2 = (words) => {
26214
26222
  };
26215
26223
  var XARGS_VALUE = /^-[IinLPdsEa]$/;
26216
26224
  var runsWriter = (words) => {
26217
- 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
+ ];
26218
26229
  const edits = editsOf(filled);
26219
26230
  return edits === null || edits.length > 0 || opaqueWrites(filled) !== null;
26220
26231
  };
26221
- var opaqueWrites = (input, scriptOf = (index) => input[index]) => {
26232
+ var opaqueWrites = (input, scriptOf = (index) => input[index], fed) => {
26222
26233
  let words = input;
26223
26234
  while (words.length && (PREFIXES2.has(words[0]) || /^\w+=/.test(words[0]))) {
26224
26235
  if (words[0] === "xargs") {
@@ -26275,17 +26286,17 @@ var opaqueWrites = (input, scriptOf = (index) => input[index]) => {
26275
26286
  }
26276
26287
  const inline = (flag) => {
26277
26288
  const at = args.findIndex((arg) => flag.test(arg));
26278
- if (at < 0)
26289
+ if (at < 0 && (fed === undefined || !/^(?:-|\/dev\/stdin)?$/.test(scriptArgs(name, args).named ?? "")))
26279
26290
  return null;
26280
26291
  const runs = input.length - args.length - 1;
26281
- 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 : [
26282
26297
  ".",
26283
- ...input.flatMap((word, index) => {
26284
- if (index === runs || index < runs && !/^\w+=/.test(word))
26285
- return [];
26286
- const text = scriptOf(index);
26287
- return text === undefined ? [unknownVarTarget(word)] : pathsIn(text);
26288
- })
26298
+ ...pathsIn(fed ?? ""),
26299
+ ...texts.flatMap((text, index) => text === undefined ? [unknownVarTarget(input[index])] : pathsIn(text))
26289
26300
  ];
26290
26301
  };
26291
26302
  if (name === "curl")
@@ -26408,6 +26419,7 @@ var configWrites = (rest) => {
26408
26419
  named++;
26409
26420
  return named > 1;
26410
26421
  };
26422
+ var plainFetch = (rest) => /^(?:\w[\w.-]*(?: [^-+:\s][^:\s]*)?)?$/.test(rest.filter((arg) => !/^-[qv]$|^--(?:quiet|verbose)$/.test(arg)).join(" "));
26411
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))$/;
26412
26424
  var gitOutputs = (args) => {
26413
26425
  let at = 0;
@@ -26449,7 +26461,7 @@ var gitOutputs = (args) => {
26449
26461
  if (sub === "config" && configWrites(rest))
26450
26462
  files.push(has(/^--global$/) ? "~/.gitconfig" : has(/^--system$/) ? "/etc/gitconfig" : valueOf(rest, /^(?:-f|--file=?)(.*)$/s) ?? ".");
26451
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)/);
26452
- if (sub === "fetch" || sub === "gc" || sub === "branch" && branchWrite)
26464
+ if (sub === "fetch" && !plainFetch(rest) || sub === "gc" || sub === "branch" && branchWrite)
26453
26465
  files.push(".");
26454
26466
  if (base === undefined)
26455
26467
  return files.length ? files : null;
@@ -26878,6 +26890,8 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
26878
26890
  const made = mktempPath(value, dir);
26879
26891
  if (made !== null)
26880
26892
  return made;
26893
+ if (/^(?:\$\(\s*pwd\s*\)|`pwd`)$/.test(value) && !redefined && dir !== UNKNOWN_DIR)
26894
+ return dir ?? null;
26881
26895
  const all = expansions(value, vars, loops).map(homeExpanded);
26882
26896
  return all.length === 1 && unresolvedRefs(all[0]).length === 0 ? all[0] : null;
26883
26897
  };
@@ -27064,6 +27078,8 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
27064
27078
  for (const sub of depth < 4 ? segment.subs ?? [] : [])
27065
27079
  targets.push(...segmentTargets(runIn, sub, dialect, depth + 1, strict, vars));
27066
27080
  const expanding = new Set(segment.expands ?? []);
27081
+ const stdin = segment.stdin?.join(`
27082
+ `);
27067
27083
  const scriptOf = (index) => {
27068
27084
  const word = body[index];
27069
27085
  if (word === undefined || !expanding.has(keywords + index))
@@ -27072,7 +27088,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
27072
27088
  return all.some((text) => unresolvedRefs(text).some(unescaped)) ? undefined : all.join(`
27073
27089
  `);
27074
27090
  };
27075
- 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;
27076
27092
  const ran = words.findIndex((word) => word === "xargs" || !PREFIXES2.has(word));
27077
27093
  const runner = words[ran];
27078
27094
  if (runner !== undefined && expanding.has(keywords + lead + ran) && unresolvedRefs(homeExpanded(runner)).length > 0)
@@ -27088,15 +27104,13 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
27088
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))))
27089
27105
  targets.push(...linkSources(lnArgs, at));
27090
27106
  }
27091
- for (const file of segment.redirects)
27092
- if (!/^\/dev\/(?:null|stdout|stderr|tty)$/.test(file))
27093
- targets.push(...atAll(file));
27094
27107
  const edits = editsOf(body);
27095
27108
  if (edits === null) {
27096
27109
  if (dir !== undefined)
27097
27110
  targets.push(placeholderIn(dir, DIR_TARGET));
27098
- } else
27099
- for (const file of edits)
27111
+ }
27112
+ for (const file of [...segment.redirects, ...edits ?? []])
27113
+ if (!/^\/dev\/(?:null|stdout|stderr|tty)$/.test(file))
27100
27114
  targets.push(...atAll(file));
27101
27115
  if (dir !== undefined)
27102
27116
  for (const invocation of workitInvocations(body.map(quoteWord2).join(" "), "posix")) {
@@ -28884,6 +28898,7 @@ function neededChecks(lane, configured) {
28884
28898
  // packages/workit-core/src/hooks/worktree-confine.ts
28885
28899
  import { createHash as createHash22 } from "node:crypto";
28886
28900
  import fs29 from "node:fs";
28901
+ import os10 from "node:os";
28887
28902
  import path47 from "node:path";
28888
28903
  var FANOUT_TOKEN_FILE = "workit-fanout-token";
28889
28904
  var NONE5 = { kind: "none" };
@@ -29075,10 +29090,10 @@ var unknownVarDeny = (input, worktree, targets, command) => {
29075
29090
  const wt = worktree ?? "<worktree>";
29076
29091
  const literal = literalForm(text, refs.filter((ref) => /^[$`]/.test(ref)));
29077
29092
  const retry = command === undefined || literal === command ? "" : ` ${first.length ? `${first.join(" ")} retry` : "Retry"} as: \`${literal}\`.`;
29078
- 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.`;
29079
29094
  return {
29080
29095
  kind: "deny",
29081
- 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}`,
29082
29097
  unblock
29083
29098
  };
29084
29099
  };
@@ -29204,7 +29219,8 @@ var inScratch = (real, repo) => {
29204
29219
  if (path47.basename(dir) !== SCRATCH)
29205
29220
  continue;
29206
29221
  const root = path47.dirname(dir);
29207
- 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))
29208
29224
  return true;
29209
29225
  }
29210
29226
  return false;
@@ -29417,7 +29433,7 @@ var remoteIn = (dir, name, repo) => {
29417
29433
  const url = configEntries(fs29.readFileSync(path47.join(shared, "config"), "utf8")).find(([key]) => key === `remote.${name}.url`.toLowerCase())?.[1];
29418
29434
  return url !== undefined && literalIn(url, repo, true);
29419
29435
  };
29420
- var judgeGit = (command, repo, depth = 0) => {
29436
+ var judgeGit = (command, repo, cwd, depth = 0) => {
29421
29437
  const runsGit = /\bgit\b/.test(command);
29422
29438
  for (const segment of segmentsOf(command)) {
29423
29439
  const words = segment.words;
@@ -29466,7 +29482,10 @@ var judgeGit = (command, repo, depth = 0) => {
29466
29482
  const args = words[index] === "--version" ? ["version"] : words.slice(index);
29467
29483
  if (!why && start >= 0) {
29468
29484
  const local = (source, remote) => remote && /^[\w-][\w.-]*$/.test(source) ? remoteIn(dir, source, repo) : literalIn(source, repo, true);
29469
- 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))
29470
29489
  why = `\`git ${args.slice(0, 2).join(" ")}\` is not allowed`;
29471
29490
  else if (args[0] === "status" && !unlocked) {
29472
29491
  const dirs = path47.isAbsolute(dir) ? gitDirsAt(canonical5(dir), repo) : null;
@@ -29482,7 +29501,7 @@ var judgeGit = (command, repo, depth = 0) => {
29482
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))))
29483
29502
  why ??= `\`${name}\` runs git`;
29484
29503
  for (const script of [...segment.subs ?? [], ...scripts])
29485
- 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";
29486
29505
  if (why)
29487
29506
  return why;
29488
29507
  }
@@ -29493,12 +29512,17 @@ var JUDGE_VERBS = {
29493
29512
  dir: true,
29494
29513
  help: true,
29495
29514
  "test-audit": true,
29496
- ledger: ["verdict", "finding", "list", "check", "ruling"],
29515
+ ledger: ["verdict", "list", "check", "ruling", "show"],
29516
+ finding: ["record", "list"],
29497
29517
  pr: ["status"],
29498
29518
  ci: ["wait", "logs"],
29499
29519
  fanout: ["status", "brief"],
29500
29520
  models: ["show"],
29501
- lock: ["status"]
29521
+ lock: ["status"],
29522
+ lease: ["status"],
29523
+ grant: ["show"],
29524
+ task: ["show", "list"],
29525
+ doctor: ["--json"]
29502
29526
  };
29503
29527
  var HELP = /^(?:--help|-h)$/;
29504
29528
  var judgeVerbRefused = (args) => {
@@ -29509,8 +29533,7 @@ var judgeVerbRefused = (args) => {
29509
29533
  if (verb === undefined || verb === "--version" || HELP.test(verb) || HELP.test(sub))
29510
29534
  return null;
29511
29535
  const allowed = Object.hasOwn(JUDGE_VERBS, verb) ? JUDGE_VERBS[verb] : [];
29512
- const ok = allowed === true ? !(verb === "test-audit" && call.some((arg) => /^--mutate(?:=|$)/.test(arg))) : allowed.includes(sub);
29513
- 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(" ")}`;
29514
29537
  };
29515
29538
  var CLI_RUNNERS = /^(?:npx|bunx|pnpx|npm|pnpm|yarn|bun|node|nodejs|deno|tsx|ts-node)$/;
29516
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?$/;
@@ -29589,7 +29612,7 @@ var judgeRefusal = (command, fed, depth = 0) => {
29589
29612
  }
29590
29613
  if (INTERPRETERS2.test(name) && !args.some((arg) => INLINE.test(arg))) {
29591
29614
  const operand = args.find((arg, index) => (arg === "-" || !arg.startsWith("-")) && !VALUED.test(args[index - 1] ?? ""));
29592
- 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 ?? "")))
29593
29616
  return unseen;
29594
29617
  }
29595
29618
  const tail = workitCheckTail(words.slice(at));
@@ -29630,7 +29653,7 @@ var judgeDeny = (input, what, target) => {
29630
29653
  const candidate = target ? checkoutOf2(target)?.root : undefined;
29631
29654
  const also = root && candidate && candidate !== root && commonDir(candidate) === commonDir(root) ? ` or ${path47.join(candidate, SCRATCH)}` : "";
29632
29655
  const scratch = root ? `${path47.join(root, SCRATCH)}${also}` : `${SCRATCH}/ at the root of the checkout you judge`;
29633
- 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.`;
29634
29657
  return {
29635
29658
  kind: "deny",
29636
29659
  reason: `workit scratch confinement: ${role} ${input.session.agentId} may write only in its scratch dir ${scratch}, and ${what}. ${unblock}`,
@@ -29643,6 +29666,10 @@ function confineJudge(input, targets, placeholders = placeholdersOf(targets)) {
29643
29666
  return NONE5;
29644
29667
  const judged = checkoutOf2(input.cwd);
29645
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
+ });
29646
29673
  for (const target of targets) {
29647
29674
  const resolved = path47.resolve(target);
29648
29675
  if (within(resolved, UNKNOWN_VAR) || within(resolved, UNKNOWN_DIR))
@@ -29652,7 +29679,7 @@ function confineJudge(input, targets, placeholders = placeholdersOf(targets)) {
29652
29679
  const gitDirs = runsGit ? gitDirsAt(path47.dirname(real), repo) : [];
29653
29680
  if (gitDirs === null)
29654
29681
  return judgeDeny(input, `git in ${shown(target)} uses a git dir or config Workit cannot check`);
29655
- 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))
29656
29683
  continue;
29657
29684
  const runner = runnerAt(target);
29658
29685
  return judgeDeny(input, runner === null ? `${shown(target)} is outside it` : `\`${runner}\` runs in ${shown(target)}, outside it`, target);
@@ -29676,7 +29703,7 @@ function confineJudgeShell(input, command, dialect = "posix") {
29676
29703
  if (!refused && dialect === "posix") {
29677
29704
  const judged = checkoutOf2(input.cwd);
29678
29705
  try {
29679
- 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);
29680
29707
  if (why)
29681
29708
  refused = `${why}: ${JUDGE_GIT}`;
29682
29709
  } catch {
@@ -29685,11 +29712,11 @@ function confineJudgeShell(input, command, dialect = "posix") {
29685
29712
  }
29686
29713
  if (refused)
29687
29714
  return judgeDeny(input, refused);
29688
- if (dialect === "posix" && substitutingHeredoc(command))
29715
+ if (dialect === "posix" && substitutingHeredoc(command.replaceAll("\\\n", "")))
29689
29716
  return judgeDeny(input, "an unquoted heredoc runs the `$(…)` or backtick command in its body: quote the delimiter (<<'EOF')");
29690
29717
  let git = [];
29691
29718
  try {
29692
- 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)))) ? [
29693
29720
  path47.join(dir === undefined ? UNKNOWN_DIR : path47.resolve(input.cwd, dir ?? "."), `${OPAQUE_TARGET}git`)
29694
29721
  ] : []);
29695
29722
  } catch {}
@@ -29955,7 +29982,7 @@ var cdWorkitSplit = (command) => {
29955
29982
 
29956
29983
  // packages/workit-core/src/hooks/model-limit.ts
29957
29984
  import { closeSync as closeSync3, openSync as openSync3, readdirSync as readdirSync7, readSync, statSync as statSync5 } from "node:fs";
29958
- import os10 from "node:os";
29985
+ import os11 from "node:os";
29959
29986
  import path49 from "node:path";
29960
29987
  var MONTHS = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
29961
29988
  var WEEKDAYS = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"];
@@ -30161,7 +30188,7 @@ var listDir = (dir) => {
30161
30188
  };
30162
30189
  var SCAN_MS = 30 * 60000;
30163
30190
  var scanClaudeTranscripts = (cwd, env, now = new Date) => {
30164
- 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");
30165
30192
  const project = path49.join(projects, claudeProjectSlug(cwd));
30166
30193
  const notes = [];
30167
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 })));
@@ -30812,6 +30839,7 @@ var usageLimitOnStop = (input, agentId, text) => {
30812
30839
  };
30813
30840
  var subagentSession = (session, agentId) => [session, agentId].filter((part) => Boolean(part)).join(":").replace(/[^A-Za-z0-9_.:@/+-]/g, "-").slice(0, 128);
30814
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.";
30815
30843
  var subagentStartText = (input, descriptor, event) => {
30816
30844
  const session = input.session.id ?? null;
30817
30845
  const { role, isolated, git } = agentSteering(descriptor, input.cwd, {
@@ -30838,12 +30866,12 @@ ${subagentStartText({ ...input, cwd: "" }, descriptor, event)}`;
30838
30866
  const checks = judgeChecksLine(cwd);
30839
30867
  const checksText = checks ? ` ${checks}` : "";
30840
30868
  if (descriptor.host === "codex_cli" || descriptor.host === "codex_desktop")
30841
- 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}`;
30842
30870
  const token = session ? recordIssuedSession(cwd, session, own) : null;
30843
30871
  if (session && !token)
30844
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.`;
30845
30873
  const line = verdictCommand({ branch, judge, session: own, token });
30846
- 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}`;
30847
30875
  };
30848
30876
  var PRE_TOOL = new Set(["shell.pre", "write.pre", "tool.pre"]);
30849
30877
  function handleHook(input, deps) {
@@ -31559,7 +31587,7 @@ var skillPromptNudge = (prompt, ctx) => process.env.WORKIT_PI_WORKER_SESSION ? n
31559
31587
 
31560
31588
  // packages/workit-pi/src/launches.ts
31561
31589
  import { mkdirSync as mkdirSync7, readFileSync as readFileSync16, readdirSync as readdirSync8, rmSync as rmSync4, writeFileSync as writeFileSync6 } from "node:fs";
31562
- import os11 from "node:os";
31590
+ import os12 from "node:os";
31563
31591
  import path51 from "node:path";
31564
31592
  var launchDir = (root) => {
31565
31593
  const location = resolveStore(root);
@@ -31575,7 +31603,7 @@ var recordLaunch = (root, attempt) => {
31575
31603
  writeFileSync6(fileFor(dir, attempt.workerId), JSON.stringify({
31576
31604
  ...attempt,
31577
31605
  pid: process.pid,
31578
- host: os11.hostname(),
31606
+ host: os12.hostname(),
31579
31607
  at: new Date().toISOString()
31580
31608
  }), { flag: "wx" });
31581
31609
  return true;
@@ -31589,7 +31617,7 @@ var clearLaunch = (root, workerId) => {
31589
31617
  rmSync4(fileFor(dir, workerId), { force: true });
31590
31618
  };
31591
31619
  var alive = (attempt) => {
31592
- if (attempt.host !== os11.hostname())
31620
+ if (attempt.host !== os12.hostname())
31593
31621
  return true;
31594
31622
  try {
31595
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.6.0",
3
+ "version": "2.7.1",
4
4
  "description": "Workit native extension for Pi — tools, method skills, and session continuity",
5
5
  "keywords": [
6
6
  "agentic-coding",
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: workit-continue
3
- description: Keep work on track across interruptions and sessions - sort new input, checkpoint, hand off with a resume brief, and pick up by verifying inherited claims. Use for resume, pick up, handoff, new session, interruption, change of direction.
3
+ description: Keep work on track across interruptions and sessions - sort new input, checkpoint, hand off with a resume brief, pick up by verifying claims. Use for resume, pick up, handoff, leaving, tomorrow, end of day, pause, interruption, change of direction.
4
4
  ---
5
5
 
6
6
  # Continue without losing the thread
@@ -12,8 +12,7 @@ description: Keep work on track across interruptions and sessions - sort new inp
12
12
  keep going.
13
13
  - **Separate request:** do not silently resume an old objective, and do not
14
14
  drop the current one. Checkpoint it (below) if it must continue later, then
15
- start the new work. Held items stay parked with their resume condition until
16
- the user resumes them.
15
+ start the new work. Held items stay parked with their resume condition.
17
16
 
18
17
  ## Checkpoint and hand off
19
18
 
@@ -25,8 +24,9 @@ workit handoff --note "<state in one line>" --next "<next command>" --record
25
24
  The brief carries the branch, HEAD, dirty state, check freshness, verdict,
26
25
  rulings and the next command. Add only what it cannot know: choices still
27
26
  open, approaches that failed and why. Work spanning repos gets one brief per
28
- checkout, each with its branch and delivery endpoint. Notes too long for
29
- `--note` go in a file under `workit dir handoffs`; name its path in the note.
27
+ checkout, each with its branch and delivery endpoint. Notes, drafts and logs
28
+ go in `workit dir notes` or `workit dir handoffs`, never the repo tree; name
29
+ the file in `--note`.
30
30
 
31
31
  ## Pick up
32
32
 
@@ -40,8 +40,8 @@ checkout, each with its branch and delivery endpoint. Notes too long for
40
40
 
41
41
  ## Example
42
42
 
43
- Bad: a new session re-reads the whole codebase, re-asks the user which
44
- approach to take, and redoes a finished slice.
43
+ Bad: a new session re-reads the codebase, re-asks a settled approach and
44
+ redoes a finished slice.
45
45
 
46
46
  Good: "`workit handoff`: feature/usage at 4be1, `test` stale, verdict none,
47
47
  next `workit check test`. Re-ran it: exit 0. The brief says PR #42 is open: