@workit-dev/pi 2.25.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.
Files changed (2) hide show
  1. package/dist/workit.js +246 -128
  2. package/package.json +1 -1
package/dist/workit.js CHANGED
@@ -28025,6 +28025,58 @@ var linkSources = (args, at) => {
28025
28025
  return resolved ? [resolved] : [];
28026
28026
  });
28027
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
+ };
28028
28080
  var shellWrites = (command, depth = 0) => {
28029
28081
  const targets = [];
28030
28082
  let unknown = false;
@@ -28133,6 +28185,7 @@ var recording = (make) => {
28133
28185
  var placeholdersOf = (targets) => PLACEHOLDERS.get(targets) ?? new Set;
28134
28186
  var OPAQUE_TARGET = ".workit-runs-";
28135
28187
  var UNRESOLVED_TARGET = ".workit-unresolved-target";
28188
+ var LINK_SOURCE = ".workit-link-source";
28136
28189
  var OVERRIDE = "WORKIT_LIVE_SESSION=override";
28137
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("--"));
28138
28191
  var gitMutationDirs = (cwd, command, dialect) => {
@@ -28534,6 +28587,10 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
28534
28587
  if (inner !== null && dir !== undefined)
28535
28588
  for (const runIn of workitRunDir(dir, words, atAll))
28536
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));
28537
28594
  const bare = strict === "registry" && depth < 4 ? unwrapped2(words) : null;
28538
28595
  if (bare?.length && dir !== undefined)
28539
28596
  targets.push(...segmentTargets(dir, bare.flatMap((word) => expansions(word, vars, loops)).map(quoteWord2).join(" "), "posix", depth + 1, strict, vars));
@@ -28609,9 +28666,11 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
28609
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"))))
28610
28667
  for (const file of operands(args))
28611
28668
  targets.push(...atAll(file));
28612
- if (verb === "cp" && args.some((arg) => /^-[a-zA-Z]*l|^--link$/.test(arg)))
28613
- for (const file of operands(args).slice(0, -1))
28614
- 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));
28615
28674
  }
28616
28675
  if (strict && dir !== undefined) {
28617
28676
  const runIn = dir;
@@ -28807,19 +28866,42 @@ var hardLinked = (file, state, configs, inodes) => {
28807
28866
  return;
28808
28867
  }
28809
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
+ };
28810
28885
  var registryTarget = (cwd, targets) => {
28811
28886
  const state = resolveStateDir();
28812
28887
  const configs = configDirs();
28813
28888
  const inodes = {};
28814
28889
  for (const target of targets) {
28815
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
+ }
28816
28898
  if (realPath(path42.resolve(cwd, file)) === null)
28817
28899
  return { file: target, registry: "link" };
28818
28900
  const glob = globbed(cwd, file, state, configs)[0];
28819
28901
  const viaGlob = glob === undefined ? null : registryTarget(cwd, [glob]);
28820
28902
  if (viaGlob)
28821
28903
  return { file: target, registry: viaGlob.registry };
28822
- 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);
28823
28905
  if (registry)
28824
28906
  return { file: target, registry };
28825
28907
  }
@@ -28846,6 +28928,7 @@ var underConfig = (dir, cwd, target, platform = process.platform, real = (file)
28846
28928
  const parts = partsUnder(dir, cwd, target, platform, real);
28847
28929
  return parts?.length === 1 && ["", ...CONFIG_FILES, DIR_TARGET, UNRESOLVED_TARGET].includes(parts[0]);
28848
28930
  };
28931
+ var windowsSlashed = (command, platform = process.platform) => platform === "win32" && command.includes("\\") ? command.replace(/[^\s'"|;&<>()]*\\[^\s'"|;&<>()]*/g, (word) => word.replaceAll("\\", "/")) : null;
28849
28932
  var unquotedWindowsRegistry = (command, platform = process.platform) => {
28850
28933
  if (platform !== "win32" || !command.includes("\\"))
28851
28934
  return null;
@@ -28854,28 +28937,36 @@ var unquotedWindowsRegistry = (command, platform = process.platform) => {
28854
28937
  const state = flat(resolveStateDir());
28855
28938
  const configs = configDirs().map(flat);
28856
28939
  const folders = `${state}/folders/`;
28857
- 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));
28858
- const registry = text.includes(`${state}/issued`) ? "issued" : text.includes(`${state}/approvals`) ? "approvals" : ledger(text) ? "ledger" : configs.some((dir) => text.includes(dir)) ? "grants" : null;
28859
- 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)
28860
28943
  return null;
28861
- const spans = command.replace(/[^\s'"|;&<>()]*\\[^\s'"|;&<>()]*/g, (word) => word.replaceAll("\\", "/"));
28944
+ const spans = windowsSlashed(command, platform) ?? command;
28862
28945
  const writes = shellWrites(spans);
28946
+ if (!writes.writes)
28947
+ return null;
28863
28948
  const moved = [
28864
28949
  "",
28865
28950
  ...[...spans.matchAll(/(?:^|[;&|(]\s*)(?:cd|pushd|chdir)\s+([^\s;&|)]+)/g)].map((match) => `${match[1]}/`)
28866
28951
  ];
28867
- const named = (target) => moved.some((dir) => {
28952
+ const named = (registry, target) => moved.some((dir) => {
28868
28953
  const at = flat(/^(?:[a-z]:)?\//i.test(target) ? target : dir + target).replace(/\/\.?\//g, "/");
28869
- 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}`);
28870
28955
  });
28871
- 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;
28872
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.";
28873
28959
  var REGISTRY_DENY = {
28874
28960
  link: {
28875
28961
  label: "registry guard",
28876
28962
  what: "a symlink chain Workit could not resolve (over 40 links), which may reach a guarded path",
28877
28963
  unblock: "Write to the file's real path."
28878
28964
  },
28965
+ holds: {
28966
+ label: "registry guard",
28967
+ what: "Workit's state, its config or a repository ledger",
28968
+ unblock: LINK_UNBLOCK
28969
+ },
28879
28970
  issued: {
28880
28971
  label: "issued-registry guard",
28881
28972
  what: "Workit's issued-session state",
@@ -28899,6 +28990,12 @@ var REGISTRY_DENY = {
28899
28990
  };
28900
28991
  var registryDeny = ({ file, registry }) => {
28901
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
+ };
28902
28999
  if (path42.basename(file) === UNRESOLVED_TARGET)
28903
29000
  return {
28904
29001
  kind: "deny",
@@ -28930,7 +29027,8 @@ function writeGate(cwd, paths, owner, deps) {
28930
29027
  function shellGate(cwd, command, owner, dialect = "posix", deps) {
28931
29028
  try {
28932
29029
  const windows = unquotedWindowsRegistry(command);
28933
- 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);
28934
29032
  if (forged)
28935
29033
  return registryDeny(forged);
28936
29034
  } catch {
@@ -29069,6 +29167,26 @@ function currentJudgment(cwd) {
29069
29167
  }
29070
29168
  }
29071
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
+
29072
29190
  // packages/workit-core/src/hooks/stop.ts
29073
29191
  var NONE4 = { kind: "none" };
29074
29192
  var QUESTION = /[??؟](?=[\s*_`"')\]>]*(?:\s|$))|¿/;
@@ -29182,7 +29300,7 @@ var unverified = (cwd, branch, all, descriptor, verification, head) => {
29182
29300
  const check = checkVerdicts(cwd, branch, all);
29183
29301
  if (check.accepted.accepted || check.accepted.reasons.includes("failing_verdict"))
29184
29302
  return null;
29185
- 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)))
29186
29304
  return null;
29187
29305
  const judgment = currentJudgment(cwd);
29188
29306
  const high = judgment?.riskTier === "high";
@@ -29539,12 +29657,12 @@ var writePaths = (input) => {
29539
29657
  };
29540
29658
  // packages/workit-core/src/hooks/standing.ts
29541
29659
  import fs31 from "node:fs";
29542
- import path49 from "node:path";
29660
+ import path50 from "node:path";
29543
29661
 
29544
29662
  // packages/workit-core/src/approvals/store.ts
29545
29663
  import { createHash as createHash20, randomBytes as randomBytes4 } from "node:crypto";
29546
29664
  import { mkdirSync as mkdirSync7, readdirSync as readdirSync6, readFileSync as readFileSync13, rmSync as rmSync3 } from "node:fs";
29547
- import path44 from "node:path";
29665
+ import path45 from "node:path";
29548
29666
  var REQUEST_TTL_MS = 30 * 60000;
29549
29667
  var GRANT_TTL_MS = 15 * 60000;
29550
29668
  var ID_PATTERN = /^ap_[a-z2-7]{8}$/u;
@@ -29556,10 +29674,10 @@ var approvalHash = (fields) => createHash20("sha256").update(canonicalJson({
29556
29674
  effect: fields.effect,
29557
29675
  subject: fields.subject
29558
29676
  })).digest("hex");
29559
- var approvalsDir = () => path44.join(resolveStateDir(), "approvals");
29560
- var dirOf = (part) => path44.join(approvalsDir(), part);
29561
- var fileOf = (part, id) => path44.join(dirOf(part), `${id}.json`);
29562
- 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`);
29563
29681
  var readJson3 = (file) => {
29564
29682
  try {
29565
29683
  const value = JSON.parse(readFileSync13(file, "utf8"));
@@ -29569,7 +29687,7 @@ var readJson3 = (file) => {
29569
29687
  }
29570
29688
  };
29571
29689
  var write = (file, value) => {
29572
- mkdirSync7(path44.dirname(file), { recursive: true });
29690
+ mkdirSync7(path45.dirname(file), { recursive: true });
29573
29691
  writeFileAtomic(file, `${JSON.stringify(value, null, 2)}
29574
29692
  `);
29575
29693
  };
@@ -29694,7 +29812,7 @@ var namesTicket = (text) => /WORKIT_APPROVAL_(?:TICKET|UNASKED)/u.test(text.repl
29694
29812
  var TICKET_DENY = "Only the host's prompt adds an approval ticket.";
29695
29813
  var dropInline = (drop) => {
29696
29814
  for (const name of names2("inline")) {
29697
- const file = path44.join(dirOf("inline"), name);
29815
+ const file = path45.join(dirOf("inline"), name);
29698
29816
  const row = readJson3(file);
29699
29817
  if (!row || drop(row))
29700
29818
  rmSync3(file, { force: true });
@@ -29756,12 +29874,12 @@ var approveCallIn = (command, dialect = "posix") => {
29756
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.`;
29757
29875
 
29758
29876
  // packages/workit-core/src/approvals/inline.ts
29759
- import path47 from "node:path";
29877
+ import path48 from "node:path";
29760
29878
 
29761
29879
  // packages/workit-core/src/approvals/release-notes-ask.ts
29762
29880
  import { createHash as createHash21 } from "node:crypto";
29763
29881
  import { existsSync as existsSync17, readFileSync as readFileSync14 } from "node:fs";
29764
- import path45 from "node:path";
29882
+ import path46 from "node:path";
29765
29883
  var sha2563 = (data) => createHash21("sha256").update(data).digest("hex");
29766
29884
  var isReleaseNotesApprove = (words) => words[0] === "notes" && words[1] === "approve";
29767
29885
  var versionOf = (args) => {
@@ -29801,10 +29919,10 @@ var releaseNotesAskAt = (args, cwd) => {
29801
29919
  const common = version ? gitCommonDir(cwd) : null;
29802
29920
  if (!version || !common)
29803
29921
  return null;
29804
- const dir = path45.join(common, "workit", "release-notes");
29922
+ const dir = path46.join(common, "workit", "release-notes");
29805
29923
  for (const file of [
29806
- path45.join(dir, "packages", `${version.replaceAll("/", "%2F")}.md`),
29807
- path45.join(dir, `${version}.md`)
29924
+ path46.join(dir, "packages", `${version.replaceAll("/", "%2F")}.md`),
29925
+ path46.join(dir, `${version}.md`)
29808
29926
  ])
29809
29927
  if (existsSync17(file))
29810
29928
  try {
@@ -29818,7 +29936,7 @@ var releaseNotesAskAt = (args, cwd) => {
29818
29936
  // packages/workit-core/src/approvals/youtrack-ask.ts
29819
29937
  import { createHash as createHash22 } from "node:crypto";
29820
29938
  import { readFileSync as readFileSync15, realpathSync as realpathSync12 } from "node:fs";
29821
- import path46 from "node:path";
29939
+ import path47 from "node:path";
29822
29940
  var TIME = "markdown file minutes text date";
29823
29941
  var FLAGS = {
29824
29942
  note: TIME,
@@ -29862,7 +29980,7 @@ var youTrackAsk = (args, cwd, load = readFileSync15) => {
29862
29980
  const files = [];
29863
29981
  const read = (file) => {
29864
29982
  try {
29865
- const named = path46.resolve(cwd, file);
29983
+ const named = path47.resolve(cwd, file);
29866
29984
  const content = load(named);
29867
29985
  files.push([realpathSync12(named), sha2564(content)]);
29868
29986
  return content;
@@ -29900,7 +30018,7 @@ var youTrackAsk = (args, cwd, load = readFileSync15) => {
29900
30018
  const content = read(file);
29901
30019
  if (!content)
29902
30020
  return null;
29903
- lines.push(`attach: ${path46.basename(file)} (${content.length} bytes)`);
30021
+ lines.push(`attach: ${path47.basename(file)} (${content.length} bytes)`);
29904
30022
  }
29905
30023
  if (!lines.length)
29906
30024
  return null;
@@ -29937,7 +30055,7 @@ var cwdOf = (globals) => {
29937
30055
  }
29938
30056
  return cwd;
29939
30057
  };
29940
- 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;
29941
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;
29942
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));
29943
30061
  var inlineCallIn = (command, dialect = "posix") => {
@@ -30460,35 +30578,35 @@ function neededChecks(lane, configured) {
30460
30578
  import { createHash as createHash23 } from "node:crypto";
30461
30579
  import fs30 from "node:fs";
30462
30580
  import os11 from "node:os";
30463
- import path48 from "node:path";
30581
+ import path49 from "node:path";
30464
30582
  var FANOUT_TOKEN_FILE = "workit-fanout-token";
30465
30583
  var NONE5 = { kind: "none" };
30466
30584
  var CASE_INSENSITIVE2 = process.platform === "darwin" || process.platform === "win32";
30467
30585
  var realOf = (file) => {
30468
30586
  let rest = "";
30469
- for (let dir = file;; dir = path48.dirname(dir)) {
30587
+ for (let dir = file;; dir = path49.dirname(dir)) {
30470
30588
  try {
30471
- return path48.join(fs30.realpathSync.native(dir), rest);
30589
+ return path49.join(fs30.realpathSync.native(dir), rest);
30472
30590
  } catch {
30473
- if (path48.dirname(dir) === dir)
30591
+ if (path49.dirname(dir) === dir)
30474
30592
  return file;
30475
- rest = rest ? path48.join(path48.basename(dir), rest) : path48.basename(dir);
30593
+ rest = rest ? path49.join(path49.basename(dir), rest) : path49.basename(dir);
30476
30594
  }
30477
30595
  }
30478
30596
  };
30479
30597
  var canonical6 = (file, hops = { chain: 40, total: 1000 }) => {
30480
- const start = path48.isAbsolute(file) ? file : `${process.cwd()}${path48.sep}${file}`;
30481
- const { root } = path48.parse(start);
30598
+ const start = path49.isAbsolute(file) ? file : `${process.cwd()}${path49.sep}${file}`;
30599
+ const { root } = path49.parse(start);
30482
30600
  let at = root;
30483
30601
  let missing = false;
30484
30602
  for (const part of start.slice(root.length).split(/[\\/]+/)) {
30485
30603
  if (part === "" || part === ".")
30486
30604
  continue;
30487
30605
  if (part === "..") {
30488
- at = path48.dirname(at);
30606
+ at = path49.dirname(at);
30489
30607
  continue;
30490
30608
  }
30491
- const next = path48.join(at, part);
30609
+ const next = path49.join(at, part);
30492
30610
  let link = null;
30493
30611
  if (!missing)
30494
30612
  try {
@@ -30500,25 +30618,25 @@ var canonical6 = (file, hops = { chain: 40, total: 1000 }) => {
30500
30618
  at = next;
30501
30619
  hops.chain = 40;
30502
30620
  } else if (hops.chain-- > 0 && hops.total-- > 0)
30503
- at = canonical6(path48.isAbsolute(link) ? link : `${at}${path48.sep}${link}`, hops);
30621
+ at = canonical6(path49.isAbsolute(link) ? link : `${at}${path49.sep}${link}`, hops);
30504
30622
  else
30505
- return path48.resolve(file);
30623
+ return path49.resolve(file);
30506
30624
  }
30507
30625
  return realOf(at);
30508
30626
  };
30509
30627
  var within = (child, parent) => {
30510
30628
  const fold = (value) => CASE_INSENSITIVE2 ? value.toLowerCase() : value;
30511
- const relative = path48.relative(fold(parent), fold(child));
30512
- return relative === "" || !relative.startsWith("..") && !path48.isAbsolute(relative);
30629
+ const relative = path49.relative(fold(parent), fold(child));
30630
+ return relative === "" || !relative.startsWith("..") && !path49.isAbsolute(relative);
30513
30631
  };
30514
30632
  var checkoutOf2 = (file) => {
30515
- for (let dir = canonical6(file);; dir = path48.dirname(dir)) {
30516
- const dotGit = path48.join(dir, ".git");
30633
+ for (let dir = canonical6(file);; dir = path49.dirname(dir)) {
30634
+ const dotGit = path49.join(dir, ".git");
30517
30635
  if (fs30.existsSync(dotGit)) {
30518
30636
  const admin = fs30.statSync(dotGit).isFile() ? gitDirsAt(dir, null, false)?.[0] : undefined;
30519
- 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)) };
30520
30638
  }
30521
- if (path48.dirname(dir) === dir)
30639
+ if (path49.dirname(dir) === dir)
30522
30640
  return null;
30523
30641
  }
30524
30642
  };
@@ -30530,8 +30648,8 @@ var workitWorktreeOf = (file) => {
30530
30648
  return null;
30531
30649
  }
30532
30650
  };
30533
- var bindingDir = () => path48.join(resolveStateDir(), "worktree-bind");
30534
- 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`);
30535
30653
  var readBinding = (file) => {
30536
30654
  try {
30537
30655
  const value = JSON.parse(fs30.readFileSync(file, "utf8"));
@@ -30556,7 +30674,7 @@ var bind = (input, worktree) => {
30556
30674
  agentId,
30557
30675
  at: new Date().toISOString()
30558
30676
  };
30559
- fs30.mkdirSync(path48.dirname(file), { recursive: true });
30677
+ fs30.mkdirSync(path49.dirname(file), { recursive: true });
30560
30678
  fs30.writeFileSync(file, JSON.stringify(binding));
30561
30679
  try {
30562
30680
  if (inWorkitWorkspace(input.cwd))
@@ -30575,26 +30693,26 @@ var hostIsolated = (cwd, agentId) => {
30575
30693
  const checkout = checkoutOf2(cwd);
30576
30694
  if (!checkout)
30577
30695
  return false;
30578
- const dotGit = path48.join(checkout.root, ".git");
30696
+ const dotGit = path49.join(checkout.root, ".git");
30579
30697
  if (!fs30.statSync(dotGit).isFile())
30580
30698
  return false;
30581
30699
  const [adminDir, gitDir] = gitDirsAt(checkout.root, null, false) ?? [];
30582
- const back = fs30.readFileSync(path48.join(adminDir, "gitdir"), "utf8").trim();
30583
- 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)) !== "")
30584
30702
  return false;
30585
- const expected = path48.join(path48.dirname(gitDir), ".claude", "worktrees", `agent-${agentId}`);
30586
- 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) === "";
30587
30705
  } catch {
30588
30706
  return false;
30589
30707
  }
30590
30708
  };
30591
30709
  var runnerAt = (target) => {
30592
- const base = path48.basename(target);
30710
+ const base = path49.basename(target);
30593
30711
  return base.startsWith(OPAQUE_TARGET) ? decodeURIComponent(base.slice(OPAQUE_TARGET.length)) : null;
30594
30712
  };
30595
30713
  var shown = (target) => {
30596
- const named = /^\.workit-(?:live-target$|runs-)/.test(path48.basename(target)) ? path48.dirname(target) : target;
30597
- 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;
30598
30716
  };
30599
30717
  var runFrom = (dir, command) => `cd ${dir} && ${command.replace(/^\s*cd\s+\S+\s*(?:&&|;)\s*/, "")}`;
30600
30718
  var deny2 = (what, unblock) => ({
@@ -30610,7 +30728,7 @@ var outsideDeny = (input, worktree, target, command) => {
30610
30728
  };
30611
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\`.`);
30612
30730
  var refsOf = (targets) => [
30613
- ...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)))
30614
30732
  ];
30615
30733
  var literalForm = (command, refs) => {
30616
30734
  let text = command;
@@ -30643,10 +30761,10 @@ function confineImplementer(input, targets, command) {
30643
30761
  try {
30644
30762
  if (!input.session.agentId || hostIsolated(input.cwd, input.session.agentId))
30645
30763
  return NONE5;
30646
- const unresolved = targets.filter((target) => within(path48.resolve(target), UNKNOWN_VAR));
30764
+ const unresolved = targets.filter((target) => within(path49.resolve(target), UNKNOWN_VAR));
30647
30765
  if (unresolved.length > 0)
30648
30766
  return unknownVarDeny(input, unresolved, command);
30649
- if (targets.some((target) => within(path48.resolve(target), UNKNOWN_DIR)))
30767
+ if (targets.some((target) => within(path49.resolve(target), UNKNOWN_DIR)))
30650
30768
  return unknownDirDeny(input, boundWorktree(input));
30651
30769
  const bindings = canonical6(bindingDir());
30652
30770
  const judged = targets.map((named) => ({ named, real: canonical6(named) })).filter(({ real }) => within(real, bindings) || checkoutOf2(real) !== null);
@@ -30753,10 +30871,10 @@ var INLINE = /^-[a-zA-Z]*[ceEpm]$|^--(?:eval|print|test|version|help)$|^-[hvV]$/
30753
30871
  var VALUED2 = /^-[WXIrC]$|^--(?:require|import|loader|conditions|input-type)$/;
30754
30872
  var commonDir = (root) => gitDirsAt(root, null, false)?.[1] ?? "";
30755
30873
  var inScratch = (real, repo) => {
30756
- for (let dir = real;path48.dirname(dir) !== dir; dir = path48.dirname(dir)) {
30757
- if (path48.basename(dir) !== SCRATCH)
30874
+ for (let dir = real;path49.dirname(dir) !== dir; dir = path49.dirname(dir)) {
30875
+ if (path49.basename(dir) !== SCRATCH)
30758
30876
  continue;
30759
- const root = path48.dirname(dir);
30877
+ const root = path49.dirname(dir);
30760
30878
  const checkout = checkoutOf2(root);
30761
30879
  if (checkout?.root === root && (repo === null || checkout.workit || commonDir(root) === repo))
30762
30880
  return true;
@@ -30766,7 +30884,7 @@ var inScratch = (real, repo) => {
30766
30884
  var inGitDir = (real) => real.split(/[\\/]/).includes(".git");
30767
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)$/;
30768
30886
  var literalIn = (value, repo, checkout = false) => {
30769
- if (/[$`]/.test(value) || !path48.isAbsolute(value))
30887
+ if (/[$`]/.test(value) || !path49.isAbsolute(value))
30770
30888
  return false;
30771
30889
  const real = canonical6(value);
30772
30890
  const root = checkout ? checkoutOf2(real)?.root : undefined;
@@ -30787,8 +30905,8 @@ var configEntries = (text) => {
30787
30905
  return entries;
30788
30906
  };
30789
30907
  function gitDirsAt(dir, repo, scan = true) {
30790
- for (let at = dir;; at = path48.dirname(at)) {
30791
- const dotGit = path48.join(at, ".git");
30908
+ for (let at = dir;; at = path49.dirname(at)) {
30909
+ const dotGit = path49.join(at, ".git");
30792
30910
  let gitDir = null;
30793
30911
  try {
30794
30912
  if (fs30.statSync(dotGit).isDirectory())
@@ -30797,19 +30915,19 @@ function gitDirsAt(dir, repo, scan = true) {
30797
30915
  const named = /^gitdir:\s*(.+?)\s*$/mu.exec(fs30.readFileSync(dotGit, "utf8"))?.[1];
30798
30916
  if (!named)
30799
30917
  return null;
30800
- gitDir = canonical6(path48.resolve(at, named));
30918
+ gitDir = canonical6(path49.resolve(at, named));
30801
30919
  }
30802
30920
  } catch (error) {
30803
30921
  if (error.code !== "ENOENT")
30804
30922
  return null;
30805
- 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))))
30806
30924
  gitDir = canonical6(at);
30807
30925
  }
30808
30926
  if (gitDir !== null) {
30809
- const common = path48.join(gitDir, "commondir");
30810
- 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;
30811
30929
  const dirs = [gitDir, shared];
30812
- 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")]) : []) {
30813
30931
  let text = "";
30814
30932
  try {
30815
30933
  text = fs30.readFileSync(config, "utf8");
@@ -30818,14 +30936,14 @@ function gitDirsAt(dir, repo, scan = true) {
30818
30936
  }
30819
30937
  for (const [key, value] of configEntries(text)) {
30820
30938
  if (key === "core.worktree")
30821
- dirs.push(canonical6(path48.resolve(gitDir, value)));
30939
+ dirs.push(canonical6(path49.resolve(gitDir, value)));
30822
30940
  else if (/^remote\..*\.url$/.test(key) ? !literalIn(value, repo, true) : !SAFE_KEY.test(key))
30823
30941
  return null;
30824
30942
  }
30825
30943
  }
30826
30944
  return dirs;
30827
30945
  }
30828
- if (path48.dirname(at) === at)
30946
+ if (path49.dirname(at) === at)
30829
30947
  return [];
30830
30948
  }
30831
30949
  }
@@ -30965,10 +31083,10 @@ var gitKind = (args, local = () => true) => {
30965
31083
  return GIT_VERBS[verb].startsWith("+") ? "write" : "read";
30966
31084
  };
30967
31085
  var remoteIn = (dir, name, repo) => {
30968
- 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;
30969
31087
  if (!shared)
30970
31088
  return false;
30971
- 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];
30972
31090
  return url !== undefined && literalIn(url, repo, true);
30973
31091
  };
30974
31092
  var judgeGit = (command, repo, cwd, depth = 0) => {
@@ -30982,7 +31100,7 @@ var judgeGit = (command, repo, cwd, depth = 0) => {
30982
31100
  const lead = [];
30983
31101
  while (/^\w+\+?=/.test(words[at] ?? ""))
30984
31102
  lead.push(words[at++]);
30985
- const name = path48.basename(words[at] ?? "");
31103
+ const name = path49.basename(words[at] ?? "");
30986
31104
  let start = words.findIndex((word) => /(?:^|[\\/])git(?:\.exe)?(?:=|$)/.test(word));
30987
31105
  if (start > at) {
30988
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] ?? ""))
@@ -30993,7 +31111,7 @@ var judgeGit = (command, repo, cwd, depth = 0) => {
30993
31111
  if (start >= 0 && words[start].includes("="))
30994
31112
  why = "git is redefined";
30995
31113
  const run = words[start] ?? "";
30996
- if (run.includes("/") && (!path48.isAbsolute(run) || literalIn(run, repo, true)))
31114
+ if (run.includes("/") && (!path49.isAbsolute(run) || literalIn(run, repo, true)))
30997
31115
  why ??= `\`${run}\` is not the system git`;
30998
31116
  if (segment.expands?.includes(at) && name !== "[" || /\{[^}]*,/.test(words[at] ?? ""))
30999
31117
  why = "the command's name is expanded by the shell";
@@ -31018,13 +31136,13 @@ var judgeGit = (command, repo, cwd, depth = 0) => {
31018
31136
  const args = words[index] === "--version" ? ["version"] : words.slice(index);
31019
31137
  if (!why && start >= 0) {
31020
31138
  const local = (source, remote) => remote && /^[\w-][\w.-]*$/.test(source) ? remoteIn(dir, source, repo) : literalIn(source, repo, true);
31021
- const runsIn = path48.isAbsolute(dir) ? dir : cwd && path48.resolve(cwd, dir);
31139
+ const runsIn = path49.isAbsolute(dir) ? dir : cwd && path49.resolve(cwd, dir);
31022
31140
  const home = runsIn && checkoutOf2(runsIn);
31023
31141
  const fetches = args[0] === "fetch" && plainFetch(args.slice(1)) && home && (home.workit || commonDir(home.root) === repo) && !words.some((word) => /^--[gw]/.test(word));
31024
31142
  if (!fetches && !gitKind(args, local))
31025
31143
  why = `\`git ${args.slice(0, 2).join(" ")}\` is not allowed`;
31026
31144
  }
31027
- 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)));
31028
31146
  const scripts = [
31029
31147
  ...words.filter((_, after) => shell >= 0 && after > shell && /^-[a-zA-Z]*c[a-zA-Z]*$/.test(words[after - 1])),
31030
31148
  ...shell < 0 ? [] : segment.stdin ?? []
@@ -31069,7 +31187,7 @@ var judgeVerbRefused = (args) => {
31069
31187
  var CLI_RUNNERS = /^(?:npx|bunx|pnpx|npm|pnpm|yarn|bun|node|nodejs|deno|tsx|ts-node)$/;
31070
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?$/;
31071
31189
  var workitCalls = (command, depth = 0, aliases = new Map) => depth > 4 ? [] : commandLines(command).flatMap((words) => {
31072
- const name = path48.basename(words[0] ?? "").toLowerCase();
31190
+ const name = path49.basename(words[0] ?? "").toLowerCase();
31073
31191
  if (name === "alias")
31074
31192
  return words.flatMap((word) => {
31075
31193
  const set = /^([\w-]+)=(.*)$/s.exec(word);
@@ -31098,11 +31216,11 @@ var judgeRefusal = (command, fed, depth = 0) => {
31098
31216
  return why;
31099
31217
  }
31100
31218
  const { words } = segment;
31101
- const runs = (word = "") => RUNS.test(path48.basename(word).toLowerCase());
31219
+ const runs = (word = "") => RUNS.test(path49.basename(word).toLowerCase());
31102
31220
  let at = 0;
31103
31221
  while (at < words.length && (LEADS.test(words[at]) || /^-\w$/.test(words[at - 1] ?? "") && !runs(words[at])))
31104
31222
  at++;
31105
- const name = path48.basename(words[at] ?? "").toLowerCase();
31223
+ const name = path49.basename(words[at] ?? "").toLowerCase();
31106
31224
  const args = words.slice(at + 1);
31107
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`;
31108
31226
  if (/^(?:cd|chdir|pushd|popd)$/.test(name))
@@ -31184,9 +31302,9 @@ var judgeDeny = (input, what, target, retry) => {
31184
31302
  const role = input.session.agentType?.endsWith("reviewer") ? "reviewer" : "verifier";
31185
31303
  const root = checkoutOf2(input.cwd)?.root;
31186
31304
  const candidate = target ? checkoutOf2(target)?.root : undefined;
31187
- const other = root && candidate && candidate !== root && commonDir(candidate) === commonDir(root) ? path48.join(candidate, SCRATCH) : undefined;
31188
- const scratch = root ? `${path48.join(root, SCRATCH)}${other ? ` or ${other}` : ""}` : `${SCRATCH}/ at the root of the checkout you judge`;
31189
- 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;
31190
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`).";
31191
31309
  return {
31192
31310
  kind: "deny",
@@ -31197,9 +31315,9 @@ ${unblock}`,
31197
31315
  };
31198
31316
  var movedInto = (command, cwd, target, dir) => {
31199
31317
  for (const { words, redirects } of segmentsOf(command))
31200
- for (const word of [...redirects, ...path48.basename(words[0] ?? "") === "tee" ? words : []])
31201
- if (path48.resolve(cwd, word) === path48.resolve(cwd, target)) {
31202
- 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)}`);
31203
31321
  return moved === command ? null : moved;
31204
31322
  }
31205
31323
  return null;
@@ -31211,19 +31329,19 @@ function confineJudge(input, targets, placeholders = placeholdersOf(targets), co
31211
31329
  const judged = checkoutOf2(input.cwd);
31212
31330
  const repo = judged ? commonDir(judged.root) : null;
31213
31331
  const scratch = (real) => inScratch(real, repo) || [os11.tmpdir(), "/tmp"].some((dir) => {
31214
- const [host, , session] = path48.relative(canonical6(dir), real).split(path48.sep);
31332
+ const [host, , session] = path49.relative(canonical6(dir), real).split(path49.sep);
31215
31333
  return /^claude-\d+$/.test(host) && session === input.session.id;
31216
31334
  });
31217
31335
  for (const target of targets) {
31218
- const resolved = path48.resolve(target);
31336
+ const resolved = path49.resolve(target);
31219
31337
  if (within(resolved, UNKNOWN_VAR) || within(resolved, UNKNOWN_DIR))
31220
31338
  return judgeDeny(input, "it writes to a path Workit cannot resolve", undefined, () => {
31221
31339
  const literal = command && literalForm(command, refsOf([target]));
31222
31340
  return literal === command ? null : literal;
31223
31341
  });
31224
31342
  const real = canonical6(target);
31225
- const runsGit = placeholders.has(target) && /^\.workit-(?:runs-git|live-target)$/.test(path48.basename(target));
31226
- 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) : [];
31227
31345
  if (gitDirs === null)
31228
31346
  return judgeDeny(input, `git in ${shown(target)} uses a git dir or config Workit cannot check`);
31229
31347
  if (runsGit ? gitDirs.length > 0 ? gitDirs.every(scratch) : scratch(real) : scratch(real) && !inGitDir(real))
@@ -31289,7 +31407,7 @@ function confineJudgeShell(input, command, dialect = "posix") {
31289
31407
  let git = [];
31290
31408
  try {
31291
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)))) ? [
31292
- 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`)
31293
31411
  ] : []);
31294
31412
  } catch {}
31295
31413
  const lists = [
@@ -31334,7 +31452,7 @@ var judgeChecksLine = (cwd) => {
31334
31452
 
31335
31453
  // packages/workit-core/src/hooks/standing.ts
31336
31454
  var readPlans = (store) => {
31337
- const dir = path49.join(store, "fanouts");
31455
+ const dir = path50.join(store, "fanouts");
31338
31456
  let names;
31339
31457
  try {
31340
31458
  names = fs31.readdirSync(dir).filter((name) => name.endsWith(".json"));
@@ -31344,7 +31462,7 @@ var readPlans = (store) => {
31344
31462
  const plans = [];
31345
31463
  for (const name of names) {
31346
31464
  try {
31347
- const raw = JSON.parse(fs31.readFileSync(path49.join(dir, name), "utf8"));
31465
+ const raw = JSON.parse(fs31.readFileSync(path50.join(dir, name), "utf8"));
31348
31466
  if (typeof raw.name !== "string" || !Array.isArray(raw.slices))
31349
31467
  continue;
31350
31468
  const texts = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string" && item !== "") : [];
@@ -31554,12 +31672,12 @@ var cdWorkitSplit = (command) => {
31554
31672
 
31555
31673
  // packages/workit-core/src/hooks/spawn-gate.ts
31556
31674
  import fs32 from "node:fs";
31557
- import path51 from "node:path";
31675
+ import path52 from "node:path";
31558
31676
 
31559
31677
  // packages/workit-core/src/hooks/model-limit.ts
31560
31678
  import { closeSync as closeSync4, openSync as openSync4, readdirSync as readdirSync7, readSync, statSync as statSync5 } from "node:fs";
31561
31679
  import os12 from "node:os";
31562
- import path50 from "node:path";
31680
+ import path51 from "node:path";
31563
31681
  var MONTHS = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
31564
31682
  var WEEKDAYS = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"];
31565
31683
  var TIME_WORD = String.raw`(?:\d|(?:in|at|on|later|tomorrow|soon)\b|(?:${[...WEEKDAYS, ...MONTHS].join("|")})[a-z]*\b)`;
@@ -31757,17 +31875,17 @@ var firstPrompt = (file) => {
31757
31875
  var claudeProjectSlug = (cwd) => cwd.replace(/[^A-Za-z0-9]/gu, "-");
31758
31876
  var listDir = (dir) => {
31759
31877
  try {
31760
- return readdirSync7(dir).map((name) => path50.join(dir, name));
31878
+ return readdirSync7(dir).map((name) => path51.join(dir, name));
31761
31879
  } catch {
31762
31880
  return [];
31763
31881
  }
31764
31882
  };
31765
31883
  var SCAN_MS = 30 * 60000;
31766
31884
  var scanClaudeTranscripts = (cwd, env, now = new Date) => {
31767
- const projects = path50.join(env.CLAUDE_CONFIG_DIR || path50.join(env.HOME || os12.homedir(), ".claude"), "projects");
31768
- 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));
31769
31887
  const notes = [];
31770
- 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 })));
31771
31889
  for (const { file, worker } of files)
31772
31890
  try {
31773
31891
  const stat = statSync5(file);
@@ -31782,7 +31900,7 @@ var scanClaudeTranscripts = (cwd, env, now = new Date) => {
31782
31900
  if (!seen)
31783
31901
  continue;
31784
31902
  notes.push(worker ? redispatchNote(seen, {
31785
- label: `worker ${path50.basename(file, ".jsonl")}`,
31903
+ label: `worker ${path51.basename(file, ".jsonl")}`,
31786
31904
  prompt: firstPrompt(file)
31787
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.`);
31788
31906
  } catch {}
@@ -31884,10 +32002,10 @@ var namesMade = (word) => {
31884
32002
  const stat = fs32.statSync(word);
31885
32003
  if (stat.isFile())
31886
32004
  return stat.size < 1e6 && MADE_WORKTREE.test(fs32.readFileSync(word, "utf8"));
31887
- const dotGit = path51.join(word, ".git");
32005
+ const dotGit = path52.join(word, ".git");
31888
32006
  const link = fs32.statSync(dotGit);
31889
32007
  const admin = link.isFile() && link.size <= 4096 && /^gitdir: *(.+)/u.exec(fs32.readFileSync(dotGit, "utf8"));
31890
- 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));
31891
32009
  } catch {
31892
32010
  return false;
31893
32011
  }
@@ -31933,8 +32051,8 @@ var spawnDecision = (descriptor, cwd, tool, permissionMode = null) => {
31933
32051
 
31934
32052
  // packages/workit-core/src/hooks/server-gate.ts
31935
32053
  import fs33 from "node:fs";
31936
- import path52 from "node:path";
31937
- 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`);
31938
32056
  var mb = (bytes) => `${Math.round(Number(bytes) / 1048576)} MB`;
31939
32057
  function takeProcNotice(session, env = process.env) {
31940
32058
  if (!session)
@@ -31972,21 +32090,21 @@ function takeProcNotice(session, env = process.env) {
31972
32090
  // packages/workit-core/src/hooks/teardown.ts
31973
32091
  import { spawn } from "node:child_process";
31974
32092
  import fs34 from "node:fs";
31975
- import path54 from "node:path";
32093
+ import path55 from "node:path";
31976
32094
 
31977
32095
  // packages/workit-core/src/core/cli-locate.ts
31978
32096
  import { closeSync as closeSync5, existsSync as existsSync18, openSync as openSync5, readSync as readSync2 } from "node:fs";
31979
- import path53 from "node:path";
32097
+ import path54 from "node:path";
31980
32098
  var LAUNCHER_MARKER = "workit-owned-launcher";
31981
32099
  var CLI_PACKAGE_PATH = ["node_modules", "@workit-dev", "cli"];
31982
32100
  var installRoot = (env, platform = process.platform) => {
31983
32101
  if (env.WORKIT_INSTALL_ROOT)
31984
32102
  return env.WORKIT_INSTALL_ROOT;
31985
32103
  const data = dataDir(env, platform);
31986
- return platform === "win32" ? path53.join(data, "install") : data;
32104
+ return platform === "win32" ? path54.join(data, "install") : data;
31987
32105
  };
31988
- var ownedLauncherPath = (env, platform = process.platform) => path53.join(installRoot(env, platform), "bin", platform === "win32" ? "workit.cmd" : "workit");
31989
- 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");
31990
32108
  var head = (file) => {
31991
32109
  let fd;
31992
32110
  try {
@@ -32013,7 +32131,7 @@ var locateWorkitCli = (options = {}) => {
32013
32131
  source: "owned-launcher",
32014
32132
  command: launcher,
32015
32133
  args: [],
32016
- binDir: path53.dirname(launcher)
32134
+ binDir: path54.dirname(launcher)
32017
32135
  };
32018
32136
  const current = ownedCurrentEntry(env, platform);
32019
32137
  if (exists(current))
@@ -32042,7 +32160,7 @@ var workitCliEnv = (located, env = process.env, platform = process.platform) =>
32042
32160
  if (located.binDir) {
32043
32161
  const key = pathKey(env);
32044
32162
  const delimiter = platform === "win32" ? ";" : ":";
32045
- 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);
32046
32164
  const rest = (env[key] ?? "").split(delimiter).filter((dir) => dir && !same(dir));
32047
32165
  patch[key] = [located.binDir, ...rest].join(delimiter);
32048
32166
  }
@@ -32066,9 +32184,9 @@ var ENDS = {
32066
32184
  };
32067
32185
  var SAFE_SESSION = /^[\w.@+][\w.:@/+-]{0,127}$/u;
32068
32186
  var HOST_SESSION_VARS2 = ["OPENCODE_SESSION_ID", "PI_SESSION_ID", "CODEX_THREAD_ID"];
32069
- var teardownDir = (env) => path54.join(stateDir(env), "procs");
32070
- var teardownLog = (env) => path54.join(teardownDir(env), "teardown.log");
32071
- 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");
32072
32190
  function spawnDetached(request) {
32073
32191
  try {
32074
32192
  const shell = process.platform === "win32" && !/\.exe$/iu.test(request.command);
@@ -32095,7 +32213,7 @@ var teardownDeps = {
32095
32213
  var openLog = (env, args) => {
32096
32214
  try {
32097
32215
  const file = teardownLog(env);
32098
- fs34.mkdirSync(path54.dirname(file), { recursive: true });
32216
+ fs34.mkdirSync(path55.dirname(file), { recursive: true });
32099
32217
  let size = 0;
32100
32218
  try {
32101
32219
  size = fs34.statSync(file).size;
@@ -32180,7 +32298,7 @@ function reapAtStart(_cwd, env = process.env) {
32180
32298
  try {
32181
32299
  if (fresh(stamp, now))
32182
32300
  return false;
32183
- fs34.mkdirSync(path54.dirname(stamp), { recursive: true });
32301
+ fs34.mkdirSync(path55.dirname(stamp), { recursive: true });
32184
32302
  if (!claim2(lock, now))
32185
32303
  return false;
32186
32304
  } catch {
@@ -33195,10 +33313,10 @@ var modelKey = (model) => {
33195
33313
  // packages/workit-core/src/hooks/budget-signal.ts
33196
33314
  import { createHash as createHash24 } from "node:crypto";
33197
33315
  import fs35 from "node:fs";
33198
- import path55 from "node:path";
33316
+ import path56 from "node:path";
33199
33317
  var hash2 = (text) => createHash24("sha256").update(text).digest("hex").slice(0, 32);
33200
- var budgetDir = (store) => path55.join(store, "budget");
33201
- 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 ?? ""}`));
33202
33320
  var spawnBudget = (prompt) => {
33203
33321
  const found = /^TIMEBOX:[^\n]*?\b(\d+)\s+tool calls\b/mu.exec(prompt);
33204
33322
  const n = found ? Number(found[1]) : NaN;
@@ -33218,8 +33336,8 @@ var startBudget = (store, session, agentId, n) => {
33218
33336
  const cutoff = Date.now() - 604800000;
33219
33337
  for (const name of fs35.readdirSync(dir))
33220
33338
  try {
33221
- if (fs35.statSync(path55.join(dir, name)).mtimeMs < cutoff)
33222
- fs35.rmSync(path55.join(dir, name));
33339
+ if (fs35.statSync(path56.join(dir, name)).mtimeMs < cutoff)
33340
+ fs35.rmSync(path56.join(dir, name));
33223
33341
  } catch {}
33224
33342
  const base = agentBase(store, session, agentId);
33225
33343
  fs35.writeFileSync(`${base}.json`, JSON.stringify({ limit: n, told: 0 }));
@@ -33674,12 +33792,12 @@ var skillPromptNudge = (prompt, ctx) => process.env.WORKIT_PI_WORKER_SESSION ? n
33674
33792
  // packages/workit-pi/src/launches.ts
33675
33793
  import { mkdirSync as mkdirSync8, readFileSync as readFileSync16, readdirSync as readdirSync8, rmSync as rmSync4, writeFileSync as writeFileSync7 } from "node:fs";
33676
33794
  import os13 from "node:os";
33677
- import path56 from "node:path";
33795
+ import path57 from "node:path";
33678
33796
  var launchDir = (root) => {
33679
33797
  const location = resolveStore(root);
33680
- return location instanceof Error ? null : path56.join(location.dir, "pi-launches");
33798
+ return location instanceof Error ? null : path57.join(location.dir, "pi-launches");
33681
33799
  };
33682
- 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`);
33683
33801
  var recordLaunch = (root, attempt) => {
33684
33802
  const dir = launchDir(root);
33685
33803
  if (!dir)
@@ -33725,7 +33843,7 @@ var abandonedLaunches = (root) => {
33725
33843
  const found = [];
33726
33844
  for (const name of names) {
33727
33845
  try {
33728
- const attempt = JSON.parse(readFileSync16(path56.join(dir, name), "utf8"));
33846
+ const attempt = JSON.parse(readFileSync16(path57.join(dir, name), "utf8"));
33729
33847
  if (typeof attempt.workerId === "string" && typeof attempt.session === "string") {
33730
33848
  if (!alive(attempt))
33731
33849
  found.push(attempt);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/pi",
3
- "version": "2.25.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",