@workit-dev/codex 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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "workit",
3
- "version": "2.24.0",
3
+ "version": "2.25.1",
4
4
  "description": "Adaptive engineering workflow rails for Codex",
5
5
  "author": {
6
6
  "name": "BrainerVirus"
@@ -14836,6 +14836,7 @@ var workspaceConfigSchema = looseObject({
14836
14836
  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`."),
14837
14837
  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.'),
14838
14838
  liveSessionGuard: described(optional(boolean2()), "Whether the live-session guard denies edits in a checkout another live agent session owns (default true)."),
14839
+ 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."),
14839
14840
  fanout: described(optional(looseObject({
14840
14841
  tierModels: described(optional(unknown()), "The model per slice TIER (mundane, standard, hard), as one name or per host."),
14841
14842
  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."),
@@ -32217,6 +32218,8 @@ var CLOSES = new Set(["fi", "done", "}"]);
32217
32218
  var UNFOLLOWED = new Set(["case", "esac", "select", "function"]);
32218
32219
  var TRANSPARENT = new Set(["builtin", "command", "time", "!"]);
32219
32220
  var UNKNOWN_VAR = path35.resolve(path35.parse(process.cwd()).root, ".workit-unknown-var");
32221
+ // packages/workit-core/src/core/verdict-set.ts
32222
+ var SET_TTL_MS = 7 * 86400000;
32220
32223
  // packages/workit-core/src/core/skill-manifests.ts
32221
32224
  if (false) {}
32222
32225
 
@@ -4183,6 +4183,7 @@ var workspaceConfigSchema = looseObject({
4183
4183
  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`."),
4184
4184
  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.'),
4185
4185
  liveSessionGuard: described(optional(boolean2()), "Whether the live-session guard denies edits in a checkout another live agent session owns (default true)."),
4186
+ 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."),
4186
4187
  fanout: described(optional(looseObject({
4187
4188
  tierModels: described(optional(unknown()), "The model per slice TIER (mundane, standard, hard), as one name or per host."),
4188
4189
  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."),
@@ -18205,6 +18206,58 @@ var linkSources = (args, at) => {
18205
18206
  return resolved ? [resolved] : [];
18206
18207
  });
18207
18208
  };
18209
+ var commandName2 = (word) => (word.split(/[\\/]/).at(-1) ?? "").toLowerCase();
18210
+ var fedRuns = (words, fed) => {
18211
+ const run = words.slice(Math.max(0, words.findIndex((word) => word === "xargs" || !PREFIXES2.has(word))));
18212
+ const name = commandName2(run[0] ?? "");
18213
+ if (name === "xargs")
18214
+ return xargsCommands(run, fed);
18215
+ if (name !== "parallel")
18216
+ return [run];
18217
+ return parallelCommands(fed === undefined || run.includes(":::") ? run : [...run, ":::", ...fed.split(`
18218
+ `).filter(Boolean)]);
18219
+ };
18220
+ var windowsScript = (input, stdin) => {
18221
+ const words = input.slice(Math.max(0, input.findIndex((word) => !PREFIXES2.has(word))));
18222
+ const name = commandName2(words[0] ?? "").replace(/\.exe$/, "");
18223
+ if (name === "cmd")
18224
+ return cmdScript(words);
18225
+ return name === "pwsh" || name === "powershell" ? powershellScript(words, stdin) : null;
18226
+ };
18227
+ var WINDOWS_LINK_TYPE = /^(?:symboliclink|junction|hardlink)$/i;
18228
+ var linkReach = (verb, args, at, atAll) => {
18229
+ const all = (files) => files.flatMap((file) => atAll(file));
18230
+ const names = operands(args);
18231
+ if (verb === "mount" || verb === "bindfs")
18232
+ return all(names);
18233
+ if (verb === "ln" || verb === "cp" && args.some((arg) => /^-[a-zA-Z]*[ls]|^--(?:link|symbolic-link)$/.test(arg)))
18234
+ return [...linkSources(args, at), ...all(names.length < 2 ? names : names.slice(0, -1))];
18235
+ if (verb === "install") {
18236
+ const flag = args.findIndex((arg) => arg.startsWith("-l"));
18237
+ if (flag < 0)
18238
+ return [];
18239
+ const rest = operands(args.filter((_, index) => index !== flag && (args[flag] !== "-l" || index !== flag + 1)));
18240
+ return all(rest.slice(0, -1));
18241
+ }
18242
+ if (verb === "rsync") {
18243
+ const dest = names.at(-1);
18244
+ return args.flatMap((arg, index) => {
18245
+ const match = /^--link-dest(?:=(.*))?$/s.exec(arg);
18246
+ const dir = match ? match[1] ?? args[index + 1] : undefined;
18247
+ if (!dir)
18248
+ return [];
18249
+ return [...atAll(dir), ...dest && !path30.isAbsolute(dir) ? atAll(path30.join(dest, dir)) : []];
18250
+ });
18251
+ }
18252
+ if (verb === "mklink")
18253
+ return all(args.filter((arg) => !/^\/[dhj]$/i.test(arg)));
18254
+ if ((verb === "new-item" || verb === "ni") && args.some((arg) => WINDOWS_LINK_TYPE.test(arg.replace(/^-[\w-]+:/, ""))))
18255
+ return all(args.flatMap((arg) => {
18256
+ const value = arg.startsWith("-") ? /^-[\w-]+:(.+)$/s.exec(arg)?.[1] : arg;
18257
+ return value && !WINDOWS_LINK_TYPE.test(value) ? [value] : [];
18258
+ }));
18259
+ return [];
18260
+ };
18208
18261
  var shellWrites = (command, depth = 0) => {
18209
18262
  const targets = [];
18210
18263
  let unknown = false;
@@ -18313,6 +18366,7 @@ var recording = (make) => {
18313
18366
  var placeholdersOf = (targets) => PLACEHOLDERS.get(targets) ?? new Set;
18314
18367
  var OPAQUE_TARGET = ".workit-runs-";
18315
18368
  var UNRESOLVED_TARGET = ".workit-unresolved-target";
18369
+ var LINK_SOURCE = ".workit-link-source";
18316
18370
  var OVERRIDE = "WORKIT_LIVE_SESSION=override";
18317
18371
  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("--"));
18318
18372
  var gitMutationDirs = (cwd, command, dialect) => {
@@ -18714,6 +18768,10 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
18714
18768
  if (inner !== null && dir !== undefined)
18715
18769
  for (const runIn of workitRunDir(dir, words, atAll))
18716
18770
  targets.push(...segmentTargets(runIn, inner, "posix", depth + 1, strict, runIn === dir ? vars : unPwd()));
18771
+ const windows = strict && depth < 4 ? windowsScript(words, segment.stdin?.join(`
18772
+ `)) : null;
18773
+ if (windows !== null && dir !== undefined)
18774
+ targets.push(...segmentTargets(dir, windows, "powershell", depth + 1, strict, vars));
18717
18775
  const bare = strict === "registry" && depth < 4 ? unwrapped2(words) : null;
18718
18776
  if (bare?.length && dir !== undefined)
18719
18777
  targets.push(...segmentTargets(dir, bare.flatMap((word) => expansions(word, vars, loops)).map(quoteWord2).join(" "), "posix", depth + 1, strict, vars));
@@ -18789,9 +18847,11 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
18789
18847
  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"))))
18790
18848
  for (const file of operands(args))
18791
18849
  targets.push(...atAll(file));
18792
- if (verb === "cp" && args.some((arg) => /^-[a-zA-Z]*l|^--link$/.test(arg)))
18793
- for (const file of operands(args).slice(0, -1))
18794
- targets.push(...atAll(file));
18850
+ const feed = fed === undefined && !piped.length ? undefined : [fed, ...piped].join(`
18851
+ `);
18852
+ for (const [linker = "", ...rest] of fedRuns(words, feed))
18853
+ for (const source of linkReach(commandName2(linker), rest, at, atAll))
18854
+ targets.push(path30.join(source, LINK_SOURCE));
18795
18855
  }
18796
18856
  if (strict && dir !== undefined) {
18797
18857
  const runIn = dir;
@@ -18987,19 +19047,42 @@ var hardLinked = (file, state, configs, inodes) => {
18987
19047
  return;
18988
19048
  }
18989
19049
  };
19050
+ var inRepoLedger = (file) => [...file.matchAll(/[\\/]workit[\\/]ledger(?=[\\/]|$)/g)].some(({ index }) => {
19051
+ const gitDir = file.slice(0, index);
19052
+ return /(?:^|[\\/])\.git$/.test(gitDir) || existsSync12(path30.join(gitDir, "HEAD")) && existsSync12(path30.join(gitDir, "objects"));
19053
+ });
19054
+ var holdsGuarded = (cwd, source, state, configs) => {
19055
+ const real = canonical5(source);
19056
+ const below = (parent, child) => {
19057
+ const rel = path30.relative(parent, child);
19058
+ return rel === "" || !rel.startsWith("..") && !path30.isAbsolute(rel);
19059
+ };
19060
+ const holds = (file) => below(real, canonical5(file));
19061
+ const inState = path30.relative(canonical5(state), real).split(path30.sep);
19062
+ const ledgers = ["ledger", "workit/ledger", ".git/workit/ledger"].map((rel) => path30.join(real, rel)).filter((dir) => existsSync12(dir) && inRepoLedger(dir));
19063
+ const own = ledgerPath(cwd);
19064
+ return holds(state) || below(canonical5(state), real) && inState[0] === "folders" && inState.length <= 2 || configs.some(holds) || ledgers.length > 0 || own.ok && existsSync12(own.value) && holds(path30.dirname(own.value));
19065
+ };
18990
19066
  var registryTarget = (cwd, targets) => {
18991
19067
  const state = resolveStateDir();
18992
19068
  const configs = configDirs();
18993
19069
  const inodes = {};
18994
19070
  for (const target of targets) {
18995
19071
  const file = homeExpanded(target);
19072
+ if (path30.basename(file) === LINK_SOURCE) {
19073
+ const source = path30.dirname(path30.resolve(cwd, file));
19074
+ const reached = registryTarget(cwd, [source])?.registry ?? (holdsGuarded(cwd, source, state, configs) ? "holds" : null);
19075
+ if (reached)
19076
+ return { file: target, registry: reached };
19077
+ continue;
19078
+ }
18996
19079
  if (realPath(path30.resolve(cwd, file)) === null)
18997
19080
  return { file: target, registry: "link" };
18998
19081
  const glob = globbed(cwd, file, state, configs)[0];
18999
19082
  const viaGlob = glob === undefined ? null : registryTarget(cwd, [glob]);
19000
19083
  if (viaGlob)
19001
19084
  return { file: target, registry: viaGlob.registry };
19002
- const registry = hardLinked(path30.resolve(cwd, file), state, configs, inodes) ?? underRegistry(state, cwd, file, process.platform, canonical5) ?? (/[\\/]\.git[\\/]workit[\\/]ledger(?:[\\/]|$)/.test(canonical5(path30.resolve(cwd, file))) ? "ledger" : null) ?? (configs.some((dir) => underConfig(dir, cwd, file, process.platform, canonical5)) ? "grants" : null);
19085
+ const registry = hardLinked(path30.resolve(cwd, file), state, configs, inodes) ?? underRegistry(state, cwd, file, process.platform, canonical5) ?? (inRepoLedger(canonical5(path30.resolve(cwd, file))) ? "ledger" : null) ?? (configs.some((dir) => underConfig(dir, cwd, file, process.platform, canonical5)) ? "grants" : null);
19003
19086
  if (registry)
19004
19087
  return { file: target, registry };
19005
19088
  }
@@ -19026,6 +19109,7 @@ var underConfig = (dir, cwd, target, platform = process.platform, real = (file)
19026
19109
  const parts = partsUnder(dir, cwd, target, platform, real);
19027
19110
  return parts?.length === 1 && ["", ...CONFIG_FILES, DIR_TARGET, UNRESOLVED_TARGET].includes(parts[0]);
19028
19111
  };
19112
+ var windowsSlashed = (command, platform = process.platform) => platform === "win32" && command.includes("\\") ? command.replace(/[^\s'"|;&<>()]*\\[^\s'"|;&<>()]*/g, (word) => word.replaceAll("\\", "/")) : null;
19029
19113
  var unquotedWindowsRegistry = (command, platform = process.platform) => {
19030
19114
  if (platform !== "win32" || !command.includes("\\"))
19031
19115
  return null;
@@ -19034,28 +19118,36 @@ var unquotedWindowsRegistry = (command, platform = process.platform) => {
19034
19118
  const state = flat(resolveStateDir());
19035
19119
  const configs = configDirs().map(flat);
19036
19120
  const folders = `${state}/folders/`;
19037
- 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));
19038
- const registry = text.includes(`${state}/issued`) ? "issued" : text.includes(`${state}/approvals`) ? "approvals" : ledger(text) ? "ledger" : configs.some((dir) => text.includes(dir)) ? "grants" : null;
19039
- if (!registry)
19121
+ 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));
19122
+ const present = ["issued", "approvals", "ledger", "grants"].filter((kind) => kind === "ledger" ? ledger(text) : kind === "grants" ? configs.some((dir) => text.includes(dir)) : text.includes(`${state}/${kind}`));
19123
+ if (!present.length)
19040
19124
  return null;
19041
- const spans = command.replace(/[^\s'"|;&<>()]*\\[^\s'"|;&<>()]*/g, (word) => word.replaceAll("\\", "/"));
19125
+ const spans = windowsSlashed(command, platform) ?? command;
19042
19126
  const writes = shellWrites(spans);
19127
+ if (!writes.writes)
19128
+ return null;
19043
19129
  const moved = [
19044
19130
  "",
19045
19131
  ...[...spans.matchAll(/(?:^|[;&|(]\s*)(?:cd|pushd|chdir)\s+([^\s;&|)]+)/g)].map((match) => `${match[1]}/`)
19046
19132
  ];
19047
- const named = (target) => moved.some((dir) => {
19133
+ const named = (registry, target) => moved.some((dir) => {
19048
19134
  const at = flat(/^(?:[a-z]:)?\//i.test(target) ? target : dir + target).replace(/\/\.?\//g, "/");
19049
- return registry === "grants" ? configs.some((cfg) => [cfg, `${cfg}/`, ...CONFIG_FILES.map((name) => `${cfg}/${name}`)].includes(at)) : registry === "ledger" ? ledger(at) : at.includes(`${state}/${registry}`);
19135
+ 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}`);
19050
19136
  });
19051
- return writes.writes && (writes.targets === null || writes.targets.some(named)) ? registry : null;
19137
+ return present.find((registry) => writes.targets === null || writes.targets.some((target) => named(registry, target))) ?? null;
19052
19138
  };
19139
+ 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.";
19053
19140
  var REGISTRY_DENY = {
19054
19141
  link: {
19055
19142
  label: "registry guard",
19056
19143
  what: "a symlink chain Workit could not resolve (over 40 links), which may reach a guarded path",
19057
19144
  unblock: "Write to the file's real path."
19058
19145
  },
19146
+ holds: {
19147
+ label: "registry guard",
19148
+ what: "Workit's state, its config or a repository ledger",
19149
+ unblock: LINK_UNBLOCK
19150
+ },
19059
19151
  issued: {
19060
19152
  label: "issued-registry guard",
19061
19153
  what: "Workit's issued-session state",
@@ -19079,6 +19171,12 @@ var REGISTRY_DENY = {
19079
19171
  };
19080
19172
  var registryDeny = ({ file, registry }) => {
19081
19173
  const { label, what, unblock } = REGISTRY_DENY[registry];
19174
+ if (path30.basename(file) === LINK_SOURCE)
19175
+ return {
19176
+ kind: "deny",
19177
+ reason: `workit ${label}: this command links or mounts ${path30.dirname(file)}, which is or holds ${what}. ${LINK_UNBLOCK}`,
19178
+ unblock: LINK_UNBLOCK
19179
+ };
19082
19180
  if (path30.basename(file) === UNRESOLVED_TARGET)
19083
19181
  return {
19084
19182
  kind: "deny",
@@ -19110,7 +19208,8 @@ function writeGate(cwd, paths, owner, deps) {
19110
19208
  function shellGate(cwd, command, owner, dialect = "posix", deps) {
19111
19209
  try {
19112
19210
  const windows = unquotedWindowsRegistry(command);
19113
- const forged = registryTarget(cwd, shellMutationTargets(cwd, command, dialect, "registry")) ?? (windows ? { file: `the ${windows} registry`, registry: windows } : null);
19211
+ const slashed = dialect === "posix" ? windowsSlashed(command) : null;
19212
+ 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);
19114
19213
  if (forged)
19115
19214
  return registryDeny(forged);
19116
19215
  } catch {
@@ -19249,6 +19348,26 @@ function currentJudgment(cwd) {
19249
19348
  }
19250
19349
  }
19251
19350
 
19351
+ // packages/workit-core/src/core/verdict-set.ts
19352
+ import path32 from "node:path";
19353
+ var SET_TTL_MS = 7 * 86400000;
19354
+ var SET_VOID = "verdict.set.voided";
19355
+ var setStorePath = () => path32.join(resolveStateDir(), "verdicts", "sets", "ledger.jsonl");
19356
+ function gateStands(cwd, gate, rows, now = Date.now()) {
19357
+ const id = typeof gate.verdictId === "string" ? gate.verdictId : null;
19358
+ if (id !== null && verdictVoids(rows).has(id))
19359
+ return false;
19360
+ if (gate.via !== "set")
19361
+ return true;
19362
+ const until = typeof gate.expires === "string" ? Date.parse(gate.expires) : Date.parse(gate.at) + SET_TTL_MS;
19363
+ if (!(until > now))
19364
+ return false;
19365
+ if (id === null)
19366
+ return true;
19367
+ const read = readLedgerAt(cwd, setStorePath(), { integrity: true });
19368
+ return read.ok && !read.value.rows.some((row) => row.type === SET_VOID && row.target === id && row.integrity === "verified");
19369
+ }
19370
+
19252
19371
  // packages/workit-core/src/hooks/stop.ts
19253
19372
  var NONE4 = { kind: "none" };
19254
19373
  var QUESTION = /[??؟](?=[\s*_`"')\]>]*(?:\s|$))|¿/;
@@ -19362,7 +19481,7 @@ var unverified = (cwd, branch, all, descriptor, verification, head) => {
19362
19481
  const check = checkVerdicts(cwd, branch, all);
19363
19482
  if (check.accepted.accepted || check.accepted.reasons.includes("failing_verdict"))
19364
19483
  return null;
19365
- if (all.some((row) => row.type === "pr.gate" && row.branch === branch && row.head === check.head))
19484
+ if (all.some((row) => row.type === "pr.gate" && row.branch === branch && row.head === check.head && gateStands(cwd, row, all)))
19366
19485
  return null;
19367
19486
  const judgment = currentJudgment(cwd);
19368
19487
  const high = judgment?.riskTier === "high";
@@ -19683,12 +19802,12 @@ ${line}` };
19683
19802
  };
19684
19803
  // packages/workit-core/src/hooks/hosts/fields.ts
19685
19804
  import { existsSync as existsSync13, realpathSync as realpathSync9, statSync as statSync4 } from "node:fs";
19686
- import path32 from "node:path";
19805
+ import path33 from "node:path";
19687
19806
  var isRecord7 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
19688
19807
  var nonEmpty2 = (value) => typeof value === "string" && value.trim() !== "";
19689
19808
  var optionalText = (value) => typeof value === "string" ? value : null;
19690
19809
  var existingDirectory = (value) => {
19691
- if (!nonEmpty2(value) || !path32.isAbsolute(value) || !existsSync13(value))
19810
+ if (!nonEmpty2(value) || !path33.isAbsolute(value) || !existsSync13(value))
19692
19811
  return null;
19693
19812
  try {
19694
19813
  return statSync4(value).isDirectory() ? realpathSync9(value) : null;
@@ -19756,7 +19875,7 @@ var writeTargets = (input) => {
19756
19875
  };
19757
19876
  // packages/workit-core/src/hooks/standing.ts
19758
19877
  import fs23 from "node:fs";
19759
- import path34 from "node:path";
19878
+ import path35 from "node:path";
19760
19879
 
19761
19880
  // packages/workit-core/src/approvals/store.ts
19762
19881
  var REQUEST_TTL_MS = 30 * 60000;
@@ -20464,35 +20583,35 @@ function neededChecks(lane, configured) {
20464
20583
  import { createHash as createHash16 } from "node:crypto";
20465
20584
  import fs22 from "node:fs";
20466
20585
  import os10 from "node:os";
20467
- import path33 from "node:path";
20586
+ import path34 from "node:path";
20468
20587
  var FANOUT_TOKEN_FILE = "workit-fanout-token";
20469
20588
  var NONE5 = { kind: "none" };
20470
20589
  var CASE_INSENSITIVE2 = process.platform === "darwin" || process.platform === "win32";
20471
20590
  var realOf = (file) => {
20472
20591
  let rest = "";
20473
- for (let dir = file;; dir = path33.dirname(dir)) {
20592
+ for (let dir = file;; dir = path34.dirname(dir)) {
20474
20593
  try {
20475
- return path33.join(fs22.realpathSync.native(dir), rest);
20594
+ return path34.join(fs22.realpathSync.native(dir), rest);
20476
20595
  } catch {
20477
- if (path33.dirname(dir) === dir)
20596
+ if (path34.dirname(dir) === dir)
20478
20597
  return file;
20479
- rest = rest ? path33.join(path33.basename(dir), rest) : path33.basename(dir);
20598
+ rest = rest ? path34.join(path34.basename(dir), rest) : path34.basename(dir);
20480
20599
  }
20481
20600
  }
20482
20601
  };
20483
20602
  var canonical6 = (file, hops = { chain: 40, total: 1000 }) => {
20484
- const start = path33.isAbsolute(file) ? file : `${process.cwd()}${path33.sep}${file}`;
20485
- const { root } = path33.parse(start);
20603
+ const start = path34.isAbsolute(file) ? file : `${process.cwd()}${path34.sep}${file}`;
20604
+ const { root } = path34.parse(start);
20486
20605
  let at = root;
20487
20606
  let missing = false;
20488
20607
  for (const part of start.slice(root.length).split(/[\\/]+/)) {
20489
20608
  if (part === "" || part === ".")
20490
20609
  continue;
20491
20610
  if (part === "..") {
20492
- at = path33.dirname(at);
20611
+ at = path34.dirname(at);
20493
20612
  continue;
20494
20613
  }
20495
- const next = path33.join(at, part);
20614
+ const next = path34.join(at, part);
20496
20615
  let link = null;
20497
20616
  if (!missing)
20498
20617
  try {
@@ -20504,25 +20623,25 @@ var canonical6 = (file, hops = { chain: 40, total: 1000 }) => {
20504
20623
  at = next;
20505
20624
  hops.chain = 40;
20506
20625
  } else if (hops.chain-- > 0 && hops.total-- > 0)
20507
- at = canonical6(path33.isAbsolute(link) ? link : `${at}${path33.sep}${link}`, hops);
20626
+ at = canonical6(path34.isAbsolute(link) ? link : `${at}${path34.sep}${link}`, hops);
20508
20627
  else
20509
- return path33.resolve(file);
20628
+ return path34.resolve(file);
20510
20629
  }
20511
20630
  return realOf(at);
20512
20631
  };
20513
20632
  var within = (child, parent) => {
20514
20633
  const fold = (value) => CASE_INSENSITIVE2 ? value.toLowerCase() : value;
20515
- const relative = path33.relative(fold(parent), fold(child));
20516
- return relative === "" || !relative.startsWith("..") && !path33.isAbsolute(relative);
20634
+ const relative = path34.relative(fold(parent), fold(child));
20635
+ return relative === "" || !relative.startsWith("..") && !path34.isAbsolute(relative);
20517
20636
  };
20518
20637
  var checkoutOf2 = (file) => {
20519
- for (let dir = canonical6(file);; dir = path33.dirname(dir)) {
20520
- const dotGit = path33.join(dir, ".git");
20638
+ for (let dir = canonical6(file);; dir = path34.dirname(dir)) {
20639
+ const dotGit = path34.join(dir, ".git");
20521
20640
  if (fs22.existsSync(dotGit)) {
20522
20641
  const admin = fs22.statSync(dotGit).isFile() ? gitDirsAt(dir, null, false)?.[0] : undefined;
20523
- return { root: dir, workit: !!admin && fs22.existsSync(path33.join(admin, FANOUT_TOKEN_FILE)) };
20642
+ return { root: dir, workit: !!admin && fs22.existsSync(path34.join(admin, FANOUT_TOKEN_FILE)) };
20524
20643
  }
20525
- if (path33.dirname(dir) === dir)
20644
+ if (path34.dirname(dir) === dir)
20526
20645
  return null;
20527
20646
  }
20528
20647
  };
@@ -20534,8 +20653,8 @@ var workitWorktreeOf = (file) => {
20534
20653
  return null;
20535
20654
  }
20536
20655
  };
20537
- var bindingDir = () => path33.join(resolveStateDir(), "worktree-bind");
20538
- var bindingFile = (session, agentId) => path33.join(bindingDir(), `${createHash16("sha256").update(`${session}\x00${agentId}`).digest("hex").slice(0, 32)}.json`);
20656
+ var bindingDir = () => path34.join(resolveStateDir(), "worktree-bind");
20657
+ var bindingFile = (session, agentId) => path34.join(bindingDir(), `${createHash16("sha256").update(`${session}\x00${agentId}`).digest("hex").slice(0, 32)}.json`);
20539
20658
  var readBinding = (file) => {
20540
20659
  try {
20541
20660
  const value = JSON.parse(fs22.readFileSync(file, "utf8"));
@@ -20560,7 +20679,7 @@ var bind = (input, worktree) => {
20560
20679
  agentId,
20561
20680
  at: new Date().toISOString()
20562
20681
  };
20563
- fs22.mkdirSync(path33.dirname(file), { recursive: true });
20682
+ fs22.mkdirSync(path34.dirname(file), { recursive: true });
20564
20683
  fs22.writeFileSync(file, JSON.stringify(binding));
20565
20684
  try {
20566
20685
  if (inWorkitWorkspace(input.cwd))
@@ -20579,26 +20698,26 @@ var hostIsolated = (cwd, agentId) => {
20579
20698
  const checkout = checkoutOf2(cwd);
20580
20699
  if (!checkout)
20581
20700
  return false;
20582
- const dotGit = path33.join(checkout.root, ".git");
20701
+ const dotGit = path34.join(checkout.root, ".git");
20583
20702
  if (!fs22.statSync(dotGit).isFile())
20584
20703
  return false;
20585
20704
  const [adminDir, gitDir] = gitDirsAt(checkout.root, null, false) ?? [];
20586
- const back = fs22.readFileSync(path33.join(adminDir, "gitdir"), "utf8").trim();
20587
- if (path33.relative(canonical6(path33.resolve(adminDir, back)), canonical6(dotGit)) !== "")
20705
+ const back = fs22.readFileSync(path34.join(adminDir, "gitdir"), "utf8").trim();
20706
+ if (path34.relative(canonical6(path34.resolve(adminDir, back)), canonical6(dotGit)) !== "")
20588
20707
  return false;
20589
- const expected = path33.join(path33.dirname(gitDir), ".claude", "worktrees", `agent-${agentId}`);
20590
- return path33.relative(canonical6(expected), checkout.root) === "";
20708
+ const expected = path34.join(path34.dirname(gitDir), ".claude", "worktrees", `agent-${agentId}`);
20709
+ return path34.relative(canonical6(expected), checkout.root) === "";
20591
20710
  } catch {
20592
20711
  return false;
20593
20712
  }
20594
20713
  };
20595
20714
  var runnerAt = (target) => {
20596
- const base = path33.basename(target);
20715
+ const base = path34.basename(target);
20597
20716
  return base.startsWith(OPAQUE_TARGET) ? decodeURIComponent(base.slice(OPAQUE_TARGET.length)) : null;
20598
20717
  };
20599
20718
  var shown = (target) => {
20600
- const named = /^\.workit-(?:live-target$|runs-)/.test(path33.basename(target)) ? path33.dirname(target) : target;
20601
- return path33.sep === "\\" ? named.replaceAll("/", "\\") : named;
20719
+ const named = /^\.workit-(?:live-target$|runs-)/.test(path34.basename(target)) ? path34.dirname(target) : target;
20720
+ return path34.sep === "\\" ? named.replaceAll("/", "\\") : named;
20602
20721
  };
20603
20722
  var runFrom = (dir, command) => `cd ${dir} && ${command.replace(/^\s*cd\s+\S+\s*(?:&&|;)\s*/, "")}`;
20604
20723
  var deny2 = (what, unblock) => ({
@@ -20614,7 +20733,7 @@ var outsideDeny = (input, worktree, target, command) => {
20614
20733
  };
20615
20734
  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\`.`);
20616
20735
  var refsOf = (targets) => [
20617
- ...new Set(targets.flatMap((target) => path33.relative(UNKNOWN_VAR, path33.resolve(target)).split(path33.sep)[0].split("+").filter(Boolean).map(decodeURIComponent)))
20736
+ ...new Set(targets.flatMap((target) => path34.relative(UNKNOWN_VAR, path34.resolve(target)).split(path34.sep)[0].split("+").filter(Boolean).map(decodeURIComponent)))
20618
20737
  ];
20619
20738
  var literalForm = (command, refs) => {
20620
20739
  let text = command;
@@ -20647,10 +20766,10 @@ function confineImplementer(input, targets, command) {
20647
20766
  try {
20648
20767
  if (!input.session.agentId || hostIsolated(input.cwd, input.session.agentId))
20649
20768
  return NONE5;
20650
- const unresolved = targets.filter((target) => within(path33.resolve(target), UNKNOWN_VAR));
20769
+ const unresolved = targets.filter((target) => within(path34.resolve(target), UNKNOWN_VAR));
20651
20770
  if (unresolved.length > 0)
20652
20771
  return unknownVarDeny(input, unresolved, command);
20653
- if (targets.some((target) => within(path33.resolve(target), UNKNOWN_DIR)))
20772
+ if (targets.some((target) => within(path34.resolve(target), UNKNOWN_DIR)))
20654
20773
  return unknownDirDeny(input, boundWorktree(input));
20655
20774
  const bindings = canonical6(bindingDir());
20656
20775
  const judged = targets.map((named) => ({ named, real: canonical6(named) })).filter(({ real }) => within(real, bindings) || checkoutOf2(real) !== null);
@@ -20757,10 +20876,10 @@ var INLINE = /^-[a-zA-Z]*[ceEpm]$|^--(?:eval|print|test|version|help)$|^-[hvV]$/
20757
20876
  var VALUED2 = /^-[WXIrC]$|^--(?:require|import|loader|conditions|input-type)$/;
20758
20877
  var commonDir = (root) => gitDirsAt(root, null, false)?.[1] ?? "";
20759
20878
  var inScratch = (real, repo) => {
20760
- for (let dir = real;path33.dirname(dir) !== dir; dir = path33.dirname(dir)) {
20761
- if (path33.basename(dir) !== SCRATCH)
20879
+ for (let dir = real;path34.dirname(dir) !== dir; dir = path34.dirname(dir)) {
20880
+ if (path34.basename(dir) !== SCRATCH)
20762
20881
  continue;
20763
- const root = path33.dirname(dir);
20882
+ const root = path34.dirname(dir);
20764
20883
  const checkout = checkoutOf2(root);
20765
20884
  if (checkout?.root === root && (repo === null || checkout.workit || commonDir(root) === repo))
20766
20885
  return true;
@@ -20770,7 +20889,7 @@ var inScratch = (real, repo) => {
20770
20889
  var inGitDir = (real) => real.split(/[\\/]/).includes(".git");
20771
20890
  var SAFE_KEY = /^(?:core\.(?:repositoryformatversion|filemode|bare|logallrefupdates|ignorecase|precomposeunicode|symlinks)|user\..*|init\.defaultbranch|commit\.gpgsign|extensions\.(?:objectformat|refstorage)|branch\..*\.(?:remote|merge)|remote\..*\.fetch)$/;
20772
20891
  var literalIn = (value, repo, checkout = false) => {
20773
- if (/[$`]/.test(value) || !path33.isAbsolute(value))
20892
+ if (/[$`]/.test(value) || !path34.isAbsolute(value))
20774
20893
  return false;
20775
20894
  const real = canonical6(value);
20776
20895
  const root = checkout ? checkoutOf2(real)?.root : undefined;
@@ -20791,8 +20910,8 @@ var configEntries = (text) => {
20791
20910
  return entries;
20792
20911
  };
20793
20912
  function gitDirsAt(dir, repo, scan = true) {
20794
- for (let at = dir;; at = path33.dirname(at)) {
20795
- const dotGit = path33.join(at, ".git");
20913
+ for (let at = dir;; at = path34.dirname(at)) {
20914
+ const dotGit = path34.join(at, ".git");
20796
20915
  let gitDir = null;
20797
20916
  try {
20798
20917
  if (fs22.statSync(dotGit).isDirectory())
@@ -20801,19 +20920,19 @@ function gitDirsAt(dir, repo, scan = true) {
20801
20920
  const named = /^gitdir:\s*(.+?)\s*$/mu.exec(fs22.readFileSync(dotGit, "utf8"))?.[1];
20802
20921
  if (!named)
20803
20922
  return null;
20804
- gitDir = canonical6(path33.resolve(at, named));
20923
+ gitDir = canonical6(path34.resolve(at, named));
20805
20924
  }
20806
20925
  } catch (error) {
20807
20926
  if (error.code !== "ENOENT")
20808
20927
  return null;
20809
- if (["HEAD", "objects", "refs"].every((name) => fs22.existsSync(path33.join(at, name))))
20928
+ if (["HEAD", "objects", "refs"].every((name) => fs22.existsSync(path34.join(at, name))))
20810
20929
  gitDir = canonical6(at);
20811
20930
  }
20812
20931
  if (gitDir !== null) {
20813
- const common = path33.join(gitDir, "commondir");
20814
- const shared = fs22.existsSync(common) ? canonical6(path33.resolve(gitDir, fs22.readFileSync(common, "utf8").trim())) : gitDir;
20932
+ const common = path34.join(gitDir, "commondir");
20933
+ const shared = fs22.existsSync(common) ? canonical6(path34.resolve(gitDir, fs22.readFileSync(common, "utf8").trim())) : gitDir;
20815
20934
  const dirs = [gitDir, shared];
20816
- for (const config of scan ? new Set([path33.join(gitDir, "config"), path33.join(shared, "config")]) : []) {
20935
+ for (const config of scan ? new Set([path34.join(gitDir, "config"), path34.join(shared, "config")]) : []) {
20817
20936
  let text = "";
20818
20937
  try {
20819
20938
  text = fs22.readFileSync(config, "utf8");
@@ -20822,14 +20941,14 @@ function gitDirsAt(dir, repo, scan = true) {
20822
20941
  }
20823
20942
  for (const [key, value] of configEntries(text)) {
20824
20943
  if (key === "core.worktree")
20825
- dirs.push(canonical6(path33.resolve(gitDir, value)));
20944
+ dirs.push(canonical6(path34.resolve(gitDir, value)));
20826
20945
  else if (/^remote\..*\.url$/.test(key) ? !literalIn(value, repo, true) : !SAFE_KEY.test(key))
20827
20946
  return null;
20828
20947
  }
20829
20948
  }
20830
20949
  return dirs;
20831
20950
  }
20832
- if (path33.dirname(at) === at)
20951
+ if (path34.dirname(at) === at)
20833
20952
  return [];
20834
20953
  }
20835
20954
  }
@@ -20969,10 +21088,10 @@ var gitKind = (args, local = () => true) => {
20969
21088
  return GIT_VERBS[verb].startsWith("+") ? "write" : "read";
20970
21089
  };
20971
21090
  var remoteIn = (dir, name, repo) => {
20972
- const shared = path33.isAbsolute(dir) ? gitDirsAt(canonical6(dir), repo, false)?.[1] : undefined;
21091
+ const shared = path34.isAbsolute(dir) ? gitDirsAt(canonical6(dir), repo, false)?.[1] : undefined;
20973
21092
  if (!shared)
20974
21093
  return false;
20975
- const url = configEntries(fs22.readFileSync(path33.join(shared, "config"), "utf8")).find(([key]) => key === `remote.${name}.url`.toLowerCase())?.[1];
21094
+ const url = configEntries(fs22.readFileSync(path34.join(shared, "config"), "utf8")).find(([key]) => key === `remote.${name}.url`.toLowerCase())?.[1];
20976
21095
  return url !== undefined && literalIn(url, repo, true);
20977
21096
  };
20978
21097
  var judgeGit = (command, repo, cwd, depth = 0) => {
@@ -20986,7 +21105,7 @@ var judgeGit = (command, repo, cwd, depth = 0) => {
20986
21105
  const lead = [];
20987
21106
  while (/^\w+\+?=/.test(words[at] ?? ""))
20988
21107
  lead.push(words[at++]);
20989
- const name = path33.basename(words[at] ?? "");
21108
+ const name = path34.basename(words[at] ?? "");
20990
21109
  let start = words.findIndex((word) => /(?:^|[\\/])git(?:\.exe)?(?:=|$)/.test(word));
20991
21110
  if (start > at) {
20992
21111
  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] ?? ""))
@@ -20997,7 +21116,7 @@ var judgeGit = (command, repo, cwd, depth = 0) => {
20997
21116
  if (start >= 0 && words[start].includes("="))
20998
21117
  why = "git is redefined";
20999
21118
  const run = words[start] ?? "";
21000
- if (run.includes("/") && (!path33.isAbsolute(run) || literalIn(run, repo, true)))
21119
+ if (run.includes("/") && (!path34.isAbsolute(run) || literalIn(run, repo, true)))
21001
21120
  why ??= `\`${run}\` is not the system git`;
21002
21121
  if (segment.expands?.includes(at) && name !== "[" || /\{[^}]*,/.test(words[at] ?? ""))
21003
21122
  why = "the command's name is expanded by the shell";
@@ -21022,13 +21141,13 @@ var judgeGit = (command, repo, cwd, depth = 0) => {
21022
21141
  const args = words[index] === "--version" ? ["version"] : words.slice(index);
21023
21142
  if (!why && start >= 0) {
21024
21143
  const local = (source, remote) => remote && /^[\w-][\w.-]*$/.test(source) ? remoteIn(dir, source, repo) : literalIn(source, repo, true);
21025
- const runsIn = path33.isAbsolute(dir) ? dir : cwd && path33.resolve(cwd, dir);
21144
+ const runsIn = path34.isAbsolute(dir) ? dir : cwd && path34.resolve(cwd, dir);
21026
21145
  const home = runsIn && checkoutOf2(runsIn);
21027
21146
  const fetches = args[0] === "fetch" && plainFetch(args.slice(1)) && home && (home.workit || commonDir(home.root) === repo) && !words.some((word) => /^--[gw]/.test(word));
21028
21147
  if (!fetches && !gitKind(args, local))
21029
21148
  why = `\`git ${args.slice(0, 2).join(" ")}\` is not allowed`;
21030
21149
  }
21031
- const shell = /^(?:grep|egrep|rg|echo|printf|cat)$/.test(name) ? -1 : words.findIndex((word) => /^(?:sh|bash|zsh|dash|ksh|mksh|ash)$/.test(path33.basename(word)));
21150
+ const shell = /^(?:grep|egrep|rg|echo|printf|cat)$/.test(name) ? -1 : words.findIndex((word) => /^(?:sh|bash|zsh|dash|ksh|mksh|ash)$/.test(path34.basename(word)));
21032
21151
  const scripts = [
21033
21152
  ...words.filter((_, after) => shell >= 0 && after > shell && /^-[a-zA-Z]*c[a-zA-Z]*$/.test(words[after - 1])),
21034
21153
  ...shell < 0 ? [] : segment.stdin ?? []
@@ -21073,7 +21192,7 @@ var judgeVerbRefused = (args) => {
21073
21192
  var CLI_RUNNERS = /^(?:npx|bunx|pnpx|npm|pnpm|yarn|bun|node|nodejs|deno|tsx|ts-node)$/;
21074
21193
  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?$/;
21075
21194
  var workitCalls = (command, depth = 0, aliases = new Map) => depth > 4 ? [] : commandLines(command).flatMap((words) => {
21076
- const name = path33.basename(words[0] ?? "").toLowerCase();
21195
+ const name = path34.basename(words[0] ?? "").toLowerCase();
21077
21196
  if (name === "alias")
21078
21197
  return words.flatMap((word) => {
21079
21198
  const set = /^([\w-]+)=(.*)$/s.exec(word);
@@ -21102,11 +21221,11 @@ var judgeRefusal = (command, fed, depth = 0) => {
21102
21221
  return why;
21103
21222
  }
21104
21223
  const { words } = segment;
21105
- const runs = (word = "") => RUNS.test(path33.basename(word).toLowerCase());
21224
+ const runs = (word = "") => RUNS.test(path34.basename(word).toLowerCase());
21106
21225
  let at = 0;
21107
21226
  while (at < words.length && (LEADS.test(words[at]) || /^-\w$/.test(words[at - 1] ?? "") && !runs(words[at])))
21108
21227
  at++;
21109
- const name = path33.basename(words[at] ?? "").toLowerCase();
21228
+ const name = path34.basename(words[at] ?? "").toLowerCase();
21110
21229
  const args = words.slice(at + 1);
21111
21230
  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`;
21112
21231
  if (/^(?:cd|chdir|pushd|popd)$/.test(name))
@@ -21188,9 +21307,9 @@ var judgeDeny = (input, what, target, retry) => {
21188
21307
  const role = input.session.agentType?.endsWith("reviewer") ? "reviewer" : "verifier";
21189
21308
  const root = checkoutOf2(input.cwd)?.root;
21190
21309
  const candidate = target ? checkoutOf2(target)?.root : undefined;
21191
- const other = root && candidate && candidate !== root && commonDir(candidate) === commonDir(root) ? path33.join(candidate, SCRATCH) : undefined;
21192
- const scratch = root ? `${path33.join(root, SCRATCH)}${other ? ` or ${other}` : ""}` : `${SCRATCH}/ at the root of the checkout you judge`;
21193
- const call = root ? retry?.((other ?? path33.join(root, SCRATCH)).replaceAll("\\", "/")) : null;
21310
+ const other = root && candidate && candidate !== root && commonDir(candidate) === commonDir(root) ? path34.join(candidate, SCRATCH) : undefined;
21311
+ const scratch = root ? `${path34.join(root, SCRATCH)}${other ? ` or ${other}` : ""}` : `${SCRATCH}/ at the root of the checkout you judge`;
21312
+ const call = root ? retry?.((other ?? path34.join(root, SCRATCH)).replaceAll("\\", "/")) : null;
21194
21313
  const unblock = call ? `Retry as: ${call}` : "Why: write only there (mkdir -p it); a fix the candidate needs is a finding (`workit finding record`).";
21195
21314
  return {
21196
21315
  kind: "deny",
@@ -21201,9 +21320,9 @@ ${unblock}`,
21201
21320
  };
21202
21321
  var movedInto = (command, cwd, target, dir) => {
21203
21322
  for (const { words, redirects } of segmentsOf(command))
21204
- for (const word of [...redirects, ...path33.basename(words[0] ?? "") === "tee" ? words : []])
21205
- if (path33.resolve(cwd, word) === path33.resolve(cwd, target)) {
21206
- const moved = command.replace(new RegExp(`((?:>>?\\|?|\\btee(?:\\s+-a)?)\\s*)(['"]?)${word.replace(/[$()*+.?[\\\]^{|}]/g, "\\$&")}\\2(?![^\\s;&|)])`), (_, lead) => `${lead}${dir}/${path33.basename(word)}`);
21323
+ for (const word of [...redirects, ...path34.basename(words[0] ?? "") === "tee" ? words : []])
21324
+ if (path34.resolve(cwd, word) === path34.resolve(cwd, target)) {
21325
+ const moved = command.replace(new RegExp(`((?:>>?\\|?|\\btee(?:\\s+-a)?)\\s*)(['"]?)${word.replace(/[$()*+.?[\\\]^{|}]/g, "\\$&")}\\2(?![^\\s;&|)])`), (_, lead) => `${lead}${dir}/${path34.basename(word)}`);
21207
21326
  return moved === command ? null : moved;
21208
21327
  }
21209
21328
  return null;
@@ -21215,19 +21334,19 @@ function confineJudge(input, targets, placeholders = placeholdersOf(targets), co
21215
21334
  const judged = checkoutOf2(input.cwd);
21216
21335
  const repo = judged ? commonDir(judged.root) : null;
21217
21336
  const scratch = (real) => inScratch(real, repo) || [os10.tmpdir(), "/tmp"].some((dir) => {
21218
- const [host, , session] = path33.relative(canonical6(dir), real).split(path33.sep);
21337
+ const [host, , session] = path34.relative(canonical6(dir), real).split(path34.sep);
21219
21338
  return /^claude-\d+$/.test(host) && session === input.session.id;
21220
21339
  });
21221
21340
  for (const target of targets) {
21222
- const resolved = path33.resolve(target);
21341
+ const resolved = path34.resolve(target);
21223
21342
  if (within(resolved, UNKNOWN_VAR) || within(resolved, UNKNOWN_DIR))
21224
21343
  return judgeDeny(input, "it writes to a path Workit cannot resolve", undefined, () => {
21225
21344
  const literal = command && literalForm(command, refsOf([target]));
21226
21345
  return literal === command ? null : literal;
21227
21346
  });
21228
21347
  const real = canonical6(target);
21229
- const runsGit = placeholders.has(target) && /^\.workit-(?:runs-git|live-target)$/.test(path33.basename(target));
21230
- const gitDirs = runsGit ? gitDirsAt(path33.dirname(real), repo) : [];
21348
+ const runsGit = placeholders.has(target) && /^\.workit-(?:runs-git|live-target)$/.test(path34.basename(target));
21349
+ const gitDirs = runsGit ? gitDirsAt(path34.dirname(real), repo) : [];
21231
21350
  if (gitDirs === null)
21232
21351
  return judgeDeny(input, `git in ${shown(target)} uses a git dir or config Workit cannot check`);
21233
21352
  if (runsGit ? gitDirs.length > 0 ? gitDirs.every(scratch) : scratch(real) : scratch(real) && !inGitDir(real))
@@ -21293,7 +21412,7 @@ function confineJudgeShell(input, command, dialect = "posix") {
21293
21412
  let git = [];
21294
21413
  try {
21295
21414
  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)))) ? [
21296
- path33.join(dir === undefined ? UNKNOWN_DIR : path33.resolve(input.cwd, dir ?? "."), `${OPAQUE_TARGET}git`)
21415
+ path34.join(dir === undefined ? UNKNOWN_DIR : path34.resolve(input.cwd, dir ?? "."), `${OPAQUE_TARGET}git`)
21297
21416
  ] : []);
21298
21417
  } catch {}
21299
21418
  const lists = [
@@ -21338,7 +21457,7 @@ var judgeChecksLine = (cwd) => {
21338
21457
 
21339
21458
  // packages/workit-core/src/hooks/standing.ts
21340
21459
  var readPlans = (store) => {
21341
- const dir = path34.join(store, "fanouts");
21460
+ const dir = path35.join(store, "fanouts");
21342
21461
  let names;
21343
21462
  try {
21344
21463
  names = fs23.readdirSync(dir).filter((name) => name.endsWith(".json"));
@@ -21348,7 +21467,7 @@ var readPlans = (store) => {
21348
21467
  const plans = [];
21349
21468
  for (const name of names) {
21350
21469
  try {
21351
- const raw = JSON.parse(fs23.readFileSync(path34.join(dir, name), "utf8"));
21470
+ const raw = JSON.parse(fs23.readFileSync(path35.join(dir, name), "utf8"));
21352
21471
  if (typeof raw.name !== "string" || !Array.isArray(raw.slices))
21353
21472
  continue;
21354
21473
  const texts = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string" && item !== "") : [];
@@ -21558,12 +21677,12 @@ var cdWorkitSplit = (command) => {
21558
21677
 
21559
21678
  // packages/workit-core/src/hooks/spawn-gate.ts
21560
21679
  import fs24 from "node:fs";
21561
- import path36 from "node:path";
21680
+ import path37 from "node:path";
21562
21681
 
21563
21682
  // packages/workit-core/src/hooks/model-limit.ts
21564
21683
  import { closeSync as closeSync3, openSync as openSync3, readdirSync as readdirSync4, readSync, statSync as statSync5 } from "node:fs";
21565
21684
  import os11 from "node:os";
21566
- import path35 from "node:path";
21685
+ import path36 from "node:path";
21567
21686
  var MONTHS = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
21568
21687
  var WEEKDAYS = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"];
21569
21688
  var TIME_WORD = String.raw`(?:\d|(?:in|at|on|later|tomorrow|soon)\b|(?:${[...WEEKDAYS, ...MONTHS].join("|")})[a-z]*\b)`;
@@ -21761,17 +21880,17 @@ var firstPrompt = (file) => {
21761
21880
  var claudeProjectSlug = (cwd) => cwd.replace(/[^A-Za-z0-9]/gu, "-");
21762
21881
  var listDir = (dir) => {
21763
21882
  try {
21764
- return readdirSync4(dir).map((name) => path35.join(dir, name));
21883
+ return readdirSync4(dir).map((name) => path36.join(dir, name));
21765
21884
  } catch {
21766
21885
  return [];
21767
21886
  }
21768
21887
  };
21769
21888
  var SCAN_MS = 30 * 60000;
21770
21889
  var scanClaudeTranscripts = (cwd, env, now = new Date) => {
21771
- const projects = path35.join(env.CLAUDE_CONFIG_DIR || path35.join(env.HOME || os11.homedir(), ".claude"), "projects");
21772
- const project = path35.join(projects, claudeProjectSlug(cwd));
21890
+ const projects = path36.join(env.CLAUDE_CONFIG_DIR || path36.join(env.HOME || os11.homedir(), ".claude"), "projects");
21891
+ const project = path36.join(projects, claudeProjectSlug(cwd));
21773
21892
  const notes = [];
21774
- const files = listDir(project).flatMap((entry) => entry.endsWith(".jsonl") ? [{ file: entry, worker: false }] : listDir(path35.join(entry, "subagents")).filter((file) => file.endsWith(".jsonl")).map((file) => ({ file, worker: true })));
21893
+ const files = listDir(project).flatMap((entry) => entry.endsWith(".jsonl") ? [{ file: entry, worker: false }] : listDir(path36.join(entry, "subagents")).filter((file) => file.endsWith(".jsonl")).map((file) => ({ file, worker: true })));
21775
21894
  for (const { file, worker } of files)
21776
21895
  try {
21777
21896
  const stat = statSync5(file);
@@ -21786,7 +21905,7 @@ var scanClaudeTranscripts = (cwd, env, now = new Date) => {
21786
21905
  if (!seen)
21787
21906
  continue;
21788
21907
  notes.push(worker ? redispatchNote(seen, {
21789
- label: `worker ${path35.basename(file, ".jsonl")}`,
21908
+ label: `worker ${path36.basename(file, ".jsonl")}`,
21790
21909
  prompt: firstPrompt(file)
21791
21910
  }, 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.`);
21792
21911
  } catch {}
@@ -21888,10 +22007,10 @@ var namesMade = (word) => {
21888
22007
  const stat = fs24.statSync(word);
21889
22008
  if (stat.isFile())
21890
22009
  return stat.size < 1e6 && MADE_WORKTREE.test(fs24.readFileSync(word, "utf8"));
21891
- const dotGit = path36.join(word, ".git");
22010
+ const dotGit = path37.join(word, ".git");
21892
22011
  const link = fs24.statSync(dotGit);
21893
22012
  const admin = link.isFile() && link.size <= 4096 && /^gitdir: *(.+)/u.exec(fs24.readFileSync(dotGit, "utf8"));
21894
- return !!admin && fs24.existsSync(path36.resolve(word, admin[1].trim(), FANOUT_TOKEN_FILE));
22013
+ return !!admin && fs24.existsSync(path37.resolve(word, admin[1].trim(), FANOUT_TOKEN_FILE));
21895
22014
  } catch {
21896
22015
  return false;
21897
22016
  }
@@ -21938,7 +22057,7 @@ var spawnDecision = (descriptor, cwd, tool, permissionMode = null) => {
21938
22057
  // packages/workit-core/src/hooks/teardown.ts
21939
22058
  import { spawn } from "node:child_process";
21940
22059
  import fs25 from "node:fs";
21941
- import path37 from "node:path";
22060
+ import path38 from "node:path";
21942
22061
  var REAP_INTERVAL_MS = 10 * 60000;
21943
22062
  var LOG_MAX_BYTES = 1 << 20;
21944
22063
  var ENDS = {
@@ -21949,9 +22068,9 @@ var ENDS = {
21949
22068
  };
21950
22069
  var SAFE_SESSION = /^[\w.@+][\w.:@/+-]{0,127}$/u;
21951
22070
  var HOST_SESSION_VARS = ["OPENCODE_SESSION_ID", "PI_SESSION_ID", "CODEX_THREAD_ID"];
21952
- var teardownDir = (env) => path37.join(stateDir3(env), "procs");
21953
- var teardownLog = (env) => path37.join(teardownDir(env), "teardown.log");
21954
- var reapStamp = (env) => path37.join(teardownDir(env), "reap-at-start.stamp");
22071
+ var teardownDir = (env) => path38.join(stateDir3(env), "procs");
22072
+ var teardownLog = (env) => path38.join(teardownDir(env), "teardown.log");
22073
+ var reapStamp = (env) => path38.join(teardownDir(env), "reap-at-start.stamp");
21955
22074
  function spawnDetached(request) {
21956
22075
  try {
21957
22076
  const shell = process.platform === "win32" && !/\.exe$/iu.test(request.command);
@@ -21978,7 +22097,7 @@ var teardownDeps = {
21978
22097
  var openLog = (env, args) => {
21979
22098
  try {
21980
22099
  const file = teardownLog(env);
21981
- fs25.mkdirSync(path37.dirname(file), { recursive: true });
22100
+ fs25.mkdirSync(path38.dirname(file), { recursive: true });
21982
22101
  let size = 0;
21983
22102
  try {
21984
22103
  size = fs25.statSync(file).size;
@@ -22063,7 +22182,7 @@ function reapAtStart(_cwd, env = process.env) {
22063
22182
  try {
22064
22183
  if (fresh(stamp, now))
22065
22184
  return false;
22066
- fs25.mkdirSync(path37.dirname(stamp), { recursive: true });
22185
+ fs25.mkdirSync(path38.dirname(stamp), { recursive: true });
22067
22186
  if (!claim2(lock, now))
22068
22187
  return false;
22069
22188
  } catch {
@@ -23083,7 +23202,7 @@ var dispatchHook = (adapter, raw, env = process.env) => {
23083
23202
  };
23084
23203
  // packages/workit-core/src/hooks/deadline.ts
23085
23204
  import { appendFileSync, mkdirSync as mkdirSync4 } from "node:fs";
23086
- import path38 from "node:path";
23205
+ import path39 from "node:path";
23087
23206
  var HOOK_SKIP_TEXT = "workit context skipped: host under load";
23088
23207
  var HOOK_DEADLINE_MS = 8000;
23089
23208
  var HOST_DEADLINES = {
@@ -23101,7 +23220,7 @@ var hookDeadlineMs = (env, host = "", native) => {
23101
23220
  const row = HOST_DEADLINES[host];
23102
23221
  return override(env) ?? (row ? native === undefined ? Math.min(...Object.values(row)) : row[native] ?? row[""] : HOOK_DEADLINE_MS);
23103
23222
  };
23104
- var skipsFile = (stateDir) => path38.join(stateDir, HOOK_SKIPS_FILE);
23223
+ var skipsFile = (stateDir) => path39.join(stateDir, HOOK_SKIPS_FILE);
23105
23224
  var recordHookSkip = (skip, stateDir = resolveStateDir()) => {
23106
23225
  try {
23107
23226
  mkdirSync4(stateDir, { recursive: true });
@@ -76,7 +76,11 @@ var reachTests = (dirs) => {
76
76
  };
77
77
  const state = canon(dirs.state);
78
78
  const configs = dirs.configs.map(canon);
79
- const at = (file) => file === LOST || configs.some((dir) => within(dir, file)) || within(state, file) && /^(?:issued[^\\/]*|approvals|verdicts|folders[\\/][^\\/]+[\\/]ledger)(?:[\\/]|$)/.test(path.relative(state, file)) || /[\\/]\.git[\\/]workit[\\/]ledger(?:[\\/]|$)/.test(file);
79
+ const repoLedger = (file) => [...file.matchAll(/[\\/]workit[\\/]ledger(?=[\\/]|$)/g)].some(({ index }) => {
80
+ const gitDir = file.slice(0, index);
81
+ return /(?:^|[\\/])\.git$/.test(gitDir) || existsSync(path.join(gitDir, "HEAD")) && existsSync(path.join(gitDir, "objects"));
82
+ });
83
+ const at = (file) => file === LOST || configs.some((dir) => within(dir, file)) || within(state, file) && /^(?:issued[^\\/]*|approvals|verdicts|folders[\\/][^\\/]+[\\/]ledger)(?:[\\/]|$)/.test(path.relative(state, file)) || repoLedger(file);
80
84
  const above = (file) => within(file, state) || configs.some((dir) => within(file, dir));
81
85
  const linked = (file) => {
82
86
  try {
@@ -98,7 +102,7 @@ var mayReachWith = (text, cwd, dirs) => {
98
102
  return true;
99
103
  const joined = text.replace(/\\\r?\n/g, "");
100
104
  const bare = joined.replace(/['"\\]/g, "");
101
- if (/\$['"]/.test(joined) || /~[\w+-]|\$\{(?:!|\w+[^\w}])|\bpopd\b/.test(bare) || /(?:^|[\s;&|(])(?:cd|pushd|chdir)(?:\s+-\S*)*\s*(?:$|[;&|)\n$`])/.test(bare) || dirs.env.CDPATH !== undefined && /\b(?:cd|pushd)\b/.test(bare))
105
+ if (/\$['"]/.test(joined) || /~[\w+-]|\$\{(?:!|\w+[^\w}])|\bpopd\b/.test(bare) || /(?:^|[\s;&|(])(?:cd|pushd|chdir)(?:\s+-\S*)*\s*(?:$|[;&|)\n$`])/.test(bare) || dirs.env.CDPATH !== undefined && /\b(?:cd|pushd)\b/.test(bare) || /(?:^|[\s;&|(/])(?:ln|mount|bindfs|mklink)(?:\s|$)/i.test(bare) || /(?:^|[\s;&|(/])(?:cp|install)\s[^;&|\n]*\s(?:-[a-zA-Z]*[ls]|--(?:link|symbolic-link)\b)/.test(bare) || /--link-dest\b|\b(?:symboliclink|junction|hardlink)\b/i.test(bare))
102
106
  return true;
103
107
  const bound = (name) => new RegExp(`(?:^|[^\\w$])${name}=|\\bfor\\s+${name}\\b|\\bread\\b[^;&|\\n]*\\b${name}\\b`).test(bare);
104
108
  const expanded = bare.replace(/\$\{([A-Za-z_]\w*)\}|\$([A-Za-z_]\w*)/g, (all, braced, plain) => {
@@ -40,7 +40,7 @@ var { standingPending } = await import("./workit-hook-mk64s4fk.js");
40
40
  var { procNoticeFile } = await import("./workit-hook-dv9s0sjq.js");
41
41
  var { recordHookRun } = await import("./workit-hook-a7qmf2t8.js");
42
42
  var { observeHookBudget } = await import("./workit-hook-3g6cv3hd.js");
43
- var { hasTaskStore, mayReach } = await import("./workit-hook-5ke74t8j.js");
43
+ var { hasTaskStore, mayReach } = await import("./workit-hook-zgd5gqzm.js");
44
44
  var YTRACK_WORD = /ytrack(?![\w/-]|\.(?!exe|cmd))/i;
45
45
  var namesYtrack = (text) => {
46
46
  const bare = text.replace(/['"\\]/g, "");
@@ -101,7 +101,7 @@ if (quiet) {
101
101
  `);
102
102
  } else {
103
103
  try {
104
- const { runCodexHook } = await import("./workit-hook-y3cw1pkt.js");
104
+ const { runCodexHook } = await import("./workit-hook-2et385jj.js");
105
105
  await runCodexHook([payload]);
106
106
  } catch (error) {
107
107
  const { answerRuntimeFailure } = await import("./workit-hook-2j7nwxvz.js");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/codex",
3
- "version": "2.24.0",
3
+ "version": "2.25.1",
4
4
  "private": false,
5
5
  "description": "Workit Codex CLI/desktop plugin — shared MCP transport, hooks, method skills, and verifier/reviewer/implementer agents",
6
6
  "keywords": [
@@ -41,8 +41,8 @@
41
41
  "build": "bun scripts/build.ts"
42
42
  },
43
43
  "devDependencies": {
44
- "@workit-dev/core": "^2.24.0",
45
- "@workit-dev/mcp": "^2.24.0"
44
+ "@workit-dev/core": "^2.25.1",
45
+ "@workit-dev/mcp": "^2.25.1"
46
46
  },
47
47
  "engines": {
48
48
  "node": ">=24"