@c4a/context-cli 0.7.82 → 0.7.83

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/cli.js CHANGED
@@ -88170,6 +88170,36 @@ var init_packageSiteExtensions = __esm(() => {
88170
88170
  invalid = invalidSiteExtension;
88171
88171
  });
88172
88172
 
88173
+ // src/lib/packageVersion.ts
88174
+ import { existsSync as existsSync16, readFileSync as readFileSync7 } from "node:fs";
88175
+ import { dirname as dirname29, join as join68 } from "node:path";
88176
+ import { fileURLToPath as fileURLToPath6 } from "node:url";
88177
+ function readPackageVersion() {
88178
+ try {
88179
+ let dir = dirname29(fileURLToPath6(import.meta.url));
88180
+ for (let depth = 0;depth < 8; depth += 1) {
88181
+ const packagePath = join68(dir, "package.json");
88182
+ if (existsSync16(packagePath)) {
88183
+ const parsed = JSON.parse(readFileSync7(packagePath, "utf8"));
88184
+ if (typeof parsed.version === "string" && parsed.version.length > 0) {
88185
+ return parsed.version;
88186
+ }
88187
+ break;
88188
+ }
88189
+ const parent = dirname29(dir);
88190
+ if (parent === dir)
88191
+ break;
88192
+ dir = parent;
88193
+ }
88194
+ } catch (error) {
88195
+ throw new TypeError("Context CLI package version cannot be read", {
88196
+ cause: error
88197
+ });
88198
+ }
88199
+ throw new TypeError("Context CLI package version is missing from package.json");
88200
+ }
88201
+ var init_packageVersion = () => {};
88202
+
88173
88203
  // src/project/packageArticleLinks.ts
88174
88204
  import { posix as posix8 } from "node:path";
88175
88205
  function projectPackageArticleLinks(input) {
@@ -88217,11 +88247,11 @@ var init_packageArticleLinks = __esm(() => {
88217
88247
  // src/project/packageRenderCache.ts
88218
88248
  import { createHash as createHash19 } from "node:crypto";
88219
88249
  import { readFile as readFile60 } from "node:fs/promises";
88220
- import { join as join68 } from "node:path";
88250
+ import { join as join69 } from "node:path";
88221
88251
  async function cachedPackageKnowledgeMarkdown(input) {
88222
88252
  const fingerprint = digest3(`${PACKAGE_READER_MARKDOWN_VERSION}
88223
88253
  ${input.content}`);
88224
- const path2 = join68(input.projectRoot, ".tmp/context-runtime/package-render", `${digest3(input.key)}.json`);
88254
+ const path2 = join69(input.projectRoot, ".tmp/context-runtime/package-render", `${digest3(input.key)}.json`);
88225
88255
  try {
88226
88256
  const cached = JSON.parse(await readFile60(path2, "utf8"));
88227
88257
  if (cached !== null && typeof cached === "object" && "fingerprint" in cached && cached.fingerprint === fingerprint && "markdown" in cached && typeof cached.markdown === "string") {
@@ -88243,7 +88273,7 @@ var init_packageRenderCache = __esm(() => {
88243
88273
 
88244
88274
  // src/project/packageAssets.ts
88245
88275
  import { readFile as readFile61 } from "node:fs/promises";
88246
- import { dirname as dirname29, relative as relative21, sep as sep6 } from "node:path";
88276
+ import { dirname as dirname30, relative as relative21, sep as sep6 } from "node:path";
88247
88277
  function posixPath2(value) {
88248
88278
  return value.split(sep6).join("/");
88249
88279
  }
@@ -88265,7 +88295,7 @@ function packageAssetPath(projectRoot, absolute) {
88265
88295
  };
88266
88296
  }
88267
88297
  function packageMarkdownTarget(pageOutputPath, assetOutputPath) {
88268
- const target = posixPath2(relative21(dirname29(pageOutputPath), assetOutputPath));
88298
+ const target = posixPath2(relative21(dirname30(pageOutputPath), assetOutputPath));
88269
88299
  return target.startsWith(".") ? target : `./${target}`;
88270
88300
  }
88271
88301
  async function projectPackageKnowledgeAssets(input) {
@@ -88310,7 +88340,7 @@ var init_packageAssets = __esm(() => {
88310
88340
  // src/project/packageAssetOptimization.ts
88311
88341
  import { createHash as createHash20 } from "node:crypto";
88312
88342
  import { createRequire as createRequire4 } from "node:module";
88313
- import { dirname as dirname30, extname as extname10 } from "node:path";
88343
+ import { dirname as dirname31, extname as extname10 } from "node:path";
88314
88344
  function isPng(bytes) {
88315
88345
  return bytes.byteLength >= 8 && bytes[0] === 137 && bytes[1] === 80 && bytes[2] === 78 && bytes[3] === 71 && bytes[4] === 13 && bytes[5] === 10 && bytes[6] === 26 && bytes[7] === 10;
88316
88346
  }
@@ -88364,7 +88394,7 @@ function isWebp(bytes) {
88364
88394
  }
88365
88395
  function contentAddressedWebpPath(asset, bytes) {
88366
88396
  const digest4 = createHash20("sha256").update(bytes).digest("hex");
88367
- return `${dirname30(asset.packageRelPath)}/${digest4}.webp`;
88397
+ return `${dirname31(asset.packageRelPath)}/${digest4}.webp`;
88368
88398
  }
88369
88399
  async function loadSharpProcessor() {
88370
88400
  const requireFromCli = createRequire4(import.meta.url);
@@ -88577,7 +88607,7 @@ var init_packageAssetOptimization = __esm(() => {
88577
88607
  // src/project/packageAssetDelivery.ts
88578
88608
  import { execFile as execFile8 } from "node:child_process";
88579
88609
  import { realpath as realpath10 } from "node:fs/promises";
88580
- import { join as join69, relative as relative22, sep as sep7 } from "node:path";
88610
+ import { join as join70, relative as relative22, sep as sep7 } from "node:path";
88581
88611
  import { promisify as promisify8 } from "node:util";
88582
88612
  async function git(projectRoot, args) {
88583
88613
  try {
@@ -88597,7 +88627,7 @@ async function git(projectRoot, args) {
88597
88627
  }
88598
88628
  }
88599
88629
  function repositoryPath(repoRoot, projectRoot, asset) {
88600
- const path2 = relative22(repoRoot, join69(projectRoot, asset.knowledgeRelPath)).split(sep7).join("/");
88630
+ const path2 = relative22(repoRoot, join70(projectRoot, asset.knowledgeRelPath)).split(sep7).join("/");
88601
88631
  if (path2 === ".." || path2.startsWith("../") || path2.startsWith("/")) {
88602
88632
  throw new ContextError(ExitCode.WorkspaceStateError, "knowledge asset is outside the current Git repository", {
88603
88633
  category: ErrorCategory.WorkspaceStateInvalid,
@@ -88776,9 +88806,9 @@ var init_packageAssetDelivery = __esm(() => {
88776
88806
  });
88777
88807
 
88778
88808
  // src/project/packageBuildContent.ts
88779
- import { existsSync as existsSync16 } from "node:fs";
88809
+ import { existsSync as existsSync17 } from "node:fs";
88780
88810
  import { mkdir as mkdir24, readFile as readFile62, writeFile as writeFile20 } from "node:fs/promises";
88781
- import { dirname as dirname31, join as join70 } from "node:path";
88811
+ import { dirname as dirname32, join as join71 } from "node:path";
88782
88812
  function globToRegExp(pattern) {
88783
88813
  const normalized = toPosixPath5(pattern);
88784
88814
  if (normalized.endsWith("/**")) {
@@ -88925,8 +88955,8 @@ async function writeRenderedPackageTemplate(input) {
88925
88955
  templateRelPath: renderedRelPath,
88926
88956
  logicalTemplateRelPath: renderedLogicalRelPath
88927
88957
  });
88928
- const outputPath = join70(input.projectRoot, input.pkg.outDir, renderedRelPath);
88929
- await mkdir24(dirname31(outputPath), { recursive: true });
88958
+ const outputPath = join71(input.projectRoot, input.pkg.outDir, renderedRelPath);
88959
+ await mkdir24(dirname32(outputPath), { recursive: true });
88930
88960
  await writeFile20(outputPath, renderTemplateText(file.content, contentVars), "utf8");
88931
88961
  written++;
88932
88962
  }
@@ -88960,7 +88990,7 @@ async function writeSelectedPackageKnowledge(input) {
88960
88990
  for (let offset2 = 0;offset2 < projectedPages.length; offset2 += 8) {
88961
88991
  const results = await Promise.allSettled(projectedPages.slice(offset2, offset2 + 8).map(async (projected) => {
88962
88992
  assertSafeRenderedPath(projected.pageOutputPath, "knowledge path");
88963
- const outputPath = join70(input.projectRoot, input.pkg.outDir, projected.pageOutputPath);
88993
+ const outputPath = join71(input.projectRoot, input.pkg.outDir, projected.pageOutputPath);
88964
88994
  let mediaContent = projected.content;
88965
88995
  const omitted = new Set((delivered.omittedImages ?? []).map((path2) => packageMarkdownTarget(projected.pageOutputPath, path2)));
88966
88996
  for (const link of markdownReaderLinks(mediaContent).reverse()) {
@@ -88977,7 +89007,7 @@ async function writeSelectedPackageKnowledge(input) {
88977
89007
  }
88978
89008
  return;
88979
89009
  });
88980
- await mkdir24(dirname31(outputPath), { recursive: true });
89010
+ await mkdir24(dirname32(outputPath), { recursive: true });
88981
89011
  const links = projectPackageArticleLinks({ markdown: await projectLinks(rewritten), approvedPath: approvedByOutput.get(projected.pageOutputPath), outputPath: projected.pageOutputPath, selected: outputByApproved });
88982
89012
  const markdown = await cachedPackageKnowledgeMarkdown({
88983
89013
  projectRoot: input.projectRoot,
@@ -88997,8 +89027,8 @@ async function writeSelectedPackageKnowledge(input) {
88997
89027
  const deliveredAssets = new Map(delivered.assets.map((asset) => [asset.packageRelPath, asset]));
88998
89028
  for (const asset of deliveredAssets.values()) {
88999
89029
  assertSafeRenderedPath(asset.packageRelPath, "package resource path");
89000
- const outputPath = join70(input.projectRoot, input.pkg.outDir, asset.packageRelPath);
89001
- await mkdir24(dirname31(outputPath), { recursive: true });
89030
+ const outputPath = join71(input.projectRoot, input.pkg.outDir, asset.packageRelPath);
89031
+ await mkdir24(dirname32(outputPath), { recursive: true });
89002
89032
  await writeFile20(outputPath, asset.bytes);
89003
89033
  }
89004
89034
  return {
@@ -89012,8 +89042,8 @@ async function writeSelectedPackageKnowledge(input) {
89012
89042
  async function appendLlmsKnowledge(input) {
89013
89043
  if (packageKind(input.pkg) !== "llms" || input.templateConsumesKnowledge || input.knowledgeCount === 0)
89014
89044
  return 0;
89015
- const outputPath = join70(input.projectRoot, input.pkg.outDir, "llms.txt");
89016
- const existed = existsSync16(outputPath);
89045
+ const outputPath = join71(input.projectRoot, input.pkg.outDir, "llms.txt");
89046
+ const existed = existsSync17(outputPath);
89017
89047
  const existing = existed ? await readFile62(outputPath, "utf8") : "";
89018
89048
  const content3 = existing.trim().length > 0 ? `${existing.trimEnd()}
89019
89049
 
@@ -89022,7 +89052,7 @@ async function appendLlmsKnowledge(input) {
89022
89052
  ${input.bundle}
89023
89053
  ` : `${input.bundle}
89024
89054
  `;
89025
- await mkdir24(dirname31(outputPath), { recursive: true });
89055
+ await mkdir24(dirname32(outputPath), { recursive: true });
89026
89056
  await writeFile20(outputPath, content3, "utf8");
89027
89057
  return existed ? 0 : 1;
89028
89058
  }
@@ -89050,9 +89080,9 @@ var init_packageBuildContent = __esm(() => {
89050
89080
 
89051
89081
  // src/project/siteTranslation.ts
89052
89082
  import { createHash as createHash21 } from "node:crypto";
89053
- import { existsSync as existsSync17 } from "node:fs";
89083
+ import { existsSync as existsSync18 } from "node:fs";
89054
89084
  import { mkdir as mkdir25, readFile as readFile63, readdir as readdir17, rename as rename8, rm as rm12, writeFile as writeFile21 } from "node:fs/promises";
89055
- import { dirname as dirname32, join as join71, relative as relative23, resolve as resolve26 } from "node:path";
89085
+ import { dirname as dirname33, join as join72, relative as relative23, resolve as resolve26 } from "node:path";
89056
89086
  function sha256(value) {
89057
89087
  return createHash21("sha256").update(value).digest("hex");
89058
89088
  }
@@ -89096,7 +89126,7 @@ async function optionalText2(path2) {
89096
89126
  }
89097
89127
  }
89098
89128
  async function readMapTranslation(projectRoot, locale) {
89099
- const content3 = await optionalText2(join71(projectRoot, mapTranslationPath(locale)));
89129
+ const content3 = await optionalText2(join72(projectRoot, mapTranslationPath(locale)));
89100
89130
  if (content3 === undefined)
89101
89131
  return {};
89102
89132
  const parsed = mapTranslationSchema.safeParse(import_yaml38.parse(content3));
@@ -89111,10 +89141,10 @@ async function readMapTranslation(projectRoot, locale) {
89111
89141
  return parsed.data.entries;
89112
89142
  }
89113
89143
  async function listTranslationFiles(root) {
89114
- if (!existsSync17(root))
89144
+ if (!existsSync18(root))
89115
89145
  return [];
89116
89146
  const entries2 = await readdir17(root, { withFileTypes: true, recursive: true });
89117
- return entries2.filter((entry) => entry.isFile() && entry.name.endsWith(".md")).map((entry) => relative23(root, join71(entry.parentPath, entry.name)).split("\\").join("/"));
89147
+ return entries2.filter((entry) => entry.isFile() && entry.name.endsWith(".md")).map((entry) => relative23(root, join72(entry.parentPath, entry.name)).split("\\").join("/"));
89118
89148
  }
89119
89149
  async function selectedArticles(projectRoot, packages) {
89120
89150
  const approved = await listApprovedKnowledge(projectRoot);
@@ -89126,7 +89156,7 @@ async function selectedArticles(projectRoot, packages) {
89126
89156
  return [...selected.values()].sort((left, right) => left.relPath.localeCompare(right.relPath));
89127
89157
  }
89128
89158
  async function readTranslatedArticle(projectRoot, locale, file) {
89129
- const content3 = await optionalText2(join71(projectRoot, translationArticlePath(locale, file.relPath)));
89159
+ const content3 = await optionalText2(join72(projectRoot, translationArticlePath(locale, file.relPath)));
89130
89160
  if (content3 === undefined)
89131
89161
  return;
89132
89162
  const { frontmatter, body } = splitFrontmatter(content3);
@@ -89146,7 +89176,7 @@ async function readTranslatedMapTitles(projectRoot, locale) {
89146
89176
  return new Map(Object.entries(await readMapTranslation(projectRoot, locale)).map(([key, entry]) => [key, entry.title]));
89147
89177
  }
89148
89178
  async function readReceipt(projectRoot) {
89149
- const content3 = await optionalText2(join71(projectRoot, TRANSLATION_RUNTIME_ROOT, RECEIPT_FILE));
89179
+ const content3 = await optionalText2(join72(projectRoot, TRANSLATION_RUNTIME_ROOT, RECEIPT_FILE));
89150
89180
  if (content3 === undefined)
89151
89181
  return;
89152
89182
  try {
@@ -89167,7 +89197,7 @@ async function inspectSiteTranslations(projectRoot, packages) {
89167
89197
  for (const locale of locales) {
89168
89198
  for (const file of articles) {
89169
89199
  const sourceDigest = approvedArticleDigest(file.content);
89170
- const content3 = await optionalText2(join71(projectRoot, translationArticlePath(locale, file.relPath)));
89200
+ const content3 = await optionalText2(join72(projectRoot, translationArticlePath(locale, file.relPath)));
89171
89201
  const stored = content3 === undefined ? undefined : splitFrontmatter(content3).frontmatter.translation;
89172
89202
  items.push({
89173
89203
  kind: "article",
@@ -89194,7 +89224,7 @@ async function inspectSiteTranslations(projectRoot, packages) {
89194
89224
  });
89195
89225
  }
89196
89226
  const known = new Set(articles.map((file) => file.relPath));
89197
- for (const relPath of await listTranslationFiles(join71(projectRoot, TRANSLATIONS_ROOT, locale))) {
89227
+ for (const relPath of await listTranslationFiles(join72(projectRoot, TRANSLATIONS_ROOT, locale))) {
89198
89228
  if (!known.has(relPath))
89199
89229
  orphans.push(translationArticlePath(locale, relPath));
89200
89230
  }
@@ -89245,31 +89275,31 @@ async function prepareSiteTranslation(projectRoot, packages) {
89245
89275
  if (item.state === "current")
89246
89276
  continue;
89247
89277
  const source2 = approved.get(item.approved_path);
89248
- const stored = await optionalText2(join71(projectRoot, item.translation_path));
89278
+ const stored = await optionalText2(join72(projectRoot, item.translation_path));
89249
89279
  const file = `${DRAFT_ROOT}/${item.locale}/${source2.relPath}`;
89250
89280
  const seed = stored ?? source2.content;
89251
- const existing = await optionalText2(join71(projectRoot, file));
89281
+ const existing = await optionalText2(join72(projectRoot, file));
89252
89282
  const body = (content3) => content3.slice(FRONTMATTER_RE3.exec(content3)?.[0].length ?? 0);
89253
89283
  const kept = existing !== undefined && body(existing) !== body(seed);
89254
89284
  if (!kept)
89255
- await atomicWrite(join71(projectRoot, file), seed);
89285
+ await atomicWrite(join72(projectRoot, file), seed);
89256
89286
  const translation = stored === undefined ? undefined : splitFrontmatter(stored).frontmatter.translation;
89257
89287
  const diff = kept || stored === undefined ? undefined : await sourceDiffSince(projectRoot, source2.relPath, stringField3(translation?.source_digest));
89258
89288
  const diffFile = `${file}.diff`;
89259
89289
  if (diff)
89260
- await atomicWrite(join71(projectRoot, diffFile), `${diff}
89290
+ await atomicWrite(join72(projectRoot, diffFile), `${diff}
89261
89291
  `);
89262
89292
  else
89263
- await rm12(join71(projectRoot, diffFile), { force: true });
89293
+ await rm12(join72(projectRoot, diffFile), { force: true });
89264
89294
  items.push({ ...item, file, draft: kept ? "kept" : "generated", source_diff: diff ? diffFile : null });
89265
89295
  articles.push({ locale: item.locale, approved_path: item.approved_path, file });
89266
89296
  }
89267
89297
  const task = { expected_digest: inspection.source_set_digest, locales: inspection.locales, items, orphans: inspection.orphans };
89268
89298
  const taskPath = `${TRANSLATION_RUNTIME_ROOT}/${TASK_FILE}`;
89269
89299
  const submissionPath = `${TRANSLATION_RUNTIME_ROOT}/submission.yaml`;
89270
- await atomicWrite(join71(projectRoot, taskPath), JSON.stringify(task, null, 2) + `
89300
+ await atomicWrite(join72(projectRoot, taskPath), JSON.stringify(task, null, 2) + `
89271
89301
  `);
89272
- await atomicWrite(join71(projectRoot, submissionPath), import_yaml38.stringify({ expected_digest: task.expected_digest, articles, map_entries }));
89302
+ await atomicWrite(join72(projectRoot, submissionPath), import_yaml38.stringify({ expected_digest: task.expected_digest, articles, map_entries }));
89273
89303
  return { ...task, task_path: taskPath, submission_path: submissionPath };
89274
89304
  });
89275
89305
  }
@@ -89317,13 +89347,13 @@ function invalidSubmission(message, extra = {}) {
89317
89347
  });
89318
89348
  }
89319
89349
  async function atomicWrite(path2, content3) {
89320
- await mkdir25(dirname32(path2), { recursive: true });
89350
+ await mkdir25(dirname33(path2), { recursive: true });
89321
89351
  const temp = `${path2}.${process.pid}.tmp`;
89322
89352
  await writeFile21(temp, content3, "utf8");
89323
89353
  await rename8(temp, path2);
89324
89354
  }
89325
89355
  async function writeReceipt(projectRoot, digest4, outcome) {
89326
- await atomicWrite(join71(projectRoot, TRANSLATION_RUNTIME_ROOT, RECEIPT_FILE), JSON.stringify({ source_set_digest: digest4, outcome, recorded_at: new Date().toISOString() }, null, 2) + `
89356
+ await atomicWrite(join72(projectRoot, TRANSLATION_RUNTIME_ROOT, RECEIPT_FILE), JSON.stringify({ source_set_digest: digest4, outcome, recorded_at: new Date().toISOString() }, null, 2) + `
89327
89357
  `);
89328
89358
  }
89329
89359
  function assertExpectedDigest(inspection, expected) {
@@ -89404,12 +89434,12 @@ ${body.trimStart()}` });
89404
89434
  writes.push({ path: mapTranslationPath(locale), content: import_yaml38.stringify({ locale, entries: entries2 }) });
89405
89435
  }
89406
89436
  for (const write of writes)
89407
- await atomicWrite(join71(projectRoot, write.path), write.content);
89437
+ await atomicWrite(join72(projectRoot, write.path), write.content);
89408
89438
  for (const draft of drafts)
89409
89439
  for (const path2 of [draft, `${draft}.diff`])
89410
- await rm12(join71(projectRoot, path2), { force: true });
89440
+ await rm12(join72(projectRoot, path2), { force: true });
89411
89441
  for (const orphan of inspection.orphans)
89412
- await rm12(join71(projectRoot, orphan), { force: true });
89442
+ await rm12(join72(projectRoot, orphan), { force: true });
89413
89443
  await writeReceipt(projectRoot, digest4, "submitted");
89414
89444
  return { written: writes.map((write) => write.path), removed: inspection.orphans };
89415
89445
  });
@@ -89427,9 +89457,9 @@ async function siteTranslationFingerprint(projectRoot, pkg) {
89427
89457
  return null;
89428
89458
  const files = [];
89429
89459
  for (const locale of locales) {
89430
- const root = join71(projectRoot, TRANSLATIONS_ROOT, locale);
89431
- for (const relPath of [...await listTranslationFiles(root), ...existsSync17(join71(root, TRANSLATION_MAP_FILE)) ? [TRANSLATION_MAP_FILE] : []].sort()) {
89432
- files.push([`${locale}/${relPath}`, sha256(await readFile63(join71(root, relPath), "utf8"))]);
89460
+ const root = join72(projectRoot, TRANSLATIONS_ROOT, locale);
89461
+ for (const relPath of [...await listTranslationFiles(root), ...existsSync18(join72(root, TRANSLATION_MAP_FILE)) ? [TRANSLATION_MAP_FILE] : []].sort()) {
89462
+ files.push([`${locale}/${relPath}`, sha256(await readFile63(join72(root, relPath), "utf8"))]);
89433
89463
  }
89434
89464
  }
89435
89465
  return sha256(JSON.stringify(files));
@@ -89666,7 +89696,7 @@ import { createHash as createHash22 } from "node:crypto";
89666
89696
  import { spawn as spawn3 } from "node:child_process";
89667
89697
  import { mkdir as mkdir26, mkdtemp as mkdtemp2, readFile as readFile64, writeFile as writeFile22, rm as rm13, symlink as symlink2, cp, access as access5, stat as stat10 } from "node:fs/promises";
89668
89698
  import { createRequire as createRequire5 } from "node:module";
89669
- import { dirname as dirname33, join as join72, posix as posix10 } from "node:path";
89699
+ import { dirname as dirname34, join as join73, posix as posix10 } from "node:path";
89670
89700
  function sitePagePath(identity) {
89671
89701
  return `pages/${createHash22("sha256").update(identity).digest("hex").slice(0, 32)}.html`;
89672
89702
  }
@@ -89784,9 +89814,9 @@ function siteSections(entries2) {
89784
89814
  }));
89785
89815
  }
89786
89816
  async function compileSite(root, outDir) {
89787
- const vitepressRoot = dirname33(require2.resolve("vitepress/package.json"));
89817
+ const vitepressRoot = dirname34(require2.resolve("vitepress/package.json"));
89788
89818
  await new Promise((resolve8, reject) => {
89789
- const child = spawn3(process.versions.bun ? "node" : process.execPath, [join72(vitepressRoot, "bin/vitepress.js"), "build", root, "--outDir", outDir], { stdio: ["ignore", "pipe", "pipe"] });
89819
+ const child = spawn3(process.versions.bun ? "node" : process.execPath, [join73(vitepressRoot, "bin/vitepress.js"), "build", root, "--outDir", outDir], { stdio: ["ignore", "pipe", "pipe"] });
89790
89820
  let tail = "";
89791
89821
  const receive = (chunk) => {
89792
89822
  tail = (tail + chunk.toString()).slice(-16000);
@@ -89833,8 +89863,8 @@ async function writePackageSite(input) {
89833
89863
  const base = options.base ?? "/";
89834
89864
  const history = await readWorkspaceChangelog(projectRoot);
89835
89865
  const historyDate = history[0]?.date ?? null;
89836
- const root = join72(projectRoot, pkg.outDir);
89837
- const output = join72(projectRoot, packageSiteOutputDir(pkg));
89866
+ const root = join73(projectRoot, pkg.outDir);
89867
+ const output = join73(projectRoot, packageSiteOutputDir(pkg));
89838
89868
  try {
89839
89869
  await access5(output);
89840
89870
  throw new Error("Website output already exists; build through the staged package workflow.");
@@ -89842,9 +89872,9 @@ async function writePackageSite(input) {
89842
89872
  if (error.code !== "ENOENT")
89843
89873
  throw error;
89844
89874
  }
89845
- const temporaryRoot = join72(projectRoot, ".tmp");
89875
+ const temporaryRoot = join73(projectRoot, ".tmp");
89846
89876
  await mkdir26(temporaryRoot, { recursive: true });
89847
- const temporary = await mkdtemp2(join72(temporaryRoot, "website-"));
89877
+ const temporary = await mkdtemp2(join73(temporaryRoot, "website-"));
89848
89878
  try {
89849
89879
  const registry2 = await loadSourcesRegistry({ rootDir: projectRoot });
89850
89880
  const repositoryRemote = await optionalRepoGit(projectRoot, ["remote", "get-url", "origin"]);
@@ -89870,27 +89900,27 @@ async function writePackageSite(input) {
89870
89900
  }
89871
89901
  const sections = siteSections(mapping.entries);
89872
89902
  const resources = new Set(delivered.filter((file) => file.relPath.startsWith("others/assets/") || file.relPath.startsWith("skills/") && !file.relPath.endsWith(".md")).map((file) => file.relPath));
89873
- const configRoot = join72(temporary, ".vitepress");
89874
- await mkdir26(join72(configRoot, "theme"), { recursive: true });
89875
- await mkdir26(join72(temporary, "node_modules"), { recursive: true });
89876
- const vitepressRoot = dirname33(require2.resolve("vitepress/package.json"));
89877
- const vueRequire = createRequire5(join72(vitepressRoot, "package.json"));
89903
+ const configRoot = join73(temporary, ".vitepress");
89904
+ await mkdir26(join73(configRoot, "theme"), { recursive: true });
89905
+ await mkdir26(join73(temporary, "node_modules"), { recursive: true });
89906
+ const vitepressRoot = dirname34(require2.resolve("vitepress/package.json"));
89907
+ const vueRequire = createRequire5(join73(vitepressRoot, "package.json"));
89878
89908
  for (const [name3, path2] of [
89879
89909
  ["vitepress", vitepressRoot],
89880
- ["vue", dirname33(vueRequire.resolve("vue/package.json"))],
89881
- ["@mermaid-js/layout-elk", dirname33(require2.resolve("@mermaid-js/layout-elk/package.json"))],
89882
- ["mermaid", dirname33(require2.resolve("mermaid/package.json"))]
89910
+ ["vue", dirname34(vueRequire.resolve("vue/package.json"))],
89911
+ ["@mermaid-js/layout-elk", dirname34(require2.resolve("@mermaid-js/layout-elk/package.json"))],
89912
+ ["mermaid", dirname34(require2.resolve("mermaid/package.json"))]
89883
89913
  ]) {
89884
- await mkdir26(dirname33(join72(temporary, "node_modules", name3)), { recursive: true });
89885
- await symlink2(path2, join72(temporary, "node_modules", name3), "dir");
89914
+ await mkdir26(dirname34(join73(temporary, "node_modules", name3)), { recursive: true });
89915
+ await symlink2(path2, join73(temporary, "node_modules", name3), "dir");
89886
89916
  }
89887
89917
  const readers = siteReaderLocales(options, pkg.name);
89888
89918
  const marker = createLocaleMarker();
89889
- await writeFile22(join72(configRoot, "theme/index.js"), siteThemeScript);
89890
- await writeFile22(join72(configRoot, "theme/style.css"), siteThemeCss + siteLocaleCss(readers) + siteThemeVariables(await resolveSiteTheme(projectRoot, options.theme, true)));
89919
+ await writeFile22(join73(configRoot, "theme/index.js"), siteThemeScript);
89920
+ await writeFile22(join73(configRoot, "theme/style.css"), siteThemeCss + siteLocaleCss(readers) + siteThemeVariables(await resolveSiteTheme(projectRoot, options.theme, true)));
89891
89921
  await writeSiteExtensions(projectRoot, temporary, options.extensions);
89892
89922
  const localizer = await createSiteLocalizer({ projectRoot, readers, marker, selected, byPath, resources });
89893
- await mkdir26(join72(temporary, "pages"), { recursive: true });
89923
+ await mkdir26(join73(temporary, "pages"), { recursive: true });
89894
89924
  const primaryBody = (page, packageContent) => {
89895
89925
  let content3 = packageContent;
89896
89926
  if (page.package_path === "wikis/index.md" && typeof pkg.repoContentPage !== "object") {
@@ -89920,9 +89950,9 @@ ${titles ? `contextTitles: ${JSON.stringify(titles)}
89920
89950
  `;
89921
89951
  };
89922
89952
  for (const page of byPath.values()) {
89923
- const content3 = await readFile64(join72(root, page.package_path), "utf8");
89953
+ const content3 = await readFile64(join73(root, page.package_path), "utf8");
89924
89954
  const localized = await localizer.page(page, primaryBody(page, content3));
89925
- await writeFile22(join72(temporary, page.site_path.replace(/\.html$/u, ".md")), `${pageFrontmatter(page, content3, localized.titles)}
89955
+ await writeFile22(join73(temporary, page.site_path.replace(/\.html$/u, ".md")), `${pageFrontmatter(page, content3, localized.titles)}
89926
89956
  ${localized.body}`);
89927
89957
  }
89928
89958
  const themeSections = sections.map((section) => ({
@@ -89981,7 +90011,7 @@ ${localized.body}`);
89981
90011
  contextLocales: { primary: readers.primary, tags: readers.tags, labels: readers.labels, titles: readers.titles, preferenceKey: readers.preferenceKey }
89982
90012
  }
89983
90013
  };
89984
- await writeFile22(join72(configRoot, "config.mjs"), `const contextLocaleMarker = ${JSON.stringify(readers.translated ? marker : null)};
90014
+ await writeFile22(join73(configRoot, "config.mjs"), `const contextLocaleMarker = ${JSON.stringify(readers.translated ? marker : null)};
89985
90015
  ` + `export default { ...${JSON.stringify(config)}, markdown: { ${siteMarkdownConfig} },
89986
90016
  ` + ` transformHtml: html => html.replace(/<script id="check-dark-mode">[\\s\\S]*?<\\/script>/u, "") };
89987
90017
  `);
@@ -89997,9 +90027,9 @@ ${localized.body}`);
89997
90027
  menu(lines, entries2, 0, tag);
89998
90028
  lines.push("", "</div>", "");
89999
90029
  };
90000
- await mkdir26(join72(temporary, "sections"), { recursive: true });
90030
+ await mkdir26(join73(temporary, "sections"), { recursive: true });
90001
90031
  for (const section of sections) {
90002
- await writeFile22(join72(temporary, section.href.slice(1).replace(/\.html$/u, ".md")), localizer.variants((tag) => {
90032
+ await writeFile22(join73(temporary, section.href.slice(1).replace(/\.html$/u, ".md")), localizer.variants((tag) => {
90003
90033
  const lines = [`# ${mdLabel(localizer.entryTitle(tag, section.entry))}`, "", '<div class="context-section-grid">', ""];
90004
90034
  const grouped = section.entries.some((entry) => entry.children.length > 0);
90005
90035
  let articles = [];
@@ -90038,12 +90068,12 @@ ${localized.body}`);
90038
90068
  ` : "";
90039
90069
  const homeHero = options.extensions?.slots?.banner === undefined ? `hero: ${JSON.stringify(hero)}
90040
90070
  ${heroActions}` : "";
90041
- await writeFile22(join72(temporary, "index.md"), `---
90071
+ await writeFile22(join73(temporary, "index.md"), `---
90042
90072
  layout: home
90043
90073
  title: ${JSON.stringify(options.home?.title ?? options.title ?? pkg.name)}
90044
90074
  ${homeHero}---
90045
90075
  `);
90046
- await writeFile22(join72(temporary, "changelog.md"), `---
90076
+ await writeFile22(join73(temporary, "changelog.md"), `---
90047
90077
  title: Changelog
90048
90078
  contextHistory: ${JSON.stringify(Buffer.from(JSON.stringify(history)).toString("base64"))}
90049
90079
  ---
@@ -90056,19 +90086,19 @@ contextHistory: ${JSON.stringify(Buffer.from(JSON.stringify(history)).toString("
90056
90086
  assetsPrefix: "resources/",
90057
90087
  articles: await Promise.all(llmsArticles(pkg, selected).map(async (article) => ({
90058
90088
  ...article,
90059
- content: await readFile64(join72(root, article.path), "utf8")
90089
+ content: await readFile64(join73(root, article.path), "utf8")
90060
90090
  }))),
90061
90091
  ...structure ? { map: structure } : {}
90062
90092
  });
90063
- await writeLlmsDocuments(join72(temporary, "public"), llms, { utf8Bom: true });
90064
- await mkdir26(join72(temporary, "llms"), { recursive: true });
90093
+ await writeLlmsDocuments(join73(temporary, "public"), llms, { utf8Bom: true });
90094
+ await mkdir26(join73(temporary, "llms"), { recursive: true });
90065
90095
  let landingNavigation = llms.navigationMarkdown;
90066
90096
  for (const link of markdownReaderLinks(landingNavigation).reverse()) {
90067
90097
  if (!link.target.startsWith(base))
90068
90098
  continue;
90069
90099
  landingNavigation = landingNavigation.slice(0, link.start) + `[${link.label}](</${link.target.slice(base.length)}>)` + landingNavigation.slice(link.end);
90070
90100
  }
90071
- await writeFile22(join72(temporary, "llms/index.md"), `---
90101
+ await writeFile22(join73(temporary, "llms/index.md"), `---
90072
90102
  title: LLM Docs
90073
90103
  ---
90074
90104
 
@@ -90078,9 +90108,9 @@ title: LLM Docs
90078
90108
 
90079
90109
  ` + landingNavigation);
90080
90110
  for (const path2 of resources) {
90081
- const destination = join72(temporary, "public/resources", path2);
90082
- await mkdir26(dirname33(destination), { recursive: true });
90083
- await cp(join72(root, path2), destination);
90111
+ const destination = join73(temporary, "public/resources", path2);
90112
+ await mkdir26(dirname34(destination), { recursive: true });
90113
+ await cp(join73(root, path2), destination);
90084
90114
  }
90085
90115
  await compileSite(temporary, output);
90086
90116
  const originLinks = [...navigation.nav, ...navigation.more].filter((item) => item.origin).map((item) => item.link);
@@ -90112,11 +90142,11 @@ title: LLM Docs
90112
90142
  warnings: mapping.warnings
90113
90143
  }, null, 2) + `
90114
90144
  `;
90115
- const packageSiteMap = join72(projectRoot, pkg.outDir, "context-site-map.json");
90116
- const distributedSiteMap = join72(projectRoot, pkg.outDir, packageDistributionMetadataPath("context-site-map.json"));
90117
- await mkdir26(dirname33(distributedSiteMap), { recursive: true });
90145
+ const packageSiteMap = join73(projectRoot, pkg.outDir, "context-site-map.json");
90146
+ const distributedSiteMap = join73(projectRoot, pkg.outDir, packageDistributionMetadataPath("context-site-map.json"));
90147
+ await mkdir26(dirname34(distributedSiteMap), { recursive: true });
90118
90148
  await Promise.all([
90119
- writeFile22(join72(output, "context-site-map.json"), siteMapContent),
90149
+ writeFile22(join73(output, "context-site-map.json"), siteMapContent),
90120
90150
  writeFile22(packageSiteMap, siteMapContent),
90121
90151
  writeFile22(distributedSiteMap, siteMapContent)
90122
90152
  ]);
@@ -90145,13 +90175,22 @@ var init_packageSite2 = __esm(() => {
90145
90175
  init_packageSiteBranding();
90146
90176
  init_packageSiteExtensions();
90147
90177
  init_packageDistributionMetadata();
90178
+ init_packageVersion();
90148
90179
  init_packageSiteLocales();
90149
- PACKAGE_SITE_VERSION = `vitepress-site-v50-light-shared-preferences:${createHash22("sha256").update(JSON.stringify([siteThemeVariables.toString(), siteMarkdownConfig, siteThemeCss, siteThemeScript, siteThemeLabels("zh"), siteThemeLabels("en")])).digest("hex")}`;
90180
+ PACKAGE_SITE_VERSION = `vitepress-site-v50-light-shared-preferences:${createHash22("sha256").update(JSON.stringify([
90181
+ readPackageVersion(),
90182
+ siteThemeVariables.toString(),
90183
+ siteMarkdownConfig,
90184
+ siteThemeCss,
90185
+ siteThemeScript,
90186
+ siteThemeLabels("zh"),
90187
+ siteThemeLabels("en")
90188
+ ])).digest("hex")}`;
90150
90189
  require2 = createRequire5(import.meta.url);
90151
90190
  });
90152
90191
 
90153
90192
  // src/project/workspaceBuildVersion.ts
90154
- import { join as join73 } from "node:path";
90193
+ import { join as join74 } from "node:path";
90155
90194
  import { mkdir as mkdir27, writeFile as writeFile23 } from "node:fs/promises";
90156
90195
  async function workspaceVersionFingerprint(root) {
90157
90196
  return { version: await workspaceVersion(root), changelog: await readWorkspaceChangelog(root) };
@@ -90163,8 +90202,8 @@ async function writePackageVersion(projectRoot, output) {
90163
90202
  throw new TypeError(`Package template uses reserved version output ${path2}; rename that template output.`);
90164
90203
  }
90165
90204
  await mkdir27(output, { recursive: true });
90166
- await writeFile23(join73(output, "CHANGELOG.md"), renderChangelog(info.changelog));
90167
- await writeFile23(join73(output, "context-version.json"), JSON.stringify({ version: info.version }) + `
90205
+ await writeFile23(join74(output, "CHANGELOG.md"), renderChangelog(info.changelog));
90206
+ await writeFile23(join74(output, "context-version.json"), JSON.stringify({ version: info.version }) + `
90168
90207
  `);
90169
90208
  }
90170
90209
  var init_workspaceBuildVersion = __esm(() => {
@@ -90173,40 +90212,40 @@ var init_workspaceBuildVersion = __esm(() => {
90173
90212
 
90174
90213
  // src/project/packageBuildStage.ts
90175
90214
  import { mkdir as mkdir28, mkdtemp as mkdtemp3, readFile as readFile65, rename as rename9, rm as rm14, rmdir } from "node:fs/promises";
90176
- import { dirname as dirname34, join as join74, relative as relative24 } from "node:path";
90215
+ import { dirname as dirname35, join as join75, relative as relative24 } from "node:path";
90177
90216
  async function withStagedPackageOutput(projectRoot, pkg, render) {
90178
- const tempRoot = join74(projectRoot, ".tmp");
90217
+ const tempRoot = join75(projectRoot, ".tmp");
90179
90218
  await mkdir28(tempRoot, { recursive: true });
90180
- const stage = await mkdtemp3(join74(tempRoot, "package-build-"));
90181
- const stagedPackage = { ...pkg, outDir: relative24(projectRoot, join74(stage, pkg.name)) };
90219
+ const stage = await mkdtemp3(join75(tempRoot, "package-build-"));
90220
+ const stagedPackage = { ...pkg, outDir: relative24(projectRoot, join75(stage, pkg.name)) };
90182
90221
  try {
90183
- await mkdir28(join74(projectRoot, stagedPackage.outDir), { recursive: true });
90222
+ await mkdir28(join75(projectRoot, stagedPackage.outDir), { recursive: true });
90184
90223
  const value = await render(stagedPackage);
90185
90224
  await validatePackageIndexLinks({ projectRoot, pkg: stagedPackage });
90186
90225
  const destinations = packageOutputDirs(pkg);
90187
90226
  const staged = packageOutputDirs(stagedPackage);
90188
90227
  for (const [index2, destination] of destinations.entries()) {
90189
- const target = join74(projectRoot, destination);
90228
+ const target = join75(projectRoot, destination);
90190
90229
  const previous2 = await walkPackageFiles(target);
90191
- const next = await walkPackageFiles(join74(projectRoot, staged[index2]));
90230
+ const next = await walkPackageFiles(join75(projectRoot, staged[index2]));
90192
90231
  const desired = new Set(next.map((file) => file.relPath));
90193
90232
  for (const file of previous2) {
90194
90233
  if (desired.has(file.relPath))
90195
90234
  continue;
90196
90235
  await rm14(file.absPath);
90197
- let directory = dirname34(file.absPath);
90236
+ let directory = dirname35(file.absPath);
90198
90237
  while (directory !== target) {
90199
90238
  try {
90200
90239
  await rmdir(directory);
90201
90240
  } catch {
90202
90241
  break;
90203
90242
  }
90204
- directory = dirname34(directory);
90243
+ directory = dirname35(directory);
90205
90244
  }
90206
90245
  }
90207
90246
  for (let offset2 = 0;offset2 < next.length; offset2 += 8) {
90208
90247
  const results = await Promise.allSettled(next.slice(offset2, offset2 + 8).map(async (file) => {
90209
- const output = join74(target, file.relPath);
90248
+ const output = join75(target, file.relPath);
90210
90249
  const bytes = await readFile65(file.absPath);
90211
90250
  const old = await readFile65(output).catch((error) => {
90212
90251
  if (error.code === "ENOENT")
@@ -90215,7 +90254,7 @@ async function withStagedPackageOutput(projectRoot, pkg, render) {
90215
90254
  });
90216
90255
  if (old?.equals(bytes))
90217
90256
  return;
90218
- await mkdir28(dirname34(output), { recursive: true });
90257
+ await mkdir28(dirname35(output), { recursive: true });
90219
90258
  await rename9(file.absPath, output);
90220
90259
  }));
90221
90260
  for (const result of results)
@@ -90454,7 +90493,7 @@ var init_newKnowledgePage = __esm(() => {
90454
90493
 
90455
90494
  // src/project/repoContentLinks.ts
90456
90495
  import { lstat as lstat14, mkdir as mkdir29, readdir as readdir18, readlink, symlink as symlink3, unlink as unlink2 } from "node:fs/promises";
90457
- import { dirname as dirname35, join as join75, relative as relative25 } from "node:path";
90496
+ import { dirname as dirname36, join as join76, relative as relative25 } from "node:path";
90458
90497
  function repoContentLinksNeedRepair(results) {
90459
90498
  return results.some((item) => item.status === "missing" || item.status === "mismatch");
90460
90499
  }
@@ -90478,12 +90517,12 @@ async function inspectRepoContentLinks(projectRoot, repair = false) {
90478
90517
  return [{
90479
90518
  type: "repo-content",
90480
90519
  name: "repo-content.yaml",
90481
- path: join75(projectRoot, "repo-content.yaml"),
90520
+ path: join76(projectRoot, "repo-content.yaml"),
90482
90521
  status: "invalid",
90483
90522
  message: `${error instanceof Error ? error.message : String(error)}. Correct the registry before repairing the view; existing links are unchanged.`
90484
90523
  }];
90485
90524
  }
90486
- const view = join75(registry2?.projectRoot ?? projectRoot, "repo-content");
90525
+ const view = join76(registry2?.projectRoot ?? projectRoot, "repo-content");
90487
90526
  const viewInfo = await info(view);
90488
90527
  if (viewInfo && !viewInfo.isDirectory())
90489
90528
  return [{
@@ -90501,7 +90540,7 @@ async function inspectRepoContentLinks(projectRoot, repair = false) {
90501
90540
  return;
90502
90541
  for (const file of await readdir18(directory, { withFileTypes: true })) {
90503
90542
  const mount = prefix + file.name;
90504
- const path2 = join75(directory, file.name);
90543
+ const path2 = join76(directory, file.name);
90505
90544
  if (file.isSymbolicLink() && !expected.has(mount)) {
90506
90545
  if (repair && !disabled)
90507
90546
  await unlink2(path2);
@@ -90517,13 +90556,13 @@ async function inspectRepoContentLinks(projectRoot, repair = false) {
90517
90556
  }
90518
90557
  }
90519
90558
  for (const entry of registry2?.entries ?? []) {
90520
- const path2 = join75(view, entry.mountPath);
90559
+ const path2 = join76(view, entry.mountPath);
90521
90560
  const base = { type: "repo-content", name: entry.id, path: path2 };
90522
90561
  if (!await repoContentTargetExists(entry)) {
90523
90562
  results.push({ ...base, status: "target-missing", message: `Check the registered path ${entry.path}, sparse checkout, or a possible move; no content was restored.` });
90524
90563
  continue;
90525
90564
  }
90526
- const parent = dirname35(path2);
90565
+ const parent = dirname36(path2);
90527
90566
  const parentInfo = parent === view ? viewInfo : await info(parent);
90528
90567
  if (parentInfo && !parentInfo.isDirectory()) {
90529
90568
  results.push({ ...base, status: "conflict", message: "View parent is not an ordinary directory." });
@@ -90578,11 +90617,11 @@ __export(exports_knowledgeUpdate, {
90578
90617
  beginKnowledgeUpdate: () => beginKnowledgeUpdate
90579
90618
  });
90580
90619
  import { readFile as readFile66 } from "node:fs/promises";
90581
- import { join as join76 } from "node:path";
90620
+ import { join as join77 } from "node:path";
90582
90621
  async function readKnowledgeUpdate(projectRoot) {
90583
90622
  let value;
90584
90623
  try {
90585
- value = JSON.parse(await readFile66(join76(projectRoot, await revisionStoragePath(projectRoot)), "utf8"));
90624
+ value = JSON.parse(await readFile66(join77(projectRoot, await revisionStoragePath(projectRoot)), "utf8"));
90586
90625
  } catch (error) {
90587
90626
  if (error && typeof error === "object" && "code" in error && error.code === "ENOENT")
90588
90627
  return;
@@ -90643,7 +90682,7 @@ async function beginKnowledgeUpdate(projectRoot, value) {
90643
90682
  ...input.changes === undefined ? {} : { changes: input.changes }
90644
90683
  };
90645
90684
  const request = updateSchema.parse({ ...payload, revision: indexerProtocolDigest(payload) });
90646
- await atomicWriteFile(join76(projectRoot, await revisionStoragePath(projectRoot)), `${JSON.stringify(request)}
90685
+ await atomicWriteFile(join77(projectRoot, await revisionStoragePath(projectRoot)), `${JSON.stringify(request)}
90647
90686
  `);
90648
90687
  return {
90649
90688
  outcome: "update-prepared",
@@ -90728,7 +90767,7 @@ async function completeKnowledgeUpdate(input) {
90728
90767
  if (input.new_topics.length && !input.structure_approved) {
90729
90768
  const { revision: _revision, ...rest } = request;
90730
90769
  const payload = { ...rest, structure_proposal: { decisions: input.decisions, scope_summary: input.scope_summary, new_topics: input.new_topics } };
90731
- await atomicWriteFile(join76(input.projectRoot, await revisionStoragePath(input.projectRoot)), `${JSON.stringify({ ...payload, revision: indexerProtocolDigest(payload) })}
90770
+ await atomicWriteFile(join77(input.projectRoot, await revisionStoragePath(input.projectRoot)), `${JSON.stringify({ ...payload, revision: indexerProtocolDigest(payload) })}
90732
90771
  `);
90733
90772
  return { outcome: "structure-review-required" };
90734
90773
  }
@@ -90765,7 +90804,7 @@ async function completeUpdateStructureReview(input) {
90765
90804
  const { revision: _revision, structure_proposal: _proposal, ...rest } = request;
90766
90805
  const payload = { ...rest, changes: `${rest.changes ?? ""}
90767
90806
  Structure feedback: ${input.feedback}` };
90768
- await atomicWriteFile(join76(input.projectRoot, await revisionStoragePath(input.projectRoot)), `${JSON.stringify({ ...payload, revision: indexerProtocolDigest(payload) })}
90807
+ await atomicWriteFile(join77(input.projectRoot, await revisionStoragePath(input.projectRoot)), `${JSON.stringify({ ...payload, revision: indexerProtocolDigest(payload) })}
90769
90808
  `);
90770
90809
  return { outcome: "structure-adjustment-required" };
90771
90810
  });
@@ -90828,9 +90867,9 @@ __export(exports_packageBuilder, {
90828
90867
  buildProjectPackages: () => buildProjectPackages
90829
90868
  });
90830
90869
  import { createHash as createHash23 } from "node:crypto";
90831
- import { existsSync as existsSync18 } from "node:fs";
90870
+ import { existsSync as existsSync19 } from "node:fs";
90832
90871
  import { mkdir as mkdir30, readdir as readdir19, readFile as readFile67, rm as rm15, writeFile as writeFile24 } from "node:fs/promises";
90833
- import { dirname as dirname36, join as join77, resolve as resolve27 } from "node:path";
90872
+ import { dirname as dirname37, join as join78, resolve as resolve27 } from "node:path";
90834
90873
  function packageAssetDeliverySummary(value) {
90835
90874
  if (value === null || typeof value !== "object" || Array.isArray(value))
90836
90875
  return;
@@ -90852,7 +90891,7 @@ function assertPackageOutputDir(pkg) {
90852
90891
  }
90853
90892
  function packageFingerprintPath(projectRoot, pkg) {
90854
90893
  assertSafeRenderedPath(`${pkg.name}.json`, "package fingerprint path");
90855
- return join77(projectRoot, PACKAGE_FINGERPRINT_ROOT, `${pkg.name}.json`);
90894
+ return join78(projectRoot, PACKAGE_FINGERPRINT_ROOT, `${pkg.name}.json`);
90856
90895
  }
90857
90896
  async function listApprovedKnowledge(projectRoot) {
90858
90897
  const metadata = await readApprovedKnowledgeMetadataIndex(projectRoot);
@@ -90883,7 +90922,7 @@ function isDeprecatedKnowledge(content3) {
90883
90922
  async function listTemplateFiles(projectRoot, templatePath) {
90884
90923
  assertSafeRenderedPath(templatePath, "package template path");
90885
90924
  const templateRoot = resolve27(projectRoot, templatePath);
90886
- if (!existsSync18(templateRoot)) {
90925
+ if (!existsSync19(templateRoot)) {
90887
90926
  throw new ContextError(ExitCode.WorkspaceStateError, `package template path is missing: ${templatePath}`, {
90888
90927
  category: ErrorCategory.WorkspaceStateInvalid,
90889
90928
  path: templatePath,
@@ -90958,7 +90997,7 @@ async function packageInputFingerprint(input) {
90958
90997
  }
90959
90998
  async function readPackageManifest(projectRoot, pkg) {
90960
90999
  const filePath2 = packageFingerprintPath(projectRoot, pkg);
90961
- if (!existsSync18(filePath2))
91000
+ if (!existsSync19(filePath2))
90962
91001
  return null;
90963
91002
  try {
90964
91003
  const parsed = JSON.parse(await readFile67(filePath2, "utf8"));
@@ -90992,7 +91031,7 @@ async function readPackageManifest(projectRoot, pkg) {
90992
91031
  }
90993
91032
  async function writePackageFingerprint(input) {
90994
91033
  const filePath2 = packageFingerprintPath(input.projectRoot, input.pkg);
90995
- await mkdir30(dirname36(filePath2), { recursive: true });
91034
+ await mkdir30(dirname37(filePath2), { recursive: true });
90996
91035
  await writeFile24(filePath2, `${JSON.stringify({
90997
91036
  package: input.pkg.name,
90998
91037
  kind: packageKind(input.pkg),
@@ -91008,12 +91047,12 @@ async function writePackageFingerprint(input) {
91008
91047
  `, "utf8");
91009
91048
  }
91010
91049
  async function removeOrphanPackageDirs(projectRoot, packages) {
91011
- const distRoot = join77(projectRoot, "dist");
91012
- if (!existsSync18(distRoot))
91050
+ const distRoot = join78(projectRoot, "dist");
91051
+ if (!existsSync19(distRoot))
91013
91052
  return;
91014
91053
  const declaredNames = new Set(packages.flatMap((pkg) => packageOutputDirs(pkg).map((path2) => path2.slice("dist/".length))));
91015
91054
  const entries2 = await readdir19(distRoot, { withFileTypes: true });
91016
- await Promise.all(entries2.filter((entry) => entry.isDirectory() && !declaredNames.has(entry.name)).map((entry) => rm15(join77(distRoot, entry.name), { recursive: true, force: true, maxRetries: 3, retryDelay: 100 })));
91055
+ await Promise.all(entries2.filter((entry) => entry.isDirectory() && !declaredNames.has(entry.name)).map((entry) => rm15(join78(distRoot, entry.name), { recursive: true, force: true, maxRetries: 3, retryDelay: 100 })));
91017
91056
  }
91018
91057
  async function collectPackageFreshness(projectRoot, packages) {
91019
91058
  assertDistinctPackageOutputs(packages);
@@ -91022,8 +91061,8 @@ async function collectPackageFreshness(projectRoot, packages) {
91022
91061
  assertPackageOutputDir(pkg);
91023
91062
  const selected = selectPackageKnowledge(approved, pkg);
91024
91063
  assertSafeRenderedPath(pkg.template.path, "package template path");
91025
- const templateRoot = join77(projectRoot, pkg.template.path);
91026
- const templateExists = existsSync18(templateRoot);
91064
+ const templateRoot = join78(projectRoot, pkg.template.path);
91065
+ const templateExists = existsSync19(templateRoot);
91027
91066
  if (!templateExists) {
91028
91067
  throw new ContextError(ExitCode.WorkspaceStateError, `package template path is missing: ${pkg.template.path}`, {
91029
91068
  category: ErrorCategory.WorkspaceStateInvalid,
@@ -91258,19 +91297,19 @@ async function buildProjectPackagesInternal(projectRoot, options) {
91258
91297
  if (stagedPkg.kind === "package.llms") {
91259
91298
  const articles = await Promise.all(llmsArticles(stagedPkg, selected).map(async (article) => ({
91260
91299
  ...article,
91261
- content: await readFile67(join77(projectRoot, stagedPkg.outDir, article.path), "utf8")
91300
+ content: await readFile67(join78(projectRoot, stagedPkg.outDir, article.path), "utf8")
91262
91301
  })));
91263
- await writeLlmsDocuments(join77(projectRoot, stagedPkg.outDir), buildLlmsDocuments({
91302
+ await writeLlmsDocuments(join78(projectRoot, stagedPkg.outDir), buildLlmsDocuments({
91264
91303
  title: stagedPkg.name,
91265
91304
  articles,
91266
91305
  ...reading ? { map: reading } : {}
91267
91306
  }), { preserveIndex: true });
91268
91307
  }
91269
- await writePackageVersion(projectRoot, join77(projectRoot, stagedPkg.outDir));
91308
+ await writePackageVersion(projectRoot, join78(projectRoot, stagedPkg.outDir));
91270
91309
  await writePackageSite({ projectRoot, pkg: stagedPkg, selected, ...siteUrl ? { siteUrl } : {}, ...reading ? { structure: reading } : {} });
91271
91310
  const linkWarnings = [
91272
91311
  ...writtenKnowledge2.linkWarnings,
91273
- ...await inspectPackageMarkdownDirectory(join77(projectRoot, stagedPkg.outDir))
91312
+ ...await inspectPackageMarkdownDirectory(join78(projectRoot, stagedPkg.outDir))
91274
91313
  ];
91275
91314
  return { ...writtenKnowledge2, linkWarnings };
91276
91315
  });
@@ -91408,7 +91447,7 @@ var init_packageBuilder = __esm(() => {
91408
91447
  init_siteTranslation();
91409
91448
  init_approvedKnowledgeMetadata();
91410
91449
  import_yaml41 = __toESM(require_dist(), 1);
91411
- PACKAGE_FINGERPRINT_ROOT = join77(".tmp", "context-runtime", "packages");
91450
+ PACKAGE_FINGERPRINT_ROOT = join78(".tmp", "context-runtime", "packages");
91412
91451
  });
91413
91452
 
91414
91453
  // src/project/taskRollback.ts
@@ -91419,7 +91458,7 @@ __export(exports_taskRollback, {
91419
91458
  finishTaskRollback: () => finishTaskRollback
91420
91459
  });
91421
91460
  import { readFile as readFile68 } from "node:fs/promises";
91422
- import { join as join78 } from "node:path";
91461
+ import { join as join79 } from "node:path";
91423
91462
  async function readTaskRollback(projectRoot) {
91424
91463
  const raw = await readJsonMaybe(projectRoot, await revisionStoragePath(projectRoot));
91425
91464
  if (!raw || typeof raw !== "object" || !("protocol" in raw) || raw.protocol !== "context.task-rollback/v1")
@@ -91428,7 +91467,7 @@ async function readTaskRollback(projectRoot) {
91428
91467
  }
91429
91468
  async function contents(projectRoot, path2) {
91430
91469
  try {
91431
- return await readFile68(join78(projectRoot, path2), "utf8");
91470
+ return await readFile68(join79(projectRoot, path2), "utf8");
91432
91471
  } catch (error) {
91433
91472
  if (error && typeof error === "object" && "code" in error && error.code === "ENOENT")
91434
91473
  return;
@@ -91596,9 +91635,9 @@ __export(exports_close, {
91596
91635
  approvedStructureInputHashFor: () => approvedStructureInputHashFor,
91597
91636
  approvedKnowledgeInputHash: () => approvedKnowledgeInputHash
91598
91637
  });
91599
- import { existsSync as existsSync19 } from "node:fs";
91638
+ import { existsSync as existsSync20 } from "node:fs";
91600
91639
  import { mkdir as mkdir31, writeFile as writeFile25 } from "node:fs/promises";
91601
- import { dirname as dirname37, join as join79 } from "node:path";
91640
+ import { dirname as dirname38, join as join80 } from "node:path";
91602
91641
  function parseFrontmatter4(content3) {
91603
91642
  const match = /^---\r?\n([\s\S]*?)\r?\n---/u.exec(content3);
91604
91643
  if (match?.[1] === undefined)
@@ -91670,8 +91709,8 @@ async function deriveApprovedStructure(projectRoot) {
91670
91709
  }
91671
91710
  async function writeApprovedStructureProjection(projectRoot) {
91672
91711
  const { inputHash, structure, compactFiles } = await deriveApprovedStructure(projectRoot);
91673
- const outputPath = join79(projectRoot, STRUCTURE_PATH4);
91674
- await mkdir31(dirname37(outputPath), { recursive: true });
91712
+ const outputPath = join80(projectRoot, STRUCTURE_PATH4);
91713
+ await mkdir31(dirname38(outputPath), { recursive: true });
91675
91714
  await writeFile25(outputPath, import_yaml42.default.stringify(structure), "utf8");
91676
91715
  await Promise.all(compactFiles.map((file) => writeFile25(file.absPath, file.content, "utf8")));
91677
91716
  return { inputHash, articles: structure.articles.length, structure: STRUCTURE_PATH4 };
@@ -91681,11 +91720,11 @@ function referencesReceipt() {
91681
91720
  }
91682
91721
  async function readProjectCloseStatus(projectRoot) {
91683
91722
  const approved = await approvedKnowledgeFiles(projectRoot);
91684
- const structurePath = join79(projectRoot, STRUCTURE_PATH4);
91685
- if (approved.length === 0 && !existsSync19(structurePath))
91723
+ const structurePath = join80(projectRoot, STRUCTURE_PATH4);
91724
+ if (approved.length === 0 && !existsSync20(structurePath))
91686
91725
  return { state: "missing", diagnostics: [] };
91687
91726
  const inputHash = await approvedKnowledgeInputHash(projectRoot);
91688
- if (!existsSync19(structurePath))
91727
+ if (!existsSync20(structurePath))
91689
91728
  return { state: "missing", inputHash, diagnostics: [`close structure is missing: ${STRUCTURE_PATH4}`] };
91690
91729
  try {
91691
91730
  const parsed = await readApprovedStructureValue(projectRoot);
@@ -91738,8 +91777,8 @@ async function closeProjectWorkspace(projectRoot) {
91738
91777
  next: "Fix context verify errors, then rerun context close --format json."
91739
91778
  });
91740
91779
  }
91741
- const outputPath = join79(projectRoot, STRUCTURE_PATH4);
91742
- await mkdir31(dirname37(outputPath), { recursive: true });
91780
+ const outputPath = join80(projectRoot, STRUCTURE_PATH4);
91781
+ await mkdir31(dirname38(outputPath), { recursive: true });
91743
91782
  await writeFile25(outputPath, `${import_yaml42.default.stringify(structure)}`, "utf8");
91744
91783
  await Promise.all(compactFiles.map((file) => writeFile25(file.absPath, file.content, "utf8")));
91745
91784
  const { readTaskRollback: readTaskRollback2 } = await Promise.resolve().then(() => (init_taskRollback(), exports_taskRollback));
@@ -91815,7 +91854,7 @@ var init_close = __esm(() => {
91815
91854
  init_knowledgeAssetRepair();
91816
91855
  init_approvedKnowledgeMetadata();
91817
91856
  import_yaml42 = __toESM(require_dist(), 1);
91818
- STRUCTURE_PATH4 = join79(KNOWLEDGE_ROOT, "structure.yaml");
91857
+ STRUCTURE_PATH4 = join80(KNOWLEDGE_ROOT, "structure.yaml");
91819
91858
  });
91820
91859
 
91821
91860
  // src/project/processedScopeStorage.ts
@@ -91827,7 +91866,7 @@ __export(exports_processedScopeStorage, {
91827
91866
  captureProcessedScopes: () => captureProcessedScopes
91828
91867
  });
91829
91868
  import { readFile as readFile69 } from "node:fs/promises";
91830
- import { join as join80 } from "node:path";
91869
+ import { join as join81 } from "node:path";
91831
91870
  async function currentScopeSourceVersion(projectRoot, sourceRef) {
91832
91871
  if (sourceRef.startsWith("repo-content:"))
91833
91872
  return repoContentWorkingVersion(projectRoot, sourceRef);
@@ -91846,7 +91885,7 @@ async function currentScopeSourceVersion(projectRoot, sourceRef) {
91846
91885
  const version3 = entries3[0].ref;
91847
91886
  if (!/^[a-f0-9]{40}(?:[a-f0-9]{24})?$/u.test(version3))
91848
91887
  throw new TypeError("Processing requires a fixed commit, not a moving ref");
91849
- await assertPinnedSource(join80(projectRoot, entries3[0].materializedAt), version3);
91888
+ await assertPinnedSource(join81(projectRoot, entries3[0].materializedAt), version3);
91850
91889
  return version3;
91851
91890
  }
91852
91891
  const entries2 = (type === "file" ? sources.files : type === "lark" ? sources.larks : []).filter((entry2) => entry2.id === name3 || entry2.name === name3);
@@ -91854,7 +91893,7 @@ async function currentScopeSourceVersion(projectRoot, sourceRef) {
91854
91893
  throw new TypeError(`Source must identify one registered document: ${sourceRef}`);
91855
91894
  const entry = entries2[0];
91856
91895
  const manifest = entry.snapshot?.manifest ?? `${entry.materializedAt}/manifest.json`;
91857
- return parseDocumentSnapshotForSource(JSON.parse(await readFile69(join80(projectRoot, manifest), "utf8")), entry.name).snapshot_hash;
91896
+ return parseDocumentSnapshotForSource(JSON.parse(await readFile69(join81(projectRoot, manifest), "utf8")), entry.name).snapshot_hash;
91858
91897
  }
91859
91898
  async function captureProcessedScopes(projectRoot, requested) {
91860
91899
  const scopes = processedScopesSchema.parse(requested);
@@ -91888,7 +91927,7 @@ async function commitProcessedScopes(projectRoot, scopes) {
91888
91927
  const { articles } = await inspectSettledReferences(projectRoot, repoContent, scopes.map((scope2) => scope2.source_ref), settled);
91889
91928
  const { approvedStructureInputHashFor: approvedStructureInputHashFor2 } = await Promise.resolve().then(() => (init_close(), exports_close));
91890
91929
  const input_hash = structure.parsed.input_hash === await approvedStructureInputHashFor2(projectRoot, previous2) ? await approvedStructureInputHashFor2(projectRoot, articles) : structure.parsed.input_hash;
91891
- await atomicWriteFile(join80(projectRoot, structure.path), import_yaml43.default.stringify({ ...structure.parsed, input_hash, articles, processed_scopes: processed }));
91930
+ await atomicWriteFile(join81(projectRoot, structure.path), import_yaml43.default.stringify({ ...structure.parsed, input_hash, articles, processed_scopes: processed }));
91892
91931
  }
91893
91932
  async function invalidateChangedProcessedRequirements(projectRoot, previous2, current2) {
91894
91933
  const targets = new Map(current2.map((requirement2) => [requirement2.id, indexerProtocolDigest(requirement2)]));
@@ -91902,7 +91941,7 @@ async function invalidateChangedProcessedRequirements(projectRoot, previous2, cu
91902
91941
  const retained = scopes.filter((scope2) => !changed.has(scope2.requirement_ref));
91903
91942
  if (retained.length === scopes.length)
91904
91943
  return;
91905
- await atomicWriteFile(join80(projectRoot, structure.path), import_yaml43.default.stringify({ ...structure.parsed, processed_scopes: retained }));
91944
+ await atomicWriteFile(join81(projectRoot, structure.path), import_yaml43.default.stringify({ ...structure.parsed, processed_scopes: retained }));
91906
91945
  }
91907
91946
  var import_yaml43;
91908
91947
  var init_processedScopeStorage = __esm(() => {
@@ -92043,7 +92082,7 @@ __export(exports_approvedRevisionPrograms, {
92043
92082
  });
92044
92083
  import { execFile as execFile9 } from "node:child_process";
92045
92084
  import { promisify as promisify9 } from "node:util";
92046
- import { extname as extname11, join as join81 } from "node:path";
92085
+ import { extname as extname11, join as join82 } from "node:path";
92047
92086
  import { createRequire as createRequire6 } from "node:module";
92048
92087
  import { pathToFileURL } from "node:url";
92049
92088
  async function prepareRevisionProgramBlocks(root, sourceRefs, scopes, references) {
@@ -92059,7 +92098,7 @@ async function prepareRevisionProgramBlocks(root, sourceRefs, scopes, references
92059
92098
  if (entries2.length !== 1)
92060
92099
  throw new TypeError(`Regeneration requires one registered source: ${source2}`);
92061
92100
  const entry = entries2[0];
92062
- const directory = join81(root, entry.materializedAt);
92101
+ const directory = join82(root, entry.materializedAt);
92063
92102
  const paths = [...new Set(references.filter((reference2) => reference2.source_ref === source2).map((reference2) => reference2.locator.path))];
92064
92103
  if (!paths.length)
92065
92104
  continue;
@@ -92379,14 +92418,14 @@ __export(exports_knowledgeMaintenance, {
92379
92418
  advanceKnowledgeMaintenance: () => advanceKnowledgeMaintenance
92380
92419
  });
92381
92420
  import { readFile as readFile70, readdir as readdir20, rm as rm16 } from "node:fs/promises";
92382
- import { join as join82 } from "node:path";
92421
+ import { join as join83 } from "node:path";
92383
92422
  async function deliveryDigest(root) {
92384
- const directory = join82(root, ".tmp/context-runtime/packages");
92423
+ const directory = join83(root, ".tmp/context-runtime/packages");
92385
92424
  try {
92386
92425
  const files = (await readdir20(directory)).filter((name3) => name3.endsWith(".json")).sort();
92387
92426
  if (!files.length)
92388
92427
  return indexerProtocolDigest(null);
92389
- return indexerProtocolDigest(await Promise.all(files.map((name3) => readFile70(join82(directory, name3), "utf8"))));
92428
+ return indexerProtocolDigest(await Promise.all(files.map((name3) => readFile70(join83(directory, name3), "utf8"))));
92390
92429
  } catch (error) {
92391
92430
  if (error.code === "ENOENT")
92392
92431
  return indexerProtocolDigest(null);
@@ -92485,7 +92524,7 @@ async function observeKnowledgeMaintenance(root) {
92485
92524
  async function maintenanceRevision(root) {
92486
92525
  const observed = await observeKnowledgeMaintenance(root);
92487
92526
  const localInputs = observed.state.active ? {
92488
- revision: await readFile70(join82(root, MAINTENANCE_ROOT, "revision.json"), "utf8").catch((error) => {
92527
+ revision: await readFile70(join83(root, MAINTENANCE_ROOT, "revision.json"), "utf8").catch((error) => {
92489
92528
  if (error.code === "ENOENT")
92490
92529
  return null;
92491
92530
  throw error;
@@ -92562,7 +92601,7 @@ async function finishMaintenanceRevision(root, outcome = "completed") {
92562
92601
  outcome = state.active.completion_outcome;
92563
92602
  state.active.phase = "finishing";
92564
92603
  await saveMaintenance(root, state);
92565
- await rm16(join82(root, MAINTENANCE_ROOT, "revision.json"), { force: true });
92604
+ await rm16(join83(root, MAINTENANCE_ROOT, "revision.json"), { force: true });
92566
92605
  state.completed.push({ id: state.active.input.id, input_digest: indexerProtocolDigest(state.active.input), outcome });
92567
92606
  delete state.active;
92568
92607
  await saveMaintenance(root, state);
@@ -92596,8 +92635,8 @@ async function discardMaintenanceDraft(root) {
92596
92635
  const owned = new Set([...request?.batch_candidates ?? [], ...request?.candidate ? [request.candidate] : []].map((item) => item.candidate_id));
92597
92636
  if (candidates.some((item) => !owned.has(item.candidate_id)))
92598
92637
  throw new TypeError("Unrelated Candidates are present; no draft was discarded. Inspect the current review before retrying cancellation.");
92599
- await rm16(join82(root, CANDIDATE_LEDGER_FILE), { force: true });
92600
- await rm16(join82(root, MAINTENANCE_ROOT, "revision.json"), { force: true });
92638
+ await rm16(join83(root, CANDIDATE_LEDGER_FILE), { force: true });
92639
+ await rm16(join83(root, MAINTENANCE_ROOT, "revision.json"), { force: true });
92601
92640
  const { closeProjectWorkspace: closeProjectWorkspace2 } = await Promise.resolve().then(() => (init_close(), exports_close));
92602
92641
  const { buildProjectPackages: buildProjectPackages2 } = await Promise.resolve().then(() => (init_packageBuilder(), exports_packageBuilder));
92603
92642
  await closeProjectWorkspace2(root);
@@ -92636,7 +92675,7 @@ __export(exports_approvedRevision, {
92636
92675
  APPROVED_REVISION_PATH: () => APPROVED_REVISION_PATH
92637
92676
  });
92638
92677
  import { readFile as readFile71, realpath as realpath11, rm as rm17 } from "node:fs/promises";
92639
- import { join as join83, relative as relative26, isAbsolute as isAbsolute15 } from "node:path";
92678
+ import { join as join84, relative as relative26, isAbsolute as isAbsolute15 } from "node:path";
92640
92679
  function requestDigest(input) {
92641
92680
  const scopes = input.processed_scopes?.filter((scope2) => input.target.source_refs.some((ref2) => repoContentScopeMatches(scope2.source_ref, ref2) || ref2.startsWith(`${scope2.source_ref}#`) || ref2.startsWith(`${scope2.source_ref}/`)));
92642
92681
  const ids = new Set(scopes?.map((scope2) => scope2.requirement_ref));
@@ -92674,7 +92713,7 @@ function revisionCandidateFingerprint(revision, markdown, sections) {
92674
92713
  }
92675
92714
  async function readApprovedRevision(projectRoot) {
92676
92715
  try {
92677
- return parseApprovedRevision(JSON.parse(await readFile71(join83(projectRoot, await revisionStoragePath(projectRoot)), "utf8")));
92716
+ return parseApprovedRevision(JSON.parse(await readFile71(join84(projectRoot, await revisionStoragePath(projectRoot)), "utf8")));
92678
92717
  } catch (error) {
92679
92718
  if (error && typeof error === "object" && "code" in error && error.code === "ENOENT")
92680
92719
  return;
@@ -92733,12 +92772,12 @@ async function resolveApprovedRevisionAuthor(projectRoot, request) {
92733
92772
  }
92734
92773
  async function targetBytes(projectRoot, path2) {
92735
92774
  const project = await realpath11(projectRoot);
92736
- const root = await realpath11(join83(projectRoot, "knowledge"));
92775
+ const root = await realpath11(join84(projectRoot, "knowledge"));
92737
92776
  const rootRelative = relative26(project, root);
92738
92777
  if (isAbsolute15(rootRelative) || rootRelative === ".." || rootRelative.startsWith("../")) {
92739
92778
  throw new TypeError("Approved knowledge directory leaves the Context workspace");
92740
92779
  }
92741
- const target = await realpath11(join83(root, path2));
92780
+ const target = await realpath11(join84(root, path2));
92742
92781
  const rel = relative26(root, target);
92743
92782
  if (isAbsolute15(rel) || rel === ".." || rel.startsWith("../"))
92744
92783
  throw new TypeError("Approved revision target leaves knowledge/");
@@ -92894,7 +92933,7 @@ ${import_yaml44.default.stringify({ ...import_yaml44.default.parse(fields), type
92894
92933
  revision: requestDigest(payload)
92895
92934
  });
92896
92935
  if (input.persist !== false)
92897
- await atomicWriteFile(join83(input.projectRoot, await revisionStoragePath(input.projectRoot)), `${JSON.stringify(request)}
92936
+ await atomicWriteFile(join84(input.projectRoot, await revisionStoragePath(input.projectRoot)), `${JSON.stringify(request)}
92898
92937
  `);
92899
92938
  return {
92900
92939
  status: "author-reopened",
@@ -93005,17 +93044,17 @@ async function completeApprovedRevision(input) {
93005
93044
  const { prepareRevisionBatchContinuation: prepareRevisionBatchContinuation3 } = await Promise.resolve().then(() => (init_approvedRevisionBatch(), exports_approvedRevisionBatch));
93006
93045
  const next2 = await prepareRevisionBatchContinuation3(input.projectRoot, request, request.batch_candidates ?? []);
93007
93046
  if (next2 || request.batch_candidates?.length || request.build_pending) {
93008
- await atomicWriteFile(join83(input.projectRoot, await revisionStoragePath(input.projectRoot)), `${JSON.stringify(next2 ?? { ...request, review_ready: true })}
93047
+ await atomicWriteFile(join84(input.projectRoot, await revisionStoragePath(input.projectRoot)), `${JSON.stringify(next2 ?? { ...request, review_ready: true })}
93009
93048
  `);
93010
93049
  } else {
93011
93050
  await advanceApprovedRevision(input.projectRoot, request);
93012
93051
  }
93013
93052
  return;
93014
93053
  }
93015
- const current2 = await readFile71(join83(input.projectRoot, await revisionStoragePath(input.projectRoot)), "utf8");
93054
+ const current2 = await readFile71(join84(input.projectRoot, await revisionStoragePath(input.projectRoot)), "utf8");
93016
93055
  let previous2;
93017
93056
  try {
93018
- previous2 = await readFile71(join83(input.projectRoot, CANDIDATE_LEDGER_FILE), "utf8");
93057
+ previous2 = await readFile71(join84(input.projectRoot, CANDIDATE_LEDGER_FILE), "utf8");
93019
93058
  } catch (error) {
93020
93059
  if (!(error && typeof error === "object" && ("code" in error) && error.code === "ENOENT"))
93021
93060
  throw error;
@@ -93097,7 +93136,7 @@ async function advanceApprovedRevision(projectRoot, request, buildPending = fals
93097
93136
  return;
93098
93137
  const { readProductionStage: readProductionStage2 } = await Promise.resolve().then(() => (init_productionStageStore(), exports_productionStageStore));
93099
93138
  if (await readProductionStage2(projectRoot)) {
93100
- await rm17(join83(projectRoot, await revisionStoragePath(projectRoot)), { force: true });
93139
+ await rm17(join84(projectRoot, await revisionStoragePath(projectRoot)), { force: true });
93101
93140
  return;
93102
93141
  }
93103
93142
  const { clearCompletedLifecycle: clearCompletedLifecycle2 } = await Promise.resolve().then(() => (init_lifecycleCleanup(), exports_lifecycleCleanup));
@@ -93168,12 +93207,12 @@ async function reopenApprovedRevision(input) {
93168
93207
  }))
93169
93208
  } : {}
93170
93209
  } };
93171
- const current2 = await readFile71(join83(input.projectRoot, await revisionStoragePath(input.projectRoot)), "utf8");
93210
+ const current2 = await readFile71(join84(input.projectRoot, await revisionStoragePath(input.projectRoot)), "utf8");
93172
93211
  const content3 = `${JSON.stringify({ ...payload, revision: requestDigest(payload) })}
93173
93212
  `;
93174
93213
  let ledger;
93175
93214
  try {
93176
- ledger = await readFile71(join83(input.projectRoot, CANDIDATE_LEDGER_FILE), "utf8");
93215
+ ledger = await readFile71(join84(input.projectRoot, CANDIDATE_LEDGER_FILE), "utf8");
93177
93216
  } catch (error) {
93178
93217
  if (!(error && typeof error === "object" && ("code" in error) && error.code === "ENOENT"))
93179
93218
  throw error;
@@ -93286,7 +93325,7 @@ var init_sourceInputMutation = __esm(() => {
93286
93325
  // src/project/documentCapture.ts
93287
93326
  import { createHash as createHash24 } from "node:crypto";
93288
93327
  import { mkdir as mkdir32, readdir as readdir21, readFile as readFile72, rm as rm18, stat as stat11, writeFile as writeFile26 } from "node:fs/promises";
93289
- import { basename as basename8, dirname as dirname38, extname as extname12, join as join84, relative as relative27, resolve as resolve28 } from "node:path";
93328
+ import { basename as basename8, dirname as dirname39, extname as extname12, join as join85, relative as relative27, resolve as resolve28 } from "node:path";
93290
93329
  function toPosixPath7(path2) {
93291
93330
  return path2.split(/[\\/]+/u).filter((part) => part.length > 0).join("/");
93292
93331
  }
@@ -93409,7 +93448,7 @@ async function walkMarkdownFiles(input) {
93409
93448
  const visit3 = async (dir) => {
93410
93449
  const entries2 = await readdir21(dir, { withFileTypes: true });
93411
93450
  for (const entry of entries2) {
93412
- const absolutePath = join84(dir, entry.name);
93451
+ const absolutePath = join85(dir, entry.name);
93413
93452
  if (entry.isDirectory()) {
93414
93453
  await visit3(absolutePath);
93415
93454
  continue;
@@ -93434,11 +93473,11 @@ async function writeTextIfChanged(path2, content3) {
93434
93473
  if (await readFile72(path2, "utf8") === content3)
93435
93474
  return;
93436
93475
  } catch {}
93437
- await mkdir32(dirname38(path2), { recursive: true });
93476
+ await mkdir32(dirname39(path2), { recursive: true });
93438
93477
  await writeFile26(path2, content3, "utf8");
93439
93478
  }
93440
93479
  function sourceManifestPath(entry) {
93441
- return entry.snapshot?.manifest ?? join84(entry.materializedAt, "manifest.json");
93480
+ return entry.snapshot?.manifest ?? join85(entry.materializedAt, "manifest.json");
93442
93481
  }
93443
93482
  function runtimeError3(message, detail) {
93444
93483
  return new ContextError(ExitCode.UserError, message, {
@@ -93511,7 +93550,7 @@ async function removeEmptySnapshotDirs(root, dir = root) {
93511
93550
  for (const entry of entries2) {
93512
93551
  if (!entry.isDirectory() || entry.name === ".tmp" || entry.name === ".cache")
93513
93552
  continue;
93514
- await removeEmptySnapshotDirs(root, join84(dir, entry.name));
93553
+ await removeEmptySnapshotDirs(root, join85(dir, entry.name));
93515
93554
  }
93516
93555
  if (dir === root)
93517
93556
  return;
@@ -93523,7 +93562,7 @@ async function removeEmptySnapshotDirs(root, dir = root) {
93523
93562
  async function cleanupStaleSnapshotFiles(input) {
93524
93563
  for (const path2 of input.previousPaths) {
93525
93564
  if (!input.currentPaths.has(path2)) {
93526
- await rm18(join84(input.materializedAtAbsPath, path2), { force: true });
93565
+ await rm18(join85(input.materializedAtAbsPath, path2), { force: true });
93527
93566
  }
93528
93567
  }
93529
93568
  await removeEmptySnapshotDirs(input.materializedAtAbsPath);
@@ -93706,9 +93745,9 @@ async function runCaptureFilePhaseUnlocked(input) {
93706
93745
  documentSnapshot
93707
93746
  });
93708
93747
  const manifestPath = sourceManifestPath(entry);
93709
- const manifestAbsPath = join84(input.projectRoot, manifestPath);
93748
+ const manifestAbsPath = join85(input.projectRoot, manifestPath);
93710
93749
  const materializedAt = entry.materializedAt;
93711
- const materializedAtAbsPath = join84(input.projectRoot, materializedAt);
93750
+ const materializedAtAbsPath = join85(input.projectRoot, materializedAt);
93712
93751
  const manifestInput = {
93713
93752
  sourceType: "file",
93714
93753
  sourceName: resolved.sourceName,
@@ -93758,13 +93797,13 @@ async function runCaptureFilePhaseUnlocked(input) {
93758
93797
  }));
93759
93798
  try {
93760
93799
  for (const file of snapshotFiles) {
93761
- await writeTextIfChanged(join84(materializedAtAbsPath, file.path), String(file.bytes));
93800
+ await writeTextIfChanged(join85(materializedAtAbsPath, file.path), String(file.bytes));
93762
93801
  }
93763
93802
  for (const file of files.metadata) {
93764
- await writeTextIfChanged(join84(materializedAtAbsPath, file.snapshotPath), routeMetadata.rawByPath.get(file.snapshotPath) ?? "");
93803
+ await writeTextIfChanged(join85(materializedAtAbsPath, file.snapshotPath), routeMetadata.rawByPath.get(file.snapshotPath) ?? "");
93765
93804
  }
93766
93805
  for (const asset of linkedAssets) {
93767
- await writeCaptureAssetIfChanged(join84(materializedAtAbsPath, asset.snapshotPath), asset.bytes);
93806
+ await writeCaptureAssetIfChanged(join85(materializedAtAbsPath, asset.snapshotPath), asset.bytes);
93768
93807
  }
93769
93808
  await writeTextIfChanged(manifestAbsPath, manifestContent);
93770
93809
  await cleanupStaleSnapshotFiles({
@@ -93941,8 +93980,8 @@ var init_larkCaptureReport = __esm(() => {
93941
93980
  });
93942
93981
 
93943
93982
  // src/project/documentSnapshotFidelity.ts
93944
- import { readFileSync as readFileSync7 } from "node:fs";
93945
- import { join as join85 } from "node:path";
93983
+ import { readFileSync as readFileSync8 } from "node:fs";
93984
+ import { join as join86 } from "node:path";
93946
93985
  function readDocumentSnapshotCaptureReport(input) {
93947
93986
  const summary = input.manifest.metadata?.capture?.report;
93948
93987
  if (summary === undefined)
@@ -93951,7 +93990,7 @@ function readDocumentSnapshotCaptureReport(input) {
93951
93990
  if (asset === undefined || asset.role !== "audit" || asset.content_hash === undefined) {
93952
93991
  throw new TypeError(`snapshot capture report is not registered as a hashed audit asset: ${summary.path}`);
93953
93992
  }
93954
- const bytes = readFileSync7(join85(input.projectRoot, input.materializedAt, summary.path));
93993
+ const bytes = readFileSync8(join86(input.projectRoot, input.materializedAt, summary.path));
93955
93994
  if (computeDocumentContentHash(bytes) !== asset.content_hash) {
93956
93995
  throw new TypeError(`snapshot capture report hash does not match manifest: ${summary.path}`);
93957
93996
  }
@@ -94047,9 +94086,9 @@ function larkSnapshotIdentityDiagnostic(source2, manifest) {
94047
94086
  }
94048
94087
 
94049
94088
  // src/project/repoSourceModules.ts
94050
- import { existsSync as existsSync20 } from "node:fs";
94089
+ import { existsSync as existsSync21 } from "node:fs";
94051
94090
  import { readFile as readFile73, readdir as readdir22 } from "node:fs/promises";
94052
- import { join as join86, resolve as resolve29 } from "node:path";
94091
+ import { join as join87, resolve as resolve29 } from "node:path";
94053
94092
  async function rootNames(root) {
94054
94093
  try {
94055
94094
  return (await readdir22(root)).sort();
@@ -94058,8 +94097,8 @@ async function rootNames(root) {
94058
94097
  }
94059
94098
  }
94060
94099
  async function packageEntries(root) {
94061
- const path2 = join86(root, "package.json");
94062
- if (!existsSync20(path2))
94100
+ const path2 = join87(root, "package.json");
94101
+ if (!existsSync21(path2))
94063
94102
  return [];
94064
94103
  try {
94065
94104
  const value = JSON.parse(await readFile73(path2, "utf8"));
@@ -94070,9 +94109,9 @@ async function packageEntries(root) {
94070
94109
  }
94071
94110
  }
94072
94111
  async function planningEvidence(inspectPath, module) {
94073
- const root = module.path === "." ? inspectPath : join86(inspectPath, module.path);
94112
+ const root = module.path === "." ? inspectPath : join87(inspectPath, module.path);
94074
94113
  const names = await rootNames(root);
94075
- const commonEntries = ["src/index.ts", "src/index.tsx", "src/main.ts", "src/main.tsx", "main.go"].filter((path2) => existsSync20(join86(root, path2)));
94114
+ const commonEntries = ["src/index.ts", "src/index.tsx", "src/main.ts", "src/main.tsx", "main.go"].filter((path2) => existsSync21(join87(root, path2)));
94076
94115
  const protocolNames = names.filter((name3) => /(?:openapi|swagger|schema|protocol|idl)/iu.test(name3) || /\.(?:proto|thrift)$/iu.test(name3));
94077
94116
  const lifecycleNames = names.filter((name3) => /(?:generated|vendor|mirror|legacy|sync)/iu.test(name3));
94078
94117
  return {
@@ -94110,8 +94149,8 @@ function suggestedModuleName(module) {
94110
94149
  return slug || "module";
94111
94150
  }
94112
94151
  async function inspectRepoSourceModules(input) {
94113
- const inspectPath = input.scopedAbs !== null && existsSync20(input.scopedAbs) ? input.scopedAbs : join86(input.projectRoot, input.status.materializedAt);
94114
- const modules = existsSync20(inspectPath) ? await detectModuleBoundaries(inspectPath, input.status.head ?? input.status.ref, DEFAULT_PATH_FILTER) : [];
94152
+ const inspectPath = input.scopedAbs !== null && existsSync21(input.scopedAbs) ? input.scopedAbs : join87(input.projectRoot, input.status.materializedAt);
94153
+ const modules = existsSync21(inspectPath) ? await detectModuleBoundaries(inspectPath, input.status.head ?? input.status.ref, DEFAULT_PATH_FILTER) : [];
94115
94154
  const recommended_sources = modules.filter((module) => module.path !== "." || modules.length === 1).map((module) => {
94116
94155
  const local = sourceModuleLocalForDisplay({ source: input.source, status: input.status, module });
94117
94156
  return {
@@ -94149,8 +94188,8 @@ var init_repoSourceModules = __esm(() => {
94149
94188
  });
94150
94189
 
94151
94190
  // src/project/repoSourceRegistry.ts
94152
- import { existsSync as existsSync21 } from "node:fs";
94153
- import { join as join87 } from "node:path";
94191
+ import { existsSync as existsSync22 } from "node:fs";
94192
+ import { join as join88 } from "node:path";
94154
94193
  function assertRepoModuleName(name3) {
94155
94194
  if (!SOURCE_NAME_PATTERN2.test(name3)) {
94156
94195
  throw new ContextError(ExitCode.UserError, `repo source name must be a lowercase path-safe slug: ${name3}`, {
@@ -94201,14 +94240,14 @@ function registryEntryToRecord(entry) {
94201
94240
  };
94202
94241
  }
94203
94242
  function registryPath(projectRoot) {
94204
- return join87(projectRoot, DEFAULT_REPO_SOURCES_REGISTRY_PATH);
94243
+ return join88(projectRoot, DEFAULT_REPO_SOURCES_REGISTRY_PATH);
94205
94244
  }
94206
94245
  function defaultRepoMaterializedAt(source2) {
94207
94246
  return `sources/repo/${source2.namespace}/${source2.module}`;
94208
94247
  }
94209
94248
  async function readRepoRegistry(projectRoot) {
94210
94249
  const path2 = registryPath(projectRoot);
94211
- if (!existsSync21(path2))
94250
+ if (!existsSync22(path2))
94212
94251
  return { repos: [] };
94213
94252
  const registry2 = await loadSourcesRegistry({ rootDir: projectRoot });
94214
94253
  return {
@@ -94259,11 +94298,11 @@ var init_repoSourceRegistry = __esm(() => {
94259
94298
  });
94260
94299
 
94261
94300
  // src/project/repoSources.ts
94262
- import { existsSync as existsSync22 } from "node:fs";
94301
+ import { existsSync as existsSync23 } from "node:fs";
94263
94302
  import { lstat as lstat15, mkdir as mkdir33, readFile as readFile74, readlink as readlink2, realpath as realpath12, rm as rm19, symlink as symlink4 } from "node:fs/promises";
94264
94303
  import { execFile as execFile10 } from "node:child_process";
94265
94304
  import { promisify as promisify10 } from "node:util";
94266
- import { dirname as dirname39, isAbsolute as isAbsolute16, join as join88, relative as relative28, resolve as resolve30 } from "node:path";
94305
+ import { dirname as dirname40, isAbsolute as isAbsolute16, join as join89, relative as relative28, resolve as resolve30 } from "node:path";
94267
94306
  function nonEmpty(value) {
94268
94307
  if (value == null)
94269
94308
  return null;
@@ -94321,11 +94360,11 @@ async function localPathForRegistry(input) {
94321
94360
  async function inferNamedLocalPath(projectRoot, module) {
94322
94361
  const candidates = [
94323
94362
  resolve30(projectRoot, module),
94324
- resolve30(dirname39(projectRoot), module)
94363
+ resolve30(dirname40(projectRoot), module)
94325
94364
  ];
94326
94365
  const matches = new Map;
94327
94366
  for (const candidate of candidates) {
94328
- if (!existsSync22(candidate))
94367
+ if (!existsSync23(candidate))
94329
94368
  continue;
94330
94369
  const canonical = await realpath12(candidate).catch(() => null);
94331
94370
  if (canonical === null)
@@ -94346,13 +94385,13 @@ async function gitOutput(cwd, args) {
94346
94385
  }
94347
94386
  }
94348
94387
  async function readGitOriginRemote(cwd) {
94349
- const directConfigPath = join88(cwd, ".git", "config");
94388
+ const directConfigPath = join89(cwd, ".git", "config");
94350
94389
  let config = await readFile74(directConfigPath, "utf8").catch(() => "");
94351
94390
  if (config.length === 0) {
94352
94391
  const gitDir = await resolveGitDir(cwd);
94353
94392
  if (gitDir === null)
94354
94393
  return null;
94355
- config = await readFile74(join88(gitDir, "config"), "utf8").catch(() => "");
94394
+ config = await readFile74(join89(gitDir, "config"), "utf8").catch(() => "");
94356
94395
  }
94357
94396
  let inOriginBlock = false;
94358
94397
  for (const line of config.split(/\r?\n/u)) {
@@ -94372,17 +94411,17 @@ async function readGitOriginRemote(cwd) {
94372
94411
  async function resolveGitRoot(cwd) {
94373
94412
  let current2 = resolve30(cwd);
94374
94413
  while (true) {
94375
- if (existsSync22(join88(current2, ".git")))
94414
+ if (existsSync23(join89(current2, ".git")))
94376
94415
  return current2;
94377
- const parent = dirname39(current2);
94416
+ const parent = dirname40(current2);
94378
94417
  if (parent === current2)
94379
94418
  return null;
94380
94419
  current2 = parent;
94381
94420
  }
94382
94421
  }
94383
94422
  async function resolveGitDir(cwd) {
94384
- const dotGit = join88(cwd, ".git");
94385
- if (!existsSync22(dotGit))
94423
+ const dotGit = join89(cwd, ".git");
94424
+ if (!existsSync23(dotGit))
94386
94425
  return null;
94387
94426
  const stats = await lstat15(dotGit);
94388
94427
  if (stats.isDirectory())
@@ -94399,17 +94438,17 @@ async function readGitHead(cwd) {
94399
94438
  const gitDir = await resolveGitDir(cwd);
94400
94439
  if (gitDir === null)
94401
94440
  return null;
94402
- const headRaw = (await readFile74(join88(gitDir, "HEAD"), "utf8").catch(() => "")).trim();
94441
+ const headRaw = (await readFile74(join89(gitDir, "HEAD"), "utf8").catch(() => "")).trim();
94403
94442
  if (/^[a-f0-9]{40}$/iu.test(headRaw))
94404
94443
  return headRaw.toLowerCase();
94405
94444
  const match = /^ref:\s*(.+)\s*$/iu.exec(headRaw);
94406
94445
  const refPath = match?.[1];
94407
94446
  if (refPath === undefined)
94408
94447
  return null;
94409
- const looseRef = (await readFile74(join88(gitDir, refPath), "utf8").catch(() => "")).trim();
94448
+ const looseRef = (await readFile74(join89(gitDir, refPath), "utf8").catch(() => "")).trim();
94410
94449
  if (/^[a-f0-9]{40}$/iu.test(looseRef))
94411
94450
  return looseRef.toLowerCase();
94412
- const packedRefs = await readFile74(join88(gitDir, "packed-refs"), "utf8").catch(() => "");
94451
+ const packedRefs = await readFile74(join89(gitDir, "packed-refs"), "utf8").catch(() => "");
94413
94452
  for (const line of packedRefs.split(/\r?\n/u)) {
94414
94453
  if (line.startsWith("#") || line.startsWith("^"))
94415
94454
  continue;
@@ -94420,27 +94459,27 @@ async function readGitHead(cwd) {
94420
94459
  return null;
94421
94460
  }
94422
94461
  async function ensureMaterializedSymlink(input) {
94423
- const linkPath = join88(input.projectRoot, input.materializedAt);
94424
- await mkdir33(dirname39(linkPath), { recursive: true });
94425
- if (existsSync22(linkPath)) {
94462
+ const linkPath = join89(input.projectRoot, input.materializedAt);
94463
+ await mkdir33(dirname40(linkPath), { recursive: true });
94464
+ if (existsSync23(linkPath)) {
94426
94465
  const stats = await lstat15(linkPath);
94427
94466
  if (!stats.isSymbolicLink()) {
94428
94467
  input.diagnostics.push(`materialized path exists and is not a symlink: ${input.materializedAt}`);
94429
94468
  return false;
94430
94469
  }
94431
94470
  const current2 = await readlink2(linkPath);
94432
- const currentAbs = resolve30(dirname39(linkPath), current2);
94471
+ const currentAbs = resolve30(dirname40(linkPath), current2);
94433
94472
  if (currentAbs === input.localAbs)
94434
94473
  return true;
94435
94474
  await rm19(linkPath);
94436
94475
  }
94437
- const relTarget = relative28(dirname39(linkPath), input.localAbs) || ".";
94476
+ const relTarget = relative28(dirname40(linkPath), input.localAbs) || ".";
94438
94477
  await symlink4(relTarget, linkPath);
94439
94478
  return true;
94440
94479
  }
94441
94480
  async function diagnoseMaterializedSymlink(input) {
94442
- const linkPath = join88(input.projectRoot, input.materializedAt);
94443
- if (!existsSync22(linkPath)) {
94481
+ const linkPath = join89(input.projectRoot, input.materializedAt);
94482
+ if (!existsSync23(linkPath)) {
94444
94483
  input.diagnostics.push(`materialized path is missing: ${input.materializedAt}`);
94445
94484
  input.agent_hints.push(`Run context source ensure ${input.sourceName} to materialize the local source link.`);
94446
94485
  return false;
@@ -94451,9 +94490,9 @@ async function diagnoseMaterializedSymlink(input) {
94451
94490
  return false;
94452
94491
  }
94453
94492
  const current2 = await readlink2(linkPath);
94454
- const currentAbs = resolve30(dirname39(linkPath), current2);
94493
+ const currentAbs = resolve30(dirname40(linkPath), current2);
94455
94494
  if (currentAbs !== input.localAbs) {
94456
- input.diagnostics.push(`materialized path points to ${current2}, expected local checkout ${relative28(dirname39(linkPath), input.localAbs) || "."}`);
94495
+ input.diagnostics.push(`materialized path points to ${current2}, expected local checkout ${relative28(dirname40(linkPath), input.localAbs) || "."}`);
94457
94496
  input.agent_hints.push(`Run context source ensure ${input.sourceName} to refresh the local source link.`);
94458
94497
  return false;
94459
94498
  }
@@ -94485,7 +94524,7 @@ async function normalizeInputRef(input) {
94485
94524
  next: "Pass --local <path> with a git checkout, or use a full 40-character commit sha."
94486
94525
  });
94487
94526
  }
94488
- if (!existsSync22(localAbs)) {
94527
+ if (!existsSync23(localAbs)) {
94489
94528
  throw new ContextError(ExitCode.UserError, `short repo source ref cannot be resolved because local path is missing: ${input.local}`, {
94490
94529
  category: ErrorCategory.UserInputInvalid,
94491
94530
  sourceName: input.sourceName,
@@ -94542,7 +94581,7 @@ async function normalizeAddInput(input, existing) {
94542
94581
  let originalLocalAbs = null;
94543
94582
  if (originalLocal !== undefined) {
94544
94583
  originalLocalAbs = resolveLocalPath(input.projectRoot, originalLocal);
94545
- if (originalLocalAbs !== null && existsSync22(originalLocalAbs)) {
94584
+ if (originalLocalAbs !== null && existsSync23(originalLocalAbs)) {
94546
94585
  gitRootAbs = await resolveGitRoot(originalLocalAbs);
94547
94586
  if (gitRootAbs !== null && localWasResolvedFromInput) {
94548
94587
  const detectedSubpath = normalizeSubpath2(relative28(gitRootAbs, originalLocalAbs));
@@ -94562,7 +94601,7 @@ async function normalizeAddInput(input, existing) {
94562
94601
  localScoped: localWasResolvedFromInput && gitRootAbs !== null
94563
94602
  });
94564
94603
  if (input.local !== undefined && (explicitRemote === null || explicitRef === null)) {
94565
- if (originalLocalAbs === null || !existsSync22(originalLocalAbs)) {
94604
+ if (originalLocalAbs === null || !existsSync23(originalLocalAbs)) {
94566
94605
  throw new ContextError(ExitCode.UserError, `repo source local path does not exist: ${input.local}`, {
94567
94606
  category: ErrorCategory.UserInputInvalid,
94568
94607
  sourceName,
@@ -94664,11 +94703,11 @@ async function inspectRepoSource(input) {
94664
94703
  const diagnostics = [];
94665
94704
  const agent_hints = [];
94666
94705
  const localAbs = resolveLocalPath(input.projectRoot, source2.local);
94667
- const localExists = localAbs !== null && existsSync22(localAbs);
94706
+ const localExists = localAbs !== null && existsSync23(localAbs);
94668
94707
  const subpath = normalizeSubpath2(source2.subpath);
94669
94708
  const scopedAbs = localAbs === null ? null : scopedLocalPath(localAbs, subpath);
94670
- const scopeExists = scopedAbs !== null && existsSync22(scopedAbs);
94671
- let materialized = existsSync22(join88(input.projectRoot, materializedAt));
94709
+ const scopeExists = scopedAbs !== null && existsSync23(scopedAbs);
94710
+ let materialized = existsSync23(join89(input.projectRoot, materializedAt));
94672
94711
  const checkout = await inspectRepoCheckout({
94673
94712
  source: source2,
94674
94713
  localAbs,
@@ -94854,7 +94893,7 @@ var init_entityId = __esm(() => {
94854
94893
  // src/project/reviewShared.ts
94855
94894
  import { createHash as createHash25 } from "node:crypto";
94856
94895
  import { mkdir as mkdir34, writeFile as writeFile27 } from "node:fs/promises";
94857
- import { dirname as dirname40, join as join89 } from "node:path";
94896
+ import { dirname as dirname41, join as join90 } from "node:path";
94858
94897
  function isRecord14(value) {
94859
94898
  return value !== null && typeof value === "object" && !Array.isArray(value);
94860
94899
  }
@@ -94897,7 +94936,7 @@ async function buildApprovedArticleIndex(projectRoot) {
94897
94936
  if (!isApprovedKnowledgeMarkdownPath(rel))
94898
94937
  continue;
94899
94938
  const { absPath, content: content3 } = file;
94900
- const relPath = join89("knowledge", collection, rel);
94939
+ const relPath = join90("knowledge", collection, rel);
94901
94940
  assetReferencesByRelPath.set(relPath, knowledgeAssetReferences({
94902
94941
  pageRelPath: relPath,
94903
94942
  content: content3
@@ -94910,7 +94949,7 @@ async function buildApprovedArticleIndex(projectRoot) {
94910
94949
  continue;
94911
94950
  const frontmatter2 = hydrateApprovedFrontmatter({
94912
94951
  frontmatter: parsed,
94913
- relPath: join89(collection, rel),
94952
+ relPath: join90(collection, rel),
94914
94953
  metadata
94915
94954
  });
94916
94955
  const article = articlesByPath.get(`${collection}/${rel}`);
@@ -94965,9 +95004,9 @@ ${yaml3}
94965
95004
  }
94966
95005
  async function writeReviewActionLog(input) {
94967
95006
  const stamp = new Date().toISOString().replace(/[-:.TZ]/gu, "");
94968
- const relPath = join89(REVIEW_ACTION_ROOT2, `${stamp}-${input.action}-${input.id.replace(/[\\/]+/gu, "_")}.json`);
94969
- const path2 = join89(input.projectRoot, relPath);
94970
- await mkdir34(dirname40(path2), { recursive: true });
95007
+ const relPath = join90(REVIEW_ACTION_ROOT2, `${stamp}-${input.action}-${input.id.replace(/[\\/]+/gu, "_")}.json`);
95008
+ const path2 = join90(input.projectRoot, relPath);
95009
+ await mkdir34(dirname41(path2), { recursive: true });
94971
95010
  await writeFile27(path2, `${JSON.stringify({
94972
95011
  action: input.action,
94973
95012
  id: input.id,
@@ -94999,7 +95038,7 @@ var init_reviewShared = __esm(() => {
94999
95038
  init_knowledgeAssets();
95000
95039
  init_entityId();
95001
95040
  import_yaml46 = __toESM(require_dist(), 1);
95002
- REVIEW_ACTION_ROOT2 = join89(".tmp", "context-runtime", "review-actions");
95041
+ REVIEW_ACTION_ROOT2 = join90(".tmp", "context-runtime", "review-actions");
95003
95042
  });
95004
95043
 
95005
95044
  // src/project/managedDocumentStatus.ts
@@ -95074,17 +95113,17 @@ __export(exports_statusReaders, {
95074
95113
  loadStatusPhases: () => loadStatusPhases,
95075
95114
  countFiles: () => countFiles
95076
95115
  });
95077
- import { existsSync as existsSync23, readFileSync as readFileSync8 } from "node:fs";
95078
- import { join as join90 } from "node:path";
95116
+ import { existsSync as existsSync24, readFileSync as readFileSync9 } from "node:fs";
95117
+ import { join as join91 } from "node:path";
95079
95118
  async function countFiles(root, predicate) {
95080
- if (!existsSync23(root))
95119
+ if (!existsSync24(root))
95081
95120
  return 0;
95082
95121
  let count = 0;
95083
95122
  const visit3 = async (dir, prefix = "") => {
95084
95123
  const entries2 = await readCommandDirectory(dir);
95085
95124
  for (const entry of entries2) {
95086
95125
  const rel = prefix.length === 0 ? entry.name : `${prefix}/${entry.name}`;
95087
- const abs = join90(dir, entry.name);
95126
+ const abs = join91(dir, entry.name);
95088
95127
  if (entry.isDirectory())
95089
95128
  await visit3(abs, rel);
95090
95129
  else if (entry.isFile() && predicate(rel))
@@ -95275,8 +95314,8 @@ async function documentSourceSiteHint(input) {
95275
95314
  });
95276
95315
  }
95277
95316
  function documentSnapshotReadiness(input) {
95278
- const manifestPath = join90(input.projectRoot, input.manifest);
95279
- if (!existsSync23(manifestPath)) {
95317
+ const manifestPath = join91(input.projectRoot, input.manifest);
95318
+ if (!existsSync24(manifestPath)) {
95280
95319
  return {
95281
95320
  ready: false,
95282
95321
  diagnostics: [`snapshot is missing: ${input.manifest}`],
@@ -95284,7 +95323,7 @@ function documentSnapshotReadiness(input) {
95284
95323
  };
95285
95324
  }
95286
95325
  try {
95287
- const manifest = findDocumentSnapshotForSource(JSON.parse(readFileSync8(manifestPath, "utf8")), input.sourceName);
95326
+ const manifest = findDocumentSnapshotForSource(JSON.parse(readFileSync9(manifestPath, "utf8")), input.sourceName);
95288
95327
  if (manifest === null) {
95289
95328
  return {
95290
95329
  ready: false,
@@ -95345,7 +95384,7 @@ function documentSnapshotReadiness(input) {
95345
95384
  const missingFiles = [
95346
95385
  ...manifest.files.map((file) => file.path),
95347
95386
  ...(manifest.assets ?? []).filter((asset) => asset.content_hash !== undefined).map((asset) => asset.path)
95348
- ].filter((path2) => !existsSync23(join90(input.projectRoot, input.materializedAt, path2)));
95387
+ ].filter((path2) => !existsSync24(join91(input.projectRoot, input.materializedAt, path2)));
95349
95388
  if (missingFiles.length > 0) {
95350
95389
  return {
95351
95390
  ready: false,
@@ -95765,11 +95804,11 @@ var init_workflowHostPlans = __esm(() => {
95765
95804
  });
95766
95805
 
95767
95806
  // src/project/workflow/workflowProvider.ts
95768
- import { existsSync as existsSync24 } from "node:fs";
95769
- import { dirname as dirname41, resolve as resolve31 } from "node:path";
95770
- import { fileURLToPath as fileURLToPath6 } from "node:url";
95807
+ import { existsSync as existsSync25 } from "node:fs";
95808
+ import { dirname as dirname42, resolve as resolve31 } from "node:path";
95809
+ import { fileURLToPath as fileURLToPath7 } from "node:url";
95771
95810
  function providerCandidates() {
95772
- const moduleDir2 = dirname41(fileURLToPath6(import.meta.url));
95811
+ const moduleDir2 = dirname42(fileURLToPath7(import.meta.url));
95773
95812
  return [
95774
95813
  ...process.env.C4A_CONTEXT_WORKFLOW_PROVIDER ? [resolve31(process.env.C4A_CONTEXT_WORKFLOW_PROVIDER)] : [],
95775
95814
  resolve31(moduleDir2, "providers", "context", "manifest.json"),
@@ -95777,7 +95816,7 @@ function providerCandidates() {
95777
95816
  ];
95778
95817
  }
95779
95818
  function contextWorkflowProviderPath() {
95780
- const candidate = providerCandidates().find((path2) => existsSync24(path2));
95819
+ const candidate = providerCandidates().find((path2) => existsSync25(path2));
95781
95820
  if (candidate === undefined) {
95782
95821
  throw new Error("Context workflow Provider is missing. Rebuild @c4a/context-cli or reinstall the published package.");
95783
95822
  }
@@ -96137,7 +96176,7 @@ var init_workflowProvider = __esm(() => {
96137
96176
 
96138
96177
  // src/project/productionStageRefresh.ts
96139
96178
  import { readFile as readFile76 } from "node:fs/promises";
96140
- import { join as join92 } from "node:path";
96179
+ import { join as join93 } from "node:path";
96141
96180
  async function refreshProductionStageSources(projectRoot, stage) {
96142
96181
  const active = activeProductionSources(stage);
96143
96182
  const affected = new Set(stage.gaps.filter((gap) => active.has(gap.scope)).map((gap) => gap.scope));
@@ -96182,8 +96221,8 @@ Restore the authorized source and retry preparation.
96182
96221
  tasks: stage.tasks.map((task) => !["accepted", "excluded", "replaced"].includes(task.status) && task.sources.some((source2) => affected.has(source2.scope)) ? { ...task, status: "blocked", reason: "Source material refreshed; investigate and explicitly replace this unfinished task." } : task)
96183
96222
  });
96184
96223
  const directory = productionStageDirectory(stage.id);
96185
- const contents2 = new Map([...sourceMaterials].map(([scope2, content3]) => [join92(directory, productionSourceFile(scope2)), content3]));
96186
- contents2.set(join92(directory, "manifest.json"), `${JSON.stringify(updated)}
96224
+ const contents2 = new Map([...sourceMaterials].map(([scope2, content3]) => [join93(directory, productionSourceFile(scope2)), content3]));
96225
+ contents2.set(join93(directory, "manifest.json"), `${JSON.stringify(updated)}
96187
96226
  `);
96188
96227
  const targets = [];
96189
96228
  for (const [path2, content3] of contents2) {
@@ -96314,7 +96353,7 @@ var init_productionReport = __esm(() => {
96314
96353
  });
96315
96354
 
96316
96355
  // src/project/productionPlanningRoute.ts
96317
- import { join as join93 } from "node:path";
96356
+ import { join as join94 } from "node:path";
96318
96357
  async function productionPlanningRoute(input, stage) {
96319
96358
  const request = stage ? undefined : await productionPlanningRequest(input.projectRoot);
96320
96359
  const present = !!stage || !!request;
@@ -96352,7 +96391,7 @@ async function productionPlanningRoute(input, stage) {
96352
96391
  id: `production/${stage.id}/planning`,
96353
96392
  kind: "context-view",
96354
96393
  media_type: "text/markdown",
96355
- path: join93(input.projectRoot, productionStageDirectory(stage.id), "planning.md"),
96394
+ path: join94(input.projectRoot, productionStageDirectory(stage.id), "planning.md"),
96356
96395
  read_state: "read-required"
96357
96396
  }] : []
96358
96397
  ],
@@ -96379,8 +96418,8 @@ var init_productionPlanningRoute = __esm(() => {
96379
96418
  });
96380
96419
 
96381
96420
  // src/project/productionWorkflowRoute.ts
96382
- import { existsSync as existsSync25 } from "node:fs";
96383
- import { join as join94 } from "node:path";
96421
+ import { existsSync as existsSync26 } from "node:fs";
96422
+ import { join as join95 } from "node:path";
96384
96423
  async function productionWorkflowRoute(input) {
96385
96424
  const stage = await readProductionStage(input.projectRoot);
96386
96425
  if (!stage || !stage.planning_complete)
@@ -96398,7 +96437,7 @@ async function productionWorkflowRoute(input) {
96398
96437
  const selected = new Set(dispatch.batches.flatMap((batch) => batch.tasks));
96399
96438
  const context = { workspace: input.projectRoot, authorities: [...input.authorities], facts: { production: {
96400
96439
  report_approved: stage.report_approved,
96401
- prepared: !dispatch.batches.length || existsSync25(join94(input.projectRoot, directory, "stage.md")) && stage.tasks.filter((task) => selected.has(task.id)).every((task) => task.status === "issued"),
96440
+ prepared: !dispatch.batches.length || existsSync26(join95(input.projectRoot, directory, "stage.md")) && stage.tasks.filter((task) => selected.has(task.id)).every((task) => task.status === "issued"),
96402
96441
  writing_complete: dispatch.batches.length === 0,
96403
96442
  complete: dispatch.state === "ended",
96404
96443
  review_clear: rejected.length === 0,
@@ -96415,7 +96454,7 @@ async function productionWorkflowRoute(input) {
96415
96454
  const resolved = await resolveRoute(provider, "indexer", "production", primary.routeId, context, evaluated.evaluation.revision);
96416
96455
  const report = resolved.node === "confirm-production-report";
96417
96456
  if (report)
96418
- await writeProductionProjection(input.projectRoot, join94(directory, "plan.md"), productionPlanMarkdown(stage));
96457
+ await writeProductionProjection(input.projectRoot, join95(directory, "plan.md"), productionPlanMarkdown(stage));
96419
96458
  const prepare = resolved.node === "prepare-production-stage";
96420
96459
  const writing = resolved.node === "work-production-stage";
96421
96460
  const repair = resolved.node === "repair-production-articles";
@@ -96430,7 +96469,7 @@ async function productionWorkflowRoute(input) {
96430
96469
  id: `production/${stage.id}/${report ? "plan" : "stage"}`,
96431
96470
  kind: "context-view",
96432
96471
  media_type: "text/markdown",
96433
- path: join94(input.projectRoot, directory, path3),
96472
+ path: join95(input.projectRoot, directory, path3),
96434
96473
  read_state: "read-required"
96435
96474
  });
96436
96475
  if (report || writing)
@@ -96441,18 +96480,18 @@ async function productionWorkflowRoute(input) {
96441
96480
  id: `production/${stage.id}/planning`,
96442
96481
  kind: "context-view",
96443
96482
  media_type: "text/markdown",
96444
- path: join94(input.projectRoot, directory, "planning.md"),
96483
+ path: join95(input.projectRoot, directory, "planning.md"),
96445
96484
  read_state: "read-required"
96446
96485
  });
96447
96486
  }
96448
96487
  if (repair) {
96449
- await writeProductionProjection(input.projectRoot, join94(directory, "repair.md"), [
96488
+ await writeProductionProjection(input.projectRoot, join95(directory, "repair.md"), [
96450
96489
  "# Revise rejected articles",
96451
96490
  "",
96452
96491
  ...rejected.map((candidate) => `- ${candidate.path}: ${candidate.review.title}`),
96453
96492
  "",
96454
96493
  "Use the user's Review feedback to add revision tasks for these article paths. Rejection does not cancel their planned responsibilities. Ask for missing feedback instead of guessing the reason.",
96455
- `Submit the plan amendment to ${path2} using ${join94(directory, "planning.schema.json")}. Keep accepted task identities unchanged; the CLI assigns the revision tasks and preserves article identities.`,
96494
+ `Submit the plan amendment to ${path2} using ${join95(directory, "planning.schema.json")}. Keep accepted task identities unchanged; the CLI assigns the revision tasks and preserves article identities.`,
96456
96495
  "Once issued, repair the affected sections through the existing edits submission. Unchanged sections and references do not need resubmission.",
96457
96496
  ""
96458
96497
  ].join(`
@@ -96461,7 +96500,7 @@ async function productionWorkflowRoute(input) {
96461
96500
  id: `production/${stage.id}/repair`,
96462
96501
  kind: "context-view",
96463
96502
  media_type: "text/markdown",
96464
- path: join94(input.projectRoot, directory, "repair.md"),
96503
+ path: join95(input.projectRoot, directory, "repair.md"),
96465
96504
  read_state: "read-required"
96466
96505
  });
96467
96506
  }
@@ -101381,7 +101420,7 @@ var init_larkResourceCommand = __esm(() => {
101381
101420
 
101382
101421
  // src/lib/larkMediaDownload.ts
101383
101422
  import { readdir as readdir24, rm as rm21 } from "node:fs/promises";
101384
- import { join as join104 } from "node:path";
101423
+ import { join as join105 } from "node:path";
101385
101424
  async function downloadLarkMedia(input) {
101386
101425
  const shared = ["--as", input.identity, "--token", input.token, "--output", "./resource", "--format", "json"];
101387
101426
  try {
@@ -101391,7 +101430,7 @@ async function downloadLarkMedia(input) {
101391
101430
  if (!input.allowPreview || !isLarkResourcePermissionDenied(error))
101392
101431
  throw error;
101393
101432
  for (const entry of await readdir24(input.cwd))
101394
- await rm21(join104(input.cwd, entry), { recursive: true, force: true });
101433
+ await rm21(join105(input.cwd, entry), { recursive: true, force: true });
101395
101434
  await runLarkResourceCommand(input.runner, ["docs", "+media-preview", ...shared], { cwd: input.cwd });
101396
101435
  return "preview";
101397
101436
  }
@@ -101403,7 +101442,7 @@ var init_larkMediaDownload = __esm(() => {
101403
101442
  // src/lib/larkWhiteboardExport.ts
101404
101443
  import { mkdtemp as mkdtemp4, readFile as readFile84, rm as rm22 } from "node:fs/promises";
101405
101444
  import { tmpdir } from "node:os";
101406
- import { join as join105 } from "node:path";
101445
+ import { join as join106 } from "node:path";
101407
101446
  function stableJson2(value) {
101408
101447
  if (value === undefined)
101409
101448
  return "null";
@@ -101433,7 +101472,7 @@ function canonicalWhiteboardPayload(value) {
101433
101472
  };
101434
101473
  }
101435
101474
  async function exportLarkWhiteboardRaw(runner2, identity2, token) {
101436
- const tempRoot = await mkdtemp4(join105(tmpdir(), "context-lark-whiteboard-"));
101475
+ const tempRoot = await mkdtemp4(join106(tmpdir(), "context-lark-whiteboard-"));
101437
101476
  try {
101438
101477
  await runLarkResourceCommand(runner2, [
101439
101478
  "whiteboard",
@@ -101450,7 +101489,7 @@ async function exportLarkWhiteboardRaw(runner2, identity2, token) {
101450
101489
  "--format",
101451
101490
  "json"
101452
101491
  ], { cwd: tempRoot });
101453
- const rawPayload = JSON.parse(await readFile84(join105(tempRoot, "raw.json"), "utf8"));
101492
+ const rawPayload = JSON.parse(await readFile84(join106(tempRoot, "raw.json"), "utf8"));
101454
101493
  return Buffer.from(`${stableJson2(canonicalWhiteboardPayload(rawPayload))}
101455
101494
  `, "utf8");
101456
101495
  } finally {
@@ -101490,7 +101529,7 @@ var init_larkImagePolicy = __esm(() => {
101490
101529
  // src/lib/larkResourceMaterialization.ts
101491
101530
  import { createHash as createHash31 } from "node:crypto";
101492
101531
  import { mkdtemp as mkdtemp5, readFile as readFile85, readdir as readdir25, rm as rm23 } from "node:fs/promises";
101493
- import { extname as extname13, join as join106 } from "node:path";
101532
+ import { extname as extname13, join as join107 } from "node:path";
101494
101533
  import { tmpdir as tmpdir2 } from "node:os";
101495
101534
  function countByKind(items, status) {
101496
101535
  const counts2 = new Map;
@@ -101598,14 +101637,14 @@ async function downloadedFile(input) {
101598
101637
  const bytes = await readFile85(input.localPath);
101599
101638
  return { path: input.localPath, bytes, mediaType: mediaTypeFor(input.localPath, bytes), representation: "original" };
101600
101639
  }
101601
- const tempRoot = await mkdtemp5(join106(tmpdir2(), "context-lark-resource-"));
101640
+ const tempRoot = await mkdtemp5(join107(tmpdir2(), "context-lark-resource-"));
101602
101641
  try {
101603
101642
  const representation = await downloadLarkMedia({ ...input, cwd: tempRoot });
101604
101643
  const entries2 = (await readdir25(tempRoot, { withFileTypes: true })).filter((entry) => entry.isFile());
101605
101644
  if (entries2.length !== 1)
101606
101645
  throw new Error(`media download produced ${entries2.length} files, expected exactly one`);
101607
101646
  const path3 = entries2[0]?.name ?? "resource.bin";
101608
- const bytes = await readFile85(join106(tempRoot, path3));
101647
+ const bytes = await readFile85(join107(tempRoot, path3));
101609
101648
  return { path: path3, bytes, mediaType: mediaTypeFor(path3, bytes), representation };
101610
101649
  } finally {
101611
101650
  await rm23(tempRoot, { recursive: true, force: true });
@@ -101677,9 +101716,9 @@ async function sheetMaterialization(resource, runner2, identity2) {
101677
101716
  const sheetId = resource.attributes["sheet-id"];
101678
101717
  if (token === undefined || sheetId === undefined)
101679
101718
  throw new Error("embedded Sheet requires token and sheet-id");
101680
- const tempRoot = await mkdtemp5(join106(tmpdir2(), "context-lark-sheet-"));
101719
+ const tempRoot = await mkdtemp5(join107(tmpdir2(), "context-lark-sheet-"));
101681
101720
  try {
101682
- const outputPath = join106(tempRoot, "sheet.json");
101721
+ const outputPath = join107(tempRoot, "sheet.json");
101683
101722
  const stdout = await runLarkResourceCommand(runner2, [
101684
101723
  "sheets",
101685
101724
  "+csv-get",
@@ -102815,7 +102854,7 @@ var init_sensitiveSourceLiteral = __esm(() => {
102815
102854
  // src/project/larkSnapshotBundle.ts
102816
102855
  import { createHash as createHash32 } from "node:crypto";
102817
102856
  import { lstat as lstat16, mkdir as mkdir37, readFile as readFile86, realpath as realpath13, rename as rename10, writeFile as writeFile29 } from "node:fs/promises";
102818
- import { basename as basename10, dirname as dirname43, isAbsolute as isAbsolute19, join as join107, relative as relative29, resolve as resolve34, sep as sep10 } from "node:path";
102857
+ import { basename as basename10, dirname as dirname44, isAbsolute as isAbsolute19, join as join108, relative as relative29, resolve as resolve34, sep as sep10 } from "node:path";
102819
102858
  import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
102820
102859
  function normalizedSnapshotResourcePolicy(policy) {
102821
102860
  return { ...policy, images: policy.images ?? "bundle", gifs: policy.gifs ?? "bundle" };
@@ -102856,7 +102895,7 @@ async function readFileEntry(root2, entry) {
102856
102895
  const parts = safePath(entry.path).split("/");
102857
102896
  let current2 = root2;
102858
102897
  for (const [index2, part] of parts.entries()) {
102859
- current2 = join107(current2, part);
102898
+ current2 = join108(current2, part);
102860
102899
  const stat12 = await lstat16(current2);
102861
102900
  if (stat12.isSymbolicLink() || (index2 === parts.length - 1 ? !stat12.isFile() : !stat12.isDirectory())) {
102862
102901
  throw larkSnapshotError(`Snapshot entry is not a regular file: ${entry.path}`, "path-invalid");
@@ -102925,13 +102964,13 @@ async function writeLarkSnapshotBundle(input) {
102925
102964
  };
102926
102965
  schema2.parse(manifest);
102927
102966
  for (const [path3, bytes] of files) {
102928
- await mkdir37(dirname43(join107(root2, path3)), { recursive: true });
102929
- await writeFile29(join107(root2, path3), bytes, { flag: "wx", mode: 384 });
102967
+ await mkdir37(dirname44(join108(root2, path3)), { recursive: true });
102968
+ await writeFile29(join108(root2, path3), bytes, { flag: "wx", mode: 384 });
102930
102969
  }
102931
102970
  await validateBundle(root2, manifest);
102932
- await writeFile29(join107(root2, `${FILE2}.pending`), `${JSON.stringify(manifest, null, 2)}
102971
+ await writeFile29(join108(root2, `${FILE2}.pending`), `${JSON.stringify(manifest, null, 2)}
102933
102972
  `, { flag: "wx", mode: 384 });
102934
- await rename10(join107(root2, `${FILE2}.pending`), join107(root2, FILE2));
102973
+ await rename10(join108(root2, `${FILE2}.pending`), join108(root2, FILE2));
102935
102974
  return manifest;
102936
102975
  }
102937
102976
  async function validateBundle(root2, manifest) {
@@ -103004,7 +103043,7 @@ async function validateBundle(root2, manifest) {
103004
103043
  async function readLarkSnapshotBundle(directory, target) {
103005
103044
  try {
103006
103045
  const root2 = await assertSnapshotDirectory(directory);
103007
- const path3 = join107(root2, FILE2);
103046
+ const path3 = join108(root2, FILE2);
103008
103047
  const stat12 = await lstat16(path3);
103009
103048
  if (stat12.isSymbolicLink() || !stat12.isFile())
103010
103049
  throw larkSnapshotError("Snapshot receipt must be a regular file", "path-invalid");
@@ -103019,7 +103058,7 @@ async function readLarkSnapshotBundle(directory, target) {
103019
103058
  }
103020
103059
  async function reserveSnapshotDirectory(directory, workspaceRoot) {
103021
103060
  const requested = resolve34(directory);
103022
- let ancestor = dirname43(requested);
103061
+ let ancestor = dirname44(requested);
103023
103062
  const missing2 = [];
103024
103063
  while (true) {
103025
103064
  try {
@@ -103029,11 +103068,11 @@ async function reserveSnapshotDirectory(directory, workspaceRoot) {
103029
103068
  if (!(error instanceof Error) || !("code" in error) || error.code !== "ENOENT")
103030
103069
  throw error;
103031
103070
  missing2.unshift(basename10(ancestor));
103032
- ancestor = dirname43(ancestor);
103071
+ ancestor = dirname44(ancestor);
103033
103072
  }
103034
103073
  }
103035
- const parent = join107(ancestor, ...missing2);
103036
- const output = join107(parent, basename10(requested));
103074
+ const parent = join108(ancestor, ...missing2);
103075
+ const output = join108(parent, basename10(requested));
103037
103076
  const { findContextProjectRoot: findContextProjectRoot2 } = await Promise.resolve().then(() => (init_workspace(), exports_workspace));
103038
103077
  const owner = findContextProjectRoot2(parent)?.projectRoot ?? workspaceRoot;
103039
103078
  if (owner !== undefined) {
@@ -103107,7 +103146,7 @@ var init_larkSnapshotBundle = __esm(() => {
103107
103146
 
103108
103147
  // src/project/documentCaptureLark.ts
103109
103148
  import { readdir as readdir26, readFile as readFile87 } from "node:fs/promises";
103110
- import { basename as basename11, extname as extname14, join as join108 } from "node:path";
103149
+ import { basename as basename11, extname as extname14, join as join109 } from "node:path";
103111
103150
  function titleFromMarkdown2(markdown, fallbackPath) {
103112
103151
  const heading2 = markdown.split(`
103113
103152
  `).find((line) => /^#\s+\S/u.test(line));
@@ -103134,7 +103173,7 @@ async function fileContentMatches(path3, content3) {
103134
103173
  }
103135
103174
  }
103136
103175
  function sourceManifestPath2(entry) {
103137
- return entry.snapshot?.manifest ?? join108(entry.materializedAt, "manifest.json");
103176
+ return entry.snapshot?.manifest ?? join109(entry.materializedAt, "manifest.json");
103138
103177
  }
103139
103178
  function larkRuntimeError(message, detail) {
103140
103179
  return new ContextError(ExitCode.ExternalToolError, message, {
@@ -103261,7 +103300,7 @@ function assetManifestEntry(asset, assetRoot) {
103261
103300
  };
103262
103301
  }
103263
103302
  async function listSnapshotAssetFiles(root2, assetRoot) {
103264
- const assetsRoot = join108(root2, assetRoot);
103303
+ const assetsRoot = join109(root2, assetRoot);
103265
103304
  const files = [];
103266
103305
  const visit4 = async (dir, prefix = assetRoot) => {
103267
103306
  let entries2;
@@ -103274,7 +103313,7 @@ async function listSnapshotAssetFiles(root2, assetRoot) {
103274
103313
  }
103275
103314
  for (const entry of entries2) {
103276
103315
  const relPath = `${prefix}/${entry.name}`;
103277
- const absolutePath = join108(dir, entry.name);
103316
+ const absolutePath = join109(dir, entry.name);
103278
103317
  if (entry.isDirectory()) {
103279
103318
  await visit4(absolutePath, relPath);
103280
103319
  continue;
@@ -103289,7 +103328,7 @@ async function listSnapshotAssetFiles(root2, assetRoot) {
103289
103328
  }
103290
103329
  async function staleSnapshotAssetPaths(input) {
103291
103330
  const existingPaths = await listSnapshotAssetFiles(input.materializedAtAbsPath, input.assetRoot);
103292
- return existingPaths.filter((path3) => !input.currentPaths.has(path3)).map((path3) => join108(input.materializedAtAbsPath, path3));
103331
+ return existingPaths.filter((path3) => !input.currentPaths.has(path3)).map((path3) => join109(input.materializedAtAbsPath, path3));
103293
103332
  }
103294
103333
  function normalizeLarkError(error, sourceName) {
103295
103334
  if (error instanceof ContextError)
@@ -103410,9 +103449,9 @@ async function runCaptureLarkPhaseUnlocked(input) {
103410
103449
  locator
103411
103450
  }];
103412
103451
  const manifestPath = sourceManifestPath2(entry);
103413
- const manifestAbsPath = join108(input.projectRoot, manifestPath);
103452
+ const manifestAbsPath = join109(input.projectRoot, manifestPath);
103414
103453
  const materializedAt = entry.materializedAt;
103415
- const materializedAtAbsPath = join108(input.projectRoot, materializedAt);
103454
+ const materializedAtAbsPath = join109(input.projectRoot, materializedAt);
103416
103455
  const manifest = createDocumentSnapshotManifest({
103417
103456
  sourceType: "lark",
103418
103457
  sourceName: resolved.sourceName,
@@ -103446,13 +103485,13 @@ async function runCaptureLarkPhaseUnlocked(input) {
103446
103485
  }));
103447
103486
  try {
103448
103487
  const requestedWrites = [{
103449
- path: join108(materializedAtAbsPath, documentPath),
103488
+ path: join109(materializedAtAbsPath, documentPath),
103450
103489
  bytes: normalized
103451
103490
  }];
103452
103491
  for (const asset of assets) {
103453
103492
  if (asset.bytes !== undefined) {
103454
103493
  requestedWrites.push({
103455
- path: join108(materializedAtAbsPath, asset.entry.path),
103494
+ path: join109(materializedAtAbsPath, asset.entry.path),
103456
103495
  bytes: asset.bytes
103457
103496
  });
103458
103497
  }
@@ -103469,7 +103508,7 @@ async function runCaptureLarkPhaseUnlocked(input) {
103469
103508
  currentPaths: new Set(assets.filter((asset) => asset.bytes !== undefined).map((asset) => asset.entry.path))
103470
103509
  });
103471
103510
  await applyAtomicFileBatch({
103472
- transactionRoot: join108(input.projectRoot, ".tmp", "context-runtime", "capture-transactions"),
103511
+ transactionRoot: join109(input.projectRoot, ".tmp", "context-runtime", "capture-transactions"),
103473
103512
  writes,
103474
103513
  removals
103475
103514
  });
@@ -103576,7 +103615,7 @@ __export(exports_actionInputWorkspace, {
103576
103615
  assertActionInputWorkspace: () => assertActionInputWorkspace
103577
103616
  });
103578
103617
  import { realpathSync as realpathSync2 } from "node:fs";
103579
- import { dirname as dirname45, resolve as resolve36 } from "node:path";
103618
+ import { dirname as dirname46, resolve as resolve36 } from "node:path";
103580
103619
  function assertActionInputWorkspace(cwd, inputPath) {
103581
103620
  if (inputPath === "-")
103582
103621
  return;
@@ -103589,7 +103628,7 @@ function assertActionInputWorkspace(cwd, inputPath) {
103589
103628
  } catch {
103590
103629
  return;
103591
103630
  }
103592
- const owner = findContextProjectRoot(dirname45(file));
103631
+ const owner = findContextProjectRoot(dirname46(file));
103593
103632
  if (owner === null || realpathSync2(owner.projectRoot) === realpathSync2(current2.projectRoot))
103594
103633
  return;
103595
103634
  throw new ContextError(ExitCode.WorkspaceStateError, "The completion input belongs to a different Context workspace. Run the workflow CLI and read/write this task's .tmp files in the same intended workspace. No tasks were submitted.", {
@@ -103903,7 +103942,7 @@ __export(exports_writeLockRecovery, {
103903
103942
  inspectWriterLock: () => inspectWriterLock
103904
103943
  });
103905
103944
  import { lstat as lstat17, mkdir as mkdir39, readFile as readFile94, readdir as readdir28, rename as rename11, rmdir as rmdir2 } from "node:fs/promises";
103906
- import { join as join113 } from "node:path";
103945
+ import { join as join114 } from "node:path";
103907
103946
  import { createHash as createHash34, randomUUID as randomUUID8 } from "node:crypto";
103908
103947
  async function inspectWriterLock(root2) {
103909
103948
  const path3 = await safeProjectTarget(root2, lockRelative);
@@ -103950,8 +103989,8 @@ async function recoverWriterLock(input) {
103950
103989
  };
103951
103990
  if (input.plan_digest !== before.digest)
103952
103991
  throw new Error("Writer lock changed; preview recovery again.");
103953
- const path3 = join113(input.projectRoot, lockRelative);
103954
- const guard = join113(path3, ".recovery");
103992
+ const path3 = join114(input.projectRoot, lockRelative);
103993
+ const guard = join114(path3, ".recovery");
103955
103994
  await mkdir39(guard);
103956
103995
  let archived = false;
103957
103996
  try {
@@ -103962,7 +104001,7 @@ async function recoverWriterLock(input) {
103962
104001
  if (names.some((name3) => name3 !== "owner.json" && name3 !== ".recovery"))
103963
104002
  throw new Error("Unexpected lock contents; preserve for diagnosis.");
103964
104003
  const archive = `.tmp/context-runtime/locks/recovered-write-${randomUUID8()}.lock`;
103965
- await rename11(path3, join113(input.projectRoot, archive));
104004
+ await rename11(path3, join114(input.projectRoot, archive));
103966
104005
  archived = true;
103967
104006
  return { action: "writer-lock-recovered", archived_lock: archive, next: "context task recover --format json" };
103968
104007
  } finally {
@@ -103985,8 +104024,8 @@ __export(exports_taskRecovery, {
103985
104024
  TRANSACTIONS_PATH: () => TRANSACTIONS_PATH,
103986
104025
  RECOVERY_COMMAND: () => RECOVERY_COMMAND
103987
104026
  });
103988
- import { existsSync as existsSync27 } from "node:fs";
103989
- import { dirname as dirname46, join as join114 } from "node:path";
104027
+ import { existsSync as existsSync28 } from "node:fs";
104028
+ import { dirname as dirname47, join as join115 } from "node:path";
103990
104029
  import { lstat as lstat18, readdir as readdir29, readFile as readFile95 } from "node:fs/promises";
103991
104030
  async function recoveryText(root2, path3) {
103992
104031
  const target = await safeProjectTarget(root2, path3);
@@ -104004,7 +104043,7 @@ async function recoveryJournals(root2) {
104004
104043
  await safeProjectTarget(root2, path3);
104005
104044
  let stat12;
104006
104045
  try {
104007
- stat12 = await lstat18(join114(root2, path3));
104046
+ stat12 = await lstat18(join115(root2, path3));
104008
104047
  } catch (error) {
104009
104048
  if (error.code === "ENOENT")
104010
104049
  return;
@@ -104015,7 +104054,7 @@ async function recoveryJournals(root2) {
104015
104054
  if (stat12.isDirectory()) {
104016
104055
  if (depth > 3)
104017
104056
  throw new TypeError("Unexpected transaction directory depth; preserve it for diagnosis.");
104018
- for (const name3 of (await readdir29(join114(root2, path3))).sort())
104057
+ for (const name3 of (await readdir29(join115(root2, path3))).sort())
104019
104058
  await visit4(`${path3}/${name3}`, depth + 1);
104020
104059
  } else if (stat12.isFile())
104021
104060
  entries2.push({ path: path3, digest: indexerProtocolDigest(await recoveryText(root2, path3)) });
@@ -104025,12 +104064,12 @@ async function recoveryJournals(root2) {
104025
104064
  }
104026
104065
  function recoveryResources() {
104027
104066
  try {
104028
- const root2 = dirname46(contextWorkflowProviderPath());
104067
+ const root2 = dirname47(contextWorkflowProviderPath());
104029
104068
  const resources = {
104030
- skill: join114(root2, "skills/recover-workspace/SKILL.md"),
104031
- issue_template: join114(root2, "resources/templates/recovery-issue.md")
104069
+ skill: join115(root2, "skills/recover-workspace/SKILL.md"),
104070
+ issue_template: join115(root2, "resources/templates/recovery-issue.md")
104032
104071
  };
104033
- if (!Object.values(resources).every((path3) => existsSync27(path3)))
104072
+ if (!Object.values(resources).every((path3) => existsSync28(path3)))
104034
104073
  throw new Error("Recovery resources are absent from this Provider.");
104035
104074
  return resources;
104036
104075
  } catch {
@@ -104114,7 +104153,7 @@ __export(exports_taskLocalSourceAdjustment, {
104114
104153
  adjustLocalRevisionSources: () => adjustLocalRevisionSources
104115
104154
  });
104116
104155
  import { readFile as readFile96 } from "node:fs/promises";
104117
- import { join as join115 } from "node:path";
104156
+ import { join as join116 } from "node:path";
104118
104157
  async function adjustLocalRevisionSources(root2, input) {
104119
104158
  const { readMaintenance: readMaintenance2 } = await Promise.resolve().then(() => (init_maintenanceStorage(), exports_maintenanceStorage));
104120
104159
  if ((await readMaintenance2(root2)).active && await readProductionStage(root2))
@@ -104157,7 +104196,7 @@ async function adjustLocalRevisionSources(root2, input) {
104157
104196
  if (input.refresh && (!current2.refresh_sources || indexerProtocolDigest([...current2.refresh_sources].sort()) !== indexerProtocolDigest([...selected].sort()))) {
104158
104197
  throw new TypeError("No matching acquisition adjustment exists. Run task adjust without refresh first.");
104159
104198
  }
104160
- const raw = await readFile96(join115(root2, await revisionStoragePath(root2)), "utf8");
104199
+ const raw = await readFile96(join116(root2, await revisionStoragePath(root2)), "utf8");
104161
104200
  let next2;
104162
104201
  const discardIds = new Set;
104163
104202
  if (!input.refresh) {
@@ -104272,7 +104311,7 @@ ${input.instruction}` : revision.instruction
104272
104311
  content: content3
104273
104312
  }];
104274
104313
  if (discardIds.size > 0) {
104275
- const ledger = await readFile96(join115(root2, CANDIDATE_LEDGER_FILE), "utf8").catch((error) => {
104314
+ const ledger = await readFile96(join116(root2, CANDIDATE_LEDGER_FILE), "utf8").catch((error) => {
104276
104315
  if (error.code === "ENOENT")
104277
104316
  return;
104278
104317
  throw error;
@@ -104769,7 +104808,7 @@ init_dist();
104769
104808
  init_cliFeedback();
104770
104809
  init_errors3();
104771
104810
  init_exitCode();
104772
- import { join as join102 } from "node:path";
104811
+ import { join as join103 } from "node:path";
104773
104812
 
104774
104813
  // src/project/documentCaptureAvailability.ts
104775
104814
  init_atomicFileBatch();
@@ -104778,11 +104817,11 @@ init_documentRun();
104778
104817
  init_writeLock();
104779
104818
  import { createHash as createHash26 } from "node:crypto";
104780
104819
  import { readFile as readFile75, rm as rm20 } from "node:fs/promises";
104781
- import { join as join91 } from "node:path";
104820
+ import { join as join92 } from "node:path";
104782
104821
  import { isDeepStrictEqual } from "node:util";
104783
104822
  function receiptPath(root, phaseId) {
104784
104823
  const key = createHash26("sha256").update(phaseId).digest("hex");
104785
- return join91(root, ".tmp/context-runtime/document-acquisition", `${key}.json`);
104824
+ return join92(root, ".tmp/context-runtime/document-acquisition", `${key}.json`);
104786
104825
  }
104787
104826
  async function identity(root, phase) {
104788
104827
  const resolved = await resolveDocumentPhaseSource({ projectRoot: root, phase });
@@ -104814,7 +104853,7 @@ async function runDocumentCaptureWithAvailability(root, phase, capture2) {
104814
104853
  retry_command: `context run ${phase.id}`,
104815
104854
  message: source2.snapshotReady ? "Document refresh unavailable. Retain the validated registered snapshot; it is not confirmed current upstream." : "Document acquisition unavailable. Keep this source registered as a pending evidence gap; do not cite it or invent content. Unrelated work may continue."
104816
104855
  };
104817
- await applyAtomicFileBatch({ transactionRoot: join91(root, ".tmp/context-runtime/transactions"), writes: [{ path: path2, bytes: `${JSON.stringify({ configuration, warning }, null, 2)}
104856
+ await applyAtomicFileBatch({ transactionRoot: join92(root, ".tmp/context-runtime/transactions"), writes: [{ path: path2, bytes: `${JSON.stringify({ configuration, warning }, null, 2)}
104818
104857
  ` }] });
104819
104858
  return {
104820
104859
  kind: "document.capture.warning",
@@ -104859,7 +104898,7 @@ init_workspacePreparation();
104859
104898
  init_siteTranslation();
104860
104899
  init_src2();
104861
104900
  init_statusReaders();
104862
- import { join as join95 } from "node:path";
104901
+ import { join as join96 } from "node:path";
104863
104902
 
104864
104903
  // src/project/statusEvidence.ts
104865
104904
  function evidenceWarningState(issues) {
@@ -105299,7 +105338,7 @@ async function collectProjectStatusSnapshotInternal(projectRoot, options = {}) {
105299
105338
  const authoring = production && !production.delivery && (dispatchProductionStage(production, productionCapabilitiesSchema.parse({})).state !== "ended" || draftStatus.count > 0 && draftStatus.diagnostics.length === 0);
105300
105339
  const deferDeliveryChecks = !maintenance && !localRevision && !localUpdate && !localRollback && (taskPreparation === "cleared" && !production || !!authoring);
105301
105340
  const collectionsWithPages = new Set;
105302
- const approvedPages = await countFiles(join95(projectRoot, "knowledge"), (rel) => {
105341
+ const approvedPages = await countFiles(join96(projectRoot, "knowledge"), (rel) => {
105303
105342
  if (!isApprovedKnowledgeMarkdownPath(rel) || rel.startsWith("assets/"))
105304
105343
  return false;
105305
105344
  collectionsWithPages.add(rel.split("/")[0]);
@@ -105307,7 +105346,7 @@ async function collectProjectStatusSnapshotInternal(projectRoot, options = {}) {
105307
105346
  });
105308
105347
  const approvedCollections = KNOWLEDGE_COLLECTIONS.filter((collection) => collectionsWithPages.has(collection));
105309
105348
  const closeStatus = deferDeliveryChecks ? { state: "not-checked", diagnostics: [] } : await readCloseStatus(projectRoot);
105310
- const distFiles = await countFiles(join95(projectRoot, "dist"), () => true);
105349
+ const distFiles = await countFiles(join96(projectRoot, "dist"), () => true);
105311
105350
  const verifyStatus = !deferDeliveryChecks && draftStatus.diagnostics.length === 0 ? await readVerifyStatus(projectRoot) : { issues: [], diagnostics: [] };
105312
105351
  const revisionDocuments = localRevision ? documentSources.filter((source2) => localRevision.target.source_refs.some((ref2) => [source2.name, source2.id].filter(Boolean).some((name3) => ref2 === `${source2.type}:${name3}` || ref2 === `docs:${name3}` || ref2.startsWith(`${source2.type}:${name3}#`) || ref2.startsWith(`${source2.type}:${name3}/`)))) : documentSources;
105313
105352
  const pendingCapture = pendingDocumentCaptureCommands({
@@ -105685,7 +105724,7 @@ function bindWorkflowExecutionContext(result, context) {
105685
105724
  init_atomicWrite();
105686
105725
  import { Buffer as Buffer4 } from "node:buffer";
105687
105726
  import { createHash as createHash27 } from "node:crypto";
105688
- import { join as join96 } from "node:path";
105727
+ import { join as join97 } from "node:path";
105689
105728
  var WORKFLOW_ROUTE_INLINE_BYTE_LIMIT = 8 * 1024;
105690
105729
  async function workflowRouteOutput(projectRoot, route, options = {}) {
105691
105730
  if (!route)
@@ -105693,7 +105732,7 @@ async function workflowRouteOutput(projectRoot, route, options = {}) {
105693
105732
  const body = `${JSON.stringify(route, null, 2)}
105694
105733
  `;
105695
105734
  const digest6 = createHash27("sha256").update(body).digest("hex");
105696
- const file = join96(projectRoot, ".tmp/context-runtime/routes", `${digest6}.json`);
105735
+ const file = join97(projectRoot, ".tmp/context-runtime/routes", `${digest6}.json`);
105697
105736
  await atomicWriteFile(file, body);
105698
105737
  const routeBytes = Buffer4.byteLength(body);
105699
105738
  const inlineByteLimit = Math.max(0, Math.min(WORKFLOW_ROUTE_INLINE_BYTE_LIMIT, options.inlineByteLimit ?? WORKFLOW_ROUTE_INLINE_BYTE_LIMIT));
@@ -105715,7 +105754,7 @@ async function workflowRunResultFile(projectRoot, result) {
105715
105754
  const body = `${JSON.stringify(result, null, 2)}
105716
105755
  `;
105717
105756
  const digest6 = createHash27("sha256").update(body).digest("hex");
105718
- const file = join96(projectRoot, ".tmp/context-runtime/action-results", `${digest6}.run.json`);
105757
+ const file = join97(projectRoot, ".tmp/context-runtime/action-results", `${digest6}.run.json`);
105719
105758
  await atomicWriteFile(file, body);
105720
105759
  return file;
105721
105760
  }
@@ -105863,8 +105902,8 @@ init_workflowTypes();
105863
105902
  init_candidateLedger();
105864
105903
  init_reviewShared();
105865
105904
  import { mkdir as mkdir35, readFile as readFile81, writeFile as writeFile28 } from "node:fs/promises";
105866
- import { fileURLToPath as fileURLToPath7 } from "node:url";
105867
- import { dirname as dirname42, isAbsolute as isAbsolute17, join as join100, resolve as resolve32 } from "node:path";
105905
+ import { fileURLToPath as fileURLToPath8 } from "node:url";
105906
+ import { dirname as dirname43, isAbsolute as isAbsolute17, join as join101, resolve as resolve32 } from "node:path";
105868
105907
 
105869
105908
  // src/project/reviewSiteModel.ts
105870
105909
  init_siteTheme2();
@@ -105873,7 +105912,7 @@ init_unified();
105873
105912
  init_remark_parse();
105874
105913
  var import_yaml48 = __toESM(require_dist(), 1);
105875
105914
  import { readFile as readFile79 } from "node:fs/promises";
105876
- import { join as join98 } from "node:path";
105915
+ import { join as join99 } from "node:path";
105877
105916
  import { execFile as execFile11 } from "node:child_process";
105878
105917
  import { promisify as promisify11 } from "node:util";
105879
105918
  import { createHash as createHash28 } from "node:crypto";
@@ -108839,9 +108878,9 @@ init_workspace();
108839
108878
 
108840
108879
  // src/project/reviewFeedback.ts
108841
108880
  import { readdir as readdir23, readFile as readFile78 } from "node:fs/promises";
108842
- import { join as join97 } from "node:path";
108881
+ import { join as join98 } from "node:path";
108843
108882
  async function readPendingReviewFeedback(root2, candidates) {
108844
- const directory = join97(root2, ".tmp/context-runtime/review-feedback");
108883
+ const directory = join98(root2, ".tmp/context-runtime/review-feedback");
108845
108884
  let files;
108846
108885
  try {
108847
108886
  files = await readdir23(directory);
@@ -108854,7 +108893,7 @@ async function readPendingReviewFeedback(root2, candidates) {
108854
108893
  const results = new Map;
108855
108894
  const receipts = [];
108856
108895
  for (const file of files.filter((f) => /^[a-f0-9]+\.json$/u.test(f)).sort()) {
108857
- const receipt2 = JSON.parse(await readFile78(join97(directory, file), "utf8"));
108896
+ const receipt2 = JSON.parse(await readFile78(join98(directory, file), "utf8"));
108858
108897
  receipts.push(receipt2);
108859
108898
  }
108860
108899
  for (const receipt2 of receipts.sort((a, b) => a.created_at.localeCompare(b.created_at))) {
@@ -108991,7 +109030,7 @@ async function reviewSiteBaselineHash(root2, reviewedPaths) {
108991
109030
  const displayed = new Set([...reviewedPaths, ...(metadata.structure?.articles ?? []).filter((a) => navigation.changedArticles.has(a.article_id)).map((a) => a.path)]);
108992
109031
  return hash4(JSON.stringify([
108993
109032
  navigation.baseline,
108994
- await optional2(join98(root2, "src/knowledge-map.yaml")) ?? null,
109033
+ await optional2(join99(root2, "src/knowledge-map.yaml")) ?? null,
108995
109034
  files.map((f) => [f.relPath, displayed.has(f.relPath) ? hash4(f.content) : title(f.content, f.relPath)]).sort((a, b) => a[0].localeCompare(b[0]))
108996
109035
  ]));
108997
109036
  }
@@ -109101,9 +109140,9 @@ async function collectReviewSiteModel(root2, candidates) {
109101
109140
  for (const [i2, p] of unplaced.entries())
109102
109141
  nodes.push({ key: `review-page-${p.id}`, parent: "review-unplaced", title: p.title, order: i2, page: p.id, change: p.change });
109103
109142
  }
109104
- const pkgText = await optional2(join98(root2, "package.json"));
109143
+ const pkgText = await optional2(join99(root2, "package.json"));
109105
109144
  const pkg = pkgText ? JSON.parse(pkgText) : {};
109106
- const project = await optional2(join98(root2, "src/index.ts")) === undefined ? undefined : await loadContextProjectModule(root2);
109145
+ const project = await optional2(join99(root2, "src/index.ts")) === undefined ? undefined : await loadContextProjectModule(root2);
109107
109146
  const siteTitle = project?.project.packages.flatMap((p) => p.kind === "package.kb" && p.site?.title ? [p.site.title] : [])[0];
109108
109147
  const sitePackages = project?.project.packages.flatMap((p) => p.kind === "package.kb" && p.site ? [p.site] : []) ?? [];
109109
109148
  const themeCss = siteThemeVariables(await resolveSiteTheme(root2, sitePackages.length === 1 ? sitePackages[0]?.theme : undefined));
@@ -109118,8 +109157,8 @@ init_cliFeedback();
109118
109157
  init_exitCode();
109119
109158
  init_reviewShared();
109120
109159
  import { readFile as readFile80 } from "node:fs/promises";
109121
- import { join as join99 } from "node:path";
109122
- var scopePath = (root2, scope2) => join99(root2, ".tmp/context-runtime/review", `${scope2}.scope.json`);
109160
+ import { join as join100 } from "node:path";
109161
+ var scopePath = (root2, scope2) => join100(root2, ".tmp/context-runtime/review", `${scope2}.scope.json`);
109123
109162
  async function saveReviewReportScope(root2, scope2, candidates, baselineHash) {
109124
109163
  const ids = candidates.map((candidate) => candidate.record.candidate_id).sort();
109125
109164
  const value = {
@@ -109596,7 +109635,7 @@ button:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
109596
109635
 
109597
109636
  // src/project/reviewHtml.ts
109598
109637
  init_knowledgeMap2();
109599
- var REVIEW_HTML_ROOT = join100(".tmp", "context-runtime", "review");
109638
+ var REVIEW_HTML_ROOT = join101(".tmp", "context-runtime", "review");
109600
109639
  async function collectReviewCandidates(projectRoot, collection) {
109601
109640
  const rows = await readCandidateRecords(projectRoot);
109602
109641
  const draftRows = rows.filter((row) => row.collection === collection && row.status === "draft");
@@ -109645,7 +109684,7 @@ ${diagramScript ? `<script>${diagramScript}</script>` : ""}<script>const DATA=${
109645
109684
  }
109646
109685
  function resolveOutputPath(projectRoot, outPath, reviewScope) {
109647
109686
  if (outPath === undefined)
109648
- return join100(projectRoot, REVIEW_HTML_ROOT, `${reviewScope}.html`);
109687
+ return join101(projectRoot, REVIEW_HTML_ROOT, `${reviewScope}.html`);
109649
109688
  return isAbsolute17(outPath) ? outPath : resolve32(projectRoot, outPath);
109650
109689
  }
109651
109690
  async function writeReviewHtml(input) {
@@ -109655,13 +109694,13 @@ async function writeReviewHtml(input) {
109655
109694
  }
109656
109695
  const candidates = reviewScope === "all" ? await collectAllReviewCandidates(input.projectRoot) : await collectReviewCandidates(input.projectRoot, reviewScope);
109657
109696
  const outPath = resolveOutputPath(input.projectRoot, input.out, reviewScope);
109658
- await mkdir35(dirname42(outPath), { recursive: true });
109697
+ await mkdir35(dirname43(outPath), { recursive: true });
109659
109698
  const model = await collectReviewSiteModel(input.projectRoot, candidates);
109660
109699
  let diagramScript = "";
109661
109700
  if (model.pages.some((page) => page.html.includes('class="language-mermaid"'))) {
109662
- const here = dirname42(fileURLToPath7(import.meta.url));
109701
+ const here = dirname43(fileURLToPath8(import.meta.url));
109663
109702
  try {
109664
- diagramScript = await readFile81(join100(here, "browser/diagrams.js"), "utf8");
109703
+ diagramScript = await readFile81(join101(here, "browser/diagrams.js"), "utf8");
109665
109704
  } catch (error) {
109666
109705
  if (error.code !== "ENOENT")
109667
109706
  throw error;
@@ -109698,7 +109737,7 @@ init_dist();
109698
109737
  init_atomicWrite();
109699
109738
  init_reviewShared();
109700
109739
  import { mkdir as mkdir36, readFile as readFile82 } from "node:fs/promises";
109701
- import { join as join101 } from "node:path";
109740
+ import { join as join102 } from "node:path";
109702
109741
  var REVIEW_BATCH_MAX_CANDIDATES = 6;
109703
109742
  var REVIEW_BATCH_MAX_BYTES = 512 * 1024;
109704
109743
  async function readerPurposes(projectRoot, sources) {
@@ -109778,11 +109817,11 @@ async function materializeCurrentReviewBatchSet(input) {
109778
109817
  const batches = buildCurrentReviewBatchDocuments(input.candidates);
109779
109818
  const setDigest = digestText(batches.map((batch) => `${batch.task_key}:${batch.digest}`).join(`
109780
109819
  `));
109781
- const root2 = join101(input.projectRoot, ".tmp", "context-runtime", "review", `current-${setDigest.slice("sha256:".length)}`);
109820
+ const root2 = join102(input.projectRoot, ".tmp", "context-runtime", "review", `current-${setDigest.slice("sha256:".length)}`);
109782
109821
  await mkdir36(root2, { recursive: true });
109783
109822
  const entries2 = [];
109784
109823
  for (const batch of batches) {
109785
- const path4 = join101(input.projectRoot, ".tmp", "context-runtime", "review", `${batch.task_key}-${batch.digest.slice("sha256:".length)}.md`);
109824
+ const path4 = join102(input.projectRoot, ".tmp", "context-runtime", "review", `${batch.task_key}-${batch.digest.slice("sha256:".length)}.md`);
109786
109825
  const existing = await readFile82(path4, "utf8").catch((error) => {
109787
109826
  if (error.code === "ENOENT")
109788
109827
  return;
@@ -109836,7 +109875,7 @@ async function materializeCurrentReviewBatchSet(input) {
109836
109875
  ].join(`
109837
109876
  `);
109838
109877
  const digest6 = digestText(content3);
109839
- const path3 = join101(root2, "index.md");
109878
+ const path3 = join102(root2, "index.md");
109840
109879
  await atomicWriteFile(path3, `${content3}
109841
109880
  `);
109842
109881
  return {
@@ -109869,11 +109908,11 @@ function shellQuote6(value) {
109869
109908
  }
109870
109909
  function receiptSetPath(receipts) {
109871
109910
  const token = digestText(JSON.stringify(receipts)).slice("sha256:".length);
109872
- return join102(".tmp", "context-runtime", "workflow", "read-receipts", `${token}.json`);
109911
+ return join103(".tmp", "context-runtime", "workflow", "read-receipts", `${token}.json`);
109873
109912
  }
109874
109913
  async function writeReceiptContinuation(input) {
109875
109914
  const path3 = receiptSetPath(input.receipts);
109876
- const absolutePath = join102(input.projectRoot, path3);
109915
+ const absolutePath = join103(input.projectRoot, path3);
109877
109916
  await writeJsonAtomic(absolutePath, input.receipts);
109878
109917
  const contextCommand = input.managed ? [
109879
109918
  "context",
@@ -109968,7 +110007,7 @@ async function materializeContextWorkflowResource(input) {
109968
110007
  const resourceId = workflowResourceId(input.resourceId);
109969
110008
  const content3 = renderContextWorkflowResource(resourceId, status);
109970
110009
  const location = await materializeResource(await loadContextWorkflowProvider(), resourceId, {
109971
- cache: join102(found.projectRoot, ".tmp", "context-runtime", "workflow", "resources"),
110010
+ cache: join103(found.projectRoot, ".tmp", "context-runtime", "workflow", "resources"),
109972
110011
  workspace: found.projectRoot,
109973
110012
  revision: input.revision,
109974
110013
  input: {
@@ -110000,7 +110039,7 @@ async function materializeContextWorkflowResource(input) {
110000
110039
  receipts: afterReadReceipts
110001
110040
  });
110002
110041
  const directResources = (status.workflow.current?.resources.required ?? []).filter((resource) => resource.read_state === "read-required" && resource.path !== undefined && resource.digest !== undefined);
110003
- const afterReadCommand = directResources.length === 0 ? continuation.command : `context resource acknowledge-current --revision ${shellQuote6(input.revision)}${authorityCommandOptions(authorities, "resource")} --resource-receipts ${shellQuote6(`@${join102(found.projectRoot, continuation.path)}`)} --format json`;
110042
+ const afterReadCommand = directResources.length === 0 ? continuation.command : `context resource acknowledge-current --revision ${shellQuote6(input.revision)}${authorityCommandOptions(authorities, "resource")} --resource-receipts ${shellQuote6(`@${join103(found.projectRoot, continuation.path)}`)} --format json`;
110004
110043
  return {
110005
110044
  protocol: "context.workflow.resource.v1",
110006
110045
  id: resourceId,
@@ -110061,14 +110100,14 @@ async function acknowledgeCurrentWorkflowResources(input) {
110061
110100
  const reevaluated = await reevaluateProjectStatusWorkflow({
110062
110101
  snapshot,
110063
110102
  resourceReceipts: normalizedReceipts,
110064
- resourceReceiptsReference: `@${join102(found.projectRoot, continuation.path)}`
110103
+ resourceReceiptsReference: `@${join103(found.projectRoot, continuation.path)}`
110065
110104
  });
110066
110105
  return {
110067
110106
  ...reevaluated,
110068
110107
  resourceAcknowledgement: {
110069
110108
  protocol: "context.workflow.resource-receipts.v1",
110070
110109
  acknowledged: directResources.length,
110071
- receiptReference: `@${join102(found.projectRoot, continuation.path)}`,
110110
+ receiptReference: `@${join103(found.projectRoot, continuation.path)}`,
110072
110111
  message: "For workflow continuation, use the returned selected command with its revision and resource-receipt arguments. Receipts retain required-reading state for Route evaluation; they are not approval credentials or universal prerequisites for direct CLI primitives. Direct commands still enforce their own state, scope and confirmation checks. Do not pre-chain an earlier write command or replace this result with status without receipts. Acknowledgement does not necessarily change the revision; reread only changed or unavailable required content."
110073
110112
  }
110074
110113
  };
@@ -110116,8 +110155,8 @@ init_errors3();
110116
110155
  init_exitCode();
110117
110156
  init_workspace();
110118
110157
  import { readFile as readFile83 } from "node:fs/promises";
110119
- import { isAbsolute as isAbsolute18, join as join103, sep as sep8, resolve as resolve33 } from "node:path";
110120
- var RECEIPT_DIRECTORY = join103(".tmp", "context-runtime", "workflow", "read-receipts");
110158
+ import { isAbsolute as isAbsolute18, join as join104, sep as sep8, resolve as resolve33 } from "node:path";
110159
+ var RECEIPT_DIRECTORY = join104(".tmp", "context-runtime", "workflow", "read-receipts");
110121
110160
  function workflowResourceReceiptCwd(value, cwd) {
110122
110161
  if (value === undefined || !value.startsWith("@"))
110123
110162
  return cwd;
@@ -110236,7 +110275,7 @@ function registerContextWorkflowResourceCommands(program2) {
110236
110275
  }
110237
110276
 
110238
110277
  // src/commands/runProject.ts
110239
- import { fileURLToPath as fileURLToPath8 } from "node:url";
110278
+ import { fileURLToPath as fileURLToPath9 } from "node:url";
110240
110279
  init_cliFeedback();
110241
110280
  init_errors3();
110242
110281
 
@@ -110395,15 +110434,15 @@ function compactJsonResult(result, verbose) {
110395
110434
  // src/project/runLog.ts
110396
110435
  import { randomUUID as randomUUID6 } from "node:crypto";
110397
110436
  import { mkdir as mkdir38, writeFile as writeFile30 } from "node:fs/promises";
110398
- import { dirname as dirname44, join as join109 } from "node:path";
110437
+ import { dirname as dirname45, join as join110 } from "node:path";
110399
110438
  var createPhaseRunId = () => {
110400
110439
  const timestamp = new Date().toISOString().replace(/[-:.TZ]/gu, "");
110401
110440
  return `run_${timestamp}_${randomUUID6().slice(0, 8)}`;
110402
110441
  };
110403
110442
  async function writePhaseRunLog(input) {
110404
- const relPath = join109(".tmp", "context-runtime", "runs", `${input.runId}.json`);
110405
- const absPath = join109(input.projectRoot, relPath);
110406
- await mkdir38(dirname44(absPath), { recursive: true });
110443
+ const relPath = join110(".tmp", "context-runtime", "runs", `${input.runId}.json`);
110444
+ const absPath = join110(input.projectRoot, relPath);
110445
+ await mkdir38(dirname45(absPath), { recursive: true });
110407
110446
  await writeFile30(absPath, `${JSON.stringify({
110408
110447
  run_id: input.runId,
110409
110448
  phase_id: input.phase.id,
@@ -111638,9 +111677,9 @@ init_reviewCandidateAuthority();
111638
111677
  init_durableMultiFileTransaction();
111639
111678
  init_durableSingleFileTransaction();
111640
111679
  init_reviewShared();
111641
- import { existsSync as existsSync26 } from "node:fs";
111680
+ import { existsSync as existsSync27 } from "node:fs";
111642
111681
  import { readFile as readFile88 } from "node:fs/promises";
111643
- import { join as join110 } from "node:path";
111682
+ import { join as join111 } from "node:path";
111644
111683
  function existingTimestamp(markdown) {
111645
111684
  if (markdown === undefined)
111646
111685
  return;
@@ -111667,7 +111706,7 @@ async function prepareApprovedPage(input) {
111667
111706
  next: "Refresh the current production or article revision, then reopen Review before approval."
111668
111707
  });
111669
111708
  }
111670
- const relPath = join110("knowledge", input.record.path);
111709
+ const relPath = join111("knowledge", input.record.path);
111671
111710
  const existingView = findApprovedPageForArticleId(input.record.indexer_candidate.artifact_ref, input.approvedPageIndex);
111672
111711
  const previousPath = input.record.approved_revision?.previous_path;
111673
111712
  if (previousPath !== undefined && (!isSafeKnowledgeTargetPath(previousPath.split("/")[0], previousPath) || previousPath.includes("\\")))
@@ -111682,13 +111721,13 @@ async function prepareApprovedPage(input) {
111682
111721
  next: "Resolve the approved page path migration explicitly before approving this candidate."
111683
111722
  });
111684
111723
  }
111685
- const absPath = join110(input.projectRoot, relPath);
111686
- const existing = existsSync26(absPath) ? await readFile88(absPath, "utf8") : undefined;
111724
+ const absPath = join111(input.projectRoot, relPath);
111725
+ const existing = existsSync27(absPath) ? await readFile88(absPath, "utf8") : undefined;
111687
111726
  let previous3;
111688
111727
  if (previousPath !== undefined) {
111689
111728
  if (existing !== undefined || existingView?.relPath !== `knowledge/${previousPath}`)
111690
111729
  throw new TypeError("Page move destination or original identity changed; refresh its revision.");
111691
- previous3 = { path: `knowledge/${previousPath}`, content: await readFile88(join110(input.projectRoot, "knowledge", previousPath), "utf8") };
111730
+ previous3 = { path: `knowledge/${previousPath}`, content: await readFile88(join111(input.projectRoot, "knowledge", previousPath), "utf8") };
111692
111731
  }
111693
111732
  if (input.record.approved_revision !== undefined) {
111694
111733
  const base = previous3?.content ?? existing;
@@ -111735,7 +111774,7 @@ async function prepareApprovedPage(input) {
111735
111774
  }
111736
111775
  async function readProjectFileMaybe(projectRoot, relPath) {
111737
111776
  try {
111738
- return await readFile88(join110(projectRoot, relPath), "utf8");
111777
+ return await readFile88(join111(projectRoot, relPath), "utf8");
111739
111778
  } catch (error) {
111740
111779
  if (error !== null && typeof error === "object" && "code" in error && error.code === "ENOENT") {
111741
111780
  return;
@@ -111956,7 +111995,7 @@ async function applyReviewDecisions(input) {
111956
111995
  });
111957
111996
  }
111958
111997
  seenApprovedIds.set(approvedRef, row.candidate_id);
111959
- const approvedPath = join110("knowledge", row.path);
111998
+ const approvedPath = join111("knowledge", row.path);
111960
111999
  const previousPathCandidate = seenApprovedPaths.get(knowledgeTargetPathKey(approvedPath));
111961
112000
  if (previousPathCandidate !== undefined) {
111962
112001
  throw new ContextError(ExitCode.UserError, `multiple approved review decisions target the same knowledge path: ${approvedPath}`, {
@@ -112006,7 +112045,7 @@ async function applyReviewDecisions(input) {
112006
112045
  for (const path3 of approvedPageIndex.byRelPath.keys()) {
112007
112046
  if (pagesToWrite.some((page) => page.relPath === path3 || page.previous?.path === path3))
112008
112047
  continue;
112009
- const before = await readFile88(join110(input.projectRoot, path3), "utf8");
112048
+ const before = await readFile88(join111(input.projectRoot, path3), "utf8");
112010
112049
  const local = path3.replace(/^knowledge\//u, "");
112011
112050
  const after = moveKnowledgeLinkTargets2(before, local, local, moved);
112012
112051
  navigationTargets.push(reviewFileTarget({ path: path3, baseContent: before, targetContent: after }));
@@ -112090,12 +112129,12 @@ init_candidateLedger();
112090
112129
 
112091
112130
  // src/project/localHtmlReport.ts
112092
112131
  import { execFile as execFile12 } from "node:child_process";
112093
- import { isAbsolute as isAbsolute20, join as join111 } from "node:path";
112132
+ import { isAbsolute as isAbsolute20, join as join112 } from "node:path";
112094
112133
  import { pathToFileURL as pathToFileURL2 } from "node:url";
112095
112134
  import { promisify as promisify12 } from "node:util";
112096
112135
  var execFileAsync5 = promisify12(execFile12);
112097
112136
  function htmlReportReference(input) {
112098
- const absolutePath = isAbsolute20(input.path) ? input.path : join111(input.projectRoot, input.path);
112137
+ const absolutePath = isAbsolute20(input.path) ? input.path : join112(input.projectRoot, input.path);
112099
112138
  return {
112100
112139
  format: "html",
112101
112140
  path: input.path,
@@ -112899,7 +112938,7 @@ async function runProjectUntil(input) {
112899
112938
  const resourceReceipts = input.resourceReceiptsReference === undefined ? undefined : await parseWorkflowResourceReceipts(input.resourceReceiptsReference, found.projectRoot);
112900
112939
  const runtime = new WorkspaceExecutionRuntime({
112901
112940
  projectRoot: found.projectRoot,
112902
- cliEntryPath: fileURLToPath8(input.cliModuleUrl),
112941
+ cliEntryPath: fileURLToPath9(input.cliModuleUrl),
112903
112942
  inProcess: createWorkflowInProcessExecutor()
112904
112943
  });
112905
112944
  let result;
@@ -113097,7 +113136,7 @@ init_maintenanceStorage();
113097
113136
  init_productionFeedback();
113098
113137
  import { randomUUID as randomUUID7 } from "node:crypto";
113099
113138
  import { readFile as readFile91 } from "node:fs/promises";
113100
- import { join as join112 } from "node:path";
113139
+ import { join as join113 } from "node:path";
113101
113140
  async function beginProductionRevision(input) {
113102
113141
  return withProductionFeedback({ operation: "revision" }, () => withProjectWriteLock(input.projectRoot, "production-revision", async () => {
113103
113142
  await recoverDurableMultiFileTransactions(input.projectRoot);
@@ -113136,7 +113175,7 @@ async function beginProductionRevision(input) {
113136
113175
  const formal = approved.byPath.get(path3);
113137
113176
  if (!prior && !formal)
113138
113177
  throw invalid2("Write the current task first; there is no article draft to revise yet.");
113139
- const markdown = prior?.body ?? await readFile91(await safeProjectTarget(input.projectRoot, join112("knowledge", path3)), "utf8");
113178
+ const markdown = prior?.body ?? await readFile91(await safeProjectTarget(input.projectRoot, join113("knowledge", path3)), "utf8");
113140
113179
  const sections = prior?.indexer_candidate.sections.map((section) => ({ id: section.section_key, references: section.references })) ?? formal?.sections;
113141
113180
  const sources = [];
113142
113181
  for (const source2 of owner.sources) {
@@ -113702,7 +113741,7 @@ function registerVersionCommands(program2) {
113702
113741
 
113703
113742
  // src/commands/translateCommands.ts
113704
113743
  init_workspace();
113705
- import { isAbsolute as isAbsolute22, join as join116 } from "node:path";
113744
+ import { isAbsolute as isAbsolute22, join as join117 } from "node:path";
113706
113745
  init_siteTranslation();
113707
113746
  function projectRoot() {
113708
113747
  const root2 = findContextProjectRoot(process.cwd())?.projectRoot;
@@ -113787,7 +113826,7 @@ function registerTranslateCommands(program2) {
113787
113826
  readFailureNext: "Check the input path",
113788
113827
  parseFailureNext: "Use valid YAML or JSON"
113789
113828
  }));
113790
- const saved = await submitSiteTranslation(root2, await projectPackages(root2), value, (file) => isAbsolute22(file) ? file : join116(root2, file));
113829
+ const saved = await submitSiteTranslation(root2, await projectPackages(root2), value, (file) => isAbsolute22(file) ? file : join117(root2, file));
113791
113830
  write(await withWorkflow(root2, { outcome: "submitted", ...saved }));
113792
113831
  });
113793
113832
  command3.command("skip").description("Publish the current pending translations in the primary language").requiredOption("--digest <digest>", "expected_digest from context translate prepare").option("--format <format>", "json", "json").action(async (options) => {
@@ -113881,7 +113920,7 @@ init_atomicWrite();
113881
113920
  var import_yaml52 = __toESM(require_dist(), 1);
113882
113921
  import { Buffer as Buffer5 } from "node:buffer";
113883
113922
  import { createHash as createHash35 } from "node:crypto";
113884
- import { join as join117 } from "node:path";
113923
+ import { join as join118 } from "node:path";
113885
113924
  var INLINE_LIMIT = 16 * 1024;
113886
113925
  function record4(value) {
113887
113926
  return value !== null && typeof value === "object" && !Array.isArray(value) ? value : undefined;
@@ -113907,8 +113946,8 @@ async function prepareActionCompletionOutput(input) {
113907
113946
  if (production && Buffer5.byteLength(full) <= INLINE_LIMIT)
113908
113947
  return input.result;
113909
113948
  const digest7 = createHash35("sha256").update(full).digest("hex");
113910
- const root2 = join117(input.projectRoot, ".tmp/context-runtime/action-results");
113911
- const resultFile = join117(root2, `${digest7}.json`);
113949
+ const root2 = join118(input.projectRoot, ".tmp/context-runtime/action-results");
113950
+ const resultFile = join118(root2, `${digest7}.json`);
113912
113951
  await atomicWriteFile(resultFile, full);
113913
113952
  if (production)
113914
113953
  return {
@@ -114337,10 +114376,10 @@ function registerProjectActionCommands(program2) {
114337
114376
 
114338
114377
  // src/commands/cleanClaudePluginCache.ts
114339
114378
  init_cliFeedback();
114340
- import { existsSync as existsSync28 } from "node:fs";
114379
+ import { existsSync as existsSync29 } from "node:fs";
114341
114380
  import { readdir as readdir30, rm as rm24 } from "node:fs/promises";
114342
114381
  import { homedir } from "node:os";
114343
- import { join as join118 } from "node:path";
114382
+ import { join as join119 } from "node:path";
114344
114383
  var ORPHAN_MARKER = ".orphaned_at";
114345
114384
  var CLAUDE_PLUGIN_CACHE_ROOT_ENV = "C4A_CLAUDE_PLUGIN_CACHE_ROOT";
114346
114385
  var CLAUDE_PLUGIN_CACHE_HOME_ENV = "C4A_CLAUDE_PLUGIN_CACHE_HOME";
@@ -114349,7 +114388,7 @@ async function cleanClaudePluginCache(opts = {}) {
114349
114388
  const lines = [];
114350
114389
  let removed = 0;
114351
114390
  let scanned = 0;
114352
- if (!existsSync28(cacheRoot)) {
114391
+ if (!existsSync29(cacheRoot)) {
114353
114392
  lines.push("· claude plugin cache: missing — nothing to clean");
114354
114393
  return { lines, removed, scanned };
114355
114394
  }
@@ -114357,20 +114396,20 @@ async function cleanClaudePluginCache(opts = {}) {
114357
114396
  for (const mp of marketplaces) {
114358
114397
  if (!mp.isDirectory())
114359
114398
  continue;
114360
- const mpDir = join118(cacheRoot, mp.name);
114399
+ const mpDir = join119(cacheRoot, mp.name);
114361
114400
  const plugins = await readdir30(mpDir, { withFileTypes: true });
114362
114401
  for (const pl of plugins) {
114363
114402
  if (!pl.isDirectory())
114364
114403
  continue;
114365
- const plDir = join118(mpDir, pl.name);
114404
+ const plDir = join119(mpDir, pl.name);
114366
114405
  const versions = await readdir30(plDir, { withFileTypes: true });
114367
114406
  for (const ver of versions) {
114368
114407
  if (!ver.isDirectory())
114369
114408
  continue;
114370
114409
  scanned += 1;
114371
- const verDir = join118(plDir, ver.name);
114372
- const markerPath = join118(verDir, ORPHAN_MARKER);
114373
- if (!existsSync28(markerPath))
114410
+ const verDir = join119(plDir, ver.name);
114411
+ const markerPath = join119(verDir, ORPHAN_MARKER);
114412
+ if (!existsSync29(markerPath))
114374
114413
  continue;
114375
114414
  const label2 = `${mp.name}/${pl.name}/${ver.name}`;
114376
114415
  if (opts.dryRun) {
@@ -114401,7 +114440,7 @@ function resolveClaudePluginCacheRoot(opts) {
114401
114440
  if (explicitRoot)
114402
114441
  return explicitRoot;
114403
114442
  const home = opts.home ?? process.env[CLAUDE_PLUGIN_CACHE_HOME_ENV] ?? homedir();
114404
- return join118(home, ".claude", "plugins", "cache");
114443
+ return join119(home, ".claude", "plugins", "cache");
114405
114444
  }
114406
114445
  async function isEmptyDir(dir) {
114407
114446
  try {
@@ -114430,35 +114469,7 @@ async function runDoctorCleanClaudePluginCache(opts = {}) {
114430
114469
  init_errors3();
114431
114470
  init_cliFeedback();
114432
114471
  init_exitCode();
114433
-
114434
- // src/lib/packageVersion.ts
114435
- import { existsSync as existsSync29, readFileSync as readFileSync9 } from "node:fs";
114436
- import { dirname as dirname47, join as join119 } from "node:path";
114437
- import { fileURLToPath as fileURLToPath9 } from "node:url";
114438
- function readPackageVersion() {
114439
- try {
114440
- let dir = dirname47(fileURLToPath9(import.meta.url));
114441
- for (let depth = 0;depth < 8; depth += 1) {
114442
- const packagePath = join119(dir, "package.json");
114443
- if (existsSync29(packagePath)) {
114444
- const parsed = JSON.parse(readFileSync9(packagePath, "utf8"));
114445
- if (typeof parsed.version === "string" && parsed.version.length > 0) {
114446
- return parsed.version;
114447
- }
114448
- break;
114449
- }
114450
- const parent = dirname47(dir);
114451
- if (parent === dir)
114452
- break;
114453
- dir = parent;
114454
- }
114455
- } catch (error) {
114456
- throw new TypeError("Context CLI package version cannot be read", {
114457
- cause: error
114458
- });
114459
- }
114460
- throw new TypeError("Context CLI package version is missing from package.json");
114461
- }
114472
+ init_packageVersion();
114462
114473
 
114463
114474
  // src/project/sourceCommands.ts
114464
114475
  init_repoContentLinks();