@workit-dev/pi 1.4.2 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/workit.js +323 -289
  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";
@@ -16474,12 +16474,11 @@ function checkVerdictsOnce(cwd, branch, ledgerRows) {
16474
16474
  }
16475
16475
  return reasons;
16476
16476
  };
16477
- const retired = new Set;
16477
+ const voided = verdictVoids(rows, { chained: true });
16478
+ const retired = new Set(voided.keys());
16478
16479
  for (const row of rows)
16479
- if (row.type === "verdict" && row.supersedes && !row.supersedeIgnored && trustReasons(cwd, row).length === 0)
16480
+ if (row.type === "verdict" && row.supersedes && !row.supersedeIgnored && !voided.has(row.id) && trustReasons(cwd, row).length === 0)
16480
16481
  retired.add(row.supersedes);
16481
- for (const id of verdictVoids(rows, { chained: true }).keys())
16482
- retired.add(id);
16483
16482
  const byKind = new Map;
16484
16483
  for (const row of rows.toSorted(byRank))
16485
16484
  if (isLiveVerdict(row, retired) && scope(row)) {
@@ -18257,31 +18256,75 @@ var exportDigest = (bundle) => sha256({
18257
18256
  });
18258
18257
  // packages/workit-core/src/core/route-intent.ts
18259
18258
  import { spawnSync as spawnSync16 } from "node:child_process";
18260
- import { existsSync as existsSync8 } from "node:fs";
18261
- import path26 from "node:path";
18259
+ import { existsSync as existsSync9 } from "node:fs";
18260
+ import path27 from "node:path";
18262
18261
 
18263
18262
  // packages/workit-core/src/hooks/raw-git.ts
18264
18263
  import { spawnSync as spawnSync15 } from "node:child_process";
18265
18264
  import { createHash as createHash15 } from "node:crypto";
18266
18265
  import fs18 from "node:fs";
18267
- import os6 from "node:os";
18268
- import path25 from "node:path";
18266
+ import os7 from "node:os";
18267
+ import path26 from "node:path";
18269
18268
 
18270
18269
  // packages/workit-core/src/autonomy.ts
18270
+ import os6 from "node:os";
18271
+ import path24 from "node:path";
18272
+
18273
+ // packages/workit-core/src/core/eval-world.ts
18274
+ import { existsSync as existsSync8, realpathSync as realpathSync5 } from "node:fs";
18271
18275
  import os5 from "node:os";
18272
18276
  import path23 from "node:path";
18277
+ var EVAL_WORLD_ENV = "WORKIT_EVAL_WORLD";
18278
+ var EVAL_WORLD_MARKER = ".workit-eval-world";
18279
+ var inside2 = (dir, file) => {
18280
+ const rel = path23.relative(dir, file);
18281
+ return !rel.startsWith("..") && !path23.isAbsolute(rel);
18282
+ };
18283
+ var evalWorldEntry = (cwd) => {
18284
+ const raw = process.env[EVAL_WORLD_ENV];
18285
+ if (!raw || !path23.isAbsolute(raw))
18286
+ return null;
18287
+ try {
18288
+ const world = realpathSync5(raw);
18289
+ if (!inside2(realpathSync5(os5.tmpdir()), world) || !inside2(world, realpathSync5(cwd)) || !existsSync8(path23.join(world, EVAL_WORLD_MARKER)))
18290
+ return null;
18291
+ return loadWorkspacesFrom(path23.join(world, "config"))[0] ?? null;
18292
+ } catch {
18293
+ return null;
18294
+ }
18295
+ };
18296
+
18297
+ // packages/workit-core/src/autonomy.ts
18273
18298
  var accountHome2 = () => {
18274
18299
  try {
18275
- return os5.userInfo().homedir;
18300
+ return os6.userInfo().homedir;
18276
18301
  } catch {
18277
- return os5.homedir();
18302
+ return os6.homedir();
18278
18303
  }
18279
18304
  };
18280
18305
  var grantsHome = { resolve: accountHome2 };
18281
18306
  var grantsDir = () => configDir({ HOME: grantsHome.resolve() });
18307
+ var benchWorld = (cwd) => {
18308
+ const entry = evalWorldEntry(cwd);
18309
+ if (!entry)
18310
+ return null;
18311
+ const { grants } = configuredGrants(entry);
18312
+ const lowered = {};
18313
+ for (const kind of GRANT_KINDS) {
18314
+ const value = grants[kind];
18315
+ if (value !== undefined && raises(kind, value, DEFAULT_GRANTS[kind]))
18316
+ lowered[kind] = value;
18317
+ }
18318
+ return {
18319
+ name: entry.name,
18320
+ glob: entry.glob,
18321
+ ...entry.defaultEndpoint ? { defaultEndpoint: entry.defaultEndpoint } : {},
18322
+ autonomy: lowered
18323
+ };
18324
+ };
18282
18325
  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`;
18326
+ const configured = path24.resolve(resolveConfigDir());
18327
+ 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
18328
  };
18286
18329
  var GRANT_KINDS = ["push", "pr", "merge", "release", "rerun"];
18287
18330
  var DEFAULT_GRANTS = Object.freeze({
@@ -18446,11 +18489,12 @@ function capAt(named, where, by, why, main = false) {
18446
18489
  };
18447
18490
  }
18448
18491
  function resolveAutonomy(cwd, target) {
18449
- const override = grantsOverride();
18492
+ const world = benchWorld(cwd);
18493
+ const override = world ? null : grantsOverride();
18450
18494
  if (override)
18451
18495
  return { ...autonomyOf(null), note: override };
18452
18496
  const name = process.env.WORKIT_WORKSPACE_NAME?.trim() || undefined;
18453
- let autonomy = autonomyOf(resolveWorkspaceFrom(cwd, grantsDir(), name));
18497
+ let autonomy = autonomyOf(resolveWorkspaceFrom(cwd, grantsDir(), name) ?? world);
18454
18498
  if (name)
18455
18499
  autonomy = capAt(autonomy, cwd, `WORKIT_WORKSPACE_NAME=${name}`, "a name never raises grants");
18456
18500
  const above = checkoutsAbove(cwd);
@@ -18538,7 +18582,7 @@ var raises = (kind, current, next) => {
18538
18582
  // packages/workit-core/src/hooks/session-marker.ts
18539
18583
  import { createHash as createHash14 } from "node:crypto";
18540
18584
  import fs17 from "node:fs";
18541
- import path24 from "node:path";
18585
+ import path25 from "node:path";
18542
18586
  var sessionMarkerFile = (input, session, store) => {
18543
18587
  let dir = store;
18544
18588
  if (dir === undefined) {
@@ -18548,7 +18592,7 @@ var sessionMarkerFile = (input, session, store) => {
18548
18592
  dir = location.dir;
18549
18593
  }
18550
18594
  const name = createHash14("sha256").update(`${input.host}\x00${session}`).digest("hex").slice(0, 32);
18551
- return path24.join(dir, "hooks", `skills-${name}.json`);
18595
+ return path25.join(dir, "hooks", `skills-${name}.json`);
18552
18596
  };
18553
18597
  var list2 = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
18554
18598
  var EMPTY = {
@@ -18583,7 +18627,7 @@ var parseMarker = (text) => {
18583
18627
  };
18584
18628
  var readSessionMarker = (file) => parseMarker(readRaw(file));
18585
18629
  var writeAtomic = (file, marker) => {
18586
- fs17.mkdirSync(path24.dirname(file), { recursive: true });
18630
+ fs17.mkdirSync(path25.dirname(file), { recursive: true });
18587
18631
  const temp = `${file}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
18588
18632
  try {
18589
18633
  fs17.writeFileSync(temp, JSON.stringify(marker));
@@ -19168,14 +19212,14 @@ var GIT_CONFIG_ENV = /^(?:GIT_(?:CONFIG\w*|DIR|COMMON_DIR|WORK_TREE|SSH|SSH_COMM
19168
19212
  var ASSIGNMENT = /^([A-Za-z_]\w*)=([\s\S]*)$/;
19169
19213
  var MAX_DEPTH = 4;
19170
19214
  var MAX_EXPANSIONS = 16;
19171
- var isAbsolute = (value) => path25.isAbsolute(value) || /^[A-Za-z]:[\\/]/.test(value) || value.startsWith("\\\\");
19215
+ var isAbsolute = (value) => path26.isAbsolute(value) || /^[A-Za-z]:[\\/]/.test(value) || value.startsWith("\\\\");
19172
19216
  var HERE = /^(?:\$PWD|\$\{PWD\}|\$\(\s*pwd\s*\)|`pwd`|\$\(\s*git\s+rev-parse\s+--show-toplevel\s*\))(?=$|[\\/])/;
19173
19217
  var joinDir = (base, raw) => {
19174
19218
  const next = raw.replace(HERE, ".");
19175
19219
  if (base === undefined || /[$`*?]/.test(next) || next === "-")
19176
19220
  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);
19221
+ const expanded = next === "~" || next.startsWith("~/") ? path26.join(os7.homedir(), next.slice(1)) : next;
19222
+ return base === null || isAbsolute(expanded) ? expanded : path26.join(base, expanded);
19179
19223
  };
19180
19224
  var rebase = (base, inner) => inner === null ? base : inner === undefined ? undefined : joinDir(base, inner);
19181
19225
  var cdTarget = (words) => {
@@ -19576,7 +19620,7 @@ function walk2(command, dialect, depth, seen, inherited = {}) {
19576
19620
  }
19577
19621
  if (CD.has(name)) {
19578
19622
  const target = cdTarget(words);
19579
- dir = target === null ? os6.homedir() : joinDir(dir, target);
19623
+ dir = target === null ? os7.homedir() : joinDir(dir, target);
19580
19624
  } else if (PUSHD.has(name)) {
19581
19625
  const target = cdTarget(words);
19582
19626
  stack.push(dir);
@@ -20097,17 +20141,17 @@ var headSha2 = (repo) => {
20097
20141
  if (!git || git.reftable)
20098
20142
  return null;
20099
20143
  try {
20100
- const head = fs18.readFileSync(path25.join(git.gitDir, "HEAD"), "utf8").trim();
20144
+ const head = fs18.readFileSync(path26.join(git.gitDir, "HEAD"), "utf8").trim();
20101
20145
  if (/^[0-9a-f]{40,64}$/.test(head))
20102
20146
  return head;
20103
20147
  const ref = /^ref: (refs\/.+)$/.exec(head)?.[1];
20104
20148
  if (!ref)
20105
20149
  return null;
20106
- const common = path25.dirname(repo.location.dir);
20150
+ const common = path26.dirname(repo.location.dir);
20107
20151
  try {
20108
- return fs18.readFileSync(path25.join(common, ref), "utf8").trim() || null;
20152
+ return fs18.readFileSync(path26.join(common, ref), "utf8").trim() || null;
20109
20153
  } catch {}
20110
- const packed = fs18.readFileSync(path25.join(common, "packed-refs"), "utf8");
20154
+ const packed = fs18.readFileSync(path26.join(common, "packed-refs"), "utf8");
20111
20155
  return new RegExp(`^([0-9a-f]{40,64}) ${ref.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`, "m").exec(packed)?.[1] ?? null;
20112
20156
  } catch {
20113
20157
  return null;
@@ -20200,7 +20244,7 @@ var expandGitAliases = (root, invocation, cache = new Map, depth = 0) => {
20200
20244
  const sub = invocation.args[0];
20201
20245
  if (invocation.tool !== "git" || invocation.dir === undefined || !sub || sub.startsWith("-") || GIT_COMMANDS.has(sub) || depth >= MAX_DEPTH)
20202
20246
  return [invocation];
20203
- const dir = path25.resolve(root, invocation.dir ?? ".");
20247
+ const dir = path26.resolve(root, invocation.dir ?? ".");
20204
20248
  if (!fs18.existsSync(dir))
20205
20249
  return [invocation];
20206
20250
  const config = gitConfig(dir, invocation, cache);
@@ -20223,11 +20267,11 @@ var expandGitAliases = (root, invocation, cache = new Map, depth = 0) => {
20223
20267
  var normalizedUrl = (url, dir) => {
20224
20268
  const trimmed = url.trim();
20225
20269
  if (/^file:\/\//i.test(trimmed))
20226
- return path25.resolve(dir, trimmed.slice(7)).replace(/\/+$/, "").replace(/\.git$/, "");
20270
+ return path26.resolve(dir, trimmed.slice(7)).replace(/\/+$/, "").replace(/\.git$/, "");
20227
20271
  const scheme = /^[a-z][a-z0-9+.-]*:\/\//i.exec(trimmed);
20228
20272
  const scp = !scheme && /^(?:[^@/\\]+@)?[^/\\:]{2,}:/.test(trimmed);
20229
20273
  if (!scheme && !scp)
20230
- return path25.resolve(dir, trimmed).replace(/\/+$/, "").replace(/\.git$/, "");
20274
+ return path26.resolve(dir, trimmed).replace(/\/+$/, "").replace(/\.git$/, "");
20231
20275
  const value = scheme ? trimmed.slice(scheme[0].length).replace(/^[^@/]*@/, "").replace(/^([^/:]+):\d+(?=\/)/, "$1") : trimmed.replace(/^[^@/]*@/, "").replace(":", "/");
20232
20276
  return value.toLowerCase().replace(/\/{2,}/g, "/").replace(/^www\./, "").replace(/\/+$/, "").replace(/\.git$/, "");
20233
20277
  };
@@ -20455,7 +20499,7 @@ var actionsIn = (cwd, command, dialect, cache = new Map, all = false) => {
20455
20499
  const out = [];
20456
20500
  const repos = new Map;
20457
20501
  const repoFor = (relative) => {
20458
- const dir = path25.resolve(cwd, relative ?? ".");
20502
+ const dir = path26.resolve(cwd, relative ?? ".");
20459
20503
  if (!repos.has(dir)) {
20460
20504
  const repo = repoAt(dir);
20461
20505
  const workit = repo !== null && isWorkitWorkspace(repo);
@@ -20475,7 +20519,7 @@ var actionsIn = (cwd, command, dialect, cache = new Map, all = false) => {
20475
20519
  continue;
20476
20520
  const action = rawAction(invocation);
20477
20521
  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 },
20522
+ repo: { dir: path26.resolve(cwd, invocation.dir ?? "."), branch: null },
20479
20523
  workit: false
20480
20524
  } : null);
20481
20525
  if (action && at)
@@ -20612,9 +20656,9 @@ var grantRefusal = (action, repo, invocation, cache) => {
20612
20656
  return null;
20613
20657
  };
20614
20658
  var localTag = (repo, name) => {
20615
- const common = path25.dirname(repo.location.dir);
20659
+ const common = path26.dirname(repo.location.dir);
20616
20660
  try {
20617
- return fs18.existsSync(path25.join(common, "refs/tags", name)) || fs18.readFileSync(path25.join(common, "packed-refs"), "utf8").includes(` refs/tags/${name}
20661
+ return fs18.existsSync(path26.join(common, "refs/tags", name)) || fs18.readFileSync(path26.join(common, "packed-refs"), "utf8").includes(` refs/tags/${name}
20618
20662
  `);
20619
20663
  } catch {
20620
20664
  return false;
@@ -20634,7 +20678,7 @@ var analysisDenial = (error) => ({
20634
20678
  });
20635
20679
  var NEXT_COMMAND = "next";
20636
20680
  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`);
20681
+ 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
20682
  var callKey = (toolUseId, command) => toolUseId ?? `cmd:${createHash15("sha256").update(command).digest("hex")}`;
20639
20683
  function noteRawCommit(input, command, key) {
20640
20684
  try {
@@ -20645,7 +20689,7 @@ function noteRawCommit(input, command, key) {
20645
20689
  if (action.kind !== "commit")
20646
20690
  continue;
20647
20691
  const file = markerFile(repo, input.session.id, key);
20648
- fs18.mkdirSync(path25.dirname(file), { recursive: true });
20692
+ fs18.mkdirSync(path26.dirname(file), { recursive: true });
20649
20693
  fs18.writeFileSync(file, `${JSON.stringify({ head: headSha2(repo), at })}
20650
20694
  `);
20651
20695
  }
@@ -20886,8 +20930,8 @@ var judgedDir = (root, dir) => {
20886
20930
  return null;
20887
20931
  if (dir === null)
20888
20932
  return root;
20889
- const resolved = path26.resolve(root, dir);
20890
- return existsSync8(resolved) && inWorkitWorkspace(resolved) ? resolved : null;
20933
+ const resolved = path27.resolve(root, dir);
20934
+ return existsSync9(resolved) && inWorkitWorkspace(resolved) ? resolved : null;
20891
20935
  };
20892
20936
  var shellBranchPolicyViolation = (root, command, dialect = "posix") => {
20893
20937
  let judged = false;
@@ -20908,7 +20952,7 @@ var shellBranchPolicyViolation = (root, command, dialect = "posix") => {
20908
20952
  return judged ? { ok: true } : null;
20909
20953
  };
20910
20954
  // packages/workit-core/src/core/task-engine.ts
20911
- import { realpathSync as realpathSync6 } from "node:fs";
20955
+ import { realpathSync as realpathSync7 } from "node:fs";
20912
20956
 
20913
20957
  // packages/workit-core/src/core/policy-resolver.ts
20914
20958
  function resolvePolicy(input) {
@@ -21157,12 +21201,12 @@ var judgeInputSummary = (raw) => {
21157
21201
  };
21158
21202
 
21159
21203
  // packages/workit-core/src/core/task-view.ts
21160
- import { realpathSync as realpathSync5 } from "node:fs";
21204
+ import { realpathSync as realpathSync6 } from "node:fs";
21161
21205
  var environment = () => [];
21162
21206
  var sameSession2 = (value, context) => typeof value === "object" && value !== null && value.kind === "host" && value.host === context.caller.host && value.handle === context.caller.actor;
21163
21207
  function contextRootError(store, context) {
21164
21208
  try {
21165
- realpathSync5(context.root);
21209
+ realpathSync6(context.root);
21166
21210
  const root = checkoutRootOf(context.root);
21167
21211
  if (root !== store.root && !sameDirectoryIdentity(root, store.root))
21168
21212
  return failure2("invalid_input", "operation context root does not match the task store root");
@@ -22632,7 +22676,7 @@ class WorkitCore {
22632
22676
  if (view.task.workspaceId !== view.workspace.id)
22633
22677
  return failure2("invalid_input", "task and workspace bindings are invalid");
22634
22678
  try {
22635
- if (realpathSync6(view.workspace.root) !== this.store.root)
22679
+ if (realpathSync7(view.workspace.root) !== this.store.root)
22636
22680
  return failure2("invalid_input", "task view root does not match the task store");
22637
22681
  } catch {
22638
22682
  return failure2("invalid_input", "task view root cannot be resolved");
@@ -22883,8 +22927,8 @@ class WorkitCore {
22883
22927
  }
22884
22928
  // packages/workit-core/src/core/repo-context.ts
22885
22929
  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";
22930
+ import { existsSync as existsSync10, readFileSync as readFileSync8, readdirSync as readdirSync3 } from "node:fs";
22931
+ import path28 from "node:path";
22888
22932
  var isSafeContextRange = (value) => value.length <= 4096 && (() => {
22889
22933
  try {
22890
22934
  gitRevisionParts(value);
@@ -23028,13 +23072,13 @@ var findPrTemplate = (cwd) => {
23028
23072
  for (const rel of PR_TEMPLATE_FILES) {
23029
23073
  const parts = rel.split("/");
23030
23074
  const base = parts[parts.length - 1];
23031
- const dir = parts.length > 1 ? path27.join(cwd, ...parts.slice(0, -1)) : cwd;
23075
+ const dir = parts.length > 1 ? path28.join(cwd, ...parts.slice(0, -1)) : cwd;
23032
23076
  const actual = probeCaseInsensitive(dir, base);
23033
23077
  if (actual)
23034
23078
  return [...parts.slice(0, -1), actual].join("/");
23035
23079
  }
23036
23080
  for (const rel of PR_TEMPLATE_DIRS) {
23037
- const only = singleMarkdown(path27.join(cwd, ...rel.split("/")));
23081
+ const only = singleMarkdown(path28.join(cwd, ...rel.split("/")));
23038
23082
  if (only)
23039
23083
  return `${rel}/${only}`;
23040
23084
  }
@@ -23064,8 +23108,8 @@ var diffStatForRange = (cwd, range) => {
23064
23108
  return runGit(cwd, ["diff", "--stat", "--"]).stdout;
23065
23109
  };
23066
23110
  var packageScripts = (cwd, keys) => {
23067
- const pkgPath = path27.join(cwd, "package.json");
23068
- if (!existsSync9(pkgPath))
23111
+ const pkgPath = path28.join(cwd, "package.json");
23112
+ if (!existsSync10(pkgPath))
23069
23113
  return [];
23070
23114
  try {
23071
23115
  const pkg = JSON.parse(readFileSync8(pkgPath, "utf8"));
@@ -23090,9 +23134,9 @@ var documentationFiles = (cwd) => {
23090
23134
  if (entry.isDirectory()) {
23091
23135
  if (excluded.has(entry.name))
23092
23136
  continue;
23093
- walk(path27.join(dir, entry.name), depth + 1);
23137
+ walk(path28.join(dir, entry.name), depth + 1);
23094
23138
  } else if (entry.isFile() && (entry.name === "README.md" || entry.name.endsWith(".md"))) {
23095
- matches.push("./" + path27.relative(cwd, path27.join(dir, entry.name)).replaceAll("\\", "/"));
23139
+ matches.push("./" + path28.relative(cwd, path28.join(dir, entry.name)).replaceAll("\\", "/"));
23096
23140
  }
23097
23141
  }
23098
23142
  };
@@ -23100,7 +23144,7 @@ var documentationFiles = (cwd) => {
23100
23144
  return matches.toSorted().slice(0, 200);
23101
23145
  };
23102
23146
  var readTrimmed2 = (file, maxLines) => {
23103
- if (!existsSync9(file))
23147
+ if (!existsSync10(file))
23104
23148
  return "";
23105
23149
  const lines = readFileSync8(file, "utf8").split(`
23106
23150
  `);
@@ -23108,7 +23152,7 @@ var readTrimmed2 = (file, maxLines) => {
23108
23152
  `);
23109
23153
  };
23110
23154
  function prReadyContext(root, range) {
23111
- const cwd = path27.resolve(repoRoot(root));
23155
+ const cwd = path28.resolve(repoRoot(root));
23112
23156
  if (range !== undefined && !isResolvableContextRange(cwd, range))
23113
23157
  return invalidRange(cwd);
23114
23158
  let stdout = "";
@@ -23166,7 +23210,7 @@ ${status.stderr}` : "");
23166
23210
  stdout += `template_path: ${template}
23167
23211
 
23168
23212
  `;
23169
- stdout += readTrimmed2(path27.join(cwd, template), 220);
23213
+ stdout += readTrimmed2(path28.join(cwd, template), 220);
23170
23214
  } else {
23171
23215
  stdout += `template_path: none
23172
23216
 
@@ -23176,7 +23220,7 @@ ${status.stderr}` : "");
23176
23220
  stdout += `
23177
23221
  `;
23178
23222
  stdout += printSection("Recent Validation Signals");
23179
- if (existsSync9(path27.join(cwd, "package.json"))) {
23223
+ if (existsSync10(path28.join(cwd, "package.json"))) {
23180
23224
  stdout += `package.json detected. Common scripts:
23181
23225
  `;
23182
23226
  const found = packageScripts(cwd, ["lint", "format:check", "test", "build"]);
@@ -23185,7 +23229,7 @@ ${status.stderr}` : "");
23185
23229
  `) + `
23186
23230
  `;
23187
23231
  }
23188
- if (existsSync9(path27.join(cwd, "Cargo.toml")) || existsSync9(path27.join(cwd, "src-tauri/Cargo.toml"))) {
23232
+ if (existsSync10(path28.join(cwd, "Cargo.toml")) || existsSync10(path28.join(cwd, "src-tauri/Cargo.toml"))) {
23189
23233
  stdout += `Rust project detected.
23190
23234
  `;
23191
23235
  }
@@ -23218,7 +23262,7 @@ var CHANGELOG_RULES = `- Use an [Unreleased] section.
23218
23262
  - Apply with the host-native editor, preserving the repository changelog conventions.
23219
23263
  - If Unreleased already has duplicate category headings, normalize_only first.`;
23220
23264
  function changelogContext(root, range) {
23221
- const cwd = path27.resolve(repoRoot(root));
23265
+ const cwd = path28.resolve(repoRoot(root));
23222
23266
  if (range !== undefined && !isResolvableContextRange(cwd, range))
23223
23267
  return invalidRange(cwd);
23224
23268
  const resolvedRange = rangeArgOrDefault(range, cwd);
@@ -23236,8 +23280,8 @@ function changelogContext(root, range) {
23236
23280
  stdout += CHANGELOG_RULES + `
23237
23281
  `;
23238
23282
  stdout += printSection("Existing CHANGELOG.md");
23239
- const changelogPath = path27.join(cwd, "CHANGELOG.md");
23240
- if (existsSync9(changelogPath)) {
23283
+ const changelogPath = path28.join(cwd, "CHANGELOG.md");
23284
+ if (existsSync10(changelogPath)) {
23241
23285
  stdout += readTrimmed2(changelogPath, 260) + `
23242
23286
  `;
23243
23287
  } else {
@@ -23256,7 +23300,7 @@ function changelogContext(root, range) {
23256
23300
  return { stdout, stderr: "", exitCode: 0, cwd };
23257
23301
  }
23258
23302
  function docsRefreshContext(root, range) {
23259
- const cwd = path27.resolve(repoRoot(root));
23303
+ const cwd = path28.resolve(repoRoot(root));
23260
23304
  if (range !== undefined && !isResolvableContextRange(cwd, range))
23261
23305
  return invalidRange(cwd);
23262
23306
  const resolvedRange = rangeArgOrDefault(range, cwd);
@@ -23278,8 +23322,8 @@ function docsRefreshContext(root, range) {
23278
23322
  `) + `
23279
23323
  `;
23280
23324
  stdout += printSection("README Preview");
23281
- const readme = path27.join(cwd, "README.md");
23282
- if (existsSync9(readme)) {
23325
+ const readme = path28.join(cwd, "README.md");
23326
+ if (existsSync10(readme)) {
23283
23327
  stdout += readTrimmed2(readme, 220) + `
23284
23328
  `;
23285
23329
  } else {
@@ -23287,8 +23331,8 @@ function docsRefreshContext(root, range) {
23287
23331
  `;
23288
23332
  }
23289
23333
  stdout += printSection("Package Scripts");
23290
- const pkgPath = path27.join(cwd, "package.json");
23291
- if (existsSync9(pkgPath)) {
23334
+ const pkgPath = path28.join(cwd, "package.json");
23335
+ if (existsSync10(pkgPath)) {
23292
23336
  try {
23293
23337
  const pkg = JSON.parse(readFileSync8(pkgPath, "utf8"));
23294
23338
  stdout += JSON.stringify({ name: pkg.name, version: pkg.version, scripts: pkg.scripts }, null, 2) + `
@@ -23301,7 +23345,7 @@ function docsRefreshContext(root, range) {
23301
23345
  return { stdout, stderr: "", exitCode: 0, cwd };
23302
23346
  }
23303
23347
  function releaseNotesContext(root, rangeOrTag) {
23304
- const cwd = path27.resolve(repoRoot(root));
23348
+ const cwd = path28.resolve(repoRoot(root));
23305
23349
  if (!rangeOrTag) {
23306
23350
  return {
23307
23351
  stdout: "",
@@ -23344,7 +23388,7 @@ function releaseNotesContext(root, rangeOrTag) {
23344
23388
  `;
23345
23389
  stdout += printSection("Existing Release Files");
23346
23390
  for (const rel of ["CHANGELOG.md", "RELEASE_NOTES.md", ".github/releases.md"]) {
23347
- if (existsSync9(path27.join(cwd, rel)))
23391
+ if (existsSync10(path28.join(cwd, rel)))
23348
23392
  stdout += rel + `
23349
23393
  `;
23350
23394
  }
@@ -23376,7 +23420,7 @@ import { spawnSync as spawnSync19 } from "node:child_process";
23376
23420
 
23377
23421
  // packages/workit-core/src/core/pr-create.ts
23378
23422
  import fs19 from "node:fs";
23379
- import path28 from "node:path";
23423
+ import path29 from "node:path";
23380
23424
  import { spawnSync as spawnSync18 } from "node:child_process";
23381
23425
  // packages/workit-core/src/forge/pr-body.ts
23382
23426
  function parseGhIssue(value) {
@@ -23396,11 +23440,11 @@ var LOCAL = bounded(20000);
23396
23440
  var NETWORK = bounded(60000);
23397
23441
  function whichOnPath(tool) {
23398
23442
  const names = process.platform === "win32" ? [tool, `${tool}.exe`, `${tool}.cmd`] : [tool];
23399
- for (const dir of (process.env.PATH ?? "").split(path28.delimiter)) {
23443
+ for (const dir of (process.env.PATH ?? "").split(path29.delimiter)) {
23400
23444
  if (!dir)
23401
23445
  continue;
23402
23446
  for (const name of names) {
23403
- const candidate = path28.join(dir, name);
23447
+ const candidate = path29.join(dir, name);
23404
23448
  try {
23405
23449
  fs19.accessSync(candidate, fs19.constants.X_OK);
23406
23450
  return candidate;
@@ -23521,7 +23565,7 @@ var fetchGitLabIssueBody = async (ref, root, deps = {}) => {
23521
23565
 
23522
23566
  // packages/workit-core/src/core/youtrack.ts
23523
23567
  import fs21 from "node:fs";
23524
- import path30 from "node:path";
23568
+ import path31 from "node:path";
23525
23569
 
23526
23570
  // packages/workit-core/src/core/templates.ts
23527
23571
  var repoRoot2 = assetRoot();
@@ -23536,7 +23580,7 @@ import { spawnSync as spawnSync20 } from "node:child_process";
23536
23580
 
23537
23581
  // packages/workit-core/src/forge/exec.ts
23538
23582
  import fs20 from "node:fs";
23539
- import path29 from "node:path";
23583
+ import path30 from "node:path";
23540
23584
 
23541
23585
  // packages/workit-core/src/forge/redact.ts
23542
23586
  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 +23591,11 @@ var ANSI = new RegExp(String.raw`\u001b\[[0-9;?]*[ -/]*[@-~]|\u001b\][^\u0007]*\
23547
23591
  // packages/workit-core/src/forge/exec.ts
23548
23592
  var MAX_BUFFER2 = 64 * 1024 * 1024;
23549
23593
  function findExecutable(bin, env) {
23550
- const dirs = (env.PATH ?? env.Path ?? "").split(path29.delimiter).filter(Boolean);
23594
+ const dirs = (env.PATH ?? env.Path ?? "").split(path30.delimiter).filter(Boolean);
23551
23595
  const exts = process.platform === "win32" ? [".exe"] : [""];
23552
23596
  for (const dir of dirs)
23553
23597
  for (const ext of exts) {
23554
- const candidate = path29.join(dir, `${bin}${ext}`);
23598
+ const candidate = path30.join(dir, `${bin}${ext}`);
23555
23599
  try {
23556
23600
  const stat = fs20.statSync(candidate);
23557
23601
  if (stat.isFile())
@@ -23594,7 +23638,7 @@ var YTRACK_MISSING = "ytrack is not on PATH: Workit reaches YouTrack only throug
23594
23638
 
23595
23639
  // packages/workit-core/src/core/youtrack.ts
23596
23640
  var ISSUE_RE = /^[A-Z]+-\d+$/;
23597
- var youTrackReadOnlyConfigPath = () => process.env.WORKIT_YOUTRACK_CONFIG ?? path30.join(resolveConfigDir(), "youtrack.json");
23641
+ var youTrackReadOnlyConfigPath = () => process.env.WORKIT_YOUTRACK_CONFIG ?? path31.join(resolveConfigDir(), "youtrack.json");
23598
23642
  var readYouTrackContextConfig = () => {
23599
23643
  const cfgPath = youTrackReadOnlyConfigPath();
23600
23644
  if (!fs21.existsSync(cfgPath))
@@ -23961,22 +24005,22 @@ function resolveGitRevision(root, value) {
23961
24005
  }
23962
24006
  }
23963
24007
  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)) {
24008
+ const base = realpathSync8(root);
24009
+ const target = path32.resolve(base, candidate);
24010
+ if (target !== base && !target.startsWith(base + path32.sep)) {
23967
24011
  throw new Error("path must stay inside repository root");
23968
24012
  }
23969
24013
  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)) {
24014
+ while (!existsSync11(ancestor))
24015
+ ancestor = path32.dirname(ancestor);
24016
+ const canonicalAncestor = realpathSync8(ancestor);
24017
+ if (canonicalAncestor !== base && !canonicalAncestor.startsWith(base + path32.sep)) {
23974
24018
  throw new Error("path must stay inside repository root");
23975
24019
  }
23976
24020
  return target;
23977
24021
  }
23978
24022
  function run2(root, executable, args, env = {}) {
23979
- const cwd = realpathSync7(root);
24023
+ const cwd = realpathSync8(root);
23980
24024
  const result = spawnSync21(executable, args, {
23981
24025
  cwd,
23982
24026
  encoding: "utf8",
@@ -24016,7 +24060,7 @@ var capabilitiesFor = (descriptor, observed = {}) => descriptor.capabilities.map
24016
24060
  // packages/workit-core/src/hooks/context.ts
24017
24061
  import { createHash as createHash16 } from "node:crypto";
24018
24062
  import fs22 from "node:fs";
24019
- import path32 from "node:path";
24063
+ import path33 from "node:path";
24020
24064
  var MIGRATION_PENDING_NOTE = "workit migration pending — run `workit task status`";
24021
24065
  var migrationPending = (result) => !result.ok && result.code === "needs_input" && (result.error ?? "").startsWith(MIGRATION_PENDING);
24022
24066
  var boundTo = (entry, session) => entry.sessions.some((item) => item.host === session.host && item.handle === session.handle);
@@ -24104,7 +24148,7 @@ function entryCompactContext(store, entry, session, context) {
24104
24148
  current: () => recentSignal(store.root)
24105
24149
  };
24106
24150
  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)] : []));
24151
+ const files = (task?.data.decisions ?? []).flatMap((decision) => decision.data.binding.contentRefs.flatMap((ref) => ref.kind === "file" ? [path33.resolve(store.root, ref.path)] : []));
24108
24152
  const observedFiles = filesKey(files);
24109
24153
  const compact = compactContext(store, context, entry?.id ?? null, freshness, origin && { origin: origin.origin, taskId: origin.entry.id });
24110
24154
  if (!compact.ok || !compact.data)
@@ -24163,17 +24207,17 @@ ${options.addendum}` : ""}
24163
24207
  </workit-contract>`;
24164
24208
  };
24165
24209
  var checkoutAt = (cwd) => {
24166
- for (let dir = path32.resolve(cwd);; dir = path32.dirname(dir)) {
24167
- const dotGit = path32.join(dir, ".git");
24210
+ for (let dir = path33.resolve(cwd);; dir = path33.dirname(dir)) {
24211
+ const dotGit = path33.join(dir, ".git");
24168
24212
  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();
24213
+ const admin = fs22.statSync(dotGit).isFile() ? path33.resolve(dir, /^gitdir:\s*(.+)$/mu.exec(fs22.readFileSync(dotGit, "utf8"))?.[1]?.trim() ?? "") : dotGit;
24214
+ const head = fs22.readFileSync(path33.join(admin, "HEAD"), "utf8").trim();
24171
24215
  return {
24172
24216
  root: dir,
24173
24217
  branch: /^ref: refs\/heads\/(.+)$/u.exec(head)?.[1] ?? null
24174
24218
  };
24175
24219
  }
24176
- if (path32.dirname(dir) === dir)
24220
+ if (path33.dirname(dir) === dir)
24177
24221
  return null;
24178
24222
  }
24179
24223
  };
@@ -24184,7 +24228,7 @@ var whereLine = (cwd) => {
24184
24228
  return null;
24185
24229
  const allowed = branchPolicySnapshotFor(cwd).namePolicy.allowed;
24186
24230
  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}`;
24231
+ const place = checkout.root === path33.resolve(cwd) ? "" : ` in ${checkout.root}`;
24188
24232
  return `cwd ${cwd}${place} on ${checkout.branch ?? "detached HEAD"}; branch kinds: ${kinds}`;
24189
24233
  } catch {
24190
24234
  return null;
@@ -24211,14 +24255,14 @@ var turnMarker = (input) => {
24211
24255
  if (location instanceof Error)
24212
24256
  return null;
24213
24257
  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`);
24258
+ return path33.join(location.dir, "hooks", `turn-${digestOf(session).slice(0, 32)}.json`);
24215
24259
  } catch {
24216
24260
  return null;
24217
24261
  }
24218
24262
  };
24219
24263
  var writeTurnDigest = (file, digest) => {
24220
24264
  try {
24221
- fs22.mkdirSync(path32.dirname(file), { recursive: true });
24265
+ fs22.mkdirSync(path33.dirname(file), { recursive: true });
24222
24266
  fs22.writeFileSync(file, `${JSON.stringify({ digest })}
24223
24267
  `);
24224
24268
  } catch {}
@@ -24233,7 +24277,7 @@ var pruneTurnDigests = (dir, now) => {
24233
24277
  for (const name of fs22.readdirSync(dir)) {
24234
24278
  if (!name.startsWith("turn-"))
24235
24279
  continue;
24236
- const file = path32.join(dir, name);
24280
+ const file = path33.join(dir, name);
24237
24281
  try {
24238
24282
  if (now - fs22.statSync(file).mtimeMs > TURN_TTL_MS)
24239
24283
  fs22.rmSync(file, { force: true });
@@ -24263,7 +24307,7 @@ var seedTurnContext = (input, descriptor, text = turnContextText(input, descript
24263
24307
  const file = turnMarker(input);
24264
24308
  if (!file)
24265
24309
  return;
24266
- pruneTurnDigests(path32.dirname(file), Date.now());
24310
+ pruneTurnDigests(path33.dirname(file), Date.now());
24267
24311
  if (text)
24268
24312
  writeTurnDigest(file, digestOf(text));
24269
24313
  else
@@ -24368,8 +24412,8 @@ var userOnlyWorkitCall = (command, dialect = "posix") => {
24368
24412
  };
24369
24413
  // packages/workit-core/src/core/heavy-rules.ts
24370
24414
  import fs23 from "node:fs";
24371
- import os7 from "node:os";
24372
- import path33 from "node:path";
24415
+ import os8 from "node:os";
24416
+ import path34 from "node:path";
24373
24417
  var EMPTY2 = () => ({ deny: [], allow: [] });
24374
24418
  var readText3 = (file) => {
24375
24419
  try {
@@ -24410,23 +24454,23 @@ function parseJsonc(text) {
24410
24454
  return JSON.parse(out.replace(/,(\s*[}\]])/gu, "$1"));
24411
24455
  }
24412
24456
  function gitTop(cwd) {
24413
- for (let dir = path33.resolve(cwd);; dir = path33.dirname(dir)) {
24414
- if (fs23.existsSync(path33.join(dir, ".git")))
24457
+ for (let dir = path34.resolve(cwd);; dir = path34.dirname(dir)) {
24458
+ if (fs23.existsSync(path34.join(dir, ".git")))
24415
24459
  return dir;
24416
- if (path33.dirname(dir) === dir)
24460
+ if (path34.dirname(dir) === dir)
24417
24461
  return null;
24418
24462
  }
24419
24463
  }
24420
24464
  var projectDirs = (cwd) => {
24421
24465
  const top = gitTop(cwd);
24422
24466
  const dirs = [];
24423
- for (let dir = path33.resolve(cwd);; dir = path33.dirname(dir)) {
24467
+ for (let dir = path34.resolve(cwd);; dir = path34.dirname(dir)) {
24424
24468
  dirs.push(dir);
24425
- if (!top || dir === top || path33.dirname(dir) === dir)
24469
+ if (!top || dir === top || path34.dirname(dir) === dir)
24426
24470
  return dirs;
24427
24471
  }
24428
24472
  };
24429
- var homeOf = (env) => env.HOME || os7.homedir();
24473
+ var homeOf = (env) => env.HOME || os8.homedir();
24430
24474
  var CLAUDE_MANAGED = {
24431
24475
  linux: "/etc/claude-code/managed-settings.json",
24432
24476
  darwin: "/Library/Application Support/ClaudeCode/managed-settings.json",
@@ -24434,12 +24478,12 @@ var CLAUDE_MANAGED = {
24434
24478
  };
24435
24479
  function claudeSettingsFiles(cwd, env, platform = process.platform) {
24436
24480
  const project = env.CLAUDE_PROJECT_DIR || gitTop(cwd) || cwd;
24437
- const user = env.CLAUDE_CONFIG_DIR || path33.join(homeOf(env), ".claude");
24481
+ const user = env.CLAUDE_CONFIG_DIR || path34.join(homeOf(env), ".claude");
24438
24482
  return [
24439
24483
  ...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")
24484
+ path34.join(user, "settings.json"),
24485
+ path34.join(project, ".claude", "settings.json"),
24486
+ path34.join(project, ".claude", "settings.local.json")
24443
24487
  ];
24444
24488
  }
24445
24489
  var bashPattern = (entry) => {
@@ -24529,10 +24573,10 @@ var opencodeConfig = (value, rules) => {
24529
24573
  function opencodeRules(cwd, env = process.env) {
24530
24574
  const rules = EMPTY2();
24531
24575
  try {
24532
- const config = env.XDG_CONFIG_HOME || path33.join(homeOf(env), ".config");
24576
+ const config = env.XDG_CONFIG_HOME || path34.join(homeOf(env), ".config");
24533
24577
  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)])),
24578
+ ...OPENCODE_NAMES.map((name) => path34.join(config, "opencode", name)),
24579
+ ...projectDirs(cwd).flatMap((dir) => OPENCODE_NAMES.flatMap((name) => [path34.join(dir, name), path34.join(dir, ".opencode", name)])),
24536
24580
  ...env.OPENCODE_CONFIG ? [env.OPENCODE_CONFIG] : []
24537
24581
  ];
24538
24582
  for (const file of files) {
@@ -24576,9 +24620,9 @@ var codexRule = (body) => {
24576
24620
  function codexRules(cwd, env = process.env) {
24577
24621
  const rules = EMPTY2();
24578
24622
  try {
24579
- const home = env.CODEX_HOME || path33.join(homeOf(env), ".codex");
24623
+ const home = env.CODEX_HOME || path34.join(homeOf(env), ".codex");
24580
24624
  const top = gitTop(cwd) ?? cwd;
24581
- for (const dir of [path33.join(home, "rules"), path33.join(top, ".codex", "rules")]) {
24625
+ for (const dir of [path34.join(home, "rules"), path34.join(top, ".codex", "rules")]) {
24582
24626
  let files;
24583
24627
  try {
24584
24628
  files = fs23.readdirSync(dir).filter((name) => name.endsWith(".rules"));
@@ -24588,7 +24632,7 @@ function codexRules(cwd, env = process.env) {
24588
24632
  return "unreadable";
24589
24633
  }
24590
24634
  for (const name of files) {
24591
- const text = readText3(path33.join(dir, name)) ?? "";
24635
+ const text = readText3(path34.join(dir, name)) ?? "";
24592
24636
  for (const part of text.split(/\bprefix_rule\s*\(/u).slice(1)) {
24593
24637
  const rule = codexRule(part);
24594
24638
  if (!rule)
@@ -24607,8 +24651,8 @@ function cursorRules(cwd, env = process.env) {
24607
24651
  try {
24608
24652
  const top = gitTop(cwd) ?? cwd;
24609
24653
  for (const file of [
24610
- path33.join(homeOf(env), ".cursor", "cli-config.json"),
24611
- path33.join(top, ".cursor", "cli.json")
24654
+ path34.join(homeOf(env), ".cursor", "cli-config.json"),
24655
+ path34.join(top, ".cursor", "cli.json")
24612
24656
  ]) {
24613
24657
  const text = readText3(file);
24614
24658
  if (text === null)
@@ -24683,10 +24727,10 @@ function wrapAllowed(read, words, command, options = {}) {
24683
24727
 
24684
24728
  // packages/workit-core/src/core/heavy.ts
24685
24729
  import fs24 from "node:fs";
24686
- import path34 from "node:path";
24730
+ import path35 from "node:path";
24687
24731
  var stateDir2 = (env, platform = process.platform) => stateDir(env, platform);
24688
24732
  var HEAVY_COMMANDS_FILE = "heavy-commands.json";
24689
- var heavyCommandsFile = (env) => path34.join(stateDir2(env), HEAVY_COMMANDS_FILE);
24733
+ var heavyCommandsFile = (env) => path35.join(stateDir2(env), HEAVY_COMMANDS_FILE);
24690
24734
  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
24735
  var INFO_FLAGS = new Set(["--version", "-v", "-V", "--help", "-h", "help", "version"]);
24692
24736
  var WATCH_FLAG = /^(?:--watch(?:All)?(?:=.*)?|-w|--serve)$/u;
@@ -24961,7 +25005,7 @@ function machinePatterns(env) {
24961
25005
  return isRecord5(value) ? stringList(value.patterns) : [];
24962
25006
  }
24963
25007
  function repoPatterns(cwd) {
24964
- return repoHeavyCommands(gitTop(cwd) ?? path34.resolve(cwd));
25008
+ return repoHeavyCommands(gitTop(cwd) ?? path35.resolve(cwd));
24965
25009
  }
24966
25010
  function heavyLines(lines, options) {
24967
25011
  const found = [];
@@ -25039,12 +25083,12 @@ function heavyPlan(command, options) {
25039
25083
  }
25040
25084
  function workitOnPath2(env = process.env) {
25041
25085
  const names = process.platform === "win32" ? ["workit.exe", "workit.cmd", "workit"] : ["workit"];
25042
- for (const dir of (env.PATH ?? "").split(path34.delimiter))
25086
+ for (const dir of (env.PATH ?? "").split(path35.delimiter))
25043
25087
  for (const name of names) {
25044
25088
  if (!dir)
25045
25089
  continue;
25046
25090
  try {
25047
- fs24.accessSync(path34.join(dir, name), fs24.constants.X_OK);
25091
+ fs24.accessSync(path35.join(dir, name), fs24.constants.X_OK);
25048
25092
  return true;
25049
25093
  } catch {}
25050
25094
  }
@@ -25062,7 +25106,7 @@ function leaseRewrite(command) {
25062
25106
 
25063
25107
  // packages/workit-core/src/core/heavy-words.ts
25064
25108
  import fs25 from "node:fs";
25065
- import path35 from "node:path";
25109
+ import path36 from "node:path";
25066
25110
  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
25111
  var wordsOf = (command) => command.split(/[\s;&|()<>`'"]+/u).map((word) => (word.split(/[\\/]/u).at(-1) ?? "").toLowerCase().replace(/\.(?:exe|cmd|bat)$/u, "")).filter(Boolean);
25068
25112
  var stateDir3 = (env) => stateDir(env);
@@ -25075,15 +25119,15 @@ var readJson2 = (file) => {
25075
25119
  };
25076
25120
  var patternWords = (cwd, env) => {
25077
25121
  const patterns = [];
25078
- const machine = readJson2(path35.join(stateDir3(env), "heavy-commands.json"));
25122
+ const machine = readJson2(path36.join(stateDir3(env), "heavy-commands.json"));
25079
25123
  if (Array.isArray(machine?.patterns))
25080
25124
  patterns.push(...machine.patterns);
25081
- for (let dir = path35.resolve(cwd);; dir = path35.dirname(dir)) {
25082
- if (fs25.existsSync(path35.join(dir, ".git"))) {
25125
+ for (let dir = path36.resolve(cwd);; dir = path36.dirname(dir)) {
25126
+ if (fs25.existsSync(path36.join(dir, ".git"))) {
25083
25127
  patterns.push(...repoHeavyCommands(dir));
25084
25128
  break;
25085
25129
  }
25086
- if (path35.dirname(dir) === dir)
25130
+ if (path36.dirname(dir) === dir)
25087
25131
  break;
25088
25132
  }
25089
25133
  const words = new Set;
@@ -25157,16 +25201,16 @@ var splitDenial = (plan) => ({
25157
25201
  unblock: plan.unblock
25158
25202
  });
25159
25203
  // 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";
25204
+ import { existsSync as existsSync12, realpathSync as realpathSync9, statSync as statSync3 } from "node:fs";
25205
+ import os10 from "node:os";
25206
+ import path38 from "node:path";
25163
25207
 
25164
25208
  // packages/workit-core/src/core/live-session.ts
25165
25209
  import { spawnSync as spawnSync22 } from "node:child_process";
25166
25210
  import { createHash as createHash17 } from "node:crypto";
25167
25211
  import fs26 from "node:fs";
25168
- import os8 from "node:os";
25169
- import path36 from "node:path";
25212
+ import os9 from "node:os";
25213
+ import path37 from "node:path";
25170
25214
  var LIVE_SESSION_TTL_MS = 15 * 60000;
25171
25215
  var HEARTBEAT_EVERY_MS = 30000;
25172
25216
  var liveProbe = {
@@ -25240,15 +25284,15 @@ var liveOwner = (input, transport, env = process.env) => {
25240
25284
  };
25241
25285
  };
25242
25286
  var checkoutOf = (target) => {
25243
- let dir = path36.resolve(target);
25244
- while (!fs26.existsSync(dir) && path36.dirname(dir) !== dir)
25245
- dir = path36.dirname(dir);
25287
+ let dir = path37.resolve(target);
25288
+ while (!fs26.existsSync(dir) && path37.dirname(dir) !== dir)
25289
+ dir = path37.dirname(dir);
25246
25290
  if (fs26.existsSync(dir) && !fs26.statSync(dir).isDirectory())
25247
- dir = path36.dirname(dir);
25248
- const parts = dir.split(path36.sep);
25291
+ dir = path37.dirname(dir);
25292
+ const parts = dir.split(path37.sep);
25249
25293
  const dotGit = parts.lastIndexOf(".git");
25250
25294
  if (dotGit > 0)
25251
- dir = parts.slice(0, dotGit).join(path36.sep) || path36.sep;
25295
+ dir = parts.slice(0, dotGit).join(path37.sep) || path37.sep;
25252
25296
  const location = resolveStore(dir);
25253
25297
  if (location instanceof Error || !location.shared || !location.top)
25254
25298
  return null;
@@ -25258,9 +25302,9 @@ var checkoutOf = (target) => {
25258
25302
  } catch {}
25259
25303
  return top;
25260
25304
  };
25261
- var markerFile2 = (top) => path36.join(resolveStateDir(), "live-sessions", `${createHash17("sha256").update(checkoutKey(top)).digest("hex").slice(0, 32)}.json`);
25305
+ var markerFile2 = (top) => path37.join(resolveStateDir(), "live-sessions", `${createHash17("sha256").update(checkoutKey(top)).digest("hex").slice(0, 32)}.json`);
25262
25306
  var checkoutKey = (top, platform = process.platform) => {
25263
- let key = path36.resolve(top);
25307
+ let key = path37.resolve(top);
25264
25308
  try {
25265
25309
  key = fs26.realpathSync.native(key);
25266
25310
  } catch {}
@@ -25291,7 +25335,7 @@ var isLive = (marker, deps) => {
25291
25335
  const age = ageOf2(marker, deps.now ?? new Date);
25292
25336
  if (age > (deps.ttlMs ?? LIVE_SESSION_TTL_MS))
25293
25337
  return false;
25294
- if (marker.machine !== (deps.machine ?? os8.hostname()) || marker.pid === null)
25338
+ if (marker.machine !== (deps.machine ?? os9.hostname()) || marker.pid === null)
25295
25339
  return true;
25296
25340
  if (!(deps.alive ?? processAlive)(marker.pid))
25297
25341
  return false;
@@ -25320,7 +25364,7 @@ var liveConflict = (target, owner, deps = {}) => {
25320
25364
  const marker = readMarker(file);
25321
25365
  if (!marker || sameLead(marker, owner) || !isLive(marker, deps))
25322
25366
  return null;
25323
- if (sameOwner(marker, owner, deps.machine ?? os8.hostname()))
25367
+ if (sameOwner(marker, owner, deps.machine ?? os9.hostname()))
25324
25368
  return null;
25325
25369
  return { marker, file, ageMs: ageOf2(marker, deps.now ?? new Date), checkout };
25326
25370
  } catch {
@@ -25334,7 +25378,7 @@ var claimLiveSession = (target, owner, deps = {}) => {
25334
25378
  return;
25335
25379
  const file = markerFile2(checkout);
25336
25380
  const now = deps.now ?? new Date;
25337
- const machine = deps.machine ?? os8.hostname();
25381
+ const machine = deps.machine ?? os9.hostname();
25338
25382
  const current = readMarker(file);
25339
25383
  if (current) {
25340
25384
  const age = ageOf2(current, now);
@@ -25355,7 +25399,7 @@ var claimLiveSession = (target, owner, deps = {}) => {
25355
25399
  checkout,
25356
25400
  heartbeatAt: now.toISOString()
25357
25401
  };
25358
- fs26.mkdirSync(path36.dirname(file), { recursive: true });
25402
+ fs26.mkdirSync(path37.dirname(file), { recursive: true });
25359
25403
  const temp = `${file}.${process.pid}.tmp`;
25360
25404
  fs26.writeFileSync(temp, JSON.stringify(marker));
25361
25405
  fs26.renameSync(temp, file);
@@ -25367,22 +25411,22 @@ var NONE3 = { kind: "none" };
25367
25411
  var CASE_INSENSITIVE = process.platform === "darwin" || process.platform === "win32";
25368
25412
  var canonical3 = (file) => {
25369
25413
  let rest = "";
25370
- for (let dir = path37.resolve(file);; dir = path37.dirname(dir)) {
25414
+ for (let dir = path38.resolve(file);; dir = path38.dirname(dir)) {
25371
25415
  try {
25372
- return path37.join(realpathSync8.native(dir), rest);
25416
+ return path38.join(realpathSync9.native(dir), rest);
25373
25417
  } catch {
25374
- if (path37.dirname(dir) === dir)
25375
- return path37.resolve(file);
25376
- rest = rest ? path37.join(path37.basename(dir), rest) : path37.basename(dir);
25418
+ if (path38.dirname(dir) === dir)
25419
+ return path38.resolve(file);
25420
+ rest = rest ? path38.join(path38.basename(dir), rest) : path38.basename(dir);
25377
25421
  }
25378
25422
  }
25379
25423
  };
25380
25424
  var exempt = (cwd, root, file, plans) => {
25381
25425
  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))
25426
+ const relative = path38.relative(fold(canonical3(root)), fold(canonical3(path38.resolve(cwd, file))));
25427
+ if (relative.startsWith("..") || path38.isAbsolute(relative))
25384
25428
  return true;
25385
- const posix = relative.split(path37.sep).join("/");
25429
+ const posix = relative.split(path38.sep).join("/");
25386
25430
  const segments = posix.split("/");
25387
25431
  return /\.mdx?$/i.test(posix) || segments[0] === "docs" || segments.includes("plans") || [...plans].some((plan) => fold(plan) === posix);
25388
25432
  };
@@ -25733,10 +25777,10 @@ var linkSources = (args, at) => {
25733
25777
  const sources = names.filter((name, index) => into >= 0 ? name !== dest : index < names.length - 1 || names.length === 1);
25734
25778
  const target = dest === undefined ? null : at(dest);
25735
25779
  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);
25780
+ const base = target === null ? null : into >= 0 || sources.length > 1 || existsSync12(target) || /[\\/]$/.test(dest ?? "") ? target : path38.dirname(target);
25737
25781
  return sources.flatMap((source) => {
25738
- if (symbolic && base !== null && !path37.isAbsolute(homeExpanded(source)))
25739
- return [path37.resolve(base, source)];
25782
+ if (symbolic && base !== null && !path38.isAbsolute(homeExpanded(source)))
25783
+ return [path38.resolve(base, source)];
25740
25784
  const resolved = at(source);
25741
25785
  return resolved ? [resolved] : [];
25742
25786
  });
@@ -25765,7 +25809,7 @@ var shellWrites = (command, depth = 0) => {
25765
25809
  return { writes: true, targets: unknown ? null : targets };
25766
25810
  };
25767
25811
  var cache3 = new Map;
25768
- var planKeyOf = (root, plans) => [...plans].map((file) => fileSignature(path37.resolve(root, file)) ?? "-").join("\x00");
25812
+ var planKeyOf = (root, plans) => [...plans].map((file) => fileSignature(path38.resolve(root, file)) ?? "-").join("\x00");
25769
25813
  var gateFor = (cwd) => {
25770
25814
  const store = new TaskStore(cwd);
25771
25815
  const listed = store.listTaskIndex();
@@ -25845,13 +25889,13 @@ var gitMutationDirs = (cwd, command, dialect) => {
25845
25889
  return [];
25846
25890
  if (sub === "stash" && ["list", "show"].includes(rest[0] ?? ""))
25847
25891
  return [];
25848
- return [path37.resolve(cwd, invocation.dir ?? ".")];
25892
+ return [path38.resolve(cwd, invocation.dir ?? ".")];
25849
25893
  });
25850
25894
  };
25851
25895
  var CD2 = new Set(["cd", "chdir", "set-location", "sl"]);
25852
25896
  var PUSHD2 = new Set(["pushd", "push-location"]);
25853
25897
  var POPD2 = new Set(["popd", "pop-location"]);
25854
- var UNKNOWN_DIR = path37.resolve(path37.parse(process.cwd()).root, ".workit-unknown-dir");
25898
+ var UNKNOWN_DIR = path38.resolve(path38.parse(process.cwd()).root, ".workit-unknown-dir");
25855
25899
  var cdInto = (dir, words, strict = false, vars = new Map) => {
25856
25900
  const lost = strict ? UNKNOWN_DIR : undefined;
25857
25901
  const found = words.slice(1).find((word) => !word.startsWith("-") || word === "-");
@@ -25861,7 +25905,7 @@ var cdInto = (dir, words, strict = false, vars = new Map) => {
25861
25905
  return lost;
25862
25906
  if (dir === undefined)
25863
25907
  return lost;
25864
- return target === undefined ? os9.homedir() : path37.resolve(dir, target);
25908
+ return target === undefined ? os10.homedir() : path38.resolve(dir, target);
25865
25909
  };
25866
25910
  var quoteWord2 = (word) => /^[\w@%+=:,./-]+$/.test(word) ? word : `'${word.replaceAll("'", "'\\''")}'`;
25867
25911
  var expandVars = (text, vars) => vars.size === 0 || !text.includes("$") ? text : text.replace(/\$(?:(\w+)|\{(\w+)\})/g, (whole, bare, braced) => {
@@ -25995,7 +26039,7 @@ var untrustedVars = (segments) => {
25995
26039
  }
25996
26040
  return { all, names };
25997
26041
  };
25998
- var UNKNOWN_VAR = path37.resolve(path37.parse(process.cwd()).root, ".workit-unknown-var");
26042
+ var UNKNOWN_VAR = path38.resolve(path38.parse(process.cwd()).root, ".workit-unknown-var");
25999
26043
  var REFERENCE = /\$\{(\w+)[^}]*\}|\$(\w+)|\$\([^)]*\)?|`[^`]*`?/g;
26000
26044
  var unresolvedRefs = (text) => [
26001
26045
  ...new Set([...text.matchAll(REFERENCE)].map((match) => {
@@ -26005,7 +26049,7 @@ var unresolvedRefs = (text) => [
26005
26049
  ];
26006
26050
  var unknownVarTarget = (text) => {
26007
26051
  const refs = unresolvedRefs(text);
26008
- return path37.join(UNKNOWN_VAR, (refs.length > 0 ? refs : [text]).map(encodeURIComponent).join("+"));
26052
+ return path38.join(UNKNOWN_VAR, (refs.length > 0 ? refs : [text]).map(encodeURIComponent).join("+"));
26009
26053
  };
26010
26054
  var applyOperator = (value, operator) => {
26011
26055
  if (operator === "")
@@ -26063,18 +26107,18 @@ var mktempPath = (value, dir) => {
26063
26107
  template = arg;
26064
26108
  }
26065
26109
  if (base === null && (temp || template === undefined))
26066
- base = os9.tmpdir();
26110
+ base = os10.tmpdir();
26067
26111
  const name = homeExpanded(template ?? "tmp.XXXXXXXXXX");
26068
- if (path37.isAbsolute(name))
26112
+ if (path38.isAbsolute(name))
26069
26113
  return name;
26070
26114
  const from = base === null ? dir : homeExpanded(base);
26071
- if (from === undefined || !path37.isAbsolute(from) && dir === undefined)
26115
+ if (from === undefined || !path38.isAbsolute(from) && dir === undefined)
26072
26116
  return null;
26073
- return path37.resolve(dir ?? from, from, name);
26117
+ return path38.resolve(dir ?? from, from, name);
26074
26118
  };
26075
26119
  var homeExpanded = (file) => {
26076
26120
  const match = /^(?:~|\$HOME|\$\{HOME\})(?=\/|$)/.exec(file);
26077
- return match ? (process.env.HOME || os9.homedir()) + file.slice(match[0].length) : file;
26121
+ return match ? (process.env.HOME || os10.homedir()) + file.slice(match[0].length) : file;
26078
26122
  };
26079
26123
  var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherited = new Map) => {
26080
26124
  const targets = [];
@@ -26090,9 +26134,9 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
26090
26134
  const home = homeExpanded(text);
26091
26135
  if (strict && unresolvedRefs(home).length > 0)
26092
26136
  return [unknownVarTarget(home)];
26093
- if (path37.isAbsolute(home))
26137
+ if (path38.isAbsolute(home))
26094
26138
  return [home];
26095
- return base === undefined ? [] : [path37.resolve(base, home)];
26139
+ return base === undefined ? [] : [path38.resolve(base, home)];
26096
26140
  });
26097
26141
  const at = (file) => {
26098
26142
  const all = atAll(file);
@@ -26234,7 +26278,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
26234
26278
  const here = segment.unanalyzable ? DIR_TARGET : `${OPAQUE_TARGET}${encodeURIComponent(runner?.split(/[\\/]/).at(-1) ?? "a command")}`;
26235
26279
  for (const file of opaque ?? [])
26236
26280
  for (const resolved of atAll(file))
26237
- targets.push(file === "." ? path37.join(resolved, here) : resolved);
26281
+ targets.push(file === "." ? path38.join(resolved, here) : resolved);
26238
26282
  const ln = words.findIndex((word) => /^ln$/i.test(word.split(/[\\/]/).at(-1) ?? ""));
26239
26283
  if (ln >= 0 && words.slice(0, ln).every((word) => PREFIXES2.has(word)))
26240
26284
  targets.push(...linkSources(words.slice(ln + 1), at));
@@ -26245,7 +26289,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
26245
26289
  const edits = editsOf(body);
26246
26290
  if (edits === null) {
26247
26291
  if (dir !== undefined)
26248
- targets.push(path37.join(dir, DIR_TARGET));
26292
+ targets.push(path38.join(dir, DIR_TARGET));
26249
26293
  } else
26250
26294
  for (const file of edits)
26251
26295
  targets.push(...atAll(file));
@@ -26253,7 +26297,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
26253
26297
  for (const invocation of workitInvocations(body.map(quoteWord2).join(" "), "posix")) {
26254
26298
  const { at: runsIn, args } = workitCwd(dir, invocation, atAll);
26255
26299
  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)));
26300
+ targets.push(...runsIn.map((runs) => path38.join(runs, DIR_TARGET)));
26257
26301
  }
26258
26302
  }
26259
26303
  return targets;
@@ -26274,7 +26318,7 @@ var shellMutationTargets = (cwd, command, dialect = "posix", strict = false) =>
26274
26318
  try {
26275
26319
  return [
26276
26320
  ...segmentTargets(cwd, command, dialect, 0, strict),
26277
- ...gitMutationDirs(cwd, command, dialect).map((dir) => path37.join(dir, DIR_TARGET))
26321
+ ...gitMutationDirs(cwd, command, dialect).map((dir) => path38.join(dir, DIR_TARGET))
26278
26322
  ];
26279
26323
  } catch {
26280
26324
  return [];
@@ -26311,7 +26355,7 @@ var liveDeny = ({ marker, checkout, ageMs, file }) => {
26311
26355
  var guarded = (targets) => {
26312
26356
  const seen = new Set;
26313
26357
  return targets.filter((target) => {
26314
- const dir = path37.dirname(target);
26358
+ const dir = path38.dirname(target);
26315
26359
  if (seen.has(dir))
26316
26360
  return false;
26317
26361
  seen.add(dir);
@@ -26332,7 +26376,7 @@ var claimAll = (owner, targets, deps) => {
26332
26376
  for (const target of guarded(targets))
26333
26377
  claimLiveSession(target, owner, deps);
26334
26378
  };
26335
- var liveTargets = (cwd, paths) => paths?.length ? paths.map((file) => path37.resolve(cwd, file)) : [path37.join(cwd, DIR_TARGET)];
26379
+ var liveTargets = (cwd, paths) => paths?.length ? paths.map((file) => path38.resolve(cwd, file)) : [path38.join(cwd, DIR_TARGET)];
26336
26380
  var issuedTarget = (cwd, targets) => {
26337
26381
  const state = resolveStateDir();
26338
26382
  const found = targets.find((target) => underIssued(state, cwd, homeExpanded(target), process.platform, canonical3));
@@ -26340,7 +26384,7 @@ var issuedTarget = (cwd, targets) => {
26340
26384
  };
26341
26385
  var underIssued = (state, cwd, target, platform = process.platform, real = (file) => file) => {
26342
26386
  const win = platform === "win32";
26343
- const p = win ? path37.win32 : path37.posix;
26387
+ const p = win ? path38.win32 : path38.posix;
26344
26388
  const fold = (value) => win || platform === "darwin" ? value.toLowerCase() : value;
26345
26389
  const named = win ? target.replace(/^\/([a-zA-Z])(?=\/|$)/, "$1:") : target;
26346
26390
  const relative = p.relative(fold(real(p.resolve(state))), fold(real(p.resolve(cwd, named))));
@@ -26434,10 +26478,10 @@ import { spawnSync as spawnSync23 } from "node:child_process";
26434
26478
 
26435
26479
  // packages/workit-core/src/ci-waiter.ts
26436
26480
  import fs27 from "node:fs";
26437
- import path38 from "node:path";
26481
+ import path39 from "node:path";
26438
26482
  var waiterFile = (cwd, pr) => {
26439
26483
  const common = gitCommonDir(cwd);
26440
- return common ? path38.join(common, "workit", "ci-waits", `pr-${pr}.json`) : null;
26484
+ return common ? path39.join(common, "workit", "ci-waits", `pr-${pr}.json`) : null;
26441
26485
  };
26442
26486
  var pidAlive2 = (pid) => {
26443
26487
  if (!Number.isSafeInteger(pid) || pid <= 0)
@@ -26776,40 +26820,37 @@ var SKILL_HOST = {
26776
26820
  };
26777
26821
  var PROMPT_INTENTS = [
26778
26822
  [
26779
- "workit-debug",
26780
- /\b(flaky|regressed|(?:is|introduced) a regression|regression (?:in|after|since|from)|(?:is|are|got|looks) broken|debug (?:this|it|the|why)|fix (?:the|this|a) bug)\b/i
26781
- ],
26782
- [
26783
- "workit-continue",
26784
- /\b(pick up where|where (?:were|did) we|resume (?:the|this|my|our|work|where)|hand ?off)\b/i
26823
+ "debug",
26824
+ /\b(flaky|regressed|(is|introduced) a regression|regression (in|after|since|from)|(is|are|got|looks) broken|debug (this|it|the|why)|fix (the|this|a) bug)\b/i
26785
26825
  ],
26786
26826
  [
26787
- "workit-review",
26788
- /\b(blast radius|code review|review (?:the|this|my|PR|pr|#\d+|branch|diff|changes))\b/i
26827
+ "continue",
26828
+ /\b(pick up where|where (were|did) we|resume (the|this|my|our|work|where)|hand ?off)\b/i
26789
26829
  ],
26790
26830
  [
26791
- "workit-ship",
26792
- /\b(ship (?:it|this|the)|babysit|open (?:a|the) (?:PR|pr|MR|mr)(?=\s*$|\s+(?:for|to|on|with|and|against|into|from|after|once)\b|[.!,;])|merge (?:the|this|my) (?:PR|pr|MR|mr|branch)|(?:get|until|make) CI (?:is )?green)\b/i
26831
+ "review",
26832
+ /\b(blast radius|code review|review (the|this|my|PR|pr|#\d+|branch|diff|changes))\b/i
26793
26833
  ],
26794
- ["workit-bdd", /\b(BDD|TDD|acceptance criteria|Given\/When\/Then)(?![\w/])/],
26795
- ["workit-test-audit", /\b(test audit|audit the tests|tautolog\w*|weak tests)\b/i],
26796
- ["workit-deslop", /\b(deslop|slop|dead code)\b/i],
26797
26834
  [
26798
- "workit-fanout",
26799
- /\b(fan(?: |-)?out|parallelize|parallel agents|agent swarm|swarm of agents)\b/i
26835
+ "ship",
26836
+ /\b(ship (it|this|the)|babysit|open (a|the) (PR|pr|MR|mr)(?=\s*$|\s+(for|to|on|with|and|against|into|from|after|once)\b|[.!,;])|merge (the|this|my) (PR|pr|MR|mr|branch)|(get|until|make) CI (is )?green)\b/i
26800
26837
  ],
26801
- ["workit-verify-app", /\b(verify the app|smoke test|prove it works)\b/i],
26802
- ["workit-retro", /\b((?:a|the) retro(?![-\w]|\.\w)|retrospective)/i],
26803
- ["workit-architecture", /\b(deepen (?:the )?modules|architecture (?:review|pass|audit))\b/i],
26838
+ ["bdd", /\b(BDD|TDD|acceptance criteria|Given\/When\/Then)(?![\w/])/],
26839
+ ["test-audit", /\b(test audit|audit the tests|tautolog\w*|weak tests)\b/i],
26840
+ ["deslop", /\b(deslop|slop|dead code)\b/i],
26841
+ ["fanout", /\b(fan( |-)?out|parallelize|parallel agents|agent swarm|swarm of agents)\b/i],
26842
+ ["verify-app", /\b(verify the app|smoke test|prove it works)\b/i],
26843
+ ["retro", /\b((a|the) retro(?![-\w]|\.\w)|retrospective)/i],
26844
+ ["architecture", /\b(deepen (the )?modules|architecture (review|pass|audit))\b/i],
26804
26845
  [
26805
- "workit-shape",
26806
- /\b(brainstorm\w*|grill me|should we|let'?s plan|plan (?:out|how|the|a|for)|(?:write|draft) (?:a|the) spec)\b/i
26846
+ "shape",
26847
+ /\b(brainstorm\w*|grill me|should we|let'?s plan|plan (out|how|the|a|for)|(write|draft) (a|the) spec)\b/i
26807
26848
  ],
26808
26849
  [
26809
- "workit-implement",
26810
- /\b(implement (?:the|this|a|it)|add (?:a|the) feature|build (?:a|an|the) (?:new )?(?:feature|command|verb|page|endpoint|component|cli|tool))\b/i
26850
+ "implement",
26851
+ /\b(implement (the|this|a|it)|add (a|the) feature|build (a|an|the) (new )?(feature|command|verb|page|endpoint|component|cli|tool))\b/i
26811
26852
  ]
26812
- ];
26853
+ ].map(([name, pattern]) => [`workit-${name}`, pattern]);
26813
26854
  var workitSkillOf = (name) => {
26814
26855
  const bare = name.trim().replace(/^\//, "").toLowerCase();
26815
26856
  const alias = WORKIT_SKILL_ALIASES[bare];
@@ -26818,10 +26859,13 @@ var workitSkillOf = (name) => {
26818
26859
  const skill = bare.replace(/^workit:/, "workit-");
26819
26860
  return WORKIT_METHOD_SKILLS.includes(skill) ? skill : null;
26820
26861
  };
26862
+ var QUOTED = /```[\s\S]*?```|["`“][^"`”\n]*["`”]|\B'[^'\n]*'\B/g;
26863
+ var COMPLAINT = /\b(why \w+ you|you keep|stop \w+ing)\b.*?(?=\b(and|but)\b|[?.,;\n]|$)/gi;
26821
26864
  var promptTrigger = (prompt) => {
26822
- const text = prompt.replace(/```[\s\S]*?```/g, " ").slice(0, 4000);
26865
+ let asking = false;
26866
+ const text = prompt.slice(0, 4000).replace(QUOTED, " ").replace(COMPLAINT, (clause) => (asking ||= /ask|quest/i.test(clause), " "));
26823
26867
  for (const [skill, pattern] of PROMPT_INTENTS) {
26824
- const match = pattern.exec(text);
26868
+ const match = !(asking && skill === "workit-shape") && pattern.exec(text);
26825
26869
  if (match)
26826
26870
  return { skill, trigger: match[1] ?? match[0] };
26827
26871
  }
@@ -26839,24 +26883,12 @@ var loadedSkills = (cwd, session) => {
26839
26883
  };
26840
26884
  var SKILL_FILE = /(?:^|[\\/])(workit-[a-z-]+)[\\/]SKILL\.md$/;
26841
26885
  var skillFileIn = (file) => SKILL_FILE.exec(file)?.[1] ?? null;
26842
- var READERS = new Set([
26843
- "cat",
26844
- "sed",
26845
- "head",
26846
- "tail",
26847
- "less",
26848
- "more",
26849
- "bat",
26850
- "nl",
26851
- "get-content",
26852
- "gc",
26853
- "type"
26854
- ]);
26886
+ var READERS = new Set("cat sed head tail less more bat nl get-content gc type".split(" "));
26855
26887
  var skillReadIn = (command, dialect = "posix") => {
26856
26888
  for (const { words } of segmentsOf(command, dialect)) {
26857
26889
  if (!READERS.has((words[0]?.split(/[\\/]/).at(-1) ?? "").toLowerCase()))
26858
26890
  continue;
26859
- if (words.some((word) => /^(?:-i(?:\.\w+)?|--in-place(?:=.*)?)$/.test(word)))
26891
+ if (words.some((word) => /^(-i(\.\w+)?|--in-place(=.*)?)$/.test(word)))
26860
26892
  continue;
26861
26893
  for (const word of words.slice(1)) {
26862
26894
  const skill = skillFileIn(word);
@@ -26903,9 +26935,9 @@ var nudgeOnce = (input, session, skill, line) => {
26903
26935
  writeSessionMarker(file, { ...marker, nudged: [...marker.nudged, skill] });
26904
26936
  return line;
26905
26937
  };
26906
- var nudgeText = (input, skill, why) => USER_INVOKED.has(skill) ? `Workit: ${why} looks like ${skill} work, which the user starts; offer it (/${skill.replace(/^workit-/, "wk-")}) rather than loading it.` : `Workit: ${why} looks like ${skill} work; if it is, ${skillLoadWording(SKILL_HOST[input.host], skill)} first.`;
26938
+ var nudgeText = (input, skill, why) => `Workit: ${why} looks like ${skill} work${USER_INVOKED.has(skill) ? `, which the user starts; offer it (/${skill.replace(/^workit-/, "wk-")}) rather than loading it.` : `; if it is, ${skillLoadWording(SKILL_HOST[input.host], skill)} first.`}`;
26907
26939
  var promptLoads = (prompt) => /^\s*\/(?:skill:)?([\w:-]+)/.exec(prompt)?.[1] ?? /^\s*<skill name="([\w:-]+)"/.exec(prompt)?.[1] ?? /^\s*Load the (workit-[a-z-]+) skill with the skill tool\b/.exec(prompt)?.[1] ?? null;
26908
- var relayedMessage = (prompt) => /^\s*(?:Another Claude session sent a message\b|<agent-message\s+from=|\[SYSTEM NOTIFICATION\b|<task-notification>)/.test(prompt);
26940
+ var relayedMessage = (prompt) => /^\s*(Another Claude session sent a message\b|<agent-message\s+from=|\[SYSTEM NOTIFICATION\b|<task-notification>)/.test(prompt);
26909
26941
  function promptNudge(input, prompt) {
26910
26942
  try {
26911
26943
  const session = input.session.id;
@@ -26924,7 +26956,7 @@ function promptNudge(input, prompt) {
26924
26956
  return null;
26925
26957
  }
26926
26958
  }
26927
- var WORKIT_DELIVERY = /^(?:pr (?:create|merge)|ci wait|git push)\b/;
26959
+ var WORKIT_DELIVERY = /^(pr (create|merge)|ci wait|git push)\b/;
26928
26960
  var runsWorkitDelivery = (command, dialect) => workitInvocations(command, dialect).some((args) => !args.some((arg) => arg === "--help" || arg === "-h" || arg === "--dry-run") && WORKIT_DELIVERY.test(args.join(" ")));
26929
26961
  var isDeliveryCommand = (cwd, command, dialect = "posix") => rawDelivery(cwd, command, dialect) || runsWorkitDelivery(command, dialect) && inWorkitWorkspace(cwd);
26930
26962
  function shipNudge(input, command) {
@@ -26988,7 +27020,7 @@ var writePaths = (input) => {
26988
27020
  };
26989
27021
  // packages/workit-core/src/hooks/standing.ts
26990
27022
  import fs29 from "node:fs";
26991
- import path40 from "node:path";
27023
+ import path41 from "node:path";
26992
27024
 
26993
27025
  // packages/workit-core/src/hooks/hosts/claude-code.ts
26994
27026
  var CLAUDE_CODE_DESCRIPTOR = {
@@ -27460,40 +27492,40 @@ function neededChecks(lane, configured) {
27460
27492
  // packages/workit-core/src/hooks/worktree-confine.ts
27461
27493
  import { createHash as createHash18 } from "node:crypto";
27462
27494
  import fs28 from "node:fs";
27463
- import path39 from "node:path";
27495
+ import path40 from "node:path";
27464
27496
  var FANOUT_TOKEN_FILE = "workit-fanout-token";
27465
27497
  var NONE5 = { kind: "none" };
27466
27498
  var CASE_INSENSITIVE2 = process.platform === "darwin" || process.platform === "win32";
27467
27499
  var canonical4 = (file) => {
27468
27500
  let rest = "";
27469
- for (let dir = path39.resolve(file);; dir = path39.dirname(dir)) {
27501
+ for (let dir = path40.resolve(file);; dir = path40.dirname(dir)) {
27470
27502
  try {
27471
- return path39.join(fs28.realpathSync.native(dir), rest);
27503
+ return path40.join(fs28.realpathSync.native(dir), rest);
27472
27504
  } catch {
27473
- if (path39.dirname(dir) === dir)
27474
- return path39.resolve(file);
27475
- rest = rest ? path39.join(path39.basename(dir), rest) : path39.basename(dir);
27505
+ if (path40.dirname(dir) === dir)
27506
+ return path40.resolve(file);
27507
+ rest = rest ? path40.join(path40.basename(dir), rest) : path40.basename(dir);
27476
27508
  }
27477
27509
  }
27478
27510
  };
27479
27511
  var within = (child, parent) => {
27480
27512
  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);
27513
+ const relative = path40.relative(fold(parent), fold(child));
27514
+ return relative === "" || !relative.startsWith("..") && !path40.isAbsolute(relative);
27483
27515
  };
27484
27516
  var checkoutOf2 = (file) => {
27485
- for (let dir = canonical4(file);; dir = path39.dirname(dir)) {
27486
- const dotGit = path39.join(dir, ".git");
27517
+ for (let dir = canonical4(file);; dir = path40.dirname(dir)) {
27518
+ const dotGit = path40.join(dir, ".git");
27487
27519
  if (fs28.existsSync(dotGit)) {
27488
27520
  if (!fs28.statSync(dotGit).isFile())
27489
27521
  return { root: dir, workit: false };
27490
27522
  const admin = /^gitdir:\s*(.+)$/mu.exec(fs28.readFileSync(dotGit, "utf8"))?.[1]?.trim();
27491
27523
  return {
27492
27524
  root: dir,
27493
- workit: Boolean(admin) && fs28.existsSync(path39.join(path39.resolve(dir, admin), FANOUT_TOKEN_FILE))
27525
+ workit: Boolean(admin) && fs28.existsSync(path40.join(path40.resolve(dir, admin), FANOUT_TOKEN_FILE))
27494
27526
  };
27495
27527
  }
27496
- if (path39.dirname(dir) === dir)
27528
+ if (path40.dirname(dir) === dir)
27497
27529
  return null;
27498
27530
  }
27499
27531
  };
@@ -27505,8 +27537,8 @@ var workitWorktreeOf = (file) => {
27505
27537
  return null;
27506
27538
  }
27507
27539
  };
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`);
27540
+ var bindingDir = () => path40.join(resolveStateDir(), "worktree-bind");
27541
+ var bindingFile = (session, agentId) => path40.join(bindingDir(), `${createHash18("sha256").update(`${session}\x00${agentId}`).digest("hex").slice(0, 32)}.json`);
27510
27542
  var readBinding = (file) => {
27511
27543
  try {
27512
27544
  const value = JSON.parse(fs28.readFileSync(file, "utf8"));
@@ -27531,7 +27563,7 @@ var bind = (input, worktree) => {
27531
27563
  agentId,
27532
27564
  at: new Date().toISOString()
27533
27565
  };
27534
- fs28.mkdirSync(path39.dirname(file), { recursive: true });
27566
+ fs28.mkdirSync(path40.dirname(file), { recursive: true });
27535
27567
  fs28.writeFileSync(file, JSON.stringify(binding));
27536
27568
  try {
27537
27569
  if (inWorkitWorkspace(input.cwd))
@@ -27550,31 +27582,31 @@ var hostIsolated = (cwd, agentId) => {
27550
27582
  const checkout = checkoutOf2(cwd);
27551
27583
  if (!checkout)
27552
27584
  return false;
27553
- const dotGit = path39.join(checkout.root, ".git");
27585
+ const dotGit = path40.join(checkout.root, ".git");
27554
27586
  if (!fs28.statSync(dotGit).isFile())
27555
27587
  return false;
27556
27588
  const admin = /^gitdir:\s*(.+)$/mu.exec(fs28.readFileSync(dotGit, "utf8"))?.[1]?.trim();
27557
27589
  if (!admin)
27558
27590
  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)) !== "")
27591
+ const adminDir = path40.resolve(checkout.root, admin);
27592
+ const back = fs28.readFileSync(path40.join(adminDir, "gitdir"), "utf8").trim();
27593
+ if (path40.relative(canonical4(path40.resolve(adminDir, back)), canonical4(dotGit)) !== "")
27562
27594
  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) === "";
27595
+ const common = path40.join(adminDir, "commondir");
27596
+ const gitDir = fs28.existsSync(common) ? path40.resolve(adminDir, fs28.readFileSync(common, "utf8").trim()) : adminDir;
27597
+ const expected = path40.join(path40.dirname(canonical4(gitDir)), ".claude", "worktrees", `agent-${agentId}`);
27598
+ return path40.relative(canonical4(expected), checkout.root) === "";
27567
27599
  } catch {
27568
27600
  return false;
27569
27601
  }
27570
27602
  };
27571
27603
  var runnerAt = (target) => {
27572
- const base = path39.basename(target);
27604
+ const base = path40.basename(target);
27573
27605
  return base.startsWith(OPAQUE_TARGET) ? decodeURIComponent(base.slice(OPAQUE_TARGET.length)) : null;
27574
27606
  };
27575
27607
  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;
27608
+ const named = /^\.workit-(?:live-target$|runs-)/.test(path40.basename(target)) ? path40.dirname(target) : target;
27609
+ return path40.sep === "\\" ? named.replaceAll("/", "\\") : named;
27578
27610
  };
27579
27611
  var unboundDeny = (input, target) => {
27580
27612
  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 +27645,7 @@ var literalForm = (command, refs) => {
27613
27645
  };
27614
27646
  var unknownVarDeny = (input, worktree, targets, command) => {
27615
27647
  const refs = [
27616
- ...new Set(targets.flatMap((target) => path39.relative(UNKNOWN_VAR, path39.resolve(target)).split(path39.sep)[0].split("+").filter(Boolean).map(decodeURIComponent)))
27648
+ ...new Set(targets.flatMap((target) => path40.relative(UNKNOWN_VAR, path40.resolve(target)).split(path40.sep)[0].split("+").filter(Boolean).map(decodeURIComponent)))
27617
27649
  ];
27618
27650
  let text = command ?? "";
27619
27651
  const first = [];
@@ -27642,10 +27674,10 @@ function confineImplementer(input, targets, command) {
27642
27674
  try {
27643
27675
  if (!input.session.agentId || hostIsolated(input.cwd, input.session.agentId))
27644
27676
  return NONE5;
27645
- const unresolved = targets.filter((target) => within(path39.resolve(target), UNKNOWN_VAR));
27677
+ const unresolved = targets.filter((target) => within(path40.resolve(target), UNKNOWN_VAR));
27646
27678
  if (unresolved.length > 0)
27647
27679
  return unknownVarDeny(input, boundWorktree(input), unresolved, command);
27648
- if (targets.some((target) => within(path39.resolve(target), UNKNOWN_DIR)))
27680
+ if (targets.some((target) => within(path40.resolve(target), UNKNOWN_DIR)))
27649
27681
  return unknownDirDeny(input, boundWorktree(input));
27650
27682
  const bindings = canonical4(bindingDir());
27651
27683
  const judged = targets.map((named) => ({ named, real: canonical4(named) })).filter(({ real }) => within(real, bindings) || checkoutOf2(real) !== null);
@@ -27755,16 +27787,16 @@ var RUNS = /^(?:sh|bash|zsh|dash|ksh|mksh|ash|python[\d.]*|node|bun|deno|ruby|pe
27755
27787
  var INLINE = /^-[a-zA-Z]*[ceEpm]$|^--(?:eval|print|test|version|help)$|^-[hvV]$/;
27756
27788
  var VALUED = /^-[WXIrC]$|^--(?:require|import|loader|conditions|input-type)$/;
27757
27789
  var commonDir = (root) => {
27758
- const dotGit = path39.join(root, ".git");
27790
+ const dotGit = path40.join(root, ".git");
27759
27791
  if (!fs28.statSync(dotGit).isFile())
27760
27792
  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);
27793
+ const admin = path40.resolve(root, /^gitdir:\s*(.+)$/mu.exec(fs28.readFileSync(dotGit, "utf8"))?.[1]?.trim() ?? "");
27794
+ const common = path40.join(admin, "commondir");
27795
+ return canonical4(fs28.existsSync(common) ? path40.resolve(admin, fs28.readFileSync(common, "utf8").trim()) : admin);
27764
27796
  };
27765
27797
  var inScratch = (real, repo) => {
27766
27798
  const checkout = checkoutOf2(real);
27767
- return checkout !== null && within(real, path39.join(checkout.root, SCRATCH)) && (repo === null || commonDir(checkout.root) === repo);
27799
+ return checkout !== null && within(real, path40.join(checkout.root, SCRATCH)) && (repo === null || commonDir(checkout.root) === repo);
27768
27800
  };
27769
27801
  var JUDGE_VERBS = {
27770
27802
  check: true,
@@ -27793,7 +27825,7 @@ var judgeVerbRefused = (args) => {
27793
27825
  var CLI_RUNNERS = /^(?:npx|bunx|pnpx|npm|pnpm|yarn|bun|node|nodejs|deno|tsx|ts-node)$/;
27794
27826
  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
27827
  var workitCalls = (command, depth = 0, aliases = new Map) => depth > 4 ? [] : commandLines(command).flatMap((words) => {
27796
- const name = path39.basename(words[0] ?? "").toLowerCase();
27828
+ const name = path40.basename(words[0] ?? "").toLowerCase();
27797
27829
  if (name === "alias")
27798
27830
  return words.flatMap((word) => {
27799
27831
  const set = /^([\w-]+)=(.*)$/s.exec(word);
@@ -27823,11 +27855,11 @@ var judgeRefusal = (command, fed, depth = 0) => {
27823
27855
  return why;
27824
27856
  }
27825
27857
  const { words } = segment;
27826
- const runs = (word = "") => RUNS.test(path39.basename(word).toLowerCase());
27858
+ const runs = (word = "") => RUNS.test(path40.basename(word).toLowerCase());
27827
27859
  let at = 0;
27828
27860
  while (at < words.length && (LEADS.test(words[at]) || /^-\w$/.test(words[at - 1] ?? "") && !runs(words[at])))
27829
27861
  at++;
27830
- const name = path39.basename(words[at] ?? "").toLowerCase();
27862
+ const name = path40.basename(words[at] ?? "").toLowerCase();
27831
27863
  const args = words.slice(at + 1);
27832
27864
  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
27865
  if (/^(?:cd|chdir|pushd|popd)$/.test(name))
@@ -27905,7 +27937,7 @@ var substitutingHeredoc = (command) => {
27905
27937
  var judgeDeny = (input, what) => {
27906
27938
  const role = input.session.agentType?.endsWith("reviewer") ? "reviewer" : "verifier";
27907
27939
  const root = checkoutOf2(input.cwd)?.root;
27908
- const scratch = root ? path39.join(root, SCRATCH) : `${SCRATCH}/ at the root of the checkout you judge`;
27940
+ const scratch = root ? path40.join(root, SCRATCH) : `${SCRATCH}/ at the root of the checkout you judge`;
27909
27941
  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
27942
  return {
27911
27943
  kind: "deny",
@@ -27920,7 +27952,7 @@ function confineJudge(input, targets) {
27920
27952
  const judged = checkoutOf2(input.cwd);
27921
27953
  const repo = judged ? commonDir(judged.root) : null;
27922
27954
  for (const target of targets) {
27923
- const resolved = path39.resolve(target);
27955
+ const resolved = path40.resolve(target);
27924
27956
  if (within(resolved, UNKNOWN_VAR) || within(resolved, UNKNOWN_DIR))
27925
27957
  return judgeDeny(input, "it writes to a path Workit cannot resolve (a variable, a command substitution or `cd -`): spell the path out");
27926
27958
  if (inScratch(canonical4(target), repo))
@@ -27951,7 +27983,7 @@ function confineJudgeShell(input, command, dialect = "posix") {
27951
27983
  let git = [];
27952
27984
  try {
27953
27985
  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`)
27986
+ path40.join(dir === undefined ? UNKNOWN_DIR : path40.resolve(input.cwd, dir ?? "."), `${OPAQUE_TARGET}git`)
27955
27987
  ] : []);
27956
27988
  } catch {}
27957
27989
  return confineJudge(input, [
@@ -27996,7 +28028,7 @@ var judgeChecksLine = (cwd) => {
27996
28028
 
27997
28029
  // packages/workit-core/src/hooks/standing.ts
27998
28030
  var readPlans = (store) => {
27999
- const dir = path40.join(store, "fanouts");
28031
+ const dir = path41.join(store, "fanouts");
28000
28032
  let names;
28001
28033
  try {
28002
28034
  names = fs29.readdirSync(dir).filter((name) => name.endsWith(".json"));
@@ -28006,7 +28038,7 @@ var readPlans = (store) => {
28006
28038
  const plans = [];
28007
28039
  for (const name of names) {
28008
28040
  try {
28009
- const raw = JSON.parse(fs29.readFileSync(path40.join(dir, name), "utf8"));
28041
+ const raw = JSON.parse(fs29.readFileSync(path41.join(dir, name), "utf8"));
28010
28042
  if (typeof raw.name !== "string" || !Array.isArray(raw.slices))
28011
28043
  continue;
28012
28044
  const texts = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string" && item !== "") : [];
@@ -28149,7 +28181,7 @@ var cwdRewrite = (command) => {
28149
28181
  const rest = match?.[2];
28150
28182
  if (!dir || !rest || dir.startsWith("-"))
28151
28183
  return null;
28152
- if (/[&;<>`\n]/u.test(rest.replaceAll("2>&1", "").replaceAll(/'[^']*'|"(?:[^"\\]|\\.)*"/gu, "")))
28184
+ if (/[&;<>`\n]/u.test(rest.replaceAll("2>&1", "").replaceAll(/'[^']*'|"([^"\\]|\\.)*"/gu, "")))
28153
28185
  return null;
28154
28186
  const segments = segmentsOf(rest);
28155
28187
  const [head, ...filters] = segments;
@@ -28162,8 +28194,10 @@ var cwdRewrite = (command) => {
28162
28194
  if (!filters.every((s) => FILTERS.has(s.words[0] ?? "") && stdinOnly(s.words)))
28163
28195
  return null;
28164
28196
  const at = head.words.indexOf("--cwd");
28165
- if (at >= 0)
28166
- return head.words[at + 1] === dir.replace(/^(['"])(.*)\1$/u, "$2") ? rest : null;
28197
+ if (at >= 0) {
28198
+ const bare = dir.replace(/^(['"])(.*)\1$/u, "$2");
28199
+ return bare[0] === "/" && head.words[at + 1] === bare ? rest : null;
28200
+ }
28167
28201
  if (head.words.some((w) => w.startsWith("--cwd=")))
28168
28202
  return null;
28169
28203
  const args = rest.slice("workit".length).trimStart();
@@ -28183,7 +28217,7 @@ var verbFirst = (command) => {
28183
28217
  return null;
28184
28218
  return `${lead} ${verb}${globals}${command.slice(whole.length)}`;
28185
28219
  };
28186
- var MUTATING_GIT2 = /^git(?: -\S+| -[Cc] \S+)* (?:commit|push|add|switch|checkout|merge|rebase|reset|cherry-pick|revert|branch .*(?:-[dDmM]|--delete|--move)\b|tag (?!-l\b|--list)|stash(?! (?:list|show)\b))/u;
28220
+ var MUTATING_GIT2 = /^git( -\S+| -[Cc] \S+)* (commit|push|add|switch|checkout|merge|rebase|reset|cherry-pick|revert|branch .*(-[dDmM]|--delete|--move)\b|tag (?!-l\b|--list)|stash(?! (list|show)\b))/u;
28187
28221
  var cdWorkitSplit = (command) => {
28188
28222
  const match = COMPOUND2.exec(command);
28189
28223
  const dir = match?.[1];
@@ -28205,8 +28239,8 @@ var cdWorkitSplit = (command) => {
28205
28239
 
28206
28240
  // packages/workit-core/src/hooks/model-limit.ts
28207
28241
  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";
28242
+ import os11 from "node:os";
28243
+ import path42 from "node:path";
28210
28244
  var MONTHS = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
28211
28245
  var WEEKDAYS = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"];
28212
28246
  var TIME_WORD = String.raw`(?:\d|(?:in|at|on|later|tomorrow|soon)\b|(?:${[...WEEKDAYS, ...MONTHS].join("|")})[a-z]*\b)`;
@@ -28404,17 +28438,17 @@ var firstPrompt = (file) => {
28404
28438
  var claudeProjectSlug = (cwd) => cwd.replace(/[^A-Za-z0-9]/gu, "-");
28405
28439
  var listDir = (dir) => {
28406
28440
  try {
28407
- return readdirSync4(dir).map((name) => path41.join(dir, name));
28441
+ return readdirSync4(dir).map((name) => path42.join(dir, name));
28408
28442
  } catch {
28409
28443
  return [];
28410
28444
  }
28411
28445
  };
28412
28446
  var SCAN_MS = 30 * 60000;
28413
28447
  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));
28448
+ const projects = path42.join(env.CLAUDE_CONFIG_DIR || path42.join(env.HOME || os11.homedir(), ".claude"), "projects");
28449
+ const project = path42.join(projects, claudeProjectSlug(cwd));
28416
28450
  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 })));
28451
+ 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
28452
  for (const { file, worker } of files)
28419
28453
  try {
28420
28454
  const stat = statSync4(file);
@@ -28429,7 +28463,7 @@ var scanClaudeTranscripts = (cwd, env, now = new Date) => {
28429
28463
  if (!seen)
28430
28464
  continue;
28431
28465
  notes.push(worker ? redispatchNote(seen, {
28432
- label: `worker ${path41.basename(file, ".jsonl")}`,
28466
+ label: `worker ${path42.basename(file, ".jsonl")}`,
28433
28467
  prompt: firstPrompt(file)
28434
28468
  }, 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
28469
  } catch {}
@@ -28809,10 +28843,10 @@ var modelKey = (model) => {
28809
28843
  // packages/workit-core/src/hooks/budget-signal.ts
28810
28844
  import { createHash as createHash19 } from "node:crypto";
28811
28845
  import fs30 from "node:fs";
28812
- import path42 from "node:path";
28846
+ import path43 from "node:path";
28813
28847
  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 ?? ""}`));
28848
+ var budgetDir = (store) => path43.join(store, "budget");
28849
+ var agentBase = (store, session, agentId) => path43.join(budgetDir(store), hash2(`${session}\x00${agentId ?? ""}`));
28816
28850
  var spawnBudget = (prompt) => {
28817
28851
  const found = /^TIMEBOX:[^\n]*?\b(\d+)\s+tool calls\b/mu.exec(prompt);
28818
28852
  const n = found ? Number(found[1]) : NaN;
@@ -28832,8 +28866,8 @@ var startBudget = (store, session, agentId, n) => {
28832
28866
  const cutoff = Date.now() - 604800000;
28833
28867
  for (const name of fs30.readdirSync(dir))
28834
28868
  try {
28835
- if (fs30.statSync(path42.join(dir, name)).mtimeMs < cutoff)
28836
- fs30.rmSync(path42.join(dir, name));
28869
+ if (fs30.statSync(path43.join(dir, name)).mtimeMs < cutoff)
28870
+ fs30.rmSync(path43.join(dir, name));
28837
28871
  } catch {}
28838
28872
  const base = agentBase(store, session, agentId);
28839
28873
  fs30.writeFileSync(`${base}.json`, JSON.stringify({ limit: n, told: 0 }));
@@ -29175,13 +29209,13 @@ var skillPromptNudge = (prompt, ctx) => process.env.WORKIT_PI_WORKER_SESSION ? n
29175
29209
 
29176
29210
  // packages/workit-pi/src/launches.ts
29177
29211
  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";
29212
+ import os12 from "node:os";
29213
+ import path44 from "node:path";
29180
29214
  var launchDir = (root) => {
29181
29215
  const location = resolveStore(root);
29182
- return location instanceof Error ? null : path43.join(location.dir, "pi-launches");
29216
+ return location instanceof Error ? null : path44.join(location.dir, "pi-launches");
29183
29217
  };
29184
- var fileFor = (dir, workerId) => path43.join(dir, `${workerId.replace(/[^A-Za-z0-9-]/g, "_")}.json`);
29218
+ var fileFor = (dir, workerId) => path44.join(dir, `${workerId.replace(/[^A-Za-z0-9-]/g, "_")}.json`);
29185
29219
  var recordLaunch = (root, attempt) => {
29186
29220
  const dir = launchDir(root);
29187
29221
  if (!dir)
@@ -29191,7 +29225,7 @@ var recordLaunch = (root, attempt) => {
29191
29225
  writeFileSync4(fileFor(dir, attempt.workerId), JSON.stringify({
29192
29226
  ...attempt,
29193
29227
  pid: process.pid,
29194
- host: os11.hostname(),
29228
+ host: os12.hostname(),
29195
29229
  at: new Date().toISOString()
29196
29230
  }), { flag: "wx" });
29197
29231
  return true;
@@ -29205,7 +29239,7 @@ var clearLaunch = (root, workerId) => {
29205
29239
  rmSync2(fileFor(dir, workerId), { force: true });
29206
29240
  };
29207
29241
  var alive = (attempt) => {
29208
- if (attempt.host !== os11.hostname())
29242
+ if (attempt.host !== os12.hostname())
29209
29243
  return true;
29210
29244
  try {
29211
29245
  process.kill(attempt.pid, 0);
@@ -29227,7 +29261,7 @@ var abandonedLaunches = (root) => {
29227
29261
  const found = [];
29228
29262
  for (const name of names) {
29229
29263
  try {
29230
- const attempt = JSON.parse(readFileSync9(path43.join(dir, name), "utf8"));
29264
+ const attempt = JSON.parse(readFileSync9(path44.join(dir, name), "utf8"));
29231
29265
  if (typeof attempt.workerId === "string" && typeof attempt.session === "string") {
29232
29266
  if (!alive(attempt))
29233
29267
  found.push(attempt);
@@ -29239,18 +29273,18 @@ var abandonedLaunches = (root) => {
29239
29273
  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
29274
 
29241
29275
  // 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";
29276
+ import { closeSync as closeSync3, existsSync as existsSync13, openSync as openSync3, readSync as readSync2 } from "node:fs";
29277
+ import path45 from "node:path";
29244
29278
  var LAUNCHER_MARKER = "workit-owned-launcher";
29245
29279
  var CLI_PACKAGE_PATH = ["node_modules", "@workit-dev", "cli"];
29246
29280
  var installRoot = (env, platform = process.platform) => {
29247
29281
  if (env.WORKIT_INSTALL_ROOT)
29248
29282
  return env.WORKIT_INSTALL_ROOT;
29249
29283
  const data = dataDir(env, platform);
29250
- return platform === "win32" ? path44.join(data, "install") : data;
29284
+ return platform === "win32" ? path45.join(data, "install") : data;
29251
29285
  };
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");
29286
+ var ownedLauncherPath = (env, platform = process.platform) => path45.join(installRoot(env, platform), "bin", platform === "win32" ? "workit.cmd" : "workit");
29287
+ var ownedCurrentEntry = (env, platform = process.platform) => path45.join(installRoot(env, platform), "current", ...CLI_PACKAGE_PATH, "dist", "index.js");
29254
29288
  var head = (file) => {
29255
29289
  let fd;
29256
29290
  try {
@@ -29268,7 +29302,7 @@ var head = (file) => {
29268
29302
  var locateWorkitCli = (options = {}) => {
29269
29303
  const env = options.env ?? process.env;
29270
29304
  const platform = options.platform ?? process.platform;
29271
- const exists = options.exists ?? existsSync12;
29305
+ const exists = options.exists ?? existsSync13;
29272
29306
  const read = options.read ?? head;
29273
29307
  const node = options.node ?? process.execPath;
29274
29308
  const launcher = ownedLauncherPath(env, platform);
@@ -29277,7 +29311,7 @@ var locateWorkitCli = (options = {}) => {
29277
29311
  source: "owned-launcher",
29278
29312
  command: launcher,
29279
29313
  args: [],
29280
- binDir: path44.dirname(launcher)
29314
+ binDir: path45.dirname(launcher)
29281
29315
  };
29282
29316
  const current = ownedCurrentEntry(env, platform);
29283
29317
  if (exists(current))
@@ -29306,7 +29340,7 @@ var workitCliEnv = (located, env = process.env, platform = process.platform) =>
29306
29340
  if (located.binDir) {
29307
29341
  const key = pathKey(env);
29308
29342
  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);
29343
+ 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
29344
  const rest = (env[key] ?? "").split(delimiter).filter((dir) => dir && !same(dir));
29311
29345
  patch[key] = [located.binDir, ...rest].join(delimiter);
29312
29346
  }