@workit-dev/codex 2.22.1 → 2.22.2

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.
@@ -2,8 +2,10 @@
2
2
  import {
3
3
  configDir2,
4
4
  stateDir3,
5
+ folderSlug2,
6
+ folderStoreDir2,
5
7
  migrateLegacyDirs2
6
- } from "./workit-hook-7jv519ep.js";
8
+ } from "./workit-hook-sxyjantk.js";
7
9
  import {
8
10
  gitDirs,
9
11
  withinCall,
@@ -16,7 +18,7 @@ import {
16
18
  checkCommand,
17
19
  lightCommand,
18
20
  maybeHeavy2
19
- } from "./workit-hook-x482fqpj.js";
21
+ } from "./workit-hook-v0nvtq6s.js";
20
22
  import {
21
23
  gitStoreDir2,
22
24
  standingSeenFile2,
@@ -26,13 +28,13 @@ import {
26
28
  } from "./workit-hook-jy7y0gdx.js";
27
29
  import {
28
30
  takeProcNotice2
29
- } from "./workit-hook-btkg30rw.js";
31
+ } from "./workit-hook-mer435q8.js";
30
32
  import {
31
33
  locateWorkitCli2
32
- } from "./workit-hook-azjr1ew1.js";
34
+ } from "./workit-hook-agyvx03a.js";
33
35
  import {
34
36
  recordHookRun2
35
- } from "./workit-hook-xdv92sjp.js";
37
+ } from "./workit-hook-p972vv1e.js";
36
38
  import {
37
39
  budgetHooks2
38
40
  } from "./workit-hook-b8nrcfzr.js";
@@ -62,8 +64,8 @@ var capabilitiesFor = (descriptor, observed = {}) => descriptor.capabilities.map
62
64
  });
63
65
  // packages/workit-core/src/hooks/context.ts
64
66
  import { createHash as createHash11 } from "node:crypto";
65
- import fs14 from "node:fs";
66
- import path19 from "node:path";
67
+ import fs15 from "node:fs";
68
+ import path20 from "node:path";
67
69
 
68
70
  // packages/workit-core/src/core/branch.ts
69
71
  import { createHash as createHash4 } from "node:crypto";
@@ -9317,8 +9319,288 @@ ${table}` : bootstrap;
9317
9319
  // packages/workit-core/src/store/paths.ts
9318
9320
  import { spawnSync as spawnSync7 } from "node:child_process";
9319
9321
  import { createHash as createHash6 } from "node:crypto";
9322
+ import fs5 from "node:fs";
9323
+ import path9 from "node:path";
9324
+
9325
+ // packages/workit-core/src/store/folder-store.ts
9320
9326
  import fs4 from "node:fs";
9327
+ import os4 from "node:os";
9321
9328
  import path8 from "node:path";
9329
+ var FOLDER_CONFIG = new Set(["checks.json", "risk-paths"]);
9330
+ var MOVED_POINTER = "MOVED-TO-STATE.txt";
9331
+ var V2_LEFTOVERS = new Set(["recovery", "index.json"]);
9332
+ var isV2TaskStub = (rel) => /^tasks[/\\][^/\\]+\.json$/u.test(rel);
9333
+ var MARKER = "workspace.json";
9334
+ var v2Workspace = (workit) => {
9335
+ let bytes;
9336
+ try {
9337
+ bytes = fs4.readFileSync(path8.join(workit, MARKER), "utf8");
9338
+ } catch {
9339
+ return null;
9340
+ }
9341
+ try {
9342
+ const value = JSON.parse(bytes);
9343
+ return value?.store?.format !== "workit-store";
9344
+ } catch {
9345
+ return true;
9346
+ }
9347
+ };
9348
+ var generatedIgnore = (file) => {
9349
+ try {
9350
+ return /^\*\n(!risk-paths\n)?$/u.test(fs4.readFileSync(file, "utf8"));
9351
+ } catch {
9352
+ return false;
9353
+ }
9354
+ };
9355
+ var exists = (file) => {
9356
+ try {
9357
+ fs4.lstatSync(file);
9358
+ return true;
9359
+ } catch {
9360
+ return false;
9361
+ }
9362
+ };
9363
+ var isDir = (file) => {
9364
+ try {
9365
+ return fs4.lstatSync(file).isDirectory();
9366
+ } catch {
9367
+ return false;
9368
+ }
9369
+ };
9370
+ var onlyStubs = (tasks) => {
9371
+ try {
9372
+ return fs4.readdirSync(tasks).every((entry) => isV2TaskStub(`tasks/${entry}`));
9373
+ } catch {
9374
+ return false;
9375
+ }
9376
+ };
9377
+ var strayEntries = (workit) => {
9378
+ if (!isDir(workit))
9379
+ return [];
9380
+ let names;
9381
+ try {
9382
+ names = fs4.readdirSync(workit);
9383
+ } catch {
9384
+ return [];
9385
+ }
9386
+ return names.filter((name) => !FOLDER_CONFIG.has(name) && !V2_LEFTOVERS.has(name) && name !== MOVED_POINTER && name !== MARKER && !(name === ".gitignore" && generatedIgnore(path8.join(workit, name))) && !(name === "tasks" && onlyStubs(path8.join(workit, name))));
9387
+ };
9388
+ var folderStoreIo = {
9389
+ rename: (from, to) => fs4.renameSync(from, to),
9390
+ copyFile: (from, to) => fs4.copyFileSync(from, to, fs4.constants.COPYFILE_EXCL)
9391
+ };
9392
+ var tempSeq = 0;
9393
+ var tempBeside = (file) => path8.join(path8.dirname(file), `.${path8.basename(file)}.workit-move-${process.pid}-${tempSeq += 1}`);
9394
+ var copyInto = (from, to) => {
9395
+ const stat = fs4.lstatSync(from);
9396
+ if (stat.isDirectory()) {
9397
+ fs4.mkdirSync(to, { recursive: true });
9398
+ for (const name of fs4.readdirSync(from))
9399
+ copyInto(path8.join(from, name), path8.join(to, name));
9400
+ return;
9401
+ }
9402
+ if (exists(to))
9403
+ throw new Error(`${to} appeared during the move`);
9404
+ const temp = tempBeside(to);
9405
+ try {
9406
+ if (stat.isSymbolicLink())
9407
+ fs4.symlinkSync(fs4.readlinkSync(from), temp);
9408
+ else
9409
+ folderStoreIo.copyFile(from, temp);
9410
+ folderStoreIo.rename(temp, to);
9411
+ } catch (error) {
9412
+ fs4.rmSync(temp, { force: true });
9413
+ throw error;
9414
+ }
9415
+ };
9416
+ var sameFile = (left, right) => {
9417
+ try {
9418
+ const [a, b] = [fs4.lstatSync(left), fs4.lstatSync(right)];
9419
+ if (!a.isFile() || !b.isFile() || a.size !== b.size)
9420
+ return false;
9421
+ return fs4.readFileSync(left).equals(fs4.readFileSync(right));
9422
+ } catch {
9423
+ return false;
9424
+ }
9425
+ };
9426
+ var merge2 = (from, to, rel, moved) => {
9427
+ if (isV2TaskStub(rel))
9428
+ return [];
9429
+ if (!exists(to)) {
9430
+ try {
9431
+ folderStoreIo.rename(from, to);
9432
+ } catch {
9433
+ try {
9434
+ copyInto(from, to);
9435
+ fs4.rmSync(from, { recursive: true, force: true });
9436
+ } catch {
9437
+ return exists(from) ? [rel] : [];
9438
+ }
9439
+ }
9440
+ moved.push(rel);
9441
+ return [];
9442
+ }
9443
+ if (sameFile(from, to)) {
9444
+ fs4.rmSync(from, { force: true });
9445
+ moved.push(rel);
9446
+ return [];
9447
+ }
9448
+ if (!isDir(from) || !isDir(to))
9449
+ return [rel];
9450
+ const kept = fs4.readdirSync(from).flatMap((name) => merge2(path8.join(from, name), path8.join(to, name), `${rel}/${name}`, moved));
9451
+ try {
9452
+ if (fs4.readdirSync(from).length === 0)
9453
+ fs4.rmdirSync(from);
9454
+ } catch {}
9455
+ return kept;
9456
+ };
9457
+ var LOCK_STALE_MS = 1e4;
9458
+ var LOCK_WAIT_MS = 250;
9459
+ var pause = (ms) => Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
9460
+ var staleLock = (lock) => {
9461
+ try {
9462
+ const stat = fs4.statSync(lock);
9463
+ if (Date.now() - stat.mtimeMs > LOCK_STALE_MS)
9464
+ return true;
9465
+ const pid = Number(fs4.readFileSync(lock, "utf8").trim());
9466
+ if (!Number.isInteger(pid) || pid <= 0)
9467
+ return false;
9468
+ try {
9469
+ process.kill(pid, 0);
9470
+ return false;
9471
+ } catch (error) {
9472
+ return error.code === "ESRCH";
9473
+ }
9474
+ } catch {
9475
+ return false;
9476
+ }
9477
+ };
9478
+ var takeMoveLock = (target) => {
9479
+ const lock = `${target}.lock`;
9480
+ const deadline = Date.now() + LOCK_WAIT_MS;
9481
+ for (;; ) {
9482
+ try {
9483
+ const fd = fs4.openSync(lock, "wx", 384);
9484
+ fs4.writeSync(fd, `${process.pid}
9485
+ `);
9486
+ fs4.closeSync(fd);
9487
+ return () => fs4.rmSync(lock, { force: true });
9488
+ } catch (error) {
9489
+ if (error.code !== "EEXIST")
9490
+ return null;
9491
+ }
9492
+ if (staleLock(lock)) {
9493
+ fs4.rmSync(lock, { force: true });
9494
+ continue;
9495
+ }
9496
+ if (Date.now() >= deadline)
9497
+ return null;
9498
+ pause(25);
9499
+ }
9500
+ };
9501
+ var canonical2 = (dir) => {
9502
+ try {
9503
+ return fs4.realpathSync.native(dir);
9504
+ } catch {
9505
+ return path8.resolve(dir);
9506
+ }
9507
+ };
9508
+ var below = (parent, child) => {
9509
+ const rel = path8.relative(parent, child);
9510
+ return rel !== "" && !rel.startsWith("..") && !path8.isAbsolute(rel);
9511
+ };
9512
+ var TEST_RUN_REFUSALS = "folder-store-refusals.log";
9513
+ var testRunFolderRefusal = (folder, hasStray, env = process.env, tempDir = os4.tmpdir()) => {
9514
+ if (env.WORKIT_TEST_RUN === undefined || !hasStray)
9515
+ return null;
9516
+ const real = canonical2(folder);
9517
+ const tmp = canonical2(tempDir);
9518
+ if (below(tmp, real))
9519
+ return null;
9520
+ return `workit test run (WORKIT_TEST_RUN): refusing to move ${path8.join(real, ".workit")} into the run's throwaway state dir; a test must work in a fresh dir inside ${tmp}, never the temp dir itself, a parent of it or a folder outside it (#892)`;
9521
+ };
9522
+ function migrateFolderStore(folder, target, note = (line) => process.stderr.write(`${line}
9523
+ `)) {
9524
+ const workit = path8.join(folder, ".workit");
9525
+ const names = strayEntries(workit);
9526
+ const refusal = testRunFolderRefusal(folder, names.length > 0);
9527
+ if (refusal) {
9528
+ const run = process.env.WORKIT_TEST_RUN ?? "";
9529
+ if (path8.isAbsolute(run))
9530
+ try {
9531
+ fs4.appendFileSync(path8.join(run, TEST_RUN_REFUSALS), `${refusal}
9532
+ `);
9533
+ } catch {}
9534
+ throw new Error(refusal);
9535
+ }
9536
+ if (names.length === 0 || v2Workspace(workit) === true)
9537
+ return null;
9538
+ try {
9539
+ fs4.mkdirSync(path8.dirname(target), { recursive: true });
9540
+ } catch {
9541
+ return null;
9542
+ }
9543
+ const release = takeMoveLock(target);
9544
+ if (!release)
9545
+ return null;
9546
+ try {
9547
+ return moveLocked(workit, target, note);
9548
+ } finally {
9549
+ release();
9550
+ }
9551
+ }
9552
+ function moveLocked(workit, target, note) {
9553
+ const names = strayEntries(workit);
9554
+ if (names.length === 0 || v2Workspace(workit) === true)
9555
+ return null;
9556
+ try {
9557
+ fs4.mkdirSync(target, { recursive: true });
9558
+ } catch {
9559
+ return null;
9560
+ }
9561
+ const result = { from: workit, to: target, moved: [], kept: [] };
9562
+ for (const name of names) {
9563
+ result.kept.push(...merge2(path8.join(workit, name), path8.join(target, name), name, result.moved));
9564
+ }
9565
+ const left = (() => {
9566
+ try {
9567
+ return fs4.readdirSync(workit);
9568
+ } catch {
9569
+ return [];
9570
+ }
9571
+ })();
9572
+ const v2Left = left.some((name) => V2_LEFTOVERS.has(name) || name === "tasks" && isDir(path8.join(workit, name)));
9573
+ if (!v2Left && result.kept.length === 0) {
9574
+ fs4.rmSync(path8.join(workit, MARKER), { force: true });
9575
+ if (generatedIgnore(path8.join(workit, ".gitignore")))
9576
+ fs4.rmSync(path8.join(workit, ".gitignore"), { force: true });
9577
+ }
9578
+ const pointer = path8.join(workit, MOVED_POINTER);
9579
+ let wrote = false;
9580
+ if (result.kept.length > 0) {
9581
+ const text = `Workit keeps this folder's state in ${target}.
9582
+ Not moved, because the store there already has them or the move failed: ${result.kept.join(", ")}.
9583
+ Merge them by hand (cp -Rn ${workit}/. ${target}/), then delete them here.
9584
+ `;
9585
+ try {
9586
+ if (!exists(pointer) || fs4.readFileSync(pointer, "utf8") !== text) {
9587
+ fs4.writeFileSync(pointer, text);
9588
+ wrote = true;
9589
+ }
9590
+ } catch {}
9591
+ } else {
9592
+ fs4.rmSync(pointer, { force: true });
9593
+ try {
9594
+ if (fs4.readdirSync(workit).length === 0)
9595
+ fs4.rmdirSync(workit);
9596
+ } catch {}
9597
+ }
9598
+ if (result.moved.length > 0 || wrote)
9599
+ note(result.kept.length > 0 ? `workit: moved ${workit} to ${target}; ${result.kept.length} path${result.kept.length === 1 ? "" : "s"} left in place, see ${pointer}` : `workit: moved ${workit} to ${target} (outside a git repository Workit keeps its state there)`);
9600
+ return result;
9601
+ }
9602
+
9603
+ // packages/workit-core/src/store/paths.ts
9322
9604
  var NOT_A_REPO = /not a git repository \(or any (of the parent directories|parent up to)/u;
9323
9605
  var gitRun = (cwd, args) => {
9324
9606
  const run = spawnSync7("git", args, {
@@ -9346,7 +9628,7 @@ var gitRun = (cwd, args) => {
9346
9628
  var shortHash = (value) => createHash6("sha256").update(value).digest("hex").slice(0, 12);
9347
9629
  var real = (file) => {
9348
9630
  try {
9349
- return fs4.realpathSync.native(file);
9631
+ return fs5.realpathSync.native(file);
9350
9632
  } catch {
9351
9633
  return file;
9352
9634
  }
@@ -9360,14 +9642,14 @@ var DISCOVERY_ENV = [
9360
9642
  ];
9361
9643
  var isGitDir = (dir) => {
9362
9644
  try {
9363
- return fs4.statSync(path8.join(dir, "HEAD")).isFile() && fs4.statSync(path8.join(dir, "objects")).isDirectory() && fs4.statSync(path8.join(dir, "refs")).isDirectory();
9645
+ return fs5.statSync(path9.join(dir, "HEAD")).isFile() && fs5.statSync(path9.join(dir, "objects")).isDirectory() && fs5.statSync(path9.join(dir, "refs")).isDirectory();
9364
9646
  } catch {
9365
9647
  return false;
9366
9648
  }
9367
9649
  };
9368
9650
  var reftableRefs = (common) => {
9369
9651
  try {
9370
- return /^\s*refstorage\s*=\s*reftable\s*$/imu.test(fs4.readFileSync(path8.join(common, "config"), "utf8"));
9652
+ return /^\s*refstorage\s*=\s*reftable\s*$/imu.test(fs5.readFileSync(path9.join(common, "config"), "utf8"));
9371
9653
  } catch {
9372
9654
  return false;
9373
9655
  }
@@ -9380,17 +9662,17 @@ function fastGit(root) {
9380
9662
  for (;; ) {
9381
9663
  let stat;
9382
9664
  try {
9383
- stat = fs4.statSync(dir);
9665
+ stat = fs5.statSync(dir);
9384
9666
  } catch {
9385
9667
  return null;
9386
9668
  }
9387
9669
  if (device !== null && stat.dev !== device)
9388
9670
  return { kind: "none" };
9389
9671
  device = stat.dev;
9390
- const dotGit = path8.join(dir, ".git");
9672
+ const dotGit = path9.join(dir, ".git");
9391
9673
  let entry = null;
9392
9674
  try {
9393
- entry = fs4.statSync(dotGit);
9675
+ entry = fs5.statSync(dotGit);
9394
9676
  } catch {}
9395
9677
  let gitDir = null;
9396
9678
  let top = null;
@@ -9401,26 +9683,26 @@ function fastGit(root) {
9401
9683
  else if (entry.isFile()) {
9402
9684
  let text = "";
9403
9685
  try {
9404
- text = fs4.readFileSync(dotGit, "utf8");
9686
+ text = fs5.readFileSync(dotGit, "utf8");
9405
9687
  } catch {
9406
9688
  return null;
9407
9689
  }
9408
9690
  const match = /^gitdir: (.+)$/mu.exec(text);
9409
9691
  if (!match)
9410
9692
  return null;
9411
- gitDir = path8.resolve(dir, match[1].trim());
9693
+ gitDir = path9.resolve(dir, match[1].trim());
9412
9694
  } else
9413
9695
  return null;
9414
- if (!fs4.existsSync(path8.join(gitDir, "HEAD")))
9696
+ if (!fs5.existsSync(path9.join(gitDir, "HEAD")))
9415
9697
  return null;
9416
9698
  } else if (isGitDir(dir))
9417
9699
  gitDir = dir;
9418
9700
  if (gitDir) {
9419
9701
  let common = gitDir;
9420
9702
  try {
9421
- common = path8.resolve(gitDir, fs4.readFileSync(path8.join(gitDir, "commondir"), "utf8").trim());
9703
+ common = path9.resolve(gitDir, fs5.readFileSync(path9.join(gitDir, "commondir"), "utf8").trim());
9422
9704
  } catch {}
9423
- if (!fs4.existsSync(path8.join(common, "objects")))
9705
+ if (!fs5.existsSync(path9.join(common, "objects")))
9424
9706
  return null;
9425
9707
  return {
9426
9708
  kind: "repo",
@@ -9430,28 +9712,33 @@ function fastGit(root) {
9430
9712
  reftable: reftableRefs(common)
9431
9713
  };
9432
9714
  }
9433
- const parent = path8.dirname(dir);
9715
+ const parent = path9.dirname(dir);
9434
9716
  if (parent === dir)
9435
9717
  return { kind: "none" };
9436
9718
  dir = parent;
9437
9719
  }
9438
9720
  }
9721
+ var outsideGit = (root) => {
9722
+ const dir = folderStoreDir2(root);
9723
+ migrateFolderStore(root, dir);
9724
+ return { dir, shared: false, top: null };
9725
+ };
9439
9726
  function resolveStore(root) {
9440
- root = path8.resolve(root);
9727
+ root = path9.resolve(root);
9441
9728
  let stat = null;
9442
9729
  try {
9443
- stat = fs4.statSync(root);
9730
+ stat = fs5.statSync(root);
9444
9731
  } catch {}
9445
9732
  if (!stat)
9446
9733
  return new Error(`cannot locate the workit store: ${root} does not exist (removed while workit ran?); nothing is recorded under a missing directory`);
9447
9734
  if (!stat.isDirectory())
9448
- return { dir: path8.join(root, ".workit"), shared: false, top: null };
9735
+ return { dir: path9.join(root, ".workit"), shared: false, top: null };
9449
9736
  const fast = fastGit(root);
9450
9737
  if (fast?.kind === "none")
9451
- return { dir: path8.join(root, ".workit"), shared: false, top: null };
9738
+ return outsideGit(root);
9452
9739
  if (fast?.kind === "repo")
9453
9740
  return {
9454
- dir: path8.join(fast.common, "workit"),
9741
+ dir: path9.join(fast.common, "workit"),
9455
9742
  shared: true,
9456
9743
  top: fast.top,
9457
9744
  git: { gitDir: fast.gitDir, top: fast.top, reftable: fast.reftable }
@@ -9461,20 +9748,20 @@ function resolveStore(root) {
9461
9748
  if (run.ok && common) {
9462
9749
  const top = gitRun(root, ["rev-parse", "--path-format=absolute", "--show-toplevel"]);
9463
9750
  return {
9464
- dir: path8.join(real(path8.resolve(root, common)), "workit"),
9751
+ dir: path9.join(real(path9.resolve(root, common)), "workit"),
9465
9752
  shared: true,
9466
9753
  top: top.ok && top.stdout.trim() ? real(top.stdout.trim()) : null
9467
9754
  };
9468
9755
  }
9469
9756
  if (run.missing || !run.ok && NOT_A_REPO.test(run.stderr))
9470
- return { dir: path8.join(root, ".workit"), shared: false, top: null };
9757
+ return outsideGit(root);
9471
9758
  return new Error(`cannot locate the workit store: git rev-parse failed (${run.stderr.trim().split(`
9472
9759
  `)[0] || "no output"}); fix the repository (git status should work here)`);
9473
9760
  }
9474
9761
  var rebasingBranch = (gitDir) => {
9475
9762
  for (const state of ["rebase-merge", "rebase-apply"]) {
9476
9763
  try {
9477
- const ref = fs4.readFileSync(path8.join(gitDir, state, "head-name"), "utf8").trim();
9764
+ const ref = fs5.readFileSync(path9.join(gitDir, state, "head-name"), "utf8").trim();
9478
9765
  const match = /^refs\/heads\/(.+)$/u.exec(ref);
9479
9766
  if (match)
9480
9767
  return match[1];
@@ -9489,7 +9776,7 @@ function resolveTaskKey(root, location) {
9489
9776
  if (location.git && !location.git.reftable) {
9490
9777
  let head = "";
9491
9778
  try {
9492
- head = fs4.readFileSync(path8.join(location.git.gitDir, "HEAD"), "utf8").trim();
9779
+ head = fs5.readFileSync(path9.join(location.git.gitDir, "HEAD"), "utf8").trim();
9493
9780
  } catch {}
9494
9781
  const ref = /^ref: refs\/heads\/(.+)$/u.exec(head);
9495
9782
  if (ref && ref[1] !== ".invalid")
@@ -9520,10 +9807,10 @@ function resolveTaskKey(root, location) {
9520
9807
  return { key: `detached-${shortHash(real(worktree))}`, kind: "detached", branch: null };
9521
9808
  }
9522
9809
  function checkoutRootOf(root, location) {
9523
- const resolved = path8.resolve(root);
9810
+ const resolved = path9.resolve(root);
9524
9811
  let canonical = resolved;
9525
9812
  try {
9526
- canonical = fs4.realpathSync(resolved);
9813
+ canonical = fs5.realpathSync(resolved);
9527
9814
  } catch {
9528
9815
  return resolved;
9529
9816
  }
@@ -9533,7 +9820,7 @@ function checkoutRootOf(root, location) {
9533
9820
  if (real(canonical) === found.top)
9534
9821
  return canonical;
9535
9822
  try {
9536
- return fs4.realpathSync(found.top);
9823
+ return fs5.realpathSync(found.top);
9537
9824
  } catch {
9538
9825
  return canonical;
9539
9826
  }
@@ -9545,25 +9832,25 @@ function branchRenames(location) {
9545
9832
  const walk = (dir) => {
9546
9833
  let entries;
9547
9834
  try {
9548
- entries = fs4.readdirSync(dir, { withFileTypes: true });
9835
+ entries = fs5.readdirSync(dir, { withFileTypes: true });
9549
9836
  } catch {
9550
9837
  return;
9551
9838
  }
9552
9839
  for (const entry of entries)
9553
9840
  if (entry.isDirectory())
9554
- walk(path8.join(dir, entry.name));
9841
+ walk(path9.join(dir, entry.name));
9555
9842
  else
9556
- files.push(path8.join(dir, entry.name));
9843
+ files.push(path9.join(dir, entry.name));
9557
9844
  };
9558
- walk(path8.join(path8.dirname(location.dir), "logs", "refs", "heads"));
9845
+ walk(path9.join(path9.dirname(location.dir), "logs", "refs", "heads"));
9559
9846
  if (location.git)
9560
- files.push(path8.join(location.git.gitDir, "logs", "HEAD"));
9847
+ files.push(path9.join(location.git.gitDir, "logs", "HEAD"));
9561
9848
  const seen = new Set;
9562
9849
  const renames = [];
9563
9850
  for (const file of files) {
9564
9851
  let text = "";
9565
9852
  try {
9566
- text = fs4.readFileSync(file, "utf8");
9853
+ text = fs5.readFileSync(file, "utf8");
9567
9854
  } catch {
9568
9855
  continue;
9569
9856
  }
@@ -9588,13 +9875,7 @@ function followRenames(key, boundAt, renames) {
9588
9875
  }
9589
9876
  return current;
9590
9877
  }
9591
- var checkoutSlug = (root) => {
9592
- let canonical = real(root);
9593
- if (process.platform === "win32")
9594
- canonical = canonical.toLowerCase();
9595
- const base = path8.basename(canonical).replace(/[^A-Za-z0-9._-]/g, "_").slice(0, 40) || "root";
9596
- return `${base}-${shortHash(canonical)}`;
9597
- };
9878
+ var checkoutSlug = (root) => folderSlug2(root);
9598
9879
 
9599
9880
  // packages/workit-core/src/core/task-contract.ts
9600
9881
  import { createHash as createHash7, randomUUID } from "node:crypto";
@@ -10337,7 +10618,7 @@ function resolveIdRef(kind, ref, ids) {
10337
10618
  return failure2("not_found", `${kind} not found`);
10338
10619
  return failure2("invalid_input", `${kind} prefix ${ref} is ambiguous; candidates: ${matches.join(", ")}`);
10339
10620
  }
10340
- function canonical2(value, seen) {
10621
+ function canonical3(value, seen) {
10341
10622
  if (value === null || typeof value === "boolean" || typeof value === "string") {
10342
10623
  if (typeof value === "string" && invalidUnicode(value))
10343
10624
  throw new TypeError("invalid Unicode");
@@ -10359,7 +10640,7 @@ function canonical2(value, seen) {
10359
10640
  if (!(index in value))
10360
10641
  throw new TypeError("sparse array");
10361
10642
  }
10362
- result = value.map((item) => canonical2(item, seen));
10643
+ result = value.map((item) => canonical3(item, seen));
10363
10644
  } else {
10364
10645
  if (Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null)
10365
10646
  throw new TypeError("value is not a JSON object");
@@ -10367,13 +10648,13 @@ function canonical2(value, seen) {
10367
10648
  throw new TypeError("symbol key is not JSON");
10368
10649
  if (Object.keys(value).some((key) => invalidUnicode(key)))
10369
10650
  throw new TypeError("invalid Unicode");
10370
- result = Object.fromEntries(Object.keys(value).toSorted().map((key) => [key, canonical2(value[key], seen)]));
10651
+ result = Object.fromEntries(Object.keys(value).toSorted().map((key) => [key, canonical3(value[key], seen)]));
10371
10652
  }
10372
10653
  seen.delete(value);
10373
10654
  return result;
10374
10655
  }
10375
10656
  function canonicalJson(value) {
10376
- return JSON.stringify(canonical2(value, new Set));
10657
+ return JSON.stringify(canonical3(value, new Set));
10377
10658
  }
10378
10659
  function sha256(value) {
10379
10660
  if (typeof value === "string" && invalidUnicode(value))
@@ -10414,14 +10695,14 @@ function candidateDigest(input) {
10414
10695
 
10415
10696
  // packages/workit-core/src/core/task-evaluation.ts
10416
10697
  import { createHash as createHash10 } from "node:crypto";
10417
- import * as fs13 from "node:fs";
10698
+ import * as fs14 from "node:fs";
10418
10699
  import { spawnSync as spawnSync12 } from "node:child_process";
10419
- import path18 from "node:path";
10700
+ import path19 from "node:path";
10420
10701
 
10421
10702
  // packages/workit-core/src/core/task-read.ts
10422
10703
  import { randomUUID as randomUUID3 } from "node:crypto";
10423
- import * as fs10 from "node:fs";
10424
- import path13 from "node:path";
10704
+ import * as fs11 from "node:fs";
10705
+ import path14 from "node:path";
10425
10706
 
10426
10707
  // node_modules/@openclaw/fs-safe/dist/errors.js
10427
10708
  var OPERATIONAL_CODES = new Set([
@@ -10472,10 +10753,10 @@ function sameFileIdentity(left, right, platform = process.platform) {
10472
10753
  // node_modules/@openclaw/fs-safe/dist/sidecar-lock-reclaim.js
10473
10754
  import { randomBytes } from "node:crypto";
10474
10755
  import fsSync from "node:fs";
10475
- import path9 from "node:path";
10756
+ import path10 from "node:path";
10476
10757
 
10477
10758
  // node_modules/@openclaw/fs-safe/dist/bounded-read.js
10478
- import fs5 from "node:fs";
10759
+ import fs6 from "node:fs";
10479
10760
 
10480
10761
  // node_modules/@openclaw/fs-safe/dist/byte-budget.js
10481
10762
  function normalizeMaxBytes(value, options = {}) {
@@ -10512,7 +10793,7 @@ function readFileDescriptorBoundedSync(fd, maxBytes) {
10512
10793
  let total = 0;
10513
10794
  while (true) {
10514
10795
  const length = nextReadLength(total, maxBytes, scratch.length);
10515
- const bytesRead = fs5.readSync(fd, scratch, 0, length, null);
10796
+ const bytesRead = fs6.readSync(fd, scratch, 0, length, null);
10516
10797
  if (bytesRead === 0) {
10517
10798
  return Buffer.concat(chunks, total);
10518
10799
  }
@@ -10521,9 +10802,9 @@ function readFileDescriptorBoundedSync(fd, maxBytes) {
10521
10802
  }
10522
10803
 
10523
10804
  // node_modules/@openclaw/fs-safe/dist/read-open-flags.js
10524
- import fs6 from "node:fs";
10805
+ import fs7 from "node:fs";
10525
10806
  function resolveReadOpenFlags(options) {
10526
- const constants = options?.constants ?? fs6.constants;
10807
+ const constants = options?.constants ?? fs7.constants;
10527
10808
  const noFollow = process.platform !== "win32" && options?.followSymlinks !== true && typeof constants.O_NOFOLLOW === "number" ? constants.O_NOFOLLOW : 0;
10528
10809
  const nonBlocking = process.platform !== "win32" && typeof constants.O_NONBLOCK === "number" ? constants.O_NONBLOCK : 0;
10529
10810
  return constants.O_RDONLY | noFollow | nonBlocking;
@@ -10562,13 +10843,13 @@ ${ownershipToken}
10562
10843
  return { raw, ownershipToken };
10563
10844
  }
10564
10845
  function relativeSidecarLockPath(lockRoot, lockPath) {
10565
- const resolved = path9.resolve(lockPath);
10566
- const lexicalRelative = path9.relative(lockRoot.rootDir, resolved);
10567
- const relative = lexicalRelative !== ".." && !lexicalRelative.startsWith(`..${path9.sep}`) && !path9.isAbsolute(lexicalRelative) ? lexicalRelative : path9.relative(lockRoot.rootReal, resolved);
10568
- if (!relative || relative === ".." || relative.startsWith(`..${path9.sep}`) || path9.isAbsolute(relative)) {
10846
+ const resolved = path10.resolve(lockPath);
10847
+ const lexicalRelative = path10.relative(lockRoot.rootDir, resolved);
10848
+ const relative = lexicalRelative !== ".." && !lexicalRelative.startsWith(`..${path10.sep}`) && !path10.isAbsolute(lexicalRelative) ? lexicalRelative : path10.relative(lockRoot.rootReal, resolved);
10849
+ if (!relative || relative === ".." || relative.startsWith(`..${path10.sep}`) || path10.isAbsolute(relative)) {
10569
10850
  throw new FsSafeError("outside-workspace", "sidecar lock path is outside lockRoot");
10570
10851
  }
10571
- return relative.split(path9.sep).join(path9.posix.sep);
10852
+ return relative.split(path10.sep).join(path10.posix.sep);
10572
10853
  }
10573
10854
  function parseSidecarLockPayload(raw, parser) {
10574
10855
  if (parser) {
@@ -10714,8 +10995,8 @@ function getFsSafeLockConfig() {
10714
10995
  }
10715
10996
 
10716
10997
  // node_modules/@openclaw/fs-safe/dist/file-lock-sync.js
10717
- import fs7 from "node:fs";
10718
- import path10 from "node:path";
10998
+ import fs8 from "node:fs";
10999
+ import path11 from "node:path";
10719
11000
 
10720
11001
  // node_modules/@openclaw/fs-safe/dist/timing.js
10721
11002
  function sleepSync(ms) {
@@ -10745,7 +11026,7 @@ function releaseAllSyncHeldLocks() {
10745
11026
  }
10746
11027
  try {
10747
11028
  if (held.fd !== undefined)
10748
- fs7.closeSync(held.fd);
11029
+ fs8.closeSync(held.fd);
10749
11030
  } catch {}
10750
11031
  try {
10751
11032
  removeSidecarLockIfUnchangedSync(held.lockPath, held.snapshot);
@@ -10780,7 +11061,7 @@ function releaseSyncHeldLock(held) {
10780
11061
  if (held.fd !== undefined) {
10781
11062
  const fd = held.fd;
10782
11063
  held.fd = undefined;
10783
- fs7.closeSync(fd);
11064
+ fs8.closeSync(fd);
10784
11065
  }
10785
11066
  removeSidecarLockIfUnchangedSync(held.lockPath, held.snapshot);
10786
11067
  heldLocks.delete(held.normalizedTargetPath);
@@ -10803,29 +11084,29 @@ function createSyncHeldLockHandle(held) {
10803
11084
  };
10804
11085
  }
10805
11086
  function canonicalLockParentSync(parent) {
10806
- return process.platform === "win32" ? fs7.realpathSync.native(parent) : fs7.realpathSync(parent);
11087
+ return process.platform === "win32" ? fs8.realpathSync.native(parent) : fs8.realpathSync(parent);
10807
11088
  }
10808
11089
  function normalizeTargetPath(targetPath) {
10809
- const resolved = path10.resolve(targetPath);
10810
- fs7.mkdirSync(path10.dirname(resolved), { recursive: true });
11090
+ const resolved = path11.resolve(targetPath);
11091
+ fs8.mkdirSync(path11.dirname(resolved), { recursive: true });
10811
11092
  try {
10812
- return path10.join(canonicalLockParentSync(path10.dirname(resolved)), path10.basename(resolved));
11093
+ return path11.join(canonicalLockParentSync(path11.dirname(resolved)), path11.basename(resolved));
10813
11094
  } catch {
10814
11095
  return resolved;
10815
11096
  }
10816
11097
  }
10817
11098
  function boundedLockPath(lockPath, lockRoot) {
10818
- const resolved = path10.resolve(lockPath);
11099
+ const resolved = path11.resolve(lockPath);
10819
11100
  if (!lockRoot)
10820
11101
  return resolved;
10821
11102
  relativeSidecarLockPath(lockRoot, resolved);
10822
- const parent = path10.dirname(resolved);
11103
+ const parent = path11.dirname(resolved);
10823
11104
  const parentReal = canonicalLockParentSync(parent);
10824
- const parentRelative = path10.relative(lockRoot.rootReal, parentReal);
10825
- if (parentRelative === ".." || parentRelative.startsWith(`..${path10.sep}`) || path10.isAbsolute(parentRelative)) {
11105
+ const parentRelative = path11.relative(lockRoot.rootReal, parentReal);
11106
+ if (parentRelative === ".." || parentRelative.startsWith(`..${path11.sep}`) || path11.isAbsolute(parentRelative)) {
10826
11107
  throw new FsSafeError("outside-workspace", "sidecar lock parent is outside lockRoot");
10827
11108
  }
10828
- return path10.join(parentReal, path10.basename(resolved));
11109
+ return path11.join(parentReal, path11.basename(resolved));
10829
11110
  }
10830
11111
  function defaultShouldReclaim(snapshot, staleMs, nowMs) {
10831
11112
  const createdAtMs = sidecarLockPayloadCreatedAtMs(snapshot.payload);
@@ -10835,7 +11116,7 @@ function defaultShouldReclaim(snapshot, staleMs, nowMs) {
10835
11116
  }
10836
11117
  function reclaimGuardExists(reclaimGuardPath) {
10837
11118
  try {
10838
- fs7.lstatSync(reclaimGuardPath);
11119
+ fs8.lstatSync(reclaimGuardPath);
10839
11120
  return true;
10840
11121
  } catch (error) {
10841
11122
  if (error.code === "ENOENT")
@@ -10899,19 +11180,19 @@ function acquireFileLockSync(targetPath, options) {
10899
11180
  const { raw, ownershipToken } = serializeSidecarLockPayload(payload);
10900
11181
  let lockFileCreateDenied = false;
10901
11182
  try {
10902
- const noFollow = process.platform !== "win32" && typeof fs7.constants.O_NOFOLLOW === "number" ? fs7.constants.O_NOFOLLOW : 0;
11183
+ const noFollow = process.platform !== "win32" && typeof fs8.constants.O_NOFOLLOW === "number" ? fs8.constants.O_NOFOLLOW : 0;
10903
11184
  try {
10904
- fd = fs7.openSync(lockPath, fs7.constants.O_WRONLY | fs7.constants.O_CREAT | fs7.constants.O_EXCL | noFollow, 384);
11185
+ fd = fs8.openSync(lockPath, fs8.constants.O_WRONLY | fs8.constants.O_CREAT | fs8.constants.O_EXCL | noFollow, 384);
10905
11186
  } catch (error) {
10906
11187
  lockFileCreateDenied = isTransientLockFileDenial(error, lockPath);
10907
11188
  throw error;
10908
11189
  }
10909
- fs7.writeFileSync(fd, raw, "utf8");
10910
- fs7.fsyncSync(fd);
11190
+ fs8.writeFileSync(fd, raw, "utf8");
11191
+ fs8.fsyncSync(fd);
10911
11192
  const snapshot = {
10912
11193
  raw,
10913
11194
  payload,
10914
- stat: fs7.fstatSync(fd),
11195
+ stat: fs8.fstatSync(fd),
10915
11196
  ownershipToken
10916
11197
  };
10917
11198
  const createdHeld = {
@@ -10946,8 +11227,8 @@ function acquireFileLockSync(targetPath, options) {
10946
11227
  return returnedHandle;
10947
11228
  } catch (error) {
10948
11229
  if (fd !== undefined) {
10949
- const failed = { payload: null, stat: fs7.fstatSync(fd) };
10950
- fs7.closeSync(fd);
11230
+ const failed = { payload: null, stat: fs8.fstatSync(fd) };
11231
+ fs8.closeSync(fd);
10951
11232
  fd = undefined;
10952
11233
  removeSidecarLockIfUnchangedSync(lockPath, failed);
10953
11234
  }
@@ -10996,7 +11277,7 @@ function acquireFileLockSync(targetPath, options) {
10996
11277
  })) {
10997
11278
  let ownsReclaimGuard = false;
10998
11279
  try {
10999
- fs7.mkdirSync(reclaimGuardPath);
11280
+ fs8.mkdirSync(reclaimGuardPath);
11000
11281
  ownsReclaimGuard = true;
11001
11282
  if (removeSidecarLockIfUnchangedSync(lockPath, snapshot))
11002
11283
  continue;
@@ -11009,7 +11290,7 @@ function acquireFileLockSync(targetPath, options) {
11009
11290
  } finally {
11010
11291
  if (ownsReclaimGuard) {
11011
11292
  try {
11012
- fs7.rmdirSync(reclaimGuardPath);
11293
+ fs8.rmdirSync(reclaimGuardPath);
11013
11294
  } catch {}
11014
11295
  }
11015
11296
  }
@@ -11026,13 +11307,13 @@ function acquireFileLockSync(targetPath, options) {
11026
11307
  }
11027
11308
  // packages/workit-core/src/core/package-root.ts
11028
11309
  import { existsSync as existsSync4 } from "node:fs";
11029
- import path11 from "node:path";
11310
+ import path12 from "node:path";
11030
11311
  import { fileURLToPath } from "node:url";
11031
11312
  var packageRoot = () => {
11032
- let dir = path11.dirname(fileURLToPath(import.meta.url));
11313
+ let dir = path12.dirname(fileURLToPath(import.meta.url));
11033
11314
  while (true) {
11034
- const parent = path11.dirname(dir);
11035
- if (existsSync4(path11.join(dir, "package.json")) || parent === dir)
11315
+ const parent = path12.dirname(dir);
11316
+ if (existsSync4(path12.join(dir, "package.json")) || parent === dir)
11036
11317
  return dir;
11037
11318
  dir = parent;
11038
11319
  }
@@ -11040,7 +11321,7 @@ var packageRoot = () => {
11040
11321
 
11041
11322
  // packages/workit-core/src/core/store-lock.ts
11042
11323
  import { spawnSync as spawnSync8 } from "node:child_process";
11043
- import fs8 from "node:fs";
11324
+ import fs9 from "node:fs";
11044
11325
  import { hostname } from "node:os";
11045
11326
  var metadataLockSchema = object({
11046
11327
  pid: number2().int().nonnegative().safe(),
@@ -11083,7 +11364,7 @@ var parseProcStatStart = (stat) => {
11083
11364
  };
11084
11365
  var readProcStat = (pid) => {
11085
11366
  try {
11086
- return fs8.readFileSync(`/proc/${pid}/stat`, "utf8");
11367
+ return fs9.readFileSync(`/proc/${pid}/stat`, "utf8");
11087
11368
  } catch {
11088
11369
  return null;
11089
11370
  }
@@ -11112,7 +11393,7 @@ var processStartOf = (pid, deps = {}) => {
11112
11393
  };
11113
11394
  var readTrimmed = (file) => {
11114
11395
  try {
11115
- return fs8.readFileSync(file, "utf8").trim() || null;
11396
+ return fs9.readFileSync(file, "utf8").trim() || null;
11116
11397
  } catch {
11117
11398
  return null;
11118
11399
  }
@@ -11123,7 +11404,7 @@ var localLockHost = () => {
11123
11404
  return cachedLockHost;
11124
11405
  let pidns = null;
11125
11406
  try {
11126
- pidns = /\[(\d+)\]/.exec(fs8.readlinkSync("/proc/self/ns/pid"))?.[1] ?? null;
11407
+ pidns = /\[(\d+)\]/.exec(fs9.readlinkSync("/proc/self/ns/pid"))?.[1] ?? null;
11127
11408
  } catch {}
11128
11409
  const boot = readTrimmed("/proc/sys/kernel/random/boot_id");
11129
11410
  cachedLockHost = pidns || boot ? `${hostname()}#${pidns ?? "?"}:${boot ?? "?"}` : hostname();
@@ -11169,7 +11450,7 @@ var classifyLockOwner = (payload, ageMs, localHost = localLockHost(), options =
11169
11450
  };
11170
11451
  var ageOf = (file, nowMs) => {
11171
11452
  try {
11172
- return nowMs - fs8.lstatSync(file).mtimeMs;
11453
+ return nowMs - fs9.lstatSync(file).mtimeMs;
11173
11454
  } catch {
11174
11455
  return null;
11175
11456
  }
@@ -11180,7 +11461,7 @@ var clearAbandonedReclaimGuard = (lockPath, nowMs = Date.now()) => {
11180
11461
  if (age === null || age <= RECLAIM_GUARD_TTL_MS)
11181
11462
  return false;
11182
11463
  try {
11183
- fs8.rmdirSync(guard);
11464
+ fs9.rmdirSync(guard);
11184
11465
  return true;
11185
11466
  } catch {
11186
11467
  return false;
@@ -11189,8 +11470,8 @@ var clearAbandonedReclaimGuard = (lockPath, nowMs = Date.now()) => {
11189
11470
 
11190
11471
  // packages/workit-core/src/store/event-log.ts
11191
11472
  import { randomUUID as randomUUID2 } from "node:crypto";
11192
- import fs9 from "node:fs";
11193
- import path12 from "node:path";
11473
+ import fs10 from "node:fs";
11474
+ import path13 from "node:path";
11194
11475
  var EVENT_VERSION = 1;
11195
11476
 
11196
11477
  class LogDamage extends Error {
@@ -11219,7 +11500,7 @@ var parseEvent = (line, file, offset) => {
11219
11500
  function readLog(file, from = 0, expectSeq = null) {
11220
11501
  let fd;
11221
11502
  try {
11222
- fd = fs9.openSync(file, "r");
11503
+ fd = fs10.openSync(file, "r");
11223
11504
  } catch (error) {
11224
11505
  if (error.code === "ENOENT")
11225
11506
  return null;
@@ -11228,13 +11509,13 @@ function readLog(file, from = 0, expectSeq = null) {
11228
11509
  let bytes;
11229
11510
  let size;
11230
11511
  try {
11231
- size = fs9.fstatSync(fd).size;
11512
+ size = fs10.fstatSync(fd).size;
11232
11513
  if (from > size)
11233
11514
  throw new LogDamage(`${file}: shorter than its snapshot`);
11234
11515
  bytes = Buffer.alloc(size - from);
11235
11516
  let read = 0;
11236
11517
  while (read < bytes.length) {
11237
- const got = fs9.readSync(fd, bytes, read, bytes.length - read, from + read);
11518
+ const got = fs10.readSync(fd, bytes, read, bytes.length - read, from + read);
11238
11519
  if (got === 0)
11239
11520
  break;
11240
11521
  read += got;
@@ -11242,7 +11523,7 @@ function readLog(file, from = 0, expectSeq = null) {
11242
11523
  bytes = bytes.subarray(0, read);
11243
11524
  size = from + read;
11244
11525
  } finally {
11245
- fs9.closeSync(fd);
11526
+ fs10.closeSync(fd);
11246
11527
  }
11247
11528
  const events = [];
11248
11529
  let start = 0;
@@ -11267,11 +11548,11 @@ function readLog(file, from = 0, expectSeq = null) {
11267
11548
  }
11268
11549
  var fsyncDirectory = (dir) => {
11269
11550
  try {
11270
- const fd = fs9.openSync(dir, "r");
11551
+ const fd = fs10.openSync(dir, "r");
11271
11552
  try {
11272
- fs9.fsyncSync(fd);
11553
+ fs10.fsyncSync(fd);
11273
11554
  } finally {
11274
- fs9.closeSync(fd);
11555
+ fs10.closeSync(fd);
11275
11556
  }
11276
11557
  } catch (error) {
11277
11558
  if (process.platform !== "win32")
@@ -11281,20 +11562,20 @@ var fsyncDirectory = (dir) => {
11281
11562
  function replaceFile(file, bytes, durable) {
11282
11563
  const temporary = `${file}.${process.pid}.${randomUUID2()}.tmp`;
11283
11564
  try {
11284
- const fd = fs9.openSync(temporary, "wx", 384);
11565
+ const fd = fs10.openSync(temporary, "wx", 384);
11285
11566
  try {
11286
- fs9.writeSync(fd, bytes);
11567
+ fs10.writeSync(fd, bytes);
11287
11568
  if (durable)
11288
- fs9.fsyncSync(fd);
11569
+ fs10.fsyncSync(fd);
11289
11570
  } finally {
11290
- fs9.closeSync(fd);
11571
+ fs10.closeSync(fd);
11291
11572
  }
11292
11573
  renameWithRetry(temporary, file);
11293
11574
  if (durable)
11294
- fsyncDirectory(path12.dirname(file));
11575
+ fsyncDirectory(path13.dirname(file));
11295
11576
  } catch (error) {
11296
11577
  try {
11297
- fs9.unlinkSync(temporary);
11578
+ fs10.unlinkSync(temporary);
11298
11579
  } catch {}
11299
11580
  throw error;
11300
11581
  }
@@ -11319,7 +11600,7 @@ var retryTransient = (run) => {
11319
11600
  }
11320
11601
  }
11321
11602
  };
11322
- var renameWithRetry = (from, to) => retryTransient(() => fs9.renameSync(from, to));
11603
+ var renameWithRetry = (from, to) => retryTransient(() => fs10.renameSync(from, to));
11323
11604
 
11324
11605
  // packages/workit-core/src/store/patch.ts
11325
11606
  var isPlainObject2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
@@ -11511,7 +11792,7 @@ var indexEntry = (task, key, legacy, file) => {
11511
11792
  };
11512
11793
  var fileSignature = (file) => {
11513
11794
  try {
11514
- const stat = fs10.statSync(file, { bigint: true });
11795
+ const stat = fs11.statSync(file, { bigint: true });
11515
11796
  return `${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeNs}:${stat.ctimeNs}`;
11516
11797
  } catch {
11517
11798
  return null;
@@ -11528,7 +11809,7 @@ var cachedRuntimeVersion = null;
11528
11809
  var runtimeVersion = () => {
11529
11810
  if (cachedRuntimeVersion === null) {
11530
11811
  try {
11531
- const pkg = JSON.parse(fs10.readFileSync(path13.join(packageRoot(), "package.json"), "utf8"));
11812
+ const pkg = JSON.parse(fs11.readFileSync(path14.join(packageRoot(), "package.json"), "utf8"));
11532
11813
  cachedRuntimeVersion = typeof pkg.version === "string" && pkg.version ? pkg.version : "0.0.0";
11533
11814
  } catch {
11534
11815
  cachedRuntimeVersion = "0.0.0";
@@ -11550,14 +11831,14 @@ var isNewerVersion = (candidate, current) => {
11550
11831
  var validId = (value) => /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(value);
11551
11832
  var readText2 = (file) => {
11552
11833
  try {
11553
- return fs10.readFileSync(file, "utf8");
11834
+ return fs11.readFileSync(file, "utf8");
11554
11835
  } catch {
11555
11836
  return "";
11556
11837
  }
11557
11838
  };
11558
11839
  var REFLOG_LINE = /^[0-9a-f]+ ([0-9a-f]+) .* (\d+) [+-]\d{4}\t(.*)$/u;
11559
11840
  var branchStart = (location, branch, aliases) => {
11560
- const first = readText2(path13.join(path13.dirname(location.dir), "logs", "refs", "heads", branch)).split(`
11841
+ const first = readText2(path14.join(path14.dirname(location.dir), "logs", "refs", "heads", branch)).split(`
11561
11842
  `, 1)[0];
11562
11843
  const created = REFLOG_LINE.exec(first);
11563
11844
  const start = created && /^branch: Created from (\S+)$/u.exec(created[3])?.[1];
@@ -11567,7 +11848,7 @@ var branchStart = (location, branch, aliases) => {
11567
11848
  return start;
11568
11849
  if (!location.git)
11569
11850
  return null;
11570
- for (const line of readText2(path13.join(location.git.gitDir, "logs", "HEAD")).split(`
11851
+ for (const line of readText2(path14.join(location.git.gitDir, "logs", "HEAD")).split(`
11571
11852
  `)) {
11572
11853
  const entry = REFLOG_LINE.exec(line);
11573
11854
  const moved = entry && /^checkout: moving from (\S+) to (\S+)$/u.exec(entry[3]);
@@ -11577,23 +11858,23 @@ var branchStart = (location, branch, aliases) => {
11577
11858
  }
11578
11859
  return null;
11579
11860
  };
11580
- var refExists2 = (common, ref) => fs10.existsSync(path13.join(common, ref)) || readText2(path13.join(common, "packed-refs")).includes(` ${ref}
11861
+ var refExists2 = (common, ref) => fs11.existsSync(path14.join(common, ref)) || readText2(path14.join(common, "packed-refs")).includes(` ${ref}
11581
11862
  `);
11582
11863
  var origins = new Map;
11583
11864
  var sameDirectoryIdentity = (left, right) => {
11584
- if (!path13.isAbsolute(left) || !path13.isAbsolute(right))
11865
+ if (!path14.isAbsolute(left) || !path14.isAbsolute(right))
11585
11866
  return false;
11586
- const normalizedLeft = path13.resolve(left);
11587
- const normalizedRight = path13.resolve(right);
11867
+ const normalizedLeft = path14.resolve(left);
11868
+ const normalizedRight = path14.resolve(right);
11588
11869
  try {
11589
- const a = fs10.statSync(normalizedLeft, { bigint: true });
11590
- const b = fs10.statSync(normalizedRight, { bigint: true });
11870
+ const a = fs11.statSync(normalizedLeft, { bigint: true });
11871
+ const b = fs11.statSync(normalizedRight, { bigint: true });
11591
11872
  if (!a.isDirectory() || !b.isDirectory())
11592
11873
  return false;
11593
11874
  if (process.platform === "win32" ? normalizedLeft.toLowerCase() === normalizedRight.toLowerCase() : normalizedLeft === normalizedRight)
11594
11875
  return true;
11595
- const canonicalLeft = fs10.realpathSync(normalizedLeft);
11596
- const canonicalRight = fs10.realpathSync(normalizedRight);
11876
+ const canonicalLeft = fs11.realpathSync(normalizedLeft);
11877
+ const canonicalRight = fs11.realpathSync(normalizedRight);
11597
11878
  if (process.platform === "win32" ? canonicalLeft.toLowerCase() === canonicalRight.toLowerCase() : canonicalLeft === canonicalRight)
11598
11879
  return true;
11599
11880
  return a.dev === b.dev && a.ino !== 0n && a.ino === b.ino;
@@ -11618,14 +11899,14 @@ class TaskReader {
11618
11899
  located;
11619
11900
  migrationChecked = false;
11620
11901
  constructor(root, options = {}) {
11621
- const resolved = path13.resolve(root);
11622
- this.origin = fs10.existsSync(resolved) ? fs10.realpathSync(resolved) : resolved;
11902
+ const resolved = path14.resolve(root);
11903
+ this.origin = fs11.existsSync(resolved) ? fs11.realpathSync(resolved) : resolved;
11623
11904
  this.located = resolveStore(this.origin);
11624
11905
  this.root = checkoutRootOf(this.origin, this.located);
11625
11906
  this.lockTimeoutMs = options.lockTimeoutMs ?? defaultLockTimeout();
11626
11907
  }
11627
11908
  location() {
11628
- if (this.located !== undefined && !(this.located instanceof Error) && !this.located.shared && fs10.existsSync(path13.join(this.root, ".git"))) {
11909
+ if (this.located !== undefined && !(this.located instanceof Error) && !this.located.shared && fs11.existsSync(path14.join(this.root, ".git"))) {
11629
11910
  this.located = undefined;
11630
11911
  this.migrationChecked = false;
11631
11912
  }
@@ -11689,7 +11970,7 @@ class TaskReader {
11689
11970
  const tasksDir = this.paths().tasks;
11690
11971
  let names;
11691
11972
  try {
11692
- names = fs10.existsSync(tasksDir) ? fs10.readdirSync(tasksDir).filter((name) => validId(name)) : [];
11973
+ names = fs11.existsSync(tasksDir) ? fs11.readdirSync(tasksDir).filter((name) => validId(name)) : [];
11693
11974
  } catch (error) {
11694
11975
  return failure2("storage_error", `unable to list tasks: ${String(error)}`, {
11695
11976
  path: tasksDir
@@ -11730,7 +12011,7 @@ class TaskReader {
11730
12011
  const file = this.paths().workspace;
11731
12012
  let bytes;
11732
12013
  try {
11733
- bytes = retryTransient(() => fs10.readFileSync(file, "utf8"));
12014
+ bytes = retryTransient(() => fs11.readFileSync(file, "utf8"));
11734
12015
  } catch (error) {
11735
12016
  if (error.code === "ENOENT")
11736
12017
  return success(null, null, null);
@@ -11783,14 +12064,14 @@ class TaskReader {
11783
12064
  const branch = key.ok ? key.data.branch : null;
11784
12065
  if (!branch || !location.ok)
11785
12066
  return success(null, null, null);
11786
- const common = path13.dirname(location.data.dir);
11787
- const heads = path13.join(common, "logs", "refs", "heads");
11788
- const headLog = location.data.git ? path13.join(location.data.git.gitDir, "logs", "HEAD") : "";
12067
+ const common = path14.dirname(location.data.dir);
12068
+ const heads = path14.join(common, "logs", "refs", "heads");
12069
+ const headLog = location.data.git ? path14.join(location.data.git.gitDir, "logs", "HEAD") : "";
11789
12070
  const signatures = [
11790
- path13.join(heads, branch),
12071
+ path14.join(heads, branch),
11791
12072
  headLog,
11792
12073
  heads,
11793
- path13.join(common, "packed-refs")
12074
+ path14.join(common, "packed-refs")
11794
12075
  ].map((file) => fileSignature(file) ?? "-");
11795
12076
  const slot = `${location.data.dir}\x00${headLog}\x00${branch}`;
11796
12077
  let resolved = origins.get(slot);
@@ -11802,7 +12083,7 @@ class TaskReader {
11802
12083
  aliases.push(rename.from);
11803
12084
  const start = branchStart(location.data, branch, aliases);
11804
12085
  const slash = start?.indexOf("/") ?? -1;
11805
- const remote = slash > 0 && !refExists2(common, `refs/heads/${start}`) && (refExists2(common, `refs/remotes/${start}`) || readText2(path13.join(common, "config")).includes(`[remote "${start.slice(0, slash)}"]`));
12086
+ const remote = slash > 0 && !refExists2(common, `refs/heads/${start}`) && (refExists2(common, `refs/remotes/${start}`) || readText2(path14.join(common, "config")).includes(`[remote "${start.slice(0, slash)}"]`));
11806
12087
  const name = start && (remote ? start.slice(slash + 1) : start);
11807
12088
  resolved = {
11808
12089
  signature: signatures.join("|"),
@@ -11822,27 +12103,27 @@ class TaskReader {
11822
12103
  }
11823
12104
  paths() {
11824
12105
  const location = this.location();
11825
- const dir = location.ok ? location.data.dir : path13.join(this.root, ".workit");
11826
- const checkout = path13.join(dir, "checkouts", checkoutSlug(this.root));
12106
+ const dir = location.ok ? location.data.dir : path14.join(this.root, ".workit");
12107
+ const checkout = path14.join(dir, "checkouts", checkoutSlug(this.root));
11827
12108
  return {
11828
12109
  dir,
11829
12110
  shared: location.ok ? location.data.shared : false,
11830
- marker: path13.join(dir, "store.json"),
12111
+ marker: path14.join(dir, "store.json"),
11831
12112
  checkout,
11832
- workspace: path13.join(checkout, "workspace.json"),
11833
- checkoutLock: path13.join(checkout, "metadata.lock"),
11834
- tasks: path13.join(dir, "tasks"),
11835
- index: path13.join(dir, "task-index.json"),
11836
- blobs: path13.join(dir, "blobs", "candidates"),
11837
- legacy: path13.join(dir, "legacy", checkoutSlug(this.root), "v2"),
11838
- v2: path13.join(this.root, ".workit")
12113
+ workspace: path14.join(checkout, "workspace.json"),
12114
+ checkoutLock: path14.join(checkout, "metadata.lock"),
12115
+ tasks: path14.join(dir, "tasks"),
12116
+ index: path14.join(dir, "task-index.json"),
12117
+ blobs: path14.join(dir, "blobs", "candidates"),
12118
+ legacy: path14.join(dir, "legacy", checkoutSlug(this.root), "v2"),
12119
+ v2: path14.join(this.root, ".workit")
11839
12120
  };
11840
12121
  }
11841
12122
  eventsPath(taskId) {
11842
- return path13.join(this.paths().tasks, taskId, "events.jsonl");
12123
+ return path14.join(this.paths().tasks, taskId, "events.jsonl");
11843
12124
  }
11844
12125
  snapshotPath(taskId) {
11845
- return path13.join(this.paths().tasks, taskId, "snapshot.json");
12126
+ return path14.join(this.paths().tasks, taskId, "snapshot.json");
11846
12127
  }
11847
12128
  ready(write = false) {
11848
12129
  const location = this.location();
@@ -11852,7 +12133,7 @@ class TaskReader {
11852
12133
  return success(null, null, null);
11853
12134
  const dirs = this.paths();
11854
12135
  try {
11855
- const marker = JSON.parse(fs10.readFileSync(dirs.marker, "utf8"));
12136
+ const marker = JSON.parse(fs11.readFileSync(dirs.marker, "utf8"));
11856
12137
  if (typeof marker.version === "number" && marker.version > STORE_FORMAT)
11857
12138
  return failure2("recovery_required", `the workit store at ${dirs.dir} has format ${marker.version}; upgrade Workit to use it`, { path: dirs.marker });
11858
12139
  } catch {}
@@ -11877,7 +12158,7 @@ class TaskReader {
11877
12158
  return {
11878
12159
  read: (digest) => {
11879
12160
  try {
11880
- return JSON.parse(fs10.readFileSync(path13.join(dir, `${digest}.json`), "utf8"));
12161
+ return JSON.parse(fs11.readFileSync(path14.join(dir, `${digest}.json`), "utf8"));
11881
12162
  } catch (error) {
11882
12163
  throw new LogDamage(`stored candidate ${digest} is missing or unreadable: ${String(error)}`);
11883
12164
  }
@@ -11964,7 +12245,7 @@ class TaskReader {
11964
12245
  }
11965
12246
  readSnapshot(taskId) {
11966
12247
  try {
11967
- const value = JSON.parse(fs10.readFileSync(this.snapshotPath(taskId), "utf8"));
12248
+ const value = JSON.parse(fs11.readFileSync(this.snapshotPath(taskId), "utf8"));
11968
12249
  if (!isObject5(value) || value.v !== 1 || value.task !== taskId || typeof value.seq !== "number" || typeof value.lastId !== "string" || typeof value.lastStart !== "number" || typeof value.end !== "number" || !isObject5(value.record))
11969
12250
  return null;
11970
12251
  return value;
@@ -11991,7 +12272,7 @@ class TaskReader {
11991
12272
  }
11992
12273
  readIndex() {
11993
12274
  try {
11994
- const value = JSON.parse(fs10.readFileSync(this.paths().index, "utf8"));
12275
+ const value = JSON.parse(fs11.readFileSync(this.paths().index, "utf8"));
11995
12276
  if (!isObject5(value) || value.version !== INDEX_VERSION || !isObject5(value.tasks))
11996
12277
  return {};
11997
12278
  const tasks = {};
@@ -12005,7 +12286,7 @@ class TaskReader {
12005
12286
  }
12006
12287
  writeIndex(entries) {
12007
12288
  try {
12008
- fs10.mkdirSync(this.paths().tasks, { recursive: true });
12289
+ fs11.mkdirSync(this.paths().tasks, { recursive: true });
12009
12290
  replaceFile(this.paths().index, JSON.stringify({
12010
12291
  version: INDEX_VERSION,
12011
12292
  tasks: Object.fromEntries(entries.map((entry) => [entry.id, entry]))
@@ -12043,64 +12324,74 @@ class TaskReader {
12043
12324
  return failure2("recovery_required", `${label} record does not satisfy its schema`);
12044
12325
  }
12045
12326
  v2Dirs() {
12046
- return [...new Set([this.root, this.origin])].map((dir) => path13.join(dir, ".workit"));
12327
+ return [...new Set([this.root, this.origin])].map((dir) => path14.join(dir, ".workit"));
12047
12328
  }
12048
12329
  pendingMigrations() {
12049
12330
  return this.v2Dirs().filter((dir) => {
12050
- const raw = this.readV2Workspace(path13.join(dir, "workspace.json"));
12331
+ const raw = this.readV2Workspace(path14.join(dir, "workspace.json"));
12051
12332
  return raw !== null && raw !== TOMBSTONE;
12052
12333
  });
12053
12334
  }
12054
12335
  adoptLocalStore() {
12336
+ if (!this.paths().shared)
12337
+ return success(null, null, null);
12338
+ for (const local of [this.paths().v2, folderStoreDir2(this.root)]) {
12339
+ const adopted = this.adoptStoreFrom(local);
12340
+ if (!adopted.ok)
12341
+ return adopted;
12342
+ }
12343
+ return success(null, null, null);
12344
+ }
12345
+ adoptStoreFrom(local) {
12055
12346
  const dirs = this.paths();
12056
- const marker = path13.join(dirs.v2, "store.json");
12057
- if (!dirs.shared || !fs10.existsSync(marker))
12347
+ const marker = path14.join(local, "store.json");
12348
+ if (!fs11.existsSync(marker))
12058
12349
  return success(null, null, null);
12059
12350
  return this.withLock(dirs.checkoutLock, () => {
12060
- if (!fs10.existsSync(marker))
12351
+ if (!fs11.existsSync(marker))
12061
12352
  return success(null, null, null);
12062
12353
  let tasks = 0;
12063
12354
  try {
12064
12355
  const merge = (from, to) => {
12065
- if (!fs10.existsSync(to)) {
12066
- fs10.mkdirSync(path13.dirname(to), { recursive: true });
12356
+ if (!fs11.existsSync(to)) {
12357
+ fs11.mkdirSync(path14.dirname(to), { recursive: true });
12067
12358
  try {
12068
- fs10.renameSync(from, to);
12359
+ fs11.renameSync(from, to);
12069
12360
  } catch {
12070
- fs10.cpSync(from, to, { recursive: true, errorOnExist: true, force: false });
12071
- fs10.rmSync(from, { recursive: true, force: true });
12361
+ fs11.cpSync(from, to, { recursive: true, errorOnExist: true, force: false });
12362
+ fs11.rmSync(from, { recursive: true, force: true });
12072
12363
  }
12073
12364
  return;
12074
12365
  }
12075
- if (fs10.lstatSync(from).isDirectory() && fs10.lstatSync(to).isDirectory())
12076
- for (const name of fs10.readdirSync(from))
12077
- merge(path13.join(from, name), path13.join(to, name));
12366
+ if (fs11.lstatSync(from).isDirectory() && fs11.lstatSync(to).isDirectory())
12367
+ for (const name of fs11.readdirSync(from))
12368
+ merge(path14.join(from, name), path14.join(to, name));
12078
12369
  };
12079
12370
  for (const sub of ["tasks", "checkouts", "blobs", "legacy"]) {
12080
- const from = path13.join(dirs.v2, sub);
12081
- if (!fs10.existsSync(from))
12371
+ const from = path14.join(local, sub);
12372
+ if (!fs11.existsSync(from))
12082
12373
  continue;
12083
12374
  if (sub === "tasks") {
12084
- for (const name of fs10.readdirSync(from))
12085
- if (validId(name) && !fs10.existsSync(path13.join(dirs.dir, sub, name)))
12375
+ for (const name of fs11.readdirSync(from))
12376
+ if (validId(name) && !fs11.existsSync(path14.join(dirs.dir, sub, name)))
12086
12377
  tasks += 1;
12087
12378
  }
12088
- merge(from, path13.join(dirs.dir, sub));
12379
+ merge(from, path14.join(dirs.dir, sub));
12089
12380
  }
12090
- const ledger = path13.join(dirs.v2, "ledger");
12091
- if (fs10.existsSync(ledger) && !fs10.existsSync(path13.join(dirs.dir, "ledger")))
12092
- merge(ledger, path13.join(dirs.dir, "ledger"));
12093
- fs10.rmSync(path13.join(dirs.v2, "task-index.json"), { force: true });
12094
- fs10.renameSync(marker, path13.join(dirs.v2, "store.moved.json"));
12381
+ const ledger = path14.join(local, "ledger");
12382
+ if (fs11.existsSync(ledger) && !fs11.existsSync(path14.join(dirs.dir, "ledger")))
12383
+ merge(ledger, path14.join(dirs.dir, "ledger"));
12384
+ fs11.rmSync(path14.join(local, "task-index.json"), { force: true });
12385
+ fs11.renameSync(marker, path14.join(local, "store.moved.json"));
12095
12386
  } catch (error) {
12096
- return failure2("storage_error", `cannot move ${dirs.v2} into ${dirs.dir}: ${String(error)}`, {
12097
- path: dirs.v2
12387
+ return failure2("storage_error", `cannot move ${local} into ${dirs.dir}: ${String(error)}`, {
12388
+ path: local
12098
12389
  });
12099
12390
  }
12100
12391
  reportMigration({
12101
- from: dirs.v2,
12392
+ from: local,
12102
12393
  to: dirs.dir,
12103
- backup: dirs.v2,
12394
+ backup: local,
12104
12395
  tasks,
12105
12396
  skipped: 0,
12106
12397
  workspace: false
@@ -12111,7 +12402,7 @@ class TaskReader {
12111
12402
  readV2Workspace(file) {
12112
12403
  let bytes;
12113
12404
  try {
12114
- bytes = fs10.readFileSync(file, "utf8");
12405
+ bytes = fs11.readFileSync(file, "utf8");
12115
12406
  } catch {
12116
12407
  return null;
12117
12408
  }
@@ -12129,7 +12420,7 @@ class TaskReader {
12129
12420
  schemaVersion: SCHEMA_VERSION,
12130
12421
  id: workspaceId ?? newId(),
12131
12422
  revision: newRevision(),
12132
- root: path13.dirname(v2),
12423
+ root: path14.dirname(v2),
12133
12424
  runtime: { createdWith: version, updatedWith: version },
12134
12425
  writer: null,
12135
12426
  store: {
@@ -12140,47 +12431,21 @@ class TaskReader {
12140
12431
  },
12141
12432
  critical: ["store"]
12142
12433
  };
12143
- fs10.mkdirSync(v2, { recursive: true });
12144
- const ignore = path13.join(v2, ".gitignore");
12145
- if (!fs10.existsSync(ignore))
12146
- fs10.writeFileSync(ignore, `*
12434
+ fs11.mkdirSync(v2, { recursive: true });
12435
+ const ignore = path14.join(v2, ".gitignore");
12436
+ if (!fs11.existsSync(ignore))
12437
+ fs11.writeFileSync(ignore, `*
12147
12438
  `);
12148
- replaceFile(path13.join(v2, "workspace.json"), `${JSON.stringify(marker, null, 2)}
12439
+ replaceFile(path14.join(v2, "workspace.json"), `${JSON.stringify(marker, null, 2)}
12149
12440
  `, true);
12150
12441
  }
12151
- writeTombstoneIfMissing() {
12152
- try {
12153
- if (this.paths().shared)
12154
- return;
12155
- const v2 = path13.join(this.root, ".workit");
12156
- if (fs10.existsSync(path13.join(v2, "workspace.json")))
12157
- return;
12158
- let id = null;
12159
- try {
12160
- id = JSON.parse(fs10.readFileSync(this.paths().workspace, "utf8")).id ?? null;
12161
- } catch {}
12162
- this.writeTombstone(v2, id);
12163
- } catch {}
12164
- }
12165
12442
  initializeStorage() {
12166
12443
  const dirs = this.paths();
12167
- retryTransient(() => fs10.mkdirSync(dirs.checkout, { recursive: true }));
12168
- retryTransient(() => fs10.mkdirSync(dirs.tasks, { recursive: true }));
12169
- if (!fs10.existsSync(dirs.marker))
12444
+ retryTransient(() => fs11.mkdirSync(dirs.checkout, { recursive: true }));
12445
+ retryTransient(() => fs11.mkdirSync(dirs.tasks, { recursive: true }));
12446
+ if (!fs11.existsSync(dirs.marker))
12170
12447
  replaceFile(dirs.marker, `${JSON.stringify({ format: "workit-store", version: STORE_FORMAT, createdWith: runtimeVersion() })}
12171
12448
  `, false);
12172
- if (!dirs.shared) {
12173
- const ignore = path13.join(dirs.dir, ".gitignore");
12174
- let current = null;
12175
- try {
12176
- current = fs10.readFileSync(ignore, "utf8");
12177
- } catch {}
12178
- if (current !== `*
12179
- `)
12180
- retryTransient(() => fs10.writeFileSync(ignore, `*
12181
- `));
12182
- }
12183
- this.writeTombstoneIfMissing();
12184
12449
  }
12185
12450
  lockOptions(lockPath) {
12186
12451
  const inProcess = heldInProcess.has(lockPath);
@@ -12193,7 +12458,7 @@ class TaskReader {
12193
12458
  shouldReclaim: ({ payload, nowMs }) => {
12194
12459
  let ageMs = null;
12195
12460
  try {
12196
- ageMs = nowMs - fs10.lstatSync(lockPath).mtimeMs;
12461
+ ageMs = nowMs - fs11.lstatSync(lockPath).mtimeMs;
12197
12462
  } catch {}
12198
12463
  return classifyLockOwner(payload, ageMs, localLockHost(), TASK_STORE_LOCK).state === "stale";
12199
12464
  },
@@ -12230,7 +12495,7 @@ class TaskReader {
12230
12495
  withLock(lockPath, operation) {
12231
12496
  try {
12232
12497
  this.initializeStorage();
12233
- fs10.mkdirSync(path13.dirname(lockPath), { recursive: true });
12498
+ fs11.mkdirSync(path14.dirname(lockPath), { recursive: true });
12234
12499
  } catch (error) {
12235
12500
  return failure2("storage_error", `unable to initialize store: ${String(error)}`, {
12236
12501
  path: this.paths().dir
@@ -12270,18 +12535,18 @@ class TaskReader {
12270
12535
  lockDirWritable(lockPath) {
12271
12536
  const probe = `${lockPath}.${process.pid}.${randomUUID3()}.probe`;
12272
12537
  try {
12273
- fs10.closeSync(fs10.openSync(probe, "wx", 384));
12538
+ fs11.closeSync(fs11.openSync(probe, "wx", 384));
12274
12539
  } catch {
12275
12540
  return false;
12276
12541
  }
12277
12542
  try {
12278
- fs10.rmSync(probe, { force: true });
12543
+ fs11.rmSync(probe, { force: true });
12279
12544
  } catch {}
12280
12545
  return true;
12281
12546
  }
12282
12547
  lockHolderPresent(lockPath) {
12283
12548
  try {
12284
- fs10.lstatSync(lockPath);
12549
+ fs11.lstatSync(lockPath);
12285
12550
  return true;
12286
12551
  } catch (error) {
12287
12552
  return error?.code !== "ENOENT";
@@ -12293,12 +12558,12 @@ class TaskReader {
12293
12558
  if (isTransientWindowsError(error) && !this.lockHolderPresent(lockPath) && !this.lockDirWritable(lockPath))
12294
12559
  return failure2("storage_error", `cannot create the workit lock (${code}); no other Workit call holds it`, {
12295
12560
  path: lockPath,
12296
- guidance: `Check permissions and the read-only attribute on ${path13.dirname(lockPath)}.`
12561
+ guidance: `Check permissions and the read-only attribute on ${path14.dirname(lockPath)}.`
12297
12562
  });
12298
12563
  if (code === "EEXIST" || code === "file_lock_timeout" || code === "file_lock_stale" || isTransientWindowsError(error)) {
12299
12564
  let lock = null;
12300
12565
  try {
12301
- lock = parseMetadataLockOrNull(fs10.readFileSync(lockPath, "utf8"));
12566
+ lock = parseMetadataLockOrNull(fs11.readFileSync(lockPath, "utf8"));
12302
12567
  } catch {}
12303
12568
  return failure2("busy", `workit lock is held by another Workit call${lock ? ` (pid ${lock.pid} on ${lock.host})` : ""}; retry shortly`, {
12304
12569
  outcome: "not_started",
@@ -12313,13 +12578,13 @@ class TaskReader {
12313
12578
 
12314
12579
  // packages/workit-core/src/core/policy/derive.ts
12315
12580
  import { existsSync as existsSync7 } from "node:fs";
12316
- import path17 from "node:path";
12581
+ import path18 from "node:path";
12317
12582
 
12318
12583
  // packages/workit-core/src/ledger.ts
12319
12584
  import { spawnSync as spawnSync11 } from "node:child_process";
12320
12585
  import { createHash as createHash9, randomBytes as randomBytes3 } from "node:crypto";
12321
- import fs12 from "node:fs";
12322
- import path16 from "node:path";
12586
+ import fs13 from "node:fs";
12587
+ import path17 from "node:path";
12323
12588
 
12324
12589
  // packages/workit-core/src/core/policy/bookkeeping.ts
12325
12590
  import { spawnSync as spawnSync9 } from "node:child_process";
@@ -12400,7 +12665,7 @@ function bookkeepingPaths(cwd, input) {
12400
12665
 
12401
12666
  // packages/workit-core/src/core/policy/lane.ts
12402
12667
  import { existsSync as existsSync6, readFileSync as readFileSync7 } from "node:fs";
12403
- import path14 from "node:path";
12668
+ import path15 from "node:path";
12404
12669
 
12405
12670
  // packages/workit-core/src/git/default-base.ts
12406
12671
  import { spawnSync as spawnSync10 } from "node:child_process";
@@ -13788,7 +14053,7 @@ function computeLane(input) {
13788
14053
  }
13789
14054
  function untrackedStat(cwd, file) {
13790
14055
  try {
13791
- const bytes = readFileSync7(path14.join(cwd, file));
14056
+ const bytes = readFileSync7(path15.join(cwd, file));
13792
14057
  if (bytes.includes(0))
13793
14058
  return { path: file, added: 0, deleted: 0, binary: true };
13794
14059
  const text = bytes.toString("utf8");
@@ -13820,7 +14085,7 @@ function cosmeticFiles(cwd, fork, head) {
13820
14085
  let after = blobs.get(entry.newBlob);
13821
14086
  if (!after && head === null && ABSENT.test(entry.newBlob))
13822
14087
  try {
13823
- after = readFileSync7(path14.join(cwd, entry.path));
14088
+ after = readFileSync7(path15.join(cwd, entry.path));
13824
14089
  } catch {
13825
14090
  after = undefined;
13826
14091
  }
@@ -13976,13 +14241,13 @@ function verdictDrift(cwd, input) {
13976
14241
 
13977
14242
  // packages/workit-core/src/host-session.ts
13978
14243
  import { createHash as createHash8, randomBytes as randomBytes2, timingSafeEqual } from "node:crypto";
13979
- import fs11 from "node:fs";
13980
- import path15 from "node:path";
14244
+ import fs12 from "node:fs";
14245
+ import path16 from "node:path";
13981
14246
  var ISSUED_PER_LEAD = 64;
13982
14247
  var ISSUED_SESSIONS_MARKER = "workit-issued-sessions/3";
13983
14248
  var hash = (value) => createHash8("sha256").update(value).digest("hex").slice(0, 32);
13984
- var userIssuedRoot = () => path15.join(resolveStateDir(), "issued");
13985
- var userTokenRoot = () => path15.join(resolveStateDir(), "issued-tokens");
14249
+ var userIssuedRoot = () => path16.join(resolveStateDir(), "issued");
14250
+ var userTokenRoot = () => path16.join(resolveStateDir(), "issued-tokens");
13986
14251
  function migrateRepoIssued(cwd) {
13987
14252
  if (cwd === undefined)
13988
14253
  return;
@@ -13991,27 +14256,27 @@ function migrateRepoIssued(cwd) {
13991
14256
  const location = resolveStore(cwd);
13992
14257
  if (location instanceof Error)
13993
14258
  return;
13994
- old = path15.join(location.dir, "hooks", "issued");
13995
- if (!fs11.existsSync(old))
14259
+ old = path16.join(location.dir, "hooks", "issued");
14260
+ if (!fs12.existsSync(old))
13996
14261
  return;
13997
14262
  } catch {
13998
14263
  return;
13999
14264
  }
14000
14265
  for (const lead of safeList(old)) {
14001
14266
  try {
14002
- const from = path15.join(old, lead);
14003
- if (!fs11.statSync(from).isDirectory())
14267
+ const from = path16.join(old, lead);
14268
+ if (!fs12.statSync(from).isDirectory())
14004
14269
  continue;
14005
- const to = path15.join(userIssuedRoot(), lead);
14006
- fs11.mkdirSync(to, { recursive: true, mode: 448 });
14007
- for (const id of fs11.readdirSync(from)) {
14270
+ const to = path16.join(userIssuedRoot(), lead);
14271
+ fs12.mkdirSync(to, { recursive: true, mode: 448 });
14272
+ for (const id of fs12.readdirSync(from)) {
14008
14273
  try {
14009
- fs11.copyFileSync(path15.join(from, id), path15.join(to, id), fs11.constants.COPYFILE_EXCL);
14274
+ fs12.copyFileSync(path16.join(from, id), path16.join(to, id), fs12.constants.COPYFILE_EXCL);
14010
14275
  } catch (error) {
14011
14276
  if (error.code !== "EEXIST")
14012
14277
  throw error;
14013
14278
  }
14014
- fs11.rmSync(path15.join(from, id), { force: true });
14279
+ fs12.rmSync(path16.join(from, id), { force: true });
14015
14280
  }
14016
14281
  removeIfEmpty(from);
14017
14282
  } catch {}
@@ -14020,14 +14285,14 @@ function migrateRepoIssued(cwd) {
14020
14285
  }
14021
14286
  var safeList = (dir) => {
14022
14287
  try {
14023
- return fs11.readdirSync(dir);
14288
+ return fs12.readdirSync(dir);
14024
14289
  } catch {
14025
14290
  return [];
14026
14291
  }
14027
14292
  };
14028
14293
  var removeIfEmpty = (dir) => {
14029
14294
  try {
14030
- fs11.rmdirSync(dir);
14295
+ fs12.rmdirSync(dir);
14031
14296
  } catch {}
14032
14297
  };
14033
14298
  var tokenHash = (token) => createHash8("sha256").update(token).digest("hex");
@@ -14036,13 +14301,13 @@ function recordIssuedSession(cwd, lead, issued) {
14036
14301
  try {
14037
14302
  migrateRepoIssued(cwd);
14038
14303
  const own = hash(issued);
14039
- const tokens = path15.join(userTokenRoot(), hash(lead));
14040
- fs11.mkdirSync(tokens, { recursive: true, mode: 448 });
14041
- fs11.writeFileSync(path15.join(tokens, own), `${tokenHash(token)}
14304
+ const tokens = path16.join(userTokenRoot(), hash(lead));
14305
+ fs12.mkdirSync(tokens, { recursive: true, mode: 448 });
14306
+ fs12.writeFileSync(path16.join(tokens, own), `${tokenHash(token)}
14042
14307
  `, { mode: 384, flag: "wx" });
14043
- const dir = path15.join(userIssuedRoot(), hash(lead));
14044
- fs11.mkdirSync(dir, { recursive: true, mode: 448 });
14045
- fs11.writeFileSync(path15.join(dir, own), `${ISSUED_SESSIONS_MARKER}
14308
+ const dir = path16.join(userIssuedRoot(), hash(lead));
14309
+ fs12.mkdirSync(dir, { recursive: true, mode: 448 });
14310
+ fs12.writeFileSync(path16.join(dir, own), `${ISSUED_SESSIONS_MARKER}
14046
14311
  `, { mode: 384 });
14047
14312
  pruneIssued(dir, own, tokens);
14048
14313
  return token;
@@ -14069,13 +14334,13 @@ function verdictCommand(options) {
14069
14334
  }
14070
14335
  function pruneIssued(dir, own, tokens) {
14071
14336
  try {
14072
- const entries = fs11.readdirSync(dir);
14337
+ const entries = fs12.readdirSync(dir);
14073
14338
  if (entries.length <= ISSUED_PER_LEAD)
14074
14339
  return;
14075
- const byAge = entries.filter((name) => name !== own).map((name) => ({ name, at: fs11.statSync(path15.join(dir, name)).mtimeMs })).toSorted((a, b) => a.at - b.at);
14340
+ const byAge = entries.filter((name) => name !== own).map((name) => ({ name, at: fs12.statSync(path16.join(dir, name)).mtimeMs })).toSorted((a, b) => a.at - b.at);
14076
14341
  for (const { name } of byAge.slice(0, entries.length - ISSUED_PER_LEAD)) {
14077
- fs11.rmSync(path15.join(dir, name), { force: true });
14078
- fs11.rmSync(path15.join(tokens, name), { force: true });
14342
+ fs12.rmSync(path16.join(dir, name), { force: true });
14343
+ fs12.rmSync(path16.join(tokens, name), { force: true });
14079
14344
  }
14080
14345
  } catch {}
14081
14346
  }
@@ -14085,7 +14350,7 @@ var issuedRecord = (cwd, claimed) => {
14085
14350
  return null;
14086
14351
  migrateRepoIssued(cwd);
14087
14352
  try {
14088
- return fs11.readFileSync(path15.join(userIssuedRoot(), hash(claimed.slice(0, cut)), hash(claimed)), "utf8");
14353
+ return fs12.readFileSync(path16.join(userIssuedRoot(), hash(claimed.slice(0, cut)), hash(claimed)), "utf8");
14089
14354
  } catch {
14090
14355
  return null;
14091
14356
  }
@@ -14095,9 +14360,9 @@ var issuedToken = (claimed) => {
14095
14360
  const cut = claimed.lastIndexOf(":");
14096
14361
  if (cut <= 0)
14097
14362
  return { stored: null, leadBound: false };
14098
- const dir = path15.join(userTokenRoot(), hash(claimed.slice(0, cut)));
14363
+ const dir = path16.join(userTokenRoot(), hash(claimed.slice(0, cut)));
14099
14364
  try {
14100
- const text = fs11.readFileSync(path15.join(dir, hash(claimed)), "utf8");
14365
+ const text = fs12.readFileSync(path16.join(dir, hash(claimed)), "utf8");
14101
14366
  return { stored: TOKEN_HASH.exec(text)?.[1] ?? null, leadBound: true };
14102
14367
  } catch {
14103
14368
  return { stored: null, leadBound: safeList(dir).length > 0 };
@@ -14224,14 +14489,14 @@ function cleanRebase(cwd, range) {
14224
14489
  return Boolean(tree) && tree === git3(cwd, ["rev-parse", "--verify", "-q", `${range.to}^{tree}`]);
14225
14490
  }
14226
14491
  function storeRoot(cwd) {
14227
- const location = resolveStore(path16.resolve(cwd));
14492
+ const location = resolveStore(path17.resolve(cwd));
14228
14493
  if (location instanceof Error)
14229
14494
  return err("unavailable", location.message.replace(/; fix the repository.*$/u, ""), / does not exist /u.test(location.message) ? "run workit from a directory that exists" : "fix the repository (git status should work here) or run from a non-git directory");
14230
14495
  return { ok: true, value: { root: location.dir, shared: location.shared } };
14231
14496
  }
14232
14497
  function ledgerPath(cwd) {
14233
14498
  const root = storeRoot(cwd);
14234
- return root.ok ? { ok: true, value: path16.join(root.value.root, "ledger", "ledger.jsonl") } : root;
14499
+ return root.ok ? { ok: true, value: path17.join(root.value.root, "ledger", "ledger.jsonl") } : root;
14235
14500
  }
14236
14501
  var newId2 = () => `${Date.now().toString(36)}-${randomBytes3(6).toString("hex")}`;
14237
14502
  var NETWORK_FS_TYPES = new Set([
@@ -14251,25 +14516,25 @@ var onNetworkFs = (dir) => {
14251
14516
  if (process.platform !== "linux")
14252
14517
  return false;
14253
14518
  try {
14254
- return isNetworkFsType(fs12.statfsSync(dir).type);
14519
+ return isNetworkFsType(fs13.statfsSync(dir).type);
14255
14520
  } catch {
14256
14521
  return false;
14257
14522
  }
14258
14523
  };
14259
- var LOCK_WAIT_MS = 5000;
14260
- var LOCK_STALE_MS = 30000;
14524
+ var LOCK_WAIT_MS2 = 5000;
14525
+ var LOCK_STALE_MS2 = 30000;
14261
14526
  var LOCK_OWNER = "owner";
14262
14527
  var lockToken = (lock) => {
14263
14528
  try {
14264
- return fs12.readFileSync(path16.join(lock, LOCK_OWNER), "utf8");
14529
+ return fs13.readFileSync(path17.join(lock, LOCK_OWNER), "utf8");
14265
14530
  } catch {
14266
14531
  return null;
14267
14532
  }
14268
14533
  };
14269
14534
  var lockAgeMs = (lock) => {
14270
- for (const target of [path16.join(lock, LOCK_OWNER), lock]) {
14535
+ for (const target of [path17.join(lock, LOCK_OWNER), lock]) {
14271
14536
  try {
14272
- return Date.now() - fs12.statSync(target).mtimeMs;
14537
+ return Date.now() - fs13.statSync(target).mtimeMs;
14273
14538
  } catch {}
14274
14539
  }
14275
14540
  return null;
@@ -14277,14 +14542,14 @@ var lockAgeMs = (lock) => {
14277
14542
  var ledgerLock = {
14278
14543
  acquire(lock) {
14279
14544
  try {
14280
- fs12.mkdirSync(lock);
14545
+ fs13.mkdirSync(lock);
14281
14546
  } catch (error) {
14282
14547
  if (error.code === "EEXIST")
14283
14548
  return null;
14284
14549
  throw error;
14285
14550
  }
14286
14551
  const token = `${process.pid}-${randomBytes3(8).toString("hex")}`;
14287
- fs12.writeFileSync(path16.join(lock, LOCK_OWNER), token);
14552
+ fs13.writeFileSync(path17.join(lock, LOCK_OWNER), token);
14288
14553
  return token;
14289
14554
  },
14290
14555
  release(lock, token) {
@@ -14292,40 +14557,40 @@ var ledgerLock = {
14292
14557
  return false;
14293
14558
  const tomb = `${lock}.release-${randomBytes3(6).toString("hex")}`;
14294
14559
  try {
14295
- fs12.renameSync(lock, tomb);
14560
+ fs13.renameSync(lock, tomb);
14296
14561
  } catch {
14297
14562
  return false;
14298
14563
  }
14299
14564
  if (lockToken(tomb) !== token) {
14300
14565
  try {
14301
- fs12.renameSync(tomb, lock);
14566
+ fs13.renameSync(tomb, lock);
14302
14567
  } catch {}
14303
14568
  return false;
14304
14569
  }
14305
- fs12.rmSync(tomb, { recursive: true, force: true });
14570
+ fs13.rmSync(tomb, { recursive: true, force: true });
14306
14571
  return true;
14307
14572
  },
14308
14573
  token: lockToken,
14309
14574
  reap(lock, observed) {
14310
14575
  const tomb = `${lock}.reap-${randomBytes3(6).toString("hex")}`;
14311
14576
  try {
14312
- fs12.renameSync(lock, tomb);
14577
+ fs13.renameSync(lock, tomb);
14313
14578
  } catch {
14314
14579
  return false;
14315
14580
  }
14316
14581
  if (lockToken(tomb) === observed) {
14317
- fs12.rmSync(tomb, { recursive: true, force: true });
14582
+ fs13.rmSync(tomb, { recursive: true, force: true });
14318
14583
  return true;
14319
14584
  }
14320
14585
  try {
14321
- fs12.renameSync(tomb, lock);
14586
+ fs13.renameSync(tomb, lock);
14322
14587
  } catch {
14323
- fs12.rmSync(tomb, { recursive: true, force: true });
14588
+ fs13.rmSync(tomb, { recursive: true, force: true });
14324
14589
  }
14325
14590
  return false;
14326
14591
  }
14327
14592
  };
14328
- function withLedgerLock(file, fn, waitMs = hostAwareLockTimeout(LOCK_WAIT_MS)) {
14593
+ function withLedgerLock(file, fn, waitMs = hostAwareLockTimeout(LOCK_WAIT_MS2)) {
14329
14594
  const lock = `${file}.lock`;
14330
14595
  const deadline = Date.now() + waitMs;
14331
14596
  let token = null;
@@ -14335,7 +14600,7 @@ function withLedgerLock(file, fn, waitMs = hostAwareLockTimeout(LOCK_WAIT_MS)) {
14335
14600
  break;
14336
14601
  const observed = lockToken(lock);
14337
14602
  const age = lockAgeMs(lock);
14338
- if (age !== null && age > LOCK_STALE_MS && ledgerLock.reap(lock, observed))
14603
+ if (age !== null && age > LOCK_STALE_MS2 && ledgerLock.reap(lock, observed))
14339
14604
  continue;
14340
14605
  if (Date.now() >= deadline)
14341
14606
  return null;
@@ -14354,7 +14619,7 @@ var TAIL_BYTES = 64 * 1024;
14354
14619
  var lastLine = (fd, size) => {
14355
14620
  for (let span = Math.min(size, TAIL_BYTES);span > 0; span = Math.min(size, span * 2)) {
14356
14621
  const buffer = Buffer.alloc(span);
14357
- fs12.readSync(fd, buffer, 0, span, size - span);
14622
+ fs13.readSync(fd, buffer, 0, span, size - span);
14358
14623
  const end = buffer.lastIndexOf(10);
14359
14624
  if (end < 0) {
14360
14625
  if (span === size)
@@ -14385,32 +14650,32 @@ var lastLine = (fd, size) => {
14385
14650
  };
14386
14651
  var tighten = (fd) => {
14387
14652
  try {
14388
- if ((fs12.fstatSync(fd).mode & 63) !== 0)
14389
- fs12.fchmodSync(fd, 384);
14653
+ if ((fs13.fstatSync(fd).mode & 63) !== 0)
14654
+ fs13.fchmodSync(fd, 384);
14390
14655
  } catch {}
14391
14656
  };
14392
14657
  function appendLine(file, build, options) {
14393
14658
  const write = () => {
14394
- const fd = fs12.openSync(file, "a+", 384);
14659
+ const fd = fs13.openSync(file, "a+", 384);
14395
14660
  try {
14396
14661
  if (process.platform !== "win32")
14397
14662
  tighten(fd);
14398
- const line = build(lastLine(fd, fs12.fstatSync(fd).size));
14663
+ const line = build(lastLine(fd, fs13.fstatSync(fd).size));
14399
14664
  if (!line.ok)
14400
14665
  return line;
14401
14666
  const bytes = Buffer.from(`
14402
14667
  ${line.value}`);
14403
- const written = fs12.writeSync(fd, bytes);
14668
+ const written = fs13.writeSync(fd, bytes);
14404
14669
  if (written !== bytes.length)
14405
14670
  return err("unavailable", `short write to ${file}: ${written} of ${bytes.length} bytes; the row is torn and will be skipped`);
14406
14671
  return { ok: true, value: undefined };
14407
14672
  } finally {
14408
- fs12.closeSync(fd);
14673
+ fs13.closeSync(fd);
14409
14674
  }
14410
14675
  };
14411
14676
  try {
14412
- fs12.mkdirSync(path16.dirname(file), { recursive: true });
14413
- if (options.heldLock || !options.forceLock && !onNetworkFs(path16.dirname(file)))
14677
+ fs13.mkdirSync(path17.dirname(file), { recursive: true });
14678
+ if (options.heldLock || !options.forceLock && !onNetworkFs(path17.dirname(file)))
14414
14679
  return write();
14415
14680
  const locked = withLedgerLock(file, write);
14416
14681
  return locked ?? err("busy", `ledger lock ${file}.lock is held`, "retry; remove the .lock directory if no workit process is running");
@@ -14427,7 +14692,7 @@ var sealed = (row, id, at, previous) => {
14427
14692
  ` };
14428
14693
  };
14429
14694
  function appendRaw(cwd, row, options) {
14430
- const file = options.store ? { ok: true, value: path16.join(options.store.root, "ledger", "ledger.jsonl") } : ledgerPath(cwd);
14695
+ const file = options.store ? { ok: true, value: path17.join(options.store.root, "ledger", "ledger.jsonl") } : ledgerPath(cwd);
14431
14696
  if (!file.ok)
14432
14697
  return file;
14433
14698
  const id = newId2();
@@ -14477,8 +14742,8 @@ function readLedgerAt(cwd, file, options) {
14477
14742
  let text = "";
14478
14743
  let stat = null;
14479
14744
  try {
14480
- stat = fs12.statSync(file);
14481
- text = fs12.readFileSync(file, "utf8");
14745
+ stat = fs13.statSync(file);
14746
+ text = fs13.readFileSync(file, "utf8");
14482
14747
  } catch (error) {
14483
14748
  if (error.code === "ENOENT")
14484
14749
  return {
@@ -14618,7 +14883,7 @@ function ledgerTampering(cwd) {
14618
14883
  if (!file.ok)
14619
14884
  return [];
14620
14885
  try {
14621
- const stat = fs12.statSync(file.value);
14886
+ const stat = fs13.statSync(file.value);
14622
14887
  const cached = tamperCache.get(file.value);
14623
14888
  if (cached && cached.size === stat.size && cached.stamp === fileStamp(stat))
14624
14889
  return cached.breaks;
@@ -15085,8 +15350,8 @@ function remoteIdentity(cwd, hop = 0) {
15085
15350
  return null;
15086
15351
  if (hop === 0 && !/^[\w+.-]+:\/\/|^[^/\\]+@[^/\\]+:/u.test(raw)) {
15087
15352
  const local = raw.replace(/^file:\/\//u, "");
15088
- const resolved = path16.isAbsolute(local) ? local : path16.resolve(cwd, local);
15089
- if (fs12.existsSync(resolved))
15353
+ const resolved = path17.isAbsolute(local) ? local : path17.resolve(cwd, local);
15354
+ if (fs13.existsSync(resolved))
15090
15355
  return remoteIdentity(resolved, 1);
15091
15356
  }
15092
15357
  const parsed = parseRemoteUrl(raw);
@@ -15107,7 +15372,7 @@ function verdictMirrorPath(cwd) {
15107
15372
  if (!identity)
15108
15373
  return null;
15109
15374
  const key = createHash9("sha256").update(identity).digest("hex").slice(0, 32);
15110
- return path16.join(resolveStateDir(), "verdicts", key, "ledger.jsonl");
15375
+ return path17.join(resolveStateDir(), "verdicts", key, "ledger.jsonl");
15111
15376
  }
15112
15377
  var importedStamp = new Map;
15113
15378
  function importMirroredVerdicts(cwd, branch) {
@@ -15117,7 +15382,7 @@ function importMirroredVerdicts(cwd, branch) {
15117
15382
  return [];
15118
15383
  let stamp;
15119
15384
  try {
15120
- stamp = `${branch}\x00${fileStamp(fs12.statSync(file))}`;
15385
+ stamp = `${branch}\x00${fileStamp(fs13.statSync(file))}`;
15121
15386
  } catch {
15122
15387
  return [];
15123
15388
  }
@@ -15130,7 +15395,7 @@ function importMirroredVerdicts(cwd, branch) {
15130
15395
  const candidates = mirror.value.rows.filter((row) => (row.type === "verdict" || row.type === VOID_TYPE) && row.branch === branch && row.integrity === "verified");
15131
15396
  const added = new Set;
15132
15397
  try {
15133
- fs12.mkdirSync(path16.dirname(local.value), { recursive: true });
15398
+ fs13.mkdirSync(path17.dirname(local.value), { recursive: true });
15134
15399
  } catch {
15135
15400
  return [];
15136
15401
  }
@@ -15246,7 +15511,7 @@ var productDecision = (task, ledger) => {
15246
15511
  };
15247
15512
  };
15248
15513
  var planRecorded = (task, root) => {
15249
- const cited = (latestJudgment(task)?.refs ?? []).find((ref) => ref.kind === "external" || ref.kind === "file" && existsSync7(path17.resolve(root, ref.path)));
15514
+ const cited = (latestJudgment(task)?.refs ?? []).find((ref) => ref.kind === "external" || ref.kind === "file" && existsSync7(path18.resolve(root, ref.path)));
15250
15515
  if (cited)
15251
15516
  return {
15252
15517
  met: true,
@@ -15324,14 +15589,14 @@ function writeBlockers(task, root) {
15324
15589
 
15325
15590
  // packages/workit-core/src/core/task-evaluation.ts
15326
15591
  var digestBytes = (value) => createHash10("sha256").update(value).digest("hex");
15327
- var inside = (root, candidate) => candidate === root || candidate.startsWith(`${root}${path18.sep}`);
15328
- var relative = (root, candidate) => path18.relative(root, candidate).split(path18.sep).join("/") || ".";
15592
+ var inside = (root, candidate) => candidate === root || candidate.startsWith(`${root}${path19.sep}`);
15593
+ var relative = (root, candidate) => path19.relative(root, candidate).split(path19.sep).join("/") || ".";
15329
15594
  var canonicalPath = (value) => {
15330
15595
  if (typeof value !== "string" || !value)
15331
15596
  return null;
15332
15597
  if (value.includes("\\") || value.split("/").includes(".."))
15333
15598
  return null;
15334
- const normalized = path18.posix.normalize(value);
15599
+ const normalized = path19.posix.normalize(value);
15335
15600
  if (normalized === ".." || normalized.startsWith("../") || normalized.startsWith("/"))
15336
15601
  return null;
15337
15602
  return normalized === "." ? "." : normalized.replace(/\/$/, "");
@@ -15379,21 +15644,21 @@ var gitPaths = (root) => {
15379
15644
  git: !/not a git repository/i.test(stderr)
15380
15645
  };
15381
15646
  }
15382
- const paths = result.stdout ? result.stdout.toString("utf8").split("\x00").filter(Boolean).map((item) => item.split(path18.sep).join("/")) : [];
15647
+ const paths = result.stdout ? result.stdout.toString("utf8").split("\x00").filter(Boolean).map((item) => item.split(path19.sep).join("/")) : [];
15383
15648
  const stagedDeleted = spawnSync12("git", ["diff", "--cached", "--name-only", "--diff-filter=D", "-z"], { cwd: root, encoding: "buffer" });
15384
15649
  if (stagedDeleted.status !== 0) {
15385
15650
  const stderr = stagedDeleted.stderr?.toString("utf8") ?? "";
15386
15651
  if (!/not a git repository/i.test(stderr))
15387
15652
  return { paths, uncertain: true, git: true };
15388
15653
  } else if (stagedDeleted.stdout) {
15389
- paths.push(...stagedDeleted.stdout.toString("utf8").split("\x00").filter(Boolean).map((item) => item.split(path18.sep).join("/")));
15654
+ paths.push(...stagedDeleted.stdout.toString("utf8").split("\x00").filter(Boolean).map((item) => item.split(path19.sep).join("/")));
15390
15655
  }
15391
15656
  return { paths: [...new Set(paths)], uncertain: false, git: true };
15392
15657
  };
15393
15658
  var walk = (root, directory, output) => {
15394
15659
  let names;
15395
15660
  try {
15396
- names = fs13.readdirSync(directory);
15661
+ names = fs14.readdirSync(directory);
15397
15662
  } catch {
15398
15663
  return true;
15399
15664
  }
@@ -15401,10 +15666,10 @@ var walk = (root, directory, output) => {
15401
15666
  for (const name of names) {
15402
15667
  if (name === ".git" || name === ".workit")
15403
15668
  continue;
15404
- const target = path18.join(directory, name);
15669
+ const target = path19.join(directory, name);
15405
15670
  let stat;
15406
15671
  try {
15407
- stat = fs13.lstatSync(target);
15672
+ stat = fs14.lstatSync(target);
15408
15673
  } catch {
15409
15674
  uncertain = true;
15410
15675
  continue;
@@ -15419,14 +15684,14 @@ var walk = (root, directory, output) => {
15419
15684
  var scopeRoots = (root, scope) => {
15420
15685
  const roots = [];
15421
15686
  for (const item of scope.paths.length ? scope.paths : ["."]) {
15422
- const target = path18.resolve(root, item);
15687
+ const target = path19.resolve(root, item);
15423
15688
  if (!inside(root, target))
15424
15689
  return failure2("invalid_input", `candidate scope escapes checkout: ${item} — keep one task per repository and coordinate a separate linked task in the other checkout`, { fields: [{ path: "scope.paths", reason: `${item} is outside the checkout` }] });
15425
15690
  let ancestor = target;
15426
- while (!fs13.existsSync(ancestor) && ancestor !== root)
15427
- ancestor = path18.dirname(ancestor);
15691
+ while (!fs14.existsSync(ancestor) && ancestor !== root)
15692
+ ancestor = path19.dirname(ancestor);
15428
15693
  try {
15429
- if (!inside(root, fs13.realpathSync(ancestor)))
15694
+ if (!inside(root, fs14.realpathSync(ancestor)))
15430
15695
  return failure2("invalid_input", `candidate scope escapes checkout through a symlink: ${item} — keep one task per repository and coordinate a separate linked task in the other checkout`, { fields: [{ path: "scope.paths", reason: `${item} resolves outside the checkout` }] });
15431
15696
  } catch {
15432
15697
  return failure2("invalid_input", `candidate scope cannot be inspected: ${item}`);
@@ -15438,7 +15703,7 @@ var scopeRoots = (root, scope) => {
15438
15703
  function captureCandidate(root, scope, environment = []) {
15439
15704
  let checkout;
15440
15705
  try {
15441
- checkout = fs13.realpathSync(root);
15706
+ checkout = fs14.realpathSync(root);
15442
15707
  } catch {
15443
15708
  return failure2("invalid_input", "candidate root does not exist");
15444
15709
  }
@@ -15456,11 +15721,11 @@ function captureCandidate(root, scope, environment = []) {
15456
15721
  if (item === ".git" || item === ".workit")
15457
15722
  continue;
15458
15723
  names.add(item);
15459
- if (!fs13.existsSync(target))
15724
+ if (!fs14.existsSync(target))
15460
15725
  continue;
15461
15726
  let stat;
15462
15727
  try {
15463
- stat = fs13.lstatSync(target);
15728
+ stat = fs14.lstatSync(target);
15464
15729
  } catch {
15465
15730
  uncertain = true;
15466
15731
  continue;
@@ -15476,17 +15741,17 @@ function captureCandidate(root, scope, environment = []) {
15476
15741
  for (const item of [...names].toSorted()) {
15477
15742
  if (!scopeMatches(item, normalizedScope))
15478
15743
  continue;
15479
- const target = path18.join(checkout, item);
15744
+ const target = path19.join(checkout, item);
15480
15745
  try {
15481
- const stat = fs13.lstatSync(target);
15746
+ const stat = fs14.lstatSync(target);
15482
15747
  if (stat.isSymbolicLink()) {
15483
- const link = fs13.readlinkSync(target);
15748
+ const link = fs14.readlinkSync(target);
15484
15749
  files.push({ path: item, kind: "symlink", digest: digestBytes(link), executable: null });
15485
15750
  } else if (stat.isFile()) {
15486
15751
  files.push({
15487
15752
  path: item,
15488
15753
  kind: "file",
15489
- digest: digestBytes(fs13.readFileSync(target)),
15754
+ digest: digestBytes(fs14.readFileSync(target)),
15490
15755
  executable: (stat.mode & 73) !== 0
15491
15756
  });
15492
15757
  } else if (!stat.isDirectory()) {
@@ -15636,7 +15901,7 @@ var scopeCovers2 = scopeCovers;
15636
15901
  var verifyDecisionContentAtRoot = (checkoutRoot, binding) => {
15637
15902
  let root;
15638
15903
  try {
15639
- root = fs13.realpathSync(checkoutRoot);
15904
+ root = fs14.realpathSync(checkoutRoot);
15640
15905
  } catch {
15641
15906
  return failure2("permission_denied", "checkout root is unavailable");
15642
15907
  }
@@ -15645,23 +15910,23 @@ var verifyDecisionContentAtRoot = (checkoutRoot, binding) => {
15645
15910
  continue;
15646
15911
  if (!reference.digest)
15647
15912
  return failure2("invalid_input", "document references require a byte digest");
15648
- const target = path18.resolve(root, reference.path);
15649
- if (target !== root && !target.startsWith(`${root}${path18.sep}`))
15913
+ const target = path19.resolve(root, reference.path);
15914
+ if (target !== root && !target.startsWith(`${root}${path19.sep}`))
15650
15915
  return failure2("invalid_input", "document reference escapes checkout; cite it as an external file:// reference instead", {
15651
15916
  fields: [
15652
15917
  { path: "contentRefs.path", reason: `${reference.path} is outside the checkout` }
15653
15918
  ]
15654
15919
  });
15655
15920
  try {
15656
- const below = path18.relative(root, target);
15921
+ const below = path19.relative(root, target);
15657
15922
  let current = root;
15658
- for (const segment of below.split(path18.sep)) {
15923
+ for (const segment of below.split(path19.sep)) {
15659
15924
  if (!segment)
15660
15925
  continue;
15661
- current = path18.join(current, segment);
15662
- const stat = fs13.lstatSync(current);
15663
- const real = fs13.realpathSync(current);
15664
- if (real !== root && !real.startsWith(`${root}${path18.sep}`))
15926
+ current = path19.join(current, segment);
15927
+ const stat = fs14.lstatSync(current);
15928
+ const real = fs14.realpathSync(current);
15929
+ if (real !== root && !real.startsWith(`${root}${path19.sep}`))
15665
15930
  return failure2("invalid_input", "document reference escapes checkout; cite it as an external file:// reference instead", {
15666
15931
  fields: [
15667
15932
  {
@@ -15677,7 +15942,7 @@ var verifyDecisionContentAtRoot = (checkoutRoot, binding) => {
15677
15942
  if (current !== target && !stat.isDirectory())
15678
15943
  return failure2("invalid_input", "document reference ancestor is not a directory");
15679
15944
  }
15680
- if (digestBytes(fs13.readFileSync(target)) !== reference.digest)
15945
+ if (digestBytes(fs14.readFileSync(target)) !== reference.digest)
15681
15946
  return failure2("permission_denied", "decision document bytes have changed");
15682
15947
  } catch {
15683
15948
  return failure2("invalid_input", "decision document is unavailable");
@@ -16159,7 +16424,7 @@ function entryCompactContext(store, entry, session, context) {
16159
16424
  current: () => recentSignal(store.root)
16160
16425
  };
16161
16426
  const observed = task?.data.evidence.some(isObservedCheck) ?? false;
16162
- const files = (task?.data.decisions ?? []).flatMap((decision) => decision.data.binding.contentRefs.flatMap((ref) => ref.kind === "file" ? [path19.resolve(store.root, ref.path)] : []));
16427
+ const files = (task?.data.decisions ?? []).flatMap((decision) => decision.data.binding.contentRefs.flatMap((ref) => ref.kind === "file" ? [path20.resolve(store.root, ref.path)] : []));
16163
16428
  const observedFiles = filesKey(files);
16164
16429
  const compact = compactContext(store, context, entry?.id ?? null, freshness, origin && { origin: origin.origin, taskId: origin.entry.id });
16165
16430
  if (!compact.ok || !compact.data)
@@ -16218,17 +16483,17 @@ ${options.addendum}` : ""}
16218
16483
  </workit-contract>`;
16219
16484
  };
16220
16485
  var checkoutAt = (cwd) => {
16221
- for (let dir = path19.resolve(cwd);; dir = path19.dirname(dir)) {
16222
- const dotGit = path19.join(dir, ".git");
16223
- if (fs14.existsSync(dotGit)) {
16224
- const admin = fs14.statSync(dotGit).isFile() ? path19.resolve(dir, /^gitdir:\s*(.+)$/mu.exec(fs14.readFileSync(dotGit, "utf8"))?.[1]?.trim() ?? "") : dotGit;
16225
- const head = fs14.readFileSync(path19.join(admin, "HEAD"), "utf8").trim();
16486
+ for (let dir = path20.resolve(cwd);; dir = path20.dirname(dir)) {
16487
+ const dotGit = path20.join(dir, ".git");
16488
+ if (fs15.existsSync(dotGit)) {
16489
+ const admin = fs15.statSync(dotGit).isFile() ? path20.resolve(dir, /^gitdir:\s*(.+)$/mu.exec(fs15.readFileSync(dotGit, "utf8"))?.[1]?.trim() ?? "") : dotGit;
16490
+ const head = fs15.readFileSync(path20.join(admin, "HEAD"), "utf8").trim();
16226
16491
  return {
16227
16492
  root: dir,
16228
16493
  branch: /^ref: refs\/heads\/(.+)$/u.exec(head)?.[1] ?? null
16229
16494
  };
16230
16495
  }
16231
- if (path19.dirname(dir) === dir)
16496
+ if (path20.dirname(dir) === dir)
16232
16497
  return null;
16233
16498
  }
16234
16499
  };
@@ -16239,7 +16504,7 @@ var whereLine = (cwd) => {
16239
16504
  return null;
16240
16505
  const allowed = branchPolicySnapshotFor(cwd).namePolicy.allowed;
16241
16506
  const kinds = allowed.some((pattern) => pattern.source === "^.*$") ? "any" : allowedKinds(allowed).join(", ") || "see `workit help git`";
16242
- const place = checkout.root === path19.resolve(cwd) ? "" : ` in ${checkout.root}`;
16507
+ const place = checkout.root === path20.resolve(cwd) ? "" : ` in ${checkout.root}`;
16243
16508
  return `cwd ${cwd}${place} on ${checkout.branch ?? "detached HEAD"}; branch kinds: ${kinds}`;
16244
16509
  } catch {
16245
16510
  return null;
@@ -16266,32 +16531,32 @@ var turnMarker = (input) => {
16266
16531
  if (location instanceof Error)
16267
16532
  return null;
16268
16533
  const session = [input.host, input.session.id, input.session.agentId ?? ""].join("\x00");
16269
- return path19.join(location.dir, "hooks", `turn-${digestOf(session).slice(0, 32)}.json`);
16534
+ return path20.join(location.dir, "hooks", `turn-${digestOf(session).slice(0, 32)}.json`);
16270
16535
  } catch {
16271
16536
  return null;
16272
16537
  }
16273
16538
  };
16274
16539
  var writeTurnDigest = (file, digest) => {
16275
16540
  try {
16276
- fs14.mkdirSync(path19.dirname(file), { recursive: true });
16277
- fs14.writeFileSync(file, `${JSON.stringify({ digest })}
16541
+ fs15.mkdirSync(path20.dirname(file), { recursive: true });
16542
+ fs15.writeFileSync(file, `${JSON.stringify({ digest })}
16278
16543
  `);
16279
16544
  } catch {}
16280
16545
  };
16281
16546
  var clearTurnDigest = (file) => {
16282
16547
  try {
16283
- fs14.rmSync(file, { force: true });
16548
+ fs15.rmSync(file, { force: true });
16284
16549
  } catch {}
16285
16550
  };
16286
16551
  var pruneTurnDigests = (dir, now) => {
16287
16552
  try {
16288
- for (const name of fs14.readdirSync(dir)) {
16553
+ for (const name of fs15.readdirSync(dir)) {
16289
16554
  if (!name.startsWith("turn-"))
16290
16555
  continue;
16291
- const file = path19.join(dir, name);
16556
+ const file = path20.join(dir, name);
16292
16557
  try {
16293
- if (now - fs14.statSync(file).mtimeMs > TURN_TTL_MS)
16294
- fs14.rmSync(file, { force: true });
16558
+ if (now - fs15.statSync(file).mtimeMs > TURN_TTL_MS)
16559
+ fs15.rmSync(file, { force: true });
16295
16560
  } catch {}
16296
16561
  }
16297
16562
  } catch {}
@@ -16307,7 +16572,7 @@ var changedTurnContext = (input, text) => {
16307
16572
  return text;
16308
16573
  const digest = digestOf(text);
16309
16574
  try {
16310
- const previous = JSON.parse(fs14.readFileSync(file, "utf8"));
16575
+ const previous = JSON.parse(fs15.readFileSync(file, "utf8"));
16311
16576
  if (previous.digest === digest)
16312
16577
  return null;
16313
16578
  } catch {}
@@ -16318,7 +16583,7 @@ var seedTurnContext = (input, descriptor, text = turnContextText(input, descript
16318
16583
  const file = turnMarker(input);
16319
16584
  if (!file)
16320
16585
  return;
16321
- pruneTurnDigests(path19.dirname(file), Date.now());
16586
+ pruneTurnDigests(path20.dirname(file), Date.now());
16322
16587
  if (text)
16323
16588
  writeTurnDigest(file, digestOf(text));
16324
16589
  else
@@ -16327,36 +16592,36 @@ var seedTurnContext = (input, descriptor, text = turnContextText(input, descript
16327
16592
  // packages/workit-core/src/core/route-intent.ts
16328
16593
  import { spawnSync as spawnSync14 } from "node:child_process";
16329
16594
  import { existsSync as existsSync11 } from "node:fs";
16330
- import path25 from "node:path";
16595
+ import path26 from "node:path";
16331
16596
 
16332
16597
  // packages/workit-core/src/hooks/raw-git.ts
16333
16598
  import { spawnSync as spawnSync13 } from "node:child_process";
16334
16599
  import { createHash as createHash14 } from "node:crypto";
16335
- import fs16 from "node:fs";
16336
- import os5 from "node:os";
16337
- import path24 from "node:path";
16600
+ import fs17 from "node:fs";
16601
+ import os6 from "node:os";
16602
+ import path25 from "node:path";
16338
16603
 
16339
16604
  // packages/workit-core/src/autonomy.ts
16340
16605
  import { closeSync as closeSync2, copyFileSync, existsSync as existsSync10, openSync as openSync2 } from "node:fs";
16341
- import path22 from "node:path";
16606
+ import path23 from "node:path";
16342
16607
 
16343
16608
  // packages/workit-core/src/core/eval-world.ts
16344
16609
  import { existsSync as existsSync9, realpathSync as realpathSync7 } from "node:fs";
16345
- import os4 from "node:os";
16346
- import path20 from "node:path";
16610
+ import os5 from "node:os";
16611
+ import path21 from "node:path";
16347
16612
  var EVAL_WORLD_ENV = "WORKIT_EVAL_WORLD";
16348
16613
  var EVAL_WORLD_MARKER = ".workit-eval-world";
16349
16614
  var inside2 = (dir, file) => {
16350
- const rel = path20.relative(dir, file);
16351
- return !rel.startsWith("..") && !path20.isAbsolute(rel);
16615
+ const rel = path21.relative(dir, file);
16616
+ return !rel.startsWith("..") && !path21.isAbsolute(rel);
16352
16617
  };
16353
16618
  var evalWorld = (cwd) => {
16354
16619
  const raw = process.env[EVAL_WORLD_ENV];
16355
- if (!raw || !path20.isAbsolute(raw))
16620
+ if (!raw || !path21.isAbsolute(raw))
16356
16621
  return null;
16357
16622
  try {
16358
16623
  const world = realpathSync7(raw);
16359
- return inside2(realpathSync7(os4.tmpdir()), world) && inside2(world, realpathSync7(cwd)) && existsSync9(path20.join(world, EVAL_WORLD_MARKER)) ? world : null;
16624
+ return inside2(realpathSync7(os5.tmpdir()), world) && inside2(world, realpathSync7(cwd)) && existsSync9(path21.join(world, EVAL_WORLD_MARKER)) ? world : null;
16360
16625
  } catch {
16361
16626
  return null;
16362
16627
  }
@@ -16364,7 +16629,7 @@ var evalWorld = (cwd) => {
16364
16629
  var evalWorldEntry = (cwd) => {
16365
16630
  const world = evalWorld(cwd);
16366
16631
  try {
16367
- return world ? loadWorkspacesFrom(path20.join(world, "config"))[0] ?? null : null;
16632
+ return world ? loadWorkspacesFrom(path21.join(world, "config"))[0] ?? null : null;
16368
16633
  } catch {
16369
16634
  return null;
16370
16635
  }
@@ -16373,7 +16638,7 @@ var evalWorldEntry = (cwd) => {
16373
16638
  // packages/workit-core/src/core/grant-seal.ts
16374
16639
  import { createHash as createHash12 } from "node:crypto";
16375
16640
  import { readFileSync as readFileSync9 } from "node:fs";
16376
- import path21 from "node:path";
16641
+ import path22 from "node:path";
16377
16642
  var SEAL_FILE = "workspaces.json.seal";
16378
16643
  var SEAL_VERSION = 1;
16379
16644
  var SEAL_COMMAND = "workit workspace seal";
@@ -16407,15 +16672,15 @@ var sealProjection = (entries) => entries.map((entry) => {
16407
16672
  youtrack: pick2(all.youtrack, ["writes", "autoHosts"])
16408
16673
  }, ENTRY_KEYS);
16409
16674
  });
16410
- var canonical3 = (value) => JSON.stringify(value, (_key, item) => item && typeof item === "object" && !Array.isArray(item) ? Object.fromEntries(Object.entries(item).toSorted(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)) : item);
16411
- var sealDigest = (projection) => createHash12("sha256").update(canonical3(projection)).digest("hex");
16675
+ var canonical4 = (value) => JSON.stringify(value, (_key, item) => item && typeof item === "object" && !Array.isArray(item) ? Object.fromEntries(Object.entries(item).toSorted(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)) : item);
16676
+ var sealDigest = (projection) => createHash12("sha256").update(canonical4(projection)).digest("hex");
16412
16677
  var broken = (reason, sealed = null) => ({
16413
16678
  state: "broken",
16414
16679
  reason,
16415
16680
  sealed
16416
16681
  });
16417
16682
  function checkSeal(dir) {
16418
- const file = path21.join(dir, SEAL_FILE);
16683
+ const file = path22.join(dir, SEAL_FILE);
16419
16684
  let seal;
16420
16685
  try {
16421
16686
  seal = JSON.parse(readFileSync9(file, "utf8"));
@@ -16473,7 +16738,7 @@ var accountHomeDir = () => {
16473
16738
  };
16474
16739
  var deniedFile = (dir) => {
16475
16740
  for (const name of ["workspaces.json", SEAL_FILE]) {
16476
- const file = path22.join(dir, name);
16741
+ const file = path23.join(dir, name);
16477
16742
  try {
16478
16743
  closeSync2(openSync2(file, "r"));
16479
16744
  } catch (error) {
@@ -16495,7 +16760,7 @@ var accountUnread = () => {
16495
16760
  if (dir === null)
16496
16761
  return NO_ACCOUNT;
16497
16762
  const file = deniedFile(dir);
16498
- return file === null ? null : `the account's ${path22.basename(file)} cannot be read (permission denied), so it reads as no workspace entries: no grants, no models, the D4 defaults apply`;
16763
+ return file === null ? null : `the account's ${path23.basename(file)} cannot be read (permission denied), so it reads as no workspace entries: no grants, no models, the D4 defaults apply`;
16499
16764
  };
16500
16765
  var entriesIn = (dir) => dir === null ? [] : loadWorkspacesFrom(dir);
16501
16766
  var fileSource = (dir = accountDir()) => ({
@@ -16544,10 +16809,10 @@ var youTrackWritesPolicy = (cwd) => {
16544
16809
  return ASK;
16545
16810
  }
16546
16811
  };
16547
- var redirected = (dir) => path22.resolve(resolveConfigDir()) !== path22.resolve(dir);
16812
+ var redirected = (dir) => path23.resolve(resolveConfigDir()) !== path23.resolve(dir);
16548
16813
  var shownGrantsDir = () => {
16549
16814
  const world = evalWorld(process.cwd());
16550
- return world ? path22.join(world, "config") : accountDir();
16815
+ return world ? path23.join(world, "config") : accountDir();
16551
16816
  };
16552
16817
  var benchWorld = (cwd) => {
16553
16818
  const entry = evalWorldEntry(cwd);
@@ -16571,10 +16836,10 @@ var grantsOverride = () => {
16571
16836
  const shown = shownGrantsDir();
16572
16837
  if (shown === null)
16573
16838
  return accountUnread() ?? NO_ACCOUNT;
16574
- const configured = path22.resolve(resolveConfigDir());
16575
- return configured === path22.resolve(shown) ? null : `the config directory is redirected to ${configured} (WORKIT_CONFIG, WORKIT_CONFIG_DIR or XDG_CONFIG_HOME), but that override does not apply to grants: grants are read only from ${path22.join(grantsDir(), "workspaces.json")}, and under a redirect they never exceed the D4 defaults`;
16839
+ const configured = path23.resolve(resolveConfigDir());
16840
+ return configured === path23.resolve(shown) ? null : `the config directory is redirected to ${configured} (WORKIT_CONFIG, WORKIT_CONFIG_DIR or XDG_CONFIG_HOME), but that override does not apply to grants: grants are read only from ${path23.join(grantsDir(), "workspaces.json")}, and under a redirect they never exceed the D4 defaults`;
16576
16841
  };
16577
- var redirectUnblock = () => `ask the user: grants above the D4 defaults apply only without a config redirect (WORKIT_CONFIG, WORKIT_CONFIG_DIR or XDG_CONFIG_HOME), and are read from ${path22.join(grantsDir(), "workspaces.json")}`;
16842
+ var redirectUnblock = () => `ask the user: grants above the D4 defaults apply only without a config redirect (WORKIT_CONFIG, WORKIT_CONFIG_DIR or XDG_CONFIG_HOME), and are read from ${path23.join(grantsDir(), "workspaces.json")}`;
16578
16843
  var GRANT_KINDS = ["push", "pr", "merge", "release", "rerun"];
16579
16844
  var DEFAULT_GRANTS = Object.freeze({
16580
16845
  push: true,
@@ -16982,8 +17247,8 @@ var packageTagShapes = (packages) => packages.map((entry) => `${entry.tagNamespa
16982
17247
 
16983
17248
  // packages/workit-core/src/hooks/session-marker.ts
16984
17249
  import { createHash as createHash13 } from "node:crypto";
16985
- import fs15 from "node:fs";
16986
- import path23 from "node:path";
17250
+ import fs16 from "node:fs";
17251
+ import path24 from "node:path";
16987
17252
  var sessionMarkerFile = (input, session, store) => {
16988
17253
  let dir = store;
16989
17254
  if (dir === undefined) {
@@ -16993,7 +17258,7 @@ var sessionMarkerFile = (input, session, store) => {
16993
17258
  dir = location.dir;
16994
17259
  }
16995
17260
  const name = createHash13("sha256").update(`${input.host}\x00${session}`).digest("hex").slice(0, 32);
16996
- return path23.join(dir, "hooks", `skills-${name}.json`);
17261
+ return path24.join(dir, "hooks", `skills-${name}.json`);
16997
17262
  };
16998
17263
  var list = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
16999
17264
  var EMPTY = {
@@ -17006,7 +17271,7 @@ var EMPTY = {
17006
17271
  };
17007
17272
  var readRaw = (file) => {
17008
17273
  try {
17009
- return fs15.readFileSync(file, "utf8");
17274
+ return fs16.readFileSync(file, "utf8");
17010
17275
  } catch {
17011
17276
  return "";
17012
17277
  }
@@ -17028,13 +17293,13 @@ var parseMarker = (text) => {
17028
17293
  };
17029
17294
  var readSessionMarker = (file) => parseMarker(readRaw(file));
17030
17295
  var writeAtomic = (file, marker) => {
17031
- fs15.mkdirSync(path23.dirname(file), { recursive: true });
17296
+ fs16.mkdirSync(path24.dirname(file), { recursive: true });
17032
17297
  const temp = `${file}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
17033
17298
  try {
17034
- fs15.writeFileSync(temp, JSON.stringify(marker));
17035
- fs15.renameSync(temp, file);
17299
+ fs16.writeFileSync(temp, JSON.stringify(marker));
17300
+ fs16.renameSync(temp, file);
17036
17301
  } catch (error) {
17037
- fs15.rmSync(temp, { force: true });
17302
+ fs16.rmSync(temp, { force: true });
17038
17303
  throw error;
17039
17304
  }
17040
17305
  };
@@ -17616,14 +17881,14 @@ var GIT_CONFIG_ENV = /^(?:GIT_(?:CONFIG\w*|DIR|COMMON_DIR|WORK_TREE|SSH|SSH_COMM
17616
17881
  var ASSIGNMENT2 = /^([A-Za-z_]\w*)=([\s\S]*)$/;
17617
17882
  var MAX_DEPTH = 4;
17618
17883
  var MAX_EXPANSIONS = 16;
17619
- var isAbsolute = (value) => path24.isAbsolute(value) || /^[A-Za-z]:[\\/]/.test(value) || value.startsWith("\\\\");
17884
+ var isAbsolute = (value) => path25.isAbsolute(value) || /^[A-Za-z]:[\\/]/.test(value) || value.startsWith("\\\\");
17620
17885
  var HERE = /^(?:\$PWD|\$\{PWD\}|\$\(\s*pwd\s*\)|`pwd`|\$\(\s*git\s+rev-parse\s+--show-toplevel\s*\))(?=$|[\\/])/;
17621
17886
  var joinDir = (base, raw) => {
17622
17887
  const next = raw.replace(HERE, ".");
17623
17888
  if (base === undefined || /[$`*?]/.test(next) || next === "-")
17624
17889
  return;
17625
- const expanded = next === "~" || next.startsWith("~/") ? path24.join(os5.homedir(), next.slice(1)) : next;
17626
- return base === null || isAbsolute(expanded) ? expanded : path24.join(base, expanded);
17890
+ const expanded = next === "~" || next.startsWith("~/") ? path25.join(os6.homedir(), next.slice(1)) : next;
17891
+ return base === null || isAbsolute(expanded) ? expanded : path25.join(base, expanded);
17627
17892
  };
17628
17893
  var rebase = (base, inner) => inner === null ? base : inner === undefined ? undefined : joinDir(base, inner);
17629
17894
  var cdTarget = (words) => {
@@ -18024,7 +18289,7 @@ function walk2(command, dialect, depth, seen, inherited = {}) {
18024
18289
  }
18025
18290
  if (CD.has(name)) {
18026
18291
  const target = cdTarget(words);
18027
- dir = target === null ? os5.homedir() : joinDir(dir, target);
18292
+ dir = target === null ? os6.homedir() : joinDir(dir, target);
18028
18293
  } else if (PUSHD.has(name)) {
18029
18294
  const target = cdTarget(words);
18030
18295
  stack.push(dir);
@@ -18524,7 +18789,7 @@ var repoAt = (dir) => {
18524
18789
  return { location, dir, branch: resolveTaskKey(dir, location).branch };
18525
18790
  };
18526
18791
  var isWorkitWorkspace = (repo) => {
18527
- if (fs16.existsSync(repo.location.dir))
18792
+ if (fs17.existsSync(repo.location.dir))
18528
18793
  return true;
18529
18794
  try {
18530
18795
  return resolveRuntimeWorkspaceVcs(repo.location.top ?? repo.dir) !== null;
@@ -18545,17 +18810,17 @@ var headSha2 = (repo) => {
18545
18810
  if (!git || git.reftable)
18546
18811
  return null;
18547
18812
  try {
18548
- const head = fs16.readFileSync(path24.join(git.gitDir, "HEAD"), "utf8").trim();
18813
+ const head = fs17.readFileSync(path25.join(git.gitDir, "HEAD"), "utf8").trim();
18549
18814
  if (/^[0-9a-f]{40,64}$/.test(head))
18550
18815
  return head;
18551
18816
  const ref = /^ref: (refs\/.+)$/.exec(head)?.[1];
18552
18817
  if (!ref)
18553
18818
  return null;
18554
- const common = path24.dirname(repo.location.dir);
18819
+ const common = path25.dirname(repo.location.dir);
18555
18820
  try {
18556
- return fs16.readFileSync(path24.join(common, ref), "utf8").trim() || null;
18821
+ return fs17.readFileSync(path25.join(common, ref), "utf8").trim() || null;
18557
18822
  } catch {}
18558
- const packed = fs16.readFileSync(path24.join(common, "packed-refs"), "utf8");
18823
+ const packed = fs17.readFileSync(path25.join(common, "packed-refs"), "utf8");
18559
18824
  return new RegExp(`^([0-9a-f]{40,64}) ${ref.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`, "m").exec(packed)?.[1] ?? null;
18560
18825
  } catch {
18561
18826
  return null;
@@ -18648,8 +18913,8 @@ var expandGitAliases = (root, invocation, cache = new Map, depth = 0) => {
18648
18913
  const sub = invocation.args[0];
18649
18914
  if (invocation.tool !== "git" || invocation.dir === undefined || !sub || sub.startsWith("-") || GIT_COMMANDS.has(sub) || depth >= MAX_DEPTH)
18650
18915
  return [invocation];
18651
- const dir = path24.resolve(root, invocation.dir ?? ".");
18652
- if (!fs16.existsSync(dir))
18916
+ const dir = path25.resolve(root, invocation.dir ?? ".");
18917
+ if (!fs17.existsSync(dir))
18653
18918
  return [invocation];
18654
18919
  const config = gitConfig(dir, invocation, cache);
18655
18920
  const alias = configValue(config, `alias.${sub.toLowerCase()}`);
@@ -18671,11 +18936,11 @@ var expandGitAliases = (root, invocation, cache = new Map, depth = 0) => {
18671
18936
  var normalizedUrl = (url, dir) => {
18672
18937
  const trimmed = url.trim();
18673
18938
  if (/^file:\/\//i.test(trimmed))
18674
- return path24.resolve(dir, trimmed.slice(7)).replace(/\/+$/, "").replace(/\.git$/, "");
18939
+ return path25.resolve(dir, trimmed.slice(7)).replace(/\/+$/, "").replace(/\.git$/, "");
18675
18940
  const scheme = /^[a-z][a-z0-9+.-]*:\/\//i.exec(trimmed);
18676
18941
  const scp = !scheme && /^(?:[^@/\\]+@)?[^/\\:]{2,}:/.test(trimmed);
18677
18942
  if (!scheme && !scp)
18678
- return path24.resolve(dir, trimmed).replace(/\/+$/, "").replace(/\.git$/, "");
18943
+ return path25.resolve(dir, trimmed).replace(/\/+$/, "").replace(/\.git$/, "");
18679
18944
  const value = scheme ? trimmed.slice(scheme[0].length).replace(/^[^@/]*@/, "").replace(/^([^/:]+):\d+(?=\/)/, "$1") : trimmed.replace(/^[^@/]*@/, "").replace(":", "/");
18680
18945
  return value.toLowerCase().replace(/\/{2,}/g, "/").replace(/^www\./, "").replace(/\/+$/, "").replace(/\.git$/, "");
18681
18946
  };
@@ -18916,7 +19181,7 @@ var actionsIn = (cwd, command, dialect, cache = new Map, all = false) => {
18916
19181
  const out = [];
18917
19182
  const repos = new Map;
18918
19183
  const repoFor = (relative) => {
18919
- const dir = path24.resolve(cwd, relative ?? ".");
19184
+ const dir = path25.resolve(cwd, relative ?? ".");
18920
19185
  if (!repos.has(dir)) {
18921
19186
  const repo = repoAt(dir);
18922
19187
  const workit = repo !== null && isWorkitWorkspace(repo);
@@ -18937,7 +19202,7 @@ var actionsIn = (cwd, command, dialect, cache = new Map, all = false) => {
18937
19202
  const action = rawAction(invocation);
18938
19203
  const at = !action ? null : repoFor(invocation.dir) ?? (all && invocation.tool !== "git" && explicitRepo(invocation.tool === "gh", "repo" in action && action.repo || "", invocation.env ?? {}) ? {
18939
19204
  repo: {
18940
- dir: path24.resolve(cwd, invocation.dir ?? "."),
19205
+ dir: path25.resolve(cwd, invocation.dir ?? "."),
18941
19206
  branch: null
18942
19207
  },
18943
19208
  workit: false
@@ -19010,13 +19275,13 @@ var messageOf = (segment, index) => {
19010
19275
  };
19011
19276
  var sameGitDir = (a, b, platform = process.platform) => {
19012
19277
  if (platform !== "win32")
19013
- return path24.posix.resolve(a) === path24.posix.resolve(b);
19014
- const fold = (value) => path24.win32.resolve(value).toLowerCase();
19278
+ return path25.posix.resolve(a) === path25.posix.resolve(b);
19279
+ const fold = (value) => path25.win32.resolve(value).toLowerCase();
19015
19280
  return fold(a) === fold(b);
19016
19281
  };
19017
19282
  var cdCommitCall = (input, command, target, repo) => {
19018
19283
  const { top, git, dir: store } = repo.location;
19019
- if (!top || !git || sameGitDir(git.gitDir, path24.dirname(store)) || repoAt(input.cwd)?.location.top === top)
19284
+ if (!top || !git || sameGitDir(git.gitDir, path25.dirname(store)) || repoAt(input.cwd)?.location.top === top)
19020
19285
  return null;
19021
19286
  const bare = command.replaceAll(/'[^']*'|"(?:[^"\\]|\\.)*"/gu, "").replaceAll("&&", "");
19022
19287
  if (/[;|&<>`$()\n\\]/u.test(bare))
@@ -19025,7 +19290,7 @@ var cdCommitCall = (input, command, target, repo) => {
19025
19290
  const commit = rest.at(-1);
19026
19291
  if (cd?.words[0] !== "cd" || cd.words.length !== 2 || cd.expands?.length || !commit)
19027
19292
  return null;
19028
- if (path24.resolve(input.cwd, cd.words[1]) !== target)
19293
+ if (path25.resolve(input.cwd, cd.words[1]) !== target)
19029
19294
  return null;
19030
19295
  if (rest.some((each) => each.redirects.length || each.stdin?.length || each.group))
19031
19296
  return null;
@@ -19092,7 +19357,7 @@ var commitRefusal = (input, command, dialect, { action, repo, invocation, workit
19092
19357
  } catch {}
19093
19358
  if (guarded && !switches)
19094
19359
  return `workit: raw ${quote("git commit")} on ${repo.branch}, a protected branch. Branch first: ${quote("workit git branch --kind feature --slug <slug>")} (uncommitted changes come along), then ${quote("workit git commit -m '<msg>' -- <paths>")}.`;
19095
- const call = action.amend || dialect !== "posix" || typeof invocation.dir !== "string" ? null : cdCommitCall(input, command, path24.resolve(input.cwd, invocation.dir), repo);
19360
+ const call = action.amend || dialect !== "posix" || typeof invocation.dir !== "string" ? null : cdCommitCall(input, command, path25.resolve(input.cwd, invocation.dir), repo);
19096
19361
  return call && `workit: no ${quote("cd … &&")} chain; run ${quote(call)}.`;
19097
19362
  };
19098
19363
  function rawGitPre(input, command, options = {}) {
@@ -19221,9 +19486,9 @@ var grantRefusal = (action, repo, invocation, cache) => {
19221
19486
  return null;
19222
19487
  };
19223
19488
  var localTag = (repo, name) => {
19224
- const common = path24.dirname(repo.location.dir);
19489
+ const common = path25.dirname(repo.location.dir);
19225
19490
  try {
19226
- return fs16.existsSync(path24.join(common, "refs/tags", name)) || fs16.readFileSync(path24.join(common, "packed-refs"), "utf8").includes(` refs/tags/${name}
19491
+ return fs17.existsSync(path25.join(common, "refs/tags", name)) || fs17.readFileSync(path25.join(common, "packed-refs"), "utf8").includes(` refs/tags/${name}
19227
19492
  `);
19228
19493
  } catch {
19229
19494
  return false;
@@ -19243,7 +19508,7 @@ var analysisDenial = (error) => ({
19243
19508
  });
19244
19509
  var NEXT_COMMAND = "next";
19245
19510
  var MARKER_TTL_SECONDS = 3600;
19246
- var markerFile = (repo, session, key) => path24.join(repo.location.dir, "hooks", `commit-${createHash14("sha256").update(`${session}\x00${key}`).digest("hex").slice(0, 32)}.json`);
19511
+ var markerFile = (repo, session, key) => path25.join(repo.location.dir, "hooks", `commit-${createHash14("sha256").update(`${session}\x00${key}`).digest("hex").slice(0, 32)}.json`);
19247
19512
  var callKey = (toolUseId, command) => toolUseId ?? `cmd:${createHash14("sha256").update(command).digest("hex")}`;
19248
19513
  function noteRawCommit(input, command, key) {
19249
19514
  try {
@@ -19254,8 +19519,8 @@ function noteRawCommit(input, command, key) {
19254
19519
  if (action.kind !== "commit")
19255
19520
  continue;
19256
19521
  const file = markerFile(repo, input.session.id, key);
19257
- fs16.mkdirSync(path24.dirname(file), { recursive: true });
19258
- fs16.writeFileSync(file, `${JSON.stringify({ head: headSha2(repo), at })}
19522
+ fs17.mkdirSync(path25.dirname(file), { recursive: true });
19523
+ fs17.writeFileSync(file, `${JSON.stringify({ head: headSha2(repo), at })}
19259
19524
  `);
19260
19525
  }
19261
19526
  } catch {}
@@ -19288,11 +19553,11 @@ var headCommit = (dir) => {
19288
19553
  var settle2 = (input, repo, file) => {
19289
19554
  let marker;
19290
19555
  try {
19291
- marker = JSON.parse(fs16.readFileSync(file, "utf8"));
19556
+ marker = JSON.parse(fs17.readFileSync(file, "utf8"));
19292
19557
  } catch {
19293
19558
  return;
19294
19559
  }
19295
- fs16.rmSync(file, { force: true });
19560
+ fs17.rmSync(file, { force: true });
19296
19561
  const session = input.session.id;
19297
19562
  const now = Date.now() / 1000;
19298
19563
  if (typeof marker.at !== "number" || now - marker.at > MARKER_TTL_SECONDS)
@@ -19341,7 +19606,7 @@ function settlePendingCommit(input) {
19341
19606
  if (!repo)
19342
19607
  return;
19343
19608
  const file = markerFile(repo, input.session.id, NEXT_COMMAND);
19344
- if (fs16.existsSync(file))
19609
+ if (fs17.existsSync(file))
19345
19610
  settle2(input, repo, file);
19346
19611
  } catch {}
19347
19612
  }
@@ -19495,7 +19760,7 @@ var judgedDir = (root, dir) => {
19495
19760
  return null;
19496
19761
  if (dir === null)
19497
19762
  return root;
19498
- const resolved = path25.resolve(root, dir);
19763
+ const resolved = path26.resolve(root, dir);
19499
19764
  return existsSync11(resolved) && inWorkitWorkspace(resolved) ? resolved : null;
19500
19765
  };
19501
19766
  var shellBranchPolicyViolation = (root, command, dialect = "posix") => {
@@ -19692,13 +19957,13 @@ var askedWorkitCall = (command, dialect = "posix", depth = 0) => {
19692
19957
  return null;
19693
19958
  };
19694
19959
  // packages/workit-core/src/core/heavy-rules.ts
19695
- import fs17 from "node:fs";
19696
- import os6 from "node:os";
19697
- import path26 from "node:path";
19960
+ import fs18 from "node:fs";
19961
+ import os7 from "node:os";
19962
+ import path27 from "node:path";
19698
19963
  var EMPTY2 = () => ({ deny: [], allow: [] });
19699
19964
  var readText3 = (file) => {
19700
19965
  try {
19701
- return fs17.readFileSync(file, "utf8");
19966
+ return fs18.readFileSync(file, "utf8");
19702
19967
  } catch (error) {
19703
19968
  if (error.code === "ENOENT")
19704
19969
  return null;
@@ -19735,23 +20000,23 @@ function parseJsonc(text) {
19735
20000
  return JSON.parse(out.replace(/,(\s*[}\]])/gu, "$1"));
19736
20001
  }
19737
20002
  function gitTop(cwd) {
19738
- for (let dir = path26.resolve(cwd);; dir = path26.dirname(dir)) {
19739
- if (fs17.existsSync(path26.join(dir, ".git")))
20003
+ for (let dir = path27.resolve(cwd);; dir = path27.dirname(dir)) {
20004
+ if (fs18.existsSync(path27.join(dir, ".git")))
19740
20005
  return dir;
19741
- if (path26.dirname(dir) === dir)
20006
+ if (path27.dirname(dir) === dir)
19742
20007
  return null;
19743
20008
  }
19744
20009
  }
19745
20010
  var projectDirs = (cwd) => {
19746
20011
  const top = gitTop(cwd);
19747
20012
  const dirs = [];
19748
- for (let dir = path26.resolve(cwd);; dir = path26.dirname(dir)) {
20013
+ for (let dir = path27.resolve(cwd);; dir = path27.dirname(dir)) {
19749
20014
  dirs.push(dir);
19750
- if (!top || dir === top || path26.dirname(dir) === dir)
20015
+ if (!top || dir === top || path27.dirname(dir) === dir)
19751
20016
  return dirs;
19752
20017
  }
19753
20018
  };
19754
- var homeOf = (env) => env.HOME || os6.homedir();
20019
+ var homeOf = (env) => env.HOME || os7.homedir();
19755
20020
  var CLAUDE_MANAGED = {
19756
20021
  linux: "/etc/claude-code/managed-settings.json",
19757
20022
  darwin: "/Library/Application Support/ClaudeCode/managed-settings.json",
@@ -19759,12 +20024,12 @@ var CLAUDE_MANAGED = {
19759
20024
  };
19760
20025
  function claudeSettingsFiles(cwd, env, platform = process.platform) {
19761
20026
  const project = env.CLAUDE_PROJECT_DIR || gitTop(cwd) || cwd;
19762
- const user = env.CLAUDE_CONFIG_DIR || path26.join(homeOf(env), ".claude");
20027
+ const user = env.CLAUDE_CONFIG_DIR || path27.join(homeOf(env), ".claude");
19763
20028
  return [
19764
20029
  ...CLAUDE_MANAGED[platform] ? [CLAUDE_MANAGED[platform]] : [],
19765
- path26.join(user, "settings.json"),
19766
- path26.join(project, ".claude", "settings.json"),
19767
- path26.join(project, ".claude", "settings.local.json")
20030
+ path27.join(user, "settings.json"),
20031
+ path27.join(project, ".claude", "settings.json"),
20032
+ path27.join(project, ".claude", "settings.local.json")
19768
20033
  ];
19769
20034
  }
19770
20035
  var bashPattern = (entry) => {
@@ -19871,10 +20136,10 @@ var opencodeConfig = (value, rules) => isRecord5(value) && opencodeRuleset(value
19871
20136
  function opencodeRules(cwd, env = process.env) {
19872
20137
  const rules = EMPTY2();
19873
20138
  try {
19874
- const config = env.XDG_CONFIG_HOME || path26.join(homeOf(env), ".config");
20139
+ const config = env.XDG_CONFIG_HOME || path27.join(homeOf(env), ".config");
19875
20140
  const files = [
19876
- ...OPENCODE_NAMES.map((name) => path26.join(config, "opencode", name)),
19877
- ...projectDirs(cwd).flatMap((dir) => OPENCODE_NAMES.flatMap((name) => [path26.join(dir, name), path26.join(dir, ".opencode", name)])),
20141
+ ...OPENCODE_NAMES.map((name) => path27.join(config, "opencode", name)),
20142
+ ...projectDirs(cwd).flatMap((dir) => OPENCODE_NAMES.flatMap((name) => [path27.join(dir, name), path27.join(dir, ".opencode", name)])),
19878
20143
  ...env.OPENCODE_CONFIG ? [env.OPENCODE_CONFIG] : []
19879
20144
  ];
19880
20145
  for (const file of files) {
@@ -19918,19 +20183,19 @@ var codexRule = (body) => {
19918
20183
  function codexRules(cwd, env = process.env) {
19919
20184
  const rules = EMPTY2();
19920
20185
  try {
19921
- const home = env.CODEX_HOME || path26.join(homeOf(env), ".codex");
20186
+ const home = env.CODEX_HOME || path27.join(homeOf(env), ".codex");
19922
20187
  const top = gitTop(cwd) ?? cwd;
19923
- for (const dir of [path26.join(home, "rules"), path26.join(top, ".codex", "rules")]) {
20188
+ for (const dir of [path27.join(home, "rules"), path27.join(top, ".codex", "rules")]) {
19924
20189
  let files;
19925
20190
  try {
19926
- files = fs17.readdirSync(dir).filter((name) => name.endsWith(".rules"));
20191
+ files = fs18.readdirSync(dir).filter((name) => name.endsWith(".rules"));
19927
20192
  } catch (error) {
19928
20193
  if (error.code === "ENOENT")
19929
20194
  continue;
19930
20195
  return "unreadable";
19931
20196
  }
19932
20197
  for (const name of files) {
19933
- const text = readText3(path26.join(dir, name)) ?? "";
20198
+ const text = readText3(path27.join(dir, name)) ?? "";
19934
20199
  for (const part of text.split(/\bprefix_rule\s*\(/u).slice(1)) {
19935
20200
  const rule = codexRule(part);
19936
20201
  if (!rule)
@@ -19949,8 +20214,8 @@ function cursorRules(cwd, env = process.env) {
19949
20214
  try {
19950
20215
  const top = gitTop(cwd) ?? cwd;
19951
20216
  for (const file of [
19952
- path26.join(homeOf(env), ".cursor", "cli-config.json"),
19953
- path26.join(top, ".cursor", "cli.json")
20217
+ path27.join(homeOf(env), ".cursor", "cli-config.json"),
20218
+ path27.join(top, ".cursor", "cli.json")
19954
20219
  ]) {
19955
20220
  const text = readText3(file);
19956
20221
  if (text === null)
@@ -20024,11 +20289,11 @@ function wrapAllowed(read, words, command, options = {}) {
20024
20289
  }
20025
20290
 
20026
20291
  // packages/workit-core/src/core/heavy.ts
20027
- import fs18 from "node:fs";
20028
- import path27 from "node:path";
20292
+ import fs19 from "node:fs";
20293
+ import path28 from "node:path";
20029
20294
  var stateDir = (env, platform = process.platform) => stateDir3(env, platform);
20030
20295
  var HEAVY_COMMANDS_FILE = "heavy-commands.json";
20031
- var heavyCommandsFile = (env) => path27.join(stateDir(env), HEAVY_COMMANDS_FILE);
20296
+ var heavyCommandsFile = (env) => path28.join(stateDir(env), HEAVY_COMMANDS_FILE);
20032
20297
  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;
20033
20298
  var INFO_FLAGS = new Set(["--version", "-v", "-V", "--help", "-h", "help", "version"]);
20034
20299
  var WATCH_FLAG = /^(?:--watch(?:All)?(?:=.*)?|-w|--serve)$/u;
@@ -20380,7 +20645,7 @@ function parsePattern(pattern) {
20380
20645
  var matches = (matchers, words) => matchers.length <= words.length && matchers.every((matcher, index) => index === 0 ? matcher.test(words[0]) || matcher.test(baseName2(words[0])) : matcher.test(words[index]));
20381
20646
  var readJson = (file) => {
20382
20647
  try {
20383
- return JSON.parse(fs18.readFileSync(file, "utf8"));
20648
+ return JSON.parse(fs19.readFileSync(file, "utf8"));
20384
20649
  } catch {
20385
20650
  return;
20386
20651
  }
@@ -20392,7 +20657,7 @@ function machinePatterns(env) {
20392
20657
  return isRecord6(value) ? stringList(value.patterns) : [];
20393
20658
  }
20394
20659
  function repoPatterns(cwd) {
20395
- return repoHeavyCommands(gitTop(cwd) ?? path27.resolve(cwd));
20660
+ return repoHeavyCommands(gitTop(cwd) ?? path28.resolve(cwd));
20396
20661
  }
20397
20662
  function heavyLines(lines, options) {
20398
20663
  const found = [];
@@ -20495,12 +20760,12 @@ function serverPlan(command, options) {
20495
20760
  }
20496
20761
  function workitOnPath(env = process.env) {
20497
20762
  const names = process.platform === "win32" ? ["workit.exe", "workit.cmd", "workit"] : ["workit"];
20498
- for (const dir of (env.PATH ?? "").split(path27.delimiter))
20763
+ for (const dir of (env.PATH ?? "").split(path28.delimiter))
20499
20764
  for (const name of names) {
20500
20765
  if (!dir)
20501
20766
  continue;
20502
20767
  try {
20503
- fs18.accessSync(path27.join(dir, name), fs18.constants.X_OK);
20768
+ fs19.accessSync(path28.join(dir, name), fs19.constants.X_OK);
20504
20769
  return true;
20505
20770
  } catch {}
20506
20771
  }
@@ -20586,15 +20851,15 @@ import {
20586
20851
  realpathSync as realpathSync8,
20587
20852
  statSync as statSync3
20588
20853
  } from "node:fs";
20589
- import os8 from "node:os";
20590
- import path29 from "node:path";
20854
+ import os9 from "node:os";
20855
+ import path30 from "node:path";
20591
20856
 
20592
20857
  // packages/workit-core/src/core/live-session.ts
20593
20858
  import { spawnSync as spawnSync15 } from "node:child_process";
20594
20859
  import { createHash as createHash15 } from "node:crypto";
20595
- import fs19 from "node:fs";
20596
- import os7 from "node:os";
20597
- import path28 from "node:path";
20860
+ import fs20 from "node:fs";
20861
+ import os8 from "node:os";
20862
+ import path29 from "node:path";
20598
20863
  var LIVE_SESSION_TTL_MS = 15 * 60000;
20599
20864
  var HEARTBEAT_EVERY_MS = 30000;
20600
20865
  var liveProbe = {
@@ -20615,9 +20880,9 @@ var processAlive = (pid) => {
20615
20880
  var processInfo = (pid) => {
20616
20881
  try {
20617
20882
  if (liveProbe.platform === "linux") {
20618
- const stat = fs19.readFileSync(`/proc/${pid}/stat`, "utf8");
20883
+ const stat = fs20.readFileSync(`/proc/${pid}/stat`, "utf8");
20619
20884
  const ppid = Number(stat.slice(stat.lastIndexOf(")") + 2).split(" ")[1]);
20620
- const command = fs19.readFileSync(`/proc/${pid}/cmdline`, "utf8").replaceAll("\x00", " ");
20885
+ const command = fs20.readFileSync(`/proc/${pid}/cmdline`, "utf8").replaceAll("\x00", " ");
20621
20886
  return Number.isInteger(ppid) ? { ppid, command: command.trim() } : null;
20622
20887
  }
20623
20888
  if (liveProbe.platform === "win32")
@@ -20668,35 +20933,35 @@ var liveOwner = (input, transport, env = process.env) => {
20668
20933
  };
20669
20934
  };
20670
20935
  var checkoutOf = (target) => {
20671
- let dir = path28.resolve(target);
20672
- while (!fs19.existsSync(dir) && path28.dirname(dir) !== dir)
20673
- dir = path28.dirname(dir);
20674
- if (fs19.existsSync(dir) && !fs19.statSync(dir).isDirectory())
20675
- dir = path28.dirname(dir);
20676
- const parts = dir.split(path28.sep);
20936
+ let dir = path29.resolve(target);
20937
+ while (!fs20.existsSync(dir) && path29.dirname(dir) !== dir)
20938
+ dir = path29.dirname(dir);
20939
+ if (fs20.existsSync(dir) && !fs20.statSync(dir).isDirectory())
20940
+ dir = path29.dirname(dir);
20941
+ const parts = dir.split(path29.sep);
20677
20942
  const dotGit = parts.lastIndexOf(".git");
20678
20943
  if (dotGit > 0)
20679
- dir = parts.slice(0, dotGit).join(path28.sep) || path28.sep;
20944
+ dir = parts.slice(0, dotGit).join(path29.sep) || path29.sep;
20680
20945
  const location = resolveStore(dir);
20681
20946
  if (location instanceof Error || !location.shared || !location.top)
20682
20947
  return null;
20683
20948
  let top = location.top;
20684
20949
  try {
20685
- top = fs19.realpathSync.native(top);
20950
+ top = fs20.realpathSync.native(top);
20686
20951
  } catch {}
20687
20952
  return top;
20688
20953
  };
20689
- var markerFile2 = (top) => path28.join(resolveStateDir(), "live-sessions", `${createHash15("sha256").update(checkoutKey(top)).digest("hex").slice(0, 32)}.json`);
20954
+ var markerFile2 = (top) => path29.join(resolveStateDir(), "live-sessions", `${createHash15("sha256").update(checkoutKey(top)).digest("hex").slice(0, 32)}.json`);
20690
20955
  var checkoutKey = (top, platform = process.platform) => {
20691
- let key = path28.resolve(top);
20956
+ let key = path29.resolve(top);
20692
20957
  try {
20693
- key = fs19.realpathSync.native(key);
20958
+ key = fs20.realpathSync.native(key);
20694
20959
  } catch {}
20695
20960
  return platform === "win32" ? key.replaceAll("/", "\\").toLowerCase() : key;
20696
20961
  };
20697
20962
  var readMarker = (file) => {
20698
20963
  try {
20699
- const value = JSON.parse(fs19.readFileSync(file, "utf8"));
20964
+ const value = JSON.parse(fs20.readFileSync(file, "utf8"));
20700
20965
  if (value?.version !== 1 || typeof value.session !== "string" || typeof value.host !== "string" || typeof value.heartbeatAt !== "string" || Number.isNaN(Date.parse(value.heartbeatAt)))
20701
20966
  return null;
20702
20967
  return {
@@ -20719,7 +20984,7 @@ var isLive = (marker, deps) => {
20719
20984
  const age = ageOf2(marker, deps.now ?? new Date);
20720
20985
  if (age > (deps.ttlMs ?? LIVE_SESSION_TTL_MS))
20721
20986
  return false;
20722
- if (marker.machine !== (deps.machine ?? os7.hostname()) || marker.pid === null)
20987
+ if (marker.machine !== (deps.machine ?? os8.hostname()) || marker.pid === null)
20723
20988
  return true;
20724
20989
  if (!(deps.alive ?? processAlive)(marker.pid))
20725
20990
  return false;
@@ -20748,7 +21013,7 @@ var liveConflict = (target, owner, deps = {}) => {
20748
21013
  const marker = readMarker(file);
20749
21014
  if (!marker || sameLead(marker, owner) || !isLive(marker, deps))
20750
21015
  return null;
20751
- if (sameOwner(marker, owner, deps.machine ?? os7.hostname()))
21016
+ if (sameOwner(marker, owner, deps.machine ?? os8.hostname()))
20752
21017
  return null;
20753
21018
  return { marker, file, ageMs: ageOf2(marker, deps.now ?? new Date), checkout };
20754
21019
  } catch {
@@ -20762,7 +21027,7 @@ var claimLiveSession = (target, owner, deps = {}) => {
20762
21027
  return;
20763
21028
  const file = markerFile2(checkout);
20764
21029
  const now = deps.now ?? new Date;
20765
- const machine = deps.machine ?? os7.hostname();
21030
+ const machine = deps.machine ?? os8.hostname();
20766
21031
  const current = readMarker(file);
20767
21032
  if (current) {
20768
21033
  const age = ageOf2(current, now);
@@ -20783,10 +21048,10 @@ var claimLiveSession = (target, owner, deps = {}) => {
20783
21048
  checkout,
20784
21049
  heartbeatAt: now.toISOString()
20785
21050
  };
20786
- fs19.mkdirSync(path28.dirname(file), { recursive: true });
21051
+ fs20.mkdirSync(path29.dirname(file), { recursive: true });
20787
21052
  const temp = `${file}.${process.pid}.tmp`;
20788
- fs19.writeFileSync(temp, JSON.stringify(marker));
20789
- fs19.renameSync(temp, file);
21053
+ fs20.writeFileSync(temp, JSON.stringify(marker));
21054
+ fs20.renameSync(temp, file);
20790
21055
  } catch {}
20791
21056
  };
20792
21057
 
@@ -20796,44 +21061,44 @@ var CASE_INSENSITIVE = process.platform === "darwin" || process.platform === "wi
20796
21061
  var linkTarget = (file) => {
20797
21062
  try {
20798
21063
  const to = readlinkSync3(file);
20799
- let from = path29.dirname(file);
21064
+ let from = path30.dirname(file);
20800
21065
  try {
20801
21066
  from = realpathSync8.native(from);
20802
21067
  } catch {}
20803
- return path29.resolve(from, to);
21068
+ return path30.resolve(from, to);
20804
21069
  } catch {
20805
21070
  return null;
20806
21071
  }
20807
21072
  };
20808
21073
  var realPath = (file, dangling = true) => {
20809
- let dir = path29.resolve(file);
21074
+ let dir = path30.resolve(file);
20810
21075
  let rest = "";
20811
21076
  for (let hops = 0;; ) {
20812
21077
  try {
20813
- return path29.join(realpathSync8.native(dir), rest);
21078
+ return path30.join(realpathSync8.native(dir), rest);
20814
21079
  } catch {
20815
21080
  const link = dangling ? linkTarget(dir) : null;
20816
21081
  if (link !== null) {
20817
21082
  if (++hops > 40)
20818
21083
  return null;
20819
- dir = path29.join(link, rest);
21084
+ dir = path30.join(link, rest);
20820
21085
  rest = "";
20821
- } else if (path29.dirname(dir) === dir)
20822
- return path29.resolve(file);
21086
+ } else if (path30.dirname(dir) === dir)
21087
+ return path30.resolve(file);
20823
21088
  else {
20824
- rest = rest ? path29.join(path29.basename(dir), rest) : path29.basename(dir);
20825
- dir = path29.dirname(dir);
21089
+ rest = rest ? path30.join(path30.basename(dir), rest) : path30.basename(dir);
21090
+ dir = path30.dirname(dir);
20826
21091
  }
20827
21092
  }
20828
21093
  }
20829
21094
  };
20830
- var canonical4 = (file, dangling = true) => realPath(file, dangling) ?? path29.resolve(file);
21095
+ var canonical5 = (file, dangling = true) => realPath(file, dangling) ?? path30.resolve(file);
20831
21096
  var exempt = (cwd, root, file, plans) => {
20832
21097
  const fold = (value) => CASE_INSENSITIVE ? value.toLowerCase() : value;
20833
- const relative = path29.relative(fold(canonical4(root, false)), fold(canonical4(path29.resolve(cwd, file), false)));
20834
- if (relative.startsWith("..") || path29.isAbsolute(relative))
21098
+ const relative = path30.relative(fold(canonical5(root, false)), fold(canonical5(path30.resolve(cwd, file), false)));
21099
+ if (relative.startsWith("..") || path30.isAbsolute(relative))
20835
21100
  return true;
20836
- const posix = relative.split(path29.sep).join("/");
21101
+ const posix = relative.split(path30.sep).join("/");
20837
21102
  const segments = posix.split("/");
20838
21103
  return /\.mdx?$/i.test(posix) || segments[0] === "docs" || segments.includes("plans") || [...plans].some((plan) => fold(plan) === posix);
20839
21104
  };
@@ -20950,8 +21215,8 @@ var WRAPPERS3 = {
20950
21215
  bunx: "p"
20951
21216
  };
20952
21217
  var INTERPRETERS = /^(?:python[\d.]*|node|bun|deno|ruby|perl|php|tsx|ts-node)$/;
20953
- var isConfigDir = (file) => configDirs().some((dir) => canonical4(dir) === canonical4(file));
20954
- var isRoot = (file) => isConfigDir(file) || /^(?:issued[^\\/]*|approvals)$/.test(path29.relative(canonical4(resolveStateDir()), canonical4(file)));
21218
+ var isConfigDir = (file) => configDirs().some((dir) => canonical5(dir) === canonical5(file));
21219
+ var isRoot = (file) => isConfigDir(file) || /^(?:issued[^\\/]*|approvals)$/.test(path30.relative(canonical5(resolveStateDir()), canonical5(file)));
20955
21220
  var READ_CALLS = /^(?:print|log|info|warn|error|debug|puts|readdir(?:Sync)?|listdir|scandir|iterdir|glob|l?stat(?:Sync)?|exists(?:Sync)?|isdir|isfile|is_dir|is_file|access(?:Sync)?|realpath(?:Sync)?|dirname|basename|relative|str|repr|len)$/;
20956
21221
  var MUTATING_CALLS = /^(?:renames?(?:Sync)?|move|copy(?:2|file|tree|File)?(?:Sync)?|cp(?:Sync)?|rm(?:tree|dir|Sync|dirSync)?|unlink(?:Sync)?|remove(?:dirs)?|mkdirs?(?:Sync)?|makedirs|mkdtemp(?:Sync)?|(?:sym|hard)?link(?:Sync|_to)?|write\w*|append\w*|truncate(?:Sync)?|ch(?:mod|own)(?:Sync)?|touch|open(?:Sync)?|dump|save|extractall|unpack_archive|put_contents|mv|FileUtils)$/;
20957
21222
  var SPAWNS = /subprocess|child_process|WriteStream|tempfile|sqlite|inplace|getattr|spawn|\bvm\b|Function\s*\(|FileIO|ZipFile|tarfile|shelve|FileHandler|filename\s*=|savefig|utime|ch(?:mod|own)|mkfifo|mknod|\.(?:delete|to_\w+)\s*\(|Path\b.*\.replace\(|Bun\.\$|O_(?:WR|RDW|CR|AP|TR)|(?:PYTHON|NODE_)\w*=|-r\b|--(?:require|import|[\w-]*loader)|\bos\.replace|\b(?:system|popen|exec\w*|fork|eval|shutil|(?:unlink|rename|remove)\w*)\b|\]\s*\(|\brequire\s*\(\s*(?!(['"])(?:(?![a-zA-Z]:)[\w@][^'"]*|[^'"]*\.json)\1)/;
@@ -21291,10 +21556,10 @@ var linkSources = (args, at) => {
21291
21556
  const sources = names.filter((name, index) => into >= 0 ? name !== dest : index < names.length - 1 || names.length === 1);
21292
21557
  const target = dest === undefined ? null : at(dest);
21293
21558
  const symbolic = args.some((arg) => /^-[a-zA-Z]*s|^--symbolic$/.test(arg));
21294
- const base = target === null ? null : into >= 0 || sources.length > 1 || existsSync12(target) || /[\\/]$/.test(dest ?? "") ? target : path29.dirname(target);
21559
+ const base = target === null ? null : into >= 0 || sources.length > 1 || existsSync12(target) || /[\\/]$/.test(dest ?? "") ? target : path30.dirname(target);
21295
21560
  return sources.flatMap((source) => {
21296
- if (symbolic && base !== null && !path29.isAbsolute(homeExpanded(source)))
21297
- return [path29.resolve(base, source)];
21561
+ if (symbolic && base !== null && !path30.isAbsolute(homeExpanded(source)))
21562
+ return [path30.resolve(base, source)];
21298
21563
  const resolved = at(source);
21299
21564
  return resolved ? [resolved] : [];
21300
21565
  });
@@ -21323,7 +21588,7 @@ var shellWrites = (command, depth = 0) => {
21323
21588
  return { writes: true, targets: unknown ? null : targets };
21324
21589
  };
21325
21590
  var cache2 = new Map;
21326
- var planKeyOf = (root, plans) => [...plans].map((file) => fileSignature(path29.resolve(root, file)) ?? "-").join("\x00");
21591
+ var planKeyOf = (root, plans) => [...plans].map((file) => fileSignature(path30.resolve(root, file)) ?? "-").join("\x00");
21327
21592
  var gateFor = (cwd) => {
21328
21593
  const store = new TaskReader(cwd);
21329
21594
  const listed = store.listTaskIndex();
@@ -21386,7 +21651,7 @@ var DIR_TARGET = ".workit-live-target";
21386
21651
  var PLACEHOLDERS = new WeakMap;
21387
21652
  var collecting = null;
21388
21653
  var placeholderIn = (dir, name) => {
21389
- const target = path29.join(dir, name);
21654
+ const target = path30.join(dir, name);
21390
21655
  collecting?.add(target);
21391
21656
  return target;
21392
21657
  };
@@ -21426,13 +21691,13 @@ var gitMutationDirs = (cwd, command, dialect) => {
21426
21691
  return [];
21427
21692
  if (sub === "stash" && ["list", "show"].includes(rest[0] ?? ""))
21428
21693
  return [];
21429
- return [path29.resolve(cwd, invocation.dir ?? ".")];
21694
+ return [path30.resolve(cwd, invocation.dir ?? ".")];
21430
21695
  });
21431
21696
  };
21432
21697
  var CD2 = new Set(["cd", "chdir", "set-location", "sl"]);
21433
21698
  var PUSHD2 = new Set(["pushd", "push-location"]);
21434
21699
  var POPD2 = new Set(["popd", "pop-location"]);
21435
- var UNKNOWN_DIR = path29.resolve(path29.parse(process.cwd()).root, ".workit-unknown-dir");
21700
+ var UNKNOWN_DIR = path30.resolve(path30.parse(process.cwd()).root, ".workit-unknown-dir");
21436
21701
  var cdInto = (dir, words, strict = false, vars = new Map, globs = false) => {
21437
21702
  const lost = strict ? UNKNOWN_DIR : undefined;
21438
21703
  const found = words.slice(1).find((word) => !word.startsWith("-") || word === "-");
@@ -21442,7 +21707,7 @@ var cdInto = (dir, words, strict = false, vars = new Map, globs = false) => {
21442
21707
  return lost;
21443
21708
  if (dir === undefined)
21444
21709
  return lost;
21445
- return target === undefined ? os8.homedir() : path29.resolve(dir, target);
21710
+ return target === undefined ? os9.homedir() : path30.resolve(dir, target);
21446
21711
  };
21447
21712
  var quoteWord2 = (word) => /^[\w@%+=:,./-]+$/.test(word) ? word : `'${word.replaceAll("'", "'\\''")}'`;
21448
21713
  var expandVars = (text, vars) => vars.size === 0 || !text.includes("$") ? text : text.replace(/\$(?:(\w+)|\{(\w+)\})/g, (whole, bare, braced) => {
@@ -21577,7 +21842,7 @@ var untrustedVars = (segments) => {
21577
21842
  }
21578
21843
  return { all, names };
21579
21844
  };
21580
- var UNKNOWN_VAR = path29.resolve(path29.parse(process.cwd()).root, ".workit-unknown-var");
21845
+ var UNKNOWN_VAR = path30.resolve(path30.parse(process.cwd()).root, ".workit-unknown-var");
21581
21846
  var REFERENCE = /\$\{(\w+)[^}]*\}|\$(\w+)|\$\([^)]*\)?|`[^`]*`?/g;
21582
21847
  var unresolvedRefs = (text) => [
21583
21848
  ...new Set([...text.matchAll(REFERENCE)].map((match) => {
@@ -21587,7 +21852,7 @@ var unresolvedRefs = (text) => [
21587
21852
  ];
21588
21853
  var unknownVarTarget = (text) => {
21589
21854
  const refs = unresolvedRefs(text);
21590
- return path29.join(UNKNOWN_VAR, (refs.length > 0 ? refs : [text]).map(encodeURIComponent).join("+"));
21855
+ return path30.join(UNKNOWN_VAR, (refs.length > 0 ? refs : [text]).map(encodeURIComponent).join("+"));
21591
21856
  };
21592
21857
  var applyOperator = (value, operator) => {
21593
21858
  if (operator === "")
@@ -21646,18 +21911,18 @@ var mktempPath = (value, dir) => {
21646
21911
  template = arg;
21647
21912
  }
21648
21913
  if (base === null && (temp || template === undefined))
21649
- base = os8.tmpdir();
21914
+ base = os9.tmpdir();
21650
21915
  const name = homeExpanded(template ?? "tmp.XXXXXXXXXX");
21651
- if (path29.isAbsolute(name))
21916
+ if (path30.isAbsolute(name))
21652
21917
  return name;
21653
21918
  const from = base === null ? dir : homeExpanded(base);
21654
- if (from === undefined || !path29.isAbsolute(from) && dir === undefined)
21919
+ if (from === undefined || !path30.isAbsolute(from) && dir === undefined)
21655
21920
  return null;
21656
- return path29.resolve(dir ?? from, from, name);
21921
+ return path30.resolve(dir ?? from, from, name);
21657
21922
  };
21658
21923
  var homeExpanded = (file) => {
21659
21924
  const match = /^(?:~|\$HOME|\$\{HOME\})(?=\/|$)/.exec(file);
21660
- return match ? (process.env.HOME || os8.homedir()) + file.slice(match[0].length) : file;
21925
+ return match ? (process.env.HOME || os9.homedir()) + file.slice(match[0].length) : file;
21661
21926
  };
21662
21927
  var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherited = new Map) => {
21663
21928
  const targets = [];
@@ -21674,7 +21939,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
21674
21939
  const home = homeExpanded(text);
21675
21940
  if (strict && unresolvedRefs(home).length > 0)
21676
21941
  return [unknownVarTarget(home)];
21677
- if (path29.isAbsolute(home))
21942
+ if (path30.isAbsolute(home))
21678
21943
  return [home];
21679
21944
  return base === undefined ? [] : [resolvedUnder(base, home)];
21680
21945
  });
@@ -21869,7 +22134,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
21869
22134
  index
21870
22135
  }));
21871
22136
  const homes = /homedir\(|expanduser\(|Path\.home\(|['"]HOME['"]|env\.HOME|\$HOME|~/.test(text);
21872
- const under = (word) => homes ? [path29.join(homeExpanded("~"), word.replace(/^~/, ""))] : [];
22137
+ const under = (word) => homes ? [path30.join(homeExpanded("~"), word.replace(/^~/, ""))] : [];
21873
22138
  const found = [
21874
22139
  ...[...text.matchAll(PATHS)].flatMap(({ 0: word, index }) => [...atAll(word), ...under(word)].map((file) => ({ file, index }))),
21875
22140
  ...joined.flatMap(({ word, index }) => under(word).map((file) => ({ file, index })))
@@ -21877,7 +22142,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
21877
22142
  for (const { file, index } of found) {
21878
22143
  const use = isRoot(file) ? rootUse(text, index) : "takes";
21879
22144
  if (use !== "reads")
21880
- targets.push(use === "builds" ? path29.join(file, UNRESOLVED_TARGET) : file);
22145
+ targets.push(use === "builds" ? path30.join(file, UNRESOLVED_TARGET) : file);
21881
22146
  }
21882
22147
  }
21883
22148
  if (/^(?:n?vim?|ex|ed|emacs)$/.test(verb) && (segment.stdin || inputs.length > 0 || feeder || args.some((arg, index) => /^(?:-[a-zA-Z]*[se]|--(?:batch|eval|script))$/.test(arg) || /^(?:-c|--cmd)$/.test(arg) && !inertEdit(args[index + 1] ?? "") || arg.startsWith("+") && !inertEdit(arg.slice(1) || "1"))))
@@ -21912,7 +22177,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
21912
22177
  for (const file of opaque ?? [])
21913
22178
  for (const resolved of atAll(file))
21914
22179
  if (!quiet || !isRoot(resolved))
21915
- targets.push(file === "." ? placeholderIn(resolved, here) : path29.basename(resolved).startsWith(OPAQUE_TARGET) ? placeholderIn(path29.dirname(resolved), path29.basename(resolved)) : resolved);
22180
+ targets.push(file === "." ? placeholderIn(resolved, here) : path30.basename(resolved).startsWith(OPAQUE_TARGET) ? placeholderIn(path30.dirname(resolved), path30.basename(resolved)) : resolved);
21916
22181
  const ln = words.findIndex((word) => /^ln$/i.test(word.split(/[\\/]/).at(-1) ?? ""));
21917
22182
  const lnArgs = words.slice(ln + 1);
21918
22183
  if (ln >= 0 && words.slice(0, ln).every((word) => PREFIXES2.has(word)) && (strict !== "registry" || !lnArgs.some((arg) => /^-[a-zA-Z]*s|^--symbolic$/.test(arg))))
@@ -21991,7 +22256,7 @@ var liveDeny = ({ marker, checkout, ageMs, file }) => {
21991
22256
  var guarded = (targets) => {
21992
22257
  const seen = new Set;
21993
22258
  return targets.filter((target) => {
21994
- const dir = path29.dirname(target);
22259
+ const dir = path30.dirname(target);
21995
22260
  if (seen.has(dir))
21996
22261
  return false;
21997
22262
  seen.add(dir);
@@ -22012,17 +22277,17 @@ var claimAll = (owner, targets, deps) => {
22012
22277
  for (const target of guarded(targets))
22013
22278
  claimLiveSession(target, owner, deps);
22014
22279
  };
22015
- var resolvedUnder = (dir, file) => !/(?:^|[\\/])\.\.(?:[\\/]|$)/.test(file) ? path29.resolve(dir, file) : path29.isAbsolute(file) ? file : `${dir}${path29.sep}${file}`;
22280
+ var resolvedUnder = (dir, file) => !/(?:^|[\\/])\.\.(?:[\\/]|$)/.test(file) ? path30.resolve(dir, file) : path30.isAbsolute(file) ? file : `${dir}${path30.sep}${file}`;
22016
22281
  var liveTargets = (cwd, paths) => recording(() => paths?.length ? paths.map((file) => resolvedUnder(cwd, file)) : [placeholderIn(cwd, DIR_TARGET)]);
22017
22282
  var CONFIG_FILES = ["workspaces.json", SEAL_FILE];
22018
22283
  var configDirs = () => [resolveConfigDir(), grantsDir()];
22019
22284
  var globbed = (cwd, target, state, configs) => {
22020
22285
  if (!/[*?[]/.test(target))
22021
22286
  return [];
22022
- const raw = path29.resolve(cwd, target).split(path29.sep);
22287
+ const raw = path30.resolve(cwd, target).split(path30.sep);
22023
22288
  const literal = raw.findIndex((part) => /[*?[]/.test(part));
22024
22289
  const pattern = [
22025
- ...canonical4(raw.slice(0, literal).join(path29.sep) || path29.sep).replace(/[\\/]+$/, "").split(path29.sep),
22290
+ ...canonical5(raw.slice(0, literal).join(path30.sep) || path30.sep).replace(/[\\/]+$/, "").split(path30.sep),
22026
22291
  ...raw.slice(literal)
22027
22292
  ];
22028
22293
  const segment = (glob, name) => {
@@ -22033,7 +22298,7 @@ var globbed = (cwd, target, state, configs) => {
22033
22298
  }
22034
22299
  };
22035
22300
  const hit = (file, below) => {
22036
- const parts = canonical4(file).split(path29.sep);
22301
+ const parts = canonical5(file).split(path30.sep);
22037
22302
  return (below ? pattern.length >= parts.length : pattern.length === parts.length) && parts.every((part, index) => segment(pattern[index], part));
22038
22303
  };
22039
22304
  let roots = [];
@@ -22041,8 +22306,8 @@ var globbed = (cwd, target, state, configs) => {
22041
22306
  roots = readdirSync3(state).filter((name) => /^(?:issued|approvals$)/.test(name));
22042
22307
  } catch {}
22043
22308
  return [
22044
- ...roots.map((name) => path29.join(state, name)).filter((root) => hit(root, true)),
22045
- ...configs.flatMap((dir) => [dir, ...CONFIG_FILES.map((name) => path29.join(dir, name))]).filter((file) => hit(file, false))
22309
+ ...roots.map((name) => path30.join(state, name)).filter((root) => hit(root, true)),
22310
+ ...configs.flatMap((dir) => [dir, ...CONFIG_FILES.map((name) => path30.join(dir, name))]).filter((file) => hit(file, false))
22046
22311
  ];
22047
22312
  };
22048
22313
  var guardedInodes = (state, configs) => {
@@ -22056,15 +22321,15 @@ var guardedInodes = (state, configs) => {
22056
22321
  seen.set(`${stat.dev}:${stat.ino}`, registry);
22057
22322
  else if (stat?.isDirectory())
22058
22323
  for (const name of readdirSync3(file))
22059
- add(path29.join(file, name), registry);
22324
+ add(path30.join(file, name), registry);
22060
22325
  };
22061
22326
  try {
22062
22327
  for (const dir of configs)
22063
22328
  for (const name of CONFIG_FILES)
22064
- add(path29.join(dir, name), "grants");
22329
+ add(path30.join(dir, name), "grants");
22065
22330
  for (const name of readdirSync3(state))
22066
22331
  if (/^(?:issued|approvals$)/.test(name))
22067
- add(path29.join(state, name), name === "approvals" ? "approvals" : "issued");
22332
+ add(path30.join(state, name), name === "approvals" ? "approvals" : "issued");
22068
22333
  } catch {}
22069
22334
  return seen;
22070
22335
  };
@@ -22085,13 +22350,13 @@ var registryTarget = (cwd, targets) => {
22085
22350
  const inodes = {};
22086
22351
  for (const target of targets) {
22087
22352
  const file = homeExpanded(target);
22088
- if (realPath(path29.resolve(cwd, file)) === null)
22353
+ if (realPath(path30.resolve(cwd, file)) === null)
22089
22354
  return { file: target, registry: "link" };
22090
22355
  const glob = globbed(cwd, file, state, configs)[0];
22091
22356
  const viaGlob = glob === undefined ? null : registryTarget(cwd, [glob]);
22092
22357
  if (viaGlob)
22093
22358
  return { file: target, registry: viaGlob.registry };
22094
- const registry = hardLinked(path29.resolve(cwd, file), state, configs, inodes) ?? underRegistry(state, cwd, file, process.platform, canonical4) ?? (configs.some((dir) => underConfig(dir, cwd, file, process.platform, canonical4)) ? "grants" : null);
22359
+ const registry = hardLinked(path30.resolve(cwd, file), state, configs, inodes) ?? underRegistry(state, cwd, file, process.platform, canonical5) ?? (configs.some((dir) => underConfig(dir, cwd, file, process.platform, canonical5)) ? "grants" : null);
22095
22360
  if (registry)
22096
22361
  return { file: target, registry };
22097
22362
  }
@@ -22099,7 +22364,7 @@ var registryTarget = (cwd, targets) => {
22099
22364
  };
22100
22365
  var partsUnder = (dir, cwd, target, platform, real) => {
22101
22366
  const win = platform === "win32";
22102
- const p = win ? path29.win32 : path29.posix;
22367
+ const p = win ? path30.win32 : path30.posix;
22103
22368
  const fold = (value) => win || platform === "darwin" ? value.toLowerCase() : value;
22104
22369
  const named = win ? target.replace(/^\/([a-zA-Z])(?=\/|$)/, "$1:") : target;
22105
22370
  const relative = p.relative(fold(real(p.resolve(dir))), fold(real(p.resolve(cwd, named))));
@@ -22161,13 +22426,13 @@ var REGISTRY_DENY = {
22161
22426
  };
22162
22427
  var registryDeny = ({ file, registry }) => {
22163
22428
  const { label, what, unblock } = REGISTRY_DENY[registry];
22164
- if (path29.basename(file) === UNRESOLVED_TARGET)
22429
+ if (path30.basename(file) === UNRESOLVED_TARGET)
22165
22430
  return {
22166
22431
  kind: "deny",
22167
22432
  reason: `workit ${label}: Workit could not resolve the file this command's script writes, which it builds from a path under ${what}. ${unblock}`,
22168
22433
  unblock
22169
22434
  };
22170
- const named = path29.basename(file).startsWith(".workit-") ? path29.dirname(file) : file;
22435
+ const named = path30.basename(file).startsWith(".workit-") ? path30.dirname(file) : file;
22171
22436
  return {
22172
22437
  kind: "deny",
22173
22438
  reason: `workit ${label}: ${named} is under ${what}. ${unblock}`,
@@ -22256,11 +22521,11 @@ function beforeWriteGate(cwd, paths) {
22256
22521
  import { spawnSync as spawnSync16 } from "node:child_process";
22257
22522
 
22258
22523
  // packages/workit-core/src/ci-waiter.ts
22259
- import fs20 from "node:fs";
22260
- import path30 from "node:path";
22524
+ import fs21 from "node:fs";
22525
+ import path31 from "node:path";
22261
22526
  var waiterFile = (cwd, pr) => {
22262
22527
  const common = gitCommonDir(cwd);
22263
- return common ? path30.join(common, "workit", "ci-waits", `pr-${pr}.json`) : null;
22528
+ return common ? path31.join(common, "workit", "ci-waits", `pr-${pr}.json`) : null;
22264
22529
  };
22265
22530
  var pidAlive2 = (pid) => {
22266
22531
  if (!Number.isSafeInteger(pid) || pid <= 0)
@@ -22303,7 +22568,7 @@ var liveCiWaiter = (cwd, pr, head = null, nowMs = Date.now()) => {
22303
22568
  const file = waiterFile(cwd, pr);
22304
22569
  if (!file)
22305
22570
  return null;
22306
- const waiter = parse3(fs20.readFileSync(file, "utf8"));
22571
+ const waiter = parse3(fs21.readFileSync(file, "utf8"));
22307
22572
  if (!waiter || waiter.pr !== pr || waiter.pid === process.pid)
22308
22573
  return null;
22309
22574
  if (head && waiter.head && !sameSha(waiter.head, head))
@@ -22763,12 +23028,12 @@ ${line}` };
22763
23028
  };
22764
23029
  // packages/workit-core/src/hooks/hosts/fields.ts
22765
23030
  import { existsSync as existsSync13, realpathSync as realpathSync9, statSync as statSync4 } from "node:fs";
22766
- import path31 from "node:path";
23031
+ import path32 from "node:path";
22767
23032
  var isRecord7 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
22768
23033
  var nonEmpty2 = (value) => typeof value === "string" && value.trim() !== "";
22769
23034
  var optionalText = (value) => typeof value === "string" ? value : null;
22770
23035
  var existingDirectory = (value) => {
22771
- if (!nonEmpty2(value) || !path31.isAbsolute(value) || !existsSync13(value))
23036
+ if (!nonEmpty2(value) || !path32.isAbsolute(value) || !existsSync13(value))
22772
23037
  return null;
22773
23038
  try {
22774
23039
  return statSync4(value).isDirectory() ? realpathSync9(value) : null;
@@ -22835,8 +23100,8 @@ var writeTargets = (input) => {
22835
23100
  return paths.length > 0 ? paths : null;
22836
23101
  };
22837
23102
  // packages/workit-core/src/hooks/standing.ts
22838
- import fs22 from "node:fs";
22839
- import path33 from "node:path";
23103
+ import fs23 from "node:fs";
23104
+ import path34 from "node:path";
22840
23105
 
22841
23106
  // packages/workit-core/src/approvals/store.ts
22842
23107
  var REQUEST_TTL_MS = 30 * 60000;
@@ -23542,41 +23807,41 @@ function neededChecks(lane, configured) {
23542
23807
 
23543
23808
  // packages/workit-core/src/hooks/worktree-confine.ts
23544
23809
  import { createHash as createHash16 } from "node:crypto";
23545
- import fs21 from "node:fs";
23546
- import os9 from "node:os";
23547
- import path32 from "node:path";
23810
+ import fs22 from "node:fs";
23811
+ import os10 from "node:os";
23812
+ import path33 from "node:path";
23548
23813
  var FANOUT_TOKEN_FILE = "workit-fanout-token";
23549
23814
  var NONE5 = { kind: "none" };
23550
23815
  var CASE_INSENSITIVE2 = process.platform === "darwin" || process.platform === "win32";
23551
23816
  var realOf = (file) => {
23552
23817
  let rest = "";
23553
- for (let dir = file;; dir = path32.dirname(dir)) {
23818
+ for (let dir = file;; dir = path33.dirname(dir)) {
23554
23819
  try {
23555
- return path32.join(fs21.realpathSync.native(dir), rest);
23820
+ return path33.join(fs22.realpathSync.native(dir), rest);
23556
23821
  } catch {
23557
- if (path32.dirname(dir) === dir)
23822
+ if (path33.dirname(dir) === dir)
23558
23823
  return file;
23559
- rest = rest ? path32.join(path32.basename(dir), rest) : path32.basename(dir);
23824
+ rest = rest ? path33.join(path33.basename(dir), rest) : path33.basename(dir);
23560
23825
  }
23561
23826
  }
23562
23827
  };
23563
- var canonical5 = (file, hops = { chain: 40, total: 1000 }) => {
23564
- const start = path32.isAbsolute(file) ? file : `${process.cwd()}${path32.sep}${file}`;
23565
- const { root } = path32.parse(start);
23828
+ var canonical6 = (file, hops = { chain: 40, total: 1000 }) => {
23829
+ const start = path33.isAbsolute(file) ? file : `${process.cwd()}${path33.sep}${file}`;
23830
+ const { root } = path33.parse(start);
23566
23831
  let at = root;
23567
23832
  let missing = false;
23568
23833
  for (const part of start.slice(root.length).split(/[\\/]+/)) {
23569
23834
  if (part === "" || part === ".")
23570
23835
  continue;
23571
23836
  if (part === "..") {
23572
- at = path32.dirname(at);
23837
+ at = path33.dirname(at);
23573
23838
  continue;
23574
23839
  }
23575
- const next = path32.join(at, part);
23840
+ const next = path33.join(at, part);
23576
23841
  let link = null;
23577
23842
  if (!missing)
23578
23843
  try {
23579
- link = fs21.readlinkSync(next);
23844
+ link = fs22.readlinkSync(next);
23580
23845
  } catch (error) {
23581
23846
  missing = error.code !== "EINVAL";
23582
23847
  }
@@ -23584,25 +23849,25 @@ var canonical5 = (file, hops = { chain: 40, total: 1000 }) => {
23584
23849
  at = next;
23585
23850
  hops.chain = 40;
23586
23851
  } else if (hops.chain-- > 0 && hops.total-- > 0)
23587
- at = canonical5(path32.isAbsolute(link) ? link : `${at}${path32.sep}${link}`, hops);
23852
+ at = canonical6(path33.isAbsolute(link) ? link : `${at}${path33.sep}${link}`, hops);
23588
23853
  else
23589
- return path32.resolve(file);
23854
+ return path33.resolve(file);
23590
23855
  }
23591
23856
  return realOf(at);
23592
23857
  };
23593
23858
  var within = (child, parent) => {
23594
23859
  const fold = (value) => CASE_INSENSITIVE2 ? value.toLowerCase() : value;
23595
- const relative = path32.relative(fold(parent), fold(child));
23596
- return relative === "" || !relative.startsWith("..") && !path32.isAbsolute(relative);
23860
+ const relative = path33.relative(fold(parent), fold(child));
23861
+ return relative === "" || !relative.startsWith("..") && !path33.isAbsolute(relative);
23597
23862
  };
23598
23863
  var checkoutOf2 = (file) => {
23599
- for (let dir = canonical5(file);; dir = path32.dirname(dir)) {
23600
- const dotGit = path32.join(dir, ".git");
23601
- if (fs21.existsSync(dotGit)) {
23602
- const admin = fs21.statSync(dotGit).isFile() ? gitDirsAt(dir, null, false)?.[0] : undefined;
23603
- return { root: dir, workit: !!admin && fs21.existsSync(path32.join(admin, FANOUT_TOKEN_FILE)) };
23864
+ for (let dir = canonical6(file);; dir = path33.dirname(dir)) {
23865
+ const dotGit = path33.join(dir, ".git");
23866
+ if (fs22.existsSync(dotGit)) {
23867
+ const admin = fs22.statSync(dotGit).isFile() ? gitDirsAt(dir, null, false)?.[0] : undefined;
23868
+ return { root: dir, workit: !!admin && fs22.existsSync(path33.join(admin, FANOUT_TOKEN_FILE)) };
23604
23869
  }
23605
- if (path32.dirname(dir) === dir)
23870
+ if (path33.dirname(dir) === dir)
23606
23871
  return null;
23607
23872
  }
23608
23873
  };
@@ -23614,11 +23879,11 @@ var workitWorktreeOf = (file) => {
23614
23879
  return null;
23615
23880
  }
23616
23881
  };
23617
- var bindingDir = () => path32.join(resolveStateDir(), "worktree-bind");
23618
- var bindingFile = (session, agentId) => path32.join(bindingDir(), `${createHash16("sha256").update(`${session}\x00${agentId}`).digest("hex").slice(0, 32)}.json`);
23882
+ var bindingDir = () => path33.join(resolveStateDir(), "worktree-bind");
23883
+ var bindingFile = (session, agentId) => path33.join(bindingDir(), `${createHash16("sha256").update(`${session}\x00${agentId}`).digest("hex").slice(0, 32)}.json`);
23619
23884
  var readBinding = (file) => {
23620
23885
  try {
23621
- const value = JSON.parse(fs21.readFileSync(file, "utf8"));
23886
+ const value = JSON.parse(fs22.readFileSync(file, "utf8"));
23622
23887
  return typeof value.worktree === "string" ? value : null;
23623
23888
  } catch {
23624
23889
  return null;
@@ -23640,8 +23905,8 @@ var bind = (input, worktree) => {
23640
23905
  agentId,
23641
23906
  at: new Date().toISOString()
23642
23907
  };
23643
- fs21.mkdirSync(path32.dirname(file), { recursive: true });
23644
- fs21.writeFileSync(file, JSON.stringify(binding));
23908
+ fs22.mkdirSync(path33.dirname(file), { recursive: true });
23909
+ fs22.writeFileSync(file, JSON.stringify(binding));
23645
23910
  try {
23646
23911
  if (inWorkitWorkspace(input.cwd))
23647
23912
  appendHookObserved(input.cwd, {
@@ -23659,26 +23924,26 @@ var hostIsolated = (cwd, agentId) => {
23659
23924
  const checkout = checkoutOf2(cwd);
23660
23925
  if (!checkout)
23661
23926
  return false;
23662
- const dotGit = path32.join(checkout.root, ".git");
23663
- if (!fs21.statSync(dotGit).isFile())
23927
+ const dotGit = path33.join(checkout.root, ".git");
23928
+ if (!fs22.statSync(dotGit).isFile())
23664
23929
  return false;
23665
23930
  const [adminDir, gitDir] = gitDirsAt(checkout.root, null, false) ?? [];
23666
- const back = fs21.readFileSync(path32.join(adminDir, "gitdir"), "utf8").trim();
23667
- if (path32.relative(canonical5(path32.resolve(adminDir, back)), canonical5(dotGit)) !== "")
23931
+ const back = fs22.readFileSync(path33.join(adminDir, "gitdir"), "utf8").trim();
23932
+ if (path33.relative(canonical6(path33.resolve(adminDir, back)), canonical6(dotGit)) !== "")
23668
23933
  return false;
23669
- const expected = path32.join(path32.dirname(gitDir), ".claude", "worktrees", `agent-${agentId}`);
23670
- return path32.relative(canonical5(expected), checkout.root) === "";
23934
+ const expected = path33.join(path33.dirname(gitDir), ".claude", "worktrees", `agent-${agentId}`);
23935
+ return path33.relative(canonical6(expected), checkout.root) === "";
23671
23936
  } catch {
23672
23937
  return false;
23673
23938
  }
23674
23939
  };
23675
23940
  var runnerAt = (target) => {
23676
- const base = path32.basename(target);
23941
+ const base = path33.basename(target);
23677
23942
  return base.startsWith(OPAQUE_TARGET) ? decodeURIComponent(base.slice(OPAQUE_TARGET.length)) : null;
23678
23943
  };
23679
23944
  var shown = (target) => {
23680
- const named = /^\.workit-(?:live-target$|runs-)/.test(path32.basename(target)) ? path32.dirname(target) : target;
23681
- return path32.sep === "\\" ? named.replaceAll("/", "\\") : named;
23945
+ const named = /^\.workit-(?:live-target$|runs-)/.test(path33.basename(target)) ? path33.dirname(target) : target;
23946
+ return path33.sep === "\\" ? named.replaceAll("/", "\\") : named;
23682
23947
  };
23683
23948
  var runFrom = (dir, command) => `cd ${dir} && ${command.replace(/^\s*cd\s+\S+\s*(?:&&|;)\s*/, "")}`;
23684
23949
  var deny2 = (what, unblock) => ({
@@ -23694,7 +23959,7 @@ var outsideDeny = (input, worktree, target, command) => {
23694
23959
  };
23695
23960
  var unknownDirDeny = (input, worktree) => deny2(`workit worktree confinement: implementer ${input.session.agentId} writes after a directory change Workit cannot resolve (\`cd -\`, \`cd "$X"\`, \`popd\`)`, `Why: write by absolute path, \`git -C ${worktree ?? "<worktree>"}\` or \`workit <verb> --cwd\`.`);
23696
23961
  var refsOf = (targets) => [
23697
- ...new Set(targets.flatMap((target) => path32.relative(UNKNOWN_VAR, path32.resolve(target)).split(path32.sep)[0].split("+").filter(Boolean).map(decodeURIComponent)))
23962
+ ...new Set(targets.flatMap((target) => path33.relative(UNKNOWN_VAR, path33.resolve(target)).split(path33.sep)[0].split("+").filter(Boolean).map(decodeURIComponent)))
23698
23963
  ];
23699
23964
  var literalForm = (command, refs) => {
23700
23965
  let text = command;
@@ -23727,13 +23992,13 @@ function confineImplementer(input, targets, command) {
23727
23992
  try {
23728
23993
  if (!input.session.agentId || hostIsolated(input.cwd, input.session.agentId))
23729
23994
  return NONE5;
23730
- const unresolved = targets.filter((target) => within(path32.resolve(target), UNKNOWN_VAR));
23995
+ const unresolved = targets.filter((target) => within(path33.resolve(target), UNKNOWN_VAR));
23731
23996
  if (unresolved.length > 0)
23732
23997
  return unknownVarDeny(input, unresolved, command);
23733
- if (targets.some((target) => within(path32.resolve(target), UNKNOWN_DIR)))
23998
+ if (targets.some((target) => within(path33.resolve(target), UNKNOWN_DIR)))
23734
23999
  return unknownDirDeny(input, boundWorktree(input));
23735
- const bindings = canonical5(bindingDir());
23736
- const judged = targets.map((named) => ({ named, real: canonical5(named) })).filter(({ real }) => within(real, bindings) || checkoutOf2(real) !== null);
24000
+ const bindings = canonical6(bindingDir());
24001
+ const judged = targets.map((named) => ({ named, real: canonical6(named) })).filter(({ real }) => within(real, bindings) || checkoutOf2(real) !== null);
23737
24002
  if (judged.length === 0)
23738
24003
  return NONE5;
23739
24004
  let worktree = boundWorktree(input);
@@ -23747,7 +24012,7 @@ function confineImplementer(input, targets, command) {
23747
24012
  return unboundDeny(input, judged[0].named);
23748
24013
  bind(input, worktree);
23749
24014
  }
23750
- const root = canonical5(worktree);
24015
+ const root = canonical6(worktree);
23751
24016
  const outside = judged.find(({ real }) => !within(real, root) || within(real, bindings));
23752
24017
  return outside ? outsideDeny(input, worktree, outside.named, command) : NONE5;
23753
24018
  } catch {
@@ -23837,10 +24102,10 @@ var INLINE = /^-[a-zA-Z]*[ceEpm]$|^--(?:eval|print|test|version|help)$|^-[hvV]$/
23837
24102
  var VALUED2 = /^-[WXIrC]$|^--(?:require|import|loader|conditions|input-type)$/;
23838
24103
  var commonDir = (root) => gitDirsAt(root, null, false)?.[1] ?? "";
23839
24104
  var inScratch = (real, repo) => {
23840
- for (let dir = real;path32.dirname(dir) !== dir; dir = path32.dirname(dir)) {
23841
- if (path32.basename(dir) !== SCRATCH)
24105
+ for (let dir = real;path33.dirname(dir) !== dir; dir = path33.dirname(dir)) {
24106
+ if (path33.basename(dir) !== SCRATCH)
23842
24107
  continue;
23843
- const root = path32.dirname(dir);
24108
+ const root = path33.dirname(dir);
23844
24109
  const checkout = checkoutOf2(root);
23845
24110
  if (checkout?.root === root && (repo === null || checkout.workit || commonDir(root) === repo))
23846
24111
  return true;
@@ -23850,9 +24115,9 @@ var inScratch = (real, repo) => {
23850
24115
  var inGitDir = (real) => real.split(/[\\/]/).includes(".git");
23851
24116
  var SAFE_KEY = /^(?:core\.(?:repositoryformatversion|filemode|bare|logallrefupdates|ignorecase|precomposeunicode|symlinks)|user\..*|init\.defaultbranch|commit\.gpgsign|extensions\.(?:objectformat|refstorage)|branch\..*\.(?:remote|merge)|remote\..*\.fetch)$/;
23852
24117
  var literalIn = (value, repo, checkout = false) => {
23853
- if (/[$`]/.test(value) || !path32.isAbsolute(value))
24118
+ if (/[$`]/.test(value) || !path33.isAbsolute(value))
23854
24119
  return false;
23855
- const real = canonical5(value);
24120
+ const real = canonical6(value);
23856
24121
  const root = checkout ? checkoutOf2(real)?.root : undefined;
23857
24122
  return inScratch(real, repo) || root !== undefined && (repo === null || commonDir(root) === repo);
23858
24123
  };
@@ -23871,45 +24136,45 @@ var configEntries = (text) => {
23871
24136
  return entries;
23872
24137
  };
23873
24138
  function gitDirsAt(dir, repo, scan = true) {
23874
- for (let at = dir;; at = path32.dirname(at)) {
23875
- const dotGit = path32.join(at, ".git");
24139
+ for (let at = dir;; at = path33.dirname(at)) {
24140
+ const dotGit = path33.join(at, ".git");
23876
24141
  let gitDir = null;
23877
24142
  try {
23878
- if (fs21.statSync(dotGit).isDirectory())
23879
- gitDir = canonical5(dotGit);
24143
+ if (fs22.statSync(dotGit).isDirectory())
24144
+ gitDir = canonical6(dotGit);
23880
24145
  else {
23881
- const named = /^gitdir:\s*(.+?)\s*$/mu.exec(fs21.readFileSync(dotGit, "utf8"))?.[1];
24146
+ const named = /^gitdir:\s*(.+?)\s*$/mu.exec(fs22.readFileSync(dotGit, "utf8"))?.[1];
23882
24147
  if (!named)
23883
24148
  return null;
23884
- gitDir = canonical5(path32.resolve(at, named));
24149
+ gitDir = canonical6(path33.resolve(at, named));
23885
24150
  }
23886
24151
  } catch (error) {
23887
24152
  if (error.code !== "ENOENT")
23888
24153
  return null;
23889
- if (["HEAD", "objects", "refs"].every((name) => fs21.existsSync(path32.join(at, name))))
23890
- gitDir = canonical5(at);
24154
+ if (["HEAD", "objects", "refs"].every((name) => fs22.existsSync(path33.join(at, name))))
24155
+ gitDir = canonical6(at);
23891
24156
  }
23892
24157
  if (gitDir !== null) {
23893
- const common = path32.join(gitDir, "commondir");
23894
- const shared = fs21.existsSync(common) ? canonical5(path32.resolve(gitDir, fs21.readFileSync(common, "utf8").trim())) : gitDir;
24158
+ const common = path33.join(gitDir, "commondir");
24159
+ const shared = fs22.existsSync(common) ? canonical6(path33.resolve(gitDir, fs22.readFileSync(common, "utf8").trim())) : gitDir;
23895
24160
  const dirs = [gitDir, shared];
23896
- for (const config of scan ? new Set([path32.join(gitDir, "config"), path32.join(shared, "config")]) : []) {
24161
+ for (const config of scan ? new Set([path33.join(gitDir, "config"), path33.join(shared, "config")]) : []) {
23897
24162
  let text = "";
23898
24163
  try {
23899
- text = fs21.readFileSync(config, "utf8");
24164
+ text = fs22.readFileSync(config, "utf8");
23900
24165
  } catch {
23901
24166
  continue;
23902
24167
  }
23903
24168
  for (const [key, value] of configEntries(text)) {
23904
24169
  if (key === "core.worktree")
23905
- dirs.push(canonical5(path32.resolve(gitDir, value)));
24170
+ dirs.push(canonical6(path33.resolve(gitDir, value)));
23906
24171
  else if (/^remote\..*\.url$/.test(key) ? !literalIn(value, repo, true) : !SAFE_KEY.test(key))
23907
24172
  return null;
23908
24173
  }
23909
24174
  }
23910
24175
  return dirs;
23911
24176
  }
23912
- if (path32.dirname(at) === at)
24177
+ if (path33.dirname(at) === at)
23913
24178
  return [];
23914
24179
  }
23915
24180
  }
@@ -24049,10 +24314,10 @@ var gitKind = (args, local = () => true) => {
24049
24314
  return GIT_VERBS[verb].startsWith("+") ? "write" : "read";
24050
24315
  };
24051
24316
  var remoteIn = (dir, name, repo) => {
24052
- const shared = path32.isAbsolute(dir) ? gitDirsAt(canonical5(dir), repo, false)?.[1] : undefined;
24317
+ const shared = path33.isAbsolute(dir) ? gitDirsAt(canonical6(dir), repo, false)?.[1] : undefined;
24053
24318
  if (!shared)
24054
24319
  return false;
24055
- const url = configEntries(fs21.readFileSync(path32.join(shared, "config"), "utf8")).find(([key]) => key === `remote.${name}.url`.toLowerCase())?.[1];
24320
+ const url = configEntries(fs22.readFileSync(path33.join(shared, "config"), "utf8")).find(([key]) => key === `remote.${name}.url`.toLowerCase())?.[1];
24056
24321
  return url !== undefined && literalIn(url, repo, true);
24057
24322
  };
24058
24323
  var judgeGit = (command, repo, cwd, depth = 0) => {
@@ -24066,7 +24331,7 @@ var judgeGit = (command, repo, cwd, depth = 0) => {
24066
24331
  const lead = [];
24067
24332
  while (/^\w+\+?=/.test(words[at] ?? ""))
24068
24333
  lead.push(words[at++]);
24069
- const name = path32.basename(words[at] ?? "");
24334
+ const name = path33.basename(words[at] ?? "");
24070
24335
  let start = words.findIndex((word) => /(?:^|[\\/])git(?:\.exe)?(?:=|$)/.test(word));
24071
24336
  if (start > at) {
24072
24337
  if (/^(?:grep|egrep|rg|echo|printf|ls|wc|head|tail|cat|which|type|test|\[|cd|mkdir)$/.test(name) || name === "command" && /^-[vV]$/.test(words[at + 1] ?? ""))
@@ -24077,7 +24342,7 @@ var judgeGit = (command, repo, cwd, depth = 0) => {
24077
24342
  if (start >= 0 && words[start].includes("="))
24078
24343
  why = "git is redefined";
24079
24344
  const run = words[start] ?? "";
24080
- if (run.includes("/") && (!path32.isAbsolute(run) || literalIn(run, repo, true)))
24345
+ if (run.includes("/") && (!path33.isAbsolute(run) || literalIn(run, repo, true)))
24081
24346
  why ??= `\`${run}\` is not the system git`;
24082
24347
  if (segment.expands?.includes(at) && name !== "[" || /\{[^}]*,/.test(words[at] ?? ""))
24083
24348
  why = "the command's name is expanded by the shell";
@@ -24102,13 +24367,13 @@ var judgeGit = (command, repo, cwd, depth = 0) => {
24102
24367
  const args = words[index] === "--version" ? ["version"] : words.slice(index);
24103
24368
  if (!why && start >= 0) {
24104
24369
  const local = (source, remote) => remote && /^[\w-][\w.-]*$/.test(source) ? remoteIn(dir, source, repo) : literalIn(source, repo, true);
24105
- const runsIn = path32.isAbsolute(dir) ? dir : cwd && path32.resolve(cwd, dir);
24370
+ const runsIn = path33.isAbsolute(dir) ? dir : cwd && path33.resolve(cwd, dir);
24106
24371
  const home = runsIn && checkoutOf2(runsIn);
24107
24372
  const fetches = args[0] === "fetch" && plainFetch(args.slice(1)) && home && (home.workit || commonDir(home.root) === repo) && !words.some((word) => /^--[gw]/.test(word));
24108
24373
  if (!fetches && !gitKind(args, local))
24109
24374
  why = `\`git ${args.slice(0, 2).join(" ")}\` is not allowed`;
24110
24375
  }
24111
- const shell = /^(?:grep|egrep|rg|echo|printf|cat)$/.test(name) ? -1 : words.findIndex((word) => /^(?:sh|bash|zsh|dash|ksh|mksh|ash)$/.test(path32.basename(word)));
24376
+ const shell = /^(?:grep|egrep|rg|echo|printf|cat)$/.test(name) ? -1 : words.findIndex((word) => /^(?:sh|bash|zsh|dash|ksh|mksh|ash)$/.test(path33.basename(word)));
24112
24377
  const scripts = [
24113
24378
  ...words.filter((_, after) => shell >= 0 && after > shell && /^-[a-zA-Z]*c[a-zA-Z]*$/.test(words[after - 1])),
24114
24379
  ...shell < 0 ? [] : segment.stdin ?? []
@@ -24153,7 +24418,7 @@ var judgeVerbRefused = (args) => {
24153
24418
  var CLI_RUNNERS = /^(?:npx|bunx|pnpx|npm|pnpm|yarn|bun|node|nodejs|deno|tsx|ts-node)$/;
24154
24419
  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?$/;
24155
24420
  var workitCalls = (command, depth = 0, aliases = new Map) => depth > 4 ? [] : commandLines(command).flatMap((words) => {
24156
- const name = path32.basename(words[0] ?? "").toLowerCase();
24421
+ const name = path33.basename(words[0] ?? "").toLowerCase();
24157
24422
  if (name === "alias")
24158
24423
  return words.flatMap((word) => {
24159
24424
  const set = /^([\w-]+)=(.*)$/s.exec(word);
@@ -24182,11 +24447,11 @@ var judgeRefusal = (command, fed, depth = 0) => {
24182
24447
  return why;
24183
24448
  }
24184
24449
  const { words } = segment;
24185
- const runs = (word = "") => RUNS.test(path32.basename(word).toLowerCase());
24450
+ const runs = (word = "") => RUNS.test(path33.basename(word).toLowerCase());
24186
24451
  let at = 0;
24187
24452
  while (at < words.length && (LEADS.test(words[at]) || /^-\w$/.test(words[at - 1] ?? "") && !runs(words[at])))
24188
24453
  at++;
24189
- const name = path32.basename(words[at] ?? "").toLowerCase();
24454
+ const name = path33.basename(words[at] ?? "").toLowerCase();
24190
24455
  const args = words.slice(at + 1);
24191
24456
  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`;
24192
24457
  if (/^(?:cd|chdir|pushd|popd)$/.test(name))
@@ -24268,9 +24533,9 @@ var judgeDeny = (input, what, target, retry) => {
24268
24533
  const role = input.session.agentType?.endsWith("reviewer") ? "reviewer" : "verifier";
24269
24534
  const root = checkoutOf2(input.cwd)?.root;
24270
24535
  const candidate = target ? checkoutOf2(target)?.root : undefined;
24271
- const other = root && candidate && candidate !== root && commonDir(candidate) === commonDir(root) ? path32.join(candidate, SCRATCH) : undefined;
24272
- const scratch = root ? `${path32.join(root, SCRATCH)}${other ? ` or ${other}` : ""}` : `${SCRATCH}/ at the root of the checkout you judge`;
24273
- const call = root ? retry?.((other ?? path32.join(root, SCRATCH)).replaceAll("\\", "/")) : null;
24536
+ const other = root && candidate && candidate !== root && commonDir(candidate) === commonDir(root) ? path33.join(candidate, SCRATCH) : undefined;
24537
+ const scratch = root ? `${path33.join(root, SCRATCH)}${other ? ` or ${other}` : ""}` : `${SCRATCH}/ at the root of the checkout you judge`;
24538
+ const call = root ? retry?.((other ?? path33.join(root, SCRATCH)).replaceAll("\\", "/")) : null;
24274
24539
  const unblock = call ? `Retry as: ${call}` : "Why: write only there (mkdir -p it); a fix the candidate needs is a finding (`workit finding record`).";
24275
24540
  return {
24276
24541
  kind: "deny",
@@ -24281,9 +24546,9 @@ ${unblock}`,
24281
24546
  };
24282
24547
  var movedInto = (command, cwd, target, dir) => {
24283
24548
  for (const { words, redirects } of segmentsOf(command))
24284
- for (const word of [...redirects, ...path32.basename(words[0] ?? "") === "tee" ? words : []])
24285
- if (path32.resolve(cwd, word) === path32.resolve(cwd, target)) {
24286
- const moved = command.replace(new RegExp(`((?:>>?\\|?|\\btee(?:\\s+-a)?)\\s*)(['"]?)${word.replace(/[$()*+.?[\\\]^{|}]/g, "\\$&")}\\2(?![^\\s;&|)])`), (_, lead) => `${lead}${dir}/${path32.basename(word)}`);
24549
+ for (const word of [...redirects, ...path33.basename(words[0] ?? "") === "tee" ? words : []])
24550
+ if (path33.resolve(cwd, word) === path33.resolve(cwd, target)) {
24551
+ const moved = command.replace(new RegExp(`((?:>>?\\|?|\\btee(?:\\s+-a)?)\\s*)(['"]?)${word.replace(/[$()*+.?[\\\]^{|}]/g, "\\$&")}\\2(?![^\\s;&|)])`), (_, lead) => `${lead}${dir}/${path33.basename(word)}`);
24287
24552
  return moved === command ? null : moved;
24288
24553
  }
24289
24554
  return null;
@@ -24294,20 +24559,20 @@ function confineJudge(input, targets, placeholders = placeholdersOf(targets), co
24294
24559
  return NONE5;
24295
24560
  const judged = checkoutOf2(input.cwd);
24296
24561
  const repo = judged ? commonDir(judged.root) : null;
24297
- const scratch = (real) => inScratch(real, repo) || [os9.tmpdir(), "/tmp"].some((dir) => {
24298
- const [host, , session] = path32.relative(canonical5(dir), real).split(path32.sep);
24562
+ const scratch = (real) => inScratch(real, repo) || [os10.tmpdir(), "/tmp"].some((dir) => {
24563
+ const [host, , session] = path33.relative(canonical6(dir), real).split(path33.sep);
24299
24564
  return /^claude-\d+$/.test(host) && session === input.session.id;
24300
24565
  });
24301
24566
  for (const target of targets) {
24302
- const resolved = path32.resolve(target);
24567
+ const resolved = path33.resolve(target);
24303
24568
  if (within(resolved, UNKNOWN_VAR) || within(resolved, UNKNOWN_DIR))
24304
24569
  return judgeDeny(input, "it writes to a path Workit cannot resolve", undefined, () => {
24305
24570
  const literal = command && literalForm(command, refsOf([target]));
24306
24571
  return literal === command ? null : literal;
24307
24572
  });
24308
- const real = canonical5(target);
24309
- const runsGit = placeholders.has(target) && /^\.workit-(?:runs-git|live-target)$/.test(path32.basename(target));
24310
- const gitDirs = runsGit ? gitDirsAt(path32.dirname(real), repo) : [];
24573
+ const real = canonical6(target);
24574
+ const runsGit = placeholders.has(target) && /^\.workit-(?:runs-git|live-target)$/.test(path33.basename(target));
24575
+ const gitDirs = runsGit ? gitDirsAt(path33.dirname(real), repo) : [];
24311
24576
  if (gitDirs === null)
24312
24577
  return judgeDeny(input, `git in ${shown(target)} uses a git dir or config Workit cannot check`);
24313
24578
  if (runsGit ? gitDirs.length > 0 ? gitDirs.every(scratch) : scratch(real) : scratch(real) && !inGitDir(real))
@@ -24373,7 +24638,7 @@ function confineJudgeShell(input, command, dialect = "posix") {
24373
24638
  let git = [];
24374
24639
  try {
24375
24640
  git = rawInvocations(command, dialect).flatMap(({ tool, dir, args }) => tool === "git" && (args[0] === "push" || leadOwnedGit(args) || gitKind(args) === "write" && !/^(?:init|clone)$/.test(args[0]) && !(args[0] === "fetch" && plainFetch(args.slice(1)))) ? [
24376
- path32.join(dir === undefined ? UNKNOWN_DIR : path32.resolve(input.cwd, dir ?? "."), `${OPAQUE_TARGET}git`)
24641
+ path33.join(dir === undefined ? UNKNOWN_DIR : path33.resolve(input.cwd, dir ?? "."), `${OPAQUE_TARGET}git`)
24377
24642
  ] : []);
24378
24643
  } catch {}
24379
24644
  const lists = [
@@ -24418,17 +24683,17 @@ var judgeChecksLine = (cwd) => {
24418
24683
 
24419
24684
  // packages/workit-core/src/hooks/standing.ts
24420
24685
  var readPlans = (store) => {
24421
- const dir = path33.join(store, "fanouts");
24686
+ const dir = path34.join(store, "fanouts");
24422
24687
  let names;
24423
24688
  try {
24424
- names = fs22.readdirSync(dir).filter((name) => name.endsWith(".json"));
24689
+ names = fs23.readdirSync(dir).filter((name) => name.endsWith(".json"));
24425
24690
  } catch {
24426
24691
  return [];
24427
24692
  }
24428
24693
  const plans = [];
24429
24694
  for (const name of names) {
24430
24695
  try {
24431
- const raw = JSON.parse(fs22.readFileSync(path33.join(dir, name), "utf8"));
24696
+ const raw = JSON.parse(fs23.readFileSync(path34.join(dir, name), "utf8"));
24432
24697
  if (typeof raw.name !== "string" || !Array.isArray(raw.slices))
24433
24698
  continue;
24434
24699
  const texts = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string" && item !== "") : [];
@@ -24637,13 +24902,13 @@ var cdWorkitSplit = (command) => {
24637
24902
  };
24638
24903
 
24639
24904
  // packages/workit-core/src/hooks/spawn-gate.ts
24640
- import fs23 from "node:fs";
24641
- import path35 from "node:path";
24905
+ import fs24 from "node:fs";
24906
+ import path36 from "node:path";
24642
24907
 
24643
24908
  // packages/workit-core/src/hooks/model-limit.ts
24644
24909
  import { closeSync as closeSync3, openSync as openSync3, readdirSync as readdirSync4, readSync, statSync as statSync5 } from "node:fs";
24645
- import os10 from "node:os";
24646
- import path34 from "node:path";
24910
+ import os11 from "node:os";
24911
+ import path35 from "node:path";
24647
24912
  var MONTHS = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
24648
24913
  var WEEKDAYS = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"];
24649
24914
  var TIME_WORD = String.raw`(?:\d|(?:in|at|on|later|tomorrow|soon)\b|(?:${[...WEEKDAYS, ...MONTHS].join("|")})[a-z]*\b)`;
@@ -24841,17 +25106,17 @@ var firstPrompt = (file) => {
24841
25106
  var claudeProjectSlug = (cwd) => cwd.replace(/[^A-Za-z0-9]/gu, "-");
24842
25107
  var listDir = (dir) => {
24843
25108
  try {
24844
- return readdirSync4(dir).map((name) => path34.join(dir, name));
25109
+ return readdirSync4(dir).map((name) => path35.join(dir, name));
24845
25110
  } catch {
24846
25111
  return [];
24847
25112
  }
24848
25113
  };
24849
25114
  var SCAN_MS = 30 * 60000;
24850
25115
  var scanClaudeTranscripts = (cwd, env, now = new Date) => {
24851
- const projects = path34.join(env.CLAUDE_CONFIG_DIR || path34.join(env.HOME || os10.homedir(), ".claude"), "projects");
24852
- const project = path34.join(projects, claudeProjectSlug(cwd));
25116
+ const projects = path35.join(env.CLAUDE_CONFIG_DIR || path35.join(env.HOME || os11.homedir(), ".claude"), "projects");
25117
+ const project = path35.join(projects, claudeProjectSlug(cwd));
24853
25118
  const notes = [];
24854
- const files = listDir(project).flatMap((entry) => entry.endsWith(".jsonl") ? [{ file: entry, worker: false }] : listDir(path34.join(entry, "subagents")).filter((file) => file.endsWith(".jsonl")).map((file) => ({ file, worker: true })));
25119
+ const files = listDir(project).flatMap((entry) => entry.endsWith(".jsonl") ? [{ file: entry, worker: false }] : listDir(path35.join(entry, "subagents")).filter((file) => file.endsWith(".jsonl")).map((file) => ({ file, worker: true })));
24855
25120
  for (const { file, worker } of files)
24856
25121
  try {
24857
25122
  const stat = statSync5(file);
@@ -24866,7 +25131,7 @@ var scanClaudeTranscripts = (cwd, env, now = new Date) => {
24866
25131
  if (!seen)
24867
25132
  continue;
24868
25133
  notes.push(worker ? redispatchNote(seen, {
24869
- label: `worker ${path34.basename(file, ".jsonl")}`,
25134
+ label: `worker ${path35.basename(file, ".jsonl")}`,
24870
25135
  prompt: firstPrompt(file)
24871
25136
  }, 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.`);
24872
25137
  } catch {}
@@ -24965,13 +25230,13 @@ var agentModelDecision = (cwd, tool, options = {}) => {
24965
25230
  var MADE_WORKTREE = /^WORKTREE:[ \t]*(?!not made yet)\S(?![^\n]*not made yet)/mu;
24966
25231
  var namesMade = (word) => {
24967
25232
  try {
24968
- const stat = fs23.statSync(word);
25233
+ const stat = fs24.statSync(word);
24969
25234
  if (stat.isFile())
24970
- return stat.size < 1e6 && MADE_WORKTREE.test(fs23.readFileSync(word, "utf8"));
24971
- const dotGit = path35.join(word, ".git");
24972
- const link = fs23.statSync(dotGit);
24973
- const admin = link.isFile() && link.size <= 4096 && /^gitdir: *(.+)/u.exec(fs23.readFileSync(dotGit, "utf8"));
24974
- return !!admin && fs23.existsSync(path35.resolve(word, admin[1].trim(), FANOUT_TOKEN_FILE));
25235
+ return stat.size < 1e6 && MADE_WORKTREE.test(fs24.readFileSync(word, "utf8"));
25236
+ const dotGit = path36.join(word, ".git");
25237
+ const link = fs24.statSync(dotGit);
25238
+ const admin = link.isFile() && link.size <= 4096 && /^gitdir: *(.+)/u.exec(fs24.readFileSync(dotGit, "utf8"));
25239
+ return !!admin && fs24.existsSync(path36.resolve(word, admin[1].trim(), FANOUT_TOKEN_FILE));
24975
25240
  } catch {
24976
25241
  return false;
24977
25242
  }
@@ -25017,8 +25282,8 @@ var spawnDecision = (descriptor, cwd, tool, permissionMode = null) => {
25017
25282
 
25018
25283
  // packages/workit-core/src/hooks/teardown.ts
25019
25284
  import { spawn } from "node:child_process";
25020
- import fs24 from "node:fs";
25021
- import path36 from "node:path";
25285
+ import fs25 from "node:fs";
25286
+ import path37 from "node:path";
25022
25287
  var REAP_INTERVAL_MS = 10 * 60000;
25023
25288
  var LOG_MAX_BYTES = 1 << 20;
25024
25289
  var ENDS = {
@@ -25029,9 +25294,9 @@ var ENDS = {
25029
25294
  };
25030
25295
  var SAFE_SESSION = /^[\w.@+][\w.:@/+-]{0,127}$/u;
25031
25296
  var HOST_SESSION_VARS = ["OPENCODE_SESSION_ID", "PI_SESSION_ID", "CODEX_THREAD_ID"];
25032
- var teardownDir = (env) => path36.join(stateDir3(env), "procs");
25033
- var teardownLog = (env) => path36.join(teardownDir(env), "teardown.log");
25034
- var reapStamp = (env) => path36.join(teardownDir(env), "reap-at-start.stamp");
25297
+ var teardownDir = (env) => path37.join(stateDir3(env), "procs");
25298
+ var teardownLog = (env) => path37.join(teardownDir(env), "teardown.log");
25299
+ var reapStamp = (env) => path37.join(teardownDir(env), "reap-at-start.stamp");
25035
25300
  function spawnDetached(request) {
25036
25301
  try {
25037
25302
  const shell = process.platform === "win32" && !/\.exe$/iu.test(request.command);
@@ -25058,13 +25323,13 @@ var teardownDeps = {
25058
25323
  var openLog = (env, args) => {
25059
25324
  try {
25060
25325
  const file = teardownLog(env);
25061
- fs24.mkdirSync(path36.dirname(file), { recursive: true });
25326
+ fs25.mkdirSync(path37.dirname(file), { recursive: true });
25062
25327
  let size = 0;
25063
25328
  try {
25064
- size = fs24.statSync(file).size;
25329
+ size = fs25.statSync(file).size;
25065
25330
  } catch {}
25066
- const fd = fs24.openSync(file, size > LOG_MAX_BYTES ? "w" : "a", 384);
25067
- fs24.writeSync(fd, `${new Date(teardownDeps.now()).toISOString()} workit ${args.join(" ")}
25331
+ const fd = fs25.openSync(file, size > LOG_MAX_BYTES ? "w" : "a", 384);
25332
+ fs25.writeSync(fd, `${new Date(teardownDeps.now()).toISOString()} workit ${args.join(" ")}
25068
25333
  `);
25069
25334
  return fd;
25070
25335
  } catch {
@@ -25076,7 +25341,7 @@ function runCli(args, env) {
25076
25341
  try {
25077
25342
  const cli = locateWorkitCli2({ env });
25078
25343
  const cwd = teardownDir(env);
25079
- fs24.mkdirSync(cwd, { recursive: true });
25344
+ fs25.mkdirSync(cwd, { recursive: true });
25080
25345
  log = openLog(env, args);
25081
25346
  const started = teardownDeps.spawn({
25082
25347
  command: cli.command,
@@ -25086,7 +25351,7 @@ function runCli(args, env) {
25086
25351
  log
25087
25352
  });
25088
25353
  if (!started && log !== null)
25089
- fs24.writeSync(log, ` not started
25354
+ fs25.writeSync(log, ` not started
25090
25355
  `);
25091
25356
  return started;
25092
25357
  } catch {
@@ -25094,7 +25359,7 @@ function runCli(args, env) {
25094
25359
  } finally {
25095
25360
  if (log !== null)
25096
25361
  try {
25097
- fs24.closeSync(log);
25362
+ fs25.closeSync(log);
25098
25363
  } catch {}
25099
25364
  }
25100
25365
  }
@@ -25113,24 +25378,24 @@ function endSession(end, env = process.env) {
25113
25378
  var claim2 = (file, now) => {
25114
25379
  for (let attempt = 0;attempt < 2; attempt += 1)
25115
25380
  try {
25116
- fs24.writeFileSync(file, String(now), { flag: "wx", mode: 384 });
25381
+ fs25.writeFileSync(file, String(now), { flag: "wx", mode: 384 });
25117
25382
  return true;
25118
25383
  } catch (error) {
25119
25384
  if (error.code !== "EEXIST")
25120
25385
  return false;
25121
25386
  let held = Number.NaN;
25122
25387
  try {
25123
- held = Number(fs24.readFileSync(file, "utf8"));
25388
+ held = Number(fs25.readFileSync(file, "utf8"));
25124
25389
  } catch {}
25125
25390
  if (now - held < REAP_INTERVAL_MS)
25126
25391
  return false;
25127
- fs24.rmSync(file, { force: true });
25392
+ fs25.rmSync(file, { force: true });
25128
25393
  }
25129
25394
  return false;
25130
25395
  };
25131
25396
  var fresh = (stamp, now) => {
25132
25397
  try {
25133
- const last = Number(fs24.readFileSync(stamp, "utf8"));
25398
+ const last = Number(fs25.readFileSync(stamp, "utf8"));
25134
25399
  return now - last < REAP_INTERVAL_MS && last <= now;
25135
25400
  } catch {
25136
25401
  return false;
@@ -25143,7 +25408,7 @@ function reapAtStart(_cwd, env = process.env) {
25143
25408
  try {
25144
25409
  if (fresh(stamp, now))
25145
25410
  return false;
25146
- fs24.mkdirSync(path36.dirname(stamp), { recursive: true });
25411
+ fs25.mkdirSync(path37.dirname(stamp), { recursive: true });
25147
25412
  if (!claim2(lock, now))
25148
25413
  return false;
25149
25414
  } catch {
@@ -25156,12 +25421,12 @@ function reapAtStart(_cwd, env = process.env) {
25156
25421
  started = runCli(["stop", "--orphans", "--reason", "session-start"], env);
25157
25422
  if (started) {
25158
25423
  const temp = `${stamp}.${process.pid}`;
25159
- fs24.writeFileSync(temp, String(now), { mode: 384 });
25160
- fs24.renameSync(temp, stamp);
25424
+ fs25.writeFileSync(temp, String(now), { mode: 384 });
25425
+ fs25.renameSync(temp, stamp);
25161
25426
  }
25162
25427
  } catch {} finally {
25163
25428
  try {
25164
- fs24.rmSync(lock, { force: true });
25429
+ fs25.rmSync(lock, { force: true });
25165
25430
  } catch {}
25166
25431
  }
25167
25432
  return started;
@@ -26163,7 +26428,7 @@ var dispatchHook = (adapter, raw, env = process.env) => {
26163
26428
  };
26164
26429
  // packages/workit-core/src/hooks/deadline.ts
26165
26430
  import { appendFileSync, mkdirSync as mkdirSync4 } from "node:fs";
26166
- import path37 from "node:path";
26431
+ import path38 from "node:path";
26167
26432
  var HOOK_SKIP_TEXT = "workit context skipped: host under load";
26168
26433
  var HOOK_DEADLINE_MS = 8000;
26169
26434
  var HOST_DEADLINES = {
@@ -26181,7 +26446,7 @@ var hookDeadlineMs = (env, host = "", native) => {
26181
26446
  const row = HOST_DEADLINES[host];
26182
26447
  return override(env) ?? (row ? native === undefined ? Math.min(...Object.values(row)) : row[native] ?? row[""] : HOOK_DEADLINE_MS);
26183
26448
  };
26184
- var skipsFile = (stateDir) => path37.join(stateDir, HOOK_SKIPS_FILE);
26449
+ var skipsFile = (stateDir) => path38.join(stateDir, HOOK_SKIPS_FILE);
26185
26450
  var recordHookSkip = (skip, stateDir = resolveStateDir()) => {
26186
26451
  try {
26187
26452
  mkdirSync4(stateDir, { recursive: true });