@mrciphersmith/keryx 0.4.40 → 0.4.42

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.
package/dist/core.js CHANGED
@@ -5438,13 +5438,55 @@ var init_entropy_gate = __esm(() => {
5438
5438
  cachedEnabled = DEFAULT_SECURITY_CONFIG.backends.entropy.enabled;
5439
5439
  });
5440
5440
 
5441
+ // src/security/display-redaction.ts
5442
+ function maskFor(match) {
5443
+ return `[REDACTED:${match.mask ?? "sensitive"}]`;
5444
+ }
5445
+ function applyRedaction(content, matches) {
5446
+ const redactable = matches.filter((m) => m.mask !== undefined).sort((a, b) => a.start - b.start || b.end - a.end);
5447
+ let out = "";
5448
+ let cursor = 0;
5449
+ for (const match of redactable) {
5450
+ if (match.end <= cursor) {
5451
+ continue;
5452
+ }
5453
+ if (match.start < cursor) {
5454
+ cursor = match.end;
5455
+ continue;
5456
+ }
5457
+ out += content.slice(cursor, match.start);
5458
+ out += maskFor(match);
5459
+ cursor = match.end;
5460
+ }
5461
+ out += content.slice(cursor);
5462
+ return out;
5463
+ }
5464
+ function redactDisplayText(text, includeEntropy = true) {
5465
+ if (text.length === 0) {
5466
+ return text;
5467
+ }
5468
+ const matches = [
5469
+ ...detectSecrets(text),
5470
+ ...detectPii(text),
5471
+ ...detectExfil(text),
5472
+ ...includeEntropy ? detectEntropy(text) : []
5473
+ ];
5474
+ if (matches.length === 0) {
5475
+ return text;
5476
+ }
5477
+ return applyRedaction(text, matches);
5478
+ }
5479
+ var init_display_redaction = __esm(() => {
5480
+ init_secrets();
5481
+ init_pii();
5482
+ init_exfil();
5483
+ init_entropy();
5484
+ });
5485
+
5441
5486
  // src/security/redact.ts
5442
5487
  import path12 from "path";
5443
5488
  import { createHmac, randomBytes as randomBytes2 } from "crypto";
5444
5489
  import { mkdir as mkdir3, readFile as readFile3, writeFile as writeFile2, chmod as chmod3 } from "fs/promises";
5445
- function maskFor(match) {
5446
- return `[REDACTED:${match.mask ?? "sensitive"}]`;
5447
- }
5448
5490
  function tidy(value) {
5449
5491
  return value.replace(/\s+/g, " ").trim();
5450
5492
  }
@@ -5487,39 +5529,8 @@ function locationFor(content, match) {
5487
5529
  end: match.end
5488
5530
  };
5489
5531
  }
5490
- function applyRedaction(content, matches) {
5491
- const redactable = matches.filter((m) => m.mask !== undefined).sort((a, b) => a.start - b.start || b.end - a.end);
5492
- let out = "";
5493
- let cursor = 0;
5494
- for (const match of redactable) {
5495
- if (match.end <= cursor) {
5496
- continue;
5497
- }
5498
- if (match.start < cursor) {
5499
- cursor = match.end;
5500
- continue;
5501
- }
5502
- out += content.slice(cursor, match.start);
5503
- out += maskFor(match);
5504
- cursor = match.end;
5505
- }
5506
- out += content.slice(cursor);
5507
- return out;
5508
- }
5509
5532
  function redactSensitiveText(text) {
5510
- if (text.length === 0) {
5511
- return text;
5512
- }
5513
- const matches = [
5514
- ...detectSecrets(text),
5515
- ...detectPii(text),
5516
- ...detectExfil(text),
5517
- ...isEntropyBackendEnabled() ? detectEntropy(text) : []
5518
- ];
5519
- if (matches.length === 0) {
5520
- return text;
5521
- }
5522
- return applyRedaction(text, matches);
5533
+ return redactDisplayText(text, isEntropyBackendEnabled());
5523
5534
  }
5524
5535
  function keyDir(cwd) {
5525
5536
  return path12.join(securityDataRoot(cwd), "raw");
@@ -5549,10 +5560,8 @@ var PREVIEW_WINDOW = 24, KEY_FILE = "hmac.key";
5549
5560
  var init_redact = __esm(() => {
5550
5561
  init_fs();
5551
5562
  init_config();
5552
- init_secrets();
5553
- init_pii();
5554
- init_exfil();
5555
- init_entropy();
5563
+ init_display_redaction();
5564
+ init_display_redaction();
5556
5565
  init_entropy_gate();
5557
5566
  });
5558
5567
 
@@ -7089,7 +7098,7 @@ var init_incidents = __esm(() => {
7089
7098
 
7090
7099
  // src/security/self-protect.ts
7091
7100
  import path18 from "path";
7092
- import { mkdir as mkdir6, readFile as readFile6, writeFile as writeFile4 } from "fs/promises";
7101
+ import { readFile as readFile6 } from "fs/promises";
7093
7102
  function currentState(config) {
7094
7103
  const policies = {};
7095
7104
  for (const [name, policy] of Object.entries(config.policies)) {
@@ -7162,9 +7171,8 @@ async function readState(cwd) {
7162
7171
  }
7163
7172
  async function writeState(cwd, state) {
7164
7173
  const file = stateFile(cwd);
7165
- await mkdir6(path18.dirname(file), { recursive: true });
7166
- await writeFile4(file, `${JSON.stringify(state, null, 2)}
7167
- `, "utf8");
7174
+ await writeFileAtomic(file, `${JSON.stringify(state, null, 2)}
7175
+ `);
7168
7176
  }
7169
7177
  var MODE_RANK;
7170
7178
  var init_self_protect = __esm(() => {
@@ -7179,25 +7187,25 @@ var init_self_protect = __esm(() => {
7179
7187
  });
7180
7188
 
7181
7189
  // src/lib/descriptor-read.ts
7182
- import { constants, fstatSync, lstatSync as lstatSync2, statSync as statSync2 } from "fs";
7190
+ import { closeSync, constants, fstatSync, lstatSync as lstatSync2, readSync } from "fs";
7183
7191
  import path19 from "path";
7184
- import { dlopen, FFIType, ptr } from "bun:ffi";
7185
- function readDescriptorChain(workspaceRoot, absolutePath, options = {}) {
7192
+ import { dlopen, FFIType } from "bun:ffi";
7193
+ function openDescriptorChain(workspaceRoot, absolutePath, options = {}) {
7186
7194
  const relativePath = path19.relative(workspaceRoot, absolutePath);
7187
7195
  const components = relativePath.split(path19.sep);
7188
- if (!relativePath || path19.isAbsolute(relativePath) || components.some((component) => !component || component === "." || component === "..")) {
7196
+ if (!relativePath || path19.isAbsolute(relativePath) || components.some((component) => !component || component.includes("\x00") || component === "." || component === "..")) {
7189
7197
  throw new DescriptorReadError("invalid-path", "safe source path is not workspace-relative");
7190
7198
  }
7191
7199
  if (options.maxBytes !== undefined && (!Number.isSafeInteger(options.maxBytes) || options.maxBytes < 0)) {
7192
7200
  throw new DescriptorReadError("too-large", "safe source byte limit is invalid");
7193
7201
  }
7194
7202
  const libc = loadPosixLibrary();
7195
- if (!libc || !Number.isInteger(constants.O_DIRECTORY) || !Number.isInteger(constants.O_NOFOLLOW)) {
7203
+ if (!libc || !Number.isInteger(constants.O_DIRECTORY) || !Number.isInteger(constants.O_NOFOLLOW) || options.requireRegularFile && !Number.isInteger(constants.O_NONBLOCK)) {
7196
7204
  throw new DescriptorReadError("unavailable", "safe descriptor source reads are unavailable on this platform");
7197
7205
  }
7198
7206
  const opened = [];
7199
7207
  try {
7200
- const rootStat = lstatSync2(workspaceRoot);
7208
+ const rootStat = lstatSync2(workspaceRoot, { bigint: true });
7201
7209
  if (!rootStat.isDirectory() || rootStat.isSymbolicLink()) {
7202
7210
  throw new DescriptorReadError("race", "safe source owner root changed");
7203
7211
  }
@@ -7206,7 +7214,7 @@ function readDescriptorChain(workspaceRoot, absolutePath, options = {}) {
7206
7214
  }
7207
7215
  const parent = openAt(libc, atFdcwd, workspaceRoot, constants.O_RDONLY | constants.O_DIRECTORY | constants.O_NOFOLLOW);
7208
7216
  opened.push(parent);
7209
- if (!sameIdentity(rootStat, fstatSync(parent))) {
7217
+ if (!sameIdentity(rootStat, fstatSync(parent, { bigint: true }))) {
7210
7218
  throw new DescriptorReadError("race", "safe source owner root changed");
7211
7219
  }
7212
7220
  let directoryFd = parent;
@@ -7217,16 +7225,20 @@ function readDescriptorChain(workspaceRoot, absolutePath, options = {}) {
7217
7225
  const name = components.at(-1);
7218
7226
  if (!name)
7219
7227
  throw new DescriptorReadError("invalid-path", "safe source path has no final component");
7220
- const expected = options.expectedTargetIdentity ?? statSync2(absolutePath);
7221
- const finalFlags = constants.O_RDONLY | constants.O_NOFOLLOW | (options.requireRegularFile ? constants.O_NONBLOCK ?? 0 : 0);
7228
+ const target = lstatSync2(absolutePath, { bigint: true });
7229
+ if (options.requireRegularFile && !target.isFile())
7230
+ throw new DescriptorReadError("not-regular", "safe source is not a regular file");
7231
+ const expected = options.expectedTargetIdentity ?? target;
7232
+ const finalFlags = constants.O_RDONLY | constants.O_NOFOLLOW | (options.directory ? constants.O_DIRECTORY : 0) | (options.requireRegularFile ? constants.O_NONBLOCK : 0);
7222
7233
  const file = openAt(libc, directoryFd, name, finalFlags);
7223
7234
  opened.push(file);
7224
- const actual = fstatSync(file);
7235
+ const actual = fstatSync(file, { bigint: true });
7225
7236
  if (!sameIdentity(expected, actual))
7226
7237
  throw new DescriptorReadError("race", "safe source target changed");
7227
7238
  if (options.requireRegularFile && !actual.isFile())
7228
7239
  throw new DescriptorReadError("not-regular", "safe source is not a regular file");
7229
- return readAll(libc, file, actual, options.maxBytes);
7240
+ opened.pop();
7241
+ return file;
7230
7242
  } catch (error) {
7231
7243
  if (error instanceof DescriptorReadError)
7232
7244
  throw error;
@@ -7234,7 +7246,18 @@ function readDescriptorChain(workspaceRoot, absolutePath, options = {}) {
7234
7246
  } finally {
7235
7247
  for (const fd of opened.reverse())
7236
7248
  libc.symbols.close(fd);
7237
- libc.close();
7249
+ }
7250
+ }
7251
+ function readDescriptorChain(workspaceRoot, absolutePath, options = {}) {
7252
+ const fd = openDescriptorChain(workspaceRoot, absolutePath, options);
7253
+ try {
7254
+ return readAll(fd, fstatSync(fd), options.maxBytes);
7255
+ } catch (error) {
7256
+ if (error instanceof DescriptorReadError)
7257
+ throw error;
7258
+ throw new DescriptorReadError("read-failed", "safe descriptor source read failed");
7259
+ } finally {
7260
+ closeSync(fd);
7238
7261
  }
7239
7262
  }
7240
7263
  async function readDescriptorChainAsync(workspaceRoot, absolutePath, options = {}) {
@@ -7245,13 +7268,15 @@ async function readDescriptorChainAsync(workspaceRoot, absolutePath, options = {
7245
7268
  return readDescriptorChain(workspaceRoot, absolutePath, options);
7246
7269
  }
7247
7270
  function loadPosixLibrary() {
7271
+ if (posixLibrary)
7272
+ return posixLibrary;
7248
7273
  for (const candidate of libcCandidates) {
7249
7274
  try {
7250
- return dlopen(candidate, {
7275
+ posixLibrary = dlopen(candidate, {
7251
7276
  openat: { args: [FFIType.i32, FFIType.cstring, FFIType.i32, FFIType.i32], returns: FFIType.i32 },
7252
- read: { args: [FFIType.i32, FFIType.ptr, FFIType.u64], returns: FFIType.i64 },
7253
7277
  close: { args: [FFIType.i32], returns: FFIType.i32 }
7254
7278
  });
7279
+ return posixLibrary;
7255
7280
  } catch {}
7256
7281
  }
7257
7282
  return;
@@ -7265,7 +7290,7 @@ function openAt(libc, directoryFd, component, flags) {
7265
7290
  function sameIdentity(left, right) {
7266
7291
  return left.dev === right.dev && left.ino === right.ino;
7267
7292
  }
7268
- function readAll(libc, fd, descriptor, maxBytes) {
7293
+ function readAll(fd, descriptor, maxBytes) {
7269
7294
  if (maxBytes !== undefined && descriptor.size > maxBytes)
7270
7295
  throw new DescriptorReadError("too-large", "safe source exceeds the byte limit");
7271
7296
  const chunks = [];
@@ -7279,19 +7304,19 @@ function readAll(libc, fd, descriptor, maxBytes) {
7279
7304
  return Buffer.concat(chunks);
7280
7305
  }
7281
7306
  const chunk = Buffer.allocUnsafe(Math.min(READ_CHUNK_BYTES, remaining));
7282
- const read = libc.symbols.read(fd, ptr(chunk), chunk.length);
7283
- if (read < 0n)
7307
+ let length;
7308
+ try {
7309
+ length = readSync(fd, chunk, 0, chunk.length, null);
7310
+ } catch {
7284
7311
  throw new DescriptorReadError("read-failed", "safe descriptor source read failed");
7285
- if (read === 0n)
7312
+ }
7313
+ if (!length)
7286
7314
  return Buffer.concat(chunks);
7287
- const length = Number(read);
7288
- if (!Number.isSafeInteger(length) || length > chunk.length)
7289
- throw new DescriptorReadError("read-failed", "safe descriptor source read returned an invalid length");
7290
7315
  total += length;
7291
7316
  chunks.push(chunk.subarray(0, length));
7292
7317
  }
7293
7318
  }
7294
- var DescriptorReadError, atFdcwd, libcCandidates, READ_CHUNK_BYTES;
7319
+ var DescriptorReadError, atFdcwd, libcCandidates, READ_CHUNK_BYTES, posixLibrary;
7295
7320
  var init_descriptor_read = __esm(() => {
7296
7321
  DescriptorReadError = class DescriptorReadError extends Error {
7297
7322
  code;
@@ -7322,13 +7347,13 @@ async function readContainedFile(ownerRoot, candidatePath, options = {}) {
7322
7347
  let rootIdentity;
7323
7348
  let targetIdentity;
7324
7349
  try {
7325
- const rootStat = await lstat4(ownerRoot);
7350
+ const rootStat = await lstat4(ownerRoot, { bigint: true });
7326
7351
  if (!rootStat.isDirectory() || rootStat.isSymbolicLink())
7327
7352
  throw new ContainedReadError("CONTAINED_READ_RACE", "contained source owner root changed");
7328
7353
  rootIdentity = rootStat;
7329
7354
  rootReal = await realpath4(ownerRoot);
7330
7355
  targetReal = await realpath4(candidatePath);
7331
- const targetStat = await stat3(targetReal);
7356
+ const targetStat = await stat3(targetReal, { bigint: true });
7332
7357
  if (options.requireRegularFile !== false && !targetStat.isFile()) {
7333
7358
  throw new ContainedReadError("CONTAINED_READ_NOT_REGULAR", "contained source is not a regular file");
7334
7359
  }
@@ -8538,9 +8563,9 @@ function revisionOperand(ref) {
8538
8563
  // src/lib/git-worktrees.ts
8539
8564
  import { readdir as readdir3, readFile as readFile7, realpath as realpath7, stat as stat6 } from "fs/promises";
8540
8565
  import path23 from "path";
8541
- async function resolveGitCommonDir(cwd) {
8566
+ async function resolveGitCommonDir(cwd, env) {
8542
8567
  try {
8543
- const proc = Bun.spawn(["git", "rev-parse", "--git-common-dir"], { cwd, stdout: "pipe", stderr: "ignore" });
8568
+ const proc = Bun.spawn(["git", "rev-parse", "--git-common-dir"], { cwd, ...env && { env }, stdout: "pipe", stderr: "ignore" });
8544
8569
  const out = (await new Response(proc.stdout).text()).trim();
8545
8570
  if (await proc.exited !== 0 || out.length === 0) {
8546
8571
  return;
@@ -12177,7 +12202,7 @@ var init_surfaces_agents = __esm(() => {
12177
12202
  });
12178
12203
 
12179
12204
  // src/lib/git-local-ignore.ts
12180
- import { lstat as lstat6, mkdir as mkdir7, readFile as readFile11, realpath as realpath9, writeFile as writeFile5 } from "fs/promises";
12205
+ import { lstat as lstat6, mkdir as mkdir6, readFile as readFile11, realpath as realpath9, writeFile as writeFile4 } from "fs/promises";
12181
12206
  import path32 from "path";
12182
12207
  async function isPathIgnored(projectRoot, relativePath) {
12183
12208
  if (await resolveGitCommonDir(projectRoot) === undefined)
@@ -12198,8 +12223,8 @@ async function resolveLocalExcludePath(projectRoot) {
12198
12223
  return commonDir === undefined ? undefined : path32.join(commonDir, "info", "exclude");
12199
12224
  }
12200
12225
  async function writeExcludeFile(infoDir, excludePath, content) {
12201
- await mkdir7(infoDir, { recursive: true });
12202
- await writeFile5(excludePath, content, "utf8");
12226
+ await mkdir6(infoDir, { recursive: true });
12227
+ await writeFile4(excludePath, content, "utf8");
12203
12228
  }
12204
12229
  async function replaceLocalIgnoreBlock(projectRoot, lines) {
12205
12230
  const commonDir = await resolveGitCommonDir(projectRoot);
@@ -16975,15 +17000,17 @@ async function detectAndResolve(cwd, input, context, opts) {
16975
17000
  return contextual.warning !== undefined ? { decision, warning: contextual.warning } : { decision };
16976
17001
  }
16977
17002
  async function runSelfProtection(cwd, config) {
16978
- const previous = await readState(cwd);
16979
- const selfProtection = evaluateSelfProtection(config, previous);
16980
- if (selfProtection.incidents.length > 0) {
16981
- await appendIncidents(cwd, selfProtection.incidents);
16982
- }
16983
- if (!config.configUnreadable) {
16984
- await writeState(cwd, currentState(config));
16985
- }
16986
- return { findings: selfProtection.findings, warnings: selfProtection.warnings };
17003
+ return withFileLock(path41.join(securityDataRoot(cwd), "raw", "self-protection.lock"), async () => {
17004
+ const previous = await readState(cwd);
17005
+ const selfProtection = evaluateSelfProtection(config, previous);
17006
+ if (selfProtection.incidents.length > 0) {
17007
+ await appendIncidents(cwd, selfProtection.incidents);
17008
+ }
17009
+ if (!config.configUnreadable) {
17010
+ await writeState(cwd, currentState(config));
17011
+ }
17012
+ return { findings: selfProtection.findings, warnings: selfProtection.warnings };
17013
+ });
16987
17014
  }
16988
17015
  async function analyze(cwd, input, opts = {}) {
16989
17016
  const context = await loadAnalysisContext(cwd);
@@ -18252,7 +18279,7 @@ function titleSimilarity(a, b) {
18252
18279
 
18253
18280
  // src/memory/report.ts
18254
18281
  import { randomUUID as randomUUID2 } from "crypto";
18255
- import { access as access2, mkdir as mkdir10, readdir as readdir15, rename as rename4, rm as rm4, stat as stat11, writeFile as writeFile7 } from "fs/promises";
18282
+ import { access as access2, mkdir as mkdir9, readdir as readdir15, rename as rename4, rm as rm4, stat as stat11, writeFile as writeFile6 } from "fs/promises";
18256
18283
  import path65 from "path";
18257
18284
  function runtimeRoot(cwd) {
18258
18285
  return path65.join(cwd, ".metaproject", "runtime", "memory");
@@ -18492,8 +18519,8 @@ class MemoryReportStore {
18492
18519
  const destination = path65.join(searchRoot, runId);
18493
18520
  if (await exists(destination))
18494
18521
  throw new Error(`Memory report run already exists: ${runId}`);
18495
- await mkdir10(searchRoot, { recursive: true });
18496
- await mkdir10(tempRoot, { recursive: true });
18522
+ await mkdir9(searchRoot, { recursive: true });
18523
+ await mkdir9(tempRoot, { recursive: true });
18497
18524
  const staleBefore = this.clock().getTime() - STALE_STAGING_MS;
18498
18525
  for (const name of await readdir15(tempRoot)) {
18499
18526
  const candidate = path65.join(tempRoot, name);
@@ -18502,11 +18529,11 @@ class MemoryReportStore {
18502
18529
  }
18503
18530
  const staging = path65.join(tempRoot, `${runId}.${randomUUID2()}`);
18504
18531
  try {
18505
- await mkdir10(staging);
18532
+ await mkdir9(staging);
18506
18533
  await Promise.all([
18507
- writeFile7(path65.join(staging, "report.json"), `${JSON.stringify(report, null, 2)}
18534
+ writeFile6(path65.join(staging, "report.json"), `${JSON.stringify(report, null, 2)}
18508
18535
  `, "utf8"),
18509
- writeFile7(path65.join(staging, "report.md"), renderMemorySearchReportMarkdown(report), "utf8")
18536
+ writeFile6(path65.join(staging, "report.md"), renderMemorySearchReportMarkdown(report), "utf8")
18510
18537
  ]);
18511
18538
  if (await exists(destination))
18512
18539
  throw new Error(`Memory report run already exists: ${runId}`);
@@ -18851,6 +18878,17 @@ var init_config3 = __esm(() => {
18851
18878
  };
18852
18879
  });
18853
18880
 
18881
+ // src/lib/self-invocation.ts
18882
+ import path81 from "path";
18883
+ function isCompiledBinaryEntry(entry) {
18884
+ return entry.startsWith("/$bunfs/") || /^[A-Za-z]:[\\/]~BUN[\\/]/.test(entry);
18885
+ }
18886
+ function desktopResourceDirectory(entry = process.argv[1] ?? "", executable = process.execPath) {
18887
+ const bin = path81.dirname(executable);
18888
+ return isCompiledBinaryEntry(entry) && path81.basename(bin) === "MacOS" ? path81.resolve(bin, "../Resources") : undefined;
18889
+ }
18890
+ var init_self_invocation = () => {};
18891
+
18854
18892
  // src/gdgraph/treesitter/extract.ts
18855
18893
  function calleeShape(callee) {
18856
18894
  const withoutCall = callee.replace(/\(.*$/s, "").trim();
@@ -19395,7 +19433,7 @@ var init_extract = __esm(() => {
19395
19433
  });
19396
19434
 
19397
19435
  // src/gdgraph/treesitter/grammars.ts
19398
- import path81 from "path";
19436
+ import path82 from "path";
19399
19437
  function grammarAssetId(language) {
19400
19438
  return `tree-sitter-${language}`;
19401
19439
  }
@@ -19411,7 +19449,7 @@ function symbolLanguage(language) {
19411
19449
  async function resolveGrammar(cwd, language, grammarsPath) {
19412
19450
  const id = grammarAssetId(language);
19413
19451
  const lock = await loadAssetsLock(cwd);
19414
- const overrides = grammarsPath ? { [id]: { path: path81.join(grammarsPath, `${id}.wasm`) } } : undefined;
19452
+ const overrides = grammarsPath ? { [id]: { path: path82.join(grammarsPath, `${id}.wasm`) } } : undefined;
19415
19453
  const registry = registryFromLock(lock, overrides);
19416
19454
  const resolved = await resolveAsset(registry, id);
19417
19455
  if (!resolved) {
@@ -19441,7 +19479,7 @@ function toGrammarLanguages(languages) {
19441
19479
  return out;
19442
19480
  }
19443
19481
  function grammarForFile(file, available) {
19444
- const ext = path81.extname(file);
19482
+ const ext = path82.extname(file);
19445
19483
  const preference = ext === ".tsx" ? ["tsx", "typescript"] : ext === ".ts" ? ["typescript"] : ext === ".jsx" || ext === ".js" || ext === ".mjs" || ext === ".cjs" ? ["javascript"] : ext === ".java" ? ["java"] : ext === ".py" ? ["python"] : [];
19446
19484
  for (const language of preference) {
19447
19485
  if (available.includes(language)) {
@@ -19456,6 +19494,7 @@ var init_grammars = __esm(() => {
19456
19494
  });
19457
19495
 
19458
19496
  // src/gdgraph/treesitter/adapter.ts
19497
+ import path83 from "path";
19459
19498
  function describeGrammarDiagnoses(diagnoses) {
19460
19499
  if (diagnoses.length === 0) {
19461
19500
  return "no grammar languages configured";
@@ -19671,7 +19710,12 @@ function normalizeParserApi(dep) {
19671
19710
  return Promise.reject(new Error("web-tree-sitter: no Language.load"));
19672
19711
  };
19673
19712
  return {
19674
- ...init ? { init } : {},
19713
+ ...init ? { init: () => {
19714
+ const resources = desktopResourceDirectory();
19715
+ if (!resources)
19716
+ return init();
19717
+ return init({ locateFile: (name, prefix) => name === "tree-sitter.wasm" ? path83.join(resources, "tree-sitter.wasm") : path83.resolve(prefix, name) });
19718
+ } } : {},
19675
19719
  loadLanguage,
19676
19720
  create: () => new ParserClass
19677
19721
  };
@@ -19695,6 +19739,7 @@ function compareCalls2(a, b) {
19695
19739
  return a.kind < b.kind ? -1 : a.kind > b.kind ? 1 : 0;
19696
19740
  }
19697
19741
  var init_adapter = __esm(() => {
19742
+ init_self_invocation();
19698
19743
  init_seam();
19699
19744
  init_warn_once();
19700
19745
  init_extract();
@@ -19702,8 +19747,8 @@ var init_adapter = __esm(() => {
19702
19747
  });
19703
19748
 
19704
19749
  // src/gdgraph/enrich.ts
19705
- import { mkdir as mkdir14, writeFile as writeFile8 } from "fs/promises";
19706
- import path82 from "path";
19750
+ import { mkdir as mkdir13, writeFile as writeFile7 } from "fs/promises";
19751
+ import path84 from "path";
19707
19752
  async function enrichBuildWithSymbols(cwd, files, resolve, dataDir) {
19708
19753
  const config = await loadGdgraphConfig(cwd);
19709
19754
  const treesitterConfig = {
@@ -19720,11 +19765,11 @@ async function enrichBuildWithSymbols(cwd, files, resolve, dataDir) {
19720
19765
  }
19721
19766
  async function writeSymbolLayer(cwd, layer, dataDir) {
19722
19767
  const storageDir = gdgraphStorageDir(cwd, dataDir);
19723
- await mkdir14(storageDir, { recursive: true });
19724
- await writeFile8(path82.join(storageDir, "symbols.jsonl"), layer.symbols.map((symbol) => JSON.stringify(symbol)).join(`
19768
+ await mkdir13(storageDir, { recursive: true });
19769
+ await writeFile7(path84.join(storageDir, "symbols.jsonl"), layer.symbols.map((symbol) => JSON.stringify(symbol)).join(`
19725
19770
  `) + `
19726
19771
  `, "utf8");
19727
- await writeFile8(path82.join(storageDir, "calls.jsonl"), layer.calls.map((call) => JSON.stringify(call)).join(`
19772
+ await writeFile7(path84.join(storageDir, "calls.jsonl"), layer.calls.map((call) => JSON.stringify(call)).join(`
19728
19773
  `) + `
19729
19774
  `, "utf8");
19730
19775
  }
@@ -19917,11 +19962,11 @@ var NOT_CODE_SCOPED = "none";
19917
19962
  var init_describes = () => {};
19918
19963
 
19919
19964
  // src/sync/provenance.ts
19920
- import { mkdir as mkdir15, readFile as readFile40, writeFile as writeFile9 } from "fs/promises";
19921
- import path83 from "path";
19965
+ import { mkdir as mkdir14, readFile as readFile40, writeFile as writeFile8 } from "fs/promises";
19966
+ import path85 from "path";
19922
19967
  import { spawn } from "child_process";
19923
19968
  function provenancePath(cwd, module) {
19924
- return path83.join(cwd, ".metaproject", "data", module, ".provenance.json");
19969
+ return path85.join(cwd, ".metaproject", "data", module, ".provenance.json");
19925
19970
  }
19926
19971
  function gitCmdResult(cwd, args) {
19927
19972
  return new Promise((resolve) => {
@@ -19966,9 +20011,9 @@ async function recordProvenance(cwd, module, at) {
19966
20011
  if (!head)
19967
20012
  return;
19968
20013
  const file = provenancePath(cwd, module);
19969
- await mkdir15(path83.dirname(file), { recursive: true });
20014
+ await mkdir14(path85.dirname(file), { recursive: true });
19970
20015
  const provenance = { commit: head.commit, branch: head.branch, builtAt: at };
19971
- await writeFile9(file, `${JSON.stringify(provenance, null, 2)}
20016
+ await writeFile8(file, `${JSON.stringify(provenance, null, 2)}
19972
20017
  `, "utf8");
19973
20018
  }
19974
20019
  async function readProvenance(cwd, module) {
@@ -19992,7 +20037,7 @@ var init_provenance = __esm(() => {
19992
20037
  // src/gdgraph/staleness.ts
19993
20038
  import { spawn as spawn2 } from "child_process";
19994
20039
  import { stat as stat12 } from "fs/promises";
19995
- import path84 from "path";
20040
+ import path86 from "path";
19996
20041
  function gitStatusPorcelain(cwd) {
19997
20042
  return new Promise((resolve) => {
19998
20043
  try {
@@ -20015,10 +20060,10 @@ function gitStatusPorcelain(cwd) {
20015
20060
  });
20016
20061
  }
20017
20062
  function nodesJsonlPath(cwd) {
20018
- return path84.join(cwd, ".metaproject", "data", "gdgraph", "storage", "nodes.jsonl");
20063
+ return path86.join(cwd, ".metaproject", "data", "gdgraph", "storage", "nodes.jsonl");
20019
20064
  }
20020
20065
  function gdgraphConfigPath2(cwd) {
20021
- return path84.join(cwd, ".metaproject", "gdgraph.config.json");
20066
+ return path86.join(cwd, ".metaproject", "gdgraph.config.json");
20022
20067
  }
20023
20068
  function categorizeStatusEntries(entries, rootPrefix) {
20024
20069
  const metaprojectPrefix = `${rootPrefix}.metaproject/`;
@@ -20113,7 +20158,7 @@ async function checkGraphStaleness(cwd, statusObservation) {
20113
20158
  }
20114
20159
  } else {
20115
20160
  provenanceMissing = true;
20116
- const logsHeadStat = await stat12(path84.join(cwd, ".git", "logs", "HEAD")).catch(() => null);
20161
+ const logsHeadStat = await stat12(path86.join(cwd, ".git", "logs", "HEAD")).catch(() => null);
20117
20162
  if (logsHeadStat && logsHeadStat.mtimeMs > nodesStat.mtimeMs) {
20118
20163
  reasons.push("repo HEAD moved since the graph was built (no build provenance recorded; inferred from .git/logs/HEAD)");
20119
20164
  }
@@ -20141,7 +20186,7 @@ async function checkGraphStaleness(cwd, statusObservation) {
20141
20186
  if (projectRelative === null) {
20142
20187
  continue;
20143
20188
  }
20144
- const fileStat = await stat12(path84.join(cwd, projectRelative)).catch(() => null);
20189
+ const fileStat = await stat12(path86.join(cwd, projectRelative)).catch(() => null);
20145
20190
  if (fileStat && fileStat.mtimeMs > nodesStat.mtimeMs) {
20146
20191
  postBuildEdits.push(displayPath);
20147
20192
  }
@@ -20277,15 +20322,15 @@ var init_types3 = __esm(() => {
20277
20322
 
20278
20323
  // src/wiki/collect.ts
20279
20324
  import { readFile as readFile41, readdir as readdir16 } from "fs/promises";
20280
- import path85 from "path";
20325
+ import path87 from "path";
20281
20326
  function wikiRootPath(cwd) {
20282
- return path85.join(cwd, ".metaproject", "wiki");
20327
+ return path87.join(cwd, ".metaproject", "wiki");
20283
20328
  }
20284
20329
  async function collectPages(cwd) {
20285
20330
  const root = wikiRootPath(cwd);
20286
20331
  const pages = [];
20287
20332
  for (const { type, folder } of WIKI_PAGE_TYPES) {
20288
- const dir = path85.join(root, folder);
20333
+ const dir = path87.join(root, folder);
20289
20334
  let names;
20290
20335
  try {
20291
20336
  names = await readdir16(dir);
@@ -20300,7 +20345,7 @@ async function collectPages(cwd) {
20300
20345
  if (!entry.endsWith(".md")) {
20301
20346
  continue;
20302
20347
  }
20303
- const absolutePath = path85.join(dir, entry);
20348
+ const absolutePath = path87.join(dir, entry);
20304
20349
  let content;
20305
20350
  try {
20306
20351
  content = await readFile41(absolutePath, "utf8");
@@ -21160,10 +21205,10 @@ var MEMORY_EMBEDDING_ID = "memory.embedding", DEFAULT_EMBED_DIMS = 96;
21160
21205
 
21161
21206
  // src/memory/embedding/index.ts
21162
21207
  import { createHash as createHash14 } from "crypto";
21163
- import { mkdir as mkdir16, readFile as readFile42, writeFile as writeFile10 } from "fs/promises";
21164
- import path86 from "path";
21208
+ import { mkdir as mkdir15, readFile as readFile42, writeFile as writeFile9 } from "fs/promises";
21209
+ import path88 from "path";
21165
21210
  function embeddingsDir(cwd) {
21166
- return path86.join(cwd, ".metaproject", "data", "memory", "embeddings");
21211
+ return path88.join(cwd, ".metaproject", "data", "memory", "embeddings");
21167
21212
  }
21168
21213
  function entryText(entry) {
21169
21214
  return `${entry.title}
@@ -21191,18 +21236,18 @@ async function buildEmbeddingIndex(cwd, entries, embedder, model, now) {
21191
21236
  entryCount: records.length
21192
21237
  };
21193
21238
  const dir = embeddingsDir(cwd);
21194
- await mkdir16(dir, { recursive: true });
21195
- await writeFile10(path86.join(dir, "index.meta.json"), `${JSON.stringify(meta, null, 2)}
21239
+ await mkdir15(dir, { recursive: true });
21240
+ await writeFile9(path88.join(dir, "index.meta.json"), `${JSON.stringify(meta, null, 2)}
21196
21241
  `, "utf8");
21197
- await writeFile10(path86.join(dir, "vectors.jsonl"), records.map((record) => JSON.stringify(record)).join(`
21242
+ await writeFile9(path88.join(dir, "vectors.jsonl"), records.map((record) => JSON.stringify(record)).join(`
21198
21243
  `) + (records.length > 0 ? `
21199
21244
  ` : ""), "utf8");
21200
21245
  return toIndex(meta, records);
21201
21246
  }
21202
21247
  async function loadEmbeddingIndex(cwd) {
21203
21248
  const dir = embeddingsDir(cwd);
21204
- const metaPath = path86.join(dir, "index.meta.json");
21205
- const vectorsPath = path86.join(dir, "vectors.jsonl");
21249
+ const metaPath = path88.join(dir, "index.meta.json");
21250
+ const vectorsPath = path88.join(dir, "vectors.jsonl");
21206
21251
  if (!await pathExists(metaPath) || !await pathExists(vectorsPath)) {
21207
21252
  return null;
21208
21253
  }
@@ -21283,10 +21328,10 @@ var init_embedding = __esm(() => {
21283
21328
  });
21284
21329
 
21285
21330
  // src/wiki/section-tombstone.ts
21286
- import path87 from "path";
21331
+ import path89 from "path";
21287
21332
  import { stat as stat13 } from "fs/promises";
21288
21333
  function sectionRegistryPath(cwd) {
21289
- return path87.join(cwd, ".metaproject", "wiki", ".sections.json");
21334
+ return path89.join(cwd, ".metaproject", "wiki", ".sections.json");
21290
21335
  }
21291
21336
  function emptySectionRegistry() {
21292
21337
  return { version: SECTION_REGISTRY_VERSION, entries: [], tombstones: [], lifted: [] };
@@ -21588,10 +21633,10 @@ var init_section_tombstone = __esm(() => {
21588
21633
 
21589
21634
  // src/memory/cross-layer.ts
21590
21635
  import { readFile as readFile43 } from "fs/promises";
21591
- import path88 from "path";
21636
+ import path90 from "path";
21592
21637
  function extractWikiReferences(entryRelativePath, entryAbsolutePath, content, wikiRoot) {
21593
21638
  const references = [];
21594
- const entryDir = path88.dirname(entryAbsolutePath);
21639
+ const entryDir = path90.dirname(entryAbsolutePath);
21595
21640
  const lines = content.split(`
21596
21641
  `);
21597
21642
  for (let index = 0;index < lines.length; index += 1) {
@@ -21606,16 +21651,16 @@ function extractWikiReferences(entryRelativePath, entryAbsolutePath, content, wi
21606
21651
  if (withoutAnchor.length === 0) {
21607
21652
  continue;
21608
21653
  }
21609
- const absolute = path88.resolve(entryDir, withoutAnchor);
21610
- const relativeToWiki = path88.relative(wikiRoot, absolute);
21611
- if (relativeToWiki.startsWith("..") || path88.isAbsolute(relativeToWiki)) {
21654
+ const absolute = path90.resolve(entryDir, withoutAnchor);
21655
+ const relativeToWiki = path90.relative(wikiRoot, absolute);
21656
+ if (relativeToWiki.startsWith("..") || path90.isAbsolute(relativeToWiki)) {
21612
21657
  continue;
21613
21658
  }
21614
21659
  references.push({
21615
21660
  entry: entryRelativePath,
21616
21661
  kind: "page-path",
21617
21662
  raw: href,
21618
- target: relativeToWiki.split(path88.sep).join("/"),
21663
+ target: relativeToWiki.split(path90.sep).join("/"),
21619
21664
  line
21620
21665
  });
21621
21666
  }
@@ -21635,7 +21680,7 @@ function isDangling(finding) {
21635
21680
  return finding.state !== "intact";
21636
21681
  }
21637
21682
  async function loadWikiKnowledgeView(cwd) {
21638
- const wikiRoot = path88.join(cwd, ".metaproject", "wiki");
21683
+ const wikiRoot = path90.join(cwd, ".metaproject", "wiki");
21639
21684
  const pages = await collectPages(cwd);
21640
21685
  const index = buildSectionIndex(await Promise.all(pages.map(async (page) => ({
21641
21686
  page,
@@ -21853,7 +21898,7 @@ function round2(value) {
21853
21898
  var init_dedup = () => {};
21854
21899
 
21855
21900
  // src/memory/check.ts
21856
- import path89 from "path";
21901
+ import path91 from "path";
21857
21902
  async function checkMemory(cwd, config) {
21858
21903
  const entries = await collectEntries(cwd);
21859
21904
  const issues = [];
@@ -21869,7 +21914,7 @@ async function checkMemory(cwd, config) {
21869
21914
  }
21870
21915
  for (const file of entry.scopes.files) {
21871
21916
  const clean = file.replace(/^`|`$/g, "");
21872
- if (!await pathExists(path89.resolve(cwd, clean))) {
21917
+ if (!await pathExists(path91.resolve(cwd, clean))) {
21873
21918
  issues.push({ path: entry.relativePath, kind: "link", message: `related file not found: ${clean}` });
21874
21919
  }
21875
21920
  }
@@ -21923,13 +21968,13 @@ var init_check = __esm(() => {
21923
21968
  });
21924
21969
 
21925
21970
  // src/memory/write.ts
21926
- import { mkdir as mkdir17, open as open3, readFile as readFile44, rename as rename5, rm as rm5, writeFile as writeFile11 } from "fs/promises";
21927
- import path90 from "path";
21971
+ import { mkdir as mkdir16, open as open3, readFile as readFile44, rename as rename5, rm as rm5, writeFile as writeFile10 } from "fs/promises";
21972
+ import path92 from "path";
21928
21973
  async function resolveCanonicalEntryPath(cwd, relativePath) {
21929
- const root = path90.resolve(memoryRoot(cwd));
21930
- const absolutePath = path90.resolve(root, relativePath);
21931
- const normalized = toPosix2(path90.relative(root, absolutePath));
21932
- if (!normalized || normalized.startsWith("../") || path90.isAbsolute(normalized) || !normalized.endsWith(".md")) {
21974
+ const root = path92.resolve(memoryRoot(cwd));
21975
+ const absolutePath = path92.resolve(root, relativePath);
21976
+ const normalized = toPosix2(path92.relative(root, absolutePath));
21977
+ if (!normalized || normalized.startsWith("../") || path92.isAbsolute(normalized) || !normalized.endsWith(".md")) {
21933
21978
  return null;
21934
21979
  }
21935
21980
  return { absolutePath, relativePath: normalized };
@@ -22025,11 +22070,11 @@ function validateNextEntry(relativePath, content) {
22025
22070
  return null;
22026
22071
  }
22027
22072
  async function replaceAtomically(target, content) {
22028
- const dir = path90.dirname(target);
22029
- await mkdir17(dir, { recursive: true });
22030
- const tmp = path90.join(dir, `.${path90.basename(target)}.keryx-tmp-${process.pid}-${Math.random().toString(16).slice(2)}`);
22073
+ const dir = path92.dirname(target);
22074
+ await mkdir16(dir, { recursive: true });
22075
+ const tmp = path92.join(dir, `.${path92.basename(target)}.keryx-tmp-${process.pid}-${Math.random().toString(16).slice(2)}`);
22031
22076
  try {
22032
- await writeFile11(tmp, content, "utf8");
22077
+ await writeFile10(tmp, content, "utf8");
22033
22078
  const file = await open3(tmp, "r");
22034
22079
  try {
22035
22080
  await file.sync();
@@ -22063,7 +22108,7 @@ function header(content, name) {
22063
22108
  return content.match(new RegExp(`^${name}:\\s*(.+)$`, "mi"))?.[1]?.trim() ?? null;
22064
22109
  }
22065
22110
  function toPosix2(value) {
22066
- return value.split(path90.sep).join("/");
22111
+ return value.split(path92.sep).join("/");
22067
22112
  }
22068
22113
  function message(cause) {
22069
22114
  return cause instanceof Error ? cause.message : String(cause);
@@ -22077,9 +22122,9 @@ var init_write = __esm(() => {
22077
22122
  // src/memory/ingest.ts
22078
22123
  import { existsSync as existsSync10 } from "fs";
22079
22124
  import { readFile as readFile45 } from "fs/promises";
22080
- import path91 from "path";
22125
+ import path93 from "path";
22081
22126
  async function ingestMemory(cwd, source, filePath, config, now) {
22082
- const absolute = path91.resolve(cwd, filePath);
22127
+ const absolute = path93.resolve(cwd, filePath);
22083
22128
  if (!await pathExists(absolute)) {
22084
22129
  throw new Error(`Ingest source not found: ${filePath}`);
22085
22130
  }
@@ -22096,8 +22141,8 @@ async function ingestMemory(cwd, source, filePath, config, now) {
22096
22141
  const securityWarnings = [];
22097
22142
  const securitySkipped = [];
22098
22143
  let skippedDuplicates = 0;
22099
- const dir = path91.join(memoryRoot(cwd), folder);
22100
- const link = path91.relative(cwd, absolute);
22144
+ const dir = path93.join(memoryRoot(cwd), folder);
22145
+ const link = path93.relative(cwd, absolute);
22101
22146
  const date = dateString(now);
22102
22147
  for (const text of candidates) {
22103
22148
  const title = toTitle(text);
@@ -22278,7 +22323,7 @@ function uniqueSlug(dir, title) {
22278
22323
  const base = slugify2(title) || "entry";
22279
22324
  let slug = base;
22280
22325
  let counter = 2;
22281
- while (existsSync10(path91.join(dir, `${slug}.md`))) {
22326
+ while (existsSync10(path93.join(dir, `${slug}.md`))) {
22282
22327
  slug = `${base}-${counter}`;
22283
22328
  counter += 1;
22284
22329
  }
@@ -22313,7 +22358,7 @@ var init_ingest = __esm(() => {
22313
22358
 
22314
22359
  // src/memory/supersede.ts
22315
22360
  import { readFile as readFile46 } from "fs/promises";
22316
- import path92 from "path";
22361
+ import path94 from "path";
22317
22362
  async function supersedeEntry(input, now) {
22318
22363
  const date = input.date ?? now.toISOString().slice(0, 10);
22319
22364
  const today = now.toISOString().slice(0, 10);
@@ -22373,12 +22418,12 @@ async function supersedeEntry(input, now) {
22373
22418
  async function resolveEntryPath(cwd, raw) {
22374
22419
  const root = memoryRoot(cwd);
22375
22420
  const candidates = [
22376
- path92.resolve(cwd, raw),
22377
- path92.resolve(root, raw),
22378
- path92.isAbsolute(raw) ? raw : path92.join(cwd, raw)
22421
+ path94.resolve(cwd, raw),
22422
+ path94.resolve(root, raw),
22423
+ path94.isAbsolute(raw) ? raw : path94.join(cwd, raw)
22379
22424
  ];
22380
22425
  for (const absolute of candidates) {
22381
- const confined = await resolveCanonicalEntryPath(cwd, path92.relative(root, absolute));
22426
+ const confined = await resolveCanonicalEntryPath(cwd, path94.relative(root, absolute));
22382
22427
  if (confined && await pathExists(confined.absolutePath)) {
22383
22428
  return { absolute: confined.absolutePath, relative: confined.relativePath };
22384
22429
  }
@@ -22573,10 +22618,10 @@ __export(exports_service3, {
22573
22618
  selectHandoffEntries: () => selectHandoffEntries
22574
22619
  });
22575
22620
  import { createHash as createHash15 } from "crypto";
22576
- import { mkdir as mkdir18, readFile as readFile47, writeFile as writeFile12 } from "fs/promises";
22577
- import path93 from "path";
22621
+ import { mkdir as mkdir17, readFile as readFile47, writeFile as writeFile11 } from "fs/promises";
22622
+ import path95 from "path";
22578
22623
  function dataRoot2(cwd) {
22579
- return path93.join(cwd, ".metaproject", "data", "memory");
22624
+ return path95.join(cwd, ".metaproject", "data", "memory");
22580
22625
  }
22581
22626
  function createMemoryService() {
22582
22627
  const reportStore = createMemoryReportStore();
@@ -22591,9 +22636,9 @@ function createMemoryService() {
22591
22636
  if (!/^[a-z0-9][a-z0-9-]*$/.test(slug)) {
22592
22637
  throw new Error(`Invalid slug: ${slug}. Use lowercase letters, digits, and hyphens.`);
22593
22638
  }
22594
- const dir = path93.join(memoryRoot(input.cwd), typeConfig.folder);
22595
- const filePath = path93.join(dir, `${slug}.md`);
22596
- const relativePath = path93.relative(input.cwd, filePath);
22639
+ const dir = path95.join(memoryRoot(input.cwd), typeConfig.folder);
22640
+ const filePath = path95.join(dir, `${slug}.md`);
22641
+ const relativePath = path95.relative(input.cwd, filePath);
22597
22642
  if (await pathExists(filePath) && !input.force) {
22598
22643
  throw new Error(`Entry already exists: ${relativePath}. Use --force to overwrite.`);
22599
22644
  }
@@ -22624,10 +22669,10 @@ function createMemoryService() {
22624
22669
  async index(input) {
22625
22670
  const entries = await collectEntries(input.cwd);
22626
22671
  const generatedAt = new Date().toISOString();
22627
- const indexDir = input.indexDir ?? path93.join(dataRoot2(input.cwd), "index");
22628
- await mkdir18(indexDir, { recursive: true });
22629
- const indexPath = path93.join(indexDir, "index.json");
22630
- await writeFile12(indexPath, `${JSON.stringify({
22672
+ const indexDir = input.indexDir ?? path95.join(dataRoot2(input.cwd), "index");
22673
+ await mkdir17(indexDir, { recursive: true });
22674
+ const indexPath = path95.join(indexDir, "index.json");
22675
+ await writeFile11(indexPath, `${JSON.stringify({
22631
22676
  catalogVersion: 1,
22632
22677
  sourceFingerprint: createHash15("sha256").update(JSON.stringify(entries.map((e) => ({
22633
22678
  path: e.relativePath,
@@ -22647,7 +22692,7 @@ function createMemoryService() {
22647
22692
  }, null, 2)}
22648
22693
  `, "utf8");
22649
22694
  const result = {
22650
- path: path93.relative(input.cwd, indexPath),
22695
+ path: path95.relative(input.cwd, indexPath),
22651
22696
  entryCount: entries.length,
22652
22697
  generatedAt
22653
22698
  };
@@ -22660,7 +22705,7 @@ function createMemoryService() {
22660
22705
  const built = await buildEmbeddingIndex(input.cwd, entries, embedder.embed, embedder.model, new Date);
22661
22706
  result.embeddings = {
22662
22707
  built: true,
22663
- path: path93.relative(input.cwd, embeddingsDir(input.cwd)),
22708
+ path: path95.relative(input.cwd, embeddingsDir(input.cwd)),
22664
22709
  vectorCount: built.meta.entryCount,
22665
22710
  model: built.meta.model
22666
22711
  };
@@ -23262,7 +23307,7 @@ var init_ask = __esm(() => {
23262
23307
  });
23263
23308
 
23264
23309
  // src/wiki/backlinks.ts
23265
- import path94 from "path";
23310
+ import path96 from "path";
23266
23311
  function extractCodePaths(content) {
23267
23312
  const out = [];
23268
23313
  let match;
@@ -23292,8 +23337,8 @@ function resolveLink(fromRepoPath, raw) {
23292
23337
  const clean = (raw.split("#")[0] ?? "").trim();
23293
23338
  if (!clean)
23294
23339
  return "";
23295
- const fromDir = path94.posix.dirname(fromRepoPath.split(path94.sep).join("/"));
23296
- return path94.posix.normalize(path94.posix.join(fromDir, clean));
23340
+ const fromDir = path96.posix.dirname(fromRepoPath.split(path96.sep).join("/"));
23341
+ return path96.posix.normalize(path96.posix.join(fromDir, clean));
23297
23342
  }
23298
23343
  function buildBacklinkIndex(pages) {
23299
23344
  const index = new Map;
@@ -23307,18 +23352,18 @@ function buildBacklinkIndex(pages) {
23307
23352
  }
23308
23353
  };
23309
23354
  for (const page of pages) {
23310
- const from = page.repoPath.split(path94.sep).join("/");
23355
+ const from = page.repoPath.split(path96.sep).join("/");
23311
23356
  for (const raw of extractLinks(page.content))
23312
23357
  add(resolveLink(from, raw), from);
23313
23358
  for (const raw of extractCodePaths(page.content))
23314
- add(path94.posix.normalize(raw), from);
23359
+ add(path96.posix.normalize(raw), from);
23315
23360
  }
23316
23361
  for (const list of index.values())
23317
23362
  list.sort();
23318
23363
  return index;
23319
23364
  }
23320
23365
  function backlinksFor(index, targetRepoPath) {
23321
- const key = path94.posix.normalize(targetRepoPath.split(path94.sep).join("/"));
23366
+ const key = path96.posix.normalize(targetRepoPath.split(path96.sep).join("/"));
23322
23367
  return index.get(key) ?? [];
23323
23368
  }
23324
23369
  var LINK, CODE_SPAN, FILE_LIKE;
@@ -23330,8 +23375,8 @@ var init_backlinks = __esm(() => {
23330
23375
 
23331
23376
  // src/ctx/assembly.ts
23332
23377
  import { createHash as createHash16 } from "crypto";
23333
- import { mkdir as mkdir19, rename as rename6, writeFile as writeFile13 } from "fs/promises";
23334
- import path95 from "path";
23378
+ import { mkdir as mkdir18, rename as rename6, writeFile as writeFile12 } from "fs/promises";
23379
+ import path97 from "path";
23335
23380
  function assembleContext(input) {
23336
23381
  let items = 0;
23337
23382
  let tokens = 0;
@@ -23375,11 +23420,11 @@ async function recordNoContentContext(input) {
23375
23420
  return assembly;
23376
23421
  }
23377
23422
  async function recordContextAssembly(input) {
23378
- const directory = path95.join(input.workspaceRoot, ".metaproject", "context-operations", "traces");
23379
- await mkdir19(directory, { recursive: true });
23380
- const target = path95.join(directory, path95.basename(input.assembly.traceRef));
23423
+ const directory = path97.join(input.workspaceRoot, ".metaproject", "context-operations", "traces");
23424
+ await mkdir18(directory, { recursive: true });
23425
+ const target = path97.join(directory, path97.basename(input.assembly.traceRef));
23381
23426
  const temporary = `${target}.${process.pid}.tmp`;
23382
- await writeFile13(temporary, `${JSON.stringify({ schemaVersion: "1.0", correlationId: input.correlationId, outcome: input.outcome, configurationRevision: input.assembly.configurationRevision, policy: { ref: input.assembly.policyRef, revision: input.assembly.policyRevision }, selected: input.assembly.selected, omittedOptional: input.assembly.omittedOptional, partial: input.assembly.partial })}
23427
+ await writeFile12(temporary, `${JSON.stringify({ schemaVersion: "1.0", correlationId: input.correlationId, outcome: input.outcome, configurationRevision: input.assembly.configurationRevision, policy: { ref: input.assembly.policyRef, revision: input.assembly.policyRevision }, selected: input.assembly.selected, omittedOptional: input.assembly.omittedOptional, partial: input.assembly.partial })}
23383
23428
  `, { mode: 384 });
23384
23429
  await rename6(temporary, target);
23385
23430
  }
@@ -23777,9 +23822,9 @@ var init_evidence = __esm(() => {
23777
23822
  });
23778
23823
 
23779
23824
  // src/wiki/config.ts
23780
- import path96 from "path";
23825
+ import path98 from "path";
23781
23826
  function wikiConfigPath(cwd) {
23782
- return path96.join(cwd, ".metaproject", "wiki.config.json");
23827
+ return path98.join(cwd, ".metaproject", "wiki.config.json");
23783
23828
  }
23784
23829
  function mergeWikiConfig(parsed) {
23785
23830
  const base = DEFAULT_WIKI_CONFIG;
@@ -23856,13 +23901,13 @@ var init_config4 = __esm(() => {
23856
23901
 
23857
23902
  // src/wiki/history.ts
23858
23903
  import { createHash as createHash17, randomBytes as randomBytes5 } from "crypto";
23859
- import { appendFile as appendFile4, mkdir as mkdir20, open as open4, readFile as readFile49, rm as rm6, stat as stat14, writeFile as writeFile14 } from "fs/promises";
23860
- import path97 from "path";
23904
+ import { appendFile as appendFile4, mkdir as mkdir19, open as open4, readFile as readFile49, rm as rm6, stat as stat14, writeFile as writeFile13 } from "fs/promises";
23905
+ import path99 from "path";
23861
23906
  function wikiRootPath2(cwd) {
23862
- return path97.join(cwd, ".metaproject", "wiki");
23907
+ return path99.join(cwd, ".metaproject", "wiki");
23863
23908
  }
23864
23909
  function wikiHistoryRoot(cwd) {
23865
- return path97.join(cwd, ".metaproject", "data", "gdwiki", "history");
23910
+ return path99.join(cwd, ".metaproject", "data", "gdwiki", "history");
23866
23911
  }
23867
23912
  function newWikiRunId(now = new Date) {
23868
23913
  const stamp = now.toISOString().replace(/[-:]/g, "").replace(/\.\d+Z$/, "Z");
@@ -23883,29 +23928,29 @@ async function openWikiWriteContext(cwd, command) {
23883
23928
  return createWikiWriteContext(cwd, command, { keep: (await loadWikiConfig(cwd)).history.keep });
23884
23929
  }
23885
23930
  function wikiPageKey(cwd, absolutePath) {
23886
- const relative = path97.relative(wikiRootPath2(cwd), path97.resolve(absolutePath));
23887
- if (relative === "" || relative.startsWith("..") || path97.isAbsolute(relative)) {
23931
+ const relative = path99.relative(wikiRootPath2(cwd), path99.resolve(absolutePath));
23932
+ if (relative === "" || relative.startsWith("..") || path99.isAbsolute(relative)) {
23888
23933
  throw new Error(`not a wiki page: ${absolutePath}`);
23889
23934
  }
23890
23935
  return toPosix(relative);
23891
23936
  }
23892
23937
  function assertPageKey(page) {
23893
23938
  const segments = page.split("/");
23894
- if (page.length === 0 || page.includes("\\") || path97.isAbsolute(page) || segments.some((segment) => segment === "" || segment === "." || segment === "..")) {
23939
+ if (page.length === 0 || page.includes("\\") || path99.isAbsolute(page) || segments.some((segment) => segment === "" || segment === "." || segment === "..")) {
23895
23940
  throw new Error(`not a wiki page path: ${page}`);
23896
23941
  }
23897
23942
  return page;
23898
23943
  }
23899
23944
  function pageHistoryDir(cwd, page) {
23900
- return path97.join(wikiHistoryRoot(cwd), ...assertPageKey(page).replace(/\.md$/i, "").split("/"));
23945
+ return path99.join(wikiHistoryRoot(cwd), ...assertPageKey(page).replace(/\.md$/i, "").split("/"));
23901
23946
  }
23902
23947
  function pagePath(cwd, page) {
23903
- return path97.join(wikiRootPath2(cwd), ...assertPageKey(page).split("/"));
23948
+ return path99.join(wikiRootPath2(cwd), ...assertPageKey(page).split("/"));
23904
23949
  }
23905
23950
  function versionFilePath(cwd, page, file) {
23906
23951
  const dir = pageHistoryDir(cwd, page);
23907
- const target = path97.join(dir, file);
23908
- if (!VERSION_FILE.test(file) || path97.dirname(target) !== dir) {
23952
+ const target = path99.join(dir, file);
23953
+ if (!VERSION_FILE.test(file) || path99.dirname(target) !== dir) {
23909
23954
  throw new Error(`history index names an invalid version file for ${page}: ${file}`);
23910
23955
  }
23911
23956
  return target;
@@ -23978,7 +24023,7 @@ function parsePageHistoryIndex(markdown, page) {
23978
24023
  return { page, rows };
23979
24024
  }
23980
24025
  async function readPageHistory(cwd, page) {
23981
- const indexPath = path97.join(pageHistoryDir(cwd, page), INDEX_FILE);
24026
+ const indexPath = path99.join(pageHistoryDir(cwd, page), INDEX_FILE);
23982
24027
  const raw = await readBufferOrNull(indexPath);
23983
24028
  if (raw === null)
23984
24029
  return null;
@@ -23990,9 +24035,9 @@ async function readPageHistory(cwd, page) {
23990
24035
  }
23991
24036
  async function storeVersion(cwd, page, version, at, content) {
23992
24037
  const fileName = `${versionLabel(version)}-${at.replace(/[:.]/g, "-")}.md`;
23993
- const target = path97.join(pageHistoryDir(cwd, page), fileName);
23994
- await mkdir20(path97.dirname(target), { recursive: true });
23995
- await writeFile14(target, content);
24038
+ const target = path99.join(pageHistoryDir(cwd, page), fileName);
24039
+ await mkdir19(path99.dirname(target), { recursive: true });
24040
+ await writeFile13(target, content);
23996
24041
  if (sha2562(await readFile49(target)) !== sha2562(content)) {
23997
24042
  throw new Error(`history: stored version does not match the page bytes: ${target}`);
23998
24043
  }
@@ -24029,11 +24074,11 @@ function planPrune(history, keep, maxRows = MAX_INDEX_ROWS) {
24029
24074
  }
24030
24075
  async function ensureHistoryRoot(cwd) {
24031
24076
  const root = wikiHistoryRoot(cwd);
24032
- const ignore = path97.join(root, ".gitignore");
24077
+ const ignore = path99.join(root, ".gitignore");
24033
24078
  if (await readBufferOrNull(ignore))
24034
24079
  return;
24035
- await mkdir20(root, { recursive: true });
24036
- await writeFile14(ignore, `# keryx wiki page history (flow 367): local undo state, never committed.
24080
+ await mkdir19(root, { recursive: true });
24081
+ await writeFile13(ignore, `# keryx wiki page history (flow 367): local undo state, never committed.
24037
24082
  *
24038
24083
  `, "utf8");
24039
24084
  }
@@ -24059,14 +24104,14 @@ async function endsWithoutNewline(file) {
24059
24104
  }
24060
24105
  async function appendRun(cwd, entry) {
24061
24106
  const root = wikiHistoryRoot(cwd);
24062
- const file = path97.join(root, RUNS_FILE);
24107
+ const file = path99.join(root, RUNS_FILE);
24063
24108
  const lead = await endsWithoutNewline(file) ? `
24064
24109
  ` : "";
24065
24110
  await appendFile4(file, `${lead}${JSON.stringify(entry)}
24066
24111
  `, "utf8");
24067
24112
  if ((await stat14(file)).size <= MAX_RUNS_BYTES)
24068
24113
  return;
24069
- await withFileLock(path97.join(root, ".runs.lock"), async () => {
24114
+ await withFileLock(path99.join(root, ".runs.lock"), async () => {
24070
24115
  if ((await stat14(file)).size <= MAX_RUNS_BYTES)
24071
24116
  return;
24072
24117
  const lines = (await readFile49(file, "utf8")).split(`
@@ -24080,7 +24125,7 @@ async function mutatePage(ctx, absolutePath, next) {
24080
24125
  const page = wikiPageKey(ctx.cwd, absolutePath);
24081
24126
  const dir = pageHistoryDir(ctx.cwd, page);
24082
24127
  await ensureHistoryRoot(ctx.cwd);
24083
- return withFileLock(path97.join(path97.dirname(dir), `.${path97.basename(dir)}.lock`), async () => {
24128
+ return withFileLock(path99.join(path99.dirname(dir), `.${path99.basename(dir)}.lock`), async () => {
24084
24129
  const live = await readBufferOrNull(absolutePath);
24085
24130
  if (next === null ? live === null : live !== null && live.equals(next)) {
24086
24131
  return { changed: false };
@@ -24104,15 +24149,15 @@ async function mutatePage(ctx, absolutePath, next) {
24104
24149
  if (next === null) {
24105
24150
  await rm6(absolutePath, { force: true });
24106
24151
  } else {
24107
- await mkdir20(path97.dirname(absolutePath), { recursive: true });
24108
- await writeFile14(absolutePath, next);
24152
+ await mkdir19(path99.dirname(absolutePath), { recursive: true });
24153
+ await writeFile13(absolutePath, next);
24109
24154
  }
24110
24155
  } catch (error) {
24111
24156
  if (VERSION_FILE.test(row.file))
24112
24157
  await rm6(versionFilePath(ctx.cwd, page, row.file), { force: true });
24113
24158
  throw error;
24114
24159
  }
24115
- await writeFileAtomic(path97.join(dir, INDEX_FILE), renderPageHistoryIndex(history));
24160
+ await writeFileAtomic(path99.join(dir, INDEX_FILE), renderPageHistoryIndex(history));
24116
24161
  for (const file of pruned)
24117
24162
  await rm6(versionFilePath(ctx.cwd, page, file), { force: true });
24118
24163
  return { changed: true, action };
@@ -24125,7 +24170,7 @@ async function deleteWikiPage(ctx, absolutePath) {
24125
24170
  return mutatePage(ctx, absolutePath, null);
24126
24171
  }
24127
24172
  async function readWikiRuns(cwd) {
24128
- const raw = await readBufferOrNull(path97.join(wikiHistoryRoot(cwd), RUNS_FILE));
24173
+ const raw = await readBufferOrNull(path99.join(wikiHistoryRoot(cwd), RUNS_FILE));
24129
24174
  if (raw === null)
24130
24175
  return [];
24131
24176
  const entries = [];
@@ -24817,7 +24862,7 @@ var init_page_invariants = __esm(() => {
24817
24862
  });
24818
24863
 
24819
24864
  // src/wiki/readme-links.ts
24820
- import path98 from "path";
24865
+ import path100 from "path";
24821
24866
  function rewriteReadmeLinks(text, readmeDir, pageLink) {
24822
24867
  return text.replace(MARKDOWN_LINK, (whole, bang, label, target) => {
24823
24868
  if (target === "" || HAS_SCHEME.test(target)) {
@@ -24827,7 +24872,7 @@ function rewriteReadmeLinks(text, readmeDir, pageLink) {
24827
24872
  if (filePart === "") {
24828
24873
  return label;
24829
24874
  }
24830
- const resolved = path98.posix.normalize(filePart.startsWith("/") ? filePart.replace(/^\/+/, "") : path98.posix.join(readmeDir, filePart));
24875
+ const resolved = path100.posix.normalize(filePart.startsWith("/") ? filePart.replace(/^\/+/, "") : path100.posix.join(readmeDir, filePart));
24831
24876
  const codePath = resolved.replace(/\/+$/, "");
24832
24877
  if (codePath === "" || codePath === "." || codePath === ".." || codePath.startsWith("../")) {
24833
24878
  return label;
@@ -24842,12 +24887,12 @@ function rewriteReadmeLinks(text, readmeDir, pageLink) {
24842
24887
  });
24843
24888
  }
24844
24889
  function moduleOfTarget(filePart, codePath) {
24845
- const base = path98.posix.basename(codePath);
24890
+ const base = path100.posix.basename(codePath);
24846
24891
  if (filePart.endsWith("/") || !/\.[A-Za-z0-9]+$/.test(base)) {
24847
24892
  return codePath;
24848
24893
  }
24849
24894
  if (DOC_ENTRY.test(base)) {
24850
- const dir = path98.posix.dirname(codePath);
24895
+ const dir = path100.posix.dirname(codePath);
24851
24896
  return dir === "." ? null : dir;
24852
24897
  }
24853
24898
  return null;
@@ -25294,16 +25339,16 @@ __export(exports_service4, {
25294
25339
  });
25295
25340
  import { spawn as spawn3 } from "child_process";
25296
25341
  import { createHash as createHash19 } from "crypto";
25297
- import { mkdir as mkdir21, readFile as readFile50, readdir as readdir17, writeFile as writeFile15 } from "fs/promises";
25298
- import path99 from "path";
25342
+ import { mkdir as mkdir20, readFile as readFile50, readdir as readdir17, writeFile as writeFile14 } from "fs/promises";
25343
+ import path101 from "path";
25299
25344
  function wikiRootPath3(cwd) {
25300
- return path99.join(cwd, ".metaproject", "wiki");
25345
+ return path101.join(cwd, ".metaproject", "wiki");
25301
25346
  }
25302
25347
  function dataRootPath(cwd) {
25303
- return path99.join(cwd, ".metaproject", "data", "gdwiki");
25348
+ return path101.join(cwd, ".metaproject", "data", "gdwiki");
25304
25349
  }
25305
25350
  function linkCheckReportPath(cwd) {
25306
- return path99.join(dataRootPath(cwd), "link-check", "latest.md");
25351
+ return path101.join(dataRootPath(cwd), "link-check", "latest.md");
25307
25352
  }
25308
25353
  async function wikiStatus(cwd) {
25309
25354
  const root = wikiRootPath3(cwd);
@@ -25311,7 +25356,7 @@ async function wikiStatus(cwd) {
25311
25356
  const pages = enabled ? await collectPages(cwd) : [];
25312
25357
  return {
25313
25358
  enabled,
25314
- wikiRoot: path99.relative(cwd, root),
25359
+ wikiRoot: path101.relative(cwd, root),
25315
25360
  totalPages: pages.length,
25316
25361
  countsByType: WIKI_PAGE_TYPES.map(({ type }) => ({
25317
25362
  type,
@@ -25342,13 +25387,13 @@ async function wikiCreatePage(input) {
25342
25387
  if (!/^[a-z0-9][a-z0-9-]*$/.test(input.slug)) {
25343
25388
  throw new Error(`Invalid slug: ${input.slug}. Use lowercase letters, digits, and hyphens.`);
25344
25389
  }
25345
- const dir = path99.join(wikiRootPath3(input.cwd), typeConfig.folder);
25346
- const filePath = path99.join(dir, `${input.slug}.md`);
25347
- const relativePath = path99.relative(input.cwd, filePath);
25390
+ const dir = path101.join(wikiRootPath3(input.cwd), typeConfig.folder);
25391
+ const filePath = path101.join(dir, `${input.slug}.md`);
25392
+ const relativePath = path101.relative(input.cwd, filePath);
25348
25393
  if (await pathExists(filePath) && !input.force) {
25349
25394
  throw new Error(`Page already exists: ${relativePath}. Use --force to overwrite.`);
25350
25395
  }
25351
- await mkdir21(dir, { recursive: true });
25396
+ await mkdir20(dir, { recursive: true });
25352
25397
  const title = input.title ?? slugToTitle2(input.slug);
25353
25398
  const history = input.history ?? await openWikiWriteContext(input.cwd, input.force ? "wiki new --force" : "wiki new");
25354
25399
  await writeWikiPage(history, filePath, renderWikiPage({ title, type: typeConfig.type }));
@@ -25356,7 +25401,7 @@ async function wikiCreatePage(input) {
25356
25401
  }
25357
25402
  async function wikiGenerateIndex(cwd, history) {
25358
25403
  const root = wikiRootPath3(cwd);
25359
- const indexPath = path99.join(root, "index.md");
25404
+ const indexPath = path101.join(root, "index.md");
25360
25405
  const pages = await collectPages(cwd);
25361
25406
  const generatedAt = new Date().toISOString();
25362
25407
  const managedBlock = `${WIKI_INDEX_BEGIN}
@@ -25373,7 +25418,7 @@ ${managedBlock}
25373
25418
  `;
25374
25419
  await writeWikiPage(history ?? await openWikiWriteContext(cwd, "wiki index"), indexPath, next);
25375
25420
  return {
25376
- path: path99.relative(cwd, indexPath),
25421
+ path: path101.relative(cwd, indexPath),
25377
25422
  pageCount: pages.length,
25378
25423
  generatedAt
25379
25424
  };
@@ -25381,13 +25426,13 @@ ${managedBlock}
25381
25426
  async function wikiCheckLinks(cwd) {
25382
25427
  const root = wikiRootPath3(cwd);
25383
25428
  const allFiles = await pathExists(root) ? await walkMarkdown(root) : [];
25384
- const files = allFiles.filter((absolutePath) => !path99.relative(root, absolutePath).startsWith(`templates${path99.sep}`));
25429
+ const files = allFiles.filter((absolutePath) => !path101.relative(root, absolutePath).startsWith(`templates${path101.sep}`));
25385
25430
  const broken = [];
25386
25431
  let checkedLinks = 0;
25387
25432
  let skippedExternal = 0;
25388
25433
  for (const absolutePath of files) {
25389
25434
  const content = await readFile50(absolutePath, "utf8");
25390
- const pageRelative = path99.relative(cwd, absolutePath);
25435
+ const pageRelative = path101.relative(cwd, absolutePath);
25391
25436
  for (const target of extractLinkTargets(content)) {
25392
25437
  if (EXTERNAL_LINK.test(target)) {
25393
25438
  skippedExternal += 1;
@@ -25398,7 +25443,7 @@ async function wikiCheckLinks(cwd) {
25398
25443
  continue;
25399
25444
  }
25400
25445
  checkedLinks += 1;
25401
- const resolved = path99.resolve(path99.dirname(absolutePath), filePart);
25446
+ const resolved = path101.resolve(path101.dirname(absolutePath), filePart);
25402
25447
  if (!await pathExists(resolved)) {
25403
25448
  broken.push({
25404
25449
  page: pageRelative,
@@ -25410,8 +25455,8 @@ async function wikiCheckLinks(cwd) {
25410
25455
  }
25411
25456
  const generatedAt = new Date().toISOString();
25412
25457
  const reportPath = linkCheckReportPath(cwd);
25413
- await mkdir21(path99.dirname(reportPath), { recursive: true });
25414
- await writeFile15(reportPath, renderLinkCheckReport({
25458
+ await mkdir20(path101.dirname(reportPath), { recursive: true });
25459
+ await writeFile14(reportPath, renderLinkCheckReport({
25415
25460
  generatedAt,
25416
25461
  checkedPages: files.length,
25417
25462
  checkedLinks,
@@ -25419,7 +25464,7 @@ async function wikiCheckLinks(cwd) {
25419
25464
  broken
25420
25465
  }), "utf8");
25421
25466
  return {
25422
- reportPath: path99.relative(cwd, reportPath),
25467
+ reportPath: path101.relative(cwd, reportPath),
25423
25468
  checkedPages: files.length,
25424
25469
  checkedLinks,
25425
25470
  skippedExternal,
@@ -25470,7 +25515,7 @@ async function wikiValidate(cwd) {
25470
25515
  }
25471
25516
  if (await isIndexStale(cwd, pages)) {
25472
25517
  issues.push({
25473
- page: path99.join(path99.relative(cwd, wikiRootPath3(cwd)), "index.md"),
25518
+ page: path101.join(path101.relative(cwd, wikiRootPath3(cwd)), "index.md"),
25474
25519
  kind: "index",
25475
25520
  message: "index out of date, run `keryx wiki index`"
25476
25521
  });
@@ -25516,7 +25561,7 @@ function collectCommandLabel(input) {
25516
25561
  return ["wiki collect", ...flags].join(" ");
25517
25562
  }
25518
25563
  async function wikiPruneOrphans(cwd, history) {
25519
- const componentsDir = path99.join(wikiRootPath3(cwd), "components");
25564
+ const componentsDir = path101.join(wikiRootPath3(cwd), "components");
25520
25565
  if (!await pathExists(componentsDir)) {
25521
25566
  return { pruned: [], orphanedAccepted: [] };
25522
25567
  }
@@ -25536,15 +25581,15 @@ async function wikiPruneOrphans(cwd, history) {
25536
25581
  if (validSlugs.has(slug)) {
25537
25582
  continue;
25538
25583
  }
25539
- const filePath = path99.join(componentsDir, entry);
25584
+ const filePath = path101.join(componentsDir, entry);
25540
25585
  const current = await readFile50(filePath, "utf8");
25541
25586
  const isUnmodifiedDraft = /\nStatus:\s*draft\s*\n/.test(current) && current.includes("Generated by `keryx wiki collect`");
25542
25587
  if (isUnmodifiedDraft) {
25543
25588
  run ??= history ?? await openWikiWriteContext(cwd, "wiki prune");
25544
25589
  await deleteWikiPage(run, filePath);
25545
- pruned.push(path99.relative(cwd, filePath));
25590
+ pruned.push(path101.relative(cwd, filePath));
25546
25591
  } else {
25547
- orphanedAccepted.push(path99.relative(cwd, filePath));
25592
+ orphanedAccepted.push(path101.relative(cwd, filePath));
25548
25593
  }
25549
25594
  }
25550
25595
  return { pruned, orphanedAccepted };
@@ -25554,7 +25599,7 @@ async function validModuleNames(cwd, dataDir) {
25554
25599
  return counts === undefined ? undefined : new Set(counts.keys());
25555
25600
  }
25556
25601
  async function moduleFileCounts(cwd, dataDir) {
25557
- const nodesPath = path99.join(gdgraphStorageDir(cwd, dataDir), "nodes.jsonl");
25602
+ const nodesPath = path101.join(gdgraphStorageDir(cwd, dataDir), "nodes.jsonl");
25558
25603
  if (!await pathExists(nodesPath)) {
25559
25604
  return;
25560
25605
  }
@@ -25625,9 +25670,9 @@ async function wikiEvidence(input) {
25625
25670
  });
25626
25671
  }
25627
25672
  function resolveEvidenceScope(cwd, override) {
25628
- const absolute = path99.resolve(cwd);
25673
+ const absolute = path101.resolve(cwd);
25629
25674
  return {
25630
- projectId: override?.projectId ?? (path99.basename(absolute) || "project"),
25675
+ projectId: override?.projectId ?? (path101.basename(absolute) || "project"),
25631
25676
  checkoutId: override?.checkoutId ?? `checkout:${createHash19("sha256").update(absolute).digest("hex").slice(0, 16)}`,
25632
25677
  ...override?.workspaceId ? { workspaceId: override.workspaceId } : {},
25633
25678
  ...override?.taskId ? { taskId: override.taskId } : {}
@@ -25642,7 +25687,7 @@ function isMachineAuthoredPage(pageType, relativePath, content) {
25642
25687
  if (source === null) {
25643
25688
  return false;
25644
25689
  }
25645
- const normalised = relativePath.split(path99.sep).join("/").replace(/^wiki\//, "");
25690
+ const normalised = relativePath.split(path101.sep).join("/").replace(/^wiki\//, "");
25646
25691
  return WIKI_PAGE_PRODUCERS.some((producer) => producer.source === source && producer.pageType === pageType && producer.path.test(normalised) && /^-[ \t]+Link:.*\bsha256\b/m.test(content));
25647
25692
  }
25648
25693
  function createGdWikiService() {
@@ -25658,8 +25703,8 @@ function createGdWikiService() {
25658
25703
  };
25659
25704
  }
25660
25705
  async function collectGraphWikiCandidates(cwd, generatedAt, limit, onlyModules, dataDir) {
25661
- const nodesPath = path99.join(gdgraphStorageDir(cwd, dataDir), "nodes.jsonl");
25662
- const edgesPath = path99.join(gdgraphStorageDir(cwd, dataDir), "edges.jsonl");
25706
+ const nodesPath = path101.join(gdgraphStorageDir(cwd, dataDir), "nodes.jsonl");
25707
+ const edgesPath = path101.join(gdgraphStorageDir(cwd, dataDir), "edges.jsonl");
25663
25708
  if (!await pathExists(nodesPath) || !await pathExists(edgesPath)) {
25664
25709
  return [];
25665
25710
  }
@@ -25746,7 +25791,7 @@ async function collectGraphWikiCandidates(cwd, generatedAt, limit, onlyModules,
25746
25791
  };
25747
25792
  const moduleCandidates = [];
25748
25793
  const pageModules = new Set(topModules.map((entry) => entry.name));
25749
- const componentsDir = path99.join(wikiRootPath3(cwd), "components");
25794
+ const componentsDir = path101.join(wikiRootPath3(cwd), "components");
25750
25795
  const existingSlugs = new Set((await pathExists(componentsDir) ? await readdir17(componentsDir) : []).filter((entry) => entry.endsWith(".md")).map((entry) => entry.slice(0, -3)));
25751
25796
  const pageLink = (name) => {
25752
25797
  const slug = slugifyPath(name);
@@ -25854,7 +25899,7 @@ function topCounts(bucket, limit) {
25854
25899
  return [...bucket.entries()].sort((a, b) => b[1] - a[1]).slice(0, limit);
25855
25900
  }
25856
25901
  async function readModuleReadme(cwd, moduleName, pageLink) {
25857
- const readmePath = path99.join(cwd, ...moduleName.split("/"), "README.md");
25902
+ const readmePath = path101.join(cwd, ...moduleName.split("/"), "README.md");
25858
25903
  if (!await pathExists(readmePath)) {
25859
25904
  return null;
25860
25905
  }
@@ -25875,7 +25920,7 @@ async function extractModuleExports(cwd, files) {
25875
25920
  const declRe = /export\s+(?:async\s+)?(?:default\s+)?(?:const|let|var|function|class|type|interface|enum)\s+([A-Za-z_$][\w$]*)/g;
25876
25921
  const braceRe = /export\s*\{([^}]+)\}/g;
25877
25922
  for (const file of files.slice(0, 4)) {
25878
- const filePath = path99.join(cwd, ...file.split("/"));
25923
+ const filePath = path101.join(cwd, ...file.split("/"));
25879
25924
  if (!await pathExists(filePath)) {
25880
25925
  continue;
25881
25926
  }
@@ -25906,7 +25951,7 @@ async function extractModuleExports(cwd, files) {
25906
25951
  }
25907
25952
  async function extractModuleApi(cwd, files, dataDir) {
25908
25953
  const names = await extractModuleExports(cwd, files);
25909
- const symbolsPath = path99.join(gdgraphStorageDir(cwd, dataDir), "symbols.jsonl");
25954
+ const symbolsPath = path101.join(gdgraphStorageDir(cwd, dataDir), "symbols.jsonl");
25910
25955
  if (names.length === 0 || !await pathExists(symbolsPath)) {
25911
25956
  return names.map((name) => "`" + name + "`");
25912
25957
  }
@@ -25932,7 +25977,7 @@ async function extractModuleApi(cwd, files, dataDir) {
25932
25977
  });
25933
25978
  }
25934
25979
  async function collectHealthWikiCandidates(cwd, generatedAt) {
25935
- const healthPath = path99.join(cwd, ".metaproject", "data", "health", "artifacts", "latest.json");
25980
+ const healthPath = path101.join(cwd, ".metaproject", "data", "health", "artifacts", "latest.json");
25936
25981
  if (!await pathExists(healthPath)) {
25937
25982
  return [];
25938
25983
  }
@@ -25974,7 +26019,7 @@ async function collectHealthWikiCandidates(cwd, generatedAt) {
25974
26019
  }];
25975
26020
  }
25976
26021
  async function collectTestingWikiCandidates(cwd, generatedAt) {
25977
- const contextPath = path99.join(cwd, ".metaproject", "data", "testing", "context.md");
26022
+ const contextPath = path101.join(cwd, ".metaproject", "data", "testing", "context.md");
25978
26023
  if (!await pathExists(contextPath)) {
25979
26024
  return [];
25980
26025
  }
@@ -26005,8 +26050,8 @@ async function writeCollectedPage(cwd, candidate, force, history) {
26005
26050
  if (!folder) {
26006
26051
  throw new Error(`Unsupported collected wiki type: ${candidate.type}`);
26007
26052
  }
26008
- const filePath = path99.join(wikiRootPath3(cwd), folder, `${candidate.slug}.md`);
26009
- const relativePath = path99.relative(cwd, filePath);
26053
+ const filePath = path101.join(wikiRootPath3(cwd), folder, `${candidate.slug}.md`);
26054
+ const relativePath = path101.relative(cwd, filePath);
26010
26055
  const exists = await pathExists(filePath);
26011
26056
  if (exists && !force) {
26012
26057
  return { path: relativePath, type: candidate.type, source: candidate.source, action: "skipped" };
@@ -26057,7 +26102,7 @@ async function writeCollectedPage(cwd, candidate, force, history) {
26057
26102
  async function wikiPagesForFile(cwd, targetRepoPath) {
26058
26103
  const pages = await collectPages(cwd);
26059
26104
  const refs = await Promise.all(pages.map(async (page) => ({
26060
- repoPath: path99.relative(cwd, page.absolutePath).split(path99.sep).join("/"),
26105
+ repoPath: path101.relative(cwd, page.absolutePath).split(path101.sep).join("/"),
26061
26106
  content: await readFile50(page.absolutePath, "utf8")
26062
26107
  })));
26063
26108
  return backlinksFor(buildBacklinkIndex(refs), targetRepoPath);
@@ -26096,7 +26141,7 @@ function renderIndexBody(pages, generatedAt) {
26096
26141
  `).trimEnd();
26097
26142
  }
26098
26143
  async function isIndexStale(cwd, pages) {
26099
- const indexPath = path99.join(wikiRootPath3(cwd), "index.md");
26144
+ const indexPath = path101.join(wikiRootPath3(cwd), "index.md");
26100
26145
  if (!await pathExists(indexPath)) {
26101
26146
  return true;
26102
26147
  }
@@ -26114,7 +26159,7 @@ async function walkMarkdown(root) {
26114
26159
  const results = [];
26115
26160
  const entries = await readdir17(root, { withFileTypes: true });
26116
26161
  for (const entry of entries) {
26117
- const absolutePath = path99.join(root, entry.name);
26162
+ const absolutePath = path101.join(root, entry.name);
26118
26163
  if (entry.isDirectory()) {
26119
26164
  results.push(...await walkMarkdown(absolutePath));
26120
26165
  } else if (entry.isFile() && entry.name.endsWith(".md")) {
@@ -26171,7 +26216,7 @@ ${JSON.stringify(state, null, 2)}
26171
26216
  `;
26172
26217
  }
26173
26218
  async function readIndexGeneratedAt(cwd) {
26174
- const indexPath = path99.join(wikiRootPath3(cwd), "index.md");
26219
+ const indexPath = path101.join(wikiRootPath3(cwd), "index.md");
26175
26220
  if (!await pathExists(indexPath)) {
26176
26221
  return null;
26177
26222
  }
@@ -26411,7 +26456,7 @@ async function validateStructure(cwd, pages, issues) {
26411
26456
  if (pattern.includes("*")) {
26412
26457
  continue;
26413
26458
  }
26414
- if (!await pathExists(path99.join(cwd, pattern))) {
26459
+ if (!await pathExists(path101.join(cwd, pattern))) {
26415
26460
  issues.push({
26416
26461
  page: page.relativePath,
26417
26462
  kind: "describes",
@@ -26481,7 +26526,7 @@ async function validatePageInvariants(cwd, pages, issues) {
26481
26526
  }
26482
26527
  }
26483
26528
  function toPosixPath(value) {
26484
- return value.split(path99.sep).join("/");
26529
+ return value.split(path101.sep).join("/");
26485
26530
  }
26486
26531
  function compareSemver(a, b) {
26487
26532
  const pa = a.split(".").map(Number);
@@ -26526,8 +26571,8 @@ var init_service4 = __esm(() => {
26526
26571
 
26527
26572
  // src/gdgraph/wiki-layer.ts
26528
26573
  import { createHash as createHash20 } from "crypto";
26529
- import { mkdir as mkdir22, stat as stat15, writeFile as writeFile16 } from "fs/promises";
26530
- import path100 from "path";
26574
+ import { mkdir as mkdir21, stat as stat15, writeFile as writeFile15 } from "fs/promises";
26575
+ import path102 from "path";
26531
26576
  function storageDir(projectRoot, dataDir) {
26532
26577
  return gdgraphStorageDir(projectRoot, dataDir);
26533
26578
  }
@@ -26586,20 +26631,20 @@ function computeFingerprints(fileRecords, mtimes) {
26586
26631
  async function writeJsonl(filePath, rows) {
26587
26632
  const body = rows.map((row) => JSON.stringify(row)).join(`
26588
26633
  `);
26589
- await writeFile16(filePath, rows.length > 0 ? `${body}
26634
+ await writeFile15(filePath, rows.length > 0 ? `${body}
26590
26635
  ` : "", "utf8");
26591
26636
  }
26592
26637
  async function enrichBuildWithWikiLayer(input) {
26593
26638
  const dir = storageDir(input.projectRoot, input.dataDir);
26594
- await mkdir22(dir, { recursive: true });
26639
+ await mkdir21(dir, { recursive: true });
26595
26640
  const mtimes = new Map;
26596
26641
  for (const record of input.fileRecords) {
26597
26642
  try {
26598
- const info = await stat15(path100.join(input.projectRoot, record.path));
26643
+ const info = await stat15(path102.join(input.projectRoot, record.path));
26599
26644
  mtimes.set(record.path, info.mtimeMs);
26600
26645
  } catch {}
26601
26646
  }
26602
- await writeFile16(path100.join(dir, BUILD_MANIFEST_FILE), `${JSON.stringify({ version: 1, files: computeFingerprints(input.fileRecords, mtimes) }, null, 2)}
26647
+ await writeFile15(path102.join(dir, BUILD_MANIFEST_FILE), `${JSON.stringify({ version: 1, files: computeFingerprints(input.fileRecords, mtimes) }, null, 2)}
26603
26648
  `, "utf8");
26604
26649
  const validModules = input.validModules !== undefined ? input.validModules : await (input.loadValidModules ?? ((root) => defaultLoadValidModules(root, input.dataDir)))(input.projectRoot);
26605
26650
  const wikiPages = await collectPages(input.projectRoot);
@@ -26624,8 +26669,8 @@ async function enrichBuildWithWikiLayer(input) {
26624
26669
  version: page.version
26625
26670
  }))
26626
26671
  });
26627
- await writeJsonl(path100.join(dir, WIKI_PAGES_FILE), layer.pages);
26628
- await writeJsonl(path100.join(dir, DESCRIBES_FILE), layer.describes);
26672
+ await writeJsonl(path102.join(dir, WIKI_PAGES_FILE), layer.pages);
26673
+ await writeJsonl(path102.join(dir, DESCRIBES_FILE), layer.describes);
26629
26674
  return layer;
26630
26675
  }
26631
26676
  async function defaultLoadValidModules(projectRoot, dataDir) {
@@ -26720,8 +26765,8 @@ function personalizedPageRank(nodes, edges, options) {
26720
26765
  }
26721
26766
 
26722
26767
  // src/gdgraph/repomap.ts
26723
- import { mkdir as mkdir24, writeFile as writeFile18 } from "fs/promises";
26724
- import path103 from "path";
26768
+ import { mkdir as mkdir23, writeFile as writeFile17 } from "fs/promises";
26769
+ import path105 from "path";
26725
26770
  function estimateTokens2(text) {
26726
26771
  return Math.ceil(text.length / 4);
26727
26772
  }
@@ -26752,7 +26797,7 @@ function overflowContent(required, missing, budget) {
26752
26797
  `);
26753
26798
  }
26754
26799
  function repomapArtifactPath(cwd) {
26755
- return path103.join(cwd, ".metaproject", "data", "gdgraph", "artifacts", "repomap.md");
26800
+ return path105.join(cwd, ".metaproject", "data", "gdgraph", "artifacts", "repomap.md");
26756
26801
  }
26757
26802
  function buildRankEdges(graph, config) {
26758
26803
  const edges = [];
@@ -26889,8 +26934,8 @@ function computeRepomap(graph, config, options = {}) {
26889
26934
  async function writeRepomap(cwd, graph, config, options = {}) {
26890
26935
  const result = computeRepomap(graph, config, options);
26891
26936
  const artifactPath = repomapArtifactPath(cwd);
26892
- await mkdir24(path103.dirname(artifactPath), { recursive: true });
26893
- await writeFile18(artifactPath, result.content, "utf8");
26937
+ await mkdir23(path105.dirname(artifactPath), { recursive: true });
26938
+ await writeFile17(artifactPath, result.content, "utf8");
26894
26939
  return { ...result, path: artifactPath };
26895
26940
  }
26896
26941
  var HEADER2;
@@ -26909,7 +26954,7 @@ var init_repomap = __esm(() => {
26909
26954
  // src/gdskills/contracts.ts
26910
26955
  import { readFile as readFile62 } from "fs/promises";
26911
26956
  import { existsSync as existsSync20 } from "fs";
26912
- import path127 from "path";
26957
+ import path129 from "path";
26913
26958
  import { fileURLToPath as fileURLToPath2 } from "url";
26914
26959
  async function loadSchema(name) {
26915
26960
  const contract = CONTRACTS.find((entry) => entry.name === name);
@@ -26920,10 +26965,13 @@ async function loadSchema(name) {
26920
26965
  return JSON.parse(raw);
26921
26966
  }
26922
26967
  function contractPath(contract) {
26923
- const here = path127.dirname(fileURLToPath2(import.meta.url));
26968
+ if (desktopResources !== undefined) {
26969
+ return contract.sourcePath ? path129.join(desktopResources, "review-skills", path129.relative("src/gdskills/bundled/skills", contract.sourcePath)) : path129.join(desktopResources, "review-contracts", contract.fileName);
26970
+ }
26971
+ const here = path129.dirname(fileURLToPath2(import.meta.url));
26924
26972
  if (contract.sourcePath) {
26925
- for (const root of [path127.join(here, "..", ".."), path127.join(here, ".."), here]) {
26926
- const candidate = path127.resolve(root, contract.sourcePath);
26973
+ for (const root of [path129.join(here, "..", ".."), path129.join(here, ".."), here]) {
26974
+ const candidate = path129.resolve(root, contract.sourcePath);
26927
26975
  if (existsSync20(candidate)) {
26928
26976
  return candidate;
26929
26977
  }
@@ -26933,14 +26981,15 @@ function contractPath(contract) {
26933
26981
  if (existsSync20(directPath)) {
26934
26982
  return directPath;
26935
26983
  }
26936
- const packagedSourcePath = path127.join(here, "..", "src", "gdskills", "contracts", contract.fileName);
26984
+ const packagedSourcePath = path129.join(here, "..", "src", "gdskills", "contracts", contract.fileName);
26937
26985
  if (existsSync20(packagedSourcePath)) {
26938
26986
  return packagedSourcePath;
26939
26987
  }
26940
26988
  return directPath;
26941
26989
  }
26942
- var CONTRACTS, SCHEMA_ROOTS;
26990
+ var CONTRACTS, desktopResources, SCHEMA_ROOTS;
26943
26991
  var init_contracts = __esm(() => {
26992
+ init_self_invocation();
26944
26993
  CONTRACTS = [
26945
26994
  {
26946
26995
  name: "agent-event",
@@ -27063,7 +27112,9 @@ var init_contracts = __esm(() => {
27063
27112
  }
27064
27113
  }
27065
27114
  ];
27115
+ desktopResources = desktopResourceDirectory();
27066
27116
  SCHEMA_ROOTS = [
27117
+ ...desktopResources ? [path129.join(desktopResources, "review-contracts"), path129.join(desktopResources, "review-skills/review/review-orchestrator")] : [],
27067
27118
  fileURLToPath2(new URL("./contracts/", import.meta.url)),
27068
27119
  fileURLToPath2(new URL("./bundled/skills/review/review-orchestrator/", import.meta.url)),
27069
27120
  fileURLToPath2(new URL("../src/gdskills/contracts/", import.meta.url)),
@@ -27075,7 +27126,7 @@ var init_contracts = __esm(() => {
27075
27126
  import {
27076
27127
  appendFileSync,
27077
27128
  chmodSync as chmodSync2,
27078
- closeSync,
27129
+ closeSync as closeSync2,
27079
27130
  constants as constants3,
27080
27131
  copyFileSync,
27081
27132
  fstatSync as fstatSync2,
@@ -27083,15 +27134,34 @@ import {
27083
27134
  openSync,
27084
27135
  readFileSync as readFileSync12,
27085
27136
  renameSync as renameSync3,
27086
- statSync as statSync3,
27137
+ statSync as statSync2,
27087
27138
  unlinkSync,
27088
27139
  writeFileSync as writeFileSync3,
27089
27140
  writeSync
27090
27141
  } from "fs";
27142
+ import { homedir as homedir2 } from "os";
27143
+ import path132 from "path";
27144
+ function keryxConfigDir(dir) {
27145
+ if (dir !== undefined) {
27146
+ return dir;
27147
+ }
27148
+ const home = homedir2();
27149
+ if (process.platform === "win32") {
27150
+ const appData = process.env.APPDATA;
27151
+ const base = appData !== undefined && appData.length > 0 ? appData : path132.join(home, "AppData", "Roaming");
27152
+ return path132.join(base, "keryx");
27153
+ }
27154
+ const xdg = process.env.XDG_DATA_HOME;
27155
+ const base = xdg !== undefined && xdg.length > 0 ? xdg : path132.join(home, ".local", "share");
27156
+ return path132.join(base, "keryx");
27157
+ }
27158
+ function keryxDataDir(override) {
27159
+ return override || process.env.KERYX_DATA_DIR || keryxConfigDir();
27160
+ }
27091
27161
  function readBoundedFile(file, maxBytes) {
27092
27162
  let stats;
27093
27163
  try {
27094
- stats = statSync3(file);
27164
+ stats = statSync2(file);
27095
27165
  } catch {
27096
27166
  return { ok: false, reason: "absent" };
27097
27167
  }
@@ -27121,8 +27191,8 @@ var init_config_dir = __esm(() => {
27121
27191
 
27122
27192
  // src/session/preservation.ts
27123
27193
  import { createHash as createHash23, randomUUID as randomUUID3 } from "crypto";
27124
- import { closeSync as closeSync2, fsyncSync, mkdirSync as mkdirSync3, openSync as openSync2, readdirSync as readdirSync3, readFileSync as readFileSync13, renameSync as renameSync4, unlinkSync as unlinkSync2, writeFileSync as writeFileSync4 } from "fs";
27125
- import path130 from "path";
27194
+ import { closeSync as closeSync3, fsyncSync, mkdirSync as mkdirSync3, openSync as openSync2, readdirSync as readdirSync3, readFileSync as readFileSync13, renameSync as renameSync4, unlinkSync as unlinkSync2, writeFileSync as writeFileSync4 } from "fs";
27195
+ import path133 from "path";
27126
27196
  function syncDir(dir) {
27127
27197
  if (process.platform === "win32")
27128
27198
  return;
@@ -27130,11 +27200,11 @@ function syncDir(dir) {
27130
27200
  try {
27131
27201
  fsyncSync(fd);
27132
27202
  } finally {
27133
- closeSync2(fd);
27203
+ closeSync3(fd);
27134
27204
  }
27135
27205
  }
27136
27206
  function writePreservationFile(file, body) {
27137
- const dir = path130.dirname(file);
27207
+ const dir = path133.dirname(file);
27138
27208
  mkdirSync3(dir, { recursive: true, mode: 448 });
27139
27209
  const tmp = `${file}.${randomUUID3()}.tmp`;
27140
27210
  const fd = openSync2(tmp, "wx", 384);
@@ -27142,7 +27212,7 @@ function writePreservationFile(file, body) {
27142
27212
  writeFileSync4(fd, body, "utf8");
27143
27213
  fsyncSync(fd);
27144
27214
  } finally {
27145
- closeSync2(fd);
27215
+ closeSync3(fd);
27146
27216
  }
27147
27217
  try {
27148
27218
  renameSync4(tmp, file);
@@ -27159,11 +27229,11 @@ function writePreservationFile(file, body) {
27159
27229
  }
27160
27230
  }
27161
27231
  function readPreservation(dir, snapshotId) {
27162
- const base = path130.join(dir, "preservation");
27232
+ const base = path133.join(dir, "preservation");
27163
27233
  let id = snapshotId;
27164
27234
  if (id === undefined) {
27165
27235
  try {
27166
- id = readFileSync13(path130.join(base, "CURRENT"), "utf8");
27236
+ id = readFileSync13(path133.join(base, "CURRENT"), "utf8");
27167
27237
  } catch (e) {
27168
27238
  if (e.code === "ENOENT")
27169
27239
  return;
@@ -27172,7 +27242,7 @@ function readPreservation(dir, snapshotId) {
27172
27242
  }
27173
27243
  if (!/^[a-f0-9]{64}$/.test(id))
27174
27244
  throw new Error("invalid preservation identity");
27175
- const read = readTranscriptFile(path130.join(base, "generations", `${id}.json`));
27245
+ const read = readTranscriptFile(path133.join(base, "generations", `${id}.json`));
27176
27246
  if (!read.ok)
27177
27247
  throw new Error(`snapshot unreadable: ${read.reason}`);
27178
27248
  if (hash(read.text) !== id)
@@ -27190,9 +27260,9 @@ function readPreservation(dir, snapshotId) {
27190
27260
  return parsed;
27191
27261
  }
27192
27262
  function readPendingHistory(dir) {
27193
- let read = readConfigFile(path130.join(dir, "preservation", "HISTORY"));
27263
+ let read = readConfigFile(path133.join(dir, "preservation", "HISTORY"));
27194
27264
  if (!read.ok && read.reason === "absent") {
27195
- read = readConfigFile(path130.join(dir, "preservation", "MIRRORING"));
27265
+ read = readConfigFile(path133.join(dir, "preservation", "MIRRORING"));
27196
27266
  }
27197
27267
  if (!read.ok) {
27198
27268
  if (read.reason === "absent")
@@ -27215,13 +27285,13 @@ var init_preservation = __esm(() => {
27215
27285
  });
27216
27286
 
27217
27287
  // src/session/slate.ts
27218
- import { mkdir as mkdir33, readFile as readFile66, readdir as readdir23, stat as stat18 } from "fs/promises";
27219
- import path135 from "path";
27288
+ import { mkdir as mkdir32, readFile as readFile66, readdir as readdir23, stat as stat18 } from "fs/promises";
27289
+ import path138 from "path";
27220
27290
  function isSlateSeedKind(value) {
27221
27291
  return typeof value === "string" && SLATE_SEED_KINDS.includes(value);
27222
27292
  }
27223
27293
  function slatePath(dir) {
27224
- return path135.join(dir, "slate.json");
27294
+ return path138.join(dir, "slate.json");
27225
27295
  }
27226
27296
  function slateLockPath(dir) {
27227
27297
  return `${slatePath(dir)}.lock`;
@@ -27237,7 +27307,7 @@ async function readSlate(dir) {
27237
27307
  }
27238
27308
  }
27239
27309
  async function writeSlate(dir, update, signal) {
27240
- await mkdir33(dir, { recursive: true });
27310
+ await mkdir32(dir, { recursive: true });
27241
27311
  return withFileLock(slateLockPath(dir), async () => {
27242
27312
  const prev = await readSlate(dir);
27243
27313
  signal?.throwIfAborted();
@@ -27748,7 +27818,7 @@ function completionExceptionQuestion(id, selected, context) {
27748
27818
  // src/flow/service.ts
27749
27819
  init_fs();
27750
27820
  init_validator();
27751
- import { mkdir as mkdir13, readFile as readFile39 } from "fs/promises";
27821
+ import { mkdir as mkdir12, readFile as readFile39 } from "fs/promises";
27752
27822
  import path78 from "path";
27753
27823
 
27754
27824
  // src/flow/machine.ts
@@ -30271,7 +30341,7 @@ var identityCache = new Map;
30271
30341
  // src/flow/store.ts
30272
30342
  init_fs();
30273
30343
  import { createHash as createHash7 } from "crypto";
30274
- import { appendFile as appendFile2, mkdir as mkdir8, readFile as readFile21, readdir as readdir9 } from "fs/promises";
30344
+ import { appendFile as appendFile2, mkdir as mkdir7, readFile as readFile21, readdir as readdir9 } from "fs/promises";
30275
30345
  import path47 from "path";
30276
30346
  function flowsRoot(cwd) {
30277
30347
  return path47.join(cwd, ".metaproject", "flows");
@@ -30411,7 +30481,7 @@ function migrateTask(task, createdAt, history) {
30411
30481
  }
30412
30482
  async function writeFlow(cwd, dir, flow) {
30413
30483
  const file = path47.join(flowsRoot(cwd), dir, "flow.json");
30414
- await mkdir8(path47.dirname(file), { recursive: true });
30484
+ await mkdir7(path47.dirname(file), { recursive: true });
30415
30485
  await writeFileAtomic(file, `${JSON.stringify(flow, null, 2)}
30416
30486
  `);
30417
30487
  }
@@ -30580,7 +30650,6 @@ var DECISION_SOURCES = {
30580
30650
  hostQuestion: "host-question"
30581
30651
  };
30582
30652
  var WORK_DECISION_SOURCES = Object.values(DECISION_SOURCES);
30583
-
30584
30653
  // src/decisions/quality.ts
30585
30654
  var SHELL_OPERATORS = new Set(["|", "&", ";", "<", ">", "`", "(", ")"]);
30586
30655
 
@@ -30801,7 +30870,7 @@ function decisionWriters(kind, packageArg = "<review-dir>") {
30801
30870
 
30802
30871
  // src/review/mutate.ts
30803
30872
  import { constants as constants2, existsSync as existsSync7, writeFileSync as writeFileSync2 } from "fs";
30804
- import { cp, lstat as lstat8, mkdir as mkdir9, mkdtemp, open as open2, readFile as readFile22, readdir as readdir11, realpath as realpath12, rm as rm3, stat as stat10, symlink, utimes as utimes2, writeFile as writeFile6 } from "fs/promises";
30873
+ import { cp, lstat as lstat8, mkdir as mkdir8, mkdtemp, open as open2, readFile as readFile22, readdir as readdir11, realpath as realpath12, rm as rm3, stat as stat10, symlink, utimes as utimes2, writeFile as writeFile5 } from "fs/promises";
30805
30874
  import path50 from "path";
30806
30875
 
30807
30876
  // src/lib/git-env.ts
@@ -34883,7 +34952,7 @@ async function intentNoteForNewFlow(cwd, dir) {
34883
34952
  init_service2();
34884
34953
  init_fs();
34885
34954
  import { createHash as createHash11 } from "crypto";
34886
- import { chmod as chmod4, mkdir as mkdir11, readFile as readFile33 } from "fs/promises";
34955
+ import { chmod as chmod4, mkdir as mkdir10, readFile as readFile33 } from "fs/promises";
34887
34956
  import path70 from "path";
34888
34957
  var AC_LINE2 = /^\s*[-*]\s*(AC\d+)\s*:\s?(.*)$/i;
34889
34958
  function parseAcceptanceCriteria(content) {
@@ -35096,7 +35165,7 @@ async function readAcCheckCache(cachePath) {
35096
35165
  }
35097
35166
  }
35098
35167
  async function writeAcCheckCache(cachePath, record) {
35099
- await mkdir11(path70.dirname(cachePath), { recursive: true });
35168
+ await mkdir10(path70.dirname(cachePath), { recursive: true });
35100
35169
  await writeFileAtomic(cachePath, `${JSON.stringify(record, null, 2)}
35101
35170
  `, { mode: 384 });
35102
35171
  if (process.platform !== "win32") {
@@ -35153,7 +35222,7 @@ function renderAcCheckAdvisoryNotice(verdicts) {
35153
35222
  return `acceptance-criteria check (advisory): ${counts.likelyMet} likely met, ${counts.notEvident} not evident, ${counts.notCheckable} not checkable` + (inDoubt.length > 0 ? ` \u2014 in doubt: ${inDoubt.join(", ")}` : "") + ` (\`keryx flow check-ac\` for detail)`;
35154
35223
  }
35155
35224
  // src/flow/allocation.ts
35156
- import { appendFile as appendFile3, mkdir as mkdir12, readFile as readFile34 } from "fs/promises";
35225
+ import { appendFile as appendFile3, mkdir as mkdir11, readFile as readFile34 } from "fs/promises";
35157
35226
  import path72 from "path";
35158
35227
 
35159
35228
  // src/lib/clone-scope.ts
@@ -35174,10 +35243,11 @@ async function gitCommonDir(cwd) {
35174
35243
  return null;
35175
35244
  }
35176
35245
  }
35177
- async function gitToplevel(cwd) {
35246
+ async function gitToplevel(cwd, env) {
35178
35247
  try {
35179
35248
  const proc = Bun.spawn(["git", "rev-parse", "--show-toplevel"], {
35180
35249
  cwd,
35250
+ ...env === undefined ? {} : { env },
35181
35251
  stdout: "pipe",
35182
35252
  stderr: "ignore"
35183
35253
  });
@@ -35243,7 +35313,7 @@ async function recordAllocation(scope, record) {
35243
35313
  if (!scope.ledgerPath) {
35244
35314
  return;
35245
35315
  }
35246
- await mkdir12(path72.dirname(scope.ledgerPath), { recursive: true });
35316
+ await mkdir11(path72.dirname(scope.ledgerPath), { recursive: true });
35247
35317
  await appendFile3(scope.ledgerPath, `${JSON.stringify(record)}
35248
35318
  `, "utf8");
35249
35319
  }
@@ -36178,7 +36248,7 @@ function createFlowService(deps) {
36178
36248
  if (await pathExists(absolute)) {
36179
36249
  throw new Error(`Flow directory already exists: ${dir}`);
36180
36250
  }
36181
- await mkdir13(absolute, { recursive: true });
36251
+ await mkdir12(absolute, { recursive: true });
36182
36252
  const createdAt = now();
36183
36253
  const flow = {
36184
36254
  schemaVersion: 1,
@@ -37286,9 +37356,9 @@ async function acCriterionKnown(input) {
37286
37356
  }
37287
37357
  // src/gdgraph/build.ts
37288
37358
  init_data_dir();
37289
- import { mkdir as mkdir23, readdir as readdir18, readFile as readFile51, writeFile as writeFile17 } from "fs/promises";
37359
+ import { mkdir as mkdir22, readdir as readdir18, readFile as readFile51, writeFile as writeFile16 } from "fs/promises";
37290
37360
  import { existsSync as existsSync11 } from "fs";
37291
- import path101 from "path";
37361
+ import path103 from "path";
37292
37362
 
37293
37363
  // src/gdgraph/types.ts
37294
37364
  var UNKNOWN_IMPORT_KIND = "unknown-static";
@@ -37355,7 +37425,7 @@ async function buildGraph(projectRoot, options = {}) {
37355
37425
  const assetNodes = new Map;
37356
37426
  const fileRecords = [];
37357
37427
  for (const file of files) {
37358
- const absolutePath = path101.join(projectRoot, file);
37428
+ const absolutePath = path103.join(projectRoot, file);
37359
37429
  const content = await readFile51(absolutePath, "utf8");
37360
37430
  fileRecords.push({ path: file, content });
37361
37431
  const language = getLanguage(file);
@@ -37408,24 +37478,24 @@ async function collectSourceFiles(projectRoot) {
37408
37478
  const result = [];
37409
37479
  const skippedDirectories = [];
37410
37480
  async function walk(relativeDir) {
37411
- const absoluteDir = path101.join(projectRoot, relativeDir);
37481
+ const absoluteDir = path103.join(projectRoot, relativeDir);
37412
37482
  const entries = await readdir18(absoluteDir, { withFileTypes: true });
37413
37483
  for (const entry of entries) {
37414
37484
  if (entry.isDirectory()) {
37415
37485
  if (IGNORE_DIRS.has(entry.name)) {
37416
- skippedDirectories.push(normalizePath3(path101.posix.join(relativeDir, entry.name)).replace(/^\.\//, ""));
37486
+ skippedDirectories.push(normalizePath3(path103.posix.join(relativeDir, entry.name)).replace(/^\.\//, ""));
37417
37487
  continue;
37418
37488
  }
37419
- await walk(normalizePath3(path101.posix.join(relativeDir, entry.name)));
37489
+ await walk(normalizePath3(path103.posix.join(relativeDir, entry.name)));
37420
37490
  continue;
37421
37491
  }
37422
37492
  if (!entry.isFile()) {
37423
37493
  continue;
37424
37494
  }
37425
- if (!SOURCE_EXTENSIONS.includes(path101.extname(entry.name))) {
37495
+ if (!SOURCE_EXTENSIONS.includes(path103.extname(entry.name))) {
37426
37496
  continue;
37427
37497
  }
37428
- result.push(normalizePath3(path101.posix.join(relativeDir, entry.name)).replace(/^\.\//, ""));
37498
+ result.push(normalizePath3(path103.posix.join(relativeDir, entry.name)).replace(/^\.\//, ""));
37429
37499
  }
37430
37500
  }
37431
37501
  await walk(".");
@@ -37507,8 +37577,8 @@ function resolveImport(projectRoot, fromFile, specifier, fileSet, resolver) {
37507
37577
  }
37508
37578
  function resolveAssetImport(projectRoot, fromFile, specifier, resolver) {
37509
37579
  for (const candidate of importCandidateBases(projectRoot, fromFile, specifier, resolver)) {
37510
- const extension = path101.posix.extname(candidate);
37511
- if (ASSET_EXTENSIONS.includes(extension) && existsSync11(path101.join(projectRoot, candidate))) {
37580
+ const extension = path103.posix.extname(candidate);
37581
+ if (ASSET_EXTENSIONS.includes(extension) && existsSync11(path103.join(projectRoot, candidate))) {
37512
37582
  return candidate;
37513
37583
  }
37514
37584
  }
@@ -37517,17 +37587,17 @@ function resolveAssetImport(projectRoot, fromFile, specifier, resolver) {
37517
37587
  function importCandidateBases(projectRoot, fromFile, specifier, resolver) {
37518
37588
  const normalizedSpecifier = stripImportSuffix(specifier);
37519
37589
  if (normalizedSpecifier.startsWith(".") && getLanguage(fromFile) !== "python") {
37520
- const fromDir = path101.posix.dirname(fromFile);
37521
- return [normalizePath3(path101.posix.normalize(path101.posix.join(fromDir, normalizedSpecifier)))];
37590
+ const fromDir = path103.posix.dirname(fromFile);
37591
+ return [normalizePath3(path103.posix.normalize(path103.posix.join(fromDir, normalizedSpecifier)))];
37522
37592
  }
37523
- return resolver.candidateBases(normalizedSpecifier, fromFile).map((candidate) => normalizePath3(path101.relative(projectRoot, path101.join(projectRoot, candidate))));
37593
+ return resolver.candidateBases(normalizedSpecifier, fromFile).map((candidate) => normalizePath3(path103.relative(projectRoot, path103.join(projectRoot, candidate))));
37524
37594
  }
37525
37595
  function resolveSourceCandidate(base, fileSet) {
37526
37596
  const candidates = [
37527
37597
  base,
37528
37598
  ...SOURCE_RESOLUTION_EXTENSIONS.map((extension) => `${base}${extension}`),
37529
- ...SOURCE_RESOLUTION_EXTENSIONS.map((extension) => path101.posix.join(base, `index${extension}`)),
37530
- path101.posix.join(base, "__init__.py")
37599
+ ...SOURCE_RESOLUTION_EXTENSIONS.map((extension) => path103.posix.join(base, `index${extension}`)),
37600
+ path103.posix.join(base, "__init__.py")
37531
37601
  ];
37532
37602
  return candidates.find((candidate) => fileSet.has(candidate)) ?? null;
37533
37603
  }
@@ -37557,7 +37627,7 @@ async function loadJavaResolver(projectRoot) {
37557
37627
  return createJavaResolver(roots);
37558
37628
  }
37559
37629
  async function discoverJavaSourceRoots(projectRoot) {
37560
- const pomPath = path101.join(projectRoot, "pom.xml");
37630
+ const pomPath = path103.join(projectRoot, "pom.xml");
37561
37631
  if (existsSync11(pomPath)) {
37562
37632
  try {
37563
37633
  const roots = parseMavenSourceRoots(await readFile51(pomPath, "utf8"));
@@ -37567,7 +37637,7 @@ async function discoverJavaSourceRoots(projectRoot) {
37567
37637
  } catch {}
37568
37638
  }
37569
37639
  for (const gradleName of ["build.gradle", "build.gradle.kts"]) {
37570
- const gradlePath = path101.join(projectRoot, gradleName);
37640
+ const gradlePath = path103.join(projectRoot, gradleName);
37571
37641
  if (existsSync11(gradlePath)) {
37572
37642
  try {
37573
37643
  const roots = parseGradleSourceRoots(await readFile51(gradlePath, "utf8"));
@@ -37589,12 +37659,12 @@ function createJavaResolver(sourceRoots) {
37589
37659
  return [];
37590
37660
  }
37591
37661
  const relative = specifier.split(".").join("/");
37592
- return sourceRoots.map((root) => normalizePath3(path101.posix.join(root, relative)));
37662
+ return sourceRoots.map((root) => normalizePath3(path103.posix.join(root, relative)));
37593
37663
  }
37594
37664
  };
37595
37665
  }
37596
37666
  function loadPythonResolver(projectRoot) {
37597
- const hasSrc = existsSync11(path101.join(projectRoot, "src"));
37667
+ const hasSrc = existsSync11(path103.join(projectRoot, "src"));
37598
37668
  return createPythonResolver(hasSrc);
37599
37669
  }
37600
37670
  function createPythonResolver(hasSrc) {
@@ -37607,16 +37677,16 @@ function createPythonResolver(hasSrc) {
37607
37677
  if (specifier.startsWith(".")) {
37608
37678
  const dots = /^\.+/.exec(specifier)?.[0].length ?? 0;
37609
37679
  const rest = specifier.slice(dots);
37610
- let baseDir = path101.posix.dirname(fromFile);
37680
+ let baseDir = path103.posix.dirname(fromFile);
37611
37681
  for (let level = 1;level < dots; level += 1) {
37612
- baseDir = path101.posix.dirname(baseDir);
37682
+ baseDir = path103.posix.dirname(baseDir);
37613
37683
  }
37614
37684
  const suffix = rest ? rest.split(".").join("/") : "";
37615
- const base = suffix ? path101.posix.join(baseDir, suffix) : baseDir;
37685
+ const base = suffix ? path103.posix.join(baseDir, suffix) : baseDir;
37616
37686
  return [normalizePath3(base)];
37617
37687
  }
37618
37688
  const relative = specifier.split(".").join("/");
37619
- return roots.map((root) => normalizePath3(root ? path101.posix.join(root, relative) : relative));
37689
+ return roots.map((root) => normalizePath3(root ? path103.posix.join(root, relative) : relative));
37620
37690
  }
37621
37691
  };
37622
37692
  }
@@ -37625,8 +37695,8 @@ function parseMavenSourceRoots(pomXml) {
37625
37695
  for (const match of pomXml.matchAll(/<module>\s*([^<]+?)\s*<\/module>/g)) {
37626
37696
  const moduleDir = match[1]?.trim();
37627
37697
  if (moduleDir && !moduleDir.includes("${")) {
37628
- roots.add(normalizePath3(path101.posix.join(moduleDir, "src/main/java")));
37629
- roots.add(normalizePath3(path101.posix.join(moduleDir, "src/test/java")));
37698
+ roots.add(normalizePath3(path103.posix.join(moduleDir, "src/main/java")));
37699
+ roots.add(normalizePath3(path103.posix.join(moduleDir, "src/test/java")));
37630
37700
  }
37631
37701
  }
37632
37702
  for (const tag of ["sourceDirectory", "testSourceDirectory"]) {
@@ -37659,7 +37729,7 @@ function parseGradleSourceRoots(buildGradle) {
37659
37729
  var TSCONFIG_EXTENDS_MAX_DEPTH = 10;
37660
37730
  async function loadTsconfigResolver(projectRoot) {
37661
37731
  const empty = createTsconfigResolver(null, []);
37662
- const tsconfigPath = path101.join(projectRoot, "tsconfig.json");
37732
+ const tsconfigPath = path103.join(projectRoot, "tsconfig.json");
37663
37733
  if (!existsSync11(tsconfigPath)) {
37664
37734
  return empty;
37665
37735
  }
@@ -37672,7 +37742,7 @@ async function loadTsconfigResolver(projectRoot) {
37672
37742
  return createTsconfigResolver(resolved.baseUrl, paths);
37673
37743
  }
37674
37744
  function toProjectRelativeDir(projectRoot, absoluteDir) {
37675
- const relative = normalizePath3(path101.relative(projectRoot, absoluteDir)).replace(/^\.\//, "");
37745
+ const relative = normalizePath3(path103.relative(projectRoot, absoluteDir)).replace(/^\.\//, "");
37676
37746
  return relative === "." ? "" : relative;
37677
37747
  }
37678
37748
  async function readTsconfigJson(configPath) {
@@ -37687,11 +37757,11 @@ function resolveTsconfigExtendsPath(configDir, extendsSpecifier) {
37687
37757
  if (!extendsSpecifier.startsWith(".") && !extendsSpecifier.startsWith("/")) {
37688
37758
  return null;
37689
37759
  }
37690
- const resolved = path101.resolve(configDir, extendsSpecifier);
37760
+ const resolved = path103.resolve(configDir, extendsSpecifier);
37691
37761
  return resolved.endsWith(".json") ? resolved : `${resolved}.json`;
37692
37762
  }
37693
37763
  async function resolveTsconfigOptions(configPath, visited, depth, projectRoot) {
37694
- const resolvedPath = path101.resolve(configPath);
37764
+ const resolvedPath = path103.resolve(configPath);
37695
37765
  if (depth > TSCONFIG_EXTENDS_MAX_DEPTH || visited.has(resolvedPath)) {
37696
37766
  return null;
37697
37767
  }
@@ -37702,15 +37772,15 @@ async function resolveTsconfigOptions(configPath, visited, depth, projectRoot) {
37702
37772
  }
37703
37773
  let inherited = null;
37704
37774
  if (typeof parsed.extends === "string") {
37705
- const basePath = resolveTsconfigExtendsPath(path101.dirname(resolvedPath), parsed.extends);
37775
+ const basePath = resolveTsconfigExtendsPath(path103.dirname(resolvedPath), parsed.extends);
37706
37776
  if (basePath) {
37707
37777
  inherited = await resolveTsconfigOptions(basePath, visited, depth + 1, projectRoot);
37708
37778
  }
37709
37779
  }
37710
- const configDir = path101.dirname(resolvedPath);
37780
+ const configDir = path103.dirname(resolvedPath);
37711
37781
  const declaringDir = toProjectRelativeDir(projectRoot, configDir);
37712
37782
  const options = parsed.compilerOptions ?? {};
37713
- const ownBaseUrl = typeof options.baseUrl === "string" ? toProjectRelativeDir(projectRoot, path101.resolve(configDir, options.baseUrl)) : null;
37783
+ const ownBaseUrl = typeof options.baseUrl === "string" ? toProjectRelativeDir(projectRoot, path103.resolve(configDir, options.baseUrl)) : null;
37714
37784
  const baseUrl = ownBaseUrl ?? inherited?.baseUrl ?? null;
37715
37785
  const ownPaths = isRecord5(options.paths) ? Object.entries(options.paths).filter((entry) => Array.isArray(entry[1])).map(([pattern, targets]) => ({
37716
37786
  pattern,
@@ -37739,7 +37809,7 @@ function createTsconfigResolver(baseUrl, mappings) {
37739
37809
  }
37740
37810
  }
37741
37811
  if (baseUrl !== null) {
37742
- candidates.push(normalizePath3(path101.posix.join(baseUrl, normalizedSpecifier)));
37812
+ candidates.push(normalizePath3(path103.posix.join(baseUrl, normalizedSpecifier)));
37743
37813
  }
37744
37814
  return [...new Set(candidates.map((candidate) => candidate.replace(/^\.\//, "")))];
37745
37815
  }
@@ -37759,7 +37829,7 @@ function matchPathPattern(pattern, specifier) {
37759
37829
  }
37760
37830
  function applyPathTarget(base, target, wildcard) {
37761
37831
  const replaced = target.includes("*") ? target.replace("*", wildcard) : target;
37762
- return normalizePath3(path101.posix.normalize(path101.posix.join(base, replaced)));
37832
+ return normalizePath3(path103.posix.normalize(path103.posix.join(base, replaced)));
37763
37833
  }
37764
37834
  function stripJsonComments(source) {
37765
37835
  let out = "";
@@ -37814,20 +37884,20 @@ function isRecord5(value) {
37814
37884
  async function writeGraph(projectRoot, graph, dataDir) {
37815
37885
  const storageDir = gdgraphStorageDir(projectRoot, dataDir);
37816
37886
  const artifactsDir = gdgraphArtifactsDir(projectRoot, dataDir);
37817
- await mkdir23(storageDir, { recursive: true });
37818
- await mkdir23(artifactsDir, { recursive: true });
37819
- await writeFile17(path101.join(storageDir, "nodes.jsonl"), graph.nodes.map((node) => JSON.stringify(node)).join(`
37887
+ await mkdir22(storageDir, { recursive: true });
37888
+ await mkdir22(artifactsDir, { recursive: true });
37889
+ await writeFile16(path103.join(storageDir, "nodes.jsonl"), graph.nodes.map((node) => JSON.stringify(node)).join(`
37820
37890
  `) + `
37821
37891
  `, "utf8");
37822
- await writeFile17(path101.join(storageDir, "edges.jsonl"), graph.edges.map((edge) => JSON.stringify(edge)).join(`
37892
+ await writeFile16(path103.join(storageDir, "edges.jsonl"), graph.edges.map((edge) => JSON.stringify(edge)).join(`
37823
37893
  `) + `
37824
37894
  `, "utf8");
37825
- await writeFile17(path101.join(artifactsDir, "module-map.json"), JSON.stringify(buildModuleMap(graph), null, 2) + `
37895
+ await writeFile16(path103.join(artifactsDir, "module-map.json"), JSON.stringify(buildModuleMap(graph), null, 2) + `
37826
37896
  `, "utf8");
37827
37897
  }
37828
37898
  async function writeSummary(projectRoot, graph, collection, dataDir) {
37829
37899
  const artifactsDir = gdgraphArtifactsDir(projectRoot, dataDir);
37830
- await mkdir23(artifactsDir, { recursive: true });
37900
+ await mkdir22(artifactsDir, { recursive: true });
37831
37901
  const unresolved = graph.edges.filter((edge) => edge.kind === "unresolved");
37832
37902
  const imports = graph.edges.filter((edge) => edge.kind === "imports");
37833
37903
  const assets = graph.edges.filter((edge) => edge.kind === "asset");
@@ -37841,7 +37911,7 @@ async function writeSummary(projectRoot, graph, collection, dataDir) {
37841
37911
  `);
37842
37912
  const skippedList = collection.skippedDirectories.length > 0 ? collection.skippedDirectories.slice(0, 30).map((dir) => `- \`${dir}\``).join(`
37843
37913
  `) : "- none";
37844
- const summaryPath = path101.join(artifactsDir, "summary.md");
37914
+ const summaryPath = path103.join(artifactsDir, "summary.md");
37845
37915
  const content = `# gdgraph Summary
37846
37916
 
37847
37917
  ## Stats
@@ -37886,7 +37956,7 @@ keryx gdgraph query orphans
37886
37956
  keryx gdgraph affected <file>
37887
37957
  \`\`\`
37888
37958
  `;
37889
- await writeFile17(summaryPath, content, "utf8");
37959
+ await writeFile16(summaryPath, content, "utf8");
37890
37960
  return summaryPath;
37891
37961
  }
37892
37962
  function buildModuleMap(graph) {
@@ -37922,7 +37992,7 @@ function groupBy(items, getKey) {
37922
37992
  }
37923
37993
  function unresolvedType(specifier) {
37924
37994
  const stripped = stripImportSuffix(specifier);
37925
- const extension = path101.posix.extname(stripped);
37995
+ const extension = path103.posix.extname(stripped);
37926
37996
  if (extension) {
37927
37997
  return extension;
37928
37998
  }
@@ -37932,7 +38002,7 @@ function unresolvedType(specifier) {
37932
38002
  return "package";
37933
38003
  }
37934
38004
  function normalizePath3(value) {
37935
- return value.split(path101.sep).join("/");
38005
+ return value.split(path103.sep).join("/");
37936
38006
  }
37937
38007
 
37938
38008
  // src/gdgraph/service.ts
@@ -37941,17 +38011,17 @@ init_config3();
37941
38011
 
37942
38012
  // src/gdgraph/query.ts
37943
38013
  import { readFile as readFile52 } from "fs/promises";
37944
- import path102 from "path";
38014
+ import path104 from "path";
37945
38015
  init_data_dir();
37946
38016
  init_target();
37947
38017
  async function loadGraph(projectRoot, dataDir) {
37948
38018
  const storageDir = gdgraphStorageDir(projectRoot, dataDir);
37949
- const nodes = await readJsonl(path102.join(storageDir, "nodes.jsonl"));
37950
- const edges = await readJsonl(path102.join(storageDir, "edges.jsonl"));
37951
- const symbols = await readJsonl(path102.join(storageDir, "symbols.jsonl"));
37952
- const calls = await readJsonl(path102.join(storageDir, "calls.jsonl"));
37953
- const wikiPages = await readJsonl(path102.join(storageDir, "wiki-pages.jsonl"));
37954
- const describes = await readJsonl(path102.join(storageDir, "describes.jsonl"));
38019
+ const nodes = await readJsonl(path104.join(storageDir, "nodes.jsonl"));
38020
+ const edges = await readJsonl(path104.join(storageDir, "edges.jsonl"));
38021
+ const symbols = await readJsonl(path104.join(storageDir, "symbols.jsonl"));
38022
+ const calls = await readJsonl(path104.join(storageDir, "calls.jsonl"));
38023
+ const wikiPages = await readJsonl(path104.join(storageDir, "wiki-pages.jsonl"));
38024
+ const describes = await readJsonl(path104.join(storageDir, "describes.jsonl"));
37955
38025
  const graph = { nodes, edges };
37956
38026
  if (symbols.length > 0) {
37957
38027
  graph.symbols = symbols;
@@ -38011,7 +38081,7 @@ async function bunfigPreloadRoots(projectRoot) {
38011
38081
  const roots = new Set;
38012
38082
  let text;
38013
38083
  try {
38014
- text = await readFile52(path102.join(projectRoot, "bunfig.toml"), "utf8");
38084
+ text = await readFile52(path104.join(projectRoot, "bunfig.toml"), "utf8");
38015
38085
  } catch {
38016
38086
  return roots;
38017
38087
  }
@@ -38025,8 +38095,8 @@ async function bunfigPreloadRoots(projectRoot) {
38025
38095
  if (raw.length === 0) {
38026
38096
  continue;
38027
38097
  }
38028
- const absolute = path102.resolve(projectRoot, raw);
38029
- const relative = path102.relative(projectRoot, absolute).split(path102.sep).join("/");
38098
+ const absolute = path104.resolve(projectRoot, raw);
38099
+ const relative = path104.relative(projectRoot, absolute).split(path104.sep).join("/");
38030
38100
  roots.add(relative);
38031
38101
  }
38032
38102
  }
@@ -38180,13 +38250,13 @@ init_section_tombstone();
38180
38250
 
38181
38251
  // src/forgetting/journal.ts
38182
38252
  init_fs();
38183
- import { appendFile as appendFile5, mkdir as mkdir25, readFile as readFile53, stat as stat16 } from "fs/promises";
38184
- import path104 from "path";
38253
+ import { appendFile as appendFile5, mkdir as mkdir24, readFile as readFile53, stat as stat16 } from "fs/promises";
38254
+ import path106 from "path";
38185
38255
  function forgettingDataDir(cwd) {
38186
- return path104.join(cwd, ".metaproject", "data", "forgetting");
38256
+ return path106.join(cwd, ".metaproject", "data", "forgetting");
38187
38257
  }
38188
38258
  function deletionJournalPath(cwd) {
38189
- return path104.join(forgettingDataDir(cwd), "journal.jsonl");
38259
+ return path106.join(forgettingDataDir(cwd), "journal.jsonl");
38190
38260
  }
38191
38261
  async function readDeletionJournal(cwd) {
38192
38262
  const file = deletionJournalPath(cwd);
@@ -38601,12 +38671,12 @@ function createGdgraphService() {
38601
38671
  // src/health/service.ts
38602
38672
  init_fs();
38603
38673
  init_json();
38604
- import path124 from "path";
38674
+ import path126 from "path";
38605
38675
 
38606
38676
  // src/health/config.ts
38607
38677
  init_fs();
38608
38678
  init_json();
38609
- import path105 from "path";
38679
+ import path107 from "path";
38610
38680
  var DEFAULT_HEALTH_CONFIG = {
38611
38681
  schemaVersion: 2,
38612
38682
  ignore: {
@@ -38663,7 +38733,7 @@ var DEFAULT_HEALTH_CONFIG = {
38663
38733
  }
38664
38734
  };
38665
38735
  function configPath2(cwd) {
38666
- return path105.join(cwd, ".metaproject", "health.config.json");
38736
+ return path107.join(cwd, ".metaproject", "health.config.json");
38667
38737
  }
38668
38738
  var STRICTEST_GATE = {
38669
38739
  failOnPriorities: ["P0", "P1", "P2", "P3"],
@@ -38713,8 +38783,8 @@ async function loadHealthConfig(cwd) {
38713
38783
 
38714
38784
  // src/health/run.ts
38715
38785
  init_fs();
38716
- import { mkdir as mkdir29, writeFile as writeFile22 } from "fs/promises";
38717
- import path123 from "path";
38786
+ import { mkdir as mkdir28, writeFile as writeFile21 } from "fs/promises";
38787
+ import path125 from "path";
38718
38788
 
38719
38789
  // src/metrics/provenance.ts
38720
38790
  async function collectGitProvenance(cwd) {
@@ -38827,12 +38897,12 @@ function computeGate2(input) {
38827
38897
  }
38828
38898
 
38829
38899
  // src/health/scopes.ts
38830
- import path108 from "path";
38900
+ import path110 from "path";
38831
38901
 
38832
38902
  // src/health/util.ts
38833
38903
  init_fs();
38834
- import { mkdir as mkdir26, readFile as readFile54, readdir as readdir19, writeFile as writeFile19 } from "fs/promises";
38835
- import path106 from "path";
38904
+ import { mkdir as mkdir25, readFile as readFile54, readdir as readdir19, writeFile as writeFile18 } from "fs/promises";
38905
+ import path108 from "path";
38836
38906
  var IGNORED_DIRS = new Set([
38837
38907
  "node_modules",
38838
38908
  ".git",
@@ -38876,14 +38946,14 @@ async function toolVersion(command, cwd) {
38876
38946
  }
38877
38947
  }
38878
38948
  function dataRoot3(cwd) {
38879
- return path106.join(cwd, ".metaproject", "data", "health");
38949
+ return path108.join(cwd, ".metaproject", "data", "health");
38880
38950
  }
38881
38951
  async function writeRaw(cwd, source, content, stamp) {
38882
- const dir = path106.join(dataRoot3(cwd), "raw", source);
38883
- await mkdir26(dir, { recursive: true });
38884
- const file = path106.join(dir, `${stamp}.log`);
38885
- await writeFile19(file, content, "utf8");
38886
- return path106.relative(cwd, file);
38952
+ const dir = path108.join(dataRoot3(cwd), "raw", source);
38953
+ await mkdir25(dir, { recursive: true });
38954
+ const file = path108.join(dir, `${stamp}.log`);
38955
+ await writeFile18(file, content, "utf8");
38956
+ return path108.relative(cwd, file);
38887
38957
  }
38888
38958
  async function listSourceFiles(cwd, ignorePaths = []) {
38889
38959
  const { files } = await listSourceFilesWithReasons(cwd, ignorePaths);
@@ -38903,7 +38973,7 @@ async function walk2(root, dir, out, incompleteReasons) {
38903
38973
  try {
38904
38974
  entries = await readdir19(dir, { withFileTypes: true });
38905
38975
  } catch (error) {
38906
- incompleteReasons.push(`${path106.relative(root, dir) || "."}: ${error instanceof Error ? error.message : String(error)}`);
38976
+ incompleteReasons.push(`${path108.relative(root, dir) || "."}: ${error instanceof Error ? error.message : String(error)}`);
38907
38977
  return;
38908
38978
  }
38909
38979
  for (const entry of entries) {
@@ -38911,14 +38981,14 @@ async function walk2(root, dir, out, incompleteReasons) {
38911
38981
  if (entry.isDirectory() && !IGNORED_DIRS.has(entry.name)) {}
38912
38982
  continue;
38913
38983
  }
38914
- const abs = path106.join(dir, entry.name);
38984
+ const abs = path108.join(dir, entry.name);
38915
38985
  if (entry.isDirectory()) {
38916
38986
  if (IGNORED_DIRS.has(entry.name)) {
38917
38987
  continue;
38918
38988
  }
38919
38989
  await walk2(root, abs, out, incompleteReasons);
38920
- } else if (entry.isFile() && SOURCE_EXT.has(path106.extname(entry.name))) {
38921
- out.push(path106.relative(root, abs));
38990
+ } else if (entry.isFile() && SOURCE_EXT.has(path108.extname(entry.name))) {
38991
+ out.push(path108.relative(root, abs));
38922
38992
  }
38923
38993
  }
38924
38994
  }
@@ -38933,7 +39003,7 @@ function moduleOfFile(file) {
38933
39003
  return null;
38934
39004
  }
38935
39005
  function isSourceFile(file) {
38936
- return SOURCE_EXT.has(path106.extname(file));
39006
+ return SOURCE_EXT.has(path108.extname(file));
38937
39007
  }
38938
39008
  function matchesAnyPattern(file, patterns) {
38939
39009
  const normalized = file.replace(/\\/g, "/").replace(/^\.\//, "");
@@ -39035,7 +39105,7 @@ function rankHotspots(files, churn, sourceAnalysis) {
39035
39105
  // src/health/source-analysis.ts
39036
39106
  init_fs();
39037
39107
  import { readFile as readFile55 } from "fs/promises";
39038
- import path107 from "path";
39108
+ import path109 from "path";
39039
39109
 
39040
39110
  // src/health/metrics/complexity.ts
39041
39111
  var CONTROL_KEYWORDS = new Set([
@@ -39269,7 +39339,7 @@ async function analyzeSourceFiles(cwd, sourceFiles) {
39269
39339
  return new Map(entries.filter((entry) => entry !== null));
39270
39340
  }
39271
39341
  async function analyzeSourceFile(cwd, file) {
39272
- const abs = path107.join(cwd, file);
39342
+ const abs = path109.join(cwd, file);
39273
39343
  if (!await pathExists(abs)) {
39274
39344
  return null;
39275
39345
  }
@@ -39346,14 +39416,14 @@ async function computeMetrics(input) {
39346
39416
  }
39347
39417
  const components = new Map;
39348
39418
  for (const file of sourceFiles) {
39349
- const dir = path108.posix.dirname(file);
39419
+ const dir = path110.posix.dirname(file);
39350
39420
  if (dir === "." || dir === moduleOfFile(file)) {
39351
39421
  continue;
39352
39422
  }
39353
39423
  components.set(dir, [...components.get(dir) ?? [], file]);
39354
39424
  }
39355
39425
  for (const [name, files] of [...components.entries()].sort()) {
39356
- const compFindings = findings.filter((f) => f.file && path108.posix.dirname(f.file) === name);
39426
+ const compFindings = findings.filter((f) => f.file && path110.posix.dirname(f.file) === name);
39357
39427
  scopes.push(build("component", `component:${name}`, name, files, compFindings, averageCoverage(files, coverage)));
39358
39428
  }
39359
39429
  const findingFiles = findings.map((f) => f.file).filter((f) => Boolean(f));
@@ -39397,8 +39467,8 @@ function tally2(values) {
39397
39467
 
39398
39468
  // src/health/baseline.ts
39399
39469
  init_fs();
39400
- import { mkdir as mkdir27, readFile as readFile56, writeFile as writeFile20 } from "fs/promises";
39401
- import path109 from "path";
39470
+ import { mkdir as mkdir26, readFile as readFile56, writeFile as writeFile19 } from "fs/promises";
39471
+ import path111 from "path";
39402
39472
  var LEGACY_BASELINE_SOURCES = Object.freeze([
39403
39473
  "complexity",
39404
39474
  "coverage",
@@ -39423,7 +39493,7 @@ function measuredSources(sources) {
39423
39493
  return sources.filter((s) => s !== null && typeof s === "object").filter((s) => !didNotProduceResult(s)).map((s) => s.source).sort();
39424
39494
  }
39425
39495
  function baselinePath(cwd) {
39426
- return path109.join(cwd, ".metaproject", "health", "baselines", "scores.json");
39496
+ return path111.join(cwd, ".metaproject", "health", "baselines", "scores.json");
39427
39497
  }
39428
39498
  async function readBaselineFile(cwd) {
39429
39499
  const file = baselinePath(cwd);
@@ -39444,8 +39514,8 @@ async function loadBaselineSources(cwd) {
39444
39514
  }
39445
39515
  async function writeBaselineFile(cwd, data) {
39446
39516
  const file = baselinePath(cwd);
39447
- await mkdir27(path109.dirname(file), { recursive: true });
39448
- await writeFile20(file, `${JSON.stringify(data, null, 2)}
39517
+ await mkdir26(path111.dirname(file), { recursive: true });
39518
+ await writeFile19(file, `${JSON.stringify(data, null, 2)}
39449
39519
  `, "utf8");
39450
39520
  }
39451
39521
  async function loadBaseline(cwd) {
@@ -39526,10 +39596,10 @@ async function getChurn(cwd, windowDays) {
39526
39596
 
39527
39597
  // src/health/metrics/wiki-freshness.ts
39528
39598
  import { readFile as readFile57, stat as stat17 } from "fs/promises";
39529
- import path110 from "path";
39599
+ import path112 from "path";
39530
39600
  var DEFAULT_STALE_EVIDENCE_DAYS = 7;
39531
39601
  function freshnessReportPath(cwd) {
39532
- return path110.join(cwd, ".metaproject", "data", "wiki", "freshness", "latest.json");
39602
+ return path112.join(cwd, ".metaproject", "data", "wiki", "freshness", "latest.json");
39533
39603
  }
39534
39604
  async function readWikiFreshnessMetric(cwd, options = {}) {
39535
39605
  const file = freshnessReportPath(cwd);
@@ -39550,7 +39620,7 @@ async function readWikiFreshnessMetric(cwd, options = {}) {
39550
39620
  } catch {
39551
39621
  return {
39552
39622
  status: "unreadable-report",
39553
- reason: `${path110.relative(cwd, file)} is not valid JSON; re-run \`keryx wiki freshness\`.`
39623
+ reason: `${path112.relative(cwd, file)} is not valid JSON; re-run \`keryx wiki freshness\`.`
39554
39624
  };
39555
39625
  }
39556
39626
  const report = parsed;
@@ -39560,7 +39630,7 @@ async function readWikiFreshnessMetric(cwd, options = {}) {
39560
39630
  if (pagesTotal === null || pagesFresh === null) {
39561
39631
  return {
39562
39632
  status: "unreadable-report",
39563
- reason: `${path110.relative(cwd, file)} is missing its totals; re-run \`keryx wiki freshness\`.`
39633
+ reason: `${path112.relative(cwd, file)} is missing its totals; re-run \`keryx wiki freshness\`.`
39564
39634
  };
39565
39635
  }
39566
39636
  const pagesUndecidable = numberOr3(totals.pagesUndecidable) ?? 0;
@@ -39614,12 +39684,12 @@ function renderWikiFreshnessLine(metric) {
39614
39684
  }
39615
39685
 
39616
39686
  // src/health/sources/helpers.ts
39617
- import path111 from "path";
39687
+ import path113 from "path";
39618
39688
  import { existsSync as existsSync12 } from "fs";
39619
39689
  class NoImportError extends Error {
39620
39690
  }
39621
39691
  function resolveBin(cwd, name) {
39622
- const local = path111.join(cwd, "node_modules", ".bin", name);
39692
+ const local = path113.join(cwd, "node_modules", ".bin", name);
39623
39693
  if (existsSync12(local)) {
39624
39694
  return local;
39625
39695
  }
@@ -39700,13 +39770,13 @@ async function getComplexityFindings(cwd, sourceFiles, config, sourceAnalysis) {
39700
39770
 
39701
39771
  // src/health/metrics/coverage.ts
39702
39772
  import { existsSync as existsSync13 } from "fs";
39703
- import path112 from "path";
39773
+ import path114 from "path";
39704
39774
  var SUMMARY_PATHS = [
39705
39775
  "coverage/coverage-summary.json",
39706
39776
  "coverage/coverage-final.json"
39707
39777
  ];
39708
39778
  async function getCoverage(cwd) {
39709
- const summary = SUMMARY_PATHS.map((rel) => path112.join(cwd, rel)).find((abs) => existsSync13(abs));
39779
+ const summary = SUMMARY_PATHS.map((rel) => path114.join(cwd, rel)).find((abs) => existsSync13(abs));
39710
39780
  if (!summary) {
39711
39781
  return { status: "missing", total: null, byFile: new Map };
39712
39782
  }
@@ -39727,7 +39797,7 @@ async function getCoverage(cwd) {
39727
39797
  total = pct;
39728
39798
  continue;
39729
39799
  }
39730
- const relative = path112.isAbsolute(key) ? path112.relative(cwd, key) : key;
39800
+ const relative = path114.isAbsolute(key) ? path114.relative(cwd, key) : key;
39731
39801
  byFile.set(relative.replace(/\\/g, "/"), pct);
39732
39802
  }
39733
39803
  return { status: "available", total, byFile };
@@ -39860,10 +39930,10 @@ function renderWikiFreshness(metric) {
39860
39930
  // src/health/skills.ts
39861
39931
  init_fs();
39862
39932
  import { readFile as readFile58 } from "fs/promises";
39863
- import path113 from "path";
39933
+ import path115 from "path";
39864
39934
  var EMPTY = { skills: [], skillForFile: () => null };
39865
39935
  async function loadSkillOwnership(cwd) {
39866
- const manifestPath = path113.join(cwd, ".metaproject", "metaproject.json");
39936
+ const manifestPath = path115.join(cwd, ".metaproject", "metaproject.json");
39867
39937
  if (!await pathExists(manifestPath)) {
39868
39938
  return EMPTY;
39869
39939
  }
@@ -39901,7 +39971,7 @@ function normalize(value) {
39901
39971
 
39902
39972
  // src/health/sources/eslint.ts
39903
39973
  import { existsSync as existsSync14 } from "fs";
39904
- import path114 from "path";
39974
+ import path116 from "path";
39905
39975
  var CONFIG_FILES = [
39906
39976
  ".eslintrc",
39907
39977
  ".eslintrc.js",
@@ -39915,7 +39985,7 @@ var CONFIG_FILES = [
39915
39985
  "eslint.config.ts"
39916
39986
  ];
39917
39987
  function hasConfig(cwd) {
39918
- return CONFIG_FILES.some((file) => existsSync14(path114.join(cwd, file)));
39988
+ return CONFIG_FILES.some((file) => existsSync14(path116.join(cwd, file)));
39919
39989
  }
39920
39990
  var eslintAdapter = {
39921
39991
  id: "eslint",
@@ -39941,7 +40011,7 @@ var eslintAdapter = {
39941
40011
  };
39942
40012
  },
39943
40013
  async import(ctx) {
39944
- const report = path114.join(ctx.cwd, "eslint-report.json");
40014
+ const report = path116.join(ctx.cwd, "eslint-report.json");
39945
40015
  if (!existsSync14(report)) {
39946
40016
  throw new NoImportError("no eslint-report.json");
39947
40017
  }
@@ -39968,7 +40038,7 @@ var eslintAdapter = {
39968
40038
  }
39969
40039
  const findings = [];
39970
40040
  for (const file of data) {
39971
- const relative = path114.isAbsolute(file.filePath) ? path114.relative(ctx.cwd, file.filePath) : file.filePath;
40041
+ const relative = path116.isAbsolute(file.filePath) ? path116.relative(ctx.cwd, file.filePath) : file.filePath;
39972
40042
  for (const message of file.messages ?? []) {
39973
40043
  const isError = message.severity === 2;
39974
40044
  findings.push(makeFinding({
@@ -40000,19 +40070,19 @@ var eslintAdapter = {
40000
40070
 
40001
40071
  // src/health/sources/oxlint.ts
40002
40072
  import { existsSync as existsSync15, readFileSync as readFileSync11 } from "fs";
40003
- import path115 from "path";
40073
+ import path117 from "path";
40004
40074
  var CONFIG_FILES2 = [".oxlintrc.json", ".oxlintrc.jsonc"];
40005
40075
  var OXLINT_FORMAT = "json";
40006
40076
  var OXLINT_PARSE_ERROR = "oxlint JSON format was not recognized";
40007
40077
  var OXLINT_NO_FILES = "oxlint found no files to lint (check its paths and ignore patterns)";
40008
40078
  var NO_FILES_PREAMBLE = "No files found to lint";
40009
40079
  function hasConfigFile(cwd) {
40010
- if (CONFIG_FILES2.some((file) => existsSync15(path115.join(cwd, file))))
40080
+ if (CONFIG_FILES2.some((file) => existsSync15(path117.join(cwd, file))))
40011
40081
  return true;
40012
- return [".oxlintrc.js", ".oxlintrc.cjs", ".oxlintrc.mjs", ".oxlintrc.ts"].some((file) => existsSync15(path115.join(cwd, file)));
40082
+ return [".oxlintrc.js", ".oxlintrc.cjs", ".oxlintrc.mjs", ".oxlintrc.ts"].some((file) => existsSync15(path117.join(cwd, file)));
40013
40083
  }
40014
40084
  function packageNamesOxlint(cwd) {
40015
- const file = path115.join(cwd, "package.json");
40085
+ const file = path117.join(cwd, "package.json");
40016
40086
  if (!existsSync15(file))
40017
40087
  return false;
40018
40088
  try {
@@ -40070,7 +40140,7 @@ var oxlintAdapter = {
40070
40140
  return [];
40071
40141
  return data.map((diagnostic) => {
40072
40142
  const filePath = diagnostic.filename ?? "";
40073
- const relative = filePath && path115.isAbsolute(filePath) ? path115.relative(ctx.cwd, filePath) : filePath;
40143
+ const relative = filePath && path117.isAbsolute(filePath) ? path117.relative(ctx.cwd, filePath) : filePath;
40074
40144
  const isError = diagnostic.severity === "error";
40075
40145
  return makeFinding({
40076
40146
  source: "oxlint",
@@ -40096,9 +40166,9 @@ var oxlintAdapter = {
40096
40166
 
40097
40167
  // src/health/sources/typescript.ts
40098
40168
  import { existsSync as existsSync16 } from "fs";
40099
- import path116 from "path";
40169
+ import path118 from "path";
40100
40170
  function hasTsconfig(cwd) {
40101
- return existsSync16(path116.join(cwd, "tsconfig.json"));
40171
+ return existsSync16(path118.join(cwd, "tsconfig.json"));
40102
40172
  }
40103
40173
  var typescriptAdapter = {
40104
40174
  id: "typescript",
@@ -40159,12 +40229,12 @@ init_fs();
40159
40229
  init_contained_write();
40160
40230
  import { existsSync as existsSync17 } from "fs";
40161
40231
  import { readFile as readFile61, readdir as readdir20 } from "fs/promises";
40162
- import path120 from "path";
40232
+ import path122 from "path";
40163
40233
  // src/metrics/lifecycle.ts
40164
40234
  init_fs();
40165
40235
  init_guard();
40166
40236
  import { readFile as readFile59 } from "fs/promises";
40167
- import path117 from "path";
40237
+ import path119 from "path";
40168
40238
 
40169
40239
  // src/metrics/record.ts
40170
40240
  var RELIABILITIES = new Set(["exact", "estimated", "unknown"]);
@@ -40179,7 +40249,7 @@ var RETRY_TYPES = new Set([
40179
40249
 
40180
40250
  // src/metrics/lifecycle.ts
40181
40251
  async function readArtifactPointer(root, expected) {
40182
- const pointerFile = path117.join(root, "latest.json");
40252
+ const pointerFile = path119.join(root, "latest.json");
40183
40253
  if (!await pathExists(pointerFile))
40184
40254
  return { status: "missing", pointer: null };
40185
40255
  let pointer;
@@ -40188,7 +40258,7 @@ async function readArtifactPointer(root, expected) {
40188
40258
  } catch {
40189
40259
  return { status: "stale", pointer: null, reason: "latest pointer is invalid JSON" };
40190
40260
  }
40191
- const recordFile = pointer.record ? path117.join(root, pointer.record) : null;
40261
+ const recordFile = pointer.record ? path119.join(root, pointer.record) : null;
40192
40262
  if (!recordFile || !isPathInside(root, recordFile) || !await pathExists(recordFile)) {
40193
40263
  return { status: "stale", pointer, reason: "pointer record is missing" };
40194
40264
  }
@@ -40204,9 +40274,9 @@ init_guard();
40204
40274
  // src/testing/capability.ts
40205
40275
  init_fs();
40206
40276
  init_json();
40207
- import path118 from "path";
40277
+ import path120 from "path";
40208
40278
  async function isTestingCapabilityEnabled(cwd, capability) {
40209
- const manifestPath = path118.join(cwd, ".metaproject", "metaproject.json");
40279
+ const manifestPath = path120.join(cwd, ".metaproject", "metaproject.json");
40210
40280
  if (!await pathExists(manifestPath)) {
40211
40281
  return false;
40212
40282
  }
@@ -40231,11 +40301,11 @@ async function isTestingCapabilityEnabled(cwd, capability) {
40231
40301
  // src/testing/coverage-map.ts
40232
40302
  init_fs();
40233
40303
  init_guard();
40234
- import { readFile as readFile60, mkdir as mkdir28, writeFile as writeFile21 } from "fs/promises";
40235
- import path119 from "path";
40304
+ import { readFile as readFile60, mkdir as mkdir27, writeFile as writeFile20 } from "fs/promises";
40305
+ import path121 from "path";
40236
40306
  var COVERAGE_MAP_SCHEMA_VERSION = 1;
40237
40307
  function coverageMapPath(cwd, cfg) {
40238
- return path119.isAbsolute(cfg.coverageMap.artifact) ? cfg.coverageMap.artifact : path119.join(cwd, cfg.coverageMap.artifact);
40308
+ return path121.isAbsolute(cfg.coverageMap.artifact) ? cfg.coverageMap.artifact : path121.join(cwd, cfg.coverageMap.artifact);
40239
40309
  }
40240
40310
  async function loadCoverageMap(cwd, cfg) {
40241
40311
  const file = coverageMapPath(cwd, cfg);
@@ -40370,7 +40440,7 @@ var DEFAULT_TESTING_CONFIG = {
40370
40440
  }
40371
40441
  };
40372
40442
  function testingDataRoot(cwd) {
40373
- return path120.join(cwd, ".metaproject", "data", "testing");
40443
+ return path122.join(cwd, ".metaproject", "data", "testing");
40374
40444
  }
40375
40445
  async function computeTestingContext(cwd) {
40376
40446
  const { files, incompleteReasons } = await listProjectFiles(cwd);
@@ -40545,7 +40615,7 @@ async function runTesting(input) {
40545
40615
  return runResult;
40546
40616
  }
40547
40617
  async function loadTestingContext(cwd) {
40548
- const file = path120.join(testingDataRoot(cwd), "context.json");
40618
+ const file = path122.join(testingDataRoot(cwd), "context.json");
40549
40619
  if (!await pathExists(file)) {
40550
40620
  return null;
40551
40621
  }
@@ -40556,18 +40626,18 @@ async function loadTestingContext(cwd) {
40556
40626
  }
40557
40627
  }
40558
40628
  async function loadTestingReport(cwd) {
40559
- const file = path120.join(testingDataRoot(cwd), "artifacts", "latest.json");
40629
+ const file = path122.join(testingDataRoot(cwd), "artifacts", "latest.json");
40560
40630
  if (!await pathExists(file)) {
40561
40631
  return null;
40562
40632
  }
40563
40633
  try {
40564
40634
  const latest = JSON.parse(await readFile61(file, "utf8"));
40565
40635
  if (typeof latest.record === "string") {
40566
- const pointer = await readArtifactPointer(path120.join(testingDataRoot(cwd), "artifacts"), await collectGitProvenance(cwd));
40636
+ const pointer = await readArtifactPointer(path122.join(testingDataRoot(cwd), "artifacts"), await collectGitProvenance(cwd));
40567
40637
  if (pointer.status !== "fresh")
40568
40638
  return null;
40569
- const recordFile = path120.join(testingDataRoot(cwd), "artifacts", latest.record);
40570
- if (!isPathInside(path120.join(testingDataRoot(cwd), "artifacts"), recordFile))
40639
+ const recordFile = path122.join(testingDataRoot(cwd), "artifacts", latest.record);
40640
+ if (!isPathInside(path122.join(testingDataRoot(cwd), "artifacts"), recordFile))
40571
40641
  return null;
40572
40642
  if (!await pathExists(recordFile))
40573
40643
  return null;
@@ -40614,28 +40684,28 @@ async function ensureContext(cwd) {
40614
40684
  }
40615
40685
  async function writeContext(cwd, context) {
40616
40686
  const root = testingDataRoot(cwd);
40617
- const rel = (p) => path120.relative(cwd, p);
40687
+ const rel = (p) => path122.relative(cwd, p);
40618
40688
  await mkdirContained(cwd, rel(root));
40619
- await writeContained(cwd, rel(path120.join(root, "context.json")), `${JSON.stringify(context, null, 2)}
40689
+ await writeContained(cwd, rel(path122.join(root, "context.json")), `${JSON.stringify(context, null, 2)}
40620
40690
  `);
40621
- await writeContained(cwd, rel(path120.join(root, "context.md")), renderContextMarkdown(context));
40622
- await writeContained(cwd, rel(path120.join(root, "recommendations.md")), renderRecommendationsMarkdown(context));
40691
+ await writeContained(cwd, rel(path122.join(root, "context.md")), renderContextMarkdown(context));
40692
+ await writeContained(cwd, rel(path122.join(root, "recommendations.md")), renderRecommendationsMarkdown(context));
40623
40693
  }
40624
40694
  async function writeReport(cwd, report) {
40625
40695
  const root = testingDataRoot(cwd);
40626
- const artifacts = path120.join(root, "artifacts");
40627
- const history = path120.join(root, "history");
40628
- const rel = (p) => path120.relative(cwd, p);
40696
+ const artifacts = path122.join(root, "artifacts");
40697
+ const history = path122.join(root, "history");
40698
+ const rel = (p) => path122.relative(cwd, p);
40629
40699
  await mkdirContained(cwd, rel(artifacts));
40630
40700
  await mkdirContained(cwd, rel(history));
40631
40701
  const stamp = report.generatedAt.replace(/[:.]/g, "-");
40632
- const json = path120.join(artifacts, "latest.json");
40633
- const markdown = path120.join(artifacts, "latest.md");
40702
+ const json = path122.join(artifacts, "latest.json");
40703
+ const markdown = path122.join(artifacts, "latest.md");
40634
40704
  const serialized = `${JSON.stringify(report, null, 2)}
40635
40705
  `;
40636
40706
  if (report.runId) {
40637
- const runJson = path120.join(artifacts, "runs", `${report.runId}.json`);
40638
- const runMarkdown = path120.join(artifacts, "runs", `${report.runId}.md`);
40707
+ const runJson = path122.join(artifacts, "runs", `${report.runId}.json`);
40708
+ const runMarkdown = path122.join(artifacts, "runs", `${report.runId}.md`);
40639
40709
  if (await pathExists(runJson))
40640
40710
  throw new Error(`immutable testing run already exists: ${report.runId}`);
40641
40711
  await writeContained(cwd, rel(runJson), serialized);
@@ -40646,26 +40716,26 @@ async function writeReport(cwd, report) {
40646
40716
  branch: report.provenance?.branch ?? null,
40647
40717
  worktree: report.provenance?.worktree ?? null,
40648
40718
  generated_at: report.generatedAt,
40649
- record: path120.posix.join("runs", `${report.runId}.json`)
40719
+ record: path122.posix.join("runs", `${report.runId}.json`)
40650
40720
  }, null, 2)}
40651
40721
  `);
40652
40722
  } else {
40653
40723
  await writeContained(cwd, rel(json), serialized);
40654
40724
  }
40655
40725
  await writeContained(cwd, rel(markdown), renderReportMarkdown3(report));
40656
- await writeContained(cwd, rel(path120.join(history, `${stamp}.json`)), serialized);
40726
+ await writeContained(cwd, rel(path122.join(history, `${stamp}.json`)), serialized);
40657
40727
  return {
40658
- markdownPath: path120.relative(cwd, markdown),
40659
- jsonPath: path120.relative(cwd, json)
40728
+ markdownPath: path122.relative(cwd, markdown),
40729
+ jsonPath: path122.relative(cwd, json)
40660
40730
  };
40661
40731
  }
40662
40732
  async function writeRawLog(cwd, raw) {
40663
- const logs = path120.join(testingDataRoot(cwd), "logs");
40664
- const rel = (p) => path120.relative(cwd, p);
40733
+ const logs = path122.join(testingDataRoot(cwd), "logs");
40734
+ const rel = (p) => path122.relative(cwd, p);
40665
40735
  await mkdirContained(cwd, rel(logs));
40666
- const latest = path120.join(logs, "latest.raw.log");
40736
+ const latest = path122.join(logs, "latest.raw.log");
40667
40737
  await writeContained(cwd, rel(latest), raw);
40668
- return path120.relative(cwd, latest);
40738
+ return path122.relative(cwd, latest);
40669
40739
  }
40670
40740
  async function listProjectFiles(cwd) {
40671
40741
  const out = [];
@@ -40678,11 +40748,11 @@ async function walk3(root, dir, out, incompleteReasons) {
40678
40748
  try {
40679
40749
  entries = await readdir20(dir, { withFileTypes: true });
40680
40750
  } catch (error) {
40681
- incompleteReasons.push(`${normalizePath6(path120.relative(root, dir)) || "."}: ${error instanceof Error ? error.message : String(error)}`);
40751
+ incompleteReasons.push(`${normalizePath6(path122.relative(root, dir)) || "."}: ${error instanceof Error ? error.message : String(error)}`);
40682
40752
  return;
40683
40753
  }
40684
40754
  for (const entry of entries) {
40685
- const abs = path120.join(dir, entry.name);
40755
+ const abs = path122.join(dir, entry.name);
40686
40756
  if (entry.isDirectory()) {
40687
40757
  if (IGNORED_DIRS2.has(entry.name) || entry.name.startsWith(".tmp-")) {
40688
40758
  continue;
@@ -40691,12 +40761,12 @@ async function walk3(root, dir, out, incompleteReasons) {
40691
40761
  continue;
40692
40762
  }
40693
40763
  if (entry.isFile()) {
40694
- out.push(normalizePath6(path120.relative(root, abs)));
40764
+ out.push(normalizePath6(path122.relative(root, abs)));
40695
40765
  }
40696
40766
  }
40697
40767
  }
40698
40768
  async function readPackageJson(cwd) {
40699
- const file = path120.join(cwd, "package.json");
40769
+ const file = path122.join(cwd, "package.json");
40700
40770
  if (!await pathExists(file)) {
40701
40771
  return null;
40702
40772
  }
@@ -40707,7 +40777,7 @@ async function readPackageJson(cwd) {
40707
40777
  }
40708
40778
  }
40709
40779
  async function loadTestingConfig(cwd) {
40710
- const file = path120.join(cwd, ".metaproject", "testing.config.json");
40780
+ const file = path122.join(cwd, ".metaproject", "testing.config.json");
40711
40781
  if (!await pathExists(file)) {
40712
40782
  return DEFAULT_TESTING_CONFIG;
40713
40783
  }
@@ -40772,7 +40842,7 @@ function detectFrameworks(input) {
40772
40842
  async function extractConventions(cwd, files) {
40773
40843
  const conventions = new Set;
40774
40844
  for (const file of files.slice(0, 40)) {
40775
- const abs = path120.join(cwd, file);
40845
+ const abs = path122.join(cwd, file);
40776
40846
  if (!await pathExists(abs)) {
40777
40847
  continue;
40778
40848
  }
@@ -40902,7 +40972,7 @@ async function findTestsByImportedTargets(cwd, targets, testFiles) {
40902
40972
  const targetKeys = new Set(targets.map((target) => modulePathKey(normalizePath6(target))));
40903
40973
  const selected = new Set;
40904
40974
  for (const testFile of testFiles) {
40905
- const absoluteTest = path120.join(cwd, testFile);
40975
+ const absoluteTest = path122.join(cwd, testFile);
40906
40976
  if (!await pathExists(absoluteTest)) {
40907
40977
  continue;
40908
40978
  }
@@ -40936,10 +41006,10 @@ function resolveImportPath(cwd, testFile, importPath) {
40936
41006
  if (!importPath.startsWith(".")) {
40937
41007
  return null;
40938
41008
  }
40939
- const importerDir = path120.dirname(testFile);
40940
- const absoluteResolved = path120.resolve(path120.join(cwd, importerDir), importPath);
40941
- const relative = path120.relative(cwd, absoluteResolved);
40942
- if (relative.startsWith(`..${path120.sep}`) || relative === "..") {
41009
+ const importerDir = path122.dirname(testFile);
41010
+ const absoluteResolved = path122.resolve(path122.join(cwd, importerDir), importPath);
41011
+ const relative = path122.relative(cwd, absoluteResolved);
41012
+ if (relative.startsWith(`..${path122.sep}`) || relative === "..") {
40943
41013
  return null;
40944
41014
  }
40945
41015
  const relativeNormalized = normalizePath6(relative);
@@ -40991,13 +41061,13 @@ function resolveTestCommand(cwd, context, input) {
40991
41061
  }
40992
41062
  var BUN_LOCKFILES = ["bun.lock", "bun.lockb"];
40993
41063
  function detectPackageManager(cwd) {
40994
- if (resolveBunBin() && BUN_LOCKFILES.some((name) => pathExistsSync(path120.join(cwd, name)))) {
41064
+ if (resolveBunBin() && BUN_LOCKFILES.some((name) => pathExistsSync(path122.join(cwd, name)))) {
40995
41065
  return "bun";
40996
41066
  }
40997
- if (Bun.which("pnpm") && pathExistsSync(path120.join(cwd, "pnpm-lock.yaml"))) {
41067
+ if (Bun.which("pnpm") && pathExistsSync(path122.join(cwd, "pnpm-lock.yaml"))) {
40998
41068
  return "pnpm";
40999
41069
  }
41000
- if (Bun.which("yarn") && pathExistsSync(path120.join(cwd, "yarn.lock"))) {
41070
+ if (Bun.which("yarn") && pathExistsSync(path122.join(cwd, "yarn.lock"))) {
41001
41071
  return "yarn";
41002
41072
  }
41003
41073
  return "npm";
@@ -41337,7 +41407,7 @@ async function compatibleReportForHealth(ctx) {
41337
41407
 
41338
41408
  // src/health/sources/dependency-audit.ts
41339
41409
  import { existsSync as existsSync18 } from "fs";
41340
- import path121 from "path";
41410
+ import path123 from "path";
41341
41411
  function auditSeverityToPriority(severity) {
41342
41412
  if (severity === "critical" || severity === "high")
41343
41413
  return "P0";
@@ -41456,7 +41526,7 @@ var LOCKFILE_COMMANDS = [
41456
41526
  ];
41457
41527
  function auditCommand(cwd) {
41458
41528
  for (const entry of LOCKFILE_COMMANDS) {
41459
- if (!entry.lockfiles.some((name) => existsSync18(path121.join(cwd, name))))
41529
+ if (!entry.lockfiles.some((name) => existsSync18(path123.join(cwd, name))))
41460
41530
  continue;
41461
41531
  const bin = resolveBin(cwd, entry.bin);
41462
41532
  if (bin)
@@ -41515,13 +41585,13 @@ var dependencyAuditAdapter = {
41515
41585
 
41516
41586
  // src/health/sources/sonarqube.ts
41517
41587
  import { existsSync as existsSync19 } from "fs";
41518
- import path122 from "path";
41588
+ import path124 from "path";
41519
41589
  var REPORT_FILES = ["sonar-issues.json", ".metaproject/data/health/sonar-issues.json"];
41520
41590
  function reportPath(cwd) {
41521
41591
  const fromEnv = process.env.SONAR_ISSUES_FILE;
41522
41592
  const candidates = fromEnv ? [fromEnv, ...REPORT_FILES] : REPORT_FILES;
41523
41593
  for (const rel of candidates) {
41524
- const abs = path122.isAbsolute(rel) ? rel : path122.join(cwd, rel);
41594
+ const abs = path124.isAbsolute(rel) ? rel : path124.join(cwd, rel);
41525
41595
  if (existsSync19(abs)) {
41526
41596
  return abs;
41527
41597
  }
@@ -41605,7 +41675,7 @@ var sonarqubeAdapter = {
41605
41675
  function relativizeComponent(component, cwd) {
41606
41676
  const colon = component.indexOf(":");
41607
41677
  const value = colon >= 0 ? component.slice(colon + 1) : component;
41608
- return path122.isAbsolute(value) ? path122.relative(cwd, value) : value;
41678
+ return path124.isAbsolute(value) ? path124.relative(cwd, value) : value;
41609
41679
  }
41610
41680
 
41611
41681
  // src/health/sources/index.ts
@@ -41966,19 +42036,19 @@ function filteredInfo(source, cfg) {
41966
42036
  };
41967
42037
  }
41968
42038
  async function writeOutputs(cwd, report, config, stamp) {
41969
- const artifacts = path123.join(dataRoot3(cwd), "artifacts");
41970
- const history = path123.join(dataRoot3(cwd), "history");
41971
- await mkdir29(artifacts, { recursive: true });
41972
- await mkdir29(history, { recursive: true });
41973
- const markdown = path123.join(artifacts, "latest.md");
41974
- const json = path123.join(artifacts, "latest.json");
41975
- const historyJson = path123.join(history, `${stamp}.json`);
42039
+ const artifacts = path125.join(dataRoot3(cwd), "artifacts");
42040
+ const history = path125.join(dataRoot3(cwd), "history");
42041
+ await mkdir28(artifacts, { recursive: true });
42042
+ await mkdir28(history, { recursive: true });
42043
+ const markdown = path125.join(artifacts, "latest.md");
42044
+ const json = path125.join(artifacts, "latest.json");
42045
+ const historyJson = path125.join(history, `${stamp}.json`);
41976
42046
  const serialized = `${JSON.stringify(report, null, 2)}
41977
42047
  `;
41978
- await writeFile22(markdown, renderReportMarkdown2(report, config), "utf8");
42048
+ await writeFile21(markdown, renderReportMarkdown2(report, config), "utf8");
41979
42049
  if (report.runId) {
41980
- const runJson = path123.join(artifacts, "runs", `${report.runId}.json`);
41981
- const runMarkdown = path123.join(artifacts, "runs", `${report.runId}.md`);
42050
+ const runJson = path125.join(artifacts, "runs", `${report.runId}.json`);
42051
+ const runMarkdown = path125.join(artifacts, "runs", `${report.runId}.md`);
41982
42052
  if (await pathExists(runJson))
41983
42053
  throw new Error(`immutable health run already exists: ${report.runId}`);
41984
42054
  await writeFileAtomic(runJson, serialized);
@@ -41989,16 +42059,16 @@ async function writeOutputs(cwd, report, config, stamp) {
41989
42059
  branch: report.provenance?.branch ?? null,
41990
42060
  worktree: report.provenance?.worktree ?? null,
41991
42061
  generated_at: report.generatedAt,
41992
- record: path123.posix.join("runs", `${report.runId}.json`)
42062
+ record: path125.posix.join("runs", `${report.runId}.json`)
41993
42063
  }, null, 2)}
41994
42064
  `);
41995
42065
  } else {
41996
- await writeFile22(json, serialized, "utf8");
42066
+ await writeFile21(json, serialized, "utf8");
41997
42067
  }
41998
- await writeFile22(historyJson, serialized, "utf8");
42068
+ await writeFile21(historyJson, serialized, "utf8");
41999
42069
  return {
42000
- markdownPath: path123.relative(cwd, markdown),
42001
- jsonPath: path123.relative(cwd, json)
42070
+ markdownPath: path125.relative(cwd, markdown),
42071
+ jsonPath: path125.relative(cwd, json)
42002
42072
  };
42003
42073
  }
42004
42074
  async function resolveChanged(cwd, selector) {
@@ -42051,7 +42121,7 @@ function hasGateShape(value) {
42051
42121
  return Array.isArray(report.metrics) && Array.isArray(report.sources) && Array.isArray(report.findings);
42052
42122
  }
42053
42123
  async function readLatest(cwd) {
42054
- const file = path124.join(dataRoot3(cwd), "artifacts", "latest.json");
42124
+ const file = path126.join(dataRoot3(cwd), "artifacts", "latest.json");
42055
42125
  if (!await pathExists(file)) {
42056
42126
  return null;
42057
42127
  }
@@ -42062,11 +42132,11 @@ async function readLatest(cwd) {
42062
42132
  const latest = read.value;
42063
42133
  const record = latest.record;
42064
42134
  if (typeof record === "string") {
42065
- const pointer = await readArtifactPointer(path124.join(dataRoot3(cwd), "artifacts"), await collectGitProvenance(cwd));
42135
+ const pointer = await readArtifactPointer(path126.join(dataRoot3(cwd), "artifacts"), await collectGitProvenance(cwd));
42066
42136
  if (pointer.status !== "fresh")
42067
42137
  return null;
42068
- const recordFile = path124.join(dataRoot3(cwd), "artifacts", record);
42069
- if (!isPathInside(path124.join(dataRoot3(cwd), "artifacts"), recordFile))
42138
+ const recordFile = path126.join(dataRoot3(cwd), "artifacts", record);
42139
+ if (!isPathInside(path126.join(dataRoot3(cwd), "artifacts"), recordFile))
42070
42140
  return null;
42071
42141
  if (!await pathExists(recordFile))
42072
42142
  return null;
@@ -42139,7 +42209,7 @@ function createCodeHealthService() {
42139
42209
  return {
42140
42210
  run: (input) => runHealth(input),
42141
42211
  async status(input) {
42142
- const enabled = await pathExists(path124.join(input.cwd, ".metaproject", "health.config.json"));
42212
+ const enabled = await pathExists(path126.join(input.cwd, ".metaproject", "health.config.json"));
42143
42213
  const latest = await readLatest(input.cwd);
42144
42214
  const project = latest?.metrics.find((m) => m.key === "project") ?? null;
42145
42215
  const decliningScopes = latest ? latest.metrics.filter((m) => m.regression_score > 0).length : 0;
@@ -42296,10 +42366,10 @@ function renderEvidenceBlock(evidences, siblings) {
42296
42366
  init_fs();
42297
42367
  init_contained_write();
42298
42368
  init_json();
42299
- import path125 from "path";
42369
+ import path127 from "path";
42300
42370
  import { createHash as createHash21 } from "crypto";
42301
42371
  function impactEvidenceDataRoot(root) {
42302
- return path125.join(root, ".metaproject", "data", "security", "impact-evidence");
42372
+ return path127.join(root, ".metaproject", "data", "security", "impact-evidence");
42303
42373
  }
42304
42374
  function sanitizeSessionId(sessionId) {
42305
42375
  const cleaned = sessionId.replace(/[^A-Za-z0-9._-]/g, "_");
@@ -42311,7 +42381,7 @@ function sessionStateFilename(sessionId) {
42311
42381
  return `${sanitized}-${suffix}.json`;
42312
42382
  }
42313
42383
  function sessionStatePath(root, sessionId) {
42314
- return path125.join(impactEvidenceDataRoot(root), "sessions", sessionStateFilename(sessionId));
42384
+ return path127.join(impactEvidenceDataRoot(root), "sessions", sessionStateFilename(sessionId));
42315
42385
  }
42316
42386
  async function loadSessionState(root, sessionId) {
42317
42387
  const file = sessionStatePath(root, sessionId);
@@ -42330,11 +42400,11 @@ async function loadSessionState(root, sessionId) {
42330
42400
  }
42331
42401
  async function saveSessionState(root, sessionId, state) {
42332
42402
  const file = sessionStatePath(root, sessionId);
42333
- await writeContained(root, path125.relative(root, file), `${JSON.stringify(state, null, 2)}
42403
+ await writeContained(root, path127.relative(root, file), `${JSON.stringify(state, null, 2)}
42334
42404
  `);
42335
42405
  }
42336
42406
  function logPath(root) {
42337
- return path125.join(impactEvidenceDataRoot(root), "log.jsonl");
42407
+ return path127.join(impactEvidenceDataRoot(root), "log.jsonl");
42338
42408
  }
42339
42409
  async function appendLogRecord(root, record) {
42340
42410
  const full = {
@@ -42345,7 +42415,7 @@ async function appendLogRecord(root, record) {
42345
42415
  ...record.detail !== undefined ? { detail: record.detail } : {}
42346
42416
  };
42347
42417
  const file = logPath(root);
42348
- await appendContained(root, path125.relative(root, file), `${JSON.stringify(full)}
42418
+ await appendContained(root, path127.relative(root, file), `${JSON.stringify(full)}
42349
42419
  `);
42350
42420
  return full;
42351
42421
  }
@@ -42372,7 +42442,7 @@ init_command_risk();
42372
42442
  init_shell_syntax();
42373
42443
  init_fs();
42374
42444
  init_service2();
42375
- import path126 from "path";
42445
+ import path128 from "path";
42376
42446
  import { createHash as createHash22 } from "crypto";
42377
42447
  import { realpathSync as realpathSync2 } from "fs";
42378
42448
  function impactEvidenceHookClass(strict) {
@@ -42388,29 +42458,29 @@ function realpathNearestExisting(p) {
42388
42458
  for (;; ) {
42389
42459
  try {
42390
42460
  const real = realpathSync2(current);
42391
- return tail.length > 0 ? path126.join(real, ...tail) : real;
42461
+ return tail.length > 0 ? path128.join(real, ...tail) : real;
42392
42462
  } catch {
42393
- const parent = path126.dirname(current);
42463
+ const parent = path128.dirname(current);
42394
42464
  if (parent === current) {
42395
- return tail.length > 0 ? path126.join(current, ...tail) : current;
42465
+ return tail.length > 0 ? path128.join(current, ...tail) : current;
42396
42466
  }
42397
- tail.unshift(path126.basename(current));
42467
+ tail.unshift(path128.basename(current));
42398
42468
  current = parent;
42399
42469
  }
42400
42470
  }
42401
42471
  }
42402
42472
  function normalizeRequestFiles(root, files) {
42403
- const rootReal = realpathNearestExisting(path126.resolve(root));
42473
+ const rootReal = realpathNearestExisting(path128.resolve(root));
42404
42474
  const normalized = [];
42405
42475
  const rejected = [];
42406
42476
  for (const file of files) {
42407
- const lexicalAbsolute = path126.isAbsolute(file) ? path126.resolve(file) : path126.resolve(rootReal, toPosix(file).replace(/^\.\//, ""));
42477
+ const lexicalAbsolute = path128.isAbsolute(file) ? path128.resolve(file) : path128.resolve(rootReal, toPosix(file).replace(/^\.\//, ""));
42408
42478
  const effective = realpathNearestExisting(lexicalAbsolute);
42409
42479
  if (!isPathInside(rootReal, effective)) {
42410
42480
  rejected.push(file);
42411
42481
  continue;
42412
42482
  }
42413
- normalized.push(toPosix(path126.relative(rootReal, effective)));
42483
+ normalized.push(toPosix(path128.relative(rootReal, effective)));
42414
42484
  }
42415
42485
  return { files: [...new Set(normalized)], rejected };
42416
42486
  }
@@ -42691,8 +42761,8 @@ function hostDeliveryStatus() {
42691
42761
  }
42692
42762
  // src/job/service.ts
42693
42763
  init_fs();
42694
- import { copyFile, mkdir as mkdir31 } from "fs/promises";
42695
- import path129 from "path";
42764
+ import { copyFile, mkdir as mkdir30 } from "fs/promises";
42765
+ import path131 from "path";
42696
42766
 
42697
42767
  // src/job/types.ts
42698
42768
  var JOB_INTENTS = ["implement", "analyze", "review", "custom"];
@@ -42832,16 +42902,16 @@ function defaultPlan(intent) {
42832
42902
  init_validator();
42833
42903
  init_contracts();
42834
42904
  init_fs();
42835
- import { appendFile as appendFile6, mkdir as mkdir30, readFile as readFile63, readdir as readdir21 } from "fs/promises";
42836
- import path128 from "path";
42905
+ import { appendFile as appendFile6, mkdir as mkdir29, readFile as readFile63, readdir as readdir21 } from "fs/promises";
42906
+ import path130 from "path";
42837
42907
  function jobsRoot(cwd) {
42838
- return path128.join(cwd, ".metaproject", "jobs");
42908
+ return path130.join(cwd, ".metaproject", "jobs");
42839
42909
  }
42840
42910
  function jobDir(cwd, name) {
42841
- return path128.join(jobsRoot(cwd), name);
42911
+ return path130.join(jobsRoot(cwd), name);
42842
42912
  }
42843
42913
  function jobStatePath(cwd, name) {
42844
- return path128.join(jobDir(cwd, name), "state.json");
42914
+ return path130.join(jobDir(cwd, name), "state.json");
42845
42915
  }
42846
42916
  var JOB_NAME_PATTERN = /^[a-z0-9-]+$/;
42847
42917
  function assertJobName(name) {
@@ -42878,12 +42948,12 @@ async function writeJob(cwd, name, state) {
42878
42948
  `));
42879
42949
  }
42880
42950
  const file = jobStatePath(cwd, name);
42881
- await mkdir30(path128.dirname(file), { recursive: true });
42951
+ await mkdir29(path130.dirname(file), { recursive: true });
42882
42952
  await writeFileAtomic(file, `${JSON.stringify(state, null, 2)}
42883
42953
  `);
42884
42954
  }
42885
42955
  async function appendJournal2(cwd, name, at, line) {
42886
- await appendFile6(path128.join(jobDir(cwd, name), "journal.md"), `- ${at} - ${line}
42956
+ await appendFile6(path130.join(jobDir(cwd, name), "journal.md"), `- ${at} - ${line}
42887
42957
  `, "utf8");
42888
42958
  }
42889
42959
  function renderJournal2(name, at) {
@@ -42904,7 +42974,7 @@ function assertDocumentType(raw) {
42904
42974
  return raw;
42905
42975
  }
42906
42976
  function documentFileName(type, sourcePath) {
42907
- const extension = path128.extname(sourcePath) || ".md";
42977
+ const extension = path130.extname(sourcePath) || ".md";
42908
42978
  return `${type}${extension}`;
42909
42979
  }
42910
42980
 
@@ -42912,7 +42982,7 @@ function documentFileName(type, sourcePath) {
42912
42982
  function createJobService(deps) {
42913
42983
  const now = () => deps.now().toISOString();
42914
42984
  function lockPath(cwd, name) {
42915
- return path129.join(jobsRoot(cwd), `.job-lock-${name}`);
42985
+ return path131.join(jobsRoot(cwd), `.job-lock-${name}`);
42916
42986
  }
42917
42987
  async function mutate(cwd, name, run) {
42918
42988
  assertJobName(name);
@@ -42950,7 +43020,7 @@ function createJobService(deps) {
42950
43020
  if (await pathExists(absolute)) {
42951
43021
  throw new Error(`Job package already exists: .metaproject/jobs/${name}. ` + `Run: keryx job status ${name}`);
42952
43022
  }
42953
- await mkdir31(absolute, { recursive: true });
43023
+ await mkdir30(absolute, { recursive: true });
42954
43024
  const createdAt = now();
42955
43025
  const state = {
42956
43026
  phase: "PLAN",
@@ -42961,20 +43031,20 @@ function createJobService(deps) {
42961
43031
  },
42962
43032
  plan: { steps: defaultPlan(intent) },
42963
43033
  documentation: {
42964
- job_path: path129.join(".metaproject", "jobs", name),
43034
+ job_path: path131.join(".metaproject", "jobs", name),
42965
43035
  documents_created: []
42966
43036
  },
42967
43037
  metrics: { steps: [] },
42968
- jobs_root: path129.join(".metaproject", "jobs"),
43038
+ jobs_root: path131.join(".metaproject", "jobs"),
42969
43039
  updated_at: createdAt
42970
43040
  };
42971
43041
  const first = firstOpenStep(state.plan.steps);
42972
43042
  if (first) {
42973
43043
  state.plan.current_step = first.id;
42974
43044
  }
42975
- await writeFileAtomic(path129.join(absolute, "journal.md"), renderJournal2(name, createdAt));
43045
+ await writeFileAtomic(path131.join(absolute, "journal.md"), renderJournal2(name, createdAt));
42976
43046
  await writeJob(input.cwd, name, state);
42977
- return { state, dir: path129.relative(input.cwd, absolute) };
43047
+ return { state, dir: path131.relative(input.cwd, absolute) };
42978
43048
  },
42979
43049
  async status({ cwd, name }) {
42980
43050
  assertJobName(name);
@@ -42986,7 +43056,7 @@ function createJobService(deps) {
42986
43056
  }
42987
43057
  return {
42988
43058
  state,
42989
- dir: path129.join(".metaproject", "jobs", name),
43059
+ dir: path131.join(".metaproject", "jobs", name),
42990
43060
  stepsDone: state.plan.steps.filter((step) => isTerminalStep(step.status)).length,
42991
43061
  stepsTotal: state.plan.steps.length,
42992
43062
  nextStep: firstOpenStep(state.plan.steps),
@@ -43043,23 +43113,23 @@ function createJobService(deps) {
43043
43113
  if (!input.file) {
43044
43114
  throw new Error("Missing --file. Usage: keryx job document <name> --type <type> --file <path>");
43045
43115
  }
43046
- const source = path129.isAbsolute(input.file) ? input.file : path129.join(input.cwd, input.file);
43116
+ const source = path131.isAbsolute(input.file) ? input.file : path131.join(input.cwd, input.file);
43047
43117
  if (!await pathExists(source)) {
43048
43118
  throw new Error(`--file not found: ${input.file}. Write the document first, then record it.`);
43049
43119
  }
43050
43120
  let recorded;
43051
43121
  await mutate(input.cwd, input.name, async (state) => {
43052
43122
  const fileName = documentFileName(type, source);
43053
- const target = path129.join(jobDir(input.cwd, state.job_name), fileName);
43123
+ const target = path131.join(jobDir(input.cwd, state.job_name), fileName);
43054
43124
  await copyFile(source, target);
43055
43125
  state.documentation ??= {};
43056
- state.documentation.job_path ??= path129.join(".metaproject", "jobs", state.job_name);
43126
+ state.documentation.job_path ??= path131.join(".metaproject", "jobs", state.job_name);
43057
43127
  const created = state.documentation.documents_created ?? [];
43058
43128
  state.documentation.documents_created = created.includes(fileName) ? created : [...created, fileName];
43059
43129
  recorded = {
43060
43130
  state,
43061
43131
  document: fileName,
43062
- path: path129.join(".metaproject", "jobs", state.job_name, fileName)
43132
+ path: path131.join(".metaproject", "jobs", state.job_name, fileName)
43063
43133
  };
43064
43134
  return { state, event: "document", detail: `${type} -> ${fileName}` };
43065
43135
  });
@@ -43094,7 +43164,7 @@ function createJobService(deps) {
43094
43164
  name: state.job_name,
43095
43165
  phase: state.phase,
43096
43166
  intent: state.intent,
43097
- dir: path129.join(".metaproject", "jobs", name),
43167
+ dir: path131.join(".metaproject", "jobs", name),
43098
43168
  stepsDone: state.plan.steps.filter((step) => isTerminalStep(step.status)).length,
43099
43169
  stepsTotal: state.plan.steps.length,
43100
43170
  nextStep: firstOpenStep(state.plan.steps)?.id ?? null
@@ -43115,39 +43185,22 @@ init_fs();
43115
43185
  init_preservation();
43116
43186
  import { randomUUID as randomUUID8 } from "crypto";
43117
43187
  import { lstat as lstat10, readdir as readdir26 } from "fs/promises";
43118
- import path143 from "path";
43188
+ import path146 from "path";
43119
43189
 
43120
43190
  // src/session/paths.ts
43191
+ init_config_dir();
43192
+ init_config_dir();
43121
43193
  import { existsSync as existsSync21 } from "fs";
43122
- import { homedir as homedir2 } from "os";
43123
- import path131 from "path";
43124
- function keryxDataDir(override) {
43125
- if (override !== undefined && override.length > 0) {
43126
- return override;
43127
- }
43128
- const env = process.env.KERYX_DATA_DIR;
43129
- if (env !== undefined && env.length > 0) {
43130
- return env;
43131
- }
43132
- const home = homedir2();
43133
- if (process.platform === "win32") {
43134
- const appData = process.env.APPDATA;
43135
- const base = appData !== undefined && appData.length > 0 ? appData : path131.join(home, "AppData", "Roaming");
43136
- return path131.join(base, "keryx");
43137
- }
43138
- const xdg = process.env.XDG_DATA_HOME;
43139
- const base = xdg !== undefined && xdg.length > 0 ? xdg : path131.join(home, ".local", "share");
43140
- return path131.join(base, "keryx");
43141
- }
43194
+ import path134 from "path";
43142
43195
  function resolveProjectRoot2(cwd) {
43143
- const abs = path131.resolve(cwd);
43196
+ const abs = path134.resolve(cwd);
43144
43197
  let dir = abs;
43145
43198
  for (;; ) {
43146
- const gitPath = path131.join(dir, ".git");
43199
+ const gitPath = path134.join(dir, ".git");
43147
43200
  if (existsSync21(gitPath)) {
43148
43201
  return dir;
43149
43202
  }
43150
- const parent = path131.dirname(dir);
43203
+ const parent = path134.dirname(dir);
43151
43204
  if (parent === dir) {
43152
43205
  break;
43153
43206
  }
@@ -43156,12 +43209,12 @@ function resolveProjectRoot2(cwd) {
43156
43209
  return abs;
43157
43210
  }
43158
43211
  function projectKeyFromPath(projectPath) {
43159
- const abs = path131.resolve(projectPath);
43212
+ const abs = path134.resolve(projectPath);
43160
43213
  const encoded = encodeURIComponent(abs);
43161
43214
  if (encoded.length <= 200) {
43162
43215
  return encoded;
43163
43216
  }
43164
- const base = path131.basename(abs).replace(/[^a-zA-Z0-9._-]+/g, "_").slice(0, 40);
43217
+ const base = path134.basename(abs).replace(/[^a-zA-Z0-9._-]+/g, "_").slice(0, 40);
43165
43218
  let h = 0;
43166
43219
  for (let i = 0;i < abs.length; i++) {
43167
43220
  h = Math.imul(31, h) + abs.charCodeAt(i) | 0;
@@ -43171,22 +43224,22 @@ function projectKeyFromPath(projectPath) {
43171
43224
  }
43172
43225
  function projectSessionsDir(projectPath, dataDir) {
43173
43226
  const key = projectKeyFromPath(resolveProjectRoot2(projectPath));
43174
- return path131.join(keryxDataDir(dataDir), "sessions", key);
43227
+ return path134.join(keryxDataDir(dataDir), "sessions", key);
43175
43228
  }
43176
43229
  function sessionDir(projectPath, sessionId, dataDir) {
43177
- return path131.join(projectSessionsDir(projectPath, dataDir), sessionId);
43230
+ return path134.join(projectSessionsDir(projectPath, dataDir), sessionId);
43178
43231
  }
43179
43232
 
43180
43233
  // src/sac/proposal-lifecycle.ts
43181
43234
  init_fs();
43182
43235
  import { createHash as createHash32, randomUUID as randomUUID7 } from "crypto";
43183
- import { appendFile as appendFile7, mkdir as mkdir35, readdir as readdir25, readFile as readFile73 } from "fs/promises";
43184
- import path142 from "path";
43236
+ import { appendFile as appendFile7, mkdir as mkdir34, readdir as readdir25, readFile as readFile73 } from "fs/promises";
43237
+ import path145 from "path";
43185
43238
 
43186
43239
  // src/sac/index.ts
43187
43240
  import { access as access3, readFile as readFile64, realpath as realpath14 } from "fs/promises";
43188
43241
  import { createHash as createHash24 } from "crypto";
43189
- import path132 from "path";
43242
+ import path135 from "path";
43190
43243
  import { fileURLToPath as fileURLToPath3 } from "url";
43191
43244
 
43192
43245
  // src/sac/workspace-reference.ts
@@ -43246,21 +43299,21 @@ var normativeSchemaFiles = {
43246
43299
  "review-decision": "review-decision.schema.json"
43247
43300
  };
43248
43301
  var normativeSchemas = new Map;
43249
- var NORMATIVE_SCHEMA_DIR = path132.join("docs", "requirements", "shared-agent-context", "schemas");
43302
+ var NORMATIVE_SCHEMA_DIR = path135.join("docs", "requirements", "shared-agent-context", "schemas");
43250
43303
  async function resolveSacNormativeSchemaPath(fileName, searchFrom = [fileURLToPath3(new URL(".", import.meta.url)), process.cwd()]) {
43251
43304
  const seen = new Set;
43252
43305
  for (const start of searchFrom) {
43253
- let dir = path132.resolve(start);
43306
+ let dir = path135.resolve(start);
43254
43307
  for (let i = 0;i < 10; i++) {
43255
43308
  if (seen.has(dir))
43256
43309
  break;
43257
43310
  seen.add(dir);
43258
- const candidate = path132.join(dir, NORMATIVE_SCHEMA_DIR, fileName);
43311
+ const candidate = path135.join(dir, NORMATIVE_SCHEMA_DIR, fileName);
43259
43312
  try {
43260
43313
  await access3(candidate);
43261
43314
  return candidate;
43262
43315
  } catch {}
43263
- const parent = path132.dirname(dir);
43316
+ const parent = path135.dirname(dir);
43264
43317
  if (parent === dir)
43265
43318
  break;
43266
43319
  dir = parent;
@@ -43929,12 +43982,12 @@ class SacReferenceError extends Error {
43929
43982
  code = "unsafe_workspace_reference";
43930
43983
  }
43931
43984
  async function resolveWorkspaceReference(input) {
43932
- if (!workspacePathPattern.test(input.uri) || path132.isAbsolute(input.uri) || /^[a-z][a-z0-9+.-]*:/i.test(input.uri) || input.uri.includes("\\"))
43985
+ if (!workspacePathPattern.test(input.uri) || path135.isAbsolute(input.uri) || /^[a-z][a-z0-9+.-]*:/i.test(input.uri) || input.uri.includes("\\"))
43933
43986
  throw new SacReferenceError("unsafe workspace reference");
43934
- const lexicalRoot = path132.resolve(input.workspaceRoot);
43987
+ const lexicalRoot = path135.resolve(input.workspaceRoot);
43935
43988
  const root = await realpath14(lexicalRoot);
43936
- const candidate = path132.resolve(lexicalRoot, input.uri.slice(2));
43937
- if (candidate !== lexicalRoot && !candidate.startsWith(`${lexicalRoot}${path132.sep}`))
43989
+ const candidate = path135.resolve(lexicalRoot, input.uri.slice(2));
43990
+ if (candidate !== lexicalRoot && !candidate.startsWith(`${lexicalRoot}${path135.sep}`))
43938
43991
  throw new SacReferenceError("workspace reference escapes root");
43939
43992
  let resolved;
43940
43993
  try {
@@ -43942,7 +43995,7 @@ async function resolveWorkspaceReference(input) {
43942
43995
  } catch {
43943
43996
  throw new SacReferenceError("workspace reference is not resolvable");
43944
43997
  }
43945
- if (resolved !== root && !resolved.startsWith(`${root}${path132.sep}`))
43998
+ if (resolved !== root && !resolved.startsWith(`${root}${path135.sep}`))
43946
43999
  throw new SacReferenceError("workspace reference escapes root after realpath");
43947
44000
  return candidate;
43948
44001
  }
@@ -43996,18 +44049,18 @@ async function evaluateStrictSacGuard(input) {
43996
44049
 
43997
44050
  // src/sac/workspace-service.ts
43998
44051
  init_fs();
43999
- import { mkdir as mkdir32, readdir as readdir22, readFile as readFile65 } from "fs/promises";
44052
+ import { mkdir as mkdir31, readdir as readdir22, readFile as readFile65 } from "fs/promises";
44000
44053
  import { createHash as createHash25, randomUUID as randomUUID4 } from "crypto";
44001
- import path134 from "path";
44054
+ import path137 from "path";
44002
44055
 
44003
44056
  // src/sac/secure-resource-read.ts
44004
44057
  init_contained_read();
44005
44058
  init_descriptor_read();
44006
- import path133 from "path";
44059
+ import path136 from "path";
44007
44060
  function readWorkspaceFileNoFollow(workspaceRoot, absolutePath) {
44008
- const relativePath = path133.relative(workspaceRoot, absolutePath);
44009
- const components = relativePath.split(path133.sep);
44010
- if (!relativePath || path133.isAbsolute(relativePath) || components.some((component) => !component || component === "." || component === "..")) {
44061
+ const relativePath = path136.relative(workspaceRoot, absolutePath);
44062
+ const components = relativePath.split(path136.sep);
44063
+ if (!relativePath || path136.isAbsolute(relativePath) || components.some((component) => !component || component === "." || component === "..")) {
44011
44064
  throw new Error("safe source path is not workspace-relative");
44012
44065
  }
44013
44066
  return readDescriptorChain(workspaceRoot, absolutePath, {
@@ -44034,8 +44087,8 @@ class WorkspaceService {
44034
44087
  now;
44035
44088
  constructor(options) {
44036
44089
  this.options = options;
44037
- this.root = path134.resolve(options.workspaceRoot);
44038
- this.storageRoot = path134.resolve(options.storageRoot ?? path134.join(this.root, ".metaproject", "workspaces"));
44090
+ this.root = path137.resolve(options.workspaceRoot);
44091
+ this.storageRoot = path137.resolve(options.storageRoot ?? path137.join(this.root, ".metaproject", "workspaces"));
44039
44092
  this.now = options.now ?? (() => new Date);
44040
44093
  }
44041
44094
  async create(input) {
@@ -44055,7 +44108,7 @@ class WorkspaceService {
44055
44108
  if (input.component)
44056
44109
  manifest.resources = [await this.pinResource(input.component)];
44057
44110
  const dir = this.workspaceDir(manifest.id);
44058
- await mkdir32(this.storageRoot, { recursive: true, mode: 448 });
44111
+ await mkdir31(this.storageRoot, { recursive: true, mode: 448 });
44059
44112
  await withFileLock(this.lockPath(manifest.id), async () => {
44060
44113
  try {
44061
44114
  await readFile65(this.manifestPath(manifest.id), "utf8");
@@ -44064,7 +44117,7 @@ class WorkspaceService {
44064
44117
  if (error instanceof WorkspaceServiceError || !isNotFound(error))
44065
44118
  throw error;
44066
44119
  }
44067
- await mkdir32(dir, { recursive: true, mode: 448 });
44120
+ await mkdir31(dir, { recursive: true, mode: 448 });
44068
44121
  await writeFileAtomic(this.manifestPath(manifest.id), `${JSON.stringify(manifest, null, 2)}
44069
44122
  `);
44070
44123
  });
@@ -44083,7 +44136,7 @@ class WorkspaceService {
44083
44136
  }
44084
44137
  async enumerateVisible(actor, includeArchived) {
44085
44138
  try {
44086
- await mkdir32(this.storageRoot, { recursive: true, mode: 448 });
44139
+ await mkdir31(this.storageRoot, { recursive: true, mode: 448 });
44087
44140
  } catch {
44088
44141
  return [];
44089
44142
  }
@@ -44361,13 +44414,13 @@ class WorkspaceService {
44361
44414
  return parsed;
44362
44415
  }
44363
44416
  workspaceDir(id) {
44364
- return path134.join(this.storageRoot, id);
44417
+ return path137.join(this.storageRoot, id);
44365
44418
  }
44366
44419
  manifestPath(id) {
44367
- return path134.join(this.workspaceDir(id), "workspace.json");
44420
+ return path137.join(this.workspaceDir(id), "workspace.json");
44368
44421
  }
44369
44422
  lockPath(id) {
44370
- return path134.join(this.storageRoot, `.${id}.lock`);
44423
+ return path137.join(this.storageRoot, `.${id}.lock`);
44371
44424
  }
44372
44425
  timestamp() {
44373
44426
  return this.now().toISOString();
@@ -44485,8 +44538,8 @@ function bindingHash(owner, intent) {
44485
44538
 
44486
44539
  // src/sac/session-wrap-up.ts
44487
44540
  import { createHash as createHash28 } from "crypto";
44488
- import { mkdir as mkdir34, writeFile as writeFile23 } from "fs/promises";
44489
- import path137 from "path";
44541
+ import { mkdir as mkdir33, writeFile as writeFile22 } from "fs/promises";
44542
+ import path140 from "path";
44490
44543
 
44491
44544
  // src/session/store.ts
44492
44545
  init_preservation();
@@ -44499,7 +44552,7 @@ import {
44499
44552
  renameSync as renameSync5,
44500
44553
  writeFileSync as writeFileSync5
44501
44554
  } from "fs";
44502
- import path136 from "path";
44555
+ import path139 from "path";
44503
44556
  init_slate();
44504
44557
  init_redact();
44505
44558
  var SESSION_SCHEMA_VERSION = 1;
@@ -44592,7 +44645,7 @@ function parseRemote(value) {
44592
44645
  function readSummaryFile(file) {
44593
44646
  let pending;
44594
44647
  try {
44595
- pending = readPendingHistory(path136.dirname(file));
44648
+ pending = readPendingHistory(path139.dirname(file));
44596
44649
  } catch {
44597
44650
  pending = undefined;
44598
44651
  }
@@ -44644,11 +44697,11 @@ class TranscriptUnreadableError extends Error {
44644
44697
  }
44645
44698
  }
44646
44699
  function readJsonl2(file) {
44647
- const pending = readPendingHistory(path136.dirname(file));
44700
+ const pending = readPendingHistory(path139.dirname(file));
44648
44701
  if (pending === undefined && !existsSync22(file)) {
44649
44702
  return [];
44650
44703
  }
44651
- const read = pending !== undefined ? { ok: true, text: pending.files[path136.basename(file)] } : readTranscriptFile(file);
44704
+ const read = pending !== undefined ? { ok: true, text: pending.files[path139.basename(file)] } : readTranscriptFile(file);
44652
44705
  if (!read.ok) {
44653
44706
  throw new TranscriptUnreadableError(file, read.reason);
44654
44707
  }
@@ -44699,11 +44752,11 @@ function listSessions(cwd, dataDir) {
44699
44752
  if (name.startsWith(".")) {
44700
44753
  continue;
44701
44754
  }
44702
- const summary = readSummaryFile(path136.join(root, name, "summary.json"));
44755
+ const summary = readSummaryFile(path139.join(root, name, "summary.json"));
44703
44756
  if (summary === undefined) {
44704
44757
  continue;
44705
44758
  }
44706
- if (path136.resolve(summary.projectPath) !== path136.resolve(projectPath)) {
44759
+ if (path139.resolve(summary.projectPath) !== path139.resolve(projectPath)) {
44707
44760
  continue;
44708
44761
  }
44709
44762
  out.push(summary);
@@ -44736,15 +44789,15 @@ async function readSessionSlate(cwd, sessionId, dataDir) {
44736
44789
  }
44737
44790
  function loadContext(cwd, sessionId, dataDir) {
44738
44791
  const dir = sessionDir(resolveProjectRoot2(cwd), sessionId, dataDir);
44739
- const contextPath = path136.join(dir, "context.jsonl");
44792
+ const contextPath = path139.join(dir, "context.jsonl");
44740
44793
  if (readPendingHistory(dir) !== undefined || existsSync22(contextPath)) {
44741
44794
  return readJsonl2(contextPath);
44742
44795
  }
44743
- return readJsonl2(path136.join(dir, "transcript.jsonl"));
44796
+ return readJsonl2(path139.join(dir, "transcript.jsonl"));
44744
44797
  }
44745
44798
  function loadArchive(cwd, sessionId, dataDir, onDegraded) {
44746
44799
  const dir = sessionDir(resolveProjectRoot2(cwd), sessionId, dataDir);
44747
- const archivePath = path136.join(dir, "archive.jsonl");
44800
+ const archivePath = path139.join(dir, "archive.jsonl");
44748
44801
  if (readPendingHistory(dir) !== undefined || existsSync22(archivePath)) {
44749
44802
  try {
44750
44803
  const archive = readJsonl2(archivePath);
@@ -44819,7 +44872,7 @@ function sessionEvidenceRef(workspaceId, sessionId) {
44819
44872
  }
44820
44873
  async function resolveSessionWrapUp(input) {
44821
44874
  const now = input.now ?? (() => new Date);
44822
- const sessionId = path137.posix.basename(input.sourceRef, ".md");
44875
+ const sessionId = path140.posix.basename(input.sourceRef, ".md");
44823
44876
  const summary = findSession(input.cwd, sessionId);
44824
44877
  if (summary === undefined || input.sourceRef !== sessionEvidenceRef(input.workspaceId, summary.id)) {
44825
44878
  throw new SessionWrapUpError("session_not_found", `no session matching "${input.sourceRef}" in this project \u2014 use \`keryx sessions list\``);
@@ -44836,7 +44889,7 @@ async function resolveSessionWrapUp(input) {
44836
44889
  throw new SessionWrapUpError("session_unreadable", `session "${summary.id}" could not be read: ${cause.message}`);
44837
44890
  }
44838
44891
  const relPath = sessionEvidenceRef(input.workspaceId, summary.id).slice(2);
44839
- const evidenceDir = path137.dirname(relPath);
44892
+ const evidenceDir = path140.dirname(relPath);
44840
44893
  const slate = await readSessionSlate(input.cwd, summary.id);
44841
44894
  const diff = await gitDiff(input.cwd);
44842
44895
  const diffBody = diff.kind === "measured" ? diff.text : unmeasurableDiffBody(diff.detail);
@@ -44858,23 +44911,23 @@ async function resolveSessionWrapUp(input) {
44858
44911
  ""
44859
44912
  ].join(`
44860
44913
  `);
44861
- const wrapUpRelPath = path137.join(evidenceDir, `${summary.id}.wrap-up.md`);
44862
- const diffRelPath = path137.join(evidenceDir, `${summary.id}.diff.txt`);
44863
- const noticeRelPath = path137.join(evidenceDir, `${summary.id}.redaction.md`);
44914
+ const wrapUpRelPath = path140.join(evidenceDir, `${summary.id}.wrap-up.md`);
44915
+ const diffRelPath = path140.join(evidenceDir, `${summary.id}.diff.txt`);
44916
+ const noticeRelPath = path140.join(evidenceDir, `${summary.id}.redaction.md`);
44864
44917
  const floor = await applyEvidenceRedactionFloor(input.cwd, [
44865
- { name: path137.basename(relPath), content: markdown, path: relPath, source: "generated" },
44866
- { name: path137.basename(wrapUpRelPath), content: wrapUpMarkdown, path: wrapUpRelPath, source: "generated" },
44867
- { name: path137.basename(diffRelPath), content: diffBody, path: diffRelPath, source: "tool-output" }
44918
+ { name: path140.basename(relPath), content: markdown, path: relPath, source: "generated" },
44919
+ { name: path140.basename(wrapUpRelPath), content: wrapUpMarkdown, path: wrapUpRelPath, source: "generated" },
44920
+ { name: path140.basename(diffRelPath), content: diffBody, path: diffRelPath, source: "tool-output" }
44868
44921
  ]);
44869
44922
  if (!floor.ok)
44870
44923
  throw new SessionWrapUpError("security_denied", floor.reason);
44871
44924
  const [safeSession, safeWrapUp, safeDiff] = floor.bodies;
44872
- await mkdir34(path137.join(input.cwd, evidenceDir), { recursive: true });
44873
- await writeFile23(path137.join(input.cwd, relPath), safeSession.content, "utf8");
44874
- await writeFile23(path137.join(input.cwd, wrapUpRelPath), safeWrapUp.content, "utf8");
44875
- await writeFile23(path137.join(input.cwd, diffRelPath), safeDiff.content, "utf8");
44925
+ await mkdir33(path140.join(input.cwd, evidenceDir), { recursive: true });
44926
+ await writeFile22(path140.join(input.cwd, relPath), safeSession.content, "utf8");
44927
+ await writeFile22(path140.join(input.cwd, wrapUpRelPath), safeWrapUp.content, "utf8");
44928
+ await writeFile22(path140.join(input.cwd, diffRelPath), safeDiff.content, "utf8");
44876
44929
  if (floor.notice !== undefined)
44877
- await writeFile23(path137.join(input.cwd, noticeRelPath), floor.notice, "utf8");
44930
+ await writeFile22(path140.join(input.cwd, noticeRelPath), floor.notice, "utf8");
44878
44931
  const observedAt = now().toISOString();
44879
44932
  const evidence = [
44880
44933
  { kind: "wrap-up", uri: `./${wrapUpRelPath}`, revision: createHash28("sha256").update(safeWrapUp.content).digest("hex"), observedAt },
@@ -44897,13 +44950,13 @@ async function resolveSessionWrapUp(input) {
44897
44950
  init_fs();
44898
44951
  import { createHash as createHash29, randomBytes as randomBytes6 } from "crypto";
44899
44952
  import { readFile as readFile67 } from "fs/promises";
44900
- import path138 from "path";
44953
+ import path141 from "path";
44901
44954
  var CONFIRM_TOKEN_TTL_MS = 2 * 60000;
44902
44955
  function confirmTokenPath2(cwd, workspaceId, proposalId) {
44903
- return path138.join(cwd, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.confirm-token.json`);
44956
+ return path141.join(cwd, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.confirm-token.json`);
44904
44957
  }
44905
44958
  function confirmReceiptPath(cwd, workspaceId, proposalId, idempotencyKey) {
44906
- return path138.join(cwd, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${sha2563(idempotencyKey)}.confirm-receipt.json`);
44959
+ return path141.join(cwd, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${sha2563(idempotencyKey)}.confirm-receipt.json`);
44907
44960
  }
44908
44961
  function sha2563(text) {
44909
44962
  return createHash29("sha256").update(text).digest("hex");
@@ -44944,21 +44997,21 @@ init_store();
44944
44997
  init_config2();
44945
44998
  import { readFile as readFile69, readdir as readdir24 } from "fs/promises";
44946
44999
  import { randomUUID as randomUUID6 } from "crypto";
44947
- import path140 from "path";
45000
+ import path143 from "path";
44948
45001
 
44949
45002
  // src/sac/proposal-evidence.ts
44950
45003
  init_fs();
44951
45004
  import { createHash as createHash30 } from "crypto";
44952
45005
  import { readFile as readFile68, rm as rm7 } from "fs/promises";
44953
- import path139 from "path";
45006
+ import path142 from "path";
44954
45007
  function proposalPath(cwd, workspaceId, proposalId) {
44955
- return path139.join(cwd, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.json`);
45008
+ return path142.join(cwd, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.json`);
44956
45009
  }
44957
45010
  function ownerReceiptPath(cwd, owner, workspaceId, idempotencyKey) {
44958
- return path139.join(cwd, ".metaproject", "workspaces", workspaceId, `${owner}-write-receipts`, `${idempotencyKey}.json`);
45011
+ return path142.join(cwd, ".metaproject", "workspaces", workspaceId, `${owner}-write-receipts`, `${idempotencyKey}.json`);
44959
45012
  }
44960
45013
  function proposalNotePath(cwd, workspaceId, proposalId) {
44961
- return path139.join(cwd, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.note.txt`);
45014
+ return path142.join(cwd, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.note.txt`);
44962
45015
  }
44963
45016
  async function readVerifiedProposalEvidence(cwd, workspaceId, proposalId) {
44964
45017
  let proposal;
@@ -44972,7 +45025,7 @@ async function readVerifiedProposalEvidence(cwd, workspaceId, proposalId) {
44972
45025
  return { ok: false, code: "no_evidence_to_write" };
44973
45026
  let content;
44974
45027
  try {
44975
- content = await readFile68(path139.join(cwd, evidence.uri), "utf8");
45028
+ content = await readFile68(path142.join(cwd, evidence.uri), "utf8");
44976
45029
  } catch {
44977
45030
  return { ok: false, code: "evidence_file_unreadable" };
44978
45031
  }
@@ -45002,22 +45055,22 @@ function targetRelPath(targetRef) {
45002
45055
  return targetRef.replace(/^\.\//, "");
45003
45056
  }
45004
45057
  function targetAbsolutePath(cwd, targetRef) {
45005
- return path139.join(cwd, ".metaproject", targetRelPath(targetRef));
45058
+ return path142.join(cwd, ".metaproject", targetRelPath(targetRef));
45006
45059
  }
45007
45060
  function targetKey(targetRef) {
45008
45061
  return digestOf2(targetRelPath(targetRef)).slice(0, 32);
45009
45062
  }
45010
45063
  function ownerTargetVersionPath(cwd, owner, workspaceId, targetRef) {
45011
- return path139.join(cwd, ".metaproject", "workspaces", workspaceId, `${owner}-target-versions`, `${targetKey(targetRef)}.json`);
45064
+ return path142.join(cwd, ".metaproject", "workspaces", workspaceId, `${owner}-target-versions`, `${targetKey(targetRef)}.json`);
45012
45065
  }
45013
45066
  function ownerTargetLockPath(cwd, owner, targetRef) {
45014
- return path139.join(cwd, ".metaproject", "data", "sac", "target-locks", owner, `${targetKey(targetRef)}.lock`);
45067
+ return path142.join(cwd, ".metaproject", "data", "sac", "target-locks", owner, `${targetKey(targetRef)}.lock`);
45015
45068
  }
45016
45069
  function ownerStagingDir(cwd, owner, workspaceId, idempotencyKey) {
45017
- return path139.join(cwd, ".metaproject", "workspaces", workspaceId, `${owner}-write-staging`, digestOf2(idempotencyKey).slice(0, 32));
45070
+ return path142.join(cwd, ".metaproject", "workspaces", workspaceId, `${owner}-write-staging`, digestOf2(idempotencyKey).slice(0, 32));
45018
45071
  }
45019
45072
  function ownerConflictDir(cwd, owner, workspaceId, idempotencyKey) {
45020
- return path139.join(cwd, ".metaproject", "workspaces", workspaceId, `${owner}-write-conflicts`, digestOf2(idempotencyKey).slice(0, 32));
45073
+ return path142.join(cwd, ".metaproject", "workspaces", workspaceId, `${owner}-write-conflicts`, digestOf2(idempotencyKey).slice(0, 32));
45021
45074
  }
45022
45075
  async function readJson4(file) {
45023
45076
  try {
@@ -45088,7 +45141,7 @@ async function applyGuardedTargetWrite(input) {
45088
45141
  staged: input.staged,
45089
45142
  stagedAt: receipt.completedAt
45090
45143
  };
45091
- await writeFileAtomic(path139.join(ownerStagingDir(cwd, owner, intent.workspaceId, intent.idempotencyKey), "plan.json"), `${JSON.stringify(staged, null, 2)}
45144
+ await writeFileAtomic(path142.join(ownerStagingDir(cwd, owner, intent.workspaceId, intent.idempotencyKey), "plan.json"), `${JSON.stringify(staged, null, 2)}
45092
45145
  `);
45093
45146
  const applied = await input.apply(input.staged);
45094
45147
  if (!applied.ok) {
@@ -45114,15 +45167,15 @@ async function recoverStagedOwnerWrite(input) {
45114
45167
  });
45115
45168
  }
45116
45169
  async function readStagedOwnerWrite(cwd, owner, workspaceId, idempotencyKey) {
45117
- return readJson4(path139.join(ownerStagingDir(cwd, owner, workspaceId, idempotencyKey), "plan.json"));
45170
+ return readJson4(path142.join(ownerStagingDir(cwd, owner, workspaceId, idempotencyKey), "plan.json"));
45118
45171
  }
45119
45172
  async function recordConflict(input) {
45120
45173
  const base = { targetRef: input.targetRef, expectedVersion: input.expectedVersion, currentVersion: input.currentVersion };
45121
45174
  if (input.proposedContent === undefined)
45122
45175
  return base;
45123
45176
  const dir = ownerConflictDir(input.cwd, input.owner, input.intent.workspaceId, input.intent.idempotencyKey);
45124
- await writeFileAtomic(path139.join(dir, "proposed"), input.proposedContent);
45125
- const diffRef = `./workspaces/${input.intent.workspaceId}/${input.owner}-write-conflicts/${path139.basename(dir)}/proposed`;
45177
+ await writeFileAtomic(path142.join(dir, "proposed"), input.proposedContent);
45178
+ const diffRef = `./workspaces/${input.intent.workspaceId}/${input.owner}-write-conflicts/${path142.basename(dir)}/proposed`;
45126
45179
  return { ...base, diffRef };
45127
45180
  }
45128
45181
 
@@ -45172,7 +45225,7 @@ async function resolveWorkspaceModule(cwd, workspaceId) {
45172
45225
  }
45173
45226
  }
45174
45227
  async function collectWikiDecisionEntries(cwd) {
45175
- const dir = path140.join(cwd, ".metaproject", "wiki", "decisions");
45228
+ const dir = path143.join(cwd, ".metaproject", "wiki", "decisions");
45176
45229
  let files;
45177
45230
  try {
45178
45231
  files = (await readdir24(dir)).filter((name) => name.endsWith(".md"));
@@ -45181,12 +45234,12 @@ async function collectWikiDecisionEntries(cwd) {
45181
45234
  }
45182
45235
  const entries = [];
45183
45236
  for (const file of files) {
45184
- const absolutePath = path140.join(dir, file);
45237
+ const absolutePath = path143.join(dir, file);
45185
45238
  try {
45186
45239
  const content = await readFile69(absolutePath, "utf8");
45187
45240
  entries.push({
45188
45241
  absolutePath,
45189
- relativePath: path140.posix.join("decisions", file),
45242
+ relativePath: path143.posix.join("decisions", file),
45190
45243
  type: extractHeaderField(content, "Type") ?? "decision",
45191
45244
  title: extractTitle(content),
45192
45245
  version: extractHeaderField(content, "Version") ?? null,
@@ -45408,7 +45461,7 @@ function createRealMemoryOwnerWriter(cwd, opts) {
45408
45461
  init_service4();
45409
45462
  init_guard();
45410
45463
  import { readFile as readFile71 } from "fs/promises";
45411
- import path141 from "path";
45464
+ import path144 from "path";
45412
45465
  function renderWrapUpDecisionPage(input) {
45413
45466
  const note = input.note?.trim();
45414
45467
  return `# ${input.title}
@@ -45449,7 +45502,7 @@ export is the source of truth for what actually happened.
45449
45502
  `;
45450
45503
  }
45451
45504
  function wikiPageRelativePath(proposalId) {
45452
- return path141.posix.join("decisions", `sac-${proposalId}.md`);
45505
+ return path144.posix.join("decisions", `sac-${proposalId}.md`);
45453
45506
  }
45454
45507
  function createRealWikiOwnerWriter(cwd, opts) {
45455
45508
  const now = opts?.now ?? (() => new Date);
@@ -45457,7 +45510,7 @@ function createRealWikiOwnerWriter(cwd, opts) {
45457
45510
  const relativePath = staged.relativePath;
45458
45511
  const content = staged.content;
45459
45512
  const history = await openWikiWriteContext(cwd, "sac proposal accept");
45460
- await writeWikiPage(history, path141.join(cwd, ".metaproject", "wiki", relativePath), content);
45513
+ await writeWikiPage(history, path144.join(cwd, ".metaproject", "wiki", relativePath), content);
45461
45514
  return { ok: true };
45462
45515
  };
45463
45516
  return {
@@ -45606,7 +45659,7 @@ class ProposalLifecycleService {
45606
45659
  now;
45607
45660
  constructor(options) {
45608
45661
  this.options = options;
45609
- this.root = path142.resolve(options.workspaceRoot);
45662
+ this.root = path145.resolve(options.workspaceRoot);
45610
45663
  this.now = options.now ?? (() => new Date);
45611
45664
  }
45612
45665
  async create(input) {
@@ -45626,7 +45679,7 @@ class ProposalLifecycleService {
45626
45679
  if (manifest.status === "archived")
45627
45680
  throw new ProposalLifecycleError("guard_denied", "workspace is archived");
45628
45681
  const file = this.proposalPath(workspaceId, proposal.id);
45629
- await mkdir35(path142.dirname(file), { recursive: true, mode: 448 });
45682
+ await mkdir34(path145.dirname(file), { recursive: true, mode: 448 });
45630
45683
  return withFileLock(`${file}.lock`, async () => {
45631
45684
  const consume = this.options.wrapUpAuthority.consume(input.wrapUp, { actor, workspaceId });
45632
45685
  if (consume !== "ok")
@@ -45654,7 +45707,7 @@ class ProposalLifecycleService {
45654
45707
  return this.options.workspaces.withAuthorizedActor({ actorContext: actor, workspaceId: input.workspaceId, action: "review", execute: async (manifest) => {
45655
45708
  const proposal = await this.loadProposal(input.workspaceId, input.proposalId);
45656
45709
  const ledger = this.ledgerPath(input.workspaceId);
45657
- await mkdir35(path142.dirname(ledger), { recursive: true, mode: 448 });
45710
+ await mkdir34(path145.dirname(ledger), { recursive: true, mode: 448 });
45658
45711
  return withFileLock(`${ledger}.lock`, async () => {
45659
45712
  const records = (await this.records(ledger)).filter((record) => record.proposalId === proposal.id);
45660
45713
  const events = records.filter((record) => record.recordType === "proposal-transition");
@@ -45696,7 +45749,7 @@ class ProposalLifecycleService {
45696
45749
  } });
45697
45750
  }
45698
45751
  async listProposedProposals(workspaceId) {
45699
- const proposalsDir = path142.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals");
45752
+ const proposalsDir = path145.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals");
45700
45753
  let entries;
45701
45754
  try {
45702
45755
  entries = (await readdir25(proposalsDir)).filter((name) => name.endsWith(".json"));
@@ -45708,7 +45761,7 @@ class ProposalLifecycleService {
45708
45761
  const proposals = [];
45709
45762
  for (const entry of entries) {
45710
45763
  try {
45711
- const parsed = JSON.parse(await readFile73(path142.join(proposalsDir, entry), "utf8"));
45764
+ const parsed = JSON.parse(await readFile73(path145.join(proposalsDir, entry), "utf8"));
45712
45765
  if (parsed.recordType === "proposal-created")
45713
45766
  proposals.push(parsed);
45714
45767
  } catch {}
@@ -45974,31 +46027,31 @@ class ProposalLifecycleService {
45974
46027
  }
45975
46028
  }
45976
46029
  proposalPath(workspaceId, proposalId) {
45977
- return path142.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.json`);
46030
+ return path145.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.json`);
45978
46031
  }
45979
46032
  decisionRef(proposalId, key) {
45980
46033
  return `./proposals/${proposalId}.${hash2(key)}.decision.json`;
45981
46034
  }
45982
46035
  decisionPath(workspaceId, proposalId, key) {
45983
- return path142.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.decision.json`);
46036
+ return path145.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.decision.json`);
45984
46037
  }
45985
46038
  approvalRef(proposalId, key) {
45986
46039
  return `./proposals/${proposalId}.${hash2(key)}.approval.json`;
45987
46040
  }
45988
46041
  approvalPath(workspaceId, proposalId, key) {
45989
- return path142.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.approval.json`);
46042
+ return path145.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.approval.json`);
45990
46043
  }
45991
46044
  writeResultPath(workspaceId, proposalId, key) {
45992
- return path142.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.write-result.json`);
46045
+ return path145.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.write-result.json`);
45993
46046
  }
45994
46047
  intentRef(proposalId, key) {
45995
46048
  return `./proposals/${proposalId}.${hash2(key)}.write-intent.json`;
45996
46049
  }
45997
46050
  intentPath(workspaceId, proposalId, key) {
45998
- return path142.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.write-intent.json`);
46051
+ return path145.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.write-intent.json`);
45999
46052
  }
46000
46053
  attemptPath(workspaceId, proposalId, key) {
46001
- return path142.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.owner-write-attempt.json`);
46054
+ return path145.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.owner-write-attempt.json`);
46002
46055
  }
46003
46056
  async loadWriteResult(workspaceId, proposalId, key) {
46004
46057
  try {
@@ -46025,7 +46078,7 @@ class ProposalLifecycleService {
46025
46078
  }
46026
46079
  }
46027
46080
  ledgerPath(workspaceId) {
46028
- return path142.join(this.root, ".metaproject", "workspaces", workspaceId, "activity.jsonl");
46081
+ return path145.join(this.root, ".metaproject", "workspaces", workspaceId, "activity.jsonl");
46029
46082
  }
46030
46083
  timestamp() {
46031
46084
  return this.now().toISOString();
@@ -46144,11 +46197,11 @@ async function replayPreservation(input) {
46144
46197
  if (typeof slate.workspaceId !== "string" || !/^[a-z][a-z0-9-]{2,63}$/.test(slate.workspaceId))
46145
46198
  throw new Error("invalid workspace identity");
46146
46199
  const workspaceId = slate.workspaceId;
46147
- const outbox = path143.join(input.dir, "preservation", "outbox");
46148
- const receipt = await readReplayJson(path143.join(outbox, `${input.snapshot}.json`));
46200
+ const outbox = path146.join(input.dir, "preservation", "outbox");
46201
+ const receipt = await readReplayJson(path146.join(outbox, `${input.snapshot}.json`));
46149
46202
  if (receipt.version !== 1 || receipt.snapshot !== input.snapshot || receipt.state !== "pending-review")
46150
46203
  throw new Error("invalid outbox receipt");
46151
- return withFileLock(path143.join(outbox, `${input.snapshot}.delivery.lock`), async () => {
46204
+ return withFileLock(path146.join(outbox, `${input.snapshot}.delivery.lock`), async () => {
46152
46205
  input.signal?.throwIfAborted();
46153
46206
  const { service, wrapUpAuthority, authorizationServer } = createHarnessProposalLifecycleService(input.cwd, {
46154
46207
  workspaceId,
@@ -46175,12 +46228,12 @@ async function replayPreservation(input) {
46175
46228
  } catch (error) {
46176
46229
  if (!(error instanceof ProposalLifecycleError) || error.code !== "conflict")
46177
46230
  throw error;
46178
- const existing = await readReplayJson(path143.join(input.cwd, ".metaproject", "workspaces", workspaceId, "proposals", `${id}.json`));
46231
+ const existing = await readReplayJson(path146.join(input.cwd, ".metaproject", "workspaces", workspaceId, "proposals", `${id}.json`));
46179
46232
  const refs = (evidence) => evidence.map((e) => [e.uri, e.revision]);
46180
46233
  if (existing.workspaceId !== workspaceId || existing.author !== actor.subject || existing.kind !== "follow-up" || existing.proposalRevision !== input.snapshot || existing.wrapUp?.sourceRef !== sourceRef || existing.wrapUp?.sourceRevision !== wrapUp.sourceRevision || JSON.stringify(refs(existing.evidence)) !== JSON.stringify(refs(wrapUp.evidence)))
46181
46234
  throw new Error("delivery conflict mismatch", { cause: error });
46182
46235
  }
46183
- const delivered = path143.join(outbox, `${input.snapshot}.delivered`);
46236
+ const delivered = path146.join(outbox, `${input.snapshot}.delivered`);
46184
46237
  try {
46185
46238
  const marker = await readReplayJson(delivered);
46186
46239
  if (marker.version !== 1 || marker.workspaceId !== workspaceId || marker.proposalId !== id || marker.snapshot !== input.snapshot) {
@@ -46193,7 +46246,7 @@ async function replayPreservation(input) {
46193
46246
  }
46194
46247
  input.afterCreate?.();
46195
46248
  input.signal?.throwIfAborted();
46196
- writePreservationFile(path143.join(outbox, `${input.snapshot}.delivered`), JSON.stringify({ version: 1, workspaceId, proposalId: id, snapshot: input.snapshot }));
46249
+ writePreservationFile(path146.join(outbox, `${input.snapshot}.delivered`), JSON.stringify({ version: 1, workspaceId, proposalId: id, snapshot: input.snapshot }));
46197
46250
  return "proposed";
46198
46251
  }, input.signal ? { signal: input.signal } : {});
46199
46252
  }
@@ -46216,14 +46269,14 @@ async function scanPreservationOutbox(input) {
46216
46269
  const result = { proposed: 0, deferred: 0, unbound: 0 };
46217
46270
  let entries;
46218
46271
  try {
46219
- entries = await readdir26(path143.join(input.dir, "preservation", "outbox"));
46272
+ entries = await readdir26(path146.join(input.dir, "preservation", "outbox"));
46220
46273
  } catch (error) {
46221
46274
  if (error.code === "ENOENT")
46222
46275
  return result;
46223
46276
  throw error;
46224
46277
  }
46225
46278
  let attempted = 0;
46226
- const cursorFile = path143.join(input.dir, "preservation", "outbox", "SCAN_CURSOR");
46279
+ const cursorFile = path146.join(input.dir, "preservation", "outbox", "SCAN_CURSOR");
46227
46280
  for (const entry of resumeScan(entries.filter((name) => /^[a-f0-9]{64}\.json$/.test(name)), cursorFile)) {
46228
46281
  if (input.signal?.aborted || Date.now() >= (input.deadline ?? Infinity) || attempted >= (input.maxItems ?? 8))
46229
46282
  break;
@@ -46248,11 +46301,11 @@ async function replayProjectPreservationOutboxes(input) {
46248
46301
  return boundedReplay(input, scanProjectPreservationOutboxes);
46249
46302
  }
46250
46303
  async function retryProjectPreservation(cwd) {
46251
- return replayProjectPreservationOutboxes({ cwd, dir: path143.join(projectSessionsDir(cwd), ".explicit-retry") });
46304
+ return replayProjectPreservationOutboxes({ cwd, dir: path146.join(projectSessionsDir(cwd), ".explicit-retry") });
46252
46305
  }
46253
46306
  async function scanProjectPreservationOutboxes(input) {
46254
46307
  const result = { proposed: 0, deferred: 0, unbound: 0 };
46255
- const root = path143.dirname(input.dir);
46308
+ const root = path146.dirname(input.dir);
46256
46309
  let entries;
46257
46310
  try {
46258
46311
  entries = await readdir26(root, { withFileTypes: true });
@@ -46263,7 +46316,7 @@ async function scanProjectPreservationOutboxes(input) {
46263
46316
  }
46264
46317
  const deadline = input.deadline ?? Date.now() + 2000;
46265
46318
  let scanned = 0;
46266
- const cursorFile = path143.join(root, ".preservation-replay-cursor");
46319
+ const cursorFile = path146.join(root, ".preservation-replay-cursor");
46267
46320
  const candidates = entries.filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => entry.name);
46268
46321
  for (const name of resumeScan(candidates, cursorFile)) {
46269
46322
  if (input.signal?.aborted || Date.now() >= deadline || scanned >= 32)
@@ -46272,7 +46325,7 @@ async function scanProjectPreservationOutboxes(input) {
46272
46325
  recordScanCursor(cursorFile, name);
46273
46326
  scanned++;
46274
46327
  try {
46275
- const replay = await replayPreservationOutbox({ ...input, deadline, maxItems: 1, dir: path143.join(root, name) });
46328
+ const replay = await replayPreservationOutbox({ ...input, deadline, maxItems: 1, dir: path146.join(root, name) });
46276
46329
  result.proposed += replay.proposed;
46277
46330
  result.deferred += replay.deferred;
46278
46331
  result.unbound += replay.unbound;
@@ -46310,8 +46363,8 @@ async function boundedReplay(input, scan) {
46310
46363
  // src/sac/fwk-service.ts
46311
46364
  import { createHash as createHash35, randomUUID as randomUUID9 } from "crypto";
46312
46365
  init_assembly();
46313
- import { appendFile as appendFile8, mkdir as mkdir36, open as open5, readFile as readFile74, rename as rename7, rm as rm8, stat as stat19, writeFile as writeFile24 } from "fs/promises";
46314
- import path144 from "path";
46366
+ import { appendFile as appendFile8, mkdir as mkdir35, open as open5, readFile as readFile74, rename as rename7, rm as rm8, stat as stat19, writeFile as writeFile23 } from "fs/promises";
46367
+ import path147 from "path";
46315
46368
  init_fs();
46316
46369
 
46317
46370
  // src/sac/policy-experiment.ts
@@ -46937,7 +46990,7 @@ async function writeCheckpoint(checkpointPath, body) {
46937
46990
  const temporary = `${checkpointPath}.${process.pid}.${randomUUID9()}.tmp`;
46938
46991
  const checkpoint = { ...body, integrity: { checkpointHash: checkpointHash(body) } };
46939
46992
  try {
46940
- await writeFile24(temporary, `${JSON.stringify(checkpoint)}
46993
+ await writeFile23(temporary, `${JSON.stringify(checkpoint)}
46941
46994
  `, { mode: 384, flag: "wx" });
46942
46995
  await rename7(temporary, checkpointPath);
46943
46996
  } catch (error) {
@@ -47054,7 +47107,7 @@ function hasReportIntegrity(report) {
47054
47107
  return reportHashPattern.test(reportDigest) && sha2566(body) === reportDigest;
47055
47108
  }
47056
47109
  async function resolvePolicySelection(workspaceRoot, canonicalFallback) {
47057
- const configPath = path144.join(workspaceRoot, ...policyExperimentConfigPath);
47110
+ const configPath = path147.join(workspaceRoot, ...policyExperimentConfigPath);
47058
47111
  let configJson;
47059
47112
  try {
47060
47113
  const raw = await readFile74(configPath, "utf8").catch((error) => {
@@ -47252,9 +47305,9 @@ class FwkReadService {
47252
47305
  const recordedAt = nowIso2(now);
47253
47306
  const id = `receipt-${randomUUID9().replace(/-/g, "").slice(0, 16)}`;
47254
47307
  const base = { schemaVersion: "1.0", id, workspaceId, actor, action, decision, recordedAt, cost: { tokens: 0, toolCalls: 1, elapsedMs: 0 }, contextAssembly: { traceRef: assembly.traceRef, configurationRevision: assembly.configurationRevision, selected: assembly.selected.map((id) => `./ids/${id}`), omittedOptional: assembly.omittedOptional.map((id) => `./ids/${id}`) }, policy: { ref: assembly.policyRef, revision: assembly.policyRevision }, ...action === "resource" ? { resourceRef: `./ids/${resourceId ?? "unknown"}` } : {} };
47255
- const ledger = path144.join(this.options.canonical.workspaceRoot, ".metaproject", "context-operations", "access-receipts.jsonl");
47256
- const checkpointPath = path144.join(path144.dirname(ledger), "access-receipts.checkpoint.json");
47257
- await mkdir36(path144.dirname(ledger), { recursive: true, mode: 448 });
47308
+ const ledger = path147.join(this.options.canonical.workspaceRoot, ".metaproject", "context-operations", "access-receipts.jsonl");
47309
+ const checkpointPath = path147.join(path147.dirname(ledger), "access-receipts.checkpoint.json");
47310
+ await mkdir35(path147.dirname(ledger), { recursive: true, mode: 448 });
47258
47311
  return withFileLock(`${ledger}.lock`, async () => {
47259
47312
  const state = await resolveLedgerState(ledger, checkpointPath, this.options.verifyReceiptLedger ?? verifyAccessReceiptLedger);
47260
47313
  const receipt = sealAccessReceipt(base, state.headHash);
@@ -47357,7 +47410,7 @@ function normalizeFwkResult(result) {
47357
47410
  // src/sac/propose-from-session.ts
47358
47411
  init_guard();
47359
47412
  import { randomUUID as randomUUID10 } from "crypto";
47360
- import { writeFile as writeFile25 } from "fs/promises";
47413
+ import { writeFile as writeFile24 } from "fs/promises";
47361
47414
  async function proposeFromSession(input) {
47362
47415
  const { cwd, workspaceId, kind, sessionRef } = input;
47363
47416
  const session = findSession(cwd, sessionRef);
@@ -47386,13 +47439,13 @@ async function proposeFromSession(input) {
47386
47439
  wrapUp
47387
47440
  });
47388
47441
  if (persistedNote)
47389
- await writeFile25(notePath, persistedNote, "utf8");
47442
+ await writeFile24(notePath, persistedNote, "utf8");
47390
47443
  return { ok: true, result: normalizeProposalLifecycleResult(proposal) };
47391
47444
  }
47392
47445
  // src/sac/collaboration-service.ts
47393
- import { appendFile as appendFile9, mkdir as mkdir37, readFile as readFile75 } from "fs/promises";
47446
+ import { appendFile as appendFile9, mkdir as mkdir36, readFile as readFile75 } from "fs/promises";
47394
47447
  import { randomUUID as randomUUID11 } from "crypto";
47395
- import path145 from "path";
47448
+ import path148 from "path";
47396
47449
  class CollaborationServiceError extends Error {
47397
47450
  code;
47398
47451
  constructor(code, message) {
@@ -47407,7 +47460,7 @@ class CollaborationService {
47407
47460
  this.input = input;
47408
47461
  }
47409
47462
  file(id) {
47410
- return path145.join(this.input.workspaceRoot, ".metaproject", "workspaces", id, "activity.jsonl");
47463
+ return path148.join(this.input.workspaceRoot, ".metaproject", "workspaces", id, "activity.jsonl");
47411
47464
  }
47412
47465
  async overview(input) {
47413
47466
  const manifest = await this.input.workspaces.show(input);
@@ -47444,7 +47497,7 @@ class CollaborationService {
47444
47497
  occurredAt: (this.input.now ?? (() => new Date))().toISOString(),
47445
47498
  ...suppliedHandoff ? { handoff: { ...suppliedHandoff, from: actor.subject } } : {}
47446
47499
  });
47447
- await mkdir37(path145.dirname(this.file(manifest.id)), { recursive: true, mode: 448 });
47500
+ await mkdir36(path148.dirname(this.file(manifest.id)), { recursive: true, mode: 448 });
47448
47501
  await appendFile9(this.file(manifest.id), `${JSON.stringify(activity)}
47449
47502
  `, { mode: 384 });
47450
47503
  return normalizeCollaborationResult(activity);
@@ -47493,15 +47546,15 @@ function normalizeCollaborationResult(value) {
47493
47546
  }
47494
47547
  // src/session/external-slate.ts
47495
47548
  init_fs();
47496
- import { mkdir as mkdir39, readdir as readdir27, readFile as readFile76 } from "fs/promises";
47497
- import path147 from "path";
47549
+ import { mkdir as mkdir38, readdir as readdir27, readFile as readFile76 } from "fs/promises";
47550
+ import path150 from "path";
47498
47551
 
47499
47552
  // src/sac/machine-wrap-up.ts
47500
47553
  init_fs();
47501
47554
  init_slate();
47502
47555
  import { createHash as createHash36, randomUUID as randomUUID13 } from "crypto";
47503
- import { mkdir as mkdir38 } from "fs/promises";
47504
- import path146 from "path";
47556
+ import { mkdir as mkdir37 } from "fs/promises";
47557
+ import path149 from "path";
47505
47558
 
47506
47559
  // src/sac/workspace-resolve.ts
47507
47560
  init_redact();
@@ -47644,11 +47697,11 @@ async function resolveMachineWrapUp(input) {
47644
47697
  `;
47645
47698
  const seedsJson = `${JSON.stringify(seedsForKind.map((seed) => ({ text: seed.text, source: describeSource(seed.source) })), null, 2)}
47646
47699
  `;
47647
- const evidenceRelBase = path146.posix.join(".metaproject", "workspaces", input.workspaceId, "machine-evidence");
47700
+ const evidenceRelBase = path149.posix.join(".metaproject", "workspaces", input.workspaceId, "machine-evidence");
47648
47701
  const floor = await applyEvidenceRedactionFloor(input.cwd, [
47649
- { name: `${input.kind}.diff.txt`, content: diffBody, path: path146.posix.join(evidenceRelBase, `${input.kind}.diff.txt`), source: "tool-output" },
47650
- { name: `${input.kind}.flow.json`, content: flowSnapshotJson, path: path146.posix.join(evidenceRelBase, `${input.kind}.flow.json`), source: "generated" },
47651
- { name: `${input.kind}.seeds.json`, content: seedsJson, path: path146.posix.join(evidenceRelBase, `${input.kind}.seeds.json`), source: "generated" }
47702
+ { name: `${input.kind}.diff.txt`, content: diffBody, path: path149.posix.join(evidenceRelBase, `${input.kind}.diff.txt`), source: "tool-output" },
47703
+ { name: `${input.kind}.flow.json`, content: flowSnapshotJson, path: path149.posix.join(evidenceRelBase, `${input.kind}.flow.json`), source: "generated" },
47704
+ { name: `${input.kind}.seeds.json`, content: seedsJson, path: path149.posix.join(evidenceRelBase, `${input.kind}.seeds.json`), source: "generated" }
47652
47705
  ]);
47653
47706
  if (!floor.ok)
47654
47707
  return { ok: false, code: "security_denied", detail: floor.reason };
@@ -47702,14 +47755,14 @@ ${safeSeeds.content}`;
47702
47755
  }
47703
47756
  summary = result.text.trim().length > 0 ? result.text.trim() : mechanicalSummary(summaryDiff, course);
47704
47757
  }
47705
- const evidenceDir = path146.join(input.cwd, ".metaproject", "workspaces", input.workspaceId, "machine-evidence");
47706
- await mkdir38(evidenceDir, { recursive: true });
47758
+ const evidenceDir = path149.join(input.cwd, ".metaproject", "workspaces", input.workspaceId, "machine-evidence");
47759
+ await mkdir37(evidenceDir, { recursive: true });
47707
47760
  const diffFile = `${input.kind}.${shortHash}.diff.txt`;
47708
47761
  const flowFile = `${input.kind}.${shortHash}.flow.json`;
47709
47762
  const seedsFile = `${input.kind}.${shortHash}.seeds.json`;
47710
- await writeFileAtomic(path146.join(evidenceDir, diffFile), safeDiff.content);
47711
- await writeFileAtomic(path146.join(evidenceDir, flowFile), safeFlow.content);
47712
- await writeFileAtomic(path146.join(evidenceDir, seedsFile), safeSeeds.content);
47763
+ await writeFileAtomic(path149.join(evidenceDir, diffFile), safeDiff.content);
47764
+ await writeFileAtomic(path149.join(evidenceDir, flowFile), safeFlow.content);
47765
+ await writeFileAtomic(path149.join(evidenceDir, seedsFile), safeSeeds.content);
47713
47766
  const observedAt = now().toISOString();
47714
47767
  const relBase = `./.metaproject/workspaces/${input.workspaceId}/machine-evidence`;
47715
47768
  const evidence = [
@@ -47719,7 +47772,7 @@ ${safeSeeds.content}`;
47719
47772
  ];
47720
47773
  if (floor.notice !== undefined) {
47721
47774
  const noticeFile = `${input.kind}.${shortHash}.redaction.md`;
47722
- await writeFileAtomic(path146.join(evidenceDir, noticeFile), floor.notice);
47775
+ await writeFileAtomic(path149.join(evidenceDir, noticeFile), floor.notice);
47723
47776
  evidence.push({ kind: REDACTION_NOTICE_KIND, uri: `${relBase}/${noticeFile}`, revision: sha2567(floor.notice), observedAt });
47724
47777
  }
47725
47778
  return {
@@ -47738,18 +47791,18 @@ async function writeFlooredArchiveArtifact(params) {
47738
47791
  {
47739
47792
  name: params.filename,
47740
47793
  content: params.content,
47741
- path: path146.posix.join("slate-archive", params.filename),
47794
+ path: path149.posix.join("slate-archive", params.filename),
47742
47795
  source: "generated"
47743
47796
  }
47744
47797
  ]);
47745
47798
  if (!floor.ok)
47746
47799
  return { ok: false, code: "security_denied", detail: floor.reason };
47747
47800
  const body = floor.bodies[0];
47748
- const archiveDir = path146.join(params.dir, "slate-archive");
47749
- await mkdir38(archiveDir, { recursive: true });
47750
- await writeFileAtomic(path146.join(archiveDir, params.filename), body.content);
47801
+ const archiveDir = path149.join(params.dir, "slate-archive");
47802
+ await mkdir37(archiveDir, { recursive: true });
47803
+ await writeFileAtomic(path149.join(archiveDir, params.filename), body.content);
47751
47804
  if (floor.notice !== undefined) {
47752
- await writeFileAtomic(path146.join(archiveDir, `${params.filename}${ARCHIVE_REDACTION_NOTICE_SUFFIX}`), floor.notice);
47805
+ await writeFileAtomic(path149.join(archiveDir, `${params.filename}${ARCHIVE_REDACTION_NOTICE_SUFFIX}`), floor.notice);
47753
47806
  }
47754
47807
  return { ok: true, altered: body.altered };
47755
47808
  }
@@ -47785,9 +47838,9 @@ async function writeWrapUpOutcomeArtifact(cwd, dir, trigger, now, groups) {
47785
47838
  return;
47786
47839
  const refusalIso = now().toISOString();
47787
47840
  const refusalFilename = `${refusalIso.replace(/[:.]/g, "-")}-wrap-up-outcome.json`;
47788
- const archiveDir = path146.join(dir, "slate-archive");
47789
- await mkdir38(archiveDir, { recursive: true });
47790
- await writeFileAtomic(path146.join(archiveDir, refusalFilename), `${JSON.stringify({
47841
+ const archiveDir = path149.join(dir, "slate-archive");
47842
+ await mkdir37(archiveDir, { recursive: true });
47843
+ await writeFileAtomic(path149.join(archiveDir, refusalFilename), `${JSON.stringify({
47791
47844
  recordType: "wrap-up-outcome",
47792
47845
  trigger,
47793
47846
  generatedAt: refusalIso,
@@ -47924,7 +47977,7 @@ async function runWrapUp(input) {
47924
47977
 
47925
47978
  // src/session/external-slate.ts
47926
47979
  function externalSlatesDir(cwd) {
47927
- return path147.join(cwd, ".keryx", "external-slates");
47980
+ return path150.join(cwd, ".keryx", "external-slates");
47928
47981
  }
47929
47982
  var EXTERNAL_SESSION_ID_PATTERN = /^[A-Za-z0-9_-]{1,128}$/;
47930
47983
  function assertValidExternalSessionId(externalSessionId) {
@@ -47934,14 +47987,14 @@ function assertValidExternalSessionId(externalSessionId) {
47934
47987
  }
47935
47988
  function externalSlatePath(cwd, externalSessionId) {
47936
47989
  assertValidExternalSessionId(externalSessionId);
47937
- return path147.join(externalSlatesDir(cwd), `${externalSessionId}.json`);
47990
+ return path150.join(externalSlatesDir(cwd), `${externalSessionId}.json`);
47938
47991
  }
47939
47992
  function externalSlateLockPath(cwd, externalSessionId) {
47940
47993
  return `${externalSlatePath(cwd, externalSessionId)}.lock`;
47941
47994
  }
47942
47995
  function externalSlateEvidenceDir(cwd, externalSessionId) {
47943
47996
  assertValidExternalSessionId(externalSessionId);
47944
- return path147.join(externalSlatesDir(cwd), externalSessionId);
47997
+ return path150.join(externalSlatesDir(cwd), externalSessionId);
47945
47998
  }
47946
47999
  async function readExternalSlate(cwd, externalSessionId) {
47947
48000
  try {
@@ -47954,7 +48007,7 @@ async function readExternalSlate(cwd, externalSessionId) {
47954
48007
  }
47955
48008
  }
47956
48009
  async function writeExternalSlate(cwd, externalSessionId, update) {
47957
- await mkdir39(externalSlatesDir(cwd), { recursive: true });
48010
+ await mkdir38(externalSlatesDir(cwd), { recursive: true });
47958
48011
  return withFileLock(externalSlateLockPath(cwd, externalSessionId), async () => {
47959
48012
  const prev = await readExternalSlate(cwd, externalSessionId);
47960
48013
  const next = update(prev);
@@ -47980,7 +48033,7 @@ function isExternalSlateStale(slate, now = () => new Date) {
47980
48033
  return now().getTime() - lastWriteMs > DEFAULT_LOCK_STALE_MS;
47981
48034
  }
47982
48035
  async function closeExternalSlate(cwd, externalSessionId, trigger, now = () => new Date) {
47983
- await mkdir39(externalSlatesDir(cwd), { recursive: true });
48036
+ await mkdir38(externalSlatesDir(cwd), { recursive: true });
47984
48037
  return withFileLock(externalSlateLockPath(cwd, externalSessionId), async () => {
47985
48038
  const external = await readExternalSlate(cwd, externalSessionId);
47986
48039
  if (!external || external.closedAt !== undefined)
@@ -48025,12 +48078,12 @@ init_service2();
48025
48078
 
48026
48079
  // src/standard/service.ts
48027
48080
  init_fs();
48028
- import path150 from "path";
48081
+ import path153 from "path";
48029
48082
  import { readFile as readFile79 } from "fs/promises";
48030
48083
 
48031
48084
  // src/standard/validate.ts
48032
48085
  init_fs();
48033
- import path149 from "path";
48086
+ import path152 from "path";
48034
48087
  import { readFile as readFile78 } from "fs/promises";
48035
48088
 
48036
48089
  // src/standard/schemas.ts
@@ -48160,7 +48213,7 @@ var SCHEMA_REGISTRY2 = {
48160
48213
  // src/standard/profiles.ts
48161
48214
  init_fs();
48162
48215
  init_entrypoint_targets();
48163
- import path148 from "path";
48216
+ import path151 from "path";
48164
48217
  import { readFile as readFile77 } from "fs/promises";
48165
48218
  var AGENT_MODULES = ["gdgraph", "gdctx", "gdskills", "gdwiki", "memory"];
48166
48219
  var CI_MODULES = ["health", "testing"];
@@ -48185,7 +48238,7 @@ function enabledModuleKeys(manifest) {
48185
48238
  }
48186
48239
  async function rootEntrypointLinksIndex(cwd, manifest) {
48187
48240
  for (const { path: name } of namedEntrypoints(manifest)) {
48188
- const filePath = path148.join(cwd, name);
48241
+ const filePath = path151.join(cwd, name);
48189
48242
  if (!await pathExists(filePath)) {
48190
48243
  continue;
48191
48244
  }
@@ -48197,16 +48250,16 @@ async function rootEntrypointLinksIndex(cwd, manifest) {
48197
48250
  return false;
48198
48251
  }
48199
48252
  async function minimalSatisfied(cwd) {
48200
- const metaprojectRoot = path148.join(cwd, ".metaproject");
48253
+ const metaprojectRoot = path151.join(cwd, ".metaproject");
48201
48254
  const requiredFiles = ["index.md", "README.md", "metaproject.json"];
48202
48255
  const requiredDirs = ["modules", "rules", "skills", "data"];
48203
48256
  for (const file of requiredFiles) {
48204
- if (!await pathExists(path148.join(metaprojectRoot, file))) {
48257
+ if (!await pathExists(path151.join(metaprojectRoot, file))) {
48205
48258
  return false;
48206
48259
  }
48207
48260
  }
48208
48261
  for (const dir of requiredDirs) {
48209
- if (!await pathExists(path148.join(metaprojectRoot, dir))) {
48262
+ if (!await pathExists(path151.join(metaprojectRoot, dir))) {
48210
48263
  return false;
48211
48264
  }
48212
48265
  }
@@ -48219,7 +48272,7 @@ async function ciSatisfied(cwd, manifest) {
48219
48272
  return false;
48220
48273
  }
48221
48274
  for (const key of ciModules) {
48222
- if (await pathExists(path148.join(cwd, ".metaproject", "data", key, "artifacts"))) {
48275
+ if (await pathExists(path151.join(cwd, ".metaproject", "data", key, "artifacts"))) {
48223
48276
  return true;
48224
48277
  }
48225
48278
  }
@@ -48232,7 +48285,7 @@ async function evaluateProfiles(cwd, manifest) {
48232
48285
  satisfied.push("minimal");
48233
48286
  }
48234
48287
  const hasAgentModule = AGENT_MODULES.some((key) => new Set(enabledModuleKeys(manifest)).has(key));
48235
- const agent = minimal && hasAgentModule && await rootEntrypointLinksIndex(cwd, manifest) && await pathExists(path148.join(cwd, ".metaproject", "rules"));
48288
+ const agent = minimal && hasAgentModule && await rootEntrypointLinksIndex(cwd, manifest) && await pathExists(path151.join(cwd, ".metaproject", "rules"));
48236
48289
  if (agent) {
48237
48290
  satisfied.push("agent");
48238
48291
  }
@@ -48401,20 +48454,20 @@ var MANIFEST_TOP_LEVEL_SCHEMA = {
48401
48454
  async function validateWorkspace2(cwd) {
48402
48455
  const errors = [];
48403
48456
  const warnings = [];
48404
- const metaprojectRoot = path149.join(cwd, ".metaproject");
48457
+ const metaprojectRoot = path152.join(cwd, ".metaproject");
48405
48458
  const requiredFiles = ["index.md", "README.md", "metaproject.json"];
48406
48459
  for (const file of requiredFiles) {
48407
- if (!await pathExists(path149.join(metaprojectRoot, file))) {
48460
+ if (!await pathExists(path152.join(metaprojectRoot, file))) {
48408
48461
  errors.push(issue("missing-required-file", `Required file .metaproject/${file} is missing`, `Run \`keryx init\` to scaffold .metaproject/${file}.`));
48409
48462
  }
48410
48463
  }
48411
48464
  const requiredDirs = ["modules", "rules", "skills", "data"];
48412
48465
  for (const dir of requiredDirs) {
48413
- if (!await pathExists(path149.join(metaprojectRoot, dir))) {
48466
+ if (!await pathExists(path152.join(metaprojectRoot, dir))) {
48414
48467
  errors.push(issue("missing-required-dir", `Required directory .metaproject/${dir}/ is missing`, `Run \`keryx init\` to create .metaproject/${dir}/.`));
48415
48468
  }
48416
48469
  }
48417
- const manifestPath = path149.join(metaprojectRoot, "metaproject.json");
48470
+ const manifestPath = path152.join(metaprojectRoot, "metaproject.json");
48418
48471
  if (!await pathExists(manifestPath)) {
48419
48472
  return { ok: errors.length === 0, errors, warnings };
48420
48473
  }
@@ -48446,7 +48499,7 @@ async function validateWorkspace2(cwd) {
48446
48499
  if (typeof value !== "string") {
48447
48500
  continue;
48448
48501
  }
48449
- if (!await pathExists(path149.join(cwd, value))) {
48502
+ if (!await pathExists(path152.join(cwd, value))) {
48450
48503
  errors.push(issue("missing-declared-path", `Declared path paths.${key} -> ${value} does not exist`, `Create ${value} or remove paths.${key} from metaproject.json.`));
48451
48504
  }
48452
48505
  }
@@ -48456,7 +48509,7 @@ async function validateWorkspace2(cwd) {
48456
48509
  continue;
48457
48510
  }
48458
48511
  if (typeof entry.manifest === "string") {
48459
- if (!await pathExists(path149.join(cwd, entry.manifest))) {
48512
+ if (!await pathExists(path152.join(cwd, entry.manifest))) {
48460
48513
  errors.push(issue("missing-module-manifest", `Enabled module "${key}" manifest ${entry.manifest} is missing`, `Create ${entry.manifest} or run \`keryx update\` to regenerate module manifests.`));
48461
48514
  }
48462
48515
  }
@@ -48465,14 +48518,14 @@ async function validateWorkspace2(cwd) {
48465
48518
  if (typeof value !== "string") {
48466
48519
  continue;
48467
48520
  }
48468
- if (!await pathExists(path149.join(cwd, value))) {
48521
+ if (!await pathExists(path152.join(cwd, value))) {
48469
48522
  const sink = field === "data" ? warnings : errors;
48470
48523
  sink.push(issue("missing-module-path", `Module "${key}" declares ${String(field)} ${value}, which does not exist`, field === "data" ? `Run the module (e.g. \`keryx ${key} ...\`) to generate ${value}, or update modules.${key}.data in metaproject.json.` : `Create ${value} or update modules.${key}.${String(field)} in metaproject.json.`));
48471
48524
  }
48472
48525
  }
48473
48526
  }
48474
48527
  for (const { path: name, scope } of namedEntrypoints(manifest)) {
48475
- const filePath = path149.join(cwd, name);
48528
+ const filePath = path152.join(cwd, name);
48476
48529
  if (!await pathExists(filePath)) {
48477
48530
  continue;
48478
48531
  }
@@ -49277,6 +49330,12 @@ var HELP_GROUPS = [
49277
49330
  group: "Maintenance and diagnostics",
49278
49331
  summary: "Read the deletion trail \u2014 was this removed, or did it never exist?"
49279
49332
  },
49333
+ {
49334
+ kind: "cli",
49335
+ name: "worktree",
49336
+ group: "Managed work",
49337
+ summary: "Ready a linked git worktree (env files, dependencies, ports, memory index) and carry its findings out before removal."
49338
+ },
49280
49339
  {
49281
49340
  kind: "cli",
49282
49341
  name: "commands",
@@ -49509,7 +49568,7 @@ async function runDoctor(cwd) {
49509
49568
  return validateWorkspace2(cwd);
49510
49569
  }
49511
49570
  async function readManifest3(cwd) {
49512
- const manifestPath = path150.join(cwd, ".metaproject", "metaproject.json");
49571
+ const manifestPath = path153.join(cwd, ".metaproject", "metaproject.json");
49513
49572
  if (!await pathExists(manifestPath)) {
49514
49573
  throw new Error("Metaproject is not initialized (missing .metaproject/metaproject.json). Run `keryx init` first.");
49515
49574
  }