@c4a/context-cli 0.7.81 → 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
  }
@@ -89769,18 +89799,11 @@ function sidebar(entries2, label2 = (entry) => entry.title) {
89769
89799
  }));
89770
89800
  }
89771
89801
  function siteSections(entries2) {
89772
- const directoriesFirst = (siblings) => {
89773
- const ordered = [
89774
- ...siblings.filter((entry) => entry.children.length > 0),
89775
- ...siblings.filter((entry) => entry.children.length === 0)
89776
- ];
89777
- return ordered.map((entry) => ({ ...entry, children: directoriesFirst(entry.children) }));
89778
- };
89779
89802
  const pageLinks = (entry) => [
89780
89803
  ...entry.href ? [entry.href.split("#")[0]] : [],
89781
89804
  ...entry.children.flatMap(pageLinks)
89782
89805
  ];
89783
- return entries2.map((entry) => ({ ...entry, children: directoriesFirst(entry.children) })).map((entry) => ({
89806
+ return entries2.map((entry) => ({
89784
89807
  key: entry.key,
89785
89808
  title: entry.title,
89786
89809
  entry,
@@ -89791,9 +89814,9 @@ function siteSections(entries2) {
89791
89814
  }));
89792
89815
  }
89793
89816
  async function compileSite(root, outDir) {
89794
- const vitepressRoot = dirname33(require2.resolve("vitepress/package.json"));
89817
+ const vitepressRoot = dirname34(require2.resolve("vitepress/package.json"));
89795
89818
  await new Promise((resolve8, reject) => {
89796
- 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"] });
89797
89820
  let tail = "";
89798
89821
  const receive = (chunk) => {
89799
89822
  tail = (tail + chunk.toString()).slice(-16000);
@@ -89840,8 +89863,8 @@ async function writePackageSite(input) {
89840
89863
  const base = options.base ?? "/";
89841
89864
  const history = await readWorkspaceChangelog(projectRoot);
89842
89865
  const historyDate = history[0]?.date ?? null;
89843
- const root = join72(projectRoot, pkg.outDir);
89844
- const output = join72(projectRoot, packageSiteOutputDir(pkg));
89866
+ const root = join73(projectRoot, pkg.outDir);
89867
+ const output = join73(projectRoot, packageSiteOutputDir(pkg));
89845
89868
  try {
89846
89869
  await access5(output);
89847
89870
  throw new Error("Website output already exists; build through the staged package workflow.");
@@ -89849,9 +89872,9 @@ async function writePackageSite(input) {
89849
89872
  if (error.code !== "ENOENT")
89850
89873
  throw error;
89851
89874
  }
89852
- const temporaryRoot = join72(projectRoot, ".tmp");
89875
+ const temporaryRoot = join73(projectRoot, ".tmp");
89853
89876
  await mkdir26(temporaryRoot, { recursive: true });
89854
- const temporary = await mkdtemp2(join72(temporaryRoot, "website-"));
89877
+ const temporary = await mkdtemp2(join73(temporaryRoot, "website-"));
89855
89878
  try {
89856
89879
  const registry2 = await loadSourcesRegistry({ rootDir: projectRoot });
89857
89880
  const repositoryRemote = await optionalRepoGit(projectRoot, ["remote", "get-url", "origin"]);
@@ -89877,27 +89900,27 @@ async function writePackageSite(input) {
89877
89900
  }
89878
89901
  const sections = siteSections(mapping.entries);
89879
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));
89880
- const configRoot = join72(temporary, ".vitepress");
89881
- await mkdir26(join72(configRoot, "theme"), { recursive: true });
89882
- await mkdir26(join72(temporary, "node_modules"), { recursive: true });
89883
- const vitepressRoot = dirname33(require2.resolve("vitepress/package.json"));
89884
- 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"));
89885
89908
  for (const [name3, path2] of [
89886
89909
  ["vitepress", vitepressRoot],
89887
- ["vue", dirname33(vueRequire.resolve("vue/package.json"))],
89888
- ["@mermaid-js/layout-elk", dirname33(require2.resolve("@mermaid-js/layout-elk/package.json"))],
89889
- ["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"))]
89890
89913
  ]) {
89891
- await mkdir26(dirname33(join72(temporary, "node_modules", name3)), { recursive: true });
89892
- 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");
89893
89916
  }
89894
89917
  const readers = siteReaderLocales(options, pkg.name);
89895
89918
  const marker = createLocaleMarker();
89896
- await writeFile22(join72(configRoot, "theme/index.js"), siteThemeScript);
89897
- 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)));
89898
89921
  await writeSiteExtensions(projectRoot, temporary, options.extensions);
89899
89922
  const localizer = await createSiteLocalizer({ projectRoot, readers, marker, selected, byPath, resources });
89900
- await mkdir26(join72(temporary, "pages"), { recursive: true });
89923
+ await mkdir26(join73(temporary, "pages"), { recursive: true });
89901
89924
  const primaryBody = (page, packageContent) => {
89902
89925
  let content3 = packageContent;
89903
89926
  if (page.package_path === "wikis/index.md" && typeof pkg.repoContentPage !== "object") {
@@ -89927,9 +89950,9 @@ ${titles ? `contextTitles: ${JSON.stringify(titles)}
89927
89950
  `;
89928
89951
  };
89929
89952
  for (const page of byPath.values()) {
89930
- const content3 = await readFile64(join72(root, page.package_path), "utf8");
89953
+ const content3 = await readFile64(join73(root, page.package_path), "utf8");
89931
89954
  const localized = await localizer.page(page, primaryBody(page, content3));
89932
- 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)}
89933
89956
  ${localized.body}`);
89934
89957
  }
89935
89958
  const themeSections = sections.map((section) => ({
@@ -89988,7 +90011,7 @@ ${localized.body}`);
89988
90011
  contextLocales: { primary: readers.primary, tags: readers.tags, labels: readers.labels, titles: readers.titles, preferenceKey: readers.preferenceKey }
89989
90012
  }
89990
90013
  };
89991
- 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)};
89992
90015
  ` + `export default { ...${JSON.stringify(config)}, markdown: { ${siteMarkdownConfig} },
89993
90016
  ` + ` transformHtml: html => html.replace(/<script id="check-dark-mode">[\\s\\S]*?<\\/script>/u, "") };
89994
90017
  `);
@@ -90004,20 +90027,28 @@ ${localized.body}`);
90004
90027
  menu(lines, entries2, 0, tag);
90005
90028
  lines.push("", "</div>", "");
90006
90029
  };
90007
- await mkdir26(join72(temporary, "sections"), { recursive: true });
90030
+ await mkdir26(join73(temporary, "sections"), { recursive: true });
90008
90031
  for (const section of sections) {
90009
- 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) => {
90010
90033
  const lines = [`# ${mdLabel(localizer.entryTitle(tag, section.entry))}`, "", '<div class="context-section-grid">', ""];
90011
- const groups = section.entries.filter((entry) => entry.children.length > 0);
90012
- const articles = section.entries.filter((entry) => entry.children.length === 0);
90013
- for (const group of groups) {
90014
- card(lines, group.href ? `[${mdLabel(localizer.entryTitle(tag, group))}](${group.href})` : mdLabel(localizer.entryTitle(tag, group)), group.children, tag);
90015
- }
90016
- if (groups.length === 0)
90017
- for (const article of articles)
90018
- card(lines, undefined, [article], tag);
90019
- else if (articles.length)
90020
- card(lines, undefined, articles, tag);
90034
+ const grouped = section.entries.some((entry) => entry.children.length > 0);
90035
+ let articles = [];
90036
+ const flush = () => {
90037
+ if (articles.length)
90038
+ card(lines, undefined, articles, tag);
90039
+ articles = [];
90040
+ };
90041
+ for (const entry of section.entries) {
90042
+ if (entry.children.length === 0) {
90043
+ articles.push(entry);
90044
+ if (!grouped)
90045
+ flush();
90046
+ continue;
90047
+ }
90048
+ flush();
90049
+ card(lines, entry.href ? `[${mdLabel(localizer.entryTitle(tag, entry))}](${entry.href})` : mdLabel(localizer.entryTitle(tag, entry)), entry.children, tag);
90050
+ }
90051
+ flush();
90021
90052
  lines.push("</div>");
90022
90053
  return lines.join(`
90023
90054
  `) + `
@@ -90037,12 +90068,12 @@ ${localized.body}`);
90037
90068
  ` : "";
90038
90069
  const homeHero = options.extensions?.slots?.banner === undefined ? `hero: ${JSON.stringify(hero)}
90039
90070
  ${heroActions}` : "";
90040
- await writeFile22(join72(temporary, "index.md"), `---
90071
+ await writeFile22(join73(temporary, "index.md"), `---
90041
90072
  layout: home
90042
90073
  title: ${JSON.stringify(options.home?.title ?? options.title ?? pkg.name)}
90043
90074
  ${homeHero}---
90044
90075
  `);
90045
- await writeFile22(join72(temporary, "changelog.md"), `---
90076
+ await writeFile22(join73(temporary, "changelog.md"), `---
90046
90077
  title: Changelog
90047
90078
  contextHistory: ${JSON.stringify(Buffer.from(JSON.stringify(history)).toString("base64"))}
90048
90079
  ---
@@ -90055,19 +90086,19 @@ contextHistory: ${JSON.stringify(Buffer.from(JSON.stringify(history)).toString("
90055
90086
  assetsPrefix: "resources/",
90056
90087
  articles: await Promise.all(llmsArticles(pkg, selected).map(async (article) => ({
90057
90088
  ...article,
90058
- content: await readFile64(join72(root, article.path), "utf8")
90089
+ content: await readFile64(join73(root, article.path), "utf8")
90059
90090
  }))),
90060
90091
  ...structure ? { map: structure } : {}
90061
90092
  });
90062
- await writeLlmsDocuments(join72(temporary, "public"), llms, { utf8Bom: true });
90063
- await mkdir26(join72(temporary, "llms"), { recursive: true });
90093
+ await writeLlmsDocuments(join73(temporary, "public"), llms, { utf8Bom: true });
90094
+ await mkdir26(join73(temporary, "llms"), { recursive: true });
90064
90095
  let landingNavigation = llms.navigationMarkdown;
90065
90096
  for (const link of markdownReaderLinks(landingNavigation).reverse()) {
90066
90097
  if (!link.target.startsWith(base))
90067
90098
  continue;
90068
90099
  landingNavigation = landingNavigation.slice(0, link.start) + `[${link.label}](</${link.target.slice(base.length)}>)` + landingNavigation.slice(link.end);
90069
90100
  }
90070
- await writeFile22(join72(temporary, "llms/index.md"), `---
90101
+ await writeFile22(join73(temporary, "llms/index.md"), `---
90071
90102
  title: LLM Docs
90072
90103
  ---
90073
90104
 
@@ -90077,9 +90108,9 @@ title: LLM Docs
90077
90108
 
90078
90109
  ` + landingNavigation);
90079
90110
  for (const path2 of resources) {
90080
- const destination = join72(temporary, "public/resources", path2);
90081
- await mkdir26(dirname33(destination), { recursive: true });
90082
- 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);
90083
90114
  }
90084
90115
  await compileSite(temporary, output);
90085
90116
  const originLinks = [...navigation.nav, ...navigation.more].filter((item) => item.origin).map((item) => item.link);
@@ -90111,11 +90142,11 @@ title: LLM Docs
90111
90142
  warnings: mapping.warnings
90112
90143
  }, null, 2) + `
90113
90144
  `;
90114
- const packageSiteMap = join72(projectRoot, pkg.outDir, "context-site-map.json");
90115
- const distributedSiteMap = join72(projectRoot, pkg.outDir, packageDistributionMetadataPath("context-site-map.json"));
90116
- 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 });
90117
90148
  await Promise.all([
90118
- writeFile22(join72(output, "context-site-map.json"), siteMapContent),
90149
+ writeFile22(join73(output, "context-site-map.json"), siteMapContent),
90119
90150
  writeFile22(packageSiteMap, siteMapContent),
90120
90151
  writeFile22(distributedSiteMap, siteMapContent)
90121
90152
  ]);
@@ -90144,13 +90175,22 @@ var init_packageSite2 = __esm(() => {
90144
90175
  init_packageSiteBranding();
90145
90176
  init_packageSiteExtensions();
90146
90177
  init_packageDistributionMetadata();
90178
+ init_packageVersion();
90147
90179
  init_packageSiteLocales();
90148
- 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")}`;
90149
90189
  require2 = createRequire5(import.meta.url);
90150
90190
  });
90151
90191
 
90152
90192
  // src/project/workspaceBuildVersion.ts
90153
- import { join as join73 } from "node:path";
90193
+ import { join as join74 } from "node:path";
90154
90194
  import { mkdir as mkdir27, writeFile as writeFile23 } from "node:fs/promises";
90155
90195
  async function workspaceVersionFingerprint(root) {
90156
90196
  return { version: await workspaceVersion(root), changelog: await readWorkspaceChangelog(root) };
@@ -90162,8 +90202,8 @@ async function writePackageVersion(projectRoot, output) {
90162
90202
  throw new TypeError(`Package template uses reserved version output ${path2}; rename that template output.`);
90163
90203
  }
90164
90204
  await mkdir27(output, { recursive: true });
90165
- await writeFile23(join73(output, "CHANGELOG.md"), renderChangelog(info.changelog));
90166
- 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 }) + `
90167
90207
  `);
90168
90208
  }
90169
90209
  var init_workspaceBuildVersion = __esm(() => {
@@ -90172,40 +90212,40 @@ var init_workspaceBuildVersion = __esm(() => {
90172
90212
 
90173
90213
  // src/project/packageBuildStage.ts
90174
90214
  import { mkdir as mkdir28, mkdtemp as mkdtemp3, readFile as readFile65, rename as rename9, rm as rm14, rmdir } from "node:fs/promises";
90175
- 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";
90176
90216
  async function withStagedPackageOutput(projectRoot, pkg, render) {
90177
- const tempRoot = join74(projectRoot, ".tmp");
90217
+ const tempRoot = join75(projectRoot, ".tmp");
90178
90218
  await mkdir28(tempRoot, { recursive: true });
90179
- const stage = await mkdtemp3(join74(tempRoot, "package-build-"));
90180
- 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)) };
90181
90221
  try {
90182
- await mkdir28(join74(projectRoot, stagedPackage.outDir), { recursive: true });
90222
+ await mkdir28(join75(projectRoot, stagedPackage.outDir), { recursive: true });
90183
90223
  const value = await render(stagedPackage);
90184
90224
  await validatePackageIndexLinks({ projectRoot, pkg: stagedPackage });
90185
90225
  const destinations = packageOutputDirs(pkg);
90186
90226
  const staged = packageOutputDirs(stagedPackage);
90187
90227
  for (const [index2, destination] of destinations.entries()) {
90188
- const target = join74(projectRoot, destination);
90228
+ const target = join75(projectRoot, destination);
90189
90229
  const previous2 = await walkPackageFiles(target);
90190
- const next = await walkPackageFiles(join74(projectRoot, staged[index2]));
90230
+ const next = await walkPackageFiles(join75(projectRoot, staged[index2]));
90191
90231
  const desired = new Set(next.map((file) => file.relPath));
90192
90232
  for (const file of previous2) {
90193
90233
  if (desired.has(file.relPath))
90194
90234
  continue;
90195
90235
  await rm14(file.absPath);
90196
- let directory = dirname34(file.absPath);
90236
+ let directory = dirname35(file.absPath);
90197
90237
  while (directory !== target) {
90198
90238
  try {
90199
90239
  await rmdir(directory);
90200
90240
  } catch {
90201
90241
  break;
90202
90242
  }
90203
- directory = dirname34(directory);
90243
+ directory = dirname35(directory);
90204
90244
  }
90205
90245
  }
90206
90246
  for (let offset2 = 0;offset2 < next.length; offset2 += 8) {
90207
90247
  const results = await Promise.allSettled(next.slice(offset2, offset2 + 8).map(async (file) => {
90208
- const output = join74(target, file.relPath);
90248
+ const output = join75(target, file.relPath);
90209
90249
  const bytes = await readFile65(file.absPath);
90210
90250
  const old = await readFile65(output).catch((error) => {
90211
90251
  if (error.code === "ENOENT")
@@ -90214,7 +90254,7 @@ async function withStagedPackageOutput(projectRoot, pkg, render) {
90214
90254
  });
90215
90255
  if (old?.equals(bytes))
90216
90256
  return;
90217
- await mkdir28(dirname34(output), { recursive: true });
90257
+ await mkdir28(dirname35(output), { recursive: true });
90218
90258
  await rename9(file.absPath, output);
90219
90259
  }));
90220
90260
  for (const result of results)
@@ -90453,7 +90493,7 @@ var init_newKnowledgePage = __esm(() => {
90453
90493
 
90454
90494
  // src/project/repoContentLinks.ts
90455
90495
  import { lstat as lstat14, mkdir as mkdir29, readdir as readdir18, readlink, symlink as symlink3, unlink as unlink2 } from "node:fs/promises";
90456
- 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";
90457
90497
  function repoContentLinksNeedRepair(results) {
90458
90498
  return results.some((item) => item.status === "missing" || item.status === "mismatch");
90459
90499
  }
@@ -90477,12 +90517,12 @@ async function inspectRepoContentLinks(projectRoot, repair = false) {
90477
90517
  return [{
90478
90518
  type: "repo-content",
90479
90519
  name: "repo-content.yaml",
90480
- path: join75(projectRoot, "repo-content.yaml"),
90520
+ path: join76(projectRoot, "repo-content.yaml"),
90481
90521
  status: "invalid",
90482
90522
  message: `${error instanceof Error ? error.message : String(error)}. Correct the registry before repairing the view; existing links are unchanged.`
90483
90523
  }];
90484
90524
  }
90485
- const view = join75(registry2?.projectRoot ?? projectRoot, "repo-content");
90525
+ const view = join76(registry2?.projectRoot ?? projectRoot, "repo-content");
90486
90526
  const viewInfo = await info(view);
90487
90527
  if (viewInfo && !viewInfo.isDirectory())
90488
90528
  return [{
@@ -90500,7 +90540,7 @@ async function inspectRepoContentLinks(projectRoot, repair = false) {
90500
90540
  return;
90501
90541
  for (const file of await readdir18(directory, { withFileTypes: true })) {
90502
90542
  const mount = prefix + file.name;
90503
- const path2 = join75(directory, file.name);
90543
+ const path2 = join76(directory, file.name);
90504
90544
  if (file.isSymbolicLink() && !expected.has(mount)) {
90505
90545
  if (repair && !disabled)
90506
90546
  await unlink2(path2);
@@ -90516,13 +90556,13 @@ async function inspectRepoContentLinks(projectRoot, repair = false) {
90516
90556
  }
90517
90557
  }
90518
90558
  for (const entry of registry2?.entries ?? []) {
90519
- const path2 = join75(view, entry.mountPath);
90559
+ const path2 = join76(view, entry.mountPath);
90520
90560
  const base = { type: "repo-content", name: entry.id, path: path2 };
90521
90561
  if (!await repoContentTargetExists(entry)) {
90522
90562
  results.push({ ...base, status: "target-missing", message: `Check the registered path ${entry.path}, sparse checkout, or a possible move; no content was restored.` });
90523
90563
  continue;
90524
90564
  }
90525
- const parent = dirname35(path2);
90565
+ const parent = dirname36(path2);
90526
90566
  const parentInfo = parent === view ? viewInfo : await info(parent);
90527
90567
  if (parentInfo && !parentInfo.isDirectory()) {
90528
90568
  results.push({ ...base, status: "conflict", message: "View parent is not an ordinary directory." });
@@ -90577,11 +90617,11 @@ __export(exports_knowledgeUpdate, {
90577
90617
  beginKnowledgeUpdate: () => beginKnowledgeUpdate
90578
90618
  });
90579
90619
  import { readFile as readFile66 } from "node:fs/promises";
90580
- import { join as join76 } from "node:path";
90620
+ import { join as join77 } from "node:path";
90581
90621
  async function readKnowledgeUpdate(projectRoot) {
90582
90622
  let value;
90583
90623
  try {
90584
- value = JSON.parse(await readFile66(join76(projectRoot, await revisionStoragePath(projectRoot)), "utf8"));
90624
+ value = JSON.parse(await readFile66(join77(projectRoot, await revisionStoragePath(projectRoot)), "utf8"));
90585
90625
  } catch (error) {
90586
90626
  if (error && typeof error === "object" && "code" in error && error.code === "ENOENT")
90587
90627
  return;
@@ -90642,7 +90682,7 @@ async function beginKnowledgeUpdate(projectRoot, value) {
90642
90682
  ...input.changes === undefined ? {} : { changes: input.changes }
90643
90683
  };
90644
90684
  const request = updateSchema.parse({ ...payload, revision: indexerProtocolDigest(payload) });
90645
- await atomicWriteFile(join76(projectRoot, await revisionStoragePath(projectRoot)), `${JSON.stringify(request)}
90685
+ await atomicWriteFile(join77(projectRoot, await revisionStoragePath(projectRoot)), `${JSON.stringify(request)}
90646
90686
  `);
90647
90687
  return {
90648
90688
  outcome: "update-prepared",
@@ -90727,7 +90767,7 @@ async function completeKnowledgeUpdate(input) {
90727
90767
  if (input.new_topics.length && !input.structure_approved) {
90728
90768
  const { revision: _revision, ...rest } = request;
90729
90769
  const payload = { ...rest, structure_proposal: { decisions: input.decisions, scope_summary: input.scope_summary, new_topics: input.new_topics } };
90730
- 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) })}
90731
90771
  `);
90732
90772
  return { outcome: "structure-review-required" };
90733
90773
  }
@@ -90764,7 +90804,7 @@ async function completeUpdateStructureReview(input) {
90764
90804
  const { revision: _revision, structure_proposal: _proposal, ...rest } = request;
90765
90805
  const payload = { ...rest, changes: `${rest.changes ?? ""}
90766
90806
  Structure feedback: ${input.feedback}` };
90767
- 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) })}
90768
90808
  `);
90769
90809
  return { outcome: "structure-adjustment-required" };
90770
90810
  });
@@ -90827,9 +90867,9 @@ __export(exports_packageBuilder, {
90827
90867
  buildProjectPackages: () => buildProjectPackages
90828
90868
  });
90829
90869
  import { createHash as createHash23 } from "node:crypto";
90830
- import { existsSync as existsSync18 } from "node:fs";
90870
+ import { existsSync as existsSync19 } from "node:fs";
90831
90871
  import { mkdir as mkdir30, readdir as readdir19, readFile as readFile67, rm as rm15, writeFile as writeFile24 } from "node:fs/promises";
90832
- 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";
90833
90873
  function packageAssetDeliverySummary(value) {
90834
90874
  if (value === null || typeof value !== "object" || Array.isArray(value))
90835
90875
  return;
@@ -90851,7 +90891,7 @@ function assertPackageOutputDir(pkg) {
90851
90891
  }
90852
90892
  function packageFingerprintPath(projectRoot, pkg) {
90853
90893
  assertSafeRenderedPath(`${pkg.name}.json`, "package fingerprint path");
90854
- return join77(projectRoot, PACKAGE_FINGERPRINT_ROOT, `${pkg.name}.json`);
90894
+ return join78(projectRoot, PACKAGE_FINGERPRINT_ROOT, `${pkg.name}.json`);
90855
90895
  }
90856
90896
  async function listApprovedKnowledge(projectRoot) {
90857
90897
  const metadata = await readApprovedKnowledgeMetadataIndex(projectRoot);
@@ -90882,7 +90922,7 @@ function isDeprecatedKnowledge(content3) {
90882
90922
  async function listTemplateFiles(projectRoot, templatePath) {
90883
90923
  assertSafeRenderedPath(templatePath, "package template path");
90884
90924
  const templateRoot = resolve27(projectRoot, templatePath);
90885
- if (!existsSync18(templateRoot)) {
90925
+ if (!existsSync19(templateRoot)) {
90886
90926
  throw new ContextError(ExitCode.WorkspaceStateError, `package template path is missing: ${templatePath}`, {
90887
90927
  category: ErrorCategory.WorkspaceStateInvalid,
90888
90928
  path: templatePath,
@@ -90957,7 +90997,7 @@ async function packageInputFingerprint(input) {
90957
90997
  }
90958
90998
  async function readPackageManifest(projectRoot, pkg) {
90959
90999
  const filePath2 = packageFingerprintPath(projectRoot, pkg);
90960
- if (!existsSync18(filePath2))
91000
+ if (!existsSync19(filePath2))
90961
91001
  return null;
90962
91002
  try {
90963
91003
  const parsed = JSON.parse(await readFile67(filePath2, "utf8"));
@@ -90991,7 +91031,7 @@ async function readPackageManifest(projectRoot, pkg) {
90991
91031
  }
90992
91032
  async function writePackageFingerprint(input) {
90993
91033
  const filePath2 = packageFingerprintPath(input.projectRoot, input.pkg);
90994
- await mkdir30(dirname36(filePath2), { recursive: true });
91034
+ await mkdir30(dirname37(filePath2), { recursive: true });
90995
91035
  await writeFile24(filePath2, `${JSON.stringify({
90996
91036
  package: input.pkg.name,
90997
91037
  kind: packageKind(input.pkg),
@@ -91007,12 +91047,12 @@ async function writePackageFingerprint(input) {
91007
91047
  `, "utf8");
91008
91048
  }
91009
91049
  async function removeOrphanPackageDirs(projectRoot, packages) {
91010
- const distRoot = join77(projectRoot, "dist");
91011
- if (!existsSync18(distRoot))
91050
+ const distRoot = join78(projectRoot, "dist");
91051
+ if (!existsSync19(distRoot))
91012
91052
  return;
91013
91053
  const declaredNames = new Set(packages.flatMap((pkg) => packageOutputDirs(pkg).map((path2) => path2.slice("dist/".length))));
91014
91054
  const entries2 = await readdir19(distRoot, { withFileTypes: true });
91015
- 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 })));
91016
91056
  }
91017
91057
  async function collectPackageFreshness(projectRoot, packages) {
91018
91058
  assertDistinctPackageOutputs(packages);
@@ -91021,8 +91061,8 @@ async function collectPackageFreshness(projectRoot, packages) {
91021
91061
  assertPackageOutputDir(pkg);
91022
91062
  const selected = selectPackageKnowledge(approved, pkg);
91023
91063
  assertSafeRenderedPath(pkg.template.path, "package template path");
91024
- const templateRoot = join77(projectRoot, pkg.template.path);
91025
- const templateExists = existsSync18(templateRoot);
91064
+ const templateRoot = join78(projectRoot, pkg.template.path);
91065
+ const templateExists = existsSync19(templateRoot);
91026
91066
  if (!templateExists) {
91027
91067
  throw new ContextError(ExitCode.WorkspaceStateError, `package template path is missing: ${pkg.template.path}`, {
91028
91068
  category: ErrorCategory.WorkspaceStateInvalid,
@@ -91257,19 +91297,19 @@ async function buildProjectPackagesInternal(projectRoot, options) {
91257
91297
  if (stagedPkg.kind === "package.llms") {
91258
91298
  const articles = await Promise.all(llmsArticles(stagedPkg, selected).map(async (article) => ({
91259
91299
  ...article,
91260
- content: await readFile67(join77(projectRoot, stagedPkg.outDir, article.path), "utf8")
91300
+ content: await readFile67(join78(projectRoot, stagedPkg.outDir, article.path), "utf8")
91261
91301
  })));
91262
- await writeLlmsDocuments(join77(projectRoot, stagedPkg.outDir), buildLlmsDocuments({
91302
+ await writeLlmsDocuments(join78(projectRoot, stagedPkg.outDir), buildLlmsDocuments({
91263
91303
  title: stagedPkg.name,
91264
91304
  articles,
91265
91305
  ...reading ? { map: reading } : {}
91266
91306
  }), { preserveIndex: true });
91267
91307
  }
91268
- await writePackageVersion(projectRoot, join77(projectRoot, stagedPkg.outDir));
91308
+ await writePackageVersion(projectRoot, join78(projectRoot, stagedPkg.outDir));
91269
91309
  await writePackageSite({ projectRoot, pkg: stagedPkg, selected, ...siteUrl ? { siteUrl } : {}, ...reading ? { structure: reading } : {} });
91270
91310
  const linkWarnings = [
91271
91311
  ...writtenKnowledge2.linkWarnings,
91272
- ...await inspectPackageMarkdownDirectory(join77(projectRoot, stagedPkg.outDir))
91312
+ ...await inspectPackageMarkdownDirectory(join78(projectRoot, stagedPkg.outDir))
91273
91313
  ];
91274
91314
  return { ...writtenKnowledge2, linkWarnings };
91275
91315
  });
@@ -91407,7 +91447,7 @@ var init_packageBuilder = __esm(() => {
91407
91447
  init_siteTranslation();
91408
91448
  init_approvedKnowledgeMetadata();
91409
91449
  import_yaml41 = __toESM(require_dist(), 1);
91410
- PACKAGE_FINGERPRINT_ROOT = join77(".tmp", "context-runtime", "packages");
91450
+ PACKAGE_FINGERPRINT_ROOT = join78(".tmp", "context-runtime", "packages");
91411
91451
  });
91412
91452
 
91413
91453
  // src/project/taskRollback.ts
@@ -91418,7 +91458,7 @@ __export(exports_taskRollback, {
91418
91458
  finishTaskRollback: () => finishTaskRollback
91419
91459
  });
91420
91460
  import { readFile as readFile68 } from "node:fs/promises";
91421
- import { join as join78 } from "node:path";
91461
+ import { join as join79 } from "node:path";
91422
91462
  async function readTaskRollback(projectRoot) {
91423
91463
  const raw = await readJsonMaybe(projectRoot, await revisionStoragePath(projectRoot));
91424
91464
  if (!raw || typeof raw !== "object" || !("protocol" in raw) || raw.protocol !== "context.task-rollback/v1")
@@ -91427,7 +91467,7 @@ async function readTaskRollback(projectRoot) {
91427
91467
  }
91428
91468
  async function contents(projectRoot, path2) {
91429
91469
  try {
91430
- return await readFile68(join78(projectRoot, path2), "utf8");
91470
+ return await readFile68(join79(projectRoot, path2), "utf8");
91431
91471
  } catch (error) {
91432
91472
  if (error && typeof error === "object" && "code" in error && error.code === "ENOENT")
91433
91473
  return;
@@ -91595,9 +91635,9 @@ __export(exports_close, {
91595
91635
  approvedStructureInputHashFor: () => approvedStructureInputHashFor,
91596
91636
  approvedKnowledgeInputHash: () => approvedKnowledgeInputHash
91597
91637
  });
91598
- import { existsSync as existsSync19 } from "node:fs";
91638
+ import { existsSync as existsSync20 } from "node:fs";
91599
91639
  import { mkdir as mkdir31, writeFile as writeFile25 } from "node:fs/promises";
91600
- import { dirname as dirname37, join as join79 } from "node:path";
91640
+ import { dirname as dirname38, join as join80 } from "node:path";
91601
91641
  function parseFrontmatter4(content3) {
91602
91642
  const match = /^---\r?\n([\s\S]*?)\r?\n---/u.exec(content3);
91603
91643
  if (match?.[1] === undefined)
@@ -91669,8 +91709,8 @@ async function deriveApprovedStructure(projectRoot) {
91669
91709
  }
91670
91710
  async function writeApprovedStructureProjection(projectRoot) {
91671
91711
  const { inputHash, structure, compactFiles } = await deriveApprovedStructure(projectRoot);
91672
- const outputPath = join79(projectRoot, STRUCTURE_PATH4);
91673
- await mkdir31(dirname37(outputPath), { recursive: true });
91712
+ const outputPath = join80(projectRoot, STRUCTURE_PATH4);
91713
+ await mkdir31(dirname38(outputPath), { recursive: true });
91674
91714
  await writeFile25(outputPath, import_yaml42.default.stringify(structure), "utf8");
91675
91715
  await Promise.all(compactFiles.map((file) => writeFile25(file.absPath, file.content, "utf8")));
91676
91716
  return { inputHash, articles: structure.articles.length, structure: STRUCTURE_PATH4 };
@@ -91680,11 +91720,11 @@ function referencesReceipt() {
91680
91720
  }
91681
91721
  async function readProjectCloseStatus(projectRoot) {
91682
91722
  const approved = await approvedKnowledgeFiles(projectRoot);
91683
- const structurePath = join79(projectRoot, STRUCTURE_PATH4);
91684
- if (approved.length === 0 && !existsSync19(structurePath))
91723
+ const structurePath = join80(projectRoot, STRUCTURE_PATH4);
91724
+ if (approved.length === 0 && !existsSync20(structurePath))
91685
91725
  return { state: "missing", diagnostics: [] };
91686
91726
  const inputHash = await approvedKnowledgeInputHash(projectRoot);
91687
- if (!existsSync19(structurePath))
91727
+ if (!existsSync20(structurePath))
91688
91728
  return { state: "missing", inputHash, diagnostics: [`close structure is missing: ${STRUCTURE_PATH4}`] };
91689
91729
  try {
91690
91730
  const parsed = await readApprovedStructureValue(projectRoot);
@@ -91737,8 +91777,8 @@ async function closeProjectWorkspace(projectRoot) {
91737
91777
  next: "Fix context verify errors, then rerun context close --format json."
91738
91778
  });
91739
91779
  }
91740
- const outputPath = join79(projectRoot, STRUCTURE_PATH4);
91741
- await mkdir31(dirname37(outputPath), { recursive: true });
91780
+ const outputPath = join80(projectRoot, STRUCTURE_PATH4);
91781
+ await mkdir31(dirname38(outputPath), { recursive: true });
91742
91782
  await writeFile25(outputPath, `${import_yaml42.default.stringify(structure)}`, "utf8");
91743
91783
  await Promise.all(compactFiles.map((file) => writeFile25(file.absPath, file.content, "utf8")));
91744
91784
  const { readTaskRollback: readTaskRollback2 } = await Promise.resolve().then(() => (init_taskRollback(), exports_taskRollback));
@@ -91814,7 +91854,7 @@ var init_close = __esm(() => {
91814
91854
  init_knowledgeAssetRepair();
91815
91855
  init_approvedKnowledgeMetadata();
91816
91856
  import_yaml42 = __toESM(require_dist(), 1);
91817
- STRUCTURE_PATH4 = join79(KNOWLEDGE_ROOT, "structure.yaml");
91857
+ STRUCTURE_PATH4 = join80(KNOWLEDGE_ROOT, "structure.yaml");
91818
91858
  });
91819
91859
 
91820
91860
  // src/project/processedScopeStorage.ts
@@ -91826,7 +91866,7 @@ __export(exports_processedScopeStorage, {
91826
91866
  captureProcessedScopes: () => captureProcessedScopes
91827
91867
  });
91828
91868
  import { readFile as readFile69 } from "node:fs/promises";
91829
- import { join as join80 } from "node:path";
91869
+ import { join as join81 } from "node:path";
91830
91870
  async function currentScopeSourceVersion(projectRoot, sourceRef) {
91831
91871
  if (sourceRef.startsWith("repo-content:"))
91832
91872
  return repoContentWorkingVersion(projectRoot, sourceRef);
@@ -91845,7 +91885,7 @@ async function currentScopeSourceVersion(projectRoot, sourceRef) {
91845
91885
  const version3 = entries3[0].ref;
91846
91886
  if (!/^[a-f0-9]{40}(?:[a-f0-9]{24})?$/u.test(version3))
91847
91887
  throw new TypeError("Processing requires a fixed commit, not a moving ref");
91848
- await assertPinnedSource(join80(projectRoot, entries3[0].materializedAt), version3);
91888
+ await assertPinnedSource(join81(projectRoot, entries3[0].materializedAt), version3);
91849
91889
  return version3;
91850
91890
  }
91851
91891
  const entries2 = (type === "file" ? sources.files : type === "lark" ? sources.larks : []).filter((entry2) => entry2.id === name3 || entry2.name === name3);
@@ -91853,7 +91893,7 @@ async function currentScopeSourceVersion(projectRoot, sourceRef) {
91853
91893
  throw new TypeError(`Source must identify one registered document: ${sourceRef}`);
91854
91894
  const entry = entries2[0];
91855
91895
  const manifest = entry.snapshot?.manifest ?? `${entry.materializedAt}/manifest.json`;
91856
- 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;
91857
91897
  }
91858
91898
  async function captureProcessedScopes(projectRoot, requested) {
91859
91899
  const scopes = processedScopesSchema.parse(requested);
@@ -91887,7 +91927,7 @@ async function commitProcessedScopes(projectRoot, scopes) {
91887
91927
  const { articles } = await inspectSettledReferences(projectRoot, repoContent, scopes.map((scope2) => scope2.source_ref), settled);
91888
91928
  const { approvedStructureInputHashFor: approvedStructureInputHashFor2 } = await Promise.resolve().then(() => (init_close(), exports_close));
91889
91929
  const input_hash = structure.parsed.input_hash === await approvedStructureInputHashFor2(projectRoot, previous2) ? await approvedStructureInputHashFor2(projectRoot, articles) : structure.parsed.input_hash;
91890
- 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 }));
91891
91931
  }
91892
91932
  async function invalidateChangedProcessedRequirements(projectRoot, previous2, current2) {
91893
91933
  const targets = new Map(current2.map((requirement2) => [requirement2.id, indexerProtocolDigest(requirement2)]));
@@ -91901,7 +91941,7 @@ async function invalidateChangedProcessedRequirements(projectRoot, previous2, cu
91901
91941
  const retained = scopes.filter((scope2) => !changed.has(scope2.requirement_ref));
91902
91942
  if (retained.length === scopes.length)
91903
91943
  return;
91904
- 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 }));
91905
91945
  }
91906
91946
  var import_yaml43;
91907
91947
  var init_processedScopeStorage = __esm(() => {
@@ -92042,7 +92082,7 @@ __export(exports_approvedRevisionPrograms, {
92042
92082
  });
92043
92083
  import { execFile as execFile9 } from "node:child_process";
92044
92084
  import { promisify as promisify9 } from "node:util";
92045
- import { extname as extname11, join as join81 } from "node:path";
92085
+ import { extname as extname11, join as join82 } from "node:path";
92046
92086
  import { createRequire as createRequire6 } from "node:module";
92047
92087
  import { pathToFileURL } from "node:url";
92048
92088
  async function prepareRevisionProgramBlocks(root, sourceRefs, scopes, references) {
@@ -92058,7 +92098,7 @@ async function prepareRevisionProgramBlocks(root, sourceRefs, scopes, references
92058
92098
  if (entries2.length !== 1)
92059
92099
  throw new TypeError(`Regeneration requires one registered source: ${source2}`);
92060
92100
  const entry = entries2[0];
92061
- const directory = join81(root, entry.materializedAt);
92101
+ const directory = join82(root, entry.materializedAt);
92062
92102
  const paths = [...new Set(references.filter((reference2) => reference2.source_ref === source2).map((reference2) => reference2.locator.path))];
92063
92103
  if (!paths.length)
92064
92104
  continue;
@@ -92378,14 +92418,14 @@ __export(exports_knowledgeMaintenance, {
92378
92418
  advanceKnowledgeMaintenance: () => advanceKnowledgeMaintenance
92379
92419
  });
92380
92420
  import { readFile as readFile70, readdir as readdir20, rm as rm16 } from "node:fs/promises";
92381
- import { join as join82 } from "node:path";
92421
+ import { join as join83 } from "node:path";
92382
92422
  async function deliveryDigest(root) {
92383
- const directory = join82(root, ".tmp/context-runtime/packages");
92423
+ const directory = join83(root, ".tmp/context-runtime/packages");
92384
92424
  try {
92385
92425
  const files = (await readdir20(directory)).filter((name3) => name3.endsWith(".json")).sort();
92386
92426
  if (!files.length)
92387
92427
  return indexerProtocolDigest(null);
92388
- 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"))));
92389
92429
  } catch (error) {
92390
92430
  if (error.code === "ENOENT")
92391
92431
  return indexerProtocolDigest(null);
@@ -92484,7 +92524,7 @@ async function observeKnowledgeMaintenance(root) {
92484
92524
  async function maintenanceRevision(root) {
92485
92525
  const observed = await observeKnowledgeMaintenance(root);
92486
92526
  const localInputs = observed.state.active ? {
92487
- 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) => {
92488
92528
  if (error.code === "ENOENT")
92489
92529
  return null;
92490
92530
  throw error;
@@ -92561,7 +92601,7 @@ async function finishMaintenanceRevision(root, outcome = "completed") {
92561
92601
  outcome = state.active.completion_outcome;
92562
92602
  state.active.phase = "finishing";
92563
92603
  await saveMaintenance(root, state);
92564
- await rm16(join82(root, MAINTENANCE_ROOT, "revision.json"), { force: true });
92604
+ await rm16(join83(root, MAINTENANCE_ROOT, "revision.json"), { force: true });
92565
92605
  state.completed.push({ id: state.active.input.id, input_digest: indexerProtocolDigest(state.active.input), outcome });
92566
92606
  delete state.active;
92567
92607
  await saveMaintenance(root, state);
@@ -92595,8 +92635,8 @@ async function discardMaintenanceDraft(root) {
92595
92635
  const owned = new Set([...request?.batch_candidates ?? [], ...request?.candidate ? [request.candidate] : []].map((item) => item.candidate_id));
92596
92636
  if (candidates.some((item) => !owned.has(item.candidate_id)))
92597
92637
  throw new TypeError("Unrelated Candidates are present; no draft was discarded. Inspect the current review before retrying cancellation.");
92598
- await rm16(join82(root, CANDIDATE_LEDGER_FILE), { force: true });
92599
- 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 });
92600
92640
  const { closeProjectWorkspace: closeProjectWorkspace2 } = await Promise.resolve().then(() => (init_close(), exports_close));
92601
92641
  const { buildProjectPackages: buildProjectPackages2 } = await Promise.resolve().then(() => (init_packageBuilder(), exports_packageBuilder));
92602
92642
  await closeProjectWorkspace2(root);
@@ -92635,7 +92675,7 @@ __export(exports_approvedRevision, {
92635
92675
  APPROVED_REVISION_PATH: () => APPROVED_REVISION_PATH
92636
92676
  });
92637
92677
  import { readFile as readFile71, realpath as realpath11, rm as rm17 } from "node:fs/promises";
92638
- 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";
92639
92679
  function requestDigest(input) {
92640
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}/`)));
92641
92681
  const ids = new Set(scopes?.map((scope2) => scope2.requirement_ref));
@@ -92673,7 +92713,7 @@ function revisionCandidateFingerprint(revision, markdown, sections) {
92673
92713
  }
92674
92714
  async function readApprovedRevision(projectRoot) {
92675
92715
  try {
92676
- 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")));
92677
92717
  } catch (error) {
92678
92718
  if (error && typeof error === "object" && "code" in error && error.code === "ENOENT")
92679
92719
  return;
@@ -92732,12 +92772,12 @@ async function resolveApprovedRevisionAuthor(projectRoot, request) {
92732
92772
  }
92733
92773
  async function targetBytes(projectRoot, path2) {
92734
92774
  const project = await realpath11(projectRoot);
92735
- const root = await realpath11(join83(projectRoot, "knowledge"));
92775
+ const root = await realpath11(join84(projectRoot, "knowledge"));
92736
92776
  const rootRelative = relative26(project, root);
92737
92777
  if (isAbsolute15(rootRelative) || rootRelative === ".." || rootRelative.startsWith("../")) {
92738
92778
  throw new TypeError("Approved knowledge directory leaves the Context workspace");
92739
92779
  }
92740
- const target = await realpath11(join83(root, path2));
92780
+ const target = await realpath11(join84(root, path2));
92741
92781
  const rel = relative26(root, target);
92742
92782
  if (isAbsolute15(rel) || rel === ".." || rel.startsWith("../"))
92743
92783
  throw new TypeError("Approved revision target leaves knowledge/");
@@ -92893,7 +92933,7 @@ ${import_yaml44.default.stringify({ ...import_yaml44.default.parse(fields), type
92893
92933
  revision: requestDigest(payload)
92894
92934
  });
92895
92935
  if (input.persist !== false)
92896
- 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)}
92897
92937
  `);
92898
92938
  return {
92899
92939
  status: "author-reopened",
@@ -93004,17 +93044,17 @@ async function completeApprovedRevision(input) {
93004
93044
  const { prepareRevisionBatchContinuation: prepareRevisionBatchContinuation3 } = await Promise.resolve().then(() => (init_approvedRevisionBatch(), exports_approvedRevisionBatch));
93005
93045
  const next2 = await prepareRevisionBatchContinuation3(input.projectRoot, request, request.batch_candidates ?? []);
93006
93046
  if (next2 || request.batch_candidates?.length || request.build_pending) {
93007
- 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 })}
93008
93048
  `);
93009
93049
  } else {
93010
93050
  await advanceApprovedRevision(input.projectRoot, request);
93011
93051
  }
93012
93052
  return;
93013
93053
  }
93014
- 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");
93015
93055
  let previous2;
93016
93056
  try {
93017
- previous2 = await readFile71(join83(input.projectRoot, CANDIDATE_LEDGER_FILE), "utf8");
93057
+ previous2 = await readFile71(join84(input.projectRoot, CANDIDATE_LEDGER_FILE), "utf8");
93018
93058
  } catch (error) {
93019
93059
  if (!(error && typeof error === "object" && ("code" in error) && error.code === "ENOENT"))
93020
93060
  throw error;
@@ -93096,7 +93136,7 @@ async function advanceApprovedRevision(projectRoot, request, buildPending = fals
93096
93136
  return;
93097
93137
  const { readProductionStage: readProductionStage2 } = await Promise.resolve().then(() => (init_productionStageStore(), exports_productionStageStore));
93098
93138
  if (await readProductionStage2(projectRoot)) {
93099
- await rm17(join83(projectRoot, await revisionStoragePath(projectRoot)), { force: true });
93139
+ await rm17(join84(projectRoot, await revisionStoragePath(projectRoot)), { force: true });
93100
93140
  return;
93101
93141
  }
93102
93142
  const { clearCompletedLifecycle: clearCompletedLifecycle2 } = await Promise.resolve().then(() => (init_lifecycleCleanup(), exports_lifecycleCleanup));
@@ -93167,12 +93207,12 @@ async function reopenApprovedRevision(input) {
93167
93207
  }))
93168
93208
  } : {}
93169
93209
  } };
93170
- 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");
93171
93211
  const content3 = `${JSON.stringify({ ...payload, revision: requestDigest(payload) })}
93172
93212
  `;
93173
93213
  let ledger;
93174
93214
  try {
93175
- ledger = await readFile71(join83(input.projectRoot, CANDIDATE_LEDGER_FILE), "utf8");
93215
+ ledger = await readFile71(join84(input.projectRoot, CANDIDATE_LEDGER_FILE), "utf8");
93176
93216
  } catch (error) {
93177
93217
  if (!(error && typeof error === "object" && ("code" in error) && error.code === "ENOENT"))
93178
93218
  throw error;
@@ -93285,7 +93325,7 @@ var init_sourceInputMutation = __esm(() => {
93285
93325
  // src/project/documentCapture.ts
93286
93326
  import { createHash as createHash24 } from "node:crypto";
93287
93327
  import { mkdir as mkdir32, readdir as readdir21, readFile as readFile72, rm as rm18, stat as stat11, writeFile as writeFile26 } from "node:fs/promises";
93288
- 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";
93289
93329
  function toPosixPath7(path2) {
93290
93330
  return path2.split(/[\\/]+/u).filter((part) => part.length > 0).join("/");
93291
93331
  }
@@ -93408,7 +93448,7 @@ async function walkMarkdownFiles(input) {
93408
93448
  const visit3 = async (dir) => {
93409
93449
  const entries2 = await readdir21(dir, { withFileTypes: true });
93410
93450
  for (const entry of entries2) {
93411
- const absolutePath = join84(dir, entry.name);
93451
+ const absolutePath = join85(dir, entry.name);
93412
93452
  if (entry.isDirectory()) {
93413
93453
  await visit3(absolutePath);
93414
93454
  continue;
@@ -93433,11 +93473,11 @@ async function writeTextIfChanged(path2, content3) {
93433
93473
  if (await readFile72(path2, "utf8") === content3)
93434
93474
  return;
93435
93475
  } catch {}
93436
- await mkdir32(dirname38(path2), { recursive: true });
93476
+ await mkdir32(dirname39(path2), { recursive: true });
93437
93477
  await writeFile26(path2, content3, "utf8");
93438
93478
  }
93439
93479
  function sourceManifestPath(entry) {
93440
- return entry.snapshot?.manifest ?? join84(entry.materializedAt, "manifest.json");
93480
+ return entry.snapshot?.manifest ?? join85(entry.materializedAt, "manifest.json");
93441
93481
  }
93442
93482
  function runtimeError3(message, detail) {
93443
93483
  return new ContextError(ExitCode.UserError, message, {
@@ -93510,7 +93550,7 @@ async function removeEmptySnapshotDirs(root, dir = root) {
93510
93550
  for (const entry of entries2) {
93511
93551
  if (!entry.isDirectory() || entry.name === ".tmp" || entry.name === ".cache")
93512
93552
  continue;
93513
- await removeEmptySnapshotDirs(root, join84(dir, entry.name));
93553
+ await removeEmptySnapshotDirs(root, join85(dir, entry.name));
93514
93554
  }
93515
93555
  if (dir === root)
93516
93556
  return;
@@ -93522,7 +93562,7 @@ async function removeEmptySnapshotDirs(root, dir = root) {
93522
93562
  async function cleanupStaleSnapshotFiles(input) {
93523
93563
  for (const path2 of input.previousPaths) {
93524
93564
  if (!input.currentPaths.has(path2)) {
93525
- await rm18(join84(input.materializedAtAbsPath, path2), { force: true });
93565
+ await rm18(join85(input.materializedAtAbsPath, path2), { force: true });
93526
93566
  }
93527
93567
  }
93528
93568
  await removeEmptySnapshotDirs(input.materializedAtAbsPath);
@@ -93705,9 +93745,9 @@ async function runCaptureFilePhaseUnlocked(input) {
93705
93745
  documentSnapshot
93706
93746
  });
93707
93747
  const manifestPath = sourceManifestPath(entry);
93708
- const manifestAbsPath = join84(input.projectRoot, manifestPath);
93748
+ const manifestAbsPath = join85(input.projectRoot, manifestPath);
93709
93749
  const materializedAt = entry.materializedAt;
93710
- const materializedAtAbsPath = join84(input.projectRoot, materializedAt);
93750
+ const materializedAtAbsPath = join85(input.projectRoot, materializedAt);
93711
93751
  const manifestInput = {
93712
93752
  sourceType: "file",
93713
93753
  sourceName: resolved.sourceName,
@@ -93757,13 +93797,13 @@ async function runCaptureFilePhaseUnlocked(input) {
93757
93797
  }));
93758
93798
  try {
93759
93799
  for (const file of snapshotFiles) {
93760
- await writeTextIfChanged(join84(materializedAtAbsPath, file.path), String(file.bytes));
93800
+ await writeTextIfChanged(join85(materializedAtAbsPath, file.path), String(file.bytes));
93761
93801
  }
93762
93802
  for (const file of files.metadata) {
93763
- await writeTextIfChanged(join84(materializedAtAbsPath, file.snapshotPath), routeMetadata.rawByPath.get(file.snapshotPath) ?? "");
93803
+ await writeTextIfChanged(join85(materializedAtAbsPath, file.snapshotPath), routeMetadata.rawByPath.get(file.snapshotPath) ?? "");
93764
93804
  }
93765
93805
  for (const asset of linkedAssets) {
93766
- await writeCaptureAssetIfChanged(join84(materializedAtAbsPath, asset.snapshotPath), asset.bytes);
93806
+ await writeCaptureAssetIfChanged(join85(materializedAtAbsPath, asset.snapshotPath), asset.bytes);
93767
93807
  }
93768
93808
  await writeTextIfChanged(manifestAbsPath, manifestContent);
93769
93809
  await cleanupStaleSnapshotFiles({
@@ -93940,8 +93980,8 @@ var init_larkCaptureReport = __esm(() => {
93940
93980
  });
93941
93981
 
93942
93982
  // src/project/documentSnapshotFidelity.ts
93943
- import { readFileSync as readFileSync7 } from "node:fs";
93944
- import { join as join85 } from "node:path";
93983
+ import { readFileSync as readFileSync8 } from "node:fs";
93984
+ import { join as join86 } from "node:path";
93945
93985
  function readDocumentSnapshotCaptureReport(input) {
93946
93986
  const summary = input.manifest.metadata?.capture?.report;
93947
93987
  if (summary === undefined)
@@ -93950,7 +93990,7 @@ function readDocumentSnapshotCaptureReport(input) {
93950
93990
  if (asset === undefined || asset.role !== "audit" || asset.content_hash === undefined) {
93951
93991
  throw new TypeError(`snapshot capture report is not registered as a hashed audit asset: ${summary.path}`);
93952
93992
  }
93953
- const bytes = readFileSync7(join85(input.projectRoot, input.materializedAt, summary.path));
93993
+ const bytes = readFileSync8(join86(input.projectRoot, input.materializedAt, summary.path));
93954
93994
  if (computeDocumentContentHash(bytes) !== asset.content_hash) {
93955
93995
  throw new TypeError(`snapshot capture report hash does not match manifest: ${summary.path}`);
93956
93996
  }
@@ -94046,9 +94086,9 @@ function larkSnapshotIdentityDiagnostic(source2, manifest) {
94046
94086
  }
94047
94087
 
94048
94088
  // src/project/repoSourceModules.ts
94049
- import { existsSync as existsSync20 } from "node:fs";
94089
+ import { existsSync as existsSync21 } from "node:fs";
94050
94090
  import { readFile as readFile73, readdir as readdir22 } from "node:fs/promises";
94051
- import { join as join86, resolve as resolve29 } from "node:path";
94091
+ import { join as join87, resolve as resolve29 } from "node:path";
94052
94092
  async function rootNames(root) {
94053
94093
  try {
94054
94094
  return (await readdir22(root)).sort();
@@ -94057,8 +94097,8 @@ async function rootNames(root) {
94057
94097
  }
94058
94098
  }
94059
94099
  async function packageEntries(root) {
94060
- const path2 = join86(root, "package.json");
94061
- if (!existsSync20(path2))
94100
+ const path2 = join87(root, "package.json");
94101
+ if (!existsSync21(path2))
94062
94102
  return [];
94063
94103
  try {
94064
94104
  const value = JSON.parse(await readFile73(path2, "utf8"));
@@ -94069,9 +94109,9 @@ async function packageEntries(root) {
94069
94109
  }
94070
94110
  }
94071
94111
  async function planningEvidence(inspectPath, module) {
94072
- const root = module.path === "." ? inspectPath : join86(inspectPath, module.path);
94112
+ const root = module.path === "." ? inspectPath : join87(inspectPath, module.path);
94073
94113
  const names = await rootNames(root);
94074
- 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)));
94075
94115
  const protocolNames = names.filter((name3) => /(?:openapi|swagger|schema|protocol|idl)/iu.test(name3) || /\.(?:proto|thrift)$/iu.test(name3));
94076
94116
  const lifecycleNames = names.filter((name3) => /(?:generated|vendor|mirror|legacy|sync)/iu.test(name3));
94077
94117
  return {
@@ -94109,8 +94149,8 @@ function suggestedModuleName(module) {
94109
94149
  return slug || "module";
94110
94150
  }
94111
94151
  async function inspectRepoSourceModules(input) {
94112
- const inspectPath = input.scopedAbs !== null && existsSync20(input.scopedAbs) ? input.scopedAbs : join86(input.projectRoot, input.status.materializedAt);
94113
- 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) : [];
94114
94154
  const recommended_sources = modules.filter((module) => module.path !== "." || modules.length === 1).map((module) => {
94115
94155
  const local = sourceModuleLocalForDisplay({ source: input.source, status: input.status, module });
94116
94156
  return {
@@ -94148,8 +94188,8 @@ var init_repoSourceModules = __esm(() => {
94148
94188
  });
94149
94189
 
94150
94190
  // src/project/repoSourceRegistry.ts
94151
- import { existsSync as existsSync21 } from "node:fs";
94152
- import { join as join87 } from "node:path";
94191
+ import { existsSync as existsSync22 } from "node:fs";
94192
+ import { join as join88 } from "node:path";
94153
94193
  function assertRepoModuleName(name3) {
94154
94194
  if (!SOURCE_NAME_PATTERN2.test(name3)) {
94155
94195
  throw new ContextError(ExitCode.UserError, `repo source name must be a lowercase path-safe slug: ${name3}`, {
@@ -94200,14 +94240,14 @@ function registryEntryToRecord(entry) {
94200
94240
  };
94201
94241
  }
94202
94242
  function registryPath(projectRoot) {
94203
- return join87(projectRoot, DEFAULT_REPO_SOURCES_REGISTRY_PATH);
94243
+ return join88(projectRoot, DEFAULT_REPO_SOURCES_REGISTRY_PATH);
94204
94244
  }
94205
94245
  function defaultRepoMaterializedAt(source2) {
94206
94246
  return `sources/repo/${source2.namespace}/${source2.module}`;
94207
94247
  }
94208
94248
  async function readRepoRegistry(projectRoot) {
94209
94249
  const path2 = registryPath(projectRoot);
94210
- if (!existsSync21(path2))
94250
+ if (!existsSync22(path2))
94211
94251
  return { repos: [] };
94212
94252
  const registry2 = await loadSourcesRegistry({ rootDir: projectRoot });
94213
94253
  return {
@@ -94258,11 +94298,11 @@ var init_repoSourceRegistry = __esm(() => {
94258
94298
  });
94259
94299
 
94260
94300
  // src/project/repoSources.ts
94261
- import { existsSync as existsSync22 } from "node:fs";
94301
+ import { existsSync as existsSync23 } from "node:fs";
94262
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";
94263
94303
  import { execFile as execFile10 } from "node:child_process";
94264
94304
  import { promisify as promisify10 } from "node:util";
94265
- 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";
94266
94306
  function nonEmpty(value) {
94267
94307
  if (value == null)
94268
94308
  return null;
@@ -94320,11 +94360,11 @@ async function localPathForRegistry(input) {
94320
94360
  async function inferNamedLocalPath(projectRoot, module) {
94321
94361
  const candidates = [
94322
94362
  resolve30(projectRoot, module),
94323
- resolve30(dirname39(projectRoot), module)
94363
+ resolve30(dirname40(projectRoot), module)
94324
94364
  ];
94325
94365
  const matches = new Map;
94326
94366
  for (const candidate of candidates) {
94327
- if (!existsSync22(candidate))
94367
+ if (!existsSync23(candidate))
94328
94368
  continue;
94329
94369
  const canonical = await realpath12(candidate).catch(() => null);
94330
94370
  if (canonical === null)
@@ -94345,13 +94385,13 @@ async function gitOutput(cwd, args) {
94345
94385
  }
94346
94386
  }
94347
94387
  async function readGitOriginRemote(cwd) {
94348
- const directConfigPath = join88(cwd, ".git", "config");
94388
+ const directConfigPath = join89(cwd, ".git", "config");
94349
94389
  let config = await readFile74(directConfigPath, "utf8").catch(() => "");
94350
94390
  if (config.length === 0) {
94351
94391
  const gitDir = await resolveGitDir(cwd);
94352
94392
  if (gitDir === null)
94353
94393
  return null;
94354
- config = await readFile74(join88(gitDir, "config"), "utf8").catch(() => "");
94394
+ config = await readFile74(join89(gitDir, "config"), "utf8").catch(() => "");
94355
94395
  }
94356
94396
  let inOriginBlock = false;
94357
94397
  for (const line of config.split(/\r?\n/u)) {
@@ -94371,17 +94411,17 @@ async function readGitOriginRemote(cwd) {
94371
94411
  async function resolveGitRoot(cwd) {
94372
94412
  let current2 = resolve30(cwd);
94373
94413
  while (true) {
94374
- if (existsSync22(join88(current2, ".git")))
94414
+ if (existsSync23(join89(current2, ".git")))
94375
94415
  return current2;
94376
- const parent = dirname39(current2);
94416
+ const parent = dirname40(current2);
94377
94417
  if (parent === current2)
94378
94418
  return null;
94379
94419
  current2 = parent;
94380
94420
  }
94381
94421
  }
94382
94422
  async function resolveGitDir(cwd) {
94383
- const dotGit = join88(cwd, ".git");
94384
- if (!existsSync22(dotGit))
94423
+ const dotGit = join89(cwd, ".git");
94424
+ if (!existsSync23(dotGit))
94385
94425
  return null;
94386
94426
  const stats = await lstat15(dotGit);
94387
94427
  if (stats.isDirectory())
@@ -94398,17 +94438,17 @@ async function readGitHead(cwd) {
94398
94438
  const gitDir = await resolveGitDir(cwd);
94399
94439
  if (gitDir === null)
94400
94440
  return null;
94401
- const headRaw = (await readFile74(join88(gitDir, "HEAD"), "utf8").catch(() => "")).trim();
94441
+ const headRaw = (await readFile74(join89(gitDir, "HEAD"), "utf8").catch(() => "")).trim();
94402
94442
  if (/^[a-f0-9]{40}$/iu.test(headRaw))
94403
94443
  return headRaw.toLowerCase();
94404
94444
  const match = /^ref:\s*(.+)\s*$/iu.exec(headRaw);
94405
94445
  const refPath = match?.[1];
94406
94446
  if (refPath === undefined)
94407
94447
  return null;
94408
- const looseRef = (await readFile74(join88(gitDir, refPath), "utf8").catch(() => "")).trim();
94448
+ const looseRef = (await readFile74(join89(gitDir, refPath), "utf8").catch(() => "")).trim();
94409
94449
  if (/^[a-f0-9]{40}$/iu.test(looseRef))
94410
94450
  return looseRef.toLowerCase();
94411
- const packedRefs = await readFile74(join88(gitDir, "packed-refs"), "utf8").catch(() => "");
94451
+ const packedRefs = await readFile74(join89(gitDir, "packed-refs"), "utf8").catch(() => "");
94412
94452
  for (const line of packedRefs.split(/\r?\n/u)) {
94413
94453
  if (line.startsWith("#") || line.startsWith("^"))
94414
94454
  continue;
@@ -94419,27 +94459,27 @@ async function readGitHead(cwd) {
94419
94459
  return null;
94420
94460
  }
94421
94461
  async function ensureMaterializedSymlink(input) {
94422
- const linkPath = join88(input.projectRoot, input.materializedAt);
94423
- await mkdir33(dirname39(linkPath), { recursive: true });
94424
- if (existsSync22(linkPath)) {
94462
+ const linkPath = join89(input.projectRoot, input.materializedAt);
94463
+ await mkdir33(dirname40(linkPath), { recursive: true });
94464
+ if (existsSync23(linkPath)) {
94425
94465
  const stats = await lstat15(linkPath);
94426
94466
  if (!stats.isSymbolicLink()) {
94427
94467
  input.diagnostics.push(`materialized path exists and is not a symlink: ${input.materializedAt}`);
94428
94468
  return false;
94429
94469
  }
94430
94470
  const current2 = await readlink2(linkPath);
94431
- const currentAbs = resolve30(dirname39(linkPath), current2);
94471
+ const currentAbs = resolve30(dirname40(linkPath), current2);
94432
94472
  if (currentAbs === input.localAbs)
94433
94473
  return true;
94434
94474
  await rm19(linkPath);
94435
94475
  }
94436
- const relTarget = relative28(dirname39(linkPath), input.localAbs) || ".";
94476
+ const relTarget = relative28(dirname40(linkPath), input.localAbs) || ".";
94437
94477
  await symlink4(relTarget, linkPath);
94438
94478
  return true;
94439
94479
  }
94440
94480
  async function diagnoseMaterializedSymlink(input) {
94441
- const linkPath = join88(input.projectRoot, input.materializedAt);
94442
- if (!existsSync22(linkPath)) {
94481
+ const linkPath = join89(input.projectRoot, input.materializedAt);
94482
+ if (!existsSync23(linkPath)) {
94443
94483
  input.diagnostics.push(`materialized path is missing: ${input.materializedAt}`);
94444
94484
  input.agent_hints.push(`Run context source ensure ${input.sourceName} to materialize the local source link.`);
94445
94485
  return false;
@@ -94450,9 +94490,9 @@ async function diagnoseMaterializedSymlink(input) {
94450
94490
  return false;
94451
94491
  }
94452
94492
  const current2 = await readlink2(linkPath);
94453
- const currentAbs = resolve30(dirname39(linkPath), current2);
94493
+ const currentAbs = resolve30(dirname40(linkPath), current2);
94454
94494
  if (currentAbs !== input.localAbs) {
94455
- 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) || "."}`);
94456
94496
  input.agent_hints.push(`Run context source ensure ${input.sourceName} to refresh the local source link.`);
94457
94497
  return false;
94458
94498
  }
@@ -94484,7 +94524,7 @@ async function normalizeInputRef(input) {
94484
94524
  next: "Pass --local <path> with a git checkout, or use a full 40-character commit sha."
94485
94525
  });
94486
94526
  }
94487
- if (!existsSync22(localAbs)) {
94527
+ if (!existsSync23(localAbs)) {
94488
94528
  throw new ContextError(ExitCode.UserError, `short repo source ref cannot be resolved because local path is missing: ${input.local}`, {
94489
94529
  category: ErrorCategory.UserInputInvalid,
94490
94530
  sourceName: input.sourceName,
@@ -94541,7 +94581,7 @@ async function normalizeAddInput(input, existing) {
94541
94581
  let originalLocalAbs = null;
94542
94582
  if (originalLocal !== undefined) {
94543
94583
  originalLocalAbs = resolveLocalPath(input.projectRoot, originalLocal);
94544
- if (originalLocalAbs !== null && existsSync22(originalLocalAbs)) {
94584
+ if (originalLocalAbs !== null && existsSync23(originalLocalAbs)) {
94545
94585
  gitRootAbs = await resolveGitRoot(originalLocalAbs);
94546
94586
  if (gitRootAbs !== null && localWasResolvedFromInput) {
94547
94587
  const detectedSubpath = normalizeSubpath2(relative28(gitRootAbs, originalLocalAbs));
@@ -94561,7 +94601,7 @@ async function normalizeAddInput(input, existing) {
94561
94601
  localScoped: localWasResolvedFromInput && gitRootAbs !== null
94562
94602
  });
94563
94603
  if (input.local !== undefined && (explicitRemote === null || explicitRef === null)) {
94564
- if (originalLocalAbs === null || !existsSync22(originalLocalAbs)) {
94604
+ if (originalLocalAbs === null || !existsSync23(originalLocalAbs)) {
94565
94605
  throw new ContextError(ExitCode.UserError, `repo source local path does not exist: ${input.local}`, {
94566
94606
  category: ErrorCategory.UserInputInvalid,
94567
94607
  sourceName,
@@ -94663,11 +94703,11 @@ async function inspectRepoSource(input) {
94663
94703
  const diagnostics = [];
94664
94704
  const agent_hints = [];
94665
94705
  const localAbs = resolveLocalPath(input.projectRoot, source2.local);
94666
- const localExists = localAbs !== null && existsSync22(localAbs);
94706
+ const localExists = localAbs !== null && existsSync23(localAbs);
94667
94707
  const subpath = normalizeSubpath2(source2.subpath);
94668
94708
  const scopedAbs = localAbs === null ? null : scopedLocalPath(localAbs, subpath);
94669
- const scopeExists = scopedAbs !== null && existsSync22(scopedAbs);
94670
- let materialized = existsSync22(join88(input.projectRoot, materializedAt));
94709
+ const scopeExists = scopedAbs !== null && existsSync23(scopedAbs);
94710
+ let materialized = existsSync23(join89(input.projectRoot, materializedAt));
94671
94711
  const checkout = await inspectRepoCheckout({
94672
94712
  source: source2,
94673
94713
  localAbs,
@@ -94853,7 +94893,7 @@ var init_entityId = __esm(() => {
94853
94893
  // src/project/reviewShared.ts
94854
94894
  import { createHash as createHash25 } from "node:crypto";
94855
94895
  import { mkdir as mkdir34, writeFile as writeFile27 } from "node:fs/promises";
94856
- import { dirname as dirname40, join as join89 } from "node:path";
94896
+ import { dirname as dirname41, join as join90 } from "node:path";
94857
94897
  function isRecord14(value) {
94858
94898
  return value !== null && typeof value === "object" && !Array.isArray(value);
94859
94899
  }
@@ -94896,7 +94936,7 @@ async function buildApprovedArticleIndex(projectRoot) {
94896
94936
  if (!isApprovedKnowledgeMarkdownPath(rel))
94897
94937
  continue;
94898
94938
  const { absPath, content: content3 } = file;
94899
- const relPath = join89("knowledge", collection, rel);
94939
+ const relPath = join90("knowledge", collection, rel);
94900
94940
  assetReferencesByRelPath.set(relPath, knowledgeAssetReferences({
94901
94941
  pageRelPath: relPath,
94902
94942
  content: content3
@@ -94909,7 +94949,7 @@ async function buildApprovedArticleIndex(projectRoot) {
94909
94949
  continue;
94910
94950
  const frontmatter2 = hydrateApprovedFrontmatter({
94911
94951
  frontmatter: parsed,
94912
- relPath: join89(collection, rel),
94952
+ relPath: join90(collection, rel),
94913
94953
  metadata
94914
94954
  });
94915
94955
  const article = articlesByPath.get(`${collection}/${rel}`);
@@ -94964,9 +95004,9 @@ ${yaml3}
94964
95004
  }
94965
95005
  async function writeReviewActionLog(input) {
94966
95006
  const stamp = new Date().toISOString().replace(/[-:.TZ]/gu, "");
94967
- const relPath = join89(REVIEW_ACTION_ROOT2, `${stamp}-${input.action}-${input.id.replace(/[\\/]+/gu, "_")}.json`);
94968
- const path2 = join89(input.projectRoot, relPath);
94969
- 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 });
94970
95010
  await writeFile27(path2, `${JSON.stringify({
94971
95011
  action: input.action,
94972
95012
  id: input.id,
@@ -94998,7 +95038,7 @@ var init_reviewShared = __esm(() => {
94998
95038
  init_knowledgeAssets();
94999
95039
  init_entityId();
95000
95040
  import_yaml46 = __toESM(require_dist(), 1);
95001
- REVIEW_ACTION_ROOT2 = join89(".tmp", "context-runtime", "review-actions");
95041
+ REVIEW_ACTION_ROOT2 = join90(".tmp", "context-runtime", "review-actions");
95002
95042
  });
95003
95043
 
95004
95044
  // src/project/managedDocumentStatus.ts
@@ -95073,17 +95113,17 @@ __export(exports_statusReaders, {
95073
95113
  loadStatusPhases: () => loadStatusPhases,
95074
95114
  countFiles: () => countFiles
95075
95115
  });
95076
- import { existsSync as existsSync23, readFileSync as readFileSync8 } from "node:fs";
95077
- 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";
95078
95118
  async function countFiles(root, predicate) {
95079
- if (!existsSync23(root))
95119
+ if (!existsSync24(root))
95080
95120
  return 0;
95081
95121
  let count = 0;
95082
95122
  const visit3 = async (dir, prefix = "") => {
95083
95123
  const entries2 = await readCommandDirectory(dir);
95084
95124
  for (const entry of entries2) {
95085
95125
  const rel = prefix.length === 0 ? entry.name : `${prefix}/${entry.name}`;
95086
- const abs = join90(dir, entry.name);
95126
+ const abs = join91(dir, entry.name);
95087
95127
  if (entry.isDirectory())
95088
95128
  await visit3(abs, rel);
95089
95129
  else if (entry.isFile() && predicate(rel))
@@ -95274,8 +95314,8 @@ async function documentSourceSiteHint(input) {
95274
95314
  });
95275
95315
  }
95276
95316
  function documentSnapshotReadiness(input) {
95277
- const manifestPath = join90(input.projectRoot, input.manifest);
95278
- if (!existsSync23(manifestPath)) {
95317
+ const manifestPath = join91(input.projectRoot, input.manifest);
95318
+ if (!existsSync24(manifestPath)) {
95279
95319
  return {
95280
95320
  ready: false,
95281
95321
  diagnostics: [`snapshot is missing: ${input.manifest}`],
@@ -95283,7 +95323,7 @@ function documentSnapshotReadiness(input) {
95283
95323
  };
95284
95324
  }
95285
95325
  try {
95286
- const manifest = findDocumentSnapshotForSource(JSON.parse(readFileSync8(manifestPath, "utf8")), input.sourceName);
95326
+ const manifest = findDocumentSnapshotForSource(JSON.parse(readFileSync9(manifestPath, "utf8")), input.sourceName);
95287
95327
  if (manifest === null) {
95288
95328
  return {
95289
95329
  ready: false,
@@ -95344,7 +95384,7 @@ function documentSnapshotReadiness(input) {
95344
95384
  const missingFiles = [
95345
95385
  ...manifest.files.map((file) => file.path),
95346
95386
  ...(manifest.assets ?? []).filter((asset) => asset.content_hash !== undefined).map((asset) => asset.path)
95347
- ].filter((path2) => !existsSync23(join90(input.projectRoot, input.materializedAt, path2)));
95387
+ ].filter((path2) => !existsSync24(join91(input.projectRoot, input.materializedAt, path2)));
95348
95388
  if (missingFiles.length > 0) {
95349
95389
  return {
95350
95390
  ready: false,
@@ -95764,11 +95804,11 @@ var init_workflowHostPlans = __esm(() => {
95764
95804
  });
95765
95805
 
95766
95806
  // src/project/workflow/workflowProvider.ts
95767
- import { existsSync as existsSync24 } from "node:fs";
95768
- import { dirname as dirname41, resolve as resolve31 } from "node:path";
95769
- 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";
95770
95810
  function providerCandidates() {
95771
- const moduleDir2 = dirname41(fileURLToPath6(import.meta.url));
95811
+ const moduleDir2 = dirname42(fileURLToPath7(import.meta.url));
95772
95812
  return [
95773
95813
  ...process.env.C4A_CONTEXT_WORKFLOW_PROVIDER ? [resolve31(process.env.C4A_CONTEXT_WORKFLOW_PROVIDER)] : [],
95774
95814
  resolve31(moduleDir2, "providers", "context", "manifest.json"),
@@ -95776,7 +95816,7 @@ function providerCandidates() {
95776
95816
  ];
95777
95817
  }
95778
95818
  function contextWorkflowProviderPath() {
95779
- const candidate = providerCandidates().find((path2) => existsSync24(path2));
95819
+ const candidate = providerCandidates().find((path2) => existsSync25(path2));
95780
95820
  if (candidate === undefined) {
95781
95821
  throw new Error("Context workflow Provider is missing. Rebuild @c4a/context-cli or reinstall the published package.");
95782
95822
  }
@@ -96136,7 +96176,7 @@ var init_workflowProvider = __esm(() => {
96136
96176
 
96137
96177
  // src/project/productionStageRefresh.ts
96138
96178
  import { readFile as readFile76 } from "node:fs/promises";
96139
- import { join as join92 } from "node:path";
96179
+ import { join as join93 } from "node:path";
96140
96180
  async function refreshProductionStageSources(projectRoot, stage) {
96141
96181
  const active = activeProductionSources(stage);
96142
96182
  const affected = new Set(stage.gaps.filter((gap) => active.has(gap.scope)).map((gap) => gap.scope));
@@ -96181,8 +96221,8 @@ Restore the authorized source and retry preparation.
96181
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)
96182
96222
  });
96183
96223
  const directory = productionStageDirectory(stage.id);
96184
- const contents2 = new Map([...sourceMaterials].map(([scope2, content3]) => [join92(directory, productionSourceFile(scope2)), content3]));
96185
- 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)}
96186
96226
  `);
96187
96227
  const targets = [];
96188
96228
  for (const [path2, content3] of contents2) {
@@ -96313,7 +96353,7 @@ var init_productionReport = __esm(() => {
96313
96353
  });
96314
96354
 
96315
96355
  // src/project/productionPlanningRoute.ts
96316
- import { join as join93 } from "node:path";
96356
+ import { join as join94 } from "node:path";
96317
96357
  async function productionPlanningRoute(input, stage) {
96318
96358
  const request = stage ? undefined : await productionPlanningRequest(input.projectRoot);
96319
96359
  const present = !!stage || !!request;
@@ -96351,7 +96391,7 @@ async function productionPlanningRoute(input, stage) {
96351
96391
  id: `production/${stage.id}/planning`,
96352
96392
  kind: "context-view",
96353
96393
  media_type: "text/markdown",
96354
- path: join93(input.projectRoot, productionStageDirectory(stage.id), "planning.md"),
96394
+ path: join94(input.projectRoot, productionStageDirectory(stage.id), "planning.md"),
96355
96395
  read_state: "read-required"
96356
96396
  }] : []
96357
96397
  ],
@@ -96378,8 +96418,8 @@ var init_productionPlanningRoute = __esm(() => {
96378
96418
  });
96379
96419
 
96380
96420
  // src/project/productionWorkflowRoute.ts
96381
- import { existsSync as existsSync25 } from "node:fs";
96382
- import { join as join94 } from "node:path";
96421
+ import { existsSync as existsSync26 } from "node:fs";
96422
+ import { join as join95 } from "node:path";
96383
96423
  async function productionWorkflowRoute(input) {
96384
96424
  const stage = await readProductionStage(input.projectRoot);
96385
96425
  if (!stage || !stage.planning_complete)
@@ -96397,7 +96437,7 @@ async function productionWorkflowRoute(input) {
96397
96437
  const selected = new Set(dispatch.batches.flatMap((batch) => batch.tasks));
96398
96438
  const context = { workspace: input.projectRoot, authorities: [...input.authorities], facts: { production: {
96399
96439
  report_approved: stage.report_approved,
96400
- 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"),
96401
96441
  writing_complete: dispatch.batches.length === 0,
96402
96442
  complete: dispatch.state === "ended",
96403
96443
  review_clear: rejected.length === 0,
@@ -96414,7 +96454,7 @@ async function productionWorkflowRoute(input) {
96414
96454
  const resolved = await resolveRoute(provider, "indexer", "production", primary.routeId, context, evaluated.evaluation.revision);
96415
96455
  const report = resolved.node === "confirm-production-report";
96416
96456
  if (report)
96417
- await writeProductionProjection(input.projectRoot, join94(directory, "plan.md"), productionPlanMarkdown(stage));
96457
+ await writeProductionProjection(input.projectRoot, join95(directory, "plan.md"), productionPlanMarkdown(stage));
96418
96458
  const prepare = resolved.node === "prepare-production-stage";
96419
96459
  const writing = resolved.node === "work-production-stage";
96420
96460
  const repair = resolved.node === "repair-production-articles";
@@ -96429,7 +96469,7 @@ async function productionWorkflowRoute(input) {
96429
96469
  id: `production/${stage.id}/${report ? "plan" : "stage"}`,
96430
96470
  kind: "context-view",
96431
96471
  media_type: "text/markdown",
96432
- path: join94(input.projectRoot, directory, path3),
96472
+ path: join95(input.projectRoot, directory, path3),
96433
96473
  read_state: "read-required"
96434
96474
  });
96435
96475
  if (report || writing)
@@ -96440,18 +96480,18 @@ async function productionWorkflowRoute(input) {
96440
96480
  id: `production/${stage.id}/planning`,
96441
96481
  kind: "context-view",
96442
96482
  media_type: "text/markdown",
96443
- path: join94(input.projectRoot, directory, "planning.md"),
96483
+ path: join95(input.projectRoot, directory, "planning.md"),
96444
96484
  read_state: "read-required"
96445
96485
  });
96446
96486
  }
96447
96487
  if (repair) {
96448
- await writeProductionProjection(input.projectRoot, join94(directory, "repair.md"), [
96488
+ await writeProductionProjection(input.projectRoot, join95(directory, "repair.md"), [
96449
96489
  "# Revise rejected articles",
96450
96490
  "",
96451
96491
  ...rejected.map((candidate) => `- ${candidate.path}: ${candidate.review.title}`),
96452
96492
  "",
96453
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.",
96454
- `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.`,
96455
96495
  "Once issued, repair the affected sections through the existing edits submission. Unchanged sections and references do not need resubmission.",
96456
96496
  ""
96457
96497
  ].join(`
@@ -96460,7 +96500,7 @@ async function productionWorkflowRoute(input) {
96460
96500
  id: `production/${stage.id}/repair`,
96461
96501
  kind: "context-view",
96462
96502
  media_type: "text/markdown",
96463
- path: join94(input.projectRoot, directory, "repair.md"),
96503
+ path: join95(input.projectRoot, directory, "repair.md"),
96464
96504
  read_state: "read-required"
96465
96505
  });
96466
96506
  }
@@ -101380,7 +101420,7 @@ var init_larkResourceCommand = __esm(() => {
101380
101420
 
101381
101421
  // src/lib/larkMediaDownload.ts
101382
101422
  import { readdir as readdir24, rm as rm21 } from "node:fs/promises";
101383
- import { join as join104 } from "node:path";
101423
+ import { join as join105 } from "node:path";
101384
101424
  async function downloadLarkMedia(input) {
101385
101425
  const shared = ["--as", input.identity, "--token", input.token, "--output", "./resource", "--format", "json"];
101386
101426
  try {
@@ -101390,7 +101430,7 @@ async function downloadLarkMedia(input) {
101390
101430
  if (!input.allowPreview || !isLarkResourcePermissionDenied(error))
101391
101431
  throw error;
101392
101432
  for (const entry of await readdir24(input.cwd))
101393
- await rm21(join104(input.cwd, entry), { recursive: true, force: true });
101433
+ await rm21(join105(input.cwd, entry), { recursive: true, force: true });
101394
101434
  await runLarkResourceCommand(input.runner, ["docs", "+media-preview", ...shared], { cwd: input.cwd });
101395
101435
  return "preview";
101396
101436
  }
@@ -101402,7 +101442,7 @@ var init_larkMediaDownload = __esm(() => {
101402
101442
  // src/lib/larkWhiteboardExport.ts
101403
101443
  import { mkdtemp as mkdtemp4, readFile as readFile84, rm as rm22 } from "node:fs/promises";
101404
101444
  import { tmpdir } from "node:os";
101405
- import { join as join105 } from "node:path";
101445
+ import { join as join106 } from "node:path";
101406
101446
  function stableJson2(value) {
101407
101447
  if (value === undefined)
101408
101448
  return "null";
@@ -101432,7 +101472,7 @@ function canonicalWhiteboardPayload(value) {
101432
101472
  };
101433
101473
  }
101434
101474
  async function exportLarkWhiteboardRaw(runner2, identity2, token) {
101435
- const tempRoot = await mkdtemp4(join105(tmpdir(), "context-lark-whiteboard-"));
101475
+ const tempRoot = await mkdtemp4(join106(tmpdir(), "context-lark-whiteboard-"));
101436
101476
  try {
101437
101477
  await runLarkResourceCommand(runner2, [
101438
101478
  "whiteboard",
@@ -101449,7 +101489,7 @@ async function exportLarkWhiteboardRaw(runner2, identity2, token) {
101449
101489
  "--format",
101450
101490
  "json"
101451
101491
  ], { cwd: tempRoot });
101452
- const rawPayload = JSON.parse(await readFile84(join105(tempRoot, "raw.json"), "utf8"));
101492
+ const rawPayload = JSON.parse(await readFile84(join106(tempRoot, "raw.json"), "utf8"));
101453
101493
  return Buffer.from(`${stableJson2(canonicalWhiteboardPayload(rawPayload))}
101454
101494
  `, "utf8");
101455
101495
  } finally {
@@ -101489,7 +101529,7 @@ var init_larkImagePolicy = __esm(() => {
101489
101529
  // src/lib/larkResourceMaterialization.ts
101490
101530
  import { createHash as createHash31 } from "node:crypto";
101491
101531
  import { mkdtemp as mkdtemp5, readFile as readFile85, readdir as readdir25, rm as rm23 } from "node:fs/promises";
101492
- import { extname as extname13, join as join106 } from "node:path";
101532
+ import { extname as extname13, join as join107 } from "node:path";
101493
101533
  import { tmpdir as tmpdir2 } from "node:os";
101494
101534
  function countByKind(items, status) {
101495
101535
  const counts2 = new Map;
@@ -101597,14 +101637,14 @@ async function downloadedFile(input) {
101597
101637
  const bytes = await readFile85(input.localPath);
101598
101638
  return { path: input.localPath, bytes, mediaType: mediaTypeFor(input.localPath, bytes), representation: "original" };
101599
101639
  }
101600
- const tempRoot = await mkdtemp5(join106(tmpdir2(), "context-lark-resource-"));
101640
+ const tempRoot = await mkdtemp5(join107(tmpdir2(), "context-lark-resource-"));
101601
101641
  try {
101602
101642
  const representation = await downloadLarkMedia({ ...input, cwd: tempRoot });
101603
101643
  const entries2 = (await readdir25(tempRoot, { withFileTypes: true })).filter((entry) => entry.isFile());
101604
101644
  if (entries2.length !== 1)
101605
101645
  throw new Error(`media download produced ${entries2.length} files, expected exactly one`);
101606
101646
  const path3 = entries2[0]?.name ?? "resource.bin";
101607
- const bytes = await readFile85(join106(tempRoot, path3));
101647
+ const bytes = await readFile85(join107(tempRoot, path3));
101608
101648
  return { path: path3, bytes, mediaType: mediaTypeFor(path3, bytes), representation };
101609
101649
  } finally {
101610
101650
  await rm23(tempRoot, { recursive: true, force: true });
@@ -101676,9 +101716,9 @@ async function sheetMaterialization(resource, runner2, identity2) {
101676
101716
  const sheetId = resource.attributes["sheet-id"];
101677
101717
  if (token === undefined || sheetId === undefined)
101678
101718
  throw new Error("embedded Sheet requires token and sheet-id");
101679
- const tempRoot = await mkdtemp5(join106(tmpdir2(), "context-lark-sheet-"));
101719
+ const tempRoot = await mkdtemp5(join107(tmpdir2(), "context-lark-sheet-"));
101680
101720
  try {
101681
- const outputPath = join106(tempRoot, "sheet.json");
101721
+ const outputPath = join107(tempRoot, "sheet.json");
101682
101722
  const stdout = await runLarkResourceCommand(runner2, [
101683
101723
  "sheets",
101684
101724
  "+csv-get",
@@ -102814,7 +102854,7 @@ var init_sensitiveSourceLiteral = __esm(() => {
102814
102854
  // src/project/larkSnapshotBundle.ts
102815
102855
  import { createHash as createHash32 } from "node:crypto";
102816
102856
  import { lstat as lstat16, mkdir as mkdir37, readFile as readFile86, realpath as realpath13, rename as rename10, writeFile as writeFile29 } from "node:fs/promises";
102817
- 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";
102818
102858
  import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
102819
102859
  function normalizedSnapshotResourcePolicy(policy) {
102820
102860
  return { ...policy, images: policy.images ?? "bundle", gifs: policy.gifs ?? "bundle" };
@@ -102855,7 +102895,7 @@ async function readFileEntry(root2, entry) {
102855
102895
  const parts = safePath(entry.path).split("/");
102856
102896
  let current2 = root2;
102857
102897
  for (const [index2, part] of parts.entries()) {
102858
- current2 = join107(current2, part);
102898
+ current2 = join108(current2, part);
102859
102899
  const stat12 = await lstat16(current2);
102860
102900
  if (stat12.isSymbolicLink() || (index2 === parts.length - 1 ? !stat12.isFile() : !stat12.isDirectory())) {
102861
102901
  throw larkSnapshotError(`Snapshot entry is not a regular file: ${entry.path}`, "path-invalid");
@@ -102924,13 +102964,13 @@ async function writeLarkSnapshotBundle(input) {
102924
102964
  };
102925
102965
  schema2.parse(manifest);
102926
102966
  for (const [path3, bytes] of files) {
102927
- await mkdir37(dirname43(join107(root2, path3)), { recursive: true });
102928
- 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 });
102929
102969
  }
102930
102970
  await validateBundle(root2, manifest);
102931
- await writeFile29(join107(root2, `${FILE2}.pending`), `${JSON.stringify(manifest, null, 2)}
102971
+ await writeFile29(join108(root2, `${FILE2}.pending`), `${JSON.stringify(manifest, null, 2)}
102932
102972
  `, { flag: "wx", mode: 384 });
102933
- await rename10(join107(root2, `${FILE2}.pending`), join107(root2, FILE2));
102973
+ await rename10(join108(root2, `${FILE2}.pending`), join108(root2, FILE2));
102934
102974
  return manifest;
102935
102975
  }
102936
102976
  async function validateBundle(root2, manifest) {
@@ -103003,7 +103043,7 @@ async function validateBundle(root2, manifest) {
103003
103043
  async function readLarkSnapshotBundle(directory, target) {
103004
103044
  try {
103005
103045
  const root2 = await assertSnapshotDirectory(directory);
103006
- const path3 = join107(root2, FILE2);
103046
+ const path3 = join108(root2, FILE2);
103007
103047
  const stat12 = await lstat16(path3);
103008
103048
  if (stat12.isSymbolicLink() || !stat12.isFile())
103009
103049
  throw larkSnapshotError("Snapshot receipt must be a regular file", "path-invalid");
@@ -103018,7 +103058,7 @@ async function readLarkSnapshotBundle(directory, target) {
103018
103058
  }
103019
103059
  async function reserveSnapshotDirectory(directory, workspaceRoot) {
103020
103060
  const requested = resolve34(directory);
103021
- let ancestor = dirname43(requested);
103061
+ let ancestor = dirname44(requested);
103022
103062
  const missing2 = [];
103023
103063
  while (true) {
103024
103064
  try {
@@ -103028,11 +103068,11 @@ async function reserveSnapshotDirectory(directory, workspaceRoot) {
103028
103068
  if (!(error instanceof Error) || !("code" in error) || error.code !== "ENOENT")
103029
103069
  throw error;
103030
103070
  missing2.unshift(basename10(ancestor));
103031
- ancestor = dirname43(ancestor);
103071
+ ancestor = dirname44(ancestor);
103032
103072
  }
103033
103073
  }
103034
- const parent = join107(ancestor, ...missing2);
103035
- const output = join107(parent, basename10(requested));
103074
+ const parent = join108(ancestor, ...missing2);
103075
+ const output = join108(parent, basename10(requested));
103036
103076
  const { findContextProjectRoot: findContextProjectRoot2 } = await Promise.resolve().then(() => (init_workspace(), exports_workspace));
103037
103077
  const owner = findContextProjectRoot2(parent)?.projectRoot ?? workspaceRoot;
103038
103078
  if (owner !== undefined) {
@@ -103106,7 +103146,7 @@ var init_larkSnapshotBundle = __esm(() => {
103106
103146
 
103107
103147
  // src/project/documentCaptureLark.ts
103108
103148
  import { readdir as readdir26, readFile as readFile87 } from "node:fs/promises";
103109
- 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";
103110
103150
  function titleFromMarkdown2(markdown, fallbackPath) {
103111
103151
  const heading2 = markdown.split(`
103112
103152
  `).find((line) => /^#\s+\S/u.test(line));
@@ -103133,7 +103173,7 @@ async function fileContentMatches(path3, content3) {
103133
103173
  }
103134
103174
  }
103135
103175
  function sourceManifestPath2(entry) {
103136
- return entry.snapshot?.manifest ?? join108(entry.materializedAt, "manifest.json");
103176
+ return entry.snapshot?.manifest ?? join109(entry.materializedAt, "manifest.json");
103137
103177
  }
103138
103178
  function larkRuntimeError(message, detail) {
103139
103179
  return new ContextError(ExitCode.ExternalToolError, message, {
@@ -103260,7 +103300,7 @@ function assetManifestEntry(asset, assetRoot) {
103260
103300
  };
103261
103301
  }
103262
103302
  async function listSnapshotAssetFiles(root2, assetRoot) {
103263
- const assetsRoot = join108(root2, assetRoot);
103303
+ const assetsRoot = join109(root2, assetRoot);
103264
103304
  const files = [];
103265
103305
  const visit4 = async (dir, prefix = assetRoot) => {
103266
103306
  let entries2;
@@ -103273,7 +103313,7 @@ async function listSnapshotAssetFiles(root2, assetRoot) {
103273
103313
  }
103274
103314
  for (const entry of entries2) {
103275
103315
  const relPath = `${prefix}/${entry.name}`;
103276
- const absolutePath = join108(dir, entry.name);
103316
+ const absolutePath = join109(dir, entry.name);
103277
103317
  if (entry.isDirectory()) {
103278
103318
  await visit4(absolutePath, relPath);
103279
103319
  continue;
@@ -103288,7 +103328,7 @@ async function listSnapshotAssetFiles(root2, assetRoot) {
103288
103328
  }
103289
103329
  async function staleSnapshotAssetPaths(input) {
103290
103330
  const existingPaths = await listSnapshotAssetFiles(input.materializedAtAbsPath, input.assetRoot);
103291
- 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));
103292
103332
  }
103293
103333
  function normalizeLarkError(error, sourceName) {
103294
103334
  if (error instanceof ContextError)
@@ -103409,9 +103449,9 @@ async function runCaptureLarkPhaseUnlocked(input) {
103409
103449
  locator
103410
103450
  }];
103411
103451
  const manifestPath = sourceManifestPath2(entry);
103412
- const manifestAbsPath = join108(input.projectRoot, manifestPath);
103452
+ const manifestAbsPath = join109(input.projectRoot, manifestPath);
103413
103453
  const materializedAt = entry.materializedAt;
103414
- const materializedAtAbsPath = join108(input.projectRoot, materializedAt);
103454
+ const materializedAtAbsPath = join109(input.projectRoot, materializedAt);
103415
103455
  const manifest = createDocumentSnapshotManifest({
103416
103456
  sourceType: "lark",
103417
103457
  sourceName: resolved.sourceName,
@@ -103445,13 +103485,13 @@ async function runCaptureLarkPhaseUnlocked(input) {
103445
103485
  }));
103446
103486
  try {
103447
103487
  const requestedWrites = [{
103448
- path: join108(materializedAtAbsPath, documentPath),
103488
+ path: join109(materializedAtAbsPath, documentPath),
103449
103489
  bytes: normalized
103450
103490
  }];
103451
103491
  for (const asset of assets) {
103452
103492
  if (asset.bytes !== undefined) {
103453
103493
  requestedWrites.push({
103454
- path: join108(materializedAtAbsPath, asset.entry.path),
103494
+ path: join109(materializedAtAbsPath, asset.entry.path),
103455
103495
  bytes: asset.bytes
103456
103496
  });
103457
103497
  }
@@ -103468,7 +103508,7 @@ async function runCaptureLarkPhaseUnlocked(input) {
103468
103508
  currentPaths: new Set(assets.filter((asset) => asset.bytes !== undefined).map((asset) => asset.entry.path))
103469
103509
  });
103470
103510
  await applyAtomicFileBatch({
103471
- transactionRoot: join108(input.projectRoot, ".tmp", "context-runtime", "capture-transactions"),
103511
+ transactionRoot: join109(input.projectRoot, ".tmp", "context-runtime", "capture-transactions"),
103472
103512
  writes,
103473
103513
  removals
103474
103514
  });
@@ -103575,7 +103615,7 @@ __export(exports_actionInputWorkspace, {
103575
103615
  assertActionInputWorkspace: () => assertActionInputWorkspace
103576
103616
  });
103577
103617
  import { realpathSync as realpathSync2 } from "node:fs";
103578
- import { dirname as dirname45, resolve as resolve36 } from "node:path";
103618
+ import { dirname as dirname46, resolve as resolve36 } from "node:path";
103579
103619
  function assertActionInputWorkspace(cwd, inputPath) {
103580
103620
  if (inputPath === "-")
103581
103621
  return;
@@ -103588,7 +103628,7 @@ function assertActionInputWorkspace(cwd, inputPath) {
103588
103628
  } catch {
103589
103629
  return;
103590
103630
  }
103591
- const owner = findContextProjectRoot(dirname45(file));
103631
+ const owner = findContextProjectRoot(dirname46(file));
103592
103632
  if (owner === null || realpathSync2(owner.projectRoot) === realpathSync2(current2.projectRoot))
103593
103633
  return;
103594
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.", {
@@ -103902,7 +103942,7 @@ __export(exports_writeLockRecovery, {
103902
103942
  inspectWriterLock: () => inspectWriterLock
103903
103943
  });
103904
103944
  import { lstat as lstat17, mkdir as mkdir39, readFile as readFile94, readdir as readdir28, rename as rename11, rmdir as rmdir2 } from "node:fs/promises";
103905
- import { join as join113 } from "node:path";
103945
+ import { join as join114 } from "node:path";
103906
103946
  import { createHash as createHash34, randomUUID as randomUUID8 } from "node:crypto";
103907
103947
  async function inspectWriterLock(root2) {
103908
103948
  const path3 = await safeProjectTarget(root2, lockRelative);
@@ -103949,8 +103989,8 @@ async function recoverWriterLock(input) {
103949
103989
  };
103950
103990
  if (input.plan_digest !== before.digest)
103951
103991
  throw new Error("Writer lock changed; preview recovery again.");
103952
- const path3 = join113(input.projectRoot, lockRelative);
103953
- const guard = join113(path3, ".recovery");
103992
+ const path3 = join114(input.projectRoot, lockRelative);
103993
+ const guard = join114(path3, ".recovery");
103954
103994
  await mkdir39(guard);
103955
103995
  let archived = false;
103956
103996
  try {
@@ -103961,7 +104001,7 @@ async function recoverWriterLock(input) {
103961
104001
  if (names.some((name3) => name3 !== "owner.json" && name3 !== ".recovery"))
103962
104002
  throw new Error("Unexpected lock contents; preserve for diagnosis.");
103963
104003
  const archive = `.tmp/context-runtime/locks/recovered-write-${randomUUID8()}.lock`;
103964
- await rename11(path3, join113(input.projectRoot, archive));
104004
+ await rename11(path3, join114(input.projectRoot, archive));
103965
104005
  archived = true;
103966
104006
  return { action: "writer-lock-recovered", archived_lock: archive, next: "context task recover --format json" };
103967
104007
  } finally {
@@ -103984,8 +104024,8 @@ __export(exports_taskRecovery, {
103984
104024
  TRANSACTIONS_PATH: () => TRANSACTIONS_PATH,
103985
104025
  RECOVERY_COMMAND: () => RECOVERY_COMMAND
103986
104026
  });
103987
- import { existsSync as existsSync27 } from "node:fs";
103988
- 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";
103989
104029
  import { lstat as lstat18, readdir as readdir29, readFile as readFile95 } from "node:fs/promises";
103990
104030
  async function recoveryText(root2, path3) {
103991
104031
  const target = await safeProjectTarget(root2, path3);
@@ -104003,7 +104043,7 @@ async function recoveryJournals(root2) {
104003
104043
  await safeProjectTarget(root2, path3);
104004
104044
  let stat12;
104005
104045
  try {
104006
- stat12 = await lstat18(join114(root2, path3));
104046
+ stat12 = await lstat18(join115(root2, path3));
104007
104047
  } catch (error) {
104008
104048
  if (error.code === "ENOENT")
104009
104049
  return;
@@ -104014,7 +104054,7 @@ async function recoveryJournals(root2) {
104014
104054
  if (stat12.isDirectory()) {
104015
104055
  if (depth > 3)
104016
104056
  throw new TypeError("Unexpected transaction directory depth; preserve it for diagnosis.");
104017
- for (const name3 of (await readdir29(join114(root2, path3))).sort())
104057
+ for (const name3 of (await readdir29(join115(root2, path3))).sort())
104018
104058
  await visit4(`${path3}/${name3}`, depth + 1);
104019
104059
  } else if (stat12.isFile())
104020
104060
  entries2.push({ path: path3, digest: indexerProtocolDigest(await recoveryText(root2, path3)) });
@@ -104024,12 +104064,12 @@ async function recoveryJournals(root2) {
104024
104064
  }
104025
104065
  function recoveryResources() {
104026
104066
  try {
104027
- const root2 = dirname46(contextWorkflowProviderPath());
104067
+ const root2 = dirname47(contextWorkflowProviderPath());
104028
104068
  const resources = {
104029
- skill: join114(root2, "skills/recover-workspace/SKILL.md"),
104030
- 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")
104031
104071
  };
104032
- if (!Object.values(resources).every((path3) => existsSync27(path3)))
104072
+ if (!Object.values(resources).every((path3) => existsSync28(path3)))
104033
104073
  throw new Error("Recovery resources are absent from this Provider.");
104034
104074
  return resources;
104035
104075
  } catch {
@@ -104113,7 +104153,7 @@ __export(exports_taskLocalSourceAdjustment, {
104113
104153
  adjustLocalRevisionSources: () => adjustLocalRevisionSources
104114
104154
  });
104115
104155
  import { readFile as readFile96 } from "node:fs/promises";
104116
- import { join as join115 } from "node:path";
104156
+ import { join as join116 } from "node:path";
104117
104157
  async function adjustLocalRevisionSources(root2, input) {
104118
104158
  const { readMaintenance: readMaintenance2 } = await Promise.resolve().then(() => (init_maintenanceStorage(), exports_maintenanceStorage));
104119
104159
  if ((await readMaintenance2(root2)).active && await readProductionStage(root2))
@@ -104156,7 +104196,7 @@ async function adjustLocalRevisionSources(root2, input) {
104156
104196
  if (input.refresh && (!current2.refresh_sources || indexerProtocolDigest([...current2.refresh_sources].sort()) !== indexerProtocolDigest([...selected].sort()))) {
104157
104197
  throw new TypeError("No matching acquisition adjustment exists. Run task adjust without refresh first.");
104158
104198
  }
104159
- const raw = await readFile96(join115(root2, await revisionStoragePath(root2)), "utf8");
104199
+ const raw = await readFile96(join116(root2, await revisionStoragePath(root2)), "utf8");
104160
104200
  let next2;
104161
104201
  const discardIds = new Set;
104162
104202
  if (!input.refresh) {
@@ -104271,7 +104311,7 @@ ${input.instruction}` : revision.instruction
104271
104311
  content: content3
104272
104312
  }];
104273
104313
  if (discardIds.size > 0) {
104274
- 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) => {
104275
104315
  if (error.code === "ENOENT")
104276
104316
  return;
104277
104317
  throw error;
@@ -104768,7 +104808,7 @@ init_dist();
104768
104808
  init_cliFeedback();
104769
104809
  init_errors3();
104770
104810
  init_exitCode();
104771
- import { join as join102 } from "node:path";
104811
+ import { join as join103 } from "node:path";
104772
104812
 
104773
104813
  // src/project/documentCaptureAvailability.ts
104774
104814
  init_atomicFileBatch();
@@ -104777,11 +104817,11 @@ init_documentRun();
104777
104817
  init_writeLock();
104778
104818
  import { createHash as createHash26 } from "node:crypto";
104779
104819
  import { readFile as readFile75, rm as rm20 } from "node:fs/promises";
104780
- import { join as join91 } from "node:path";
104820
+ import { join as join92 } from "node:path";
104781
104821
  import { isDeepStrictEqual } from "node:util";
104782
104822
  function receiptPath(root, phaseId) {
104783
104823
  const key = createHash26("sha256").update(phaseId).digest("hex");
104784
- return join91(root, ".tmp/context-runtime/document-acquisition", `${key}.json`);
104824
+ return join92(root, ".tmp/context-runtime/document-acquisition", `${key}.json`);
104785
104825
  }
104786
104826
  async function identity(root, phase) {
104787
104827
  const resolved = await resolveDocumentPhaseSource({ projectRoot: root, phase });
@@ -104813,7 +104853,7 @@ async function runDocumentCaptureWithAvailability(root, phase, capture2) {
104813
104853
  retry_command: `context run ${phase.id}`,
104814
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."
104815
104855
  };
104816
- 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)}
104817
104857
  ` }] });
104818
104858
  return {
104819
104859
  kind: "document.capture.warning",
@@ -104858,7 +104898,7 @@ init_workspacePreparation();
104858
104898
  init_siteTranslation();
104859
104899
  init_src2();
104860
104900
  init_statusReaders();
104861
- import { join as join95 } from "node:path";
104901
+ import { join as join96 } from "node:path";
104862
104902
 
104863
104903
  // src/project/statusEvidence.ts
104864
104904
  function evidenceWarningState(issues) {
@@ -105298,7 +105338,7 @@ async function collectProjectStatusSnapshotInternal(projectRoot, options = {}) {
105298
105338
  const authoring = production && !production.delivery && (dispatchProductionStage(production, productionCapabilitiesSchema.parse({})).state !== "ended" || draftStatus.count > 0 && draftStatus.diagnostics.length === 0);
105299
105339
  const deferDeliveryChecks = !maintenance && !localRevision && !localUpdate && !localRollback && (taskPreparation === "cleared" && !production || !!authoring);
105300
105340
  const collectionsWithPages = new Set;
105301
- const approvedPages = await countFiles(join95(projectRoot, "knowledge"), (rel) => {
105341
+ const approvedPages = await countFiles(join96(projectRoot, "knowledge"), (rel) => {
105302
105342
  if (!isApprovedKnowledgeMarkdownPath(rel) || rel.startsWith("assets/"))
105303
105343
  return false;
105304
105344
  collectionsWithPages.add(rel.split("/")[0]);
@@ -105306,7 +105346,7 @@ async function collectProjectStatusSnapshotInternal(projectRoot, options = {}) {
105306
105346
  });
105307
105347
  const approvedCollections = KNOWLEDGE_COLLECTIONS.filter((collection) => collectionsWithPages.has(collection));
105308
105348
  const closeStatus = deferDeliveryChecks ? { state: "not-checked", diagnostics: [] } : await readCloseStatus(projectRoot);
105309
- const distFiles = await countFiles(join95(projectRoot, "dist"), () => true);
105349
+ const distFiles = await countFiles(join96(projectRoot, "dist"), () => true);
105310
105350
  const verifyStatus = !deferDeliveryChecks && draftStatus.diagnostics.length === 0 ? await readVerifyStatus(projectRoot) : { issues: [], diagnostics: [] };
105311
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;
105312
105352
  const pendingCapture = pendingDocumentCaptureCommands({
@@ -105684,7 +105724,7 @@ function bindWorkflowExecutionContext(result, context) {
105684
105724
  init_atomicWrite();
105685
105725
  import { Buffer as Buffer4 } from "node:buffer";
105686
105726
  import { createHash as createHash27 } from "node:crypto";
105687
- import { join as join96 } from "node:path";
105727
+ import { join as join97 } from "node:path";
105688
105728
  var WORKFLOW_ROUTE_INLINE_BYTE_LIMIT = 8 * 1024;
105689
105729
  async function workflowRouteOutput(projectRoot, route, options = {}) {
105690
105730
  if (!route)
@@ -105692,7 +105732,7 @@ async function workflowRouteOutput(projectRoot, route, options = {}) {
105692
105732
  const body = `${JSON.stringify(route, null, 2)}
105693
105733
  `;
105694
105734
  const digest6 = createHash27("sha256").update(body).digest("hex");
105695
- const file = join96(projectRoot, ".tmp/context-runtime/routes", `${digest6}.json`);
105735
+ const file = join97(projectRoot, ".tmp/context-runtime/routes", `${digest6}.json`);
105696
105736
  await atomicWriteFile(file, body);
105697
105737
  const routeBytes = Buffer4.byteLength(body);
105698
105738
  const inlineByteLimit = Math.max(0, Math.min(WORKFLOW_ROUTE_INLINE_BYTE_LIMIT, options.inlineByteLimit ?? WORKFLOW_ROUTE_INLINE_BYTE_LIMIT));
@@ -105714,7 +105754,7 @@ async function workflowRunResultFile(projectRoot, result) {
105714
105754
  const body = `${JSON.stringify(result, null, 2)}
105715
105755
  `;
105716
105756
  const digest6 = createHash27("sha256").update(body).digest("hex");
105717
- 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`);
105718
105758
  await atomicWriteFile(file, body);
105719
105759
  return file;
105720
105760
  }
@@ -105862,8 +105902,8 @@ init_workflowTypes();
105862
105902
  init_candidateLedger();
105863
105903
  init_reviewShared();
105864
105904
  import { mkdir as mkdir35, readFile as readFile81, writeFile as writeFile28 } from "node:fs/promises";
105865
- import { fileURLToPath as fileURLToPath7 } from "node:url";
105866
- 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";
105867
105907
 
105868
105908
  // src/project/reviewSiteModel.ts
105869
105909
  init_siteTheme2();
@@ -105872,7 +105912,7 @@ init_unified();
105872
105912
  init_remark_parse();
105873
105913
  var import_yaml48 = __toESM(require_dist(), 1);
105874
105914
  import { readFile as readFile79 } from "node:fs/promises";
105875
- import { join as join98 } from "node:path";
105915
+ import { join as join99 } from "node:path";
105876
105916
  import { execFile as execFile11 } from "node:child_process";
105877
105917
  import { promisify as promisify11 } from "node:util";
105878
105918
  import { createHash as createHash28 } from "node:crypto";
@@ -108838,9 +108878,9 @@ init_workspace();
108838
108878
 
108839
108879
  // src/project/reviewFeedback.ts
108840
108880
  import { readdir as readdir23, readFile as readFile78 } from "node:fs/promises";
108841
- import { join as join97 } from "node:path";
108881
+ import { join as join98 } from "node:path";
108842
108882
  async function readPendingReviewFeedback(root2, candidates) {
108843
- const directory = join97(root2, ".tmp/context-runtime/review-feedback");
108883
+ const directory = join98(root2, ".tmp/context-runtime/review-feedback");
108844
108884
  let files;
108845
108885
  try {
108846
108886
  files = await readdir23(directory);
@@ -108853,7 +108893,7 @@ async function readPendingReviewFeedback(root2, candidates) {
108853
108893
  const results = new Map;
108854
108894
  const receipts = [];
108855
108895
  for (const file of files.filter((f) => /^[a-f0-9]+\.json$/u.test(f)).sort()) {
108856
- const receipt2 = JSON.parse(await readFile78(join97(directory, file), "utf8"));
108896
+ const receipt2 = JSON.parse(await readFile78(join98(directory, file), "utf8"));
108857
108897
  receipts.push(receipt2);
108858
108898
  }
108859
108899
  for (const receipt2 of receipts.sort((a, b) => a.created_at.localeCompare(b.created_at))) {
@@ -108990,7 +109030,7 @@ async function reviewSiteBaselineHash(root2, reviewedPaths) {
108990
109030
  const displayed = new Set([...reviewedPaths, ...(metadata.structure?.articles ?? []).filter((a) => navigation.changedArticles.has(a.article_id)).map((a) => a.path)]);
108991
109031
  return hash4(JSON.stringify([
108992
109032
  navigation.baseline,
108993
- await optional2(join98(root2, "src/knowledge-map.yaml")) ?? null,
109033
+ await optional2(join99(root2, "src/knowledge-map.yaml")) ?? null,
108994
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]))
108995
109035
  ]));
108996
109036
  }
@@ -109100,9 +109140,9 @@ async function collectReviewSiteModel(root2, candidates) {
109100
109140
  for (const [i2, p] of unplaced.entries())
109101
109141
  nodes.push({ key: `review-page-${p.id}`, parent: "review-unplaced", title: p.title, order: i2, page: p.id, change: p.change });
109102
109142
  }
109103
- const pkgText = await optional2(join98(root2, "package.json"));
109143
+ const pkgText = await optional2(join99(root2, "package.json"));
109104
109144
  const pkg = pkgText ? JSON.parse(pkgText) : {};
109105
- 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);
109106
109146
  const siteTitle = project?.project.packages.flatMap((p) => p.kind === "package.kb" && p.site?.title ? [p.site.title] : [])[0];
109107
109147
  const sitePackages = project?.project.packages.flatMap((p) => p.kind === "package.kb" && p.site ? [p.site] : []) ?? [];
109108
109148
  const themeCss = siteThemeVariables(await resolveSiteTheme(root2, sitePackages.length === 1 ? sitePackages[0]?.theme : undefined));
@@ -109117,8 +109157,8 @@ init_cliFeedback();
109117
109157
  init_exitCode();
109118
109158
  init_reviewShared();
109119
109159
  import { readFile as readFile80 } from "node:fs/promises";
109120
- import { join as join99 } from "node:path";
109121
- 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`);
109122
109162
  async function saveReviewReportScope(root2, scope2, candidates, baselineHash) {
109123
109163
  const ids = candidates.map((candidate) => candidate.record.candidate_id).sort();
109124
109164
  const value = {
@@ -109595,7 +109635,7 @@ button:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
109595
109635
 
109596
109636
  // src/project/reviewHtml.ts
109597
109637
  init_knowledgeMap2();
109598
- var REVIEW_HTML_ROOT = join100(".tmp", "context-runtime", "review");
109638
+ var REVIEW_HTML_ROOT = join101(".tmp", "context-runtime", "review");
109599
109639
  async function collectReviewCandidates(projectRoot, collection) {
109600
109640
  const rows = await readCandidateRecords(projectRoot);
109601
109641
  const draftRows = rows.filter((row) => row.collection === collection && row.status === "draft");
@@ -109644,7 +109684,7 @@ ${diagramScript ? `<script>${diagramScript}</script>` : ""}<script>const DATA=${
109644
109684
  }
109645
109685
  function resolveOutputPath(projectRoot, outPath, reviewScope) {
109646
109686
  if (outPath === undefined)
109647
- return join100(projectRoot, REVIEW_HTML_ROOT, `${reviewScope}.html`);
109687
+ return join101(projectRoot, REVIEW_HTML_ROOT, `${reviewScope}.html`);
109648
109688
  return isAbsolute17(outPath) ? outPath : resolve32(projectRoot, outPath);
109649
109689
  }
109650
109690
  async function writeReviewHtml(input) {
@@ -109654,13 +109694,13 @@ async function writeReviewHtml(input) {
109654
109694
  }
109655
109695
  const candidates = reviewScope === "all" ? await collectAllReviewCandidates(input.projectRoot) : await collectReviewCandidates(input.projectRoot, reviewScope);
109656
109696
  const outPath = resolveOutputPath(input.projectRoot, input.out, reviewScope);
109657
- await mkdir35(dirname42(outPath), { recursive: true });
109697
+ await mkdir35(dirname43(outPath), { recursive: true });
109658
109698
  const model = await collectReviewSiteModel(input.projectRoot, candidates);
109659
109699
  let diagramScript = "";
109660
109700
  if (model.pages.some((page) => page.html.includes('class="language-mermaid"'))) {
109661
- const here = dirname42(fileURLToPath7(import.meta.url));
109701
+ const here = dirname43(fileURLToPath8(import.meta.url));
109662
109702
  try {
109663
- diagramScript = await readFile81(join100(here, "browser/diagrams.js"), "utf8");
109703
+ diagramScript = await readFile81(join101(here, "browser/diagrams.js"), "utf8");
109664
109704
  } catch (error) {
109665
109705
  if (error.code !== "ENOENT")
109666
109706
  throw error;
@@ -109697,7 +109737,7 @@ init_dist();
109697
109737
  init_atomicWrite();
109698
109738
  init_reviewShared();
109699
109739
  import { mkdir as mkdir36, readFile as readFile82 } from "node:fs/promises";
109700
- import { join as join101 } from "node:path";
109740
+ import { join as join102 } from "node:path";
109701
109741
  var REVIEW_BATCH_MAX_CANDIDATES = 6;
109702
109742
  var REVIEW_BATCH_MAX_BYTES = 512 * 1024;
109703
109743
  async function readerPurposes(projectRoot, sources) {
@@ -109777,11 +109817,11 @@ async function materializeCurrentReviewBatchSet(input) {
109777
109817
  const batches = buildCurrentReviewBatchDocuments(input.candidates);
109778
109818
  const setDigest = digestText(batches.map((batch) => `${batch.task_key}:${batch.digest}`).join(`
109779
109819
  `));
109780
- 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)}`);
109781
109821
  await mkdir36(root2, { recursive: true });
109782
109822
  const entries2 = [];
109783
109823
  for (const batch of batches) {
109784
- 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`);
109785
109825
  const existing = await readFile82(path4, "utf8").catch((error) => {
109786
109826
  if (error.code === "ENOENT")
109787
109827
  return;
@@ -109835,7 +109875,7 @@ async function materializeCurrentReviewBatchSet(input) {
109835
109875
  ].join(`
109836
109876
  `);
109837
109877
  const digest6 = digestText(content3);
109838
- const path3 = join101(root2, "index.md");
109878
+ const path3 = join102(root2, "index.md");
109839
109879
  await atomicWriteFile(path3, `${content3}
109840
109880
  `);
109841
109881
  return {
@@ -109868,11 +109908,11 @@ function shellQuote6(value) {
109868
109908
  }
109869
109909
  function receiptSetPath(receipts) {
109870
109910
  const token = digestText(JSON.stringify(receipts)).slice("sha256:".length);
109871
- return join102(".tmp", "context-runtime", "workflow", "read-receipts", `${token}.json`);
109911
+ return join103(".tmp", "context-runtime", "workflow", "read-receipts", `${token}.json`);
109872
109912
  }
109873
109913
  async function writeReceiptContinuation(input) {
109874
109914
  const path3 = receiptSetPath(input.receipts);
109875
- const absolutePath = join102(input.projectRoot, path3);
109915
+ const absolutePath = join103(input.projectRoot, path3);
109876
109916
  await writeJsonAtomic(absolutePath, input.receipts);
109877
109917
  const contextCommand = input.managed ? [
109878
109918
  "context",
@@ -109967,7 +110007,7 @@ async function materializeContextWorkflowResource(input) {
109967
110007
  const resourceId = workflowResourceId(input.resourceId);
109968
110008
  const content3 = renderContextWorkflowResource(resourceId, status);
109969
110009
  const location = await materializeResource(await loadContextWorkflowProvider(), resourceId, {
109970
- cache: join102(found.projectRoot, ".tmp", "context-runtime", "workflow", "resources"),
110010
+ cache: join103(found.projectRoot, ".tmp", "context-runtime", "workflow", "resources"),
109971
110011
  workspace: found.projectRoot,
109972
110012
  revision: input.revision,
109973
110013
  input: {
@@ -109999,7 +110039,7 @@ async function materializeContextWorkflowResource(input) {
109999
110039
  receipts: afterReadReceipts
110000
110040
  });
110001
110041
  const directResources = (status.workflow.current?.resources.required ?? []).filter((resource) => resource.read_state === "read-required" && resource.path !== undefined && resource.digest !== undefined);
110002
- 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`;
110003
110043
  return {
110004
110044
  protocol: "context.workflow.resource.v1",
110005
110045
  id: resourceId,
@@ -110060,14 +110100,14 @@ async function acknowledgeCurrentWorkflowResources(input) {
110060
110100
  const reevaluated = await reevaluateProjectStatusWorkflow({
110061
110101
  snapshot,
110062
110102
  resourceReceipts: normalizedReceipts,
110063
- resourceReceiptsReference: `@${join102(found.projectRoot, continuation.path)}`
110103
+ resourceReceiptsReference: `@${join103(found.projectRoot, continuation.path)}`
110064
110104
  });
110065
110105
  return {
110066
110106
  ...reevaluated,
110067
110107
  resourceAcknowledgement: {
110068
110108
  protocol: "context.workflow.resource-receipts.v1",
110069
110109
  acknowledged: directResources.length,
110070
- receiptReference: `@${join102(found.projectRoot, continuation.path)}`,
110110
+ receiptReference: `@${join103(found.projectRoot, continuation.path)}`,
110071
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."
110072
110112
  }
110073
110113
  };
@@ -110115,8 +110155,8 @@ init_errors3();
110115
110155
  init_exitCode();
110116
110156
  init_workspace();
110117
110157
  import { readFile as readFile83 } from "node:fs/promises";
110118
- import { isAbsolute as isAbsolute18, join as join103, sep as sep8, resolve as resolve33 } from "node:path";
110119
- 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");
110120
110160
  function workflowResourceReceiptCwd(value, cwd) {
110121
110161
  if (value === undefined || !value.startsWith("@"))
110122
110162
  return cwd;
@@ -110235,7 +110275,7 @@ function registerContextWorkflowResourceCommands(program2) {
110235
110275
  }
110236
110276
 
110237
110277
  // src/commands/runProject.ts
110238
- import { fileURLToPath as fileURLToPath8 } from "node:url";
110278
+ import { fileURLToPath as fileURLToPath9 } from "node:url";
110239
110279
  init_cliFeedback();
110240
110280
  init_errors3();
110241
110281
 
@@ -110394,15 +110434,15 @@ function compactJsonResult(result, verbose) {
110394
110434
  // src/project/runLog.ts
110395
110435
  import { randomUUID as randomUUID6 } from "node:crypto";
110396
110436
  import { mkdir as mkdir38, writeFile as writeFile30 } from "node:fs/promises";
110397
- import { dirname as dirname44, join as join109 } from "node:path";
110437
+ import { dirname as dirname45, join as join110 } from "node:path";
110398
110438
  var createPhaseRunId = () => {
110399
110439
  const timestamp = new Date().toISOString().replace(/[-:.TZ]/gu, "");
110400
110440
  return `run_${timestamp}_${randomUUID6().slice(0, 8)}`;
110401
110441
  };
110402
110442
  async function writePhaseRunLog(input) {
110403
- const relPath = join109(".tmp", "context-runtime", "runs", `${input.runId}.json`);
110404
- const absPath = join109(input.projectRoot, relPath);
110405
- 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 });
110406
110446
  await writeFile30(absPath, `${JSON.stringify({
110407
110447
  run_id: input.runId,
110408
110448
  phase_id: input.phase.id,
@@ -111637,9 +111677,9 @@ init_reviewCandidateAuthority();
111637
111677
  init_durableMultiFileTransaction();
111638
111678
  init_durableSingleFileTransaction();
111639
111679
  init_reviewShared();
111640
- import { existsSync as existsSync26 } from "node:fs";
111680
+ import { existsSync as existsSync27 } from "node:fs";
111641
111681
  import { readFile as readFile88 } from "node:fs/promises";
111642
- import { join as join110 } from "node:path";
111682
+ import { join as join111 } from "node:path";
111643
111683
  function existingTimestamp(markdown) {
111644
111684
  if (markdown === undefined)
111645
111685
  return;
@@ -111666,7 +111706,7 @@ async function prepareApprovedPage(input) {
111666
111706
  next: "Refresh the current production or article revision, then reopen Review before approval."
111667
111707
  });
111668
111708
  }
111669
- const relPath = join110("knowledge", input.record.path);
111709
+ const relPath = join111("knowledge", input.record.path);
111670
111710
  const existingView = findApprovedPageForArticleId(input.record.indexer_candidate.artifact_ref, input.approvedPageIndex);
111671
111711
  const previousPath = input.record.approved_revision?.previous_path;
111672
111712
  if (previousPath !== undefined && (!isSafeKnowledgeTargetPath(previousPath.split("/")[0], previousPath) || previousPath.includes("\\")))
@@ -111681,13 +111721,13 @@ async function prepareApprovedPage(input) {
111681
111721
  next: "Resolve the approved page path migration explicitly before approving this candidate."
111682
111722
  });
111683
111723
  }
111684
- const absPath = join110(input.projectRoot, relPath);
111685
- 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;
111686
111726
  let previous3;
111687
111727
  if (previousPath !== undefined) {
111688
111728
  if (existing !== undefined || existingView?.relPath !== `knowledge/${previousPath}`)
111689
111729
  throw new TypeError("Page move destination or original identity changed; refresh its revision.");
111690
- 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") };
111691
111731
  }
111692
111732
  if (input.record.approved_revision !== undefined) {
111693
111733
  const base = previous3?.content ?? existing;
@@ -111734,7 +111774,7 @@ async function prepareApprovedPage(input) {
111734
111774
  }
111735
111775
  async function readProjectFileMaybe(projectRoot, relPath) {
111736
111776
  try {
111737
- return await readFile88(join110(projectRoot, relPath), "utf8");
111777
+ return await readFile88(join111(projectRoot, relPath), "utf8");
111738
111778
  } catch (error) {
111739
111779
  if (error !== null && typeof error === "object" && "code" in error && error.code === "ENOENT") {
111740
111780
  return;
@@ -111955,7 +111995,7 @@ async function applyReviewDecisions(input) {
111955
111995
  });
111956
111996
  }
111957
111997
  seenApprovedIds.set(approvedRef, row.candidate_id);
111958
- const approvedPath = join110("knowledge", row.path);
111998
+ const approvedPath = join111("knowledge", row.path);
111959
111999
  const previousPathCandidate = seenApprovedPaths.get(knowledgeTargetPathKey(approvedPath));
111960
112000
  if (previousPathCandidate !== undefined) {
111961
112001
  throw new ContextError(ExitCode.UserError, `multiple approved review decisions target the same knowledge path: ${approvedPath}`, {
@@ -112005,7 +112045,7 @@ async function applyReviewDecisions(input) {
112005
112045
  for (const path3 of approvedPageIndex.byRelPath.keys()) {
112006
112046
  if (pagesToWrite.some((page) => page.relPath === path3 || page.previous?.path === path3))
112007
112047
  continue;
112008
- const before = await readFile88(join110(input.projectRoot, path3), "utf8");
112048
+ const before = await readFile88(join111(input.projectRoot, path3), "utf8");
112009
112049
  const local = path3.replace(/^knowledge\//u, "");
112010
112050
  const after = moveKnowledgeLinkTargets2(before, local, local, moved);
112011
112051
  navigationTargets.push(reviewFileTarget({ path: path3, baseContent: before, targetContent: after }));
@@ -112089,12 +112129,12 @@ init_candidateLedger();
112089
112129
 
112090
112130
  // src/project/localHtmlReport.ts
112091
112131
  import { execFile as execFile12 } from "node:child_process";
112092
- import { isAbsolute as isAbsolute20, join as join111 } from "node:path";
112132
+ import { isAbsolute as isAbsolute20, join as join112 } from "node:path";
112093
112133
  import { pathToFileURL as pathToFileURL2 } from "node:url";
112094
112134
  import { promisify as promisify12 } from "node:util";
112095
112135
  var execFileAsync5 = promisify12(execFile12);
112096
112136
  function htmlReportReference(input) {
112097
- 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);
112098
112138
  return {
112099
112139
  format: "html",
112100
112140
  path: input.path,
@@ -112898,7 +112938,7 @@ async function runProjectUntil(input) {
112898
112938
  const resourceReceipts = input.resourceReceiptsReference === undefined ? undefined : await parseWorkflowResourceReceipts(input.resourceReceiptsReference, found.projectRoot);
112899
112939
  const runtime = new WorkspaceExecutionRuntime({
112900
112940
  projectRoot: found.projectRoot,
112901
- cliEntryPath: fileURLToPath8(input.cliModuleUrl),
112941
+ cliEntryPath: fileURLToPath9(input.cliModuleUrl),
112902
112942
  inProcess: createWorkflowInProcessExecutor()
112903
112943
  });
112904
112944
  let result;
@@ -113096,7 +113136,7 @@ init_maintenanceStorage();
113096
113136
  init_productionFeedback();
113097
113137
  import { randomUUID as randomUUID7 } from "node:crypto";
113098
113138
  import { readFile as readFile91 } from "node:fs/promises";
113099
- import { join as join112 } from "node:path";
113139
+ import { join as join113 } from "node:path";
113100
113140
  async function beginProductionRevision(input) {
113101
113141
  return withProductionFeedback({ operation: "revision" }, () => withProjectWriteLock(input.projectRoot, "production-revision", async () => {
113102
113142
  await recoverDurableMultiFileTransactions(input.projectRoot);
@@ -113135,7 +113175,7 @@ async function beginProductionRevision(input) {
113135
113175
  const formal = approved.byPath.get(path3);
113136
113176
  if (!prior && !formal)
113137
113177
  throw invalid2("Write the current task first; there is no article draft to revise yet.");
113138
- 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");
113139
113179
  const sections = prior?.indexer_candidate.sections.map((section) => ({ id: section.section_key, references: section.references })) ?? formal?.sections;
113140
113180
  const sources = [];
113141
113181
  for (const source2 of owner.sources) {
@@ -113701,7 +113741,7 @@ function registerVersionCommands(program2) {
113701
113741
 
113702
113742
  // src/commands/translateCommands.ts
113703
113743
  init_workspace();
113704
- import { isAbsolute as isAbsolute22, join as join116 } from "node:path";
113744
+ import { isAbsolute as isAbsolute22, join as join117 } from "node:path";
113705
113745
  init_siteTranslation();
113706
113746
  function projectRoot() {
113707
113747
  const root2 = findContextProjectRoot(process.cwd())?.projectRoot;
@@ -113786,7 +113826,7 @@ function registerTranslateCommands(program2) {
113786
113826
  readFailureNext: "Check the input path",
113787
113827
  parseFailureNext: "Use valid YAML or JSON"
113788
113828
  }));
113789
- 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));
113790
113830
  write(await withWorkflow(root2, { outcome: "submitted", ...saved }));
113791
113831
  });
113792
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) => {
@@ -113880,7 +113920,7 @@ init_atomicWrite();
113880
113920
  var import_yaml52 = __toESM(require_dist(), 1);
113881
113921
  import { Buffer as Buffer5 } from "node:buffer";
113882
113922
  import { createHash as createHash35 } from "node:crypto";
113883
- import { join as join117 } from "node:path";
113923
+ import { join as join118 } from "node:path";
113884
113924
  var INLINE_LIMIT = 16 * 1024;
113885
113925
  function record4(value) {
113886
113926
  return value !== null && typeof value === "object" && !Array.isArray(value) ? value : undefined;
@@ -113906,8 +113946,8 @@ async function prepareActionCompletionOutput(input) {
113906
113946
  if (production && Buffer5.byteLength(full) <= INLINE_LIMIT)
113907
113947
  return input.result;
113908
113948
  const digest7 = createHash35("sha256").update(full).digest("hex");
113909
- const root2 = join117(input.projectRoot, ".tmp/context-runtime/action-results");
113910
- const resultFile = join117(root2, `${digest7}.json`);
113949
+ const root2 = join118(input.projectRoot, ".tmp/context-runtime/action-results");
113950
+ const resultFile = join118(root2, `${digest7}.json`);
113911
113951
  await atomicWriteFile(resultFile, full);
113912
113952
  if (production)
113913
113953
  return {
@@ -114336,10 +114376,10 @@ function registerProjectActionCommands(program2) {
114336
114376
 
114337
114377
  // src/commands/cleanClaudePluginCache.ts
114338
114378
  init_cliFeedback();
114339
- import { existsSync as existsSync28 } from "node:fs";
114379
+ import { existsSync as existsSync29 } from "node:fs";
114340
114380
  import { readdir as readdir30, rm as rm24 } from "node:fs/promises";
114341
114381
  import { homedir } from "node:os";
114342
- import { join as join118 } from "node:path";
114382
+ import { join as join119 } from "node:path";
114343
114383
  var ORPHAN_MARKER = ".orphaned_at";
114344
114384
  var CLAUDE_PLUGIN_CACHE_ROOT_ENV = "C4A_CLAUDE_PLUGIN_CACHE_ROOT";
114345
114385
  var CLAUDE_PLUGIN_CACHE_HOME_ENV = "C4A_CLAUDE_PLUGIN_CACHE_HOME";
@@ -114348,7 +114388,7 @@ async function cleanClaudePluginCache(opts = {}) {
114348
114388
  const lines = [];
114349
114389
  let removed = 0;
114350
114390
  let scanned = 0;
114351
- if (!existsSync28(cacheRoot)) {
114391
+ if (!existsSync29(cacheRoot)) {
114352
114392
  lines.push("· claude plugin cache: missing — nothing to clean");
114353
114393
  return { lines, removed, scanned };
114354
114394
  }
@@ -114356,20 +114396,20 @@ async function cleanClaudePluginCache(opts = {}) {
114356
114396
  for (const mp of marketplaces) {
114357
114397
  if (!mp.isDirectory())
114358
114398
  continue;
114359
- const mpDir = join118(cacheRoot, mp.name);
114399
+ const mpDir = join119(cacheRoot, mp.name);
114360
114400
  const plugins = await readdir30(mpDir, { withFileTypes: true });
114361
114401
  for (const pl of plugins) {
114362
114402
  if (!pl.isDirectory())
114363
114403
  continue;
114364
- const plDir = join118(mpDir, pl.name);
114404
+ const plDir = join119(mpDir, pl.name);
114365
114405
  const versions = await readdir30(plDir, { withFileTypes: true });
114366
114406
  for (const ver of versions) {
114367
114407
  if (!ver.isDirectory())
114368
114408
  continue;
114369
114409
  scanned += 1;
114370
- const verDir = join118(plDir, ver.name);
114371
- const markerPath = join118(verDir, ORPHAN_MARKER);
114372
- if (!existsSync28(markerPath))
114410
+ const verDir = join119(plDir, ver.name);
114411
+ const markerPath = join119(verDir, ORPHAN_MARKER);
114412
+ if (!existsSync29(markerPath))
114373
114413
  continue;
114374
114414
  const label2 = `${mp.name}/${pl.name}/${ver.name}`;
114375
114415
  if (opts.dryRun) {
@@ -114400,7 +114440,7 @@ function resolveClaudePluginCacheRoot(opts) {
114400
114440
  if (explicitRoot)
114401
114441
  return explicitRoot;
114402
114442
  const home = opts.home ?? process.env[CLAUDE_PLUGIN_CACHE_HOME_ENV] ?? homedir();
114403
- return join118(home, ".claude", "plugins", "cache");
114443
+ return join119(home, ".claude", "plugins", "cache");
114404
114444
  }
114405
114445
  async function isEmptyDir(dir) {
114406
114446
  try {
@@ -114429,35 +114469,7 @@ async function runDoctorCleanClaudePluginCache(opts = {}) {
114429
114469
  init_errors3();
114430
114470
  init_cliFeedback();
114431
114471
  init_exitCode();
114432
-
114433
- // src/lib/packageVersion.ts
114434
- import { existsSync as existsSync29, readFileSync as readFileSync9 } from "node:fs";
114435
- import { dirname as dirname47, join as join119 } from "node:path";
114436
- import { fileURLToPath as fileURLToPath9 } from "node:url";
114437
- function readPackageVersion() {
114438
- try {
114439
- let dir = dirname47(fileURLToPath9(import.meta.url));
114440
- for (let depth = 0;depth < 8; depth += 1) {
114441
- const packagePath = join119(dir, "package.json");
114442
- if (existsSync29(packagePath)) {
114443
- const parsed = JSON.parse(readFileSync9(packagePath, "utf8"));
114444
- if (typeof parsed.version === "string" && parsed.version.length > 0) {
114445
- return parsed.version;
114446
- }
114447
- break;
114448
- }
114449
- const parent = dirname47(dir);
114450
- if (parent === dir)
114451
- break;
114452
- dir = parent;
114453
- }
114454
- } catch (error) {
114455
- throw new TypeError("Context CLI package version cannot be read", {
114456
- cause: error
114457
- });
114458
- }
114459
- throw new TypeError("Context CLI package version is missing from package.json");
114460
- }
114472
+ init_packageVersion();
114461
114473
 
114462
114474
  // src/project/sourceCommands.ts
114463
114475
  init_repoContentLinks();