@workit-dev/mcp 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.
Files changed (2) hide show
  1. package/dist/index.js +829 -553
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -6620,11 +6620,11 @@ var require_dist = __commonJS(function(exports, module) {
6620
6620
 
6621
6621
  // packages/workit-mcp/src/index.ts
6622
6622
  import { fileURLToPath as fileURLToPath3 } from "node:url";
6623
- import path31 from "node:path";
6623
+ import path32 from "node:path";
6624
6624
 
6625
6625
  // packages/workit-mcp/src/server.ts
6626
- import { existsSync as existsSync14, readFileSync as readFileSync11, realpathSync as realpathSync10 } from "node:fs";
6627
- import path30 from "node:path";
6626
+ import { existsSync as existsSync15, readFileSync as readFileSync11, realpathSync as realpathSync11 } from "node:fs";
6627
+ import path31 from "node:path";
6628
6628
 
6629
6629
  // node_modules/zod/v4/core/util.js
6630
6630
  function getEnumValues(entries) {
@@ -14973,8 +14973,8 @@ import { fileURLToPath as fileURLToPath2 } from "node:url";
14973
14973
 
14974
14974
  // packages/workit-core/src/core.ts
14975
14975
  import { spawnSync as spawnSync20 } from "node:child_process";
14976
- import { existsSync as existsSync13, realpathSync as realpathSync9 } from "node:fs";
14977
- import path29 from "node:path";
14976
+ import { existsSync as existsSync14, realpathSync as realpathSync10 } from "node:fs";
14977
+ import path30 from "node:path";
14978
14978
 
14979
14979
  // packages/workit-core/src/core/task-contract.ts
14980
14980
  import { createHash, randomUUID } from "node:crypto";
@@ -16409,23 +16409,25 @@ function explainInvalidOperation(family, request) {
16409
16409
  return parsed.success ? null : invalidOperation(family, request, parsed.error);
16410
16410
  }
16411
16411
  // packages/workit-core/src/core/task-store.ts
16412
- import { createHash as createHash8 } from "node:crypto";
16413
- import * as fs13 from "node:fs";
16414
- import path16 from "node:path";
16412
+ import { createHash as createHash9 } from "node:crypto";
16413
+ import * as fs14 from "node:fs";
16414
+ import path17 from "node:path";
16415
16415
 
16416
16416
  // packages/workit-core/src/host-session.ts
16417
- import { createHash as createHash6, randomBytes, timingSafeEqual } from "node:crypto";
16418
- import fs6 from "node:fs";
16419
- import path10 from "node:path";
16417
+ import { createHash as createHash7, randomBytes, timingSafeEqual } from "node:crypto";
16418
+ import fs7 from "node:fs";
16419
+ import path11 from "node:path";
16420
16420
 
16421
16421
  // packages/workit-core/src/core/branch-policy.ts
16422
16422
  import { spawnSync } from "node:child_process";
16423
16423
 
16424
16424
  // packages/workit-core/src/core/config.ts
16425
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
16425
+ import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync, writeFileSync as writeFileSync2 } from "node:fs";
16426
16426
  import path2 from "node:path";
16427
16427
 
16428
16428
  // packages/workit-core/src/core/workit-paths.mjs
16429
+ import { createHash as createHash2 } from "node:crypto";
16430
+ import { existsSync, lstatSync, mkdirSync, realpathSync, renameSync, writeFileSync } from "node:fs";
16429
16431
  import os from "node:os";
16430
16432
  import path from "node:path";
16431
16433
  var WORKIT_DIR_OVERRIDES = {
@@ -16476,6 +16478,17 @@ var workitDir = (kind, env = process.env, platform = process.platform) => {
16476
16478
  };
16477
16479
  var configDir = (env, platform) => workitDir("config", env, platform);
16478
16480
  var stateDir = (env, platform) => workitDir("state", env, platform);
16481
+ var folderSlug = (dir, platform = process.platform) => {
16482
+ let canonical = dir;
16483
+ try {
16484
+ canonical = realpathSync.native(dir);
16485
+ } catch {}
16486
+ if (platform === "win32")
16487
+ canonical = canonical.toLowerCase();
16488
+ const base = path.basename(canonical).replace(/[^A-Za-z0-9._-]/g, "_").slice(0, 40) || "root";
16489
+ return `${base}-${createHash2("sha256").update(canonical).digest("hex").slice(0, 12)}`;
16490
+ };
16491
+ var folderStoreDir = (dir, env, platform) => path.join(stateDir(env, platform), "folders", folderSlug(dir, platform));
16479
16492
 
16480
16493
  // packages/workit-core/src/core/config.ts
16481
16494
  var UPDATES_MODES = ["prompt", "auto", "off"];
@@ -16737,18 +16750,18 @@ var gitContext = (workspaceRoot, paths = []) => {
16737
16750
 
16738
16751
  // packages/workit-core/src/core/workspaces.ts
16739
16752
  import { spawnSync as spawnSync6 } from "node:child_process";
16740
- import { createHash as createHash3 } from "node:crypto";
16741
- import { existsSync as existsSync3, lstatSync as lstatSync2, readFileSync as readFileSync4, realpathSync as realpathSync3 } from "node:fs";
16753
+ import { createHash as createHash4 } from "node:crypto";
16754
+ import { existsSync as existsSync4, lstatSync as lstatSync3, readFileSync as readFileSync4, realpathSync as realpathSync4 } from "node:fs";
16742
16755
  import path7 from "node:path";
16743
16756
 
16744
16757
  // packages/workit-core/src/core/remotes.ts
16745
- import { lstatSync, readFileSync as readFileSync3, realpathSync as realpathSync2, statSync } from "node:fs";
16758
+ import { lstatSync as lstatSync2, readFileSync as readFileSync3, realpathSync as realpathSync3, statSync } from "node:fs";
16746
16759
  import { spawnSync as spawnSync5 } from "node:child_process";
16747
16760
  import path6 from "node:path";
16748
16761
 
16749
16762
  // packages/workit-core/src/git/rev.ts
16750
16763
  import { spawnSync as spawnSync3 } from "node:child_process";
16751
- import { createHash as createHash2 } from "node:crypto";
16764
+ import { createHash as createHash3 } from "node:crypto";
16752
16765
  import fs3 from "node:fs";
16753
16766
  import os2 from "node:os";
16754
16767
  import path5 from "node:path";
@@ -17204,7 +17217,7 @@ function worktreeTree(cwd, options = {}) {
17204
17217
  if (!tree)
17205
17218
  return null;
17206
17219
  const base = line(git(top, ["rev-parse", "--verify", "-q", "HEAD^{tree}"])) ?? emptyTree(top);
17207
- const key = skipped.length ? `sha256:${createHash2("sha256").update(JSON.stringify({ tree, skipped })).digest("hex")}` : tree;
17220
+ const key = skipped.length ? `sha256:${createHash3("sha256").update(JSON.stringify({ tree, skipped })).digest("hex")}` : tree;
17208
17221
  return { tree, key, dirty: tree !== base || skipped.length > 0, skipped };
17209
17222
  } finally {
17210
17223
  fs3.rmSync(scratch, { recursive: true, force: true });
@@ -17227,7 +17240,7 @@ function worktreeSignal(cwd, options = {}) {
17227
17240
  });
17228
17241
  if (!status.ok)
17229
17242
  return null;
17230
- const hash = createHash2("sha256");
17243
+ const hash = createHash3("sha256");
17231
17244
  hash.update(`${headSha(top) ?? "unborn"}\x00`);
17232
17245
  for (const entry of status.stdout.split("\x00")) {
17233
17246
  if (entry.length < 4)
@@ -17568,7 +17581,7 @@ function resolveSshHost(alias, sshConfig) {
17568
17581
 
17569
17582
  // packages/workit-core/src/core/account-home.ts
17570
17583
  import { spawnSync as spawnSync4 } from "node:child_process";
17571
- import { existsSync as existsSync2, readFileSync as readFileSync2, readlinkSync, realpathSync } from "node:fs";
17584
+ import { existsSync as existsSync3, readFileSync as readFileSync2, readlinkSync, realpathSync as realpathSync2 } from "node:fs";
17572
17585
  import os3 from "node:os";
17573
17586
  var WINDOWS = "C:\\Windows";
17574
17587
  var SYSTEM32 = `${WINDOWS}\\System32\\`;
@@ -17660,7 +17673,7 @@ var canonical2 = (real) => {
17660
17673
  };
17661
17674
  var isRepoDir = (dir) => ["HEAD", "objects", "refs"].every((name) => {
17662
17675
  try {
17663
- lstatSync(`${dir}/${name}`);
17676
+ lstatSync2(`${dir}/${name}`);
17664
17677
  return true;
17665
17678
  } catch {
17666
17679
  return false;
@@ -17669,7 +17682,7 @@ var isRepoDir = (dir) => ["HEAD", "objects", "refs"].every((name) => {
17669
17682
  var gitDirAt = (at, depth = 0) => {
17670
17683
  let real;
17671
17684
  try {
17672
- real = realpathSync2.native(at);
17685
+ real = realpathSync3.native(at);
17673
17686
  } catch {
17674
17687
  return null;
17675
17688
  }
@@ -17688,7 +17701,7 @@ var gitDirAt = (at, depth = 0) => {
17688
17701
  common = readFileSync3(`${real}/commondir`, "utf8").trim();
17689
17702
  } catch {}
17690
17703
  if (common !== undefined) {
17691
- lstatSync(`${real}/HEAD`);
17704
+ lstatSync2(`${real}/HEAD`);
17692
17705
  return gitDirAt(path6.isAbsolute(common) ? common : `${real}/${common}`, depth + 1);
17693
17706
  }
17694
17707
  if (!isRepoDir(real))
@@ -17697,11 +17710,11 @@ var gitDirAt = (at, depth = 0) => {
17697
17710
  for (const name of ["refs", "objects", "config", "packed-refs"]) {
17698
17711
  const item = `${real}/${name}`;
17699
17712
  try {
17700
- lstatSync(item);
17713
+ lstatSync2(item);
17701
17714
  } catch {
17702
17715
  continue;
17703
17716
  }
17704
- const resolved = realpathSync2.native(item);
17717
+ const resolved = realpathSync3.native(item);
17705
17718
  const rel = path6.relative(real, resolved);
17706
17719
  if (rel && !rel.startsWith("..") && !path6.isAbsolute(rel))
17707
17720
  continue;
@@ -17986,7 +17999,7 @@ var workspacesFileSchema = object({
17986
17999
  names.add(workspace.name);
17987
18000
  }
17988
18001
  });
17989
- var workspacesRevision = (contents) => createHash3("sha256").update(contents ?? "<missing>").digest("hex");
18002
+ var workspacesRevision = (contents) => createHash4("sha256").update(contents ?? "<missing>").digest("hex");
17990
18003
  var validateWorkspacesDocument = (parsed, file) => {
17991
18004
  if (!isConfigObject(parsed)) {
17992
18005
  return {
@@ -18137,8 +18150,8 @@ var probeCheckout = (cwd) => {
18137
18150
  if (cached !== undefined)
18138
18151
  return cached;
18139
18152
  let dir = path7.resolve(cwd);
18140
- while (!existsSync3(path7.join(dir, ".git"))) {
18141
- if (["HEAD", "objects", "refs"].every((name) => existsSync3(path7.join(dir, name)))) {
18153
+ while (!existsSync4(path7.join(dir, ".git"))) {
18154
+ if (["HEAD", "objects", "refs"].every((name) => existsSync4(path7.join(dir, name)))) {
18142
18155
  const real = realpathOf(dir);
18143
18156
  const owner = ownInternals(real) === true ? gitDirOwner(real) : null;
18144
18157
  if (owner === null)
@@ -18205,7 +18218,7 @@ var probeCheckout = (cwd) => {
18205
18218
  };
18206
18219
  var ownGitDir = (dotGit, real) => {
18207
18220
  try {
18208
- return lstatSync2(dotGit).isDirectory() && realpathOf(dotGit) === real;
18221
+ return lstatSync3(dotGit).isDirectory() && realpathOf(dotGit) === real;
18209
18222
  } catch {
18210
18223
  return false;
18211
18224
  }
@@ -18216,13 +18229,13 @@ var ownInternals = (real) => {
18216
18229
  for (const name of INTERNALS) {
18217
18230
  const at = path7.join(real, name);
18218
18231
  try {
18219
- lstatSync2(at);
18232
+ lstatSync3(at);
18220
18233
  } catch {
18221
18234
  continue;
18222
18235
  }
18223
18236
  let resolved;
18224
18237
  try {
18225
- resolved = (realpathSync3.native ?? realpathSync3)(at);
18238
+ resolved = (realpathSync4.native ?? realpathSync4)(at);
18226
18239
  } catch {
18227
18240
  return false;
18228
18241
  }
@@ -18280,7 +18293,7 @@ var matchingEntries = (cwd, entries) => {
18280
18293
  return main ? match(main) : direct;
18281
18294
  };
18282
18295
  var realpathOf = (p) => {
18283
- const real = realpathSync3.native ?? realpathSync3;
18296
+ const real = realpathSync4.native ?? realpathSync4;
18284
18297
  try {
18285
18298
  return real(p);
18286
18299
  } catch {
@@ -18445,7 +18458,7 @@ import path8 from "node:path";
18445
18458
  import { spawnSync as spawnSync8 } from "node:child_process";
18446
18459
 
18447
18460
  // packages/workit-core/src/core/release-tracks.ts
18448
- import { createHash as createHash4 } from "node:crypto";
18461
+ import { createHash as createHash5 } from "node:crypto";
18449
18462
  import { spawnSync as spawnSync7 } from "node:child_process";
18450
18463
  var KNOWN_FIELDS = new Set([
18451
18464
  "strategy",
@@ -18815,7 +18828,7 @@ function resolveTrackFor(cwd, options) {
18815
18828
  ]) ?? "",
18816
18829
  git2(cwd, ["config", "--get", recordedBaseKey(branch)]) ?? ""
18817
18830
  ] : [];
18818
- key = createHash4("sha256").update(JSON.stringify({ cwd, input, refs, head, own })).digest("hex");
18831
+ key = createHash5("sha256").update(JSON.stringify({ cwd, input, refs, head, own })).digest("hex");
18819
18832
  const hit = memo2.get(key);
18820
18833
  if (hit)
18821
18834
  return hit;
@@ -19209,9 +19222,289 @@ var redactSecrets = (value) => applyPatterns(value);
19209
19222
 
19210
19223
  // packages/workit-core/src/store/paths.ts
19211
19224
  import { spawnSync as spawnSync9 } from "node:child_process";
19212
- import { createHash as createHash5 } from "node:crypto";
19225
+ import { createHash as createHash6 } from "node:crypto";
19226
+ import fs6 from "node:fs";
19227
+ import path10 from "node:path";
19228
+
19229
+ // packages/workit-core/src/store/folder-store.ts
19213
19230
  import fs5 from "node:fs";
19231
+ import os5 from "node:os";
19214
19232
  import path9 from "node:path";
19233
+ var FOLDER_CONFIG = new Set(["checks.json", "risk-paths"]);
19234
+ var MOVED_POINTER = "MOVED-TO-STATE.txt";
19235
+ var V2_LEFTOVERS = new Set(["recovery", "index.json"]);
19236
+ var isV2TaskStub = (rel) => /^tasks[/\\][^/\\]+\.json$/u.test(rel);
19237
+ var MARKER = "workspace.json";
19238
+ var v2Workspace = (workit) => {
19239
+ let bytes;
19240
+ try {
19241
+ bytes = fs5.readFileSync(path9.join(workit, MARKER), "utf8");
19242
+ } catch {
19243
+ return null;
19244
+ }
19245
+ try {
19246
+ const value = JSON.parse(bytes);
19247
+ return value?.store?.format !== "workit-store";
19248
+ } catch {
19249
+ return true;
19250
+ }
19251
+ };
19252
+ var generatedIgnore = (file) => {
19253
+ try {
19254
+ return /^\*\n(!risk-paths\n)?$/u.test(fs5.readFileSync(file, "utf8"));
19255
+ } catch {
19256
+ return false;
19257
+ }
19258
+ };
19259
+ var exists = (file) => {
19260
+ try {
19261
+ fs5.lstatSync(file);
19262
+ return true;
19263
+ } catch {
19264
+ return false;
19265
+ }
19266
+ };
19267
+ var isDir = (file) => {
19268
+ try {
19269
+ return fs5.lstatSync(file).isDirectory();
19270
+ } catch {
19271
+ return false;
19272
+ }
19273
+ };
19274
+ var onlyStubs = (tasks) => {
19275
+ try {
19276
+ return fs5.readdirSync(tasks).every((entry) => isV2TaskStub(`tasks/${entry}`));
19277
+ } catch {
19278
+ return false;
19279
+ }
19280
+ };
19281
+ var strayEntries = (workit) => {
19282
+ if (!isDir(workit))
19283
+ return [];
19284
+ let names;
19285
+ try {
19286
+ names = fs5.readdirSync(workit);
19287
+ } catch {
19288
+ return [];
19289
+ }
19290
+ return names.filter((name) => !FOLDER_CONFIG.has(name) && !V2_LEFTOVERS.has(name) && name !== MOVED_POINTER && name !== MARKER && !(name === ".gitignore" && generatedIgnore(path9.join(workit, name))) && !(name === "tasks" && onlyStubs(path9.join(workit, name))));
19291
+ };
19292
+ var folderStoreIo = {
19293
+ rename: (from, to) => fs5.renameSync(from, to),
19294
+ copyFile: (from, to) => fs5.copyFileSync(from, to, fs5.constants.COPYFILE_EXCL)
19295
+ };
19296
+ var tempSeq = 0;
19297
+ var tempBeside = (file) => path9.join(path9.dirname(file), `.${path9.basename(file)}.workit-move-${process.pid}-${tempSeq += 1}`);
19298
+ var copyInto = (from, to) => {
19299
+ const stat = fs5.lstatSync(from);
19300
+ if (stat.isDirectory()) {
19301
+ fs5.mkdirSync(to, { recursive: true });
19302
+ for (const name of fs5.readdirSync(from))
19303
+ copyInto(path9.join(from, name), path9.join(to, name));
19304
+ return;
19305
+ }
19306
+ if (exists(to))
19307
+ throw new Error(`${to} appeared during the move`);
19308
+ const temp = tempBeside(to);
19309
+ try {
19310
+ if (stat.isSymbolicLink())
19311
+ fs5.symlinkSync(fs5.readlinkSync(from), temp);
19312
+ else
19313
+ folderStoreIo.copyFile(from, temp);
19314
+ folderStoreIo.rename(temp, to);
19315
+ } catch (error) {
19316
+ fs5.rmSync(temp, { force: true });
19317
+ throw error;
19318
+ }
19319
+ };
19320
+ var sameFile = (left, right) => {
19321
+ try {
19322
+ const [a, b] = [fs5.lstatSync(left), fs5.lstatSync(right)];
19323
+ if (!a.isFile() || !b.isFile() || a.size !== b.size)
19324
+ return false;
19325
+ return fs5.readFileSync(left).equals(fs5.readFileSync(right));
19326
+ } catch {
19327
+ return false;
19328
+ }
19329
+ };
19330
+ var merge2 = (from, to, rel, moved) => {
19331
+ if (isV2TaskStub(rel))
19332
+ return [];
19333
+ if (!exists(to)) {
19334
+ try {
19335
+ folderStoreIo.rename(from, to);
19336
+ } catch {
19337
+ try {
19338
+ copyInto(from, to);
19339
+ fs5.rmSync(from, { recursive: true, force: true });
19340
+ } catch {
19341
+ return exists(from) ? [rel] : [];
19342
+ }
19343
+ }
19344
+ moved.push(rel);
19345
+ return [];
19346
+ }
19347
+ if (sameFile(from, to)) {
19348
+ fs5.rmSync(from, { force: true });
19349
+ moved.push(rel);
19350
+ return [];
19351
+ }
19352
+ if (!isDir(from) || !isDir(to))
19353
+ return [rel];
19354
+ const kept = fs5.readdirSync(from).flatMap((name) => merge2(path9.join(from, name), path9.join(to, name), `${rel}/${name}`, moved));
19355
+ try {
19356
+ if (fs5.readdirSync(from).length === 0)
19357
+ fs5.rmdirSync(from);
19358
+ } catch {}
19359
+ return kept;
19360
+ };
19361
+ var LOCK_STALE_MS = 1e4;
19362
+ var LOCK_WAIT_MS = 250;
19363
+ var pause = (ms) => Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
19364
+ var staleLock = (lock) => {
19365
+ try {
19366
+ const stat = fs5.statSync(lock);
19367
+ if (Date.now() - stat.mtimeMs > LOCK_STALE_MS)
19368
+ return true;
19369
+ const pid = Number(fs5.readFileSync(lock, "utf8").trim());
19370
+ if (!Number.isInteger(pid) || pid <= 0)
19371
+ return false;
19372
+ try {
19373
+ process.kill(pid, 0);
19374
+ return false;
19375
+ } catch (error) {
19376
+ return error.code === "ESRCH";
19377
+ }
19378
+ } catch {
19379
+ return false;
19380
+ }
19381
+ };
19382
+ var takeMoveLock = (target) => {
19383
+ const lock = `${target}.lock`;
19384
+ const deadline = Date.now() + LOCK_WAIT_MS;
19385
+ for (;; ) {
19386
+ try {
19387
+ const fd = fs5.openSync(lock, "wx", 384);
19388
+ fs5.writeSync(fd, `${process.pid}
19389
+ `);
19390
+ fs5.closeSync(fd);
19391
+ return () => fs5.rmSync(lock, { force: true });
19392
+ } catch (error) {
19393
+ if (error.code !== "EEXIST")
19394
+ return null;
19395
+ }
19396
+ if (staleLock(lock)) {
19397
+ fs5.rmSync(lock, { force: true });
19398
+ continue;
19399
+ }
19400
+ if (Date.now() >= deadline)
19401
+ return null;
19402
+ pause(25);
19403
+ }
19404
+ };
19405
+ var canonical3 = (dir) => {
19406
+ try {
19407
+ return fs5.realpathSync.native(dir);
19408
+ } catch {
19409
+ return path9.resolve(dir);
19410
+ }
19411
+ };
19412
+ var below = (parent, child) => {
19413
+ const rel = path9.relative(parent, child);
19414
+ return rel !== "" && !rel.startsWith("..") && !path9.isAbsolute(rel);
19415
+ };
19416
+ var TEST_RUN_REFUSALS = "folder-store-refusals.log";
19417
+ var testRunFolderRefusal = (folder, hasStray, env = process.env, tempDir = os5.tmpdir()) => {
19418
+ if (env.WORKIT_TEST_RUN === undefined || !hasStray)
19419
+ return null;
19420
+ const real = canonical3(folder);
19421
+ const tmp = canonical3(tempDir);
19422
+ if (below(tmp, real))
19423
+ return null;
19424
+ return `workit test run (WORKIT_TEST_RUN): refusing to move ${path9.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)`;
19425
+ };
19426
+ function migrateFolderStore(folder, target, note = (line) => process.stderr.write(`${line}
19427
+ `)) {
19428
+ const workit = path9.join(folder, ".workit");
19429
+ const names = strayEntries(workit);
19430
+ const refusal = testRunFolderRefusal(folder, names.length > 0);
19431
+ if (refusal) {
19432
+ const run = process.env.WORKIT_TEST_RUN ?? "";
19433
+ if (path9.isAbsolute(run))
19434
+ try {
19435
+ fs5.appendFileSync(path9.join(run, TEST_RUN_REFUSALS), `${refusal}
19436
+ `);
19437
+ } catch {}
19438
+ throw new Error(refusal);
19439
+ }
19440
+ if (names.length === 0 || v2Workspace(workit) === true)
19441
+ return null;
19442
+ try {
19443
+ fs5.mkdirSync(path9.dirname(target), { recursive: true });
19444
+ } catch {
19445
+ return null;
19446
+ }
19447
+ const release = takeMoveLock(target);
19448
+ if (!release)
19449
+ return null;
19450
+ try {
19451
+ return moveLocked(workit, target, note);
19452
+ } finally {
19453
+ release();
19454
+ }
19455
+ }
19456
+ function moveLocked(workit, target, note) {
19457
+ const names = strayEntries(workit);
19458
+ if (names.length === 0 || v2Workspace(workit) === true)
19459
+ return null;
19460
+ try {
19461
+ fs5.mkdirSync(target, { recursive: true });
19462
+ } catch {
19463
+ return null;
19464
+ }
19465
+ const result = { from: workit, to: target, moved: [], kept: [] };
19466
+ for (const name of names) {
19467
+ result.kept.push(...merge2(path9.join(workit, name), path9.join(target, name), name, result.moved));
19468
+ }
19469
+ const left = (() => {
19470
+ try {
19471
+ return fs5.readdirSync(workit);
19472
+ } catch {
19473
+ return [];
19474
+ }
19475
+ })();
19476
+ const v2Left = left.some((name) => V2_LEFTOVERS.has(name) || name === "tasks" && isDir(path9.join(workit, name)));
19477
+ if (!v2Left && result.kept.length === 0) {
19478
+ fs5.rmSync(path9.join(workit, MARKER), { force: true });
19479
+ if (generatedIgnore(path9.join(workit, ".gitignore")))
19480
+ fs5.rmSync(path9.join(workit, ".gitignore"), { force: true });
19481
+ }
19482
+ const pointer = path9.join(workit, MOVED_POINTER);
19483
+ let wrote = false;
19484
+ if (result.kept.length > 0) {
19485
+ const text = `Workit keeps this folder's state in ${target}.
19486
+ Not moved, because the store there already has them or the move failed: ${result.kept.join(", ")}.
19487
+ Merge them by hand (cp -Rn ${workit}/. ${target}/), then delete them here.
19488
+ `;
19489
+ try {
19490
+ if (!exists(pointer) || fs5.readFileSync(pointer, "utf8") !== text) {
19491
+ fs5.writeFileSync(pointer, text);
19492
+ wrote = true;
19493
+ }
19494
+ } catch {}
19495
+ } else {
19496
+ fs5.rmSync(pointer, { force: true });
19497
+ try {
19498
+ if (fs5.readdirSync(workit).length === 0)
19499
+ fs5.rmdirSync(workit);
19500
+ } catch {}
19501
+ }
19502
+ if (result.moved.length > 0 || wrote)
19503
+ 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)`);
19504
+ return result;
19505
+ }
19506
+
19507
+ // packages/workit-core/src/store/paths.ts
19215
19508
  var NOT_A_REPO = /not a git repository \(or any (of the parent directories|parent up to)/u;
19216
19509
  var gitRun = (cwd, args) => {
19217
19510
  const run = spawnSync9("git", args, {
@@ -19236,10 +19529,10 @@ var gitRun = (cwd, args) => {
19236
19529
  missing: error?.code === "ENOENT"
19237
19530
  };
19238
19531
  };
19239
- var shortHash = (value) => createHash5("sha256").update(value).digest("hex").slice(0, 12);
19532
+ var shortHash = (value) => createHash6("sha256").update(value).digest("hex").slice(0, 12);
19240
19533
  var real = (file) => {
19241
19534
  try {
19242
- return fs5.realpathSync.native(file);
19535
+ return fs6.realpathSync.native(file);
19243
19536
  } catch {
19244
19537
  return file;
19245
19538
  }
@@ -19253,14 +19546,14 @@ var DISCOVERY_ENV = [
19253
19546
  ];
19254
19547
  var isGitDir = (dir) => {
19255
19548
  try {
19256
- return fs5.statSync(path9.join(dir, "HEAD")).isFile() && fs5.statSync(path9.join(dir, "objects")).isDirectory() && fs5.statSync(path9.join(dir, "refs")).isDirectory();
19549
+ return fs6.statSync(path10.join(dir, "HEAD")).isFile() && fs6.statSync(path10.join(dir, "objects")).isDirectory() && fs6.statSync(path10.join(dir, "refs")).isDirectory();
19257
19550
  } catch {
19258
19551
  return false;
19259
19552
  }
19260
19553
  };
19261
19554
  var reftableRefs = (common) => {
19262
19555
  try {
19263
- return /^\s*refstorage\s*=\s*reftable\s*$/imu.test(fs5.readFileSync(path9.join(common, "config"), "utf8"));
19556
+ return /^\s*refstorage\s*=\s*reftable\s*$/imu.test(fs6.readFileSync(path10.join(common, "config"), "utf8"));
19264
19557
  } catch {
19265
19558
  return false;
19266
19559
  }
@@ -19273,17 +19566,17 @@ function fastGit(root) {
19273
19566
  for (;; ) {
19274
19567
  let stat;
19275
19568
  try {
19276
- stat = fs5.statSync(dir);
19569
+ stat = fs6.statSync(dir);
19277
19570
  } catch {
19278
19571
  return null;
19279
19572
  }
19280
19573
  if (device !== null && stat.dev !== device)
19281
19574
  return { kind: "none" };
19282
19575
  device = stat.dev;
19283
- const dotGit = path9.join(dir, ".git");
19576
+ const dotGit = path10.join(dir, ".git");
19284
19577
  let entry = null;
19285
19578
  try {
19286
- entry = fs5.statSync(dotGit);
19579
+ entry = fs6.statSync(dotGit);
19287
19580
  } catch {}
19288
19581
  let gitDir = null;
19289
19582
  let top = null;
@@ -19294,26 +19587,26 @@ function fastGit(root) {
19294
19587
  else if (entry.isFile()) {
19295
19588
  let text = "";
19296
19589
  try {
19297
- text = fs5.readFileSync(dotGit, "utf8");
19590
+ text = fs6.readFileSync(dotGit, "utf8");
19298
19591
  } catch {
19299
19592
  return null;
19300
19593
  }
19301
19594
  const match = /^gitdir: (.+)$/mu.exec(text);
19302
19595
  if (!match)
19303
19596
  return null;
19304
- gitDir = path9.resolve(dir, match[1].trim());
19597
+ gitDir = path10.resolve(dir, match[1].trim());
19305
19598
  } else
19306
19599
  return null;
19307
- if (!fs5.existsSync(path9.join(gitDir, "HEAD")))
19600
+ if (!fs6.existsSync(path10.join(gitDir, "HEAD")))
19308
19601
  return null;
19309
19602
  } else if (isGitDir(dir))
19310
19603
  gitDir = dir;
19311
19604
  if (gitDir) {
19312
19605
  let common = gitDir;
19313
19606
  try {
19314
- common = path9.resolve(gitDir, fs5.readFileSync(path9.join(gitDir, "commondir"), "utf8").trim());
19607
+ common = path10.resolve(gitDir, fs6.readFileSync(path10.join(gitDir, "commondir"), "utf8").trim());
19315
19608
  } catch {}
19316
- if (!fs5.existsSync(path9.join(common, "objects")))
19609
+ if (!fs6.existsSync(path10.join(common, "objects")))
19317
19610
  return null;
19318
19611
  return {
19319
19612
  kind: "repo",
@@ -19323,28 +19616,33 @@ function fastGit(root) {
19323
19616
  reftable: reftableRefs(common)
19324
19617
  };
19325
19618
  }
19326
- const parent = path9.dirname(dir);
19619
+ const parent = path10.dirname(dir);
19327
19620
  if (parent === dir)
19328
19621
  return { kind: "none" };
19329
19622
  dir = parent;
19330
19623
  }
19331
19624
  }
19625
+ var outsideGit = (root) => {
19626
+ const dir = folderStoreDir(root);
19627
+ migrateFolderStore(root, dir);
19628
+ return { dir, shared: false, top: null };
19629
+ };
19332
19630
  function resolveStore(root) {
19333
- root = path9.resolve(root);
19631
+ root = path10.resolve(root);
19334
19632
  let stat = null;
19335
19633
  try {
19336
- stat = fs5.statSync(root);
19634
+ stat = fs6.statSync(root);
19337
19635
  } catch {}
19338
19636
  if (!stat)
19339
19637
  return new Error(`cannot locate the workit store: ${root} does not exist (removed while workit ran?); nothing is recorded under a missing directory`);
19340
19638
  if (!stat.isDirectory())
19341
- return { dir: path9.join(root, ".workit"), shared: false, top: null };
19639
+ return { dir: path10.join(root, ".workit"), shared: false, top: null };
19342
19640
  const fast = fastGit(root);
19343
19641
  if (fast?.kind === "none")
19344
- return { dir: path9.join(root, ".workit"), shared: false, top: null };
19642
+ return outsideGit(root);
19345
19643
  if (fast?.kind === "repo")
19346
19644
  return {
19347
- dir: path9.join(fast.common, "workit"),
19645
+ dir: path10.join(fast.common, "workit"),
19348
19646
  shared: true,
19349
19647
  top: fast.top,
19350
19648
  git: { gitDir: fast.gitDir, top: fast.top, reftable: fast.reftable }
@@ -19354,20 +19652,20 @@ function resolveStore(root) {
19354
19652
  if (run.ok && common) {
19355
19653
  const top = gitRun(root, ["rev-parse", "--path-format=absolute", "--show-toplevel"]);
19356
19654
  return {
19357
- dir: path9.join(real(path9.resolve(root, common)), "workit"),
19655
+ dir: path10.join(real(path10.resolve(root, common)), "workit"),
19358
19656
  shared: true,
19359
19657
  top: top.ok && top.stdout.trim() ? real(top.stdout.trim()) : null
19360
19658
  };
19361
19659
  }
19362
19660
  if (run.missing || !run.ok && NOT_A_REPO.test(run.stderr))
19363
- return { dir: path9.join(root, ".workit"), shared: false, top: null };
19661
+ return outsideGit(root);
19364
19662
  return new Error(`cannot locate the workit store: git rev-parse failed (${run.stderr.trim().split(`
19365
19663
  `)[0] || "no output"}); fix the repository (git status should work here)`);
19366
19664
  }
19367
19665
  var rebasingBranch = (gitDir) => {
19368
19666
  for (const state of ["rebase-merge", "rebase-apply"]) {
19369
19667
  try {
19370
- const ref = fs5.readFileSync(path9.join(gitDir, state, "head-name"), "utf8").trim();
19668
+ const ref = fs6.readFileSync(path10.join(gitDir, state, "head-name"), "utf8").trim();
19371
19669
  const match = /^refs\/heads\/(.+)$/u.exec(ref);
19372
19670
  if (match)
19373
19671
  return match[1];
@@ -19382,7 +19680,7 @@ function resolveTaskKey(root, location) {
19382
19680
  if (location.git && !location.git.reftable) {
19383
19681
  let head = "";
19384
19682
  try {
19385
- head = fs5.readFileSync(path9.join(location.git.gitDir, "HEAD"), "utf8").trim();
19683
+ head = fs6.readFileSync(path10.join(location.git.gitDir, "HEAD"), "utf8").trim();
19386
19684
  } catch {}
19387
19685
  const ref = /^ref: refs\/heads\/(.+)$/u.exec(head);
19388
19686
  if (ref && ref[1] !== ".invalid")
@@ -19413,10 +19711,10 @@ function resolveTaskKey(root, location) {
19413
19711
  return { key: `detached-${shortHash(real(worktree))}`, kind: "detached", branch: null };
19414
19712
  }
19415
19713
  function checkoutRootOf(root, location) {
19416
- const resolved = path9.resolve(root);
19714
+ const resolved = path10.resolve(root);
19417
19715
  let canonical = resolved;
19418
19716
  try {
19419
- canonical = fs5.realpathSync(resolved);
19717
+ canonical = fs6.realpathSync(resolved);
19420
19718
  } catch {
19421
19719
  return resolved;
19422
19720
  }
@@ -19426,7 +19724,7 @@ function checkoutRootOf(root, location) {
19426
19724
  if (real(canonical) === found.top)
19427
19725
  return canonical;
19428
19726
  try {
19429
- return fs5.realpathSync(found.top);
19727
+ return fs6.realpathSync(found.top);
19430
19728
  } catch {
19431
19729
  return canonical;
19432
19730
  }
@@ -19438,25 +19736,25 @@ function branchRenames(location) {
19438
19736
  const walk = (dir) => {
19439
19737
  let entries;
19440
19738
  try {
19441
- entries = fs5.readdirSync(dir, { withFileTypes: true });
19739
+ entries = fs6.readdirSync(dir, { withFileTypes: true });
19442
19740
  } catch {
19443
19741
  return;
19444
19742
  }
19445
19743
  for (const entry of entries)
19446
19744
  if (entry.isDirectory())
19447
- walk(path9.join(dir, entry.name));
19745
+ walk(path10.join(dir, entry.name));
19448
19746
  else
19449
- files.push(path9.join(dir, entry.name));
19747
+ files.push(path10.join(dir, entry.name));
19450
19748
  };
19451
- walk(path9.join(path9.dirname(location.dir), "logs", "refs", "heads"));
19749
+ walk(path10.join(path10.dirname(location.dir), "logs", "refs", "heads"));
19452
19750
  if (location.git)
19453
- files.push(path9.join(location.git.gitDir, "logs", "HEAD"));
19751
+ files.push(path10.join(location.git.gitDir, "logs", "HEAD"));
19454
19752
  const seen = new Set;
19455
19753
  const renames = [];
19456
19754
  for (const file of files) {
19457
19755
  let text = "";
19458
19756
  try {
19459
- text = fs5.readFileSync(file, "utf8");
19757
+ text = fs6.readFileSync(file, "utf8");
19460
19758
  } catch {
19461
19759
  continue;
19462
19760
  }
@@ -19481,13 +19779,7 @@ function followRenames(key, boundAt, renames) {
19481
19779
  }
19482
19780
  return current;
19483
19781
  }
19484
- var checkoutSlug = (root) => {
19485
- let canonical = real(root);
19486
- if (process.platform === "win32")
19487
- canonical = canonical.toLowerCase();
19488
- const base = path9.basename(canonical).replace(/[^A-Za-z0-9._-]/g, "_").slice(0, 40) || "root";
19489
- return `${base}-${shortHash(canonical)}`;
19490
- };
19782
+ var checkoutSlug = (root) => folderSlug(root);
19491
19783
 
19492
19784
  // packages/workit-core/src/host-session.ts
19493
19785
  var HOST_SESSION_VARS = [
@@ -19517,9 +19809,9 @@ function hostSessionFromEnv(env) {
19517
19809
  }
19518
19810
  return inner ? { host: inner.host, session: inner.session } : { host: declared, session: null };
19519
19811
  }
19520
- var hash = (value) => createHash6("sha256").update(value).digest("hex").slice(0, 32);
19521
- var userIssuedRoot = () => path10.join(resolveStateDir(), "issued");
19522
- var userTokenRoot = () => path10.join(resolveStateDir(), "issued-tokens");
19812
+ var hash = (value) => createHash7("sha256").update(value).digest("hex").slice(0, 32);
19813
+ var userIssuedRoot = () => path11.join(resolveStateDir(), "issued");
19814
+ var userTokenRoot = () => path11.join(resolveStateDir(), "issued-tokens");
19523
19815
  function migrateRepoIssued(cwd) {
19524
19816
  if (cwd === undefined)
19525
19817
  return;
@@ -19528,27 +19820,27 @@ function migrateRepoIssued(cwd) {
19528
19820
  const location = resolveStore(cwd);
19529
19821
  if (location instanceof Error)
19530
19822
  return;
19531
- old = path10.join(location.dir, "hooks", "issued");
19532
- if (!fs6.existsSync(old))
19823
+ old = path11.join(location.dir, "hooks", "issued");
19824
+ if (!fs7.existsSync(old))
19533
19825
  return;
19534
19826
  } catch {
19535
19827
  return;
19536
19828
  }
19537
19829
  for (const lead of safeList(old)) {
19538
19830
  try {
19539
- const from = path10.join(old, lead);
19540
- if (!fs6.statSync(from).isDirectory())
19831
+ const from = path11.join(old, lead);
19832
+ if (!fs7.statSync(from).isDirectory())
19541
19833
  continue;
19542
- const to = path10.join(userIssuedRoot(), lead);
19543
- fs6.mkdirSync(to, { recursive: true, mode: 448 });
19544
- for (const id of fs6.readdirSync(from)) {
19834
+ const to = path11.join(userIssuedRoot(), lead);
19835
+ fs7.mkdirSync(to, { recursive: true, mode: 448 });
19836
+ for (const id of fs7.readdirSync(from)) {
19545
19837
  try {
19546
- fs6.copyFileSync(path10.join(from, id), path10.join(to, id), fs6.constants.COPYFILE_EXCL);
19838
+ fs7.copyFileSync(path11.join(from, id), path11.join(to, id), fs7.constants.COPYFILE_EXCL);
19547
19839
  } catch (error) {
19548
19840
  if (error.code !== "EEXIST")
19549
19841
  throw error;
19550
19842
  }
19551
- fs6.rmSync(path10.join(from, id), { force: true });
19843
+ fs7.rmSync(path11.join(from, id), { force: true });
19552
19844
  }
19553
19845
  removeIfEmpty(from);
19554
19846
  } catch {}
@@ -19557,14 +19849,14 @@ function migrateRepoIssued(cwd) {
19557
19849
  }
19558
19850
  var safeList = (dir) => {
19559
19851
  try {
19560
- return fs6.readdirSync(dir);
19852
+ return fs7.readdirSync(dir);
19561
19853
  } catch {
19562
19854
  return [];
19563
19855
  }
19564
19856
  };
19565
19857
  var removeIfEmpty = (dir) => {
19566
19858
  try {
19567
- fs6.rmdirSync(dir);
19859
+ fs7.rmdirSync(dir);
19568
19860
  } catch {}
19569
19861
  };
19570
19862
  var issuedRecord = (cwd, claimed) => {
@@ -19573,7 +19865,7 @@ var issuedRecord = (cwd, claimed) => {
19573
19865
  return null;
19574
19866
  migrateRepoIssued(cwd);
19575
19867
  try {
19576
- return fs6.readFileSync(path10.join(userIssuedRoot(), hash(claimed.slice(0, cut)), hash(claimed)), "utf8");
19868
+ return fs7.readFileSync(path11.join(userIssuedRoot(), hash(claimed.slice(0, cut)), hash(claimed)), "utf8");
19577
19869
  } catch {
19578
19870
  return null;
19579
19871
  }
@@ -19583,9 +19875,9 @@ var issuedToken = (claimed) => {
19583
19875
  const cut = claimed.lastIndexOf(":");
19584
19876
  if (cut <= 0)
19585
19877
  return { stored: null, leadBound: false };
19586
- const dir = path10.join(userTokenRoot(), hash(claimed.slice(0, cut)));
19878
+ const dir = path11.join(userTokenRoot(), hash(claimed.slice(0, cut)));
19587
19879
  try {
19588
- const text = fs6.readFileSync(path10.join(dir, hash(claimed)), "utf8");
19880
+ const text = fs7.readFileSync(path11.join(dir, hash(claimed)), "utf8");
19589
19881
  return { stored: TOKEN_HASH.exec(text)?.[1] ?? null, leadBound: true };
19590
19882
  } catch {
19591
19883
  return { stored: null, leadBound: safeList(dir).length > 0 };
@@ -19604,8 +19896,8 @@ var OWN_CHILD_SHELL = new Set(["opencode", "pi"]);
19604
19896
 
19605
19897
  // packages/workit-core/src/store/event-log.ts
19606
19898
  import { randomUUID as randomUUID2 } from "node:crypto";
19607
- import fs7 from "node:fs";
19608
- import path11 from "node:path";
19899
+ import fs8 from "node:fs";
19900
+ import path12 from "node:path";
19609
19901
  var EVENT_VERSION = 1;
19610
19902
 
19611
19903
  class LogDamage extends Error {
@@ -19634,7 +19926,7 @@ var parseEvent = (line, file, offset) => {
19634
19926
  function readLog(file, from = 0, expectSeq = null) {
19635
19927
  let fd;
19636
19928
  try {
19637
- fd = fs7.openSync(file, "r");
19929
+ fd = fs8.openSync(file, "r");
19638
19930
  } catch (error) {
19639
19931
  if (error.code === "ENOENT")
19640
19932
  return null;
@@ -19643,13 +19935,13 @@ function readLog(file, from = 0, expectSeq = null) {
19643
19935
  let bytes;
19644
19936
  let size;
19645
19937
  try {
19646
- size = fs7.fstatSync(fd).size;
19938
+ size = fs8.fstatSync(fd).size;
19647
19939
  if (from > size)
19648
19940
  throw new LogDamage(`${file}: shorter than its snapshot`);
19649
19941
  bytes = Buffer.alloc(size - from);
19650
19942
  let read = 0;
19651
19943
  while (read < bytes.length) {
19652
- const got = fs7.readSync(fd, bytes, read, bytes.length - read, from + read);
19944
+ const got = fs8.readSync(fd, bytes, read, bytes.length - read, from + read);
19653
19945
  if (got === 0)
19654
19946
  break;
19655
19947
  read += got;
@@ -19657,7 +19949,7 @@ function readLog(file, from = 0, expectSeq = null) {
19657
19949
  bytes = bytes.subarray(0, read);
19658
19950
  size = from + read;
19659
19951
  } finally {
19660
- fs7.closeSync(fd);
19952
+ fs8.closeSync(fd);
19661
19953
  }
19662
19954
  const events = [];
19663
19955
  let start = 0;
@@ -19682,11 +19974,11 @@ function readLog(file, from = 0, expectSeq = null) {
19682
19974
  }
19683
19975
  var fsyncDirectory = (dir) => {
19684
19976
  try {
19685
- const fd = fs7.openSync(dir, "r");
19977
+ const fd = fs8.openSync(dir, "r");
19686
19978
  try {
19687
- fs7.fsyncSync(fd);
19979
+ fs8.fsyncSync(fd);
19688
19980
  } finally {
19689
- fs7.closeSync(fd);
19981
+ fs8.closeSync(fd);
19690
19982
  }
19691
19983
  } catch (error) {
19692
19984
  if (process.platform !== "win32")
@@ -19696,46 +19988,46 @@ var fsyncDirectory = (dir) => {
19696
19988
  function appendEvent(file, event, validEnd) {
19697
19989
  const line = Buffer.from(`${JSON.stringify(event)}
19698
19990
  `, "utf8");
19699
- const created = !fs7.existsSync(file);
19700
- if (!created && fs7.statSync(file).size !== validEnd) {
19701
- const cut = fs7.openSync(file, "r+");
19991
+ const created = !fs8.existsSync(file);
19992
+ if (!created && fs8.statSync(file).size !== validEnd) {
19993
+ const cut = fs8.openSync(file, "r+");
19702
19994
  try {
19703
- fs7.ftruncateSync(cut, validEnd);
19704
- fs7.fsyncSync(cut);
19995
+ fs8.ftruncateSync(cut, validEnd);
19996
+ fs8.fsyncSync(cut);
19705
19997
  } finally {
19706
- fs7.closeSync(cut);
19998
+ fs8.closeSync(cut);
19707
19999
  }
19708
20000
  }
19709
- const fd = fs7.openSync(file, "a", 384);
20001
+ const fd = fs8.openSync(file, "a", 384);
19710
20002
  try {
19711
20003
  let written = 0;
19712
20004
  while (written < line.length)
19713
- written += fs7.writeSync(fd, line, written, line.length - written);
19714
- fs7.fsyncSync(fd);
20005
+ written += fs8.writeSync(fd, line, written, line.length - written);
20006
+ fs8.fsyncSync(fd);
19715
20007
  } finally {
19716
- fs7.closeSync(fd);
20008
+ fs8.closeSync(fd);
19717
20009
  }
19718
20010
  if (created)
19719
- fsyncDirectory(path11.dirname(file));
20011
+ fsyncDirectory(path12.dirname(file));
19720
20012
  return validEnd;
19721
20013
  }
19722
20014
  function replaceFile(file, bytes, durable) {
19723
20015
  const temporary = `${file}.${process.pid}.${randomUUID2()}.tmp`;
19724
20016
  try {
19725
- const fd = fs7.openSync(temporary, "wx", 384);
20017
+ const fd = fs8.openSync(temporary, "wx", 384);
19726
20018
  try {
19727
- fs7.writeSync(fd, bytes);
20019
+ fs8.writeSync(fd, bytes);
19728
20020
  if (durable)
19729
- fs7.fsyncSync(fd);
20021
+ fs8.fsyncSync(fd);
19730
20022
  } finally {
19731
- fs7.closeSync(fd);
20023
+ fs8.closeSync(fd);
19732
20024
  }
19733
20025
  renameWithRetry(temporary, file);
19734
20026
  if (durable)
19735
- fsyncDirectory(path11.dirname(file));
20027
+ fsyncDirectory(path12.dirname(file));
19736
20028
  } catch (error) {
19737
20029
  try {
19738
- fs7.unlinkSync(temporary);
20030
+ fs8.unlinkSync(temporary);
19739
20031
  } catch {}
19740
20032
  throw error;
19741
20033
  }
@@ -19760,7 +20052,7 @@ var retryTransient = (run) => {
19760
20052
  }
19761
20053
  }
19762
20054
  };
19763
- var renameWithRetry = (from, to) => retryTransient(() => fs7.renameSync(from, to));
20055
+ var renameWithRetry = (from, to) => retryTransient(() => fs8.renameSync(from, to));
19764
20056
 
19765
20057
  // packages/workit-core/src/core/checkout-leftovers.ts
19766
20058
  var CHECKOUT_LEFTOVERS = [
@@ -19889,7 +20181,7 @@ var isPatch = (value) => Array.isArray(value) && value.every((op) => {
19889
20181
  });
19890
20182
 
19891
20183
  // packages/workit-core/src/store/reduce.ts
19892
- import { createHash as createHash7 } from "node:crypto";
20184
+ import { createHash as createHash8 } from "node:crypto";
19893
20185
  var OPENING_TYPES = new Set([
19894
20186
  "task.opened",
19895
20187
  "task.imported",
@@ -19918,7 +20210,7 @@ var isObject4 = (value) => typeof value === "object" && value !== null && !Array
19918
20210
  var isKey = (value) => isObject4(value) && typeof value.key === "string" && (value.kind === "branch" || value.kind === "detached" || value.kind === "dir") && (value.branch === null || typeof value.branch === "string");
19919
20211
  var BLOB_REF = "$blob";
19920
20212
  var blobRef = (value) => isObject4(value) && Object.keys(value).length === 1 && typeof value[BLOB_REF] === "string" && /^[0-9a-f]{64}$/.test(value[BLOB_REF]) ? value[BLOB_REF] : null;
19921
- var blobDigest = (value) => createHash7("sha256").update(JSON.stringify(value)).digest("hex");
20213
+ var blobDigest = (value) => createHash8("sha256").update(JSON.stringify(value)).digest("hex");
19922
20214
  var toBlob = (value, blobs) => {
19923
20215
  if (!isObject4(value))
19924
20216
  return value;
@@ -20032,8 +20324,8 @@ var migrationReporterInstalled = () => typeof globalThis[SLOT] === "function";
20032
20324
 
20033
20325
  // packages/workit-core/src/core/task-read.ts
20034
20326
  import { randomUUID as randomUUID3 } from "node:crypto";
20035
- import * as fs12 from "node:fs";
20036
- import path15 from "node:path";
20327
+ import * as fs13 from "node:fs";
20328
+ import path16 from "node:path";
20037
20329
 
20038
20330
  // node_modules/@openclaw/fs-safe/dist/errors.js
20039
20331
  var OPERATIONAL_CODES = new Set([
@@ -20084,10 +20376,10 @@ function sameFileIdentity(left, right, platform = process.platform) {
20084
20376
  // node_modules/@openclaw/fs-safe/dist/sidecar-lock-reclaim.js
20085
20377
  import { randomBytes as randomBytes2 } from "node:crypto";
20086
20378
  import fsSync from "node:fs";
20087
- import path12 from "node:path";
20379
+ import path13 from "node:path";
20088
20380
 
20089
20381
  // node_modules/@openclaw/fs-safe/dist/bounded-read.js
20090
- import fs8 from "node:fs";
20382
+ import fs9 from "node:fs";
20091
20383
 
20092
20384
  // node_modules/@openclaw/fs-safe/dist/byte-budget.js
20093
20385
  function normalizeMaxBytes(value, options = {}) {
@@ -20124,7 +20416,7 @@ function readFileDescriptorBoundedSync(fd, maxBytes) {
20124
20416
  let total = 0;
20125
20417
  while (true) {
20126
20418
  const length = nextReadLength(total, maxBytes, scratch.length);
20127
- const bytesRead = fs8.readSync(fd, scratch, 0, length, null);
20419
+ const bytesRead = fs9.readSync(fd, scratch, 0, length, null);
20128
20420
  if (bytesRead === 0) {
20129
20421
  return Buffer.concat(chunks, total);
20130
20422
  }
@@ -20133,9 +20425,9 @@ function readFileDescriptorBoundedSync(fd, maxBytes) {
20133
20425
  }
20134
20426
 
20135
20427
  // node_modules/@openclaw/fs-safe/dist/read-open-flags.js
20136
- import fs9 from "node:fs";
20428
+ import fs10 from "node:fs";
20137
20429
  function resolveReadOpenFlags(options) {
20138
- const constants = options?.constants ?? fs9.constants;
20430
+ const constants = options?.constants ?? fs10.constants;
20139
20431
  const noFollow = process.platform !== "win32" && options?.followSymlinks !== true && typeof constants.O_NOFOLLOW === "number" ? constants.O_NOFOLLOW : 0;
20140
20432
  const nonBlocking = process.platform !== "win32" && typeof constants.O_NONBLOCK === "number" ? constants.O_NONBLOCK : 0;
20141
20433
  return constants.O_RDONLY | noFollow | nonBlocking;
@@ -20174,13 +20466,13 @@ ${ownershipToken}
20174
20466
  return { raw, ownershipToken };
20175
20467
  }
20176
20468
  function relativeSidecarLockPath(lockRoot, lockPath) {
20177
- const resolved = path12.resolve(lockPath);
20178
- const lexicalRelative = path12.relative(lockRoot.rootDir, resolved);
20179
- const relative = lexicalRelative !== ".." && !lexicalRelative.startsWith(`..${path12.sep}`) && !path12.isAbsolute(lexicalRelative) ? lexicalRelative : path12.relative(lockRoot.rootReal, resolved);
20180
- if (!relative || relative === ".." || relative.startsWith(`..${path12.sep}`) || path12.isAbsolute(relative)) {
20469
+ const resolved = path13.resolve(lockPath);
20470
+ const lexicalRelative = path13.relative(lockRoot.rootDir, resolved);
20471
+ const relative = lexicalRelative !== ".." && !lexicalRelative.startsWith(`..${path13.sep}`) && !path13.isAbsolute(lexicalRelative) ? lexicalRelative : path13.relative(lockRoot.rootReal, resolved);
20472
+ if (!relative || relative === ".." || relative.startsWith(`..${path13.sep}`) || path13.isAbsolute(relative)) {
20181
20473
  throw new FsSafeError("outside-workspace", "sidecar lock path is outside lockRoot");
20182
20474
  }
20183
- return relative.split(path12.sep).join(path12.posix.sep);
20475
+ return relative.split(path13.sep).join(path13.posix.sep);
20184
20476
  }
20185
20477
  function parseSidecarLockPayload(raw, parser) {
20186
20478
  if (parser) {
@@ -20326,8 +20618,8 @@ function getFsSafeLockConfig() {
20326
20618
  }
20327
20619
 
20328
20620
  // node_modules/@openclaw/fs-safe/dist/file-lock-sync.js
20329
- import fs10 from "node:fs";
20330
- import path13 from "node:path";
20621
+ import fs11 from "node:fs";
20622
+ import path14 from "node:path";
20331
20623
 
20332
20624
  // node_modules/@openclaw/fs-safe/dist/timing.js
20333
20625
  function sleepSync(ms) {
@@ -20357,7 +20649,7 @@ function releaseAllSyncHeldLocks() {
20357
20649
  }
20358
20650
  try {
20359
20651
  if (held.fd !== undefined)
20360
- fs10.closeSync(held.fd);
20652
+ fs11.closeSync(held.fd);
20361
20653
  } catch {}
20362
20654
  try {
20363
20655
  removeSidecarLockIfUnchangedSync(held.lockPath, held.snapshot);
@@ -20392,7 +20684,7 @@ function releaseSyncHeldLock(held) {
20392
20684
  if (held.fd !== undefined) {
20393
20685
  const fd = held.fd;
20394
20686
  held.fd = undefined;
20395
- fs10.closeSync(fd);
20687
+ fs11.closeSync(fd);
20396
20688
  }
20397
20689
  removeSidecarLockIfUnchangedSync(held.lockPath, held.snapshot);
20398
20690
  heldLocks.delete(held.normalizedTargetPath);
@@ -20415,29 +20707,29 @@ function createSyncHeldLockHandle(held) {
20415
20707
  };
20416
20708
  }
20417
20709
  function canonicalLockParentSync(parent) {
20418
- return process.platform === "win32" ? fs10.realpathSync.native(parent) : fs10.realpathSync(parent);
20710
+ return process.platform === "win32" ? fs11.realpathSync.native(parent) : fs11.realpathSync(parent);
20419
20711
  }
20420
20712
  function normalizeTargetPath(targetPath) {
20421
- const resolved = path13.resolve(targetPath);
20422
- fs10.mkdirSync(path13.dirname(resolved), { recursive: true });
20713
+ const resolved = path14.resolve(targetPath);
20714
+ fs11.mkdirSync(path14.dirname(resolved), { recursive: true });
20423
20715
  try {
20424
- return path13.join(canonicalLockParentSync(path13.dirname(resolved)), path13.basename(resolved));
20716
+ return path14.join(canonicalLockParentSync(path14.dirname(resolved)), path14.basename(resolved));
20425
20717
  } catch {
20426
20718
  return resolved;
20427
20719
  }
20428
20720
  }
20429
20721
  function boundedLockPath(lockPath, lockRoot) {
20430
- const resolved = path13.resolve(lockPath);
20722
+ const resolved = path14.resolve(lockPath);
20431
20723
  if (!lockRoot)
20432
20724
  return resolved;
20433
20725
  relativeSidecarLockPath(lockRoot, resolved);
20434
- const parent = path13.dirname(resolved);
20726
+ const parent = path14.dirname(resolved);
20435
20727
  const parentReal = canonicalLockParentSync(parent);
20436
- const parentRelative = path13.relative(lockRoot.rootReal, parentReal);
20437
- if (parentRelative === ".." || parentRelative.startsWith(`..${path13.sep}`) || path13.isAbsolute(parentRelative)) {
20728
+ const parentRelative = path14.relative(lockRoot.rootReal, parentReal);
20729
+ if (parentRelative === ".." || parentRelative.startsWith(`..${path14.sep}`) || path14.isAbsolute(parentRelative)) {
20438
20730
  throw new FsSafeError("outside-workspace", "sidecar lock parent is outside lockRoot");
20439
20731
  }
20440
- return path13.join(parentReal, path13.basename(resolved));
20732
+ return path14.join(parentReal, path14.basename(resolved));
20441
20733
  }
20442
20734
  function defaultShouldReclaim(snapshot, staleMs, nowMs) {
20443
20735
  const createdAtMs = sidecarLockPayloadCreatedAtMs(snapshot.payload);
@@ -20447,7 +20739,7 @@ function defaultShouldReclaim(snapshot, staleMs, nowMs) {
20447
20739
  }
20448
20740
  function reclaimGuardExists(reclaimGuardPath) {
20449
20741
  try {
20450
- fs10.lstatSync(reclaimGuardPath);
20742
+ fs11.lstatSync(reclaimGuardPath);
20451
20743
  return true;
20452
20744
  } catch (error) {
20453
20745
  if (error.code === "ENOENT")
@@ -20511,19 +20803,19 @@ function acquireFileLockSync(targetPath, options) {
20511
20803
  const { raw, ownershipToken } = serializeSidecarLockPayload(payload);
20512
20804
  let lockFileCreateDenied = false;
20513
20805
  try {
20514
- const noFollow = process.platform !== "win32" && typeof fs10.constants.O_NOFOLLOW === "number" ? fs10.constants.O_NOFOLLOW : 0;
20806
+ const noFollow = process.platform !== "win32" && typeof fs11.constants.O_NOFOLLOW === "number" ? fs11.constants.O_NOFOLLOW : 0;
20515
20807
  try {
20516
- fd = fs10.openSync(lockPath, fs10.constants.O_WRONLY | fs10.constants.O_CREAT | fs10.constants.O_EXCL | noFollow, 384);
20808
+ fd = fs11.openSync(lockPath, fs11.constants.O_WRONLY | fs11.constants.O_CREAT | fs11.constants.O_EXCL | noFollow, 384);
20517
20809
  } catch (error) {
20518
20810
  lockFileCreateDenied = isTransientLockFileDenial(error, lockPath);
20519
20811
  throw error;
20520
20812
  }
20521
- fs10.writeFileSync(fd, raw, "utf8");
20522
- fs10.fsyncSync(fd);
20813
+ fs11.writeFileSync(fd, raw, "utf8");
20814
+ fs11.fsyncSync(fd);
20523
20815
  const snapshot = {
20524
20816
  raw,
20525
20817
  payload,
20526
- stat: fs10.fstatSync(fd),
20818
+ stat: fs11.fstatSync(fd),
20527
20819
  ownershipToken
20528
20820
  };
20529
20821
  const createdHeld = {
@@ -20558,8 +20850,8 @@ function acquireFileLockSync(targetPath, options) {
20558
20850
  return returnedHandle;
20559
20851
  } catch (error) {
20560
20852
  if (fd !== undefined) {
20561
- const failed = { payload: null, stat: fs10.fstatSync(fd) };
20562
- fs10.closeSync(fd);
20853
+ const failed = { payload: null, stat: fs11.fstatSync(fd) };
20854
+ fs11.closeSync(fd);
20563
20855
  fd = undefined;
20564
20856
  removeSidecarLockIfUnchangedSync(lockPath, failed);
20565
20857
  }
@@ -20608,7 +20900,7 @@ function acquireFileLockSync(targetPath, options) {
20608
20900
  })) {
20609
20901
  let ownsReclaimGuard = false;
20610
20902
  try {
20611
- fs10.mkdirSync(reclaimGuardPath);
20903
+ fs11.mkdirSync(reclaimGuardPath);
20612
20904
  ownsReclaimGuard = true;
20613
20905
  if (removeSidecarLockIfUnchangedSync(lockPath, snapshot))
20614
20906
  continue;
@@ -20621,7 +20913,7 @@ function acquireFileLockSync(targetPath, options) {
20621
20913
  } finally {
20622
20914
  if (ownsReclaimGuard) {
20623
20915
  try {
20624
- fs10.rmdirSync(reclaimGuardPath);
20916
+ fs11.rmdirSync(reclaimGuardPath);
20625
20917
  } catch {}
20626
20918
  }
20627
20919
  }
@@ -20637,27 +20929,27 @@ function acquireFileLockSync(targetPath, options) {
20637
20929
  }
20638
20930
  }
20639
20931
  // packages/workit-core/src/core/package-root.ts
20640
- import { existsSync as existsSync4 } from "node:fs";
20641
- import path14 from "node:path";
20932
+ import { existsSync as existsSync5 } from "node:fs";
20933
+ import path15 from "node:path";
20642
20934
  import { fileURLToPath } from "node:url";
20643
20935
  var packageRoot = () => {
20644
- let dir = path14.dirname(fileURLToPath(import.meta.url));
20936
+ let dir = path15.dirname(fileURLToPath(import.meta.url));
20645
20937
  while (true) {
20646
- const parent = path14.dirname(dir);
20647
- if (existsSync4(path14.join(dir, "package.json")) || parent === dir)
20938
+ const parent = path15.dirname(dir);
20939
+ if (existsSync5(path15.join(dir, "package.json")) || parent === dir)
20648
20940
  return dir;
20649
20941
  dir = parent;
20650
20942
  }
20651
20943
  };
20652
20944
  var assetRoot = () => {
20653
20945
  const root = packageRoot();
20654
- const assets = path14.join(root, "assets");
20655
- return existsSync4(assets) ? assets : root;
20946
+ const assets = path15.join(root, "assets");
20947
+ return existsSync5(assets) ? assets : root;
20656
20948
  };
20657
20949
 
20658
20950
  // packages/workit-core/src/core/store-lock.ts
20659
20951
  import { spawnSync as spawnSync10 } from "node:child_process";
20660
- import fs11 from "node:fs";
20952
+ import fs12 from "node:fs";
20661
20953
  import { hostname } from "node:os";
20662
20954
  var metadataLockSchema = object({
20663
20955
  pid: number2().int().nonnegative().safe(),
@@ -20700,7 +20992,7 @@ var parseProcStatStart = (stat) => {
20700
20992
  };
20701
20993
  var readProcStat = (pid) => {
20702
20994
  try {
20703
- return fs11.readFileSync(`/proc/${pid}/stat`, "utf8");
20995
+ return fs12.readFileSync(`/proc/${pid}/stat`, "utf8");
20704
20996
  } catch {
20705
20997
  return null;
20706
20998
  }
@@ -20729,7 +21021,7 @@ var processStartOf = (pid, deps = {}) => {
20729
21021
  };
20730
21022
  var readTrimmed = (file) => {
20731
21023
  try {
20732
- return fs11.readFileSync(file, "utf8").trim() || null;
21024
+ return fs12.readFileSync(file, "utf8").trim() || null;
20733
21025
  } catch {
20734
21026
  return null;
20735
21027
  }
@@ -20740,7 +21032,7 @@ var localLockHost = () => {
20740
21032
  return cachedLockHost;
20741
21033
  let pidns = null;
20742
21034
  try {
20743
- pidns = /\[(\d+)\]/.exec(fs11.readlinkSync("/proc/self/ns/pid"))?.[1] ?? null;
21035
+ pidns = /\[(\d+)\]/.exec(fs12.readlinkSync("/proc/self/ns/pid"))?.[1] ?? null;
20744
21036
  } catch {}
20745
21037
  const boot = readTrimmed("/proc/sys/kernel/random/boot_id");
20746
21038
  cachedLockHost = pidns || boot ? `${hostname()}#${pidns ?? "?"}:${boot ?? "?"}` : hostname();
@@ -20786,7 +21078,7 @@ var classifyLockOwner = (payload, ageMs, localHost = localLockHost(), options =
20786
21078
  };
20787
21079
  var ageOf = (file, nowMs) => {
20788
21080
  try {
20789
- return nowMs - fs11.lstatSync(file).mtimeMs;
21081
+ return nowMs - fs12.lstatSync(file).mtimeMs;
20790
21082
  } catch {
20791
21083
  return null;
20792
21084
  }
@@ -20797,7 +21089,7 @@ var clearAbandonedReclaimGuard = (lockPath, nowMs = Date.now()) => {
20797
21089
  if (age === null || age <= RECLAIM_GUARD_TTL_MS)
20798
21090
  return false;
20799
21091
  try {
20800
- fs11.rmdirSync(guard);
21092
+ fs12.rmdirSync(guard);
20801
21093
  return true;
20802
21094
  } catch {
20803
21095
  return false;
@@ -20842,7 +21134,7 @@ var indexEntry = (task, key, legacy, file) => {
20842
21134
  };
20843
21135
  var fileSignature = (file) => {
20844
21136
  try {
20845
- const stat = fs12.statSync(file, { bigint: true });
21137
+ const stat = fs13.statSync(file, { bigint: true });
20846
21138
  return `${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeNs}:${stat.ctimeNs}`;
20847
21139
  } catch {
20848
21140
  return null;
@@ -20859,7 +21151,7 @@ var cachedRuntimeVersion = null;
20859
21151
  var runtimeVersion = () => {
20860
21152
  if (cachedRuntimeVersion === null) {
20861
21153
  try {
20862
- const pkg = JSON.parse(fs12.readFileSync(path15.join(packageRoot(), "package.json"), "utf8"));
21154
+ const pkg = JSON.parse(fs13.readFileSync(path16.join(packageRoot(), "package.json"), "utf8"));
20863
21155
  cachedRuntimeVersion = typeof pkg.version === "string" && pkg.version ? pkg.version : "0.0.0";
20864
21156
  } catch {
20865
21157
  cachedRuntimeVersion = "0.0.0";
@@ -20881,14 +21173,14 @@ var isNewerVersion = (candidate, current) => {
20881
21173
  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);
20882
21174
  var readText2 = (file) => {
20883
21175
  try {
20884
- return fs12.readFileSync(file, "utf8");
21176
+ return fs13.readFileSync(file, "utf8");
20885
21177
  } catch {
20886
21178
  return "";
20887
21179
  }
20888
21180
  };
20889
21181
  var REFLOG_LINE = /^[0-9a-f]+ ([0-9a-f]+) .* (\d+) [+-]\d{4}\t(.*)$/u;
20890
21182
  var branchStart = (location, branch, aliases) => {
20891
- const first = readText2(path15.join(path15.dirname(location.dir), "logs", "refs", "heads", branch)).split(`
21183
+ const first = readText2(path16.join(path16.dirname(location.dir), "logs", "refs", "heads", branch)).split(`
20892
21184
  `, 1)[0];
20893
21185
  const created = REFLOG_LINE.exec(first);
20894
21186
  const start = created && /^branch: Created from (\S+)$/u.exec(created[3])?.[1];
@@ -20898,7 +21190,7 @@ var branchStart = (location, branch, aliases) => {
20898
21190
  return start;
20899
21191
  if (!location.git)
20900
21192
  return null;
20901
- for (const line of readText2(path15.join(location.git.gitDir, "logs", "HEAD")).split(`
21193
+ for (const line of readText2(path16.join(location.git.gitDir, "logs", "HEAD")).split(`
20902
21194
  `)) {
20903
21195
  const entry = REFLOG_LINE.exec(line);
20904
21196
  const moved = entry && /^checkout: moving from (\S+) to (\S+)$/u.exec(entry[3]);
@@ -20908,23 +21200,23 @@ var branchStart = (location, branch, aliases) => {
20908
21200
  }
20909
21201
  return null;
20910
21202
  };
20911
- var refExists2 = (common, ref) => fs12.existsSync(path15.join(common, ref)) || readText2(path15.join(common, "packed-refs")).includes(` ${ref}
21203
+ var refExists2 = (common, ref) => fs13.existsSync(path16.join(common, ref)) || readText2(path16.join(common, "packed-refs")).includes(` ${ref}
20912
21204
  `);
20913
21205
  var origins = new Map;
20914
21206
  var sameDirectoryIdentity = (left, right) => {
20915
- if (!path15.isAbsolute(left) || !path15.isAbsolute(right))
21207
+ if (!path16.isAbsolute(left) || !path16.isAbsolute(right))
20916
21208
  return false;
20917
- const normalizedLeft = path15.resolve(left);
20918
- const normalizedRight = path15.resolve(right);
21209
+ const normalizedLeft = path16.resolve(left);
21210
+ const normalizedRight = path16.resolve(right);
20919
21211
  try {
20920
- const a = fs12.statSync(normalizedLeft, { bigint: true });
20921
- const b = fs12.statSync(normalizedRight, { bigint: true });
21212
+ const a = fs13.statSync(normalizedLeft, { bigint: true });
21213
+ const b = fs13.statSync(normalizedRight, { bigint: true });
20922
21214
  if (!a.isDirectory() || !b.isDirectory())
20923
21215
  return false;
20924
21216
  if (process.platform === "win32" ? normalizedLeft.toLowerCase() === normalizedRight.toLowerCase() : normalizedLeft === normalizedRight)
20925
21217
  return true;
20926
- const canonicalLeft = fs12.realpathSync(normalizedLeft);
20927
- const canonicalRight = fs12.realpathSync(normalizedRight);
21218
+ const canonicalLeft = fs13.realpathSync(normalizedLeft);
21219
+ const canonicalRight = fs13.realpathSync(normalizedRight);
20928
21220
  if (process.platform === "win32" ? canonicalLeft.toLowerCase() === canonicalRight.toLowerCase() : canonicalLeft === canonicalRight)
20929
21221
  return true;
20930
21222
  return a.dev === b.dev && a.ino !== 0n && a.ino === b.ino;
@@ -20949,14 +21241,14 @@ class TaskReader {
20949
21241
  located;
20950
21242
  migrationChecked = false;
20951
21243
  constructor(root, options = {}) {
20952
- const resolved = path15.resolve(root);
20953
- this.origin = fs12.existsSync(resolved) ? fs12.realpathSync(resolved) : resolved;
21244
+ const resolved = path16.resolve(root);
21245
+ this.origin = fs13.existsSync(resolved) ? fs13.realpathSync(resolved) : resolved;
20954
21246
  this.located = resolveStore(this.origin);
20955
21247
  this.root = checkoutRootOf(this.origin, this.located);
20956
21248
  this.lockTimeoutMs = options.lockTimeoutMs ?? defaultLockTimeout();
20957
21249
  }
20958
21250
  location() {
20959
- if (this.located !== undefined && !(this.located instanceof Error) && !this.located.shared && fs12.existsSync(path15.join(this.root, ".git"))) {
21251
+ if (this.located !== undefined && !(this.located instanceof Error) && !this.located.shared && fs13.existsSync(path16.join(this.root, ".git"))) {
20960
21252
  this.located = undefined;
20961
21253
  this.migrationChecked = false;
20962
21254
  }
@@ -21020,7 +21312,7 @@ class TaskReader {
21020
21312
  const tasksDir = this.paths().tasks;
21021
21313
  let names;
21022
21314
  try {
21023
- names = fs12.existsSync(tasksDir) ? fs12.readdirSync(tasksDir).filter((name) => validId(name)) : [];
21315
+ names = fs13.existsSync(tasksDir) ? fs13.readdirSync(tasksDir).filter((name) => validId(name)) : [];
21024
21316
  } catch (error) {
21025
21317
  return failure2("storage_error", `unable to list tasks: ${String(error)}`, {
21026
21318
  path: tasksDir
@@ -21061,7 +21353,7 @@ class TaskReader {
21061
21353
  const file = this.paths().workspace;
21062
21354
  let bytes;
21063
21355
  try {
21064
- bytes = retryTransient(() => fs12.readFileSync(file, "utf8"));
21356
+ bytes = retryTransient(() => fs13.readFileSync(file, "utf8"));
21065
21357
  } catch (error) {
21066
21358
  if (error.code === "ENOENT")
21067
21359
  return success(null, null, null);
@@ -21114,14 +21406,14 @@ class TaskReader {
21114
21406
  const branch = key.ok ? key.data.branch : null;
21115
21407
  if (!branch || !location.ok)
21116
21408
  return success(null, null, null);
21117
- const common = path15.dirname(location.data.dir);
21118
- const heads = path15.join(common, "logs", "refs", "heads");
21119
- const headLog = location.data.git ? path15.join(location.data.git.gitDir, "logs", "HEAD") : "";
21409
+ const common = path16.dirname(location.data.dir);
21410
+ const heads = path16.join(common, "logs", "refs", "heads");
21411
+ const headLog = location.data.git ? path16.join(location.data.git.gitDir, "logs", "HEAD") : "";
21120
21412
  const signatures = [
21121
- path15.join(heads, branch),
21413
+ path16.join(heads, branch),
21122
21414
  headLog,
21123
21415
  heads,
21124
- path15.join(common, "packed-refs")
21416
+ path16.join(common, "packed-refs")
21125
21417
  ].map((file) => fileSignature(file) ?? "-");
21126
21418
  const slot = `${location.data.dir}\x00${headLog}\x00${branch}`;
21127
21419
  let resolved = origins.get(slot);
@@ -21133,7 +21425,7 @@ class TaskReader {
21133
21425
  aliases.push(rename.from);
21134
21426
  const start = branchStart(location.data, branch, aliases);
21135
21427
  const slash = start?.indexOf("/") ?? -1;
21136
- const remote = slash > 0 && !refExists2(common, `refs/heads/${start}`) && (refExists2(common, `refs/remotes/${start}`) || readText2(path15.join(common, "config")).includes(`[remote "${start.slice(0, slash)}"]`));
21428
+ const remote = slash > 0 && !refExists2(common, `refs/heads/${start}`) && (refExists2(common, `refs/remotes/${start}`) || readText2(path16.join(common, "config")).includes(`[remote "${start.slice(0, slash)}"]`));
21137
21429
  const name = start && (remote ? start.slice(slash + 1) : start);
21138
21430
  resolved = {
21139
21431
  signature: signatures.join("|"),
@@ -21153,27 +21445,27 @@ class TaskReader {
21153
21445
  }
21154
21446
  paths() {
21155
21447
  const location = this.location();
21156
- const dir = location.ok ? location.data.dir : path15.join(this.root, ".workit");
21157
- const checkout = path15.join(dir, "checkouts", checkoutSlug(this.root));
21448
+ const dir = location.ok ? location.data.dir : path16.join(this.root, ".workit");
21449
+ const checkout = path16.join(dir, "checkouts", checkoutSlug(this.root));
21158
21450
  return {
21159
21451
  dir,
21160
21452
  shared: location.ok ? location.data.shared : false,
21161
- marker: path15.join(dir, "store.json"),
21453
+ marker: path16.join(dir, "store.json"),
21162
21454
  checkout,
21163
- workspace: path15.join(checkout, "workspace.json"),
21164
- checkoutLock: path15.join(checkout, "metadata.lock"),
21165
- tasks: path15.join(dir, "tasks"),
21166
- index: path15.join(dir, "task-index.json"),
21167
- blobs: path15.join(dir, "blobs", "candidates"),
21168
- legacy: path15.join(dir, "legacy", checkoutSlug(this.root), "v2"),
21169
- v2: path15.join(this.root, ".workit")
21455
+ workspace: path16.join(checkout, "workspace.json"),
21456
+ checkoutLock: path16.join(checkout, "metadata.lock"),
21457
+ tasks: path16.join(dir, "tasks"),
21458
+ index: path16.join(dir, "task-index.json"),
21459
+ blobs: path16.join(dir, "blobs", "candidates"),
21460
+ legacy: path16.join(dir, "legacy", checkoutSlug(this.root), "v2"),
21461
+ v2: path16.join(this.root, ".workit")
21170
21462
  };
21171
21463
  }
21172
21464
  eventsPath(taskId) {
21173
- return path15.join(this.paths().tasks, taskId, "events.jsonl");
21465
+ return path16.join(this.paths().tasks, taskId, "events.jsonl");
21174
21466
  }
21175
21467
  snapshotPath(taskId) {
21176
- return path15.join(this.paths().tasks, taskId, "snapshot.json");
21468
+ return path16.join(this.paths().tasks, taskId, "snapshot.json");
21177
21469
  }
21178
21470
  ready(write = false) {
21179
21471
  const location = this.location();
@@ -21183,7 +21475,7 @@ class TaskReader {
21183
21475
  return success(null, null, null);
21184
21476
  const dirs = this.paths();
21185
21477
  try {
21186
- const marker = JSON.parse(fs12.readFileSync(dirs.marker, "utf8"));
21478
+ const marker = JSON.parse(fs13.readFileSync(dirs.marker, "utf8"));
21187
21479
  if (typeof marker.version === "number" && marker.version > STORE_FORMAT)
21188
21480
  return failure2("recovery_required", `the workit store at ${dirs.dir} has format ${marker.version}; upgrade Workit to use it`, { path: dirs.marker });
21189
21481
  } catch {}
@@ -21208,7 +21500,7 @@ class TaskReader {
21208
21500
  return {
21209
21501
  read: (digest) => {
21210
21502
  try {
21211
- return JSON.parse(fs12.readFileSync(path15.join(dir, `${digest}.json`), "utf8"));
21503
+ return JSON.parse(fs13.readFileSync(path16.join(dir, `${digest}.json`), "utf8"));
21212
21504
  } catch (error) {
21213
21505
  throw new LogDamage(`stored candidate ${digest} is missing or unreadable: ${String(error)}`);
21214
21506
  }
@@ -21295,7 +21587,7 @@ class TaskReader {
21295
21587
  }
21296
21588
  readSnapshot(taskId) {
21297
21589
  try {
21298
- const value = JSON.parse(fs12.readFileSync(this.snapshotPath(taskId), "utf8"));
21590
+ const value = JSON.parse(fs13.readFileSync(this.snapshotPath(taskId), "utf8"));
21299
21591
  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))
21300
21592
  return null;
21301
21593
  return value;
@@ -21322,7 +21614,7 @@ class TaskReader {
21322
21614
  }
21323
21615
  readIndex() {
21324
21616
  try {
21325
- const value = JSON.parse(fs12.readFileSync(this.paths().index, "utf8"));
21617
+ const value = JSON.parse(fs13.readFileSync(this.paths().index, "utf8"));
21326
21618
  if (!isObject5(value) || value.version !== INDEX_VERSION || !isObject5(value.tasks))
21327
21619
  return {};
21328
21620
  const tasks = {};
@@ -21336,7 +21628,7 @@ class TaskReader {
21336
21628
  }
21337
21629
  writeIndex(entries) {
21338
21630
  try {
21339
- fs12.mkdirSync(this.paths().tasks, { recursive: true });
21631
+ fs13.mkdirSync(this.paths().tasks, { recursive: true });
21340
21632
  replaceFile(this.paths().index, JSON.stringify({
21341
21633
  version: INDEX_VERSION,
21342
21634
  tasks: Object.fromEntries(entries.map((entry) => [entry.id, entry]))
@@ -21374,64 +21666,74 @@ class TaskReader {
21374
21666
  return failure2("recovery_required", `${label} record does not satisfy its schema`);
21375
21667
  }
21376
21668
  v2Dirs() {
21377
- return [...new Set([this.root, this.origin])].map((dir) => path15.join(dir, ".workit"));
21669
+ return [...new Set([this.root, this.origin])].map((dir) => path16.join(dir, ".workit"));
21378
21670
  }
21379
21671
  pendingMigrations() {
21380
21672
  return this.v2Dirs().filter((dir) => {
21381
- const raw = this.readV2Workspace(path15.join(dir, "workspace.json"));
21673
+ const raw = this.readV2Workspace(path16.join(dir, "workspace.json"));
21382
21674
  return raw !== null && raw !== TOMBSTONE;
21383
21675
  });
21384
21676
  }
21385
21677
  adoptLocalStore() {
21678
+ if (!this.paths().shared)
21679
+ return success(null, null, null);
21680
+ for (const local of [this.paths().v2, folderStoreDir(this.root)]) {
21681
+ const adopted = this.adoptStoreFrom(local);
21682
+ if (!adopted.ok)
21683
+ return adopted;
21684
+ }
21685
+ return success(null, null, null);
21686
+ }
21687
+ adoptStoreFrom(local) {
21386
21688
  const dirs = this.paths();
21387
- const marker = path15.join(dirs.v2, "store.json");
21388
- if (!dirs.shared || !fs12.existsSync(marker))
21689
+ const marker = path16.join(local, "store.json");
21690
+ if (!fs13.existsSync(marker))
21389
21691
  return success(null, null, null);
21390
21692
  return this.withLock(dirs.checkoutLock, () => {
21391
- if (!fs12.existsSync(marker))
21693
+ if (!fs13.existsSync(marker))
21392
21694
  return success(null, null, null);
21393
21695
  let tasks = 0;
21394
21696
  try {
21395
21697
  const merge = (from, to) => {
21396
- if (!fs12.existsSync(to)) {
21397
- fs12.mkdirSync(path15.dirname(to), { recursive: true });
21698
+ if (!fs13.existsSync(to)) {
21699
+ fs13.mkdirSync(path16.dirname(to), { recursive: true });
21398
21700
  try {
21399
- fs12.renameSync(from, to);
21701
+ fs13.renameSync(from, to);
21400
21702
  } catch {
21401
- fs12.cpSync(from, to, { recursive: true, errorOnExist: true, force: false });
21402
- fs12.rmSync(from, { recursive: true, force: true });
21703
+ fs13.cpSync(from, to, { recursive: true, errorOnExist: true, force: false });
21704
+ fs13.rmSync(from, { recursive: true, force: true });
21403
21705
  }
21404
21706
  return;
21405
21707
  }
21406
- if (fs12.lstatSync(from).isDirectory() && fs12.lstatSync(to).isDirectory())
21407
- for (const name of fs12.readdirSync(from))
21408
- merge(path15.join(from, name), path15.join(to, name));
21708
+ if (fs13.lstatSync(from).isDirectory() && fs13.lstatSync(to).isDirectory())
21709
+ for (const name of fs13.readdirSync(from))
21710
+ merge(path16.join(from, name), path16.join(to, name));
21409
21711
  };
21410
21712
  for (const sub of ["tasks", "checkouts", "blobs", "legacy"]) {
21411
- const from = path15.join(dirs.v2, sub);
21412
- if (!fs12.existsSync(from))
21713
+ const from = path16.join(local, sub);
21714
+ if (!fs13.existsSync(from))
21413
21715
  continue;
21414
21716
  if (sub === "tasks") {
21415
- for (const name of fs12.readdirSync(from))
21416
- if (validId(name) && !fs12.existsSync(path15.join(dirs.dir, sub, name)))
21717
+ for (const name of fs13.readdirSync(from))
21718
+ if (validId(name) && !fs13.existsSync(path16.join(dirs.dir, sub, name)))
21417
21719
  tasks += 1;
21418
21720
  }
21419
- merge(from, path15.join(dirs.dir, sub));
21721
+ merge(from, path16.join(dirs.dir, sub));
21420
21722
  }
21421
- const ledger = path15.join(dirs.v2, "ledger");
21422
- if (fs12.existsSync(ledger) && !fs12.existsSync(path15.join(dirs.dir, "ledger")))
21423
- merge(ledger, path15.join(dirs.dir, "ledger"));
21424
- fs12.rmSync(path15.join(dirs.v2, "task-index.json"), { force: true });
21425
- fs12.renameSync(marker, path15.join(dirs.v2, "store.moved.json"));
21723
+ const ledger = path16.join(local, "ledger");
21724
+ if (fs13.existsSync(ledger) && !fs13.existsSync(path16.join(dirs.dir, "ledger")))
21725
+ merge(ledger, path16.join(dirs.dir, "ledger"));
21726
+ fs13.rmSync(path16.join(local, "task-index.json"), { force: true });
21727
+ fs13.renameSync(marker, path16.join(local, "store.moved.json"));
21426
21728
  } catch (error) {
21427
- return failure2("storage_error", `cannot move ${dirs.v2} into ${dirs.dir}: ${String(error)}`, {
21428
- path: dirs.v2
21729
+ return failure2("storage_error", `cannot move ${local} into ${dirs.dir}: ${String(error)}`, {
21730
+ path: local
21429
21731
  });
21430
21732
  }
21431
21733
  reportMigration({
21432
- from: dirs.v2,
21734
+ from: local,
21433
21735
  to: dirs.dir,
21434
- backup: dirs.v2,
21736
+ backup: local,
21435
21737
  tasks,
21436
21738
  skipped: 0,
21437
21739
  workspace: false
@@ -21442,7 +21744,7 @@ class TaskReader {
21442
21744
  readV2Workspace(file) {
21443
21745
  let bytes;
21444
21746
  try {
21445
- bytes = fs12.readFileSync(file, "utf8");
21747
+ bytes = fs13.readFileSync(file, "utf8");
21446
21748
  } catch {
21447
21749
  return null;
21448
21750
  }
@@ -21460,7 +21762,7 @@ class TaskReader {
21460
21762
  schemaVersion: SCHEMA_VERSION,
21461
21763
  id: workspaceId ?? newId(),
21462
21764
  revision: newRevision(),
21463
- root: path15.dirname(v2),
21765
+ root: path16.dirname(v2),
21464
21766
  runtime: { createdWith: version, updatedWith: version },
21465
21767
  writer: null,
21466
21768
  store: {
@@ -21471,47 +21773,21 @@ class TaskReader {
21471
21773
  },
21472
21774
  critical: ["store"]
21473
21775
  };
21474
- fs12.mkdirSync(v2, { recursive: true });
21475
- const ignore = path15.join(v2, ".gitignore");
21476
- if (!fs12.existsSync(ignore))
21477
- fs12.writeFileSync(ignore, `*
21776
+ fs13.mkdirSync(v2, { recursive: true });
21777
+ const ignore = path16.join(v2, ".gitignore");
21778
+ if (!fs13.existsSync(ignore))
21779
+ fs13.writeFileSync(ignore, `*
21478
21780
  `);
21479
- replaceFile(path15.join(v2, "workspace.json"), `${JSON.stringify(marker, null, 2)}
21781
+ replaceFile(path16.join(v2, "workspace.json"), `${JSON.stringify(marker, null, 2)}
21480
21782
  `, true);
21481
21783
  }
21482
- writeTombstoneIfMissing() {
21483
- try {
21484
- if (this.paths().shared)
21485
- return;
21486
- const v2 = path15.join(this.root, ".workit");
21487
- if (fs12.existsSync(path15.join(v2, "workspace.json")))
21488
- return;
21489
- let id = null;
21490
- try {
21491
- id = JSON.parse(fs12.readFileSync(this.paths().workspace, "utf8")).id ?? null;
21492
- } catch {}
21493
- this.writeTombstone(v2, id);
21494
- } catch {}
21495
- }
21496
21784
  initializeStorage() {
21497
21785
  const dirs = this.paths();
21498
- retryTransient(() => fs12.mkdirSync(dirs.checkout, { recursive: true }));
21499
- retryTransient(() => fs12.mkdirSync(dirs.tasks, { recursive: true }));
21500
- if (!fs12.existsSync(dirs.marker))
21786
+ retryTransient(() => fs13.mkdirSync(dirs.checkout, { recursive: true }));
21787
+ retryTransient(() => fs13.mkdirSync(dirs.tasks, { recursive: true }));
21788
+ if (!fs13.existsSync(dirs.marker))
21501
21789
  replaceFile(dirs.marker, `${JSON.stringify({ format: "workit-store", version: STORE_FORMAT, createdWith: runtimeVersion() })}
21502
21790
  `, false);
21503
- if (!dirs.shared) {
21504
- const ignore = path15.join(dirs.dir, ".gitignore");
21505
- let current = null;
21506
- try {
21507
- current = fs12.readFileSync(ignore, "utf8");
21508
- } catch {}
21509
- if (current !== `*
21510
- `)
21511
- retryTransient(() => fs12.writeFileSync(ignore, `*
21512
- `));
21513
- }
21514
- this.writeTombstoneIfMissing();
21515
21791
  }
21516
21792
  lockOptions(lockPath) {
21517
21793
  const inProcess = heldInProcess.has(lockPath);
@@ -21524,7 +21800,7 @@ class TaskReader {
21524
21800
  shouldReclaim: ({ payload, nowMs }) => {
21525
21801
  let ageMs = null;
21526
21802
  try {
21527
- ageMs = nowMs - fs12.lstatSync(lockPath).mtimeMs;
21803
+ ageMs = nowMs - fs13.lstatSync(lockPath).mtimeMs;
21528
21804
  } catch {}
21529
21805
  return classifyLockOwner(payload, ageMs, localLockHost(), TASK_STORE_LOCK).state === "stale";
21530
21806
  },
@@ -21561,7 +21837,7 @@ class TaskReader {
21561
21837
  withLock(lockPath, operation) {
21562
21838
  try {
21563
21839
  this.initializeStorage();
21564
- fs12.mkdirSync(path15.dirname(lockPath), { recursive: true });
21840
+ fs13.mkdirSync(path16.dirname(lockPath), { recursive: true });
21565
21841
  } catch (error) {
21566
21842
  return failure2("storage_error", `unable to initialize store: ${String(error)}`, {
21567
21843
  path: this.paths().dir
@@ -21601,18 +21877,18 @@ class TaskReader {
21601
21877
  lockDirWritable(lockPath) {
21602
21878
  const probe = `${lockPath}.${process.pid}.${randomUUID3()}.probe`;
21603
21879
  try {
21604
- fs12.closeSync(fs12.openSync(probe, "wx", 384));
21880
+ fs13.closeSync(fs13.openSync(probe, "wx", 384));
21605
21881
  } catch {
21606
21882
  return false;
21607
21883
  }
21608
21884
  try {
21609
- fs12.rmSync(probe, { force: true });
21885
+ fs13.rmSync(probe, { force: true });
21610
21886
  } catch {}
21611
21887
  return true;
21612
21888
  }
21613
21889
  lockHolderPresent(lockPath) {
21614
21890
  try {
21615
- fs12.lstatSync(lockPath);
21891
+ fs13.lstatSync(lockPath);
21616
21892
  return true;
21617
21893
  } catch (error) {
21618
21894
  return error?.code !== "ENOENT";
@@ -21624,12 +21900,12 @@ class TaskReader {
21624
21900
  if (isTransientWindowsError(error) && !this.lockHolderPresent(lockPath) && !this.lockDirWritable(lockPath))
21625
21901
  return failure2("storage_error", `cannot create the workit lock (${code}); no other Workit call holds it`, {
21626
21902
  path: lockPath,
21627
- guidance: `Check permissions and the read-only attribute on ${path15.dirname(lockPath)}.`
21903
+ guidance: `Check permissions and the read-only attribute on ${path16.dirname(lockPath)}.`
21628
21904
  });
21629
21905
  if (code === "EEXIST" || code === "file_lock_timeout" || code === "file_lock_stale" || isTransientWindowsError(error)) {
21630
21906
  let lock = null;
21631
21907
  try {
21632
- lock = parseMetadataLockOrNull(fs12.readFileSync(lockPath, "utf8"));
21908
+ lock = parseMetadataLockOrNull(fs13.readFileSync(lockPath, "utf8"));
21633
21909
  } catch {}
21634
21910
  return failure2("busy", `workit lock is held by another Workit call${lock ? ` (pid ${lock.pid} on ${lock.host})` : ""}; retry shortly`, {
21635
21911
  outcome: "not_started",
@@ -21659,7 +21935,7 @@ var MARKER_FIELDS = {
21659
21935
  };
21660
21936
  var isKnownMarker = (file, kind) => {
21661
21937
  try {
21662
- const value = JSON.parse(fs13.readFileSync(file, "utf8"));
21938
+ const value = JSON.parse(fs14.readFileSync(file, "utf8"));
21663
21939
  if (!isObject5(value))
21664
21940
  return false;
21665
21941
  const fields = MARKER_FIELDS[kind];
@@ -21673,35 +21949,35 @@ var isKnownMarker = (file, kind) => {
21673
21949
  }
21674
21950
  };
21675
21951
  var moveInto = (from, to) => {
21676
- if (fs13.lstatSync(from).isDirectory()) {
21952
+ if (fs14.lstatSync(from).isDirectory()) {
21677
21953
  let target = to;
21678
- if (fs13.existsSync(target) && !fs13.lstatSync(target).isDirectory())
21954
+ if (fs14.existsSync(target) && !fs14.lstatSync(target).isDirectory())
21679
21955
  target = `${to}.dir`;
21680
- fs13.mkdirSync(target, { recursive: true });
21681
- for (const name of fs13.readdirSync(from))
21682
- moveInto(path16.join(from, name), path16.join(target, name));
21683
- fs13.rmdirSync(from);
21956
+ fs14.mkdirSync(target, { recursive: true });
21957
+ for (const name of fs14.readdirSync(from))
21958
+ moveInto(path17.join(from, name), path17.join(target, name));
21959
+ fs14.rmdirSync(from);
21684
21960
  return;
21685
21961
  }
21686
21962
  let target = to;
21687
- if (fs13.existsSync(target)) {
21688
- const bytes = fs13.readFileSync(from);
21689
- if (fs13.lstatSync(target).isFile() && bytes.equals(fs13.readFileSync(target))) {
21690
- fs13.rmSync(from);
21963
+ if (fs14.existsSync(target)) {
21964
+ const bytes = fs14.readFileSync(from);
21965
+ if (fs14.lstatSync(target).isFile() && bytes.equals(fs14.readFileSync(target))) {
21966
+ fs14.rmSync(from);
21691
21967
  return;
21692
21968
  }
21693
- target = `${to}.${createHash8("sha256").update(bytes).digest("hex").slice(0, 12)}`;
21694
- if (fs13.existsSync(target)) {
21695
- fs13.rmSync(from);
21969
+ target = `${to}.${createHash9("sha256").update(bytes).digest("hex").slice(0, 12)}`;
21970
+ if (fs14.existsSync(target)) {
21971
+ fs14.rmSync(from);
21696
21972
  return;
21697
21973
  }
21698
21974
  }
21699
- fs13.mkdirSync(path16.dirname(target), { recursive: true });
21975
+ fs14.mkdirSync(path17.dirname(target), { recursive: true });
21700
21976
  try {
21701
- fs13.renameSync(from, target);
21977
+ fs14.renameSync(from, target);
21702
21978
  } catch {
21703
- fs13.copyFileSync(from, target);
21704
- fs13.rmSync(from);
21979
+ fs14.copyFileSync(from, target);
21980
+ fs14.rmSync(from);
21705
21981
  }
21706
21982
  };
21707
21983
  var now = () => new Date().toISOString().replace(/\.\d{3}Z$/, "Z");
@@ -21764,7 +22040,7 @@ class TaskStore extends TaskReader {
21764
22040
  const moved = this.bindLocked(again.data.id, key, input.now);
21765
22041
  return moved.ok ? success(moved.data.revision, null, { task: moved.data, created: false, key }) : moved;
21766
22042
  }
21767
- const label = key.kind === "branch" ? `branch ${key.branch}` : key.kind === "detached" ? "a detached HEAD" : path16.basename(this.root) || this.root;
22043
+ const label = key.kind === "branch" ? `branch ${key.branch}` : key.kind === "detached" ? "a detached HEAD" : path17.basename(this.root) || this.root;
21768
22044
  const intent = {
21769
22045
  objective: input.objective?.trim() || `Work on ${label}`,
21770
22046
  scope: { description: `the checkout (${label})`, paths: ["."], exclusions: [] },
@@ -22012,13 +22288,13 @@ class TaskStore extends TaskReader {
22012
22288
  if (!ready.ok)
22013
22289
  return ready;
22014
22290
  const dirs = this.paths();
22015
- const recovery = [path16.join(this.root, ".workit", "recovery"), path16.join(dirs.legacy, "recovery")].find((dir) => fs13.existsSync(dir)) ?? null;
22291
+ const recovery = [path17.join(this.root, ".workit", "recovery"), path17.join(dirs.legacy, "recovery")].find((dir) => fs14.existsSync(dir)) ?? null;
22016
22292
  if (recovery) {
22017
22293
  let files = 0;
22018
22294
  let bytes = 0;
22019
22295
  try {
22020
- for (const name of fs13.readdirSync(recovery)) {
22021
- const stat = fs13.lstatSync(path16.join(recovery, name));
22296
+ for (const name of fs14.readdirSync(recovery)) {
22297
+ const stat = fs14.lstatSync(path17.join(recovery, name));
22022
22298
  if (!stat.isFile())
22023
22299
  continue;
22024
22300
  files += 1;
@@ -22027,17 +22303,17 @@ class TaskStore extends TaskReader {
22027
22303
  } catch {}
22028
22304
  const remove = options.pruneRecovery === true && !dryRun;
22029
22305
  if (remove)
22030
- fs13.rmSync(recovery, { recursive: true, force: true });
22306
+ fs14.rmSync(recovery, { recursive: true, force: true });
22031
22307
  report.legacyRecovery = { path: recovery, files, bytes, removed: remove };
22032
22308
  }
22033
- if (!fs13.existsSync(dirs.tasks))
22309
+ if (!fs14.existsSync(dirs.tasks))
22034
22310
  return success(null, null, report);
22035
- const names = fs13.readdirSync(dirs.tasks).filter((name) => validId(name));
22311
+ const names = fs14.readdirSync(dirs.tasks).filter((name) => validId(name));
22036
22312
  for (const name of names) {
22037
22313
  const file = this.eventsPath(name);
22038
22314
  let size = 0;
22039
22315
  try {
22040
- size = fs13.statSync(file).size;
22316
+ size = fs14.statSync(file).size;
22041
22317
  } catch {
22042
22318
  continue;
22043
22319
  }
@@ -22065,16 +22341,16 @@ class TaskStore extends TaskReader {
22065
22341
  const references = new Set;
22066
22342
  for (const name of names)
22067
22343
  try {
22068
- for (const match of fs13.readFileSync(this.eventsPath(name), "utf8").matchAll(/"\$blob":"([0-9a-f]{64})"/g))
22344
+ for (const match of fs14.readFileSync(this.eventsPath(name), "utf8").matchAll(/"\$blob":"([0-9a-f]{64})"/g))
22069
22345
  references.add(match[1]);
22070
22346
  } catch {}
22071
- if (fs13.existsSync(dirs.blobs))
22072
- for (const name of fs13.readdirSync(dirs.blobs)) {
22347
+ if (fs14.existsSync(dirs.blobs))
22348
+ for (const name of fs14.readdirSync(dirs.blobs)) {
22073
22349
  const digest = name.replace(/\.json$/, "");
22074
- const file = path16.join(dirs.blobs, name);
22350
+ const file = path17.join(dirs.blobs, name);
22075
22351
  let stat;
22076
22352
  try {
22077
- stat = fs13.lstatSync(file);
22353
+ stat = fs14.lstatSync(file);
22078
22354
  } catch {
22079
22355
  continue;
22080
22356
  }
@@ -22085,11 +22361,11 @@ class TaskStore extends TaskReader {
22085
22361
  report.blobs.removed += 1;
22086
22362
  report.blobs.removedBytes += stat.size;
22087
22363
  if (!dryRun)
22088
- fs13.rmSync(file, { force: true });
22364
+ fs14.rmSync(file, { force: true });
22089
22365
  }
22090
22366
  return success(null, null, null);
22091
22367
  };
22092
- const swept = dryRun ? sweep() : this.withLock(path16.join(dirs.dir, "gc.lock"), sweep);
22368
+ const swept = dryRun ? sweep() : this.withLock(path17.join(dirs.dir, "gc.lock"), sweep);
22093
22369
  if (!swept.ok)
22094
22370
  return swept;
22095
22371
  const temporaryDirs = [
@@ -22097,17 +22373,17 @@ class TaskStore extends TaskReader {
22097
22373
  dirs.tasks,
22098
22374
  dirs.blobs,
22099
22375
  dirs.checkout,
22100
- ...names.map((name) => path16.join(dirs.tasks, name))
22376
+ ...names.map((name) => path17.join(dirs.tasks, name))
22101
22377
  ];
22102
22378
  for (const directory of temporaryDirs) {
22103
- if (!fs13.existsSync(directory))
22379
+ if (!fs14.existsSync(directory))
22104
22380
  continue;
22105
- for (const name of fs13.readdirSync(directory)) {
22381
+ for (const name of fs14.readdirSync(directory)) {
22106
22382
  if (!name.endsWith(".tmp") && !name.endsWith(".probe"))
22107
22383
  continue;
22108
- const file = path16.join(directory, name);
22384
+ const file = path17.join(directory, name);
22109
22385
  try {
22110
- const stat = fs13.lstatSync(file);
22386
+ const stat = fs14.lstatSync(file);
22111
22387
  if (!stat.isFile() || nowMs - stat.mtimeMs <= STALE_TEMPORARY_MS)
22112
22388
  continue;
22113
22389
  } catch {
@@ -22115,13 +22391,13 @@ class TaskStore extends TaskReader {
22115
22391
  }
22116
22392
  report.temporary.removed += 1;
22117
22393
  if (!dryRun)
22118
- fs13.rmSync(file, { force: true });
22394
+ fs14.rmSync(file, { force: true });
22119
22395
  }
22120
22396
  }
22121
22397
  return success(null, null, report);
22122
22398
  }
22123
22399
  taskLockPath(taskId) {
22124
- return path16.join(this.paths().tasks, taskId, "lock");
22400
+ return path17.join(this.paths().tasks, taskId, "lock");
22125
22401
  }
22126
22402
  settleMigrations(write) {
22127
22403
  const moved = this.adoptLocalStore();
@@ -22150,15 +22426,15 @@ class TaskStore extends TaskReader {
22150
22426
  return {
22151
22427
  read: (digest) => reader.read(digest),
22152
22428
  write: (digest, value) => {
22153
- const file = path16.join(dir, `${digest}.json`);
22154
- if (fs13.existsSync(file)) {
22429
+ const file = path17.join(dir, `${digest}.json`);
22430
+ if (fs14.existsSync(file)) {
22155
22431
  const stamp = new Date;
22156
22432
  try {
22157
- fs13.utimesSync(file, stamp, stamp);
22433
+ fs14.utimesSync(file, stamp, stamp);
22158
22434
  return;
22159
22435
  } catch {}
22160
22436
  }
22161
- fs13.mkdirSync(dir, { recursive: true });
22437
+ fs14.mkdirSync(dir, { recursive: true });
22162
22438
  replaceFile(file, JSON.stringify(value), true);
22163
22439
  }
22164
22440
  };
@@ -22252,8 +22528,8 @@ class TaskStore extends TaskReader {
22252
22528
  }
22253
22529
  }
22254
22530
  openTask(record, type, key, legacy = null) {
22255
- const dir = path16.join(this.paths().tasks, record.id);
22256
- fs13.mkdirSync(dir, { recursive: true });
22531
+ const dir = path17.join(this.paths().tasks, record.id);
22532
+ fs14.mkdirSync(dir, { recursive: true });
22257
22533
  const blobs = this.blobStore();
22258
22534
  const bound = key ? { ...key, boundAt: key.boundAt ?? new Date().toISOString() } : null;
22259
22535
  const event = this.event(record.id, 1, type, {
@@ -22305,11 +22581,11 @@ class TaskStore extends TaskReader {
22305
22581
  } catch {}
22306
22582
  if (!latest || latest.events[0]?.id !== last.id)
22307
22583
  return failure2("busy", "the task log changed during compaction; retry", { taskId });
22308
- const appended = fs13.readFileSync(file).subarray(log.end, latest.end);
22584
+ const appended = fs14.readFileSync(file).subarray(log.end, latest.end);
22309
22585
  const bytes = Buffer.concat([Buffer.from(prefix, "utf8"), appended]);
22310
22586
  replaceFile(file, bytes.toString("utf8"), true);
22311
22587
  try {
22312
- fs13.rmSync(this.snapshotPath(taskId), { force: true });
22588
+ fs14.rmSync(this.snapshotPath(taskId), { force: true });
22313
22589
  } catch {}
22314
22590
  const reloaded = this.load(taskId);
22315
22591
  if (reloaded.ok && reloaded.data)
@@ -22322,7 +22598,7 @@ class TaskStore extends TaskReader {
22322
22598
  }
22323
22599
  countEvents(file) {
22324
22600
  try {
22325
- const bytes = fs13.readFileSync(file);
22601
+ const bytes = fs14.readFileSync(file);
22326
22602
  let count = 0;
22327
22603
  for (let index = bytes.indexOf(10);index >= 0; index = bytes.indexOf(10, index + 1))
22328
22604
  count += 1;
@@ -22332,8 +22608,8 @@ class TaskStore extends TaskReader {
22332
22608
  }
22333
22609
  }
22334
22610
  withKeyLock(key, operation) {
22335
- const digest = createHash8("sha256").update(key).digest("hex").slice(0, 32);
22336
- return this.withLock(path16.join(this.paths().dir, "keys", `${digest}.lock`), operation);
22611
+ const digest = createHash9("sha256").update(key).digest("hex").slice(0, 32);
22612
+ return this.withLock(path17.join(this.paths().dir, "keys", `${digest}.lock`), operation);
22337
22613
  }
22338
22614
  bindLocked(taskId, key, timestamp) {
22339
22615
  const current = this.readWorkspace();
@@ -22474,7 +22750,7 @@ class TaskStore extends TaskReader {
22474
22750
  writeWorkspace(record) {
22475
22751
  const file = this.paths().workspace;
22476
22752
  try {
22477
- fs13.mkdirSync(path16.dirname(file), { recursive: true });
22753
+ fs14.mkdirSync(path17.dirname(file), { recursive: true });
22478
22754
  replaceFile(file, `${canonicalJson(record)}
22479
22755
  `, true);
22480
22756
  return success(null, null, null);
@@ -22500,13 +22776,13 @@ class TaskStore extends TaskReader {
22500
22776
  }
22501
22777
  migrateV2(v2) {
22502
22778
  const dirs = this.paths();
22503
- const v2Workspace = path16.join(v2, "workspace.json");
22504
- const v2Tasks = path16.join(v2, "tasks");
22505
- const legacy = path16.join(dirs.dir, "legacy", checkoutSlug(path16.dirname(v2)), "v2");
22779
+ const v2Workspace = path17.join(v2, "workspace.json");
22780
+ const v2Tasks = path17.join(v2, "tasks");
22781
+ const legacy = path17.join(dirs.dir, "legacy", checkoutSlug(path17.dirname(v2)), "v2");
22506
22782
  const raw = this.readV2Workspace(v2Workspace);
22507
22783
  if (raw === null || raw === TOMBSTONE)
22508
22784
  return success(null, null, null);
22509
- return this.withLock(dirs.checkoutLock, () => this.withLock(path16.join(v2, "metadata.lock"), () => {
22785
+ return this.withLock(dirs.checkoutLock, () => this.withLock(path17.join(v2, "metadata.lock"), () => {
22510
22786
  const workspace = this.readV2Workspace(v2Workspace);
22511
22787
  if (workspace === null || workspace === TOMBSTONE)
22512
22788
  return success(null, null, null);
@@ -22515,7 +22791,7 @@ class TaskStore extends TaskReader {
22515
22791
  return failure2("recovery_required", `cannot migrate the 2.x store at ${v2}: ${parsedWorkspace.error}; move it aside to start fresh`, { path: v2Workspace });
22516
22792
  let files = [];
22517
22793
  try {
22518
- files = fs13.readdirSync(v2Tasks).filter((name) => name.endsWith(".json") && validId(name.slice(0, -5))).filter((name) => !this.isStub(path16.join(v2Tasks, name)));
22794
+ files = fs14.readdirSync(v2Tasks).filter((name) => name.endsWith(".json") && validId(name.slice(0, -5))).filter((name) => !this.isStub(path17.join(v2Tasks, name)));
22519
22795
  } catch {}
22520
22796
  const current = this.readWorkspace();
22521
22797
  if (!current.ok)
@@ -22533,22 +22809,22 @@ class TaskStore extends TaskReader {
22533
22809
  let skipped = 0;
22534
22810
  const done = new Map;
22535
22811
  try {
22536
- fs13.mkdirSync(path16.join(legacy, "tasks"), { recursive: true });
22812
+ fs14.mkdirSync(path17.join(legacy, "tasks"), { recursive: true });
22537
22813
  for (const name of ["workspace.json", "index.json"])
22538
- if (fs13.existsSync(path16.join(v2, name)))
22539
- fs13.copyFileSync(path16.join(v2, name), path16.join(legacy, name));
22814
+ if (fs14.existsSync(path17.join(v2, name)))
22815
+ fs14.copyFileSync(path17.join(v2, name), path17.join(legacy, name));
22540
22816
  for (const name of files) {
22541
22817
  const id = name.slice(0, -5);
22542
- const file = path16.join(v2Tasks, name);
22543
- const bytes = fs13.readFileSync(file, "utf8");
22818
+ const file = path17.join(v2Tasks, name);
22819
+ const bytes = fs14.readFileSync(file, "utf8");
22544
22820
  const digest = sha256(bytes);
22545
- fs13.writeFileSync(path16.join(legacy, "tasks", name), bytes);
22821
+ fs14.writeFileSync(path17.join(legacy, "tasks", name), bytes);
22546
22822
  const parsed = this.parseRecord(bytes, taskRecordSchema, "2.x task");
22547
22823
  if (!parsed.ok || parsed.data.id !== id)
22548
22824
  return failure2("recovery_required", `cannot migrate 2.x task ${id}: ${parsed.ok ? "file name and record ID differ" : parsed.error}; move ${file} aside to continue`, { path: file });
22549
22825
  const record = { ...parsed.data, workspaceId: target.id };
22550
- const origin = { path: path16.join(legacy, "tasks", name), digest };
22551
- if (!fs13.existsSync(this.eventsPath(id))) {
22826
+ const origin = { path: path17.join(legacy, "tasks", name), digest };
22827
+ if (!fs14.existsSync(this.eventsPath(id))) {
22552
22828
  this.openTask(record, "migrated.from_v2", null, origin);
22553
22829
  migrated += 1;
22554
22830
  } else {
@@ -22583,13 +22859,13 @@ class TaskStore extends TaskReader {
22583
22859
  try {
22584
22860
  let complete = true;
22585
22861
  for (const [name, digest] of done) {
22586
- const file = path16.join(v2Tasks, name);
22587
- if (sha256(fs13.readFileSync(file, "utf8")) !== digest) {
22862
+ const file = path17.join(v2Tasks, name);
22863
+ if (sha256(fs14.readFileSync(file, "utf8")) !== digest) {
22588
22864
  complete = false;
22589
22865
  continue;
22590
22866
  }
22591
22867
  if (dirs.shared)
22592
- fs13.rmSync(file);
22868
+ fs14.rmSync(file);
22593
22869
  else
22594
22870
  replaceFile(file, this.stubFor(name.slice(0, -5)), false);
22595
22871
  }
@@ -22597,9 +22873,9 @@ class TaskStore extends TaskReader {
22597
22873
  return failure2("busy", `the 2.x store at ${v2} changed during migration; retry`, {
22598
22874
  path: v2
22599
22875
  });
22600
- fs13.rmSync(path16.join(v2, "index.json"), { force: true });
22876
+ fs14.rmSync(path17.join(v2, "index.json"), { force: true });
22601
22877
  if (dirs.shared)
22602
- fs13.rmSync(v2Workspace, { force: true });
22878
+ fs14.rmSync(v2Workspace, { force: true });
22603
22879
  else
22604
22880
  this.writeTombstone(v2, target.id);
22605
22881
  } catch (error) {
@@ -22622,49 +22898,49 @@ class TaskStore extends TaskReader {
22622
22898
  const dirs = this.paths();
22623
22899
  if (!dirs.shared)
22624
22900
  return success(null, null, null);
22625
- const present = () => CHECKOUT_LEFTOVERS.filter((name) => fs13.existsSync(path16.join(v2, name)));
22626
- const ignore = path16.join(v2, ".gitignore");
22901
+ const present = () => CHECKOUT_LEFTOVERS.filter((name) => fs14.existsSync(path17.join(v2, name)));
22902
+ const ignore = path17.join(v2, ".gitignore");
22627
22903
  const onlyGeneratedIgnore = () => {
22628
22904
  try {
22629
- return fs13.readdirSync(v2).length === 1 && GENERATED_GITIGNORES.has(fs13.readFileSync(ignore, "utf8"));
22905
+ return fs14.readdirSync(v2).length === 1 && GENERATED_GITIGNORES.has(fs14.readFileSync(ignore, "utf8"));
22630
22906
  } catch {
22631
22907
  return false;
22632
22908
  }
22633
22909
  };
22634
22910
  if (present().length === 0 && !onlyGeneratedIgnore())
22635
22911
  return success(null, null, null);
22636
- const backup = path16.join(dirs.dir, "legacy", checkoutSlug(path16.dirname(v2)), "v2");
22912
+ const backup = path17.join(dirs.dir, "legacy", checkoutSlug(path17.dirname(v2)), "v2");
22637
22913
  return this.withLock(dirs.checkoutLock, () => {
22638
22914
  let moved = 0;
22639
22915
  try {
22640
22916
  for (const name of present()) {
22641
- const entry = path16.join(v2, name);
22917
+ const entry = path17.join(v2, name);
22642
22918
  const marker = name === "workspace.json" ? isKnownMarker(entry, "workspace") : name === "store.moved.json" && isKnownMarker(entry, "moved");
22643
- const empty = fs13.lstatSync(entry).isDirectory() && fs13.readdirSync(entry).length === 0;
22919
+ const empty = fs14.lstatSync(entry).isDirectory() && fs14.readdirSync(entry).length === 0;
22644
22920
  if (marker || empty) {
22645
- fs13.rmSync(entry, { recursive: true });
22921
+ fs14.rmSync(entry, { recursive: true });
22646
22922
  continue;
22647
22923
  }
22648
- if (name === "tasks" && fs13.lstatSync(entry).isDirectory()) {
22649
- for (const task of fs13.readdirSync(entry)) {
22650
- const file = path16.join(entry, task);
22651
- if (fs13.lstatSync(file).isFile() && isKnownMarker(file, "stub"))
22652
- fs13.rmSync(file);
22924
+ if (name === "tasks" && fs14.lstatSync(entry).isDirectory()) {
22925
+ for (const task of fs14.readdirSync(entry)) {
22926
+ const file = path17.join(entry, task);
22927
+ if (fs14.lstatSync(file).isFile() && isKnownMarker(file, "stub"))
22928
+ fs14.rmSync(file);
22653
22929
  else {
22654
- moveInto(file, path16.join(backup, "tasks", task));
22930
+ moveInto(file, path17.join(backup, "tasks", task));
22655
22931
  moved += 1;
22656
22932
  }
22657
22933
  }
22658
- fs13.rmdirSync(entry);
22934
+ fs14.rmdirSync(entry);
22659
22935
  continue;
22660
22936
  }
22661
- moveInto(entry, path16.join(backup, name));
22937
+ moveInto(entry, path17.join(backup, name));
22662
22938
  moved += 1;
22663
22939
  }
22664
22940
  if (onlyGeneratedIgnore())
22665
- fs13.rmSync(ignore);
22666
- if (fs13.readdirSync(v2).length === 0)
22667
- fs13.rmdirSync(v2);
22941
+ fs14.rmSync(ignore);
22942
+ if (fs14.readdirSync(v2).length === 0)
22943
+ fs14.rmdirSync(v2);
22668
22944
  } catch (error) {
22669
22945
  return failure2("storage_error", `cannot clear ${v2}: ${String(error)}`, { path: v2 });
22670
22946
  }
@@ -22686,7 +22962,7 @@ class TaskStore extends TaskReader {
22686
22962
  }
22687
22963
  isStub(file) {
22688
22964
  try {
22689
- const value = JSON.parse(fs13.readFileSync(file, "utf8"));
22965
+ const value = JSON.parse(fs14.readFileSync(file, "utf8"));
22690
22966
  return isObject5(value) && isObject5(value.store) && value.store.format === "workit-store";
22691
22967
  } catch {
22692
22968
  return false;
@@ -22699,23 +22975,23 @@ var isUncertainWorker = (state) => UNCERTAIN_WORKER_STATES.includes(state);
22699
22975
  var workerBlocksTransition = (transition, state) => transition === "pause" ? false : isUncertainWorker(state);
22700
22976
 
22701
22977
  // packages/workit-core/src/core/task-evaluation.ts
22702
- import { createHash as createHash10 } from "node:crypto";
22703
- import * as fs16 from "node:fs";
22978
+ import { createHash as createHash11 } from "node:crypto";
22979
+ import * as fs17 from "node:fs";
22704
22980
  import { spawnSync as spawnSync15 } from "node:child_process";
22705
- import path21 from "node:path";
22981
+ import path22 from "node:path";
22706
22982
 
22707
22983
  // packages/workit-core/src/check-config.ts
22708
22984
  import { spawnSync as spawnSync11 } from "node:child_process";
22709
- import fs14 from "node:fs";
22710
- import path17 from "node:path";
22985
+ import fs15 from "node:fs";
22986
+ import path18 from "node:path";
22711
22987
  var SCRIPT_CHECKS = ["test", "lint", "typecheck", "check"];
22712
22988
  var SCRIPT_CHECK_ALIASES = { packaging: "test:packaging" };
22713
22989
  var CHECKS_FILE = ".workit/checks.json";
22714
22990
  var LEGACY_CHECKS_FILE = "workit.checks.json";
22715
22991
  function checksConfigFile(root) {
22716
- const current = path17.join(root, CHECKS_FILE);
22717
- const legacy = path17.join(root, LEGACY_CHECKS_FILE);
22718
- return !fs14.existsSync(current) && fs14.existsSync(legacy) ? legacy : current;
22992
+ const current = path18.join(root, CHECKS_FILE);
22993
+ const legacy = path18.join(root, LEGACY_CHECKS_FILE);
22994
+ return !fs15.existsSync(current) && fs15.existsSync(legacy) ? legacy : current;
22719
22995
  }
22720
22996
  var GENERATED_GITIGNORES2 = new Set([`*
22721
22997
  `, `*
@@ -22773,10 +23049,10 @@ var git3 = (cwd, args) => {
22773
23049
  return value || null;
22774
23050
  };
22775
23051
  function checkRoot(cwd) {
22776
- return path17.resolve(gitDirs(cwd)?.top ?? cwd);
23052
+ return path18.resolve(gitDirs(cwd)?.top ?? cwd);
22777
23053
  }
22778
23054
  var packageManager = (root) => {
22779
- const has = (file) => fs14.existsSync(path17.join(root, file));
23055
+ const has = (file) => fs15.existsSync(path18.join(root, file));
22780
23056
  if (has("bun.lock") || has("bun.lockb"))
22781
23057
  return "bun";
22782
23058
  if (has("pnpm-lock.yaml"))
@@ -22796,7 +23072,7 @@ var CHECK_NAME = /^[a-z0-9][a-z0-9:._-]{0,63}$/u;
22796
23072
  function detectedChecks(root) {
22797
23073
  const read = (file) => {
22798
23074
  try {
22799
- return fs14.readFileSync(path17.join(root, file), "utf8");
23075
+ return fs15.readFileSync(path18.join(root, file), "utf8");
22800
23076
  } catch {
22801
23077
  return null;
22802
23078
  }
@@ -22868,21 +23144,21 @@ function cleanupGlobs(value) {
22868
23144
  }
22869
23145
  function configFileFor(root) {
22870
23146
  const own = checksConfigFile(root);
22871
- if (fs14.existsSync(own))
23147
+ if (fs15.existsSync(own))
22872
23148
  return own;
22873
23149
  const common = git3(root, ["rev-parse", "--path-format=absolute", "--git-common-dir"]);
22874
- if (!common || path17.basename(common) !== ".git")
23150
+ if (!common || path18.basename(common) !== ".git")
22875
23151
  return own;
22876
- const main = path17.dirname(common);
22877
- if (path17.resolve(main) === path17.resolve(root))
23152
+ const main = path18.dirname(common);
23153
+ if (path18.resolve(main) === path18.resolve(root))
22878
23154
  return own;
22879
23155
  const shared = checksConfigFile(main);
22880
- return fs14.existsSync(shared) ? shared : own;
23156
+ return fs15.existsSync(shared) ? shared : own;
22881
23157
  }
22882
23158
  function loadCheckConfig(cwd) {
22883
23159
  const root = checkRoot(cwd);
22884
23160
  const file = configFileFor(root);
22885
- const legacy = path17.basename(file) === LEGACY_CHECKS_FILE;
23161
+ const legacy = path18.basename(file) === LEGACY_CHECKS_FILE;
22886
23162
  const label = legacy ? LEGACY_CHECKS_FILE : CHECKS_FILE;
22887
23163
  const note = legacy ? {
22888
23164
  note: `${LEGACY_CHECKS_FILE} is deprecated; move it to ${CHECKS_FILE} (workit doctor --fix)`
@@ -22898,7 +23174,7 @@ function loadCheckConfig(cwd) {
22898
23174
  });
22899
23175
  let text = null;
22900
23176
  try {
22901
- text = fs14.readFileSync(file, "utf8");
23177
+ text = fs15.readFileSync(file, "utf8");
22902
23178
  } catch (error) {
22903
23179
  if (error.code !== "ENOENT")
22904
23180
  return none(`cannot read ${label}: ${error.message}`);
@@ -23013,10 +23289,10 @@ function workitAvailable(env = process.env) {
23013
23289
  return workitOnPath;
23014
23290
  const windows = process.platform === "win32";
23015
23291
  const exts = windows ? (env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean) : [""];
23016
- const dirs = (env.PATH ?? env.Path ?? "").split(path17.delimiter).filter(Boolean);
23292
+ const dirs = (env.PATH ?? env.Path ?? "").split(path18.delimiter).filter(Boolean);
23017
23293
  workitOnPath = dirs.some((dir) => exts.some((ext) => {
23018
23294
  try {
23019
- return fs14.statSync(path17.join(dir, `workit${ext}`)).isFile();
23295
+ return fs15.statSync(path18.join(dir, `workit${ext}`)).isFile();
23020
23296
  } catch {
23021
23297
  return false;
23022
23298
  }
@@ -23076,14 +23352,14 @@ var PM_RUN = new Set(["run", "run-script"]);
23076
23352
  var PYTHON_RUNNERS = new Set(["uv", "poetry", "pipenv", "pdm", "hatch", "rye"]);
23077
23353
 
23078
23354
  // packages/workit-core/src/core/policy/derive.ts
23079
- import { existsSync as existsSync8 } from "node:fs";
23080
- import path20 from "node:path";
23355
+ import { existsSync as existsSync9 } from "node:fs";
23356
+ import path21 from "node:path";
23081
23357
 
23082
23358
  // packages/workit-core/src/ledger.ts
23083
23359
  import { spawnSync as spawnSync14 } from "node:child_process";
23084
- import { createHash as createHash9, randomBytes as randomBytes3 } from "node:crypto";
23085
- import fs15 from "node:fs";
23086
- import path19 from "node:path";
23360
+ import { createHash as createHash10, randomBytes as randomBytes3 } from "node:crypto";
23361
+ import fs16 from "node:fs";
23362
+ import path20 from "node:path";
23087
23363
 
23088
23364
  // packages/workit-core/src/core/policy/bookkeeping.ts
23089
23365
  import { spawnSync as spawnSync12 } from "node:child_process";
@@ -23163,8 +23439,8 @@ function bookkeepingPaths(cwd, input) {
23163
23439
  }
23164
23440
 
23165
23441
  // packages/workit-core/src/core/policy/lane.ts
23166
- import { existsSync as existsSync7, readFileSync as readFileSync7 } from "node:fs";
23167
- import path18 from "node:path";
23442
+ import { existsSync as existsSync8, readFileSync as readFileSync7 } from "node:fs";
23443
+ import path19 from "node:path";
23168
23444
 
23169
23445
  // packages/workit-core/src/git/default-base.ts
23170
23446
  import { spawnSync as spawnSync13 } from "node:child_process";
@@ -24552,7 +24828,7 @@ function computeLane(input) {
24552
24828
  }
24553
24829
  function untrackedStat(cwd, file) {
24554
24830
  try {
24555
- const bytes = readFileSync7(path18.join(cwd, file));
24831
+ const bytes = readFileSync7(path19.join(cwd, file));
24556
24832
  if (bytes.includes(0))
24557
24833
  return { path: file, added: 0, deleted: 0, binary: true };
24558
24834
  const text = bytes.toString("utf8");
@@ -24584,7 +24860,7 @@ function cosmeticFiles(cwd, fork, head) {
24584
24860
  let after = blobs.get(entry.newBlob);
24585
24861
  if (!after && head === null && ABSENT.test(entry.newBlob))
24586
24862
  try {
24587
- after = readFileSync7(path18.join(cwd, entry.path));
24863
+ after = readFileSync7(path19.join(cwd, entry.path));
24588
24864
  } catch {
24589
24865
  after = undefined;
24590
24866
  }
@@ -24803,7 +25079,7 @@ var binaryRangeDiff = (cwd, base, head) => {
24803
25079
  return diff.ok && diff.stdout ? diff.stdout : null;
24804
25080
  };
24805
25081
  var hashOfDiff = (diff) => {
24806
- const hash = createHash9("sha256");
25082
+ const hash = createHash10("sha256");
24807
25083
  for (const line of diff.split(`
24808
25084
  `)) {
24809
25085
  if (line.startsWith("index "))
@@ -24836,14 +25112,14 @@ function cleanRebase(cwd, range) {
24836
25112
  return Boolean(tree) && tree === git4(cwd, ["rev-parse", "--verify", "-q", `${range.to}^{tree}`]);
24837
25113
  }
24838
25114
  function storeRoot(cwd) {
24839
- const location = resolveStore(path19.resolve(cwd));
25115
+ const location = resolveStore(path20.resolve(cwd));
24840
25116
  if (location instanceof Error)
24841
25117
  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");
24842
25118
  return { ok: true, value: { root: location.dir, shared: location.shared } };
24843
25119
  }
24844
25120
  function ledgerPath(cwd) {
24845
25121
  const root = storeRoot(cwd);
24846
- return root.ok ? { ok: true, value: path19.join(root.value.root, "ledger", "ledger.jsonl") } : root;
25122
+ return root.ok ? { ok: true, value: path20.join(root.value.root, "ledger", "ledger.jsonl") } : root;
24847
25123
  }
24848
25124
  var newId2 = () => `${Date.now().toString(36)}-${randomBytes3(6).toString("hex")}`;
24849
25125
  var NETWORK_FS_TYPES = new Set([
@@ -24863,25 +25139,25 @@ var onNetworkFs = (dir) => {
24863
25139
  if (process.platform !== "linux")
24864
25140
  return false;
24865
25141
  try {
24866
- return isNetworkFsType(fs15.statfsSync(dir).type);
25142
+ return isNetworkFsType(fs16.statfsSync(dir).type);
24867
25143
  } catch {
24868
25144
  return false;
24869
25145
  }
24870
25146
  };
24871
- var LOCK_WAIT_MS = 5000;
24872
- var LOCK_STALE_MS = 30000;
25147
+ var LOCK_WAIT_MS2 = 5000;
25148
+ var LOCK_STALE_MS2 = 30000;
24873
25149
  var LOCK_OWNER = "owner";
24874
25150
  var lockToken = (lock) => {
24875
25151
  try {
24876
- return fs15.readFileSync(path19.join(lock, LOCK_OWNER), "utf8");
25152
+ return fs16.readFileSync(path20.join(lock, LOCK_OWNER), "utf8");
24877
25153
  } catch {
24878
25154
  return null;
24879
25155
  }
24880
25156
  };
24881
25157
  var lockAgeMs = (lock) => {
24882
- for (const target of [path19.join(lock, LOCK_OWNER), lock]) {
25158
+ for (const target of [path20.join(lock, LOCK_OWNER), lock]) {
24883
25159
  try {
24884
- return Date.now() - fs15.statSync(target).mtimeMs;
25160
+ return Date.now() - fs16.statSync(target).mtimeMs;
24885
25161
  } catch {}
24886
25162
  }
24887
25163
  return null;
@@ -24889,14 +25165,14 @@ var lockAgeMs = (lock) => {
24889
25165
  var ledgerLock = {
24890
25166
  acquire(lock) {
24891
25167
  try {
24892
- fs15.mkdirSync(lock);
25168
+ fs16.mkdirSync(lock);
24893
25169
  } catch (error) {
24894
25170
  if (error.code === "EEXIST")
24895
25171
  return null;
24896
25172
  throw error;
24897
25173
  }
24898
25174
  const token = `${process.pid}-${randomBytes3(8).toString("hex")}`;
24899
- fs15.writeFileSync(path19.join(lock, LOCK_OWNER), token);
25175
+ fs16.writeFileSync(path20.join(lock, LOCK_OWNER), token);
24900
25176
  return token;
24901
25177
  },
24902
25178
  release(lock, token) {
@@ -24904,40 +25180,40 @@ var ledgerLock = {
24904
25180
  return false;
24905
25181
  const tomb = `${lock}.release-${randomBytes3(6).toString("hex")}`;
24906
25182
  try {
24907
- fs15.renameSync(lock, tomb);
25183
+ fs16.renameSync(lock, tomb);
24908
25184
  } catch {
24909
25185
  return false;
24910
25186
  }
24911
25187
  if (lockToken(tomb) !== token) {
24912
25188
  try {
24913
- fs15.renameSync(tomb, lock);
25189
+ fs16.renameSync(tomb, lock);
24914
25190
  } catch {}
24915
25191
  return false;
24916
25192
  }
24917
- fs15.rmSync(tomb, { recursive: true, force: true });
25193
+ fs16.rmSync(tomb, { recursive: true, force: true });
24918
25194
  return true;
24919
25195
  },
24920
25196
  token: lockToken,
24921
25197
  reap(lock, observed) {
24922
25198
  const tomb = `${lock}.reap-${randomBytes3(6).toString("hex")}`;
24923
25199
  try {
24924
- fs15.renameSync(lock, tomb);
25200
+ fs16.renameSync(lock, tomb);
24925
25201
  } catch {
24926
25202
  return false;
24927
25203
  }
24928
25204
  if (lockToken(tomb) === observed) {
24929
- fs15.rmSync(tomb, { recursive: true, force: true });
25205
+ fs16.rmSync(tomb, { recursive: true, force: true });
24930
25206
  return true;
24931
25207
  }
24932
25208
  try {
24933
- fs15.renameSync(tomb, lock);
25209
+ fs16.renameSync(tomb, lock);
24934
25210
  } catch {
24935
- fs15.rmSync(tomb, { recursive: true, force: true });
25211
+ fs16.rmSync(tomb, { recursive: true, force: true });
24936
25212
  }
24937
25213
  return false;
24938
25214
  }
24939
25215
  };
24940
- function withLedgerLock(file, fn, waitMs = hostAwareLockTimeout(LOCK_WAIT_MS)) {
25216
+ function withLedgerLock(file, fn, waitMs = hostAwareLockTimeout(LOCK_WAIT_MS2)) {
24941
25217
  const lock = `${file}.lock`;
24942
25218
  const deadline = Date.now() + waitMs;
24943
25219
  let token = null;
@@ -24947,7 +25223,7 @@ function withLedgerLock(file, fn, waitMs = hostAwareLockTimeout(LOCK_WAIT_MS)) {
24947
25223
  break;
24948
25224
  const observed = lockToken(lock);
24949
25225
  const age = lockAgeMs(lock);
24950
- if (age !== null && age > LOCK_STALE_MS && ledgerLock.reap(lock, observed))
25226
+ if (age !== null && age > LOCK_STALE_MS2 && ledgerLock.reap(lock, observed))
24951
25227
  continue;
24952
25228
  if (Date.now() >= deadline)
24953
25229
  return null;
@@ -24959,14 +25235,14 @@ function withLedgerLock(file, fn, waitMs = hostAwareLockTimeout(LOCK_WAIT_MS)) {
24959
25235
  ledgerLock.release(lock, token);
24960
25236
  }
24961
25237
  }
24962
- var sha2562 = (text) => createHash9("sha256").update(text).digest("hex");
25238
+ var sha2562 = (text) => createHash10("sha256").update(text).digest("hex");
24963
25239
  var chainHash = (prevHash, body) => sha2562(`${prevHash ?? ""}
24964
25240
  ${body}`);
24965
25241
  var TAIL_BYTES = 64 * 1024;
24966
25242
  var lastLine = (fd, size) => {
24967
25243
  for (let span = Math.min(size, TAIL_BYTES);span > 0; span = Math.min(size, span * 2)) {
24968
25244
  const buffer = Buffer.alloc(span);
24969
- fs15.readSync(fd, buffer, 0, span, size - span);
25245
+ fs16.readSync(fd, buffer, 0, span, size - span);
24970
25246
  const end = buffer.lastIndexOf(10);
24971
25247
  if (end < 0) {
24972
25248
  if (span === size)
@@ -24997,32 +25273,32 @@ var lastLine = (fd, size) => {
24997
25273
  };
24998
25274
  var tighten = (fd) => {
24999
25275
  try {
25000
- if ((fs15.fstatSync(fd).mode & 63) !== 0)
25001
- fs15.fchmodSync(fd, 384);
25276
+ if ((fs16.fstatSync(fd).mode & 63) !== 0)
25277
+ fs16.fchmodSync(fd, 384);
25002
25278
  } catch {}
25003
25279
  };
25004
25280
  function appendLine(file, build, options) {
25005
25281
  const write = () => {
25006
- const fd = fs15.openSync(file, "a+", 384);
25282
+ const fd = fs16.openSync(file, "a+", 384);
25007
25283
  try {
25008
25284
  if (process.platform !== "win32")
25009
25285
  tighten(fd);
25010
- const line = build(lastLine(fd, fs15.fstatSync(fd).size));
25286
+ const line = build(lastLine(fd, fs16.fstatSync(fd).size));
25011
25287
  if (!line.ok)
25012
25288
  return line;
25013
25289
  const bytes = Buffer.from(`
25014
25290
  ${line.value}`);
25015
- const written = fs15.writeSync(fd, bytes);
25291
+ const written = fs16.writeSync(fd, bytes);
25016
25292
  if (written !== bytes.length)
25017
25293
  return err("unavailable", `short write to ${file}: ${written} of ${bytes.length} bytes; the row is torn and will be skipped`);
25018
25294
  return { ok: true, value: undefined };
25019
25295
  } finally {
25020
- fs15.closeSync(fd);
25296
+ fs16.closeSync(fd);
25021
25297
  }
25022
25298
  };
25023
25299
  try {
25024
- fs15.mkdirSync(path19.dirname(file), { recursive: true });
25025
- if (options.heldLock || !options.forceLock && !onNetworkFs(path19.dirname(file)))
25300
+ fs16.mkdirSync(path20.dirname(file), { recursive: true });
25301
+ if (options.heldLock || !options.forceLock && !onNetworkFs(path20.dirname(file)))
25026
25302
  return write();
25027
25303
  const locked = withLedgerLock(file, write);
25028
25304
  return locked ?? err("busy", `ledger lock ${file}.lock is held`, "retry; remove the .lock directory if no workit process is running");
@@ -25039,7 +25315,7 @@ var sealed = (row, id, at, previous) => {
25039
25315
  ` };
25040
25316
  };
25041
25317
  function appendRaw(cwd, row, options) {
25042
- const file = options.store ? { ok: true, value: path19.join(options.store.root, "ledger", "ledger.jsonl") } : ledgerPath(cwd);
25318
+ const file = options.store ? { ok: true, value: path20.join(options.store.root, "ledger", "ledger.jsonl") } : ledgerPath(cwd);
25043
25319
  if (!file.ok)
25044
25320
  return file;
25045
25321
  const id = newId2();
@@ -25093,8 +25369,8 @@ function readLedgerAt(cwd, file, options) {
25093
25369
  let text = "";
25094
25370
  let stat = null;
25095
25371
  try {
25096
- stat = fs15.statSync(file);
25097
- text = fs15.readFileSync(file, "utf8");
25372
+ stat = fs16.statSync(file);
25373
+ text = fs16.readFileSync(file, "utf8");
25098
25374
  } catch (error) {
25099
25375
  if (error.code === "ENOENT")
25100
25376
  return {
@@ -25234,7 +25510,7 @@ function ledgerTampering(cwd) {
25234
25510
  if (!file.ok)
25235
25511
  return [];
25236
25512
  try {
25237
- const stat = fs15.statSync(file.value);
25513
+ const stat = fs16.statSync(file.value);
25238
25514
  const cached = tamperCache.get(file.value);
25239
25515
  if (cached && cached.size === stat.size && cached.stamp === fileStamp(stat))
25240
25516
  return cached.breaks;
@@ -25701,8 +25977,8 @@ function remoteIdentity(cwd, hop = 0) {
25701
25977
  return null;
25702
25978
  if (hop === 0 && !/^[\w+.-]+:\/\/|^[^/\\]+@[^/\\]+:/u.test(raw)) {
25703
25979
  const local = raw.replace(/^file:\/\//u, "");
25704
- const resolved = path19.isAbsolute(local) ? local : path19.resolve(cwd, local);
25705
- if (fs15.existsSync(resolved))
25980
+ const resolved = path20.isAbsolute(local) ? local : path20.resolve(cwd, local);
25981
+ if (fs16.existsSync(resolved))
25706
25982
  return remoteIdentity(resolved, 1);
25707
25983
  }
25708
25984
  const parsed = parseRemoteUrl(raw);
@@ -25722,8 +25998,8 @@ function verdictMirrorPath(cwd) {
25722
25998
  }
25723
25999
  if (!identity)
25724
26000
  return null;
25725
- const key = createHash9("sha256").update(identity).digest("hex").slice(0, 32);
25726
- return path19.join(resolveStateDir(), "verdicts", key, "ledger.jsonl");
26001
+ const key = createHash10("sha256").update(identity).digest("hex").slice(0, 32);
26002
+ return path20.join(resolveStateDir(), "verdicts", key, "ledger.jsonl");
25727
26003
  }
25728
26004
  var importedStamp = new Map;
25729
26005
  function importMirroredVerdicts(cwd, branch) {
@@ -25733,7 +26009,7 @@ function importMirroredVerdicts(cwd, branch) {
25733
26009
  return [];
25734
26010
  let stamp;
25735
26011
  try {
25736
- stamp = `${branch}\x00${fileStamp(fs15.statSync(file))}`;
26012
+ stamp = `${branch}\x00${fileStamp(fs16.statSync(file))}`;
25737
26013
  } catch {
25738
26014
  return [];
25739
26015
  }
@@ -25746,7 +26022,7 @@ function importMirroredVerdicts(cwd, branch) {
25746
26022
  const candidates = mirror.value.rows.filter((row) => (row.type === "verdict" || row.type === VOID_TYPE) && row.branch === branch && row.integrity === "verified");
25747
26023
  const added = new Set;
25748
26024
  try {
25749
- fs15.mkdirSync(path19.dirname(local.value), { recursive: true });
26025
+ fs16.mkdirSync(path20.dirname(local.value), { recursive: true });
25750
26026
  } catch {
25751
26027
  return [];
25752
26028
  }
@@ -25950,7 +26226,7 @@ var productDecision = (task, ledger) => {
25950
26226
  };
25951
26227
  };
25952
26228
  var planRecorded = (task, root) => {
25953
- const cited = (latestJudgment(task)?.refs ?? []).find((ref) => ref.kind === "external" || ref.kind === "file" && existsSync8(path20.resolve(root, ref.path)));
26229
+ const cited = (latestJudgment(task)?.refs ?? []).find((ref) => ref.kind === "external" || ref.kind === "file" && existsSync9(path21.resolve(root, ref.path)));
25954
26230
  if (cited)
25955
26231
  return {
25956
26232
  met: true,
@@ -26016,15 +26292,15 @@ function derivedRuleStatus(task, requirement, root, ledger) {
26016
26292
  }
26017
26293
 
26018
26294
  // packages/workit-core/src/core/task-evaluation.ts
26019
- var digestBytes = (value) => createHash10("sha256").update(value).digest("hex");
26020
- var inside = (root, candidate) => candidate === root || candidate.startsWith(`${root}${path21.sep}`);
26021
- var relative = (root, candidate) => path21.relative(root, candidate).split(path21.sep).join("/") || ".";
26295
+ var digestBytes = (value) => createHash11("sha256").update(value).digest("hex");
26296
+ var inside = (root, candidate) => candidate === root || candidate.startsWith(`${root}${path22.sep}`);
26297
+ var relative = (root, candidate) => path22.relative(root, candidate).split(path22.sep).join("/") || ".";
26022
26298
  var canonicalPath = (value) => {
26023
26299
  if (typeof value !== "string" || !value)
26024
26300
  return null;
26025
26301
  if (value.includes("\\") || value.split("/").includes(".."))
26026
26302
  return null;
26027
- const normalized = path21.posix.normalize(value);
26303
+ const normalized = path22.posix.normalize(value);
26028
26304
  if (normalized === ".." || normalized.startsWith("../") || normalized.startsWith("/"))
26029
26305
  return null;
26030
26306
  return normalized === "." ? "." : normalized.replace(/\/$/, "");
@@ -26072,21 +26348,21 @@ var gitPaths = (root) => {
26072
26348
  git: !/not a git repository/i.test(stderr)
26073
26349
  };
26074
26350
  }
26075
- const paths = result.stdout ? result.stdout.toString("utf8").split("\x00").filter(Boolean).map((item) => item.split(path21.sep).join("/")) : [];
26351
+ const paths = result.stdout ? result.stdout.toString("utf8").split("\x00").filter(Boolean).map((item) => item.split(path22.sep).join("/")) : [];
26076
26352
  const stagedDeleted = spawnSync15("git", ["diff", "--cached", "--name-only", "--diff-filter=D", "-z"], { cwd: root, encoding: "buffer" });
26077
26353
  if (stagedDeleted.status !== 0) {
26078
26354
  const stderr = stagedDeleted.stderr?.toString("utf8") ?? "";
26079
26355
  if (!/not a git repository/i.test(stderr))
26080
26356
  return { paths, uncertain: true, git: true };
26081
26357
  } else if (stagedDeleted.stdout) {
26082
- paths.push(...stagedDeleted.stdout.toString("utf8").split("\x00").filter(Boolean).map((item) => item.split(path21.sep).join("/")));
26358
+ paths.push(...stagedDeleted.stdout.toString("utf8").split("\x00").filter(Boolean).map((item) => item.split(path22.sep).join("/")));
26083
26359
  }
26084
26360
  return { paths: [...new Set(paths)], uncertain: false, git: true };
26085
26361
  };
26086
26362
  var walk = (root, directory, output) => {
26087
26363
  let names;
26088
26364
  try {
26089
- names = fs16.readdirSync(directory);
26365
+ names = fs17.readdirSync(directory);
26090
26366
  } catch {
26091
26367
  return true;
26092
26368
  }
@@ -26094,10 +26370,10 @@ var walk = (root, directory, output) => {
26094
26370
  for (const name of names) {
26095
26371
  if (name === ".git" || name === ".workit")
26096
26372
  continue;
26097
- const target = path21.join(directory, name);
26373
+ const target = path22.join(directory, name);
26098
26374
  let stat;
26099
26375
  try {
26100
- stat = fs16.lstatSync(target);
26376
+ stat = fs17.lstatSync(target);
26101
26377
  } catch {
26102
26378
  uncertain = true;
26103
26379
  continue;
@@ -26112,14 +26388,14 @@ var walk = (root, directory, output) => {
26112
26388
  var scopeRoots = (root, scope) => {
26113
26389
  const roots = [];
26114
26390
  for (const item of scope.paths.length ? scope.paths : ["."]) {
26115
- const target = path21.resolve(root, item);
26391
+ const target = path22.resolve(root, item);
26116
26392
  if (!inside(root, target))
26117
26393
  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` }] });
26118
26394
  let ancestor = target;
26119
- while (!fs16.existsSync(ancestor) && ancestor !== root)
26120
- ancestor = path21.dirname(ancestor);
26395
+ while (!fs17.existsSync(ancestor) && ancestor !== root)
26396
+ ancestor = path22.dirname(ancestor);
26121
26397
  try {
26122
- if (!inside(root, fs16.realpathSync(ancestor)))
26398
+ if (!inside(root, fs17.realpathSync(ancestor)))
26123
26399
  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` }] });
26124
26400
  } catch {
26125
26401
  return failure2("invalid_input", `candidate scope cannot be inspected: ${item}`);
@@ -26131,7 +26407,7 @@ var scopeRoots = (root, scope) => {
26131
26407
  function captureCandidate(root, scope, environment = []) {
26132
26408
  let checkout;
26133
26409
  try {
26134
- checkout = fs16.realpathSync(root);
26410
+ checkout = fs17.realpathSync(root);
26135
26411
  } catch {
26136
26412
  return failure2("invalid_input", "candidate root does not exist");
26137
26413
  }
@@ -26149,11 +26425,11 @@ function captureCandidate(root, scope, environment = []) {
26149
26425
  if (item === ".git" || item === ".workit")
26150
26426
  continue;
26151
26427
  names.add(item);
26152
- if (!fs16.existsSync(target))
26428
+ if (!fs17.existsSync(target))
26153
26429
  continue;
26154
26430
  let stat;
26155
26431
  try {
26156
- stat = fs16.lstatSync(target);
26432
+ stat = fs17.lstatSync(target);
26157
26433
  } catch {
26158
26434
  uncertain = true;
26159
26435
  continue;
@@ -26169,17 +26445,17 @@ function captureCandidate(root, scope, environment = []) {
26169
26445
  for (const item of [...names].toSorted()) {
26170
26446
  if (!scopeMatches(item, normalizedScope))
26171
26447
  continue;
26172
- const target = path21.join(checkout, item);
26448
+ const target = path22.join(checkout, item);
26173
26449
  try {
26174
- const stat = fs16.lstatSync(target);
26450
+ const stat = fs17.lstatSync(target);
26175
26451
  if (stat.isSymbolicLink()) {
26176
- const link = fs16.readlinkSync(target);
26452
+ const link = fs17.readlinkSync(target);
26177
26453
  files.push({ path: item, kind: "symlink", digest: digestBytes(link), executable: null });
26178
26454
  } else if (stat.isFile()) {
26179
26455
  files.push({
26180
26456
  path: item,
26181
26457
  kind: "file",
26182
- digest: digestBytes(fs16.readFileSync(target)),
26458
+ digest: digestBytes(fs17.readFileSync(target)),
26183
26459
  executable: (stat.mode & 73) !== 0
26184
26460
  });
26185
26461
  } else if (!stat.isDirectory()) {
@@ -26344,7 +26620,7 @@ var findingVerificationPasses = (findingCandidateId, evidence) => evidence.statu
26344
26620
  var verifyDecisionContentAtRoot = (checkoutRoot, binding) => {
26345
26621
  let root;
26346
26622
  try {
26347
- root = fs16.realpathSync(checkoutRoot);
26623
+ root = fs17.realpathSync(checkoutRoot);
26348
26624
  } catch {
26349
26625
  return failure2("permission_denied", "checkout root is unavailable");
26350
26626
  }
@@ -26353,23 +26629,23 @@ var verifyDecisionContentAtRoot = (checkoutRoot, binding) => {
26353
26629
  continue;
26354
26630
  if (!reference.digest)
26355
26631
  return failure2("invalid_input", "document references require a byte digest");
26356
- const target = path21.resolve(root, reference.path);
26357
- if (target !== root && !target.startsWith(`${root}${path21.sep}`))
26632
+ const target = path22.resolve(root, reference.path);
26633
+ if (target !== root && !target.startsWith(`${root}${path22.sep}`))
26358
26634
  return failure2("invalid_input", "document reference escapes checkout; cite it as an external file:// reference instead", {
26359
26635
  fields: [
26360
26636
  { path: "contentRefs.path", reason: `${reference.path} is outside the checkout` }
26361
26637
  ]
26362
26638
  });
26363
26639
  try {
26364
- const below = path21.relative(root, target);
26640
+ const below = path22.relative(root, target);
26365
26641
  let current = root;
26366
- for (const segment of below.split(path21.sep)) {
26642
+ for (const segment of below.split(path22.sep)) {
26367
26643
  if (!segment)
26368
26644
  continue;
26369
- current = path21.join(current, segment);
26370
- const stat = fs16.lstatSync(current);
26371
- const real = fs16.realpathSync(current);
26372
- if (real !== root && !real.startsWith(`${root}${path21.sep}`))
26645
+ current = path22.join(current, segment);
26646
+ const stat = fs17.lstatSync(current);
26647
+ const real = fs17.realpathSync(current);
26648
+ if (real !== root && !real.startsWith(`${root}${path22.sep}`))
26373
26649
  return failure2("invalid_input", "document reference escapes checkout; cite it as an external file:// reference instead", {
26374
26650
  fields: [
26375
26651
  {
@@ -26385,7 +26661,7 @@ var verifyDecisionContentAtRoot = (checkoutRoot, binding) => {
26385
26661
  if (current !== target && !stat.isDirectory())
26386
26662
  return failure2("invalid_input", "document reference ancestor is not a directory");
26387
26663
  }
26388
- if (digestBytes(fs16.readFileSync(target)) !== reference.digest)
26664
+ if (digestBytes(fs17.readFileSync(target)) !== reference.digest)
26389
26665
  return failure2("permission_denied", "decision document bytes have changed");
26390
26666
  } catch {
26391
26667
  return failure2("invalid_input", "decision document is unavailable");
@@ -27043,26 +27319,26 @@ var exportDigest = (bundle) => sha256({
27043
27319
  task: bundle.task
27044
27320
  });
27045
27321
  // packages/workit-core/src/autonomy.ts
27046
- import { closeSync as closeSync2, copyFileSync as copyFileSync2, existsSync as existsSync11, openSync as openSync2 } from "node:fs";
27047
- import path25 from "node:path";
27322
+ import { closeSync as closeSync2, copyFileSync as copyFileSync2, existsSync as existsSync12, openSync as openSync2 } from "node:fs";
27323
+ import path26 from "node:path";
27048
27324
 
27049
27325
  // packages/workit-core/src/core/eval-world.ts
27050
- import { existsSync as existsSync10, realpathSync as realpathSync6 } from "node:fs";
27051
- import os5 from "node:os";
27052
- import path22 from "node:path";
27326
+ import { existsSync as existsSync11, realpathSync as realpathSync7 } from "node:fs";
27327
+ import os6 from "node:os";
27328
+ import path23 from "node:path";
27053
27329
  var EVAL_WORLD_ENV = "WORKIT_EVAL_WORLD";
27054
27330
  var EVAL_WORLD_MARKER = ".workit-eval-world";
27055
27331
  var inside2 = (dir, file) => {
27056
- const rel = path22.relative(dir, file);
27057
- return !rel.startsWith("..") && !path22.isAbsolute(rel);
27332
+ const rel = path23.relative(dir, file);
27333
+ return !rel.startsWith("..") && !path23.isAbsolute(rel);
27058
27334
  };
27059
27335
  var evalWorld = (cwd) => {
27060
27336
  const raw = process.env[EVAL_WORLD_ENV];
27061
- if (!raw || !path22.isAbsolute(raw))
27337
+ if (!raw || !path23.isAbsolute(raw))
27062
27338
  return null;
27063
27339
  try {
27064
- const world = realpathSync6(raw);
27065
- return inside2(realpathSync6(os5.tmpdir()), world) && inside2(world, realpathSync6(cwd)) && existsSync10(path22.join(world, EVAL_WORLD_MARKER)) ? world : null;
27340
+ const world = realpathSync7(raw);
27341
+ return inside2(realpathSync7(os6.tmpdir()), world) && inside2(world, realpathSync7(cwd)) && existsSync11(path23.join(world, EVAL_WORLD_MARKER)) ? world : null;
27066
27342
  } catch {
27067
27343
  return null;
27068
27344
  }
@@ -27070,16 +27346,16 @@ var evalWorld = (cwd) => {
27070
27346
  var evalWorldEntry = (cwd) => {
27071
27347
  const world = evalWorld(cwd);
27072
27348
  try {
27073
- return world ? loadWorkspacesFrom(path22.join(world, "config"))[0] ?? null : null;
27349
+ return world ? loadWorkspacesFrom(path23.join(world, "config"))[0] ?? null : null;
27074
27350
  } catch {
27075
27351
  return null;
27076
27352
  }
27077
27353
  };
27078
27354
 
27079
27355
  // packages/workit-core/src/core/grant-seal.ts
27080
- import { createHash as createHash11 } from "node:crypto";
27356
+ import { createHash as createHash12 } from "node:crypto";
27081
27357
  import { readFileSync as readFileSync9 } from "node:fs";
27082
- import path23 from "node:path";
27358
+ import path24 from "node:path";
27083
27359
  var SEAL_FILE = "workspaces.json.seal";
27084
27360
  var SEAL_VERSION = 1;
27085
27361
  var SEAL_COMMAND = "workit workspace seal";
@@ -27113,15 +27389,15 @@ var sealProjection = (entries) => entries.map((entry) => {
27113
27389
  youtrack: pick2(all.youtrack, ["writes", "autoHosts"])
27114
27390
  }, ENTRY_KEYS);
27115
27391
  });
27116
- 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);
27117
- var sealDigest = (projection) => createHash11("sha256").update(canonical3(projection)).digest("hex");
27392
+ 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);
27393
+ var sealDigest = (projection) => createHash12("sha256").update(canonical4(projection)).digest("hex");
27118
27394
  var broken = (reason, sealed = null) => ({
27119
27395
  state: "broken",
27120
27396
  reason,
27121
27397
  sealed
27122
27398
  });
27123
27399
  function checkSeal(dir) {
27124
- const file = path23.join(dir, SEAL_FILE);
27400
+ const file = path24.join(dir, SEAL_FILE);
27125
27401
  let seal;
27126
27402
  try {
27127
27403
  seal = JSON.parse(readFileSync9(file, "utf8"));
@@ -27144,8 +27420,8 @@ function checkSeal(dir) {
27144
27420
  import { spawnSync as spawnSync16 } from "node:child_process";
27145
27421
 
27146
27422
  // packages/workit-core/src/forge/exec.ts
27147
- import fs17 from "node:fs";
27148
- import path24 from "node:path";
27423
+ import fs18 from "node:fs";
27424
+ import path25 from "node:path";
27149
27425
 
27150
27426
  // packages/workit-core/src/forge/redact.ts
27151
27427
  var NAME = "[A-Za-z0-9_.-]";
@@ -27158,13 +27434,13 @@ var ANSI = new RegExp(String.raw`\u001b\[[0-9;?]*[ -/]*[@-~]|\u001b\][^\u0007\u0
27158
27434
  // packages/workit-core/src/forge/exec.ts
27159
27435
  var MAX_BUFFER2 = 64 * 1024 * 1024;
27160
27436
  function findExecutable(bin, env) {
27161
- const dirs = (env.PATH ?? env.Path ?? "").split(path24.delimiter).filter(Boolean);
27437
+ const dirs = (env.PATH ?? env.Path ?? "").split(path25.delimiter).filter(Boolean);
27162
27438
  const exts = process.platform === "win32" ? [".exe"] : [""];
27163
27439
  for (const dir of dirs)
27164
27440
  for (const ext of exts) {
27165
- const candidate = path24.join(dir, `${bin}${ext}`);
27441
+ const candidate = path25.join(dir, `${bin}${ext}`);
27166
27442
  try {
27167
- const stat = fs17.statSync(candidate);
27443
+ const stat = fs18.statSync(candidate);
27168
27444
  if (stat.isFile())
27169
27445
  return candidate;
27170
27446
  } catch {}
@@ -27219,7 +27495,7 @@ var accountHomeDir = () => {
27219
27495
  };
27220
27496
  var deniedFile = (dir) => {
27221
27497
  for (const name of ["workspaces.json", SEAL_FILE]) {
27222
- const file = path25.join(dir, name);
27498
+ const file = path26.join(dir, name);
27223
27499
  try {
27224
27500
  closeSync2(openSync2(file, "r"));
27225
27501
  } catch (error) {
@@ -27241,7 +27517,7 @@ var accountUnread = () => {
27241
27517
  if (dir === null)
27242
27518
  return NO_ACCOUNT;
27243
27519
  const file = deniedFile(dir);
27244
- return file === null ? null : `the account's ${path25.basename(file)} cannot be read (permission denied), so it reads as no workspace entries: no grants, no models, the D4 defaults apply`;
27520
+ return file === null ? null : `the account's ${path26.basename(file)} cannot be read (permission denied), so it reads as no workspace entries: no grants, no models, the D4 defaults apply`;
27245
27521
  };
27246
27522
  var entriesIn = (dir) => dir === null ? [] : loadWorkspacesFrom(dir);
27247
27523
  var fileSource = (dir = accountDir()) => ({
@@ -27262,7 +27538,7 @@ var NO_SEAL_NOTE = `workspaces.json has no seal yet (${SEAL_COMMAND} has never r
27262
27538
  var sealNote = (seal = sealOf()) => seal.state === "broken" ? `workspaces.json does not match its seal (${seal.reason}), so grants, endpoint, verification and youtrack.writes are the stricter of their current and last sealed values; ${SEAL_UNBLOCK}` : null;
27263
27539
  var shownGrantsDir = () => {
27264
27540
  const world = evalWorld(process.cwd());
27265
- return world ? path25.join(world, "config") : accountDir();
27541
+ return world ? path26.join(world, "config") : accountDir();
27266
27542
  };
27267
27543
  var benchWorld = (cwd) => {
27268
27544
  const entry = evalWorldEntry(cwd);
@@ -27286,10 +27562,10 @@ var grantsOverride = () => {
27286
27562
  const shown = shownGrantsDir();
27287
27563
  if (shown === null)
27288
27564
  return accountUnread() ?? NO_ACCOUNT;
27289
- const configured = path25.resolve(resolveConfigDir());
27290
- return configured === path25.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 ${path25.join(grantsDir(), "workspaces.json")}, and under a redirect they never exceed the D4 defaults`;
27565
+ const configured = path26.resolve(resolveConfigDir());
27566
+ return configured === path26.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 ${path26.join(grantsDir(), "workspaces.json")}, and under a redirect they never exceed the D4 defaults`;
27291
27567
  };
27292
- 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 ${path25.join(grantsDir(), "workspaces.json")}`;
27568
+ 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 ${path26.join(grantsDir(), "workspaces.json")}`;
27293
27569
  var GRANT_KINDS = ["push", "pr", "merge", "release", "rerun"];
27294
27570
  var DEFAULT_GRANTS = Object.freeze({
27295
27571
  push: true,
@@ -27690,7 +27966,7 @@ var BRANCH_RENAME = new Set(["-m", "-M", "--move", "-c", "-C", "--copy"]);
27690
27966
  var WORKTREE_VALUES = new Set(["--reason"]);
27691
27967
  var FETCH_VALUES = new Set(["--depth", "--deepen", "--shallow-since", "--shallow-exclude", "--refmap", "-j", "--jobs"].concat(["--upload-pack", "-o", "--server-option", "--negotiation-tip", "--filter"]).concat(["--recurse-submodules-default", "--submodule-prefix", "-s", "--strategy", "-X"]).concat(["--strategy-option"]));
27692
27968
  // packages/workit-core/src/core/task-engine.ts
27693
- import { realpathSync as realpathSync8 } from "node:fs";
27969
+ import { realpathSync as realpathSync9 } from "node:fs";
27694
27970
 
27695
27971
  // packages/workit-core/src/core/policy-resolver.ts
27696
27972
  function resolvePolicy(input) {
@@ -27939,12 +28215,12 @@ var judgeInputSummary = (raw) => {
27939
28215
  };
27940
28216
 
27941
28217
  // packages/workit-core/src/core/task-view.ts
27942
- import { realpathSync as realpathSync7 } from "node:fs";
28218
+ import { realpathSync as realpathSync8 } from "node:fs";
27943
28219
  var environment = () => [];
27944
28220
  var sameSession2 = (value, context) => typeof value === "object" && value !== null && value.kind === "host" && value.host === context.caller.host && value.handle === context.caller.actor;
27945
28221
  function contextRootError(store, context) {
27946
28222
  try {
27947
- realpathSync7(context.root);
28223
+ realpathSync8(context.root);
27948
28224
  const root = checkoutRootOf(context.root);
27949
28225
  if (root !== store.root && !sameDirectoryIdentity(root, store.root))
27950
28226
  return failure2("invalid_input", "operation context root does not match the task store root");
@@ -29414,7 +29690,7 @@ class WorkitCore {
29414
29690
  if (view.task.workspaceId !== view.workspace.id)
29415
29691
  return failure2("invalid_input", "task and workspace bindings are invalid");
29416
29692
  try {
29417
- if (realpathSync8(view.workspace.root) !== this.store.root)
29693
+ if (realpathSync9(view.workspace.root) !== this.store.root)
29418
29694
  return failure2("invalid_input", "task view root does not match the task store");
29419
29695
  } catch {
29420
29696
  return failure2("invalid_input", "task view root cannot be resolved");
@@ -29665,8 +29941,8 @@ class WorkitCore {
29665
29941
  }
29666
29942
  // packages/workit-core/src/core/repo-context.ts
29667
29943
  import { spawnSync as spawnSync17 } from "node:child_process";
29668
- import { existsSync as existsSync12, readFileSync as readFileSync10, readdirSync as readdirSync4 } from "node:fs";
29669
- import path26 from "node:path";
29944
+ import { existsSync as existsSync13, readFileSync as readFileSync10, readdirSync as readdirSync4 } from "node:fs";
29945
+ import path27 from "node:path";
29670
29946
  var isSafeContextRange = (value) => value.length <= 4096 && (() => {
29671
29947
  try {
29672
29948
  gitRevisionParts(value);
@@ -29810,13 +30086,13 @@ var findPrTemplate = (cwd) => {
29810
30086
  for (const rel of PR_TEMPLATE_FILES) {
29811
30087
  const parts = rel.split("/");
29812
30088
  const base = parts[parts.length - 1];
29813
- const dir = parts.length > 1 ? path26.join(cwd, ...parts.slice(0, -1)) : cwd;
30089
+ const dir = parts.length > 1 ? path27.join(cwd, ...parts.slice(0, -1)) : cwd;
29814
30090
  const actual = probeCaseInsensitive(dir, base);
29815
30091
  if (actual)
29816
30092
  return [...parts.slice(0, -1), actual].join("/");
29817
30093
  }
29818
30094
  for (const rel of PR_TEMPLATE_DIRS) {
29819
- const only = singleMarkdown(path26.join(cwd, ...rel.split("/")));
30095
+ const only = singleMarkdown(path27.join(cwd, ...rel.split("/")));
29820
30096
  if (only)
29821
30097
  return `${rel}/${only}`;
29822
30098
  }
@@ -29846,8 +30122,8 @@ var diffStatForRange = (cwd, range) => {
29846
30122
  return runGit(cwd, ["diff", "--stat", "--"]).stdout;
29847
30123
  };
29848
30124
  var packageScripts = (cwd, keys) => {
29849
- const pkgPath = path26.join(cwd, "package.json");
29850
- if (!existsSync12(pkgPath))
30125
+ const pkgPath = path27.join(cwd, "package.json");
30126
+ if (!existsSync13(pkgPath))
29851
30127
  return [];
29852
30128
  try {
29853
30129
  const pkg = JSON.parse(readFileSync10(pkgPath, "utf8"));
@@ -29872,9 +30148,9 @@ var documentationFiles = (cwd) => {
29872
30148
  if (entry.isDirectory()) {
29873
30149
  if (excluded.has(entry.name))
29874
30150
  continue;
29875
- walk(path26.join(dir, entry.name), depth + 1);
30151
+ walk(path27.join(dir, entry.name), depth + 1);
29876
30152
  } else if (entry.isFile() && (entry.name === "README.md" || entry.name.endsWith(".md"))) {
29877
- matches.push("./" + path26.relative(cwd, path26.join(dir, entry.name)).replaceAll("\\", "/"));
30153
+ matches.push("./" + path27.relative(cwd, path27.join(dir, entry.name)).replaceAll("\\", "/"));
29878
30154
  }
29879
30155
  }
29880
30156
  };
@@ -29882,7 +30158,7 @@ var documentationFiles = (cwd) => {
29882
30158
  return matches.toSorted().slice(0, 200);
29883
30159
  };
29884
30160
  var readTrimmed2 = (file, maxLines) => {
29885
- if (!existsSync12(file))
30161
+ if (!existsSync13(file))
29886
30162
  return "";
29887
30163
  const lines = readFileSync10(file, "utf8").split(`
29888
30164
  `);
@@ -29890,7 +30166,7 @@ var readTrimmed2 = (file, maxLines) => {
29890
30166
  `);
29891
30167
  };
29892
30168
  function prReadyContext(root, range) {
29893
- const cwd = path26.resolve(repoRoot(root));
30169
+ const cwd = path27.resolve(repoRoot(root));
29894
30170
  if (range !== undefined && !isResolvableContextRange(cwd, range))
29895
30171
  return invalidRange(cwd);
29896
30172
  let stdout = "";
@@ -29948,7 +30224,7 @@ ${status.stderr}` : "");
29948
30224
  stdout += `template_path: ${template}
29949
30225
 
29950
30226
  `;
29951
- stdout += readTrimmed2(path26.join(cwd, template), 220);
30227
+ stdout += readTrimmed2(path27.join(cwd, template), 220);
29952
30228
  } else {
29953
30229
  stdout += `template_path: none
29954
30230
 
@@ -29958,7 +30234,7 @@ ${status.stderr}` : "");
29958
30234
  stdout += `
29959
30235
  `;
29960
30236
  stdout += printSection("Recent Validation Signals");
29961
- if (existsSync12(path26.join(cwd, "package.json"))) {
30237
+ if (existsSync13(path27.join(cwd, "package.json"))) {
29962
30238
  stdout += `package.json detected. Common scripts:
29963
30239
  `;
29964
30240
  const found = packageScripts(cwd, ["lint", "format:check", "test", "build"]);
@@ -29967,7 +30243,7 @@ ${status.stderr}` : "");
29967
30243
  `) + `
29968
30244
  `;
29969
30245
  }
29970
- if (existsSync12(path26.join(cwd, "Cargo.toml")) || existsSync12(path26.join(cwd, "src-tauri/Cargo.toml"))) {
30246
+ if (existsSync13(path27.join(cwd, "Cargo.toml")) || existsSync13(path27.join(cwd, "src-tauri/Cargo.toml"))) {
29971
30247
  stdout += `Rust project detected.
29972
30248
  `;
29973
30249
  }
@@ -30000,7 +30276,7 @@ var CHANGELOG_RULES = `- Use an [Unreleased] section.
30000
30276
  - Apply with the host-native editor, preserving the repository changelog conventions.
30001
30277
  - If Unreleased already has duplicate category headings, normalize_only first.`;
30002
30278
  function changelogContext(root, range) {
30003
- const cwd = path26.resolve(repoRoot(root));
30279
+ const cwd = path27.resolve(repoRoot(root));
30004
30280
  if (range !== undefined && !isResolvableContextRange(cwd, range))
30005
30281
  return invalidRange(cwd);
30006
30282
  const resolvedRange = rangeArgOrDefault(range, cwd);
@@ -30018,8 +30294,8 @@ function changelogContext(root, range) {
30018
30294
  stdout += CHANGELOG_RULES + `
30019
30295
  `;
30020
30296
  stdout += printSection("Existing CHANGELOG.md");
30021
- const changelogPath = path26.join(cwd, "CHANGELOG.md");
30022
- if (existsSync12(changelogPath)) {
30297
+ const changelogPath = path27.join(cwd, "CHANGELOG.md");
30298
+ if (existsSync13(changelogPath)) {
30023
30299
  stdout += readTrimmed2(changelogPath, 260) + `
30024
30300
  `;
30025
30301
  } else {
@@ -30038,7 +30314,7 @@ function changelogContext(root, range) {
30038
30314
  return { stdout, stderr: "", exitCode: 0, cwd };
30039
30315
  }
30040
30316
  function docsRefreshContext(root, range) {
30041
- const cwd = path26.resolve(repoRoot(root));
30317
+ const cwd = path27.resolve(repoRoot(root));
30042
30318
  if (range !== undefined && !isResolvableContextRange(cwd, range))
30043
30319
  return invalidRange(cwd);
30044
30320
  const resolvedRange = rangeArgOrDefault(range, cwd);
@@ -30060,8 +30336,8 @@ function docsRefreshContext(root, range) {
30060
30336
  `) + `
30061
30337
  `;
30062
30338
  stdout += printSection("README Preview");
30063
- const readme = path26.join(cwd, "README.md");
30064
- if (existsSync12(readme)) {
30339
+ const readme = path27.join(cwd, "README.md");
30340
+ if (existsSync13(readme)) {
30065
30341
  stdout += readTrimmed2(readme, 220) + `
30066
30342
  `;
30067
30343
  } else {
@@ -30069,8 +30345,8 @@ function docsRefreshContext(root, range) {
30069
30345
  `;
30070
30346
  }
30071
30347
  stdout += printSection("Package Scripts");
30072
- const pkgPath = path26.join(cwd, "package.json");
30073
- if (existsSync12(pkgPath)) {
30348
+ const pkgPath = path27.join(cwd, "package.json");
30349
+ if (existsSync13(pkgPath)) {
30074
30350
  try {
30075
30351
  const pkg = JSON.parse(readFileSync10(pkgPath, "utf8"));
30076
30352
  stdout += JSON.stringify({ name: pkg.name, version: pkg.version, scripts: pkg.scripts }, null, 2) + `
@@ -30083,7 +30359,7 @@ function docsRefreshContext(root, range) {
30083
30359
  return { stdout, stderr: "", exitCode: 0, cwd };
30084
30360
  }
30085
30361
  function releaseNotesContext(root, rangeOrTag) {
30086
- const cwd = path26.resolve(repoRoot(root));
30362
+ const cwd = path27.resolve(repoRoot(root));
30087
30363
  if (!rangeOrTag) {
30088
30364
  return {
30089
30365
  stdout: "",
@@ -30126,7 +30402,7 @@ function releaseNotesContext(root, rangeOrTag) {
30126
30402
  `;
30127
30403
  stdout += printSection("Existing Release Files");
30128
30404
  for (const rel of ["CHANGELOG.md", "RELEASE_NOTES.md", ".github/releases.md"]) {
30129
- if (existsSync12(path26.join(cwd, rel)))
30405
+ if (existsSync13(path27.join(cwd, rel)))
30130
30406
  stdout += rel + `
30131
30407
  `;
30132
30408
  }
@@ -30157,8 +30433,8 @@ function releaseNotesContext(root, rangeOrTag) {
30157
30433
  import { spawnSync as spawnSync19 } from "node:child_process";
30158
30434
 
30159
30435
  // packages/workit-core/src/core/pr-create.ts
30160
- import fs18 from "node:fs";
30161
- import path27 from "node:path";
30436
+ import fs19 from "node:fs";
30437
+ import path28 from "node:path";
30162
30438
  import { spawnSync as spawnSync18 } from "node:child_process";
30163
30439
  // packages/workit-core/src/forge/pr-body.ts
30164
30440
  function parseGhIssue(value) {
@@ -30178,13 +30454,13 @@ var LOCAL = bounded(20000);
30178
30454
  var NETWORK = bounded(60000);
30179
30455
  function whichOnPath(tool) {
30180
30456
  const names = process.platform === "win32" ? [tool, `${tool}.exe`, `${tool}.cmd`] : [tool];
30181
- for (const dir of (process.env.PATH ?? "").split(path27.delimiter)) {
30457
+ for (const dir of (process.env.PATH ?? "").split(path28.delimiter)) {
30182
30458
  if (!dir)
30183
30459
  continue;
30184
30460
  for (const name of names) {
30185
- const candidate = path27.join(dir, name);
30461
+ const candidate = path28.join(dir, name);
30186
30462
  try {
30187
- fs18.accessSync(candidate, fs18.constants.X_OK);
30463
+ fs19.accessSync(candidate, fs19.constants.X_OK);
30188
30464
  return candidate;
30189
30465
  } catch {}
30190
30466
  }
@@ -30302,8 +30578,8 @@ var fetchGitLabIssueBody = async (ref, root, deps = {}) => {
30302
30578
  };
30303
30579
 
30304
30580
  // packages/workit-core/src/core/youtrack.ts
30305
- import fs19 from "node:fs";
30306
- import path28 from "node:path";
30581
+ import fs20 from "node:fs";
30582
+ import path29 from "node:path";
30307
30583
 
30308
30584
  // packages/workit-core/src/core/templates.ts
30309
30585
  var repoRoot2 = assetRoot();
@@ -30315,14 +30591,14 @@ var resolveWorkspaceRoot = (explicit) => explicit || process.cwd();
30315
30591
 
30316
30592
  // packages/workit-core/src/core/youtrack.ts
30317
30593
  var ISSUE_RE = /^[A-Z][A-Z0-9_]*-\d+$/;
30318
- var youTrackReadOnlyConfigPath = () => process.env.WORKIT_YOUTRACK_CONFIG ?? path28.join(resolveConfigDir(), "youtrack.json");
30594
+ var youTrackReadOnlyConfigPath = () => process.env.WORKIT_YOUTRACK_CONFIG ?? path29.join(resolveConfigDir(), "youtrack.json");
30319
30595
  var readYouTrackContextConfig = () => {
30320
30596
  const cfgPath = youTrackReadOnlyConfigPath();
30321
- if (!fs19.existsSync(cfgPath))
30597
+ if (!fs20.existsSync(cfgPath))
30322
30598
  return { data: {} };
30323
30599
  let parsed;
30324
30600
  try {
30325
- parsed = JSON.parse(fs19.readFileSync(cfgPath, "utf8"));
30601
+ parsed = JSON.parse(fs20.readFileSync(cfgPath, "utf8"));
30326
30602
  } catch {
30327
30603
  return { error: "YouTrack configuration is unavailable" };
30328
30604
  }
@@ -30393,9 +30669,9 @@ function resolveYouTrackFromPaths(spec_path, plan_path, workspace_root) {
30393
30669
  } catch {
30394
30670
  continue;
30395
30671
  }
30396
- if (!fs19.existsSync(full))
30672
+ if (!fs20.existsSync(full))
30397
30673
  continue;
30398
- const text = fs19.readFileSync(full, "utf8");
30674
+ const text = fs20.readFileSync(full, "utf8");
30399
30675
  const m = text.match(/^\*\*YouTrack:\*\*\s*`?([A-Z]+-\d+)`?/m);
30400
30676
  if (m)
30401
30677
  return m[1];
@@ -30667,22 +30943,22 @@ function resolveGitRevision(root, value) {
30667
30943
  }
30668
30944
  }
30669
30945
  function resolveInside(root, candidate) {
30670
- const base = realpathSync9(root);
30671
- const target = path29.resolve(base, candidate);
30672
- if (target !== base && !target.startsWith(base + path29.sep)) {
30946
+ const base = realpathSync10(root);
30947
+ const target = path30.resolve(base, candidate);
30948
+ if (target !== base && !target.startsWith(base + path30.sep)) {
30673
30949
  throw new Error("path must stay inside repository root");
30674
30950
  }
30675
30951
  let ancestor = target;
30676
- while (!existsSync13(ancestor))
30677
- ancestor = path29.dirname(ancestor);
30678
- const canonicalAncestor = realpathSync9(ancestor);
30679
- if (canonicalAncestor !== base && !canonicalAncestor.startsWith(base + path29.sep)) {
30952
+ while (!existsSync14(ancestor))
30953
+ ancestor = path30.dirname(ancestor);
30954
+ const canonicalAncestor = realpathSync10(ancestor);
30955
+ if (canonicalAncestor !== base && !canonicalAncestor.startsWith(base + path30.sep)) {
30680
30956
  throw new Error("path must stay inside repository root");
30681
30957
  }
30682
30958
  return target;
30683
30959
  }
30684
30960
  function run2(root, executable, args, env = {}) {
30685
- const cwd = realpathSync9(root);
30961
+ const cwd = realpathSync10(root);
30686
30962
  const result = spawnSync20(executable, args, {
30687
30963
  cwd,
30688
30964
  encoding: "utf8",
@@ -30714,11 +30990,11 @@ var changedSourcesSinceLoad = (marker) => {
30714
30990
  };
30715
30991
 
30716
30992
  // packages/workit-core/src/hooks/repeat-failure.ts
30717
- import { createHash as createHash12 } from "node:crypto";
30993
+ import { createHash as createHash13 } from "node:crypto";
30718
30994
  var SAME_CALL_FAILED = "Same call failed twice:";
30719
30995
  var MAX_SESSIONS = 256;
30720
30996
  var stable = (value) => JSON.stringify(value, (_key, entry) => entry && typeof entry === "object" && !Array.isArray(entry) ? Object.fromEntries(Object.entries(entry).toSorted(([a], [b]) => a.localeCompare(b))) : entry) ?? "null";
30721
- var hashOf = (call) => createHash12("sha256").update(call).digest("hex").slice(0, 32);
30997
+ var hashOf = (call) => createHash13("sha256").update(call).digest("hex").slice(0, 32);
30722
30998
  var record3 = (memo, sessionId, call, failed, next) => {
30723
30999
  const previous = memo.get(sessionId);
30724
31000
  memo.delete(sessionId);
@@ -30783,13 +31059,13 @@ var rootVariants = (workspaceRoot) => {
30783
31059
  if (!workspaceRoot)
30784
31060
  return [];
30785
31061
  const roots = new Set;
30786
- for (const candidate of [workspaceRoot, path30.resolve(workspaceRoot)]) {
30787
- if (path30.isAbsolute(candidate) && candidate !== path30.parse(candidate).root)
31062
+ for (const candidate of [workspaceRoot, path31.resolve(workspaceRoot)]) {
31063
+ if (path31.isAbsolute(candidate) && candidate !== path31.parse(candidate).root)
30788
31064
  roots.add(candidate);
30789
31065
  }
30790
31066
  try {
30791
- const canonical = realpathSync10(workspaceRoot);
30792
- if (canonical !== path30.parse(canonical).root)
31067
+ const canonical = realpathSync11(workspaceRoot);
31068
+ if (canonical !== path31.parse(canonical).root)
30793
31069
  roots.add(canonical);
30794
31070
  } catch {}
30795
31071
  return [...roots].toSorted((left, right) => right.length - left.length);
@@ -30871,12 +31147,12 @@ var thrownResult = (tool, error, workspaceRoot) => {
30871
31147
  };
30872
31148
  function createMcpServer(host, contextProvider) {
30873
31149
  assertMcpHost(host);
30874
- const here = path30.dirname(fileURLToPath2(import.meta.url));
31150
+ const here = path31.dirname(fileURLToPath2(import.meta.url));
30875
31151
  const sourceMarker = markSourcesLoaded([
30876
- path30.join(here, "server.ts"),
30877
- path30.join(here, "..", "..", "workit-core", "src", "core", "task-contract.ts"),
30878
- path30.join(here, "..", "..", "workit-core", "src", "core", "task-engine.ts")
30879
- ].filter((file) => existsSync14(file)));
31152
+ path31.join(here, "server.ts"),
31153
+ path31.join(here, "..", "..", "workit-core", "src", "core", "task-contract.ts"),
31154
+ path31.join(here, "..", "..", "workit-core", "src", "core", "task-engine.ts")
31155
+ ].filter((file) => existsSync15(file)));
30880
31156
  let staleWarned = false;
30881
31157
  const failures = new Map;
30882
31158
  const server = new Server({ name: "workit", version: VERSION }, { capabilities: { tools: {}, resources: {} } });
@@ -31058,8 +31334,8 @@ var main = async () => {
31058
31334
  process.exitCode = 2;
31059
31335
  }
31060
31336
  };
31061
- var entryPath = process.argv[1] ? path31.resolve(process.argv[1]) : "";
31062
- if (entryPath === path31.resolve(fileURLToPath3(import.meta.url)))
31337
+ var entryPath = process.argv[1] ? path32.resolve(process.argv[1]) : "";
31338
+ if (entryPath === path32.resolve(fileURLToPath3(import.meta.url)))
31063
31339
  await main();
31064
31340
  export {
31065
31341
  McpCapabilityUnavailableError,