@workit-dev/codex 1.4.1 → 1.5.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.
@@ -16635,31 +16635,75 @@ var seedTurnContext = (input, descriptor, text = turnContextText(input, descript
16635
16635
  };
16636
16636
  // packages/workit-core/src/core/route-intent.ts
16637
16637
  import { spawnSync as spawnSync13 } from "node:child_process";
16638
- import { existsSync as existsSync8 } from "node:fs";
16639
- import path23 from "node:path";
16638
+ import { existsSync as existsSync9 } from "node:fs";
16639
+ import path24 from "node:path";
16640
16640
 
16641
16641
  // packages/workit-core/src/hooks/raw-git.ts
16642
16642
  import { spawnSync as spawnSync12 } from "node:child_process";
16643
16643
  import { createHash as createHash15 } from "node:crypto";
16644
16644
  import fs16 from "node:fs";
16645
- import os5 from "node:os";
16646
- import path22 from "node:path";
16645
+ import os6 from "node:os";
16646
+ import path23 from "node:path";
16647
16647
 
16648
16648
  // packages/workit-core/src/autonomy.ts
16649
+ import os5 from "node:os";
16650
+ import path21 from "node:path";
16651
+
16652
+ // packages/workit-core/src/core/eval-world.ts
16653
+ import { existsSync as existsSync8, realpathSync as realpathSync6 } from "node:fs";
16649
16654
  import os4 from "node:os";
16650
16655
  import path20 from "node:path";
16656
+ var EVAL_WORLD_ENV = "WORKIT_EVAL_WORLD";
16657
+ var EVAL_WORLD_MARKER = ".workit-eval-world";
16658
+ var inside2 = (dir, file) => {
16659
+ const rel = path20.relative(dir, file);
16660
+ return !rel.startsWith("..") && !path20.isAbsolute(rel);
16661
+ };
16662
+ var evalWorldEntry = (cwd) => {
16663
+ const raw = process.env[EVAL_WORLD_ENV];
16664
+ if (!raw || !path20.isAbsolute(raw))
16665
+ return null;
16666
+ try {
16667
+ const world = realpathSync6(raw);
16668
+ if (!inside2(realpathSync6(os4.tmpdir()), world) || !inside2(world, realpathSync6(cwd)) || !existsSync8(path20.join(world, EVAL_WORLD_MARKER)))
16669
+ return null;
16670
+ return loadWorkspacesFrom(path20.join(world, "config"))[0] ?? null;
16671
+ } catch {
16672
+ return null;
16673
+ }
16674
+ };
16675
+
16676
+ // packages/workit-core/src/autonomy.ts
16651
16677
  var accountHome2 = () => {
16652
16678
  try {
16653
- return os4.userInfo().homedir;
16679
+ return os5.userInfo().homedir;
16654
16680
  } catch {
16655
- return os4.homedir();
16681
+ return os5.homedir();
16656
16682
  }
16657
16683
  };
16658
16684
  var grantsHome = { resolve: accountHome2 };
16659
16685
  var grantsDir = () => configDir({ HOME: grantsHome.resolve() });
16686
+ var benchWorld = (cwd) => {
16687
+ const entry = evalWorldEntry(cwd);
16688
+ if (!entry)
16689
+ return null;
16690
+ const { grants } = configuredGrants(entry);
16691
+ const lowered = {};
16692
+ for (const kind of GRANT_KINDS) {
16693
+ const value = grants[kind];
16694
+ if (value !== undefined && raises(kind, value, DEFAULT_GRANTS[kind]))
16695
+ lowered[kind] = value;
16696
+ }
16697
+ return {
16698
+ name: entry.name,
16699
+ glob: entry.glob,
16700
+ ...entry.defaultEndpoint ? { defaultEndpoint: entry.defaultEndpoint } : {},
16701
+ autonomy: lowered
16702
+ };
16703
+ };
16660
16704
  var grantsOverride = () => {
16661
- const configured = path20.resolve(resolveConfigDir());
16662
- return configured === path20.resolve(grantsDir()) ? 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 ${path20.join(grantsDir(), "workspaces.json")}, so the D4 defaults apply until grants are set there`;
16705
+ const configured = path21.resolve(resolveConfigDir());
16706
+ return configured === path21.resolve(grantsDir()) ? 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`;
16663
16707
  };
16664
16708
  var GRANT_KINDS = ["push", "pr", "merge", "release", "rerun"];
16665
16709
  var DEFAULT_GRANTS = Object.freeze({
@@ -16824,11 +16868,12 @@ function capAt(named, where, by, why, main = false) {
16824
16868
  };
16825
16869
  }
16826
16870
  function resolveAutonomy(cwd, target) {
16827
- const override = grantsOverride();
16871
+ const world = benchWorld(cwd);
16872
+ const override = world ? null : grantsOverride();
16828
16873
  if (override)
16829
16874
  return { ...autonomyOf(null), note: override };
16830
16875
  const name = process.env.WORKIT_WORKSPACE_NAME?.trim() || undefined;
16831
- let autonomy = autonomyOf(resolveWorkspaceFrom(cwd, grantsDir(), name));
16876
+ let autonomy = autonomyOf(resolveWorkspaceFrom(cwd, grantsDir(), name) ?? world);
16832
16877
  if (name)
16833
16878
  autonomy = capAt(autonomy, cwd, `WORKIT_WORKSPACE_NAME=${name}`, "a name never raises grants");
16834
16879
  const above = checkoutsAbove(cwd);
@@ -16916,7 +16961,7 @@ var raises = (kind, current, next) => {
16916
16961
  // packages/workit-core/src/hooks/session-marker.ts
16917
16962
  import { createHash as createHash14 } from "node:crypto";
16918
16963
  import fs15 from "node:fs";
16919
- import path21 from "node:path";
16964
+ import path22 from "node:path";
16920
16965
  var sessionMarkerFile = (input, session, store) => {
16921
16966
  let dir = store;
16922
16967
  if (dir === undefined) {
@@ -16926,7 +16971,7 @@ var sessionMarkerFile = (input, session, store) => {
16926
16971
  dir = location.dir;
16927
16972
  }
16928
16973
  const name = createHash14("sha256").update(`${input.host}\x00${session}`).digest("hex").slice(0, 32);
16929
- return path21.join(dir, "hooks", `skills-${name}.json`);
16974
+ return path22.join(dir, "hooks", `skills-${name}.json`);
16930
16975
  };
16931
16976
  var list = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
16932
16977
  var EMPTY = {
@@ -16961,7 +17006,7 @@ var parseMarker = (text) => {
16961
17006
  };
16962
17007
  var readSessionMarker = (file) => parseMarker(readRaw(file));
16963
17008
  var writeAtomic = (file, marker) => {
16964
- fs15.mkdirSync(path21.dirname(file), { recursive: true });
17009
+ fs15.mkdirSync(path22.dirname(file), { recursive: true });
16965
17010
  const temp = `${file}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
16966
17011
  try {
16967
17012
  fs15.writeFileSync(temp, JSON.stringify(marker));
@@ -17546,14 +17591,14 @@ var GIT_CONFIG_ENV = /^(?:GIT_(?:CONFIG\w*|DIR|COMMON_DIR|WORK_TREE|SSH|SSH_COMM
17546
17591
  var ASSIGNMENT = /^([A-Za-z_]\w*)=([\s\S]*)$/;
17547
17592
  var MAX_DEPTH = 4;
17548
17593
  var MAX_EXPANSIONS = 16;
17549
- var isAbsolute = (value) => path22.isAbsolute(value) || /^[A-Za-z]:[\\/]/.test(value) || value.startsWith("\\\\");
17594
+ var isAbsolute = (value) => path23.isAbsolute(value) || /^[A-Za-z]:[\\/]/.test(value) || value.startsWith("\\\\");
17550
17595
  var HERE = /^(?:\$PWD|\$\{PWD\}|\$\(\s*pwd\s*\)|`pwd`|\$\(\s*git\s+rev-parse\s+--show-toplevel\s*\))(?=$|[\\/])/;
17551
17596
  var joinDir = (base, raw) => {
17552
17597
  const next = raw.replace(HERE, ".");
17553
17598
  if (base === undefined || /[$`*?]/.test(next) || next === "-")
17554
17599
  return;
17555
- const expanded = next === "~" || next.startsWith("~/") ? path22.join(os5.homedir(), next.slice(1)) : next;
17556
- return base === null || isAbsolute(expanded) ? expanded : path22.join(base, expanded);
17600
+ const expanded = next === "~" || next.startsWith("~/") ? path23.join(os6.homedir(), next.slice(1)) : next;
17601
+ return base === null || isAbsolute(expanded) ? expanded : path23.join(base, expanded);
17557
17602
  };
17558
17603
  var rebase = (base, inner) => inner === null ? base : inner === undefined ? undefined : joinDir(base, inner);
17559
17604
  var cdTarget = (words) => {
@@ -17954,7 +17999,7 @@ function walk2(command, dialect, depth, seen, inherited = {}) {
17954
17999
  }
17955
18000
  if (CD.has(name)) {
17956
18001
  const target = cdTarget(words);
17957
- dir = target === null ? os5.homedir() : joinDir(dir, target);
18002
+ dir = target === null ? os6.homedir() : joinDir(dir, target);
17958
18003
  } else if (PUSHD.has(name)) {
17959
18004
  const target = cdTarget(words);
17960
18005
  stack.push(dir);
@@ -18475,17 +18520,17 @@ var headSha2 = (repo) => {
18475
18520
  if (!git || git.reftable)
18476
18521
  return null;
18477
18522
  try {
18478
- const head = fs16.readFileSync(path22.join(git.gitDir, "HEAD"), "utf8").trim();
18523
+ const head = fs16.readFileSync(path23.join(git.gitDir, "HEAD"), "utf8").trim();
18479
18524
  if (/^[0-9a-f]{40,64}$/.test(head))
18480
18525
  return head;
18481
18526
  const ref = /^ref: (refs\/.+)$/.exec(head)?.[1];
18482
18527
  if (!ref)
18483
18528
  return null;
18484
- const common = path22.dirname(repo.location.dir);
18529
+ const common = path23.dirname(repo.location.dir);
18485
18530
  try {
18486
- return fs16.readFileSync(path22.join(common, ref), "utf8").trim() || null;
18531
+ return fs16.readFileSync(path23.join(common, ref), "utf8").trim() || null;
18487
18532
  } catch {}
18488
- const packed = fs16.readFileSync(path22.join(common, "packed-refs"), "utf8");
18533
+ const packed = fs16.readFileSync(path23.join(common, "packed-refs"), "utf8");
18489
18534
  return new RegExp(`^([0-9a-f]{40,64}) ${ref.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`, "m").exec(packed)?.[1] ?? null;
18490
18535
  } catch {
18491
18536
  return null;
@@ -18578,7 +18623,7 @@ var expandGitAliases = (root, invocation, cache = new Map, depth = 0) => {
18578
18623
  const sub = invocation.args[0];
18579
18624
  if (invocation.tool !== "git" || invocation.dir === undefined || !sub || sub.startsWith("-") || GIT_COMMANDS.has(sub) || depth >= MAX_DEPTH)
18580
18625
  return [invocation];
18581
- const dir = path22.resolve(root, invocation.dir ?? ".");
18626
+ const dir = path23.resolve(root, invocation.dir ?? ".");
18582
18627
  if (!fs16.existsSync(dir))
18583
18628
  return [invocation];
18584
18629
  const config = gitConfig(dir, invocation, cache);
@@ -18601,11 +18646,11 @@ var expandGitAliases = (root, invocation, cache = new Map, depth = 0) => {
18601
18646
  var normalizedUrl = (url, dir) => {
18602
18647
  const trimmed = url.trim();
18603
18648
  if (/^file:\/\//i.test(trimmed))
18604
- return path22.resolve(dir, trimmed.slice(7)).replace(/\/+$/, "").replace(/\.git$/, "");
18649
+ return path23.resolve(dir, trimmed.slice(7)).replace(/\/+$/, "").replace(/\.git$/, "");
18605
18650
  const scheme = /^[a-z][a-z0-9+.-]*:\/\//i.exec(trimmed);
18606
18651
  const scp = !scheme && /^(?:[^@/\\]+@)?[^/\\:]{2,}:/.test(trimmed);
18607
18652
  if (!scheme && !scp)
18608
- return path22.resolve(dir, trimmed).replace(/\/+$/, "").replace(/\.git$/, "");
18653
+ return path23.resolve(dir, trimmed).replace(/\/+$/, "").replace(/\.git$/, "");
18609
18654
  const value = scheme ? trimmed.slice(scheme[0].length).replace(/^[^@/]*@/, "").replace(/^([^/:]+):\d+(?=\/)/, "$1") : trimmed.replace(/^[^@/]*@/, "").replace(":", "/");
18610
18655
  return value.toLowerCase().replace(/\/{2,}/g, "/").replace(/^www\./, "").replace(/\/+$/, "").replace(/\.git$/, "");
18611
18656
  };
@@ -18833,7 +18878,7 @@ var actionsIn = (cwd, command, dialect, cache = new Map, all = false) => {
18833
18878
  const out = [];
18834
18879
  const repos = new Map;
18835
18880
  const repoFor = (relative) => {
18836
- const dir = path22.resolve(cwd, relative ?? ".");
18881
+ const dir = path23.resolve(cwd, relative ?? ".");
18837
18882
  if (!repos.has(dir)) {
18838
18883
  const repo = repoAt(dir);
18839
18884
  const workit = repo !== null && isWorkitWorkspace(repo);
@@ -18853,7 +18898,7 @@ var actionsIn = (cwd, command, dialect, cache = new Map, all = false) => {
18853
18898
  continue;
18854
18899
  const action = rawAction(invocation);
18855
18900
  const at = !action ? null : repoFor(invocation.dir) ?? (all && invocation.tool !== "git" && explicitRepo(invocation.tool === "gh", "repo" in action && action.repo || "", invocation.env ?? {}) ? {
18856
- repo: { dir: path22.resolve(cwd, invocation.dir ?? "."), branch: null },
18901
+ repo: { dir: path23.resolve(cwd, invocation.dir ?? "."), branch: null },
18857
18902
  workit: false
18858
18903
  } : null);
18859
18904
  if (action && at)
@@ -18990,9 +19035,9 @@ var grantRefusal = (action, repo, invocation, cache) => {
18990
19035
  return null;
18991
19036
  };
18992
19037
  var localTag = (repo, name) => {
18993
- const common = path22.dirname(repo.location.dir);
19038
+ const common = path23.dirname(repo.location.dir);
18994
19039
  try {
18995
- return fs16.existsSync(path22.join(common, "refs/tags", name)) || fs16.readFileSync(path22.join(common, "packed-refs"), "utf8").includes(` refs/tags/${name}
19040
+ return fs16.existsSync(path23.join(common, "refs/tags", name)) || fs16.readFileSync(path23.join(common, "packed-refs"), "utf8").includes(` refs/tags/${name}
18996
19041
  `);
18997
19042
  } catch {
18998
19043
  return false;
@@ -19012,7 +19057,7 @@ var analysisDenial = (error) => ({
19012
19057
  });
19013
19058
  var NEXT_COMMAND = "next";
19014
19059
  var MARKER_TTL_SECONDS = 3600;
19015
- var markerFile = (repo, session, key) => path22.join(repo.location.dir, "hooks", `commit-${createHash15("sha256").update(`${session}\x00${key}`).digest("hex").slice(0, 32)}.json`);
19060
+ var markerFile = (repo, session, key) => path23.join(repo.location.dir, "hooks", `commit-${createHash15("sha256").update(`${session}\x00${key}`).digest("hex").slice(0, 32)}.json`);
19016
19061
  var callKey = (toolUseId, command) => toolUseId ?? `cmd:${createHash15("sha256").update(command).digest("hex")}`;
19017
19062
  function noteRawCommit(input, command, key) {
19018
19063
  try {
@@ -19023,7 +19068,7 @@ function noteRawCommit(input, command, key) {
19023
19068
  if (action.kind !== "commit")
19024
19069
  continue;
19025
19070
  const file = markerFile(repo, input.session.id, key);
19026
- fs16.mkdirSync(path22.dirname(file), { recursive: true });
19071
+ fs16.mkdirSync(path23.dirname(file), { recursive: true });
19027
19072
  fs16.writeFileSync(file, `${JSON.stringify({ head: headSha2(repo), at })}
19028
19073
  `);
19029
19074
  }
@@ -19264,8 +19309,8 @@ var judgedDir = (root, dir) => {
19264
19309
  return null;
19265
19310
  if (dir === null)
19266
19311
  return root;
19267
- const resolved = path23.resolve(root, dir);
19268
- return existsSync8(resolved) && inWorkitWorkspace(resolved) ? resolved : null;
19312
+ const resolved = path24.resolve(root, dir);
19313
+ return existsSync9(resolved) && inWorkitWorkspace(resolved) ? resolved : null;
19269
19314
  };
19270
19315
  var shellBranchPolicyViolation = (root, command, dialect = "posix") => {
19271
19316
  let judged = false;
@@ -19385,8 +19430,8 @@ var userOnlyWorkitCall = (command, dialect = "posix") => {
19385
19430
  };
19386
19431
  // packages/workit-core/src/core/heavy-rules.ts
19387
19432
  import fs17 from "node:fs";
19388
- import os6 from "node:os";
19389
- import path24 from "node:path";
19433
+ import os7 from "node:os";
19434
+ import path25 from "node:path";
19390
19435
  var EMPTY2 = () => ({ deny: [], allow: [] });
19391
19436
  var readText3 = (file) => {
19392
19437
  try {
@@ -19427,23 +19472,23 @@ function parseJsonc(text) {
19427
19472
  return JSON.parse(out.replace(/,(\s*[}\]])/gu, "$1"));
19428
19473
  }
19429
19474
  function gitTop(cwd) {
19430
- for (let dir = path24.resolve(cwd);; dir = path24.dirname(dir)) {
19431
- if (fs17.existsSync(path24.join(dir, ".git")))
19475
+ for (let dir = path25.resolve(cwd);; dir = path25.dirname(dir)) {
19476
+ if (fs17.existsSync(path25.join(dir, ".git")))
19432
19477
  return dir;
19433
- if (path24.dirname(dir) === dir)
19478
+ if (path25.dirname(dir) === dir)
19434
19479
  return null;
19435
19480
  }
19436
19481
  }
19437
19482
  var projectDirs = (cwd) => {
19438
19483
  const top = gitTop(cwd);
19439
19484
  const dirs = [];
19440
- for (let dir = path24.resolve(cwd);; dir = path24.dirname(dir)) {
19485
+ for (let dir = path25.resolve(cwd);; dir = path25.dirname(dir)) {
19441
19486
  dirs.push(dir);
19442
- if (!top || dir === top || path24.dirname(dir) === dir)
19487
+ if (!top || dir === top || path25.dirname(dir) === dir)
19443
19488
  return dirs;
19444
19489
  }
19445
19490
  };
19446
- var homeOf = (env) => env.HOME || os6.homedir();
19491
+ var homeOf = (env) => env.HOME || os7.homedir();
19447
19492
  var CLAUDE_MANAGED = {
19448
19493
  linux: "/etc/claude-code/managed-settings.json",
19449
19494
  darwin: "/Library/Application Support/ClaudeCode/managed-settings.json",
@@ -19451,12 +19496,12 @@ var CLAUDE_MANAGED = {
19451
19496
  };
19452
19497
  function claudeSettingsFiles(cwd, env, platform = process.platform) {
19453
19498
  const project = env.CLAUDE_PROJECT_DIR || gitTop(cwd) || cwd;
19454
- const user = env.CLAUDE_CONFIG_DIR || path24.join(homeOf(env), ".claude");
19499
+ const user = env.CLAUDE_CONFIG_DIR || path25.join(homeOf(env), ".claude");
19455
19500
  return [
19456
19501
  ...CLAUDE_MANAGED[platform] ? [CLAUDE_MANAGED[platform]] : [],
19457
- path24.join(user, "settings.json"),
19458
- path24.join(project, ".claude", "settings.json"),
19459
- path24.join(project, ".claude", "settings.local.json")
19502
+ path25.join(user, "settings.json"),
19503
+ path25.join(project, ".claude", "settings.json"),
19504
+ path25.join(project, ".claude", "settings.local.json")
19460
19505
  ];
19461
19506
  }
19462
19507
  var bashPattern = (entry) => {
@@ -19546,10 +19591,10 @@ var opencodeConfig = (value, rules) => {
19546
19591
  function opencodeRules(cwd, env = process.env) {
19547
19592
  const rules = EMPTY2();
19548
19593
  try {
19549
- const config = env.XDG_CONFIG_HOME || path24.join(homeOf(env), ".config");
19594
+ const config = env.XDG_CONFIG_HOME || path25.join(homeOf(env), ".config");
19550
19595
  const files = [
19551
- ...OPENCODE_NAMES.map((name) => path24.join(config, "opencode", name)),
19552
- ...projectDirs(cwd).flatMap((dir) => OPENCODE_NAMES.flatMap((name) => [path24.join(dir, name), path24.join(dir, ".opencode", name)])),
19596
+ ...OPENCODE_NAMES.map((name) => path25.join(config, "opencode", name)),
19597
+ ...projectDirs(cwd).flatMap((dir) => OPENCODE_NAMES.flatMap((name) => [path25.join(dir, name), path25.join(dir, ".opencode", name)])),
19553
19598
  ...env.OPENCODE_CONFIG ? [env.OPENCODE_CONFIG] : []
19554
19599
  ];
19555
19600
  for (const file of files) {
@@ -19593,9 +19638,9 @@ var codexRule = (body) => {
19593
19638
  function codexRules(cwd, env = process.env) {
19594
19639
  const rules = EMPTY2();
19595
19640
  try {
19596
- const home = env.CODEX_HOME || path24.join(homeOf(env), ".codex");
19641
+ const home = env.CODEX_HOME || path25.join(homeOf(env), ".codex");
19597
19642
  const top = gitTop(cwd) ?? cwd;
19598
- for (const dir of [path24.join(home, "rules"), path24.join(top, ".codex", "rules")]) {
19643
+ for (const dir of [path25.join(home, "rules"), path25.join(top, ".codex", "rules")]) {
19599
19644
  let files;
19600
19645
  try {
19601
19646
  files = fs17.readdirSync(dir).filter((name) => name.endsWith(".rules"));
@@ -19605,7 +19650,7 @@ function codexRules(cwd, env = process.env) {
19605
19650
  return "unreadable";
19606
19651
  }
19607
19652
  for (const name of files) {
19608
- const text = readText3(path24.join(dir, name)) ?? "";
19653
+ const text = readText3(path25.join(dir, name)) ?? "";
19609
19654
  for (const part of text.split(/\bprefix_rule\s*\(/u).slice(1)) {
19610
19655
  const rule = codexRule(part);
19611
19656
  if (!rule)
@@ -19624,8 +19669,8 @@ function cursorRules(cwd, env = process.env) {
19624
19669
  try {
19625
19670
  const top = gitTop(cwd) ?? cwd;
19626
19671
  for (const file of [
19627
- path24.join(homeOf(env), ".cursor", "cli-config.json"),
19628
- path24.join(top, ".cursor", "cli.json")
19672
+ path25.join(homeOf(env), ".cursor", "cli-config.json"),
19673
+ path25.join(top, ".cursor", "cli.json")
19629
19674
  ]) {
19630
19675
  const text = readText3(file);
19631
19676
  if (text === null)
@@ -19700,10 +19745,10 @@ function wrapAllowed(read, words, command, options = {}) {
19700
19745
 
19701
19746
  // packages/workit-core/src/core/heavy.ts
19702
19747
  import fs18 from "node:fs";
19703
- import path25 from "node:path";
19748
+ import path26 from "node:path";
19704
19749
  var stateDir = (env, platform = process.platform) => stateDir3(env, platform);
19705
19750
  var HEAVY_COMMANDS_FILE = "heavy-commands.json";
19706
- var heavyCommandsFile = (env) => path25.join(stateDir(env), HEAVY_COMMANDS_FILE);
19751
+ var heavyCommandsFile = (env) => path26.join(stateDir(env), HEAVY_COMMANDS_FILE);
19707
19752
  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;
19708
19753
  var INFO_FLAGS = new Set(["--version", "-v", "-V", "--help", "-h", "help", "version"]);
19709
19754
  var WATCH_FLAG = /^(?:--watch(?:All)?(?:=.*)?|-w|--serve)$/u;
@@ -19978,7 +20023,7 @@ function machinePatterns(env) {
19978
20023
  return isRecord4(value) ? stringList(value.patterns) : [];
19979
20024
  }
19980
20025
  function repoPatterns(cwd) {
19981
- return repoHeavyCommands(gitTop(cwd) ?? path25.resolve(cwd));
20026
+ return repoHeavyCommands(gitTop(cwd) ?? path26.resolve(cwd));
19982
20027
  }
19983
20028
  function heavyLines(lines, options) {
19984
20029
  const found = [];
@@ -20056,12 +20101,12 @@ function heavyPlan(command, options) {
20056
20101
  }
20057
20102
  function workitOnPath(env = process.env) {
20058
20103
  const names = process.platform === "win32" ? ["workit.exe", "workit.cmd", "workit"] : ["workit"];
20059
- for (const dir of (env.PATH ?? "").split(path25.delimiter))
20104
+ for (const dir of (env.PATH ?? "").split(path26.delimiter))
20060
20105
  for (const name of names) {
20061
20106
  if (!dir)
20062
20107
  continue;
20063
20108
  try {
20064
- fs18.accessSync(path25.join(dir, name), fs18.constants.X_OK);
20109
+ fs18.accessSync(path26.join(dir, name), fs18.constants.X_OK);
20065
20110
  return true;
20066
20111
  } catch {}
20067
20112
  }
@@ -20125,16 +20170,16 @@ var splitDenial = (plan) => ({
20125
20170
  unblock: plan.unblock
20126
20171
  });
20127
20172
  // packages/workit-core/src/hooks/write-gate.ts
20128
- import { existsSync as existsSync9, realpathSync as realpathSync6, statSync as statSync3 } from "node:fs";
20129
- import os8 from "node:os";
20130
- import path27 from "node:path";
20173
+ import { existsSync as existsSync10, realpathSync as realpathSync7, statSync as statSync3 } from "node:fs";
20174
+ import os9 from "node:os";
20175
+ import path28 from "node:path";
20131
20176
 
20132
20177
  // packages/workit-core/src/core/live-session.ts
20133
20178
  import { spawnSync as spawnSync14 } from "node:child_process";
20134
20179
  import { createHash as createHash16 } from "node:crypto";
20135
20180
  import fs19 from "node:fs";
20136
- import os7 from "node:os";
20137
- import path26 from "node:path";
20181
+ import os8 from "node:os";
20182
+ import path27 from "node:path";
20138
20183
  var LIVE_SESSION_TTL_MS = 15 * 60000;
20139
20184
  var HEARTBEAT_EVERY_MS = 30000;
20140
20185
  var liveProbe = {
@@ -20208,15 +20253,15 @@ var liveOwner = (input, transport, env = process.env) => {
20208
20253
  };
20209
20254
  };
20210
20255
  var checkoutOf = (target) => {
20211
- let dir = path26.resolve(target);
20212
- while (!fs19.existsSync(dir) && path26.dirname(dir) !== dir)
20213
- dir = path26.dirname(dir);
20256
+ let dir = path27.resolve(target);
20257
+ while (!fs19.existsSync(dir) && path27.dirname(dir) !== dir)
20258
+ dir = path27.dirname(dir);
20214
20259
  if (fs19.existsSync(dir) && !fs19.statSync(dir).isDirectory())
20215
- dir = path26.dirname(dir);
20216
- const parts = dir.split(path26.sep);
20260
+ dir = path27.dirname(dir);
20261
+ const parts = dir.split(path27.sep);
20217
20262
  const dotGit = parts.lastIndexOf(".git");
20218
20263
  if (dotGit > 0)
20219
- dir = parts.slice(0, dotGit).join(path26.sep) || path26.sep;
20264
+ dir = parts.slice(0, dotGit).join(path27.sep) || path27.sep;
20220
20265
  const location = resolveStore(dir);
20221
20266
  if (location instanceof Error || !location.shared || !location.top)
20222
20267
  return null;
@@ -20226,9 +20271,9 @@ var checkoutOf = (target) => {
20226
20271
  } catch {}
20227
20272
  return top;
20228
20273
  };
20229
- var markerFile2 = (top) => path26.join(resolveStateDir(), "live-sessions", `${createHash16("sha256").update(checkoutKey(top)).digest("hex").slice(0, 32)}.json`);
20274
+ var markerFile2 = (top) => path27.join(resolveStateDir(), "live-sessions", `${createHash16("sha256").update(checkoutKey(top)).digest("hex").slice(0, 32)}.json`);
20230
20275
  var checkoutKey = (top, platform = process.platform) => {
20231
- let key = path26.resolve(top);
20276
+ let key = path27.resolve(top);
20232
20277
  try {
20233
20278
  key = fs19.realpathSync.native(key);
20234
20279
  } catch {}
@@ -20259,7 +20304,7 @@ var isLive = (marker, deps) => {
20259
20304
  const age = ageOf2(marker, deps.now ?? new Date);
20260
20305
  if (age > (deps.ttlMs ?? LIVE_SESSION_TTL_MS))
20261
20306
  return false;
20262
- if (marker.machine !== (deps.machine ?? os7.hostname()) || marker.pid === null)
20307
+ if (marker.machine !== (deps.machine ?? os8.hostname()) || marker.pid === null)
20263
20308
  return true;
20264
20309
  if (!(deps.alive ?? processAlive)(marker.pid))
20265
20310
  return false;
@@ -20288,7 +20333,7 @@ var liveConflict = (target, owner, deps = {}) => {
20288
20333
  const marker = readMarker(file);
20289
20334
  if (!marker || sameLead(marker, owner) || !isLive(marker, deps))
20290
20335
  return null;
20291
- if (sameOwner(marker, owner, deps.machine ?? os7.hostname()))
20336
+ if (sameOwner(marker, owner, deps.machine ?? os8.hostname()))
20292
20337
  return null;
20293
20338
  return { marker, file, ageMs: ageOf2(marker, deps.now ?? new Date), checkout };
20294
20339
  } catch {
@@ -20302,7 +20347,7 @@ var claimLiveSession = (target, owner, deps = {}) => {
20302
20347
  return;
20303
20348
  const file = markerFile2(checkout);
20304
20349
  const now = deps.now ?? new Date;
20305
- const machine = deps.machine ?? os7.hostname();
20350
+ const machine = deps.machine ?? os8.hostname();
20306
20351
  const current = readMarker(file);
20307
20352
  if (current) {
20308
20353
  const age = ageOf2(current, now);
@@ -20323,7 +20368,7 @@ var claimLiveSession = (target, owner, deps = {}) => {
20323
20368
  checkout,
20324
20369
  heartbeatAt: now.toISOString()
20325
20370
  };
20326
- fs19.mkdirSync(path26.dirname(file), { recursive: true });
20371
+ fs19.mkdirSync(path27.dirname(file), { recursive: true });
20327
20372
  const temp = `${file}.${process.pid}.tmp`;
20328
20373
  fs19.writeFileSync(temp, JSON.stringify(marker));
20329
20374
  fs19.renameSync(temp, file);
@@ -20335,22 +20380,22 @@ var NONE3 = { kind: "none" };
20335
20380
  var CASE_INSENSITIVE = process.platform === "darwin" || process.platform === "win32";
20336
20381
  var canonical3 = (file) => {
20337
20382
  let rest = "";
20338
- for (let dir = path27.resolve(file);; dir = path27.dirname(dir)) {
20383
+ for (let dir = path28.resolve(file);; dir = path28.dirname(dir)) {
20339
20384
  try {
20340
- return path27.join(realpathSync6.native(dir), rest);
20385
+ return path28.join(realpathSync7.native(dir), rest);
20341
20386
  } catch {
20342
- if (path27.dirname(dir) === dir)
20343
- return path27.resolve(file);
20344
- rest = rest ? path27.join(path27.basename(dir), rest) : path27.basename(dir);
20387
+ if (path28.dirname(dir) === dir)
20388
+ return path28.resolve(file);
20389
+ rest = rest ? path28.join(path28.basename(dir), rest) : path28.basename(dir);
20345
20390
  }
20346
20391
  }
20347
20392
  };
20348
20393
  var exempt = (cwd, root, file, plans) => {
20349
20394
  const fold = (value) => CASE_INSENSITIVE ? value.toLowerCase() : value;
20350
- const relative = path27.relative(fold(canonical3(root)), fold(canonical3(path27.resolve(cwd, file))));
20351
- if (relative.startsWith("..") || path27.isAbsolute(relative))
20395
+ const relative = path28.relative(fold(canonical3(root)), fold(canonical3(path28.resolve(cwd, file))));
20396
+ if (relative.startsWith("..") || path28.isAbsolute(relative))
20352
20397
  return true;
20353
- const posix = relative.split(path27.sep).join("/");
20398
+ const posix = relative.split(path28.sep).join("/");
20354
20399
  const segments = posix.split("/");
20355
20400
  return /\.mdx?$/i.test(posix) || segments[0] === "docs" || segments.includes("plans") || [...plans].some((plan) => fold(plan) === posix);
20356
20401
  };
@@ -20701,10 +20746,10 @@ var linkSources = (args, at) => {
20701
20746
  const sources = names.filter((name, index) => into >= 0 ? name !== dest : index < names.length - 1 || names.length === 1);
20702
20747
  const target = dest === undefined ? null : at(dest);
20703
20748
  const symbolic = args.some((arg) => /^-[a-zA-Z]*s|^--symbolic$/.test(arg));
20704
- const base = target === null ? null : into >= 0 || sources.length > 1 || existsSync9(target) || /[\\/]$/.test(dest ?? "") ? target : path27.dirname(target);
20749
+ const base = target === null ? null : into >= 0 || sources.length > 1 || existsSync10(target) || /[\\/]$/.test(dest ?? "") ? target : path28.dirname(target);
20705
20750
  return sources.flatMap((source) => {
20706
- if (symbolic && base !== null && !path27.isAbsolute(homeExpanded(source)))
20707
- return [path27.resolve(base, source)];
20751
+ if (symbolic && base !== null && !path28.isAbsolute(homeExpanded(source)))
20752
+ return [path28.resolve(base, source)];
20708
20753
  const resolved = at(source);
20709
20754
  return resolved ? [resolved] : [];
20710
20755
  });
@@ -20733,7 +20778,7 @@ var shellWrites = (command, depth = 0) => {
20733
20778
  return { writes: true, targets: unknown ? null : targets };
20734
20779
  };
20735
20780
  var cache2 = new Map;
20736
- var planKeyOf = (root, plans) => [...plans].map((file) => fileSignature(path27.resolve(root, file)) ?? "-").join("\x00");
20781
+ var planKeyOf = (root, plans) => [...plans].map((file) => fileSignature(path28.resolve(root, file)) ?? "-").join("\x00");
20737
20782
  var gateFor = (cwd) => {
20738
20783
  const store = new TaskStore(cwd);
20739
20784
  const listed = store.listTaskIndex();
@@ -20813,13 +20858,13 @@ var gitMutationDirs = (cwd, command, dialect) => {
20813
20858
  return [];
20814
20859
  if (sub === "stash" && ["list", "show"].includes(rest[0] ?? ""))
20815
20860
  return [];
20816
- return [path27.resolve(cwd, invocation.dir ?? ".")];
20861
+ return [path28.resolve(cwd, invocation.dir ?? ".")];
20817
20862
  });
20818
20863
  };
20819
20864
  var CD2 = new Set(["cd", "chdir", "set-location", "sl"]);
20820
20865
  var PUSHD2 = new Set(["pushd", "push-location"]);
20821
20866
  var POPD2 = new Set(["popd", "pop-location"]);
20822
- var UNKNOWN_DIR = path27.resolve(path27.parse(process.cwd()).root, ".workit-unknown-dir");
20867
+ var UNKNOWN_DIR = path28.resolve(path28.parse(process.cwd()).root, ".workit-unknown-dir");
20823
20868
  var cdInto = (dir, words, strict = false, vars = new Map) => {
20824
20869
  const lost = strict ? UNKNOWN_DIR : undefined;
20825
20870
  const found = words.slice(1).find((word) => !word.startsWith("-") || word === "-");
@@ -20829,7 +20874,7 @@ var cdInto = (dir, words, strict = false, vars = new Map) => {
20829
20874
  return lost;
20830
20875
  if (dir === undefined)
20831
20876
  return lost;
20832
- return target === undefined ? os8.homedir() : path27.resolve(dir, target);
20877
+ return target === undefined ? os9.homedir() : path28.resolve(dir, target);
20833
20878
  };
20834
20879
  var quoteWord2 = (word) => /^[\w@%+=:,./-]+$/.test(word) ? word : `'${word.replaceAll("'", "'\\''")}'`;
20835
20880
  var expandVars = (text, vars) => vars.size === 0 || !text.includes("$") ? text : text.replace(/\$(?:(\w+)|\{(\w+)\})/g, (whole, bare, braced) => {
@@ -20963,7 +21008,7 @@ var untrustedVars = (segments) => {
20963
21008
  }
20964
21009
  return { all, names };
20965
21010
  };
20966
- var UNKNOWN_VAR = path27.resolve(path27.parse(process.cwd()).root, ".workit-unknown-var");
21011
+ var UNKNOWN_VAR = path28.resolve(path28.parse(process.cwd()).root, ".workit-unknown-var");
20967
21012
  var REFERENCE = /\$\{(\w+)[^}]*\}|\$(\w+)|\$\([^)]*\)?|`[^`]*`?/g;
20968
21013
  var unresolvedRefs = (text) => [
20969
21014
  ...new Set([...text.matchAll(REFERENCE)].map((match) => {
@@ -20973,7 +21018,7 @@ var unresolvedRefs = (text) => [
20973
21018
  ];
20974
21019
  var unknownVarTarget = (text) => {
20975
21020
  const refs = unresolvedRefs(text);
20976
- return path27.join(UNKNOWN_VAR, (refs.length > 0 ? refs : [text]).map(encodeURIComponent).join("+"));
21021
+ return path28.join(UNKNOWN_VAR, (refs.length > 0 ? refs : [text]).map(encodeURIComponent).join("+"));
20977
21022
  };
20978
21023
  var applyOperator = (value, operator) => {
20979
21024
  if (operator === "")
@@ -21031,18 +21076,18 @@ var mktempPath = (value, dir) => {
21031
21076
  template = arg;
21032
21077
  }
21033
21078
  if (base === null && (temp || template === undefined))
21034
- base = os8.tmpdir();
21079
+ base = os9.tmpdir();
21035
21080
  const name = homeExpanded(template ?? "tmp.XXXXXXXXXX");
21036
- if (path27.isAbsolute(name))
21081
+ if (path28.isAbsolute(name))
21037
21082
  return name;
21038
21083
  const from = base === null ? dir : homeExpanded(base);
21039
- if (from === undefined || !path27.isAbsolute(from) && dir === undefined)
21084
+ if (from === undefined || !path28.isAbsolute(from) && dir === undefined)
21040
21085
  return null;
21041
- return path27.resolve(dir ?? from, from, name);
21086
+ return path28.resolve(dir ?? from, from, name);
21042
21087
  };
21043
21088
  var homeExpanded = (file) => {
21044
21089
  const match = /^(?:~|\$HOME|\$\{HOME\})(?=\/|$)/.exec(file);
21045
- return match ? (process.env.HOME || os8.homedir()) + file.slice(match[0].length) : file;
21090
+ return match ? (process.env.HOME || os9.homedir()) + file.slice(match[0].length) : file;
21046
21091
  };
21047
21092
  var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherited = new Map) => {
21048
21093
  const targets = [];
@@ -21058,9 +21103,9 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
21058
21103
  const home = homeExpanded(text);
21059
21104
  if (strict && unresolvedRefs(home).length > 0)
21060
21105
  return [unknownVarTarget(home)];
21061
- if (path27.isAbsolute(home))
21106
+ if (path28.isAbsolute(home))
21062
21107
  return [home];
21063
- return base === undefined ? [] : [path27.resolve(base, home)];
21108
+ return base === undefined ? [] : [path28.resolve(base, home)];
21064
21109
  });
21065
21110
  const at = (file) => {
21066
21111
  const all = atAll(file);
@@ -21202,7 +21247,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
21202
21247
  const here = segment.unanalyzable ? DIR_TARGET : `${OPAQUE_TARGET}${encodeURIComponent(runner?.split(/[\\/]/).at(-1) ?? "a command")}`;
21203
21248
  for (const file of opaque ?? [])
21204
21249
  for (const resolved of atAll(file))
21205
- targets.push(file === "." ? path27.join(resolved, here) : resolved);
21250
+ targets.push(file === "." ? path28.join(resolved, here) : resolved);
21206
21251
  const ln = words.findIndex((word) => /^ln$/i.test(word.split(/[\\/]/).at(-1) ?? ""));
21207
21252
  if (ln >= 0 && words.slice(0, ln).every((word) => PREFIXES2.has(word)))
21208
21253
  targets.push(...linkSources(words.slice(ln + 1), at));
@@ -21213,7 +21258,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
21213
21258
  const edits = editsOf(body);
21214
21259
  if (edits === null) {
21215
21260
  if (dir !== undefined)
21216
- targets.push(path27.join(dir, DIR_TARGET));
21261
+ targets.push(path28.join(dir, DIR_TARGET));
21217
21262
  } else
21218
21263
  for (const file of edits)
21219
21264
  targets.push(...atAll(file));
@@ -21221,7 +21266,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
21221
21266
  for (const invocation of workitInvocations(body.map(quoteWord2).join(" "), "posix")) {
21222
21267
  const { at: runsIn, args } = workitCwd(dir, invocation, atAll);
21223
21268
  if (args[0] === "git" && MUTATING_WORKIT_GIT.has(args[1] ?? "") && !inert(args.slice(2), ""))
21224
- targets.push(...runsIn.map((runs) => path27.join(runs, DIR_TARGET)));
21269
+ targets.push(...runsIn.map((runs) => path28.join(runs, DIR_TARGET)));
21225
21270
  }
21226
21271
  }
21227
21272
  return targets;
@@ -21242,7 +21287,7 @@ var shellMutationTargets = (cwd, command, dialect = "posix", strict = false) =>
21242
21287
  try {
21243
21288
  return [
21244
21289
  ...segmentTargets(cwd, command, dialect, 0, strict),
21245
- ...gitMutationDirs(cwd, command, dialect).map((dir) => path27.join(dir, DIR_TARGET))
21290
+ ...gitMutationDirs(cwd, command, dialect).map((dir) => path28.join(dir, DIR_TARGET))
21246
21291
  ];
21247
21292
  } catch {
21248
21293
  return [];
@@ -21279,7 +21324,7 @@ var liveDeny = ({ marker, checkout, ageMs, file }) => {
21279
21324
  var guarded = (targets) => {
21280
21325
  const seen = new Set;
21281
21326
  return targets.filter((target) => {
21282
- const dir = path27.dirname(target);
21327
+ const dir = path28.dirname(target);
21283
21328
  if (seen.has(dir))
21284
21329
  return false;
21285
21330
  seen.add(dir);
@@ -21300,7 +21345,7 @@ var claimAll = (owner, targets, deps) => {
21300
21345
  for (const target of guarded(targets))
21301
21346
  claimLiveSession(target, owner, deps);
21302
21347
  };
21303
- var liveTargets = (cwd, paths) => paths?.length ? paths.map((file) => path27.resolve(cwd, file)) : [path27.join(cwd, DIR_TARGET)];
21348
+ var liveTargets = (cwd, paths) => paths?.length ? paths.map((file) => path28.resolve(cwd, file)) : [path28.join(cwd, DIR_TARGET)];
21304
21349
  var issuedTarget = (cwd, targets) => {
21305
21350
  const state = resolveStateDir();
21306
21351
  const found = targets.find((target) => underIssued(state, cwd, homeExpanded(target), process.platform, canonical3));
@@ -21308,7 +21353,7 @@ var issuedTarget = (cwd, targets) => {
21308
21353
  };
21309
21354
  var underIssued = (state, cwd, target, platform = process.platform, real = (file) => file) => {
21310
21355
  const win = platform === "win32";
21311
- const p = win ? path27.win32 : path27.posix;
21356
+ const p = win ? path28.win32 : path28.posix;
21312
21357
  const fold = (value) => win || platform === "darwin" ? value.toLowerCase() : value;
21313
21358
  const named = win ? target.replace(/^\/([a-zA-Z])(?=\/|$)/, "$1:") : target;
21314
21359
  const relative = p.relative(fold(real(p.resolve(state))), fold(real(p.resolve(cwd, named))));
@@ -21402,10 +21447,10 @@ import { spawnSync as spawnSync15 } from "node:child_process";
21402
21447
 
21403
21448
  // packages/workit-core/src/ci-waiter.ts
21404
21449
  import fs20 from "node:fs";
21405
- import path28 from "node:path";
21450
+ import path29 from "node:path";
21406
21451
  var waiterFile = (cwd, pr) => {
21407
21452
  const common = gitCommonDir(cwd);
21408
- return common ? path28.join(common, "workit", "ci-waits", `pr-${pr}.json`) : null;
21453
+ return common ? path29.join(common, "workit", "ci-waits", `pr-${pr}.json`) : null;
21409
21454
  };
21410
21455
  var pidAlive2 = (pid) => {
21411
21456
  if (!Number.isSafeInteger(pid) || pid <= 0)
@@ -21919,16 +21964,16 @@ ${line}` };
21919
21964
  return decision;
21920
21965
  };
21921
21966
  // packages/workit-core/src/hooks/hosts/fields.ts
21922
- import { existsSync as existsSync10, realpathSync as realpathSync7, statSync as statSync4 } from "node:fs";
21923
- import path29 from "node:path";
21967
+ import { existsSync as existsSync11, realpathSync as realpathSync8, statSync as statSync4 } from "node:fs";
21968
+ import path30 from "node:path";
21924
21969
  var isRecord5 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
21925
21970
  var nonEmpty2 = (value) => typeof value === "string" && value.trim() !== "";
21926
21971
  var optionalText = (value) => typeof value === "string" ? value : null;
21927
21972
  var existingDirectory = (value) => {
21928
- if (!nonEmpty2(value) || !path29.isAbsolute(value) || !existsSync10(value))
21973
+ if (!nonEmpty2(value) || !path30.isAbsolute(value) || !existsSync11(value))
21929
21974
  return null;
21930
21975
  try {
21931
- return statSync4(value).isDirectory() ? realpathSync7(value) : null;
21976
+ return statSync4(value).isDirectory() ? realpathSync8(value) : null;
21932
21977
  } catch {
21933
21978
  return null;
21934
21979
  }
@@ -21993,7 +22038,7 @@ var writeTargets = (input) => {
21993
22038
  };
21994
22039
  // packages/workit-core/src/hooks/standing.ts
21995
22040
  import fs22 from "node:fs";
21996
- import path31 from "node:path";
22041
+ import path32 from "node:path";
21997
22042
 
21998
22043
  // packages/workit-core/src/hooks/hosts/claude-code.ts
21999
22044
  var CLAUDE_CODE_DESCRIPTOR = {
@@ -22628,40 +22673,40 @@ function neededChecks(lane, configured) {
22628
22673
  // packages/workit-core/src/hooks/worktree-confine.ts
22629
22674
  import { createHash as createHash17 } from "node:crypto";
22630
22675
  import fs21 from "node:fs";
22631
- import path30 from "node:path";
22676
+ import path31 from "node:path";
22632
22677
  var FANOUT_TOKEN_FILE = "workit-fanout-token";
22633
22678
  var NONE5 = { kind: "none" };
22634
22679
  var CASE_INSENSITIVE2 = process.platform === "darwin" || process.platform === "win32";
22635
22680
  var canonical4 = (file) => {
22636
22681
  let rest = "";
22637
- for (let dir = path30.resolve(file);; dir = path30.dirname(dir)) {
22682
+ for (let dir = path31.resolve(file);; dir = path31.dirname(dir)) {
22638
22683
  try {
22639
- return path30.join(fs21.realpathSync.native(dir), rest);
22684
+ return path31.join(fs21.realpathSync.native(dir), rest);
22640
22685
  } catch {
22641
- if (path30.dirname(dir) === dir)
22642
- return path30.resolve(file);
22643
- rest = rest ? path30.join(path30.basename(dir), rest) : path30.basename(dir);
22686
+ if (path31.dirname(dir) === dir)
22687
+ return path31.resolve(file);
22688
+ rest = rest ? path31.join(path31.basename(dir), rest) : path31.basename(dir);
22644
22689
  }
22645
22690
  }
22646
22691
  };
22647
22692
  var within = (child, parent) => {
22648
22693
  const fold = (value) => CASE_INSENSITIVE2 ? value.toLowerCase() : value;
22649
- const relative = path30.relative(fold(parent), fold(child));
22650
- return relative === "" || !relative.startsWith("..") && !path30.isAbsolute(relative);
22694
+ const relative = path31.relative(fold(parent), fold(child));
22695
+ return relative === "" || !relative.startsWith("..") && !path31.isAbsolute(relative);
22651
22696
  };
22652
22697
  var checkoutOf2 = (file) => {
22653
- for (let dir = canonical4(file);; dir = path30.dirname(dir)) {
22654
- const dotGit = path30.join(dir, ".git");
22698
+ for (let dir = canonical4(file);; dir = path31.dirname(dir)) {
22699
+ const dotGit = path31.join(dir, ".git");
22655
22700
  if (fs21.existsSync(dotGit)) {
22656
22701
  if (!fs21.statSync(dotGit).isFile())
22657
22702
  return { root: dir, workit: false };
22658
22703
  const admin = /^gitdir:\s*(.+)$/mu.exec(fs21.readFileSync(dotGit, "utf8"))?.[1]?.trim();
22659
22704
  return {
22660
22705
  root: dir,
22661
- workit: Boolean(admin) && fs21.existsSync(path30.join(path30.resolve(dir, admin), FANOUT_TOKEN_FILE))
22706
+ workit: Boolean(admin) && fs21.existsSync(path31.join(path31.resolve(dir, admin), FANOUT_TOKEN_FILE))
22662
22707
  };
22663
22708
  }
22664
- if (path30.dirname(dir) === dir)
22709
+ if (path31.dirname(dir) === dir)
22665
22710
  return null;
22666
22711
  }
22667
22712
  };
@@ -22673,8 +22718,8 @@ var workitWorktreeOf = (file) => {
22673
22718
  return null;
22674
22719
  }
22675
22720
  };
22676
- var bindingDir = () => path30.join(resolveStateDir(), "worktree-bind");
22677
- var bindingFile = (session, agentId) => path30.join(bindingDir(), `${createHash17("sha256").update(`${session}\x00${agentId}`).digest("hex").slice(0, 32)}.json`);
22721
+ var bindingDir = () => path31.join(resolveStateDir(), "worktree-bind");
22722
+ var bindingFile = (session, agentId) => path31.join(bindingDir(), `${createHash17("sha256").update(`${session}\x00${agentId}`).digest("hex").slice(0, 32)}.json`);
22678
22723
  var readBinding = (file) => {
22679
22724
  try {
22680
22725
  const value = JSON.parse(fs21.readFileSync(file, "utf8"));
@@ -22699,7 +22744,7 @@ var bind = (input, worktree) => {
22699
22744
  agentId,
22700
22745
  at: new Date().toISOString()
22701
22746
  };
22702
- fs21.mkdirSync(path30.dirname(file), { recursive: true });
22747
+ fs21.mkdirSync(path31.dirname(file), { recursive: true });
22703
22748
  fs21.writeFileSync(file, JSON.stringify(binding));
22704
22749
  try {
22705
22750
  if (inWorkitWorkspace(input.cwd))
@@ -22718,31 +22763,31 @@ var hostIsolated = (cwd, agentId) => {
22718
22763
  const checkout = checkoutOf2(cwd);
22719
22764
  if (!checkout)
22720
22765
  return false;
22721
- const dotGit = path30.join(checkout.root, ".git");
22766
+ const dotGit = path31.join(checkout.root, ".git");
22722
22767
  if (!fs21.statSync(dotGit).isFile())
22723
22768
  return false;
22724
22769
  const admin = /^gitdir:\s*(.+)$/mu.exec(fs21.readFileSync(dotGit, "utf8"))?.[1]?.trim();
22725
22770
  if (!admin)
22726
22771
  return false;
22727
- const adminDir = path30.resolve(checkout.root, admin);
22728
- const back = fs21.readFileSync(path30.join(adminDir, "gitdir"), "utf8").trim();
22729
- if (path30.relative(canonical4(path30.resolve(adminDir, back)), canonical4(dotGit)) !== "")
22772
+ const adminDir = path31.resolve(checkout.root, admin);
22773
+ const back = fs21.readFileSync(path31.join(adminDir, "gitdir"), "utf8").trim();
22774
+ if (path31.relative(canonical4(path31.resolve(adminDir, back)), canonical4(dotGit)) !== "")
22730
22775
  return false;
22731
- const common = path30.join(adminDir, "commondir");
22732
- const gitDir = fs21.existsSync(common) ? path30.resolve(adminDir, fs21.readFileSync(common, "utf8").trim()) : adminDir;
22733
- const expected = path30.join(path30.dirname(canonical4(gitDir)), ".claude", "worktrees", `agent-${agentId}`);
22734
- return path30.relative(canonical4(expected), checkout.root) === "";
22776
+ const common = path31.join(adminDir, "commondir");
22777
+ const gitDir = fs21.existsSync(common) ? path31.resolve(adminDir, fs21.readFileSync(common, "utf8").trim()) : adminDir;
22778
+ const expected = path31.join(path31.dirname(canonical4(gitDir)), ".claude", "worktrees", `agent-${agentId}`);
22779
+ return path31.relative(canonical4(expected), checkout.root) === "";
22735
22780
  } catch {
22736
22781
  return false;
22737
22782
  }
22738
22783
  };
22739
22784
  var runnerAt = (target) => {
22740
- const base = path30.basename(target);
22785
+ const base = path31.basename(target);
22741
22786
  return base.startsWith(OPAQUE_TARGET) ? decodeURIComponent(base.slice(OPAQUE_TARGET.length)) : null;
22742
22787
  };
22743
22788
  var shown = (target) => {
22744
- const named = /^\.workit-(?:live-target$|runs-)/.test(path30.basename(target)) ? path30.dirname(target) : target;
22745
- return path30.sep === "\\" ? named.replaceAll("/", "\\") : named;
22789
+ const named = /^\.workit-(?:live-target$|runs-)/.test(path31.basename(target)) ? path31.dirname(target) : target;
22790
+ return path31.sep === "\\" ? named.replaceAll("/", "\\") : named;
22746
22791
  };
22747
22792
  var unboundDeny = (input, target) => {
22748
22793
  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.";
@@ -22781,7 +22826,7 @@ var literalForm = (command, refs) => {
22781
22826
  };
22782
22827
  var unknownVarDeny = (input, worktree, targets, command) => {
22783
22828
  const refs = [
22784
- ...new Set(targets.flatMap((target) => path30.relative(UNKNOWN_VAR, path30.resolve(target)).split(path30.sep)[0].split("+").filter(Boolean).map(decodeURIComponent)))
22829
+ ...new Set(targets.flatMap((target) => path31.relative(UNKNOWN_VAR, path31.resolve(target)).split(path31.sep)[0].split("+").filter(Boolean).map(decodeURIComponent)))
22785
22830
  ];
22786
22831
  let text = command ?? "";
22787
22832
  const first = [];
@@ -22810,10 +22855,10 @@ function confineImplementer(input, targets, command) {
22810
22855
  try {
22811
22856
  if (!input.session.agentId || hostIsolated(input.cwd, input.session.agentId))
22812
22857
  return NONE5;
22813
- const unresolved = targets.filter((target) => within(path30.resolve(target), UNKNOWN_VAR));
22858
+ const unresolved = targets.filter((target) => within(path31.resolve(target), UNKNOWN_VAR));
22814
22859
  if (unresolved.length > 0)
22815
22860
  return unknownVarDeny(input, boundWorktree(input), unresolved, command);
22816
- if (targets.some((target) => within(path30.resolve(target), UNKNOWN_DIR)))
22861
+ if (targets.some((target) => within(path31.resolve(target), UNKNOWN_DIR)))
22817
22862
  return unknownDirDeny(input, boundWorktree(input));
22818
22863
  const bindings = canonical4(bindingDir());
22819
22864
  const judged = targets.map((named) => ({ named, real: canonical4(named) })).filter(({ real }) => within(real, bindings) || checkoutOf2(real) !== null);
@@ -22923,16 +22968,16 @@ var RUNS = /^(?:sh|bash|zsh|dash|ksh|mksh|ash|python[\d.]*|node|bun|deno|ruby|pe
22923
22968
  var INLINE = /^-[a-zA-Z]*[ceEpm]$|^--(?:eval|print|test|version|help)$|^-[hvV]$/;
22924
22969
  var VALUED = /^-[WXIrC]$|^--(?:require|import|loader|conditions|input-type)$/;
22925
22970
  var commonDir = (root) => {
22926
- const dotGit = path30.join(root, ".git");
22971
+ const dotGit = path31.join(root, ".git");
22927
22972
  if (!fs21.statSync(dotGit).isFile())
22928
22973
  return canonical4(dotGit);
22929
- const admin = path30.resolve(root, /^gitdir:\s*(.+)$/mu.exec(fs21.readFileSync(dotGit, "utf8"))?.[1]?.trim() ?? "");
22930
- const common = path30.join(admin, "commondir");
22931
- return canonical4(fs21.existsSync(common) ? path30.resolve(admin, fs21.readFileSync(common, "utf8").trim()) : admin);
22974
+ const admin = path31.resolve(root, /^gitdir:\s*(.+)$/mu.exec(fs21.readFileSync(dotGit, "utf8"))?.[1]?.trim() ?? "");
22975
+ const common = path31.join(admin, "commondir");
22976
+ return canonical4(fs21.existsSync(common) ? path31.resolve(admin, fs21.readFileSync(common, "utf8").trim()) : admin);
22932
22977
  };
22933
22978
  var inScratch = (real, repo) => {
22934
22979
  const checkout = checkoutOf2(real);
22935
- return checkout !== null && within(real, path30.join(checkout.root, SCRATCH)) && (repo === null || commonDir(checkout.root) === repo);
22980
+ return checkout !== null && within(real, path31.join(checkout.root, SCRATCH)) && (repo === null || commonDir(checkout.root) === repo);
22936
22981
  };
22937
22982
  var JUDGE_VERBS = {
22938
22983
  check: true,
@@ -22961,7 +23006,7 @@ var judgeVerbRefused = (args) => {
22961
23006
  var CLI_RUNNERS = /^(?:npx|bunx|pnpx|npm|pnpm|yarn|bun|node|nodejs|deno|tsx|ts-node)$/;
22962
23007
  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?$/;
22963
23008
  var workitCalls = (command, depth = 0, aliases = new Map) => depth > 4 ? [] : commandLines(command).flatMap((words) => {
22964
- const name = path30.basename(words[0] ?? "").toLowerCase();
23009
+ const name = path31.basename(words[0] ?? "").toLowerCase();
22965
23010
  if (name === "alias")
22966
23011
  return words.flatMap((word) => {
22967
23012
  const set = /^([\w-]+)=(.*)$/s.exec(word);
@@ -22991,11 +23036,11 @@ var judgeRefusal = (command, fed, depth = 0) => {
22991
23036
  return why;
22992
23037
  }
22993
23038
  const { words } = segment;
22994
- const runs = (word = "") => RUNS.test(path30.basename(word).toLowerCase());
23039
+ const runs = (word = "") => RUNS.test(path31.basename(word).toLowerCase());
22995
23040
  let at = 0;
22996
23041
  while (at < words.length && (LEADS.test(words[at]) || /^-\w$/.test(words[at - 1] ?? "") && !runs(words[at])))
22997
23042
  at++;
22998
- const name = path30.basename(words[at] ?? "").toLowerCase();
23043
+ const name = path31.basename(words[at] ?? "").toLowerCase();
22999
23044
  const args = words.slice(at + 1);
23000
23045
  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`;
23001
23046
  if (/^(?:cd|chdir|pushd|popd)$/.test(name))
@@ -23073,7 +23118,7 @@ var substitutingHeredoc = (command) => {
23073
23118
  var judgeDeny = (input, what) => {
23074
23119
  const role = input.session.agentType?.endsWith("reviewer") ? "reviewer" : "verifier";
23075
23120
  const root = checkoutOf2(input.cwd)?.root;
23076
- const scratch = root ? path30.join(root, SCRATCH) : `${SCRATCH}/ at the root of the checkout you judge`;
23121
+ const scratch = root ? path31.join(root, SCRATCH) : `${SCRATCH}/ at the root of the checkout you judge`;
23077
23122
  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.`;
23078
23123
  return {
23079
23124
  kind: "deny",
@@ -23088,7 +23133,7 @@ function confineJudge(input, targets) {
23088
23133
  const judged = checkoutOf2(input.cwd);
23089
23134
  const repo = judged ? commonDir(judged.root) : null;
23090
23135
  for (const target of targets) {
23091
- const resolved = path30.resolve(target);
23136
+ const resolved = path31.resolve(target);
23092
23137
  if (within(resolved, UNKNOWN_VAR) || within(resolved, UNKNOWN_DIR))
23093
23138
  return judgeDeny(input, "it writes to a path Workit cannot resolve (a variable, a command substitution or `cd -`): spell the path out");
23094
23139
  if (inScratch(canonical4(target), repo))
@@ -23119,7 +23164,7 @@ function confineJudgeShell(input, command, dialect = "posix") {
23119
23164
  let git = [];
23120
23165
  try {
23121
23166
  git = rawInvocations(command, dialect).flatMap(({ tool, dir, args }) => tool === "git" && (args[0] === "push" || leadOwnedGit(args)) ? [
23122
- path30.join(dir === undefined ? UNKNOWN_DIR : path30.resolve(input.cwd, dir ?? "."), `${OPAQUE_TARGET}git`)
23167
+ path31.join(dir === undefined ? UNKNOWN_DIR : path31.resolve(input.cwd, dir ?? "."), `${OPAQUE_TARGET}git`)
23123
23168
  ] : []);
23124
23169
  } catch {}
23125
23170
  return confineJudge(input, [
@@ -23164,7 +23209,7 @@ var judgeChecksLine = (cwd) => {
23164
23209
 
23165
23210
  // packages/workit-core/src/hooks/standing.ts
23166
23211
  var readPlans = (store) => {
23167
- const dir = path31.join(store, "fanouts");
23212
+ const dir = path32.join(store, "fanouts");
23168
23213
  let names;
23169
23214
  try {
23170
23215
  names = fs22.readdirSync(dir).filter((name) => name.endsWith(".json"));
@@ -23174,7 +23219,7 @@ var readPlans = (store) => {
23174
23219
  const plans = [];
23175
23220
  for (const name of names) {
23176
23221
  try {
23177
- const raw = JSON.parse(fs22.readFileSync(path31.join(dir, name), "utf8"));
23222
+ const raw = JSON.parse(fs22.readFileSync(path32.join(dir, name), "utf8"));
23178
23223
  if (typeof raw.name !== "string" || !Array.isArray(raw.slices))
23179
23224
  continue;
23180
23225
  const texts = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string" && item !== "") : [];
@@ -23373,8 +23418,8 @@ var cdWorkitSplit = (command) => {
23373
23418
 
23374
23419
  // packages/workit-core/src/hooks/model-limit.ts
23375
23420
  import { closeSync as closeSync2, openSync as openSync2, readdirSync as readdirSync3, readSync, statSync as statSync5 } from "node:fs";
23376
- import os9 from "node:os";
23377
- import path32 from "node:path";
23421
+ import os10 from "node:os";
23422
+ import path33 from "node:path";
23378
23423
  var MONTHS = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
23379
23424
  var WEEKDAYS = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"];
23380
23425
  var TIME_WORD = String.raw`(?:\d|(?:in|at|on|later|tomorrow|soon)\b|(?:${[...WEEKDAYS, ...MONTHS].join("|")})[a-z]*\b)`;
@@ -23572,17 +23617,17 @@ var firstPrompt = (file) => {
23572
23617
  var claudeProjectSlug = (cwd) => cwd.replace(/[^A-Za-z0-9]/gu, "-");
23573
23618
  var listDir = (dir) => {
23574
23619
  try {
23575
- return readdirSync3(dir).map((name) => path32.join(dir, name));
23620
+ return readdirSync3(dir).map((name) => path33.join(dir, name));
23576
23621
  } catch {
23577
23622
  return [];
23578
23623
  }
23579
23624
  };
23580
23625
  var SCAN_MS = 30 * 60000;
23581
23626
  var scanClaudeTranscripts = (cwd, env, now = new Date) => {
23582
- const projects = path32.join(env.CLAUDE_CONFIG_DIR || path32.join(env.HOME || os9.homedir(), ".claude"), "projects");
23583
- const project = path32.join(projects, claudeProjectSlug(cwd));
23627
+ const projects = path33.join(env.CLAUDE_CONFIG_DIR || path33.join(env.HOME || os10.homedir(), ".claude"), "projects");
23628
+ const project = path33.join(projects, claudeProjectSlug(cwd));
23584
23629
  const notes = [];
23585
- const files = listDir(project).flatMap((entry) => entry.endsWith(".jsonl") ? [{ file: entry, worker: false }] : listDir(path32.join(entry, "subagents")).filter((file) => file.endsWith(".jsonl")).map((file) => ({ file, worker: true })));
23630
+ 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 })));
23586
23631
  for (const { file, worker } of files)
23587
23632
  try {
23588
23633
  const stat = statSync5(file);
@@ -23597,7 +23642,7 @@ var scanClaudeTranscripts = (cwd, env, now = new Date) => {
23597
23642
  if (!seen)
23598
23643
  continue;
23599
23644
  notes.push(worker ? redispatchNote(seen, {
23600
- label: `worker ${path32.basename(file, ".jsonl")}`,
23645
+ label: `worker ${path33.basename(file, ".jsonl")}`,
23601
23646
  prompt: firstPrompt(file)
23602
23647
  }, 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.`);
23603
23648
  } catch {}
@@ -23982,7 +24027,7 @@ var dispatchHook = (adapter, raw, env = process.env) => {
23982
24027
  };
23983
24028
  // packages/workit-core/src/hooks/deadline.ts
23984
24029
  import { appendFileSync, mkdirSync as mkdirSync4 } from "node:fs";
23985
- import path33 from "node:path";
24030
+ import path34 from "node:path";
23986
24031
  var HOOK_SKIP_TEXT = "workit context skipped: host under load";
23987
24032
  var HOOK_DEADLINE_MS = 8000;
23988
24033
  var HOST_DEADLINES = {
@@ -24000,7 +24045,7 @@ var hookDeadlineMs = (env, host = "", native) => {
24000
24045
  const row = HOST_DEADLINES[host];
24001
24046
  return override(env) ?? (row ? native === undefined ? Math.min(...Object.values(row)) : row[native] ?? row[""] : HOOK_DEADLINE_MS);
24002
24047
  };
24003
- var skipsFile = (stateDir) => path33.join(stateDir, HOOK_SKIPS_FILE);
24048
+ var skipsFile = (stateDir) => path34.join(stateDir, HOOK_SKIPS_FILE);
24004
24049
  var recordHookSkip = (skip, stateDir = resolveStateDir()) => {
24005
24050
  try {
24006
24051
  mkdirSync4(stateDir, { recursive: true });