@mrciphersmith/keryx 0.4.45 → 0.4.47

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
@@ -18802,22 +18802,22 @@ var init_search = __esm(() => {
18802
18802
  });
18803
18803
 
18804
18804
  // src/gdgraph/data-dir.ts
18805
- import path79 from "path";
18805
+ import path80 from "path";
18806
18806
  function gdgraphDataDir(projectRoot, dataDir) {
18807
- return dataDir ?? path79.join(projectRoot, ".metaproject", "data", "gdgraph");
18807
+ return dataDir ?? path80.join(projectRoot, ".metaproject", "data", "gdgraph");
18808
18808
  }
18809
18809
  function gdgraphStorageDir(projectRoot, dataDir) {
18810
- return path79.join(gdgraphDataDir(projectRoot, dataDir), "storage");
18810
+ return path80.join(gdgraphDataDir(projectRoot, dataDir), "storage");
18811
18811
  }
18812
18812
  function gdgraphArtifactsDir(projectRoot, dataDir) {
18813
- return path79.join(gdgraphDataDir(projectRoot, dataDir), "artifacts");
18813
+ return path80.join(gdgraphDataDir(projectRoot, dataDir), "artifacts");
18814
18814
  }
18815
18815
  var init_data_dir = () => {};
18816
18816
 
18817
18817
  // src/gdgraph/config.ts
18818
- import path80 from "path";
18818
+ import path81 from "path";
18819
18819
  function gdgraphConfigPath(cwd) {
18820
- return path80.join(cwd, ".metaproject", "gdgraph.config.json");
18820
+ return path81.join(cwd, ".metaproject", "gdgraph.config.json");
18821
18821
  }
18822
18822
  function mergeGdgraphConfig(parsed) {
18823
18823
  const base = DEFAULT_GDGRAPH_CONFIG;
@@ -18879,13 +18879,13 @@ var init_config3 = __esm(() => {
18879
18879
  });
18880
18880
 
18881
18881
  // src/lib/self-invocation.ts
18882
- import path81 from "path";
18882
+ import path82 from "path";
18883
18883
  function isCompiledBinaryEntry(entry) {
18884
18884
  return entry.startsWith("/$bunfs/") || /^[A-Za-z]:[\\/]~BUN[\\/]/.test(entry);
18885
18885
  }
18886
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;
18887
+ const bin = path82.dirname(executable);
18888
+ return isCompiledBinaryEntry(entry) && path82.basename(bin) === "MacOS" ? path82.resolve(bin, "../Resources") : undefined;
18889
18889
  }
18890
18890
  var init_self_invocation = () => {};
18891
18891
 
@@ -19433,7 +19433,7 @@ var init_extract = __esm(() => {
19433
19433
  });
19434
19434
 
19435
19435
  // src/gdgraph/treesitter/grammars.ts
19436
- import path82 from "path";
19436
+ import path83 from "path";
19437
19437
  function grammarAssetId(language) {
19438
19438
  return `tree-sitter-${language}`;
19439
19439
  }
@@ -19449,7 +19449,7 @@ function symbolLanguage(language) {
19449
19449
  async function resolveGrammar(cwd, language, grammarsPath) {
19450
19450
  const id = grammarAssetId(language);
19451
19451
  const lock = await loadAssetsLock(cwd);
19452
- const overrides = grammarsPath ? { [id]: { path: path82.join(grammarsPath, `${id}.wasm`) } } : undefined;
19452
+ const overrides = grammarsPath ? { [id]: { path: path83.join(grammarsPath, `${id}.wasm`) } } : undefined;
19453
19453
  const registry = registryFromLock(lock, overrides);
19454
19454
  const resolved = await resolveAsset(registry, id);
19455
19455
  if (!resolved) {
@@ -19479,7 +19479,7 @@ function toGrammarLanguages(languages) {
19479
19479
  return out;
19480
19480
  }
19481
19481
  function grammarForFile(file, available) {
19482
- const ext = path82.extname(file);
19482
+ const ext = path83.extname(file);
19483
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"] : [];
19484
19484
  for (const language of preference) {
19485
19485
  if (available.includes(language)) {
@@ -19494,7 +19494,7 @@ var init_grammars = __esm(() => {
19494
19494
  });
19495
19495
 
19496
19496
  // src/gdgraph/treesitter/adapter.ts
19497
- import path83 from "path";
19497
+ import path84 from "path";
19498
19498
  function describeGrammarDiagnoses(diagnoses) {
19499
19499
  if (diagnoses.length === 0) {
19500
19500
  return "no grammar languages configured";
@@ -19714,7 +19714,7 @@ function normalizeParserApi(dep) {
19714
19714
  const resources = desktopResourceDirectory();
19715
19715
  if (!resources)
19716
19716
  return init();
19717
- return init({ locateFile: (name, prefix) => name === "tree-sitter.wasm" ? path83.join(resources, "tree-sitter.wasm") : path83.resolve(prefix, name) });
19717
+ return init({ locateFile: (name, prefix) => name === "tree-sitter.wasm" ? path84.join(resources, "tree-sitter.wasm") : path84.resolve(prefix, name) });
19718
19718
  } } : {},
19719
19719
  loadLanguage,
19720
19720
  create: () => new ParserClass
@@ -19748,7 +19748,7 @@ var init_adapter = __esm(() => {
19748
19748
 
19749
19749
  // src/gdgraph/enrich.ts
19750
19750
  import { mkdir as mkdir13, writeFile as writeFile7 } from "fs/promises";
19751
- import path84 from "path";
19751
+ import path85 from "path";
19752
19752
  async function enrichBuildWithSymbols(cwd, files, resolve, dataDir) {
19753
19753
  const config = await loadGdgraphConfig(cwd);
19754
19754
  const treesitterConfig = {
@@ -19766,10 +19766,10 @@ async function enrichBuildWithSymbols(cwd, files, resolve, dataDir) {
19766
19766
  async function writeSymbolLayer(cwd, layer, dataDir) {
19767
19767
  const storageDir = gdgraphStorageDir(cwd, dataDir);
19768
19768
  await mkdir13(storageDir, { recursive: true });
19769
- await writeFile7(path84.join(storageDir, "symbols.jsonl"), layer.symbols.map((symbol) => JSON.stringify(symbol)).join(`
19769
+ await writeFile7(path85.join(storageDir, "symbols.jsonl"), layer.symbols.map((symbol) => JSON.stringify(symbol)).join(`
19770
19770
  `) + `
19771
19771
  `, "utf8");
19772
- await writeFile7(path84.join(storageDir, "calls.jsonl"), layer.calls.map((call) => JSON.stringify(call)).join(`
19772
+ await writeFile7(path85.join(storageDir, "calls.jsonl"), layer.calls.map((call) => JSON.stringify(call)).join(`
19773
19773
  `) + `
19774
19774
  `, "utf8");
19775
19775
  }
@@ -19963,10 +19963,10 @@ var init_describes = () => {};
19963
19963
 
19964
19964
  // src/sync/provenance.ts
19965
19965
  import { mkdir as mkdir14, readFile as readFile40, writeFile as writeFile8 } from "fs/promises";
19966
- import path85 from "path";
19966
+ import path86 from "path";
19967
19967
  import { spawn } from "child_process";
19968
19968
  function provenancePath(cwd, module) {
19969
- return path85.join(cwd, ".metaproject", "data", module, ".provenance.json");
19969
+ return path86.join(cwd, ".metaproject", "data", module, ".provenance.json");
19970
19970
  }
19971
19971
  function gitCmdResult(cwd, args) {
19972
19972
  return new Promise((resolve) => {
@@ -20011,7 +20011,7 @@ async function recordProvenance(cwd, module, at) {
20011
20011
  if (!head)
20012
20012
  return;
20013
20013
  const file = provenancePath(cwd, module);
20014
- await mkdir14(path85.dirname(file), { recursive: true });
20014
+ await mkdir14(path86.dirname(file), { recursive: true });
20015
20015
  const provenance = { commit: head.commit, branch: head.branch, builtAt: at };
20016
20016
  await writeFile8(file, `${JSON.stringify(provenance, null, 2)}
20017
20017
  `, "utf8");
@@ -20037,7 +20037,7 @@ var init_provenance = __esm(() => {
20037
20037
  // src/gdgraph/staleness.ts
20038
20038
  import { spawn as spawn2 } from "child_process";
20039
20039
  import { stat as stat12 } from "fs/promises";
20040
- import path86 from "path";
20040
+ import path87 from "path";
20041
20041
  function gitStatusPorcelain(cwd) {
20042
20042
  return new Promise((resolve) => {
20043
20043
  try {
@@ -20060,10 +20060,10 @@ function gitStatusPorcelain(cwd) {
20060
20060
  });
20061
20061
  }
20062
20062
  function nodesJsonlPath(cwd) {
20063
- return path86.join(cwd, ".metaproject", "data", "gdgraph", "storage", "nodes.jsonl");
20063
+ return path87.join(cwd, ".metaproject", "data", "gdgraph", "storage", "nodes.jsonl");
20064
20064
  }
20065
20065
  function gdgraphConfigPath2(cwd) {
20066
- return path86.join(cwd, ".metaproject", "gdgraph.config.json");
20066
+ return path87.join(cwd, ".metaproject", "gdgraph.config.json");
20067
20067
  }
20068
20068
  function categorizeStatusEntries(entries, rootPrefix) {
20069
20069
  const metaprojectPrefix = `${rootPrefix}.metaproject/`;
@@ -20158,7 +20158,7 @@ async function checkGraphStaleness(cwd, statusObservation) {
20158
20158
  }
20159
20159
  } else {
20160
20160
  provenanceMissing = true;
20161
- const logsHeadStat = await stat12(path86.join(cwd, ".git", "logs", "HEAD")).catch(() => null);
20161
+ const logsHeadStat = await stat12(path87.join(cwd, ".git", "logs", "HEAD")).catch(() => null);
20162
20162
  if (logsHeadStat && logsHeadStat.mtimeMs > nodesStat.mtimeMs) {
20163
20163
  reasons.push("repo HEAD moved since the graph was built (no build provenance recorded; inferred from .git/logs/HEAD)");
20164
20164
  }
@@ -20186,7 +20186,7 @@ async function checkGraphStaleness(cwd, statusObservation) {
20186
20186
  if (projectRelative === null) {
20187
20187
  continue;
20188
20188
  }
20189
- const fileStat = await stat12(path86.join(cwd, projectRelative)).catch(() => null);
20189
+ const fileStat = await stat12(path87.join(cwd, projectRelative)).catch(() => null);
20190
20190
  if (fileStat && fileStat.mtimeMs > nodesStat.mtimeMs) {
20191
20191
  postBuildEdits.push(displayPath);
20192
20192
  }
@@ -20322,15 +20322,15 @@ var init_types3 = __esm(() => {
20322
20322
 
20323
20323
  // src/wiki/collect.ts
20324
20324
  import { readFile as readFile41, readdir as readdir16 } from "fs/promises";
20325
- import path87 from "path";
20325
+ import path88 from "path";
20326
20326
  function wikiRootPath(cwd) {
20327
- return path87.join(cwd, ".metaproject", "wiki");
20327
+ return path88.join(cwd, ".metaproject", "wiki");
20328
20328
  }
20329
20329
  async function collectPages(cwd) {
20330
20330
  const root = wikiRootPath(cwd);
20331
20331
  const pages = [];
20332
20332
  for (const { type, folder } of WIKI_PAGE_TYPES) {
20333
- const dir = path87.join(root, folder);
20333
+ const dir = path88.join(root, folder);
20334
20334
  let names;
20335
20335
  try {
20336
20336
  names = await readdir16(dir);
@@ -20345,7 +20345,7 @@ async function collectPages(cwd) {
20345
20345
  if (!entry.endsWith(".md")) {
20346
20346
  continue;
20347
20347
  }
20348
- const absolutePath = path87.join(dir, entry);
20348
+ const absolutePath = path88.join(dir, entry);
20349
20349
  let content;
20350
20350
  try {
20351
20351
  content = await readFile41(absolutePath, "utf8");
@@ -21206,9 +21206,9 @@ var MEMORY_EMBEDDING_ID = "memory.embedding", DEFAULT_EMBED_DIMS = 96;
21206
21206
  // src/memory/embedding/index.ts
21207
21207
  import { createHash as createHash14 } from "crypto";
21208
21208
  import { mkdir as mkdir15, readFile as readFile42, writeFile as writeFile9 } from "fs/promises";
21209
- import path88 from "path";
21209
+ import path89 from "path";
21210
21210
  function embeddingsDir(cwd) {
21211
- return path88.join(cwd, ".metaproject", "data", "memory", "embeddings");
21211
+ return path89.join(cwd, ".metaproject", "data", "memory", "embeddings");
21212
21212
  }
21213
21213
  function entryText(entry) {
21214
21214
  return `${entry.title}
@@ -21237,17 +21237,17 @@ async function buildEmbeddingIndex(cwd, entries, embedder, model, now) {
21237
21237
  };
21238
21238
  const dir = embeddingsDir(cwd);
21239
21239
  await mkdir15(dir, { recursive: true });
21240
- await writeFile9(path88.join(dir, "index.meta.json"), `${JSON.stringify(meta, null, 2)}
21240
+ await writeFile9(path89.join(dir, "index.meta.json"), `${JSON.stringify(meta, null, 2)}
21241
21241
  `, "utf8");
21242
- await writeFile9(path88.join(dir, "vectors.jsonl"), records.map((record) => JSON.stringify(record)).join(`
21242
+ await writeFile9(path89.join(dir, "vectors.jsonl"), records.map((record) => JSON.stringify(record)).join(`
21243
21243
  `) + (records.length > 0 ? `
21244
21244
  ` : ""), "utf8");
21245
21245
  return toIndex(meta, records);
21246
21246
  }
21247
21247
  async function loadEmbeddingIndex(cwd) {
21248
21248
  const dir = embeddingsDir(cwd);
21249
- const metaPath = path88.join(dir, "index.meta.json");
21250
- const vectorsPath = path88.join(dir, "vectors.jsonl");
21249
+ const metaPath = path89.join(dir, "index.meta.json");
21250
+ const vectorsPath = path89.join(dir, "vectors.jsonl");
21251
21251
  if (!await pathExists(metaPath) || !await pathExists(vectorsPath)) {
21252
21252
  return null;
21253
21253
  }
@@ -21328,10 +21328,10 @@ var init_embedding = __esm(() => {
21328
21328
  });
21329
21329
 
21330
21330
  // src/wiki/section-tombstone.ts
21331
- import path89 from "path";
21331
+ import path90 from "path";
21332
21332
  import { stat as stat13 } from "fs/promises";
21333
21333
  function sectionRegistryPath(cwd) {
21334
- return path89.join(cwd, ".metaproject", "wiki", ".sections.json");
21334
+ return path90.join(cwd, ".metaproject", "wiki", ".sections.json");
21335
21335
  }
21336
21336
  function emptySectionRegistry() {
21337
21337
  return { version: SECTION_REGISTRY_VERSION, entries: [], tombstones: [], lifted: [] };
@@ -21633,10 +21633,10 @@ var init_section_tombstone = __esm(() => {
21633
21633
 
21634
21634
  // src/memory/cross-layer.ts
21635
21635
  import { readFile as readFile43 } from "fs/promises";
21636
- import path90 from "path";
21636
+ import path91 from "path";
21637
21637
  function extractWikiReferences(entryRelativePath, entryAbsolutePath, content, wikiRoot) {
21638
21638
  const references = [];
21639
- const entryDir = path90.dirname(entryAbsolutePath);
21639
+ const entryDir = path91.dirname(entryAbsolutePath);
21640
21640
  const lines = content.split(`
21641
21641
  `);
21642
21642
  for (let index = 0;index < lines.length; index += 1) {
@@ -21651,16 +21651,16 @@ function extractWikiReferences(entryRelativePath, entryAbsolutePath, content, wi
21651
21651
  if (withoutAnchor.length === 0) {
21652
21652
  continue;
21653
21653
  }
21654
- const absolute = path90.resolve(entryDir, withoutAnchor);
21655
- const relativeToWiki = path90.relative(wikiRoot, absolute);
21656
- if (relativeToWiki.startsWith("..") || path90.isAbsolute(relativeToWiki)) {
21654
+ const absolute = path91.resolve(entryDir, withoutAnchor);
21655
+ const relativeToWiki = path91.relative(wikiRoot, absolute);
21656
+ if (relativeToWiki.startsWith("..") || path91.isAbsolute(relativeToWiki)) {
21657
21657
  continue;
21658
21658
  }
21659
21659
  references.push({
21660
21660
  entry: entryRelativePath,
21661
21661
  kind: "page-path",
21662
21662
  raw: href,
21663
- target: relativeToWiki.split(path90.sep).join("/"),
21663
+ target: relativeToWiki.split(path91.sep).join("/"),
21664
21664
  line
21665
21665
  });
21666
21666
  }
@@ -21680,7 +21680,7 @@ function isDangling(finding) {
21680
21680
  return finding.state !== "intact";
21681
21681
  }
21682
21682
  async function loadWikiKnowledgeView(cwd) {
21683
- const wikiRoot = path90.join(cwd, ".metaproject", "wiki");
21683
+ const wikiRoot = path91.join(cwd, ".metaproject", "wiki");
21684
21684
  const pages = await collectPages(cwd);
21685
21685
  const index = buildSectionIndex(await Promise.all(pages.map(async (page) => ({
21686
21686
  page,
@@ -21898,7 +21898,7 @@ function round2(value) {
21898
21898
  var init_dedup = () => {};
21899
21899
 
21900
21900
  // src/memory/check.ts
21901
- import path91 from "path";
21901
+ import path92 from "path";
21902
21902
  async function checkMemory(cwd, config) {
21903
21903
  const entries = await collectEntries(cwd);
21904
21904
  const issues = [];
@@ -21914,7 +21914,7 @@ async function checkMemory(cwd, config) {
21914
21914
  }
21915
21915
  for (const file of entry.scopes.files) {
21916
21916
  const clean = file.replace(/^`|`$/g, "");
21917
- if (!await pathExists(path91.resolve(cwd, clean))) {
21917
+ if (!await pathExists(path92.resolve(cwd, clean))) {
21918
21918
  issues.push({ path: entry.relativePath, kind: "link", message: `related file not found: ${clean}` });
21919
21919
  }
21920
21920
  }
@@ -21969,12 +21969,12 @@ var init_check = __esm(() => {
21969
21969
 
21970
21970
  // src/memory/write.ts
21971
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";
21972
+ import path93 from "path";
21973
21973
  async function resolveCanonicalEntryPath(cwd, relativePath) {
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")) {
21974
+ const root = path93.resolve(memoryRoot(cwd));
21975
+ const absolutePath = path93.resolve(root, relativePath);
21976
+ const normalized = toPosix2(path93.relative(root, absolutePath));
21977
+ if (!normalized || normalized.startsWith("../") || path93.isAbsolute(normalized) || !normalized.endsWith(".md")) {
21978
21978
  return null;
21979
21979
  }
21980
21980
  return { absolutePath, relativePath: normalized };
@@ -22070,9 +22070,9 @@ function validateNextEntry(relativePath, content) {
22070
22070
  return null;
22071
22071
  }
22072
22072
  async function replaceAtomically(target, content) {
22073
- const dir = path92.dirname(target);
22073
+ const dir = path93.dirname(target);
22074
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)}`);
22075
+ const tmp = path93.join(dir, `.${path93.basename(target)}.keryx-tmp-${process.pid}-${Math.random().toString(16).slice(2)}`);
22076
22076
  try {
22077
22077
  await writeFile10(tmp, content, "utf8");
22078
22078
  const file = await open3(tmp, "r");
@@ -22108,7 +22108,7 @@ function header(content, name) {
22108
22108
  return content.match(new RegExp(`^${name}:\\s*(.+)$`, "mi"))?.[1]?.trim() ?? null;
22109
22109
  }
22110
22110
  function toPosix2(value) {
22111
- return value.split(path92.sep).join("/");
22111
+ return value.split(path93.sep).join("/");
22112
22112
  }
22113
22113
  function message(cause) {
22114
22114
  return cause instanceof Error ? cause.message : String(cause);
@@ -22122,9 +22122,9 @@ var init_write = __esm(() => {
22122
22122
  // src/memory/ingest.ts
22123
22123
  import { existsSync as existsSync10 } from "fs";
22124
22124
  import { readFile as readFile45 } from "fs/promises";
22125
- import path93 from "path";
22125
+ import path94 from "path";
22126
22126
  async function ingestMemory(cwd, source, filePath, config, now) {
22127
- const absolute = path93.resolve(cwd, filePath);
22127
+ const absolute = path94.resolve(cwd, filePath);
22128
22128
  if (!await pathExists(absolute)) {
22129
22129
  throw new Error(`Ingest source not found: ${filePath}`);
22130
22130
  }
@@ -22141,8 +22141,8 @@ async function ingestMemory(cwd, source, filePath, config, now) {
22141
22141
  const securityWarnings = [];
22142
22142
  const securitySkipped = [];
22143
22143
  let skippedDuplicates = 0;
22144
- const dir = path93.join(memoryRoot(cwd), folder);
22145
- const link = path93.relative(cwd, absolute);
22144
+ const dir = path94.join(memoryRoot(cwd), folder);
22145
+ const link = path94.relative(cwd, absolute);
22146
22146
  const date = dateString(now);
22147
22147
  for (const text of candidates) {
22148
22148
  const title = toTitle(text);
@@ -22323,7 +22323,7 @@ function uniqueSlug(dir, title) {
22323
22323
  const base = slugify2(title) || "entry";
22324
22324
  let slug = base;
22325
22325
  let counter = 2;
22326
- while (existsSync10(path93.join(dir, `${slug}.md`))) {
22326
+ while (existsSync10(path94.join(dir, `${slug}.md`))) {
22327
22327
  slug = `${base}-${counter}`;
22328
22328
  counter += 1;
22329
22329
  }
@@ -22358,7 +22358,7 @@ var init_ingest = __esm(() => {
22358
22358
 
22359
22359
  // src/memory/supersede.ts
22360
22360
  import { readFile as readFile46 } from "fs/promises";
22361
- import path94 from "path";
22361
+ import path95 from "path";
22362
22362
  async function supersedeEntry(input, now) {
22363
22363
  const date = input.date ?? now.toISOString().slice(0, 10);
22364
22364
  const today = now.toISOString().slice(0, 10);
@@ -22418,12 +22418,12 @@ async function supersedeEntry(input, now) {
22418
22418
  async function resolveEntryPath(cwd, raw) {
22419
22419
  const root = memoryRoot(cwd);
22420
22420
  const candidates = [
22421
- path94.resolve(cwd, raw),
22422
- path94.resolve(root, raw),
22423
- path94.isAbsolute(raw) ? raw : path94.join(cwd, raw)
22421
+ path95.resolve(cwd, raw),
22422
+ path95.resolve(root, raw),
22423
+ path95.isAbsolute(raw) ? raw : path95.join(cwd, raw)
22424
22424
  ];
22425
22425
  for (const absolute of candidates) {
22426
- const confined = await resolveCanonicalEntryPath(cwd, path94.relative(root, absolute));
22426
+ const confined = await resolveCanonicalEntryPath(cwd, path95.relative(root, absolute));
22427
22427
  if (confined && await pathExists(confined.absolutePath)) {
22428
22428
  return { absolute: confined.absolutePath, relative: confined.relativePath };
22429
22429
  }
@@ -22619,9 +22619,9 @@ __export(exports_service3, {
22619
22619
  });
22620
22620
  import { createHash as createHash15 } from "crypto";
22621
22621
  import { mkdir as mkdir17, readFile as readFile47, writeFile as writeFile11 } from "fs/promises";
22622
- import path95 from "path";
22622
+ import path96 from "path";
22623
22623
  function dataRoot2(cwd) {
22624
- return path95.join(cwd, ".metaproject", "data", "memory");
22624
+ return path96.join(cwd, ".metaproject", "data", "memory");
22625
22625
  }
22626
22626
  function createMemoryService() {
22627
22627
  const reportStore = createMemoryReportStore();
@@ -22636,9 +22636,9 @@ function createMemoryService() {
22636
22636
  if (!/^[a-z0-9][a-z0-9-]*$/.test(slug)) {
22637
22637
  throw new Error(`Invalid slug: ${slug}. Use lowercase letters, digits, and hyphens.`);
22638
22638
  }
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);
22639
+ const dir = path96.join(memoryRoot(input.cwd), typeConfig.folder);
22640
+ const filePath = path96.join(dir, `${slug}.md`);
22641
+ const relativePath = path96.relative(input.cwd, filePath);
22642
22642
  if (await pathExists(filePath) && !input.force) {
22643
22643
  throw new Error(`Entry already exists: ${relativePath}. Use --force to overwrite.`);
22644
22644
  }
@@ -22669,9 +22669,9 @@ function createMemoryService() {
22669
22669
  async index(input) {
22670
22670
  const entries = await collectEntries(input.cwd);
22671
22671
  const generatedAt = new Date().toISOString();
22672
- const indexDir = input.indexDir ?? path95.join(dataRoot2(input.cwd), "index");
22672
+ const indexDir = input.indexDir ?? path96.join(dataRoot2(input.cwd), "index");
22673
22673
  await mkdir17(indexDir, { recursive: true });
22674
- const indexPath = path95.join(indexDir, "index.json");
22674
+ const indexPath = path96.join(indexDir, "index.json");
22675
22675
  await writeFile11(indexPath, `${JSON.stringify({
22676
22676
  catalogVersion: 1,
22677
22677
  sourceFingerprint: createHash15("sha256").update(JSON.stringify(entries.map((e) => ({
@@ -22692,7 +22692,7 @@ function createMemoryService() {
22692
22692
  }, null, 2)}
22693
22693
  `, "utf8");
22694
22694
  const result = {
22695
- path: path95.relative(input.cwd, indexPath),
22695
+ path: path96.relative(input.cwd, indexPath),
22696
22696
  entryCount: entries.length,
22697
22697
  generatedAt
22698
22698
  };
@@ -22705,7 +22705,7 @@ function createMemoryService() {
22705
22705
  const built = await buildEmbeddingIndex(input.cwd, entries, embedder.embed, embedder.model, new Date);
22706
22706
  result.embeddings = {
22707
22707
  built: true,
22708
- path: path95.relative(input.cwd, embeddingsDir(input.cwd)),
22708
+ path: path96.relative(input.cwd, embeddingsDir(input.cwd)),
22709
22709
  vectorCount: built.meta.entryCount,
22710
22710
  model: built.meta.model
22711
22711
  };
@@ -23307,7 +23307,7 @@ var init_ask = __esm(() => {
23307
23307
  });
23308
23308
 
23309
23309
  // src/wiki/backlinks.ts
23310
- import path96 from "path";
23310
+ import path97 from "path";
23311
23311
  function extractCodePaths(content) {
23312
23312
  const out = [];
23313
23313
  let match;
@@ -23337,8 +23337,8 @@ function resolveLink(fromRepoPath, raw) {
23337
23337
  const clean = (raw.split("#")[0] ?? "").trim();
23338
23338
  if (!clean)
23339
23339
  return "";
23340
- const fromDir = path96.posix.dirname(fromRepoPath.split(path96.sep).join("/"));
23341
- return path96.posix.normalize(path96.posix.join(fromDir, clean));
23340
+ const fromDir = path97.posix.dirname(fromRepoPath.split(path97.sep).join("/"));
23341
+ return path97.posix.normalize(path97.posix.join(fromDir, clean));
23342
23342
  }
23343
23343
  function buildBacklinkIndex(pages) {
23344
23344
  const index = new Map;
@@ -23352,18 +23352,18 @@ function buildBacklinkIndex(pages) {
23352
23352
  }
23353
23353
  };
23354
23354
  for (const page of pages) {
23355
- const from = page.repoPath.split(path96.sep).join("/");
23355
+ const from = page.repoPath.split(path97.sep).join("/");
23356
23356
  for (const raw of extractLinks(page.content))
23357
23357
  add(resolveLink(from, raw), from);
23358
23358
  for (const raw of extractCodePaths(page.content))
23359
- add(path96.posix.normalize(raw), from);
23359
+ add(path97.posix.normalize(raw), from);
23360
23360
  }
23361
23361
  for (const list of index.values())
23362
23362
  list.sort();
23363
23363
  return index;
23364
23364
  }
23365
23365
  function backlinksFor(index, targetRepoPath) {
23366
- const key = path96.posix.normalize(targetRepoPath.split(path96.sep).join("/"));
23366
+ const key = path97.posix.normalize(targetRepoPath.split(path97.sep).join("/"));
23367
23367
  return index.get(key) ?? [];
23368
23368
  }
23369
23369
  var LINK, CODE_SPAN, FILE_LIKE;
@@ -23376,7 +23376,7 @@ var init_backlinks = __esm(() => {
23376
23376
  // src/ctx/assembly.ts
23377
23377
  import { createHash as createHash16 } from "crypto";
23378
23378
  import { mkdir as mkdir18, rename as rename6, writeFile as writeFile12 } from "fs/promises";
23379
- import path97 from "path";
23379
+ import path98 from "path";
23380
23380
  function assembleContext(input) {
23381
23381
  let items = 0;
23382
23382
  let tokens = 0;
@@ -23420,9 +23420,9 @@ async function recordNoContentContext(input) {
23420
23420
  return assembly;
23421
23421
  }
23422
23422
  async function recordContextAssembly(input) {
23423
- const directory = path97.join(input.workspaceRoot, ".metaproject", "context-operations", "traces");
23423
+ const directory = path98.join(input.workspaceRoot, ".metaproject", "context-operations", "traces");
23424
23424
  await mkdir18(directory, { recursive: true });
23425
- const target = path97.join(directory, path97.basename(input.assembly.traceRef));
23425
+ const target = path98.join(directory, path98.basename(input.assembly.traceRef));
23426
23426
  const temporary = `${target}.${process.pid}.tmp`;
23427
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 })}
23428
23428
  `, { mode: 384 });
@@ -23822,9 +23822,9 @@ var init_evidence = __esm(() => {
23822
23822
  });
23823
23823
 
23824
23824
  // src/wiki/config.ts
23825
- import path98 from "path";
23825
+ import path99 from "path";
23826
23826
  function wikiConfigPath(cwd) {
23827
- return path98.join(cwd, ".metaproject", "wiki.config.json");
23827
+ return path99.join(cwd, ".metaproject", "wiki.config.json");
23828
23828
  }
23829
23829
  function mergeWikiConfig(parsed) {
23830
23830
  const base = DEFAULT_WIKI_CONFIG;
@@ -23902,12 +23902,12 @@ var init_config4 = __esm(() => {
23902
23902
  // src/wiki/history.ts
23903
23903
  import { createHash as createHash17, randomBytes as randomBytes5 } from "crypto";
23904
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";
23905
+ import path100 from "path";
23906
23906
  function wikiRootPath2(cwd) {
23907
- return path99.join(cwd, ".metaproject", "wiki");
23907
+ return path100.join(cwd, ".metaproject", "wiki");
23908
23908
  }
23909
23909
  function wikiHistoryRoot(cwd) {
23910
- return path99.join(cwd, ".metaproject", "data", "gdwiki", "history");
23910
+ return path100.join(cwd, ".metaproject", "data", "gdwiki", "history");
23911
23911
  }
23912
23912
  function newWikiRunId(now = new Date) {
23913
23913
  const stamp = now.toISOString().replace(/[-:]/g, "").replace(/\.\d+Z$/, "Z");
@@ -23928,29 +23928,29 @@ async function openWikiWriteContext(cwd, command) {
23928
23928
  return createWikiWriteContext(cwd, command, { keep: (await loadWikiConfig(cwd)).history.keep });
23929
23929
  }
23930
23930
  function wikiPageKey(cwd, absolutePath) {
23931
- const relative = path99.relative(wikiRootPath2(cwd), path99.resolve(absolutePath));
23932
- if (relative === "" || relative.startsWith("..") || path99.isAbsolute(relative)) {
23931
+ const relative = path100.relative(wikiRootPath2(cwd), path100.resolve(absolutePath));
23932
+ if (relative === "" || relative.startsWith("..") || path100.isAbsolute(relative)) {
23933
23933
  throw new Error(`not a wiki page: ${absolutePath}`);
23934
23934
  }
23935
23935
  return toPosix(relative);
23936
23936
  }
23937
23937
  function assertPageKey(page) {
23938
23938
  const segments = page.split("/");
23939
- if (page.length === 0 || page.includes("\\") || path99.isAbsolute(page) || segments.some((segment) => segment === "" || segment === "." || segment === "..")) {
23939
+ if (page.length === 0 || page.includes("\\") || path100.isAbsolute(page) || segments.some((segment) => segment === "" || segment === "." || segment === "..")) {
23940
23940
  throw new Error(`not a wiki page path: ${page}`);
23941
23941
  }
23942
23942
  return page;
23943
23943
  }
23944
23944
  function pageHistoryDir(cwd, page) {
23945
- return path99.join(wikiHistoryRoot(cwd), ...assertPageKey(page).replace(/\.md$/i, "").split("/"));
23945
+ return path100.join(wikiHistoryRoot(cwd), ...assertPageKey(page).replace(/\.md$/i, "").split("/"));
23946
23946
  }
23947
23947
  function pagePath(cwd, page) {
23948
- return path99.join(wikiRootPath2(cwd), ...assertPageKey(page).split("/"));
23948
+ return path100.join(wikiRootPath2(cwd), ...assertPageKey(page).split("/"));
23949
23949
  }
23950
23950
  function versionFilePath(cwd, page, file) {
23951
23951
  const dir = pageHistoryDir(cwd, page);
23952
- const target = path99.join(dir, file);
23953
- if (!VERSION_FILE.test(file) || path99.dirname(target) !== dir) {
23952
+ const target = path100.join(dir, file);
23953
+ if (!VERSION_FILE.test(file) || path100.dirname(target) !== dir) {
23954
23954
  throw new Error(`history index names an invalid version file for ${page}: ${file}`);
23955
23955
  }
23956
23956
  return target;
@@ -24023,7 +24023,7 @@ function parsePageHistoryIndex(markdown, page) {
24023
24023
  return { page, rows };
24024
24024
  }
24025
24025
  async function readPageHistory(cwd, page) {
24026
- const indexPath = path99.join(pageHistoryDir(cwd, page), INDEX_FILE);
24026
+ const indexPath = path100.join(pageHistoryDir(cwd, page), INDEX_FILE);
24027
24027
  const raw = await readBufferOrNull(indexPath);
24028
24028
  if (raw === null)
24029
24029
  return null;
@@ -24035,8 +24035,8 @@ async function readPageHistory(cwd, page) {
24035
24035
  }
24036
24036
  async function storeVersion(cwd, page, version, at, content) {
24037
24037
  const fileName = `${versionLabel(version)}-${at.replace(/[:.]/g, "-")}.md`;
24038
- const target = path99.join(pageHistoryDir(cwd, page), fileName);
24039
- await mkdir19(path99.dirname(target), { recursive: true });
24038
+ const target = path100.join(pageHistoryDir(cwd, page), fileName);
24039
+ await mkdir19(path100.dirname(target), { recursive: true });
24040
24040
  await writeFile13(target, content);
24041
24041
  if (sha2562(await readFile49(target)) !== sha2562(content)) {
24042
24042
  throw new Error(`history: stored version does not match the page bytes: ${target}`);
@@ -24074,7 +24074,7 @@ function planPrune(history, keep, maxRows = MAX_INDEX_ROWS) {
24074
24074
  }
24075
24075
  async function ensureHistoryRoot(cwd) {
24076
24076
  const root = wikiHistoryRoot(cwd);
24077
- const ignore = path99.join(root, ".gitignore");
24077
+ const ignore = path100.join(root, ".gitignore");
24078
24078
  if (await readBufferOrNull(ignore))
24079
24079
  return;
24080
24080
  await mkdir19(root, { recursive: true });
@@ -24104,14 +24104,14 @@ async function endsWithoutNewline(file) {
24104
24104
  }
24105
24105
  async function appendRun(cwd, entry) {
24106
24106
  const root = wikiHistoryRoot(cwd);
24107
- const file = path99.join(root, RUNS_FILE);
24107
+ const file = path100.join(root, RUNS_FILE);
24108
24108
  const lead = await endsWithoutNewline(file) ? `
24109
24109
  ` : "";
24110
24110
  await appendFile4(file, `${lead}${JSON.stringify(entry)}
24111
24111
  `, "utf8");
24112
24112
  if ((await stat14(file)).size <= MAX_RUNS_BYTES)
24113
24113
  return;
24114
- await withFileLock(path99.join(root, ".runs.lock"), async () => {
24114
+ await withFileLock(path100.join(root, ".runs.lock"), async () => {
24115
24115
  if ((await stat14(file)).size <= MAX_RUNS_BYTES)
24116
24116
  return;
24117
24117
  const lines = (await readFile49(file, "utf8")).split(`
@@ -24125,7 +24125,7 @@ async function mutatePage(ctx, absolutePath, next) {
24125
24125
  const page = wikiPageKey(ctx.cwd, absolutePath);
24126
24126
  const dir = pageHistoryDir(ctx.cwd, page);
24127
24127
  await ensureHistoryRoot(ctx.cwd);
24128
- return withFileLock(path99.join(path99.dirname(dir), `.${path99.basename(dir)}.lock`), async () => {
24128
+ return withFileLock(path100.join(path100.dirname(dir), `.${path100.basename(dir)}.lock`), async () => {
24129
24129
  const live = await readBufferOrNull(absolutePath);
24130
24130
  if (next === null ? live === null : live !== null && live.equals(next)) {
24131
24131
  return { changed: false };
@@ -24149,7 +24149,7 @@ async function mutatePage(ctx, absolutePath, next) {
24149
24149
  if (next === null) {
24150
24150
  await rm6(absolutePath, { force: true });
24151
24151
  } else {
24152
- await mkdir19(path99.dirname(absolutePath), { recursive: true });
24152
+ await mkdir19(path100.dirname(absolutePath), { recursive: true });
24153
24153
  await writeFile13(absolutePath, next);
24154
24154
  }
24155
24155
  } catch (error) {
@@ -24157,7 +24157,7 @@ async function mutatePage(ctx, absolutePath, next) {
24157
24157
  await rm6(versionFilePath(ctx.cwd, page, row.file), { force: true });
24158
24158
  throw error;
24159
24159
  }
24160
- await writeFileAtomic(path99.join(dir, INDEX_FILE), renderPageHistoryIndex(history));
24160
+ await writeFileAtomic(path100.join(dir, INDEX_FILE), renderPageHistoryIndex(history));
24161
24161
  for (const file of pruned)
24162
24162
  await rm6(versionFilePath(ctx.cwd, page, file), { force: true });
24163
24163
  return { changed: true, action };
@@ -24170,7 +24170,7 @@ async function deleteWikiPage(ctx, absolutePath) {
24170
24170
  return mutatePage(ctx, absolutePath, null);
24171
24171
  }
24172
24172
  async function readWikiRuns(cwd) {
24173
- const raw = await readBufferOrNull(path99.join(wikiHistoryRoot(cwd), RUNS_FILE));
24173
+ const raw = await readBufferOrNull(path100.join(wikiHistoryRoot(cwd), RUNS_FILE));
24174
24174
  if (raw === null)
24175
24175
  return [];
24176
24176
  const entries = [];
@@ -24862,7 +24862,7 @@ var init_page_invariants = __esm(() => {
24862
24862
  });
24863
24863
 
24864
24864
  // src/wiki/readme-links.ts
24865
- import path100 from "path";
24865
+ import path101 from "path";
24866
24866
  function rewriteReadmeLinks(text, readmeDir, pageLink) {
24867
24867
  return text.replace(MARKDOWN_LINK, (whole, bang, label, target) => {
24868
24868
  if (target === "" || HAS_SCHEME.test(target)) {
@@ -24872,7 +24872,7 @@ function rewriteReadmeLinks(text, readmeDir, pageLink) {
24872
24872
  if (filePart === "") {
24873
24873
  return label;
24874
24874
  }
24875
- const resolved = path100.posix.normalize(filePart.startsWith("/") ? filePart.replace(/^\/+/, "") : path100.posix.join(readmeDir, filePart));
24875
+ const resolved = path101.posix.normalize(filePart.startsWith("/") ? filePart.replace(/^\/+/, "") : path101.posix.join(readmeDir, filePart));
24876
24876
  const codePath = resolved.replace(/\/+$/, "");
24877
24877
  if (codePath === "" || codePath === "." || codePath === ".." || codePath.startsWith("../")) {
24878
24878
  return label;
@@ -24887,12 +24887,12 @@ function rewriteReadmeLinks(text, readmeDir, pageLink) {
24887
24887
  });
24888
24888
  }
24889
24889
  function moduleOfTarget(filePart, codePath) {
24890
- const base = path100.posix.basename(codePath);
24890
+ const base = path101.posix.basename(codePath);
24891
24891
  if (filePart.endsWith("/") || !/\.[A-Za-z0-9]+$/.test(base)) {
24892
24892
  return codePath;
24893
24893
  }
24894
24894
  if (DOC_ENTRY.test(base)) {
24895
- const dir = path100.posix.dirname(codePath);
24895
+ const dir = path101.posix.dirname(codePath);
24896
24896
  return dir === "." ? null : dir;
24897
24897
  }
24898
24898
  return null;
@@ -25340,15 +25340,15 @@ __export(exports_service4, {
25340
25340
  import { spawn as spawn3 } from "child_process";
25341
25341
  import { createHash as createHash19 } from "crypto";
25342
25342
  import { mkdir as mkdir20, readFile as readFile50, readdir as readdir17, writeFile as writeFile14 } from "fs/promises";
25343
- import path101 from "path";
25343
+ import path102 from "path";
25344
25344
  function wikiRootPath3(cwd) {
25345
- return path101.join(cwd, ".metaproject", "wiki");
25345
+ return path102.join(cwd, ".metaproject", "wiki");
25346
25346
  }
25347
25347
  function dataRootPath(cwd) {
25348
- return path101.join(cwd, ".metaproject", "data", "gdwiki");
25348
+ return path102.join(cwd, ".metaproject", "data", "gdwiki");
25349
25349
  }
25350
25350
  function linkCheckReportPath(cwd) {
25351
- return path101.join(dataRootPath(cwd), "link-check", "latest.md");
25351
+ return path102.join(dataRootPath(cwd), "link-check", "latest.md");
25352
25352
  }
25353
25353
  async function wikiStatus(cwd) {
25354
25354
  const root = wikiRootPath3(cwd);
@@ -25356,7 +25356,7 @@ async function wikiStatus(cwd) {
25356
25356
  const pages = enabled ? await collectPages(cwd) : [];
25357
25357
  return {
25358
25358
  enabled,
25359
- wikiRoot: path101.relative(cwd, root),
25359
+ wikiRoot: path102.relative(cwd, root),
25360
25360
  totalPages: pages.length,
25361
25361
  countsByType: WIKI_PAGE_TYPES.map(({ type }) => ({
25362
25362
  type,
@@ -25387,9 +25387,9 @@ async function wikiCreatePage(input) {
25387
25387
  if (!/^[a-z0-9][a-z0-9-]*$/.test(input.slug)) {
25388
25388
  throw new Error(`Invalid slug: ${input.slug}. Use lowercase letters, digits, and hyphens.`);
25389
25389
  }
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);
25390
+ const dir = path102.join(wikiRootPath3(input.cwd), typeConfig.folder);
25391
+ const filePath = path102.join(dir, `${input.slug}.md`);
25392
+ const relativePath = path102.relative(input.cwd, filePath);
25393
25393
  if (await pathExists(filePath) && !input.force) {
25394
25394
  throw new Error(`Page already exists: ${relativePath}. Use --force to overwrite.`);
25395
25395
  }
@@ -25401,7 +25401,7 @@ async function wikiCreatePage(input) {
25401
25401
  }
25402
25402
  async function wikiGenerateIndex(cwd, history) {
25403
25403
  const root = wikiRootPath3(cwd);
25404
- const indexPath = path101.join(root, "index.md");
25404
+ const indexPath = path102.join(root, "index.md");
25405
25405
  const pages = await collectPages(cwd);
25406
25406
  const generatedAt = new Date().toISOString();
25407
25407
  const managedBlock = `${WIKI_INDEX_BEGIN}
@@ -25418,7 +25418,7 @@ ${managedBlock}
25418
25418
  `;
25419
25419
  await writeWikiPage(history ?? await openWikiWriteContext(cwd, "wiki index"), indexPath, next);
25420
25420
  return {
25421
- path: path101.relative(cwd, indexPath),
25421
+ path: path102.relative(cwd, indexPath),
25422
25422
  pageCount: pages.length,
25423
25423
  generatedAt
25424
25424
  };
@@ -25426,13 +25426,13 @@ ${managedBlock}
25426
25426
  async function wikiCheckLinks(cwd) {
25427
25427
  const root = wikiRootPath3(cwd);
25428
25428
  const allFiles = await pathExists(root) ? await walkMarkdown(root) : [];
25429
- const files = allFiles.filter((absolutePath) => !path101.relative(root, absolutePath).startsWith(`templates${path101.sep}`));
25429
+ const files = allFiles.filter((absolutePath) => !path102.relative(root, absolutePath).startsWith(`templates${path102.sep}`));
25430
25430
  const broken = [];
25431
25431
  let checkedLinks = 0;
25432
25432
  let skippedExternal = 0;
25433
25433
  for (const absolutePath of files) {
25434
25434
  const content = await readFile50(absolutePath, "utf8");
25435
- const pageRelative = path101.relative(cwd, absolutePath);
25435
+ const pageRelative = path102.relative(cwd, absolutePath);
25436
25436
  for (const target of extractLinkTargets(content)) {
25437
25437
  if (EXTERNAL_LINK.test(target)) {
25438
25438
  skippedExternal += 1;
@@ -25443,7 +25443,7 @@ async function wikiCheckLinks(cwd) {
25443
25443
  continue;
25444
25444
  }
25445
25445
  checkedLinks += 1;
25446
- const resolved = path101.resolve(path101.dirname(absolutePath), filePart);
25446
+ const resolved = path102.resolve(path102.dirname(absolutePath), filePart);
25447
25447
  if (!await pathExists(resolved)) {
25448
25448
  broken.push({
25449
25449
  page: pageRelative,
@@ -25455,7 +25455,7 @@ async function wikiCheckLinks(cwd) {
25455
25455
  }
25456
25456
  const generatedAt = new Date().toISOString();
25457
25457
  const reportPath = linkCheckReportPath(cwd);
25458
- await mkdir20(path101.dirname(reportPath), { recursive: true });
25458
+ await mkdir20(path102.dirname(reportPath), { recursive: true });
25459
25459
  await writeFile14(reportPath, renderLinkCheckReport({
25460
25460
  generatedAt,
25461
25461
  checkedPages: files.length,
@@ -25464,7 +25464,7 @@ async function wikiCheckLinks(cwd) {
25464
25464
  broken
25465
25465
  }), "utf8");
25466
25466
  return {
25467
- reportPath: path101.relative(cwd, reportPath),
25467
+ reportPath: path102.relative(cwd, reportPath),
25468
25468
  checkedPages: files.length,
25469
25469
  checkedLinks,
25470
25470
  skippedExternal,
@@ -25515,7 +25515,7 @@ async function wikiValidate(cwd) {
25515
25515
  }
25516
25516
  if (await isIndexStale(cwd, pages)) {
25517
25517
  issues.push({
25518
- page: path101.join(path101.relative(cwd, wikiRootPath3(cwd)), "index.md"),
25518
+ page: path102.join(path102.relative(cwd, wikiRootPath3(cwd)), "index.md"),
25519
25519
  kind: "index",
25520
25520
  message: "index out of date, run `keryx wiki index`"
25521
25521
  });
@@ -25561,7 +25561,7 @@ function collectCommandLabel(input) {
25561
25561
  return ["wiki collect", ...flags].join(" ");
25562
25562
  }
25563
25563
  async function wikiPruneOrphans(cwd, history) {
25564
- const componentsDir = path101.join(wikiRootPath3(cwd), "components");
25564
+ const componentsDir = path102.join(wikiRootPath3(cwd), "components");
25565
25565
  if (!await pathExists(componentsDir)) {
25566
25566
  return { pruned: [], orphanedAccepted: [] };
25567
25567
  }
@@ -25581,15 +25581,15 @@ async function wikiPruneOrphans(cwd, history) {
25581
25581
  if (validSlugs.has(slug)) {
25582
25582
  continue;
25583
25583
  }
25584
- const filePath = path101.join(componentsDir, entry);
25584
+ const filePath = path102.join(componentsDir, entry);
25585
25585
  const current = await readFile50(filePath, "utf8");
25586
25586
  const isUnmodifiedDraft = /\nStatus:\s*draft\s*\n/.test(current) && current.includes("Generated by `keryx wiki collect`");
25587
25587
  if (isUnmodifiedDraft) {
25588
25588
  run ??= history ?? await openWikiWriteContext(cwd, "wiki prune");
25589
25589
  await deleteWikiPage(run, filePath);
25590
- pruned.push(path101.relative(cwd, filePath));
25590
+ pruned.push(path102.relative(cwd, filePath));
25591
25591
  } else {
25592
- orphanedAccepted.push(path101.relative(cwd, filePath));
25592
+ orphanedAccepted.push(path102.relative(cwd, filePath));
25593
25593
  }
25594
25594
  }
25595
25595
  return { pruned, orphanedAccepted };
@@ -25599,7 +25599,7 @@ async function validModuleNames(cwd, dataDir) {
25599
25599
  return counts === undefined ? undefined : new Set(counts.keys());
25600
25600
  }
25601
25601
  async function moduleFileCounts(cwd, dataDir) {
25602
- const nodesPath = path101.join(gdgraphStorageDir(cwd, dataDir), "nodes.jsonl");
25602
+ const nodesPath = path102.join(gdgraphStorageDir(cwd, dataDir), "nodes.jsonl");
25603
25603
  if (!await pathExists(nodesPath)) {
25604
25604
  return;
25605
25605
  }
@@ -25670,9 +25670,9 @@ async function wikiEvidence(input) {
25670
25670
  });
25671
25671
  }
25672
25672
  function resolveEvidenceScope(cwd, override) {
25673
- const absolute = path101.resolve(cwd);
25673
+ const absolute = path102.resolve(cwd);
25674
25674
  return {
25675
- projectId: override?.projectId ?? (path101.basename(absolute) || "project"),
25675
+ projectId: override?.projectId ?? (path102.basename(absolute) || "project"),
25676
25676
  checkoutId: override?.checkoutId ?? `checkout:${createHash19("sha256").update(absolute).digest("hex").slice(0, 16)}`,
25677
25677
  ...override?.workspaceId ? { workspaceId: override.workspaceId } : {},
25678
25678
  ...override?.taskId ? { taskId: override.taskId } : {}
@@ -25687,7 +25687,7 @@ function isMachineAuthoredPage(pageType, relativePath, content) {
25687
25687
  if (source === null) {
25688
25688
  return false;
25689
25689
  }
25690
- const normalised = relativePath.split(path101.sep).join("/").replace(/^wiki\//, "");
25690
+ const normalised = relativePath.split(path102.sep).join("/").replace(/^wiki\//, "");
25691
25691
  return WIKI_PAGE_PRODUCERS.some((producer) => producer.source === source && producer.pageType === pageType && producer.path.test(normalised) && /^-[ \t]+Link:.*\bsha256\b/m.test(content));
25692
25692
  }
25693
25693
  function createGdWikiService() {
@@ -25703,8 +25703,8 @@ function createGdWikiService() {
25703
25703
  };
25704
25704
  }
25705
25705
  async function collectGraphWikiCandidates(cwd, generatedAt, limit, onlyModules, dataDir) {
25706
- const nodesPath = path101.join(gdgraphStorageDir(cwd, dataDir), "nodes.jsonl");
25707
- const edgesPath = path101.join(gdgraphStorageDir(cwd, dataDir), "edges.jsonl");
25706
+ const nodesPath = path102.join(gdgraphStorageDir(cwd, dataDir), "nodes.jsonl");
25707
+ const edgesPath = path102.join(gdgraphStorageDir(cwd, dataDir), "edges.jsonl");
25708
25708
  if (!await pathExists(nodesPath) || !await pathExists(edgesPath)) {
25709
25709
  return [];
25710
25710
  }
@@ -25791,7 +25791,7 @@ async function collectGraphWikiCandidates(cwd, generatedAt, limit, onlyModules,
25791
25791
  };
25792
25792
  const moduleCandidates = [];
25793
25793
  const pageModules = new Set(topModules.map((entry) => entry.name));
25794
- const componentsDir = path101.join(wikiRootPath3(cwd), "components");
25794
+ const componentsDir = path102.join(wikiRootPath3(cwd), "components");
25795
25795
  const existingSlugs = new Set((await pathExists(componentsDir) ? await readdir17(componentsDir) : []).filter((entry) => entry.endsWith(".md")).map((entry) => entry.slice(0, -3)));
25796
25796
  const pageLink = (name) => {
25797
25797
  const slug = slugifyPath(name);
@@ -25899,7 +25899,7 @@ function topCounts(bucket, limit) {
25899
25899
  return [...bucket.entries()].sort((a, b) => b[1] - a[1]).slice(0, limit);
25900
25900
  }
25901
25901
  async function readModuleReadme(cwd, moduleName, pageLink) {
25902
- const readmePath = path101.join(cwd, ...moduleName.split("/"), "README.md");
25902
+ const readmePath = path102.join(cwd, ...moduleName.split("/"), "README.md");
25903
25903
  if (!await pathExists(readmePath)) {
25904
25904
  return null;
25905
25905
  }
@@ -25920,7 +25920,7 @@ async function extractModuleExports(cwd, files) {
25920
25920
  const declRe = /export\s+(?:async\s+)?(?:default\s+)?(?:const|let|var|function|class|type|interface|enum)\s+([A-Za-z_$][\w$]*)/g;
25921
25921
  const braceRe = /export\s*\{([^}]+)\}/g;
25922
25922
  for (const file of files.slice(0, 4)) {
25923
- const filePath = path101.join(cwd, ...file.split("/"));
25923
+ const filePath = path102.join(cwd, ...file.split("/"));
25924
25924
  if (!await pathExists(filePath)) {
25925
25925
  continue;
25926
25926
  }
@@ -25951,7 +25951,7 @@ async function extractModuleExports(cwd, files) {
25951
25951
  }
25952
25952
  async function extractModuleApi(cwd, files, dataDir) {
25953
25953
  const names = await extractModuleExports(cwd, files);
25954
- const symbolsPath = path101.join(gdgraphStorageDir(cwd, dataDir), "symbols.jsonl");
25954
+ const symbolsPath = path102.join(gdgraphStorageDir(cwd, dataDir), "symbols.jsonl");
25955
25955
  if (names.length === 0 || !await pathExists(symbolsPath)) {
25956
25956
  return names.map((name) => "`" + name + "`");
25957
25957
  }
@@ -25977,7 +25977,7 @@ async function extractModuleApi(cwd, files, dataDir) {
25977
25977
  });
25978
25978
  }
25979
25979
  async function collectHealthWikiCandidates(cwd, generatedAt) {
25980
- const healthPath = path101.join(cwd, ".metaproject", "data", "health", "artifacts", "latest.json");
25980
+ const healthPath = path102.join(cwd, ".metaproject", "data", "health", "artifacts", "latest.json");
25981
25981
  if (!await pathExists(healthPath)) {
25982
25982
  return [];
25983
25983
  }
@@ -26019,7 +26019,7 @@ async function collectHealthWikiCandidates(cwd, generatedAt) {
26019
26019
  }];
26020
26020
  }
26021
26021
  async function collectTestingWikiCandidates(cwd, generatedAt) {
26022
- const contextPath = path101.join(cwd, ".metaproject", "data", "testing", "context.md");
26022
+ const contextPath = path102.join(cwd, ".metaproject", "data", "testing", "context.md");
26023
26023
  if (!await pathExists(contextPath)) {
26024
26024
  return [];
26025
26025
  }
@@ -26050,8 +26050,8 @@ async function writeCollectedPage(cwd, candidate, force, history) {
26050
26050
  if (!folder) {
26051
26051
  throw new Error(`Unsupported collected wiki type: ${candidate.type}`);
26052
26052
  }
26053
- const filePath = path101.join(wikiRootPath3(cwd), folder, `${candidate.slug}.md`);
26054
- const relativePath = path101.relative(cwd, filePath);
26053
+ const filePath = path102.join(wikiRootPath3(cwd), folder, `${candidate.slug}.md`);
26054
+ const relativePath = path102.relative(cwd, filePath);
26055
26055
  const exists = await pathExists(filePath);
26056
26056
  if (exists && !force) {
26057
26057
  return { path: relativePath, type: candidate.type, source: candidate.source, action: "skipped" };
@@ -26102,7 +26102,7 @@ async function writeCollectedPage(cwd, candidate, force, history) {
26102
26102
  async function wikiPagesForFile(cwd, targetRepoPath) {
26103
26103
  const pages = await collectPages(cwd);
26104
26104
  const refs = await Promise.all(pages.map(async (page) => ({
26105
- repoPath: path101.relative(cwd, page.absolutePath).split(path101.sep).join("/"),
26105
+ repoPath: path102.relative(cwd, page.absolutePath).split(path102.sep).join("/"),
26106
26106
  content: await readFile50(page.absolutePath, "utf8")
26107
26107
  })));
26108
26108
  return backlinksFor(buildBacklinkIndex(refs), targetRepoPath);
@@ -26141,7 +26141,7 @@ function renderIndexBody(pages, generatedAt) {
26141
26141
  `).trimEnd();
26142
26142
  }
26143
26143
  async function isIndexStale(cwd, pages) {
26144
- const indexPath = path101.join(wikiRootPath3(cwd), "index.md");
26144
+ const indexPath = path102.join(wikiRootPath3(cwd), "index.md");
26145
26145
  if (!await pathExists(indexPath)) {
26146
26146
  return true;
26147
26147
  }
@@ -26159,7 +26159,7 @@ async function walkMarkdown(root) {
26159
26159
  const results = [];
26160
26160
  const entries = await readdir17(root, { withFileTypes: true });
26161
26161
  for (const entry of entries) {
26162
- const absolutePath = path101.join(root, entry.name);
26162
+ const absolutePath = path102.join(root, entry.name);
26163
26163
  if (entry.isDirectory()) {
26164
26164
  results.push(...await walkMarkdown(absolutePath));
26165
26165
  } else if (entry.isFile() && entry.name.endsWith(".md")) {
@@ -26216,7 +26216,7 @@ ${JSON.stringify(state, null, 2)}
26216
26216
  `;
26217
26217
  }
26218
26218
  async function readIndexGeneratedAt(cwd) {
26219
- const indexPath = path101.join(wikiRootPath3(cwd), "index.md");
26219
+ const indexPath = path102.join(wikiRootPath3(cwd), "index.md");
26220
26220
  if (!await pathExists(indexPath)) {
26221
26221
  return null;
26222
26222
  }
@@ -26456,7 +26456,7 @@ async function validateStructure(cwd, pages, issues) {
26456
26456
  if (pattern.includes("*")) {
26457
26457
  continue;
26458
26458
  }
26459
- if (!await pathExists(path101.join(cwd, pattern))) {
26459
+ if (!await pathExists(path102.join(cwd, pattern))) {
26460
26460
  issues.push({
26461
26461
  page: page.relativePath,
26462
26462
  kind: "describes",
@@ -26526,7 +26526,7 @@ async function validatePageInvariants(cwd, pages, issues) {
26526
26526
  }
26527
26527
  }
26528
26528
  function toPosixPath(value) {
26529
- return value.split(path101.sep).join("/");
26529
+ return value.split(path102.sep).join("/");
26530
26530
  }
26531
26531
  function compareSemver(a, b) {
26532
26532
  const pa = a.split(".").map(Number);
@@ -26572,7 +26572,7 @@ var init_service4 = __esm(() => {
26572
26572
  // src/gdgraph/wiki-layer.ts
26573
26573
  import { createHash as createHash20 } from "crypto";
26574
26574
  import { mkdir as mkdir21, stat as stat15, writeFile as writeFile15 } from "fs/promises";
26575
- import path102 from "path";
26575
+ import path103 from "path";
26576
26576
  function storageDir(projectRoot, dataDir) {
26577
26577
  return gdgraphStorageDir(projectRoot, dataDir);
26578
26578
  }
@@ -26640,11 +26640,11 @@ async function enrichBuildWithWikiLayer(input) {
26640
26640
  const mtimes = new Map;
26641
26641
  for (const record of input.fileRecords) {
26642
26642
  try {
26643
- const info = await stat15(path102.join(input.projectRoot, record.path));
26643
+ const info = await stat15(path103.join(input.projectRoot, record.path));
26644
26644
  mtimes.set(record.path, info.mtimeMs);
26645
26645
  } catch {}
26646
26646
  }
26647
- await writeFile15(path102.join(dir, BUILD_MANIFEST_FILE), `${JSON.stringify({ version: 1, files: computeFingerprints(input.fileRecords, mtimes) }, null, 2)}
26647
+ await writeFile15(path103.join(dir, BUILD_MANIFEST_FILE), `${JSON.stringify({ version: 1, files: computeFingerprints(input.fileRecords, mtimes) }, null, 2)}
26648
26648
  `, "utf8");
26649
26649
  const validModules = input.validModules !== undefined ? input.validModules : await (input.loadValidModules ?? ((root) => defaultLoadValidModules(root, input.dataDir)))(input.projectRoot);
26650
26650
  const wikiPages = await collectPages(input.projectRoot);
@@ -26669,8 +26669,8 @@ async function enrichBuildWithWikiLayer(input) {
26669
26669
  version: page.version
26670
26670
  }))
26671
26671
  });
26672
- await writeJsonl(path102.join(dir, WIKI_PAGES_FILE), layer.pages);
26673
- await writeJsonl(path102.join(dir, DESCRIBES_FILE), layer.describes);
26672
+ await writeJsonl(path103.join(dir, WIKI_PAGES_FILE), layer.pages);
26673
+ await writeJsonl(path103.join(dir, DESCRIBES_FILE), layer.describes);
26674
26674
  return layer;
26675
26675
  }
26676
26676
  async function defaultLoadValidModules(projectRoot, dataDir) {
@@ -26766,7 +26766,7 @@ function personalizedPageRank(nodes, edges, options) {
26766
26766
 
26767
26767
  // src/gdgraph/repomap.ts
26768
26768
  import { mkdir as mkdir23, writeFile as writeFile17 } from "fs/promises";
26769
- import path105 from "path";
26769
+ import path106 from "path";
26770
26770
  function estimateTokens2(text) {
26771
26771
  return Math.ceil(text.length / 4);
26772
26772
  }
@@ -26797,7 +26797,7 @@ function overflowContent(required, missing, budget) {
26797
26797
  `);
26798
26798
  }
26799
26799
  function repomapArtifactPath(cwd) {
26800
- return path105.join(cwd, ".metaproject", "data", "gdgraph", "artifacts", "repomap.md");
26800
+ return path106.join(cwd, ".metaproject", "data", "gdgraph", "artifacts", "repomap.md");
26801
26801
  }
26802
26802
  function buildRankEdges(graph, config) {
26803
26803
  const edges = [];
@@ -26934,7 +26934,7 @@ function computeRepomap(graph, config, options = {}) {
26934
26934
  async function writeRepomap(cwd, graph, config, options = {}) {
26935
26935
  const result = computeRepomap(graph, config, options);
26936
26936
  const artifactPath = repomapArtifactPath(cwd);
26937
- await mkdir23(path105.dirname(artifactPath), { recursive: true });
26937
+ await mkdir23(path106.dirname(artifactPath), { recursive: true });
26938
26938
  await writeFile17(artifactPath, result.content, "utf8");
26939
26939
  return { ...result, path: artifactPath };
26940
26940
  }
@@ -26954,7 +26954,7 @@ var init_repomap = __esm(() => {
26954
26954
  // src/gdskills/contracts.ts
26955
26955
  import { readFile as readFile62 } from "fs/promises";
26956
26956
  import { existsSync as existsSync20 } from "fs";
26957
- import path129 from "path";
26957
+ import path130 from "path";
26958
26958
  import { fileURLToPath as fileURLToPath2 } from "url";
26959
26959
  async function loadSchema(name) {
26960
26960
  const contract = CONTRACTS.find((entry) => entry.name === name);
@@ -26966,12 +26966,12 @@ async function loadSchema(name) {
26966
26966
  }
26967
26967
  function contractPath(contract) {
26968
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);
26969
+ return contract.sourcePath ? path130.join(desktopResources, "review-skills", path130.relative("src/gdskills/bundled/skills", contract.sourcePath)) : path130.join(desktopResources, "review-contracts", contract.fileName);
26970
26970
  }
26971
- const here = path129.dirname(fileURLToPath2(import.meta.url));
26971
+ const here = path130.dirname(fileURLToPath2(import.meta.url));
26972
26972
  if (contract.sourcePath) {
26973
- for (const root of [path129.join(here, "..", ".."), path129.join(here, ".."), here]) {
26974
- const candidate = path129.resolve(root, contract.sourcePath);
26973
+ for (const root of [path130.join(here, "..", ".."), path130.join(here, ".."), here]) {
26974
+ const candidate = path130.resolve(root, contract.sourcePath);
26975
26975
  if (existsSync20(candidate)) {
26976
26976
  return candidate;
26977
26977
  }
@@ -26981,7 +26981,7 @@ function contractPath(contract) {
26981
26981
  if (existsSync20(directPath)) {
26982
26982
  return directPath;
26983
26983
  }
26984
- const packagedSourcePath = path129.join(here, "..", "src", "gdskills", "contracts", contract.fileName);
26984
+ const packagedSourcePath = path130.join(here, "..", "src", "gdskills", "contracts", contract.fileName);
26985
26985
  if (existsSync20(packagedSourcePath)) {
26986
26986
  return packagedSourcePath;
26987
26987
  }
@@ -27114,7 +27114,7 @@ var init_contracts = __esm(() => {
27114
27114
  ];
27115
27115
  desktopResources = desktopResourceDirectory();
27116
27116
  SCHEMA_ROOTS = [
27117
- ...desktopResources ? [path129.join(desktopResources, "review-contracts"), path129.join(desktopResources, "review-skills/review/review-orchestrator")] : [],
27117
+ ...desktopResources ? [path130.join(desktopResources, "review-contracts"), path130.join(desktopResources, "review-skills/review/review-orchestrator")] : [],
27118
27118
  fileURLToPath2(new URL("./contracts/", import.meta.url)),
27119
27119
  fileURLToPath2(new URL("./bundled/skills/review/review-orchestrator/", import.meta.url)),
27120
27120
  fileURLToPath2(new URL("../src/gdskills/contracts/", import.meta.url)),
@@ -27140,7 +27140,7 @@ import {
27140
27140
  writeSync
27141
27141
  } from "fs";
27142
27142
  import { homedir as homedir2 } from "os";
27143
- import path132 from "path";
27143
+ import path133 from "path";
27144
27144
  function keryxConfigDir(dir) {
27145
27145
  if (dir !== undefined) {
27146
27146
  return dir;
@@ -27148,12 +27148,12 @@ function keryxConfigDir(dir) {
27148
27148
  const home = homedir2();
27149
27149
  if (process.platform === "win32") {
27150
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");
27151
+ const base = appData !== undefined && appData.length > 0 ? appData : path133.join(home, "AppData", "Roaming");
27152
+ return path133.join(base, "keryx");
27153
27153
  }
27154
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");
27155
+ const base = xdg !== undefined && xdg.length > 0 ? xdg : path133.join(home, ".local", "share");
27156
+ return path133.join(base, "keryx");
27157
27157
  }
27158
27158
  function keryxDataDir(override) {
27159
27159
  return override || process.env.KERYX_DATA_DIR || keryxConfigDir();
@@ -27192,7 +27192,7 @@ var init_config_dir = __esm(() => {
27192
27192
  // src/session/preservation.ts
27193
27193
  import { createHash as createHash23, randomUUID as randomUUID3 } from "crypto";
27194
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";
27195
+ import path134 from "path";
27196
27196
  function syncDir(dir) {
27197
27197
  if (process.platform === "win32")
27198
27198
  return;
@@ -27204,7 +27204,7 @@ function syncDir(dir) {
27204
27204
  }
27205
27205
  }
27206
27206
  function writePreservationFile(file, body) {
27207
- const dir = path133.dirname(file);
27207
+ const dir = path134.dirname(file);
27208
27208
  mkdirSync3(dir, { recursive: true, mode: 448 });
27209
27209
  const tmp = `${file}.${randomUUID3()}.tmp`;
27210
27210
  const fd = openSync2(tmp, "wx", 384);
@@ -27229,11 +27229,11 @@ function writePreservationFile(file, body) {
27229
27229
  }
27230
27230
  }
27231
27231
  function readPreservation(dir, snapshotId) {
27232
- const base = path133.join(dir, "preservation");
27232
+ const base = path134.join(dir, "preservation");
27233
27233
  let id = snapshotId;
27234
27234
  if (id === undefined) {
27235
27235
  try {
27236
- id = readFileSync13(path133.join(base, "CURRENT"), "utf8");
27236
+ id = readFileSync13(path134.join(base, "CURRENT"), "utf8");
27237
27237
  } catch (e) {
27238
27238
  if (e.code === "ENOENT")
27239
27239
  return;
@@ -27242,7 +27242,7 @@ function readPreservation(dir, snapshotId) {
27242
27242
  }
27243
27243
  if (!/^[a-f0-9]{64}$/.test(id))
27244
27244
  throw new Error("invalid preservation identity");
27245
- const read = readTranscriptFile(path133.join(base, "generations", `${id}.json`));
27245
+ const read = readTranscriptFile(path134.join(base, "generations", `${id}.json`));
27246
27246
  if (!read.ok)
27247
27247
  throw new Error(`snapshot unreadable: ${read.reason}`);
27248
27248
  if (hash(read.text) !== id)
@@ -27260,9 +27260,9 @@ function readPreservation(dir, snapshotId) {
27260
27260
  return parsed;
27261
27261
  }
27262
27262
  function readPendingHistory(dir) {
27263
- let read = readConfigFile(path133.join(dir, "preservation", "HISTORY"));
27263
+ let read = readConfigFile(path134.join(dir, "preservation", "HISTORY"));
27264
27264
  if (!read.ok && read.reason === "absent") {
27265
- read = readConfigFile(path133.join(dir, "preservation", "MIRRORING"));
27265
+ read = readConfigFile(path134.join(dir, "preservation", "MIRRORING"));
27266
27266
  }
27267
27267
  if (!read.ok) {
27268
27268
  if (read.reason === "absent")
@@ -27286,12 +27286,12 @@ var init_preservation = __esm(() => {
27286
27286
 
27287
27287
  // src/session/slate.ts
27288
27288
  import { mkdir as mkdir32, readFile as readFile66, readdir as readdir23, stat as stat18 } from "fs/promises";
27289
- import path138 from "path";
27289
+ import path139 from "path";
27290
27290
  function isSlateSeedKind(value) {
27291
27291
  return typeof value === "string" && SLATE_SEED_KINDS.includes(value);
27292
27292
  }
27293
27293
  function slatePath(dir) {
27294
- return path138.join(dir, "slate.json");
27294
+ return path139.join(dir, "slate.json");
27295
27295
  }
27296
27296
  function slateLockPath(dir) {
27297
27297
  return `${slatePath(dir)}.lock`;
@@ -27574,6 +27574,7 @@ __export(exports_service2, {
27574
27574
  extractCriterionTokens: () => extractCriterionTokens,
27575
27575
  factsOnlyVerdict: () => factsOnlyVerdict,
27576
27576
  fencedLines: () => fencedLines,
27577
+ findIssueFlows: () => findIssueFlows,
27577
27578
  flowDeliveryStatementFrom: () => flowDeliveryStatementFrom,
27578
27579
  flowStatementFrom: () => flowStatementFrom,
27579
27580
  flowsRoot: () => flowsRoot,
@@ -27586,6 +27587,7 @@ __export(exports_service2, {
27586
27587
  intentNoteForNewFlow: () => intentNoteForNewFlow,
27587
27588
  isFrozen: () => isFrozen,
27588
27589
  isOriginKind: () => isOriginKind,
27590
+ issueSourceUrl: () => issueSourceUrl,
27589
27591
  listFlowDirs: () => listFlowDirs,
27590
27592
  notCheckableVerdict: () => notCheckableVerdict,
27591
27593
  originDetailLines: () => originDetailLines,
@@ -27819,7 +27821,7 @@ function completionExceptionQuestion(id, selected, context) {
27819
27821
  init_fs();
27820
27822
  init_validator();
27821
27823
  import { mkdir as mkdir12, readFile as readFile39 } from "fs/promises";
27822
- import path78 from "path";
27824
+ import path79 from "path";
27823
27825
 
27824
27826
  // src/flow/machine.ts
27825
27827
  var TRANSITIONS = {
@@ -28462,6 +28464,22 @@ function parseUnifiedDiff(diff) {
28462
28464
  }
28463
28465
  continue;
28464
28466
  }
28467
+ if (current !== undefined && hunk === undefined && line.startsWith("index ")) {
28468
+ const index = /^index ([0-9a-f]{40})\.\.([0-9a-f]{40})( 100(?:644|755))?$/.exec(line);
28469
+ if (index) {
28470
+ const before = /^0{40}$/.test(index[1]);
28471
+ const after = /^0{40}$/.test(index[2]);
28472
+ if (index[3] && !before && !after || current.regularChange === "new" && before && !after || current.regularChange === "deleted" && !before && after) {
28473
+ current.blobs = [index[1], index[2]];
28474
+ }
28475
+ }
28476
+ continue;
28477
+ }
28478
+ if (current !== undefined && hunk === undefined) {
28479
+ const mode = /^(new|deleted) file mode 100(?:644|755)$/.exec(line)?.[1];
28480
+ if (mode === "new" || mode === "deleted")
28481
+ current.regularChange = mode;
28482
+ }
28465
28483
  if (current !== undefined && (line.startsWith("Binary files ") || line.startsWith("GIT binary patch"))) {
28466
28484
  closeHunk();
28467
28485
  current.binary = true;
@@ -28977,6 +28995,9 @@ function isReasonedDrop(reason) {
28977
28995
  var BLAST_RADIUS_SCOPE_REVIEWER = "review-regression";
28978
28996
 
28979
28997
  // src/review/slice.ts
28998
+ function structuralJsonPaths(manifest) {
28999
+ return Array.isArray(manifest?.structuralJsonFiles) ? manifest.structuralJsonFiles.filter((file) => typeof file === "string" && /\.json$/i.test(file)) : [];
29000
+ }
28980
29001
  var encoder = new TextEncoder;
28981
29002
 
28982
29003
  // src/review/coverage.ts
@@ -31068,6 +31089,7 @@ async function packageEnabledRoles(packageDir) {
31068
31089
  var LINE = new RegExp(`^${ROLE_LINE_PREFIX}.*$`, "m");
31069
31090
 
31070
31091
  // src/review/coverage.ts
31092
+ init_json();
31071
31093
  var LIGHT_MAX_FILES = 5;
31072
31094
  var LIGHT_MAX_CHANGED_LINES = 300;
31073
31095
  var LIGHT_FIXED_REVIEWERS = ["review-logic", "review-testing-practices"];
@@ -31696,7 +31718,11 @@ function dispatchSkips(dispatch) {
31696
31718
  async function packageScopeFiles(packageDir) {
31697
31719
  try {
31698
31720
  const parsed = JSON.parse(await readFile23(path52.join(packageDir, "scope-files.json"), "utf8"));
31699
- return Array.isArray(parsed?.files) && parsed.files.every((f) => typeof f === "string") ? parsed.files : undefined;
31721
+ if (!Array.isArray(parsed?.files) || !parsed.files.every((file) => typeof file === "string"))
31722
+ return;
31723
+ const manifest = await readJsonFileOr(path52.join(packageDir, "slices", "manifest.json"), undefined);
31724
+ const structured = structuralJsonPaths(manifest);
31725
+ return structured.length ? [...new Set([...parsed.files, ...structured])] : parsed.files;
31700
31726
  } catch {
31701
31727
  return;
31702
31728
  }
@@ -34296,6 +34322,166 @@ _(flow-init skill appends here)_
34296
34322
  return { markdown, notes, issueTitle };
34297
34323
  }
34298
34324
 
34325
+ // src/flow/issue-source.ts
34326
+ import path69 from "path";
34327
+
34328
+ // src/lib/clone-scope.ts
34329
+ import { realpath as realpath14 } from "fs/promises";
34330
+ import path67 from "path";
34331
+ async function gitCommonDir(cwd) {
34332
+ try {
34333
+ const proc = Bun.spawn(["git", "rev-parse", "--git-common-dir"], {
34334
+ cwd,
34335
+ stdout: "pipe",
34336
+ stderr: "ignore"
34337
+ });
34338
+ const output = (await new Response(proc.stdout).text()).trim();
34339
+ if (await proc.exited !== 0 || output.length === 0) {
34340
+ return null;
34341
+ }
34342
+ return path67.isAbsolute(output) ? output : path67.resolve(cwd, output);
34343
+ } catch {
34344
+ return null;
34345
+ }
34346
+ }
34347
+ async function gitToplevel(cwd, env) {
34348
+ try {
34349
+ const proc = Bun.spawn(["git", "rev-parse", "--show-toplevel"], {
34350
+ cwd,
34351
+ ...env === undefined ? {} : { env },
34352
+ stdout: "pipe",
34353
+ stderr: "ignore"
34354
+ });
34355
+ const output = (await new Response(proc.stdout).text()).trim();
34356
+ return await proc.exited === 0 && output.length > 0 ? output : null;
34357
+ } catch {
34358
+ return null;
34359
+ }
34360
+ }
34361
+ async function canonicalPath(target) {
34362
+ try {
34363
+ return await realpath14(target);
34364
+ } catch {
34365
+ return path67.resolve(target);
34366
+ }
34367
+ }
34368
+
34369
+ // src/flow/allocation.ts
34370
+ import { appendFile as appendFile3, mkdir as mkdir10, readFile as readFile31 } from "fs/promises";
34371
+ import path68 from "path";
34372
+ init_fs();
34373
+ function projectKey(toplevel, cwd) {
34374
+ if (!toplevel) {
34375
+ return "root";
34376
+ }
34377
+ const relative = path68.relative(toplevel, cwd);
34378
+ return relative === "" ? "root" : slugify(relative);
34379
+ }
34380
+ async function resolveAllocationScope(cwd) {
34381
+ const commonDir = await gitCommonDir(cwd);
34382
+ if (!commonDir) {
34383
+ return {
34384
+ lockPath: path68.join(flowsRoot(cwd), ".flow-init.lock"),
34385
+ ledgerPath: null,
34386
+ project: "root"
34387
+ };
34388
+ }
34389
+ const key = projectKey(await gitToplevel(cwd), cwd);
34390
+ const dir = path68.join(commonDir, "keryx", "flow-ids");
34391
+ return {
34392
+ lockPath: path68.join(dir, `${key}.lock`),
34393
+ ledgerPath: path68.join(dir, `${key}.jsonl`),
34394
+ project: key
34395
+ };
34396
+ }
34397
+ async function readAllocationLedger(scope) {
34398
+ if (!scope.ledgerPath || !await pathExists(scope.ledgerPath)) {
34399
+ return [];
34400
+ }
34401
+ const content = await readFile31(scope.ledgerPath, "utf8");
34402
+ const records = [];
34403
+ for (const line of content.split(`
34404
+ `)) {
34405
+ const trimmed = line.trim();
34406
+ if (trimmed.length === 0) {
34407
+ continue;
34408
+ }
34409
+ try {
34410
+ const parsed = JSON.parse(trimmed);
34411
+ if (typeof parsed.id === "string") {
34412
+ records.push(parsed);
34413
+ }
34414
+ } catch {}
34415
+ }
34416
+ return records;
34417
+ }
34418
+ async function reservedIds(scope) {
34419
+ const records = await readAllocationLedger(scope);
34420
+ return records.map((record) => Number(record.id)).filter((value) => !Number.isNaN(value));
34421
+ }
34422
+ async function recordAllocation(scope, record) {
34423
+ if (!scope.ledgerPath) {
34424
+ return;
34425
+ }
34426
+ await mkdir10(path68.dirname(scope.ledgerPath), { recursive: true });
34427
+ await appendFile3(scope.ledgerPath, `${JSON.stringify(record)}
34428
+ `, "utf8");
34429
+ }
34430
+
34431
+ // src/flow/issue-source.ts
34432
+ function issueSourceUrl(value) {
34433
+ try {
34434
+ const url = new URL(value);
34435
+ const match = /^\/([\w.-]+)\/([\w.-]+)\/issues\/([1-9]\d*)\/?$/i.exec(url.pathname);
34436
+ if (!match || url.protocol !== "https:" || url.host !== "github.com" || url.username || url.password)
34437
+ return;
34438
+ return `https://github.com/${match[1].toLowerCase()}/${match[2].toLowerCase()}/issues/${match[3]}`;
34439
+ } catch {
34440
+ return;
34441
+ }
34442
+ }
34443
+ async function findIssueFlows(cwd, urls) {
34444
+ if (!urls.size)
34445
+ return [];
34446
+ const scope = await resolveAllocationScope(cwd);
34447
+ const root = await canonicalPath(cwd);
34448
+ const dirs = new Map([[root, new Set(await listFlowDirs(root))]]);
34449
+ for (const row of await readAllocationLedger(scope)) {
34450
+ if (!row.cwd || !row.issue || !urls.has(row.issue) || row.retired || path69.basename(row.dir) !== row.dir)
34451
+ continue;
34452
+ const location = await canonicalPath(row.cwd);
34453
+ if (location === root)
34454
+ continue;
34455
+ let names = dirs.get(location);
34456
+ if (!names) {
34457
+ const common = await gitCommonDir(location);
34458
+ if (!common || path69.resolve(common) !== path69.resolve(await gitCommonDir(root) ?? ""))
34459
+ continue;
34460
+ dirs.set(location, names = new Set);
34461
+ }
34462
+ names.add(row.dir);
34463
+ }
34464
+ const found = [];
34465
+ const seen = new Set;
34466
+ for (const [location, names] of dirs) {
34467
+ const pending = Array.from(names);
34468
+ await Promise.all(Array.from({ length: Math.min(12, pending.length) }, async () => {
34469
+ for (let name = pending.pop();name !== undefined; name = pending.pop()) {
34470
+ if (seen.has(name))
34471
+ continue;
34472
+ const flow = await readFlow(location, name).catch(() => {
34473
+ return;
34474
+ });
34475
+ const url = flow?.source?.type === "github-issue" && flow.source.ref ? issueSourceUrl(flow.source.ref) : undefined;
34476
+ if (flow && url && urls.has(url)) {
34477
+ found.push({ cwd: location, dir: name, flow });
34478
+ seen.add(name);
34479
+ }
34480
+ }
34481
+ }));
34482
+ }
34483
+ return found.sort((a, b) => a.dir.localeCompare(b.dir));
34484
+ }
34299
34485
  // src/flow/default-tasks.ts
34300
34486
  var DEFAULT_TASKS = [
34301
34487
  { id: "T1", title: "Collect remaining context", kind: "context", origin: "scaffold" },
@@ -34307,14 +34493,14 @@ var DEFAULT_TASKS = [
34307
34493
  // src/flow/confirm-token.ts
34308
34494
  init_fs();
34309
34495
  import { createHash as createHash10, randomBytes as randomBytes4 } from "crypto";
34310
- import { readFile as readFile31 } from "fs/promises";
34311
- import path67 from "path";
34496
+ import { readFile as readFile32 } from "fs/promises";
34497
+ import path70 from "path";
34312
34498
  var CONFIRMATION_TOKEN_TTL_MS = 10 * 60000;
34313
34499
  var CONFIRMATION_CAVEAT = "The token proves an interactive confirmation step ran outside the agent's tool roster, within its TTL, " + "for this criteria checksum \u2014 not that a human ran it, and not who.";
34314
34500
  var CONFIRM_TOKEN_FILE = "confirm-token.json";
34315
34501
  var TOKEN_REF_LENGTH = 12;
34316
34502
  function confirmTokenPath(cwd, dir) {
34317
- return path67.join(flowsRoot(cwd), dir, CONFIRM_TOKEN_FILE);
34503
+ return path70.join(flowsRoot(cwd), dir, CONFIRM_TOKEN_FILE);
34318
34504
  }
34319
34505
  function completionTarget(input) {
34320
34506
  return input.merged ? "merged" : `pr:${input.prUrl ?? "none"}`;
@@ -34366,7 +34552,7 @@ async function checkConfirmationToken(cwd, dir, binding, token, now) {
34366
34552
  }
34367
34553
  let raw;
34368
34554
  try {
34369
- raw = JSON.parse(await readFile31(confirmTokenPath(cwd, dir), "utf8"));
34555
+ raw = JSON.parse(await readFile32(confirmTokenPath(cwd, dir), "utf8"));
34370
34556
  } catch (error) {
34371
34557
  return { ok: false, reason: isNotFound(error) ? "token_not_minted" : "token_unreadable" };
34372
34558
  }
@@ -34429,7 +34615,7 @@ function describeConfirmationFailure(reason, flowId) {
34429
34615
  }
34430
34616
  async function readRequireConfirmationDefault(cwd) {
34431
34617
  try {
34432
- const parsed = JSON.parse(await readFile31(path67.join(cwd, REVIEW_GATE_CONFIG_PATH), "utf8"));
34618
+ const parsed = JSON.parse(await readFile32(path70.join(cwd, REVIEW_GATE_CONFIG_PATH), "utf8"));
34433
34619
  if (typeof parsed !== "object" || parsed === null)
34434
34620
  return false;
34435
34621
  const completion = parsed["completion"];
@@ -34553,7 +34739,7 @@ async function githubPostReview(url, event, body) {
34553
34739
  }
34554
34740
  }
34555
34741
  // src/flow/uncommitted-state.ts
34556
- import path68 from "path";
34742
+ import path71 from "path";
34557
34743
  var UNCOMMITTED_LIST_CAP = 5;
34558
34744
  var READ_ONLY_GIT_FLAGS = ["--no-optional-locks"];
34559
34745
  var GIT_TIMEOUT_MS2 = 5000;
@@ -34630,7 +34816,7 @@ async function readGit(cwd, scope, git) {
34630
34816
  }
34631
34817
  async function uncommittedFlowStateNote(cwd, flowId, dir, git = spawnGit) {
34632
34818
  try {
34633
- const read = await readGit(cwd, path68.join(flowsRoot(cwd), dir), git);
34819
+ const read = await readGit(cwd, path71.join(flowsRoot(cwd), dir), git);
34634
34820
  return read === null ? null : noteFor(flowId, dir, read);
34635
34821
  } catch {
34636
34822
  return null;
@@ -34835,8 +35021,8 @@ function readAcKindRecords(value) {
34835
35021
  return out;
34836
35022
  }
34837
35023
  // src/flow/description-intent.ts
34838
- import { readFile as readFile32 } from "fs/promises";
34839
- import path69 from "path";
35024
+ import { readFile as readFile33 } from "fs/promises";
35025
+ import path72 from "path";
34840
35026
  var OUTCOME_HINT = 'State an outcome criterion: what you would look at afterwards to see this helped, as a bullet. Or write "- not measured \u2014 <reason>".';
34841
35027
  var PLACEHOLDERS = ["Describe the problem precisely", "What must be true when this flow is done"];
34842
35028
  var FLOW_STATEMENT_HEADINGS = [/^problem$/i, /^expected outcome$/i];
@@ -34949,7 +35135,7 @@ function initIntentNote(description) {
34949
35135
  }
34950
35136
  async function intentNoteForNewFlow(cwd, dir) {
34951
35137
  try {
34952
- return initIntentNote(await readFile32(path69.join(cwd, dir, "description.md"), "utf8"));
35138
+ return initIntentNote(await readFile33(path72.join(cwd, dir, "description.md"), "utf8"));
34953
35139
  } catch {
34954
35140
  return null;
34955
35141
  }
@@ -34958,8 +35144,8 @@ async function intentNoteForNewFlow(cwd, dir) {
34958
35144
  init_service2();
34959
35145
  init_fs();
34960
35146
  import { createHash as createHash11 } from "crypto";
34961
- import { chmod as chmod4, mkdir as mkdir10, readFile as readFile33 } from "fs/promises";
34962
- import path70 from "path";
35147
+ import { chmod as chmod4, mkdir as mkdir11, readFile as readFile34 } from "fs/promises";
35148
+ import path73 from "path";
34963
35149
  var AC_LINE2 = /^\s*[-*]\s*(AC\d+)\s*:\s?(.*)$/i;
34964
35150
  function parseAcceptanceCriteria(content) {
34965
35151
  const out = [];
@@ -35138,7 +35324,7 @@ function factsOnlyVerdict(item) {
35138
35324
  }
35139
35325
  async function readAcCheckEnabled(cwd) {
35140
35326
  try {
35141
- const parsed = JSON.parse(await readFile33(path70.join(cwd, REVIEW_GATE_CONFIG_PATH), "utf8"));
35327
+ const parsed = JSON.parse(await readFile34(path73.join(cwd, REVIEW_GATE_CONFIG_PATH), "utf8"));
35142
35328
  if (typeof parsed !== "object" || parsed === null)
35143
35329
  return false;
35144
35330
  const review = parsed["review"];
@@ -35159,19 +35345,19 @@ function acCheckCacheKey(criteriaChecksum, diffText) {
35159
35345
  return `${criteriaChecksum}:${hashDiff(diffText)}`;
35160
35346
  }
35161
35347
  function acCheckCachePath(cwd, flowDir) {
35162
- return path70.join(cwd, ".metaproject", "data", "ac-check", `${flowDir}.json`);
35348
+ return path73.join(cwd, ".metaproject", "data", "ac-check", `${flowDir}.json`);
35163
35349
  }
35164
35350
  async function readAcCheckCache(cachePath) {
35165
35351
  if (!await pathExists(cachePath))
35166
35352
  return;
35167
35353
  try {
35168
- return JSON.parse(await readFile33(cachePath, "utf8"));
35354
+ return JSON.parse(await readFile34(cachePath, "utf8"));
35169
35355
  } catch {
35170
35356
  return;
35171
35357
  }
35172
35358
  }
35173
35359
  async function writeAcCheckCache(cachePath, record) {
35174
- await mkdir10(path70.dirname(cachePath), { recursive: true });
35360
+ await mkdir11(path73.dirname(cachePath), { recursive: true });
35175
35361
  await writeFileAtomic(cachePath, `${JSON.stringify(record, null, 2)}
35176
35362
  `, { mode: 384 });
35177
35363
  if (process.platform !== "win32") {
@@ -35227,105 +35413,8 @@ function renderAcCheckAdvisoryNotice(verdicts) {
35227
35413
  const inDoubt = verdicts.filter((v) => v.status === "not-evident").map((v) => v.id);
35228
35414
  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)`;
35229
35415
  }
35230
- // src/flow/allocation.ts
35231
- import { appendFile as appendFile3, mkdir as mkdir11, readFile as readFile34 } from "fs/promises";
35232
- import path72 from "path";
35233
-
35234
- // src/lib/clone-scope.ts
35235
- import path71 from "path";
35236
- async function gitCommonDir(cwd) {
35237
- try {
35238
- const proc = Bun.spawn(["git", "rev-parse", "--git-common-dir"], {
35239
- cwd,
35240
- stdout: "pipe",
35241
- stderr: "ignore"
35242
- });
35243
- const output = (await new Response(proc.stdout).text()).trim();
35244
- if (await proc.exited !== 0 || output.length === 0) {
35245
- return null;
35246
- }
35247
- return path71.isAbsolute(output) ? output : path71.resolve(cwd, output);
35248
- } catch {
35249
- return null;
35250
- }
35251
- }
35252
- async function gitToplevel(cwd, env) {
35253
- try {
35254
- const proc = Bun.spawn(["git", "rev-parse", "--show-toplevel"], {
35255
- cwd,
35256
- ...env === undefined ? {} : { env },
35257
- stdout: "pipe",
35258
- stderr: "ignore"
35259
- });
35260
- const output = (await new Response(proc.stdout).text()).trim();
35261
- return await proc.exited === 0 && output.length > 0 ? output : null;
35262
- } catch {
35263
- return null;
35264
- }
35265
- }
35266
-
35267
- // src/flow/allocation.ts
35268
- init_fs();
35269
- function projectKey(toplevel, cwd) {
35270
- if (!toplevel) {
35271
- return "root";
35272
- }
35273
- const relative = path72.relative(toplevel, cwd);
35274
- return relative === "" ? "root" : slugify(relative);
35275
- }
35276
- async function resolveAllocationScope(cwd) {
35277
- const commonDir = await gitCommonDir(cwd);
35278
- if (!commonDir) {
35279
- return {
35280
- lockPath: path72.join(flowsRoot(cwd), ".flow-init.lock"),
35281
- ledgerPath: null,
35282
- project: "root"
35283
- };
35284
- }
35285
- const key = projectKey(await gitToplevel(cwd), cwd);
35286
- const dir = path72.join(commonDir, "keryx", "flow-ids");
35287
- return {
35288
- lockPath: path72.join(dir, `${key}.lock`),
35289
- ledgerPath: path72.join(dir, `${key}.jsonl`),
35290
- project: key
35291
- };
35292
- }
35293
- async function readAllocationLedger(scope) {
35294
- if (!scope.ledgerPath || !await pathExists(scope.ledgerPath)) {
35295
- return [];
35296
- }
35297
- const content = await readFile34(scope.ledgerPath, "utf8");
35298
- const records = [];
35299
- for (const line of content.split(`
35300
- `)) {
35301
- const trimmed = line.trim();
35302
- if (trimmed.length === 0) {
35303
- continue;
35304
- }
35305
- try {
35306
- const parsed = JSON.parse(trimmed);
35307
- if (typeof parsed.id === "string") {
35308
- records.push(parsed);
35309
- }
35310
- } catch {}
35311
- }
35312
- return records;
35313
- }
35314
- async function reservedIds(scope) {
35315
- const records = await readAllocationLedger(scope);
35316
- return records.map((record) => Number(record.id)).filter((value) => !Number.isNaN(value));
35317
- }
35318
- async function recordAllocation(scope, record) {
35319
- if (!scope.ledgerPath) {
35320
- return;
35321
- }
35322
- await mkdir11(path72.dirname(scope.ledgerPath), { recursive: true });
35323
- await appendFile3(scope.ledgerPath, `${JSON.stringify(record)}
35324
- `, "utf8");
35325
- }
35326
-
35327
35416
  // src/flow/remote-flows.ts
35328
- import path73 from "path";
35417
+ import path74 from "path";
35329
35418
  var MAX_REFS = 500;
35330
35419
  var CONCURRENCY = 8;
35331
35420
  async function runGit2(cwd, args) {
@@ -35406,7 +35495,7 @@ async function flowDirsOnRef(cwd, ref, flowsPath) {
35406
35495
  if (result === undefined || result.code !== 0) {
35407
35496
  return [];
35408
35497
  }
35409
- return nulSplit(result.stdout).map((entry) => path73.posix.basename(entry)).filter((name) => /^\d{3}-/.test(name));
35498
+ return nulSplit(result.stdout).map((entry) => path74.posix.basename(entry)).filter((name) => /^\d{3}-/.test(name));
35410
35499
  }
35411
35500
  async function knownRemoteFlowDirs(cwd) {
35412
35501
  try {
@@ -35586,12 +35675,12 @@ function renderJournal(createdAt) {
35586
35675
 
35587
35676
  // src/flow/task-project-context.ts
35588
35677
  import { readFile as readFile38 } from "fs/promises";
35589
- import path77 from "path";
35678
+ import path78 from "path";
35590
35679
 
35591
35680
  // src/gdskills/project-context-config.ts
35592
35681
  init_fs();
35593
35682
  import { readFile as readFile35 } from "fs/promises";
35594
- import path74 from "path";
35683
+ import path75 from "path";
35595
35684
  var PROJECT_CONTEXT_CONFIG_PATH = ".metaproject/tasks.config.json";
35596
35685
  var DEFAULT_MAX_BYTES = 131072;
35597
35686
  var MAX_BYTES_FLOOR = 4096;
@@ -35601,7 +35690,7 @@ function isValidMaxBytes(value) {
35601
35690
  }
35602
35691
  async function readRoot(projectRoot) {
35603
35692
  try {
35604
- const parsed = JSON.parse(await readFile35(path74.join(projectRoot, PROJECT_CONTEXT_CONFIG_PATH), "utf8"));
35693
+ const parsed = JSON.parse(await readFile35(path75.join(projectRoot, PROJECT_CONTEXT_CONFIG_PATH), "utf8"));
35605
35694
  return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : undefined;
35606
35695
  } catch {
35607
35696
  return;
@@ -35645,7 +35734,7 @@ async function readProjectContextConfig(projectRoot) {
35645
35734
 
35646
35735
  // src/gdskills/resolved-context-check.ts
35647
35736
  import { readFile as readFile37 } from "fs/promises";
35648
- import path76 from "path";
35737
+ import path77 from "path";
35649
35738
 
35650
35739
  // src/gdskills/project-rules.ts
35651
35740
  import { createHash as createHash12 } from "crypto";
@@ -35658,7 +35747,7 @@ function sha256Hex(content) {
35658
35747
 
35659
35748
  // src/gdskills/reference-proof.ts
35660
35749
  import { readFile as readFile36 } from "fs/promises";
35661
- import path75 from "path";
35750
+ import path76 from "path";
35662
35751
 
35663
35752
  // src/gdskills/references-section.ts
35664
35753
  var FENCE = /^ {0,3}(`{3,}|~{3,})/;
@@ -35764,7 +35853,7 @@ function pickProofItem(items, pinned) {
35764
35853
  return items.find((item) => item.sha256 === pinned && item.how !== "n/a") ?? items.find((item) => item.how !== "n/a") ?? items[0];
35765
35854
  }
35766
35855
  async function currentSection(projectRoot, entry) {
35767
- const file = path75.isAbsolute(entry.path) ? entry.path : path75.join(projectRoot, entry.path);
35856
+ const file = path76.isAbsolute(entry.path) ? entry.path : path76.join(projectRoot, entry.path);
35768
35857
  let text;
35769
35858
  try {
35770
35859
  text = await readFile36(file, "utf8");
@@ -35856,7 +35945,7 @@ function appliedOf(result) {
35856
35945
  }
35857
35946
  async function currentSha(projectRoot, entryPath) {
35858
35947
  try {
35859
- return sha256Hex(await readFile37(path76.isAbsolute(entryPath) ? entryPath : path76.join(projectRoot, entryPath), "utf8"));
35948
+ return sha256Hex(await readFile37(path77.isAbsolute(entryPath) ? entryPath : path77.join(projectRoot, entryPath), "utf8"));
35860
35949
  } catch {
35861
35950
  return;
35862
35951
  }
@@ -35935,8 +36024,8 @@ async function checkTaskProjectContext(input) {
35935
36024
  }
35936
36025
  const report = await checkResolvedContext({
35937
36026
  projectRoot: input.projectRoot,
35938
- resolved: await readResolvedFile(path77.resolve(input.projectRoot, input.resolvedFile)),
35939
- result: await readResultFile(path77.resolve(input.projectRoot, input.resultFile))
36027
+ resolved: await readResolvedFile(path78.resolve(input.projectRoot, input.resolvedFile)),
36028
+ result: await readResultFile(path78.resolve(input.projectRoot, input.resultFile))
35940
36029
  });
35941
36030
  const lines = formatResolvedReport(report);
35942
36031
  if (lines.length === 0)
@@ -36243,6 +36332,21 @@ function createFlowService(deps) {
36243
36332
  const title = input.title ?? context.issueTitle ?? provisionalTitle;
36244
36333
  const scope = await resolveAllocationScope(input.cwd);
36245
36334
  return withFileLock(scope.lockPath, async () => {
36335
+ const source = input.issue && issueSourceUrl(input.issue);
36336
+ if (source && !input.separateIssueFlow) {
36337
+ const existing = await findIssueFlows(input.cwd, new Set([source]));
36338
+ if (existing.length > 1)
36339
+ throw new Error("Several Flows match this issue. Select a package in Issues, or use --new for separate work.");
36340
+ if (existing[0]) {
36341
+ const { flow, dir, cwd } = existing[0];
36342
+ return {
36343
+ flow,
36344
+ dir: path79.relative(input.cwd, path79.join(flowsRoot(cwd), dir)),
36345
+ existingCwd: cwd,
36346
+ contextNotes: ["Existing Flow for this issue. Use --new only to create separate work."]
36347
+ };
36348
+ }
36349
+ }
36246
36350
  const id = await nextFlowId(input.cwd, [
36247
36351
  ...await reservedIds(scope),
36248
36352
  ...await remoteFlowNumbers(input.cwd)
@@ -36250,12 +36354,21 @@ function createFlowService(deps) {
36250
36354
  const date = now().slice(0, 10);
36251
36355
  const slug = slugify(input.slug ?? title);
36252
36356
  const dir = `${id}-${date}-${slug}`;
36253
- const absolute = path78.join(flowsRoot(input.cwd), dir);
36357
+ const absolute = path79.join(flowsRoot(input.cwd), dir);
36254
36358
  if (await pathExists(absolute)) {
36255
36359
  throw new Error(`Flow directory already exists: ${dir}`);
36256
36360
  }
36257
- await mkdir12(absolute, { recursive: true });
36258
36361
  const createdAt = now();
36362
+ const allocation = {
36363
+ id,
36364
+ dir,
36365
+ at: createdAt,
36366
+ project: scope.project,
36367
+ ...source ? { issue: source, cwd: path79.resolve(input.cwd) } : {}
36368
+ };
36369
+ if (source)
36370
+ await recordAllocation(scope, allocation);
36371
+ await mkdir12(absolute, { recursive: true });
36259
36372
  const flow = {
36260
36373
  schemaVersion: 1,
36261
36374
  gates: {
@@ -36286,17 +36399,18 @@ function createFlowService(deps) {
36286
36399
  history: [{ at: createdAt, event: "created" }]
36287
36400
  };
36288
36401
  const sourceLabel = input.issue ?? "user description";
36289
- await writeFileAtomic(path78.join(absolute, "description.md"), renderDescription(title, originDraft === undefined ? sourceLabel : `${sourceLabel} (origin: ${originDraft.kind})`, originDraft));
36290
- await writeFileAtomic(path78.join(absolute, "context.md"), context.markdown);
36291
- await writeFileAtomic(path78.join(absolute, "plan.md"), renderPlan());
36292
- await writeFileAtomic(path78.join(absolute, "tasks.md"), renderTasksDoc());
36293
- await writeFileAtomic(path78.join(absolute, "acceptance-criteria.md"), renderAcceptanceCriteria());
36294
- await writeFileAtomic(path78.join(absolute, "journal.md"), renderJournal(createdAt));
36402
+ await writeFileAtomic(path79.join(absolute, "description.md"), renderDescription(title, originDraft === undefined ? sourceLabel : `${sourceLabel} (origin: ${originDraft.kind})`, originDraft));
36403
+ await writeFileAtomic(path79.join(absolute, "context.md"), context.markdown);
36404
+ await writeFileAtomic(path79.join(absolute, "plan.md"), renderPlan());
36405
+ await writeFileAtomic(path79.join(absolute, "tasks.md"), renderTasksDoc());
36406
+ await writeFileAtomic(path79.join(absolute, "acceptance-criteria.md"), renderAcceptanceCriteria());
36407
+ await writeFileAtomic(path79.join(absolute, "journal.md"), renderJournal(createdAt));
36295
36408
  await writeFlow(input.cwd, dir, flow);
36296
- await recordAllocation(scope, { id, dir, at: createdAt, project: scope.project });
36409
+ if (!source)
36410
+ await recordAllocation(scope, allocation);
36297
36411
  return {
36298
36412
  flow,
36299
- dir: path78.relative(input.cwd, absolute),
36413
+ dir: path79.relative(input.cwd, absolute),
36300
36414
  contextNotes: context.notes,
36301
36415
  ...originNote === undefined ? {} : { originNote }
36302
36416
  };
@@ -37014,7 +37128,7 @@ function createFlowService(deps) {
37014
37128
  issues.push({ flow: dir, kind: "schema", message: `unknown schemaVersion ${flow.schemaVersion}` });
37015
37129
  }
37016
37130
  try {
37017
- const raw = JSON.parse(await Bun.file(path78.join(flowsRoot(cwd), dir, "flow.json")).text());
37131
+ const raw = JSON.parse(await Bun.file(path79.join(flowsRoot(cwd), dir, "flow.json")).text());
37018
37132
  const validation = validateAgainstSchemaObject(flowStateSchema(), raw);
37019
37133
  if (!validation.valid) {
37020
37134
  issues.push({
@@ -37025,7 +37139,7 @@ function createFlowService(deps) {
37025
37139
  }
37026
37140
  } catch {}
37027
37141
  for (const file of ["description.md", "context.md", "plan.md", "tasks.md", "acceptance-criteria.md", "journal.md"]) {
37028
- if (!await pathExists(path78.join(flowsRoot(cwd), dir, file))) {
37142
+ if (!await pathExists(path79.join(flowsRoot(cwd), dir, file))) {
37029
37143
  issues.push({ flow: dir, kind: "structure", message: `missing ${file}` });
37030
37144
  }
37031
37145
  }
@@ -37064,7 +37178,7 @@ function createFlowService(deps) {
37064
37178
  };
37065
37179
  }
37066
37180
  async function appendIdMap(cwd, entry) {
37067
- const file = path78.join(flowsRoot(cwd), "id-map.json");
37181
+ const file = path79.join(flowsRoot(cwd), "id-map.json");
37068
37182
  let entries = [];
37069
37183
  if (await pathExists(file)) {
37070
37184
  const raw = await readFile39(file, "utf8");
@@ -37075,7 +37189,7 @@ async function appendIdMap(cwd, entry) {
37075
37189
  }
37076
37190
  entries = parsed;
37077
37191
  } catch (error) {
37078
- throw new Error(`Cannot read ${path78.relative(cwd, file)}: ${error instanceof Error ? error.message : String(error)}`);
37192
+ throw new Error(`Cannot read ${path79.relative(cwd, file)}: ${error instanceof Error ? error.message : String(error)}`);
37079
37193
  }
37080
37194
  }
37081
37195
  entries.push(entry);
@@ -37364,7 +37478,7 @@ async function acCriterionKnown(input) {
37364
37478
  init_data_dir();
37365
37479
  import { mkdir as mkdir22, readdir as readdir18, readFile as readFile51, writeFile as writeFile16 } from "fs/promises";
37366
37480
  import { existsSync as existsSync11 } from "fs";
37367
- import path103 from "path";
37481
+ import path104 from "path";
37368
37482
 
37369
37483
  // src/gdgraph/types.ts
37370
37484
  var UNKNOWN_IMPORT_KIND = "unknown-static";
@@ -37431,7 +37545,7 @@ async function buildGraph(projectRoot, options = {}) {
37431
37545
  const assetNodes = new Map;
37432
37546
  const fileRecords = [];
37433
37547
  for (const file of files) {
37434
- const absolutePath = path103.join(projectRoot, file);
37548
+ const absolutePath = path104.join(projectRoot, file);
37435
37549
  const content = await readFile51(absolutePath, "utf8");
37436
37550
  fileRecords.push({ path: file, content });
37437
37551
  const language = getLanguage(file);
@@ -37484,24 +37598,24 @@ async function collectSourceFiles(projectRoot) {
37484
37598
  const result = [];
37485
37599
  const skippedDirectories = [];
37486
37600
  async function walk(relativeDir) {
37487
- const absoluteDir = path103.join(projectRoot, relativeDir);
37601
+ const absoluteDir = path104.join(projectRoot, relativeDir);
37488
37602
  const entries = await readdir18(absoluteDir, { withFileTypes: true });
37489
37603
  for (const entry of entries) {
37490
37604
  if (entry.isDirectory()) {
37491
37605
  if (IGNORE_DIRS.has(entry.name)) {
37492
- skippedDirectories.push(normalizePath3(path103.posix.join(relativeDir, entry.name)).replace(/^\.\//, ""));
37606
+ skippedDirectories.push(normalizePath3(path104.posix.join(relativeDir, entry.name)).replace(/^\.\//, ""));
37493
37607
  continue;
37494
37608
  }
37495
- await walk(normalizePath3(path103.posix.join(relativeDir, entry.name)));
37609
+ await walk(normalizePath3(path104.posix.join(relativeDir, entry.name)));
37496
37610
  continue;
37497
37611
  }
37498
37612
  if (!entry.isFile()) {
37499
37613
  continue;
37500
37614
  }
37501
- if (!SOURCE_EXTENSIONS.includes(path103.extname(entry.name))) {
37615
+ if (!SOURCE_EXTENSIONS.includes(path104.extname(entry.name))) {
37502
37616
  continue;
37503
37617
  }
37504
- result.push(normalizePath3(path103.posix.join(relativeDir, entry.name)).replace(/^\.\//, ""));
37618
+ result.push(normalizePath3(path104.posix.join(relativeDir, entry.name)).replace(/^\.\//, ""));
37505
37619
  }
37506
37620
  }
37507
37621
  await walk(".");
@@ -37583,8 +37697,8 @@ function resolveImport(projectRoot, fromFile, specifier, fileSet, resolver) {
37583
37697
  }
37584
37698
  function resolveAssetImport(projectRoot, fromFile, specifier, resolver) {
37585
37699
  for (const candidate of importCandidateBases(projectRoot, fromFile, specifier, resolver)) {
37586
- const extension = path103.posix.extname(candidate);
37587
- if (ASSET_EXTENSIONS.includes(extension) && existsSync11(path103.join(projectRoot, candidate))) {
37700
+ const extension = path104.posix.extname(candidate);
37701
+ if (ASSET_EXTENSIONS.includes(extension) && existsSync11(path104.join(projectRoot, candidate))) {
37588
37702
  return candidate;
37589
37703
  }
37590
37704
  }
@@ -37593,17 +37707,17 @@ function resolveAssetImport(projectRoot, fromFile, specifier, resolver) {
37593
37707
  function importCandidateBases(projectRoot, fromFile, specifier, resolver) {
37594
37708
  const normalizedSpecifier = stripImportSuffix(specifier);
37595
37709
  if (normalizedSpecifier.startsWith(".") && getLanguage(fromFile) !== "python") {
37596
- const fromDir = path103.posix.dirname(fromFile);
37597
- return [normalizePath3(path103.posix.normalize(path103.posix.join(fromDir, normalizedSpecifier)))];
37710
+ const fromDir = path104.posix.dirname(fromFile);
37711
+ return [normalizePath3(path104.posix.normalize(path104.posix.join(fromDir, normalizedSpecifier)))];
37598
37712
  }
37599
- return resolver.candidateBases(normalizedSpecifier, fromFile).map((candidate) => normalizePath3(path103.relative(projectRoot, path103.join(projectRoot, candidate))));
37713
+ return resolver.candidateBases(normalizedSpecifier, fromFile).map((candidate) => normalizePath3(path104.relative(projectRoot, path104.join(projectRoot, candidate))));
37600
37714
  }
37601
37715
  function resolveSourceCandidate(base, fileSet) {
37602
37716
  const candidates = [
37603
37717
  base,
37604
37718
  ...SOURCE_RESOLUTION_EXTENSIONS.map((extension) => `${base}${extension}`),
37605
- ...SOURCE_RESOLUTION_EXTENSIONS.map((extension) => path103.posix.join(base, `index${extension}`)),
37606
- path103.posix.join(base, "__init__.py")
37719
+ ...SOURCE_RESOLUTION_EXTENSIONS.map((extension) => path104.posix.join(base, `index${extension}`)),
37720
+ path104.posix.join(base, "__init__.py")
37607
37721
  ];
37608
37722
  return candidates.find((candidate) => fileSet.has(candidate)) ?? null;
37609
37723
  }
@@ -37633,7 +37747,7 @@ async function loadJavaResolver(projectRoot) {
37633
37747
  return createJavaResolver(roots);
37634
37748
  }
37635
37749
  async function discoverJavaSourceRoots(projectRoot) {
37636
- const pomPath = path103.join(projectRoot, "pom.xml");
37750
+ const pomPath = path104.join(projectRoot, "pom.xml");
37637
37751
  if (existsSync11(pomPath)) {
37638
37752
  try {
37639
37753
  const roots = parseMavenSourceRoots(await readFile51(pomPath, "utf8"));
@@ -37643,7 +37757,7 @@ async function discoverJavaSourceRoots(projectRoot) {
37643
37757
  } catch {}
37644
37758
  }
37645
37759
  for (const gradleName of ["build.gradle", "build.gradle.kts"]) {
37646
- const gradlePath = path103.join(projectRoot, gradleName);
37760
+ const gradlePath = path104.join(projectRoot, gradleName);
37647
37761
  if (existsSync11(gradlePath)) {
37648
37762
  try {
37649
37763
  const roots = parseGradleSourceRoots(await readFile51(gradlePath, "utf8"));
@@ -37665,12 +37779,12 @@ function createJavaResolver(sourceRoots) {
37665
37779
  return [];
37666
37780
  }
37667
37781
  const relative = specifier.split(".").join("/");
37668
- return sourceRoots.map((root) => normalizePath3(path103.posix.join(root, relative)));
37782
+ return sourceRoots.map((root) => normalizePath3(path104.posix.join(root, relative)));
37669
37783
  }
37670
37784
  };
37671
37785
  }
37672
37786
  function loadPythonResolver(projectRoot) {
37673
- const hasSrc = existsSync11(path103.join(projectRoot, "src"));
37787
+ const hasSrc = existsSync11(path104.join(projectRoot, "src"));
37674
37788
  return createPythonResolver(hasSrc);
37675
37789
  }
37676
37790
  function createPythonResolver(hasSrc) {
@@ -37683,16 +37797,16 @@ function createPythonResolver(hasSrc) {
37683
37797
  if (specifier.startsWith(".")) {
37684
37798
  const dots = /^\.+/.exec(specifier)?.[0].length ?? 0;
37685
37799
  const rest = specifier.slice(dots);
37686
- let baseDir = path103.posix.dirname(fromFile);
37800
+ let baseDir = path104.posix.dirname(fromFile);
37687
37801
  for (let level = 1;level < dots; level += 1) {
37688
- baseDir = path103.posix.dirname(baseDir);
37802
+ baseDir = path104.posix.dirname(baseDir);
37689
37803
  }
37690
37804
  const suffix = rest ? rest.split(".").join("/") : "";
37691
- const base = suffix ? path103.posix.join(baseDir, suffix) : baseDir;
37805
+ const base = suffix ? path104.posix.join(baseDir, suffix) : baseDir;
37692
37806
  return [normalizePath3(base)];
37693
37807
  }
37694
37808
  const relative = specifier.split(".").join("/");
37695
- return roots.map((root) => normalizePath3(root ? path103.posix.join(root, relative) : relative));
37809
+ return roots.map((root) => normalizePath3(root ? path104.posix.join(root, relative) : relative));
37696
37810
  }
37697
37811
  };
37698
37812
  }
@@ -37701,8 +37815,8 @@ function parseMavenSourceRoots(pomXml) {
37701
37815
  for (const match of pomXml.matchAll(/<module>\s*([^<]+?)\s*<\/module>/g)) {
37702
37816
  const moduleDir = match[1]?.trim();
37703
37817
  if (moduleDir && !moduleDir.includes("${")) {
37704
- roots.add(normalizePath3(path103.posix.join(moduleDir, "src/main/java")));
37705
- roots.add(normalizePath3(path103.posix.join(moduleDir, "src/test/java")));
37818
+ roots.add(normalizePath3(path104.posix.join(moduleDir, "src/main/java")));
37819
+ roots.add(normalizePath3(path104.posix.join(moduleDir, "src/test/java")));
37706
37820
  }
37707
37821
  }
37708
37822
  for (const tag of ["sourceDirectory", "testSourceDirectory"]) {
@@ -37735,7 +37849,7 @@ function parseGradleSourceRoots(buildGradle) {
37735
37849
  var TSCONFIG_EXTENDS_MAX_DEPTH = 10;
37736
37850
  async function loadTsconfigResolver(projectRoot) {
37737
37851
  const empty = createTsconfigResolver(null, []);
37738
- const tsconfigPath = path103.join(projectRoot, "tsconfig.json");
37852
+ const tsconfigPath = path104.join(projectRoot, "tsconfig.json");
37739
37853
  if (!existsSync11(tsconfigPath)) {
37740
37854
  return empty;
37741
37855
  }
@@ -37748,7 +37862,7 @@ async function loadTsconfigResolver(projectRoot) {
37748
37862
  return createTsconfigResolver(resolved.baseUrl, paths);
37749
37863
  }
37750
37864
  function toProjectRelativeDir(projectRoot, absoluteDir) {
37751
- const relative = normalizePath3(path103.relative(projectRoot, absoluteDir)).replace(/^\.\//, "");
37865
+ const relative = normalizePath3(path104.relative(projectRoot, absoluteDir)).replace(/^\.\//, "");
37752
37866
  return relative === "." ? "" : relative;
37753
37867
  }
37754
37868
  async function readTsconfigJson(configPath) {
@@ -37763,11 +37877,11 @@ function resolveTsconfigExtendsPath(configDir, extendsSpecifier) {
37763
37877
  if (!extendsSpecifier.startsWith(".") && !extendsSpecifier.startsWith("/")) {
37764
37878
  return null;
37765
37879
  }
37766
- const resolved = path103.resolve(configDir, extendsSpecifier);
37880
+ const resolved = path104.resolve(configDir, extendsSpecifier);
37767
37881
  return resolved.endsWith(".json") ? resolved : `${resolved}.json`;
37768
37882
  }
37769
37883
  async function resolveTsconfigOptions(configPath, visited, depth, projectRoot) {
37770
- const resolvedPath = path103.resolve(configPath);
37884
+ const resolvedPath = path104.resolve(configPath);
37771
37885
  if (depth > TSCONFIG_EXTENDS_MAX_DEPTH || visited.has(resolvedPath)) {
37772
37886
  return null;
37773
37887
  }
@@ -37778,15 +37892,15 @@ async function resolveTsconfigOptions(configPath, visited, depth, projectRoot) {
37778
37892
  }
37779
37893
  let inherited = null;
37780
37894
  if (typeof parsed.extends === "string") {
37781
- const basePath = resolveTsconfigExtendsPath(path103.dirname(resolvedPath), parsed.extends);
37895
+ const basePath = resolveTsconfigExtendsPath(path104.dirname(resolvedPath), parsed.extends);
37782
37896
  if (basePath) {
37783
37897
  inherited = await resolveTsconfigOptions(basePath, visited, depth + 1, projectRoot);
37784
37898
  }
37785
37899
  }
37786
- const configDir = path103.dirname(resolvedPath);
37900
+ const configDir = path104.dirname(resolvedPath);
37787
37901
  const declaringDir = toProjectRelativeDir(projectRoot, configDir);
37788
37902
  const options = parsed.compilerOptions ?? {};
37789
- const ownBaseUrl = typeof options.baseUrl === "string" ? toProjectRelativeDir(projectRoot, path103.resolve(configDir, options.baseUrl)) : null;
37903
+ const ownBaseUrl = typeof options.baseUrl === "string" ? toProjectRelativeDir(projectRoot, path104.resolve(configDir, options.baseUrl)) : null;
37790
37904
  const baseUrl = ownBaseUrl ?? inherited?.baseUrl ?? null;
37791
37905
  const ownPaths = isRecord5(options.paths) ? Object.entries(options.paths).filter((entry) => Array.isArray(entry[1])).map(([pattern, targets]) => ({
37792
37906
  pattern,
@@ -37815,7 +37929,7 @@ function createTsconfigResolver(baseUrl, mappings) {
37815
37929
  }
37816
37930
  }
37817
37931
  if (baseUrl !== null) {
37818
- candidates.push(normalizePath3(path103.posix.join(baseUrl, normalizedSpecifier)));
37932
+ candidates.push(normalizePath3(path104.posix.join(baseUrl, normalizedSpecifier)));
37819
37933
  }
37820
37934
  return [...new Set(candidates.map((candidate) => candidate.replace(/^\.\//, "")))];
37821
37935
  }
@@ -37835,7 +37949,7 @@ function matchPathPattern(pattern, specifier) {
37835
37949
  }
37836
37950
  function applyPathTarget(base, target, wildcard) {
37837
37951
  const replaced = target.includes("*") ? target.replace("*", wildcard) : target;
37838
- return normalizePath3(path103.posix.normalize(path103.posix.join(base, replaced)));
37952
+ return normalizePath3(path104.posix.normalize(path104.posix.join(base, replaced)));
37839
37953
  }
37840
37954
  function stripJsonComments(source) {
37841
37955
  let out = "";
@@ -37892,13 +38006,13 @@ async function writeGraph(projectRoot, graph, dataDir) {
37892
38006
  const artifactsDir = gdgraphArtifactsDir(projectRoot, dataDir);
37893
38007
  await mkdir22(storageDir, { recursive: true });
37894
38008
  await mkdir22(artifactsDir, { recursive: true });
37895
- await writeFile16(path103.join(storageDir, "nodes.jsonl"), graph.nodes.map((node) => JSON.stringify(node)).join(`
38009
+ await writeFile16(path104.join(storageDir, "nodes.jsonl"), graph.nodes.map((node) => JSON.stringify(node)).join(`
37896
38010
  `) + `
37897
38011
  `, "utf8");
37898
- await writeFile16(path103.join(storageDir, "edges.jsonl"), graph.edges.map((edge) => JSON.stringify(edge)).join(`
38012
+ await writeFile16(path104.join(storageDir, "edges.jsonl"), graph.edges.map((edge) => JSON.stringify(edge)).join(`
37899
38013
  `) + `
37900
38014
  `, "utf8");
37901
- await writeFile16(path103.join(artifactsDir, "module-map.json"), JSON.stringify(buildModuleMap(graph), null, 2) + `
38015
+ await writeFile16(path104.join(artifactsDir, "module-map.json"), JSON.stringify(buildModuleMap(graph), null, 2) + `
37902
38016
  `, "utf8");
37903
38017
  }
37904
38018
  async function writeSummary(projectRoot, graph, collection, dataDir) {
@@ -37917,7 +38031,7 @@ async function writeSummary(projectRoot, graph, collection, dataDir) {
37917
38031
  `);
37918
38032
  const skippedList = collection.skippedDirectories.length > 0 ? collection.skippedDirectories.slice(0, 30).map((dir) => `- \`${dir}\``).join(`
37919
38033
  `) : "- none";
37920
- const summaryPath = path103.join(artifactsDir, "summary.md");
38034
+ const summaryPath = path104.join(artifactsDir, "summary.md");
37921
38035
  const content = `# gdgraph Summary
37922
38036
 
37923
38037
  ## Stats
@@ -37998,7 +38112,7 @@ function groupBy(items, getKey) {
37998
38112
  }
37999
38113
  function unresolvedType(specifier) {
38000
38114
  const stripped = stripImportSuffix(specifier);
38001
- const extension = path103.posix.extname(stripped);
38115
+ const extension = path104.posix.extname(stripped);
38002
38116
  if (extension) {
38003
38117
  return extension;
38004
38118
  }
@@ -38008,7 +38122,7 @@ function unresolvedType(specifier) {
38008
38122
  return "package";
38009
38123
  }
38010
38124
  function normalizePath3(value) {
38011
- return value.split(path103.sep).join("/");
38125
+ return value.split(path104.sep).join("/");
38012
38126
  }
38013
38127
 
38014
38128
  // src/gdgraph/service.ts
@@ -38017,17 +38131,17 @@ init_config3();
38017
38131
 
38018
38132
  // src/gdgraph/query.ts
38019
38133
  import { readFile as readFile52 } from "fs/promises";
38020
- import path104 from "path";
38134
+ import path105 from "path";
38021
38135
  init_data_dir();
38022
38136
  init_target();
38023
38137
  async function loadGraph(projectRoot, dataDir) {
38024
38138
  const storageDir = gdgraphStorageDir(projectRoot, dataDir);
38025
- const nodes = await readJsonl(path104.join(storageDir, "nodes.jsonl"));
38026
- const edges = await readJsonl(path104.join(storageDir, "edges.jsonl"));
38027
- const symbols = await readJsonl(path104.join(storageDir, "symbols.jsonl"));
38028
- const calls = await readJsonl(path104.join(storageDir, "calls.jsonl"));
38029
- const wikiPages = await readJsonl(path104.join(storageDir, "wiki-pages.jsonl"));
38030
- const describes = await readJsonl(path104.join(storageDir, "describes.jsonl"));
38139
+ const nodes = await readJsonl(path105.join(storageDir, "nodes.jsonl"));
38140
+ const edges = await readJsonl(path105.join(storageDir, "edges.jsonl"));
38141
+ const symbols = await readJsonl(path105.join(storageDir, "symbols.jsonl"));
38142
+ const calls = await readJsonl(path105.join(storageDir, "calls.jsonl"));
38143
+ const wikiPages = await readJsonl(path105.join(storageDir, "wiki-pages.jsonl"));
38144
+ const describes = await readJsonl(path105.join(storageDir, "describes.jsonl"));
38031
38145
  const graph = { nodes, edges };
38032
38146
  if (symbols.length > 0) {
38033
38147
  graph.symbols = symbols;
@@ -38087,7 +38201,7 @@ async function bunfigPreloadRoots(projectRoot) {
38087
38201
  const roots = new Set;
38088
38202
  let text;
38089
38203
  try {
38090
- text = await readFile52(path104.join(projectRoot, "bunfig.toml"), "utf8");
38204
+ text = await readFile52(path105.join(projectRoot, "bunfig.toml"), "utf8");
38091
38205
  } catch {
38092
38206
  return roots;
38093
38207
  }
@@ -38101,8 +38215,8 @@ async function bunfigPreloadRoots(projectRoot) {
38101
38215
  if (raw.length === 0) {
38102
38216
  continue;
38103
38217
  }
38104
- const absolute = path104.resolve(projectRoot, raw);
38105
- const relative = path104.relative(projectRoot, absolute).split(path104.sep).join("/");
38218
+ const absolute = path105.resolve(projectRoot, raw);
38219
+ const relative = path105.relative(projectRoot, absolute).split(path105.sep).join("/");
38106
38220
  roots.add(relative);
38107
38221
  }
38108
38222
  }
@@ -38257,12 +38371,12 @@ init_section_tombstone();
38257
38371
  // src/forgetting/journal.ts
38258
38372
  init_fs();
38259
38373
  import { appendFile as appendFile5, mkdir as mkdir24, readFile as readFile53, stat as stat16 } from "fs/promises";
38260
- import path106 from "path";
38374
+ import path107 from "path";
38261
38375
  function forgettingDataDir(cwd) {
38262
- return path106.join(cwd, ".metaproject", "data", "forgetting");
38376
+ return path107.join(cwd, ".metaproject", "data", "forgetting");
38263
38377
  }
38264
38378
  function deletionJournalPath(cwd) {
38265
- return path106.join(forgettingDataDir(cwd), "journal.jsonl");
38379
+ return path107.join(forgettingDataDir(cwd), "journal.jsonl");
38266
38380
  }
38267
38381
  async function readDeletionJournal(cwd) {
38268
38382
  const file = deletionJournalPath(cwd);
@@ -38677,12 +38791,12 @@ function createGdgraphService() {
38677
38791
  // src/health/service.ts
38678
38792
  init_fs();
38679
38793
  init_json();
38680
- import path126 from "path";
38794
+ import path127 from "path";
38681
38795
 
38682
38796
  // src/health/config.ts
38683
38797
  init_fs();
38684
38798
  init_json();
38685
- import path107 from "path";
38799
+ import path108 from "path";
38686
38800
  var DEFAULT_HEALTH_CONFIG = {
38687
38801
  schemaVersion: 2,
38688
38802
  ignore: {
@@ -38739,7 +38853,7 @@ var DEFAULT_HEALTH_CONFIG = {
38739
38853
  }
38740
38854
  };
38741
38855
  function configPath2(cwd) {
38742
- return path107.join(cwd, ".metaproject", "health.config.json");
38856
+ return path108.join(cwd, ".metaproject", "health.config.json");
38743
38857
  }
38744
38858
  var STRICTEST_GATE = {
38745
38859
  failOnPriorities: ["P0", "P1", "P2", "P3"],
@@ -38790,7 +38904,7 @@ async function loadHealthConfig(cwd) {
38790
38904
  // src/health/run.ts
38791
38905
  init_fs();
38792
38906
  import { mkdir as mkdir28, writeFile as writeFile21 } from "fs/promises";
38793
- import path125 from "path";
38907
+ import path126 from "path";
38794
38908
 
38795
38909
  // src/metrics/provenance.ts
38796
38910
  async function collectGitProvenance(cwd) {
@@ -38903,12 +39017,12 @@ function computeGate2(input) {
38903
39017
  }
38904
39018
 
38905
39019
  // src/health/scopes.ts
38906
- import path110 from "path";
39020
+ import path111 from "path";
38907
39021
 
38908
39022
  // src/health/util.ts
38909
39023
  init_fs();
38910
39024
  import { mkdir as mkdir25, readFile as readFile54, readdir as readdir19, writeFile as writeFile18 } from "fs/promises";
38911
- import path108 from "path";
39025
+ import path109 from "path";
38912
39026
  var IGNORED_DIRS = new Set([
38913
39027
  "node_modules",
38914
39028
  ".git",
@@ -38952,14 +39066,14 @@ async function toolVersion(command, cwd) {
38952
39066
  }
38953
39067
  }
38954
39068
  function dataRoot3(cwd) {
38955
- return path108.join(cwd, ".metaproject", "data", "health");
39069
+ return path109.join(cwd, ".metaproject", "data", "health");
38956
39070
  }
38957
39071
  async function writeRaw(cwd, source, content, stamp) {
38958
- const dir = path108.join(dataRoot3(cwd), "raw", source);
39072
+ const dir = path109.join(dataRoot3(cwd), "raw", source);
38959
39073
  await mkdir25(dir, { recursive: true });
38960
- const file = path108.join(dir, `${stamp}.log`);
39074
+ const file = path109.join(dir, `${stamp}.log`);
38961
39075
  await writeFile18(file, content, "utf8");
38962
- return path108.relative(cwd, file);
39076
+ return path109.relative(cwd, file);
38963
39077
  }
38964
39078
  async function listSourceFiles(cwd, ignorePaths = []) {
38965
39079
  const { files } = await listSourceFilesWithReasons(cwd, ignorePaths);
@@ -38979,7 +39093,7 @@ async function walk2(root, dir, out, incompleteReasons) {
38979
39093
  try {
38980
39094
  entries = await readdir19(dir, { withFileTypes: true });
38981
39095
  } catch (error) {
38982
- incompleteReasons.push(`${path108.relative(root, dir) || "."}: ${error instanceof Error ? error.message : String(error)}`);
39096
+ incompleteReasons.push(`${path109.relative(root, dir) || "."}: ${error instanceof Error ? error.message : String(error)}`);
38983
39097
  return;
38984
39098
  }
38985
39099
  for (const entry of entries) {
@@ -38987,14 +39101,14 @@ async function walk2(root, dir, out, incompleteReasons) {
38987
39101
  if (entry.isDirectory() && !IGNORED_DIRS.has(entry.name)) {}
38988
39102
  continue;
38989
39103
  }
38990
- const abs = path108.join(dir, entry.name);
39104
+ const abs = path109.join(dir, entry.name);
38991
39105
  if (entry.isDirectory()) {
38992
39106
  if (IGNORED_DIRS.has(entry.name)) {
38993
39107
  continue;
38994
39108
  }
38995
39109
  await walk2(root, abs, out, incompleteReasons);
38996
- } else if (entry.isFile() && SOURCE_EXT.has(path108.extname(entry.name))) {
38997
- out.push(path108.relative(root, abs));
39110
+ } else if (entry.isFile() && SOURCE_EXT.has(path109.extname(entry.name))) {
39111
+ out.push(path109.relative(root, abs));
38998
39112
  }
38999
39113
  }
39000
39114
  }
@@ -39009,7 +39123,7 @@ function moduleOfFile(file) {
39009
39123
  return null;
39010
39124
  }
39011
39125
  function isSourceFile(file) {
39012
- return SOURCE_EXT.has(path108.extname(file));
39126
+ return SOURCE_EXT.has(path109.extname(file));
39013
39127
  }
39014
39128
  function matchesAnyPattern(file, patterns) {
39015
39129
  const normalized = file.replace(/\\/g, "/").replace(/^\.\//, "");
@@ -39111,7 +39225,7 @@ function rankHotspots(files, churn, sourceAnalysis) {
39111
39225
  // src/health/source-analysis.ts
39112
39226
  init_fs();
39113
39227
  import { readFile as readFile55 } from "fs/promises";
39114
- import path109 from "path";
39228
+ import path110 from "path";
39115
39229
 
39116
39230
  // src/health/metrics/complexity.ts
39117
39231
  var CONTROL_KEYWORDS = new Set([
@@ -39345,7 +39459,7 @@ async function analyzeSourceFiles(cwd, sourceFiles) {
39345
39459
  return new Map(entries.filter((entry) => entry !== null));
39346
39460
  }
39347
39461
  async function analyzeSourceFile(cwd, file) {
39348
- const abs = path109.join(cwd, file);
39462
+ const abs = path110.join(cwd, file);
39349
39463
  if (!await pathExists(abs)) {
39350
39464
  return null;
39351
39465
  }
@@ -39422,14 +39536,14 @@ async function computeMetrics(input) {
39422
39536
  }
39423
39537
  const components = new Map;
39424
39538
  for (const file of sourceFiles) {
39425
- const dir = path110.posix.dirname(file);
39539
+ const dir = path111.posix.dirname(file);
39426
39540
  if (dir === "." || dir === moduleOfFile(file)) {
39427
39541
  continue;
39428
39542
  }
39429
39543
  components.set(dir, [...components.get(dir) ?? [], file]);
39430
39544
  }
39431
39545
  for (const [name, files] of [...components.entries()].sort()) {
39432
- const compFindings = findings.filter((f) => f.file && path110.posix.dirname(f.file) === name);
39546
+ const compFindings = findings.filter((f) => f.file && path111.posix.dirname(f.file) === name);
39433
39547
  scopes.push(build("component", `component:${name}`, name, files, compFindings, averageCoverage(files, coverage)));
39434
39548
  }
39435
39549
  const findingFiles = findings.map((f) => f.file).filter((f) => Boolean(f));
@@ -39474,7 +39588,7 @@ function tally2(values) {
39474
39588
  // src/health/baseline.ts
39475
39589
  init_fs();
39476
39590
  import { mkdir as mkdir26, readFile as readFile56, writeFile as writeFile19 } from "fs/promises";
39477
- import path111 from "path";
39591
+ import path112 from "path";
39478
39592
  var LEGACY_BASELINE_SOURCES = Object.freeze([
39479
39593
  "complexity",
39480
39594
  "coverage",
@@ -39499,7 +39613,7 @@ function measuredSources(sources) {
39499
39613
  return sources.filter((s) => s !== null && typeof s === "object").filter((s) => !didNotProduceResult(s)).map((s) => s.source).sort();
39500
39614
  }
39501
39615
  function baselinePath(cwd) {
39502
- return path111.join(cwd, ".metaproject", "health", "baselines", "scores.json");
39616
+ return path112.join(cwd, ".metaproject", "health", "baselines", "scores.json");
39503
39617
  }
39504
39618
  async function readBaselineFile(cwd) {
39505
39619
  const file = baselinePath(cwd);
@@ -39520,7 +39634,7 @@ async function loadBaselineSources(cwd) {
39520
39634
  }
39521
39635
  async function writeBaselineFile(cwd, data) {
39522
39636
  const file = baselinePath(cwd);
39523
- await mkdir26(path111.dirname(file), { recursive: true });
39637
+ await mkdir26(path112.dirname(file), { recursive: true });
39524
39638
  await writeFile19(file, `${JSON.stringify(data, null, 2)}
39525
39639
  `, "utf8");
39526
39640
  }
@@ -39602,10 +39716,10 @@ async function getChurn(cwd, windowDays) {
39602
39716
 
39603
39717
  // src/health/metrics/wiki-freshness.ts
39604
39718
  import { readFile as readFile57, stat as stat17 } from "fs/promises";
39605
- import path112 from "path";
39719
+ import path113 from "path";
39606
39720
  var DEFAULT_STALE_EVIDENCE_DAYS = 7;
39607
39721
  function freshnessReportPath(cwd) {
39608
- return path112.join(cwd, ".metaproject", "data", "wiki", "freshness", "latest.json");
39722
+ return path113.join(cwd, ".metaproject", "data", "wiki", "freshness", "latest.json");
39609
39723
  }
39610
39724
  async function readWikiFreshnessMetric(cwd, options = {}) {
39611
39725
  const file = freshnessReportPath(cwd);
@@ -39626,7 +39740,7 @@ async function readWikiFreshnessMetric(cwd, options = {}) {
39626
39740
  } catch {
39627
39741
  return {
39628
39742
  status: "unreadable-report",
39629
- reason: `${path112.relative(cwd, file)} is not valid JSON; re-run \`keryx wiki freshness\`.`
39743
+ reason: `${path113.relative(cwd, file)} is not valid JSON; re-run \`keryx wiki freshness\`.`
39630
39744
  };
39631
39745
  }
39632
39746
  const report = parsed;
@@ -39636,7 +39750,7 @@ async function readWikiFreshnessMetric(cwd, options = {}) {
39636
39750
  if (pagesTotal === null || pagesFresh === null) {
39637
39751
  return {
39638
39752
  status: "unreadable-report",
39639
- reason: `${path112.relative(cwd, file)} is missing its totals; re-run \`keryx wiki freshness\`.`
39753
+ reason: `${path113.relative(cwd, file)} is missing its totals; re-run \`keryx wiki freshness\`.`
39640
39754
  };
39641
39755
  }
39642
39756
  const pagesUndecidable = numberOr3(totals.pagesUndecidable) ?? 0;
@@ -39690,12 +39804,12 @@ function renderWikiFreshnessLine(metric) {
39690
39804
  }
39691
39805
 
39692
39806
  // src/health/sources/helpers.ts
39693
- import path113 from "path";
39807
+ import path114 from "path";
39694
39808
  import { existsSync as existsSync12 } from "fs";
39695
39809
  class NoImportError extends Error {
39696
39810
  }
39697
39811
  function resolveBin(cwd, name) {
39698
- const local = path113.join(cwd, "node_modules", ".bin", name);
39812
+ const local = path114.join(cwd, "node_modules", ".bin", name);
39699
39813
  if (existsSync12(local)) {
39700
39814
  return local;
39701
39815
  }
@@ -39776,13 +39890,13 @@ async function getComplexityFindings(cwd, sourceFiles, config, sourceAnalysis) {
39776
39890
 
39777
39891
  // src/health/metrics/coverage.ts
39778
39892
  import { existsSync as existsSync13 } from "fs";
39779
- import path114 from "path";
39893
+ import path115 from "path";
39780
39894
  var SUMMARY_PATHS = [
39781
39895
  "coverage/coverage-summary.json",
39782
39896
  "coverage/coverage-final.json"
39783
39897
  ];
39784
39898
  async function getCoverage(cwd) {
39785
- const summary = SUMMARY_PATHS.map((rel) => path114.join(cwd, rel)).find((abs) => existsSync13(abs));
39899
+ const summary = SUMMARY_PATHS.map((rel) => path115.join(cwd, rel)).find((abs) => existsSync13(abs));
39786
39900
  if (!summary) {
39787
39901
  return { status: "missing", total: null, byFile: new Map };
39788
39902
  }
@@ -39803,7 +39917,7 @@ async function getCoverage(cwd) {
39803
39917
  total = pct;
39804
39918
  continue;
39805
39919
  }
39806
- const relative = path114.isAbsolute(key) ? path114.relative(cwd, key) : key;
39920
+ const relative = path115.isAbsolute(key) ? path115.relative(cwd, key) : key;
39807
39921
  byFile.set(relative.replace(/\\/g, "/"), pct);
39808
39922
  }
39809
39923
  return { status: "available", total, byFile };
@@ -39936,10 +40050,10 @@ function renderWikiFreshness(metric) {
39936
40050
  // src/health/skills.ts
39937
40051
  init_fs();
39938
40052
  import { readFile as readFile58 } from "fs/promises";
39939
- import path115 from "path";
40053
+ import path116 from "path";
39940
40054
  var EMPTY = { skills: [], skillForFile: () => null };
39941
40055
  async function loadSkillOwnership(cwd) {
39942
- const manifestPath = path115.join(cwd, ".metaproject", "metaproject.json");
40056
+ const manifestPath = path116.join(cwd, ".metaproject", "metaproject.json");
39943
40057
  if (!await pathExists(manifestPath)) {
39944
40058
  return EMPTY;
39945
40059
  }
@@ -39977,7 +40091,7 @@ function normalize(value) {
39977
40091
 
39978
40092
  // src/health/sources/eslint.ts
39979
40093
  import { existsSync as existsSync14 } from "fs";
39980
- import path116 from "path";
40094
+ import path117 from "path";
39981
40095
  var CONFIG_FILES = [
39982
40096
  ".eslintrc",
39983
40097
  ".eslintrc.js",
@@ -39991,7 +40105,7 @@ var CONFIG_FILES = [
39991
40105
  "eslint.config.ts"
39992
40106
  ];
39993
40107
  function hasConfig(cwd) {
39994
- return CONFIG_FILES.some((file) => existsSync14(path116.join(cwd, file)));
40108
+ return CONFIG_FILES.some((file) => existsSync14(path117.join(cwd, file)));
39995
40109
  }
39996
40110
  var eslintAdapter = {
39997
40111
  id: "eslint",
@@ -40017,7 +40131,7 @@ var eslintAdapter = {
40017
40131
  };
40018
40132
  },
40019
40133
  async import(ctx) {
40020
- const report = path116.join(ctx.cwd, "eslint-report.json");
40134
+ const report = path117.join(ctx.cwd, "eslint-report.json");
40021
40135
  if (!existsSync14(report)) {
40022
40136
  throw new NoImportError("no eslint-report.json");
40023
40137
  }
@@ -40044,7 +40158,7 @@ var eslintAdapter = {
40044
40158
  }
40045
40159
  const findings = [];
40046
40160
  for (const file of data) {
40047
- const relative = path116.isAbsolute(file.filePath) ? path116.relative(ctx.cwd, file.filePath) : file.filePath;
40161
+ const relative = path117.isAbsolute(file.filePath) ? path117.relative(ctx.cwd, file.filePath) : file.filePath;
40048
40162
  for (const message of file.messages ?? []) {
40049
40163
  const isError = message.severity === 2;
40050
40164
  findings.push(makeFinding({
@@ -40076,19 +40190,19 @@ var eslintAdapter = {
40076
40190
 
40077
40191
  // src/health/sources/oxlint.ts
40078
40192
  import { existsSync as existsSync15, readFileSync as readFileSync11 } from "fs";
40079
- import path117 from "path";
40193
+ import path118 from "path";
40080
40194
  var CONFIG_FILES2 = [".oxlintrc.json", ".oxlintrc.jsonc"];
40081
40195
  var OXLINT_FORMAT = "json";
40082
40196
  var OXLINT_PARSE_ERROR = "oxlint JSON format was not recognized";
40083
40197
  var OXLINT_NO_FILES = "oxlint found no files to lint (check its paths and ignore patterns)";
40084
40198
  var NO_FILES_PREAMBLE = "No files found to lint";
40085
40199
  function hasConfigFile(cwd) {
40086
- if (CONFIG_FILES2.some((file) => existsSync15(path117.join(cwd, file))))
40200
+ if (CONFIG_FILES2.some((file) => existsSync15(path118.join(cwd, file))))
40087
40201
  return true;
40088
- return [".oxlintrc.js", ".oxlintrc.cjs", ".oxlintrc.mjs", ".oxlintrc.ts"].some((file) => existsSync15(path117.join(cwd, file)));
40202
+ return [".oxlintrc.js", ".oxlintrc.cjs", ".oxlintrc.mjs", ".oxlintrc.ts"].some((file) => existsSync15(path118.join(cwd, file)));
40089
40203
  }
40090
40204
  function packageNamesOxlint(cwd) {
40091
- const file = path117.join(cwd, "package.json");
40205
+ const file = path118.join(cwd, "package.json");
40092
40206
  if (!existsSync15(file))
40093
40207
  return false;
40094
40208
  try {
@@ -40146,7 +40260,7 @@ var oxlintAdapter = {
40146
40260
  return [];
40147
40261
  return data.map((diagnostic) => {
40148
40262
  const filePath = diagnostic.filename ?? "";
40149
- const relative = filePath && path117.isAbsolute(filePath) ? path117.relative(ctx.cwd, filePath) : filePath;
40263
+ const relative = filePath && path118.isAbsolute(filePath) ? path118.relative(ctx.cwd, filePath) : filePath;
40150
40264
  const isError = diagnostic.severity === "error";
40151
40265
  return makeFinding({
40152
40266
  source: "oxlint",
@@ -40172,9 +40286,9 @@ var oxlintAdapter = {
40172
40286
 
40173
40287
  // src/health/sources/typescript.ts
40174
40288
  import { existsSync as existsSync16 } from "fs";
40175
- import path118 from "path";
40289
+ import path119 from "path";
40176
40290
  function hasTsconfig(cwd) {
40177
- return existsSync16(path118.join(cwd, "tsconfig.json"));
40291
+ return existsSync16(path119.join(cwd, "tsconfig.json"));
40178
40292
  }
40179
40293
  var typescriptAdapter = {
40180
40294
  id: "typescript",
@@ -40235,12 +40349,12 @@ init_fs();
40235
40349
  init_contained_write();
40236
40350
  import { existsSync as existsSync17 } from "fs";
40237
40351
  import { readFile as readFile61, readdir as readdir20 } from "fs/promises";
40238
- import path122 from "path";
40352
+ import path123 from "path";
40239
40353
  // src/metrics/lifecycle.ts
40240
40354
  init_fs();
40241
40355
  init_guard();
40242
40356
  import { readFile as readFile59 } from "fs/promises";
40243
- import path119 from "path";
40357
+ import path120 from "path";
40244
40358
 
40245
40359
  // src/metrics/record.ts
40246
40360
  var RELIABILITIES = new Set(["exact", "estimated", "unknown"]);
@@ -40255,7 +40369,7 @@ var RETRY_TYPES = new Set([
40255
40369
 
40256
40370
  // src/metrics/lifecycle.ts
40257
40371
  async function readArtifactPointer(root, expected) {
40258
- const pointerFile = path119.join(root, "latest.json");
40372
+ const pointerFile = path120.join(root, "latest.json");
40259
40373
  if (!await pathExists(pointerFile))
40260
40374
  return { status: "missing", pointer: null };
40261
40375
  let pointer;
@@ -40264,7 +40378,7 @@ async function readArtifactPointer(root, expected) {
40264
40378
  } catch {
40265
40379
  return { status: "stale", pointer: null, reason: "latest pointer is invalid JSON" };
40266
40380
  }
40267
- const recordFile = pointer.record ? path119.join(root, pointer.record) : null;
40381
+ const recordFile = pointer.record ? path120.join(root, pointer.record) : null;
40268
40382
  if (!recordFile || !isPathInside(root, recordFile) || !await pathExists(recordFile)) {
40269
40383
  return { status: "stale", pointer, reason: "pointer record is missing" };
40270
40384
  }
@@ -40280,9 +40394,9 @@ init_guard();
40280
40394
  // src/testing/capability.ts
40281
40395
  init_fs();
40282
40396
  init_json();
40283
- import path120 from "path";
40397
+ import path121 from "path";
40284
40398
  async function isTestingCapabilityEnabled(cwd, capability) {
40285
- const manifestPath = path120.join(cwd, ".metaproject", "metaproject.json");
40399
+ const manifestPath = path121.join(cwd, ".metaproject", "metaproject.json");
40286
40400
  if (!await pathExists(manifestPath)) {
40287
40401
  return false;
40288
40402
  }
@@ -40308,10 +40422,10 @@ async function isTestingCapabilityEnabled(cwd, capability) {
40308
40422
  init_fs();
40309
40423
  init_guard();
40310
40424
  import { readFile as readFile60, mkdir as mkdir27, writeFile as writeFile20 } from "fs/promises";
40311
- import path121 from "path";
40425
+ import path122 from "path";
40312
40426
  var COVERAGE_MAP_SCHEMA_VERSION = 1;
40313
40427
  function coverageMapPath(cwd, cfg) {
40314
- return path121.isAbsolute(cfg.coverageMap.artifact) ? cfg.coverageMap.artifact : path121.join(cwd, cfg.coverageMap.artifact);
40428
+ return path122.isAbsolute(cfg.coverageMap.artifact) ? cfg.coverageMap.artifact : path122.join(cwd, cfg.coverageMap.artifact);
40315
40429
  }
40316
40430
  async function loadCoverageMap(cwd, cfg) {
40317
40431
  const file = coverageMapPath(cwd, cfg);
@@ -40446,7 +40560,7 @@ var DEFAULT_TESTING_CONFIG = {
40446
40560
  }
40447
40561
  };
40448
40562
  function testingDataRoot(cwd) {
40449
- return path122.join(cwd, ".metaproject", "data", "testing");
40563
+ return path123.join(cwd, ".metaproject", "data", "testing");
40450
40564
  }
40451
40565
  async function computeTestingContext(cwd) {
40452
40566
  const { files, incompleteReasons } = await listProjectFiles(cwd);
@@ -40621,7 +40735,7 @@ async function runTesting(input) {
40621
40735
  return runResult;
40622
40736
  }
40623
40737
  async function loadTestingContext(cwd) {
40624
- const file = path122.join(testingDataRoot(cwd), "context.json");
40738
+ const file = path123.join(testingDataRoot(cwd), "context.json");
40625
40739
  if (!await pathExists(file)) {
40626
40740
  return null;
40627
40741
  }
@@ -40632,18 +40746,18 @@ async function loadTestingContext(cwd) {
40632
40746
  }
40633
40747
  }
40634
40748
  async function loadTestingReport(cwd) {
40635
- const file = path122.join(testingDataRoot(cwd), "artifacts", "latest.json");
40749
+ const file = path123.join(testingDataRoot(cwd), "artifacts", "latest.json");
40636
40750
  if (!await pathExists(file)) {
40637
40751
  return null;
40638
40752
  }
40639
40753
  try {
40640
40754
  const latest = JSON.parse(await readFile61(file, "utf8"));
40641
40755
  if (typeof latest.record === "string") {
40642
- const pointer = await readArtifactPointer(path122.join(testingDataRoot(cwd), "artifacts"), await collectGitProvenance(cwd));
40756
+ const pointer = await readArtifactPointer(path123.join(testingDataRoot(cwd), "artifacts"), await collectGitProvenance(cwd));
40643
40757
  if (pointer.status !== "fresh")
40644
40758
  return null;
40645
- const recordFile = path122.join(testingDataRoot(cwd), "artifacts", latest.record);
40646
- if (!isPathInside(path122.join(testingDataRoot(cwd), "artifacts"), recordFile))
40759
+ const recordFile = path123.join(testingDataRoot(cwd), "artifacts", latest.record);
40760
+ if (!isPathInside(path123.join(testingDataRoot(cwd), "artifacts"), recordFile))
40647
40761
  return null;
40648
40762
  if (!await pathExists(recordFile))
40649
40763
  return null;
@@ -40690,28 +40804,28 @@ async function ensureContext(cwd) {
40690
40804
  }
40691
40805
  async function writeContext(cwd, context) {
40692
40806
  const root = testingDataRoot(cwd);
40693
- const rel = (p) => path122.relative(cwd, p);
40807
+ const rel = (p) => path123.relative(cwd, p);
40694
40808
  await mkdirContained(cwd, rel(root));
40695
- await writeContained(cwd, rel(path122.join(root, "context.json")), `${JSON.stringify(context, null, 2)}
40809
+ await writeContained(cwd, rel(path123.join(root, "context.json")), `${JSON.stringify(context, null, 2)}
40696
40810
  `);
40697
- await writeContained(cwd, rel(path122.join(root, "context.md")), renderContextMarkdown(context));
40698
- await writeContained(cwd, rel(path122.join(root, "recommendations.md")), renderRecommendationsMarkdown(context));
40811
+ await writeContained(cwd, rel(path123.join(root, "context.md")), renderContextMarkdown(context));
40812
+ await writeContained(cwd, rel(path123.join(root, "recommendations.md")), renderRecommendationsMarkdown(context));
40699
40813
  }
40700
40814
  async function writeReport(cwd, report) {
40701
40815
  const root = testingDataRoot(cwd);
40702
- const artifacts = path122.join(root, "artifacts");
40703
- const history = path122.join(root, "history");
40704
- const rel = (p) => path122.relative(cwd, p);
40816
+ const artifacts = path123.join(root, "artifacts");
40817
+ const history = path123.join(root, "history");
40818
+ const rel = (p) => path123.relative(cwd, p);
40705
40819
  await mkdirContained(cwd, rel(artifacts));
40706
40820
  await mkdirContained(cwd, rel(history));
40707
40821
  const stamp = report.generatedAt.replace(/[:.]/g, "-");
40708
- const json = path122.join(artifacts, "latest.json");
40709
- const markdown = path122.join(artifacts, "latest.md");
40822
+ const json = path123.join(artifacts, "latest.json");
40823
+ const markdown = path123.join(artifacts, "latest.md");
40710
40824
  const serialized = `${JSON.stringify(report, null, 2)}
40711
40825
  `;
40712
40826
  if (report.runId) {
40713
- const runJson = path122.join(artifacts, "runs", `${report.runId}.json`);
40714
- const runMarkdown = path122.join(artifacts, "runs", `${report.runId}.md`);
40827
+ const runJson = path123.join(artifacts, "runs", `${report.runId}.json`);
40828
+ const runMarkdown = path123.join(artifacts, "runs", `${report.runId}.md`);
40715
40829
  if (await pathExists(runJson))
40716
40830
  throw new Error(`immutable testing run already exists: ${report.runId}`);
40717
40831
  await writeContained(cwd, rel(runJson), serialized);
@@ -40722,26 +40836,26 @@ async function writeReport(cwd, report) {
40722
40836
  branch: report.provenance?.branch ?? null,
40723
40837
  worktree: report.provenance?.worktree ?? null,
40724
40838
  generated_at: report.generatedAt,
40725
- record: path122.posix.join("runs", `${report.runId}.json`)
40839
+ record: path123.posix.join("runs", `${report.runId}.json`)
40726
40840
  }, null, 2)}
40727
40841
  `);
40728
40842
  } else {
40729
40843
  await writeContained(cwd, rel(json), serialized);
40730
40844
  }
40731
40845
  await writeContained(cwd, rel(markdown), renderReportMarkdown3(report));
40732
- await writeContained(cwd, rel(path122.join(history, `${stamp}.json`)), serialized);
40846
+ await writeContained(cwd, rel(path123.join(history, `${stamp}.json`)), serialized);
40733
40847
  return {
40734
- markdownPath: path122.relative(cwd, markdown),
40735
- jsonPath: path122.relative(cwd, json)
40848
+ markdownPath: path123.relative(cwd, markdown),
40849
+ jsonPath: path123.relative(cwd, json)
40736
40850
  };
40737
40851
  }
40738
40852
  async function writeRawLog(cwd, raw) {
40739
- const logs = path122.join(testingDataRoot(cwd), "logs");
40740
- const rel = (p) => path122.relative(cwd, p);
40853
+ const logs = path123.join(testingDataRoot(cwd), "logs");
40854
+ const rel = (p) => path123.relative(cwd, p);
40741
40855
  await mkdirContained(cwd, rel(logs));
40742
- const latest = path122.join(logs, "latest.raw.log");
40856
+ const latest = path123.join(logs, "latest.raw.log");
40743
40857
  await writeContained(cwd, rel(latest), raw);
40744
- return path122.relative(cwd, latest);
40858
+ return path123.relative(cwd, latest);
40745
40859
  }
40746
40860
  async function listProjectFiles(cwd) {
40747
40861
  const out = [];
@@ -40754,11 +40868,11 @@ async function walk3(root, dir, out, incompleteReasons) {
40754
40868
  try {
40755
40869
  entries = await readdir20(dir, { withFileTypes: true });
40756
40870
  } catch (error) {
40757
- incompleteReasons.push(`${normalizePath6(path122.relative(root, dir)) || "."}: ${error instanceof Error ? error.message : String(error)}`);
40871
+ incompleteReasons.push(`${normalizePath6(path123.relative(root, dir)) || "."}: ${error instanceof Error ? error.message : String(error)}`);
40758
40872
  return;
40759
40873
  }
40760
40874
  for (const entry of entries) {
40761
- const abs = path122.join(dir, entry.name);
40875
+ const abs = path123.join(dir, entry.name);
40762
40876
  if (entry.isDirectory()) {
40763
40877
  if (IGNORED_DIRS2.has(entry.name) || entry.name.startsWith(".tmp-")) {
40764
40878
  continue;
@@ -40767,12 +40881,12 @@ async function walk3(root, dir, out, incompleteReasons) {
40767
40881
  continue;
40768
40882
  }
40769
40883
  if (entry.isFile()) {
40770
- out.push(normalizePath6(path122.relative(root, abs)));
40884
+ out.push(normalizePath6(path123.relative(root, abs)));
40771
40885
  }
40772
40886
  }
40773
40887
  }
40774
40888
  async function readPackageJson(cwd) {
40775
- const file = path122.join(cwd, "package.json");
40889
+ const file = path123.join(cwd, "package.json");
40776
40890
  if (!await pathExists(file)) {
40777
40891
  return null;
40778
40892
  }
@@ -40783,7 +40897,7 @@ async function readPackageJson(cwd) {
40783
40897
  }
40784
40898
  }
40785
40899
  async function loadTestingConfig(cwd) {
40786
- const file = path122.join(cwd, ".metaproject", "testing.config.json");
40900
+ const file = path123.join(cwd, ".metaproject", "testing.config.json");
40787
40901
  if (!await pathExists(file)) {
40788
40902
  return DEFAULT_TESTING_CONFIG;
40789
40903
  }
@@ -40848,7 +40962,7 @@ function detectFrameworks(input) {
40848
40962
  async function extractConventions(cwd, files) {
40849
40963
  const conventions = new Set;
40850
40964
  for (const file of files.slice(0, 40)) {
40851
- const abs = path122.join(cwd, file);
40965
+ const abs = path123.join(cwd, file);
40852
40966
  if (!await pathExists(abs)) {
40853
40967
  continue;
40854
40968
  }
@@ -40978,7 +41092,7 @@ async function findTestsByImportedTargets(cwd, targets, testFiles) {
40978
41092
  const targetKeys = new Set(targets.map((target) => modulePathKey(normalizePath6(target))));
40979
41093
  const selected = new Set;
40980
41094
  for (const testFile of testFiles) {
40981
- const absoluteTest = path122.join(cwd, testFile);
41095
+ const absoluteTest = path123.join(cwd, testFile);
40982
41096
  if (!await pathExists(absoluteTest)) {
40983
41097
  continue;
40984
41098
  }
@@ -41012,10 +41126,10 @@ function resolveImportPath(cwd, testFile, importPath) {
41012
41126
  if (!importPath.startsWith(".")) {
41013
41127
  return null;
41014
41128
  }
41015
- const importerDir = path122.dirname(testFile);
41016
- const absoluteResolved = path122.resolve(path122.join(cwd, importerDir), importPath);
41017
- const relative = path122.relative(cwd, absoluteResolved);
41018
- if (relative.startsWith(`..${path122.sep}`) || relative === "..") {
41129
+ const importerDir = path123.dirname(testFile);
41130
+ const absoluteResolved = path123.resolve(path123.join(cwd, importerDir), importPath);
41131
+ const relative = path123.relative(cwd, absoluteResolved);
41132
+ if (relative.startsWith(`..${path123.sep}`) || relative === "..") {
41019
41133
  return null;
41020
41134
  }
41021
41135
  const relativeNormalized = normalizePath6(relative);
@@ -41067,13 +41181,13 @@ function resolveTestCommand(cwd, context, input) {
41067
41181
  }
41068
41182
  var BUN_LOCKFILES = ["bun.lock", "bun.lockb"];
41069
41183
  function detectPackageManager(cwd) {
41070
- if (resolveBunBin() && BUN_LOCKFILES.some((name) => pathExistsSync(path122.join(cwd, name)))) {
41184
+ if (resolveBunBin() && BUN_LOCKFILES.some((name) => pathExistsSync(path123.join(cwd, name)))) {
41071
41185
  return "bun";
41072
41186
  }
41073
- if (Bun.which("pnpm") && pathExistsSync(path122.join(cwd, "pnpm-lock.yaml"))) {
41187
+ if (Bun.which("pnpm") && pathExistsSync(path123.join(cwd, "pnpm-lock.yaml"))) {
41074
41188
  return "pnpm";
41075
41189
  }
41076
- if (Bun.which("yarn") && pathExistsSync(path122.join(cwd, "yarn.lock"))) {
41190
+ if (Bun.which("yarn") && pathExistsSync(path123.join(cwd, "yarn.lock"))) {
41077
41191
  return "yarn";
41078
41192
  }
41079
41193
  return "npm";
@@ -41413,7 +41527,7 @@ async function compatibleReportForHealth(ctx) {
41413
41527
 
41414
41528
  // src/health/sources/dependency-audit.ts
41415
41529
  import { existsSync as existsSync18 } from "fs";
41416
- import path123 from "path";
41530
+ import path124 from "path";
41417
41531
  function auditSeverityToPriority(severity) {
41418
41532
  if (severity === "critical" || severity === "high")
41419
41533
  return "P0";
@@ -41532,7 +41646,7 @@ var LOCKFILE_COMMANDS = [
41532
41646
  ];
41533
41647
  function auditCommand(cwd) {
41534
41648
  for (const entry of LOCKFILE_COMMANDS) {
41535
- if (!entry.lockfiles.some((name) => existsSync18(path123.join(cwd, name))))
41649
+ if (!entry.lockfiles.some((name) => existsSync18(path124.join(cwd, name))))
41536
41650
  continue;
41537
41651
  const bin = resolveBin(cwd, entry.bin);
41538
41652
  if (bin)
@@ -41591,13 +41705,13 @@ var dependencyAuditAdapter = {
41591
41705
 
41592
41706
  // src/health/sources/sonarqube.ts
41593
41707
  import { existsSync as existsSync19 } from "fs";
41594
- import path124 from "path";
41708
+ import path125 from "path";
41595
41709
  var REPORT_FILES = ["sonar-issues.json", ".metaproject/data/health/sonar-issues.json"];
41596
41710
  function reportPath(cwd) {
41597
41711
  const fromEnv = process.env.SONAR_ISSUES_FILE;
41598
41712
  const candidates = fromEnv ? [fromEnv, ...REPORT_FILES] : REPORT_FILES;
41599
41713
  for (const rel of candidates) {
41600
- const abs = path124.isAbsolute(rel) ? rel : path124.join(cwd, rel);
41714
+ const abs = path125.isAbsolute(rel) ? rel : path125.join(cwd, rel);
41601
41715
  if (existsSync19(abs)) {
41602
41716
  return abs;
41603
41717
  }
@@ -41681,7 +41795,7 @@ var sonarqubeAdapter = {
41681
41795
  function relativizeComponent(component, cwd) {
41682
41796
  const colon = component.indexOf(":");
41683
41797
  const value = colon >= 0 ? component.slice(colon + 1) : component;
41684
- return path124.isAbsolute(value) ? path124.relative(cwd, value) : value;
41798
+ return path125.isAbsolute(value) ? path125.relative(cwd, value) : value;
41685
41799
  }
41686
41800
 
41687
41801
  // src/health/sources/index.ts
@@ -42042,19 +42156,19 @@ function filteredInfo(source, cfg) {
42042
42156
  };
42043
42157
  }
42044
42158
  async function writeOutputs(cwd, report, config, stamp) {
42045
- const artifacts = path125.join(dataRoot3(cwd), "artifacts");
42046
- const history = path125.join(dataRoot3(cwd), "history");
42159
+ const artifacts = path126.join(dataRoot3(cwd), "artifacts");
42160
+ const history = path126.join(dataRoot3(cwd), "history");
42047
42161
  await mkdir28(artifacts, { recursive: true });
42048
42162
  await mkdir28(history, { recursive: true });
42049
- const markdown = path125.join(artifacts, "latest.md");
42050
- const json = path125.join(artifacts, "latest.json");
42051
- const historyJson = path125.join(history, `${stamp}.json`);
42163
+ const markdown = path126.join(artifacts, "latest.md");
42164
+ const json = path126.join(artifacts, "latest.json");
42165
+ const historyJson = path126.join(history, `${stamp}.json`);
42052
42166
  const serialized = `${JSON.stringify(report, null, 2)}
42053
42167
  `;
42054
42168
  await writeFile21(markdown, renderReportMarkdown2(report, config), "utf8");
42055
42169
  if (report.runId) {
42056
- const runJson = path125.join(artifacts, "runs", `${report.runId}.json`);
42057
- const runMarkdown = path125.join(artifacts, "runs", `${report.runId}.md`);
42170
+ const runJson = path126.join(artifacts, "runs", `${report.runId}.json`);
42171
+ const runMarkdown = path126.join(artifacts, "runs", `${report.runId}.md`);
42058
42172
  if (await pathExists(runJson))
42059
42173
  throw new Error(`immutable health run already exists: ${report.runId}`);
42060
42174
  await writeFileAtomic(runJson, serialized);
@@ -42065,7 +42179,7 @@ async function writeOutputs(cwd, report, config, stamp) {
42065
42179
  branch: report.provenance?.branch ?? null,
42066
42180
  worktree: report.provenance?.worktree ?? null,
42067
42181
  generated_at: report.generatedAt,
42068
- record: path125.posix.join("runs", `${report.runId}.json`)
42182
+ record: path126.posix.join("runs", `${report.runId}.json`)
42069
42183
  }, null, 2)}
42070
42184
  `);
42071
42185
  } else {
@@ -42073,8 +42187,8 @@ async function writeOutputs(cwd, report, config, stamp) {
42073
42187
  }
42074
42188
  await writeFile21(historyJson, serialized, "utf8");
42075
42189
  return {
42076
- markdownPath: path125.relative(cwd, markdown),
42077
- jsonPath: path125.relative(cwd, json)
42190
+ markdownPath: path126.relative(cwd, markdown),
42191
+ jsonPath: path126.relative(cwd, json)
42078
42192
  };
42079
42193
  }
42080
42194
  async function resolveChanged(cwd, selector) {
@@ -42127,7 +42241,7 @@ function hasGateShape(value) {
42127
42241
  return Array.isArray(report.metrics) && Array.isArray(report.sources) && Array.isArray(report.findings);
42128
42242
  }
42129
42243
  async function readLatest(cwd) {
42130
- const file = path126.join(dataRoot3(cwd), "artifacts", "latest.json");
42244
+ const file = path127.join(dataRoot3(cwd), "artifacts", "latest.json");
42131
42245
  if (!await pathExists(file)) {
42132
42246
  return null;
42133
42247
  }
@@ -42138,11 +42252,11 @@ async function readLatest(cwd) {
42138
42252
  const latest = read.value;
42139
42253
  const record = latest.record;
42140
42254
  if (typeof record === "string") {
42141
- const pointer = await readArtifactPointer(path126.join(dataRoot3(cwd), "artifacts"), await collectGitProvenance(cwd));
42255
+ const pointer = await readArtifactPointer(path127.join(dataRoot3(cwd), "artifacts"), await collectGitProvenance(cwd));
42142
42256
  if (pointer.status !== "fresh")
42143
42257
  return null;
42144
- const recordFile = path126.join(dataRoot3(cwd), "artifacts", record);
42145
- if (!isPathInside(path126.join(dataRoot3(cwd), "artifacts"), recordFile))
42258
+ const recordFile = path127.join(dataRoot3(cwd), "artifacts", record);
42259
+ if (!isPathInside(path127.join(dataRoot3(cwd), "artifacts"), recordFile))
42146
42260
  return null;
42147
42261
  if (!await pathExists(recordFile))
42148
42262
  return null;
@@ -42215,7 +42329,7 @@ function createCodeHealthService() {
42215
42329
  return {
42216
42330
  run: (input) => runHealth(input),
42217
42331
  async status(input) {
42218
- const enabled = await pathExists(path126.join(input.cwd, ".metaproject", "health.config.json"));
42332
+ const enabled = await pathExists(path127.join(input.cwd, ".metaproject", "health.config.json"));
42219
42333
  const latest = await readLatest(input.cwd);
42220
42334
  const project = latest?.metrics.find((m) => m.key === "project") ?? null;
42221
42335
  const decliningScopes = latest ? latest.metrics.filter((m) => m.regression_score > 0).length : 0;
@@ -42372,10 +42486,10 @@ function renderEvidenceBlock(evidences, siblings) {
42372
42486
  init_fs();
42373
42487
  init_contained_write();
42374
42488
  init_json();
42375
- import path127 from "path";
42489
+ import path128 from "path";
42376
42490
  import { createHash as createHash21 } from "crypto";
42377
42491
  function impactEvidenceDataRoot(root) {
42378
- return path127.join(root, ".metaproject", "data", "security", "impact-evidence");
42492
+ return path128.join(root, ".metaproject", "data", "security", "impact-evidence");
42379
42493
  }
42380
42494
  function sanitizeSessionId(sessionId) {
42381
42495
  const cleaned = sessionId.replace(/[^A-Za-z0-9._-]/g, "_");
@@ -42387,7 +42501,7 @@ function sessionStateFilename(sessionId) {
42387
42501
  return `${sanitized}-${suffix}.json`;
42388
42502
  }
42389
42503
  function sessionStatePath(root, sessionId) {
42390
- return path127.join(impactEvidenceDataRoot(root), "sessions", sessionStateFilename(sessionId));
42504
+ return path128.join(impactEvidenceDataRoot(root), "sessions", sessionStateFilename(sessionId));
42391
42505
  }
42392
42506
  async function loadSessionState(root, sessionId) {
42393
42507
  const file = sessionStatePath(root, sessionId);
@@ -42406,11 +42520,11 @@ async function loadSessionState(root, sessionId) {
42406
42520
  }
42407
42521
  async function saveSessionState(root, sessionId, state) {
42408
42522
  const file = sessionStatePath(root, sessionId);
42409
- await writeContained(root, path127.relative(root, file), `${JSON.stringify(state, null, 2)}
42523
+ await writeContained(root, path128.relative(root, file), `${JSON.stringify(state, null, 2)}
42410
42524
  `);
42411
42525
  }
42412
42526
  function logPath(root) {
42413
- return path127.join(impactEvidenceDataRoot(root), "log.jsonl");
42527
+ return path128.join(impactEvidenceDataRoot(root), "log.jsonl");
42414
42528
  }
42415
42529
  async function appendLogRecord(root, record) {
42416
42530
  const full = {
@@ -42421,7 +42535,7 @@ async function appendLogRecord(root, record) {
42421
42535
  ...record.detail !== undefined ? { detail: record.detail } : {}
42422
42536
  };
42423
42537
  const file = logPath(root);
42424
- await appendContained(root, path127.relative(root, file), `${JSON.stringify(full)}
42538
+ await appendContained(root, path128.relative(root, file), `${JSON.stringify(full)}
42425
42539
  `);
42426
42540
  return full;
42427
42541
  }
@@ -42448,7 +42562,7 @@ init_command_risk();
42448
42562
  init_shell_syntax();
42449
42563
  init_fs();
42450
42564
  init_service2();
42451
- import path128 from "path";
42565
+ import path129 from "path";
42452
42566
  import { createHash as createHash22 } from "crypto";
42453
42567
  import { realpathSync as realpathSync2 } from "fs";
42454
42568
  function impactEvidenceHookClass(strict) {
@@ -42464,29 +42578,29 @@ function realpathNearestExisting(p) {
42464
42578
  for (;; ) {
42465
42579
  try {
42466
42580
  const real = realpathSync2(current);
42467
- return tail.length > 0 ? path128.join(real, ...tail) : real;
42581
+ return tail.length > 0 ? path129.join(real, ...tail) : real;
42468
42582
  } catch {
42469
- const parent = path128.dirname(current);
42583
+ const parent = path129.dirname(current);
42470
42584
  if (parent === current) {
42471
- return tail.length > 0 ? path128.join(current, ...tail) : current;
42585
+ return tail.length > 0 ? path129.join(current, ...tail) : current;
42472
42586
  }
42473
- tail.unshift(path128.basename(current));
42587
+ tail.unshift(path129.basename(current));
42474
42588
  current = parent;
42475
42589
  }
42476
42590
  }
42477
42591
  }
42478
42592
  function normalizeRequestFiles(root, files) {
42479
- const rootReal = realpathNearestExisting(path128.resolve(root));
42593
+ const rootReal = realpathNearestExisting(path129.resolve(root));
42480
42594
  const normalized = [];
42481
42595
  const rejected = [];
42482
42596
  for (const file of files) {
42483
- const lexicalAbsolute = path128.isAbsolute(file) ? path128.resolve(file) : path128.resolve(rootReal, toPosix(file).replace(/^\.\//, ""));
42597
+ const lexicalAbsolute = path129.isAbsolute(file) ? path129.resolve(file) : path129.resolve(rootReal, toPosix(file).replace(/^\.\//, ""));
42484
42598
  const effective = realpathNearestExisting(lexicalAbsolute);
42485
42599
  if (!isPathInside(rootReal, effective)) {
42486
42600
  rejected.push(file);
42487
42601
  continue;
42488
42602
  }
42489
- normalized.push(toPosix(path128.relative(rootReal, effective)));
42603
+ normalized.push(toPosix(path129.relative(rootReal, effective)));
42490
42604
  }
42491
42605
  return { files: [...new Set(normalized)], rejected };
42492
42606
  }
@@ -42768,7 +42882,7 @@ function hostDeliveryStatus() {
42768
42882
  // src/job/service.ts
42769
42883
  init_fs();
42770
42884
  import { copyFile, mkdir as mkdir30 } from "fs/promises";
42771
- import path131 from "path";
42885
+ import path132 from "path";
42772
42886
 
42773
42887
  // src/job/types.ts
42774
42888
  var JOB_INTENTS = ["implement", "analyze", "review", "custom"];
@@ -42909,15 +43023,15 @@ init_validator();
42909
43023
  init_contracts();
42910
43024
  init_fs();
42911
43025
  import { appendFile as appendFile6, mkdir as mkdir29, readFile as readFile63, readdir as readdir21 } from "fs/promises";
42912
- import path130 from "path";
43026
+ import path131 from "path";
42913
43027
  function jobsRoot(cwd) {
42914
- return path130.join(cwd, ".metaproject", "jobs");
43028
+ return path131.join(cwd, ".metaproject", "jobs");
42915
43029
  }
42916
43030
  function jobDir(cwd, name) {
42917
- return path130.join(jobsRoot(cwd), name);
43031
+ return path131.join(jobsRoot(cwd), name);
42918
43032
  }
42919
43033
  function jobStatePath(cwd, name) {
42920
- return path130.join(jobDir(cwd, name), "state.json");
43034
+ return path131.join(jobDir(cwd, name), "state.json");
42921
43035
  }
42922
43036
  var JOB_NAME_PATTERN = /^[a-z0-9-]+$/;
42923
43037
  function assertJobName(name) {
@@ -42954,12 +43068,12 @@ async function writeJob(cwd, name, state) {
42954
43068
  `));
42955
43069
  }
42956
43070
  const file = jobStatePath(cwd, name);
42957
- await mkdir29(path130.dirname(file), { recursive: true });
43071
+ await mkdir29(path131.dirname(file), { recursive: true });
42958
43072
  await writeFileAtomic(file, `${JSON.stringify(state, null, 2)}
42959
43073
  `);
42960
43074
  }
42961
43075
  async function appendJournal2(cwd, name, at, line) {
42962
- await appendFile6(path130.join(jobDir(cwd, name), "journal.md"), `- ${at} - ${line}
43076
+ await appendFile6(path131.join(jobDir(cwd, name), "journal.md"), `- ${at} - ${line}
42963
43077
  `, "utf8");
42964
43078
  }
42965
43079
  function renderJournal2(name, at) {
@@ -42980,7 +43094,7 @@ function assertDocumentType(raw) {
42980
43094
  return raw;
42981
43095
  }
42982
43096
  function documentFileName(type, sourcePath) {
42983
- const extension = path130.extname(sourcePath) || ".md";
43097
+ const extension = path131.extname(sourcePath) || ".md";
42984
43098
  return `${type}${extension}`;
42985
43099
  }
42986
43100
 
@@ -42988,7 +43102,7 @@ function documentFileName(type, sourcePath) {
42988
43102
  function createJobService(deps) {
42989
43103
  const now = () => deps.now().toISOString();
42990
43104
  function lockPath(cwd, name) {
42991
- return path131.join(jobsRoot(cwd), `.job-lock-${name}`);
43105
+ return path132.join(jobsRoot(cwd), `.job-lock-${name}`);
42992
43106
  }
42993
43107
  async function mutate(cwd, name, run) {
42994
43108
  assertJobName(name);
@@ -43037,20 +43151,20 @@ function createJobService(deps) {
43037
43151
  },
43038
43152
  plan: { steps: defaultPlan(intent) },
43039
43153
  documentation: {
43040
- job_path: path131.join(".metaproject", "jobs", name),
43154
+ job_path: path132.join(".metaproject", "jobs", name),
43041
43155
  documents_created: []
43042
43156
  },
43043
43157
  metrics: { steps: [] },
43044
- jobs_root: path131.join(".metaproject", "jobs"),
43158
+ jobs_root: path132.join(".metaproject", "jobs"),
43045
43159
  updated_at: createdAt
43046
43160
  };
43047
43161
  const first = firstOpenStep(state.plan.steps);
43048
43162
  if (first) {
43049
43163
  state.plan.current_step = first.id;
43050
43164
  }
43051
- await writeFileAtomic(path131.join(absolute, "journal.md"), renderJournal2(name, createdAt));
43165
+ await writeFileAtomic(path132.join(absolute, "journal.md"), renderJournal2(name, createdAt));
43052
43166
  await writeJob(input.cwd, name, state);
43053
- return { state, dir: path131.relative(input.cwd, absolute) };
43167
+ return { state, dir: path132.relative(input.cwd, absolute) };
43054
43168
  },
43055
43169
  async status({ cwd, name }) {
43056
43170
  assertJobName(name);
@@ -43062,7 +43176,7 @@ function createJobService(deps) {
43062
43176
  }
43063
43177
  return {
43064
43178
  state,
43065
- dir: path131.join(".metaproject", "jobs", name),
43179
+ dir: path132.join(".metaproject", "jobs", name),
43066
43180
  stepsDone: state.plan.steps.filter((step) => isTerminalStep(step.status)).length,
43067
43181
  stepsTotal: state.plan.steps.length,
43068
43182
  nextStep: firstOpenStep(state.plan.steps),
@@ -43119,23 +43233,23 @@ function createJobService(deps) {
43119
43233
  if (!input.file) {
43120
43234
  throw new Error("Missing --file. Usage: keryx job document <name> --type <type> --file <path>");
43121
43235
  }
43122
- const source = path131.isAbsolute(input.file) ? input.file : path131.join(input.cwd, input.file);
43236
+ const source = path132.isAbsolute(input.file) ? input.file : path132.join(input.cwd, input.file);
43123
43237
  if (!await pathExists(source)) {
43124
43238
  throw new Error(`--file not found: ${input.file}. Write the document first, then record it.`);
43125
43239
  }
43126
43240
  let recorded;
43127
43241
  await mutate(input.cwd, input.name, async (state) => {
43128
43242
  const fileName = documentFileName(type, source);
43129
- const target = path131.join(jobDir(input.cwd, state.job_name), fileName);
43243
+ const target = path132.join(jobDir(input.cwd, state.job_name), fileName);
43130
43244
  await copyFile(source, target);
43131
43245
  state.documentation ??= {};
43132
- state.documentation.job_path ??= path131.join(".metaproject", "jobs", state.job_name);
43246
+ state.documentation.job_path ??= path132.join(".metaproject", "jobs", state.job_name);
43133
43247
  const created = state.documentation.documents_created ?? [];
43134
43248
  state.documentation.documents_created = created.includes(fileName) ? created : [...created, fileName];
43135
43249
  recorded = {
43136
43250
  state,
43137
43251
  document: fileName,
43138
- path: path131.join(".metaproject", "jobs", state.job_name, fileName)
43252
+ path: path132.join(".metaproject", "jobs", state.job_name, fileName)
43139
43253
  };
43140
43254
  return { state, event: "document", detail: `${type} -> ${fileName}` };
43141
43255
  });
@@ -43170,7 +43284,7 @@ function createJobService(deps) {
43170
43284
  name: state.job_name,
43171
43285
  phase: state.phase,
43172
43286
  intent: state.intent,
43173
- dir: path131.join(".metaproject", "jobs", name),
43287
+ dir: path132.join(".metaproject", "jobs", name),
43174
43288
  stepsDone: state.plan.steps.filter((step) => isTerminalStep(step.status)).length,
43175
43289
  stepsTotal: state.plan.steps.length,
43176
43290
  nextStep: firstOpenStep(state.plan.steps)?.id ?? null
@@ -43191,22 +43305,22 @@ init_fs();
43191
43305
  init_preservation();
43192
43306
  import { randomUUID as randomUUID8 } from "crypto";
43193
43307
  import { lstat as lstat10, readdir as readdir26 } from "fs/promises";
43194
- import path146 from "path";
43308
+ import path147 from "path";
43195
43309
 
43196
43310
  // src/session/paths.ts
43197
43311
  init_config_dir();
43198
43312
  init_config_dir();
43199
43313
  import { existsSync as existsSync21 } from "fs";
43200
- import path134 from "path";
43314
+ import path135 from "path";
43201
43315
  function resolveProjectRoot2(cwd) {
43202
- const abs = path134.resolve(cwd);
43316
+ const abs = path135.resolve(cwd);
43203
43317
  let dir = abs;
43204
43318
  for (;; ) {
43205
- const gitPath = path134.join(dir, ".git");
43319
+ const gitPath = path135.join(dir, ".git");
43206
43320
  if (existsSync21(gitPath)) {
43207
43321
  return dir;
43208
43322
  }
43209
- const parent = path134.dirname(dir);
43323
+ const parent = path135.dirname(dir);
43210
43324
  if (parent === dir) {
43211
43325
  break;
43212
43326
  }
@@ -43215,12 +43329,12 @@ function resolveProjectRoot2(cwd) {
43215
43329
  return abs;
43216
43330
  }
43217
43331
  function projectKeyFromPath(projectPath) {
43218
- const abs = path134.resolve(projectPath);
43332
+ const abs = path135.resolve(projectPath);
43219
43333
  const encoded = encodeURIComponent(abs);
43220
43334
  if (encoded.length <= 200) {
43221
43335
  return encoded;
43222
43336
  }
43223
- const base = path134.basename(abs).replace(/[^a-zA-Z0-9._-]+/g, "_").slice(0, 40);
43337
+ const base = path135.basename(abs).replace(/[^a-zA-Z0-9._-]+/g, "_").slice(0, 40);
43224
43338
  let h = 0;
43225
43339
  for (let i = 0;i < abs.length; i++) {
43226
43340
  h = Math.imul(31, h) + abs.charCodeAt(i) | 0;
@@ -43230,22 +43344,22 @@ function projectKeyFromPath(projectPath) {
43230
43344
  }
43231
43345
  function projectSessionsDir(projectPath, dataDir) {
43232
43346
  const key = projectKeyFromPath(resolveProjectRoot2(projectPath));
43233
- return path134.join(keryxDataDir(dataDir), "sessions", key);
43347
+ return path135.join(keryxDataDir(dataDir), "sessions", key);
43234
43348
  }
43235
43349
  function sessionDir(projectPath, sessionId, dataDir) {
43236
- return path134.join(projectSessionsDir(projectPath, dataDir), sessionId);
43350
+ return path135.join(projectSessionsDir(projectPath, dataDir), sessionId);
43237
43351
  }
43238
43352
 
43239
43353
  // src/sac/proposal-lifecycle.ts
43240
43354
  init_fs();
43241
43355
  import { createHash as createHash32, randomUUID as randomUUID7 } from "crypto";
43242
43356
  import { appendFile as appendFile7, mkdir as mkdir34, readdir as readdir25, readFile as readFile73 } from "fs/promises";
43243
- import path145 from "path";
43357
+ import path146 from "path";
43244
43358
 
43245
43359
  // src/sac/index.ts
43246
- import { access as access3, readFile as readFile64, realpath as realpath14 } from "fs/promises";
43360
+ import { access as access3, readFile as readFile64, realpath as realpath15 } from "fs/promises";
43247
43361
  import { createHash as createHash24 } from "crypto";
43248
- import path135 from "path";
43362
+ import path136 from "path";
43249
43363
  import { fileURLToPath as fileURLToPath3 } from "url";
43250
43364
 
43251
43365
  // src/sac/workspace-reference.ts
@@ -43305,21 +43419,21 @@ var normativeSchemaFiles = {
43305
43419
  "review-decision": "review-decision.schema.json"
43306
43420
  };
43307
43421
  var normativeSchemas = new Map;
43308
- var NORMATIVE_SCHEMA_DIR = path135.join("docs", "requirements", "shared-agent-context", "schemas");
43422
+ var NORMATIVE_SCHEMA_DIR = path136.join("docs", "requirements", "shared-agent-context", "schemas");
43309
43423
  async function resolveSacNormativeSchemaPath(fileName, searchFrom = [fileURLToPath3(new URL(".", import.meta.url)), process.cwd()]) {
43310
43424
  const seen = new Set;
43311
43425
  for (const start of searchFrom) {
43312
- let dir = path135.resolve(start);
43426
+ let dir = path136.resolve(start);
43313
43427
  for (let i = 0;i < 10; i++) {
43314
43428
  if (seen.has(dir))
43315
43429
  break;
43316
43430
  seen.add(dir);
43317
- const candidate = path135.join(dir, NORMATIVE_SCHEMA_DIR, fileName);
43431
+ const candidate = path136.join(dir, NORMATIVE_SCHEMA_DIR, fileName);
43318
43432
  try {
43319
43433
  await access3(candidate);
43320
43434
  return candidate;
43321
43435
  } catch {}
43322
- const parent = path135.dirname(dir);
43436
+ const parent = path136.dirname(dir);
43323
43437
  if (parent === dir)
43324
43438
  break;
43325
43439
  dir = parent;
@@ -43988,20 +44102,20 @@ class SacReferenceError extends Error {
43988
44102
  code = "unsafe_workspace_reference";
43989
44103
  }
43990
44104
  async function resolveWorkspaceReference(input) {
43991
- if (!workspacePathPattern.test(input.uri) || path135.isAbsolute(input.uri) || /^[a-z][a-z0-9+.-]*:/i.test(input.uri) || input.uri.includes("\\"))
44105
+ if (!workspacePathPattern.test(input.uri) || path136.isAbsolute(input.uri) || /^[a-z][a-z0-9+.-]*:/i.test(input.uri) || input.uri.includes("\\"))
43992
44106
  throw new SacReferenceError("unsafe workspace reference");
43993
- const lexicalRoot = path135.resolve(input.workspaceRoot);
43994
- const root = await realpath14(lexicalRoot);
43995
- const candidate = path135.resolve(lexicalRoot, input.uri.slice(2));
43996
- if (candidate !== lexicalRoot && !candidate.startsWith(`${lexicalRoot}${path135.sep}`))
44107
+ const lexicalRoot = path136.resolve(input.workspaceRoot);
44108
+ const root = await realpath15(lexicalRoot);
44109
+ const candidate = path136.resolve(lexicalRoot, input.uri.slice(2));
44110
+ if (candidate !== lexicalRoot && !candidate.startsWith(`${lexicalRoot}${path136.sep}`))
43997
44111
  throw new SacReferenceError("workspace reference escapes root");
43998
44112
  let resolved;
43999
44113
  try {
44000
- resolved = await realpath14(candidate);
44114
+ resolved = await realpath15(candidate);
44001
44115
  } catch {
44002
44116
  throw new SacReferenceError("workspace reference is not resolvable");
44003
44117
  }
44004
- if (resolved !== root && !resolved.startsWith(`${root}${path135.sep}`))
44118
+ if (resolved !== root && !resolved.startsWith(`${root}${path136.sep}`))
44005
44119
  throw new SacReferenceError("workspace reference escapes root after realpath");
44006
44120
  return candidate;
44007
44121
  }
@@ -44057,16 +44171,16 @@ async function evaluateStrictSacGuard(input) {
44057
44171
  init_fs();
44058
44172
  import { mkdir as mkdir31, readdir as readdir22, readFile as readFile65 } from "fs/promises";
44059
44173
  import { createHash as createHash25, randomUUID as randomUUID4 } from "crypto";
44060
- import path137 from "path";
44174
+ import path138 from "path";
44061
44175
 
44062
44176
  // src/sac/secure-resource-read.ts
44063
44177
  init_contained_read();
44064
44178
  init_descriptor_read();
44065
- import path136 from "path";
44179
+ import path137 from "path";
44066
44180
  function readWorkspaceFileNoFollow(workspaceRoot, absolutePath) {
44067
- const relativePath = path136.relative(workspaceRoot, absolutePath);
44068
- const components = relativePath.split(path136.sep);
44069
- if (!relativePath || path136.isAbsolute(relativePath) || components.some((component) => !component || component === "." || component === "..")) {
44181
+ const relativePath = path137.relative(workspaceRoot, absolutePath);
44182
+ const components = relativePath.split(path137.sep);
44183
+ if (!relativePath || path137.isAbsolute(relativePath) || components.some((component) => !component || component === "." || component === "..")) {
44070
44184
  throw new Error("safe source path is not workspace-relative");
44071
44185
  }
44072
44186
  return readDescriptorChain(workspaceRoot, absolutePath, {
@@ -44093,8 +44207,8 @@ class WorkspaceService {
44093
44207
  now;
44094
44208
  constructor(options) {
44095
44209
  this.options = options;
44096
- this.root = path137.resolve(options.workspaceRoot);
44097
- this.storageRoot = path137.resolve(options.storageRoot ?? path137.join(this.root, ".metaproject", "workspaces"));
44210
+ this.root = path138.resolve(options.workspaceRoot);
44211
+ this.storageRoot = path138.resolve(options.storageRoot ?? path138.join(this.root, ".metaproject", "workspaces"));
44098
44212
  this.now = options.now ?? (() => new Date);
44099
44213
  }
44100
44214
  async create(input) {
@@ -44420,13 +44534,13 @@ class WorkspaceService {
44420
44534
  return parsed;
44421
44535
  }
44422
44536
  workspaceDir(id) {
44423
- return path137.join(this.storageRoot, id);
44537
+ return path138.join(this.storageRoot, id);
44424
44538
  }
44425
44539
  manifestPath(id) {
44426
- return path137.join(this.workspaceDir(id), "workspace.json");
44540
+ return path138.join(this.workspaceDir(id), "workspace.json");
44427
44541
  }
44428
44542
  lockPath(id) {
44429
- return path137.join(this.storageRoot, `.${id}.lock`);
44543
+ return path138.join(this.storageRoot, `.${id}.lock`);
44430
44544
  }
44431
44545
  timestamp() {
44432
44546
  return this.now().toISOString();
@@ -44545,7 +44659,7 @@ function bindingHash(owner, intent) {
44545
44659
  // src/sac/session-wrap-up.ts
44546
44660
  import { createHash as createHash28 } from "crypto";
44547
44661
  import { mkdir as mkdir33, writeFile as writeFile22 } from "fs/promises";
44548
- import path140 from "path";
44662
+ import path141 from "path";
44549
44663
 
44550
44664
  // src/session/store.ts
44551
44665
  init_preservation();
@@ -44558,7 +44672,7 @@ import {
44558
44672
  renameSync as renameSync5,
44559
44673
  writeFileSync as writeFileSync5
44560
44674
  } from "fs";
44561
- import path139 from "path";
44675
+ import path140 from "path";
44562
44676
  init_slate();
44563
44677
  init_redact();
44564
44678
  var SESSION_SCHEMA_VERSION = 1;
@@ -44651,7 +44765,7 @@ function parseRemote(value) {
44651
44765
  function readSummaryFile(file) {
44652
44766
  let pending;
44653
44767
  try {
44654
- pending = readPendingHistory(path139.dirname(file));
44768
+ pending = readPendingHistory(path140.dirname(file));
44655
44769
  } catch {
44656
44770
  pending = undefined;
44657
44771
  }
@@ -44703,11 +44817,11 @@ class TranscriptUnreadableError extends Error {
44703
44817
  }
44704
44818
  }
44705
44819
  function readJsonl2(file) {
44706
- const pending = readPendingHistory(path139.dirname(file));
44820
+ const pending = readPendingHistory(path140.dirname(file));
44707
44821
  if (pending === undefined && !existsSync22(file)) {
44708
44822
  return [];
44709
44823
  }
44710
- const read = pending !== undefined ? { ok: true, text: pending.files[path139.basename(file)] } : readTranscriptFile(file);
44824
+ const read = pending !== undefined ? { ok: true, text: pending.files[path140.basename(file)] } : readTranscriptFile(file);
44711
44825
  if (!read.ok) {
44712
44826
  throw new TranscriptUnreadableError(file, read.reason);
44713
44827
  }
@@ -44758,11 +44872,11 @@ function listSessions(cwd, dataDir) {
44758
44872
  if (name.startsWith(".")) {
44759
44873
  continue;
44760
44874
  }
44761
- const summary = readSummaryFile(path139.join(root, name, "summary.json"));
44875
+ const summary = readSummaryFile(path140.join(root, name, "summary.json"));
44762
44876
  if (summary === undefined) {
44763
44877
  continue;
44764
44878
  }
44765
- if (path139.resolve(summary.projectPath) !== path139.resolve(projectPath)) {
44879
+ if (path140.resolve(summary.projectPath) !== path140.resolve(projectPath)) {
44766
44880
  continue;
44767
44881
  }
44768
44882
  out.push(summary);
@@ -44795,15 +44909,15 @@ async function readSessionSlate(cwd, sessionId, dataDir) {
44795
44909
  }
44796
44910
  function loadContext(cwd, sessionId, dataDir) {
44797
44911
  const dir = sessionDir(resolveProjectRoot2(cwd), sessionId, dataDir);
44798
- const contextPath = path139.join(dir, "context.jsonl");
44912
+ const contextPath = path140.join(dir, "context.jsonl");
44799
44913
  if (readPendingHistory(dir) !== undefined || existsSync22(contextPath)) {
44800
44914
  return readJsonl2(contextPath);
44801
44915
  }
44802
- return readJsonl2(path139.join(dir, "transcript.jsonl"));
44916
+ return readJsonl2(path140.join(dir, "transcript.jsonl"));
44803
44917
  }
44804
44918
  function loadArchive(cwd, sessionId, dataDir, onDegraded) {
44805
44919
  const dir = sessionDir(resolveProjectRoot2(cwd), sessionId, dataDir);
44806
- const archivePath = path139.join(dir, "archive.jsonl");
44920
+ const archivePath = path140.join(dir, "archive.jsonl");
44807
44921
  if (readPendingHistory(dir) !== undefined || existsSync22(archivePath)) {
44808
44922
  try {
44809
44923
  const archive = readJsonl2(archivePath);
@@ -44878,7 +44992,7 @@ function sessionEvidenceRef(workspaceId, sessionId) {
44878
44992
  }
44879
44993
  async function resolveSessionWrapUp(input) {
44880
44994
  const now = input.now ?? (() => new Date);
44881
- const sessionId = path140.posix.basename(input.sourceRef, ".md");
44995
+ const sessionId = path141.posix.basename(input.sourceRef, ".md");
44882
44996
  const summary = findSession(input.cwd, sessionId);
44883
44997
  if (summary === undefined || input.sourceRef !== sessionEvidenceRef(input.workspaceId, summary.id)) {
44884
44998
  throw new SessionWrapUpError("session_not_found", `no session matching "${input.sourceRef}" in this project \u2014 use \`keryx sessions list\``);
@@ -44895,7 +45009,7 @@ async function resolveSessionWrapUp(input) {
44895
45009
  throw new SessionWrapUpError("session_unreadable", `session "${summary.id}" could not be read: ${cause.message}`);
44896
45010
  }
44897
45011
  const relPath = sessionEvidenceRef(input.workspaceId, summary.id).slice(2);
44898
- const evidenceDir = path140.dirname(relPath);
45012
+ const evidenceDir = path141.dirname(relPath);
44899
45013
  const slate = await readSessionSlate(input.cwd, summary.id);
44900
45014
  const diff = await gitDiff(input.cwd);
44901
45015
  const diffBody = diff.kind === "measured" ? diff.text : unmeasurableDiffBody(diff.detail);
@@ -44917,23 +45031,23 @@ async function resolveSessionWrapUp(input) {
44917
45031
  ""
44918
45032
  ].join(`
44919
45033
  `);
44920
- const wrapUpRelPath = path140.join(evidenceDir, `${summary.id}.wrap-up.md`);
44921
- const diffRelPath = path140.join(evidenceDir, `${summary.id}.diff.txt`);
44922
- const noticeRelPath = path140.join(evidenceDir, `${summary.id}.redaction.md`);
45034
+ const wrapUpRelPath = path141.join(evidenceDir, `${summary.id}.wrap-up.md`);
45035
+ const diffRelPath = path141.join(evidenceDir, `${summary.id}.diff.txt`);
45036
+ const noticeRelPath = path141.join(evidenceDir, `${summary.id}.redaction.md`);
44923
45037
  const floor = await applyEvidenceRedactionFloor(input.cwd, [
44924
- { name: path140.basename(relPath), content: markdown, path: relPath, source: "generated" },
44925
- { name: path140.basename(wrapUpRelPath), content: wrapUpMarkdown, path: wrapUpRelPath, source: "generated" },
44926
- { name: path140.basename(diffRelPath), content: diffBody, path: diffRelPath, source: "tool-output" }
45038
+ { name: path141.basename(relPath), content: markdown, path: relPath, source: "generated" },
45039
+ { name: path141.basename(wrapUpRelPath), content: wrapUpMarkdown, path: wrapUpRelPath, source: "generated" },
45040
+ { name: path141.basename(diffRelPath), content: diffBody, path: diffRelPath, source: "tool-output" }
44927
45041
  ]);
44928
45042
  if (!floor.ok)
44929
45043
  throw new SessionWrapUpError("security_denied", floor.reason);
44930
45044
  const [safeSession, safeWrapUp, safeDiff] = floor.bodies;
44931
- await mkdir33(path140.join(input.cwd, evidenceDir), { recursive: true });
44932
- await writeFile22(path140.join(input.cwd, relPath), safeSession.content, "utf8");
44933
- await writeFile22(path140.join(input.cwd, wrapUpRelPath), safeWrapUp.content, "utf8");
44934
- await writeFile22(path140.join(input.cwd, diffRelPath), safeDiff.content, "utf8");
45045
+ await mkdir33(path141.join(input.cwd, evidenceDir), { recursive: true });
45046
+ await writeFile22(path141.join(input.cwd, relPath), safeSession.content, "utf8");
45047
+ await writeFile22(path141.join(input.cwd, wrapUpRelPath), safeWrapUp.content, "utf8");
45048
+ await writeFile22(path141.join(input.cwd, diffRelPath), safeDiff.content, "utf8");
44935
45049
  if (floor.notice !== undefined)
44936
- await writeFile22(path140.join(input.cwd, noticeRelPath), floor.notice, "utf8");
45050
+ await writeFile22(path141.join(input.cwd, noticeRelPath), floor.notice, "utf8");
44937
45051
  const observedAt = now().toISOString();
44938
45052
  const evidence = [
44939
45053
  { kind: "wrap-up", uri: `./${wrapUpRelPath}`, revision: createHash28("sha256").update(safeWrapUp.content).digest("hex"), observedAt },
@@ -44956,13 +45070,13 @@ async function resolveSessionWrapUp(input) {
44956
45070
  init_fs();
44957
45071
  import { createHash as createHash29, randomBytes as randomBytes6 } from "crypto";
44958
45072
  import { readFile as readFile67 } from "fs/promises";
44959
- import path141 from "path";
45073
+ import path142 from "path";
44960
45074
  var CONFIRM_TOKEN_TTL_MS = 2 * 60000;
44961
45075
  function confirmTokenPath2(cwd, workspaceId, proposalId) {
44962
- return path141.join(cwd, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.confirm-token.json`);
45076
+ return path142.join(cwd, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.confirm-token.json`);
44963
45077
  }
44964
45078
  function confirmReceiptPath(cwd, workspaceId, proposalId, idempotencyKey) {
44965
- return path141.join(cwd, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${sha2563(idempotencyKey)}.confirm-receipt.json`);
45079
+ return path142.join(cwd, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${sha2563(idempotencyKey)}.confirm-receipt.json`);
44966
45080
  }
44967
45081
  function sha2563(text) {
44968
45082
  return createHash29("sha256").update(text).digest("hex");
@@ -45003,21 +45117,21 @@ init_store();
45003
45117
  init_config2();
45004
45118
  import { readFile as readFile69, readdir as readdir24 } from "fs/promises";
45005
45119
  import { randomUUID as randomUUID6 } from "crypto";
45006
- import path143 from "path";
45120
+ import path144 from "path";
45007
45121
 
45008
45122
  // src/sac/proposal-evidence.ts
45009
45123
  init_fs();
45010
45124
  import { createHash as createHash30 } from "crypto";
45011
45125
  import { readFile as readFile68, rm as rm7 } from "fs/promises";
45012
- import path142 from "path";
45126
+ import path143 from "path";
45013
45127
  function proposalPath(cwd, workspaceId, proposalId) {
45014
- return path142.join(cwd, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.json`);
45128
+ return path143.join(cwd, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.json`);
45015
45129
  }
45016
45130
  function ownerReceiptPath(cwd, owner, workspaceId, idempotencyKey) {
45017
- return path142.join(cwd, ".metaproject", "workspaces", workspaceId, `${owner}-write-receipts`, `${idempotencyKey}.json`);
45131
+ return path143.join(cwd, ".metaproject", "workspaces", workspaceId, `${owner}-write-receipts`, `${idempotencyKey}.json`);
45018
45132
  }
45019
45133
  function proposalNotePath(cwd, workspaceId, proposalId) {
45020
- return path142.join(cwd, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.note.txt`);
45134
+ return path143.join(cwd, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.note.txt`);
45021
45135
  }
45022
45136
  async function readVerifiedProposalEvidence(cwd, workspaceId, proposalId) {
45023
45137
  let proposal;
@@ -45031,7 +45145,7 @@ async function readVerifiedProposalEvidence(cwd, workspaceId, proposalId) {
45031
45145
  return { ok: false, code: "no_evidence_to_write" };
45032
45146
  let content;
45033
45147
  try {
45034
- content = await readFile68(path142.join(cwd, evidence.uri), "utf8");
45148
+ content = await readFile68(path143.join(cwd, evidence.uri), "utf8");
45035
45149
  } catch {
45036
45150
  return { ok: false, code: "evidence_file_unreadable" };
45037
45151
  }
@@ -45061,22 +45175,22 @@ function targetRelPath(targetRef) {
45061
45175
  return targetRef.replace(/^\.\//, "");
45062
45176
  }
45063
45177
  function targetAbsolutePath(cwd, targetRef) {
45064
- return path142.join(cwd, ".metaproject", targetRelPath(targetRef));
45178
+ return path143.join(cwd, ".metaproject", targetRelPath(targetRef));
45065
45179
  }
45066
45180
  function targetKey(targetRef) {
45067
45181
  return digestOf2(targetRelPath(targetRef)).slice(0, 32);
45068
45182
  }
45069
45183
  function ownerTargetVersionPath(cwd, owner, workspaceId, targetRef) {
45070
- return path142.join(cwd, ".metaproject", "workspaces", workspaceId, `${owner}-target-versions`, `${targetKey(targetRef)}.json`);
45184
+ return path143.join(cwd, ".metaproject", "workspaces", workspaceId, `${owner}-target-versions`, `${targetKey(targetRef)}.json`);
45071
45185
  }
45072
45186
  function ownerTargetLockPath(cwd, owner, targetRef) {
45073
- return path142.join(cwd, ".metaproject", "data", "sac", "target-locks", owner, `${targetKey(targetRef)}.lock`);
45187
+ return path143.join(cwd, ".metaproject", "data", "sac", "target-locks", owner, `${targetKey(targetRef)}.lock`);
45074
45188
  }
45075
45189
  function ownerStagingDir(cwd, owner, workspaceId, idempotencyKey) {
45076
- return path142.join(cwd, ".metaproject", "workspaces", workspaceId, `${owner}-write-staging`, digestOf2(idempotencyKey).slice(0, 32));
45190
+ return path143.join(cwd, ".metaproject", "workspaces", workspaceId, `${owner}-write-staging`, digestOf2(idempotencyKey).slice(0, 32));
45077
45191
  }
45078
45192
  function ownerConflictDir(cwd, owner, workspaceId, idempotencyKey) {
45079
- return path142.join(cwd, ".metaproject", "workspaces", workspaceId, `${owner}-write-conflicts`, digestOf2(idempotencyKey).slice(0, 32));
45193
+ return path143.join(cwd, ".metaproject", "workspaces", workspaceId, `${owner}-write-conflicts`, digestOf2(idempotencyKey).slice(0, 32));
45080
45194
  }
45081
45195
  async function readJson4(file) {
45082
45196
  try {
@@ -45147,7 +45261,7 @@ async function applyGuardedTargetWrite(input) {
45147
45261
  staged: input.staged,
45148
45262
  stagedAt: receipt.completedAt
45149
45263
  };
45150
- await writeFileAtomic(path142.join(ownerStagingDir(cwd, owner, intent.workspaceId, intent.idempotencyKey), "plan.json"), `${JSON.stringify(staged, null, 2)}
45264
+ await writeFileAtomic(path143.join(ownerStagingDir(cwd, owner, intent.workspaceId, intent.idempotencyKey), "plan.json"), `${JSON.stringify(staged, null, 2)}
45151
45265
  `);
45152
45266
  const applied = await input.apply(input.staged);
45153
45267
  if (!applied.ok) {
@@ -45173,15 +45287,15 @@ async function recoverStagedOwnerWrite(input) {
45173
45287
  });
45174
45288
  }
45175
45289
  async function readStagedOwnerWrite(cwd, owner, workspaceId, idempotencyKey) {
45176
- return readJson4(path142.join(ownerStagingDir(cwd, owner, workspaceId, idempotencyKey), "plan.json"));
45290
+ return readJson4(path143.join(ownerStagingDir(cwd, owner, workspaceId, idempotencyKey), "plan.json"));
45177
45291
  }
45178
45292
  async function recordConflict(input) {
45179
45293
  const base = { targetRef: input.targetRef, expectedVersion: input.expectedVersion, currentVersion: input.currentVersion };
45180
45294
  if (input.proposedContent === undefined)
45181
45295
  return base;
45182
45296
  const dir = ownerConflictDir(input.cwd, input.owner, input.intent.workspaceId, input.intent.idempotencyKey);
45183
- await writeFileAtomic(path142.join(dir, "proposed"), input.proposedContent);
45184
- const diffRef = `./workspaces/${input.intent.workspaceId}/${input.owner}-write-conflicts/${path142.basename(dir)}/proposed`;
45297
+ await writeFileAtomic(path143.join(dir, "proposed"), input.proposedContent);
45298
+ const diffRef = `./workspaces/${input.intent.workspaceId}/${input.owner}-write-conflicts/${path143.basename(dir)}/proposed`;
45185
45299
  return { ...base, diffRef };
45186
45300
  }
45187
45301
 
@@ -45231,7 +45345,7 @@ async function resolveWorkspaceModule(cwd, workspaceId) {
45231
45345
  }
45232
45346
  }
45233
45347
  async function collectWikiDecisionEntries(cwd) {
45234
- const dir = path143.join(cwd, ".metaproject", "wiki", "decisions");
45348
+ const dir = path144.join(cwd, ".metaproject", "wiki", "decisions");
45235
45349
  let files;
45236
45350
  try {
45237
45351
  files = (await readdir24(dir)).filter((name) => name.endsWith(".md"));
@@ -45240,12 +45354,12 @@ async function collectWikiDecisionEntries(cwd) {
45240
45354
  }
45241
45355
  const entries = [];
45242
45356
  for (const file of files) {
45243
- const absolutePath = path143.join(dir, file);
45357
+ const absolutePath = path144.join(dir, file);
45244
45358
  try {
45245
45359
  const content = await readFile69(absolutePath, "utf8");
45246
45360
  entries.push({
45247
45361
  absolutePath,
45248
- relativePath: path143.posix.join("decisions", file),
45362
+ relativePath: path144.posix.join("decisions", file),
45249
45363
  type: extractHeaderField(content, "Type") ?? "decision",
45250
45364
  title: extractTitle(content),
45251
45365
  version: extractHeaderField(content, "Version") ?? null,
@@ -45467,7 +45581,7 @@ function createRealMemoryOwnerWriter(cwd, opts) {
45467
45581
  init_service4();
45468
45582
  init_guard();
45469
45583
  import { readFile as readFile71 } from "fs/promises";
45470
- import path144 from "path";
45584
+ import path145 from "path";
45471
45585
  function renderWrapUpDecisionPage(input) {
45472
45586
  const note = input.note?.trim();
45473
45587
  return `# ${input.title}
@@ -45508,7 +45622,7 @@ export is the source of truth for what actually happened.
45508
45622
  `;
45509
45623
  }
45510
45624
  function wikiPageRelativePath(proposalId) {
45511
- return path144.posix.join("decisions", `sac-${proposalId}.md`);
45625
+ return path145.posix.join("decisions", `sac-${proposalId}.md`);
45512
45626
  }
45513
45627
  function createRealWikiOwnerWriter(cwd, opts) {
45514
45628
  const now = opts?.now ?? (() => new Date);
@@ -45516,7 +45630,7 @@ function createRealWikiOwnerWriter(cwd, opts) {
45516
45630
  const relativePath = staged.relativePath;
45517
45631
  const content = staged.content;
45518
45632
  const history = await openWikiWriteContext(cwd, "sac proposal accept");
45519
- await writeWikiPage(history, path144.join(cwd, ".metaproject", "wiki", relativePath), content);
45633
+ await writeWikiPage(history, path145.join(cwd, ".metaproject", "wiki", relativePath), content);
45520
45634
  return { ok: true };
45521
45635
  };
45522
45636
  return {
@@ -45665,7 +45779,7 @@ class ProposalLifecycleService {
45665
45779
  now;
45666
45780
  constructor(options) {
45667
45781
  this.options = options;
45668
- this.root = path145.resolve(options.workspaceRoot);
45782
+ this.root = path146.resolve(options.workspaceRoot);
45669
45783
  this.now = options.now ?? (() => new Date);
45670
45784
  }
45671
45785
  async create(input) {
@@ -45685,7 +45799,7 @@ class ProposalLifecycleService {
45685
45799
  if (manifest.status === "archived")
45686
45800
  throw new ProposalLifecycleError("guard_denied", "workspace is archived");
45687
45801
  const file = this.proposalPath(workspaceId, proposal.id);
45688
- await mkdir34(path145.dirname(file), { recursive: true, mode: 448 });
45802
+ await mkdir34(path146.dirname(file), { recursive: true, mode: 448 });
45689
45803
  return withFileLock(`${file}.lock`, async () => {
45690
45804
  const consume = this.options.wrapUpAuthority.consume(input.wrapUp, { actor, workspaceId });
45691
45805
  if (consume !== "ok")
@@ -45713,7 +45827,7 @@ class ProposalLifecycleService {
45713
45827
  return this.options.workspaces.withAuthorizedActor({ actorContext: actor, workspaceId: input.workspaceId, action: "review", execute: async (manifest) => {
45714
45828
  const proposal = await this.loadProposal(input.workspaceId, input.proposalId);
45715
45829
  const ledger = this.ledgerPath(input.workspaceId);
45716
- await mkdir34(path145.dirname(ledger), { recursive: true, mode: 448 });
45830
+ await mkdir34(path146.dirname(ledger), { recursive: true, mode: 448 });
45717
45831
  return withFileLock(`${ledger}.lock`, async () => {
45718
45832
  const records = (await this.records(ledger)).filter((record) => record.proposalId === proposal.id);
45719
45833
  const events = records.filter((record) => record.recordType === "proposal-transition");
@@ -45755,7 +45869,7 @@ class ProposalLifecycleService {
45755
45869
  } });
45756
45870
  }
45757
45871
  async listProposedProposals(workspaceId) {
45758
- const proposalsDir = path145.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals");
45872
+ const proposalsDir = path146.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals");
45759
45873
  let entries;
45760
45874
  try {
45761
45875
  entries = (await readdir25(proposalsDir)).filter((name) => name.endsWith(".json"));
@@ -45767,7 +45881,7 @@ class ProposalLifecycleService {
45767
45881
  const proposals = [];
45768
45882
  for (const entry of entries) {
45769
45883
  try {
45770
- const parsed = JSON.parse(await readFile73(path145.join(proposalsDir, entry), "utf8"));
45884
+ const parsed = JSON.parse(await readFile73(path146.join(proposalsDir, entry), "utf8"));
45771
45885
  if (parsed.recordType === "proposal-created")
45772
45886
  proposals.push(parsed);
45773
45887
  } catch {}
@@ -46033,31 +46147,31 @@ class ProposalLifecycleService {
46033
46147
  }
46034
46148
  }
46035
46149
  proposalPath(workspaceId, proposalId) {
46036
- return path145.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.json`);
46150
+ return path146.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.json`);
46037
46151
  }
46038
46152
  decisionRef(proposalId, key) {
46039
46153
  return `./proposals/${proposalId}.${hash2(key)}.decision.json`;
46040
46154
  }
46041
46155
  decisionPath(workspaceId, proposalId, key) {
46042
- return path145.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.decision.json`);
46156
+ return path146.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.decision.json`);
46043
46157
  }
46044
46158
  approvalRef(proposalId, key) {
46045
46159
  return `./proposals/${proposalId}.${hash2(key)}.approval.json`;
46046
46160
  }
46047
46161
  approvalPath(workspaceId, proposalId, key) {
46048
- return path145.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.approval.json`);
46162
+ return path146.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.approval.json`);
46049
46163
  }
46050
46164
  writeResultPath(workspaceId, proposalId, key) {
46051
- return path145.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.write-result.json`);
46165
+ return path146.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.write-result.json`);
46052
46166
  }
46053
46167
  intentRef(proposalId, key) {
46054
46168
  return `./proposals/${proposalId}.${hash2(key)}.write-intent.json`;
46055
46169
  }
46056
46170
  intentPath(workspaceId, proposalId, key) {
46057
- return path145.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.write-intent.json`);
46171
+ return path146.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.write-intent.json`);
46058
46172
  }
46059
46173
  attemptPath(workspaceId, proposalId, key) {
46060
- return path145.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.owner-write-attempt.json`);
46174
+ return path146.join(this.root, ".metaproject", "workspaces", workspaceId, "proposals", `${proposalId}.${hash2(key)}.owner-write-attempt.json`);
46061
46175
  }
46062
46176
  async loadWriteResult(workspaceId, proposalId, key) {
46063
46177
  try {
@@ -46084,7 +46198,7 @@ class ProposalLifecycleService {
46084
46198
  }
46085
46199
  }
46086
46200
  ledgerPath(workspaceId) {
46087
- return path145.join(this.root, ".metaproject", "workspaces", workspaceId, "activity.jsonl");
46201
+ return path146.join(this.root, ".metaproject", "workspaces", workspaceId, "activity.jsonl");
46088
46202
  }
46089
46203
  timestamp() {
46090
46204
  return this.now().toISOString();
@@ -46203,11 +46317,11 @@ async function replayPreservation(input) {
46203
46317
  if (typeof slate.workspaceId !== "string" || !/^[a-z][a-z0-9-]{2,63}$/.test(slate.workspaceId))
46204
46318
  throw new Error("invalid workspace identity");
46205
46319
  const workspaceId = slate.workspaceId;
46206
- const outbox = path146.join(input.dir, "preservation", "outbox");
46207
- const receipt = await readReplayJson(path146.join(outbox, `${input.snapshot}.json`));
46320
+ const outbox = path147.join(input.dir, "preservation", "outbox");
46321
+ const receipt = await readReplayJson(path147.join(outbox, `${input.snapshot}.json`));
46208
46322
  if (receipt.version !== 1 || receipt.snapshot !== input.snapshot || receipt.state !== "pending-review")
46209
46323
  throw new Error("invalid outbox receipt");
46210
- return withFileLock(path146.join(outbox, `${input.snapshot}.delivery.lock`), async () => {
46324
+ return withFileLock(path147.join(outbox, `${input.snapshot}.delivery.lock`), async () => {
46211
46325
  input.signal?.throwIfAborted();
46212
46326
  const { service, wrapUpAuthority, authorizationServer } = createHarnessProposalLifecycleService(input.cwd, {
46213
46327
  workspaceId,
@@ -46234,12 +46348,12 @@ async function replayPreservation(input) {
46234
46348
  } catch (error) {
46235
46349
  if (!(error instanceof ProposalLifecycleError) || error.code !== "conflict")
46236
46350
  throw error;
46237
- const existing = await readReplayJson(path146.join(input.cwd, ".metaproject", "workspaces", workspaceId, "proposals", `${id}.json`));
46351
+ const existing = await readReplayJson(path147.join(input.cwd, ".metaproject", "workspaces", workspaceId, "proposals", `${id}.json`));
46238
46352
  const refs = (evidence) => evidence.map((e) => [e.uri, e.revision]);
46239
46353
  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)))
46240
46354
  throw new Error("delivery conflict mismatch", { cause: error });
46241
46355
  }
46242
- const delivered = path146.join(outbox, `${input.snapshot}.delivered`);
46356
+ const delivered = path147.join(outbox, `${input.snapshot}.delivered`);
46243
46357
  try {
46244
46358
  const marker = await readReplayJson(delivered);
46245
46359
  if (marker.version !== 1 || marker.workspaceId !== workspaceId || marker.proposalId !== id || marker.snapshot !== input.snapshot) {
@@ -46252,7 +46366,7 @@ async function replayPreservation(input) {
46252
46366
  }
46253
46367
  input.afterCreate?.();
46254
46368
  input.signal?.throwIfAborted();
46255
- writePreservationFile(path146.join(outbox, `${input.snapshot}.delivered`), JSON.stringify({ version: 1, workspaceId, proposalId: id, snapshot: input.snapshot }));
46369
+ writePreservationFile(path147.join(outbox, `${input.snapshot}.delivered`), JSON.stringify({ version: 1, workspaceId, proposalId: id, snapshot: input.snapshot }));
46256
46370
  return "proposed";
46257
46371
  }, input.signal ? { signal: input.signal } : {});
46258
46372
  }
@@ -46275,14 +46389,14 @@ async function scanPreservationOutbox(input) {
46275
46389
  const result = { proposed: 0, deferred: 0, unbound: 0 };
46276
46390
  let entries;
46277
46391
  try {
46278
- entries = await readdir26(path146.join(input.dir, "preservation", "outbox"));
46392
+ entries = await readdir26(path147.join(input.dir, "preservation", "outbox"));
46279
46393
  } catch (error) {
46280
46394
  if (error.code === "ENOENT")
46281
46395
  return result;
46282
46396
  throw error;
46283
46397
  }
46284
46398
  let attempted = 0;
46285
- const cursorFile = path146.join(input.dir, "preservation", "outbox", "SCAN_CURSOR");
46399
+ const cursorFile = path147.join(input.dir, "preservation", "outbox", "SCAN_CURSOR");
46286
46400
  for (const entry of resumeScan(entries.filter((name) => /^[a-f0-9]{64}\.json$/.test(name)), cursorFile)) {
46287
46401
  if (input.signal?.aborted || Date.now() >= (input.deadline ?? Infinity) || attempted >= (input.maxItems ?? 8))
46288
46402
  break;
@@ -46307,11 +46421,11 @@ async function replayProjectPreservationOutboxes(input) {
46307
46421
  return boundedReplay(input, scanProjectPreservationOutboxes);
46308
46422
  }
46309
46423
  async function retryProjectPreservation(cwd) {
46310
- return replayProjectPreservationOutboxes({ cwd, dir: path146.join(projectSessionsDir(cwd), ".explicit-retry") });
46424
+ return replayProjectPreservationOutboxes({ cwd, dir: path147.join(projectSessionsDir(cwd), ".explicit-retry") });
46311
46425
  }
46312
46426
  async function scanProjectPreservationOutboxes(input) {
46313
46427
  const result = { proposed: 0, deferred: 0, unbound: 0 };
46314
- const root = path146.dirname(input.dir);
46428
+ const root = path147.dirname(input.dir);
46315
46429
  let entries;
46316
46430
  try {
46317
46431
  entries = await readdir26(root, { withFileTypes: true });
@@ -46322,7 +46436,7 @@ async function scanProjectPreservationOutboxes(input) {
46322
46436
  }
46323
46437
  const deadline = input.deadline ?? Date.now() + 2000;
46324
46438
  let scanned = 0;
46325
- const cursorFile = path146.join(root, ".preservation-replay-cursor");
46439
+ const cursorFile = path147.join(root, ".preservation-replay-cursor");
46326
46440
  const candidates = entries.filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => entry.name);
46327
46441
  for (const name of resumeScan(candidates, cursorFile)) {
46328
46442
  if (input.signal?.aborted || Date.now() >= deadline || scanned >= 32)
@@ -46331,7 +46445,7 @@ async function scanProjectPreservationOutboxes(input) {
46331
46445
  recordScanCursor(cursorFile, name);
46332
46446
  scanned++;
46333
46447
  try {
46334
- const replay = await replayPreservationOutbox({ ...input, deadline, maxItems: 1, dir: path146.join(root, name) });
46448
+ const replay = await replayPreservationOutbox({ ...input, deadline, maxItems: 1, dir: path147.join(root, name) });
46335
46449
  result.proposed += replay.proposed;
46336
46450
  result.deferred += replay.deferred;
46337
46451
  result.unbound += replay.unbound;
@@ -46370,7 +46484,7 @@ async function boundedReplay(input, scan) {
46370
46484
  import { createHash as createHash35, randomUUID as randomUUID9 } from "crypto";
46371
46485
  init_assembly();
46372
46486
  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";
46373
- import path147 from "path";
46487
+ import path148 from "path";
46374
46488
  init_fs();
46375
46489
 
46376
46490
  // src/sac/policy-experiment.ts
@@ -47113,7 +47227,7 @@ function hasReportIntegrity(report) {
47113
47227
  return reportHashPattern.test(reportDigest) && sha2566(body) === reportDigest;
47114
47228
  }
47115
47229
  async function resolvePolicySelection(workspaceRoot, canonicalFallback) {
47116
- const configPath = path147.join(workspaceRoot, ...policyExperimentConfigPath);
47230
+ const configPath = path148.join(workspaceRoot, ...policyExperimentConfigPath);
47117
47231
  let configJson;
47118
47232
  try {
47119
47233
  const raw = await readFile74(configPath, "utf8").catch((error) => {
@@ -47311,9 +47425,9 @@ class FwkReadService {
47311
47425
  const recordedAt = nowIso2(now);
47312
47426
  const id = `receipt-${randomUUID9().replace(/-/g, "").slice(0, 16)}`;
47313
47427
  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"}` } : {} };
47314
- const ledger = path147.join(this.options.canonical.workspaceRoot, ".metaproject", "context-operations", "access-receipts.jsonl");
47315
- const checkpointPath = path147.join(path147.dirname(ledger), "access-receipts.checkpoint.json");
47316
- await mkdir35(path147.dirname(ledger), { recursive: true, mode: 448 });
47428
+ const ledger = path148.join(this.options.canonical.workspaceRoot, ".metaproject", "context-operations", "access-receipts.jsonl");
47429
+ const checkpointPath = path148.join(path148.dirname(ledger), "access-receipts.checkpoint.json");
47430
+ await mkdir35(path148.dirname(ledger), { recursive: true, mode: 448 });
47317
47431
  return withFileLock(`${ledger}.lock`, async () => {
47318
47432
  const state = await resolveLedgerState(ledger, checkpointPath, this.options.verifyReceiptLedger ?? verifyAccessReceiptLedger);
47319
47433
  const receipt = sealAccessReceipt(base, state.headHash);
@@ -47451,7 +47565,7 @@ async function proposeFromSession(input) {
47451
47565
  // src/sac/collaboration-service.ts
47452
47566
  import { appendFile as appendFile9, mkdir as mkdir36, readFile as readFile75 } from "fs/promises";
47453
47567
  import { randomUUID as randomUUID11 } from "crypto";
47454
- import path148 from "path";
47568
+ import path149 from "path";
47455
47569
  class CollaborationServiceError extends Error {
47456
47570
  code;
47457
47571
  constructor(code, message) {
@@ -47466,7 +47580,7 @@ class CollaborationService {
47466
47580
  this.input = input;
47467
47581
  }
47468
47582
  file(id) {
47469
- return path148.join(this.input.workspaceRoot, ".metaproject", "workspaces", id, "activity.jsonl");
47583
+ return path149.join(this.input.workspaceRoot, ".metaproject", "workspaces", id, "activity.jsonl");
47470
47584
  }
47471
47585
  async overview(input) {
47472
47586
  const manifest = await this.input.workspaces.show(input);
@@ -47503,7 +47617,7 @@ class CollaborationService {
47503
47617
  occurredAt: (this.input.now ?? (() => new Date))().toISOString(),
47504
47618
  ...suppliedHandoff ? { handoff: { ...suppliedHandoff, from: actor.subject } } : {}
47505
47619
  });
47506
- await mkdir36(path148.dirname(this.file(manifest.id)), { recursive: true, mode: 448 });
47620
+ await mkdir36(path149.dirname(this.file(manifest.id)), { recursive: true, mode: 448 });
47507
47621
  await appendFile9(this.file(manifest.id), `${JSON.stringify(activity)}
47508
47622
  `, { mode: 384 });
47509
47623
  return normalizeCollaborationResult(activity);
@@ -47553,14 +47667,14 @@ function normalizeCollaborationResult(value) {
47553
47667
  // src/session/external-slate.ts
47554
47668
  init_fs();
47555
47669
  import { mkdir as mkdir38, readdir as readdir27, readFile as readFile76 } from "fs/promises";
47556
- import path150 from "path";
47670
+ import path151 from "path";
47557
47671
 
47558
47672
  // src/sac/machine-wrap-up.ts
47559
47673
  init_fs();
47560
47674
  init_slate();
47561
47675
  import { createHash as createHash36, randomUUID as randomUUID13 } from "crypto";
47562
47676
  import { mkdir as mkdir37 } from "fs/promises";
47563
- import path149 from "path";
47677
+ import path150 from "path";
47564
47678
 
47565
47679
  // src/sac/workspace-resolve.ts
47566
47680
  init_redact();
@@ -47703,11 +47817,11 @@ async function resolveMachineWrapUp(input) {
47703
47817
  `;
47704
47818
  const seedsJson = `${JSON.stringify(seedsForKind.map((seed) => ({ text: seed.text, source: describeSource(seed.source) })), null, 2)}
47705
47819
  `;
47706
- const evidenceRelBase = path149.posix.join(".metaproject", "workspaces", input.workspaceId, "machine-evidence");
47820
+ const evidenceRelBase = path150.posix.join(".metaproject", "workspaces", input.workspaceId, "machine-evidence");
47707
47821
  const floor = await applyEvidenceRedactionFloor(input.cwd, [
47708
- { name: `${input.kind}.diff.txt`, content: diffBody, path: path149.posix.join(evidenceRelBase, `${input.kind}.diff.txt`), source: "tool-output" },
47709
- { name: `${input.kind}.flow.json`, content: flowSnapshotJson, path: path149.posix.join(evidenceRelBase, `${input.kind}.flow.json`), source: "generated" },
47710
- { name: `${input.kind}.seeds.json`, content: seedsJson, path: path149.posix.join(evidenceRelBase, `${input.kind}.seeds.json`), source: "generated" }
47822
+ { name: `${input.kind}.diff.txt`, content: diffBody, path: path150.posix.join(evidenceRelBase, `${input.kind}.diff.txt`), source: "tool-output" },
47823
+ { name: `${input.kind}.flow.json`, content: flowSnapshotJson, path: path150.posix.join(evidenceRelBase, `${input.kind}.flow.json`), source: "generated" },
47824
+ { name: `${input.kind}.seeds.json`, content: seedsJson, path: path150.posix.join(evidenceRelBase, `${input.kind}.seeds.json`), source: "generated" }
47711
47825
  ]);
47712
47826
  if (!floor.ok)
47713
47827
  return { ok: false, code: "security_denied", detail: floor.reason };
@@ -47761,14 +47875,14 @@ ${safeSeeds.content}`;
47761
47875
  }
47762
47876
  summary = result.text.trim().length > 0 ? result.text.trim() : mechanicalSummary(summaryDiff, course);
47763
47877
  }
47764
- const evidenceDir = path149.join(input.cwd, ".metaproject", "workspaces", input.workspaceId, "machine-evidence");
47878
+ const evidenceDir = path150.join(input.cwd, ".metaproject", "workspaces", input.workspaceId, "machine-evidence");
47765
47879
  await mkdir37(evidenceDir, { recursive: true });
47766
47880
  const diffFile = `${input.kind}.${shortHash}.diff.txt`;
47767
47881
  const flowFile = `${input.kind}.${shortHash}.flow.json`;
47768
47882
  const seedsFile = `${input.kind}.${shortHash}.seeds.json`;
47769
- await writeFileAtomic(path149.join(evidenceDir, diffFile), safeDiff.content);
47770
- await writeFileAtomic(path149.join(evidenceDir, flowFile), safeFlow.content);
47771
- await writeFileAtomic(path149.join(evidenceDir, seedsFile), safeSeeds.content);
47883
+ await writeFileAtomic(path150.join(evidenceDir, diffFile), safeDiff.content);
47884
+ await writeFileAtomic(path150.join(evidenceDir, flowFile), safeFlow.content);
47885
+ await writeFileAtomic(path150.join(evidenceDir, seedsFile), safeSeeds.content);
47772
47886
  const observedAt = now().toISOString();
47773
47887
  const relBase = `./.metaproject/workspaces/${input.workspaceId}/machine-evidence`;
47774
47888
  const evidence = [
@@ -47778,7 +47892,7 @@ ${safeSeeds.content}`;
47778
47892
  ];
47779
47893
  if (floor.notice !== undefined) {
47780
47894
  const noticeFile = `${input.kind}.${shortHash}.redaction.md`;
47781
- await writeFileAtomic(path149.join(evidenceDir, noticeFile), floor.notice);
47895
+ await writeFileAtomic(path150.join(evidenceDir, noticeFile), floor.notice);
47782
47896
  evidence.push({ kind: REDACTION_NOTICE_KIND, uri: `${relBase}/${noticeFile}`, revision: sha2567(floor.notice), observedAt });
47783
47897
  }
47784
47898
  return {
@@ -47797,18 +47911,18 @@ async function writeFlooredArchiveArtifact(params) {
47797
47911
  {
47798
47912
  name: params.filename,
47799
47913
  content: params.content,
47800
- path: path149.posix.join("slate-archive", params.filename),
47914
+ path: path150.posix.join("slate-archive", params.filename),
47801
47915
  source: "generated"
47802
47916
  }
47803
47917
  ]);
47804
47918
  if (!floor.ok)
47805
47919
  return { ok: false, code: "security_denied", detail: floor.reason };
47806
47920
  const body = floor.bodies[0];
47807
- const archiveDir = path149.join(params.dir, "slate-archive");
47921
+ const archiveDir = path150.join(params.dir, "slate-archive");
47808
47922
  await mkdir37(archiveDir, { recursive: true });
47809
- await writeFileAtomic(path149.join(archiveDir, params.filename), body.content);
47923
+ await writeFileAtomic(path150.join(archiveDir, params.filename), body.content);
47810
47924
  if (floor.notice !== undefined) {
47811
- await writeFileAtomic(path149.join(archiveDir, `${params.filename}${ARCHIVE_REDACTION_NOTICE_SUFFIX}`), floor.notice);
47925
+ await writeFileAtomic(path150.join(archiveDir, `${params.filename}${ARCHIVE_REDACTION_NOTICE_SUFFIX}`), floor.notice);
47812
47926
  }
47813
47927
  return { ok: true, altered: body.altered };
47814
47928
  }
@@ -47844,9 +47958,9 @@ async function writeWrapUpOutcomeArtifact(cwd, dir, trigger, now, groups) {
47844
47958
  return;
47845
47959
  const refusalIso = now().toISOString();
47846
47960
  const refusalFilename = `${refusalIso.replace(/[:.]/g, "-")}-wrap-up-outcome.json`;
47847
- const archiveDir = path149.join(dir, "slate-archive");
47961
+ const archiveDir = path150.join(dir, "slate-archive");
47848
47962
  await mkdir37(archiveDir, { recursive: true });
47849
- await writeFileAtomic(path149.join(archiveDir, refusalFilename), `${JSON.stringify({
47963
+ await writeFileAtomic(path150.join(archiveDir, refusalFilename), `${JSON.stringify({
47850
47964
  recordType: "wrap-up-outcome",
47851
47965
  trigger,
47852
47966
  generatedAt: refusalIso,
@@ -47983,7 +48097,7 @@ async function runWrapUp(input) {
47983
48097
 
47984
48098
  // src/session/external-slate.ts
47985
48099
  function externalSlatesDir(cwd) {
47986
- return path150.join(cwd, ".keryx", "external-slates");
48100
+ return path151.join(cwd, ".keryx", "external-slates");
47987
48101
  }
47988
48102
  var EXTERNAL_SESSION_ID_PATTERN = /^[A-Za-z0-9_-]{1,128}$/;
47989
48103
  function assertValidExternalSessionId(externalSessionId) {
@@ -47993,14 +48107,14 @@ function assertValidExternalSessionId(externalSessionId) {
47993
48107
  }
47994
48108
  function externalSlatePath(cwd, externalSessionId) {
47995
48109
  assertValidExternalSessionId(externalSessionId);
47996
- return path150.join(externalSlatesDir(cwd), `${externalSessionId}.json`);
48110
+ return path151.join(externalSlatesDir(cwd), `${externalSessionId}.json`);
47997
48111
  }
47998
48112
  function externalSlateLockPath(cwd, externalSessionId) {
47999
48113
  return `${externalSlatePath(cwd, externalSessionId)}.lock`;
48000
48114
  }
48001
48115
  function externalSlateEvidenceDir(cwd, externalSessionId) {
48002
48116
  assertValidExternalSessionId(externalSessionId);
48003
- return path150.join(externalSlatesDir(cwd), externalSessionId);
48117
+ return path151.join(externalSlatesDir(cwd), externalSessionId);
48004
48118
  }
48005
48119
  async function readExternalSlate(cwd, externalSessionId) {
48006
48120
  try {
@@ -48084,12 +48198,12 @@ init_service2();
48084
48198
 
48085
48199
  // src/standard/service.ts
48086
48200
  init_fs();
48087
- import path153 from "path";
48201
+ import path154 from "path";
48088
48202
  import { readFile as readFile79 } from "fs/promises";
48089
48203
 
48090
48204
  // src/standard/validate.ts
48091
48205
  init_fs();
48092
- import path152 from "path";
48206
+ import path153 from "path";
48093
48207
  import { readFile as readFile78 } from "fs/promises";
48094
48208
 
48095
48209
  // src/standard/schemas.ts
@@ -48219,7 +48333,7 @@ var SCHEMA_REGISTRY2 = {
48219
48333
  // src/standard/profiles.ts
48220
48334
  init_fs();
48221
48335
  init_entrypoint_targets();
48222
- import path151 from "path";
48336
+ import path152 from "path";
48223
48337
  import { readFile as readFile77 } from "fs/promises";
48224
48338
  var AGENT_MODULES = ["gdgraph", "gdctx", "gdskills", "gdwiki", "memory"];
48225
48339
  var CI_MODULES = ["health", "testing"];
@@ -48244,7 +48358,7 @@ function enabledModuleKeys(manifest) {
48244
48358
  }
48245
48359
  async function rootEntrypointLinksIndex(cwd, manifest) {
48246
48360
  for (const { path: name } of namedEntrypoints(manifest)) {
48247
- const filePath = path151.join(cwd, name);
48361
+ const filePath = path152.join(cwd, name);
48248
48362
  if (!await pathExists(filePath)) {
48249
48363
  continue;
48250
48364
  }
@@ -48256,16 +48370,16 @@ async function rootEntrypointLinksIndex(cwd, manifest) {
48256
48370
  return false;
48257
48371
  }
48258
48372
  async function minimalSatisfied(cwd) {
48259
- const metaprojectRoot = path151.join(cwd, ".metaproject");
48373
+ const metaprojectRoot = path152.join(cwd, ".metaproject");
48260
48374
  const requiredFiles = ["index.md", "README.md", "metaproject.json"];
48261
48375
  const requiredDirs = ["modules", "rules", "skills", "data"];
48262
48376
  for (const file of requiredFiles) {
48263
- if (!await pathExists(path151.join(metaprojectRoot, file))) {
48377
+ if (!await pathExists(path152.join(metaprojectRoot, file))) {
48264
48378
  return false;
48265
48379
  }
48266
48380
  }
48267
48381
  for (const dir of requiredDirs) {
48268
- if (!await pathExists(path151.join(metaprojectRoot, dir))) {
48382
+ if (!await pathExists(path152.join(metaprojectRoot, dir))) {
48269
48383
  return false;
48270
48384
  }
48271
48385
  }
@@ -48278,7 +48392,7 @@ async function ciSatisfied(cwd, manifest) {
48278
48392
  return false;
48279
48393
  }
48280
48394
  for (const key of ciModules) {
48281
- if (await pathExists(path151.join(cwd, ".metaproject", "data", key, "artifacts"))) {
48395
+ if (await pathExists(path152.join(cwd, ".metaproject", "data", key, "artifacts"))) {
48282
48396
  return true;
48283
48397
  }
48284
48398
  }
@@ -48291,7 +48405,7 @@ async function evaluateProfiles(cwd, manifest) {
48291
48405
  satisfied.push("minimal");
48292
48406
  }
48293
48407
  const hasAgentModule = AGENT_MODULES.some((key) => new Set(enabledModuleKeys(manifest)).has(key));
48294
- const agent = minimal && hasAgentModule && await rootEntrypointLinksIndex(cwd, manifest) && await pathExists(path151.join(cwd, ".metaproject", "rules"));
48408
+ const agent = minimal && hasAgentModule && await rootEntrypointLinksIndex(cwd, manifest) && await pathExists(path152.join(cwd, ".metaproject", "rules"));
48295
48409
  if (agent) {
48296
48410
  satisfied.push("agent");
48297
48411
  }
@@ -48460,20 +48574,20 @@ var MANIFEST_TOP_LEVEL_SCHEMA = {
48460
48574
  async function validateWorkspace2(cwd) {
48461
48575
  const errors = [];
48462
48576
  const warnings = [];
48463
- const metaprojectRoot = path152.join(cwd, ".metaproject");
48577
+ const metaprojectRoot = path153.join(cwd, ".metaproject");
48464
48578
  const requiredFiles = ["index.md", "README.md", "metaproject.json"];
48465
48579
  for (const file of requiredFiles) {
48466
- if (!await pathExists(path152.join(metaprojectRoot, file))) {
48580
+ if (!await pathExists(path153.join(metaprojectRoot, file))) {
48467
48581
  errors.push(issue("missing-required-file", `Required file .metaproject/${file} is missing`, `Run \`keryx init\` to scaffold .metaproject/${file}.`));
48468
48582
  }
48469
48583
  }
48470
48584
  const requiredDirs = ["modules", "rules", "skills", "data"];
48471
48585
  for (const dir of requiredDirs) {
48472
- if (!await pathExists(path152.join(metaprojectRoot, dir))) {
48586
+ if (!await pathExists(path153.join(metaprojectRoot, dir))) {
48473
48587
  errors.push(issue("missing-required-dir", `Required directory .metaproject/${dir}/ is missing`, `Run \`keryx init\` to create .metaproject/${dir}/.`));
48474
48588
  }
48475
48589
  }
48476
- const manifestPath = path152.join(metaprojectRoot, "metaproject.json");
48590
+ const manifestPath = path153.join(metaprojectRoot, "metaproject.json");
48477
48591
  if (!await pathExists(manifestPath)) {
48478
48592
  return { ok: errors.length === 0, errors, warnings };
48479
48593
  }
@@ -48505,7 +48619,7 @@ async function validateWorkspace2(cwd) {
48505
48619
  if (typeof value !== "string") {
48506
48620
  continue;
48507
48621
  }
48508
- if (!await pathExists(path152.join(cwd, value))) {
48622
+ if (!await pathExists(path153.join(cwd, value))) {
48509
48623
  errors.push(issue("missing-declared-path", `Declared path paths.${key} -> ${value} does not exist`, `Create ${value} or remove paths.${key} from metaproject.json.`));
48510
48624
  }
48511
48625
  }
@@ -48515,7 +48629,7 @@ async function validateWorkspace2(cwd) {
48515
48629
  continue;
48516
48630
  }
48517
48631
  if (typeof entry.manifest === "string") {
48518
- if (!await pathExists(path152.join(cwd, entry.manifest))) {
48632
+ if (!await pathExists(path153.join(cwd, entry.manifest))) {
48519
48633
  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.`));
48520
48634
  }
48521
48635
  }
@@ -48524,14 +48638,14 @@ async function validateWorkspace2(cwd) {
48524
48638
  if (typeof value !== "string") {
48525
48639
  continue;
48526
48640
  }
48527
- if (!await pathExists(path152.join(cwd, value))) {
48641
+ if (!await pathExists(path153.join(cwd, value))) {
48528
48642
  const sink = field === "data" ? warnings : errors;
48529
48643
  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.`));
48530
48644
  }
48531
48645
  }
48532
48646
  }
48533
48647
  for (const { path: name, scope } of namedEntrypoints(manifest)) {
48534
- const filePath = path152.join(cwd, name);
48648
+ const filePath = path153.join(cwd, name);
48535
48649
  if (!await pathExists(filePath)) {
48536
48650
  continue;
48537
48651
  }
@@ -48817,6 +48931,7 @@ var HELP_GROUPS = [
48817
48931
  group: "Project knowledge",
48818
48932
  summary: "Portable bundle export/import of skills, rules, agents, memory and hooks across scopes and harnesses."
48819
48933
  },
48934
+ { kind: "cli", name: "issues", group: "Managed work", summary: "Browse GitHub issues and projects, open linked sessions and prepare issue flows." },
48820
48935
  { kind: "cli", name: "flow", group: "Managed work", summary: "Agent-first flow lifecycle (Task Manager)." },
48821
48936
  {
48822
48937
  kind: "cli",
@@ -49574,7 +49689,7 @@ async function runDoctor(cwd) {
49574
49689
  return validateWorkspace2(cwd);
49575
49690
  }
49576
49691
  async function readManifest3(cwd) {
49577
- const manifestPath = path153.join(cwd, ".metaproject", "metaproject.json");
49692
+ const manifestPath = path154.join(cwd, ".metaproject", "metaproject.json");
49578
49693
  if (!await pathExists(manifestPath)) {
49579
49694
  throw new Error("Metaproject is not initialized (missing .metaproject/metaproject.json). Run `keryx init` first.");
49580
49695
  }