@workit-dev/codex 1.11.0 → 1.12.0

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.
@@ -15492,17 +15492,17 @@ var seedTurnContext = (input, descriptor, text = turnContextText(input, descript
15492
15492
  // packages/workit-core/src/core/route-intent.ts
15493
15493
  import { spawnSync as spawnSync14 } from "node:child_process";
15494
15494
  import { existsSync as existsSync9 } from "node:fs";
15495
- import path24 from "node:path";
15495
+ import path25 from "node:path";
15496
15496
 
15497
15497
  // packages/workit-core/src/hooks/raw-git.ts
15498
15498
  import { spawnSync as spawnSync13 } from "node:child_process";
15499
- import { createHash as createHash13 } from "node:crypto";
15499
+ import { createHash as createHash14 } from "node:crypto";
15500
15500
  import fs16 from "node:fs";
15501
15501
  import os5 from "node:os";
15502
- import path23 from "node:path";
15502
+ import path24 from "node:path";
15503
15503
 
15504
15504
  // packages/workit-core/src/autonomy.ts
15505
- import path21 from "node:path";
15505
+ import path22 from "node:path";
15506
15506
 
15507
15507
  // packages/workit-core/src/core/eval-world.ts
15508
15508
  import { existsSync as existsSync8, realpathSync as realpathSync6 } from "node:fs";
@@ -15534,6 +15534,68 @@ var evalWorldEntry = (cwd) => {
15534
15534
  }
15535
15535
  };
15536
15536
 
15537
+ // packages/workit-core/src/core/grant-seal.ts
15538
+ import { createHash as createHash12 } from "node:crypto";
15539
+ import { readFileSync as readFileSync9 } from "node:fs";
15540
+ import path21 from "node:path";
15541
+ var SEAL_FILE = "workspaces.json.seal";
15542
+ var SEAL_VERSION = 1;
15543
+ var SEAL_COMMAND = "workit workspace seal";
15544
+ var pick2 = (value, keys) => {
15545
+ if (!value || typeof value !== "object" || Array.isArray(value))
15546
+ return;
15547
+ const out = Object.fromEntries(keys.flatMap((key) => {
15548
+ const item = value[key];
15549
+ return item === undefined ? [] : [[key, item]];
15550
+ }));
15551
+ return Object.keys(out).length > 0 ? out : undefined;
15552
+ };
15553
+ var ENTRY_KEYS = [
15554
+ "name",
15555
+ "glob",
15556
+ "remotes",
15557
+ "vcs",
15558
+ "autonomy",
15559
+ "autoApprove",
15560
+ "defaultEndpoint",
15561
+ "verification",
15562
+ "youtrack"
15563
+ ];
15564
+ var sealProjection = (entries) => entries.map((entry) => {
15565
+ const all = pick2(entry, ENTRY_KEYS) ?? {};
15566
+ return pick2({
15567
+ ...all,
15568
+ vcs: pick2(all.vcs, ["provider", "account"]),
15569
+ youtrack: pick2(all.youtrack, ["writes"])
15570
+ }, ENTRY_KEYS);
15571
+ });
15572
+ var canonical3 = (value) => JSON.stringify(value, (_key, item) => item && typeof item === "object" && !Array.isArray(item) ? Object.fromEntries(Object.entries(item).toSorted(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)) : item);
15573
+ var sealDigest = (projection) => createHash12("sha256").update(canonical3(projection)).digest("hex");
15574
+ var broken = (reason, sealed = null) => ({
15575
+ state: "broken",
15576
+ reason,
15577
+ sealed
15578
+ });
15579
+ function checkSeal(dir) {
15580
+ const file = path21.join(dir, SEAL_FILE);
15581
+ let seal;
15582
+ try {
15583
+ seal = JSON.parse(readFileSync9(file, "utf8"));
15584
+ } catch (error) {
15585
+ if (error.code === "ENOENT")
15586
+ return { state: "none" };
15587
+ return broken(`${SEAL_FILE} cannot be read`);
15588
+ }
15589
+ if (seal?.version !== SEAL_VERSION || !Array.isArray(seal.projection) || seal.sha256 !== sealDigest(seal.projection))
15590
+ return broken(`${SEAL_FILE} is malformed`);
15591
+ const sealed = validateWorkspacesDocument({ workspaces: seal.projection }, file);
15592
+ if (sealed.status !== "valid")
15593
+ return broken(`${SEAL_FILE} is malformed`);
15594
+ const current = readWorkspacesResult(dir);
15595
+ const ok = current.status === "valid" || current.status === "missing";
15596
+ return ok && sealDigest(sealProjection(current.entries)) === seal.sha256 ? { state: "valid" } : broken("workspaces.json changed since it was sealed", sealed.entries);
15597
+ }
15598
+
15537
15599
  // packages/workit-core/src/autonomy.ts
15538
15600
  var grantsHome = { resolve: accountHome };
15539
15601
  var accountDir = () => {
@@ -15543,13 +15605,27 @@ var accountDir = () => {
15543
15605
  var grantsDir = () => accountDir() ?? resolveConfigDir();
15544
15606
  var NO_ACCOUNT = "no OS account record answered (core/account-home.ts), so no grants are read: the D4 defaults apply";
15545
15607
  var entriesIn = (dir) => dir === null ? [] : loadWorkspacesFrom(dir);
15546
- var resolveFrom = (cwd, name) => {
15608
+ var fileSource = (dir = accountDir()) => ({
15609
+ resolve: (cwd, name) => dir === null ? null : resolveWorkspaceFrom(cwd, dir, name),
15610
+ entries: () => entriesIn(dir)
15611
+ });
15612
+ var sealedSource = (entries) => ({
15613
+ resolve: (cwd, name) => resolveWorkspaceFromEntries(cwd, entries, name),
15614
+ entries: () => entries
15615
+ });
15616
+ var sealOf = () => {
15547
15617
  const dir = accountDir();
15548
- return dir === null ? null : resolveWorkspaceFrom(cwd, dir, name);
15618
+ return dir === null ? { state: "none" } : checkSeal(dir);
15619
+ };
15620
+ var SEAL_UNBLOCK = `if the user made this change, ask them to run, in their own terminal: ${SEAL_COMMAND}`;
15621
+ var sealNote = (seal = sealOf()) => seal.state === "broken" ? `workspaces.json does not match its seal (${seal.reason}), so grants, endpoint, verification and youtrack.writes are the stricter of their current and last sealed values; ${SEAL_UNBLOCK}` : null;
15622
+ var youTrackWritesMode = (cwd) => {
15623
+ const youtrack = resolveRuntimeWorkspaceVcs(cwd)?.youtrack;
15624
+ return youtrack && typeof youtrack === "object" && youtrack.writes === "auto" && !sealNote() ? "auto" : "ask";
15549
15625
  };
15550
15626
  var shownGrantsDir = () => {
15551
15627
  const world = evalWorld(process.cwd());
15552
- return world ? path21.join(world, "config") : accountDir();
15628
+ return world ? path22.join(world, "config") : accountDir();
15553
15629
  };
15554
15630
  var benchWorld = (cwd) => {
15555
15631
  const entry = evalWorldEntry(cwd);
@@ -15573,8 +15649,8 @@ var grantsOverride = () => {
15573
15649
  const shown = shownGrantsDir();
15574
15650
  if (shown === null)
15575
15651
  return NO_ACCOUNT;
15576
- const configured = path21.resolve(resolveConfigDir());
15577
- return configured === path21.resolve(shown) ? null : `the config directory is redirected to ${configured} (WORKIT_CONFIG, WORKIT_CONFIG_DIR or XDG_CONFIG_HOME), but that override does not apply to grants: grants are read only from ${path21.join(grantsDir(), "workspaces.json")}, so the D4 defaults apply until grants are set there`;
15652
+ const configured = path22.resolve(resolveConfigDir());
15653
+ return configured === path22.resolve(shown) ? null : `the config directory is redirected to ${configured} (WORKIT_CONFIG, WORKIT_CONFIG_DIR or XDG_CONFIG_HOME), but that override does not apply to grants: grants are read only from ${path22.join(grantsDir(), "workspaces.json")}, so the D4 defaults apply until grants are set there`;
15578
15654
  };
15579
15655
  var GRANT_KINDS = ["push", "pr", "merge", "release", "rerun"];
15580
15656
  var DEFAULT_GRANTS = Object.freeze({
@@ -15694,13 +15770,13 @@ function autonomyOf(workspace) {
15694
15770
  verification: verificationOf(workspace)
15695
15771
  };
15696
15772
  }
15697
- function capAt(named, where, by, why, main = false) {
15773
+ function capAt(source, named, where, by, why, main = false) {
15698
15774
  let folder = null;
15699
15775
  let none = "";
15700
15776
  try {
15701
15777
  if (where instanceof Error)
15702
15778
  throw where;
15703
- folder = autonomyOf(typeof where === "string" ? resolveFrom(where) : where.entry);
15779
+ folder = autonomyOf(typeof where === "string" ? source.resolve(where) : where.entry);
15704
15780
  } catch (error) {
15705
15781
  none = error.message;
15706
15782
  }
@@ -15743,43 +15819,105 @@ function resolveAutonomy(cwd, target) {
15743
15819
  const override = world ? null : grantsOverride();
15744
15820
  if (override)
15745
15821
  return { ...autonomyOf(null), note: override };
15822
+ let resolved;
15823
+ const once = typeof target === "function" ? () => resolved ??= target() : target;
15824
+ const current = resolveWith(fileSource(), cwd, world, once);
15825
+ const seal = sealOf();
15826
+ if (seal.state !== "broken")
15827
+ return current;
15828
+ let sealed = autonomyOf(null);
15829
+ try {
15830
+ if (seal.sealed)
15831
+ sealed = resolveWith(sealedSource(seal.sealed), cwd, world, once);
15832
+ } catch {
15833
+ sealed = null;
15834
+ }
15835
+ return stricter(current, sealed, sealNote(seal));
15836
+ }
15837
+ function resolveWith(source, cwd, world, target) {
15746
15838
  const name = process.env.WORKIT_WORKSPACE_NAME?.trim() || undefined;
15747
- const real = resolveFrom(cwd, name);
15839
+ const real = source.resolve(cwd, name);
15748
15840
  let autonomy = autonomyOf(real ?? world);
15749
15841
  if (!real && world)
15750
15842
  autonomy.world = evalWorld(cwd) ?? undefined;
15751
15843
  if (name)
15752
- autonomy = capAt(autonomy, cwd, `WORKIT_WORKSPACE_NAME=${name}`, "a name never raises grants");
15844
+ autonomy = capAt(source, autonomy, cwd, `WORKIT_WORKSPACE_NAME=${name}`, "a name never raises grants");
15753
15845
  const above = checkoutsAbove(cwd);
15754
15846
  for (const where of above instanceof Error ? [above] : above)
15755
- autonomy = capAt(autonomy, where, where instanceof Error ? "git" : `checkout ${where}`, "a worktree or submodule never exceeds it", true);
15756
- return capAtRemotes(autonomy, cwd, target);
15847
+ autonomy = capAt(source, autonomy, where, where instanceof Error ? "git" : `checkout ${where}`, "a worktree or submodule never exceeds it", true);
15848
+ return capAtRemotes(source, autonomy, cwd, target);
15757
15849
  }
15758
- function capAtRemotes(autonomy, cwd, target) {
15759
- const claiming = entriesIn(accountDir()).filter((entry) => entry.remotes?.length);
15850
+ var needsAccount = (autonomy) => autonomy.configured.length > 0 && !autonomy.accountConfigured;
15851
+ function stricter(current, sealed, note) {
15852
+ const grants = { ...current.grants };
15853
+ const unblocks = { ...current.unblocks };
15854
+ for (const kind of GRANT_KINDS) {
15855
+ const floor = sealed ? sealed.grants[kind] : false;
15856
+ if (!raises(kind, floor, grants[kind]))
15857
+ continue;
15858
+ grants[kind] = floor;
15859
+ unblocks[kind] = SEAL_UNBLOCK;
15860
+ }
15861
+ const configured = GRANT_KINDS.filter((kind) => current.configured.includes(kind) || sealed?.configured.includes(kind));
15862
+ const accountConfigured = !needsAccount(current) && !(sealed && needsAccount(sealed)) && (current.accountConfigured || Boolean(sealed?.accountConfigured));
15863
+ const lower = (a, b) => raisesEndpoint(a, b) ? a : b;
15864
+ const defaultEndpoint = lower(current.defaultEndpoint, sealed?.defaultEndpoint ?? DEFAULT_ENDPOINT);
15865
+ const effective = effectiveEndpoint(defaultEndpoint, {
15866
+ workspace: current.workspace,
15867
+ grants,
15868
+ configured,
15869
+ accountConfigured
15870
+ });
15871
+ const endpoint = lower(lower(effective.endpoint, current.effectiveEndpoint), sealed?.effectiveEndpoint ?? DEFAULT_ENDPOINT);
15872
+ const strict = sealed?.verification ?? "independent";
15873
+ const looser = VERIFICATION_STRICTNESS.indexOf(current.verification) > VERIFICATION_STRICTNESS.indexOf(strict);
15874
+ return {
15875
+ ...current,
15876
+ grants,
15877
+ configured,
15878
+ accountConfigured,
15879
+ defaultEndpoint,
15880
+ effectiveEndpoint: endpoint,
15881
+ endpointReason: endpoint === current.effectiveEndpoint ? current.endpointReason : SEAL_UNBLOCK,
15882
+ verification: looser ? strict : current.verification,
15883
+ unblocks,
15884
+ note: current.note ? `${current.note}; ${note}` : note
15885
+ };
15886
+ }
15887
+ function capAtRemotes(source, autonomy, cwd, target) {
15888
+ const claiming = source.entries().filter((entry) => entry.remotes?.length);
15760
15889
  if (claiming.length === 0)
15761
15890
  return autonomy;
15762
15891
  const remotes = target === undefined ? checkoutRemotes(cwd) : typeof target === "function" ? target() : target;
15763
15892
  if (remotes instanceof Error)
15764
- return capAt(autonomy, remotes, target === undefined ? "git" : "target", "a target that cannot be resolved never raises grants");
15893
+ return capAt(source, autonomy, remotes, target === undefined ? "git" : "target", "a target that cannot be resolved never raises grants");
15765
15894
  let capped = autonomy;
15766
15895
  for (const remote of Array.isArray(remotes) ? remotes : remotes.remotes)
15767
15896
  for (const entry of claiming) {
15768
15897
  const pattern = entry.remotes.find((item) => remoteMatches(item, remote.key));
15769
15898
  if (pattern)
15770
- capped = capAt(capped, { entry }, `remote ${remote.name} ${remote.url} (workspace ${entry.name} claims ${pattern})`, "a checkout never exceeds the workspace that owns its remote");
15899
+ capped = capAt(source, capped, { entry }, `remote ${remote.name} ${remote.url} (workspace ${entry.name} claims ${pattern})`, "a checkout never exceeds the workspace that owns its remote");
15771
15900
  }
15772
15901
  return capped;
15773
15902
  }
15774
- var grantsMatter = (kind) => !grantsOverride() && entriesIn(accountDir()).some((entry) => {
15775
- const autonomy = autonomyOf(entry);
15776
- return entry.remotes?.length || autonomy.grants[kind] === false || autonomy.configured.length > 0 && !autonomy.accountConfigured;
15777
- });
15778
- var remotesClaimed = (dir = accountDir()) => entriesIn(dir).some((entry) => entry.remotes?.length);
15779
- function targetClaims(target, dir = accountDir()) {
15903
+ var grantsMatter = (kind) => {
15904
+ if (grantsOverride())
15905
+ return false;
15906
+ const matters = entriesIn(accountDir()).some((entry) => {
15907
+ const autonomy = autonomyOf(entry);
15908
+ return entry.remotes?.length || autonomy.grants[kind] === false || needsAccount(autonomy);
15909
+ });
15910
+ const seal = sealOf();
15911
+ return matters || seal.state === "broken" && (seal.sealed ? seal.sealed.length > 0 : DEFAULT_GRANTS[kind] === false);
15912
+ };
15913
+ var authorityEntries = () => {
15914
+ const seal = sealOf();
15915
+ return [...entriesIn(accountDir()), ...seal.state === "broken" ? seal.sealed ?? [] : []];
15916
+ };
15917
+ function claimsIn(target, entries) {
15780
15918
  if (target instanceof Error)
15781
15919
  return target;
15782
- const claiming = entriesIn(dir).filter((entry) => entry.remotes?.length);
15920
+ const claiming = entries.filter((entry) => entry.remotes?.length);
15783
15921
  return target.remotes.flatMap((remote) => claiming.flatMap((entry) => {
15784
15922
  const pattern = entry.remotes.find((item) => remoteMatches(item, remote.key));
15785
15923
  return pattern ? [{ url: remote.url, workspace: entry.name, pattern }] : [];
@@ -15789,7 +15927,8 @@ var suggested = (kind) => kind === "merge" ? "verified" : "true";
15789
15927
  var accountHint = (workspace) => `set vcs.account for workspace "${workspace ?? "?"}" in ${configFilePath("workspaces.json")}`;
15790
15928
  var grantHint = (workspace, kind) => `ask the user to run, in their own terminal: workit grant set ${workspace ?? "<workspace>"} ${kind}=${suggested(kind)}`;
15791
15929
  function rawGrantDenial(cwd, kind, target) {
15792
- const claimed = remotesClaimed();
15930
+ const entries = authorityEntries();
15931
+ const claimed = entries.some((entry) => entry.remotes?.length);
15793
15932
  if (!grantsMatter(kind))
15794
15933
  return null;
15795
15934
  let resolved;
@@ -15814,14 +15953,10 @@ function rawGrantDenial(cwd, kind, target) {
15814
15953
  };
15815
15954
  if (!claimed || !lazy)
15816
15955
  return null;
15817
- const claims = targetClaims(lazy());
15956
+ const claims = claimsIn(lazy(), entries);
15818
15957
  if (claims instanceof Error)
15819
15958
  return { error: `${kind}: ${claims.message}`, unblock: "name a target workit can resolve" };
15820
- const entries = entriesIn(accountDir());
15821
- const strict = claims.find(({ workspace: name }) => {
15822
- const entry = entries.find((item) => item.name === name);
15823
- return entry && autonomyOf(entry).grants[kind] === false;
15824
- });
15959
+ const strict = claims.find(({ workspace: name }) => entries.some((item) => item.name === name && autonomyOf(item).grants[kind] === false));
15825
15960
  return strict ? {
15826
15961
  error: `${kind} is not granted for workspace ${strict.workspace}, which claims ${strict.url} (${strict.pattern})`,
15827
15962
  unblock: grantHint(strict.workspace, kind)
@@ -15833,9 +15968,9 @@ var raises = (kind, current, next) => {
15833
15968
  };
15834
15969
 
15835
15970
  // packages/workit-core/src/hooks/session-marker.ts
15836
- import { createHash as createHash12 } from "node:crypto";
15971
+ import { createHash as createHash13 } from "node:crypto";
15837
15972
  import fs15 from "node:fs";
15838
- import path22 from "node:path";
15973
+ import path23 from "node:path";
15839
15974
  var sessionMarkerFile = (input, session, store) => {
15840
15975
  let dir = store;
15841
15976
  if (dir === undefined) {
@@ -15844,8 +15979,8 @@ var sessionMarkerFile = (input, session, store) => {
15844
15979
  return null;
15845
15980
  dir = location.dir;
15846
15981
  }
15847
- const name = createHash12("sha256").update(`${input.host}\x00${session}`).digest("hex").slice(0, 32);
15848
- return path22.join(dir, "hooks", `skills-${name}.json`);
15982
+ const name = createHash13("sha256").update(`${input.host}\x00${session}`).digest("hex").slice(0, 32);
15983
+ return path23.join(dir, "hooks", `skills-${name}.json`);
15849
15984
  };
15850
15985
  var list = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
15851
15986
  var EMPTY = {
@@ -15880,7 +16015,7 @@ var parseMarker = (text) => {
15880
16015
  };
15881
16016
  var readSessionMarker = (file) => parseMarker(readRaw(file));
15882
16017
  var writeAtomic = (file, marker) => {
15883
- fs15.mkdirSync(path22.dirname(file), { recursive: true });
16018
+ fs15.mkdirSync(path23.dirname(file), { recursive: true });
15884
16019
  const temp = `${file}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
15885
16020
  try {
15886
16021
  fs15.writeFileSync(temp, JSON.stringify(marker));
@@ -16467,14 +16602,14 @@ var GIT_CONFIG_ENV = /^(?:GIT_(?:CONFIG\w*|DIR|COMMON_DIR|WORK_TREE|SSH|SSH_COMM
16467
16602
  var ASSIGNMENT = /^([A-Za-z_]\w*)=([\s\S]*)$/;
16468
16603
  var MAX_DEPTH = 4;
16469
16604
  var MAX_EXPANSIONS = 16;
16470
- var isAbsolute = (value) => path23.isAbsolute(value) || /^[A-Za-z]:[\\/]/.test(value) || value.startsWith("\\\\");
16605
+ var isAbsolute = (value) => path24.isAbsolute(value) || /^[A-Za-z]:[\\/]/.test(value) || value.startsWith("\\\\");
16471
16606
  var HERE = /^(?:\$PWD|\$\{PWD\}|\$\(\s*pwd\s*\)|`pwd`|\$\(\s*git\s+rev-parse\s+--show-toplevel\s*\))(?=$|[\\/])/;
16472
16607
  var joinDir = (base, raw) => {
16473
16608
  const next = raw.replace(HERE, ".");
16474
16609
  if (base === undefined || /[$`*?]/.test(next) || next === "-")
16475
16610
  return;
16476
- const expanded = next === "~" || next.startsWith("~/") ? path23.join(os5.homedir(), next.slice(1)) : next;
16477
- return base === null || isAbsolute(expanded) ? expanded : path23.join(base, expanded);
16611
+ const expanded = next === "~" || next.startsWith("~/") ? path24.join(os5.homedir(), next.slice(1)) : next;
16612
+ return base === null || isAbsolute(expanded) ? expanded : path24.join(base, expanded);
16478
16613
  };
16479
16614
  var rebase = (base, inner) => inner === null ? base : inner === undefined ? undefined : joinDir(base, inner);
16480
16615
  var cdTarget = (words) => {
@@ -17396,17 +17531,17 @@ var headSha2 = (repo) => {
17396
17531
  if (!git || git.reftable)
17397
17532
  return null;
17398
17533
  try {
17399
- const head = fs16.readFileSync(path23.join(git.gitDir, "HEAD"), "utf8").trim();
17534
+ const head = fs16.readFileSync(path24.join(git.gitDir, "HEAD"), "utf8").trim();
17400
17535
  if (/^[0-9a-f]{40,64}$/.test(head))
17401
17536
  return head;
17402
17537
  const ref = /^ref: (refs\/.+)$/.exec(head)?.[1];
17403
17538
  if (!ref)
17404
17539
  return null;
17405
- const common = path23.dirname(repo.location.dir);
17540
+ const common = path24.dirname(repo.location.dir);
17406
17541
  try {
17407
- return fs16.readFileSync(path23.join(common, ref), "utf8").trim() || null;
17542
+ return fs16.readFileSync(path24.join(common, ref), "utf8").trim() || null;
17408
17543
  } catch {}
17409
- const packed = fs16.readFileSync(path23.join(common, "packed-refs"), "utf8");
17544
+ const packed = fs16.readFileSync(path24.join(common, "packed-refs"), "utf8");
17410
17545
  return new RegExp(`^([0-9a-f]{40,64}) ${ref.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`, "m").exec(packed)?.[1] ?? null;
17411
17546
  } catch {
17412
17547
  return null;
@@ -17499,7 +17634,7 @@ var expandGitAliases = (root, invocation, cache = new Map, depth = 0) => {
17499
17634
  const sub = invocation.args[0];
17500
17635
  if (invocation.tool !== "git" || invocation.dir === undefined || !sub || sub.startsWith("-") || GIT_COMMANDS.has(sub) || depth >= MAX_DEPTH)
17501
17636
  return [invocation];
17502
- const dir = path23.resolve(root, invocation.dir ?? ".");
17637
+ const dir = path24.resolve(root, invocation.dir ?? ".");
17503
17638
  if (!fs16.existsSync(dir))
17504
17639
  return [invocation];
17505
17640
  const config = gitConfig(dir, invocation, cache);
@@ -17522,11 +17657,11 @@ var expandGitAliases = (root, invocation, cache = new Map, depth = 0) => {
17522
17657
  var normalizedUrl = (url, dir) => {
17523
17658
  const trimmed = url.trim();
17524
17659
  if (/^file:\/\//i.test(trimmed))
17525
- return path23.resolve(dir, trimmed.slice(7)).replace(/\/+$/, "").replace(/\.git$/, "");
17660
+ return path24.resolve(dir, trimmed.slice(7)).replace(/\/+$/, "").replace(/\.git$/, "");
17526
17661
  const scheme = /^[a-z][a-z0-9+.-]*:\/\//i.exec(trimmed);
17527
17662
  const scp = !scheme && /^(?:[^@/\\]+@)?[^/\\:]{2,}:/.test(trimmed);
17528
17663
  if (!scheme && !scp)
17529
- return path23.resolve(dir, trimmed).replace(/\/+$/, "").replace(/\.git$/, "");
17664
+ return path24.resolve(dir, trimmed).replace(/\/+$/, "").replace(/\.git$/, "");
17530
17665
  const value = scheme ? trimmed.slice(scheme[0].length).replace(/^[^@/]*@/, "").replace(/^([^/:]+):\d+(?=\/)/, "$1") : trimmed.replace(/^[^@/]*@/, "").replace(":", "/");
17531
17666
  return value.toLowerCase().replace(/\/{2,}/g, "/").replace(/^www\./, "").replace(/\/+$/, "").replace(/\.git$/, "");
17532
17667
  };
@@ -17754,7 +17889,7 @@ var actionsIn = (cwd, command, dialect, cache = new Map, all = false) => {
17754
17889
  const out = [];
17755
17890
  const repos = new Map;
17756
17891
  const repoFor = (relative) => {
17757
- const dir = path23.resolve(cwd, relative ?? ".");
17892
+ const dir = path24.resolve(cwd, relative ?? ".");
17758
17893
  if (!repos.has(dir)) {
17759
17894
  const repo = repoAt(dir);
17760
17895
  const workit = repo !== null && isWorkitWorkspace(repo);
@@ -17775,7 +17910,7 @@ var actionsIn = (cwd, command, dialect, cache = new Map, all = false) => {
17775
17910
  const action = rawAction(invocation);
17776
17911
  const at = !action ? null : repoFor(invocation.dir) ?? (all && invocation.tool !== "git" && explicitRepo(invocation.tool === "gh", "repo" in action && action.repo || "", invocation.env ?? {}) ? {
17777
17912
  repo: {
17778
- dir: path23.resolve(cwd, invocation.dir ?? "."),
17913
+ dir: path24.resolve(cwd, invocation.dir ?? "."),
17779
17914
  branch: null
17780
17915
  },
17781
17916
  workit: false
@@ -17848,13 +17983,13 @@ var messageOf = (segment, index) => {
17848
17983
  };
17849
17984
  var sameGitDir = (a, b, platform = process.platform) => {
17850
17985
  if (platform !== "win32")
17851
- return path23.posix.resolve(a) === path23.posix.resolve(b);
17852
- const fold = (value) => path23.win32.resolve(value).toLowerCase();
17986
+ return path24.posix.resolve(a) === path24.posix.resolve(b);
17987
+ const fold = (value) => path24.win32.resolve(value).toLowerCase();
17853
17988
  return fold(a) === fold(b);
17854
17989
  };
17855
17990
  var cdCommitCall = (input, command, target, repo) => {
17856
17991
  const { top, git, dir: store } = repo.location;
17857
- if (!top || !git || sameGitDir(git.gitDir, path23.dirname(store)) || repoAt(input.cwd)?.location.top === top)
17992
+ if (!top || !git || sameGitDir(git.gitDir, path24.dirname(store)) || repoAt(input.cwd)?.location.top === top)
17858
17993
  return null;
17859
17994
  const bare = command.replaceAll(/'[^']*'|"(?:[^"\\]|\\.)*"/gu, "").replaceAll("&&", "");
17860
17995
  if (/[;|&<>`$()\n\\]/u.test(bare))
@@ -17863,7 +17998,7 @@ var cdCommitCall = (input, command, target, repo) => {
17863
17998
  const commit = rest.at(-1);
17864
17999
  if (cd?.words[0] !== "cd" || cd.words.length !== 2 || cd.expands?.length || !commit)
17865
18000
  return null;
17866
- if (path23.resolve(input.cwd, cd.words[1]) !== target)
18001
+ if (path24.resolve(input.cwd, cd.words[1]) !== target)
17867
18002
  return null;
17868
18003
  if (rest.some((each) => each.redirects.length || each.stdin?.length || each.group))
17869
18004
  return null;
@@ -17930,7 +18065,7 @@ var commitRefusal = (input, command, dialect, { action, repo, invocation, workit
17930
18065
  } catch {}
17931
18066
  if (guarded && !switches)
17932
18067
  return `workit: raw ${quote("git commit")} on ${repo.branch}, a protected branch. Branch first: ${quote("workit git branch --kind feature --slug <slug>")} (uncommitted changes come along), then ${quote("workit git commit -m '<msg>' -- <paths>")}.`;
17933
- const call = action.amend || dialect !== "posix" || typeof invocation.dir !== "string" ? null : cdCommitCall(input, command, path23.resolve(input.cwd, invocation.dir), repo);
18068
+ const call = action.amend || dialect !== "posix" || typeof invocation.dir !== "string" ? null : cdCommitCall(input, command, path24.resolve(input.cwd, invocation.dir), repo);
17934
18069
  return call && `workit: no ${quote("cd … &&")} chain; run ${quote(call)}.`;
17935
18070
  };
17936
18071
  function rawGitPre(input, command, options = {}) {
@@ -18028,9 +18163,9 @@ var grantRefusal = (action, repo, invocation, cache) => {
18028
18163
  return null;
18029
18164
  };
18030
18165
  var localTag = (repo, name) => {
18031
- const common = path23.dirname(repo.location.dir);
18166
+ const common = path24.dirname(repo.location.dir);
18032
18167
  try {
18033
- return fs16.existsSync(path23.join(common, "refs/tags", name)) || fs16.readFileSync(path23.join(common, "packed-refs"), "utf8").includes(` refs/tags/${name}
18168
+ return fs16.existsSync(path24.join(common, "refs/tags", name)) || fs16.readFileSync(path24.join(common, "packed-refs"), "utf8").includes(` refs/tags/${name}
18034
18169
  `);
18035
18170
  } catch {
18036
18171
  return false;
@@ -18050,8 +18185,8 @@ var analysisDenial = (error) => ({
18050
18185
  });
18051
18186
  var NEXT_COMMAND = "next";
18052
18187
  var MARKER_TTL_SECONDS = 3600;
18053
- var markerFile = (repo, session, key) => path23.join(repo.location.dir, "hooks", `commit-${createHash13("sha256").update(`${session}\x00${key}`).digest("hex").slice(0, 32)}.json`);
18054
- var callKey = (toolUseId, command) => toolUseId ?? `cmd:${createHash13("sha256").update(command).digest("hex")}`;
18188
+ var markerFile = (repo, session, key) => path24.join(repo.location.dir, "hooks", `commit-${createHash14("sha256").update(`${session}\x00${key}`).digest("hex").slice(0, 32)}.json`);
18189
+ var callKey = (toolUseId, command) => toolUseId ?? `cmd:${createHash14("sha256").update(command).digest("hex")}`;
18055
18190
  function noteRawCommit(input, command, key) {
18056
18191
  try {
18057
18192
  if (!input.session.id || !/\bcommit\b/.test(command))
@@ -18061,7 +18196,7 @@ function noteRawCommit(input, command, key) {
18061
18196
  if (action.kind !== "commit")
18062
18197
  continue;
18063
18198
  const file = markerFile(repo, input.session.id, key);
18064
- fs16.mkdirSync(path23.dirname(file), { recursive: true });
18199
+ fs16.mkdirSync(path24.dirname(file), { recursive: true });
18065
18200
  fs16.writeFileSync(file, `${JSON.stringify({ head: headSha2(repo), at })}
18066
18201
  `);
18067
18202
  }
@@ -18302,7 +18437,7 @@ var judgedDir = (root, dir) => {
18302
18437
  return null;
18303
18438
  if (dir === null)
18304
18439
  return root;
18305
- const resolved = path24.resolve(root, dir);
18440
+ const resolved = path25.resolve(root, dir);
18306
18441
  return existsSync9(resolved) && inWorkitWorkspace(resolved) ? resolved : null;
18307
18442
  };
18308
18443
  var shellBranchPolicyViolation = (root, command, dialect = "posix") => {
@@ -18425,7 +18560,7 @@ var userOnlyWorkitCall = (command, dialect = "posix") => {
18425
18560
  // packages/workit-core/src/core/heavy-rules.ts
18426
18561
  import fs17 from "node:fs";
18427
18562
  import os6 from "node:os";
18428
- import path25 from "node:path";
18563
+ import path26 from "node:path";
18429
18564
  var EMPTY2 = () => ({ deny: [], allow: [] });
18430
18565
  var readText3 = (file) => {
18431
18566
  try {
@@ -18466,19 +18601,19 @@ function parseJsonc(text) {
18466
18601
  return JSON.parse(out.replace(/,(\s*[}\]])/gu, "$1"));
18467
18602
  }
18468
18603
  function gitTop(cwd) {
18469
- for (let dir = path25.resolve(cwd);; dir = path25.dirname(dir)) {
18470
- if (fs17.existsSync(path25.join(dir, ".git")))
18604
+ for (let dir = path26.resolve(cwd);; dir = path26.dirname(dir)) {
18605
+ if (fs17.existsSync(path26.join(dir, ".git")))
18471
18606
  return dir;
18472
- if (path25.dirname(dir) === dir)
18607
+ if (path26.dirname(dir) === dir)
18473
18608
  return null;
18474
18609
  }
18475
18610
  }
18476
18611
  var projectDirs = (cwd) => {
18477
18612
  const top = gitTop(cwd);
18478
18613
  const dirs = [];
18479
- for (let dir = path25.resolve(cwd);; dir = path25.dirname(dir)) {
18614
+ for (let dir = path26.resolve(cwd);; dir = path26.dirname(dir)) {
18480
18615
  dirs.push(dir);
18481
- if (!top || dir === top || path25.dirname(dir) === dir)
18616
+ if (!top || dir === top || path26.dirname(dir) === dir)
18482
18617
  return dirs;
18483
18618
  }
18484
18619
  };
@@ -18490,12 +18625,12 @@ var CLAUDE_MANAGED = {
18490
18625
  };
18491
18626
  function claudeSettingsFiles(cwd, env, platform = process.platform) {
18492
18627
  const project = env.CLAUDE_PROJECT_DIR || gitTop(cwd) || cwd;
18493
- const user = env.CLAUDE_CONFIG_DIR || path25.join(homeOf(env), ".claude");
18628
+ const user = env.CLAUDE_CONFIG_DIR || path26.join(homeOf(env), ".claude");
18494
18629
  return [
18495
18630
  ...CLAUDE_MANAGED[platform] ? [CLAUDE_MANAGED[platform]] : [],
18496
- path25.join(user, "settings.json"),
18497
- path25.join(project, ".claude", "settings.json"),
18498
- path25.join(project, ".claude", "settings.local.json")
18631
+ path26.join(user, "settings.json"),
18632
+ path26.join(project, ".claude", "settings.json"),
18633
+ path26.join(project, ".claude", "settings.local.json")
18499
18634
  ];
18500
18635
  }
18501
18636
  var bashPattern = (entry) => {
@@ -18585,10 +18720,10 @@ var opencodeConfig = (value, rules) => {
18585
18720
  function opencodeRules(cwd, env = process.env) {
18586
18721
  const rules = EMPTY2();
18587
18722
  try {
18588
- const config = env.XDG_CONFIG_HOME || path25.join(homeOf(env), ".config");
18723
+ const config = env.XDG_CONFIG_HOME || path26.join(homeOf(env), ".config");
18589
18724
  const files = [
18590
- ...OPENCODE_NAMES.map((name) => path25.join(config, "opencode", name)),
18591
- ...projectDirs(cwd).flatMap((dir) => OPENCODE_NAMES.flatMap((name) => [path25.join(dir, name), path25.join(dir, ".opencode", name)])),
18725
+ ...OPENCODE_NAMES.map((name) => path26.join(config, "opencode", name)),
18726
+ ...projectDirs(cwd).flatMap((dir) => OPENCODE_NAMES.flatMap((name) => [path26.join(dir, name), path26.join(dir, ".opencode", name)])),
18592
18727
  ...env.OPENCODE_CONFIG ? [env.OPENCODE_CONFIG] : []
18593
18728
  ];
18594
18729
  for (const file of files) {
@@ -18632,9 +18767,9 @@ var codexRule = (body) => {
18632
18767
  function codexRules(cwd, env = process.env) {
18633
18768
  const rules = EMPTY2();
18634
18769
  try {
18635
- const home = env.CODEX_HOME || path25.join(homeOf(env), ".codex");
18770
+ const home = env.CODEX_HOME || path26.join(homeOf(env), ".codex");
18636
18771
  const top = gitTop(cwd) ?? cwd;
18637
- for (const dir of [path25.join(home, "rules"), path25.join(top, ".codex", "rules")]) {
18772
+ for (const dir of [path26.join(home, "rules"), path26.join(top, ".codex", "rules")]) {
18638
18773
  let files;
18639
18774
  try {
18640
18775
  files = fs17.readdirSync(dir).filter((name) => name.endsWith(".rules"));
@@ -18644,7 +18779,7 @@ function codexRules(cwd, env = process.env) {
18644
18779
  return "unreadable";
18645
18780
  }
18646
18781
  for (const name of files) {
18647
- const text = readText3(path25.join(dir, name)) ?? "";
18782
+ const text = readText3(path26.join(dir, name)) ?? "";
18648
18783
  for (const part of text.split(/\bprefix_rule\s*\(/u).slice(1)) {
18649
18784
  const rule = codexRule(part);
18650
18785
  if (!rule)
@@ -18663,8 +18798,8 @@ function cursorRules(cwd, env = process.env) {
18663
18798
  try {
18664
18799
  const top = gitTop(cwd) ?? cwd;
18665
18800
  for (const file of [
18666
- path25.join(homeOf(env), ".cursor", "cli-config.json"),
18667
- path25.join(top, ".cursor", "cli.json")
18801
+ path26.join(homeOf(env), ".cursor", "cli-config.json"),
18802
+ path26.join(top, ".cursor", "cli.json")
18668
18803
  ]) {
18669
18804
  const text = readText3(file);
18670
18805
  if (text === null)
@@ -18739,10 +18874,10 @@ function wrapAllowed(read, words, command, options = {}) {
18739
18874
 
18740
18875
  // packages/workit-core/src/core/heavy.ts
18741
18876
  import fs18 from "node:fs";
18742
- import path26 from "node:path";
18877
+ import path27 from "node:path";
18743
18878
  var stateDir = (env, platform = process.platform) => stateDir3(env, platform);
18744
18879
  var HEAVY_COMMANDS_FILE = "heavy-commands.json";
18745
- var heavyCommandsFile = (env) => path26.join(stateDir(env), HEAVY_COMMANDS_FILE);
18880
+ var heavyCommandsFile = (env) => path27.join(stateDir(env), HEAVY_COMMANDS_FILE);
18746
18881
  var HEAVY_SCRIPT = /^(?:test|tests|t|tst|unit|integration|e2e|coverage|cov|lint|eslint|typecheck|type-check|types|tsc|check|verify|validate|build|compile|bundle|ci|sonar|cypress|playwright|jest|vitest|mocha|bench|benchmark|all)(?:$|[:_.-])/iu;
18747
18882
  var INFO_FLAGS = new Set(["--version", "-v", "-V", "--help", "-h", "help", "version"]);
18748
18883
  var WATCH_FLAG = /^(?:--watch(?:All)?(?:=.*)?|-w|--serve)$/u;
@@ -19017,7 +19152,7 @@ function machinePatterns(env) {
19017
19152
  return isRecord4(value) ? stringList(value.patterns) : [];
19018
19153
  }
19019
19154
  function repoPatterns(cwd) {
19020
- return repoHeavyCommands(gitTop(cwd) ?? path26.resolve(cwd));
19155
+ return repoHeavyCommands(gitTop(cwd) ?? path27.resolve(cwd));
19021
19156
  }
19022
19157
  function heavyLines(lines, options) {
19023
19158
  const found = [];
@@ -19095,12 +19230,12 @@ function heavyPlan(command, options) {
19095
19230
  }
19096
19231
  function workitOnPath(env = process.env) {
19097
19232
  const names = process.platform === "win32" ? ["workit.exe", "workit.cmd", "workit"] : ["workit"];
19098
- for (const dir of (env.PATH ?? "").split(path26.delimiter))
19233
+ for (const dir of (env.PATH ?? "").split(path27.delimiter))
19099
19234
  for (const name of names) {
19100
19235
  if (!dir)
19101
19236
  continue;
19102
19237
  try {
19103
- fs18.accessSync(path26.join(dir, name), fs18.constants.X_OK);
19238
+ fs18.accessSync(path27.join(dir, name), fs18.constants.X_OK);
19104
19239
  return true;
19105
19240
  } catch {}
19106
19241
  }
@@ -19164,16 +19299,16 @@ var splitDenial = (plan) => ({
19164
19299
  unblock: plan.unblock
19165
19300
  });
19166
19301
  // packages/workit-core/src/hooks/write-gate.ts
19167
- import { existsSync as existsSync10, readdirSync as readdirSync3, readFileSync as readFileSync9, realpathSync as realpathSync7, statSync as statSync3 } from "node:fs";
19302
+ import { existsSync as existsSync10, readdirSync as readdirSync3, readFileSync as readFileSync10, realpathSync as realpathSync7, statSync as statSync3 } from "node:fs";
19168
19303
  import os8 from "node:os";
19169
- import path28 from "node:path";
19304
+ import path29 from "node:path";
19170
19305
 
19171
19306
  // packages/workit-core/src/core/live-session.ts
19172
19307
  import { spawnSync as spawnSync15 } from "node:child_process";
19173
- import { createHash as createHash14 } from "node:crypto";
19308
+ import { createHash as createHash15 } from "node:crypto";
19174
19309
  import fs19 from "node:fs";
19175
19310
  import os7 from "node:os";
19176
- import path27 from "node:path";
19311
+ import path28 from "node:path";
19177
19312
  var LIVE_SESSION_TTL_MS = 15 * 60000;
19178
19313
  var HEARTBEAT_EVERY_MS = 30000;
19179
19314
  var liveProbe = {
@@ -19247,15 +19382,15 @@ var liveOwner = (input, transport, env = process.env) => {
19247
19382
  };
19248
19383
  };
19249
19384
  var checkoutOf = (target) => {
19250
- let dir = path27.resolve(target);
19251
- while (!fs19.existsSync(dir) && path27.dirname(dir) !== dir)
19252
- dir = path27.dirname(dir);
19385
+ let dir = path28.resolve(target);
19386
+ while (!fs19.existsSync(dir) && path28.dirname(dir) !== dir)
19387
+ dir = path28.dirname(dir);
19253
19388
  if (fs19.existsSync(dir) && !fs19.statSync(dir).isDirectory())
19254
- dir = path27.dirname(dir);
19255
- const parts = dir.split(path27.sep);
19389
+ dir = path28.dirname(dir);
19390
+ const parts = dir.split(path28.sep);
19256
19391
  const dotGit = parts.lastIndexOf(".git");
19257
19392
  if (dotGit > 0)
19258
- dir = parts.slice(0, dotGit).join(path27.sep) || path27.sep;
19393
+ dir = parts.slice(0, dotGit).join(path28.sep) || path28.sep;
19259
19394
  const location = resolveStore(dir);
19260
19395
  if (location instanceof Error || !location.shared || !location.top)
19261
19396
  return null;
@@ -19265,9 +19400,9 @@ var checkoutOf = (target) => {
19265
19400
  } catch {}
19266
19401
  return top;
19267
19402
  };
19268
- var markerFile2 = (top) => path27.join(resolveStateDir(), "live-sessions", `${createHash14("sha256").update(checkoutKey(top)).digest("hex").slice(0, 32)}.json`);
19403
+ var markerFile2 = (top) => path28.join(resolveStateDir(), "live-sessions", `${createHash15("sha256").update(checkoutKey(top)).digest("hex").slice(0, 32)}.json`);
19269
19404
  var checkoutKey = (top, platform = process.platform) => {
19270
- let key = path27.resolve(top);
19405
+ let key = path28.resolve(top);
19271
19406
  try {
19272
19407
  key = fs19.realpathSync.native(key);
19273
19408
  } catch {}
@@ -19362,7 +19497,7 @@ var claimLiveSession = (target, owner, deps = {}) => {
19362
19497
  checkout,
19363
19498
  heartbeatAt: now.toISOString()
19364
19499
  };
19365
- fs19.mkdirSync(path27.dirname(file), { recursive: true });
19500
+ fs19.mkdirSync(path28.dirname(file), { recursive: true });
19366
19501
  const temp = `${file}.${process.pid}.tmp`;
19367
19502
  fs19.writeFileSync(temp, JSON.stringify(marker));
19368
19503
  fs19.renameSync(temp, file);
@@ -19372,24 +19507,24 @@ var claimLiveSession = (target, owner, deps = {}) => {
19372
19507
  // packages/workit-core/src/hooks/write-gate.ts
19373
19508
  var NONE3 = { kind: "none" };
19374
19509
  var CASE_INSENSITIVE = process.platform === "darwin" || process.platform === "win32";
19375
- var canonical3 = (file) => {
19510
+ var canonical4 = (file) => {
19376
19511
  let rest = "";
19377
- for (let dir = path28.resolve(file);; dir = path28.dirname(dir)) {
19512
+ for (let dir = path29.resolve(file);; dir = path29.dirname(dir)) {
19378
19513
  try {
19379
- return path28.join(realpathSync7.native(dir), rest);
19514
+ return path29.join(realpathSync7.native(dir), rest);
19380
19515
  } catch {
19381
- if (path28.dirname(dir) === dir)
19382
- return path28.resolve(file);
19383
- rest = rest ? path28.join(path28.basename(dir), rest) : path28.basename(dir);
19516
+ if (path29.dirname(dir) === dir)
19517
+ return path29.resolve(file);
19518
+ rest = rest ? path29.join(path29.basename(dir), rest) : path29.basename(dir);
19384
19519
  }
19385
19520
  }
19386
19521
  };
19387
19522
  var exempt = (cwd, root, file, plans) => {
19388
19523
  const fold = (value) => CASE_INSENSITIVE ? value.toLowerCase() : value;
19389
- const relative = path28.relative(fold(canonical3(root)), fold(canonical3(path28.resolve(cwd, file))));
19390
- if (relative.startsWith("..") || path28.isAbsolute(relative))
19524
+ const relative = path29.relative(fold(canonical4(root)), fold(canonical4(path29.resolve(cwd, file))));
19525
+ if (relative.startsWith("..") || path29.isAbsolute(relative))
19391
19526
  return true;
19392
- const posix = relative.split(path28.sep).join("/");
19527
+ const posix = relative.split(path29.sep).join("/");
19393
19528
  const segments = posix.split("/");
19394
19529
  return /\.mdx?$/i.test(posix) || segments[0] === "docs" || segments.includes("plans") || [...plans].some((plan) => fold(plan) === posix);
19395
19530
  };
@@ -19505,8 +19640,8 @@ var WRAPPERS2 = {
19505
19640
  bunx: "p"
19506
19641
  };
19507
19642
  var INTERPRETERS = /^(?:python[\d.]*|node|bun|deno|ruby|perl|php|tsx|ts-node)$/;
19508
- var isConfigDir = (file) => configDirs().some((dir) => canonical3(dir) === canonical3(file));
19509
- var isRoot = (file) => isConfigDir(file) || /^(?:issued[^\\/]*|approvals)$/.test(path28.relative(canonical3(resolveStateDir()), canonical3(file)));
19643
+ var isConfigDir = (file) => configDirs().some((dir) => canonical4(dir) === canonical4(file));
19644
+ var isRoot = (file) => isConfigDir(file) || /^(?:issued[^\\/]*|approvals)$/.test(path29.relative(canonical4(resolveStateDir()), canonical4(file)));
19510
19645
  var READ_CALLS = /^(?:print|log|info|warn|error|debug|puts|readdir(?:Sync)?|listdir|scandir|iterdir|glob|l?stat(?:Sync)?|exists(?:Sync)?|isdir|isfile|is_dir|is_file|access(?:Sync)?|realpath(?:Sync)?|dirname|basename|relative|str|repr|len)$/;
19511
19646
  var MUTATING_CALLS = /^(?:renames?(?:Sync)?|move|copy(?:2|file|tree|File)?(?:Sync)?|cp(?:Sync)?|rm(?:tree|dir|Sync|dirSync)?|unlink(?:Sync)?|remove(?:dirs)?|mkdirs?(?:Sync)?|makedirs|mkdtemp(?:Sync)?|(?:sym|hard)?link(?:Sync|_to)?|write\w*|append\w*|truncate(?:Sync)?|ch(?:mod|own)(?:Sync)?|touch|open(?:Sync)?|dump|save|extractall|unpack_archive|put_contents|mv|FileUtils)$/;
19512
19647
  var PATH_CALLS = /^(?:join|resolve|normalize|abspath|expanduser|expandvars|Path|PurePath|fspath)$/;
@@ -19817,10 +19952,10 @@ var linkSources = (args, at) => {
19817
19952
  const sources = names.filter((name, index) => into >= 0 ? name !== dest : index < names.length - 1 || names.length === 1);
19818
19953
  const target = dest === undefined ? null : at(dest);
19819
19954
  const symbolic = args.some((arg) => /^-[a-zA-Z]*s|^--symbolic$/.test(arg));
19820
- const base = target === null ? null : into >= 0 || sources.length > 1 || existsSync10(target) || /[\\/]$/.test(dest ?? "") ? target : path28.dirname(target);
19955
+ const base = target === null ? null : into >= 0 || sources.length > 1 || existsSync10(target) || /[\\/]$/.test(dest ?? "") ? target : path29.dirname(target);
19821
19956
  return sources.flatMap((source) => {
19822
- if (symbolic && base !== null && !path28.isAbsolute(homeExpanded(source)))
19823
- return [path28.resolve(base, source)];
19957
+ if (symbolic && base !== null && !path29.isAbsolute(homeExpanded(source)))
19958
+ return [path29.resolve(base, source)];
19824
19959
  const resolved = at(source);
19825
19960
  return resolved ? [resolved] : [];
19826
19961
  });
@@ -19849,7 +19984,7 @@ var shellWrites = (command, depth = 0) => {
19849
19984
  return { writes: true, targets: unknown ? null : targets };
19850
19985
  };
19851
19986
  var cache2 = new Map;
19852
- var planKeyOf = (root, plans) => [...plans].map((file) => fileSignature(path28.resolve(root, file)) ?? "-").join("\x00");
19987
+ var planKeyOf = (root, plans) => [...plans].map((file) => fileSignature(path29.resolve(root, file)) ?? "-").join("\x00");
19853
19988
  var gateFor = (cwd) => {
19854
19989
  const store = new TaskReader(cwd);
19855
19990
  const listed = store.listTaskIndex();
@@ -19929,13 +20064,13 @@ var gitMutationDirs = (cwd, command, dialect) => {
19929
20064
  return [];
19930
20065
  if (sub === "stash" && ["list", "show"].includes(rest[0] ?? ""))
19931
20066
  return [];
19932
- return [path28.resolve(cwd, invocation.dir ?? ".")];
20067
+ return [path29.resolve(cwd, invocation.dir ?? ".")];
19933
20068
  });
19934
20069
  };
19935
20070
  var CD2 = new Set(["cd", "chdir", "set-location", "sl"]);
19936
20071
  var PUSHD2 = new Set(["pushd", "push-location"]);
19937
20072
  var POPD2 = new Set(["popd", "pop-location"]);
19938
- var UNKNOWN_DIR = path28.resolve(path28.parse(process.cwd()).root, ".workit-unknown-dir");
20073
+ var UNKNOWN_DIR = path29.resolve(path29.parse(process.cwd()).root, ".workit-unknown-dir");
19939
20074
  var cdInto = (dir, words, strict = false, vars = new Map, globs = false) => {
19940
20075
  const lost = strict ? UNKNOWN_DIR : undefined;
19941
20076
  const found = words.slice(1).find((word) => !word.startsWith("-") || word === "-");
@@ -19945,7 +20080,7 @@ var cdInto = (dir, words, strict = false, vars = new Map, globs = false) => {
19945
20080
  return lost;
19946
20081
  if (dir === undefined)
19947
20082
  return lost;
19948
- return target === undefined ? os8.homedir() : path28.resolve(dir, target);
20083
+ return target === undefined ? os8.homedir() : path29.resolve(dir, target);
19949
20084
  };
19950
20085
  var quoteWord2 = (word) => /^[\w@%+=:,./-]+$/.test(word) ? word : `'${word.replaceAll("'", "'\\''")}'`;
19951
20086
  var expandVars = (text, vars) => vars.size === 0 || !text.includes("$") ? text : text.replace(/\$(?:(\w+)|\{(\w+)\})/g, (whole, bare, braced) => {
@@ -20080,7 +20215,7 @@ var untrustedVars = (segments) => {
20080
20215
  }
20081
20216
  return { all, names };
20082
20217
  };
20083
- var UNKNOWN_VAR = path28.resolve(path28.parse(process.cwd()).root, ".workit-unknown-var");
20218
+ var UNKNOWN_VAR = path29.resolve(path29.parse(process.cwd()).root, ".workit-unknown-var");
20084
20219
  var REFERENCE = /\$\{(\w+)[^}]*\}|\$(\w+)|\$\([^)]*\)?|`[^`]*`?/g;
20085
20220
  var unresolvedRefs = (text) => [
20086
20221
  ...new Set([...text.matchAll(REFERENCE)].map((match) => {
@@ -20090,7 +20225,7 @@ var unresolvedRefs = (text) => [
20090
20225
  ];
20091
20226
  var unknownVarTarget = (text) => {
20092
20227
  const refs = unresolvedRefs(text);
20093
- return path28.join(UNKNOWN_VAR, (refs.length > 0 ? refs : [text]).map(encodeURIComponent).join("+"));
20228
+ return path29.join(UNKNOWN_VAR, (refs.length > 0 ? refs : [text]).map(encodeURIComponent).join("+"));
20094
20229
  };
20095
20230
  var applyOperator = (value, operator) => {
20096
20231
  if (operator === "")
@@ -20151,12 +20286,12 @@ var mktempPath = (value, dir) => {
20151
20286
  if (base === null && (temp || template === undefined))
20152
20287
  base = os8.tmpdir();
20153
20288
  const name = homeExpanded(template ?? "tmp.XXXXXXXXXX");
20154
- if (path28.isAbsolute(name))
20289
+ if (path29.isAbsolute(name))
20155
20290
  return name;
20156
20291
  const from = base === null ? dir : homeExpanded(base);
20157
- if (from === undefined || !path28.isAbsolute(from) && dir === undefined)
20292
+ if (from === undefined || !path29.isAbsolute(from) && dir === undefined)
20158
20293
  return null;
20159
- return path28.resolve(dir ?? from, from, name);
20294
+ return path29.resolve(dir ?? from, from, name);
20160
20295
  };
20161
20296
  var homeExpanded = (file) => {
20162
20297
  const match = /^(?:~|\$HOME|\$\{HOME\})(?=\/|$)/.exec(file);
@@ -20177,9 +20312,9 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
20177
20312
  const home = homeExpanded(text);
20178
20313
  if (strict && unresolvedRefs(home).length > 0)
20179
20314
  return [unknownVarTarget(home)];
20180
- if (path28.isAbsolute(home))
20315
+ if (path29.isAbsolute(home))
20181
20316
  return [home];
20182
- return base === undefined ? [] : [path28.resolve(base, home)];
20317
+ return base === undefined ? [] : [path29.resolve(base, home)];
20183
20318
  });
20184
20319
  const at = (file) => {
20185
20320
  const all = atAll(file);
@@ -20327,7 +20462,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
20327
20462
  return [made];
20328
20463
  try {
20329
20464
  const stat = statSync3(script);
20330
- const text = stat.isFile() && stat.size <= 262144 ? readFileSync9(script, "utf8") : "\x00";
20465
+ const text = stat.isFile() && stat.size <= 262144 ? readFileSync10(script, "utf8") : "\x00";
20331
20466
  return text.includes("\x00") ? [] : [text];
20332
20467
  } catch {
20333
20468
  return [];
@@ -20370,7 +20505,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
20370
20505
  index
20371
20506
  }));
20372
20507
  const homes = /homedir\(|expanduser\(|Path\.home\(|['"]HOME['"]|env\.HOME|\$HOME|~/.test(text);
20373
- const under = (word) => homes ? [path28.join(homeExpanded("~"), word.replace(/^~/, ""))] : [];
20508
+ const under = (word) => homes ? [path29.join(homeExpanded("~"), word.replace(/^~/, ""))] : [];
20374
20509
  const found = [
20375
20510
  ...[...text.matchAll(PATHS)].flatMap(({ 0: word, index }) => [...atAll(word), ...under(word)].map((file) => ({ file, index }))),
20376
20511
  ...joined.flatMap(({ word, index }) => under(word).map((file) => ({ file, index })))
@@ -20409,7 +20544,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
20409
20544
  for (const file of opaque ?? [])
20410
20545
  for (const resolved of atAll(file))
20411
20546
  if (!quiet || !isRoot(resolved))
20412
- targets.push(file === "." ? path28.join(resolved, here) : resolved);
20547
+ targets.push(file === "." ? path29.join(resolved, here) : resolved);
20413
20548
  const ln = words.findIndex((word) => /^ln$/i.test(word.split(/[\\/]/).at(-1) ?? ""));
20414
20549
  const lnArgs = words.slice(ln + 1);
20415
20550
  if (ln >= 0 && words.slice(0, ln).every((word) => PREFIXES2.has(word)) && (strict !== "registry" || !lnArgs.some((arg) => /^-[a-zA-Z]*s|^--symbolic$/.test(arg))))
@@ -20421,7 +20556,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
20421
20556
  const edits = editsOf(body);
20422
20557
  if (edits === null) {
20423
20558
  if (dir !== undefined)
20424
- targets.push(path28.join(dir, DIR_TARGET));
20559
+ targets.push(path29.join(dir, DIR_TARGET));
20425
20560
  } else
20426
20561
  for (const file of edits)
20427
20562
  targets.push(...atAll(file));
@@ -20429,7 +20564,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
20429
20564
  for (const invocation of workitInvocations(body.map(quoteWord2).join(" "), "posix")) {
20430
20565
  const { at: runsIn, args } = workitCwd(dir, invocation, atAll);
20431
20566
  if (args[0] === "git" && MUTATING_WORKIT_GIT.has(args[1] ?? "") && !inert(args.slice(2), ""))
20432
- targets.push(...runsIn.map((runs) => path28.join(runs, DIR_TARGET)));
20567
+ targets.push(...runsIn.map((runs) => path29.join(runs, DIR_TARGET)));
20433
20568
  }
20434
20569
  }
20435
20570
  return targets;
@@ -20451,7 +20586,7 @@ var shellMutationTargets = (cwd, command, dialect = "posix", strict = false) =>
20451
20586
  const env = new Map(strict === "registry" ? [...command.matchAll(/\$\{?([A-Za-z_]\w*)/g)].filter((match) => !/^(?:OLD)?PWD$/.test(match[1])).map((match) => [match[1], process.env[match[1]] ?? ""]) : []);
20452
20587
  return [
20453
20588
  ...segmentTargets(cwd, command, dialect, 0, strict, env),
20454
- ...gitMutationDirs(cwd, command, dialect).map((dir) => path28.join(dir, DIR_TARGET))
20589
+ ...gitMutationDirs(cwd, command, dialect).map((dir) => path29.join(dir, DIR_TARGET))
20455
20590
  ];
20456
20591
  } catch (error) {
20457
20592
  if (strict === "registry")
@@ -20490,7 +20625,7 @@ var liveDeny = ({ marker, checkout, ageMs, file }) => {
20490
20625
  var guarded = (targets) => {
20491
20626
  const seen = new Set;
20492
20627
  return targets.filter((target) => {
20493
- const dir = path28.dirname(target);
20628
+ const dir = path29.dirname(target);
20494
20629
  if (seen.has(dir))
20495
20630
  return false;
20496
20631
  seen.add(dir);
@@ -20511,15 +20646,16 @@ var claimAll = (owner, targets, deps) => {
20511
20646
  for (const target of guarded(targets))
20512
20647
  claimLiveSession(target, owner, deps);
20513
20648
  };
20514
- var liveTargets = (cwd, paths) => paths?.length ? paths.map((file) => path28.resolve(cwd, file)) : [path28.join(cwd, DIR_TARGET)];
20649
+ var liveTargets = (cwd, paths) => paths?.length ? paths.map((file) => path29.resolve(cwd, file)) : [path29.join(cwd, DIR_TARGET)];
20650
+ var CONFIG_FILES = ["workspaces.json", SEAL_FILE];
20515
20651
  var configDirs = () => [resolveConfigDir(), grantsDir()];
20516
20652
  var globbed = (cwd, target, state, configs) => {
20517
20653
  if (!/[*?[]/.test(target))
20518
20654
  return [];
20519
- const raw = path28.resolve(cwd, target).split(path28.sep);
20655
+ const raw = path29.resolve(cwd, target).split(path29.sep);
20520
20656
  const literal = raw.findIndex((part) => /[*?[]/.test(part));
20521
20657
  const pattern = [
20522
- ...canonical3(raw.slice(0, literal).join(path28.sep) || path28.sep).replace(/[\\/]+$/, "").split(path28.sep),
20658
+ ...canonical4(raw.slice(0, literal).join(path29.sep) || path29.sep).replace(/[\\/]+$/, "").split(path29.sep),
20523
20659
  ...raw.slice(literal)
20524
20660
  ];
20525
20661
  const segment = (glob, name) => {
@@ -20530,7 +20666,7 @@ var globbed = (cwd, target, state, configs) => {
20530
20666
  }
20531
20667
  };
20532
20668
  const hit = (file, below) => {
20533
- const parts = canonical3(file).split(path28.sep);
20669
+ const parts = canonical4(file).split(path29.sep);
20534
20670
  return (below ? pattern.length >= parts.length : pattern.length === parts.length) && parts.every((part, index) => segment(pattern[index], part));
20535
20671
  };
20536
20672
  let roots = [];
@@ -20538,8 +20674,8 @@ var globbed = (cwd, target, state, configs) => {
20538
20674
  roots = readdirSync3(state).filter((name) => /^(?:issued|approvals$)/.test(name));
20539
20675
  } catch {}
20540
20676
  return [
20541
- ...roots.map((name) => path28.join(state, name)).filter((root) => hit(root, true)),
20542
- ...configs.flatMap((dir) => [dir, path28.join(dir, "workspaces.json")]).filter((file) => hit(file, false))
20677
+ ...roots.map((name) => path29.join(state, name)).filter((root) => hit(root, true)),
20678
+ ...configs.flatMap((dir) => [dir, ...CONFIG_FILES.map((name) => path29.join(dir, name))]).filter((file) => hit(file, false))
20543
20679
  ];
20544
20680
  };
20545
20681
  var guardedInodes = (state, configs) => {
@@ -20553,14 +20689,15 @@ var guardedInodes = (state, configs) => {
20553
20689
  seen.set(`${stat.dev}:${stat.ino}`, registry);
20554
20690
  else if (stat?.isDirectory())
20555
20691
  for (const name of readdirSync3(file))
20556
- add(path28.join(file, name), registry);
20692
+ add(path29.join(file, name), registry);
20557
20693
  };
20558
20694
  try {
20559
20695
  for (const dir of configs)
20560
- add(path28.join(dir, "workspaces.json"), "grants");
20696
+ for (const name of CONFIG_FILES)
20697
+ add(path29.join(dir, name), "grants");
20561
20698
  for (const name of readdirSync3(state))
20562
20699
  if (/^(?:issued|approvals$)/.test(name))
20563
- add(path28.join(state, name), name === "approvals" ? "approvals" : "issued");
20700
+ add(path29.join(state, name), name === "approvals" ? "approvals" : "issued");
20564
20701
  } catch {}
20565
20702
  return seen;
20566
20703
  };
@@ -20585,7 +20722,7 @@ var registryTarget = (cwd, targets) => {
20585
20722
  const viaGlob = glob === undefined ? null : registryTarget(cwd, [glob]);
20586
20723
  if (viaGlob)
20587
20724
  return { file: target, registry: viaGlob.registry };
20588
- const registry = hardLinked(path28.resolve(cwd, file), state, configs, inodes) ?? underRegistry(state, cwd, file, process.platform, canonical3) ?? (configs.some((dir) => underConfig(dir, cwd, file, process.platform, canonical3)) ? "grants" : null);
20725
+ const registry = hardLinked(path29.resolve(cwd, file), state, configs, inodes) ?? underRegistry(state, cwd, file, process.platform, canonical4) ?? (configs.some((dir) => underConfig(dir, cwd, file, process.platform, canonical4)) ? "grants" : null);
20589
20726
  if (registry)
20590
20727
  return { file: target, registry };
20591
20728
  }
@@ -20593,7 +20730,7 @@ var registryTarget = (cwd, targets) => {
20593
20730
  };
20594
20731
  var partsUnder = (dir, cwd, target, platform, real) => {
20595
20732
  const win = platform === "win32";
20596
- const p = win ? path28.win32 : path28.posix;
20733
+ const p = win ? path29.win32 : path29.posix;
20597
20734
  const fold = (value) => win || platform === "darwin" ? value.toLowerCase() : value;
20598
20735
  const named = win ? target.replace(/^\/([a-zA-Z])(?=\/|$)/, "$1:") : target;
20599
20736
  const relative = p.relative(fold(real(p.resolve(dir))), fold(real(p.resolve(cwd, named))));
@@ -20607,7 +20744,7 @@ var underRegistry = (state, cwd, target, platform = process.platform, real = (fi
20607
20744
  };
20608
20745
  var underConfig = (dir, cwd, target, platform = process.platform, real = (file) => file) => {
20609
20746
  const parts = partsUnder(dir, cwd, target, platform, real);
20610
- return parts?.length === 1 && ["", "workspaces.json", DIR_TARGET].includes(parts[0]);
20747
+ return parts?.length === 1 && ["", ...CONFIG_FILES, DIR_TARGET].includes(parts[0]);
20611
20748
  };
20612
20749
  var unquotedWindowsRegistry = (command, platform = process.platform) => {
20613
20750
  if (platform !== "win32" || !command.includes("\\"))
@@ -20627,7 +20764,7 @@ var unquotedWindowsRegistry = (command, platform = process.platform) => {
20627
20764
  ];
20628
20765
  const named = (target) => moved.some((dir) => {
20629
20766
  const at = flat(/^(?:[a-z]:)?\//i.test(target) ? target : dir + target).replace(/\/\.?\//g, "/");
20630
- return registry === "grants" ? configs.some((cfg) => [cfg, `${cfg}/`, `${cfg}/workspaces.json`].includes(at)) : at.includes(`${state}/${registry}`);
20767
+ return registry === "grants" ? configs.some((cfg) => [cfg, `${cfg}/`, ...CONFIG_FILES.map((name) => `${cfg}/${name}`)].includes(at)) : at.includes(`${state}/${registry}`);
20631
20768
  });
20632
20769
  return writes.writes && (writes.targets === null || writes.targets.some(named)) ? registry : null;
20633
20770
  };
@@ -20650,7 +20787,7 @@ var REGISTRY_DENY = {
20650
20787
  };
20651
20788
  var registryDeny = ({ file, registry }) => {
20652
20789
  const { label, what, unblock } = REGISTRY_DENY[registry];
20653
- const named = path28.basename(file).startsWith(".workit-") ? path28.dirname(file) : file;
20790
+ const named = path29.basename(file).startsWith(".workit-") ? path29.dirname(file) : file;
20654
20791
  return {
20655
20792
  kind: "deny",
20656
20793
  reason: `workit ${label}: ${named} is under ${what}. ${unblock}`,
@@ -20740,10 +20877,10 @@ import { spawnSync as spawnSync16 } from "node:child_process";
20740
20877
 
20741
20878
  // packages/workit-core/src/ci-waiter.ts
20742
20879
  import fs20 from "node:fs";
20743
- import path29 from "node:path";
20880
+ import path30 from "node:path";
20744
20881
  var waiterFile = (cwd, pr) => {
20745
20882
  const common = gitCommonDir(cwd);
20746
- return common ? path29.join(common, "workit", "ci-waits", `pr-${pr}.json`) : null;
20883
+ return common ? path30.join(common, "workit", "ci-waits", `pr-${pr}.json`) : null;
20747
20884
  };
20748
20885
  var pidAlive2 = (pid) => {
20749
20886
  if (!Number.isSafeInteger(pid) || pid <= 0)
@@ -21246,12 +21383,12 @@ ${line}` };
21246
21383
  };
21247
21384
  // packages/workit-core/src/hooks/hosts/fields.ts
21248
21385
  import { existsSync as existsSync11, realpathSync as realpathSync8, statSync as statSync4 } from "node:fs";
21249
- import path30 from "node:path";
21386
+ import path31 from "node:path";
21250
21387
  var isRecord5 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
21251
21388
  var nonEmpty2 = (value) => typeof value === "string" && value.trim() !== "";
21252
21389
  var optionalText = (value) => typeof value === "string" ? value : null;
21253
21390
  var existingDirectory = (value) => {
21254
- if (!nonEmpty2(value) || !path30.isAbsolute(value) || !existsSync11(value))
21391
+ if (!nonEmpty2(value) || !path31.isAbsolute(value) || !existsSync11(value))
21255
21392
  return null;
21256
21393
  try {
21257
21394
  return statSync4(value).isDirectory() ? realpathSync8(value) : null;
@@ -21319,7 +21456,7 @@ var writeTargets = (input) => {
21319
21456
  };
21320
21457
  // packages/workit-core/src/hooks/standing.ts
21321
21458
  import fs22 from "node:fs";
21322
- import path32 from "node:path";
21459
+ import path33 from "node:path";
21323
21460
 
21324
21461
  // packages/workit-core/src/approvals/store.ts
21325
21462
  var REQUEST_TTL_MS = 30 * 60000;
@@ -22005,42 +22142,42 @@ function neededChecks(lane, configured) {
22005
22142
  }
22006
22143
 
22007
22144
  // packages/workit-core/src/hooks/worktree-confine.ts
22008
- import { createHash as createHash15 } from "node:crypto";
22145
+ import { createHash as createHash16 } from "node:crypto";
22009
22146
  import fs21 from "node:fs";
22010
- import path31 from "node:path";
22147
+ import path32 from "node:path";
22011
22148
  var FANOUT_TOKEN_FILE = "workit-fanout-token";
22012
22149
  var NONE5 = { kind: "none" };
22013
22150
  var CASE_INSENSITIVE2 = process.platform === "darwin" || process.platform === "win32";
22014
- var canonical4 = (file) => {
22151
+ var canonical5 = (file) => {
22015
22152
  let rest = "";
22016
- for (let dir = path31.resolve(file);; dir = path31.dirname(dir)) {
22153
+ for (let dir = path32.resolve(file);; dir = path32.dirname(dir)) {
22017
22154
  try {
22018
- return path31.join(fs21.realpathSync.native(dir), rest);
22155
+ return path32.join(fs21.realpathSync.native(dir), rest);
22019
22156
  } catch {
22020
- if (path31.dirname(dir) === dir)
22021
- return path31.resolve(file);
22022
- rest = rest ? path31.join(path31.basename(dir), rest) : path31.basename(dir);
22157
+ if (path32.dirname(dir) === dir)
22158
+ return path32.resolve(file);
22159
+ rest = rest ? path32.join(path32.basename(dir), rest) : path32.basename(dir);
22023
22160
  }
22024
22161
  }
22025
22162
  };
22026
22163
  var within = (child, parent) => {
22027
22164
  const fold = (value) => CASE_INSENSITIVE2 ? value.toLowerCase() : value;
22028
- const relative = path31.relative(fold(parent), fold(child));
22029
- return relative === "" || !relative.startsWith("..") && !path31.isAbsolute(relative);
22165
+ const relative = path32.relative(fold(parent), fold(child));
22166
+ return relative === "" || !relative.startsWith("..") && !path32.isAbsolute(relative);
22030
22167
  };
22031
22168
  var checkoutOf2 = (file) => {
22032
- for (let dir = canonical4(file);; dir = path31.dirname(dir)) {
22033
- const dotGit = path31.join(dir, ".git");
22169
+ for (let dir = canonical5(file);; dir = path32.dirname(dir)) {
22170
+ const dotGit = path32.join(dir, ".git");
22034
22171
  if (fs21.existsSync(dotGit)) {
22035
22172
  if (!fs21.statSync(dotGit).isFile())
22036
22173
  return { root: dir, workit: false };
22037
22174
  const admin = /^gitdir:\s*(.+)$/mu.exec(fs21.readFileSync(dotGit, "utf8"))?.[1]?.trim();
22038
22175
  return {
22039
22176
  root: dir,
22040
- workit: Boolean(admin) && fs21.existsSync(path31.join(path31.resolve(dir, admin), FANOUT_TOKEN_FILE))
22177
+ workit: Boolean(admin) && fs21.existsSync(path32.join(path32.resolve(dir, admin), FANOUT_TOKEN_FILE))
22041
22178
  };
22042
22179
  }
22043
- if (path31.dirname(dir) === dir)
22180
+ if (path32.dirname(dir) === dir)
22044
22181
  return null;
22045
22182
  }
22046
22183
  };
@@ -22052,8 +22189,8 @@ var workitWorktreeOf = (file) => {
22052
22189
  return null;
22053
22190
  }
22054
22191
  };
22055
- var bindingDir = () => path31.join(resolveStateDir(), "worktree-bind");
22056
- var bindingFile = (session, agentId) => path31.join(bindingDir(), `${createHash15("sha256").update(`${session}\x00${agentId}`).digest("hex").slice(0, 32)}.json`);
22192
+ var bindingDir = () => path32.join(resolveStateDir(), "worktree-bind");
22193
+ var bindingFile = (session, agentId) => path32.join(bindingDir(), `${createHash16("sha256").update(`${session}\x00${agentId}`).digest("hex").slice(0, 32)}.json`);
22057
22194
  var readBinding = (file) => {
22058
22195
  try {
22059
22196
  const value = JSON.parse(fs21.readFileSync(file, "utf8"));
@@ -22078,7 +22215,7 @@ var bind = (input, worktree) => {
22078
22215
  agentId,
22079
22216
  at: new Date().toISOString()
22080
22217
  };
22081
- fs21.mkdirSync(path31.dirname(file), { recursive: true });
22218
+ fs21.mkdirSync(path32.dirname(file), { recursive: true });
22082
22219
  fs21.writeFileSync(file, JSON.stringify(binding));
22083
22220
  try {
22084
22221
  if (inWorkitWorkspace(input.cwd))
@@ -22097,31 +22234,31 @@ var hostIsolated = (cwd, agentId) => {
22097
22234
  const checkout = checkoutOf2(cwd);
22098
22235
  if (!checkout)
22099
22236
  return false;
22100
- const dotGit = path31.join(checkout.root, ".git");
22237
+ const dotGit = path32.join(checkout.root, ".git");
22101
22238
  if (!fs21.statSync(dotGit).isFile())
22102
22239
  return false;
22103
22240
  const admin = /^gitdir:\s*(.+)$/mu.exec(fs21.readFileSync(dotGit, "utf8"))?.[1]?.trim();
22104
22241
  if (!admin)
22105
22242
  return false;
22106
- const adminDir = path31.resolve(checkout.root, admin);
22107
- const back = fs21.readFileSync(path31.join(adminDir, "gitdir"), "utf8").trim();
22108
- if (path31.relative(canonical4(path31.resolve(adminDir, back)), canonical4(dotGit)) !== "")
22243
+ const adminDir = path32.resolve(checkout.root, admin);
22244
+ const back = fs21.readFileSync(path32.join(adminDir, "gitdir"), "utf8").trim();
22245
+ if (path32.relative(canonical5(path32.resolve(adminDir, back)), canonical5(dotGit)) !== "")
22109
22246
  return false;
22110
- const common = path31.join(adminDir, "commondir");
22111
- const gitDir = fs21.existsSync(common) ? path31.resolve(adminDir, fs21.readFileSync(common, "utf8").trim()) : adminDir;
22112
- const expected = path31.join(path31.dirname(canonical4(gitDir)), ".claude", "worktrees", `agent-${agentId}`);
22113
- return path31.relative(canonical4(expected), checkout.root) === "";
22247
+ const common = path32.join(adminDir, "commondir");
22248
+ const gitDir = fs21.existsSync(common) ? path32.resolve(adminDir, fs21.readFileSync(common, "utf8").trim()) : adminDir;
22249
+ const expected = path32.join(path32.dirname(canonical5(gitDir)), ".claude", "worktrees", `agent-${agentId}`);
22250
+ return path32.relative(canonical5(expected), checkout.root) === "";
22114
22251
  } catch {
22115
22252
  return false;
22116
22253
  }
22117
22254
  };
22118
22255
  var runnerAt = (target) => {
22119
- const base = path31.basename(target);
22256
+ const base = path32.basename(target);
22120
22257
  return base.startsWith(OPAQUE_TARGET) ? decodeURIComponent(base.slice(OPAQUE_TARGET.length)) : null;
22121
22258
  };
22122
22259
  var shown = (target) => {
22123
- const named = /^\.workit-(?:live-target$|runs-)/.test(path31.basename(target)) ? path31.dirname(target) : target;
22124
- return path31.sep === "\\" ? named.replaceAll("/", "\\") : named;
22260
+ const named = /^\.workit-(?:live-target$|runs-)/.test(path32.basename(target)) ? path32.dirname(target) : target;
22261
+ return path32.sep === "\\" ? named.replaceAll("/", "\\") : named;
22125
22262
  };
22126
22263
  var unboundDeny = (input, target) => {
22127
22264
  const unblock = "Work only in the worktree your brief names, which the lead made with `workit fanout worktree create <slice>`: edit files under it and run one verb per call against it (`workit git --cwd <worktree> commit -m … -- <paths>`, `workit check --cwd <worktree> <name>`). If your brief names no worktree, stop and report that to the lead.";
@@ -22160,7 +22297,7 @@ var literalForm = (command, refs) => {
22160
22297
  };
22161
22298
  var unknownVarDeny = (input, worktree, targets, command) => {
22162
22299
  const refs = [
22163
- ...new Set(targets.flatMap((target) => path31.relative(UNKNOWN_VAR, path31.resolve(target)).split(path31.sep)[0].split("+").filter(Boolean).map(decodeURIComponent)))
22300
+ ...new Set(targets.flatMap((target) => path32.relative(UNKNOWN_VAR, path32.resolve(target)).split(path32.sep)[0].split("+").filter(Boolean).map(decodeURIComponent)))
22164
22301
  ];
22165
22302
  let text = command ?? "";
22166
22303
  const first = [];
@@ -22189,13 +22326,13 @@ function confineImplementer(input, targets, command) {
22189
22326
  try {
22190
22327
  if (!input.session.agentId || hostIsolated(input.cwd, input.session.agentId))
22191
22328
  return NONE5;
22192
- const unresolved = targets.filter((target) => within(path31.resolve(target), UNKNOWN_VAR));
22329
+ const unresolved = targets.filter((target) => within(path32.resolve(target), UNKNOWN_VAR));
22193
22330
  if (unresolved.length > 0)
22194
22331
  return unknownVarDeny(input, boundWorktree(input), unresolved, command);
22195
- if (targets.some((target) => within(path31.resolve(target), UNKNOWN_DIR)))
22332
+ if (targets.some((target) => within(path32.resolve(target), UNKNOWN_DIR)))
22196
22333
  return unknownDirDeny(input, boundWorktree(input));
22197
- const bindings = canonical4(bindingDir());
22198
- const judged = targets.map((named) => ({ named, real: canonical4(named) })).filter(({ real }) => within(real, bindings) || checkoutOf2(real) !== null);
22334
+ const bindings = canonical5(bindingDir());
22335
+ const judged = targets.map((named) => ({ named, real: canonical5(named) })).filter(({ real }) => within(real, bindings) || checkoutOf2(real) !== null);
22199
22336
  if (judged.length === 0)
22200
22337
  return NONE5;
22201
22338
  let worktree = boundWorktree(input);
@@ -22209,7 +22346,7 @@ function confineImplementer(input, targets, command) {
22209
22346
  return unboundDeny(input, judged[0].named);
22210
22347
  bind(input, worktree);
22211
22348
  }
22212
- const root = canonical4(worktree);
22349
+ const root = canonical5(worktree);
22213
22350
  const outside = judged.find(({ real }) => !within(real, root) || within(real, bindings));
22214
22351
  return outside ? outsideDeny(input, worktree, outside.named) : NONE5;
22215
22352
  } catch {
@@ -22302,16 +22439,16 @@ var RUNS = /^(?:sh|bash|zsh|dash|ksh|mksh|ash|python[\d.]*|node|bun|deno|ruby|pe
22302
22439
  var INLINE = /^-[a-zA-Z]*[ceEpm]$|^--(?:eval|print|test|version|help)$|^-[hvV]$/;
22303
22440
  var VALUED = /^-[WXIrC]$|^--(?:require|import|loader|conditions|input-type)$/;
22304
22441
  var commonDir = (root) => {
22305
- const dotGit = path31.join(root, ".git");
22442
+ const dotGit = path32.join(root, ".git");
22306
22443
  if (!fs21.statSync(dotGit).isFile())
22307
- return canonical4(dotGit);
22308
- const admin = path31.resolve(root, /^gitdir:\s*(.+)$/mu.exec(fs21.readFileSync(dotGit, "utf8"))?.[1]?.trim() ?? "");
22309
- const common = path31.join(admin, "commondir");
22310
- return canonical4(fs21.existsSync(common) ? path31.resolve(admin, fs21.readFileSync(common, "utf8").trim()) : admin);
22444
+ return canonical5(dotGit);
22445
+ const admin = path32.resolve(root, /^gitdir:\s*(.+)$/mu.exec(fs21.readFileSync(dotGit, "utf8"))?.[1]?.trim() ?? "");
22446
+ const common = path32.join(admin, "commondir");
22447
+ return canonical5(fs21.existsSync(common) ? path32.resolve(admin, fs21.readFileSync(common, "utf8").trim()) : admin);
22311
22448
  };
22312
22449
  var inScratch = (real, repo) => {
22313
22450
  const checkout = checkoutOf2(real);
22314
- return checkout !== null && within(real, path31.join(checkout.root, SCRATCH)) && (repo === null || commonDir(checkout.root) === repo);
22451
+ return checkout !== null && within(real, path32.join(checkout.root, SCRATCH)) && (repo === null || commonDir(checkout.root) === repo);
22315
22452
  };
22316
22453
  var JUDGE_VERBS = {
22317
22454
  check: true,
@@ -22340,7 +22477,7 @@ var judgeVerbRefused = (args) => {
22340
22477
  var CLI_RUNNERS = /^(?:npx|bunx|pnpx|npm|pnpm|yarn|bun|node|nodejs|deno|tsx|ts-node)$/;
22341
22478
  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?$/;
22342
22479
  var workitCalls = (command, depth = 0, aliases = new Map) => depth > 4 ? [] : commandLines(command).flatMap((words) => {
22343
- const name = path31.basename(words[0] ?? "").toLowerCase();
22480
+ const name = path32.basename(words[0] ?? "").toLowerCase();
22344
22481
  if (name === "alias")
22345
22482
  return words.flatMap((word) => {
22346
22483
  const set = /^([\w-]+)=(.*)$/s.exec(word);
@@ -22370,11 +22507,11 @@ var judgeRefusal = (command, fed, depth = 0) => {
22370
22507
  return why;
22371
22508
  }
22372
22509
  const { words } = segment;
22373
- const runs = (word = "") => RUNS.test(path31.basename(word).toLowerCase());
22510
+ const runs = (word = "") => RUNS.test(path32.basename(word).toLowerCase());
22374
22511
  let at = 0;
22375
22512
  while (at < words.length && (LEADS.test(words[at]) || /^-\w$/.test(words[at - 1] ?? "") && !runs(words[at])))
22376
22513
  at++;
22377
- const name = path31.basename(words[at] ?? "").toLowerCase();
22514
+ const name = path32.basename(words[at] ?? "").toLowerCase();
22378
22515
  const args = words.slice(at + 1);
22379
22516
  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`;
22380
22517
  if (/^(?:cd|chdir|pushd|popd)$/.test(name))
@@ -22453,8 +22590,8 @@ var judgeDeny = (input, what, target) => {
22453
22590
  const role = input.session.agentType?.endsWith("reviewer") ? "reviewer" : "verifier";
22454
22591
  const root = checkoutOf2(input.cwd)?.root;
22455
22592
  const candidate = target ? checkoutOf2(target)?.root : undefined;
22456
- const also = root && candidate && candidate !== root && commonDir(candidate) === commonDir(root) ? ` or ${path31.join(candidate, SCRATCH)}` : "";
22457
- const scratch = root ? `${path31.join(root, SCRATCH)}${also}` : `${SCRATCH}/ at the root of the checkout you judge`;
22593
+ const also = root && candidate && candidate !== root && commonDir(candidate) === commonDir(root) ? ` or ${path32.join(candidate, SCRATCH)}` : "";
22594
+ const scratch = root ? `${path32.join(root, SCRATCH)}${also}` : `${SCRATCH}/ at the root of the checkout you judge`;
22458
22595
  const unblock = `Write only under ${scratch} (mkdir -p it): put a generated case in a file there with a quoted heredoc (<<'EOF') and never run it in the shell. Reads, \`workit check\` and \`workit ledger verdict|finding\` stay allowed; a change the candidate needs is a finding, not an edit.`;
22459
22596
  return {
22460
22597
  kind: "deny",
@@ -22469,10 +22606,10 @@ function confineJudge(input, targets) {
22469
22606
  const judged = checkoutOf2(input.cwd);
22470
22607
  const repo = judged ? commonDir(judged.root) : null;
22471
22608
  for (const target of targets) {
22472
- const resolved = path31.resolve(target);
22609
+ const resolved = path32.resolve(target);
22473
22610
  if (within(resolved, UNKNOWN_VAR) || within(resolved, UNKNOWN_DIR))
22474
22611
  return judgeDeny(input, "it writes to a path Workit cannot resolve (a variable, a command substitution or `cd -`): spell the path out");
22475
- if (inScratch(canonical4(target), repo))
22612
+ if (inScratch(canonical5(target), repo))
22476
22613
  continue;
22477
22614
  const runner = runnerAt(target);
22478
22615
  return judgeDeny(input, runner === null ? `${shown(target)} is outside it` : `\`${runner}\` runs in ${shown(target)}, outside it`, target);
@@ -22500,7 +22637,7 @@ function confineJudgeShell(input, command, dialect = "posix") {
22500
22637
  let git = [];
22501
22638
  try {
22502
22639
  git = rawInvocations(command, dialect).flatMap(({ tool, dir, args }) => tool === "git" && (args[0] === "push" || leadOwnedGit(args)) ? [
22503
- path31.join(dir === undefined ? UNKNOWN_DIR : path31.resolve(input.cwd, dir ?? "."), `${OPAQUE_TARGET}git`)
22640
+ path32.join(dir === undefined ? UNKNOWN_DIR : path32.resolve(input.cwd, dir ?? "."), `${OPAQUE_TARGET}git`)
22504
22641
  ] : []);
22505
22642
  } catch {}
22506
22643
  return confineJudge(input, [
@@ -22545,7 +22682,7 @@ var judgeChecksLine = (cwd) => {
22545
22682
 
22546
22683
  // packages/workit-core/src/hooks/standing.ts
22547
22684
  var readPlans = (store) => {
22548
- const dir = path32.join(store, "fanouts");
22685
+ const dir = path33.join(store, "fanouts");
22549
22686
  let names;
22550
22687
  try {
22551
22688
  names = fs22.readdirSync(dir).filter((name) => name.endsWith(".json"));
@@ -22555,7 +22692,7 @@ var readPlans = (store) => {
22555
22692
  const plans = [];
22556
22693
  for (const name of names) {
22557
22694
  try {
22558
- const raw = JSON.parse(fs22.readFileSync(path32.join(dir, name), "utf8"));
22695
+ const raw = JSON.parse(fs22.readFileSync(path33.join(dir, name), "utf8"));
22559
22696
  if (typeof raw.name !== "string" || !Array.isArray(raw.slices))
22560
22697
  continue;
22561
22698
  const texts = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string" && item !== "") : [];
@@ -22766,7 +22903,7 @@ var cdWorkitSplit = (command) => {
22766
22903
  // packages/workit-core/src/hooks/model-limit.ts
22767
22904
  import { closeSync as closeSync2, openSync as openSync2, readdirSync as readdirSync4, readSync, statSync as statSync5 } from "node:fs";
22768
22905
  import os9 from "node:os";
22769
- import path33 from "node:path";
22906
+ import path34 from "node:path";
22770
22907
  var MONTHS = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
22771
22908
  var WEEKDAYS = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"];
22772
22909
  var TIME_WORD = String.raw`(?:\d|(?:in|at|on|later|tomorrow|soon)\b|(?:${[...WEEKDAYS, ...MONTHS].join("|")})[a-z]*\b)`;
@@ -22964,17 +23101,17 @@ var firstPrompt = (file) => {
22964
23101
  var claudeProjectSlug = (cwd) => cwd.replace(/[^A-Za-z0-9]/gu, "-");
22965
23102
  var listDir = (dir) => {
22966
23103
  try {
22967
- return readdirSync4(dir).map((name) => path33.join(dir, name));
23104
+ return readdirSync4(dir).map((name) => path34.join(dir, name));
22968
23105
  } catch {
22969
23106
  return [];
22970
23107
  }
22971
23108
  };
22972
23109
  var SCAN_MS = 30 * 60000;
22973
23110
  var scanClaudeTranscripts = (cwd, env, now = new Date) => {
22974
- const projects = path33.join(env.CLAUDE_CONFIG_DIR || path33.join(env.HOME || os9.homedir(), ".claude"), "projects");
22975
- const project = path33.join(projects, claudeProjectSlug(cwd));
23111
+ const projects = path34.join(env.CLAUDE_CONFIG_DIR || path34.join(env.HOME || os9.homedir(), ".claude"), "projects");
23112
+ const project = path34.join(projects, claudeProjectSlug(cwd));
22976
23113
  const notes = [];
22977
- const files = listDir(project).flatMap((entry) => entry.endsWith(".jsonl") ? [{ file: entry, worker: false }] : listDir(path33.join(entry, "subagents")).filter((file) => file.endsWith(".jsonl")).map((file) => ({ file, worker: true })));
23114
+ const files = listDir(project).flatMap((entry) => entry.endsWith(".jsonl") ? [{ file: entry, worker: false }] : listDir(path34.join(entry, "subagents")).filter((file) => file.endsWith(".jsonl")).map((file) => ({ file, worker: true })));
22978
23115
  for (const { file, worker } of files)
22979
23116
  try {
22980
23117
  const stat = statSync5(file);
@@ -22989,7 +23126,7 @@ var scanClaudeTranscripts = (cwd, env, now = new Date) => {
22989
23126
  if (!seen)
22990
23127
  continue;
22991
23128
  notes.push(worker ? redispatchNote(seen, {
22992
- label: `worker ${path33.basename(file, ".jsonl")}`,
23129
+ label: `worker ${path34.basename(file, ".jsonl")}`,
22993
23130
  prompt: firstPrompt(file)
22994
23131
  }, 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.`);
22995
23132
  } catch {}
@@ -23553,7 +23690,6 @@ var ytrackWrites = (command, dialect = "posix", depth = 0, plain = true) => {
23553
23690
  READ.delete(READ.keys().next().value);
23554
23691
  return found;
23555
23692
  };
23556
- var writesMode = (cwd) => resolveRuntimeWorkspaceVcs(cwd)?.youtrack?.writes;
23557
23693
  var ytrackGate = (cwd, command, dialect, ask) => {
23558
23694
  let writes;
23559
23695
  try {
@@ -23564,7 +23700,7 @@ var ytrackGate = (cwd, command, dialect, ask) => {
23564
23700
  }
23565
23701
  writes = [...merged.values()];
23566
23702
  } catch {
23567
- if (writesMode(cwd) === "auto")
23703
+ if (youTrackWritesMode(cwd) === "auto")
23568
23704
  return null;
23569
23705
  return {
23570
23706
  kind: "deny",
@@ -23572,7 +23708,7 @@ var ytrackGate = (cwd, command, dialect, ask) => {
23572
23708
  unblock: null
23573
23709
  };
23574
23710
  }
23575
- if (!writes.length || writesMode(cwd) === "auto")
23711
+ if (!writes.length || youTrackWritesMode(cwd) === "auto")
23576
23712
  return null;
23577
23713
  const calls = writes.flatMap((write) => write.workit ? [`\`${write.workit}\``] : []);
23578
23714
  const bare = writes.filter((write) => !write.workit).map((write) => `\`${write.command}\` (${write.gap ? `Workit cannot carry ${write.gap} into a workit youtrack call` : "no workit youtrack verb covers it"})`);
@@ -23886,7 +24022,7 @@ var dispatchHook = (adapter, raw, env = process.env) => {
23886
24022
  };
23887
24023
  // packages/workit-core/src/hooks/deadline.ts
23888
24024
  import { appendFileSync, mkdirSync as mkdirSync4 } from "node:fs";
23889
- import path34 from "node:path";
24025
+ import path35 from "node:path";
23890
24026
  var HOOK_SKIP_TEXT = "workit context skipped: host under load";
23891
24027
  var HOOK_DEADLINE_MS = 8000;
23892
24028
  var HOST_DEADLINES = {
@@ -23904,7 +24040,7 @@ var hookDeadlineMs = (env, host = "", native) => {
23904
24040
  const row = HOST_DEADLINES[host];
23905
24041
  return override(env) ?? (row ? native === undefined ? Math.min(...Object.values(row)) : row[native] ?? row[""] : HOOK_DEADLINE_MS);
23906
24042
  };
23907
- var skipsFile = (stateDir) => path34.join(stateDir, HOOK_SKIPS_FILE);
24043
+ var skipsFile = (stateDir) => path35.join(stateDir, HOOK_SKIPS_FILE);
23908
24044
  var recordHookSkip = (skip, stateDir = resolveStateDir()) => {
23909
24045
  try {
23910
24046
  mkdirSync4(stateDir, { recursive: true });