@workit-dev/pi 2.24.0 → 2.25.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
@@ -6516,6 +6516,7 @@ var workspaceConfigSchema = looseObject({
6516
6516
  cleanup: described(optional(unknown()), "What happens when work finishes: `auto` (default) removes the delivered branch's clean Workit worktree and local branch, switches a clean checkout on it back to the trunk, and stops the processes registered inside them; `keep` removes and stops nothing. A value Workit does not know reads as `keep`."),
6517
6517
  feedback: described(optional(unknown()), '`workit feedback` for this workspace: `off` hides its contract line and makes the verb refuse; `{ "account": "<login>" }` names the GitHub login it posts with; workspaces inside this one inherit it.'),
6518
6518
  liveSessionGuard: described(optional(boolean2()), "Whether the live-session guard denies edits in a checkout another live agent session owns (default true)."),
6519
+ shared: described(optional(boolean2()), "Whether this workspace's repos are shared with a team that must not see Workit named (default false): `workit pr create` and `workit pr edit` then warn, never block, when the PR title, body or a new doc names it."),
6519
6520
  fanout: described(optional(looseObject({
6520
6521
  tierModels: described(optional(unknown()), "The model per slice TIER (mundane, standard, hard), as one name or per host."),
6521
6522
  deps: described(optional(unknown()), "How `workit fanout worktree create` gives a slice worktree node_modules: `install` (default: its own frozen install of its lockfile) or `link` (links into the main checkout's installed packages, for a repo too slow to install per slice). `--deps` overrides it."),
package/dist/workit.js CHANGED
@@ -8470,6 +8470,7 @@ var workspaceConfigSchema = looseObject({
8470
8470
  cleanup: described(optional(unknown()), "What happens when work finishes: `auto` (default) removes the delivered branch's clean Workit worktree and local branch, switches a clean checkout on it back to the trunk, and stops the processes registered inside them; `keep` removes and stops nothing. A value Workit does not know reads as `keep`."),
8471
8471
  feedback: described(optional(unknown()), '`workit feedback` for this workspace: `off` hides its contract line and makes the verb refuse; `{ "account": "<login>" }` names the GitHub login it posts with; workspaces inside this one inherit it.'),
8472
8472
  liveSessionGuard: described(optional(boolean2()), "Whether the live-session guard denies edits in a checkout another live agent session owns (default true)."),
8473
+ shared: described(optional(boolean2()), "Whether this workspace's repos are shared with a team that must not see Workit named (default false): `workit pr create` and `workit pr edit` then warn, never block, when the PR title, body or a new doc names it."),
8473
8474
  fanout: described(optional(looseObject({
8474
8475
  tierModels: described(optional(unknown()), "The model per slice TIER (mundane, standard, hard), as one name or per host."),
8475
8476
  deps: described(optional(unknown()), "How `workit fanout worktree create` gives a slice worktree node_modules: `install` (default: its own frozen install of its lockfile) or `link` (links into the main checkout's installed packages, for a repo too slow to install per slice). `--deps` overrides it."),
@@ -28024,6 +28025,58 @@ var linkSources = (args, at) => {
28024
28025
  return resolved ? [resolved] : [];
28025
28026
  });
28026
28027
  };
28028
+ var commandName2 = (word) => (word.split(/[\\/]/).at(-1) ?? "").toLowerCase();
28029
+ var fedRuns = (words, fed) => {
28030
+ const run = words.slice(Math.max(0, words.findIndex((word) => word === "xargs" || !PREFIXES2.has(word))));
28031
+ const name = commandName2(run[0] ?? "");
28032
+ if (name === "xargs")
28033
+ return xargsCommands(run, fed);
28034
+ if (name !== "parallel")
28035
+ return [run];
28036
+ return parallelCommands(fed === undefined || run.includes(":::") ? run : [...run, ":::", ...fed.split(`
28037
+ `).filter(Boolean)]);
28038
+ };
28039
+ var windowsScript = (input, stdin) => {
28040
+ const words = input.slice(Math.max(0, input.findIndex((word) => !PREFIXES2.has(word))));
28041
+ const name = commandName2(words[0] ?? "").replace(/\.exe$/, "");
28042
+ if (name === "cmd")
28043
+ return cmdScript(words);
28044
+ return name === "pwsh" || name === "powershell" ? powershellScript(words, stdin) : null;
28045
+ };
28046
+ var WINDOWS_LINK_TYPE = /^(?:symboliclink|junction|hardlink)$/i;
28047
+ var linkReach = (verb, args, at, atAll) => {
28048
+ const all = (files) => files.flatMap((file) => atAll(file));
28049
+ const names = operands(args);
28050
+ if (verb === "mount" || verb === "bindfs")
28051
+ return all(names);
28052
+ if (verb === "ln" || verb === "cp" && args.some((arg) => /^-[a-zA-Z]*[ls]|^--(?:link|symbolic-link)$/.test(arg)))
28053
+ return [...linkSources(args, at), ...all(names.length < 2 ? names : names.slice(0, -1))];
28054
+ if (verb === "install") {
28055
+ const flag = args.findIndex((arg) => arg.startsWith("-l"));
28056
+ if (flag < 0)
28057
+ return [];
28058
+ const rest = operands(args.filter((_, index) => index !== flag && (args[flag] !== "-l" || index !== flag + 1)));
28059
+ return all(rest.slice(0, -1));
28060
+ }
28061
+ if (verb === "rsync") {
28062
+ const dest = names.at(-1);
28063
+ return args.flatMap((arg, index) => {
28064
+ const match = /^--link-dest(?:=(.*))?$/s.exec(arg);
28065
+ const dir = match ? match[1] ?? args[index + 1] : undefined;
28066
+ if (!dir)
28067
+ return [];
28068
+ return [...atAll(dir), ...dest && !path42.isAbsolute(dir) ? atAll(path42.join(dest, dir)) : []];
28069
+ });
28070
+ }
28071
+ if (verb === "mklink")
28072
+ return all(args.filter((arg) => !/^\/[dhj]$/i.test(arg)));
28073
+ if ((verb === "new-item" || verb === "ni") && args.some((arg) => WINDOWS_LINK_TYPE.test(arg.replace(/^-[\w-]+:/, ""))))
28074
+ return all(args.flatMap((arg) => {
28075
+ const value = arg.startsWith("-") ? /^-[\w-]+:(.+)$/s.exec(arg)?.[1] : arg;
28076
+ return value && !WINDOWS_LINK_TYPE.test(value) ? [value] : [];
28077
+ }));
28078
+ return [];
28079
+ };
28027
28080
  var shellWrites = (command, depth = 0) => {
28028
28081
  const targets = [];
28029
28082
  let unknown = false;
@@ -28132,6 +28185,7 @@ var recording = (make) => {
28132
28185
  var placeholdersOf = (targets) => PLACEHOLDERS.get(targets) ?? new Set;
28133
28186
  var OPAQUE_TARGET = ".workit-runs-";
28134
28187
  var UNRESOLVED_TARGET = ".workit-unresolved-target";
28188
+ var LINK_SOURCE = ".workit-link-source";
28135
28189
  var OVERRIDE = "WORKIT_LIVE_SESSION=override";
28136
28190
  var inert = (args, sub) => args.some((arg) => arg === "--help" || arg === "-h" || arg === "--dry-run" || DRY_N.has(sub) && /^-[a-zA-Z]*n[a-zA-Z]*$/.test(arg) && !arg.startsWith("--"));
28137
28191
  var gitMutationDirs = (cwd, command, dialect) => {
@@ -28533,6 +28587,10 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
28533
28587
  if (inner !== null && dir !== undefined)
28534
28588
  for (const runIn of workitRunDir(dir, words, atAll))
28535
28589
  targets.push(...segmentTargets(runIn, inner, "posix", depth + 1, strict, runIn === dir ? vars : unPwd()));
28590
+ const windows = strict && depth < 4 ? windowsScript(words, segment.stdin?.join(`
28591
+ `)) : null;
28592
+ if (windows !== null && dir !== undefined)
28593
+ targets.push(...segmentTargets(dir, windows, "powershell", depth + 1, strict, vars));
28536
28594
  const bare = strict === "registry" && depth < 4 ? unwrapped2(words) : null;
28537
28595
  if (bare?.length && dir !== undefined)
28538
28596
  targets.push(...segmentTargets(dir, bare.flatMap((word) => expansions(word, vars, loops)).map(quoteWord2).join(" "), "posix", depth + 1, strict, vars));
@@ -28608,9 +28666,11 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
28608
28666
  if (/^(?:n?vim?|ex|ed|emacs)$/.test(verb) && (segment.stdin || inputs.length > 0 || feeder || args.some((arg, index) => /^(?:-[a-zA-Z]*[se]|--(?:batch|eval|script))$/.test(arg) || /^(?:-c|--cmd)$/.test(arg) && !inertEdit(args[index + 1] ?? "") || arg.startsWith("+") && !inertEdit(arg.slice(1) || "1"))))
28609
28667
  for (const file of operands(args))
28610
28668
  targets.push(...atAll(file));
28611
- if (verb === "cp" && args.some((arg) => /^-[a-zA-Z]*l|^--link$/.test(arg)))
28612
- for (const file of operands(args).slice(0, -1))
28613
- targets.push(...atAll(file));
28669
+ const feed = fed === undefined && !piped.length ? undefined : [fed, ...piped].join(`
28670
+ `);
28671
+ for (const [linker = "", ...rest] of fedRuns(words, feed))
28672
+ for (const source of linkReach(commandName2(linker), rest, at, atAll))
28673
+ targets.push(path42.join(source, LINK_SOURCE));
28614
28674
  }
28615
28675
  if (strict && dir !== undefined) {
28616
28676
  const runIn = dir;
@@ -28806,19 +28866,42 @@ var hardLinked = (file, state, configs, inodes) => {
28806
28866
  return;
28807
28867
  }
28808
28868
  };
28869
+ var inRepoLedger = (file) => [...file.matchAll(/[\\/]workit[\\/]ledger(?=[\\/]|$)/g)].some(({ index }) => {
28870
+ const gitDir = file.slice(0, index);
28871
+ return /(?:^|[\\/])\.git$/.test(gitDir) || existsSync16(path42.join(gitDir, "HEAD")) && existsSync16(path42.join(gitDir, "objects"));
28872
+ });
28873
+ var holdsGuarded = (cwd, source, state, configs) => {
28874
+ const real = canonical5(source);
28875
+ const below = (parent, child) => {
28876
+ const rel = path42.relative(parent, child);
28877
+ return rel === "" || !rel.startsWith("..") && !path42.isAbsolute(rel);
28878
+ };
28879
+ const holds = (file) => below(real, canonical5(file));
28880
+ const inState = path42.relative(canonical5(state), real).split(path42.sep);
28881
+ const ledgers = ["ledger", "workit/ledger", ".git/workit/ledger"].map((rel) => path42.join(real, rel)).filter((dir) => existsSync16(dir) && inRepoLedger(dir));
28882
+ const own = ledgerPath(cwd);
28883
+ return holds(state) || below(canonical5(state), real) && inState[0] === "folders" && inState.length <= 2 || configs.some(holds) || ledgers.length > 0 || own.ok && existsSync16(own.value) && holds(path42.dirname(own.value));
28884
+ };
28809
28885
  var registryTarget = (cwd, targets) => {
28810
28886
  const state = resolveStateDir();
28811
28887
  const configs = configDirs();
28812
28888
  const inodes = {};
28813
28889
  for (const target of targets) {
28814
28890
  const file = homeExpanded(target);
28891
+ if (path42.basename(file) === LINK_SOURCE) {
28892
+ const source = path42.dirname(path42.resolve(cwd, file));
28893
+ const reached = registryTarget(cwd, [source])?.registry ?? (holdsGuarded(cwd, source, state, configs) ? "holds" : null);
28894
+ if (reached)
28895
+ return { file: target, registry: reached };
28896
+ continue;
28897
+ }
28815
28898
  if (realPath(path42.resolve(cwd, file)) === null)
28816
28899
  return { file: target, registry: "link" };
28817
28900
  const glob = globbed(cwd, file, state, configs)[0];
28818
28901
  const viaGlob = glob === undefined ? null : registryTarget(cwd, [glob]);
28819
28902
  if (viaGlob)
28820
28903
  return { file: target, registry: viaGlob.registry };
28821
- const registry = hardLinked(path42.resolve(cwd, file), state, configs, inodes) ?? underRegistry(state, cwd, file, process.platform, canonical5) ?? (/[\\/]\.git[\\/]workit[\\/]ledger(?:[\\/]|$)/.test(canonical5(path42.resolve(cwd, file))) ? "ledger" : null) ?? (configs.some((dir) => underConfig(dir, cwd, file, process.platform, canonical5)) ? "grants" : null);
28904
+ const registry = hardLinked(path42.resolve(cwd, file), state, configs, inodes) ?? underRegistry(state, cwd, file, process.platform, canonical5) ?? (inRepoLedger(canonical5(path42.resolve(cwd, file))) ? "ledger" : null) ?? (configs.some((dir) => underConfig(dir, cwd, file, process.platform, canonical5)) ? "grants" : null);
28822
28905
  if (registry)
28823
28906
  return { file: target, registry };
28824
28907
  }
@@ -28845,6 +28928,7 @@ var underConfig = (dir, cwd, target, platform = process.platform, real = (file)
28845
28928
  const parts = partsUnder(dir, cwd, target, platform, real);
28846
28929
  return parts?.length === 1 && ["", ...CONFIG_FILES, DIR_TARGET, UNRESOLVED_TARGET].includes(parts[0]);
28847
28930
  };
28931
+ var windowsSlashed = (command, platform = process.platform) => platform === "win32" && command.includes("\\") ? command.replace(/[^\s'"|;&<>()]*\\[^\s'"|;&<>()]*/g, (word) => word.replaceAll("\\", "/")) : null;
28848
28932
  var unquotedWindowsRegistry = (command, platform = process.platform) => {
28849
28933
  if (platform !== "win32" || !command.includes("\\"))
28850
28934
  return null;
@@ -28853,28 +28937,36 @@ var unquotedWindowsRegistry = (command, platform = process.platform) => {
28853
28937
  const state = flat(resolveStateDir());
28854
28938
  const configs = configDirs().map(flat);
28855
28939
  const folders = `${state}/folders/`;
28856
- const ledger = (at) => at.includes(`${state}/verdicts`) || /\/\.git\/workit\/ledger(?:[/\s'"]|$)/.test(at) || at.split(folders).slice(1).some((rest) => /^[^/\s]+\/ledger(?:[/\s'"]|$)/.test(rest));
28857
- const registry = text.includes(`${state}/issued`) ? "issued" : text.includes(`${state}/approvals`) ? "approvals" : ledger(text) ? "ledger" : configs.some((dir) => text.includes(dir)) ? "grants" : null;
28858
- if (!registry)
28940
+ const ledger = (at, named = false) => at.includes(`${state}/verdicts`) || (named ? inRepoLedger(at) : /\/workit\/ledger(?:[/\s'"]|$)/.test(at)) || at.split(folders).slice(1).some((rest) => /^[^/\s]+\/ledger(?:[/\s'"]|$)/.test(rest));
28941
+ const present = ["issued", "approvals", "ledger", "grants"].filter((kind) => kind === "ledger" ? ledger(text) : kind === "grants" ? configs.some((dir) => text.includes(dir)) : text.includes(`${state}/${kind}`));
28942
+ if (!present.length)
28859
28943
  return null;
28860
- const spans = command.replace(/[^\s'"|;&<>()]*\\[^\s'"|;&<>()]*/g, (word) => word.replaceAll("\\", "/"));
28944
+ const spans = windowsSlashed(command, platform) ?? command;
28861
28945
  const writes = shellWrites(spans);
28946
+ if (!writes.writes)
28947
+ return null;
28862
28948
  const moved = [
28863
28949
  "",
28864
28950
  ...[...spans.matchAll(/(?:^|[;&|(]\s*)(?:cd|pushd|chdir)\s+([^\s;&|)]+)/g)].map((match) => `${match[1]}/`)
28865
28951
  ];
28866
- const named = (target) => moved.some((dir) => {
28952
+ const named = (registry, target) => moved.some((dir) => {
28867
28953
  const at = flat(/^(?:[a-z]:)?\//i.test(target) ? target : dir + target).replace(/\/\.?\//g, "/");
28868
- return registry === "grants" ? configs.some((cfg) => [cfg, `${cfg}/`, ...CONFIG_FILES.map((name) => `${cfg}/${name}`)].includes(at)) : registry === "ledger" ? ledger(at) : at.includes(`${state}/${registry}`);
28954
+ return registry === "grants" ? configs.some((cfg) => [cfg, `${cfg}/`, ...CONFIG_FILES.map((name) => `${cfg}/${name}`)].includes(at)) : registry === "ledger" ? ledger(at, true) : at.includes(`${state}/${registry}`);
28869
28955
  });
28870
- return writes.writes && (writes.targets === null || writes.targets.some(named)) ? registry : null;
28956
+ return present.find((registry) => writes.targets === null || writes.targets.some((target) => named(registry, target))) ?? null;
28871
28957
  };
28958
+ var LINK_UNBLOCK = "Never link or bind-mount Workit's state, config or ledgers: a write through the link would land in them. Read the file in place.";
28872
28959
  var REGISTRY_DENY = {
28873
28960
  link: {
28874
28961
  label: "registry guard",
28875
28962
  what: "a symlink chain Workit could not resolve (over 40 links), which may reach a guarded path",
28876
28963
  unblock: "Write to the file's real path."
28877
28964
  },
28965
+ holds: {
28966
+ label: "registry guard",
28967
+ what: "Workit's state, its config or a repository ledger",
28968
+ unblock: LINK_UNBLOCK
28969
+ },
28878
28970
  issued: {
28879
28971
  label: "issued-registry guard",
28880
28972
  what: "Workit's issued-session state",
@@ -28898,6 +28990,12 @@ var REGISTRY_DENY = {
28898
28990
  };
28899
28991
  var registryDeny = ({ file, registry }) => {
28900
28992
  const { label, what, unblock } = REGISTRY_DENY[registry];
28993
+ if (path42.basename(file) === LINK_SOURCE)
28994
+ return {
28995
+ kind: "deny",
28996
+ reason: `workit ${label}: this command links or mounts ${path42.dirname(file)}, which is or holds ${what}. ${LINK_UNBLOCK}`,
28997
+ unblock: LINK_UNBLOCK
28998
+ };
28901
28999
  if (path42.basename(file) === UNRESOLVED_TARGET)
28902
29000
  return {
28903
29001
  kind: "deny",
@@ -28929,7 +29027,8 @@ function writeGate(cwd, paths, owner, deps) {
28929
29027
  function shellGate(cwd, command, owner, dialect = "posix", deps) {
28930
29028
  try {
28931
29029
  const windows = unquotedWindowsRegistry(command);
28932
- const forged = registryTarget(cwd, shellMutationTargets(cwd, command, dialect, "registry")) ?? (windows ? { file: `the ${windows} registry`, registry: windows } : null);
29030
+ const slashed = dialect === "posix" ? windowsSlashed(command) : null;
29031
+ const forged = registryTarget(cwd, shellMutationTargets(cwd, command, dialect, "registry")) ?? (slashed === null ? null : registryTarget(cwd, shellMutationTargets(cwd, slashed, dialect, "registry"))) ?? (windows ? { file: `the ${windows} registry`, registry: windows } : null);
28933
29032
  if (forged)
28934
29033
  return registryDeny(forged);
28935
29034
  } catch {
@@ -29068,6 +29167,26 @@ function currentJudgment(cwd) {
29068
29167
  }
29069
29168
  }
29070
29169
 
29170
+ // packages/workit-core/src/core/verdict-set.ts
29171
+ import path44 from "node:path";
29172
+ var SET_TTL_MS = 7 * 86400000;
29173
+ var SET_VOID = "verdict.set.voided";
29174
+ var setStorePath = () => path44.join(resolveStateDir(), "verdicts", "sets", "ledger.jsonl");
29175
+ function gateStands(cwd, gate, rows, now = Date.now()) {
29176
+ const id = typeof gate.verdictId === "string" ? gate.verdictId : null;
29177
+ if (id !== null && verdictVoids(rows).has(id))
29178
+ return false;
29179
+ if (gate.via !== "set")
29180
+ return true;
29181
+ const until = typeof gate.expires === "string" ? Date.parse(gate.expires) : Date.parse(gate.at) + SET_TTL_MS;
29182
+ if (!(until > now))
29183
+ return false;
29184
+ if (id === null)
29185
+ return true;
29186
+ const read = readLedgerAt(cwd, setStorePath(), { integrity: true });
29187
+ return read.ok && !read.value.rows.some((row) => row.type === SET_VOID && row.target === id && row.integrity === "verified");
29188
+ }
29189
+
29071
29190
  // packages/workit-core/src/hooks/stop.ts
29072
29191
  var NONE4 = { kind: "none" };
29073
29192
  var QUESTION = /[??؟](?=[\s*_`"')\]>]*(?:\s|$))|¿/;
@@ -29181,7 +29300,7 @@ var unverified = (cwd, branch, all, descriptor, verification, head) => {
29181
29300
  const check = checkVerdicts(cwd, branch, all);
29182
29301
  if (check.accepted.accepted || check.accepted.reasons.includes("failing_verdict"))
29183
29302
  return null;
29184
- if (all.some((row) => row.type === "pr.gate" && row.branch === branch && row.head === check.head))
29303
+ if (all.some((row) => row.type === "pr.gate" && row.branch === branch && row.head === check.head && gateStands(cwd, row, all)))
29185
29304
  return null;
29186
29305
  const judgment = currentJudgment(cwd);
29187
29306
  const high = judgment?.riskTier === "high";
@@ -29538,12 +29657,12 @@ var writePaths = (input) => {
29538
29657
  };
29539
29658
  // packages/workit-core/src/hooks/standing.ts
29540
29659
  import fs31 from "node:fs";
29541
- import path49 from "node:path";
29660
+ import path50 from "node:path";
29542
29661
 
29543
29662
  // packages/workit-core/src/approvals/store.ts
29544
29663
  import { createHash as createHash20, randomBytes as randomBytes4 } from "node:crypto";
29545
29664
  import { mkdirSync as mkdirSync7, readdirSync as readdirSync6, readFileSync as readFileSync13, rmSync as rmSync3 } from "node:fs";
29546
- import path44 from "node:path";
29665
+ import path45 from "node:path";
29547
29666
  var REQUEST_TTL_MS = 30 * 60000;
29548
29667
  var GRANT_TTL_MS = 15 * 60000;
29549
29668
  var ID_PATTERN = /^ap_[a-z2-7]{8}$/u;
@@ -29555,10 +29674,10 @@ var approvalHash = (fields) => createHash20("sha256").update(canonicalJson({
29555
29674
  effect: fields.effect,
29556
29675
  subject: fields.subject
29557
29676
  })).digest("hex");
29558
- var approvalsDir = () => path44.join(resolveStateDir(), "approvals");
29559
- var dirOf = (part) => path44.join(approvalsDir(), part);
29560
- var fileOf = (part, id) => path44.join(dirOf(part), `${id}.json`);
29561
- var askedFile = (session, toolUseId) => path44.join(dirOf("asked"), `${createHash20("sha256").update(`${session}\x00${toolUseId}`).digest("hex").slice(0, 32)}.json`);
29677
+ var approvalsDir = () => path45.join(resolveStateDir(), "approvals");
29678
+ var dirOf = (part) => path45.join(approvalsDir(), part);
29679
+ var fileOf = (part, id) => path45.join(dirOf(part), `${id}.json`);
29680
+ var askedFile = (session, toolUseId) => path45.join(dirOf("asked"), `${createHash20("sha256").update(`${session}\x00${toolUseId}`).digest("hex").slice(0, 32)}.json`);
29562
29681
  var readJson3 = (file) => {
29563
29682
  try {
29564
29683
  const value = JSON.parse(readFileSync13(file, "utf8"));
@@ -29568,7 +29687,7 @@ var readJson3 = (file) => {
29568
29687
  }
29569
29688
  };
29570
29689
  var write = (file, value) => {
29571
- mkdirSync7(path44.dirname(file), { recursive: true });
29690
+ mkdirSync7(path45.dirname(file), { recursive: true });
29572
29691
  writeFileAtomic(file, `${JSON.stringify(value, null, 2)}
29573
29692
  `);
29574
29693
  };
@@ -29693,7 +29812,7 @@ var namesTicket = (text) => /WORKIT_APPROVAL_(?:TICKET|UNASKED)/u.test(text.repl
29693
29812
  var TICKET_DENY = "Only the host's prompt adds an approval ticket.";
29694
29813
  var dropInline = (drop) => {
29695
29814
  for (const name of names2("inline")) {
29696
- const file = path44.join(dirOf("inline"), name);
29815
+ const file = path45.join(dirOf("inline"), name);
29697
29816
  const row = readJson3(file);
29698
29817
  if (!row || drop(row))
29699
29818
  rmSync3(file, { force: true });
@@ -29755,12 +29874,12 @@ var approveCallIn = (command, dialect = "posix") => {
29755
29874
  var approveCallDeny = (fix) => `Run \`${fix}\` as its own call: no chain, pipe, substitution, leading cd, env prefix or redirect around it, so the host can show the request and record the user's answer.`;
29756
29875
 
29757
29876
  // packages/workit-core/src/approvals/inline.ts
29758
- import path47 from "node:path";
29877
+ import path48 from "node:path";
29759
29878
 
29760
29879
  // packages/workit-core/src/approvals/release-notes-ask.ts
29761
29880
  import { createHash as createHash21 } from "node:crypto";
29762
29881
  import { existsSync as existsSync17, readFileSync as readFileSync14 } from "node:fs";
29763
- import path45 from "node:path";
29882
+ import path46 from "node:path";
29764
29883
  var sha2563 = (data) => createHash21("sha256").update(data).digest("hex");
29765
29884
  var isReleaseNotesApprove = (words) => words[0] === "notes" && words[1] === "approve";
29766
29885
  var versionOf = (args) => {
@@ -29800,10 +29919,10 @@ var releaseNotesAskAt = (args, cwd) => {
29800
29919
  const common = version ? gitCommonDir(cwd) : null;
29801
29920
  if (!version || !common)
29802
29921
  return null;
29803
- const dir = path45.join(common, "workit", "release-notes");
29922
+ const dir = path46.join(common, "workit", "release-notes");
29804
29923
  for (const file of [
29805
- path45.join(dir, "packages", `${version.replaceAll("/", "%2F")}.md`),
29806
- path45.join(dir, `${version}.md`)
29924
+ path46.join(dir, "packages", `${version.replaceAll("/", "%2F")}.md`),
29925
+ path46.join(dir, `${version}.md`)
29807
29926
  ])
29808
29927
  if (existsSync17(file))
29809
29928
  try {
@@ -29817,7 +29936,7 @@ var releaseNotesAskAt = (args, cwd) => {
29817
29936
  // packages/workit-core/src/approvals/youtrack-ask.ts
29818
29937
  import { createHash as createHash22 } from "node:crypto";
29819
29938
  import { readFileSync as readFileSync15, realpathSync as realpathSync12 } from "node:fs";
29820
- import path46 from "node:path";
29939
+ import path47 from "node:path";
29821
29940
  var TIME = "markdown file minutes text date";
29822
29941
  var FLAGS = {
29823
29942
  note: TIME,
@@ -29861,7 +29980,7 @@ var youTrackAsk = (args, cwd, load = readFileSync15) => {
29861
29980
  const files = [];
29862
29981
  const read = (file) => {
29863
29982
  try {
29864
- const named = path46.resolve(cwd, file);
29983
+ const named = path47.resolve(cwd, file);
29865
29984
  const content = load(named);
29866
29985
  files.push([realpathSync12(named), sha2564(content)]);
29867
29986
  return content;
@@ -29899,7 +30018,7 @@ var youTrackAsk = (args, cwd, load = readFileSync15) => {
29899
30018
  const content = read(file);
29900
30019
  if (!content)
29901
30020
  return null;
29902
- lines.push(`attach: ${path46.basename(file)} (${content.length} bytes)`);
30021
+ lines.push(`attach: ${path47.basename(file)} (${content.length} bytes)`);
29903
30022
  }
29904
30023
  if (!lines.length)
29905
30024
  return null;
@@ -29936,7 +30055,7 @@ var cwdOf = (globals) => {
29936
30055
  }
29937
30056
  return cwd;
29938
30057
  };
29939
- var inlineCallCwd = (call, base) => call.cwd ? path47.resolve(base, call.cwd) : base;
30058
+ var inlineCallCwd = (call, base) => call.cwd ? path48.resolve(base, call.cwd) : base;
29940
30059
  var isReadFilter = (segment) => (segment.words[0] === "tail" || segment.words[0] === "head") && segment.words.slice(1).every((word) => /^(?:-[nc]|-[nc]?\d+|\+?\d+)$/u.test(word)) && !segment.redirects.length && !segment.subs?.length && !segment.stdin?.length && !segment.inputs?.length && !segment.expands?.length && !segment.group && !segment.unanalyzable;
29941
30060
  var onlyFiltersAfter = (segments) => segments[0]?.pipe === true && segments.slice(1).every((segment, index, rest) => isReadFilter(segment) && (index === rest.length - 1 ? !segment.pipe : segment.pipe));
29942
30061
  var inlineCallIn = (command, dialect = "posix") => {
@@ -30459,35 +30578,35 @@ function neededChecks(lane, configured) {
30459
30578
  import { createHash as createHash23 } from "node:crypto";
30460
30579
  import fs30 from "node:fs";
30461
30580
  import os11 from "node:os";
30462
- import path48 from "node:path";
30581
+ import path49 from "node:path";
30463
30582
  var FANOUT_TOKEN_FILE = "workit-fanout-token";
30464
30583
  var NONE5 = { kind: "none" };
30465
30584
  var CASE_INSENSITIVE2 = process.platform === "darwin" || process.platform === "win32";
30466
30585
  var realOf = (file) => {
30467
30586
  let rest = "";
30468
- for (let dir = file;; dir = path48.dirname(dir)) {
30587
+ for (let dir = file;; dir = path49.dirname(dir)) {
30469
30588
  try {
30470
- return path48.join(fs30.realpathSync.native(dir), rest);
30589
+ return path49.join(fs30.realpathSync.native(dir), rest);
30471
30590
  } catch {
30472
- if (path48.dirname(dir) === dir)
30591
+ if (path49.dirname(dir) === dir)
30473
30592
  return file;
30474
- rest = rest ? path48.join(path48.basename(dir), rest) : path48.basename(dir);
30593
+ rest = rest ? path49.join(path49.basename(dir), rest) : path49.basename(dir);
30475
30594
  }
30476
30595
  }
30477
30596
  };
30478
30597
  var canonical6 = (file, hops = { chain: 40, total: 1000 }) => {
30479
- const start = path48.isAbsolute(file) ? file : `${process.cwd()}${path48.sep}${file}`;
30480
- const { root } = path48.parse(start);
30598
+ const start = path49.isAbsolute(file) ? file : `${process.cwd()}${path49.sep}${file}`;
30599
+ const { root } = path49.parse(start);
30481
30600
  let at = root;
30482
30601
  let missing = false;
30483
30602
  for (const part of start.slice(root.length).split(/[\\/]+/)) {
30484
30603
  if (part === "" || part === ".")
30485
30604
  continue;
30486
30605
  if (part === "..") {
30487
- at = path48.dirname(at);
30606
+ at = path49.dirname(at);
30488
30607
  continue;
30489
30608
  }
30490
- const next = path48.join(at, part);
30609
+ const next = path49.join(at, part);
30491
30610
  let link = null;
30492
30611
  if (!missing)
30493
30612
  try {
@@ -30499,25 +30618,25 @@ var canonical6 = (file, hops = { chain: 40, total: 1000 }) => {
30499
30618
  at = next;
30500
30619
  hops.chain = 40;
30501
30620
  } else if (hops.chain-- > 0 && hops.total-- > 0)
30502
- at = canonical6(path48.isAbsolute(link) ? link : `${at}${path48.sep}${link}`, hops);
30621
+ at = canonical6(path49.isAbsolute(link) ? link : `${at}${path49.sep}${link}`, hops);
30503
30622
  else
30504
- return path48.resolve(file);
30623
+ return path49.resolve(file);
30505
30624
  }
30506
30625
  return realOf(at);
30507
30626
  };
30508
30627
  var within = (child, parent) => {
30509
30628
  const fold = (value) => CASE_INSENSITIVE2 ? value.toLowerCase() : value;
30510
- const relative = path48.relative(fold(parent), fold(child));
30511
- return relative === "" || !relative.startsWith("..") && !path48.isAbsolute(relative);
30629
+ const relative = path49.relative(fold(parent), fold(child));
30630
+ return relative === "" || !relative.startsWith("..") && !path49.isAbsolute(relative);
30512
30631
  };
30513
30632
  var checkoutOf2 = (file) => {
30514
- for (let dir = canonical6(file);; dir = path48.dirname(dir)) {
30515
- const dotGit = path48.join(dir, ".git");
30633
+ for (let dir = canonical6(file);; dir = path49.dirname(dir)) {
30634
+ const dotGit = path49.join(dir, ".git");
30516
30635
  if (fs30.existsSync(dotGit)) {
30517
30636
  const admin = fs30.statSync(dotGit).isFile() ? gitDirsAt(dir, null, false)?.[0] : undefined;
30518
- return { root: dir, workit: !!admin && fs30.existsSync(path48.join(admin, FANOUT_TOKEN_FILE)) };
30637
+ return { root: dir, workit: !!admin && fs30.existsSync(path49.join(admin, FANOUT_TOKEN_FILE)) };
30519
30638
  }
30520
- if (path48.dirname(dir) === dir)
30639
+ if (path49.dirname(dir) === dir)
30521
30640
  return null;
30522
30641
  }
30523
30642
  };
@@ -30529,8 +30648,8 @@ var workitWorktreeOf = (file) => {
30529
30648
  return null;
30530
30649
  }
30531
30650
  };
30532
- var bindingDir = () => path48.join(resolveStateDir(), "worktree-bind");
30533
- var bindingFile = (session, agentId) => path48.join(bindingDir(), `${createHash23("sha256").update(`${session}\x00${agentId}`).digest("hex").slice(0, 32)}.json`);
30651
+ var bindingDir = () => path49.join(resolveStateDir(), "worktree-bind");
30652
+ var bindingFile = (session, agentId) => path49.join(bindingDir(), `${createHash23("sha256").update(`${session}\x00${agentId}`).digest("hex").slice(0, 32)}.json`);
30534
30653
  var readBinding = (file) => {
30535
30654
  try {
30536
30655
  const value = JSON.parse(fs30.readFileSync(file, "utf8"));
@@ -30555,7 +30674,7 @@ var bind = (input, worktree) => {
30555
30674
  agentId,
30556
30675
  at: new Date().toISOString()
30557
30676
  };
30558
- fs30.mkdirSync(path48.dirname(file), { recursive: true });
30677
+ fs30.mkdirSync(path49.dirname(file), { recursive: true });
30559
30678
  fs30.writeFileSync(file, JSON.stringify(binding));
30560
30679
  try {
30561
30680
  if (inWorkitWorkspace(input.cwd))
@@ -30574,26 +30693,26 @@ var hostIsolated = (cwd, agentId) => {
30574
30693
  const checkout = checkoutOf2(cwd);
30575
30694
  if (!checkout)
30576
30695
  return false;
30577
- const dotGit = path48.join(checkout.root, ".git");
30696
+ const dotGit = path49.join(checkout.root, ".git");
30578
30697
  if (!fs30.statSync(dotGit).isFile())
30579
30698
  return false;
30580
30699
  const [adminDir, gitDir] = gitDirsAt(checkout.root, null, false) ?? [];
30581
- const back = fs30.readFileSync(path48.join(adminDir, "gitdir"), "utf8").trim();
30582
- if (path48.relative(canonical6(path48.resolve(adminDir, back)), canonical6(dotGit)) !== "")
30700
+ const back = fs30.readFileSync(path49.join(adminDir, "gitdir"), "utf8").trim();
30701
+ if (path49.relative(canonical6(path49.resolve(adminDir, back)), canonical6(dotGit)) !== "")
30583
30702
  return false;
30584
- const expected = path48.join(path48.dirname(gitDir), ".claude", "worktrees", `agent-${agentId}`);
30585
- return path48.relative(canonical6(expected), checkout.root) === "";
30703
+ const expected = path49.join(path49.dirname(gitDir), ".claude", "worktrees", `agent-${agentId}`);
30704
+ return path49.relative(canonical6(expected), checkout.root) === "";
30586
30705
  } catch {
30587
30706
  return false;
30588
30707
  }
30589
30708
  };
30590
30709
  var runnerAt = (target) => {
30591
- const base = path48.basename(target);
30710
+ const base = path49.basename(target);
30592
30711
  return base.startsWith(OPAQUE_TARGET) ? decodeURIComponent(base.slice(OPAQUE_TARGET.length)) : null;
30593
30712
  };
30594
30713
  var shown = (target) => {
30595
- const named = /^\.workit-(?:live-target$|runs-)/.test(path48.basename(target)) ? path48.dirname(target) : target;
30596
- return path48.sep === "\\" ? named.replaceAll("/", "\\") : named;
30714
+ const named = /^\.workit-(?:live-target$|runs-)/.test(path49.basename(target)) ? path49.dirname(target) : target;
30715
+ return path49.sep === "\\" ? named.replaceAll("/", "\\") : named;
30597
30716
  };
30598
30717
  var runFrom = (dir, command) => `cd ${dir} && ${command.replace(/^\s*cd\s+\S+\s*(?:&&|;)\s*/, "")}`;
30599
30718
  var deny2 = (what, unblock) => ({
@@ -30609,7 +30728,7 @@ var outsideDeny = (input, worktree, target, command) => {
30609
30728
  };
30610
30729
  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\`.`);
30611
30730
  var refsOf = (targets) => [
30612
- ...new Set(targets.flatMap((target) => path48.relative(UNKNOWN_VAR, path48.resolve(target)).split(path48.sep)[0].split("+").filter(Boolean).map(decodeURIComponent)))
30731
+ ...new Set(targets.flatMap((target) => path49.relative(UNKNOWN_VAR, path49.resolve(target)).split(path49.sep)[0].split("+").filter(Boolean).map(decodeURIComponent)))
30613
30732
  ];
30614
30733
  var literalForm = (command, refs) => {
30615
30734
  let text = command;
@@ -30642,10 +30761,10 @@ function confineImplementer(input, targets, command) {
30642
30761
  try {
30643
30762
  if (!input.session.agentId || hostIsolated(input.cwd, input.session.agentId))
30644
30763
  return NONE5;
30645
- const unresolved = targets.filter((target) => within(path48.resolve(target), UNKNOWN_VAR));
30764
+ const unresolved = targets.filter((target) => within(path49.resolve(target), UNKNOWN_VAR));
30646
30765
  if (unresolved.length > 0)
30647
30766
  return unknownVarDeny(input, unresolved, command);
30648
- if (targets.some((target) => within(path48.resolve(target), UNKNOWN_DIR)))
30767
+ if (targets.some((target) => within(path49.resolve(target), UNKNOWN_DIR)))
30649
30768
  return unknownDirDeny(input, boundWorktree(input));
30650
30769
  const bindings = canonical6(bindingDir());
30651
30770
  const judged = targets.map((named) => ({ named, real: canonical6(named) })).filter(({ real }) => within(real, bindings) || checkoutOf2(real) !== null);
@@ -30752,10 +30871,10 @@ var INLINE = /^-[a-zA-Z]*[ceEpm]$|^--(?:eval|print|test|version|help)$|^-[hvV]$/
30752
30871
  var VALUED2 = /^-[WXIrC]$|^--(?:require|import|loader|conditions|input-type)$/;
30753
30872
  var commonDir = (root) => gitDirsAt(root, null, false)?.[1] ?? "";
30754
30873
  var inScratch = (real, repo) => {
30755
- for (let dir = real;path48.dirname(dir) !== dir; dir = path48.dirname(dir)) {
30756
- if (path48.basename(dir) !== SCRATCH)
30874
+ for (let dir = real;path49.dirname(dir) !== dir; dir = path49.dirname(dir)) {
30875
+ if (path49.basename(dir) !== SCRATCH)
30757
30876
  continue;
30758
- const root = path48.dirname(dir);
30877
+ const root = path49.dirname(dir);
30759
30878
  const checkout = checkoutOf2(root);
30760
30879
  if (checkout?.root === root && (repo === null || checkout.workit || commonDir(root) === repo))
30761
30880
  return true;
@@ -30765,7 +30884,7 @@ var inScratch = (real, repo) => {
30765
30884
  var inGitDir = (real) => real.split(/[\\/]/).includes(".git");
30766
30885
  var SAFE_KEY = /^(?:core\.(?:repositoryformatversion|filemode|bare|logallrefupdates|ignorecase|precomposeunicode|symlinks)|user\..*|init\.defaultbranch|commit\.gpgsign|extensions\.(?:objectformat|refstorage)|branch\..*\.(?:remote|merge)|remote\..*\.fetch)$/;
30767
30886
  var literalIn = (value, repo, checkout = false) => {
30768
- if (/[$`]/.test(value) || !path48.isAbsolute(value))
30887
+ if (/[$`]/.test(value) || !path49.isAbsolute(value))
30769
30888
  return false;
30770
30889
  const real = canonical6(value);
30771
30890
  const root = checkout ? checkoutOf2(real)?.root : undefined;
@@ -30786,8 +30905,8 @@ var configEntries = (text) => {
30786
30905
  return entries;
30787
30906
  };
30788
30907
  function gitDirsAt(dir, repo, scan = true) {
30789
- for (let at = dir;; at = path48.dirname(at)) {
30790
- const dotGit = path48.join(at, ".git");
30908
+ for (let at = dir;; at = path49.dirname(at)) {
30909
+ const dotGit = path49.join(at, ".git");
30791
30910
  let gitDir = null;
30792
30911
  try {
30793
30912
  if (fs30.statSync(dotGit).isDirectory())
@@ -30796,19 +30915,19 @@ function gitDirsAt(dir, repo, scan = true) {
30796
30915
  const named = /^gitdir:\s*(.+?)\s*$/mu.exec(fs30.readFileSync(dotGit, "utf8"))?.[1];
30797
30916
  if (!named)
30798
30917
  return null;
30799
- gitDir = canonical6(path48.resolve(at, named));
30918
+ gitDir = canonical6(path49.resolve(at, named));
30800
30919
  }
30801
30920
  } catch (error) {
30802
30921
  if (error.code !== "ENOENT")
30803
30922
  return null;
30804
- if (["HEAD", "objects", "refs"].every((name) => fs30.existsSync(path48.join(at, name))))
30923
+ if (["HEAD", "objects", "refs"].every((name) => fs30.existsSync(path49.join(at, name))))
30805
30924
  gitDir = canonical6(at);
30806
30925
  }
30807
30926
  if (gitDir !== null) {
30808
- const common = path48.join(gitDir, "commondir");
30809
- const shared = fs30.existsSync(common) ? canonical6(path48.resolve(gitDir, fs30.readFileSync(common, "utf8").trim())) : gitDir;
30927
+ const common = path49.join(gitDir, "commondir");
30928
+ const shared = fs30.existsSync(common) ? canonical6(path49.resolve(gitDir, fs30.readFileSync(common, "utf8").trim())) : gitDir;
30810
30929
  const dirs = [gitDir, shared];
30811
- for (const config of scan ? new Set([path48.join(gitDir, "config"), path48.join(shared, "config")]) : []) {
30930
+ for (const config of scan ? new Set([path49.join(gitDir, "config"), path49.join(shared, "config")]) : []) {
30812
30931
  let text = "";
30813
30932
  try {
30814
30933
  text = fs30.readFileSync(config, "utf8");
@@ -30817,14 +30936,14 @@ function gitDirsAt(dir, repo, scan = true) {
30817
30936
  }
30818
30937
  for (const [key, value] of configEntries(text)) {
30819
30938
  if (key === "core.worktree")
30820
- dirs.push(canonical6(path48.resolve(gitDir, value)));
30939
+ dirs.push(canonical6(path49.resolve(gitDir, value)));
30821
30940
  else if (/^remote\..*\.url$/.test(key) ? !literalIn(value, repo, true) : !SAFE_KEY.test(key))
30822
30941
  return null;
30823
30942
  }
30824
30943
  }
30825
30944
  return dirs;
30826
30945
  }
30827
- if (path48.dirname(at) === at)
30946
+ if (path49.dirname(at) === at)
30828
30947
  return [];
30829
30948
  }
30830
30949
  }
@@ -30964,10 +31083,10 @@ var gitKind = (args, local = () => true) => {
30964
31083
  return GIT_VERBS[verb].startsWith("+") ? "write" : "read";
30965
31084
  };
30966
31085
  var remoteIn = (dir, name, repo) => {
30967
- const shared = path48.isAbsolute(dir) ? gitDirsAt(canonical6(dir), repo, false)?.[1] : undefined;
31086
+ const shared = path49.isAbsolute(dir) ? gitDirsAt(canonical6(dir), repo, false)?.[1] : undefined;
30968
31087
  if (!shared)
30969
31088
  return false;
30970
- const url = configEntries(fs30.readFileSync(path48.join(shared, "config"), "utf8")).find(([key]) => key === `remote.${name}.url`.toLowerCase())?.[1];
31089
+ const url = configEntries(fs30.readFileSync(path49.join(shared, "config"), "utf8")).find(([key]) => key === `remote.${name}.url`.toLowerCase())?.[1];
30971
31090
  return url !== undefined && literalIn(url, repo, true);
30972
31091
  };
30973
31092
  var judgeGit = (command, repo, cwd, depth = 0) => {
@@ -30981,7 +31100,7 @@ var judgeGit = (command, repo, cwd, depth = 0) => {
30981
31100
  const lead = [];
30982
31101
  while (/^\w+\+?=/.test(words[at] ?? ""))
30983
31102
  lead.push(words[at++]);
30984
- const name = path48.basename(words[at] ?? "");
31103
+ const name = path49.basename(words[at] ?? "");
30985
31104
  let start = words.findIndex((word) => /(?:^|[\\/])git(?:\.exe)?(?:=|$)/.test(word));
30986
31105
  if (start > at) {
30987
31106
  if (/^(?:grep|egrep|rg|echo|printf|ls|wc|head|tail|cat|which|type|test|\[|cd|mkdir)$/.test(name) || name === "command" && /^-[vV]$/.test(words[at + 1] ?? ""))
@@ -30992,7 +31111,7 @@ var judgeGit = (command, repo, cwd, depth = 0) => {
30992
31111
  if (start >= 0 && words[start].includes("="))
30993
31112
  why = "git is redefined";
30994
31113
  const run = words[start] ?? "";
30995
- if (run.includes("/") && (!path48.isAbsolute(run) || literalIn(run, repo, true)))
31114
+ if (run.includes("/") && (!path49.isAbsolute(run) || literalIn(run, repo, true)))
30996
31115
  why ??= `\`${run}\` is not the system git`;
30997
31116
  if (segment.expands?.includes(at) && name !== "[" || /\{[^}]*,/.test(words[at] ?? ""))
30998
31117
  why = "the command's name is expanded by the shell";
@@ -31017,13 +31136,13 @@ var judgeGit = (command, repo, cwd, depth = 0) => {
31017
31136
  const args = words[index] === "--version" ? ["version"] : words.slice(index);
31018
31137
  if (!why && start >= 0) {
31019
31138
  const local = (source, remote) => remote && /^[\w-][\w.-]*$/.test(source) ? remoteIn(dir, source, repo) : literalIn(source, repo, true);
31020
- const runsIn = path48.isAbsolute(dir) ? dir : cwd && path48.resolve(cwd, dir);
31139
+ const runsIn = path49.isAbsolute(dir) ? dir : cwd && path49.resolve(cwd, dir);
31021
31140
  const home = runsIn && checkoutOf2(runsIn);
31022
31141
  const fetches = args[0] === "fetch" && plainFetch(args.slice(1)) && home && (home.workit || commonDir(home.root) === repo) && !words.some((word) => /^--[gw]/.test(word));
31023
31142
  if (!fetches && !gitKind(args, local))
31024
31143
  why = `\`git ${args.slice(0, 2).join(" ")}\` is not allowed`;
31025
31144
  }
31026
- const shell = /^(?:grep|egrep|rg|echo|printf|cat)$/.test(name) ? -1 : words.findIndex((word) => /^(?:sh|bash|zsh|dash|ksh|mksh|ash)$/.test(path48.basename(word)));
31145
+ const shell = /^(?:grep|egrep|rg|echo|printf|cat)$/.test(name) ? -1 : words.findIndex((word) => /^(?:sh|bash|zsh|dash|ksh|mksh|ash)$/.test(path49.basename(word)));
31027
31146
  const scripts = [
31028
31147
  ...words.filter((_, after) => shell >= 0 && after > shell && /^-[a-zA-Z]*c[a-zA-Z]*$/.test(words[after - 1])),
31029
31148
  ...shell < 0 ? [] : segment.stdin ?? []
@@ -31068,7 +31187,7 @@ var judgeVerbRefused = (args) => {
31068
31187
  var CLI_RUNNERS = /^(?:npx|bunx|pnpx|npm|pnpm|yarn|bun|node|nodejs|deno|tsx|ts-node)$/;
31069
31188
  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?$/;
31070
31189
  var workitCalls = (command, depth = 0, aliases = new Map) => depth > 4 ? [] : commandLines(command).flatMap((words) => {
31071
- const name = path48.basename(words[0] ?? "").toLowerCase();
31190
+ const name = path49.basename(words[0] ?? "").toLowerCase();
31072
31191
  if (name === "alias")
31073
31192
  return words.flatMap((word) => {
31074
31193
  const set = /^([\w-]+)=(.*)$/s.exec(word);
@@ -31097,11 +31216,11 @@ var judgeRefusal = (command, fed, depth = 0) => {
31097
31216
  return why;
31098
31217
  }
31099
31218
  const { words } = segment;
31100
- const runs = (word = "") => RUNS.test(path48.basename(word).toLowerCase());
31219
+ const runs = (word = "") => RUNS.test(path49.basename(word).toLowerCase());
31101
31220
  let at = 0;
31102
31221
  while (at < words.length && (LEADS.test(words[at]) || /^-\w$/.test(words[at - 1] ?? "") && !runs(words[at])))
31103
31222
  at++;
31104
- const name = path48.basename(words[at] ?? "").toLowerCase();
31223
+ const name = path49.basename(words[at] ?? "").toLowerCase();
31105
31224
  const args = words.slice(at + 1);
31106
31225
  const unseen = `\`${words.join(" ").slice(0, 80)}\` runs a script Workit cannot read (piped, on stdin, a process substitution or eval): write the case to a file in ${SCRATCH} and dispatch it from a test instead`;
31107
31226
  if (/^(?:cd|chdir|pushd|popd)$/.test(name))
@@ -31183,9 +31302,9 @@ var judgeDeny = (input, what, target, retry) => {
31183
31302
  const role = input.session.agentType?.endsWith("reviewer") ? "reviewer" : "verifier";
31184
31303
  const root = checkoutOf2(input.cwd)?.root;
31185
31304
  const candidate = target ? checkoutOf2(target)?.root : undefined;
31186
- const other = root && candidate && candidate !== root && commonDir(candidate) === commonDir(root) ? path48.join(candidate, SCRATCH) : undefined;
31187
- const scratch = root ? `${path48.join(root, SCRATCH)}${other ? ` or ${other}` : ""}` : `${SCRATCH}/ at the root of the checkout you judge`;
31188
- const call = root ? retry?.((other ?? path48.join(root, SCRATCH)).replaceAll("\\", "/")) : null;
31305
+ const other = root && candidate && candidate !== root && commonDir(candidate) === commonDir(root) ? path49.join(candidate, SCRATCH) : undefined;
31306
+ const scratch = root ? `${path49.join(root, SCRATCH)}${other ? ` or ${other}` : ""}` : `${SCRATCH}/ at the root of the checkout you judge`;
31307
+ const call = root ? retry?.((other ?? path49.join(root, SCRATCH)).replaceAll("\\", "/")) : null;
31189
31308
  const unblock = call ? `Retry as: ${call}` : "Why: write only there (mkdir -p it); a fix the candidate needs is a finding (`workit finding record`).";
31190
31309
  return {
31191
31310
  kind: "deny",
@@ -31196,9 +31315,9 @@ ${unblock}`,
31196
31315
  };
31197
31316
  var movedInto = (command, cwd, target, dir) => {
31198
31317
  for (const { words, redirects } of segmentsOf(command))
31199
- for (const word of [...redirects, ...path48.basename(words[0] ?? "") === "tee" ? words : []])
31200
- if (path48.resolve(cwd, word) === path48.resolve(cwd, target)) {
31201
- const moved = command.replace(new RegExp(`((?:>>?\\|?|\\btee(?:\\s+-a)?)\\s*)(['"]?)${word.replace(/[$()*+.?[\\\]^{|}]/g, "\\$&")}\\2(?![^\\s;&|)])`), (_, lead) => `${lead}${dir}/${path48.basename(word)}`);
31318
+ for (const word of [...redirects, ...path49.basename(words[0] ?? "") === "tee" ? words : []])
31319
+ if (path49.resolve(cwd, word) === path49.resolve(cwd, target)) {
31320
+ const moved = command.replace(new RegExp(`((?:>>?\\|?|\\btee(?:\\s+-a)?)\\s*)(['"]?)${word.replace(/[$()*+.?[\\\]^{|}]/g, "\\$&")}\\2(?![^\\s;&|)])`), (_, lead) => `${lead}${dir}/${path49.basename(word)}`);
31202
31321
  return moved === command ? null : moved;
31203
31322
  }
31204
31323
  return null;
@@ -31210,19 +31329,19 @@ function confineJudge(input, targets, placeholders = placeholdersOf(targets), co
31210
31329
  const judged = checkoutOf2(input.cwd);
31211
31330
  const repo = judged ? commonDir(judged.root) : null;
31212
31331
  const scratch = (real) => inScratch(real, repo) || [os11.tmpdir(), "/tmp"].some((dir) => {
31213
- const [host, , session] = path48.relative(canonical6(dir), real).split(path48.sep);
31332
+ const [host, , session] = path49.relative(canonical6(dir), real).split(path49.sep);
31214
31333
  return /^claude-\d+$/.test(host) && session === input.session.id;
31215
31334
  });
31216
31335
  for (const target of targets) {
31217
- const resolved = path48.resolve(target);
31336
+ const resolved = path49.resolve(target);
31218
31337
  if (within(resolved, UNKNOWN_VAR) || within(resolved, UNKNOWN_DIR))
31219
31338
  return judgeDeny(input, "it writes to a path Workit cannot resolve", undefined, () => {
31220
31339
  const literal = command && literalForm(command, refsOf([target]));
31221
31340
  return literal === command ? null : literal;
31222
31341
  });
31223
31342
  const real = canonical6(target);
31224
- const runsGit = placeholders.has(target) && /^\.workit-(?:runs-git|live-target)$/.test(path48.basename(target));
31225
- const gitDirs = runsGit ? gitDirsAt(path48.dirname(real), repo) : [];
31343
+ const runsGit = placeholders.has(target) && /^\.workit-(?:runs-git|live-target)$/.test(path49.basename(target));
31344
+ const gitDirs = runsGit ? gitDirsAt(path49.dirname(real), repo) : [];
31226
31345
  if (gitDirs === null)
31227
31346
  return judgeDeny(input, `git in ${shown(target)} uses a git dir or config Workit cannot check`);
31228
31347
  if (runsGit ? gitDirs.length > 0 ? gitDirs.every(scratch) : scratch(real) : scratch(real) && !inGitDir(real))
@@ -31288,7 +31407,7 @@ function confineJudgeShell(input, command, dialect = "posix") {
31288
31407
  let git = [];
31289
31408
  try {
31290
31409
  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)))) ? [
31291
- path48.join(dir === undefined ? UNKNOWN_DIR : path48.resolve(input.cwd, dir ?? "."), `${OPAQUE_TARGET}git`)
31410
+ path49.join(dir === undefined ? UNKNOWN_DIR : path49.resolve(input.cwd, dir ?? "."), `${OPAQUE_TARGET}git`)
31292
31411
  ] : []);
31293
31412
  } catch {}
31294
31413
  const lists = [
@@ -31333,7 +31452,7 @@ var judgeChecksLine = (cwd) => {
31333
31452
 
31334
31453
  // packages/workit-core/src/hooks/standing.ts
31335
31454
  var readPlans = (store) => {
31336
- const dir = path49.join(store, "fanouts");
31455
+ const dir = path50.join(store, "fanouts");
31337
31456
  let names;
31338
31457
  try {
31339
31458
  names = fs31.readdirSync(dir).filter((name) => name.endsWith(".json"));
@@ -31343,7 +31462,7 @@ var readPlans = (store) => {
31343
31462
  const plans = [];
31344
31463
  for (const name of names) {
31345
31464
  try {
31346
- const raw = JSON.parse(fs31.readFileSync(path49.join(dir, name), "utf8"));
31465
+ const raw = JSON.parse(fs31.readFileSync(path50.join(dir, name), "utf8"));
31347
31466
  if (typeof raw.name !== "string" || !Array.isArray(raw.slices))
31348
31467
  continue;
31349
31468
  const texts = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string" && item !== "") : [];
@@ -31553,12 +31672,12 @@ var cdWorkitSplit = (command) => {
31553
31672
 
31554
31673
  // packages/workit-core/src/hooks/spawn-gate.ts
31555
31674
  import fs32 from "node:fs";
31556
- import path51 from "node:path";
31675
+ import path52 from "node:path";
31557
31676
 
31558
31677
  // packages/workit-core/src/hooks/model-limit.ts
31559
31678
  import { closeSync as closeSync4, openSync as openSync4, readdirSync as readdirSync7, readSync, statSync as statSync5 } from "node:fs";
31560
31679
  import os12 from "node:os";
31561
- import path50 from "node:path";
31680
+ import path51 from "node:path";
31562
31681
  var MONTHS = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
31563
31682
  var WEEKDAYS = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"];
31564
31683
  var TIME_WORD = String.raw`(?:\d|(?:in|at|on|later|tomorrow|soon)\b|(?:${[...WEEKDAYS, ...MONTHS].join("|")})[a-z]*\b)`;
@@ -31756,17 +31875,17 @@ var firstPrompt = (file) => {
31756
31875
  var claudeProjectSlug = (cwd) => cwd.replace(/[^A-Za-z0-9]/gu, "-");
31757
31876
  var listDir = (dir) => {
31758
31877
  try {
31759
- return readdirSync7(dir).map((name) => path50.join(dir, name));
31878
+ return readdirSync7(dir).map((name) => path51.join(dir, name));
31760
31879
  } catch {
31761
31880
  return [];
31762
31881
  }
31763
31882
  };
31764
31883
  var SCAN_MS = 30 * 60000;
31765
31884
  var scanClaudeTranscripts = (cwd, env, now = new Date) => {
31766
- const projects = path50.join(env.CLAUDE_CONFIG_DIR || path50.join(env.HOME || os12.homedir(), ".claude"), "projects");
31767
- const project = path50.join(projects, claudeProjectSlug(cwd));
31885
+ const projects = path51.join(env.CLAUDE_CONFIG_DIR || path51.join(env.HOME || os12.homedir(), ".claude"), "projects");
31886
+ const project = path51.join(projects, claudeProjectSlug(cwd));
31768
31887
  const notes = [];
31769
- const files = listDir(project).flatMap((entry) => entry.endsWith(".jsonl") ? [{ file: entry, worker: false }] : listDir(path50.join(entry, "subagents")).filter((file) => file.endsWith(".jsonl")).map((file) => ({ file, worker: true })));
31888
+ const files = listDir(project).flatMap((entry) => entry.endsWith(".jsonl") ? [{ file: entry, worker: false }] : listDir(path51.join(entry, "subagents")).filter((file) => file.endsWith(".jsonl")).map((file) => ({ file, worker: true })));
31770
31889
  for (const { file, worker } of files)
31771
31890
  try {
31772
31891
  const stat = statSync5(file);
@@ -31781,7 +31900,7 @@ var scanClaudeTranscripts = (cwd, env, now = new Date) => {
31781
31900
  if (!seen)
31782
31901
  continue;
31783
31902
  notes.push(worker ? redispatchNote(seen, {
31784
- label: `worker ${path50.basename(file, ".jsonl")}`,
31903
+ label: `worker ${path51.basename(file, ".jsonl")}`,
31785
31904
  prompt: firstPrompt(file)
31786
31905
  }, now) : `Workit: this session hit a usage limit (${seen.reason}); ${seen.key} is marked exhausted until ${shortTime(seen.until)}. Claude Code runs only Anthropic models: Workit cannot switch this session, so continue on another host or after the reset.`);
31787
31906
  } catch {}
@@ -31883,10 +32002,10 @@ var namesMade = (word) => {
31883
32002
  const stat = fs32.statSync(word);
31884
32003
  if (stat.isFile())
31885
32004
  return stat.size < 1e6 && MADE_WORKTREE.test(fs32.readFileSync(word, "utf8"));
31886
- const dotGit = path51.join(word, ".git");
32005
+ const dotGit = path52.join(word, ".git");
31887
32006
  const link = fs32.statSync(dotGit);
31888
32007
  const admin = link.isFile() && link.size <= 4096 && /^gitdir: *(.+)/u.exec(fs32.readFileSync(dotGit, "utf8"));
31889
- return !!admin && fs32.existsSync(path51.resolve(word, admin[1].trim(), FANOUT_TOKEN_FILE));
32008
+ return !!admin && fs32.existsSync(path52.resolve(word, admin[1].trim(), FANOUT_TOKEN_FILE));
31890
32009
  } catch {
31891
32010
  return false;
31892
32011
  }
@@ -31932,8 +32051,8 @@ var spawnDecision = (descriptor, cwd, tool, permissionMode = null) => {
31932
32051
 
31933
32052
  // packages/workit-core/src/hooks/server-gate.ts
31934
32053
  import fs33 from "node:fs";
31935
- import path52 from "node:path";
31936
- var procNoticeFile = (env, session) => path52.join(stateDir(env), "procs", "notices", `${session.replace(/[^A-Za-z0-9_.@+-]/gu, "-").slice(0, 120) || "none"}.json`);
32054
+ import path53 from "node:path";
32055
+ var procNoticeFile = (env, session) => path53.join(stateDir(env), "procs", "notices", `${session.replace(/[^A-Za-z0-9_.@+-]/gu, "-").slice(0, 120) || "none"}.json`);
31937
32056
  var mb = (bytes) => `${Math.round(Number(bytes) / 1048576)} MB`;
31938
32057
  function takeProcNotice(session, env = process.env) {
31939
32058
  if (!session)
@@ -31971,21 +32090,21 @@ function takeProcNotice(session, env = process.env) {
31971
32090
  // packages/workit-core/src/hooks/teardown.ts
31972
32091
  import { spawn } from "node:child_process";
31973
32092
  import fs34 from "node:fs";
31974
- import path54 from "node:path";
32093
+ import path55 from "node:path";
31975
32094
 
31976
32095
  // packages/workit-core/src/core/cli-locate.ts
31977
32096
  import { closeSync as closeSync5, existsSync as existsSync18, openSync as openSync5, readSync as readSync2 } from "node:fs";
31978
- import path53 from "node:path";
32097
+ import path54 from "node:path";
31979
32098
  var LAUNCHER_MARKER = "workit-owned-launcher";
31980
32099
  var CLI_PACKAGE_PATH = ["node_modules", "@workit-dev", "cli"];
31981
32100
  var installRoot = (env, platform = process.platform) => {
31982
32101
  if (env.WORKIT_INSTALL_ROOT)
31983
32102
  return env.WORKIT_INSTALL_ROOT;
31984
32103
  const data = dataDir(env, platform);
31985
- return platform === "win32" ? path53.join(data, "install") : data;
32104
+ return platform === "win32" ? path54.join(data, "install") : data;
31986
32105
  };
31987
- var ownedLauncherPath = (env, platform = process.platform) => path53.join(installRoot(env, platform), "bin", platform === "win32" ? "workit.cmd" : "workit");
31988
- var ownedCurrentEntry = (env, platform = process.platform) => path53.join(installRoot(env, platform), "current", ...CLI_PACKAGE_PATH, "dist", "index.js");
32106
+ var ownedLauncherPath = (env, platform = process.platform) => path54.join(installRoot(env, platform), "bin", platform === "win32" ? "workit.cmd" : "workit");
32107
+ var ownedCurrentEntry = (env, platform = process.platform) => path54.join(installRoot(env, platform), "current", ...CLI_PACKAGE_PATH, "dist", "index.js");
31989
32108
  var head = (file) => {
31990
32109
  let fd;
31991
32110
  try {
@@ -32012,7 +32131,7 @@ var locateWorkitCli = (options = {}) => {
32012
32131
  source: "owned-launcher",
32013
32132
  command: launcher,
32014
32133
  args: [],
32015
- binDir: path53.dirname(launcher)
32134
+ binDir: path54.dirname(launcher)
32016
32135
  };
32017
32136
  const current = ownedCurrentEntry(env, platform);
32018
32137
  if (exists(current))
@@ -32041,7 +32160,7 @@ var workitCliEnv = (located, env = process.env, platform = process.platform) =>
32041
32160
  if (located.binDir) {
32042
32161
  const key = pathKey(env);
32043
32162
  const delimiter = platform === "win32" ? ";" : ":";
32044
- const same = (dir) => platform === "win32" ? path53.win32.normalize(dir).toLowerCase() === path53.win32.normalize(located.binDir).toLowerCase() : path53.posix.normalize(dir) === path53.posix.normalize(located.binDir);
32163
+ const same = (dir) => platform === "win32" ? path54.win32.normalize(dir).toLowerCase() === path54.win32.normalize(located.binDir).toLowerCase() : path54.posix.normalize(dir) === path54.posix.normalize(located.binDir);
32045
32164
  const rest = (env[key] ?? "").split(delimiter).filter((dir) => dir && !same(dir));
32046
32165
  patch[key] = [located.binDir, ...rest].join(delimiter);
32047
32166
  }
@@ -32065,9 +32184,9 @@ var ENDS = {
32065
32184
  };
32066
32185
  var SAFE_SESSION = /^[\w.@+][\w.:@/+-]{0,127}$/u;
32067
32186
  var HOST_SESSION_VARS2 = ["OPENCODE_SESSION_ID", "PI_SESSION_ID", "CODEX_THREAD_ID"];
32068
- var teardownDir = (env) => path54.join(stateDir(env), "procs");
32069
- var teardownLog = (env) => path54.join(teardownDir(env), "teardown.log");
32070
- var reapStamp = (env) => path54.join(teardownDir(env), "reap-at-start.stamp");
32187
+ var teardownDir = (env) => path55.join(stateDir(env), "procs");
32188
+ var teardownLog = (env) => path55.join(teardownDir(env), "teardown.log");
32189
+ var reapStamp = (env) => path55.join(teardownDir(env), "reap-at-start.stamp");
32071
32190
  function spawnDetached(request) {
32072
32191
  try {
32073
32192
  const shell = process.platform === "win32" && !/\.exe$/iu.test(request.command);
@@ -32094,7 +32213,7 @@ var teardownDeps = {
32094
32213
  var openLog = (env, args) => {
32095
32214
  try {
32096
32215
  const file = teardownLog(env);
32097
- fs34.mkdirSync(path54.dirname(file), { recursive: true });
32216
+ fs34.mkdirSync(path55.dirname(file), { recursive: true });
32098
32217
  let size = 0;
32099
32218
  try {
32100
32219
  size = fs34.statSync(file).size;
@@ -32179,7 +32298,7 @@ function reapAtStart(_cwd, env = process.env) {
32179
32298
  try {
32180
32299
  if (fresh(stamp, now))
32181
32300
  return false;
32182
- fs34.mkdirSync(path54.dirname(stamp), { recursive: true });
32301
+ fs34.mkdirSync(path55.dirname(stamp), { recursive: true });
32183
32302
  if (!claim2(lock, now))
32184
32303
  return false;
32185
32304
  } catch {
@@ -33194,10 +33313,10 @@ var modelKey = (model) => {
33194
33313
  // packages/workit-core/src/hooks/budget-signal.ts
33195
33314
  import { createHash as createHash24 } from "node:crypto";
33196
33315
  import fs35 from "node:fs";
33197
- import path55 from "node:path";
33316
+ import path56 from "node:path";
33198
33317
  var hash2 = (text) => createHash24("sha256").update(text).digest("hex").slice(0, 32);
33199
- var budgetDir = (store) => path55.join(store, "budget");
33200
- var agentBase = (store, session, agentId) => path55.join(budgetDir(store), hash2(`${session}\x00${agentId ?? ""}`));
33318
+ var budgetDir = (store) => path56.join(store, "budget");
33319
+ var agentBase = (store, session, agentId) => path56.join(budgetDir(store), hash2(`${session}\x00${agentId ?? ""}`));
33201
33320
  var spawnBudget = (prompt) => {
33202
33321
  const found = /^TIMEBOX:[^\n]*?\b(\d+)\s+tool calls\b/mu.exec(prompt);
33203
33322
  const n = found ? Number(found[1]) : NaN;
@@ -33217,8 +33336,8 @@ var startBudget = (store, session, agentId, n) => {
33217
33336
  const cutoff = Date.now() - 604800000;
33218
33337
  for (const name of fs35.readdirSync(dir))
33219
33338
  try {
33220
- if (fs35.statSync(path55.join(dir, name)).mtimeMs < cutoff)
33221
- fs35.rmSync(path55.join(dir, name));
33339
+ if (fs35.statSync(path56.join(dir, name)).mtimeMs < cutoff)
33340
+ fs35.rmSync(path56.join(dir, name));
33222
33341
  } catch {}
33223
33342
  const base = agentBase(store, session, agentId);
33224
33343
  fs35.writeFileSync(`${base}.json`, JSON.stringify({ limit: n, told: 0 }));
@@ -33673,12 +33792,12 @@ var skillPromptNudge = (prompt, ctx) => process.env.WORKIT_PI_WORKER_SESSION ? n
33673
33792
  // packages/workit-pi/src/launches.ts
33674
33793
  import { mkdirSync as mkdirSync8, readFileSync as readFileSync16, readdirSync as readdirSync8, rmSync as rmSync4, writeFileSync as writeFileSync7 } from "node:fs";
33675
33794
  import os13 from "node:os";
33676
- import path56 from "node:path";
33795
+ import path57 from "node:path";
33677
33796
  var launchDir = (root) => {
33678
33797
  const location = resolveStore(root);
33679
- return location instanceof Error ? null : path56.join(location.dir, "pi-launches");
33798
+ return location instanceof Error ? null : path57.join(location.dir, "pi-launches");
33680
33799
  };
33681
- var fileFor = (dir, workerId) => path56.join(dir, `${workerId.replace(/[^A-Za-z0-9-]/g, "_")}.json`);
33800
+ var fileFor = (dir, workerId) => path57.join(dir, `${workerId.replace(/[^A-Za-z0-9-]/g, "_")}.json`);
33682
33801
  var recordLaunch = (root, attempt) => {
33683
33802
  const dir = launchDir(root);
33684
33803
  if (!dir)
@@ -33724,7 +33843,7 @@ var abandonedLaunches = (root) => {
33724
33843
  const found = [];
33725
33844
  for (const name of names) {
33726
33845
  try {
33727
- const attempt = JSON.parse(readFileSync16(path56.join(dir, name), "utf8"));
33846
+ const attempt = JSON.parse(readFileSync16(path57.join(dir, name), "utf8"));
33728
33847
  if (typeof attempt.workerId === "string" && typeof attempt.session === "string") {
33729
33848
  if (!alive(attempt))
33730
33849
  found.push(attempt);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/pi",
3
- "version": "2.24.0",
3
+ "version": "2.25.1",
4
4
  "description": "Workit native extension for Pi — tools, method skills, and session continuity",
5
5
  "keywords": [
6
6
  "agentic-coding",