@workit-dev/pi 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.
Files changed (2) hide show
  1. package/dist/workit.js +284 -239
  2. package/package.json +1 -1
package/dist/workit.js CHANGED
@@ -4,8 +4,8 @@ import { fileURLToPath as fileURLToPath2 } from "node:url";
4
4
 
5
5
  // packages/workit-core/src/core.ts
6
6
  import { spawnSync as spawnSync21 } from "node:child_process";
7
- import { existsSync as existsSync10, realpathSync as realpathSync7 } from "node:fs";
8
- import path31 from "node:path";
7
+ import { existsSync as existsSync11, realpathSync as realpathSync8 } from "node:fs";
8
+ import path32 from "node:path";
9
9
 
10
10
  // packages/workit-core/src/core/task-contract.ts
11
11
  import { createHash, randomUUID } from "node:crypto";
@@ -18257,31 +18257,75 @@ var exportDigest = (bundle) => sha256({
18257
18257
  });
18258
18258
  // packages/workit-core/src/core/route-intent.ts
18259
18259
  import { spawnSync as spawnSync16 } from "node:child_process";
18260
- import { existsSync as existsSync8 } from "node:fs";
18261
- import path26 from "node:path";
18260
+ import { existsSync as existsSync9 } from "node:fs";
18261
+ import path27 from "node:path";
18262
18262
 
18263
18263
  // packages/workit-core/src/hooks/raw-git.ts
18264
18264
  import { spawnSync as spawnSync15 } from "node:child_process";
18265
18265
  import { createHash as createHash15 } from "node:crypto";
18266
18266
  import fs18 from "node:fs";
18267
- import os6 from "node:os";
18268
- import path25 from "node:path";
18267
+ import os7 from "node:os";
18268
+ import path26 from "node:path";
18269
18269
 
18270
18270
  // packages/workit-core/src/autonomy.ts
18271
+ import os6 from "node:os";
18272
+ import path24 from "node:path";
18273
+
18274
+ // packages/workit-core/src/core/eval-world.ts
18275
+ import { existsSync as existsSync8, realpathSync as realpathSync5 } from "node:fs";
18271
18276
  import os5 from "node:os";
18272
18277
  import path23 from "node:path";
18278
+ var EVAL_WORLD_ENV = "WORKIT_EVAL_WORLD";
18279
+ var EVAL_WORLD_MARKER = ".workit-eval-world";
18280
+ var inside2 = (dir, file) => {
18281
+ const rel = path23.relative(dir, file);
18282
+ return !rel.startsWith("..") && !path23.isAbsolute(rel);
18283
+ };
18284
+ var evalWorldEntry = (cwd) => {
18285
+ const raw = process.env[EVAL_WORLD_ENV];
18286
+ if (!raw || !path23.isAbsolute(raw))
18287
+ return null;
18288
+ try {
18289
+ const world = realpathSync5(raw);
18290
+ if (!inside2(realpathSync5(os5.tmpdir()), world) || !inside2(world, realpathSync5(cwd)) || !existsSync8(path23.join(world, EVAL_WORLD_MARKER)))
18291
+ return null;
18292
+ return loadWorkspacesFrom(path23.join(world, "config"))[0] ?? null;
18293
+ } catch {
18294
+ return null;
18295
+ }
18296
+ };
18297
+
18298
+ // packages/workit-core/src/autonomy.ts
18273
18299
  var accountHome2 = () => {
18274
18300
  try {
18275
- return os5.userInfo().homedir;
18301
+ return os6.userInfo().homedir;
18276
18302
  } catch {
18277
- return os5.homedir();
18303
+ return os6.homedir();
18278
18304
  }
18279
18305
  };
18280
18306
  var grantsHome = { resolve: accountHome2 };
18281
18307
  var grantsDir = () => configDir({ HOME: grantsHome.resolve() });
18308
+ var benchWorld = (cwd) => {
18309
+ const entry = evalWorldEntry(cwd);
18310
+ if (!entry)
18311
+ return null;
18312
+ const { grants } = configuredGrants(entry);
18313
+ const lowered = {};
18314
+ for (const kind of GRANT_KINDS) {
18315
+ const value = grants[kind];
18316
+ if (value !== undefined && raises(kind, value, DEFAULT_GRANTS[kind]))
18317
+ lowered[kind] = value;
18318
+ }
18319
+ return {
18320
+ name: entry.name,
18321
+ glob: entry.glob,
18322
+ ...entry.defaultEndpoint ? { defaultEndpoint: entry.defaultEndpoint } : {},
18323
+ autonomy: lowered
18324
+ };
18325
+ };
18282
18326
  var grantsOverride = () => {
18283
- const configured = path23.resolve(resolveConfigDir());
18284
- return configured === path23.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 ${path23.join(grantsDir(), "workspaces.json")}, so the D4 defaults apply until grants are set there`;
18327
+ const configured = path24.resolve(resolveConfigDir());
18328
+ return configured === path24.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 ${path24.join(grantsDir(), "workspaces.json")}, so the D4 defaults apply until grants are set there`;
18285
18329
  };
18286
18330
  var GRANT_KINDS = ["push", "pr", "merge", "release", "rerun"];
18287
18331
  var DEFAULT_GRANTS = Object.freeze({
@@ -18446,11 +18490,12 @@ function capAt(named, where, by, why, main = false) {
18446
18490
  };
18447
18491
  }
18448
18492
  function resolveAutonomy(cwd, target) {
18449
- const override = grantsOverride();
18493
+ const world = benchWorld(cwd);
18494
+ const override = world ? null : grantsOverride();
18450
18495
  if (override)
18451
18496
  return { ...autonomyOf(null), note: override };
18452
18497
  const name = process.env.WORKIT_WORKSPACE_NAME?.trim() || undefined;
18453
- let autonomy = autonomyOf(resolveWorkspaceFrom(cwd, grantsDir(), name));
18498
+ let autonomy = autonomyOf(resolveWorkspaceFrom(cwd, grantsDir(), name) ?? world);
18454
18499
  if (name)
18455
18500
  autonomy = capAt(autonomy, cwd, `WORKIT_WORKSPACE_NAME=${name}`, "a name never raises grants");
18456
18501
  const above = checkoutsAbove(cwd);
@@ -18538,7 +18583,7 @@ var raises = (kind, current, next) => {
18538
18583
  // packages/workit-core/src/hooks/session-marker.ts
18539
18584
  import { createHash as createHash14 } from "node:crypto";
18540
18585
  import fs17 from "node:fs";
18541
- import path24 from "node:path";
18586
+ import path25 from "node:path";
18542
18587
  var sessionMarkerFile = (input, session, store) => {
18543
18588
  let dir = store;
18544
18589
  if (dir === undefined) {
@@ -18548,7 +18593,7 @@ var sessionMarkerFile = (input, session, store) => {
18548
18593
  dir = location.dir;
18549
18594
  }
18550
18595
  const name = createHash14("sha256").update(`${input.host}\x00${session}`).digest("hex").slice(0, 32);
18551
- return path24.join(dir, "hooks", `skills-${name}.json`);
18596
+ return path25.join(dir, "hooks", `skills-${name}.json`);
18552
18597
  };
18553
18598
  var list2 = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
18554
18599
  var EMPTY = {
@@ -18583,7 +18628,7 @@ var parseMarker = (text) => {
18583
18628
  };
18584
18629
  var readSessionMarker = (file) => parseMarker(readRaw(file));
18585
18630
  var writeAtomic = (file, marker) => {
18586
- fs17.mkdirSync(path24.dirname(file), { recursive: true });
18631
+ fs17.mkdirSync(path25.dirname(file), { recursive: true });
18587
18632
  const temp = `${file}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
18588
18633
  try {
18589
18634
  fs17.writeFileSync(temp, JSON.stringify(marker));
@@ -19168,14 +19213,14 @@ var GIT_CONFIG_ENV = /^(?:GIT_(?:CONFIG\w*|DIR|COMMON_DIR|WORK_TREE|SSH|SSH_COMM
19168
19213
  var ASSIGNMENT = /^([A-Za-z_]\w*)=([\s\S]*)$/;
19169
19214
  var MAX_DEPTH = 4;
19170
19215
  var MAX_EXPANSIONS = 16;
19171
- var isAbsolute = (value) => path25.isAbsolute(value) || /^[A-Za-z]:[\\/]/.test(value) || value.startsWith("\\\\");
19216
+ var isAbsolute = (value) => path26.isAbsolute(value) || /^[A-Za-z]:[\\/]/.test(value) || value.startsWith("\\\\");
19172
19217
  var HERE = /^(?:\$PWD|\$\{PWD\}|\$\(\s*pwd\s*\)|`pwd`|\$\(\s*git\s+rev-parse\s+--show-toplevel\s*\))(?=$|[\\/])/;
19173
19218
  var joinDir = (base, raw) => {
19174
19219
  const next = raw.replace(HERE, ".");
19175
19220
  if (base === undefined || /[$`*?]/.test(next) || next === "-")
19176
19221
  return;
19177
- const expanded = next === "~" || next.startsWith("~/") ? path25.join(os6.homedir(), next.slice(1)) : next;
19178
- return base === null || isAbsolute(expanded) ? expanded : path25.join(base, expanded);
19222
+ const expanded = next === "~" || next.startsWith("~/") ? path26.join(os7.homedir(), next.slice(1)) : next;
19223
+ return base === null || isAbsolute(expanded) ? expanded : path26.join(base, expanded);
19179
19224
  };
19180
19225
  var rebase = (base, inner) => inner === null ? base : inner === undefined ? undefined : joinDir(base, inner);
19181
19226
  var cdTarget = (words) => {
@@ -19576,7 +19621,7 @@ function walk2(command, dialect, depth, seen, inherited = {}) {
19576
19621
  }
19577
19622
  if (CD.has(name)) {
19578
19623
  const target = cdTarget(words);
19579
- dir = target === null ? os6.homedir() : joinDir(dir, target);
19624
+ dir = target === null ? os7.homedir() : joinDir(dir, target);
19580
19625
  } else if (PUSHD.has(name)) {
19581
19626
  const target = cdTarget(words);
19582
19627
  stack.push(dir);
@@ -20097,17 +20142,17 @@ var headSha2 = (repo) => {
20097
20142
  if (!git || git.reftable)
20098
20143
  return null;
20099
20144
  try {
20100
- const head = fs18.readFileSync(path25.join(git.gitDir, "HEAD"), "utf8").trim();
20145
+ const head = fs18.readFileSync(path26.join(git.gitDir, "HEAD"), "utf8").trim();
20101
20146
  if (/^[0-9a-f]{40,64}$/.test(head))
20102
20147
  return head;
20103
20148
  const ref = /^ref: (refs\/.+)$/.exec(head)?.[1];
20104
20149
  if (!ref)
20105
20150
  return null;
20106
- const common = path25.dirname(repo.location.dir);
20151
+ const common = path26.dirname(repo.location.dir);
20107
20152
  try {
20108
- return fs18.readFileSync(path25.join(common, ref), "utf8").trim() || null;
20153
+ return fs18.readFileSync(path26.join(common, ref), "utf8").trim() || null;
20109
20154
  } catch {}
20110
- const packed = fs18.readFileSync(path25.join(common, "packed-refs"), "utf8");
20155
+ const packed = fs18.readFileSync(path26.join(common, "packed-refs"), "utf8");
20111
20156
  return new RegExp(`^([0-9a-f]{40,64}) ${ref.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`, "m").exec(packed)?.[1] ?? null;
20112
20157
  } catch {
20113
20158
  return null;
@@ -20200,7 +20245,7 @@ var expandGitAliases = (root, invocation, cache = new Map, depth = 0) => {
20200
20245
  const sub = invocation.args[0];
20201
20246
  if (invocation.tool !== "git" || invocation.dir === undefined || !sub || sub.startsWith("-") || GIT_COMMANDS.has(sub) || depth >= MAX_DEPTH)
20202
20247
  return [invocation];
20203
- const dir = path25.resolve(root, invocation.dir ?? ".");
20248
+ const dir = path26.resolve(root, invocation.dir ?? ".");
20204
20249
  if (!fs18.existsSync(dir))
20205
20250
  return [invocation];
20206
20251
  const config = gitConfig(dir, invocation, cache);
@@ -20223,11 +20268,11 @@ var expandGitAliases = (root, invocation, cache = new Map, depth = 0) => {
20223
20268
  var normalizedUrl = (url, dir) => {
20224
20269
  const trimmed = url.trim();
20225
20270
  if (/^file:\/\//i.test(trimmed))
20226
- return path25.resolve(dir, trimmed.slice(7)).replace(/\/+$/, "").replace(/\.git$/, "");
20271
+ return path26.resolve(dir, trimmed.slice(7)).replace(/\/+$/, "").replace(/\.git$/, "");
20227
20272
  const scheme = /^[a-z][a-z0-9+.-]*:\/\//i.exec(trimmed);
20228
20273
  const scp = !scheme && /^(?:[^@/\\]+@)?[^/\\:]{2,}:/.test(trimmed);
20229
20274
  if (!scheme && !scp)
20230
- return path25.resolve(dir, trimmed).replace(/\/+$/, "").replace(/\.git$/, "");
20275
+ return path26.resolve(dir, trimmed).replace(/\/+$/, "").replace(/\.git$/, "");
20231
20276
  const value = scheme ? trimmed.slice(scheme[0].length).replace(/^[^@/]*@/, "").replace(/^([^/:]+):\d+(?=\/)/, "$1") : trimmed.replace(/^[^@/]*@/, "").replace(":", "/");
20232
20277
  return value.toLowerCase().replace(/\/{2,}/g, "/").replace(/^www\./, "").replace(/\/+$/, "").replace(/\.git$/, "");
20233
20278
  };
@@ -20455,7 +20500,7 @@ var actionsIn = (cwd, command, dialect, cache = new Map, all = false) => {
20455
20500
  const out = [];
20456
20501
  const repos = new Map;
20457
20502
  const repoFor = (relative) => {
20458
- const dir = path25.resolve(cwd, relative ?? ".");
20503
+ const dir = path26.resolve(cwd, relative ?? ".");
20459
20504
  if (!repos.has(dir)) {
20460
20505
  const repo = repoAt(dir);
20461
20506
  const workit = repo !== null && isWorkitWorkspace(repo);
@@ -20475,7 +20520,7 @@ var actionsIn = (cwd, command, dialect, cache = new Map, all = false) => {
20475
20520
  continue;
20476
20521
  const action = rawAction(invocation);
20477
20522
  const at = !action ? null : repoFor(invocation.dir) ?? (all && invocation.tool !== "git" && explicitRepo(invocation.tool === "gh", "repo" in action && action.repo || "", invocation.env ?? {}) ? {
20478
- repo: { dir: path25.resolve(cwd, invocation.dir ?? "."), branch: null },
20523
+ repo: { dir: path26.resolve(cwd, invocation.dir ?? "."), branch: null },
20479
20524
  workit: false
20480
20525
  } : null);
20481
20526
  if (action && at)
@@ -20612,9 +20657,9 @@ var grantRefusal = (action, repo, invocation, cache) => {
20612
20657
  return null;
20613
20658
  };
20614
20659
  var localTag = (repo, name) => {
20615
- const common = path25.dirname(repo.location.dir);
20660
+ const common = path26.dirname(repo.location.dir);
20616
20661
  try {
20617
- return fs18.existsSync(path25.join(common, "refs/tags", name)) || fs18.readFileSync(path25.join(common, "packed-refs"), "utf8").includes(` refs/tags/${name}
20662
+ return fs18.existsSync(path26.join(common, "refs/tags", name)) || fs18.readFileSync(path26.join(common, "packed-refs"), "utf8").includes(` refs/tags/${name}
20618
20663
  `);
20619
20664
  } catch {
20620
20665
  return false;
@@ -20634,7 +20679,7 @@ var analysisDenial = (error) => ({
20634
20679
  });
20635
20680
  var NEXT_COMMAND = "next";
20636
20681
  var MARKER_TTL_SECONDS = 3600;
20637
- var markerFile = (repo, session, key) => path25.join(repo.location.dir, "hooks", `commit-${createHash15("sha256").update(`${session}\x00${key}`).digest("hex").slice(0, 32)}.json`);
20682
+ var markerFile = (repo, session, key) => path26.join(repo.location.dir, "hooks", `commit-${createHash15("sha256").update(`${session}\x00${key}`).digest("hex").slice(0, 32)}.json`);
20638
20683
  var callKey = (toolUseId, command) => toolUseId ?? `cmd:${createHash15("sha256").update(command).digest("hex")}`;
20639
20684
  function noteRawCommit(input, command, key) {
20640
20685
  try {
@@ -20645,7 +20690,7 @@ function noteRawCommit(input, command, key) {
20645
20690
  if (action.kind !== "commit")
20646
20691
  continue;
20647
20692
  const file = markerFile(repo, input.session.id, key);
20648
- fs18.mkdirSync(path25.dirname(file), { recursive: true });
20693
+ fs18.mkdirSync(path26.dirname(file), { recursive: true });
20649
20694
  fs18.writeFileSync(file, `${JSON.stringify({ head: headSha2(repo), at })}
20650
20695
  `);
20651
20696
  }
@@ -20886,8 +20931,8 @@ var judgedDir = (root, dir) => {
20886
20931
  return null;
20887
20932
  if (dir === null)
20888
20933
  return root;
20889
- const resolved = path26.resolve(root, dir);
20890
- return existsSync8(resolved) && inWorkitWorkspace(resolved) ? resolved : null;
20934
+ const resolved = path27.resolve(root, dir);
20935
+ return existsSync9(resolved) && inWorkitWorkspace(resolved) ? resolved : null;
20891
20936
  };
20892
20937
  var shellBranchPolicyViolation = (root, command, dialect = "posix") => {
20893
20938
  let judged = false;
@@ -20908,7 +20953,7 @@ var shellBranchPolicyViolation = (root, command, dialect = "posix") => {
20908
20953
  return judged ? { ok: true } : null;
20909
20954
  };
20910
20955
  // packages/workit-core/src/core/task-engine.ts
20911
- import { realpathSync as realpathSync6 } from "node:fs";
20956
+ import { realpathSync as realpathSync7 } from "node:fs";
20912
20957
 
20913
20958
  // packages/workit-core/src/core/policy-resolver.ts
20914
20959
  function resolvePolicy(input) {
@@ -21157,12 +21202,12 @@ var judgeInputSummary = (raw) => {
21157
21202
  };
21158
21203
 
21159
21204
  // packages/workit-core/src/core/task-view.ts
21160
- import { realpathSync as realpathSync5 } from "node:fs";
21205
+ import { realpathSync as realpathSync6 } from "node:fs";
21161
21206
  var environment = () => [];
21162
21207
  var sameSession2 = (value, context) => typeof value === "object" && value !== null && value.kind === "host" && value.host === context.caller.host && value.handle === context.caller.actor;
21163
21208
  function contextRootError(store, context) {
21164
21209
  try {
21165
- realpathSync5(context.root);
21210
+ realpathSync6(context.root);
21166
21211
  const root = checkoutRootOf(context.root);
21167
21212
  if (root !== store.root && !sameDirectoryIdentity(root, store.root))
21168
21213
  return failure2("invalid_input", "operation context root does not match the task store root");
@@ -22632,7 +22677,7 @@ class WorkitCore {
22632
22677
  if (view.task.workspaceId !== view.workspace.id)
22633
22678
  return failure2("invalid_input", "task and workspace bindings are invalid");
22634
22679
  try {
22635
- if (realpathSync6(view.workspace.root) !== this.store.root)
22680
+ if (realpathSync7(view.workspace.root) !== this.store.root)
22636
22681
  return failure2("invalid_input", "task view root does not match the task store");
22637
22682
  } catch {
22638
22683
  return failure2("invalid_input", "task view root cannot be resolved");
@@ -22883,8 +22928,8 @@ class WorkitCore {
22883
22928
  }
22884
22929
  // packages/workit-core/src/core/repo-context.ts
22885
22930
  import { spawnSync as spawnSync17 } from "node:child_process";
22886
- import { existsSync as existsSync9, readFileSync as readFileSync8, readdirSync as readdirSync3 } from "node:fs";
22887
- import path27 from "node:path";
22931
+ import { existsSync as existsSync10, readFileSync as readFileSync8, readdirSync as readdirSync3 } from "node:fs";
22932
+ import path28 from "node:path";
22888
22933
  var isSafeContextRange = (value) => value.length <= 4096 && (() => {
22889
22934
  try {
22890
22935
  gitRevisionParts(value);
@@ -23028,13 +23073,13 @@ var findPrTemplate = (cwd) => {
23028
23073
  for (const rel of PR_TEMPLATE_FILES) {
23029
23074
  const parts = rel.split("/");
23030
23075
  const base = parts[parts.length - 1];
23031
- const dir = parts.length > 1 ? path27.join(cwd, ...parts.slice(0, -1)) : cwd;
23076
+ const dir = parts.length > 1 ? path28.join(cwd, ...parts.slice(0, -1)) : cwd;
23032
23077
  const actual = probeCaseInsensitive(dir, base);
23033
23078
  if (actual)
23034
23079
  return [...parts.slice(0, -1), actual].join("/");
23035
23080
  }
23036
23081
  for (const rel of PR_TEMPLATE_DIRS) {
23037
- const only = singleMarkdown(path27.join(cwd, ...rel.split("/")));
23082
+ const only = singleMarkdown(path28.join(cwd, ...rel.split("/")));
23038
23083
  if (only)
23039
23084
  return `${rel}/${only}`;
23040
23085
  }
@@ -23064,8 +23109,8 @@ var diffStatForRange = (cwd, range) => {
23064
23109
  return runGit(cwd, ["diff", "--stat", "--"]).stdout;
23065
23110
  };
23066
23111
  var packageScripts = (cwd, keys) => {
23067
- const pkgPath = path27.join(cwd, "package.json");
23068
- if (!existsSync9(pkgPath))
23112
+ const pkgPath = path28.join(cwd, "package.json");
23113
+ if (!existsSync10(pkgPath))
23069
23114
  return [];
23070
23115
  try {
23071
23116
  const pkg = JSON.parse(readFileSync8(pkgPath, "utf8"));
@@ -23090,9 +23135,9 @@ var documentationFiles = (cwd) => {
23090
23135
  if (entry.isDirectory()) {
23091
23136
  if (excluded.has(entry.name))
23092
23137
  continue;
23093
- walk(path27.join(dir, entry.name), depth + 1);
23138
+ walk(path28.join(dir, entry.name), depth + 1);
23094
23139
  } else if (entry.isFile() && (entry.name === "README.md" || entry.name.endsWith(".md"))) {
23095
- matches.push("./" + path27.relative(cwd, path27.join(dir, entry.name)).replaceAll("\\", "/"));
23140
+ matches.push("./" + path28.relative(cwd, path28.join(dir, entry.name)).replaceAll("\\", "/"));
23096
23141
  }
23097
23142
  }
23098
23143
  };
@@ -23100,7 +23145,7 @@ var documentationFiles = (cwd) => {
23100
23145
  return matches.toSorted().slice(0, 200);
23101
23146
  };
23102
23147
  var readTrimmed2 = (file, maxLines) => {
23103
- if (!existsSync9(file))
23148
+ if (!existsSync10(file))
23104
23149
  return "";
23105
23150
  const lines = readFileSync8(file, "utf8").split(`
23106
23151
  `);
@@ -23108,7 +23153,7 @@ var readTrimmed2 = (file, maxLines) => {
23108
23153
  `);
23109
23154
  };
23110
23155
  function prReadyContext(root, range) {
23111
- const cwd = path27.resolve(repoRoot(root));
23156
+ const cwd = path28.resolve(repoRoot(root));
23112
23157
  if (range !== undefined && !isResolvableContextRange(cwd, range))
23113
23158
  return invalidRange(cwd);
23114
23159
  let stdout = "";
@@ -23166,7 +23211,7 @@ ${status.stderr}` : "");
23166
23211
  stdout += `template_path: ${template}
23167
23212
 
23168
23213
  `;
23169
- stdout += readTrimmed2(path27.join(cwd, template), 220);
23214
+ stdout += readTrimmed2(path28.join(cwd, template), 220);
23170
23215
  } else {
23171
23216
  stdout += `template_path: none
23172
23217
 
@@ -23176,7 +23221,7 @@ ${status.stderr}` : "");
23176
23221
  stdout += `
23177
23222
  `;
23178
23223
  stdout += printSection("Recent Validation Signals");
23179
- if (existsSync9(path27.join(cwd, "package.json"))) {
23224
+ if (existsSync10(path28.join(cwd, "package.json"))) {
23180
23225
  stdout += `package.json detected. Common scripts:
23181
23226
  `;
23182
23227
  const found = packageScripts(cwd, ["lint", "format:check", "test", "build"]);
@@ -23185,7 +23230,7 @@ ${status.stderr}` : "");
23185
23230
  `) + `
23186
23231
  `;
23187
23232
  }
23188
- if (existsSync9(path27.join(cwd, "Cargo.toml")) || existsSync9(path27.join(cwd, "src-tauri/Cargo.toml"))) {
23233
+ if (existsSync10(path28.join(cwd, "Cargo.toml")) || existsSync10(path28.join(cwd, "src-tauri/Cargo.toml"))) {
23189
23234
  stdout += `Rust project detected.
23190
23235
  `;
23191
23236
  }
@@ -23218,7 +23263,7 @@ var CHANGELOG_RULES = `- Use an [Unreleased] section.
23218
23263
  - Apply with the host-native editor, preserving the repository changelog conventions.
23219
23264
  - If Unreleased already has duplicate category headings, normalize_only first.`;
23220
23265
  function changelogContext(root, range) {
23221
- const cwd = path27.resolve(repoRoot(root));
23266
+ const cwd = path28.resolve(repoRoot(root));
23222
23267
  if (range !== undefined && !isResolvableContextRange(cwd, range))
23223
23268
  return invalidRange(cwd);
23224
23269
  const resolvedRange = rangeArgOrDefault(range, cwd);
@@ -23236,8 +23281,8 @@ function changelogContext(root, range) {
23236
23281
  stdout += CHANGELOG_RULES + `
23237
23282
  `;
23238
23283
  stdout += printSection("Existing CHANGELOG.md");
23239
- const changelogPath = path27.join(cwd, "CHANGELOG.md");
23240
- if (existsSync9(changelogPath)) {
23284
+ const changelogPath = path28.join(cwd, "CHANGELOG.md");
23285
+ if (existsSync10(changelogPath)) {
23241
23286
  stdout += readTrimmed2(changelogPath, 260) + `
23242
23287
  `;
23243
23288
  } else {
@@ -23256,7 +23301,7 @@ function changelogContext(root, range) {
23256
23301
  return { stdout, stderr: "", exitCode: 0, cwd };
23257
23302
  }
23258
23303
  function docsRefreshContext(root, range) {
23259
- const cwd = path27.resolve(repoRoot(root));
23304
+ const cwd = path28.resolve(repoRoot(root));
23260
23305
  if (range !== undefined && !isResolvableContextRange(cwd, range))
23261
23306
  return invalidRange(cwd);
23262
23307
  const resolvedRange = rangeArgOrDefault(range, cwd);
@@ -23278,8 +23323,8 @@ function docsRefreshContext(root, range) {
23278
23323
  `) + `
23279
23324
  `;
23280
23325
  stdout += printSection("README Preview");
23281
- const readme = path27.join(cwd, "README.md");
23282
- if (existsSync9(readme)) {
23326
+ const readme = path28.join(cwd, "README.md");
23327
+ if (existsSync10(readme)) {
23283
23328
  stdout += readTrimmed2(readme, 220) + `
23284
23329
  `;
23285
23330
  } else {
@@ -23287,8 +23332,8 @@ function docsRefreshContext(root, range) {
23287
23332
  `;
23288
23333
  }
23289
23334
  stdout += printSection("Package Scripts");
23290
- const pkgPath = path27.join(cwd, "package.json");
23291
- if (existsSync9(pkgPath)) {
23335
+ const pkgPath = path28.join(cwd, "package.json");
23336
+ if (existsSync10(pkgPath)) {
23292
23337
  try {
23293
23338
  const pkg = JSON.parse(readFileSync8(pkgPath, "utf8"));
23294
23339
  stdout += JSON.stringify({ name: pkg.name, version: pkg.version, scripts: pkg.scripts }, null, 2) + `
@@ -23301,7 +23346,7 @@ function docsRefreshContext(root, range) {
23301
23346
  return { stdout, stderr: "", exitCode: 0, cwd };
23302
23347
  }
23303
23348
  function releaseNotesContext(root, rangeOrTag) {
23304
- const cwd = path27.resolve(repoRoot(root));
23349
+ const cwd = path28.resolve(repoRoot(root));
23305
23350
  if (!rangeOrTag) {
23306
23351
  return {
23307
23352
  stdout: "",
@@ -23344,7 +23389,7 @@ function releaseNotesContext(root, rangeOrTag) {
23344
23389
  `;
23345
23390
  stdout += printSection("Existing Release Files");
23346
23391
  for (const rel of ["CHANGELOG.md", "RELEASE_NOTES.md", ".github/releases.md"]) {
23347
- if (existsSync9(path27.join(cwd, rel)))
23392
+ if (existsSync10(path28.join(cwd, rel)))
23348
23393
  stdout += rel + `
23349
23394
  `;
23350
23395
  }
@@ -23376,7 +23421,7 @@ import { spawnSync as spawnSync19 } from "node:child_process";
23376
23421
 
23377
23422
  // packages/workit-core/src/core/pr-create.ts
23378
23423
  import fs19 from "node:fs";
23379
- import path28 from "node:path";
23424
+ import path29 from "node:path";
23380
23425
  import { spawnSync as spawnSync18 } from "node:child_process";
23381
23426
  // packages/workit-core/src/forge/pr-body.ts
23382
23427
  function parseGhIssue(value) {
@@ -23396,11 +23441,11 @@ var LOCAL = bounded(20000);
23396
23441
  var NETWORK = bounded(60000);
23397
23442
  function whichOnPath(tool) {
23398
23443
  const names = process.platform === "win32" ? [tool, `${tool}.exe`, `${tool}.cmd`] : [tool];
23399
- for (const dir of (process.env.PATH ?? "").split(path28.delimiter)) {
23444
+ for (const dir of (process.env.PATH ?? "").split(path29.delimiter)) {
23400
23445
  if (!dir)
23401
23446
  continue;
23402
23447
  for (const name of names) {
23403
- const candidate = path28.join(dir, name);
23448
+ const candidate = path29.join(dir, name);
23404
23449
  try {
23405
23450
  fs19.accessSync(candidate, fs19.constants.X_OK);
23406
23451
  return candidate;
@@ -23521,7 +23566,7 @@ var fetchGitLabIssueBody = async (ref, root, deps = {}) => {
23521
23566
 
23522
23567
  // packages/workit-core/src/core/youtrack.ts
23523
23568
  import fs21 from "node:fs";
23524
- import path30 from "node:path";
23569
+ import path31 from "node:path";
23525
23570
 
23526
23571
  // packages/workit-core/src/core/templates.ts
23527
23572
  var repoRoot2 = assetRoot();
@@ -23536,7 +23581,7 @@ import { spawnSync as spawnSync20 } from "node:child_process";
23536
23581
 
23537
23582
  // packages/workit-core/src/forge/exec.ts
23538
23583
  import fs20 from "node:fs";
23539
- import path29 from "node:path";
23584
+ import path30 from "node:path";
23540
23585
 
23541
23586
  // packages/workit-core/src/forge/redact.ts
23542
23587
  var KEY = String.raw`[A-Za-z0-9_.-]*?(?:token|secret|password|passwd|pwd|api[_-]?key|access[_-]?key|account[_-]?key|private[_-]?key|client[_-]?secret|credentials?|authorization|cookie|signature)[A-Za-z0-9_.-]*`;
@@ -23547,11 +23592,11 @@ var ANSI = new RegExp(String.raw`\u001b\[[0-9;?]*[ -/]*[@-~]|\u001b\][^\u0007]*\
23547
23592
  // packages/workit-core/src/forge/exec.ts
23548
23593
  var MAX_BUFFER2 = 64 * 1024 * 1024;
23549
23594
  function findExecutable(bin, env) {
23550
- const dirs = (env.PATH ?? env.Path ?? "").split(path29.delimiter).filter(Boolean);
23595
+ const dirs = (env.PATH ?? env.Path ?? "").split(path30.delimiter).filter(Boolean);
23551
23596
  const exts = process.platform === "win32" ? [".exe"] : [""];
23552
23597
  for (const dir of dirs)
23553
23598
  for (const ext of exts) {
23554
- const candidate = path29.join(dir, `${bin}${ext}`);
23599
+ const candidate = path30.join(dir, `${bin}${ext}`);
23555
23600
  try {
23556
23601
  const stat = fs20.statSync(candidate);
23557
23602
  if (stat.isFile())
@@ -23594,7 +23639,7 @@ var YTRACK_MISSING = "ytrack is not on PATH: Workit reaches YouTrack only throug
23594
23639
 
23595
23640
  // packages/workit-core/src/core/youtrack.ts
23596
23641
  var ISSUE_RE = /^[A-Z]+-\d+$/;
23597
- var youTrackReadOnlyConfigPath = () => process.env.WORKIT_YOUTRACK_CONFIG ?? path30.join(resolveConfigDir(), "youtrack.json");
23642
+ var youTrackReadOnlyConfigPath = () => process.env.WORKIT_YOUTRACK_CONFIG ?? path31.join(resolveConfigDir(), "youtrack.json");
23598
23643
  var readYouTrackContextConfig = () => {
23599
23644
  const cfgPath = youTrackReadOnlyConfigPath();
23600
23645
  if (!fs21.existsSync(cfgPath))
@@ -23961,22 +24006,22 @@ function resolveGitRevision(root, value) {
23961
24006
  }
23962
24007
  }
23963
24008
  function resolveInside(root, candidate) {
23964
- const base = realpathSync7(root);
23965
- const target = path31.resolve(base, candidate);
23966
- if (target !== base && !target.startsWith(base + path31.sep)) {
24009
+ const base = realpathSync8(root);
24010
+ const target = path32.resolve(base, candidate);
24011
+ if (target !== base && !target.startsWith(base + path32.sep)) {
23967
24012
  throw new Error("path must stay inside repository root");
23968
24013
  }
23969
24014
  let ancestor = target;
23970
- while (!existsSync10(ancestor))
23971
- ancestor = path31.dirname(ancestor);
23972
- const canonicalAncestor = realpathSync7(ancestor);
23973
- if (canonicalAncestor !== base && !canonicalAncestor.startsWith(base + path31.sep)) {
24015
+ while (!existsSync11(ancestor))
24016
+ ancestor = path32.dirname(ancestor);
24017
+ const canonicalAncestor = realpathSync8(ancestor);
24018
+ if (canonicalAncestor !== base && !canonicalAncestor.startsWith(base + path32.sep)) {
23974
24019
  throw new Error("path must stay inside repository root");
23975
24020
  }
23976
24021
  return target;
23977
24022
  }
23978
24023
  function run2(root, executable, args, env = {}) {
23979
- const cwd = realpathSync7(root);
24024
+ const cwd = realpathSync8(root);
23980
24025
  const result = spawnSync21(executable, args, {
23981
24026
  cwd,
23982
24027
  encoding: "utf8",
@@ -24016,7 +24061,7 @@ var capabilitiesFor = (descriptor, observed = {}) => descriptor.capabilities.map
24016
24061
  // packages/workit-core/src/hooks/context.ts
24017
24062
  import { createHash as createHash16 } from "node:crypto";
24018
24063
  import fs22 from "node:fs";
24019
- import path32 from "node:path";
24064
+ import path33 from "node:path";
24020
24065
  var MIGRATION_PENDING_NOTE = "workit migration pending — run `workit task status`";
24021
24066
  var migrationPending = (result) => !result.ok && result.code === "needs_input" && (result.error ?? "").startsWith(MIGRATION_PENDING);
24022
24067
  var boundTo = (entry, session) => entry.sessions.some((item) => item.host === session.host && item.handle === session.handle);
@@ -24104,7 +24149,7 @@ function entryCompactContext(store, entry, session, context) {
24104
24149
  current: () => recentSignal(store.root)
24105
24150
  };
24106
24151
  const observed = task?.data.evidence.some(isObservedCheck) ?? false;
24107
- const files = (task?.data.decisions ?? []).flatMap((decision) => decision.data.binding.contentRefs.flatMap((ref) => ref.kind === "file" ? [path32.resolve(store.root, ref.path)] : []));
24152
+ const files = (task?.data.decisions ?? []).flatMap((decision) => decision.data.binding.contentRefs.flatMap((ref) => ref.kind === "file" ? [path33.resolve(store.root, ref.path)] : []));
24108
24153
  const observedFiles = filesKey(files);
24109
24154
  const compact = compactContext(store, context, entry?.id ?? null, freshness, origin && { origin: origin.origin, taskId: origin.entry.id });
24110
24155
  if (!compact.ok || !compact.data)
@@ -24163,17 +24208,17 @@ ${options.addendum}` : ""}
24163
24208
  </workit-contract>`;
24164
24209
  };
24165
24210
  var checkoutAt = (cwd) => {
24166
- for (let dir = path32.resolve(cwd);; dir = path32.dirname(dir)) {
24167
- const dotGit = path32.join(dir, ".git");
24211
+ for (let dir = path33.resolve(cwd);; dir = path33.dirname(dir)) {
24212
+ const dotGit = path33.join(dir, ".git");
24168
24213
  if (fs22.existsSync(dotGit)) {
24169
- const admin = fs22.statSync(dotGit).isFile() ? path32.resolve(dir, /^gitdir:\s*(.+)$/mu.exec(fs22.readFileSync(dotGit, "utf8"))?.[1]?.trim() ?? "") : dotGit;
24170
- const head = fs22.readFileSync(path32.join(admin, "HEAD"), "utf8").trim();
24214
+ const admin = fs22.statSync(dotGit).isFile() ? path33.resolve(dir, /^gitdir:\s*(.+)$/mu.exec(fs22.readFileSync(dotGit, "utf8"))?.[1]?.trim() ?? "") : dotGit;
24215
+ const head = fs22.readFileSync(path33.join(admin, "HEAD"), "utf8").trim();
24171
24216
  return {
24172
24217
  root: dir,
24173
24218
  branch: /^ref: refs\/heads\/(.+)$/u.exec(head)?.[1] ?? null
24174
24219
  };
24175
24220
  }
24176
- if (path32.dirname(dir) === dir)
24221
+ if (path33.dirname(dir) === dir)
24177
24222
  return null;
24178
24223
  }
24179
24224
  };
@@ -24184,7 +24229,7 @@ var whereLine = (cwd) => {
24184
24229
  return null;
24185
24230
  const allowed = branchPolicySnapshotFor(cwd).namePolicy.allowed;
24186
24231
  const kinds = allowed.some((pattern) => pattern.source === "^.*$") ? "any" : allowedKinds(allowed).join(", ") || "see `workit help git`";
24187
- const place = checkout.root === path32.resolve(cwd) ? "" : ` in ${checkout.root}`;
24232
+ const place = checkout.root === path33.resolve(cwd) ? "" : ` in ${checkout.root}`;
24188
24233
  return `cwd ${cwd}${place} on ${checkout.branch ?? "detached HEAD"}; branch kinds: ${kinds}`;
24189
24234
  } catch {
24190
24235
  return null;
@@ -24211,14 +24256,14 @@ var turnMarker = (input) => {
24211
24256
  if (location instanceof Error)
24212
24257
  return null;
24213
24258
  const session = [input.host, input.session.id, input.session.agentId ?? ""].join("\x00");
24214
- return path32.join(location.dir, "hooks", `turn-${digestOf(session).slice(0, 32)}.json`);
24259
+ return path33.join(location.dir, "hooks", `turn-${digestOf(session).slice(0, 32)}.json`);
24215
24260
  } catch {
24216
24261
  return null;
24217
24262
  }
24218
24263
  };
24219
24264
  var writeTurnDigest = (file, digest) => {
24220
24265
  try {
24221
- fs22.mkdirSync(path32.dirname(file), { recursive: true });
24266
+ fs22.mkdirSync(path33.dirname(file), { recursive: true });
24222
24267
  fs22.writeFileSync(file, `${JSON.stringify({ digest })}
24223
24268
  `);
24224
24269
  } catch {}
@@ -24233,7 +24278,7 @@ var pruneTurnDigests = (dir, now) => {
24233
24278
  for (const name of fs22.readdirSync(dir)) {
24234
24279
  if (!name.startsWith("turn-"))
24235
24280
  continue;
24236
- const file = path32.join(dir, name);
24281
+ const file = path33.join(dir, name);
24237
24282
  try {
24238
24283
  if (now - fs22.statSync(file).mtimeMs > TURN_TTL_MS)
24239
24284
  fs22.rmSync(file, { force: true });
@@ -24263,7 +24308,7 @@ var seedTurnContext = (input, descriptor, text = turnContextText(input, descript
24263
24308
  const file = turnMarker(input);
24264
24309
  if (!file)
24265
24310
  return;
24266
- pruneTurnDigests(path32.dirname(file), Date.now());
24311
+ pruneTurnDigests(path33.dirname(file), Date.now());
24267
24312
  if (text)
24268
24313
  writeTurnDigest(file, digestOf(text));
24269
24314
  else
@@ -24368,8 +24413,8 @@ var userOnlyWorkitCall = (command, dialect = "posix") => {
24368
24413
  };
24369
24414
  // packages/workit-core/src/core/heavy-rules.ts
24370
24415
  import fs23 from "node:fs";
24371
- import os7 from "node:os";
24372
- import path33 from "node:path";
24416
+ import os8 from "node:os";
24417
+ import path34 from "node:path";
24373
24418
  var EMPTY2 = () => ({ deny: [], allow: [] });
24374
24419
  var readText3 = (file) => {
24375
24420
  try {
@@ -24410,23 +24455,23 @@ function parseJsonc(text) {
24410
24455
  return JSON.parse(out.replace(/,(\s*[}\]])/gu, "$1"));
24411
24456
  }
24412
24457
  function gitTop(cwd) {
24413
- for (let dir = path33.resolve(cwd);; dir = path33.dirname(dir)) {
24414
- if (fs23.existsSync(path33.join(dir, ".git")))
24458
+ for (let dir = path34.resolve(cwd);; dir = path34.dirname(dir)) {
24459
+ if (fs23.existsSync(path34.join(dir, ".git")))
24415
24460
  return dir;
24416
- if (path33.dirname(dir) === dir)
24461
+ if (path34.dirname(dir) === dir)
24417
24462
  return null;
24418
24463
  }
24419
24464
  }
24420
24465
  var projectDirs = (cwd) => {
24421
24466
  const top = gitTop(cwd);
24422
24467
  const dirs = [];
24423
- for (let dir = path33.resolve(cwd);; dir = path33.dirname(dir)) {
24468
+ for (let dir = path34.resolve(cwd);; dir = path34.dirname(dir)) {
24424
24469
  dirs.push(dir);
24425
- if (!top || dir === top || path33.dirname(dir) === dir)
24470
+ if (!top || dir === top || path34.dirname(dir) === dir)
24426
24471
  return dirs;
24427
24472
  }
24428
24473
  };
24429
- var homeOf = (env) => env.HOME || os7.homedir();
24474
+ var homeOf = (env) => env.HOME || os8.homedir();
24430
24475
  var CLAUDE_MANAGED = {
24431
24476
  linux: "/etc/claude-code/managed-settings.json",
24432
24477
  darwin: "/Library/Application Support/ClaudeCode/managed-settings.json",
@@ -24434,12 +24479,12 @@ var CLAUDE_MANAGED = {
24434
24479
  };
24435
24480
  function claudeSettingsFiles(cwd, env, platform = process.platform) {
24436
24481
  const project = env.CLAUDE_PROJECT_DIR || gitTop(cwd) || cwd;
24437
- const user = env.CLAUDE_CONFIG_DIR || path33.join(homeOf(env), ".claude");
24482
+ const user = env.CLAUDE_CONFIG_DIR || path34.join(homeOf(env), ".claude");
24438
24483
  return [
24439
24484
  ...CLAUDE_MANAGED[platform] ? [CLAUDE_MANAGED[platform]] : [],
24440
- path33.join(user, "settings.json"),
24441
- path33.join(project, ".claude", "settings.json"),
24442
- path33.join(project, ".claude", "settings.local.json")
24485
+ path34.join(user, "settings.json"),
24486
+ path34.join(project, ".claude", "settings.json"),
24487
+ path34.join(project, ".claude", "settings.local.json")
24443
24488
  ];
24444
24489
  }
24445
24490
  var bashPattern = (entry) => {
@@ -24529,10 +24574,10 @@ var opencodeConfig = (value, rules) => {
24529
24574
  function opencodeRules(cwd, env = process.env) {
24530
24575
  const rules = EMPTY2();
24531
24576
  try {
24532
- const config = env.XDG_CONFIG_HOME || path33.join(homeOf(env), ".config");
24577
+ const config = env.XDG_CONFIG_HOME || path34.join(homeOf(env), ".config");
24533
24578
  const files = [
24534
- ...OPENCODE_NAMES.map((name) => path33.join(config, "opencode", name)),
24535
- ...projectDirs(cwd).flatMap((dir) => OPENCODE_NAMES.flatMap((name) => [path33.join(dir, name), path33.join(dir, ".opencode", name)])),
24579
+ ...OPENCODE_NAMES.map((name) => path34.join(config, "opencode", name)),
24580
+ ...projectDirs(cwd).flatMap((dir) => OPENCODE_NAMES.flatMap((name) => [path34.join(dir, name), path34.join(dir, ".opencode", name)])),
24536
24581
  ...env.OPENCODE_CONFIG ? [env.OPENCODE_CONFIG] : []
24537
24582
  ];
24538
24583
  for (const file of files) {
@@ -24576,9 +24621,9 @@ var codexRule = (body) => {
24576
24621
  function codexRules(cwd, env = process.env) {
24577
24622
  const rules = EMPTY2();
24578
24623
  try {
24579
- const home = env.CODEX_HOME || path33.join(homeOf(env), ".codex");
24624
+ const home = env.CODEX_HOME || path34.join(homeOf(env), ".codex");
24580
24625
  const top = gitTop(cwd) ?? cwd;
24581
- for (const dir of [path33.join(home, "rules"), path33.join(top, ".codex", "rules")]) {
24626
+ for (const dir of [path34.join(home, "rules"), path34.join(top, ".codex", "rules")]) {
24582
24627
  let files;
24583
24628
  try {
24584
24629
  files = fs23.readdirSync(dir).filter((name) => name.endsWith(".rules"));
@@ -24588,7 +24633,7 @@ function codexRules(cwd, env = process.env) {
24588
24633
  return "unreadable";
24589
24634
  }
24590
24635
  for (const name of files) {
24591
- const text = readText3(path33.join(dir, name)) ?? "";
24636
+ const text = readText3(path34.join(dir, name)) ?? "";
24592
24637
  for (const part of text.split(/\bprefix_rule\s*\(/u).slice(1)) {
24593
24638
  const rule = codexRule(part);
24594
24639
  if (!rule)
@@ -24607,8 +24652,8 @@ function cursorRules(cwd, env = process.env) {
24607
24652
  try {
24608
24653
  const top = gitTop(cwd) ?? cwd;
24609
24654
  for (const file of [
24610
- path33.join(homeOf(env), ".cursor", "cli-config.json"),
24611
- path33.join(top, ".cursor", "cli.json")
24655
+ path34.join(homeOf(env), ".cursor", "cli-config.json"),
24656
+ path34.join(top, ".cursor", "cli.json")
24612
24657
  ]) {
24613
24658
  const text = readText3(file);
24614
24659
  if (text === null)
@@ -24683,10 +24728,10 @@ function wrapAllowed(read, words, command, options = {}) {
24683
24728
 
24684
24729
  // packages/workit-core/src/core/heavy.ts
24685
24730
  import fs24 from "node:fs";
24686
- import path34 from "node:path";
24731
+ import path35 from "node:path";
24687
24732
  var stateDir2 = (env, platform = process.platform) => stateDir(env, platform);
24688
24733
  var HEAVY_COMMANDS_FILE = "heavy-commands.json";
24689
- var heavyCommandsFile = (env) => path34.join(stateDir2(env), HEAVY_COMMANDS_FILE);
24734
+ var heavyCommandsFile = (env) => path35.join(stateDir2(env), HEAVY_COMMANDS_FILE);
24690
24735
  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;
24691
24736
  var INFO_FLAGS = new Set(["--version", "-v", "-V", "--help", "-h", "help", "version"]);
24692
24737
  var WATCH_FLAG = /^(?:--watch(?:All)?(?:=.*)?|-w|--serve)$/u;
@@ -24961,7 +25006,7 @@ function machinePatterns(env) {
24961
25006
  return isRecord5(value) ? stringList(value.patterns) : [];
24962
25007
  }
24963
25008
  function repoPatterns(cwd) {
24964
- return repoHeavyCommands(gitTop(cwd) ?? path34.resolve(cwd));
25009
+ return repoHeavyCommands(gitTop(cwd) ?? path35.resolve(cwd));
24965
25010
  }
24966
25011
  function heavyLines(lines, options) {
24967
25012
  const found = [];
@@ -25039,12 +25084,12 @@ function heavyPlan(command, options) {
25039
25084
  }
25040
25085
  function workitOnPath2(env = process.env) {
25041
25086
  const names = process.platform === "win32" ? ["workit.exe", "workit.cmd", "workit"] : ["workit"];
25042
- for (const dir of (env.PATH ?? "").split(path34.delimiter))
25087
+ for (const dir of (env.PATH ?? "").split(path35.delimiter))
25043
25088
  for (const name of names) {
25044
25089
  if (!dir)
25045
25090
  continue;
25046
25091
  try {
25047
- fs24.accessSync(path34.join(dir, name), fs24.constants.X_OK);
25092
+ fs24.accessSync(path35.join(dir, name), fs24.constants.X_OK);
25048
25093
  return true;
25049
25094
  } catch {}
25050
25095
  }
@@ -25062,7 +25107,7 @@ function leaseRewrite(command) {
25062
25107
 
25063
25108
  // packages/workit-core/src/core/heavy-words.ts
25064
25109
  import fs25 from "node:fs";
25065
- import path35 from "node:path";
25110
+ import path36 from "node:path";
25066
25111
  var HEAVY_WORDS = new Set(("npm npx pnpm pnpx yarn bun bunx deno corepack make gmake docker podman nerdctl " + "python python3 py uv poetry pdm pipenv hatch rye bundle rake nx " + "jest vitest mocha ava tap karma jasmine nyc c8 tsc vue-tsc svelte-check eslint stylelint " + "tslint webpack webpack-cli rollup parcel tsup vite next nuxt nuxi astro ng react-scripts " + "playwright cypress wdio testcafe turbo lerna sonar-scanner sonarless sonarless-mcp go " + "golangci-lint gotestsum staticcheck cargo mvn mvnw gradle gradlew ant sbt bazel bazelisk " + "buck2 dotnet msbuild pytest py.test tox nox mypy pyright pylint coverage maturin pip pip3 " + "rspec rails phpunit pest phpstan psalm composer mix swift xcodebuild flutter dart pod cmake " + "ninja meson ctest scons docker-compose buildah earthly").split(" "));
25067
25112
  var wordsOf = (command) => command.split(/[\s;&|()<>`'"]+/u).map((word) => (word.split(/[\\/]/u).at(-1) ?? "").toLowerCase().replace(/\.(?:exe|cmd|bat)$/u, "")).filter(Boolean);
25068
25113
  var stateDir3 = (env) => stateDir(env);
@@ -25075,15 +25120,15 @@ var readJson2 = (file) => {
25075
25120
  };
25076
25121
  var patternWords = (cwd, env) => {
25077
25122
  const patterns = [];
25078
- const machine = readJson2(path35.join(stateDir3(env), "heavy-commands.json"));
25123
+ const machine = readJson2(path36.join(stateDir3(env), "heavy-commands.json"));
25079
25124
  if (Array.isArray(machine?.patterns))
25080
25125
  patterns.push(...machine.patterns);
25081
- for (let dir = path35.resolve(cwd);; dir = path35.dirname(dir)) {
25082
- if (fs25.existsSync(path35.join(dir, ".git"))) {
25126
+ for (let dir = path36.resolve(cwd);; dir = path36.dirname(dir)) {
25127
+ if (fs25.existsSync(path36.join(dir, ".git"))) {
25083
25128
  patterns.push(...repoHeavyCommands(dir));
25084
25129
  break;
25085
25130
  }
25086
- if (path35.dirname(dir) === dir)
25131
+ if (path36.dirname(dir) === dir)
25087
25132
  break;
25088
25133
  }
25089
25134
  const words = new Set;
@@ -25157,16 +25202,16 @@ var splitDenial = (plan) => ({
25157
25202
  unblock: plan.unblock
25158
25203
  });
25159
25204
  // packages/workit-core/src/hooks/write-gate.ts
25160
- import { existsSync as existsSync11, realpathSync as realpathSync8, statSync as statSync3 } from "node:fs";
25161
- import os9 from "node:os";
25162
- import path37 from "node:path";
25205
+ import { existsSync as existsSync12, realpathSync as realpathSync9, statSync as statSync3 } from "node:fs";
25206
+ import os10 from "node:os";
25207
+ import path38 from "node:path";
25163
25208
 
25164
25209
  // packages/workit-core/src/core/live-session.ts
25165
25210
  import { spawnSync as spawnSync22 } from "node:child_process";
25166
25211
  import { createHash as createHash17 } from "node:crypto";
25167
25212
  import fs26 from "node:fs";
25168
- import os8 from "node:os";
25169
- import path36 from "node:path";
25213
+ import os9 from "node:os";
25214
+ import path37 from "node:path";
25170
25215
  var LIVE_SESSION_TTL_MS = 15 * 60000;
25171
25216
  var HEARTBEAT_EVERY_MS = 30000;
25172
25217
  var liveProbe = {
@@ -25240,15 +25285,15 @@ var liveOwner = (input, transport, env = process.env) => {
25240
25285
  };
25241
25286
  };
25242
25287
  var checkoutOf = (target) => {
25243
- let dir = path36.resolve(target);
25244
- while (!fs26.existsSync(dir) && path36.dirname(dir) !== dir)
25245
- dir = path36.dirname(dir);
25288
+ let dir = path37.resolve(target);
25289
+ while (!fs26.existsSync(dir) && path37.dirname(dir) !== dir)
25290
+ dir = path37.dirname(dir);
25246
25291
  if (fs26.existsSync(dir) && !fs26.statSync(dir).isDirectory())
25247
- dir = path36.dirname(dir);
25248
- const parts = dir.split(path36.sep);
25292
+ dir = path37.dirname(dir);
25293
+ const parts = dir.split(path37.sep);
25249
25294
  const dotGit = parts.lastIndexOf(".git");
25250
25295
  if (dotGit > 0)
25251
- dir = parts.slice(0, dotGit).join(path36.sep) || path36.sep;
25296
+ dir = parts.slice(0, dotGit).join(path37.sep) || path37.sep;
25252
25297
  const location = resolveStore(dir);
25253
25298
  if (location instanceof Error || !location.shared || !location.top)
25254
25299
  return null;
@@ -25258,9 +25303,9 @@ var checkoutOf = (target) => {
25258
25303
  } catch {}
25259
25304
  return top;
25260
25305
  };
25261
- var markerFile2 = (top) => path36.join(resolveStateDir(), "live-sessions", `${createHash17("sha256").update(checkoutKey(top)).digest("hex").slice(0, 32)}.json`);
25306
+ var markerFile2 = (top) => path37.join(resolveStateDir(), "live-sessions", `${createHash17("sha256").update(checkoutKey(top)).digest("hex").slice(0, 32)}.json`);
25262
25307
  var checkoutKey = (top, platform = process.platform) => {
25263
- let key = path36.resolve(top);
25308
+ let key = path37.resolve(top);
25264
25309
  try {
25265
25310
  key = fs26.realpathSync.native(key);
25266
25311
  } catch {}
@@ -25291,7 +25336,7 @@ var isLive = (marker, deps) => {
25291
25336
  const age = ageOf2(marker, deps.now ?? new Date);
25292
25337
  if (age > (deps.ttlMs ?? LIVE_SESSION_TTL_MS))
25293
25338
  return false;
25294
- if (marker.machine !== (deps.machine ?? os8.hostname()) || marker.pid === null)
25339
+ if (marker.machine !== (deps.machine ?? os9.hostname()) || marker.pid === null)
25295
25340
  return true;
25296
25341
  if (!(deps.alive ?? processAlive)(marker.pid))
25297
25342
  return false;
@@ -25320,7 +25365,7 @@ var liveConflict = (target, owner, deps = {}) => {
25320
25365
  const marker = readMarker(file);
25321
25366
  if (!marker || sameLead(marker, owner) || !isLive(marker, deps))
25322
25367
  return null;
25323
- if (sameOwner(marker, owner, deps.machine ?? os8.hostname()))
25368
+ if (sameOwner(marker, owner, deps.machine ?? os9.hostname()))
25324
25369
  return null;
25325
25370
  return { marker, file, ageMs: ageOf2(marker, deps.now ?? new Date), checkout };
25326
25371
  } catch {
@@ -25334,7 +25379,7 @@ var claimLiveSession = (target, owner, deps = {}) => {
25334
25379
  return;
25335
25380
  const file = markerFile2(checkout);
25336
25381
  const now = deps.now ?? new Date;
25337
- const machine = deps.machine ?? os8.hostname();
25382
+ const machine = deps.machine ?? os9.hostname();
25338
25383
  const current = readMarker(file);
25339
25384
  if (current) {
25340
25385
  const age = ageOf2(current, now);
@@ -25355,7 +25400,7 @@ var claimLiveSession = (target, owner, deps = {}) => {
25355
25400
  checkout,
25356
25401
  heartbeatAt: now.toISOString()
25357
25402
  };
25358
- fs26.mkdirSync(path36.dirname(file), { recursive: true });
25403
+ fs26.mkdirSync(path37.dirname(file), { recursive: true });
25359
25404
  const temp = `${file}.${process.pid}.tmp`;
25360
25405
  fs26.writeFileSync(temp, JSON.stringify(marker));
25361
25406
  fs26.renameSync(temp, file);
@@ -25367,22 +25412,22 @@ var NONE3 = { kind: "none" };
25367
25412
  var CASE_INSENSITIVE = process.platform === "darwin" || process.platform === "win32";
25368
25413
  var canonical3 = (file) => {
25369
25414
  let rest = "";
25370
- for (let dir = path37.resolve(file);; dir = path37.dirname(dir)) {
25415
+ for (let dir = path38.resolve(file);; dir = path38.dirname(dir)) {
25371
25416
  try {
25372
- return path37.join(realpathSync8.native(dir), rest);
25417
+ return path38.join(realpathSync9.native(dir), rest);
25373
25418
  } catch {
25374
- if (path37.dirname(dir) === dir)
25375
- return path37.resolve(file);
25376
- rest = rest ? path37.join(path37.basename(dir), rest) : path37.basename(dir);
25419
+ if (path38.dirname(dir) === dir)
25420
+ return path38.resolve(file);
25421
+ rest = rest ? path38.join(path38.basename(dir), rest) : path38.basename(dir);
25377
25422
  }
25378
25423
  }
25379
25424
  };
25380
25425
  var exempt = (cwd, root, file, plans) => {
25381
25426
  const fold = (value) => CASE_INSENSITIVE ? value.toLowerCase() : value;
25382
- const relative = path37.relative(fold(canonical3(root)), fold(canonical3(path37.resolve(cwd, file))));
25383
- if (relative.startsWith("..") || path37.isAbsolute(relative))
25427
+ const relative = path38.relative(fold(canonical3(root)), fold(canonical3(path38.resolve(cwd, file))));
25428
+ if (relative.startsWith("..") || path38.isAbsolute(relative))
25384
25429
  return true;
25385
- const posix = relative.split(path37.sep).join("/");
25430
+ const posix = relative.split(path38.sep).join("/");
25386
25431
  const segments = posix.split("/");
25387
25432
  return /\.mdx?$/i.test(posix) || segments[0] === "docs" || segments.includes("plans") || [...plans].some((plan) => fold(plan) === posix);
25388
25433
  };
@@ -25733,10 +25778,10 @@ var linkSources = (args, at) => {
25733
25778
  const sources = names.filter((name, index) => into >= 0 ? name !== dest : index < names.length - 1 || names.length === 1);
25734
25779
  const target = dest === undefined ? null : at(dest);
25735
25780
  const symbolic = args.some((arg) => /^-[a-zA-Z]*s|^--symbolic$/.test(arg));
25736
- const base = target === null ? null : into >= 0 || sources.length > 1 || existsSync11(target) || /[\\/]$/.test(dest ?? "") ? target : path37.dirname(target);
25781
+ const base = target === null ? null : into >= 0 || sources.length > 1 || existsSync12(target) || /[\\/]$/.test(dest ?? "") ? target : path38.dirname(target);
25737
25782
  return sources.flatMap((source) => {
25738
- if (symbolic && base !== null && !path37.isAbsolute(homeExpanded(source)))
25739
- return [path37.resolve(base, source)];
25783
+ if (symbolic && base !== null && !path38.isAbsolute(homeExpanded(source)))
25784
+ return [path38.resolve(base, source)];
25740
25785
  const resolved = at(source);
25741
25786
  return resolved ? [resolved] : [];
25742
25787
  });
@@ -25765,7 +25810,7 @@ var shellWrites = (command, depth = 0) => {
25765
25810
  return { writes: true, targets: unknown ? null : targets };
25766
25811
  };
25767
25812
  var cache3 = new Map;
25768
- var planKeyOf = (root, plans) => [...plans].map((file) => fileSignature(path37.resolve(root, file)) ?? "-").join("\x00");
25813
+ var planKeyOf = (root, plans) => [...plans].map((file) => fileSignature(path38.resolve(root, file)) ?? "-").join("\x00");
25769
25814
  var gateFor = (cwd) => {
25770
25815
  const store = new TaskStore(cwd);
25771
25816
  const listed = store.listTaskIndex();
@@ -25845,13 +25890,13 @@ var gitMutationDirs = (cwd, command, dialect) => {
25845
25890
  return [];
25846
25891
  if (sub === "stash" && ["list", "show"].includes(rest[0] ?? ""))
25847
25892
  return [];
25848
- return [path37.resolve(cwd, invocation.dir ?? ".")];
25893
+ return [path38.resolve(cwd, invocation.dir ?? ".")];
25849
25894
  });
25850
25895
  };
25851
25896
  var CD2 = new Set(["cd", "chdir", "set-location", "sl"]);
25852
25897
  var PUSHD2 = new Set(["pushd", "push-location"]);
25853
25898
  var POPD2 = new Set(["popd", "pop-location"]);
25854
- var UNKNOWN_DIR = path37.resolve(path37.parse(process.cwd()).root, ".workit-unknown-dir");
25899
+ var UNKNOWN_DIR = path38.resolve(path38.parse(process.cwd()).root, ".workit-unknown-dir");
25855
25900
  var cdInto = (dir, words, strict = false, vars = new Map) => {
25856
25901
  const lost = strict ? UNKNOWN_DIR : undefined;
25857
25902
  const found = words.slice(1).find((word) => !word.startsWith("-") || word === "-");
@@ -25861,7 +25906,7 @@ var cdInto = (dir, words, strict = false, vars = new Map) => {
25861
25906
  return lost;
25862
25907
  if (dir === undefined)
25863
25908
  return lost;
25864
- return target === undefined ? os9.homedir() : path37.resolve(dir, target);
25909
+ return target === undefined ? os10.homedir() : path38.resolve(dir, target);
25865
25910
  };
25866
25911
  var quoteWord2 = (word) => /^[\w@%+=:,./-]+$/.test(word) ? word : `'${word.replaceAll("'", "'\\''")}'`;
25867
25912
  var expandVars = (text, vars) => vars.size === 0 || !text.includes("$") ? text : text.replace(/\$(?:(\w+)|\{(\w+)\})/g, (whole, bare, braced) => {
@@ -25995,7 +26040,7 @@ var untrustedVars = (segments) => {
25995
26040
  }
25996
26041
  return { all, names };
25997
26042
  };
25998
- var UNKNOWN_VAR = path37.resolve(path37.parse(process.cwd()).root, ".workit-unknown-var");
26043
+ var UNKNOWN_VAR = path38.resolve(path38.parse(process.cwd()).root, ".workit-unknown-var");
25999
26044
  var REFERENCE = /\$\{(\w+)[^}]*\}|\$(\w+)|\$\([^)]*\)?|`[^`]*`?/g;
26000
26045
  var unresolvedRefs = (text) => [
26001
26046
  ...new Set([...text.matchAll(REFERENCE)].map((match) => {
@@ -26005,7 +26050,7 @@ var unresolvedRefs = (text) => [
26005
26050
  ];
26006
26051
  var unknownVarTarget = (text) => {
26007
26052
  const refs = unresolvedRefs(text);
26008
- return path37.join(UNKNOWN_VAR, (refs.length > 0 ? refs : [text]).map(encodeURIComponent).join("+"));
26053
+ return path38.join(UNKNOWN_VAR, (refs.length > 0 ? refs : [text]).map(encodeURIComponent).join("+"));
26009
26054
  };
26010
26055
  var applyOperator = (value, operator) => {
26011
26056
  if (operator === "")
@@ -26063,18 +26108,18 @@ var mktempPath = (value, dir) => {
26063
26108
  template = arg;
26064
26109
  }
26065
26110
  if (base === null && (temp || template === undefined))
26066
- base = os9.tmpdir();
26111
+ base = os10.tmpdir();
26067
26112
  const name = homeExpanded(template ?? "tmp.XXXXXXXXXX");
26068
- if (path37.isAbsolute(name))
26113
+ if (path38.isAbsolute(name))
26069
26114
  return name;
26070
26115
  const from = base === null ? dir : homeExpanded(base);
26071
- if (from === undefined || !path37.isAbsolute(from) && dir === undefined)
26116
+ if (from === undefined || !path38.isAbsolute(from) && dir === undefined)
26072
26117
  return null;
26073
- return path37.resolve(dir ?? from, from, name);
26118
+ return path38.resolve(dir ?? from, from, name);
26074
26119
  };
26075
26120
  var homeExpanded = (file) => {
26076
26121
  const match = /^(?:~|\$HOME|\$\{HOME\})(?=\/|$)/.exec(file);
26077
- return match ? (process.env.HOME || os9.homedir()) + file.slice(match[0].length) : file;
26122
+ return match ? (process.env.HOME || os10.homedir()) + file.slice(match[0].length) : file;
26078
26123
  };
26079
26124
  var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherited = new Map) => {
26080
26125
  const targets = [];
@@ -26090,9 +26135,9 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
26090
26135
  const home = homeExpanded(text);
26091
26136
  if (strict && unresolvedRefs(home).length > 0)
26092
26137
  return [unknownVarTarget(home)];
26093
- if (path37.isAbsolute(home))
26138
+ if (path38.isAbsolute(home))
26094
26139
  return [home];
26095
- return base === undefined ? [] : [path37.resolve(base, home)];
26140
+ return base === undefined ? [] : [path38.resolve(base, home)];
26096
26141
  });
26097
26142
  const at = (file) => {
26098
26143
  const all = atAll(file);
@@ -26234,7 +26279,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
26234
26279
  const here = segment.unanalyzable ? DIR_TARGET : `${OPAQUE_TARGET}${encodeURIComponent(runner?.split(/[\\/]/).at(-1) ?? "a command")}`;
26235
26280
  for (const file of opaque ?? [])
26236
26281
  for (const resolved of atAll(file))
26237
- targets.push(file === "." ? path37.join(resolved, here) : resolved);
26282
+ targets.push(file === "." ? path38.join(resolved, here) : resolved);
26238
26283
  const ln = words.findIndex((word) => /^ln$/i.test(word.split(/[\\/]/).at(-1) ?? ""));
26239
26284
  if (ln >= 0 && words.slice(0, ln).every((word) => PREFIXES2.has(word)))
26240
26285
  targets.push(...linkSources(words.slice(ln + 1), at));
@@ -26245,7 +26290,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
26245
26290
  const edits = editsOf(body);
26246
26291
  if (edits === null) {
26247
26292
  if (dir !== undefined)
26248
- targets.push(path37.join(dir, DIR_TARGET));
26293
+ targets.push(path38.join(dir, DIR_TARGET));
26249
26294
  } else
26250
26295
  for (const file of edits)
26251
26296
  targets.push(...atAll(file));
@@ -26253,7 +26298,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
26253
26298
  for (const invocation of workitInvocations(body.map(quoteWord2).join(" "), "posix")) {
26254
26299
  const { at: runsIn, args } = workitCwd(dir, invocation, atAll);
26255
26300
  if (args[0] === "git" && MUTATING_WORKIT_GIT.has(args[1] ?? "") && !inert(args.slice(2), ""))
26256
- targets.push(...runsIn.map((runs) => path37.join(runs, DIR_TARGET)));
26301
+ targets.push(...runsIn.map((runs) => path38.join(runs, DIR_TARGET)));
26257
26302
  }
26258
26303
  }
26259
26304
  return targets;
@@ -26274,7 +26319,7 @@ var shellMutationTargets = (cwd, command, dialect = "posix", strict = false) =>
26274
26319
  try {
26275
26320
  return [
26276
26321
  ...segmentTargets(cwd, command, dialect, 0, strict),
26277
- ...gitMutationDirs(cwd, command, dialect).map((dir) => path37.join(dir, DIR_TARGET))
26322
+ ...gitMutationDirs(cwd, command, dialect).map((dir) => path38.join(dir, DIR_TARGET))
26278
26323
  ];
26279
26324
  } catch {
26280
26325
  return [];
@@ -26311,7 +26356,7 @@ var liveDeny = ({ marker, checkout, ageMs, file }) => {
26311
26356
  var guarded = (targets) => {
26312
26357
  const seen = new Set;
26313
26358
  return targets.filter((target) => {
26314
- const dir = path37.dirname(target);
26359
+ const dir = path38.dirname(target);
26315
26360
  if (seen.has(dir))
26316
26361
  return false;
26317
26362
  seen.add(dir);
@@ -26332,7 +26377,7 @@ var claimAll = (owner, targets, deps) => {
26332
26377
  for (const target of guarded(targets))
26333
26378
  claimLiveSession(target, owner, deps);
26334
26379
  };
26335
- var liveTargets = (cwd, paths) => paths?.length ? paths.map((file) => path37.resolve(cwd, file)) : [path37.join(cwd, DIR_TARGET)];
26380
+ var liveTargets = (cwd, paths) => paths?.length ? paths.map((file) => path38.resolve(cwd, file)) : [path38.join(cwd, DIR_TARGET)];
26336
26381
  var issuedTarget = (cwd, targets) => {
26337
26382
  const state = resolveStateDir();
26338
26383
  const found = targets.find((target) => underIssued(state, cwd, homeExpanded(target), process.platform, canonical3));
@@ -26340,7 +26385,7 @@ var issuedTarget = (cwd, targets) => {
26340
26385
  };
26341
26386
  var underIssued = (state, cwd, target, platform = process.platform, real = (file) => file) => {
26342
26387
  const win = platform === "win32";
26343
- const p = win ? path37.win32 : path37.posix;
26388
+ const p = win ? path38.win32 : path38.posix;
26344
26389
  const fold = (value) => win || platform === "darwin" ? value.toLowerCase() : value;
26345
26390
  const named = win ? target.replace(/^\/([a-zA-Z])(?=\/|$)/, "$1:") : target;
26346
26391
  const relative = p.relative(fold(real(p.resolve(state))), fold(real(p.resolve(cwd, named))));
@@ -26434,10 +26479,10 @@ import { spawnSync as spawnSync23 } from "node:child_process";
26434
26479
 
26435
26480
  // packages/workit-core/src/ci-waiter.ts
26436
26481
  import fs27 from "node:fs";
26437
- import path38 from "node:path";
26482
+ import path39 from "node:path";
26438
26483
  var waiterFile = (cwd, pr) => {
26439
26484
  const common = gitCommonDir(cwd);
26440
- return common ? path38.join(common, "workit", "ci-waits", `pr-${pr}.json`) : null;
26485
+ return common ? path39.join(common, "workit", "ci-waits", `pr-${pr}.json`) : null;
26441
26486
  };
26442
26487
  var pidAlive2 = (pid) => {
26443
26488
  if (!Number.isSafeInteger(pid) || pid <= 0)
@@ -26988,7 +27033,7 @@ var writePaths = (input) => {
26988
27033
  };
26989
27034
  // packages/workit-core/src/hooks/standing.ts
26990
27035
  import fs29 from "node:fs";
26991
- import path40 from "node:path";
27036
+ import path41 from "node:path";
26992
27037
 
26993
27038
  // packages/workit-core/src/hooks/hosts/claude-code.ts
26994
27039
  var CLAUDE_CODE_DESCRIPTOR = {
@@ -27460,40 +27505,40 @@ function neededChecks(lane, configured) {
27460
27505
  // packages/workit-core/src/hooks/worktree-confine.ts
27461
27506
  import { createHash as createHash18 } from "node:crypto";
27462
27507
  import fs28 from "node:fs";
27463
- import path39 from "node:path";
27508
+ import path40 from "node:path";
27464
27509
  var FANOUT_TOKEN_FILE = "workit-fanout-token";
27465
27510
  var NONE5 = { kind: "none" };
27466
27511
  var CASE_INSENSITIVE2 = process.platform === "darwin" || process.platform === "win32";
27467
27512
  var canonical4 = (file) => {
27468
27513
  let rest = "";
27469
- for (let dir = path39.resolve(file);; dir = path39.dirname(dir)) {
27514
+ for (let dir = path40.resolve(file);; dir = path40.dirname(dir)) {
27470
27515
  try {
27471
- return path39.join(fs28.realpathSync.native(dir), rest);
27516
+ return path40.join(fs28.realpathSync.native(dir), rest);
27472
27517
  } catch {
27473
- if (path39.dirname(dir) === dir)
27474
- return path39.resolve(file);
27475
- rest = rest ? path39.join(path39.basename(dir), rest) : path39.basename(dir);
27518
+ if (path40.dirname(dir) === dir)
27519
+ return path40.resolve(file);
27520
+ rest = rest ? path40.join(path40.basename(dir), rest) : path40.basename(dir);
27476
27521
  }
27477
27522
  }
27478
27523
  };
27479
27524
  var within = (child, parent) => {
27480
27525
  const fold = (value) => CASE_INSENSITIVE2 ? value.toLowerCase() : value;
27481
- const relative = path39.relative(fold(parent), fold(child));
27482
- return relative === "" || !relative.startsWith("..") && !path39.isAbsolute(relative);
27526
+ const relative = path40.relative(fold(parent), fold(child));
27527
+ return relative === "" || !relative.startsWith("..") && !path40.isAbsolute(relative);
27483
27528
  };
27484
27529
  var checkoutOf2 = (file) => {
27485
- for (let dir = canonical4(file);; dir = path39.dirname(dir)) {
27486
- const dotGit = path39.join(dir, ".git");
27530
+ for (let dir = canonical4(file);; dir = path40.dirname(dir)) {
27531
+ const dotGit = path40.join(dir, ".git");
27487
27532
  if (fs28.existsSync(dotGit)) {
27488
27533
  if (!fs28.statSync(dotGit).isFile())
27489
27534
  return { root: dir, workit: false };
27490
27535
  const admin = /^gitdir:\s*(.+)$/mu.exec(fs28.readFileSync(dotGit, "utf8"))?.[1]?.trim();
27491
27536
  return {
27492
27537
  root: dir,
27493
- workit: Boolean(admin) && fs28.existsSync(path39.join(path39.resolve(dir, admin), FANOUT_TOKEN_FILE))
27538
+ workit: Boolean(admin) && fs28.existsSync(path40.join(path40.resolve(dir, admin), FANOUT_TOKEN_FILE))
27494
27539
  };
27495
27540
  }
27496
- if (path39.dirname(dir) === dir)
27541
+ if (path40.dirname(dir) === dir)
27497
27542
  return null;
27498
27543
  }
27499
27544
  };
@@ -27505,8 +27550,8 @@ var workitWorktreeOf = (file) => {
27505
27550
  return null;
27506
27551
  }
27507
27552
  };
27508
- var bindingDir = () => path39.join(resolveStateDir(), "worktree-bind");
27509
- var bindingFile = (session, agentId) => path39.join(bindingDir(), `${createHash18("sha256").update(`${session}\x00${agentId}`).digest("hex").slice(0, 32)}.json`);
27553
+ var bindingDir = () => path40.join(resolveStateDir(), "worktree-bind");
27554
+ var bindingFile = (session, agentId) => path40.join(bindingDir(), `${createHash18("sha256").update(`${session}\x00${agentId}`).digest("hex").slice(0, 32)}.json`);
27510
27555
  var readBinding = (file) => {
27511
27556
  try {
27512
27557
  const value = JSON.parse(fs28.readFileSync(file, "utf8"));
@@ -27531,7 +27576,7 @@ var bind = (input, worktree) => {
27531
27576
  agentId,
27532
27577
  at: new Date().toISOString()
27533
27578
  };
27534
- fs28.mkdirSync(path39.dirname(file), { recursive: true });
27579
+ fs28.mkdirSync(path40.dirname(file), { recursive: true });
27535
27580
  fs28.writeFileSync(file, JSON.stringify(binding));
27536
27581
  try {
27537
27582
  if (inWorkitWorkspace(input.cwd))
@@ -27550,31 +27595,31 @@ var hostIsolated = (cwd, agentId) => {
27550
27595
  const checkout = checkoutOf2(cwd);
27551
27596
  if (!checkout)
27552
27597
  return false;
27553
- const dotGit = path39.join(checkout.root, ".git");
27598
+ const dotGit = path40.join(checkout.root, ".git");
27554
27599
  if (!fs28.statSync(dotGit).isFile())
27555
27600
  return false;
27556
27601
  const admin = /^gitdir:\s*(.+)$/mu.exec(fs28.readFileSync(dotGit, "utf8"))?.[1]?.trim();
27557
27602
  if (!admin)
27558
27603
  return false;
27559
- const adminDir = path39.resolve(checkout.root, admin);
27560
- const back = fs28.readFileSync(path39.join(adminDir, "gitdir"), "utf8").trim();
27561
- if (path39.relative(canonical4(path39.resolve(adminDir, back)), canonical4(dotGit)) !== "")
27604
+ const adminDir = path40.resolve(checkout.root, admin);
27605
+ const back = fs28.readFileSync(path40.join(adminDir, "gitdir"), "utf8").trim();
27606
+ if (path40.relative(canonical4(path40.resolve(adminDir, back)), canonical4(dotGit)) !== "")
27562
27607
  return false;
27563
- const common = path39.join(adminDir, "commondir");
27564
- const gitDir = fs28.existsSync(common) ? path39.resolve(adminDir, fs28.readFileSync(common, "utf8").trim()) : adminDir;
27565
- const expected = path39.join(path39.dirname(canonical4(gitDir)), ".claude", "worktrees", `agent-${agentId}`);
27566
- return path39.relative(canonical4(expected), checkout.root) === "";
27608
+ const common = path40.join(adminDir, "commondir");
27609
+ const gitDir = fs28.existsSync(common) ? path40.resolve(adminDir, fs28.readFileSync(common, "utf8").trim()) : adminDir;
27610
+ const expected = path40.join(path40.dirname(canonical4(gitDir)), ".claude", "worktrees", `agent-${agentId}`);
27611
+ return path40.relative(canonical4(expected), checkout.root) === "";
27567
27612
  } catch {
27568
27613
  return false;
27569
27614
  }
27570
27615
  };
27571
27616
  var runnerAt = (target) => {
27572
- const base = path39.basename(target);
27617
+ const base = path40.basename(target);
27573
27618
  return base.startsWith(OPAQUE_TARGET) ? decodeURIComponent(base.slice(OPAQUE_TARGET.length)) : null;
27574
27619
  };
27575
27620
  var shown = (target) => {
27576
- const named = /^\.workit-(?:live-target$|runs-)/.test(path39.basename(target)) ? path39.dirname(target) : target;
27577
- return path39.sep === "\\" ? named.replaceAll("/", "\\") : named;
27621
+ const named = /^\.workit-(?:live-target$|runs-)/.test(path40.basename(target)) ? path40.dirname(target) : target;
27622
+ return path40.sep === "\\" ? named.replaceAll("/", "\\") : named;
27578
27623
  };
27579
27624
  var unboundDeny = (input, target) => {
27580
27625
  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.";
@@ -27613,7 +27658,7 @@ var literalForm = (command, refs) => {
27613
27658
  };
27614
27659
  var unknownVarDeny = (input, worktree, targets, command) => {
27615
27660
  const refs = [
27616
- ...new Set(targets.flatMap((target) => path39.relative(UNKNOWN_VAR, path39.resolve(target)).split(path39.sep)[0].split("+").filter(Boolean).map(decodeURIComponent)))
27661
+ ...new Set(targets.flatMap((target) => path40.relative(UNKNOWN_VAR, path40.resolve(target)).split(path40.sep)[0].split("+").filter(Boolean).map(decodeURIComponent)))
27617
27662
  ];
27618
27663
  let text = command ?? "";
27619
27664
  const first = [];
@@ -27642,10 +27687,10 @@ function confineImplementer(input, targets, command) {
27642
27687
  try {
27643
27688
  if (!input.session.agentId || hostIsolated(input.cwd, input.session.agentId))
27644
27689
  return NONE5;
27645
- const unresolved = targets.filter((target) => within(path39.resolve(target), UNKNOWN_VAR));
27690
+ const unresolved = targets.filter((target) => within(path40.resolve(target), UNKNOWN_VAR));
27646
27691
  if (unresolved.length > 0)
27647
27692
  return unknownVarDeny(input, boundWorktree(input), unresolved, command);
27648
- if (targets.some((target) => within(path39.resolve(target), UNKNOWN_DIR)))
27693
+ if (targets.some((target) => within(path40.resolve(target), UNKNOWN_DIR)))
27649
27694
  return unknownDirDeny(input, boundWorktree(input));
27650
27695
  const bindings = canonical4(bindingDir());
27651
27696
  const judged = targets.map((named) => ({ named, real: canonical4(named) })).filter(({ real }) => within(real, bindings) || checkoutOf2(real) !== null);
@@ -27755,16 +27800,16 @@ var RUNS = /^(?:sh|bash|zsh|dash|ksh|mksh|ash|python[\d.]*|node|bun|deno|ruby|pe
27755
27800
  var INLINE = /^-[a-zA-Z]*[ceEpm]$|^--(?:eval|print|test|version|help)$|^-[hvV]$/;
27756
27801
  var VALUED = /^-[WXIrC]$|^--(?:require|import|loader|conditions|input-type)$/;
27757
27802
  var commonDir = (root) => {
27758
- const dotGit = path39.join(root, ".git");
27803
+ const dotGit = path40.join(root, ".git");
27759
27804
  if (!fs28.statSync(dotGit).isFile())
27760
27805
  return canonical4(dotGit);
27761
- const admin = path39.resolve(root, /^gitdir:\s*(.+)$/mu.exec(fs28.readFileSync(dotGit, "utf8"))?.[1]?.trim() ?? "");
27762
- const common = path39.join(admin, "commondir");
27763
- return canonical4(fs28.existsSync(common) ? path39.resolve(admin, fs28.readFileSync(common, "utf8").trim()) : admin);
27806
+ const admin = path40.resolve(root, /^gitdir:\s*(.+)$/mu.exec(fs28.readFileSync(dotGit, "utf8"))?.[1]?.trim() ?? "");
27807
+ const common = path40.join(admin, "commondir");
27808
+ return canonical4(fs28.existsSync(common) ? path40.resolve(admin, fs28.readFileSync(common, "utf8").trim()) : admin);
27764
27809
  };
27765
27810
  var inScratch = (real, repo) => {
27766
27811
  const checkout = checkoutOf2(real);
27767
- return checkout !== null && within(real, path39.join(checkout.root, SCRATCH)) && (repo === null || commonDir(checkout.root) === repo);
27812
+ return checkout !== null && within(real, path40.join(checkout.root, SCRATCH)) && (repo === null || commonDir(checkout.root) === repo);
27768
27813
  };
27769
27814
  var JUDGE_VERBS = {
27770
27815
  check: true,
@@ -27793,7 +27838,7 @@ var judgeVerbRefused = (args) => {
27793
27838
  var CLI_RUNNERS = /^(?:npx|bunx|pnpx|npm|pnpm|yarn|bun|node|nodejs|deno|tsx|ts-node)$/;
27794
27839
  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?$/;
27795
27840
  var workitCalls = (command, depth = 0, aliases = new Map) => depth > 4 ? [] : commandLines(command).flatMap((words) => {
27796
- const name = path39.basename(words[0] ?? "").toLowerCase();
27841
+ const name = path40.basename(words[0] ?? "").toLowerCase();
27797
27842
  if (name === "alias")
27798
27843
  return words.flatMap((word) => {
27799
27844
  const set = /^([\w-]+)=(.*)$/s.exec(word);
@@ -27823,11 +27868,11 @@ var judgeRefusal = (command, fed, depth = 0) => {
27823
27868
  return why;
27824
27869
  }
27825
27870
  const { words } = segment;
27826
- const runs = (word = "") => RUNS.test(path39.basename(word).toLowerCase());
27871
+ const runs = (word = "") => RUNS.test(path40.basename(word).toLowerCase());
27827
27872
  let at = 0;
27828
27873
  while (at < words.length && (LEADS.test(words[at]) || /^-\w$/.test(words[at - 1] ?? "") && !runs(words[at])))
27829
27874
  at++;
27830
- const name = path39.basename(words[at] ?? "").toLowerCase();
27875
+ const name = path40.basename(words[at] ?? "").toLowerCase();
27831
27876
  const args = words.slice(at + 1);
27832
27877
  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`;
27833
27878
  if (/^(?:cd|chdir|pushd|popd)$/.test(name))
@@ -27905,7 +27950,7 @@ var substitutingHeredoc = (command) => {
27905
27950
  var judgeDeny = (input, what) => {
27906
27951
  const role = input.session.agentType?.endsWith("reviewer") ? "reviewer" : "verifier";
27907
27952
  const root = checkoutOf2(input.cwd)?.root;
27908
- const scratch = root ? path39.join(root, SCRATCH) : `${SCRATCH}/ at the root of the checkout you judge`;
27953
+ const scratch = root ? path40.join(root, SCRATCH) : `${SCRATCH}/ at the root of the checkout you judge`;
27909
27954
  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.`;
27910
27955
  return {
27911
27956
  kind: "deny",
@@ -27920,7 +27965,7 @@ function confineJudge(input, targets) {
27920
27965
  const judged = checkoutOf2(input.cwd);
27921
27966
  const repo = judged ? commonDir(judged.root) : null;
27922
27967
  for (const target of targets) {
27923
- const resolved = path39.resolve(target);
27968
+ const resolved = path40.resolve(target);
27924
27969
  if (within(resolved, UNKNOWN_VAR) || within(resolved, UNKNOWN_DIR))
27925
27970
  return judgeDeny(input, "it writes to a path Workit cannot resolve (a variable, a command substitution or `cd -`): spell the path out");
27926
27971
  if (inScratch(canonical4(target), repo))
@@ -27951,7 +27996,7 @@ function confineJudgeShell(input, command, dialect = "posix") {
27951
27996
  let git = [];
27952
27997
  try {
27953
27998
  git = rawInvocations(command, dialect).flatMap(({ tool, dir, args }) => tool === "git" && (args[0] === "push" || leadOwnedGit(args)) ? [
27954
- path39.join(dir === undefined ? UNKNOWN_DIR : path39.resolve(input.cwd, dir ?? "."), `${OPAQUE_TARGET}git`)
27999
+ path40.join(dir === undefined ? UNKNOWN_DIR : path40.resolve(input.cwd, dir ?? "."), `${OPAQUE_TARGET}git`)
27955
28000
  ] : []);
27956
28001
  } catch {}
27957
28002
  return confineJudge(input, [
@@ -27996,7 +28041,7 @@ var judgeChecksLine = (cwd) => {
27996
28041
 
27997
28042
  // packages/workit-core/src/hooks/standing.ts
27998
28043
  var readPlans = (store) => {
27999
- const dir = path40.join(store, "fanouts");
28044
+ const dir = path41.join(store, "fanouts");
28000
28045
  let names;
28001
28046
  try {
28002
28047
  names = fs29.readdirSync(dir).filter((name) => name.endsWith(".json"));
@@ -28006,7 +28051,7 @@ var readPlans = (store) => {
28006
28051
  const plans = [];
28007
28052
  for (const name of names) {
28008
28053
  try {
28009
- const raw = JSON.parse(fs29.readFileSync(path40.join(dir, name), "utf8"));
28054
+ const raw = JSON.parse(fs29.readFileSync(path41.join(dir, name), "utf8"));
28010
28055
  if (typeof raw.name !== "string" || !Array.isArray(raw.slices))
28011
28056
  continue;
28012
28057
  const texts = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string" && item !== "") : [];
@@ -28205,8 +28250,8 @@ var cdWorkitSplit = (command) => {
28205
28250
 
28206
28251
  // packages/workit-core/src/hooks/model-limit.ts
28207
28252
  import { closeSync as closeSync2, openSync as openSync2, readdirSync as readdirSync4, readSync, statSync as statSync4 } from "node:fs";
28208
- import os10 from "node:os";
28209
- import path41 from "node:path";
28253
+ import os11 from "node:os";
28254
+ import path42 from "node:path";
28210
28255
  var MONTHS = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
28211
28256
  var WEEKDAYS = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"];
28212
28257
  var TIME_WORD = String.raw`(?:\d|(?:in|at|on|later|tomorrow|soon)\b|(?:${[...WEEKDAYS, ...MONTHS].join("|")})[a-z]*\b)`;
@@ -28404,17 +28449,17 @@ var firstPrompt = (file) => {
28404
28449
  var claudeProjectSlug = (cwd) => cwd.replace(/[^A-Za-z0-9]/gu, "-");
28405
28450
  var listDir = (dir) => {
28406
28451
  try {
28407
- return readdirSync4(dir).map((name) => path41.join(dir, name));
28452
+ return readdirSync4(dir).map((name) => path42.join(dir, name));
28408
28453
  } catch {
28409
28454
  return [];
28410
28455
  }
28411
28456
  };
28412
28457
  var SCAN_MS = 30 * 60000;
28413
28458
  var scanClaudeTranscripts = (cwd, env, now = new Date) => {
28414
- const projects = path41.join(env.CLAUDE_CONFIG_DIR || path41.join(env.HOME || os10.homedir(), ".claude"), "projects");
28415
- const project = path41.join(projects, claudeProjectSlug(cwd));
28459
+ const projects = path42.join(env.CLAUDE_CONFIG_DIR || path42.join(env.HOME || os11.homedir(), ".claude"), "projects");
28460
+ const project = path42.join(projects, claudeProjectSlug(cwd));
28416
28461
  const notes = [];
28417
- const files = listDir(project).flatMap((entry) => entry.endsWith(".jsonl") ? [{ file: entry, worker: false }] : listDir(path41.join(entry, "subagents")).filter((file) => file.endsWith(".jsonl")).map((file) => ({ file, worker: true })));
28462
+ const files = listDir(project).flatMap((entry) => entry.endsWith(".jsonl") ? [{ file: entry, worker: false }] : listDir(path42.join(entry, "subagents")).filter((file) => file.endsWith(".jsonl")).map((file) => ({ file, worker: true })));
28418
28463
  for (const { file, worker } of files)
28419
28464
  try {
28420
28465
  const stat = statSync4(file);
@@ -28429,7 +28474,7 @@ var scanClaudeTranscripts = (cwd, env, now = new Date) => {
28429
28474
  if (!seen)
28430
28475
  continue;
28431
28476
  notes.push(worker ? redispatchNote(seen, {
28432
- label: `worker ${path41.basename(file, ".jsonl")}`,
28477
+ label: `worker ${path42.basename(file, ".jsonl")}`,
28433
28478
  prompt: firstPrompt(file)
28434
28479
  }, 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.`);
28435
28480
  } catch {}
@@ -28809,10 +28854,10 @@ var modelKey = (model) => {
28809
28854
  // packages/workit-core/src/hooks/budget-signal.ts
28810
28855
  import { createHash as createHash19 } from "node:crypto";
28811
28856
  import fs30 from "node:fs";
28812
- import path42 from "node:path";
28857
+ import path43 from "node:path";
28813
28858
  var hash2 = (text) => createHash19("sha256").update(text).digest("hex").slice(0, 32);
28814
- var budgetDir = (store) => path42.join(store, "budget");
28815
- var agentBase = (store, session, agentId) => path42.join(budgetDir(store), hash2(`${session}\x00${agentId ?? ""}`));
28859
+ var budgetDir = (store) => path43.join(store, "budget");
28860
+ var agentBase = (store, session, agentId) => path43.join(budgetDir(store), hash2(`${session}\x00${agentId ?? ""}`));
28816
28861
  var spawnBudget = (prompt) => {
28817
28862
  const found = /^TIMEBOX:[^\n]*?\b(\d+)\s+tool calls\b/mu.exec(prompt);
28818
28863
  const n = found ? Number(found[1]) : NaN;
@@ -28832,8 +28877,8 @@ var startBudget = (store, session, agentId, n) => {
28832
28877
  const cutoff = Date.now() - 604800000;
28833
28878
  for (const name of fs30.readdirSync(dir))
28834
28879
  try {
28835
- if (fs30.statSync(path42.join(dir, name)).mtimeMs < cutoff)
28836
- fs30.rmSync(path42.join(dir, name));
28880
+ if (fs30.statSync(path43.join(dir, name)).mtimeMs < cutoff)
28881
+ fs30.rmSync(path43.join(dir, name));
28837
28882
  } catch {}
28838
28883
  const base = agentBase(store, session, agentId);
28839
28884
  fs30.writeFileSync(`${base}.json`, JSON.stringify({ limit: n, told: 0 }));
@@ -29175,13 +29220,13 @@ var skillPromptNudge = (prompt, ctx) => process.env.WORKIT_PI_WORKER_SESSION ? n
29175
29220
 
29176
29221
  // packages/workit-pi/src/launches.ts
29177
29222
  import { mkdirSync as mkdirSync4, readFileSync as readFileSync9, readdirSync as readdirSync5, rmSync as rmSync2, writeFileSync as writeFileSync4 } from "node:fs";
29178
- import os11 from "node:os";
29179
- import path43 from "node:path";
29223
+ import os12 from "node:os";
29224
+ import path44 from "node:path";
29180
29225
  var launchDir = (root) => {
29181
29226
  const location = resolveStore(root);
29182
- return location instanceof Error ? null : path43.join(location.dir, "pi-launches");
29227
+ return location instanceof Error ? null : path44.join(location.dir, "pi-launches");
29183
29228
  };
29184
- var fileFor = (dir, workerId) => path43.join(dir, `${workerId.replace(/[^A-Za-z0-9-]/g, "_")}.json`);
29229
+ var fileFor = (dir, workerId) => path44.join(dir, `${workerId.replace(/[^A-Za-z0-9-]/g, "_")}.json`);
29185
29230
  var recordLaunch = (root, attempt) => {
29186
29231
  const dir = launchDir(root);
29187
29232
  if (!dir)
@@ -29191,7 +29236,7 @@ var recordLaunch = (root, attempt) => {
29191
29236
  writeFileSync4(fileFor(dir, attempt.workerId), JSON.stringify({
29192
29237
  ...attempt,
29193
29238
  pid: process.pid,
29194
- host: os11.hostname(),
29239
+ host: os12.hostname(),
29195
29240
  at: new Date().toISOString()
29196
29241
  }), { flag: "wx" });
29197
29242
  return true;
@@ -29205,7 +29250,7 @@ var clearLaunch = (root, workerId) => {
29205
29250
  rmSync2(fileFor(dir, workerId), { force: true });
29206
29251
  };
29207
29252
  var alive = (attempt) => {
29208
- if (attempt.host !== os11.hostname())
29253
+ if (attempt.host !== os12.hostname())
29209
29254
  return true;
29210
29255
  try {
29211
29256
  process.kill(attempt.pid, 0);
@@ -29227,7 +29272,7 @@ var abandonedLaunches = (root) => {
29227
29272
  const found = [];
29228
29273
  for (const name of names) {
29229
29274
  try {
29230
- const attempt = JSON.parse(readFileSync9(path43.join(dir, name), "utf8"));
29275
+ const attempt = JSON.parse(readFileSync9(path44.join(dir, name), "utf8"));
29231
29276
  if (typeof attempt.workerId === "string" && typeof attempt.session === "string") {
29232
29277
  if (!alive(attempt))
29233
29278
  found.push(attempt);
@@ -29239,18 +29284,18 @@ var abandonedLaunches = (root) => {
29239
29284
  var cancelHint = (workerId) => `cancel it first: workit_worker {"action":"cancel","workerId":"${workerId}","reason":"launch outcome unknown"} (CLI: workit worker cancel --payload '{"workerId":"${workerId}","reason":"launch outcome unknown"}')`;
29240
29285
 
29241
29286
  // packages/workit-core/src/core/cli-locate.ts
29242
- import { closeSync as closeSync3, existsSync as existsSync12, openSync as openSync3, readSync as readSync2 } from "node:fs";
29243
- import path44 from "node:path";
29287
+ import { closeSync as closeSync3, existsSync as existsSync13, openSync as openSync3, readSync as readSync2 } from "node:fs";
29288
+ import path45 from "node:path";
29244
29289
  var LAUNCHER_MARKER = "workit-owned-launcher";
29245
29290
  var CLI_PACKAGE_PATH = ["node_modules", "@workit-dev", "cli"];
29246
29291
  var installRoot = (env, platform = process.platform) => {
29247
29292
  if (env.WORKIT_INSTALL_ROOT)
29248
29293
  return env.WORKIT_INSTALL_ROOT;
29249
29294
  const data = dataDir(env, platform);
29250
- return platform === "win32" ? path44.join(data, "install") : data;
29295
+ return platform === "win32" ? path45.join(data, "install") : data;
29251
29296
  };
29252
- var ownedLauncherPath = (env, platform = process.platform) => path44.join(installRoot(env, platform), "bin", platform === "win32" ? "workit.cmd" : "workit");
29253
- var ownedCurrentEntry = (env, platform = process.platform) => path44.join(installRoot(env, platform), "current", ...CLI_PACKAGE_PATH, "dist", "index.js");
29297
+ var ownedLauncherPath = (env, platform = process.platform) => path45.join(installRoot(env, platform), "bin", platform === "win32" ? "workit.cmd" : "workit");
29298
+ var ownedCurrentEntry = (env, platform = process.platform) => path45.join(installRoot(env, platform), "current", ...CLI_PACKAGE_PATH, "dist", "index.js");
29254
29299
  var head = (file) => {
29255
29300
  let fd;
29256
29301
  try {
@@ -29268,7 +29313,7 @@ var head = (file) => {
29268
29313
  var locateWorkitCli = (options = {}) => {
29269
29314
  const env = options.env ?? process.env;
29270
29315
  const platform = options.platform ?? process.platform;
29271
- const exists = options.exists ?? existsSync12;
29316
+ const exists = options.exists ?? existsSync13;
29272
29317
  const read = options.read ?? head;
29273
29318
  const node = options.node ?? process.execPath;
29274
29319
  const launcher = ownedLauncherPath(env, platform);
@@ -29277,7 +29322,7 @@ var locateWorkitCli = (options = {}) => {
29277
29322
  source: "owned-launcher",
29278
29323
  command: launcher,
29279
29324
  args: [],
29280
- binDir: path44.dirname(launcher)
29325
+ binDir: path45.dirname(launcher)
29281
29326
  };
29282
29327
  const current = ownedCurrentEntry(env, platform);
29283
29328
  if (exists(current))
@@ -29306,7 +29351,7 @@ var workitCliEnv = (located, env = process.env, platform = process.platform) =>
29306
29351
  if (located.binDir) {
29307
29352
  const key = pathKey(env);
29308
29353
  const delimiter = platform === "win32" ? ";" : ":";
29309
- const same = (dir) => platform === "win32" ? path44.win32.normalize(dir).toLowerCase() === path44.win32.normalize(located.binDir).toLowerCase() : path44.posix.normalize(dir) === path44.posix.normalize(located.binDir);
29354
+ const same = (dir) => platform === "win32" ? path45.win32.normalize(dir).toLowerCase() === path45.win32.normalize(located.binDir).toLowerCase() : path45.posix.normalize(dir) === path45.posix.normalize(located.binDir);
29310
29355
  const rest = (env[key] ?? "").split(delimiter).filter((dir) => dir && !same(dir));
29311
29356
  patch[key] = [located.binDir, ...rest].join(delimiter);
29312
29357
  }