@c4a/context-cli 0.7.103 → 0.7.104

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
@@ -41463,6 +41463,7 @@ var init_indexerApprovedKnowledge = __esm(() => {
41463
41463
  });
41464
41464
 
41465
41465
  // ../context/src/index.ts
41466
+ var DEFAULT_PACKAGE_RULE_LIMITS;
41466
41467
  var init_src2 = __esm(() => {
41467
41468
  init_siteTheme();
41468
41469
  init_packageSite();
@@ -41516,6 +41517,7 @@ var init_src2 = __esm(() => {
41516
41517
  init_indexerApprovedKnowledge();
41517
41518
  init_articleStructure();
41518
41519
  init_articleSourceLocatorInput();
41520
+ DEFAULT_PACKAGE_RULE_LIMITS = { fileKb: 16, totalKb: 64 };
41519
41521
  });
41520
41522
 
41521
41523
  // src/project/documentRun.ts
@@ -71250,6 +71252,37 @@ var init_approvedFileRead = __esm(() => {
71250
71252
  import_yaml13 = __toESM(require_dist(), 1);
71251
71253
  });
71252
71254
 
71255
+ // src/project/knowledgePathPatterns.ts
71256
+ function globToRegExp(pattern) {
71257
+ const normalized = pattern.split("\\").join("/");
71258
+ if (normalized.endsWith("/**")) {
71259
+ const prefix = normalized.slice(0, -3).replace(/[.+^${}()|[\]\\]/gu, "\\$&");
71260
+ return new RegExp(`^${prefix}(?:/.*)?$`, "u");
71261
+ }
71262
+ let out = "^";
71263
+ for (let index2 = 0;index2 < normalized.length; index2++) {
71264
+ const char = normalized[index2];
71265
+ const next = normalized[index2 + 1];
71266
+ if (char === "*" && next === "*") {
71267
+ out += ".*";
71268
+ index2++;
71269
+ } else if (char === "*") {
71270
+ out += "[^/]*";
71271
+ } else if (char === "?") {
71272
+ out += "[^/]";
71273
+ } else {
71274
+ out += char?.replace(/[.+^${}()|[\]\\]/gu, "\\$&") ?? "";
71275
+ }
71276
+ }
71277
+ return new RegExp(`${out}$`, "u");
71278
+ }
71279
+ function matchingKnowledgePatterns(path2, patterns) {
71280
+ return patterns?.filter((pattern) => pattern === path2 || globToRegExp(pattern).test(path2)) ?? [];
71281
+ }
71282
+ function matchesKnowledgePattern(path2, patterns) {
71283
+ return matchingKnowledgePatterns(path2, patterns).length > 0;
71284
+ }
71285
+
71253
71286
  // src/project/okfTypes.ts
71254
71287
  function isKnowledgeCollection(value) {
71255
71288
  return value !== undefined && KNOWLEDGE_COLLECTIONS.includes(value);
@@ -71260,14 +71293,16 @@ function okfTypeForCollection(collection) {
71260
71293
  function okfRootForCollection(collection) {
71261
71294
  return OKF_ROOT_BY_COLLECTION[collection];
71262
71295
  }
71263
- function okfPackagePathForKnowledgePath(relPath) {
71296
+ function okfPackagePathForKnowledgePath(relPath, rules) {
71264
71297
  const parts = relPath.split(/[\\/]+/u).filter(Boolean);
71265
71298
  const hasKnowledgeRoot = parts[0] === "knowledge";
71266
71299
  const collection = hasKnowledgeRoot ? parts[1] : parts[0];
71267
71300
  if (!isKnowledgeCollection(collection))
71268
71301
  return relPath;
71269
71302
  const rest = hasKnowledgeRoot ? parts.slice(2) : parts.slice(1);
71270
- const root = okfRootForCollection(collection);
71303
+ let root = okfRootForCollection(collection);
71304
+ if (root === "rules" && matchesKnowledgePattern([collection, ...rest].join("/"), rules?.exclude))
71305
+ root = "guides";
71271
71306
  return root === collection ? [root, ...rest].join("/") : [root, collection, ...rest].join("/");
71272
71307
  }
71273
71308
  function okfTypeForKnowledgePath(relPath) {
@@ -71349,7 +71384,7 @@ function namespaceOkfPath(pkg, relPath) {
71349
71384
  return relPath;
71350
71385
  }
71351
71386
  function packageKnowledgeOutputPath(pkg, approvedRelPath) {
71352
- return namespaceOkfPath(pkg, okfPackagePathForKnowledgePath(approvedRelPath));
71387
+ return namespaceOkfPath(pkg, okfPackagePathForKnowledgePath(approvedRelPath, pkg.kind === "package.kb" ? pkg.rules : undefined));
71353
71388
  }
71354
71389
  function packageTemplateOutputPath(pkg, logicalRelPath) {
71355
71390
  return namespaceOkfPath(pkg, logicalRelPath);
@@ -77347,6 +77382,13 @@ function formatPackageBuildSummary(pkg) {
77347
77382
  const explanation = warning.code === "package-article-not-selected" ? "is not included; its source coordinate is retained for inspection" : warning.code === "package-link-anchor-unresolved" ? "has an unresolved section anchor; check the target heading or explicit anchor" : "has no matching Markdown page in this package; check the selected navigation";
77348
77383
  lines.push(` warning: ${warning.path} references ${warning.target}, which ${explanation}.`);
77349
77384
  }
77385
+ if (pkg.rules) {
77386
+ lines.push(` warning: ${pkg.rules.message}`);
77387
+ for (const path2 of pkg.rules.oversized) {
77388
+ lines.push(` ${path2}: ${pkg.rules.files.find((file) => file.path === path2)?.kb ?? "?"} KB`);
77389
+ }
77390
+ lines.push(` next: ${pkg.rules.next_action.instruction}`);
77391
+ }
77350
77392
  const optimization = pkg.resources.delivery.optimization;
77351
77393
  for (const warning of optimization?.warnings ?? []) {
77352
77394
  lines.push(` image replaced with placeholder: ${warning.path}: ${warning.reason}`);
@@ -77858,7 +77900,7 @@ function knowledgeInventory(files, templateRelPath, navigation = DEFAULT_PACKAGE
77858
77900
  const productionFrontmatter = parseKnowledgeFrontmatter(file.content);
77859
77901
  const frontmatter = packageKnowledgeFrontmatter(productionFrontmatter);
77860
77902
  const productionMetadata = packageKnowledgeMetadata(productionFrontmatter);
77861
- const logicalOutputRelPath = okfPackagePathForKnowledgePath(file.relPath);
77903
+ const logicalOutputRelPath = okfPackagePathForKnowledgePath(file.relPath, pkg?.kind === "package.kb" ? pkg.rules : undefined);
77862
77904
  const outputRelPath = pkg === undefined ? logicalOutputRelPath : packageKnowledgeOutputPath(pkg, file.relPath);
77863
77905
  const sourcePath = file.relPath;
77864
77906
  const sourceCollection = splitKnowledgePath(file.relPath).collection;
@@ -91323,34 +91365,23 @@ var init_packageAssetDelivery = __esm(() => {
91323
91365
  import { existsSync as existsSync17 } from "node:fs";
91324
91366
  import { mkdir as mkdir27, readFile as readFile68, writeFile as writeFile20 } from "node:fs/promises";
91325
91367
  import { dirname as dirname33, join as join78 } from "node:path";
91326
- function globToRegExp(pattern) {
91327
- const normalized = toPosixPath5(pattern);
91328
- if (normalized.endsWith("/**")) {
91329
- const prefix = normalized.slice(0, -3).replace(/[.+^${}()|[\]\\]/gu, "\\$&");
91330
- return new RegExp(`^${prefix}(?:/.*)?$`, "u");
91331
- }
91332
- let out = "^";
91333
- for (let index3 = 0;index3 < normalized.length; index3++) {
91334
- const char = normalized[index3];
91335
- const next = normalized[index3 + 1];
91336
- if (char === "*" && next === "*") {
91337
- out += ".*";
91338
- index3++;
91339
- } else if (char === "*") {
91340
- out += "[^/]*";
91341
- } else if (char === "?") {
91342
- out += "[^/]";
91343
- } else {
91344
- out += char?.replace(/[.+^${}()|[\]\\]/gu, "\\$&") ?? "";
91345
- }
91346
- }
91347
- return new RegExp(`${out}$`, "u");
91368
+ function withAlwaysApply(markdown) {
91369
+ const end = markdown.startsWith(`---
91370
+ `) ? markdown.indexOf(`
91371
+ ---`, 3) : -1;
91372
+ if (end < 0)
91373
+ return markdown;
91374
+ const frontmatter = markdown.slice(4, end);
91375
+ const updated = /^alwaysApply:.*$/mu.test(frontmatter) ? frontmatter.replace(/^alwaysApply:.*$/mu, "alwaysApply: true") : `alwaysApply: true
91376
+ ${frontmatter}`;
91377
+ return `---
91378
+ ${updated}${markdown.slice(end)}`;
91348
91379
  }
91349
91380
  function matchesAny(path2, patterns) {
91350
- return patterns?.some((pattern) => pattern === path2 || globToRegExp(pattern).test(path2)) === true;
91381
+ return matchesKnowledgePattern(path2, patterns);
91351
91382
  }
91352
91383
  function matchingPatterns(path2, patterns) {
91353
- return patterns?.filter((pattern) => pattern === path2 || globToRegExp(pattern).test(path2)) ?? [];
91384
+ return matchingKnowledgePatterns(path2, patterns);
91354
91385
  }
91355
91386
  function selectionReasonsForFile(file, pkg) {
91356
91387
  const internalCollection = file.relPath.split("/")[0];
@@ -91361,7 +91392,7 @@ function selectionReasonsForFile(file, pkg) {
91361
91392
  return null;
91362
91393
  if (pkg.select?.collections?.length)
91363
91394
  reasons.push({ kind: "collection", value: internalCollection });
91364
- const okfRoot = okfRootForCollection(internalCollection);
91395
+ const okfRoot = okfPackagePathForKnowledgePath(file.relPath, pkg.kind === "package.kb" ? pkg.rules : undefined).startsWith("guides/") ? "guides" : okfRootForCollection(internalCollection);
91365
91396
  if (pkg.select?.okfRoots?.length && !pkg.select.okfRoots.includes(okfRoot))
91366
91397
  return null;
91367
91398
  if (pkg.select?.okfRoots?.length)
@@ -91529,7 +91560,9 @@ async function writeSelectedPackageKnowledge(input) {
91529
91560
  content: links.markdown
91530
91561
  });
91531
91562
  const file = byPath.get(approvedByOutput.get(projected.pageOutputPath));
91532
- await writeFile20(outputPath, markdown + articleProvenanceMarkdown(file?.article, registry2, repositoryRemote), "utf8");
91563
+ const alwaysOn = input.pkg.kind === "package.kb" && projected.pageOutputPath.startsWith("rules/") && matchesKnowledgePattern(approvedByOutput.get(projected.pageOutputPath).replace(/^knowledge\//u, ""), input.pkg.rules?.alwaysApply);
91564
+ const ruleMarkdown = alwaysOn ? withAlwaysApply(markdown) : markdown;
91565
+ await writeFile20(outputPath, ruleMarkdown + articleProvenanceMarkdown(file?.article, registry2, repositoryRemote), "utf8");
91533
91566
  return links.warnings;
91534
91567
  }));
91535
91568
  for (const result of results) {
@@ -95330,6 +95363,101 @@ var init_runtimeEvents = __esm(() => {
95330
95363
  RUNTIME_EVENT_SINK_DESCRIPTION_MAX_BYTES = 16 * 1024;
95331
95364
  });
95332
95365
 
95366
+ // src/project/sdkAlignment.ts
95367
+ var exports_sdkAlignment = {};
95368
+ __export(exports_sdkAlignment, {
95369
+ inspectSdkAlignment: () => inspectSdkAlignment
95370
+ });
95371
+ import { readFile as readFile74 } from "node:fs/promises";
95372
+ import { join as join87 } from "node:path";
95373
+ function core3(version3) {
95374
+ const match = /^(\d+)\.(\d+)\.(\d+)$/u.exec(version3?.trim() ?? "");
95375
+ return match ? [Number(match[1]), Number(match[2]), Number(match[3])] : null;
95376
+ }
95377
+ function older(left, right) {
95378
+ for (let index3 = 0;index3 < 3; index3++)
95379
+ if (left[index3] !== right[index3])
95380
+ return left[index3] < right[index3];
95381
+ return false;
95382
+ }
95383
+ async function readJson(path2) {
95384
+ try {
95385
+ return JSON.parse(await readFile74(path2, "utf8"));
95386
+ } catch {
95387
+ return null;
95388
+ }
95389
+ }
95390
+ async function inspectSdkAlignment(projectRoot, cliVersion = readCurrentPackageVersion()) {
95391
+ const manifest = await readJson(join87(projectRoot, "package.json"));
95392
+ const dependencies = { ...manifest?.devDependencies, ...manifest?.dependencies };
95393
+ const pinned = dependencies[SDK_PACKAGE];
95394
+ const installed = (await readJson(join87(projectRoot, "node_modules", ...SDK_PACKAGE.split("/"), "package.json")))?.version;
95395
+ const cli = core3(cliVersion);
95396
+ const target = core3(pinned);
95397
+ if (pinned === undefined || cli === null || target === null || target[0] !== cli[0])
95398
+ return;
95399
+ const installedCore = core3(typeof installed === "string" ? installed : null);
95400
+ if (!older(target, cli) && (installedCore === null || !older(installedCore, cli)))
95401
+ return;
95402
+ return {
95403
+ workspace_sdk: { pinned, installed: typeof installed === "string" ? installed : null },
95404
+ cli: cliVersion,
95405
+ message: `The workspace pins ${SDK_PACKAGE} ${pinned}, older than the running CLI ${cliVersion}; its documentation and registry parsing lag behind the CLI.`,
95406
+ instruction: `Set ${SDK_PACKAGE} in package.json to ${cliVersion}, install with the workspace package manager (bun install for bun.lock) and commit package.json together with the lock file in the next delivery. A routine update without content changes may deliver this upgrade alone.`
95407
+ };
95408
+ }
95409
+ var SDK_PACKAGE = "@c4a/context";
95410
+ var init_sdkAlignment = __esm(() => {
95411
+ init_workspace();
95412
+ });
95413
+
95414
+ // src/project/packageRulesSize.ts
95415
+ import { readFile as readFile75 } from "node:fs/promises";
95416
+ import { join as join88 } from "node:path";
95417
+ async function inspectPackageRules(projectRoot, pkg) {
95418
+ if (pkg.kind !== "package.kb")
95419
+ return;
95420
+ const limits = { ...DEFAULT_PACKAGE_RULE_LIMITS, ...pkg.rules?.limits };
95421
+ const files = [];
95422
+ let total = 0;
95423
+ for (const file of await walkPackageFiles(join88(projectRoot, pkg.outDir, "rules"))) {
95424
+ if (!/\.mdx?$/iu.test(file.relPath))
95425
+ continue;
95426
+ const content3 = await readFile75(file.absPath, "utf8");
95427
+ const frontmatter = /^---\r?\n([\s\S]*?)\r?\n---/u.exec(content3)?.[1] ?? "";
95428
+ if (/^type:\s*["']?Knowledge Directory["']?\s*$/mu.test(frontmatter))
95429
+ continue;
95430
+ const bytes = Buffer.byteLength(content3);
95431
+ total += bytes;
95432
+ files.push({ path: `rules/${file.relPath}`, kb: kb(bytes), always_apply: /^alwaysApply:\s*true\s*$/mu.test(frontmatter) });
95433
+ }
95434
+ const oversized = files.filter((file) => file.kb > limits.fileKb).map((file) => file.path);
95435
+ const totalKb = kb(total);
95436
+ if (oversized.length === 0 && totalKb <= limits.totalKb)
95437
+ return;
95438
+ const alignment = await inspectSdkAlignment(projectRoot);
95439
+ const instruction = "Read the listed rule articles and decide with the user which are binding rules: keep those short and list the ones every session needs in the package's rules.alwaysApply; move reference material (dictionaries, tables, methodology) to guides/ with rules.exclude. Adjust rules.limits if larger rules are intended. Then rebuild.";
95440
+ return {
95441
+ total_kb: totalKb,
95442
+ limits,
95443
+ files: files.sort((left, right) => right.kb - left.kb),
95444
+ oversized,
95445
+ total_exceeded: totalKb > limits.totalKb,
95446
+ message: `Package rules total ${totalKb} KB${oversized.length ? `; ${oversized.length} file(s) exceed ${limits.fileKb} KB` : ""}. AI tools may load package rules into every session.`,
95447
+ next_action: {
95448
+ file: "src/index.ts",
95449
+ instruction: alignment ? `First upgrade the workspace SDK as version_alignment describes: an older SDK ignores the rules option. ${instruction}` : instruction
95450
+ },
95451
+ ...alignment ? { version_alignment: alignment } : {}
95452
+ };
95453
+ }
95454
+ var kb = (bytes) => Math.round(bytes / 102.4) / 10;
95455
+ var init_packageRulesSize = __esm(() => {
95456
+ init_src2();
95457
+ init_packageBuildReceipt();
95458
+ init_sdkAlignment();
95459
+ });
95460
+
95333
95461
  // src/project/packageTemplateGuard.ts
95334
95462
  function validatePackageTemplateContract(pkg, templateFiles2) {
95335
95463
  if (pkg.kind === "package.kb") {
@@ -95514,8 +95642,8 @@ var init_packageTemplateGuard = __esm(() => {
95514
95642
  });
95515
95643
 
95516
95644
  // src/project/approvedKnowledgeSnapshots.ts
95517
- import { readFile as readFile74 } from "node:fs/promises";
95518
- import { join as join87 } from "node:path";
95645
+ import { readFile as readFile76 } from "node:fs/promises";
95646
+ import { join as join89 } from "node:path";
95519
95647
  function approvedKnowledgeSnapshotsFromStructure(structure) {
95520
95648
  return validateArticleStructureEntries(structure?.articles ?? []);
95521
95649
  }
@@ -95524,7 +95652,7 @@ async function prepareApprovedKnowledgeSnapshotTarget(input) {
95524
95652
  return;
95525
95653
  let before;
95526
95654
  try {
95527
- before = await readFile74(join87(input.projectRoot, STRUCTURE_PATH2), "utf8");
95655
+ before = await readFile76(join89(input.projectRoot, STRUCTURE_PATH2), "utf8");
95528
95656
  } catch (error) {
95529
95657
  if (error.code !== "ENOENT")
95530
95658
  throw error;
@@ -95703,10 +95831,10 @@ var init_approvedStructureInputHash = () => {};
95703
95831
 
95704
95832
  // src/project/verifyApprovedStructure.ts
95705
95833
  import { existsSync as existsSync22 } from "node:fs";
95706
- import { join as join88 } from "node:path";
95834
+ import { join as join90 } from "node:path";
95707
95835
  async function validateApprovedStructure(input) {
95708
95836
  const issue = (code, path3, message) => input.issues.push({ severity: "error", code, path: path3, message });
95709
- const path2 = join88(input.projectRoot, STRUCTURE_PATH3);
95837
+ const path2 = join90(input.projectRoot, STRUCTURE_PATH3);
95710
95838
  if (!input.structureOverride && !existsSync22(path2))
95711
95839
  return;
95712
95840
  let parsed;
@@ -95864,7 +95992,7 @@ var init_verifyDiagnostics = __esm(() => {
95864
95992
 
95865
95993
  // src/project/verify.ts
95866
95994
  import { existsSync as existsSync23 } from "node:fs";
95867
- import { join as join89 } from "node:path";
95995
+ import { join as join91 } from "node:path";
95868
95996
  function evidenceStatusForIssues(issues) {
95869
95997
  if (issues.some((issue) => issue.severity === "error"))
95870
95998
  return "fail";
@@ -95938,7 +96066,7 @@ async function verifyProjectWorkspace(projectRoot, options = {}) {
95938
96066
  pageRelPath: `knowledge/${file.relPath}`,
95939
96067
  content: content3
95940
96068
  })) {
95941
- if (!existsSync23(join89(projectRoot, assetPath))) {
96069
+ if (!existsSync23(join91(projectRoot, assetPath))) {
95942
96070
  issues.push({
95943
96071
  severity: "error",
95944
96072
  code: "approved-resource-missing",
@@ -96077,8 +96205,8 @@ __export(exports_packageBuilder, {
96077
96205
  });
96078
96206
  import { createHash as createHash28 } from "node:crypto";
96079
96207
  import { existsSync as existsSync24 } from "node:fs";
96080
- import { mkdir as mkdir33, readdir as readdir21, readFile as readFile75, rm as rm20, writeFile as writeFile25 } from "node:fs/promises";
96081
- import { dirname as dirname40, join as join90, resolve as resolve31 } from "node:path";
96208
+ import { mkdir as mkdir33, readdir as readdir21, readFile as readFile77, rm as rm20, writeFile as writeFile25 } from "node:fs/promises";
96209
+ import { dirname as dirname40, join as join92, resolve as resolve31 } from "node:path";
96082
96210
  function packageAssetDeliverySummary(value) {
96083
96211
  if (value === null || typeof value !== "object" || Array.isArray(value))
96084
96212
  return;
@@ -96100,7 +96228,7 @@ function assertPackageOutputDir(pkg) {
96100
96228
  }
96101
96229
  function packageFingerprintPath(projectRoot, pkg) {
96102
96230
  assertSafeRenderedPath(`${pkg.name}.json`, "package fingerprint path");
96103
- return join90(projectRoot, PACKAGE_FINGERPRINT_ROOT, `${pkg.name}.json`);
96231
+ return join92(projectRoot, PACKAGE_FINGERPRINT_ROOT, `${pkg.name}.json`);
96104
96232
  }
96105
96233
  async function listApprovedKnowledge(projectRoot) {
96106
96234
  const metadata = await readApprovedKnowledgeMetadataIndex(projectRoot);
@@ -96141,7 +96269,7 @@ async function listTemplateFiles(projectRoot, templatePath) {
96141
96269
  const files = await walkPackageFiles(templateRoot);
96142
96270
  return Promise.all(files.filter((file) => file.relPath.split("/").at(-1) !== PACKAGE_TEMPLATE_REVIEW_FILE).map(async (file) => ({
96143
96271
  ...file,
96144
- content: await readFile75(file.absPath, "utf8")
96272
+ content: await readFile77(file.absPath, "utf8")
96145
96273
  })));
96146
96274
  }
96147
96275
  function stableHash2(value) {
@@ -96183,6 +96311,7 @@ async function packageInputFingerprint(input) {
96183
96311
  name: input.pkg.name,
96184
96312
  select: input.pkg.select ?? null,
96185
96313
  navigation: input.pkg.kind === "package.kb" ? packageNavigation(input.pkg) : null,
96314
+ ...input.pkg.kind === "package.kb" && input.pkg.rules !== undefined ? { rules: input.pkg.rules } : {},
96186
96315
  assets: input.pkg.kind === "package.kb" ? input.pkg.assets ?? null : null,
96187
96316
  ...input.pkg.kind === "package.kb" && input.pkg.site ? { site: { ...input.pkg.site, renderer: PACKAGE_SITE_VERSION } } : {},
96188
96317
  template: input.pkg.template,
@@ -96209,7 +96338,7 @@ async function readPackageManifest(projectRoot, pkg) {
96209
96338
  if (!existsSync24(filePath2))
96210
96339
  return null;
96211
96340
  try {
96212
- const parsed = JSON.parse(await readFile75(filePath2, "utf8"));
96341
+ const parsed = JSON.parse(await readFile77(filePath2, "utf8"));
96213
96342
  if (parsed !== null && typeof parsed === "object" && !Array.isArray(parsed)) {
96214
96343
  const candidate = parsed;
96215
96344
  if (typeof candidate.builder_protocol === "string" && typeof candidate.fingerprint === "string" && typeof candidate.output_fingerprint === "string" && typeof candidate.output_files === "number" && Array.isArray(candidate.outputs)) {
@@ -96256,12 +96385,12 @@ async function writePackageFingerprint(input) {
96256
96385
  `, "utf8");
96257
96386
  }
96258
96387
  async function removeOrphanPackageDirs(projectRoot, packages) {
96259
- const distRoot = join90(projectRoot, "dist");
96388
+ const distRoot = join92(projectRoot, "dist");
96260
96389
  if (!existsSync24(distRoot))
96261
96390
  return;
96262
96391
  const declaredNames = new Set(packages.flatMap((pkg) => packageOutputDirs(pkg).map((path2) => path2.slice("dist/".length))));
96263
96392
  const entries2 = await readdir21(distRoot, { withFileTypes: true });
96264
- await Promise.all(entries2.filter((entry) => entry.isDirectory() && !declaredNames.has(entry.name)).map((entry) => rm20(join90(distRoot, entry.name), { recursive: true, force: true, maxRetries: 3, retryDelay: 100 })));
96393
+ await Promise.all(entries2.filter((entry) => entry.isDirectory() && !declaredNames.has(entry.name)).map((entry) => rm20(join92(distRoot, entry.name), { recursive: true, force: true, maxRetries: 3, retryDelay: 100 })));
96265
96394
  }
96266
96395
  async function collectPackageFreshness(projectRoot, packages) {
96267
96396
  assertDistinctPackageOutputs(packages);
@@ -96270,7 +96399,7 @@ async function collectPackageFreshness(projectRoot, packages) {
96270
96399
  assertPackageOutputDir(pkg);
96271
96400
  const selected = selectPackageKnowledge(approved, pkg);
96272
96401
  assertSafeRenderedPath(pkg.template.path, "package template path");
96273
- const templateRoot = join90(projectRoot, pkg.template.path);
96402
+ const templateRoot = join92(projectRoot, pkg.template.path);
96274
96403
  const templateExists = existsSync24(templateRoot);
96275
96404
  if (!templateExists) {
96276
96405
  throw new ContextError(ExitCode.WorkspaceStateError, `package template path is missing: ${pkg.template.path}`, {
@@ -96437,11 +96566,13 @@ async function buildProjectPackagesInternal(projectRoot, options) {
96437
96566
  if (previousManifest?.builderProtocol === PACKAGE_BUILDER_PROTOCOL_VERSION && previousManifest.fingerprint === fingerprint && previousManifest.assetDelivery !== undefined) {
96438
96567
  const existingOutput = await packageOutputFingerprint(projectRoot, pkg);
96439
96568
  if (existingOutput.fingerprint === previousManifest.outputFingerprint) {
96569
+ const unchangedRules = await inspectPackageRules(projectRoot, pkg);
96440
96570
  summaries.push({
96441
96571
  name: pkg.name,
96442
96572
  kind: packageKind(pkg),
96443
96573
  outDir: pkg.outDir,
96444
96574
  ...pkg.kind === "package.kb" && pkg.site ? { siteOutDir: packageSiteOutputDir(pkg) } : {},
96575
+ ...unchangedRules ? { rules: unchangedRules } : {},
96445
96576
  inputs: selected.length,
96446
96577
  files: existingOutput.files,
96447
96578
  state: "unchanged",
@@ -96521,19 +96652,19 @@ async function buildProjectPackagesInternal(projectRoot, options) {
96521
96652
  if (stagedPkg.kind === "package.llms") {
96522
96653
  const articles = await Promise.all(llmsArticles(stagedPkg, selected).map(async (article) => ({
96523
96654
  ...article,
96524
- content: await readFile75(join90(projectRoot, stagedPkg.outDir, article.path), "utf8")
96655
+ content: await readFile77(join92(projectRoot, stagedPkg.outDir, article.path), "utf8")
96525
96656
  })));
96526
- await writeLlmsDocuments(join90(projectRoot, stagedPkg.outDir), buildLlmsDocuments({
96657
+ await writeLlmsDocuments(join92(projectRoot, stagedPkg.outDir), buildLlmsDocuments({
96527
96658
  title: stagedPkg.name,
96528
96659
  articles,
96529
96660
  ...reading ? { map: reading } : {}
96530
96661
  }), { preserveIndex: true });
96531
96662
  }
96532
- await writePackageVersion(projectRoot, join90(projectRoot, stagedPkg.outDir));
96663
+ await writePackageVersion(projectRoot, join92(projectRoot, stagedPkg.outDir));
96533
96664
  await writePackageSite({ projectRoot, pkg: stagedPkg, selected, ...siteUrl ? { siteUrl } : {}, ...reading ? { structure: reading } : {} });
96534
96665
  const linkWarnings = [
96535
96666
  ...writtenKnowledge2.linkWarnings,
96536
- ...await inspectPackageMarkdownDirectory(join90(projectRoot, stagedPkg.outDir))
96667
+ ...await inspectPackageMarkdownDirectory(join92(projectRoot, stagedPkg.outDir))
96537
96668
  ];
96538
96669
  return { ...writtenKnowledge2, linkWarnings };
96539
96670
  });
@@ -96551,9 +96682,11 @@ async function buildProjectPackagesInternal(projectRoot, options) {
96551
96682
  assetDelivery: writtenKnowledge.assetDelivery,
96552
96683
  linkWarnings: writtenKnowledge.linkWarnings
96553
96684
  });
96685
+ const rulesReport = await inspectPackageRules(projectRoot, pkg);
96554
96686
  summaries.push({
96555
96687
  name: pkg.name,
96556
96688
  ...pkg.kind === "package.kb" && pkg.site ? { siteOutDir: packageSiteOutputDir(pkg) } : {},
96689
+ ...rulesReport ? { rules: rulesReport } : {},
96557
96690
  kind: packageKind(pkg),
96558
96691
  outDir: pkg.outDir,
96559
96692
  inputs: selected.length,
@@ -96665,6 +96798,7 @@ var init_packageBuilder = __esm(() => {
96665
96798
  init_packageIndexes();
96666
96799
  init_packageNavigation();
96667
96800
  init_packageBuildReceipt();
96801
+ init_packageRulesSize();
96668
96802
  init_packageBuildContent();
96669
96803
  init_packageTemplateGuard();
96670
96804
  init_packageAssets();
@@ -96678,7 +96812,7 @@ var init_packageBuilder = __esm(() => {
96678
96812
  init_siteTranslation();
96679
96813
  init_approvedKnowledgeMetadata();
96680
96814
  import_yaml44 = __toESM(require_dist(), 1);
96681
- PACKAGE_FINGERPRINT_ROOT = join90(".tmp", "context-runtime", "packages");
96815
+ PACKAGE_FINGERPRINT_ROOT = join92(".tmp", "context-runtime", "packages");
96682
96816
  });
96683
96817
 
96684
96818
  // src/project/knowledgeMaintenance.ts
@@ -96693,15 +96827,15 @@ __export(exports_knowledgeMaintenance, {
96693
96827
  cancelKnowledgeMaintenance: () => cancelKnowledgeMaintenance,
96694
96828
  advanceKnowledgeMaintenance: () => advanceKnowledgeMaintenance
96695
96829
  });
96696
- import { readFile as readFile76, readdir as readdir22, rm as rm21 } from "node:fs/promises";
96697
- import { join as join91 } from "node:path";
96830
+ import { readFile as readFile78, readdir as readdir22, rm as rm21 } from "node:fs/promises";
96831
+ import { join as join93 } from "node:path";
96698
96832
  async function deliveryDigest(root) {
96699
- const directory = join91(root, ".tmp/context-runtime/packages");
96833
+ const directory = join93(root, ".tmp/context-runtime/packages");
96700
96834
  try {
96701
96835
  const files = (await readdir22(directory)).filter((name3) => name3.endsWith(".json")).sort();
96702
96836
  if (!files.length)
96703
96837
  return indexerProtocolDigest(null);
96704
- return indexerProtocolDigest(await Promise.all(files.map((name3) => readFile76(join91(directory, name3), "utf8"))));
96838
+ return indexerProtocolDigest(await Promise.all(files.map((name3) => readFile78(join93(directory, name3), "utf8"))));
96705
96839
  } catch (error) {
96706
96840
  if (error.code === "ENOENT")
96707
96841
  return indexerProtocolDigest(null);
@@ -96844,7 +96978,7 @@ async function observeKnowledgeMaintenance(root) {
96844
96978
  async function maintenanceRevision(root) {
96845
96979
  const observed = await observeKnowledgeMaintenance(root);
96846
96980
  const localInputs = observed.state.active ? {
96847
- revision: await readFile76(join91(root, MAINTENANCE_ROOT, "revision.json"), "utf8").catch((error) => {
96981
+ revision: await readFile78(join93(root, MAINTENANCE_ROOT, "revision.json"), "utf8").catch((error) => {
96848
96982
  if (error.code === "ENOENT")
96849
96983
  return null;
96850
96984
  throw error;
@@ -96957,7 +97091,7 @@ async function finishMaintenanceRevision(root, outcome = "completed") {
96957
97091
  outcome = state.active.completion_outcome;
96958
97092
  state.active.phase = "finishing";
96959
97093
  await saveMaintenance(root, state);
96960
- await rm21(join91(root, MAINTENANCE_ROOT, "revision.json"), { force: true });
97094
+ await rm21(join93(root, MAINTENANCE_ROOT, "revision.json"), { force: true });
96961
97095
  state.completed.push({ id: state.active.input.id, input_digest: indexerProtocolDigest(state.active.input), outcome });
96962
97096
  delete state.active;
96963
97097
  await saveMaintenance(root, state);
@@ -96991,8 +97125,8 @@ async function discardMaintenanceDraft(root) {
96991
97125
  const owned = new Set([...request?.batch_candidates ?? [], ...request?.candidate ? [request.candidate] : []].map((item) => item.candidate_id));
96992
97126
  if (candidates.some((item) => !owned.has(item.candidate_id)))
96993
97127
  throw new TypeError("Unrelated Candidates are present; no draft was discarded. Inspect the current review before retrying cancellation.");
96994
- await rm21(join91(root, CANDIDATE_LEDGER_FILE), { force: true });
96995
- await rm21(join91(root, MAINTENANCE_ROOT, "revision.json"), { force: true });
97128
+ await rm21(join93(root, CANDIDATE_LEDGER_FILE), { force: true });
97129
+ await rm21(join93(root, MAINTENANCE_ROOT, "revision.json"), { force: true });
96996
97130
  const { closeProjectWorkspace } = await Promise.resolve().then(() => (init_close(), exports_close));
96997
97131
  const { buildProjectPackages: buildProjectPackages2 } = await Promise.resolve().then(() => (init_packageBuilder(), exports_packageBuilder));
96998
97132
  await closeProjectWorkspace(root);
@@ -97020,8 +97154,8 @@ __export(exports_taskRollback, {
97020
97154
  readTaskRollback: () => readTaskRollback,
97021
97155
  finishTaskRollback: () => finishTaskRollback
97022
97156
  });
97023
- import { readFile as readFile77, rm as rm22 } from "node:fs/promises";
97024
- import { join as join92 } from "node:path";
97157
+ import { readFile as readFile79, rm as rm22 } from "node:fs/promises";
97158
+ import { join as join94 } from "node:path";
97025
97159
  async function productionScope(projectRoot) {
97026
97160
  const { readProductionStage: readProductionStage2 } = await Promise.resolve().then(() => (init_productionStageStore(), exports_productionStageStore));
97027
97161
  const stage = await readProductionStage2(projectRoot);
@@ -97062,7 +97196,7 @@ async function readTaskRollback(projectRoot) {
97062
97196
  }
97063
97197
  async function contents(projectRoot, path2) {
97064
97198
  try {
97065
- return await readFile77(join92(projectRoot, path2), "utf8");
97199
+ return await readFile79(join94(projectRoot, path2), "utf8");
97066
97200
  } catch (error) {
97067
97201
  if (error && typeof error === "object" && "code" in error && error.code === "ENOENT")
97068
97202
  return;
@@ -97210,7 +97344,7 @@ async function finishTaskRollback(projectRoot) {
97210
97344
  const production = await readProductionStage2(projectRoot);
97211
97345
  const recorded = rollback.production;
97212
97346
  if (production && recorded !== undefined && (recorded === null || !recorded.discard || recorded.stage !== production.id)) {
97213
- await rm22(join92(projectRoot, await revisionStoragePath(projectRoot)), { force: true });
97347
+ await rm22(join94(projectRoot, await revisionStoragePath(projectRoot)), { force: true });
97214
97348
  return {
97215
97349
  action: "finished",
97216
97350
  production: recorded?.stage === production.id ? "resumed" : "kept",
@@ -97345,7 +97479,7 @@ __export(exports_close, {
97345
97479
  });
97346
97480
  import { existsSync as existsSync25 } from "node:fs";
97347
97481
  import { mkdir as mkdir34, writeFile as writeFile26 } from "node:fs/promises";
97348
- import { dirname as dirname41, join as join93 } from "node:path";
97482
+ import { dirname as dirname41, join as join95 } from "node:path";
97349
97483
  function parseFrontmatter4(content3) {
97350
97484
  const match = /^---\r?\n([\s\S]*?)\r?\n---/u.exec(content3);
97351
97485
  if (match?.[1] === undefined)
@@ -97417,7 +97551,7 @@ async function deriveApprovedStructure(projectRoot) {
97417
97551
  }
97418
97552
  async function writeApprovedStructureProjection(projectRoot) {
97419
97553
  const { inputHash, structure, compactFiles } = await deriveApprovedStructure(projectRoot);
97420
- const outputPath = join93(projectRoot, STRUCTURE_PATH4);
97554
+ const outputPath = join95(projectRoot, STRUCTURE_PATH4);
97421
97555
  await mkdir34(dirname41(outputPath), { recursive: true });
97422
97556
  await writeFile26(outputPath, import_yaml45.default.stringify(structure), "utf8");
97423
97557
  await Promise.all(compactFiles.map((file) => writeFile26(file.absPath, file.content, "utf8")));
@@ -97428,7 +97562,7 @@ function referencesReceipt() {
97428
97562
  }
97429
97563
  async function readProjectCloseStatus(projectRoot) {
97430
97564
  const approved = await approvedKnowledgeFiles(projectRoot);
97431
- const structurePath = join93(projectRoot, STRUCTURE_PATH4);
97565
+ const structurePath = join95(projectRoot, STRUCTURE_PATH4);
97432
97566
  if (approved.length === 0 && !existsSync25(structurePath))
97433
97567
  return { state: "missing", diagnostics: [] };
97434
97568
  const inputHash = await approvedKnowledgeInputHash(projectRoot);
@@ -97492,7 +97626,7 @@ async function closeProjectWorkspace(projectRoot) {
97492
97626
  next: "Fix context verify errors, then rerun context close --format json."
97493
97627
  });
97494
97628
  }
97495
- const outputPath = join93(projectRoot, STRUCTURE_PATH4);
97629
+ const outputPath = join95(projectRoot, STRUCTURE_PATH4);
97496
97630
  await mkdir34(dirname41(outputPath), { recursive: true });
97497
97631
  await writeFile26(outputPath, `${import_yaml45.default.stringify(structure)}`, "utf8");
97498
97632
  await Promise.all(compactFiles.map((file) => writeFile26(file.absPath, file.content, "utf8")));
@@ -97569,7 +97703,7 @@ var init_close = __esm(() => {
97569
97703
  init_knowledgeAssetRepair();
97570
97704
  init_approvedKnowledgeMetadata();
97571
97705
  import_yaml45 = __toESM(require_dist(), 1);
97572
- STRUCTURE_PATH4 = join93(KNOWLEDGE_ROOT, "structure.yaml");
97706
+ STRUCTURE_PATH4 = join95(KNOWLEDGE_ROOT, "structure.yaml");
97573
97707
  });
97574
97708
 
97575
97709
  // src/project/processedScopeStorage.ts
@@ -97582,8 +97716,8 @@ __export(exports_processedScopeStorage, {
97582
97716
  commitProcessedScopes: () => commitProcessedScopes,
97583
97717
  captureProcessedScopes: () => captureProcessedScopes
97584
97718
  });
97585
- import { access as access6, readFile as readFile78 } from "node:fs/promises";
97586
- import { dirname as dirname42, join as join94 } from "node:path";
97719
+ import { access as access6, readFile as readFile80 } from "node:fs/promises";
97720
+ import { dirname as dirname42, join as join96 } from "node:path";
97587
97721
  async function currentScopeSourceVersion(projectRoot, sourceRef) {
97588
97722
  if (sourceRef.startsWith("repo-content:"))
97589
97723
  return repoContentWorkingVersion(projectRoot, sourceRef);
@@ -97609,7 +97743,7 @@ async function currentScopeSourceVersion(projectRoot, sourceRef) {
97609
97743
  throw new TypeError(`Source must identify one registered document: ${sourceRef}`);
97610
97744
  const entry = entries2[0];
97611
97745
  const manifest = entry.snapshot?.manifest ?? `${entry.materializedAt}/manifest.json`;
97612
- return parseDocumentSnapshotForSource(JSON.parse(await readFile78(join94(projectRoot, manifest), "utf8")), entry.name).snapshot_hash;
97746
+ return parseDocumentSnapshotForSource(JSON.parse(await readFile80(join96(projectRoot, manifest), "utf8")), entry.name).snapshot_hash;
97613
97747
  }
97614
97748
  async function sourceMaterialAvailable(projectRoot, sourceRef) {
97615
97749
  try {
@@ -97632,10 +97766,10 @@ async function sourceMaterialAvailable(projectRoot, sourceRef) {
97632
97766
  if (entries2.length !== 1)
97633
97767
  return false;
97634
97768
  const manifestPath = entries2[0].snapshot?.manifest ?? `${entries2[0].materializedAt}/manifest.json`;
97635
- const snapshot = parseDocumentSnapshotForSource(JSON.parse(await readFile78(join94(projectRoot, manifestPath), "utf8")), entries2[0].name);
97636
- const base = join94(projectRoot, dirname42(manifestPath));
97769
+ const snapshot = parseDocumentSnapshotForSource(JSON.parse(await readFile80(join96(projectRoot, manifestPath), "utf8")), entries2[0].name);
97770
+ const base = join96(projectRoot, dirname42(manifestPath));
97637
97771
  for (const file of snapshot.files)
97638
- await access6(join94(base, file.path));
97772
+ await access6(join96(base, file.path));
97639
97773
  return true;
97640
97774
  } catch {
97641
97775
  return false;
@@ -97673,7 +97807,7 @@ async function commitProcessedScopes(projectRoot, scopes) {
97673
97807
  const { articles } = await inspectSettledReferences(projectRoot, repoContent, scopes.map((scope2) => scope2.source_ref), settled);
97674
97808
  const { approvedStructureInputHashFor: approvedStructureInputHashFor2 } = await Promise.resolve().then(() => (init_close(), exports_close));
97675
97809
  const input_hash = structure.parsed.input_hash === await approvedStructureInputHashFor2(projectRoot, previous2) ? await approvedStructureInputHashFor2(projectRoot, articles) : structure.parsed.input_hash;
97676
- await atomicWriteFile(join94(projectRoot, structure.path), import_yaml46.default.stringify({ ...structure.parsed, input_hash, articles, processed_scopes: processed }));
97810
+ await atomicWriteFile(join96(projectRoot, structure.path), import_yaml46.default.stringify({ ...structure.parsed, input_hash, articles, processed_scopes: processed }));
97677
97811
  }
97678
97812
  async function invalidateChangedProcessedRequirements(projectRoot, previous2, current3) {
97679
97813
  const targets = new Map(current3.map((requirement2) => [requirement2.id, indexerProtocolDigest(requirement2)]));
@@ -97687,7 +97821,7 @@ async function invalidateChangedProcessedRequirements(projectRoot, previous2, cu
97687
97821
  const retained = scopes.filter((scope2) => !changed.has(scope2.requirement_ref));
97688
97822
  if (retained.length === scopes.length)
97689
97823
  return;
97690
- await atomicWriteFile(join94(projectRoot, structure.path), import_yaml46.default.stringify({ ...structure.parsed, processed_scopes: retained }));
97824
+ await atomicWriteFile(join96(projectRoot, structure.path), import_yaml46.default.stringify({ ...structure.parsed, processed_scopes: retained }));
97691
97825
  }
97692
97826
  async function migrateUnchangedScopeReferences(projectRoot, scopes) {
97693
97827
  const structure = await readKnowledgeStructure(projectRoot);
@@ -97706,7 +97840,7 @@ async function migrateUnchangedScopeReferences(projectRoot, scopes) {
97706
97840
  }
97707
97841
  const { approvedStructureInputHashFor: approvedStructureInputHashFor2 } = await Promise.resolve().then(() => (init_close(), exports_close));
97708
97842
  const input_hash = structure.parsed.input_hash === await approvedStructureInputHashFor2(projectRoot, previous2) ? await approvedStructureInputHashFor2(projectRoot, second.articles) : structure.parsed.input_hash;
97709
- await atomicWriteFile(join94(projectRoot, structure.path), import_yaml46.default.stringify({ ...structure.parsed, input_hash, articles: second.articles }));
97843
+ await atomicWriteFile(join96(projectRoot, structure.path), import_yaml46.default.stringify({ ...structure.parsed, input_hash, articles: second.articles }));
97710
97844
  return previous2.flatMap((article) => article.sections.flatMap((section) => section.references.flatMap((before, index3) => {
97711
97845
  const after = second.articles.find((item) => item.path === article.path).sections.find((item) => item.id === section.id).references[index3];
97712
97846
  return indexerProtocolDigest(before) === indexerProtocolDigest(after) ? [] : [{ article: article.path, section: section.id, before, after }];
@@ -97725,7 +97859,7 @@ var init_processedScopeStorage = __esm(() => {
97725
97859
  });
97726
97860
 
97727
97861
  // src/project/codeAnalysisInput.ts
97728
- import { readFile as readFile79 } from "node:fs/promises";
97862
+ import { readFile as readFile81 } from "node:fs/promises";
97729
97863
  import { relative as relative28, resolve as resolve32 } from "node:path";
97730
97864
  function safeCodeSourcePath(root, normalizedPath) {
97731
97865
  const absolute = resolve32(root, normalizedPath);
@@ -97768,7 +97902,7 @@ function sourceFileSystem(root, tracked, texts, readSource) {
97768
97902
  return {
97769
97903
  readFile: async (path2) => {
97770
97904
  const normalized = assertTrackedFile(path2);
97771
- return contents2.has(normalized) ? contents2.get(normalized) : readSource ? readSource(normalized) : readFile79(safeCodeSourcePath(root, normalized), "utf8");
97905
+ return contents2.has(normalized) ? contents2.get(normalized) : readSource ? readSource(normalized) : readFile81(safeCodeSourcePath(root, normalized), "utf8");
97772
97906
  },
97773
97907
  async readdir(path2) {
97774
97908
  const normalized = normalizedVirtualPath(path2);
@@ -97955,7 +98089,7 @@ __export(exports_approvedRevisionPrograms, {
97955
98089
  });
97956
98090
  import { execFile as execFile16 } from "node:child_process";
97957
98091
  import { promisify as promisify13 } from "node:util";
97958
- import { extname as extname11, join as join95 } from "node:path";
98092
+ import { extname as extname11, join as join97 } from "node:path";
97959
98093
  import { createRequire as createRequire6 } from "node:module";
97960
98094
  import { pathToFileURL } from "node:url";
97961
98095
  async function prepareRevisionProgramBlocks(root, sourceRefs, scopes, references) {
@@ -97971,7 +98105,7 @@ async function prepareRevisionProgramBlocks(root, sourceRefs, scopes, references
97971
98105
  if (entries2.length !== 1)
97972
98106
  throw new TypeError(`Regeneration requires one registered source: ${source2}`);
97973
98107
  const entry = entries2[0];
97974
- const directory = join95(root, entry.materializedAt);
98108
+ const directory = join97(root, entry.materializedAt);
97975
98109
  const paths = [...new Set(references.filter((reference2) => reference2.source_ref === source2).map((reference2) => reference2.locator.path))];
97976
98110
  if (!paths.length)
97977
98111
  continue;
@@ -98157,8 +98291,8 @@ __export(exports_approvedRevision, {
98157
98291
  assertApprovedRevisionBase: () => assertApprovedRevisionBase,
98158
98292
  APPROVED_REVISION_PATH: () => APPROVED_REVISION_PATH
98159
98293
  });
98160
- import { readFile as readFile80, realpath as realpath14, rm as rm23 } from "node:fs/promises";
98161
- import { join as join96, relative as relative29, isAbsolute as isAbsolute16 } from "node:path";
98294
+ import { readFile as readFile82, realpath as realpath14, rm as rm23 } from "node:fs/promises";
98295
+ import { join as join98, relative as relative29, isAbsolute as isAbsolute16 } from "node:path";
98162
98296
  function requestDigest(input) {
98163
98297
  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}/`)));
98164
98298
  const ids = new Set(scopes?.map((scope2) => scope2.requirement_ref));
@@ -98196,7 +98330,7 @@ function revisionCandidateFingerprint(revision, markdown, sections) {
98196
98330
  }
98197
98331
  async function readApprovedRevision(projectRoot) {
98198
98332
  try {
98199
- return parseApprovedRevision(JSON.parse(await readFile80(join96(projectRoot, await revisionStoragePath(projectRoot)), "utf8")));
98333
+ return parseApprovedRevision(JSON.parse(await readFile82(join98(projectRoot, await revisionStoragePath(projectRoot)), "utf8")));
98200
98334
  } catch (error) {
98201
98335
  if (error && typeof error === "object" && "code" in error && error.code === "ENOENT")
98202
98336
  return;
@@ -98255,16 +98389,16 @@ async function resolveApprovedRevisionAuthor(projectRoot, request) {
98255
98389
  }
98256
98390
  async function targetBytes(projectRoot, path2) {
98257
98391
  const project = await realpath14(projectRoot);
98258
- const root = await realpath14(join96(projectRoot, "knowledge"));
98392
+ const root = await realpath14(join98(projectRoot, "knowledge"));
98259
98393
  const rootRelative = relative29(project, root);
98260
98394
  if (isAbsolute16(rootRelative) || rootRelative === ".." || rootRelative.startsWith("../")) {
98261
98395
  throw new TypeError("Approved knowledge directory leaves the Context workspace");
98262
98396
  }
98263
- const target = await realpath14(join96(root, path2));
98397
+ const target = await realpath14(join98(root, path2));
98264
98398
  const rel = relative29(root, target);
98265
98399
  if (isAbsolute16(rel) || rel === ".." || rel.startsWith("../"))
98266
98400
  throw new TypeError("Approved revision target leaves knowledge/");
98267
- return readFile80(target, "utf8");
98401
+ return readFile82(target, "utf8");
98268
98402
  }
98269
98403
  async function assertApprovedRevisionBase(projectRoot, request) {
98270
98404
  let current3;
@@ -98417,7 +98551,7 @@ ${import_yaml47.default.stringify({ ...import_yaml47.default.parse(fields), type
98417
98551
  revision: requestDigest(payload)
98418
98552
  });
98419
98553
  if (input.persist !== false) {
98420
- await atomicWriteFile(join96(input.projectRoot, await revisionStoragePath(input.projectRoot)), `${JSON.stringify(request)}
98554
+ await atomicWriteFile(join98(input.projectRoot, await revisionStoragePath(input.projectRoot)), `${JSON.stringify(request)}
98421
98555
  `);
98422
98556
  markSubmissionState("committed");
98423
98557
  }
@@ -98545,7 +98679,7 @@ async function completeApprovedRevision(input) {
98545
98679
  const { prepareRevisionBatchContinuation: prepareRevisionBatchContinuation3 } = await Promise.resolve().then(() => (init_approvedRevisionBatch(), exports_approvedRevisionBatch));
98546
98680
  const next2 = await prepareRevisionBatchContinuation3(input.projectRoot, request, request.batch_candidates ?? []);
98547
98681
  if (next2 || request.batch_candidates?.length || request.build_pending) {
98548
- await atomicWriteFile(join96(input.projectRoot, await revisionStoragePath(input.projectRoot)), `${JSON.stringify(next2 ?? { ...request, review_ready: true })}
98682
+ await atomicWriteFile(join98(input.projectRoot, await revisionStoragePath(input.projectRoot)), `${JSON.stringify(next2 ?? { ...request, review_ready: true })}
98549
98683
  `);
98550
98684
  markSubmissionState("committed");
98551
98685
  } else {
@@ -98553,10 +98687,10 @@ async function completeApprovedRevision(input) {
98553
98687
  }
98554
98688
  return;
98555
98689
  }
98556
- const current3 = await readFile80(join96(input.projectRoot, await revisionStoragePath(input.projectRoot)), "utf8");
98690
+ const current3 = await readFile82(join98(input.projectRoot, await revisionStoragePath(input.projectRoot)), "utf8");
98557
98691
  let previous2;
98558
98692
  try {
98559
- previous2 = await readFile80(join96(input.projectRoot, CANDIDATE_LEDGER_FILE), "utf8");
98693
+ previous2 = await readFile82(join98(input.projectRoot, CANDIDATE_LEDGER_FILE), "utf8");
98560
98694
  } catch (error) {
98561
98695
  if (!(error && typeof error === "object" && ("code" in error) && error.code === "ENOENT"))
98562
98696
  throw error;
@@ -98651,7 +98785,7 @@ async function advanceApprovedRevision(projectRoot, request, buildPending = fals
98651
98785
  return;
98652
98786
  const { readProductionStage: readProductionStage2 } = await Promise.resolve().then(() => (init_productionStageStore(), exports_productionStageStore));
98653
98787
  if (await readProductionStage2(projectRoot)) {
98654
- await rm23(join96(projectRoot, await revisionStoragePath(projectRoot)), { force: true });
98788
+ await rm23(join98(projectRoot, await revisionStoragePath(projectRoot)), { force: true });
98655
98789
  return;
98656
98790
  }
98657
98791
  const { clearCompletedLifecycle: clearCompletedLifecycle2 } = await Promise.resolve().then(() => (init_lifecycleCleanup(), exports_lifecycleCleanup));
@@ -98755,12 +98889,12 @@ Additional request: ${input.instruction.trim()}` : input.instruction.trim();
98755
98889
  }))
98756
98890
  } : {}
98757
98891
  } };
98758
- const current3 = await readFile80(join96(input.projectRoot, await revisionStoragePath(input.projectRoot)), "utf8");
98892
+ const current3 = await readFile82(join98(input.projectRoot, await revisionStoragePath(input.projectRoot)), "utf8");
98759
98893
  const content3 = `${JSON.stringify({ ...payload, revision: requestDigest(payload) })}
98760
98894
  `;
98761
98895
  let ledger;
98762
98896
  try {
98763
- ledger = await readFile80(join96(input.projectRoot, CANDIDATE_LEDGER_FILE), "utf8");
98897
+ ledger = await readFile82(join98(input.projectRoot, CANDIDATE_LEDGER_FILE), "utf8");
98764
98898
  } catch (error) {
98765
98899
  if (!(error && typeof error === "object" && ("code" in error) && error.code === "ENOENT"))
98766
98900
  throw error;
@@ -98880,8 +99014,8 @@ var init_sourceInputMutation = __esm(() => {
98880
99014
 
98881
99015
  // src/project/documentCapture.ts
98882
99016
  import { createHash as createHash29 } from "node:crypto";
98883
- import { lstat as lstat15, mkdir as mkdir35, readdir as readdir23, readFile as readFile81, rm as rm24, stat as stat10, writeFile as writeFile27 } from "node:fs/promises";
98884
- import { basename as basename7, dirname as dirname43, extname as extname12, join as join97, relative as relative30, resolve as resolve33 } from "node:path";
99017
+ import { lstat as lstat15, mkdir as mkdir35, readdir as readdir23, readFile as readFile83, rm as rm24, stat as stat10, writeFile as writeFile27 } from "node:fs/promises";
99018
+ import { basename as basename7, dirname as dirname43, extname as extname12, join as join99, relative as relative30, resolve as resolve33 } from "node:path";
98885
99019
  function toPosixPath7(path2) {
98886
99020
  return path2.split(/[\\/]+/u).filter((part) => part.length > 0).join("/");
98887
99021
  }
@@ -99019,7 +99153,7 @@ async function walkMarkdownFiles(input) {
99019
99153
  const visit3 = async (dir) => {
99020
99154
  const entries2 = await readdir23(dir, { withFileTypes: true });
99021
99155
  for (const entry of entries2) {
99022
- const absolutePath = join97(dir, entry.name);
99156
+ const absolutePath = join99(dir, entry.name);
99023
99157
  if (entry.isSymbolicLink() && input.rejectSymlinks === true) {
99024
99158
  throw new ContextError(ExitCode.UserError, `file source contains a symbolic link: ${toPosixPath7(relative30(input.localRoot, absolutePath))}`, {
99025
99159
  category: ErrorCategory.UserInputInvalid,
@@ -99049,14 +99183,14 @@ async function walkMarkdownFiles(input) {
99049
99183
  }
99050
99184
  async function writeTextIfChanged(path2, content3) {
99051
99185
  try {
99052
- if (await readFile81(path2, "utf8") === content3)
99186
+ if (await readFile83(path2, "utf8") === content3)
99053
99187
  return;
99054
99188
  } catch {}
99055
99189
  await mkdir35(dirname43(path2), { recursive: true });
99056
99190
  await writeFile27(path2, content3, "utf8");
99057
99191
  }
99058
99192
  function sourceManifestPath(entry) {
99059
- return entry.snapshot?.manifest ?? join97(entry.materializedAt, "manifest.json");
99193
+ return entry.snapshot?.manifest ?? join99(entry.materializedAt, "manifest.json");
99060
99194
  }
99061
99195
  function runtimeError2(message, detail) {
99062
99196
  return new ContextError(ExitCode.UserError, message, {
@@ -99161,7 +99295,7 @@ async function removeEmptySnapshotDirs(root, dir = root) {
99161
99295
  for (const entry of entries2) {
99162
99296
  if (!entry.isDirectory() || entry.name === ".tmp" || entry.name === ".cache")
99163
99297
  continue;
99164
- await removeEmptySnapshotDirs(root, join97(dir, entry.name));
99298
+ await removeEmptySnapshotDirs(root, join99(dir, entry.name));
99165
99299
  }
99166
99300
  if (dir === root)
99167
99301
  return;
@@ -99173,7 +99307,7 @@ async function removeEmptySnapshotDirs(root, dir = root) {
99173
99307
  async function cleanupStaleSnapshotFiles(input) {
99174
99308
  for (const path2 of input.previousPaths) {
99175
99309
  if (!input.currentPaths.has(path2)) {
99176
- await rm24(join97(input.materializedAtAbsPath, path2), { force: true });
99310
+ await rm24(join99(input.materializedAtAbsPath, path2), { force: true });
99177
99311
  }
99178
99312
  }
99179
99313
  await removeEmptySnapshotDirs(input.materializedAtAbsPath);
@@ -99185,7 +99319,7 @@ async function readDocumentFiles(input) {
99185
99319
  for (const file of input.files) {
99186
99320
  let raw;
99187
99321
  try {
99188
- raw = await readFile81(file.absolutePath, "utf8");
99322
+ raw = await readFile83(file.absolutePath, "utf8");
99189
99323
  } catch (error) {
99190
99324
  const message = error instanceof Error ? error.message : String(error);
99191
99325
  throw runtimeError2(`file source ${input.sourceName} document read failed: ${file.snapshotPath}: ${message}`, {
@@ -99386,9 +99520,9 @@ async function runCaptureFilePhaseUnlocked(input) {
99386
99520
  routeMetadata,
99387
99521
  documentSnapshot
99388
99522
  });
99389
- const manifestAbsPath = join97(input.projectRoot, manifestPath);
99523
+ const manifestAbsPath = join99(input.projectRoot, manifestPath);
99390
99524
  const materializedAt = entry.materializedAt;
99391
- const materializedAtAbsPath = join97(input.projectRoot, materializedAt);
99525
+ const materializedAtAbsPath = join99(input.projectRoot, materializedAt);
99392
99526
  const manifestInput = {
99393
99527
  sourceType: "file",
99394
99528
  sourceName: resolved.sourceName,
@@ -99440,13 +99574,13 @@ async function runCaptureFilePhaseUnlocked(input) {
99440
99574
  }));
99441
99575
  try {
99442
99576
  for (const file of snapshotFiles) {
99443
- await writeTextIfChanged(join97(materializedAtAbsPath, file.path), String(file.bytes));
99577
+ await writeTextIfChanged(join99(materializedAtAbsPath, file.path), String(file.bytes));
99444
99578
  }
99445
99579
  for (const file of files.metadata) {
99446
- await writeTextIfChanged(join97(materializedAtAbsPath, file.snapshotPath), routeMetadata.rawByPath.get(file.snapshotPath) ?? "");
99580
+ await writeTextIfChanged(join99(materializedAtAbsPath, file.snapshotPath), routeMetadata.rawByPath.get(file.snapshotPath) ?? "");
99447
99581
  }
99448
99582
  for (const asset of linkedAssets) {
99449
- await writeCaptureAssetIfChanged(join97(materializedAtAbsPath, asset.snapshotPath), asset.bytes);
99583
+ await writeCaptureAssetIfChanged(join99(materializedAtAbsPath, asset.snapshotPath), asset.bytes);
99450
99584
  }
99451
99585
  await writeTextIfChanged(manifestAbsPath, manifestContent);
99452
99586
  await cleanupStaleSnapshotFiles({
@@ -99648,7 +99782,7 @@ var init_entityId = __esm(() => {
99648
99782
  // src/project/reviewShared.ts
99649
99783
  import { createHash as createHash30 } from "node:crypto";
99650
99784
  import { mkdir as mkdir36, writeFile as writeFile28 } from "node:fs/promises";
99651
- import { dirname as dirname44, join as join98 } from "node:path";
99785
+ import { dirname as dirname44, join as join100 } from "node:path";
99652
99786
  function isRecord14(value) {
99653
99787
  return value !== null && typeof value === "object" && !Array.isArray(value);
99654
99788
  }
@@ -99691,7 +99825,7 @@ async function buildApprovedArticleIndex(projectRoot) {
99691
99825
  if (!isApprovedKnowledgeMarkdownPath(rel))
99692
99826
  continue;
99693
99827
  const { absPath, content: content3 } = file;
99694
- const relPath = join98("knowledge", collection, rel);
99828
+ const relPath = join100("knowledge", collection, rel);
99695
99829
  assetReferencesByRelPath.set(relPath, knowledgeAssetReferences({
99696
99830
  pageRelPath: relPath,
99697
99831
  content: content3
@@ -99704,7 +99838,7 @@ async function buildApprovedArticleIndex(projectRoot) {
99704
99838
  continue;
99705
99839
  const frontmatter2 = hydrateApprovedFrontmatter({
99706
99840
  frontmatter: parsed,
99707
- relPath: join98(collection, rel),
99841
+ relPath: join100(collection, rel),
99708
99842
  metadata
99709
99843
  });
99710
99844
  const article = articlesByPath.get(`${collection}/${rel}`);
@@ -99759,8 +99893,8 @@ ${yaml3}
99759
99893
  }
99760
99894
  async function writeReviewActionLog(input) {
99761
99895
  const stamp = new Date().toISOString().replace(/[-:.TZ]/gu, "");
99762
- const relPath = join98(REVIEW_ACTION_ROOT2, `${stamp}-${input.action}-${input.id.replace(/[\\/]+/gu, "_")}.json`);
99763
- const path2 = join98(input.projectRoot, relPath);
99896
+ const relPath = join100(REVIEW_ACTION_ROOT2, `${stamp}-${input.action}-${input.id.replace(/[\\/]+/gu, "_")}.json`);
99897
+ const path2 = join100(input.projectRoot, relPath);
99764
99898
  await mkdir36(dirname44(path2), { recursive: true });
99765
99899
  await writeFile28(path2, `${JSON.stringify({
99766
99900
  action: input.action,
@@ -99793,7 +99927,7 @@ var init_reviewShared = __esm(() => {
99793
99927
  init_knowledgeAssets();
99794
99928
  init_entityId();
99795
99929
  import_yaml48 = __toESM(require_dist(), 1);
99796
- REVIEW_ACTION_ROOT2 = join98(".tmp", "context-runtime", "review-actions");
99930
+ REVIEW_ACTION_ROOT2 = join100(".tmp", "context-runtime", "review-actions");
99797
99931
  });
99798
99932
 
99799
99933
  // src/project/managedDocumentStatus.ts
@@ -99869,7 +100003,7 @@ __export(exports_statusReaders, {
99869
100003
  countFiles: () => countFiles
99870
100004
  });
99871
100005
  import { existsSync as existsSync26, readFileSync as readFileSync9 } from "node:fs";
99872
- import { join as join99 } from "node:path";
100006
+ import { join as join101 } from "node:path";
99873
100007
  async function countFiles(root, predicate) {
99874
100008
  if (!existsSync26(root))
99875
100009
  return 0;
@@ -99878,7 +100012,7 @@ async function countFiles(root, predicate) {
99878
100012
  const entries2 = await readCommandDirectory(dir);
99879
100013
  for (const entry of entries2) {
99880
100014
  const rel = prefix.length === 0 ? entry.name : `${prefix}/${entry.name}`;
99881
- const abs = join99(dir, entry.name);
100015
+ const abs = join101(dir, entry.name);
99882
100016
  if (entry.isDirectory())
99883
100017
  await visit3(abs, rel);
99884
100018
  else if (entry.isFile() && predicate(rel))
@@ -100080,7 +100214,7 @@ async function documentSourceSiteHint(input) {
100080
100214
  });
100081
100215
  }
100082
100216
  function documentSnapshotReadiness(input) {
100083
- const manifestPath = join99(input.projectRoot, input.manifest);
100217
+ const manifestPath = join101(input.projectRoot, input.manifest);
100084
100218
  if (!existsSync26(manifestPath)) {
100085
100219
  return {
100086
100220
  ready: false,
@@ -100161,7 +100295,7 @@ function documentSnapshotReadiness(input) {
100161
100295
  const missingFiles = [
100162
100296
  ...manifest.files.map((file) => file.path),
100163
100297
  ...(manifest.assets ?? []).filter((asset) => asset.content_hash !== undefined).map((asset) => asset.path)
100164
- ].filter((path2) => !existsSync26(join99(input.projectRoot, input.materializedAt, path2)));
100298
+ ].filter((path2) => !existsSync26(join101(input.projectRoot, input.materializedAt, path2)));
100165
100299
  if (missingFiles.length > 0) {
100166
100300
  return {
100167
100301
  ready: false,
@@ -100208,12 +100342,12 @@ var init_statusReaders = __esm(() => {
100208
100342
 
100209
100343
  // src/project/documentCaptureAvailability.ts
100210
100344
  import { createHash as createHash31 } from "node:crypto";
100211
- import { readFile as readFile82, rm as rm25 } from "node:fs/promises";
100212
- import { join as join100 } from "node:path";
100345
+ import { readFile as readFile84, rm as rm25 } from "node:fs/promises";
100346
+ import { join as join102 } from "node:path";
100213
100347
  import { isDeepStrictEqual } from "node:util";
100214
100348
  function receiptPath(root, phaseId) {
100215
100349
  const key = createHash31("sha256").update(phaseId).digest("hex");
100216
- return join100(root, ".tmp/context-runtime/document-acquisition", `${key}.json`);
100350
+ return join102(root, ".tmp/context-runtime/document-acquisition", `${key}.json`);
100217
100351
  }
100218
100352
  async function identity(root, phase) {
100219
100353
  const resolved = await resolveDocumentPhaseSource({ projectRoot: root, phase });
@@ -100248,7 +100382,7 @@ async function runDocumentCaptureWithAvailability(root, phase, capture2) {
100248
100382
  ...Array.isArray(error.detail.access_events) ? { access_events: error.detail.access_events } : {},
100249
100383
  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."
100250
100384
  };
100251
- await applyAtomicFileBatch({ transactionRoot: join100(root, ".tmp/context-runtime/transactions"), writes: [{ path: path2, bytes: `${JSON.stringify({ configuration, warning }, null, 2)}
100385
+ await applyAtomicFileBatch({ transactionRoot: join102(root, ".tmp/context-runtime/transactions"), writes: [{ path: path2, bytes: `${JSON.stringify({ configuration, warning }, null, 2)}
100252
100386
  ` }] });
100253
100387
  return {
100254
100388
  kind: "document.capture.warning",
@@ -100265,7 +100399,7 @@ async function attachDocumentAcquisitionWarnings(root, phases, sources) {
100265
100399
  continue;
100266
100400
  let receipt2;
100267
100401
  try {
100268
- receipt2 = JSON.parse(await readFile82(receiptPath(root, phase.id), "utf8"));
100402
+ receipt2 = JSON.parse(await readFile84(receiptPath(root, phase.id), "utf8"));
100269
100403
  } catch {
100270
100404
  continue;
100271
100405
  }
@@ -101407,8 +101541,8 @@ function pendingDocumentCaptureCommands(input) {
101407
101541
  }
101408
101542
 
101409
101543
  // src/project/productionStageRefresh.ts
101410
- import { readFile as readFile83 } from "node:fs/promises";
101411
- import { join as join101 } from "node:path";
101544
+ import { readFile as readFile85 } from "node:fs/promises";
101545
+ import { join as join103 } from "node:path";
101412
101546
  async function refreshProductionStageSources(projectRoot, stage) {
101413
101547
  const active = activeProductionSources(stage);
101414
101548
  const affected = new Set(stage.gaps.filter((gap) => active.has(gap.scope)).map((gap) => gap.scope));
@@ -101453,14 +101587,14 @@ Restore the authorized source and retry preparation.
101453
101587
  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)
101454
101588
  });
101455
101589
  const directory = productionStageDirectory(stage.id);
101456
- const contents2 = new Map([...sourceMaterials].map(([scope2, content3]) => [join101(directory, productionSourceFile(scope2)), content3]));
101457
- contents2.set(join101(directory, "manifest.json"), `${JSON.stringify(updated)}
101590
+ const contents2 = new Map([...sourceMaterials].map(([scope2, content3]) => [join103(directory, productionSourceFile(scope2)), content3]));
101591
+ contents2.set(join103(directory, "manifest.json"), `${JSON.stringify(updated)}
101458
101592
  `);
101459
101593
  const targets = [];
101460
101594
  for (const [path2, content3] of contents2) {
101461
101595
  let previous2;
101462
101596
  try {
101463
- previous2 = await readFile83(await safeProjectTarget(projectRoot, path2), "utf8");
101597
+ previous2 = await readFile85(await safeProjectTarget(projectRoot, path2), "utf8");
101464
101598
  } catch (error) {
101465
101599
  if (error.code !== "ENOENT")
101466
101600
  throw error;
@@ -101585,7 +101719,7 @@ var init_productionReport = __esm(() => {
101585
101719
  });
101586
101720
 
101587
101721
  // src/project/productionPlanningRoute.ts
101588
- import { join as join102 } from "node:path";
101722
+ import { join as join104 } from "node:path";
101589
101723
  async function productionPlanningRoute(input, stage) {
101590
101724
  const request = stage ? undefined : await productionPlanningRequest(input.projectRoot);
101591
101725
  const present = !!stage || !!request;
@@ -101623,7 +101757,7 @@ async function productionPlanningRoute(input, stage) {
101623
101757
  id: `production/${stage.id}/planning`,
101624
101758
  kind: "context-view",
101625
101759
  media_type: "text/markdown",
101626
- path: join102(input.projectRoot, productionStageDirectory(stage.id), "planning.md"),
101760
+ path: join104(input.projectRoot, productionStageDirectory(stage.id), "planning.md"),
101627
101761
  read_state: "read-required"
101628
101762
  }] : []
101629
101763
  ],
@@ -101651,7 +101785,7 @@ var init_productionPlanningRoute = __esm(() => {
101651
101785
 
101652
101786
  // src/project/productionWorkflowRoute.ts
101653
101787
  import { existsSync as existsSync28 } from "node:fs";
101654
- import { join as join103 } from "node:path";
101788
+ import { join as join105 } from "node:path";
101655
101789
  async function productionWorkflowRoute(input) {
101656
101790
  const stage = await readProductionStage(input.projectRoot);
101657
101791
  if (!stage || !stage.planning_complete)
@@ -101669,7 +101803,7 @@ async function productionWorkflowRoute(input) {
101669
101803
  const selected = new Set(dispatch2.batches.flatMap((batch) => batch.tasks));
101670
101804
  const context = { workspace: input.projectRoot, authorities: [...input.authorities], facts: { production: {
101671
101805
  report_approved: stage.report_approved,
101672
- prepared: !dispatch2.batches.length || existsSync28(join103(input.projectRoot, directory, "stage.md")) && stage.tasks.filter((task) => selected.has(task.id)).every((task) => task.status === "issued"),
101806
+ prepared: !dispatch2.batches.length || existsSync28(join105(input.projectRoot, directory, "stage.md")) && stage.tasks.filter((task) => selected.has(task.id)).every((task) => task.status === "issued"),
101673
101807
  writing_complete: dispatch2.batches.length === 0,
101674
101808
  complete: dispatch2.state === "ended",
101675
101809
  review_clear: rejected.length === 0,
@@ -101686,7 +101820,7 @@ async function productionWorkflowRoute(input) {
101686
101820
  const resolved = await resolveRoute(provider, "indexer", "production", primary.routeId, context, evaluated.evaluation.revision);
101687
101821
  const report = resolved.node === "confirm-production-report";
101688
101822
  if (report)
101689
- await writeProductionProjection(input.projectRoot, join103(directory, "plan.md"), productionPlanMarkdown(stage));
101823
+ await writeProductionProjection(input.projectRoot, join105(directory, "plan.md"), productionPlanMarkdown(stage));
101690
101824
  const prepare = resolved.node === "prepare-production-stage";
101691
101825
  const writing = resolved.node === "work-production-stage";
101692
101826
  const repair = resolved.node === "repair-production-articles";
@@ -101701,7 +101835,7 @@ async function productionWorkflowRoute(input) {
101701
101835
  id: `production/${stage.id}/${report ? "plan" : "stage"}`,
101702
101836
  kind: "context-view",
101703
101837
  media_type: "text/markdown",
101704
- path: join103(input.projectRoot, directory, path3),
101838
+ path: join105(input.projectRoot, directory, path3),
101705
101839
  read_state: "read-required"
101706
101840
  });
101707
101841
  if (report || writing)
@@ -101712,18 +101846,18 @@ async function productionWorkflowRoute(input) {
101712
101846
  id: `production/${stage.id}/planning`,
101713
101847
  kind: "context-view",
101714
101848
  media_type: "text/markdown",
101715
- path: join103(input.projectRoot, directory, "planning.md"),
101849
+ path: join105(input.projectRoot, directory, "planning.md"),
101716
101850
  read_state: "read-required"
101717
101851
  });
101718
101852
  }
101719
101853
  if (repair) {
101720
- await writeProductionProjection(input.projectRoot, join103(directory, "repair.md"), [
101854
+ await writeProductionProjection(input.projectRoot, join105(directory, "repair.md"), [
101721
101855
  "# Revise rejected articles",
101722
101856
  "",
101723
101857
  ...rejected.map((candidate) => `- ${candidate.path}: ${candidate.review.title}`),
101724
101858
  "",
101725
101859
  "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.",
101726
- `Submit the plan amendment to ${path2} using ${join103(directory, "planning.schema.json")}. Keep accepted task identities unchanged; the CLI assigns the revision tasks and preserves article identities.`,
101860
+ `Submit the plan amendment to ${path2} using ${join105(directory, "planning.schema.json")}. Keep accepted task identities unchanged; the CLI assigns the revision tasks and preserves article identities.`,
101727
101861
  "Once issued, repair the affected sections through the existing edits submission. Unchanged sections and references do not need resubmission.",
101728
101862
  ""
101729
101863
  ].join(`
@@ -101732,7 +101866,7 @@ async function productionWorkflowRoute(input) {
101732
101866
  id: `production/${stage.id}/repair`,
101733
101867
  kind: "context-view",
101734
101868
  media_type: "text/markdown",
101735
- path: join103(input.projectRoot, directory, "repair.md"),
101869
+ path: join105(input.projectRoot, directory, "repair.md"),
101736
101870
  read_state: "read-required"
101737
101871
  });
101738
101872
  }
@@ -101831,7 +101965,7 @@ var init_knowledgeMaintenanceRoute = __esm(() => {
101831
101965
  });
101832
101966
 
101833
101967
  // src/project/approvedRevisionContext.ts
101834
- import { readFile as readFile84 } from "node:fs/promises";
101968
+ import { readFile as readFile86 } from "node:fs/promises";
101835
101969
  async function approvedRevisionContext(root, target) {
101836
101970
  const registry2 = await readProductionRequirements(root);
101837
101971
  const requirements = registry2.requirements.filter((requirement2) => requirement2.target_scope.targets.some((source2) => target.source_refs.some((ref2) => repoContentScopeMatches(source2.source_ref, ref2) || ref2.startsWith(`${source2.source_ref}#`) || ref2.startsWith(`${source2.source_ref}/`))));
@@ -101842,7 +101976,7 @@ async function approvedRevisionContext(root, target) {
101842
101976
  const type = source_ref.slice(0, separator);
101843
101977
  const name3 = source_ref.slice(separator + 1);
101844
101978
  const path2 = await assertManagedDocumentPath(root, type, name3);
101845
- const markdown = await readFile84(path2, "utf8");
101979
+ const markdown = await readFile86(path2, "utf8");
101846
101980
  const changes = type === "sessions" ? readSessionChanges(markdown) : undefined;
101847
101981
  return {
101848
101982
  source_ref,
@@ -101874,14 +102008,14 @@ __export(exports_approvedRevisionRoute, {
101874
102008
  buildApprovedRevisionRoute: () => buildApprovedRevisionRoute
101875
102009
  });
101876
102010
  import { existsSync as existsSync29 } from "node:fs";
101877
- import { join as join104 } from "node:path";
102011
+ import { join as join106 } from "node:path";
101878
102012
  async function sourceUpdateRouteInput(projectRoot, update) {
101879
102013
  const { reference_evidence: evidence, ...rest } = update;
101880
102014
  if (!evidence?.length)
101881
102015
  return rest;
101882
102016
  const file = `.tmp/context-runtime/source-update/evidence-${update.revision.replace(/^sha256:/u, "")}.json`;
101883
- if (!existsSync29(join104(projectRoot, file)))
101884
- await atomicWriteFile(join104(projectRoot, file), `${JSON.stringify(evidence, null, 2)}
102017
+ if (!existsSync29(join106(projectRoot, file)))
102018
+ await atomicWriteFile(join106(projectRoot, file), `${JSON.stringify(evidence, null, 2)}
101885
102019
  `);
101886
102020
  return { ...rest, reference_evidence_file: file, reference_evidence_count: evidence.length };
101887
102021
  }
@@ -102082,7 +102216,7 @@ __export(exports_status, {
102082
102216
  collectProjectStatusSnapshot: () => collectProjectStatusSnapshot,
102083
102217
  collectProjectStatus: () => collectProjectStatus
102084
102218
  });
102085
- import { join as join105 } from "node:path";
102219
+ import { join as join107 } from "node:path";
102086
102220
  async function recordWorkflowEvaluation(projectRoot, workflow) {
102087
102221
  const current3 = workflow.current;
102088
102222
  await recordAgentGraphEvaluation({
@@ -102134,7 +102268,7 @@ async function collectProjectStatusSnapshotInternal(projectRoot, options = {}) {
102134
102268
  const navigationOnly = !maintenance && !localRevision && !localUpdate && !localRollback && taskPreparation === "cleared" && !production && phaseStatus.projectEntryValid && await navigationOnlyChange(projectRoot, phaseStatus.packages);
102135
102269
  const deferDeliveryChecks = !maintenance && !localRevision && !localUpdate && !localRollback && !navigationOnly && (taskPreparation === "cleared" && !production || !!authoring);
102136
102270
  const collectionsWithPages = new Set;
102137
- const approvedPages = await countFiles(join105(projectRoot, "knowledge"), (rel) => {
102271
+ const approvedPages = await countFiles(join107(projectRoot, "knowledge"), (rel) => {
102138
102272
  if (!isApprovedKnowledgeMarkdownPath(rel) || rel.startsWith("assets/"))
102139
102273
  return false;
102140
102274
  collectionsWithPages.add(rel.split("/")[0]);
@@ -102142,7 +102276,7 @@ async function collectProjectStatusSnapshotInternal(projectRoot, options = {}) {
102142
102276
  });
102143
102277
  const approvedCollections = KNOWLEDGE_COLLECTIONS.filter((collection) => collectionsWithPages.has(collection));
102144
102278
  const closeStatus = deferDeliveryChecks ? { state: "not-checked", diagnostics: [] } : await readCloseStatus(projectRoot);
102145
- const distFiles = await countFiles(join105(projectRoot, "dist"), () => true);
102279
+ const distFiles = await countFiles(join107(projectRoot, "dist"), () => true);
102146
102280
  const verifyStatus = !deferDeliveryChecks && draftStatus.diagnostics.length === 0 ? await readVerifyStatus(projectRoot) : { issues: [], diagnostics: [] };
102147
102281
  const productionCapture = !localRevision && production ? productionCaptureDocuments(production, documentSources) : undefined;
102148
102282
  const revisionDocuments = localRevision ? documentSources.filter((source2) => localRevision.target.source_refs.some((ref2) => documentSourceMatches(source2, ref2))) : productionCapture?.documents ?? documentSources;
@@ -102625,14 +102759,14 @@ __export(exports_workflowRouteOutput, {
102625
102759
  });
102626
102760
  import { Buffer as Buffer4 } from "node:buffer";
102627
102761
  import { createHash as createHash32 } from "node:crypto";
102628
- import { join as join106 } from "node:path";
102762
+ import { join as join108 } from "node:path";
102629
102763
  async function workflowRouteOutput(projectRoot, route, options = {}) {
102630
102764
  if (!route)
102631
102765
  return null;
102632
102766
  const body = `${JSON.stringify(route, null, 2)}
102633
102767
  `;
102634
102768
  const digest7 = createHash32("sha256").update(body).digest("hex");
102635
- const file = join106(projectRoot, ".tmp/context-runtime/routes", `${digest7}.json`);
102769
+ const file = join108(projectRoot, ".tmp/context-runtime/routes", `${digest7}.json`);
102636
102770
  await atomicWriteFile(file, body);
102637
102771
  const routeBytes = Buffer4.byteLength(body);
102638
102772
  const inlineByteLimit = Math.max(0, Math.min(WORKFLOW_ROUTE_INLINE_BYTE_LIMIT, options.inlineByteLimit ?? WORKFLOW_ROUTE_INLINE_BYTE_LIMIT));
@@ -102654,7 +102788,7 @@ async function workflowRunResultFile(projectRoot, result) {
102654
102788
  const body = `${JSON.stringify(result, null, 2)}
102655
102789
  `;
102656
102790
  const digest7 = createHash32("sha256").update(body).digest("hex");
102657
- const file = join106(projectRoot, ".tmp/context-runtime/action-results", `${digest7}.run.json`);
102791
+ const file = join108(projectRoot, ".tmp/context-runtime/action-results", `${digest7}.run.json`);
102658
102792
  await atomicWriteFile(file, body);
102659
102793
  return file;
102660
102794
  }
@@ -102673,15 +102807,15 @@ __export(exports_originalRevisions, {
102673
102807
  originalRevisionReviewHtml: () => originalRevisionReviewHtml,
102674
102808
  ORIGINAL_REVISION_PROPOSALS_PATH: () => ORIGINAL_REVISION_PROPOSALS_PATH
102675
102809
  });
102676
- import { readFile as readFile85, rm as rm26 } from "node:fs/promises";
102677
- import { join as join107 } from "node:path";
102810
+ import { readFile as readFile87, rm as rm26 } from "node:fs/promises";
102811
+ import { join as join109 } from "node:path";
102678
102812
  function inputError(message, reasonCode) {
102679
102813
  return new ContextError(ExitCode.UserError, message, { category: ErrorCategory.UserInputInvalid, reason_code: reasonCode });
102680
102814
  }
102681
102815
  async function readOriginalRevisionProposals(projectRoot) {
102682
102816
  let content3;
102683
102817
  try {
102684
- content3 = await readFile85(join107(projectRoot, ORIGINAL_REVISION_PROPOSALS_PATH), "utf8");
102818
+ content3 = await readFile87(join109(projectRoot, ORIGINAL_REVISION_PROPOSALS_PATH), "utf8");
102685
102819
  } catch (error) {
102686
102820
  if (error.code === "ENOENT")
102687
102821
  return [];
@@ -102694,7 +102828,7 @@ async function readOriginalRevisionProposals(projectRoot) {
102694
102828
  return parsed.data.revisions;
102695
102829
  }
102696
102830
  async function writeProposals(projectRoot, proposals) {
102697
- const path2 = join107(projectRoot, ORIGINAL_REVISION_PROPOSALS_PATH);
102831
+ const path2 = join109(projectRoot, ORIGINAL_REVISION_PROPOSALS_PATH);
102698
102832
  if (proposals.length === 0) {
102699
102833
  await rm26(path2, { force: true });
102700
102834
  return;
@@ -102792,54 +102926,6 @@ var init_originalRevisions = __esm(() => {
102792
102926
  storedProposalsSchema = exports_external.object({ revisions: exports_external.array(storedProposalSchema).default([]) }).strict();
102793
102927
  });
102794
102928
 
102795
- // src/project/sdkAlignment.ts
102796
- var exports_sdkAlignment = {};
102797
- __export(exports_sdkAlignment, {
102798
- inspectSdkAlignment: () => inspectSdkAlignment
102799
- });
102800
- import { readFile as readFile86 } from "node:fs/promises";
102801
- import { join as join108 } from "node:path";
102802
- function core3(version3) {
102803
- const match = /^(\d+)\.(\d+)\.(\d+)$/u.exec(version3?.trim() ?? "");
102804
- return match ? [Number(match[1]), Number(match[2]), Number(match[3])] : null;
102805
- }
102806
- function older(left, right) {
102807
- for (let index3 = 0;index3 < 3; index3++)
102808
- if (left[index3] !== right[index3])
102809
- return left[index3] < right[index3];
102810
- return false;
102811
- }
102812
- async function readJson(path2) {
102813
- try {
102814
- return JSON.parse(await readFile86(path2, "utf8"));
102815
- } catch {
102816
- return null;
102817
- }
102818
- }
102819
- async function inspectSdkAlignment(projectRoot, cliVersion = readCurrentPackageVersion()) {
102820
- const manifest = await readJson(join108(projectRoot, "package.json"));
102821
- const dependencies = { ...manifest?.devDependencies, ...manifest?.dependencies };
102822
- const pinned = dependencies[SDK_PACKAGE];
102823
- const installed = (await readJson(join108(projectRoot, "node_modules", ...SDK_PACKAGE.split("/"), "package.json")))?.version;
102824
- const cli = core3(cliVersion);
102825
- const target = core3(pinned);
102826
- if (pinned === undefined || cli === null || target === null || target[0] !== cli[0])
102827
- return;
102828
- const installedCore = core3(typeof installed === "string" ? installed : null);
102829
- if (!older(target, cli) && (installedCore === null || !older(installedCore, cli)))
102830
- return;
102831
- return {
102832
- workspace_sdk: { pinned, installed: typeof installed === "string" ? installed : null },
102833
- cli: cliVersion,
102834
- message: `The workspace pins ${SDK_PACKAGE} ${pinned}, older than the running CLI ${cliVersion}; its documentation and registry parsing lag behind the CLI.`,
102835
- instruction: `Set ${SDK_PACKAGE} in package.json to ${cliVersion}, install with the workspace package manager (bun install for bun.lock) and commit package.json together with the lock file in the next delivery. A routine update without content changes may deliver this upgrade alone.`
102836
- };
102837
- }
102838
- var SDK_PACKAGE = "@c4a/context";
102839
- var init_sdkAlignment = __esm(() => {
102840
- init_workspace();
102841
- });
102842
-
102843
102929
  // src/project/statusCommand.ts
102844
102930
  async function projectStatusSummary(status, projectRoot) {
102845
102931
  const { observeKnowledgeMaintenance: observeKnowledgeMaintenance2 } = await Promise.resolve().then(() => (init_knowledgeMaintenance(), exports_knowledgeMaintenance));
@@ -103012,7 +103098,7 @@ __export(exports_articleRetirement, {
103012
103098
  batchDraftReader: () => batchDraftReader,
103013
103099
  articleRetirementSchema: () => articleRetirementSchema
103014
103100
  });
103015
- import { readFile as readFile88, readdir as readdir25 } from "node:fs/promises";
103101
+ import { readFile as readFile89, readdir as readdir25 } from "node:fs/promises";
103016
103102
  import { posix as posix14 } from "node:path";
103017
103103
  function rebuildInput(revision) {
103018
103104
  return JSON.stringify({ id: `retirement-${revision.slice(7)}`, operation: "rebuild", timing: "priority", targets: [] });
@@ -103033,7 +103119,7 @@ function invalid2(reason, message, details = {}) {
103033
103119
  }
103034
103120
  async function text11(root2, path3) {
103035
103121
  try {
103036
- return await readFile88(await safeProjectTarget(root2, path3), "utf8");
103122
+ return await readFile89(await safeProjectTarget(root2, path3), "utf8");
103037
103123
  } catch (error) {
103038
103124
  if (error.code === "ENOENT")
103039
103125
  return;
@@ -108092,7 +108178,7 @@ var init_larkResourceCommand = __esm(() => {
108092
108178
 
108093
108179
  // src/lib/larkMediaDownload.ts
108094
108180
  import { readdir as readdir26, rm as rm27 } from "node:fs/promises";
108095
- import { join as join116 } from "node:path";
108181
+ import { join as join117 } from "node:path";
108096
108182
  async function downloadLarkMedia(input) {
108097
108183
  const shared = ["--as", input.identity, "--token", input.token, "--output", "./resource", "--format", "json"];
108098
108184
  try {
@@ -108102,7 +108188,7 @@ async function downloadLarkMedia(input) {
108102
108188
  if (!input.allowPreview || !isLarkResourcePermissionDenied(error))
108103
108189
  throw error;
108104
108190
  for (const entry of await readdir26(input.cwd))
108105
- await rm27(join116(input.cwd, entry), { recursive: true, force: true });
108191
+ await rm27(join117(input.cwd, entry), { recursive: true, force: true });
108106
108192
  await runLarkResourceCommand(input.runner, ["docs", "+media-preview", ...shared], { cwd: input.cwd });
108107
108193
  return "preview";
108108
108194
  }
@@ -108112,9 +108198,9 @@ var init_larkMediaDownload = __esm(() => {
108112
108198
  });
108113
108199
 
108114
108200
  // src/lib/larkWhiteboardExport.ts
108115
- import { mkdtemp as mkdtemp5, readFile as readFile94, rm as rm28 } from "node:fs/promises";
108201
+ import { mkdtemp as mkdtemp5, readFile as readFile95, rm as rm28 } from "node:fs/promises";
108116
108202
  import { tmpdir as tmpdir2 } from "node:os";
108117
- import { join as join117 } from "node:path";
108203
+ import { join as join118 } from "node:path";
108118
108204
  function stableJson2(value) {
108119
108205
  if (value === undefined)
108120
108206
  return "null";
@@ -108144,7 +108230,7 @@ function canonicalWhiteboardPayload(value) {
108144
108230
  };
108145
108231
  }
108146
108232
  async function exportLarkWhiteboardRaw(runner2, identity2, token) {
108147
- const tempRoot = await mkdtemp5(join117(tmpdir2(), "context-lark-whiteboard-"));
108233
+ const tempRoot = await mkdtemp5(join118(tmpdir2(), "context-lark-whiteboard-"));
108148
108234
  try {
108149
108235
  await runLarkResourceCommand(runner2, [
108150
108236
  "whiteboard",
@@ -108161,7 +108247,7 @@ async function exportLarkWhiteboardRaw(runner2, identity2, token) {
108161
108247
  "--format",
108162
108248
  "json"
108163
108249
  ], { cwd: tempRoot });
108164
- const rawPayload = JSON.parse(await readFile94(join117(tempRoot, "raw.json"), "utf8"));
108250
+ const rawPayload = JSON.parse(await readFile95(join118(tempRoot, "raw.json"), "utf8"));
108165
108251
  return Buffer.from(`${stableJson2(canonicalWhiteboardPayload(rawPayload))}
108166
108252
  `, "utf8");
108167
108253
  } finally {
@@ -108200,8 +108286,8 @@ var init_larkImagePolicy = __esm(() => {
108200
108286
 
108201
108287
  // src/lib/larkResourceMaterialization.ts
108202
108288
  import { createHash as createHash36 } from "node:crypto";
108203
- import { mkdtemp as mkdtemp6, readFile as readFile95, readdir as readdir27, rm as rm29 } from "node:fs/promises";
108204
- import { extname as extname13, join as join118 } from "node:path";
108289
+ import { mkdtemp as mkdtemp6, readFile as readFile96, readdir as readdir27, rm as rm29 } from "node:fs/promises";
108290
+ import { extname as extname13, join as join119 } from "node:path";
108205
108291
  import { tmpdir as tmpdir3 } from "node:os";
108206
108292
  function countByKind(items, status) {
108207
108293
  const counts2 = new Map;
@@ -108306,17 +108392,17 @@ function findBooleanField(value, name3) {
108306
108392
  }
108307
108393
  async function downloadedFile(input) {
108308
108394
  if (input.localPath !== undefined) {
108309
- const bytes = await readFile95(input.localPath);
108395
+ const bytes = await readFile96(input.localPath);
108310
108396
  return { path: input.localPath, bytes, mediaType: mediaTypeFor(input.localPath, bytes), representation: "original" };
108311
108397
  }
108312
- const tempRoot = await mkdtemp6(join118(tmpdir3(), "context-lark-resource-"));
108398
+ const tempRoot = await mkdtemp6(join119(tmpdir3(), "context-lark-resource-"));
108313
108399
  try {
108314
108400
  const representation = await downloadLarkMedia({ ...input, cwd: tempRoot });
108315
108401
  const entries2 = (await readdir27(tempRoot, { withFileTypes: true })).filter((entry) => entry.isFile());
108316
108402
  if (entries2.length !== 1)
108317
108403
  throw new Error(`media download produced ${entries2.length} files, expected exactly one`);
108318
108404
  const path3 = entries2[0]?.name ?? "resource.bin";
108319
- const bytes = await readFile95(join118(tempRoot, path3));
108405
+ const bytes = await readFile96(join119(tempRoot, path3));
108320
108406
  return { path: path3, bytes, mediaType: mediaTypeFor(path3, bytes), representation };
108321
108407
  } finally {
108322
108408
  await rm29(tempRoot, { recursive: true, force: true });
@@ -108388,9 +108474,9 @@ async function sheetMaterialization(resource, runner2, identity2) {
108388
108474
  const sheetId = resource.attributes["sheet-id"];
108389
108475
  if (token === undefined || sheetId === undefined)
108390
108476
  throw new Error("embedded Sheet requires token and sheet-id");
108391
- const tempRoot = await mkdtemp6(join118(tmpdir3(), "context-lark-sheet-"));
108477
+ const tempRoot = await mkdtemp6(join119(tmpdir3(), "context-lark-sheet-"));
108392
108478
  try {
108393
- const outputPath = join118(tempRoot, "sheet.json");
108479
+ const outputPath = join119(tempRoot, "sheet.json");
108394
108480
  const stdout = await runLarkResourceCommand(runner2, [
108395
108481
  "sheets",
108396
108482
  "+csv-get",
@@ -108410,7 +108496,7 @@ async function sheetMaterialization(resource, runner2, identity2) {
108410
108496
  if (findBooleanField(receipt2, "truncated") === true || findBooleanField(receipt2, "complete") === false) {
108411
108497
  throw new Error("embedded Sheet read was truncated");
108412
108498
  }
108413
- const payload = JSON.parse(await readFile95(outputPath, "utf8"));
108499
+ const payload = JSON.parse(await readFile96(outputPath, "utf8"));
108414
108500
  const csv = findStringField(payload, new Set(["annotated_csv", "csv", "content", "text"]));
108415
108501
  if (csv === undefined)
108416
108502
  throw new Error("embedded Sheet response has no CSV payload");
@@ -109581,8 +109667,8 @@ var init_sensitiveSourceLiteral = __esm(() => {
109581
109667
 
109582
109668
  // src/project/larkSnapshotBundle.ts
109583
109669
  import { createHash as createHash37 } from "node:crypto";
109584
- import { lstat as lstat16, mkdir as mkdir39, readFile as readFile96, realpath as realpath15, rename as rename10, writeFile as writeFile30 } from "node:fs/promises";
109585
- import { basename as basename9, dirname as dirname47, isAbsolute as isAbsolute19, join as join119, relative as relative31, resolve as resolve37, sep as sep10 } from "node:path";
109670
+ import { lstat as lstat16, mkdir as mkdir39, readFile as readFile97, realpath as realpath15, rename as rename10, writeFile as writeFile30 } from "node:fs/promises";
109671
+ import { basename as basename9, dirname as dirname47, isAbsolute as isAbsolute19, join as join120, relative as relative31, resolve as resolve37, sep as sep10 } from "node:path";
109586
109672
  import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
109587
109673
  function normalizedSnapshotResourcePolicy(policy) {
109588
109674
  return { ...policy, images: policy.images ?? "bundle", gifs: policy.gifs ?? "bundle" };
@@ -109623,13 +109709,13 @@ async function readFileEntry(root2, entry) {
109623
109709
  const parts = safePath(entry.path).split("/");
109624
109710
  let current3 = root2;
109625
109711
  for (const [index3, part] of parts.entries()) {
109626
- current3 = join119(current3, part);
109712
+ current3 = join120(current3, part);
109627
109713
  const stat11 = await lstat16(current3);
109628
109714
  if (stat11.isSymbolicLink() || (index3 === parts.length - 1 ? !stat11.isFile() : !stat11.isDirectory())) {
109629
109715
  throw larkSnapshotError(`Snapshot entry is not a regular file: ${entry.path}`, "path-invalid");
109630
109716
  }
109631
109717
  }
109632
- const bytes = await readFile96(current3);
109718
+ const bytes = await readFile97(current3);
109633
109719
  if (digest7(bytes) !== entry.sha256)
109634
109720
  throw larkSnapshotError(`Snapshot content changed: ${entry.path}`, "digest-mismatch");
109635
109721
  return bytes;
@@ -109692,13 +109778,13 @@ async function writeLarkSnapshotBundle(input) {
109692
109778
  };
109693
109779
  schema2.parse(manifest);
109694
109780
  for (const [path3, bytes] of files) {
109695
- await mkdir39(dirname47(join119(root2, path3)), { recursive: true });
109696
- await writeFile30(join119(root2, path3), bytes, { flag: "wx", mode: 384 });
109781
+ await mkdir39(dirname47(join120(root2, path3)), { recursive: true });
109782
+ await writeFile30(join120(root2, path3), bytes, { flag: "wx", mode: 384 });
109697
109783
  }
109698
109784
  await validateBundle(root2, manifest);
109699
- await writeFile30(join119(root2, `${FILE2}.pending`), `${JSON.stringify(manifest, null, 2)}
109785
+ await writeFile30(join120(root2, `${FILE2}.pending`), `${JSON.stringify(manifest, null, 2)}
109700
109786
  `, { flag: "wx", mode: 384 });
109701
- await rename10(join119(root2, `${FILE2}.pending`), join119(root2, FILE2));
109787
+ await rename10(join120(root2, `${FILE2}.pending`), join120(root2, FILE2));
109702
109788
  return manifest;
109703
109789
  }
109704
109790
  async function validateBundle(root2, manifest) {
@@ -109772,11 +109858,11 @@ async function validateBundle(root2, manifest) {
109772
109858
  async function readLarkSnapshotBundle(directory, target) {
109773
109859
  try {
109774
109860
  const root2 = await assertSnapshotDirectory(directory);
109775
- const path3 = join119(root2, FILE2);
109861
+ const path3 = join120(root2, FILE2);
109776
109862
  const stat11 = await lstat16(path3);
109777
109863
  if (stat11.isSymbolicLink() || !stat11.isFile())
109778
109864
  throw larkSnapshotError("Snapshot receipt must be a regular file", "path-invalid");
109779
- const manifest = schema2.parse(JSON.parse(await readFile96(path3, "utf8")));
109865
+ const manifest = schema2.parse(JSON.parse(await readFile97(path3, "utf8")));
109780
109866
  assertTarget(manifest.url, target);
109781
109867
  return await validateBundle(root2, manifest);
109782
109868
  } catch (error) {
@@ -109800,8 +109886,8 @@ async function reserveSnapshotDirectory(directory, workspaceRoot) {
109800
109886
  ancestor = dirname47(ancestor);
109801
109887
  }
109802
109888
  }
109803
- const parent2 = join119(ancestor, ...missing2);
109804
- const output = join119(parent2, basename9(requested));
109889
+ const parent2 = join120(ancestor, ...missing2);
109890
+ const output = join120(parent2, basename9(requested));
109805
109891
  const { findContextProjectRoot: findContextProjectRoot2 } = await Promise.resolve().then(() => (init_workspace(), exports_workspace));
109806
109892
  const owner = findContextProjectRoot2(parent2)?.projectRoot ?? workspaceRoot;
109807
109893
  if (owner !== undefined) {
@@ -109875,8 +109961,8 @@ var init_larkSnapshotBundle = __esm(() => {
109875
109961
 
109876
109962
  // src/project/documentCaptureLark.ts
109877
109963
  import { createHash as createHash38 } from "node:crypto";
109878
- import { readdir as readdir28, readFile as readFile97 } from "node:fs/promises";
109879
- import { basename as basename10, extname as extname14, join as join120 } from "node:path";
109964
+ import { readdir as readdir28, readFile as readFile98 } from "node:fs/promises";
109965
+ import { basename as basename10, extname as extname14, join as join121 } from "node:path";
109880
109966
  function titleFromMarkdown2(markdown, fallbackPath) {
109881
109967
  const heading2 = markdown.split(`
109882
109968
  `).find((line) => /^#\s+\S/u.test(line));
@@ -109895,7 +109981,7 @@ function countLines3(markdown) {
109895
109981
  }
109896
109982
  async function fileContentMatches(path3, content3) {
109897
109983
  try {
109898
- const current3 = await readFile97(path3);
109984
+ const current3 = await readFile98(path3);
109899
109985
  const expected = typeof content3 === "string" ? Buffer.from(content3, "utf8") : Buffer.from(content3);
109900
109986
  return current3.equals(expected);
109901
109987
  } catch {
@@ -109903,7 +109989,7 @@ async function fileContentMatches(path3, content3) {
109903
109989
  }
109904
109990
  }
109905
109991
  function sourceManifestPath2(entry) {
109906
- return entry.snapshot?.manifest ?? join120(entry.materializedAt, "manifest.json");
109992
+ return entry.snapshot?.manifest ?? join121(entry.materializedAt, "manifest.json");
109907
109993
  }
109908
109994
  function larkRuntimeError(message, detail) {
109909
109995
  return new ContextError(ExitCode.ExternalToolError, message, {
@@ -110036,7 +110122,7 @@ function assetManifestEntry(asset, assetRoot) {
110036
110122
  };
110037
110123
  }
110038
110124
  async function listSnapshotAssetFiles(root2, assetRoot) {
110039
- const assetsRoot = join120(root2, assetRoot);
110125
+ const assetsRoot = join121(root2, assetRoot);
110040
110126
  const files = [];
110041
110127
  const visit4 = async (dir, prefix = assetRoot) => {
110042
110128
  let entries2;
@@ -110049,7 +110135,7 @@ async function listSnapshotAssetFiles(root2, assetRoot) {
110049
110135
  }
110050
110136
  for (const entry of entries2) {
110051
110137
  const relPath = `${prefix}/${entry.name}`;
110052
- const absolutePath = join120(dir, entry.name);
110138
+ const absolutePath = join121(dir, entry.name);
110053
110139
  if (entry.isDirectory()) {
110054
110140
  await visit4(absolutePath, relPath);
110055
110141
  continue;
@@ -110064,7 +110150,7 @@ async function listSnapshotAssetFiles(root2, assetRoot) {
110064
110150
  }
110065
110151
  async function staleSnapshotAssetPaths(input) {
110066
110152
  const existingPaths = await listSnapshotAssetFiles(input.materializedAtAbsPath, input.assetRoot);
110067
- return existingPaths.filter((path3) => !input.currentPaths.has(path3)).map((path3) => join120(input.materializedAtAbsPath, path3));
110153
+ return existingPaths.filter((path3) => !input.currentPaths.has(path3)).map((path3) => join121(input.materializedAtAbsPath, path3));
110068
110154
  }
110069
110155
  function normalizeLarkError(error, sourceName) {
110070
110156
  if (error instanceof ContextError)
@@ -110128,7 +110214,7 @@ async function runCaptureLarkPhaseUnlocked(input) {
110128
110214
  const target = larkTarget(entry);
110129
110215
  const manifestPath = sourceManifestPath2(entry);
110130
110216
  const materializedAt = entry.materializedAt;
110131
- const materializedAtAbsPath = join120(input.projectRoot, materializedAt);
110217
+ const materializedAtAbsPath = join121(input.projectRoot, materializedAt);
110132
110218
  const { current: currentManifestFile, previous: previousManifest, recovery } = await readDocumentManifestForCapture({
110133
110219
  projectRoot: input.projectRoot,
110134
110220
  manifestPath,
@@ -110275,7 +110361,7 @@ async function runCaptureLarkPhaseUnlocked(input) {
110275
110361
  title: title2,
110276
110362
  locator
110277
110363
  }];
110278
- const manifestAbsPath = join120(input.projectRoot, manifestPath);
110364
+ const manifestAbsPath = join121(input.projectRoot, manifestPath);
110279
110365
  const manifest = createDocumentSnapshotManifest({
110280
110366
  sourceType: "lark",
110281
110367
  sourceName: resolved.sourceName,
@@ -110305,13 +110391,13 @@ async function runCaptureLarkPhaseUnlocked(input) {
110305
110391
  const cacheDiagnostics = [];
110306
110392
  try {
110307
110393
  const requestedWrites = [{
110308
- path: join120(materializedAtAbsPath, documentPath),
110394
+ path: join121(materializedAtAbsPath, documentPath),
110309
110395
  bytes: normalized
110310
110396
  }];
110311
110397
  for (const asset of assets) {
110312
110398
  if (asset.bytes !== undefined) {
110313
110399
  requestedWrites.push({
110314
- path: join120(materializedAtAbsPath, asset.entry.path),
110400
+ path: join121(materializedAtAbsPath, asset.entry.path),
110315
110401
  bytes: asset.bytes
110316
110402
  });
110317
110403
  }
@@ -110345,7 +110431,7 @@ async function runCaptureLarkPhaseUnlocked(input) {
110345
110431
  if (relativePath in capturedFiles)
110346
110432
  continue;
110347
110433
  try {
110348
- capturedFiles[relativePath] = `sha256:${createHash38("sha256").update(await readFile97(join120(input.projectRoot, relativePath))).digest("hex")}`;
110434
+ capturedFiles[relativePath] = `sha256:${createHash38("sha256").update(await readFile98(join121(input.projectRoot, relativePath))).digest("hex")}`;
110349
110435
  } catch (error) {
110350
110436
  if (error.code === "ENOENT")
110351
110437
  capturedFiles[relativePath] = null;
@@ -110354,7 +110440,7 @@ async function runCaptureLarkPhaseUnlocked(input) {
110354
110440
  }
110355
110441
  }
110356
110442
  await applyAtomicFileBatch({
110357
- transactionRoot: join120(input.projectRoot, ".tmp", "context-runtime", "capture-transactions"),
110443
+ transactionRoot: join121(input.projectRoot, ".tmp", "context-runtime", "capture-transactions"),
110358
110444
  writes,
110359
110445
  removals
110360
110446
  });
@@ -110539,8 +110625,8 @@ __export(exports_writeLockRecovery, {
110539
110625
  recoverWriterLock: () => recoverWriterLock,
110540
110626
  inspectWriterLock: () => inspectWriterLock
110541
110627
  });
110542
- import { lstat as lstat17, mkdir as mkdir41, readFile as readFile103, readdir as readdir29, rename as rename11, rmdir as rmdir2 } from "node:fs/promises";
110543
- import { join as join125 } from "node:path";
110628
+ import { lstat as lstat17, mkdir as mkdir41, readFile as readFile104, readdir as readdir29, rename as rename11, rmdir as rmdir2 } from "node:fs/promises";
110629
+ import { join as join126 } from "node:path";
110544
110630
  import { createHash as createHash40, randomUUID as randomUUID8 } from "node:crypto";
110545
110631
  async function inspectWriterLock(root2) {
110546
110632
  const path3 = await safeProjectTarget(root2, lockRelative);
@@ -110555,7 +110641,7 @@ async function inspectWriterLock(root2) {
110555
110641
  if (!stat11.isDirectory() || stat11.isSymbolicLink())
110556
110642
  throw new Error("Writer lock must be a real directory.");
110557
110643
  const ownerPath = await safeProjectTarget(root2, `${lockRelative}/owner.json`);
110558
- const bytes = await readFile103(ownerPath, "utf8");
110644
+ const bytes = await readFile104(ownerPath, "utf8");
110559
110645
  const owner = JSON.parse(bytes);
110560
110646
  if (owner.protocol !== "context.project-write-lock.v1" || !Number.isSafeInteger(owner.pid) || owner.pid <= 0) {
110561
110647
  throw new Error("Writer lock owner is invalid; preserve the lock for diagnosis.");
@@ -110591,8 +110677,8 @@ async function recoverWriterLock(input) {
110591
110677
  };
110592
110678
  if (input.plan_digest !== revision)
110593
110679
  throw new Error("Writer lock or transactions changed; preview recovery again.");
110594
- const path3 = join125(input.projectRoot, lockRelative);
110595
- const guard = join125(path3, ".recovery");
110680
+ const path3 = join126(input.projectRoot, lockRelative);
110681
+ const guard = join126(path3, ".recovery");
110596
110682
  await mkdir41(guard);
110597
110683
  let archived = false;
110598
110684
  try {
@@ -110603,7 +110689,7 @@ async function recoverWriterLock(input) {
110603
110689
  if (names.some((name3) => name3 !== "owner.json" && name3 !== ".recovery"))
110604
110690
  throw new Error("Unexpected lock contents; preserve for diagnosis.");
110605
110691
  const archive = `.tmp/context-runtime/locks/recovered-write-${randomUUID8()}.lock`;
110606
- await rename11(path3, join125(input.projectRoot, archive));
110692
+ await rename11(path3, join126(input.projectRoot, archive));
110607
110693
  archived = true;
110608
110694
  const receipts = await withProjectWriteLock(input.projectRoot, "recover-writer-transactions", async () => {
110609
110695
  if (JSON.stringify(await recoveryJournals(input.projectRoot)) !== JSON.stringify(journals)) {
@@ -110636,12 +110722,12 @@ __export(exports_taskRecovery, {
110636
110722
  RECOVERY_COMMAND: () => RECOVERY_COMMAND
110637
110723
  });
110638
110724
  import { existsSync as existsSync32 } from "node:fs";
110639
- import { basename as basename11, dirname as dirname50, join as join126 } from "node:path";
110640
- import { lstat as lstat18, readdir as readdir30, readFile as readFile104 } from "node:fs/promises";
110725
+ import { basename as basename11, dirname as dirname50, join as join127 } from "node:path";
110726
+ import { lstat as lstat18, readdir as readdir30, readFile as readFile105 } from "node:fs/promises";
110641
110727
  async function recoveryText(root2, path3) {
110642
110728
  const target = await safeProjectTarget(root2, path3);
110643
110729
  try {
110644
- return await readFile104(target, "utf8");
110730
+ return await readFile105(target, "utf8");
110645
110731
  } catch (error) {
110646
110732
  if (error.code === "ENOENT")
110647
110733
  return;
@@ -110654,7 +110740,7 @@ async function recoveryJournals(root2) {
110654
110740
  await safeProjectTarget(root2, path3);
110655
110741
  let stat11;
110656
110742
  try {
110657
- stat11 = await lstat18(join126(root2, path3));
110743
+ stat11 = await lstat18(join127(root2, path3));
110658
110744
  } catch (error) {
110659
110745
  if (error.code === "ENOENT")
110660
110746
  return;
@@ -110665,7 +110751,7 @@ async function recoveryJournals(root2) {
110665
110751
  if (stat11.isDirectory()) {
110666
110752
  if (depth > 3)
110667
110753
  throw new TypeError("Unexpected transaction directory depth; preserve it for diagnosis.");
110668
- for (const name3 of (await readdir30(join126(root2, path3))).sort())
110754
+ for (const name3 of (await readdir30(join127(root2, path3))).sort())
110669
110755
  await visit4(`${path3}/${name3}`, depth + 1);
110670
110756
  } else if (stat11.isFile())
110671
110757
  entries2.push({ path: path3, digest: indexerProtocolDigest(await recoveryText(root2, path3)) });
@@ -110677,8 +110763,8 @@ function recoveryResources() {
110677
110763
  try {
110678
110764
  const root2 = dirname50(contextWorkflowProviderPath());
110679
110765
  const resources = {
110680
- skill: join126(root2, "skills/recover-workspace/SKILL.md"),
110681
- issue_template: join126(root2, "resources/templates/recovery-issue.md")
110766
+ skill: join127(root2, "skills/recover-workspace/SKILL.md"),
110767
+ issue_template: join127(root2, "resources/templates/recovery-issue.md")
110682
110768
  };
110683
110769
  if (!Object.values(resources).every((path3) => existsSync32(path3)))
110684
110770
  throw new Error("Recovery resources are absent from this Provider.");
@@ -110793,8 +110879,8 @@ var exports_taskLocalSourceAdjustment = {};
110793
110879
  __export(exports_taskLocalSourceAdjustment, {
110794
110880
  adjustLocalRevisionSources: () => adjustLocalRevisionSources
110795
110881
  });
110796
- import { readFile as readFile105 } from "node:fs/promises";
110797
- import { join as join127 } from "node:path";
110882
+ import { readFile as readFile106 } from "node:fs/promises";
110883
+ import { join as join128 } from "node:path";
110798
110884
  async function adjustLocalRevisionSources(root2, input) {
110799
110885
  const { readMaintenance: readMaintenance2 } = await Promise.resolve().then(() => (init_maintenanceStorage(), exports_maintenanceStorage));
110800
110886
  if ((await readMaintenance2(root2)).active && await readProductionStage(root2))
@@ -110840,7 +110926,7 @@ async function adjustLocalRevisionSources(root2, input) {
110840
110926
  if (input.refresh && (!current3.refresh_sources || indexerProtocolDigest([...current3.refresh_sources].sort()) !== indexerProtocolDigest([...selected].sort()))) {
110841
110927
  throw new TypeError("No matching acquisition adjustment exists. Run task adjust without refresh first.");
110842
110928
  }
110843
- const raw = await readFile105(join127(root2, await revisionStoragePath(root2)), "utf8");
110929
+ const raw = await readFile106(join128(root2, await revisionStoragePath(root2)), "utf8");
110844
110930
  let next2;
110845
110931
  const discardIds = new Set;
110846
110932
  if (!refresh) {
@@ -110955,7 +111041,7 @@ ${input.instruction}` : revision.instruction
110955
111041
  content: content3
110956
111042
  }];
110957
111043
  if (discardIds.size > 0) {
110958
- const ledger = await readFile105(join127(root2, CANDIDATE_LEDGER_FILE), "utf8").catch((error) => {
111044
+ const ledger = await readFile106(join128(root2, CANDIDATE_LEDGER_FILE), "utf8").catch((error) => {
110959
111045
  if (error.code === "ENOENT")
110960
111046
  return;
110961
111047
  throw error;
@@ -111303,7 +111389,7 @@ __export(exports_approvedRevisionSubmission, {
111303
111389
  prepareApprovedRevisionSubmission: () => prepareApprovedRevisionSubmission,
111304
111390
  completeApprovedRevisionSubmission: () => completeApprovedRevisionSubmission
111305
111391
  });
111306
- import { join as join129 } from "node:path";
111392
+ import { join as join130 } from "node:path";
111307
111393
  function paused(message, managed, authorities = []) {
111308
111394
  return new ContextError(ExitCode.WorkspaceStateError, message, {
111309
111395
  category: ErrorCategory.WorkspaceStateInvalid,
@@ -111358,9 +111444,9 @@ async function prepareApprovedRevisionSubmission(input) {
111358
111444
  const { route, requests, contexts, issued } = await issueRevisionBatch(input);
111359
111445
  const stage = stageId(issued);
111360
111446
  const directory = productionAgentDirectory(stage);
111361
- await atomicWriteFile(await safeProjectTarget(input.projectRoot, join129(directory, "issued.json")), JSON.stringify(issued));
111447
+ await atomicWriteFile(await safeProjectTarget(input.projectRoot, join130(directory, "issued.json")), JSON.stringify(issued));
111362
111448
  for (const [index3, request] of requests.entries()) {
111363
- await atomicWriteFile(await safeProjectTarget(input.projectRoot, join129(directory, `${issued.tasks[index3].task}.input.json`)), JSON.stringify({
111449
+ await atomicWriteFile(await safeProjectTarget(input.projectRoot, join130(directory, `${issued.tasks[index3].task}.input.json`)), JSON.stringify({
111364
111450
  stage: "approved-revision",
111365
111451
  revision: request.revision,
111366
111452
  instruction: request.instruction,
@@ -111375,7 +111461,7 @@ async function prepareApprovedRevisionSubmission(input) {
111375
111461
  tasks: issued.tasks.map((task, index3) => ({
111376
111462
  ...task,
111377
111463
  path: requests[index3].target.path,
111378
- task_input: join129(directory, `${task.task}.input.json`)
111464
+ task_input: join130(directory, `${task.task}.input.json`)
111379
111465
  })),
111380
111466
  submission: { stage, tasks: issued.tasks.map((task) => ({ task: task.task, input: task.input, edits: `${task.task}.edits.json` })) },
111381
111467
  next_action: {
@@ -111603,7 +111689,7 @@ var init_approvedRevisionSubmission = __esm(() => {
111603
111689
  });
111604
111690
 
111605
111691
  // src/project/managedDocumentImport.ts
111606
- import { readFile as readFile114 } from "node:fs/promises";
111692
+ import { readFile as readFile115 } from "node:fs/promises";
111607
111693
  async function importManagedDocument(projectRoot2, value) {
111608
111694
  const input = inputSchema.parse(value);
111609
111695
  if (input.type !== "sessions" && input.changes !== undefined)
@@ -111612,7 +111698,7 @@ async function importManagedDocument(projectRoot2, value) {
111612
111698
  const path3 = await assertManagedDocumentPath(projectRoot2, input.type, input.name);
111613
111699
  let previous3;
111614
111700
  try {
111615
- previous3 = await readFile114(path3, "utf8");
111701
+ previous3 = await readFile115(path3, "utf8");
111616
111702
  } catch (error) {
111617
111703
  if (!(error && typeof error === "object" && ("code" in error) && error.code === "ENOENT"))
111618
111704
  throw error;
@@ -111659,7 +111745,7 @@ var init_managedDocumentImport = __esm(() => {
111659
111745
  });
111660
111746
 
111661
111747
  // src/project/larkDocumentImport.ts
111662
- import { readFile as readFile115 } from "node:fs/promises";
111748
+ import { readFile as readFile116 } from "node:fs/promises";
111663
111749
  import { resolve as resolve48 } from "node:path";
111664
111750
  async function importLarkDocument(projectRoot2, value) {
111665
111751
  const input = schema4.parse(value);
@@ -111676,7 +111762,7 @@ async function importLarkDocument(projectRoot2, value) {
111676
111762
  const responsePages = [];
111677
111763
  for (const path3 of input.response_files) {
111678
111764
  assertActionInputWorkspace(projectRoot2, path3);
111679
- responsePages.push(await readFile115(resolve48(projectRoot2, path3), "utf8"));
111765
+ responsePages.push(await readFile116(resolve48(projectRoot2, path3), "utf8"));
111680
111766
  }
111681
111767
  const mediaFiles = {};
111682
111768
  for (const [token, path3] of Object.entries(input.media_files ?? {})) {
@@ -111743,11 +111829,11 @@ var exports_managedDocumentRename = {};
111743
111829
  __export(exports_managedDocumentRename, {
111744
111830
  renameManagedDocument: () => renameManagedDocument
111745
111831
  });
111746
- import { readFile as readFile116 } from "node:fs/promises";
111747
- import { join as join141, posix as posix15 } from "node:path";
111832
+ import { readFile as readFile117 } from "node:fs/promises";
111833
+ import { join as join142, posix as posix15 } from "node:path";
111748
111834
  async function optionalText3(path3) {
111749
111835
  try {
111750
- return await readFile116(path3, "utf8");
111836
+ return await readFile117(path3, "utf8");
111751
111837
  } catch (error) {
111752
111838
  if (error && typeof error === "object" && "code" in error && error.code === "ENOENT")
111753
111839
  return;
@@ -111831,7 +111917,7 @@ async function renameManagedDocument(input) {
111831
111917
  if (path3.split("/").includes("..") || path3.startsWith("/"))
111832
111918
  throw new TypeError("Source references contain an unsafe knowledge path; repair it before renaming.");
111833
111919
  await safeProjectTarget(input.projectRoot, path3);
111834
- const before = await optionalText3(join141(input.projectRoot, path3));
111920
+ const before = await optionalText3(join142(input.projectRoot, path3));
111835
111921
  if (before === undefined)
111836
111922
  continue;
111837
111923
  let after;
@@ -111923,7 +112009,7 @@ var exports_originalRevisionsCommand = {};
111923
112009
  __export(exports_originalRevisionsCommand, {
111924
112010
  runOriginalRevisionsCommand: () => runOriginalRevisionsCommand
111925
112011
  });
111926
- import { readFile as readFile120 } from "node:fs/promises";
112012
+ import { readFile as readFile121 } from "node:fs/promises";
111927
112013
  import { resolve as resolve56 } from "node:path";
111928
112014
  async function readInput(cwd, source2) {
111929
112015
  const raw = source2 === "-" ? await new Promise((resolveInput, reject) => {
@@ -111934,7 +112020,7 @@ async function readInput(cwd, source2) {
111934
112020
  });
111935
112021
  process.stdin.on("end", () => resolveInput(data2));
111936
112022
  process.stdin.on("error", reject);
111937
- }) : await readFile120(resolve56(cwd, source2), "utf8");
112023
+ }) : await readFile121(resolve56(cwd, source2), "utf8");
111938
112024
  return import_yaml68.default.parse(raw);
111939
112025
  }
111940
112026
  async function runOriginalRevisionsCommand(input) {
@@ -111989,7 +112075,7 @@ var init_originalRevisionsCommand = __esm(() => {
111989
112075
 
111990
112076
  // src/cli.ts
111991
112077
  import { existsSync as existsSync41, realpathSync as realpathSync3 } from "node:fs";
111992
- import { dirname as dirname57, join as join147 } from "node:path";
112078
+ import { dirname as dirname57, join as join148 } from "node:path";
111993
112079
  import { fileURLToPath as fileURLToPath12, pathToFileURL as pathToFileURL3 } from "node:url";
111994
112080
 
111995
112081
  // ../../node_modules/.bun/commander@11.1.0/node_modules/commander/esm.mjs
@@ -112028,15 +112114,15 @@ init_workflowFacts();
112028
112114
  init_workflowProvider();
112029
112115
  init_workflowResourceRender();
112030
112116
  init_workflowTypes();
112031
- import { join as join114 } from "node:path";
112117
+ import { join as join115 } from "node:path";
112032
112118
 
112033
112119
  // src/project/reviewHtml.ts
112034
112120
  init_originalRevisions();
112035
112121
  init_candidateLedger();
112036
112122
  init_reviewShared();
112037
- import { copyFile, mkdir as mkdir37, readFile as readFile91, writeFile as writeFile29 } from "node:fs/promises";
112123
+ import { copyFile, mkdir as mkdir37, readFile as readFile92, writeFile as writeFile29 } from "node:fs/promises";
112038
112124
  import { fileURLToPath as fileURLToPath8 } from "node:url";
112039
- import { dirname as dirname46, isAbsolute as isAbsolute17, join as join112, resolve as resolve35 } from "node:path";
112125
+ import { dirname as dirname46, isAbsolute as isAbsolute17, join as join113, resolve as resolve35 } from "node:path";
112040
112126
 
112041
112127
  // src/project/reviewSiteModel.ts
112042
112128
  init_siteTheme2();
@@ -112044,8 +112130,8 @@ init_src2();
112044
112130
  init_unified();
112045
112131
  init_remark_parse();
112046
112132
  var import_yaml52 = __toESM(require_dist(), 1);
112047
- import { readFile as readFile89 } from "node:fs/promises";
112048
- import { join as join110 } from "node:path";
112133
+ import { readFile as readFile90 } from "node:fs/promises";
112134
+ import { join as join111 } from "node:path";
112049
112135
  import { execFile as execFile17 } from "node:child_process";
112050
112136
  import { promisify as promisify14 } from "node:util";
112051
112137
  import { createHash as createHash33 } from "node:crypto";
@@ -115010,10 +115096,10 @@ function remarkGfm(options) {
115010
115096
  init_workspace();
115011
115097
 
115012
115098
  // src/project/reviewFeedback.ts
115013
- import { readdir as readdir24, readFile as readFile87 } from "node:fs/promises";
115014
- import { join as join109 } from "node:path";
115099
+ import { readdir as readdir24, readFile as readFile88 } from "node:fs/promises";
115100
+ import { join as join110 } from "node:path";
115015
115101
  async function readPendingReviewFeedback(root2, candidates) {
115016
- const directory = join109(root2, ".tmp/context-runtime/review-feedback");
115102
+ const directory = join110(root2, ".tmp/context-runtime/review-feedback");
115017
115103
  let files;
115018
115104
  try {
115019
115105
  files = await readdir24(directory);
@@ -115026,7 +115112,7 @@ async function readPendingReviewFeedback(root2, candidates) {
115026
115112
  const results = new Map;
115027
115113
  const receipts = [];
115028
115114
  for (const file of files.filter((f) => /^[a-f0-9]+\.json$/u.test(f)).sort()) {
115029
- const receipt2 = JSON.parse(await readFile87(join109(directory, file), "utf8"));
115115
+ const receipt2 = JSON.parse(await readFile88(join110(directory, file), "utf8"));
115030
115116
  receipts.push(receipt2);
115031
115117
  }
115032
115118
  for (const receipt2 of receipts.sort((a2, b) => a2.created_at.localeCompare(b.created_at))) {
@@ -115136,7 +115222,7 @@ var title = (s, fallback) => {
115136
115222
  };
115137
115223
  async function optional2(path3) {
115138
115224
  try {
115139
- return await readFile89(path3, "utf8");
115225
+ return await readFile90(path3, "utf8");
115140
115226
  } catch (e) {
115141
115227
  if (e.code === "ENOENT")
115142
115228
  return;
@@ -115173,7 +115259,7 @@ async function reviewSiteBaselineHash(root2, reviewedPaths) {
115173
115259
  const displayed = new Set([...reviewedPaths, ...(metadata.structure?.articles ?? []).filter((a2) => navigation.changedArticles.has(a2.article_id)).map((a2) => a2.path)]);
115174
115260
  return hash4(JSON.stringify([
115175
115261
  navigation.baseline,
115176
- await optional2(join110(root2, "src/knowledge-map.yaml")) ?? null,
115262
+ await optional2(join111(root2, "src/knowledge-map.yaml")) ?? null,
115177
115263
  navigation.planned ? [navigation.planned.retired, navigation.planned.knowledge_map ?? null] : null,
115178
115264
  files.map((f) => [f.relPath, displayed.has(f.relPath) ? hash4(f.content) : title(f.content, f.relPath)]).sort((a2, b) => a2[0].localeCompare(b[0]))
115179
115265
  ]));
@@ -115286,9 +115372,9 @@ async function collectReviewSiteModel(root2, candidates) {
115286
115372
  nodes.push({ key: `review-page-${p.id}`, parent: "review-unplaced", title: p.title, order: i2, page: p.id, change: p.change });
115287
115373
  }
115288
115374
  const navigationChanges = navigationBaseline === "empty" ? [] : reviewNavigationChanges(baseline?.entries ?? [], current3?.entries ?? [], pages);
115289
- const pkgText = await optional2(join110(root2, "package.json"));
115375
+ const pkgText = await optional2(join111(root2, "package.json"));
115290
115376
  const pkg = pkgText ? JSON.parse(pkgText) : {};
115291
- const project = await optional2(join110(root2, "src/index.ts")) === undefined ? undefined : await loadContextProjectModule(root2);
115377
+ const project = await optional2(join111(root2, "src/index.ts")) === undefined ? undefined : await loadContextProjectModule(root2);
115292
115378
  const siteTitle = project?.project.packages.flatMap((p) => p.kind === "package.kb" && p.site?.title ? [p.site.title] : [])[0];
115293
115379
  const sitePackages = project?.project.packages.flatMap((p) => p.kind === "package.kb" && p.site ? [p.site] : []) ?? [];
115294
115380
  const themeCss = siteThemeVariables(await resolveSiteTheme(root2, sitePackages.length === 1 ? sitePackages[0]?.theme : undefined));
@@ -115355,9 +115441,9 @@ init_errors3();
115355
115441
  init_cliFeedback();
115356
115442
  init_exitCode();
115357
115443
  init_reviewShared();
115358
- import { readFile as readFile90 } from "node:fs/promises";
115359
- import { join as join111 } from "node:path";
115360
- var scopePath = (root2, scope2) => join111(root2, ".tmp/context-runtime/review", `${scope2}.scope.json`);
115444
+ import { readFile as readFile91 } from "node:fs/promises";
115445
+ import { join as join112 } from "node:path";
115446
+ var scopePath = (root2, scope2) => join112(root2, ".tmp/context-runtime/review", `${scope2}.scope.json`);
115361
115447
  async function saveReviewReportScope(root2, scope2, candidates, baselineHash, reportPath) {
115362
115448
  const ids = candidates.map((candidate) => candidate.record.candidate_id).sort();
115363
115449
  const value = {
@@ -115377,7 +115463,7 @@ async function saveReviewReportScope(root2, scope2, candidates, baselineHash, re
115377
115463
  }
115378
115464
  async function readConfirmedReviewScope(root2, scope2) {
115379
115465
  try {
115380
- const value = JSON.parse(await readFile90(scopePath(root2, scope2), "utf8"));
115466
+ const value = JSON.parse(await readFile91(scopePath(root2, scope2), "utf8"));
115381
115467
  if (!value || typeof value !== "object" || !("scope" in value) || !("baseline_hash" in value))
115382
115468
  throw new Error("Missing report scope");
115383
115469
  const parsed = value;
@@ -115919,7 +116005,7 @@ button:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
115919
116005
 
115920
116006
  // src/project/reviewHtml.ts
115921
116007
  init_knowledgeMap2();
115922
- var REVIEW_HTML_ROOT = join112(".tmp", "context-runtime", "review");
116008
+ var REVIEW_HTML_ROOT = join113(".tmp", "context-runtime", "review");
115923
116009
  async function collectReviewCandidates(projectRoot, collection) {
115924
116010
  const rows = await readCandidateRecords(projectRoot);
115925
116011
  const draftRows = rows.filter((row) => row.collection === collection && row.status === "draft");
@@ -115969,13 +116055,13 @@ ${diagramScript ? `<script>${diagramScript}</script>` : ""}<script>const DATA=${
115969
116055
  }
115970
116056
  function resolveOutputPath(projectRoot, outPath, reviewScope) {
115971
116057
  if (outPath === undefined)
115972
- return join112(projectRoot, REVIEW_HTML_ROOT, `${reviewScope}.html`);
116058
+ return join113(projectRoot, REVIEW_HTML_ROOT, `${reviewScope}.html`);
115973
116059
  return isAbsolute17(outPath) ? outPath : resolve35(projectRoot, outPath);
115974
116060
  }
115975
- var APPLIED_REVIEW_REPORT_ROOT = join112(".tmp", "review-reports");
116061
+ var APPLIED_REVIEW_REPORT_ROOT = join113(".tmp", "review-reports");
115976
116062
  async function archiveAppliedReviewReport(projectRoot, reportPath, scope2) {
115977
116063
  const stamp = new Date().toISOString().replace(/[:.]/gu, "-");
115978
- const target = join112(projectRoot, APPLIED_REVIEW_REPORT_ROOT, `${stamp}-${scope2}.html`);
116064
+ const target = join113(projectRoot, APPLIED_REVIEW_REPORT_ROOT, `${stamp}-${scope2}.html`);
115979
116065
  await mkdir37(dirname46(target), { recursive: true });
115980
116066
  await copyFile(reportPath, target);
115981
116067
  return target;
@@ -116021,11 +116107,11 @@ async function writeReviewHtml(input) {
116021
116107
  if (model.pages.some((page) => page.html.includes('class="language-mermaid"'))) {
116022
116108
  const here = dirname46(fileURLToPath8(import.meta.url));
116023
116109
  try {
116024
- diagramScript = await readFile91(join112(here, "browser/diagrams.js"), "utf8");
116110
+ diagramScript = await readFile92(join113(here, "browser/diagrams.js"), "utf8");
116025
116111
  } catch (error) {
116026
116112
  if (error.code !== "ENOENT")
116027
116113
  throw error;
116028
- diagramScript = await readFile91(resolve35(here, "../../dist/browser/diagrams.js"), "utf8");
116114
+ diagramScript = await readFile92(resolve35(here, "../../dist/browser/diagrams.js"), "utf8");
116029
116115
  }
116030
116116
  }
116031
116117
  await writeFile29(outPath, renderReviewHtml(model, diagramScript), "utf8");
@@ -116069,8 +116155,8 @@ init_productionRequirements();
116069
116155
  init_dist();
116070
116156
  init_atomicWrite();
116071
116157
  init_reviewShared();
116072
- import { mkdir as mkdir38, readFile as readFile92 } from "node:fs/promises";
116073
- import { join as join113 } from "node:path";
116158
+ import { mkdir as mkdir38, readFile as readFile93 } from "node:fs/promises";
116159
+ import { join as join114 } from "node:path";
116074
116160
  var REVIEW_BATCH_MAX_CANDIDATES = 6;
116075
116161
  var REVIEW_BATCH_MAX_BYTES = 512 * 1024;
116076
116162
  async function readerPurposes(projectRoot, sources) {
@@ -116150,12 +116236,12 @@ async function materializeCurrentReviewBatchSet(input) {
116150
116236
  const batches = buildCurrentReviewBatchDocuments(input.candidates);
116151
116237
  const setDigest = digestText(batches.map((batch) => `${batch.task_key}:${batch.digest}`).join(`
116152
116238
  `));
116153
- const root2 = join113(input.projectRoot, ".tmp", "context-runtime", "review", `current-${setDigest.slice("sha256:".length)}`);
116239
+ const root2 = join114(input.projectRoot, ".tmp", "context-runtime", "review", `current-${setDigest.slice("sha256:".length)}`);
116154
116240
  await mkdir38(root2, { recursive: true });
116155
116241
  const entries2 = [];
116156
116242
  for (const batch of batches) {
116157
- const path4 = join113(input.projectRoot, ".tmp", "context-runtime", "review", `${batch.task_key}-${batch.digest.slice("sha256:".length)}.md`);
116158
- const existing = await readFile92(path4, "utf8").catch((error) => {
116243
+ const path4 = join114(input.projectRoot, ".tmp", "context-runtime", "review", `${batch.task_key}-${batch.digest.slice("sha256:".length)}.md`);
116244
+ const existing = await readFile93(path4, "utf8").catch((error) => {
116159
116245
  if (error.code === "ENOENT")
116160
116246
  return;
116161
116247
  throw error;
@@ -116208,7 +116294,7 @@ async function materializeCurrentReviewBatchSet(input) {
116208
116294
  ].join(`
116209
116295
  `);
116210
116296
  const digest7 = digestText(content3);
116211
- const path3 = join113(root2, "index.md");
116297
+ const path3 = join114(root2, "index.md");
116212
116298
  await atomicWriteFile(path3, `${content3}
116213
116299
  `);
116214
116300
  return {
@@ -116242,11 +116328,11 @@ function shellQuote6(value) {
116242
116328
  }
116243
116329
  function receiptSetPath(receipts) {
116244
116330
  const token = digestText(JSON.stringify(receipts)).slice("sha256:".length);
116245
- return join114(".tmp", "context-runtime", "workflow", "read-receipts", `${token}.json`);
116331
+ return join115(".tmp", "context-runtime", "workflow", "read-receipts", `${token}.json`);
116246
116332
  }
116247
116333
  async function writeReceiptContinuation(input) {
116248
116334
  const path3 = receiptSetPath(input.receipts);
116249
- const absolutePath = join114(input.projectRoot, path3);
116335
+ const absolutePath = join115(input.projectRoot, path3);
116250
116336
  await writeJsonAtomic(absolutePath, input.receipts);
116251
116337
  const contextCommand = input.managed ? [
116252
116338
  "context",
@@ -116341,7 +116427,7 @@ async function materializeContextWorkflowResource(input) {
116341
116427
  const resourceId = workflowResourceId(input.resourceId);
116342
116428
  const content3 = renderContextWorkflowResource(resourceId, status);
116343
116429
  const location = await materializeResource(await loadContextWorkflowProvider(), resourceId, {
116344
- cache: join114(found.projectRoot, ".tmp", "context-runtime", "workflow", "resources"),
116430
+ cache: join115(found.projectRoot, ".tmp", "context-runtime", "workflow", "resources"),
116345
116431
  workspace: found.projectRoot,
116346
116432
  revision: input.revision,
116347
116433
  input: {
@@ -116373,7 +116459,7 @@ async function materializeContextWorkflowResource(input) {
116373
116459
  receipts: afterReadReceipts
116374
116460
  });
116375
116461
  const directResources = (status.workflow.current?.resources.required ?? []).filter((resource) => resource.read_state === "read-required" && resource.path !== undefined && resource.digest !== undefined);
116376
- const afterReadCommand = directResources.length === 0 ? continuation.command : `context resource acknowledge-current --revision ${shellQuote6(input.revision)}${authorityCommandOptions(authorities, "resource")} --resource-receipts ${shellQuote6(`@${join114(found.projectRoot, continuation.path)}`)} --format json`;
116462
+ const afterReadCommand = directResources.length === 0 ? continuation.command : `context resource acknowledge-current --revision ${shellQuote6(input.revision)}${authorityCommandOptions(authorities, "resource")} --resource-receipts ${shellQuote6(`@${join115(found.projectRoot, continuation.path)}`)} --format json`;
116377
116463
  return {
116378
116464
  protocol: "context.workflow.resource.v1",
116379
116465
  id: resourceId,
@@ -116434,14 +116520,14 @@ async function acknowledgeCurrentWorkflowResources(input) {
116434
116520
  const reevaluated = await reevaluateProjectStatusWorkflow({
116435
116521
  snapshot,
116436
116522
  resourceReceipts: normalizedReceipts,
116437
- resourceReceiptsReference: `@${join114(found.projectRoot, continuation.path)}`
116523
+ resourceReceiptsReference: `@${join115(found.projectRoot, continuation.path)}`
116438
116524
  });
116439
116525
  return {
116440
116526
  ...reevaluated,
116441
116527
  resourceAcknowledgement: {
116442
116528
  protocol: "context.workflow.resource-receipts.v1",
116443
116529
  acknowledged: directResources.length,
116444
- receiptReference: `@${join114(found.projectRoot, continuation.path)}`,
116530
+ receiptReference: `@${join115(found.projectRoot, continuation.path)}`,
116445
116531
  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."
116446
116532
  }
116447
116533
  };
@@ -116488,9 +116574,9 @@ init_cliFeedback();
116488
116574
  init_errors3();
116489
116575
  init_exitCode();
116490
116576
  init_workspace();
116491
- import { readFile as readFile93 } from "node:fs/promises";
116492
- import { isAbsolute as isAbsolute18, join as join115, sep as sep8, resolve as resolve36 } from "node:path";
116493
- var RECEIPT_DIRECTORY = join115(".tmp", "context-runtime", "workflow", "read-receipts");
116577
+ import { readFile as readFile94 } from "node:fs/promises";
116578
+ import { isAbsolute as isAbsolute18, join as join116, sep as sep8, resolve as resolve36 } from "node:path";
116579
+ var RECEIPT_DIRECTORY = join116(".tmp", "context-runtime", "workflow", "read-receipts");
116494
116580
  function workflowResourceReceiptCwd(value, cwd) {
116495
116581
  if (value === undefined || !value.startsWith("@"))
116496
116582
  return cwd;
@@ -116508,7 +116594,7 @@ async function receiptDocument(value, cwd) {
116508
116594
  let source2 = value;
116509
116595
  if (value.startsWith("@")) {
116510
116596
  try {
116511
- source2 = await readFile93(resolve36(cwd, value.slice(1)), "utf8");
116597
+ source2 = await readFile94(resolve36(cwd, value.slice(1)), "utf8");
116512
116598
  } catch (error) {
116513
116599
  const ioCode = error !== null && typeof error === "object" && "code" in error && typeof error.code === "string" ? error.code : undefined;
116514
116600
  throw new ContextError(ExitCode.UserError, "resource read receipt file is unavailable", {
@@ -116770,14 +116856,14 @@ function compactJsonResult(result, verbose) {
116770
116856
  // src/project/runLog.ts
116771
116857
  import { randomUUID as randomUUID6 } from "node:crypto";
116772
116858
  import { mkdir as mkdir40, writeFile as writeFile31 } from "node:fs/promises";
116773
- import { dirname as dirname48, join as join121 } from "node:path";
116859
+ import { dirname as dirname48, join as join122 } from "node:path";
116774
116860
  var createPhaseRunId = () => {
116775
116861
  const timestamp = new Date().toISOString().replace(/[-:.TZ]/gu, "");
116776
116862
  return `run_${timestamp}_${randomUUID6().slice(0, 8)}`;
116777
116863
  };
116778
116864
  async function writePhaseRunLog(input) {
116779
- const relPath = join121(".tmp", "context-runtime", "runs", `${input.runId}.json`);
116780
- const absPath = join121(input.projectRoot, relPath);
116865
+ const relPath = join122(".tmp", "context-runtime", "runs", `${input.runId}.json`);
116866
+ const absPath = join122(input.projectRoot, relPath);
116781
116867
  await mkdir40(dirname48(absPath), { recursive: true });
116782
116868
  await writeFile31(absPath, `${JSON.stringify({
116783
116869
  run_id: input.runId,
@@ -118008,7 +118094,7 @@ init_cliFeedback();
118008
118094
  init_errors3();
118009
118095
  init_exitCode();
118010
118096
  import { existsSync as existsSync31 } from "node:fs";
118011
- import { readFile as readFile100 } from "node:fs/promises";
118097
+ import { readFile as readFile101 } from "node:fs/promises";
118012
118098
  import { isAbsolute as isAbsolute21, resolve as resolve38 } from "node:path";
118013
118099
 
118014
118100
  // src/project/reviewApply.ts
@@ -118025,8 +118111,8 @@ init_durableMultiFileTransaction();
118025
118111
  init_durableSingleFileTransaction();
118026
118112
  init_reviewShared();
118027
118113
  import { existsSync as existsSync30 } from "node:fs";
118028
- import { readFile as readFile98 } from "node:fs/promises";
118029
- import { join as join122 } from "node:path";
118114
+ import { readFile as readFile99 } from "node:fs/promises";
118115
+ import { join as join123 } from "node:path";
118030
118116
  function existingTimestamp(markdown) {
118031
118117
  if (markdown === undefined)
118032
118118
  return;
@@ -118053,7 +118139,7 @@ async function prepareApprovedPage(input) {
118053
118139
  next: "Refresh the current production or article revision, then reopen Review before approval."
118054
118140
  });
118055
118141
  }
118056
- const relPath = join122("knowledge", input.record.path);
118142
+ const relPath = join123("knowledge", input.record.path);
118057
118143
  const existingView = findApprovedPageForArticleId(input.record.indexer_candidate.artifact_ref, input.approvedPageIndex);
118058
118144
  const previousPath = input.record.approved_revision?.previous_path;
118059
118145
  if (previousPath !== undefined && (!isSafeKnowledgeTargetPath(previousPath.split("/")[0], previousPath) || previousPath.includes("\\")))
@@ -118068,13 +118154,13 @@ async function prepareApprovedPage(input) {
118068
118154
  next: "Resolve the approved page path migration explicitly before approving this candidate."
118069
118155
  });
118070
118156
  }
118071
- const absPath = join122(input.projectRoot, relPath);
118072
- const existing = existsSync30(absPath) ? await readFile98(absPath, "utf8") : undefined;
118157
+ const absPath = join123(input.projectRoot, relPath);
118158
+ const existing = existsSync30(absPath) ? await readFile99(absPath, "utf8") : undefined;
118073
118159
  let previous3;
118074
118160
  if (previousPath !== undefined) {
118075
118161
  if (existing !== undefined || existingView?.relPath !== `knowledge/${previousPath}`)
118076
118162
  throw new TypeError("Page move destination or original identity changed; refresh its revision.");
118077
- previous3 = { path: `knowledge/${previousPath}`, content: await readFile98(join122(input.projectRoot, "knowledge", previousPath), "utf8") };
118163
+ previous3 = { path: `knowledge/${previousPath}`, content: await readFile99(join123(input.projectRoot, "knowledge", previousPath), "utf8") };
118078
118164
  }
118079
118165
  if (input.record.approved_revision !== undefined) {
118080
118166
  const base = previous3?.content ?? existing;
@@ -118121,7 +118207,7 @@ async function prepareApprovedPage(input) {
118121
118207
  }
118122
118208
  async function readProjectFileMaybe(projectRoot, relPath) {
118123
118209
  try {
118124
- return await readFile98(join122(projectRoot, relPath), "utf8");
118210
+ return await readFile99(join123(projectRoot, relPath), "utf8");
118125
118211
  } catch (error) {
118126
118212
  if (error !== null && typeof error === "object" && "code" in error && error.code === "ENOENT") {
118127
118213
  return;
@@ -118342,7 +118428,7 @@ async function applyReviewDecisions(input) {
118342
118428
  });
118343
118429
  }
118344
118430
  seenApprovedIds.set(approvedRef, row.candidate_id);
118345
- const approvedPath = join122("knowledge", row.path);
118431
+ const approvedPath = join123("knowledge", row.path);
118346
118432
  const previousPathCandidate = seenApprovedPaths.get(knowledgeTargetPathKey(approvedPath));
118347
118433
  if (previousPathCandidate !== undefined) {
118348
118434
  throw new ContextError(ExitCode.UserError, `multiple approved review decisions target the same knowledge path: ${approvedPath}`, {
@@ -118392,7 +118478,7 @@ async function applyReviewDecisions(input) {
118392
118478
  for (const path3 of approvedPageIndex.byRelPath.keys()) {
118393
118479
  if (pagesToWrite.some((page) => page.relPath === path3 || page.previous?.path === path3))
118394
118480
  continue;
118395
- const before = await readFile98(join122(input.projectRoot, path3), "utf8");
118481
+ const before = await readFile99(join123(input.projectRoot, path3), "utf8");
118396
118482
  const local = path3.replace(/^knowledge\//u, "");
118397
118483
  const after = moveKnowledgeLinkTargets2(before, local, local, moved);
118398
118484
  navigationTargets.push(reviewFileTarget({ path: path3, baseContent: before, targetContent: after }));
@@ -118458,11 +118544,11 @@ async function applyReviewDecisions(input) {
118458
118544
  init_reviewShared();
118459
118545
  init_writeLock();
118460
118546
  init_verifyFrontmatter();
118461
- import { readFile as readFile99, writeFile as writeFile32 } from "node:fs/promises";
118547
+ import { readFile as readFile100, writeFile as writeFile32 } from "node:fs/promises";
118462
118548
  function deprecateApprovedPage(input) {
118463
118549
  return withProjectWriteLock(input.projectRoot, "deprecate-article", async () => {
118464
118550
  const page = await approvedPageForArticleId(input.projectRoot, input.viewRef);
118465
- const original = await readFile99(page.path, "utf8");
118551
+ const original = await readFile100(page.path, "utf8");
118466
118552
  const content3 = parseFrontmatterLoose(original).deprecated === true ? original : updateFrontmatter(original, (metadata) => ({ ...metadata, deprecated: true, timestamp: new Date().toISOString() }));
118467
118553
  const changed = content3 !== original;
118468
118554
  if (changed)
@@ -118483,12 +118569,12 @@ init_candidateLedger();
118483
118569
 
118484
118570
  // src/project/localHtmlReport.ts
118485
118571
  import { execFile as execFile18 } from "node:child_process";
118486
- import { isAbsolute as isAbsolute20, join as join123 } from "node:path";
118572
+ import { isAbsolute as isAbsolute20, join as join124 } from "node:path";
118487
118573
  import { pathToFileURL as pathToFileURL2 } from "node:url";
118488
118574
  import { promisify as promisify15 } from "node:util";
118489
118575
  var execFileAsync4 = promisify15(execFile18);
118490
118576
  function htmlReportReference(input) {
118491
- const absolutePath = isAbsolute20(input.path) ? input.path : join123(input.projectRoot, input.path);
118577
+ const absolutePath = isAbsolute20(input.path) ? input.path : join124(input.projectRoot, input.path);
118492
118578
  return {
118493
118579
  format: "html",
118494
118580
  path: input.path,
@@ -118674,7 +118760,7 @@ function parseReviewPayloadText(raw) {
118674
118760
  async function readReviewPayloadFile(filePath2, projectRoot) {
118675
118761
  let raw;
118676
118762
  try {
118677
- raw = await readFile100(filePath2, "utf8");
118763
+ raw = await readFile101(filePath2, "utf8");
118678
118764
  } catch (error) {
118679
118765
  const message = error instanceof Error ? error.message : String(error);
118680
118766
  throw new ContextError(ExitCode.UserError, `review payload file cannot be read: ${filePath2}`, {
@@ -119277,7 +119363,7 @@ init_cliFeedback();
119277
119363
  init_errors3();
119278
119364
  init_exitCode();
119279
119365
  var import_yaml53 = __toESM(require_dist(), 1);
119280
- import { readFile as readFile101 } from "node:fs/promises";
119366
+ import { readFile as readFile102 } from "node:fs/promises";
119281
119367
  function userInputError2(message, detail = {}) {
119282
119368
  return new ContextError(ExitCode.UserError, message, {
119283
119369
  category: ErrorCategory.UserInputInvalid,
@@ -119346,7 +119432,7 @@ async function readPayloadTextFromStdin(stdin) {
119346
119432
  }
119347
119433
  async function readPayloadText(path3) {
119348
119434
  if (path3 !== "-")
119349
- return readFile101(path3, "utf8");
119435
+ return readFile102(path3, "utf8");
119350
119436
  return readPayloadTextFromStdin(process.stdin);
119351
119437
  }
119352
119438
  function unquotedColonText(message) {
@@ -119676,8 +119762,8 @@ init_exitCode();
119676
119762
  init_maintenanceStorage();
119677
119763
  init_productionFeedback();
119678
119764
  import { randomUUID as randomUUID7 } from "node:crypto";
119679
- import { readFile as readFile102 } from "node:fs/promises";
119680
- import { join as join124 } from "node:path";
119765
+ import { readFile as readFile103 } from "node:fs/promises";
119766
+ import { join as join125 } from "node:path";
119681
119767
  async function beginProductionRevision(input) {
119682
119768
  return withProductionFeedback({ operation: "revision" }, () => withProjectWriteLock(input.projectRoot, "production-revision", async () => {
119683
119769
  await recoverDurableMultiFileTransactions(input.projectRoot);
@@ -119716,7 +119802,7 @@ async function beginProductionRevision(input) {
119716
119802
  const formal = approved.byPath.get(path3);
119717
119803
  if (!prior && !formal)
119718
119804
  throw invalid3("Write the current task first; there is no article draft to revise yet.");
119719
- const markdown = prior?.body ?? await readFile102(await safeProjectTarget(input.projectRoot, join124("knowledge", path3)), "utf8");
119805
+ const markdown = prior?.body ?? await readFile103(await safeProjectTarget(input.projectRoot, join125("knowledge", path3)), "utf8");
119720
119806
  const sections = prior?.indexer_candidate.sections.map((section) => ({ id: section.section_key, references: section.references })) ?? formal?.sections;
119721
119807
  const sources = [];
119722
119808
  for (const source2 of owner.sources) {
@@ -120254,7 +120340,7 @@ function registerVersionCommands(program2) {
120254
120340
 
120255
120341
  // src/commands/translateCommands.ts
120256
120342
  init_workspace();
120257
- import { isAbsolute as isAbsolute22, join as join128 } from "node:path";
120343
+ import { isAbsolute as isAbsolute22, join as join129 } from "node:path";
120258
120344
  init_status();
120259
120345
  init_workflowCommandOptions();
120260
120346
  init_workflowExecutionContext();
@@ -120348,7 +120434,7 @@ function registerTranslateCommands(program2) {
120348
120434
  readFailureNext: "Check the input path",
120349
120435
  parseFailureNext: "Use valid YAML or JSON"
120350
120436
  }));
120351
- const saved = await submitSiteTranslation(root2, await projectPackages(root2), value, (file) => isAbsolute22(file) ? file : join128(root2, file));
120437
+ const saved = await submitSiteTranslation(root2, await projectPackages(root2), value, (file) => isAbsolute22(file) ? file : join129(root2, file));
120352
120438
  write(await withWorkflow(root2, { outcome: "submitted", ...saved }));
120353
120439
  });
120354
120440
  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) => {
@@ -120446,7 +120532,7 @@ init_workflowRouteOutput();
120446
120532
  var import_yaml57 = __toESM(require_dist(), 1);
120447
120533
  import { Buffer as Buffer5 } from "node:buffer";
120448
120534
  import { createHash as createHash41 } from "node:crypto";
120449
- import { join as join130 } from "node:path";
120535
+ import { join as join131 } from "node:path";
120450
120536
  var INLINE_LIMIT = 16 * 1024;
120451
120537
  function record4(value) {
120452
120538
  return value !== null && typeof value === "object" && !Array.isArray(value) ? value : undefined;
@@ -120472,8 +120558,8 @@ async function prepareActionCompletionOutput(input) {
120472
120558
  if (production && Buffer5.byteLength(full) <= INLINE_LIMIT)
120473
120559
  return input.result;
120474
120560
  const digest8 = createHash41("sha256").update(full).digest("hex");
120475
- const root2 = join130(input.projectRoot, ".tmp/context-runtime/action-results");
120476
- const resultFile = join130(root2, `${digest8}.json`);
120561
+ const root2 = join131(input.projectRoot, ".tmp/context-runtime/action-results");
120562
+ const resultFile = join131(root2, `${digest8}.json`);
120477
120563
  await atomicWriteFile(resultFile, full);
120478
120564
  if (production)
120479
120565
  return {
@@ -120757,7 +120843,7 @@ init_cliFeedback();
120757
120843
  import { existsSync as existsSync33 } from "node:fs";
120758
120844
  import { readdir as readdir31, rm as rm30 } from "node:fs/promises";
120759
120845
  import { homedir } from "node:os";
120760
- import { join as join131 } from "node:path";
120846
+ import { join as join132 } from "node:path";
120761
120847
  var ORPHAN_MARKER = ".orphaned_at";
120762
120848
  var CLAUDE_PLUGIN_CACHE_ROOT_ENV = "C4A_CLAUDE_PLUGIN_CACHE_ROOT";
120763
120849
  var CLAUDE_PLUGIN_CACHE_HOME_ENV = "C4A_CLAUDE_PLUGIN_CACHE_HOME";
@@ -120774,19 +120860,19 @@ async function cleanClaudePluginCache(opts = {}) {
120774
120860
  for (const mp of marketplaces) {
120775
120861
  if (!mp.isDirectory())
120776
120862
  continue;
120777
- const mpDir = join131(cacheRoot, mp.name);
120863
+ const mpDir = join132(cacheRoot, mp.name);
120778
120864
  const plugins = await readdir31(mpDir, { withFileTypes: true });
120779
120865
  for (const pl of plugins) {
120780
120866
  if (!pl.isDirectory())
120781
120867
  continue;
120782
- const plDir = join131(mpDir, pl.name);
120868
+ const plDir = join132(mpDir, pl.name);
120783
120869
  const versions = await readdir31(plDir, { withFileTypes: true });
120784
120870
  for (const ver of versions) {
120785
120871
  if (!ver.isDirectory())
120786
120872
  continue;
120787
120873
  scanned += 1;
120788
- const verDir = join131(plDir, ver.name);
120789
- const markerPath = join131(verDir, ORPHAN_MARKER);
120874
+ const verDir = join132(plDir, ver.name);
120875
+ const markerPath = join132(verDir, ORPHAN_MARKER);
120790
120876
  if (!existsSync33(markerPath))
120791
120877
  continue;
120792
120878
  const label2 = `${mp.name}/${pl.name}/${ver.name}`;
@@ -120818,7 +120904,7 @@ function resolveClaudePluginCacheRoot(opts) {
120818
120904
  if (explicitRoot)
120819
120905
  return explicitRoot;
120820
120906
  const home = opts.home ?? process.env[CLAUDE_PLUGIN_CACHE_HOME_ENV] ?? homedir();
120821
- return join131(home, ".claude", "plugins", "cache");
120907
+ return join132(home, ".claude", "plugins", "cache");
120822
120908
  }
120823
120909
  async function isEmptyDir(dir) {
120824
120910
  try {
@@ -120854,7 +120940,7 @@ init_statusCommand();
120854
120940
  // src/project/sourceCommands.ts
120855
120941
  init_repoContentLinks();
120856
120942
  init_src2();
120857
- import { readFile as readFile117 } from "node:fs/promises";
120943
+ import { readFile as readFile118 } from "node:fs/promises";
120858
120944
  import { isAbsolute as isAbsolute26, resolve as resolve49 } from "node:path";
120859
120945
  init_cliFeedback();
120860
120946
  init_errors3();
@@ -121222,16 +121308,16 @@ async function restoreRepositorySources(input) {
121222
121308
  init_src2();
121223
121309
  init_documentCapture();
121224
121310
  import { existsSync as existsSync35 } from "node:fs";
121225
- import { readFile as readFile107 } from "node:fs/promises";
121226
- import { join as join133 } from "node:path";
121311
+ import { readFile as readFile108 } from "node:fs/promises";
121312
+ import { join as join134 } from "node:path";
121227
121313
 
121228
121314
  // src/project/sourceCommandViews.ts
121229
121315
  init_fileSourceOrigins();
121230
121316
  init_documentSiteDetection();
121231
121317
  init_workspace();
121232
121318
  init_documentBatchManifest();
121233
- import { readFile as readFile106 } from "node:fs/promises";
121234
- import { join as join132 } from "node:path";
121319
+ import { readFile as readFile107 } from "node:fs/promises";
121320
+ import { join as join133 } from "node:path";
121235
121321
  function repoSourceAgentView(source2) {
121236
121322
  return {
121237
121323
  id: source2.id ?? source2.name,
@@ -121296,7 +121382,7 @@ async function fileSourceAgentViewWithNextAction(input) {
121296
121382
  };
121297
121383
  }
121298
121384
  function documentSourceManifestPath(source2) {
121299
- return source2.snapshot?.manifest ?? join132(source2.materializedAt, "manifest.json");
121385
+ return source2.snapshot?.manifest ?? join133(source2.materializedAt, "manifest.json");
121300
121386
  }
121301
121387
  async function fileSourceDocumentSiteHint(input) {
121302
121388
  const detection = await detectDocumentSiteFiles({
@@ -121306,7 +121392,7 @@ async function fileSourceDocumentSiteHint(input) {
121306
121392
  let snapshotConfigured = false;
121307
121393
  const manifest = documentSourceManifestPath(input.source);
121308
121394
  try {
121309
- const parsed = parseDocumentSnapshotForSource(JSON.parse(await readFile106(join132(input.projectRoot, manifest), "utf8")), input.source.name);
121395
+ const parsed = parseDocumentSnapshotForSource(JSON.parse(await readFile107(join133(input.projectRoot, manifest), "utf8")), input.source.name);
121310
121396
  snapshotConfigured = manifestUsesMdxJsonDocs(parsed);
121311
121397
  } catch {
121312
121398
  snapshotConfigured = false;
@@ -121339,11 +121425,11 @@ async function larkSourceAgentViewWithNextAction(input) {
121339
121425
  init_documentBatchManifest();
121340
121426
  init_documentSnapshotFidelity();
121341
121427
  function documentSourceManifestPath2(source2) {
121342
- return source2.snapshot?.manifest ?? join133(source2.materializedAt, "manifest.json");
121428
+ return source2.snapshot?.manifest ?? join134(source2.materializedAt, "manifest.json");
121343
121429
  }
121344
121430
  async function documentSnapshotState(input) {
121345
121431
  const manifest = documentSourceManifestPath2(input.source);
121346
- const manifestPath = join133(input.projectRoot, manifest);
121432
+ const manifestPath = join134(input.projectRoot, manifest);
121347
121433
  if (!existsSync35(manifestPath)) {
121348
121434
  return {
121349
121435
  snapshotReady: false,
@@ -121354,7 +121440,7 @@ async function documentSnapshotState(input) {
121354
121440
  };
121355
121441
  }
121356
121442
  try {
121357
- const parsed = findDocumentSnapshotForSource(JSON.parse(await readFile107(manifestPath, "utf8")), input.source.name);
121443
+ const parsed = findDocumentSnapshotForSource(JSON.parse(await readFile108(manifestPath, "utf8")), input.source.name);
121358
121444
  if (parsed === null) {
121359
121445
  return {
121360
121446
  snapshotReady: false,
@@ -121422,7 +121508,7 @@ async function documentSnapshotState(input) {
121422
121508
  const missing2 = [
121423
121509
  ...parsed.files.map((file) => file.path),
121424
121510
  ...(parsed.assets ?? []).filter((asset) => asset.content_hash !== undefined).map((asset) => asset.path)
121425
- ].find((path3) => !existsSync35(join133(input.projectRoot, input.source.materializedAt, path3)));
121511
+ ].find((path3) => !existsSync35(join134(input.projectRoot, input.source.materializedAt, path3)));
121426
121512
  if (missing2 !== undefined) {
121427
121513
  return {
121428
121514
  snapshotReady: false,
@@ -121523,8 +121609,8 @@ init_errors3();
121523
121609
  init_exitCode();
121524
121610
  var import_yaml59 = __toESM(require_dist(), 1);
121525
121611
  import { createHash as createHash42 } from "node:crypto";
121526
- import { readFile as readFile108, realpath as realpath17 } from "node:fs/promises";
121527
- import { basename as basename13, extname as extname15, isAbsolute as isAbsolute24, join as join134, relative as relative35, resolve as resolve44 } from "node:path";
121612
+ import { readFile as readFile109, realpath as realpath17 } from "node:fs/promises";
121613
+ import { basename as basename13, extname as extname15, isAbsolute as isAbsolute24, join as join135, relative as relative35, resolve as resolve44 } from "node:path";
121528
121614
  init_writeLock();
121529
121615
  var SOURCE_NAME_PATTERN3 = /^[a-z0-9][a-z0-9._-]*$/u;
121530
121616
  function isDateSourceNamespace(value) {
@@ -121620,7 +121706,7 @@ function assertSafeFileInclude(value) {
121620
121706
  }
121621
121707
  async function readRegistryDocument(projectRoot2, registryPath2) {
121622
121708
  try {
121623
- const content3 = await readFile108(join134(projectRoot2, registryPath2), "utf8");
121709
+ const content3 = await readFile109(join135(projectRoot2, registryPath2), "utf8");
121624
121710
  return content3.trim().length === 0 ? { sources: [] } : import_yaml59.default.parse(content3);
121625
121711
  } catch (error) {
121626
121712
  if (error instanceof Error && "code" in error && error.code === "ENOENT")
@@ -121710,10 +121796,10 @@ function flatRawSource(sources, name3) {
121710
121796
  }
121711
121797
  async function ensureOriginInstallRootIgnored(projectRoot2, kind) {
121712
121798
  const line = `${fileSourceOriginInstallRoot(kind)}/`;
121713
- const path3 = join134(projectRoot2, ".gitignore");
121799
+ const path3 = join135(projectRoot2, ".gitignore");
121714
121800
  let current3 = "";
121715
121801
  try {
121716
- current3 = await readFile108(path3, "utf8");
121802
+ current3 = await readFile109(path3, "utf8");
121717
121803
  } catch {
121718
121804
  current3 = "";
121719
121805
  }
@@ -121811,7 +121897,7 @@ async function addFileSourceUnlocked(input) {
121811
121897
  sourceName: input.name
121812
121898
  });
121813
121899
  }
121814
- await atomicWriteFile(join134(input.projectRoot, DEFAULT_FILE_SOURCES_REGISTRY_PATH), import_yaml59.default.stringify({ sources: nextSources }));
121900
+ await atomicWriteFile(join135(input.projectRoot, DEFAULT_FILE_SOURCES_REGISTRY_PATH), import_yaml59.default.stringify({ sources: nextSources }));
121815
121901
  const gitignoreUpdated = origin !== undefined && await ensureOriginInstallRootIgnored(input.projectRoot, origin.kind);
121816
121902
  const updated = await loadSourcesRegistry({ rootDir: input.projectRoot });
121817
121903
  const entry = updated.files.find((source2) => source2.name === input.name || source2.id === input.name);
@@ -121872,7 +121958,7 @@ async function addLarkSourceUnlocked(input) {
121872
121958
  const record6 = entry2;
121873
121959
  return record6.name !== input.name && record6.id !== input.name;
121874
121960
  }), nextEntry];
121875
- await atomicWriteFile(join134(input.projectRoot, DEFAULT_LARK_SOURCES_REGISTRY_PATH), import_yaml59.default.stringify({ sources: nextSources }));
121961
+ await atomicWriteFile(join135(input.projectRoot, DEFAULT_LARK_SOURCES_REGISTRY_PATH), import_yaml59.default.stringify({ sources: nextSources }));
121876
121962
  const updated = await loadSourcesRegistry({ rootDir: input.projectRoot });
121877
121963
  const entry = updated.larks.find((source2) => source2.name === input.name || source2.id === input.name);
121878
121964
  if (entry === undefined) {
@@ -121904,18 +121990,18 @@ init_cliFeedback();
121904
121990
  init_errors3();
121905
121991
  init_exitCode();
121906
121992
  var import_yaml60 = __toESM(require_dist(), 1);
121907
- import { readFile as readFile109 } from "node:fs/promises";
121908
- import { join as join135 } from "node:path";
121993
+ import { readFile as readFile110 } from "node:fs/promises";
121994
+ import { join as join136 } from "node:path";
121909
121995
  import { isDeepStrictEqual as isDeepStrictEqual3 } from "node:util";
121910
121996
  function identityKeys(entry) {
121911
121997
  return new Set([entry.name, entry.id]);
121912
121998
  }
121913
121999
  async function createLarkBatchRegistration(projectRoot2, namespace) {
121914
122000
  const registry2 = await loadSourcesRegistry({ rootDir: projectRoot2 });
121915
- const registryPath2 = join135(projectRoot2, DEFAULT_LARK_SOURCES_REGISTRY_PATH);
122001
+ const registryPath2 = join136(projectRoot2, DEFAULT_LARK_SOURCES_REGISTRY_PATH);
121916
122002
  let committedSources;
121917
122003
  try {
121918
- const text12 = await readFile109(registryPath2, "utf8");
122004
+ const text12 = await readFile110(registryPath2, "utf8");
121919
122005
  committedSources = text12.trim().length === 0 ? [] : import_yaml60.default.parse(text12).sources ?? [];
121920
122006
  } catch (error) {
121921
122007
  if (!(error instanceof Error && ("code" in error) && error.code === "ENOENT"))
@@ -122033,8 +122119,8 @@ init_cliFeedback();
122033
122119
  init_errors3();
122034
122120
  init_exitCode();
122035
122121
  import { createHash as createHash43 } from "node:crypto";
122036
- import { lstat as lstat20, readFile as readFile110 } from "node:fs/promises";
122037
- import { join as join136, resolve as resolve45 } from "node:path";
122122
+ import { lstat as lstat20, readFile as readFile111 } from "node:fs/promises";
122123
+ import { join as join137, resolve as resolve45 } from "node:path";
122038
122124
  var INPUT_SCHEMA = "context.source-batch.input.v1";
122039
122125
  var STATE_SCHEMA = "context.source-batch.state.v1";
122040
122126
  var RUNTIME_PARTS = [".tmp", "context-runtime", "source-batches"];
@@ -122085,14 +122171,14 @@ function paths(projectRoot2, jobId) {
122085
122171
  throw journalError("source-batch-id-invalid", "Source batch checkpoint ID must contain exactly 32 lowercase hexadecimal characters.");
122086
122172
  }
122087
122173
  const directory = resolve45(projectRoot2, ...RUNTIME_PARTS, jobId);
122088
- return { inputPath: join136(directory, "input.json"), statePath: join136(directory, "state.json") };
122174
+ return { inputPath: join137(directory, "input.json"), statePath: join137(directory, "state.json") };
122089
122175
  }
122090
122176
  async function assertJournalPath(projectRoot2, jobId, filename) {
122091
122177
  paths(projectRoot2, jobId);
122092
122178
  let current3 = resolve45(projectRoot2);
122093
122179
  const parts = [...RUNTIME_PARTS, jobId, filename];
122094
122180
  for (const [index3, part] of parts.entries()) {
122095
- current3 = join136(current3, part);
122181
+ current3 = join137(current3, part);
122096
122182
  let stat11;
122097
122183
  try {
122098
122184
  stat11 = await lstat20(current3);
@@ -122123,7 +122209,7 @@ async function loadSourceBatchJournal(input) {
122123
122209
  const { inputPath } = paths(input.projectRoot, input.jobId);
122124
122210
  try {
122125
122211
  await assertJournalPath(input.projectRoot, input.jobId, "input.json");
122126
- const stored = JSON.parse(await readFile110(inputPath, "utf8"));
122212
+ const stored = JSON.parse(await readFile111(inputPath, "utf8"));
122127
122213
  if (stored === null || typeof stored !== "object" || Array.isArray(stored)) {
122128
122214
  throw journalError("source-batch-input-invalid", "Source batch checkpoint input must be an object.");
122129
122215
  }
@@ -122226,7 +122312,7 @@ async function readSourceBatchJournalStatus(input) {
122226
122312
  let warning;
122227
122313
  try {
122228
122314
  await assertJournalPath(journal.projectRoot, journal.jobId, "state.json");
122229
- const parsed = JSON.parse(await readFile110(journal.statePath, "utf8"));
122315
+ const parsed = JSON.parse(await readFile111(journal.statePath, "utf8"));
122230
122316
  if (parsed.schema !== STATE_SCHEMA || parsed.job_id !== journal.jobId || parsed.input_digest !== journal.inputDigest || parsed.total !== journal.items.length || !Number.isSafeInteger(parsed.pid) || parsed.pid <= 0 || typeof parsed.updated_at !== "string" || !Number.isFinite(Date.parse(parsed.updated_at))) {
122231
122317
  throw journalError("source-batch-state-invalid", "Source batch checkpoint progress is invalid.");
122232
122318
  }
@@ -122824,13 +122910,13 @@ init_exitCode();
122824
122910
 
122825
122911
  // src/project/wikiDiscovery.ts
122826
122912
  import { mkdir as mkdir44 } from "node:fs/promises";
122827
- import { join as join138, relative as relative37 } from "node:path";
122913
+ import { join as join139, relative as relative37 } from "node:path";
122828
122914
 
122829
122915
  // src/project/wikiDiscoveryStore.ts
122830
122916
  init_atomicWrite();
122831
122917
  import { createHash as createHash44, randomUUID as randomUUID9 } from "node:crypto";
122832
- import { link as link2, lstat as lstat21, mkdir as mkdir43, readFile as readFile111, readdir as readdir32, rm as rm32, writeFile as writeFile33 } from "node:fs/promises";
122833
- import { join as join137, relative as relative36, resolve as resolve46, sep as sep11 } from "node:path";
122918
+ import { link as link2, lstat as lstat21, mkdir as mkdir43, readFile as readFile112, readdir as readdir32, rm as rm32, writeFile as writeFile33 } from "node:fs/promises";
122919
+ import { join as join138, relative as relative36, resolve as resolve46, sep as sep11 } from "node:path";
122834
122920
  function wikiDiscoveryDigest(value) {
122835
122921
  return createHash44("sha256").update(value).digest("hex");
122836
122922
  }
@@ -122844,7 +122930,7 @@ async function assertWikiDiscoveryPath(root2, path3) {
122844
122930
  throw new WikiDiscoveryError("unsafe-checkpoint-path", false, "Discovery checkpoint must stay inside its workspace");
122845
122931
  let current3 = base;
122846
122932
  for (const part of parts) {
122847
- current3 = join137(current3, part);
122933
+ current3 = join138(current3, part);
122848
122934
  try {
122849
122935
  if ((await lstat21(current3)).isSymbolicLink()) {
122850
122936
  throw new WikiDiscoveryError("unsafe-checkpoint-path", false, "Discovery checkpoint paths must not contain symbolic links");
@@ -122860,7 +122946,7 @@ async function readWikiDiscoveryJson(path3) {
122860
122946
  try {
122861
122947
  if ((await lstat21(path3)).isSymbolicLink())
122862
122948
  throw new WikiDiscoveryError("unsafe-checkpoint-path", false, "Discovery checkpoint must not be a symbolic link");
122863
- return JSON.parse(await readFile111(path3, "utf8"));
122949
+ return JSON.parse(await readFile112(path3, "utf8"));
122864
122950
  } catch (error) {
122865
122951
  if (error && typeof error === "object" && "code" in error && error.code === "ENOENT")
122866
122952
  return;
@@ -122873,12 +122959,12 @@ async function saveWikiDiscoveryJson(path3, value) {
122873
122959
  }
122874
122960
  async function loadWikiDiscoveryReceipts(directory) {
122875
122961
  const result = new Map;
122876
- await assertWikiDiscoveryPath(directory, join137(directory, "pages"));
122877
- await mkdir43(join137(directory, "pages"), { recursive: true });
122878
- for (const file of await readdir32(join137(directory, "pages"))) {
122962
+ await assertWikiDiscoveryPath(directory, join138(directory, "pages"));
122963
+ await mkdir43(join138(directory, "pages"), { recursive: true });
122964
+ for (const file of await readdir32(join138(directory, "pages"))) {
122879
122965
  if (!/^[a-f0-9]{64}\.json$/u.test(file))
122880
122966
  continue;
122881
- const value = await readWikiDiscoveryJson(join137(directory, "pages", file));
122967
+ const value = await readWikiDiscoveryJson(join138(directory, "pages", file));
122882
122968
  if (!value || typeof value.parent_node_token !== "string" || value.page_token !== undefined && typeof value.page_token !== "string" || !["completed", "failed"].includes(value.status) || value.status === "completed" && (!value.page || !Array.isArray(value.page.nodes) || value.page.next_page_token !== undefined && typeof value.page.next_page_token !== "string") || value.status === "failed" && (!value.failure || typeof value.failure.retryable !== "boolean" || typeof value.failure.reason !== "string" || typeof value.failure.message !== "string") || `${wikiDiscoveryPageKey(value)}.json` !== file) {
122883
122969
  throw new WikiDiscoveryError("checkpoint-invalid", false, "Discovery page checkpoint is invalid; preserve it for inspection");
122884
122970
  }
@@ -122897,14 +122983,14 @@ function ownerRunning(pid) {
122897
122983
  }
122898
122984
  }
122899
122985
  async function acquireWikiDiscoveryLease(directory) {
122900
- const leases = join137(directory, "leases");
122986
+ const leases = join138(directory, "leases");
122901
122987
  await assertWikiDiscoveryPath(directory, leases);
122902
122988
  await mkdir43(leases, { recursive: true });
122903
122989
  for (let attempt = 0;attempt < 8; attempt++) {
122904
122990
  const files = (await readdir32(leases)).filter((file) => /^\d{12}\.json$/u.test(file)).sort();
122905
122991
  const latest = files.at(-1);
122906
122992
  if (latest) {
122907
- const current3 = await readWikiDiscoveryJson(join137(leases, latest));
122993
+ const current3 = await readWikiDiscoveryJson(join138(leases, latest));
122908
122994
  if (!current3 || !Number.isSafeInteger(current3.pid) || current3.pid <= 0 || typeof current3.token !== "string" || typeof current3.released !== "boolean") {
122909
122995
  throw new WikiDiscoveryError("checkpoint-invalid", false, "Discovery lease is invalid; preserve it for inspection");
122910
122996
  }
@@ -122913,9 +122999,9 @@ async function acquireWikiDiscoveryLease(directory) {
122913
122999
  }
122914
123000
  }
122915
123001
  const sequence = latest ? Number(latest.slice(0, 12)) + 1 : 1;
122916
- const path3 = join137(leases, `${String(sequence).padStart(12, "0")}.json`);
123002
+ const path3 = join138(leases, `${String(sequence).padStart(12, "0")}.json`);
122917
123003
  const owner = { pid: process.pid, token: randomUUID9(), released: false };
122918
- const temporary = join137(leases, `.lease-${owner.token}`);
123004
+ const temporary = join138(leases, `.lease-${owner.token}`);
122919
123005
  await writeFile33(temporary, JSON.stringify(owner), { flag: "wx", mode: 384 });
122920
123006
  try {
122921
123007
  await link2(temporary, path3);
@@ -123040,7 +123126,7 @@ async function discoverLarkWiki(input) {
123040
123126
  throw new WikiDiscoveryError("invalid-concurrency", false, "Wiki concurrency must be an integer from 1 to 4");
123041
123127
  }
123042
123128
  const jobId = wikiDiscoveryDigest(url);
123043
- const directory = join138(input.projectRoot, ".tmp", "context-runtime", "wiki-discovery", jobId);
123129
+ const directory = join139(input.projectRoot, ".tmp", "context-runtime", "wiki-discovery", jobId);
123044
123130
  await assertWikiDiscoveryPath(input.projectRoot, directory);
123045
123131
  await mkdir44(directory, { recursive: true });
123046
123132
  const release = await acquireWikiDiscoveryLease(directory);
@@ -123052,7 +123138,7 @@ async function discoverLarkWiki(input) {
123052
123138
  }
123053
123139
  async function runDiscovery(input, job) {
123054
123140
  const { directory, url, identity: identity2 } = job;
123055
- const metadataPath = join138(directory, "job.json");
123141
+ const metadataPath = join139(directory, "job.json");
123056
123142
  let metadata = await readWikiDiscoveryJson(metadataPath);
123057
123143
  if (metadata && (metadata.protocol !== "context.wiki-discovery.v1" || metadata.url !== url || metadata.identity !== identity2)) {
123058
123144
  throw new WikiDiscoveryError("job-identity-mismatch", false, "Resume must preserve the discovery's original URL and identity");
@@ -123101,7 +123187,7 @@ async function runDiscovery(input, job) {
123101
123187
  }
123102
123188
  const key = wikiDiscoveryPageKey(cursor);
123103
123189
  try {
123104
- await saveWikiDiscoveryJson(join138(directory, "pages", `${key}.json`), receipt2);
123190
+ await saveWikiDiscoveryJson(join139(directory, "pages", `${key}.json`), receipt2);
123105
123191
  receipts.set(key, receipt2);
123106
123192
  } catch {
123107
123193
  checkpointError = "A discovery page could not be checkpointed; saved pages remain reusable and unsaved pages must be requested again";
@@ -123119,7 +123205,7 @@ async function finishDiscovery(input, state) {
123119
123205
  const { directory, url, identity: identity2, jobId, metadata, view } = state;
123120
123206
  let checkpointError = state.checkpointError;
123121
123207
  let status = input.signal?.aborted ? "paused" : checkpointError || view.pending.length || view.failed.length || !metadata.root ? "partial" : "completed";
123122
- const manifestPath = join138(directory, "manifest.json");
123208
+ const manifestPath = join139(directory, "manifest.json");
123123
123209
  try {
123124
123210
  await saveWikiDiscoveryJson(manifestPath, {
123125
123211
  protocol: "context.wiki-discovery.manifest.v1",
@@ -123299,8 +123385,8 @@ init_writeLock();
123299
123385
  var import_yaml63 = __toESM(require_dist(), 1);
123300
123386
  import { existsSync as existsSync36 } from "node:fs";
123301
123387
  import { createHash as createHash45 } from "node:crypto";
123302
- import { readFile as readFile112, readdir as readdir33, rm as rm33 } from "node:fs/promises";
123303
- import { isAbsolute as isAbsolute25, join as join139, relative as relative38, resolve as resolve47, sep as sep12 } from "node:path";
123388
+ import { readFile as readFile113, readdir as readdir33, rm as rm33 } from "node:fs/promises";
123389
+ import { isAbsolute as isAbsolute25, join as join140, relative as relative38, resolve as resolve47, sep as sep12 } from "node:path";
123304
123390
  function sourceIdentity(source2) {
123305
123391
  if (source2.kind === "source.collection")
123306
123392
  return;
@@ -123332,10 +123418,10 @@ function collectStrings(value, output) {
123332
123418
  }
123333
123419
  }
123334
123420
  async function yamlReferences(input) {
123335
- const absolutePath = join139(input.projectRoot, input.path);
123421
+ const absolutePath = join140(input.projectRoot, input.path);
123336
123422
  if (!existsSync36(absolutePath))
123337
123423
  return false;
123338
- const parsed = import_yaml63.default.parse(await readFile112(absolutePath, "utf8"));
123424
+ const parsed = import_yaml63.default.parse(await readFile113(absolutePath, "utf8"));
123339
123425
  const strings = [];
123340
123426
  collectStrings(parsed, strings);
123341
123427
  return strings.some((value) => stringReferencesSource(value, input.source));
@@ -123481,8 +123567,8 @@ async function registryRemovalWrite(projectRoot2, source2) {
123481
123567
  const path3 = registryPath2(source2.type);
123482
123568
  if (path3 === null)
123483
123569
  return;
123484
- const absolutePath = join139(projectRoot2, path3);
123485
- const document4 = existsSync36(absolutePath) ? import_yaml63.default.parse(await readFile112(absolutePath, "utf8")) : { sources: [] };
123570
+ const absolutePath = join140(projectRoot2, path3);
123571
+ const document4 = existsSync36(absolutePath) ? import_yaml63.default.parse(await readFile113(absolutePath, "utf8")) : { sources: [] };
123486
123572
  return {
123487
123573
  path: absolutePath,
123488
123574
  bytes: import_yaml63.default.stringify(removeDocumentEntry(document4, source2))
@@ -123500,7 +123586,7 @@ function safeManagedMaterializedPath(projectRoot2, source2) {
123500
123586
  return absolute;
123501
123587
  }
123502
123588
  function safeManagedManifestPath(projectRoot2, source2) {
123503
- const manifest = source2.manifest ?? join139(source2.materializedAt, "manifest.json");
123589
+ const manifest = source2.manifest ?? join140(source2.materializedAt, "manifest.json");
123504
123590
  if (isAbsolute25(manifest))
123505
123591
  throw unsafeOwnership(source2, manifest);
123506
123592
  const absolute = resolve47(projectRoot2, manifest);
@@ -123629,7 +123715,7 @@ async function createRemovalPlan(projectRoot2, selector) {
123629
123715
  source: source2,
123630
123716
  registry: registryPath2(source2.type),
123631
123717
  registryBytes: registryWrite?.bytes ?? null,
123632
- managedBytes: source2.type === "note" || source2.type === "sessions" ? await readFile112(absoluteRemovals[0], "utf8") : null,
123718
+ managedBytes: source2.type === "note" || source2.type === "sessions" ? await readFile113(absoluteRemovals[0], "utf8") : null,
123633
123719
  references,
123634
123720
  cleanup,
123635
123721
  manifestBytes: manifestWrite?.bytes ?? null
@@ -123662,10 +123748,10 @@ function publicRemovalResult(plan, action) {
123662
123748
  };
123663
123749
  }
123664
123750
  async function pruneExtractRuntime(projectRoot2, source2) {
123665
- const fingerprintPath = join139(projectRoot2, ".tmp/context-runtime/extract/source-fingerprints.json");
123751
+ const fingerprintPath = join140(projectRoot2, ".tmp/context-runtime/extract/source-fingerprints.json");
123666
123752
  const removedPhaseIds = new Set;
123667
123753
  if (existsSync36(fingerprintPath)) {
123668
- const parsed = JSON.parse(await readFile112(fingerprintPath, "utf8"));
123754
+ const parsed = JSON.parse(await readFile113(fingerprintPath, "utf8"));
123669
123755
  const phases = parsed.phases ?? {};
123670
123756
  const next2 = Object.fromEntries(Object.entries(phases).filter(([phaseId, raw]) => {
123671
123757
  if (raw === null || typeof raw !== "object" || Array.isArray(raw))
@@ -123679,27 +123765,27 @@ async function pruneExtractRuntime(projectRoot2, source2) {
123679
123765
  await atomicWriteFile(fingerprintPath, `${JSON.stringify({ ...parsed, phases: next2 }, null, 2)}
123680
123766
  `);
123681
123767
  }
123682
- const phaseOwnershipPath = join139(projectRoot2, ".tmp/context-runtime/extract/custom-phase-candidates.json");
123768
+ const phaseOwnershipPath = join140(projectRoot2, ".tmp/context-runtime/extract/custom-phase-candidates.json");
123683
123769
  if (existsSync36(phaseOwnershipPath) && removedPhaseIds.size > 0) {
123684
- const parsed = JSON.parse(await readFile112(phaseOwnershipPath, "utf8"));
123770
+ const parsed = JSON.parse(await readFile113(phaseOwnershipPath, "utf8"));
123685
123771
  const phases = Object.fromEntries(Object.entries(parsed.phases ?? {}).filter(([phaseId]) => !removedPhaseIds.has(phaseId)));
123686
123772
  await atomicWriteFile(phaseOwnershipPath, `${JSON.stringify({ ...parsed, phases }, null, 2)}
123687
123773
  `);
123688
123774
  }
123689
- const symbolPath = join139(projectRoot2, ".tmp/context-runtime/extract/source-symbols.json");
123775
+ const symbolPath = join140(projectRoot2, ".tmp/context-runtime/extract/source-symbols.json");
123690
123776
  if (existsSync36(symbolPath)) {
123691
- const parsed = JSON.parse(await readFile112(symbolPath, "utf8"));
123777
+ const parsed = JSON.parse(await readFile113(symbolPath, "utf8"));
123692
123778
  const symbols = Array.isArray(parsed.symbols) ? parsed.symbols.filter((entry) => entry === null || typeof entry !== "object" || Array.isArray(entry) || entry.source !== source2.name) : [];
123693
123779
  const phaseFingerprints = Object.fromEntries(Object.entries(parsed.phaseFingerprints ?? {}).filter(([phaseId]) => !removedPhaseIds.has(phaseId)));
123694
123780
  await atomicWriteFile(symbolPath, `${JSON.stringify({ ...parsed, phaseFingerprints, symbols }, null, 2)}
123695
123781
  `);
123696
123782
  }
123697
- const snapshotRoot = join139(projectRoot2, ".tmp/context-runtime/extract/candidates");
123783
+ const snapshotRoot = join140(projectRoot2, ".tmp/context-runtime/extract/candidates");
123698
123784
  const visit4 = async (directory) => {
123699
123785
  if (!existsSync36(directory))
123700
123786
  return;
123701
123787
  for (const entry of await readdir33(directory, { withFileTypes: true })) {
123702
- const path3 = join139(directory, entry.name);
123788
+ const path3 = join140(directory, entry.name);
123703
123789
  if (entry.isDirectory()) {
123704
123790
  await visit4(path3);
123705
123791
  continue;
@@ -123707,7 +123793,7 @@ async function pruneExtractRuntime(projectRoot2, source2) {
123707
123793
  if (!entry.isFile() || !entry.name.endsWith(".json"))
123708
123794
  continue;
123709
123795
  try {
123710
- const parsed = JSON.parse(await readFile112(path3, "utf8"));
123796
+ const parsed = JSON.parse(await readFile113(path3, "utf8"));
123711
123797
  const refs = Array.isArray(parsed.source_refs) ? parsed.source_refs : [];
123712
123798
  if (parsed.source === source2.name || refs.some((ref2) => typeof ref2 === "string" && stringReferencesSource(ref2, source2))) {
123713
123799
  await rm33(path3, { force: true });
@@ -123749,7 +123835,7 @@ async function removeProjectSource(input) {
123749
123835
  });
123750
123836
  }
123751
123837
  await applyAtomicFileBatch({
123752
- transactionRoot: join139(input.projectRoot, ".tmp", "context-runtime", "source-remove-transactions"),
123838
+ transactionRoot: join140(input.projectRoot, ".tmp", "context-runtime", "source-remove-transactions"),
123753
123839
  writes: [...plan.registryWrite === undefined ? [] : [plan.registryWrite], ...plan.manifestWrite !== undefined ? [plan.manifestWrite] : []],
123754
123840
  removals: plan.absoluteRemovals
123755
123841
  });
@@ -123765,7 +123851,7 @@ init_workspace();
123765
123851
  init_writeLock();
123766
123852
  init_durableMultiFileTransaction();
123767
123853
  init_durableSingleFileTransaction();
123768
- import { readFile as readFile113 } from "node:fs/promises";
123854
+ import { readFile as readFile114 } from "node:fs/promises";
123769
123855
  import ts from "typescript";
123770
123856
  function generateSourceConfiguration(text12, selected) {
123771
123857
  const file = ts.createSourceFile("index.ts", text12, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
@@ -123905,7 +123991,7 @@ function generateSourceConfiguration(text12, selected) {
123905
123991
  async function configureRegisteredSources(projectRoot2, selected) {
123906
123992
  return withProjectWriteLock(projectRoot2, "source-project-configuration", async () => {
123907
123993
  const path3 = "src/index.ts";
123908
- const config = JSON.parse(await readFile113(await safeProjectTarget(projectRoot2, "package.json"), "utf8"));
123994
+ const config = JSON.parse(await readFile114(await safeProjectTarget(projectRoot2, "package.json"), "utf8"));
123909
123995
  if (config.context?.entry !== path3)
123910
123996
  return {
123911
123997
  status: "manual",
@@ -123914,7 +124000,7 @@ async function configureRegisteredSources(projectRoot2, selected) {
123914
124000
  sources: selected
123915
124001
  };
123916
124002
  const target = await safeProjectTarget(projectRoot2, path3);
123917
- const text12 = await readFile113(target, "utf8");
124003
+ const text12 = await readFile114(target, "utf8");
123918
124004
  const updated = generateSourceConfiguration(text12, selected);
123919
124005
  if (updated === undefined)
123920
124006
  return {
@@ -123950,7 +124036,7 @@ init_sourceInputMutation();
123950
124036
  init_writeLock();
123951
124037
  import { execFile as execFile20 } from "node:child_process";
123952
124038
  import { promisify as promisify17 } from "node:util";
123953
- import { join as join140 } from "node:path";
124039
+ import { join as join141 } from "node:path";
123954
124040
  var exec6 = promisify17(execFile20);
123955
124041
  var requestSchema3 = exports_external.object({ type: exports_external.enum(["file", "lark"]), name: exports_external.string().min(1), commit: exports_external.string().min(1).optional() }).strict();
123956
124042
  async function restoreDocumentSnapshot(projectRoot2, value) {
@@ -124042,8 +124128,8 @@ async function restoreDocumentSnapshot(projectRoot2, value) {
124042
124128
  const removals = [...previous3?.files ?? [], ...previous3?.assets ?? []].map((file) => `${source2.materializedAt}/${file.path}`).filter((path3) => !selected.files.has(path3) && !renderDocumentManifestFile(next2).includes(path3.slice(source2.materializedAt.length + 1)));
124043
124129
  const removalTargets = await Promise.all(removals.map((path3) => safeProjectTarget(projectRoot2, path3)));
124044
124130
  await applyAtomicFileBatch({
124045
- transactionRoot: join140(projectRoot2, ".tmp/context-runtime/capture-transactions"),
124046
- writes: [...selected.files].map(([path3, bytes]) => ({ path: join140(projectRoot2, path3), bytes })).concat([
124131
+ transactionRoot: join141(projectRoot2, ".tmp/context-runtime/capture-transactions"),
124132
+ writes: [...selected.files].map(([path3, bytes]) => ({ path: join141(projectRoot2, path3), bytes })).concat([
124047
124133
  { path: manifestTarget, bytes: Buffer.from(renderDocumentManifestFile(next2)) }
124048
124134
  ]),
124049
124135
  removals: removalTargets
@@ -124116,7 +124202,7 @@ async function readIncludeList(projectRoot2, path3) {
124116
124202
  }
124117
124203
  let content3;
124118
124204
  try {
124119
- content3 = await readFile117(isAbsolute26(trimmed) ? resolve49(trimmed) : resolve49(projectRoot2, trimmed), "utf8");
124205
+ content3 = await readFile118(isAbsolute26(trimmed) ? resolve49(trimmed) : resolve49(projectRoot2, trimmed), "utf8");
124120
124206
  } catch (error) {
124121
124207
  throw new ContextError(ExitCode.UserError, `cannot read include list: ${trimmed}`, {
124122
124208
  category: ErrorCategory.UserInputInvalid,
@@ -124578,7 +124664,7 @@ init_exitCode();
124578
124664
  var import_yaml66 = __toESM(require_dist(), 1);
124579
124665
  import { constants as constants6, existsSync as existsSync37 } from "node:fs";
124580
124666
  import { lstat as lstat22, open as open5, readdir as readdir34 } from "node:fs/promises";
124581
- import { dirname as dirname52, join as join142, resolve as resolve50 } from "node:path";
124667
+ import { dirname as dirname52, join as join143, resolve as resolve50 } from "node:path";
124582
124668
  import { fileURLToPath as fileURLToPath10 } from "node:url";
124583
124669
  function bundledSkillRoot() {
124584
124670
  const directory = dirname52(fileURLToPath10(import.meta.url));
@@ -124608,7 +124694,7 @@ async function readProductionSkills(root2) {
124608
124694
  const entries2 = (await readdir34(root2, { withFileTypes: true })).filter((entry) => entry.isDirectory()).sort((a2, b) => a2.name < b.name ? -1 : a2.name > b.name ? 1 : 0);
124609
124695
  const skills = [];
124610
124696
  for (const directory of entries2) {
124611
- const entry = join142(root2, directory.name, "SKILL.md");
124697
+ const entry = join143(root2, directory.name, "SKILL.md");
124612
124698
  if (!(await lstat22(entry)).isFile())
124613
124699
  throw new TypeError(`Skill entry must be a regular file: ${entry}`);
124614
124700
  const handle3 = await open5(entry, constants6.O_RDONLY | constants6.O_NOFOLLOW | constants6.O_NONBLOCK);
@@ -125022,8 +125108,8 @@ init_cliFeedback();
125022
125108
  init_errors3();
125023
125109
  init_exitCode();
125024
125110
  import { createHash as createHash46 } from "node:crypto";
125025
- import { cp as cp3, lstat as lstat23, mkdir as mkdir45, mkdtemp as mkdtemp7, readFile as readFile118, readdir as readdir35, rename as rename12, rm as rm34, writeFile as writeFile34 } from "node:fs/promises";
125026
- import { dirname as dirname54, join as join143, resolve as resolve52 } from "node:path";
125111
+ import { cp as cp3, lstat as lstat23, mkdir as mkdir45, mkdtemp as mkdtemp7, readFile as readFile119, readdir as readdir35, rename as rename12, rm as rm34, writeFile as writeFile34 } from "node:fs/promises";
125112
+ import { dirname as dirname54, join as join144, resolve as resolve52 } from "node:path";
125027
125113
  var MARKER = ".context-skill-install.json";
125028
125114
  function conflict(path3) {
125029
125115
  throw new ContextError(ExitCode.UserError, `Local skill install conflict: ${path3}`, {
@@ -125054,7 +125140,7 @@ async function digest9(root2) {
125054
125140
  for (const name3 of (await readdir35(dir)).sort()) {
125055
125141
  if (!prefix && name3 === MARKER)
125056
125142
  continue;
125057
- const path3 = join143(dir, name3);
125143
+ const path3 = join144(dir, name3);
125058
125144
  const entry = await lstat23(path3);
125059
125145
  if (entry.isSymbolicLink())
125060
125146
  conflict(path3);
@@ -125062,7 +125148,7 @@ async function digest9(root2) {
125062
125148
  if (entry.isDirectory())
125063
125149
  await visit4(path3, `${prefix}${name3}/`);
125064
125150
  else if (entry.isFile())
125065
- hash5.update(await readFile118(path3));
125151
+ hash5.update(await readFile119(path3));
125066
125152
  else
125067
125153
  conflict(path3);
125068
125154
  }
@@ -125073,12 +125159,12 @@ async function digest9(root2) {
125073
125159
  async function assertOwnedDirectory(target, existing) {
125074
125160
  if (!existing.isDirectory() || existing.isSymbolicLink())
125075
125161
  conflict(target);
125076
- const markerPath = join143(target, MARKER);
125162
+ const markerPath = join144(target, MARKER);
125077
125163
  if (!(await stat11(markerPath))?.isFile())
125078
125164
  conflict(target);
125079
125165
  let marker;
125080
125166
  try {
125081
- marker = JSON.parse(await readFile118(markerPath, "utf8"));
125167
+ marker = JSON.parse(await readFile119(markerPath, "utf8"));
125082
125168
  } catch {
125083
125169
  conflict(target);
125084
125170
  }
@@ -125089,24 +125175,24 @@ async function installLocalSkills(root2, path3, dryRun, agent) {
125089
125175
  if (!path3.trim())
125090
125176
  conflict("--local requires a non-empty path");
125091
125177
  const targetRoot = resolve52(path3);
125092
- const skillsRoot = join143(targetRoot, "skills");
125178
+ const skillsRoot = join144(targetRoot, "skills");
125093
125179
  await checkParents(skillsRoot);
125094
- const sourceRoot = join143(root2, "skills");
125180
+ const sourceRoot = join144(root2, "skills");
125095
125181
  const commandPlans = [];
125096
125182
  const commandEntries = new Set;
125097
125183
  if (agent === "claude" || agent === "cursor") {
125098
- for (const name3 of await readdir35(join143(root2, "claude", "commands"))) {
125184
+ for (const name3 of await readdir35(join144(root2, "claude", "commands"))) {
125099
125185
  if (name3.endsWith(".md"))
125100
125186
  commandEntries.add(name3.slice(0, -3));
125101
125187
  }
125102
- const commandsRoot = join143(targetRoot, "commands");
125188
+ const commandsRoot = join144(targetRoot, "commands");
125103
125189
  await checkParents(commandsRoot);
125104
- for (const entry of await readdir35(join143(root2, agent, "commands"), { withFileTypes: true })) {
125190
+ for (const entry of await readdir35(join144(root2, agent, "commands"), { withFileTypes: true })) {
125105
125191
  if (!entry.isFile() || !entry.name.endsWith(".md"))
125106
125192
  continue;
125107
- const content3 = await readFile118(join143(root2, agent, "commands", entry.name), "utf8");
125108
- const target = join143(commandsRoot, entry.name);
125109
- const marker = join143(commandsRoot, `.context-${entry.name}.json`);
125193
+ const content3 = await readFile119(join144(root2, agent, "commands", entry.name), "utf8");
125194
+ const target = join144(commandsRoot, entry.name);
125195
+ const marker = join144(commandsRoot, `.context-${entry.name}.json`);
125110
125196
  for (const file of [target, marker]) {
125111
125197
  const existing = await stat11(file);
125112
125198
  if (existing && (!existing.isFile() || existing.isSymbolicLink()))
@@ -125115,11 +125201,11 @@ async function installLocalSkills(root2, path3, dryRun, agent) {
125115
125201
  if (await stat11(target)) {
125116
125202
  let previous3;
125117
125203
  try {
125118
- previous3 = JSON.parse(await readFile118(marker, "utf8"));
125204
+ previous3 = JSON.parse(await readFile119(marker, "utf8"));
125119
125205
  } catch {
125120
125206
  conflict(target);
125121
125207
  }
125122
- const current3 = createHash46("sha256").update(await readFile118(target)).digest("hex");
125208
+ const current3 = createHash46("sha256").update(await readFile119(target)).digest("hex");
125123
125209
  if (previous3?.owner !== "context-plugin-local" || previous3.digest !== current3)
125124
125210
  conflict(target);
125125
125211
  } else if (await stat11(marker))
@@ -125127,14 +125213,14 @@ async function installLocalSkills(root2, path3, dryRun, agent) {
125127
125213
  commandPlans.push({ name: entry.name, target, marker, content: content3, hash: createHash46("sha256").update(content3).digest("hex") });
125128
125214
  }
125129
125215
  if (!commandPlans.length)
125130
- conflict(join143(root2, agent, "commands"));
125216
+ conflict(join144(root2, agent, "commands"));
125131
125217
  }
125132
125218
  const plans = [];
125133
125219
  for (const entry of (await readdir35(sourceRoot, { withFileTypes: true })).sort((a2, b) => a2.name.localeCompare(b.name))) {
125134
- if (!entry.isDirectory() || !await stat11(join143(sourceRoot, entry.name, "SKILL.md")))
125220
+ if (!entry.isDirectory() || !await stat11(join144(sourceRoot, entry.name, "SKILL.md")))
125135
125221
  continue;
125136
- const source2 = join143(sourceRoot, entry.name);
125137
- const target = join143(skillsRoot, entry.name);
125222
+ const source2 = join144(sourceRoot, entry.name);
125223
+ const target = join144(skillsRoot, entry.name);
125138
125224
  if (commandEntries.has(entry.name) && !["context-plan", "context-repo-content"].includes(entry.name)) {
125139
125225
  if (await stat11(target))
125140
125226
  conflict(`${target} (use a fresh host directory to avoid duplicate command/skill entries)`);
@@ -125148,16 +125234,16 @@ async function installLocalSkills(root2, path3, dryRun, agent) {
125148
125234
  if (!plans.length)
125149
125235
  conflict(sourceRoot);
125150
125236
  const resourcePlans = [];
125151
- const resourcesRoot = join143(targetRoot, "resources");
125237
+ const resourcesRoot = join144(targetRoot, "resources");
125152
125238
  if (agent === "claude" || agent === "cursor") {
125153
- const resourceSource = join143(root2, agent, "resources");
125239
+ const resourceSource = join144(root2, agent, "resources");
125154
125240
  if (await stat11(resourceSource)) {
125155
125241
  await checkParents(resourcesRoot);
125156
125242
  for (const entry of (await readdir35(resourceSource, { withFileTypes: true })).sort((a2, b) => a2.name.localeCompare(b.name))) {
125157
125243
  if (!entry.isDirectory())
125158
125244
  continue;
125159
- const source2 = join143(resourceSource, entry.name);
125160
- const target = join143(resourcesRoot, entry.name);
125245
+ const source2 = join144(resourceSource, entry.name);
125246
+ const target = join144(resourcesRoot, entry.name);
125161
125247
  const existing = await stat11(target);
125162
125248
  if (existing)
125163
125249
  await assertOwnedDirectory(target, existing);
@@ -125171,15 +125257,15 @@ async function installLocalSkills(root2, path3, dryRun, agent) {
125171
125257
  await mkdir45(resourcesRoot, { recursive: true });
125172
125258
  for (const plan of [...plans, ...resourcePlans]) {
125173
125259
  const resource = resourcePlans.includes(plan);
125174
- const staging = await mkdtemp7(join143(dirname54(plan.target), ".context-install-"));
125175
- const candidate = join143(staging, "candidate");
125176
- const previous3 = join143(staging, "previous");
125260
+ const staging = await mkdtemp7(join144(dirname54(plan.target), ".context-install-"));
125261
+ const candidate = join144(staging, "candidate");
125262
+ const previous3 = join144(staging, "previous");
125177
125263
  let moved = false;
125178
125264
  try {
125179
125265
  await cp3(plan.source, candidate, { recursive: true });
125180
125266
  if (!resource && (agent === "claude" || agent === "cursor" && ["context-plan", "context-repo-content"].includes(plan.name))) {
125181
- const skillFile = join143(candidate, "SKILL.md");
125182
- const content3 = await readFile118(skillFile, "utf8");
125267
+ const skillFile = join144(candidate, "SKILL.md");
125268
+ const content3 = await readFile119(skillFile, "utf8");
125183
125269
  const parts = /^(---\r?\n)([\s\S]*?)(\r?\n---(?:\r?\n|$))/.exec(content3);
125184
125270
  if (parts && (["context-plan", "context-repo-content"].includes(plan.name) || /^\s*context-public-entry:\s*["']?false["']?\s*$/mu.test(parts[2]))) {
125185
125271
  const frontmatter2 = parts[2].replace(/^user-invocable:.*\r?\n?/mu, "");
@@ -125187,7 +125273,7 @@ async function installLocalSkills(root2, path3, dryRun, agent) {
125187
125273
  ${frontmatter2}${parts[3]}${content3.slice(parts[0].length)}`);
125188
125274
  }
125189
125275
  }
125190
- await writeFile34(join143(candidate, MARKER), JSON.stringify({ owner: "context-plugin-local", digest: await digest9(candidate) }) + `
125276
+ await writeFile34(join144(candidate, MARKER), JSON.stringify({ owner: "context-plugin-local", digest: await digest9(candidate) }) + `
125191
125277
  `);
125192
125278
  if (plan.exists) {
125193
125279
  await rename12(plan.target, previous3);
@@ -125211,12 +125297,12 @@ ${frontmatter2}${parts[3]}${content3.slice(parts[0].length)}`);
125211
125297
  }
125212
125298
  for (const command3 of commandPlans) {
125213
125299
  await mkdir45(dirname54(command3.target), { recursive: true });
125214
- const staging = await mkdtemp7(join143(dirname54(command3.target), ".context-install-"));
125215
- await writeFile34(join143(staging, "command"), command3.content);
125216
- await writeFile34(join143(staging, "marker"), JSON.stringify({ owner: "context-plugin-local", digest: command3.hash }) + `
125300
+ const staging = await mkdtemp7(join144(dirname54(command3.target), ".context-install-"));
125301
+ await writeFile34(join144(staging, "command"), command3.content);
125302
+ await writeFile34(join144(staging, "marker"), JSON.stringify({ owner: "context-plugin-local", digest: command3.hash }) + `
125217
125303
  `);
125218
- await rename12(join143(staging, "command"), command3.target);
125219
- await rename12(join143(staging, "marker"), command3.marker);
125304
+ await rename12(join144(staging, "command"), command3.target);
125305
+ await rename12(join144(staging, "marker"), command3.marker);
125220
125306
  await rm34(staging, { recursive: true, force: true });
125221
125307
  }
125222
125308
  }
@@ -125241,10 +125327,10 @@ init_cliFeedback();
125241
125327
  init_errors3();
125242
125328
  init_exitCode();
125243
125329
  import { lstat as lstat24 } from "node:fs/promises";
125244
- import { join as join144, resolve as resolve53 } from "node:path";
125330
+ import { join as join145, resolve as resolve53 } from "node:path";
125245
125331
  var HOST_DIRS = { claude: ".claude", cursor: ".cursor", codex: ".agents" };
125246
125332
  async function detectLocalAgent(agent, repo) {
125247
- const path3 = join144(repo, HOST_DIRS[agent]);
125333
+ const path3 = join145(repo, HOST_DIRS[agent]);
125248
125334
  try {
125249
125335
  const entry = await lstat24(path3);
125250
125336
  if (!entry.isDirectory() || entry.isSymbolicLink()) {
@@ -125269,7 +125355,7 @@ async function installAutoLocalSkills(root2, path3, dryRun, detect = detectLocal
125269
125355
  if (selectedAgent ? selectedAgent === "all" || agent === selectedAgent : await detect(agent, repo))
125270
125356
  agents.push(agent);
125271
125357
  }
125272
- const targets = agents.length ? agents.map((agent) => ({ agent, path: join144(repo, HOST_DIRS[agent]) })) : [{ path: join144(repo, ".agents") }];
125358
+ const targets = agents.length ? agents.map((agent) => ({ agent, path: join145(repo, HOST_DIRS[agent]) })) : [{ path: join145(repo, ".agents") }];
125273
125359
  const previews = [];
125274
125360
  for (const target of targets)
125275
125361
  previews.push(await installLocalSkills(root2, target.path, true, target.agent));
@@ -125302,7 +125388,7 @@ init_cliFeedback();
125302
125388
  init_errors3();
125303
125389
  init_exitCode();
125304
125390
  import { existsSync as existsSync40 } from "node:fs";
125305
- import { dirname as dirname56, join as join146, resolve as resolve54 } from "node:path";
125391
+ import { dirname as dirname56, join as join147, resolve as resolve54 } from "node:path";
125306
125392
  import { fileURLToPath as fileURLToPath11 } from "node:url";
125307
125393
 
125308
125394
  // src/project/pluginInstallTargets.ts
@@ -125311,9 +125397,9 @@ init_errors3();
125311
125397
  init_exitCode();
125312
125398
  import { execFile as execFile21 } from "node:child_process";
125313
125399
  import { existsSync as existsSync39 } from "node:fs";
125314
- import { cp as cp4, mkdir as mkdir46, readdir as readdir36, readFile as readFile119, rename as rename13, rm as rm35, writeFile as writeFile35 } from "node:fs/promises";
125400
+ import { cp as cp4, mkdir as mkdir46, readdir as readdir36, readFile as readFile120, rename as rename13, rm as rm35, writeFile as writeFile35 } from "node:fs/promises";
125315
125401
  import { homedir as homedir2 } from "node:os";
125316
- import { dirname as dirname55, join as join145 } from "node:path";
125402
+ import { dirname as dirname55, join as join146 } from "node:path";
125317
125403
  import { promisify as promisify18 } from "node:util";
125318
125404
  var execFileAsync6 = promisify18(execFile21);
125319
125405
  var MARKETPLACE_NAME = "c4a";
@@ -125367,23 +125453,23 @@ async function claudePluginInstalled(pluginId) {
125367
125453
  }
125368
125454
  }
125369
125455
  function codexHome() {
125370
- return process.env.CODEX_HOME?.trim() || join145(homedir2(), ".codex");
125456
+ return process.env.CODEX_HOME?.trim() || join146(homedir2(), ".codex");
125371
125457
  }
125372
125458
  function claudePluginCacheRoot() {
125373
125459
  const explicitRoot = process.env[CLAUDE_PLUGIN_CACHE_ROOT_ENV2]?.trim();
125374
125460
  if (explicitRoot)
125375
125461
  return explicitRoot;
125376
125462
  const home = process.env[CLAUDE_PLUGIN_CACHE_HOME_ENV2]?.trim() || homedir2();
125377
- return join145(home, ".claude", "plugins", "cache");
125463
+ return join146(home, ".claude", "plugins", "cache");
125378
125464
  }
125379
125465
  function sharedSkillsRoot() {
125380
- return process.env[SHARED_SKILLS_ROOT_ENV]?.trim() || join145(homedir2(), ".agents", "skills");
125466
+ return process.env[SHARED_SKILLS_ROOT_ENV]?.trim() || join146(homedir2(), ".agents", "skills");
125381
125467
  }
125382
125468
  function claudeSkillsRoot() {
125383
- return process.env[CLAUDE_SKILLS_ROOT_ENV]?.trim() || join145(homedir2(), ".claude", "skills");
125469
+ return process.env[CLAUDE_SKILLS_ROOT_ENV]?.trim() || join146(homedir2(), ".claude", "skills");
125384
125470
  }
125385
125471
  function cursorPluginRoot() {
125386
- return process.env[CURSOR_PLUGIN_ROOT_ENV]?.trim() || join145(homedir2(), ".cursor", "plugins", "local", PLUGIN_NAME);
125472
+ return process.env[CURSOR_PLUGIN_ROOT_ENV]?.trim() || join146(homedir2(), ".cursor", "plugins", "local", PLUGIN_NAME);
125387
125473
  }
125388
125474
  function blockHeader(line) {
125389
125475
  const match = line.match(/^\s*\[([^\]]+)\]\s*$/u);
@@ -125434,8 +125520,8 @@ function pruneLegacyCodexConfigContent(content3) {
125434
125520
  `), removed };
125435
125521
  }
125436
125522
  async function pruneLegacyCodexConfig(dryRun, steps) {
125437
- const configPath = join145(codexHome(), "config.toml");
125438
- const current3 = await readFile119(configPath, "utf8").catch(() => "");
125523
+ const configPath = join146(codexHome(), "config.toml");
125524
+ const current3 = await readFile120(configPath, "utf8").catch(() => "");
125439
125525
  if (!current3)
125440
125526
  return;
125441
125527
  const next2 = pruneLegacyCodexConfigContent(current3);
@@ -125451,7 +125537,7 @@ async function pruneLegacyCodexConfig(dryRun, steps) {
125451
125537
  }
125452
125538
  }
125453
125539
  async function pruneCodexPluginCacheForName(pluginName, keepVersion, dryRun, steps) {
125454
- const cacheRoot = join145(codexHome(), "plugins", "cache", MARKETPLACE_NAME, pluginName);
125540
+ const cacheRoot = join146(codexHome(), "plugins", "cache", MARKETPLACE_NAME, pluginName);
125455
125541
  if (!existsSync39(cacheRoot))
125456
125542
  return;
125457
125543
  const versions = (await readdir36(cacheRoot, { withFileTypes: true }).catch(() => [])).filter((entry) => entry.isDirectory() && entry.name !== keepVersion).map((entry) => entry.name).sort();
@@ -125463,7 +125549,7 @@ async function pruneCodexPluginCacheForName(pluginName, keepVersion, dryRun, ste
125463
125549
  status: dryRun ? "planned" : "ran"
125464
125550
  });
125465
125551
  if (!dryRun)
125466
- await Promise.all(versions.map((version3) => rm35(join145(cacheRoot, version3), { recursive: true, force: true })));
125552
+ await Promise.all(versions.map((version3) => rm35(join146(cacheRoot, version3), { recursive: true, force: true })));
125467
125553
  }
125468
125554
  async function pruneCodexPluginCache(currentVersion, dryRun, steps) {
125469
125555
  await pruneCodexPluginCacheForName(PLUGIN_NAME, currentVersion, dryRun, steps);
@@ -125487,15 +125573,15 @@ async function pruneClaudeOrphanContextCache(dryRun, steps) {
125487
125573
  for (const marketplace of marketplaces) {
125488
125574
  if (!marketplace.isDirectory())
125489
125575
  continue;
125490
- const pluginDir = join145(cacheRoot, marketplace.name, PLUGIN_NAME);
125576
+ const pluginDir = join146(cacheRoot, marketplace.name, PLUGIN_NAME);
125491
125577
  if (!existsSync39(pluginDir))
125492
125578
  continue;
125493
125579
  const versions = await readdir36(pluginDir, { withFileTypes: true }).catch(() => []);
125494
125580
  for (const version3 of versions) {
125495
125581
  if (!version3.isDirectory())
125496
125582
  continue;
125497
- const versionDir = join145(pluginDir, version3.name);
125498
- if (!existsSync39(join145(versionDir, ORPHAN_MARKER2)))
125583
+ const versionDir = join146(pluginDir, version3.name);
125584
+ if (!existsSync39(join146(versionDir, ORPHAN_MARKER2)))
125499
125585
  continue;
125500
125586
  removed.push(`${marketplace.name}/${PLUGIN_NAME}/${version3.name}`);
125501
125587
  if (!dryRun) {
@@ -125505,7 +125591,7 @@ async function pruneClaudeOrphanContextCache(dryRun, steps) {
125505
125591
  if (!dryRun && await isEmptyDir2(pluginDir)) {
125506
125592
  await rm35(pluginDir, { recursive: true, force: true });
125507
125593
  }
125508
- const marketplaceDir = join145(cacheRoot, marketplace.name);
125594
+ const marketplaceDir = join146(cacheRoot, marketplace.name);
125509
125595
  if (!dryRun && await isEmptyDir2(marketplaceDir)) {
125510
125596
  await rm35(marketplaceDir, { recursive: true, force: true });
125511
125597
  }
@@ -125526,7 +125612,7 @@ async function pruneClaudeLegacyPluginCache(dryRun, steps) {
125526
125612
  return;
125527
125613
  const removed = [];
125528
125614
  for (const pluginName of LEGACY_PLUGIN_NAMES) {
125529
- const pluginDir = join145(cacheRoot, MARKETPLACE_NAME, pluginName);
125615
+ const pluginDir = join146(cacheRoot, MARKETPLACE_NAME, pluginName);
125530
125616
  if (!existsSync39(pluginDir))
125531
125617
  continue;
125532
125618
  removed.push(`${MARKETPLACE_NAME}/${pluginName}`);
@@ -125543,11 +125629,11 @@ async function pruneClaudeLegacyPluginCache(dryRun, steps) {
125543
125629
  }
125544
125630
  }
125545
125631
  async function pruneClaudeSupersededContextCache(root2, dryRun, steps) {
125546
- const manifest = await readFile119(join145(root2, "claude", ".claude-plugin", "plugin.json"), "utf8").then((content3) => JSON.parse(content3)).catch(() => null);
125632
+ const manifest = await readFile120(join146(root2, "claude", ".claude-plugin", "plugin.json"), "utf8").then((content3) => JSON.parse(content3)).catch(() => null);
125547
125633
  const currentVersion = typeof manifest?.version === "string" ? manifest.version : null;
125548
125634
  if (!currentVersion)
125549
125635
  return;
125550
- const pluginDir = join145(claudePluginCacheRoot(), MARKETPLACE_NAME, PLUGIN_NAME);
125636
+ const pluginDir = join146(claudePluginCacheRoot(), MARKETPLACE_NAME, PLUGIN_NAME);
125551
125637
  const staleVersions = (await readdir36(pluginDir, { withFileTypes: true }).catch(() => [])).filter((entry) => entry.isDirectory() && entry.name !== currentVersion).map((entry) => entry.name);
125552
125638
  if (staleVersions.length === 0)
125553
125639
  return;
@@ -125557,7 +125643,7 @@ async function pruneClaudeSupersededContextCache(root2, dryRun, steps) {
125557
125643
  status: dryRun ? "planned" : "ran"
125558
125644
  });
125559
125645
  if (!dryRun) {
125560
- await Promise.all(staleVersions.map((version3) => rm35(join145(pluginDir, version3), { recursive: true, force: true })));
125646
+ await Promise.all(staleVersions.map((version3) => rm35(join146(pluginDir, version3), { recursive: true, force: true })));
125561
125647
  }
125562
125648
  }
125563
125649
  function enableCodexPluginConfig(content3) {
@@ -125621,33 +125707,33 @@ source = ${JSON.stringify(root2)}
125621
125707
  `;
125622
125708
  }
125623
125709
  async function ensureCodexPluginEnabled() {
125624
- const configPath = join145(codexHome(), "config.toml");
125710
+ const configPath = join146(codexHome(), "config.toml");
125625
125711
  await mkdir46(dirname55(configPath), { recursive: true });
125626
- const current3 = await readFile119(configPath, "utf8").catch(() => "");
125712
+ const current3 = await readFile120(configPath, "utf8").catch(() => "");
125627
125713
  const next2 = enableCodexPluginConfig(current3);
125628
125714
  if (next2 !== current3) {
125629
125715
  await writeFile35(configPath, next2, "utf8");
125630
125716
  }
125631
125717
  }
125632
125718
  async function ensureCodexLocalMarketplace(root2) {
125633
- const configPath = join145(codexHome(), "config.toml");
125719
+ const configPath = join146(codexHome(), "config.toml");
125634
125720
  await mkdir46(dirname55(configPath), { recursive: true });
125635
- const current3 = await readFile119(configPath, "utf8").catch(() => "");
125721
+ const current3 = await readFile120(configPath, "utf8").catch(() => "");
125636
125722
  const next2 = upsertCodexLocalMarketplaceConfig(current3, root2);
125637
125723
  if (next2 !== current3) {
125638
125724
  await writeFile35(configPath, next2, "utf8");
125639
125725
  }
125640
125726
  }
125641
125727
  async function codexPluginVersion(root2) {
125642
- const manifestPath = join145(root2, "codex", ".codex-plugin", "plugin.json");
125643
- const manifest = JSON.parse(await readFile119(manifestPath, "utf8"));
125728
+ const manifestPath = join146(root2, "codex", ".codex-plugin", "plugin.json");
125729
+ const manifest = JSON.parse(await readFile120(manifestPath, "utf8"));
125644
125730
  if (typeof manifest.version !== "string" || !/^[A-Za-z0-9][A-Za-z0-9._-]*$/u.test(manifest.version)) {
125645
125731
  throw new Error(`Codex plugin manifest has an invalid version: ${manifestPath}`);
125646
125732
  }
125647
125733
  return manifest.version;
125648
125734
  }
125649
125735
  function codexPluginCacheDir(version3) {
125650
- return join145(codexHome(), "plugins", "cache", MARKETPLACE_NAME, PLUGIN_NAME, version3);
125736
+ return join146(codexHome(), "plugins", "cache", MARKETPLACE_NAME, PLUGIN_NAME, version3);
125651
125737
  }
125652
125738
  async function replaceDirectoryFromSource(source2, target) {
125653
125739
  await mkdir46(dirname55(target), { recursive: true });
@@ -125670,7 +125756,7 @@ async function replaceDirectoryFromSource(source2, target) {
125670
125756
  }
125671
125757
  }
125672
125758
  async function materializeCodexPluginCache(root2, version3, dryRun, steps) {
125673
- const source2 = join145(root2, "codex");
125759
+ const source2 = join146(root2, "codex");
125674
125760
  const target = codexPluginCacheDir(version3);
125675
125761
  steps.push({
125676
125762
  agent: "codex",
@@ -125682,16 +125768,16 @@ async function materializeCodexPluginCache(root2, version3, dryRun, steps) {
125682
125768
  await replaceDirectoryFromSource(source2, target);
125683
125769
  }
125684
125770
  async function bundledProviderSkillNames(root2) {
125685
- const skillsRoot = join145(root2, "skills");
125771
+ const skillsRoot = join146(root2, "skills");
125686
125772
  const entries2 = await readdir36(skillsRoot, { withFileTypes: true });
125687
125773
  const names = [];
125688
125774
  for (const entry of entries2) {
125689
125775
  if (!entry.isDirectory() || entry.name === "context")
125690
125776
  continue;
125691
- const skillPath = join145(skillsRoot, entry.name, "SKILL.md");
125777
+ const skillPath = join146(skillsRoot, entry.name, "SKILL.md");
125692
125778
  if (!existsSync39(skillPath))
125693
125779
  continue;
125694
- const skill = await readFile119(skillPath, "utf8");
125780
+ const skill = await readFile120(skillPath, "utf8");
125695
125781
  if (!/^\s*context-role:\s*["']?indexer-provider["']?\s*$/mu.test(skill))
125696
125782
  continue;
125697
125783
  names.push(entry.name);
@@ -125703,10 +125789,10 @@ async function bundledProviderSkillNames(root2) {
125703
125789
  return names;
125704
125790
  }
125705
125791
  async function materializeProviderSkills(root2, targetRoot, agent, dryRun, steps) {
125706
- const sourceRoot = join145(root2, "skills");
125792
+ const sourceRoot = join146(root2, "skills");
125707
125793
  for (const name3 of await bundledProviderSkillNames(root2)) {
125708
- const source2 = join145(sourceRoot, name3);
125709
- const target = join145(targetRoot, name3);
125794
+ const source2 = join146(sourceRoot, name3);
125795
+ const target = join146(targetRoot, name3);
125710
125796
  steps.push({
125711
125797
  agent,
125712
125798
  command: `materialize lifecycle Provider skill: ${shellQuote8(source2)} -> ${shellQuote8(target)}`,
@@ -125717,7 +125803,7 @@ async function materializeProviderSkills(root2, targetRoot, agent, dryRun, steps
125717
125803
  }
125718
125804
  }
125719
125805
  async function installCursor(root2, dryRun, steps) {
125720
- const source2 = join145(root2, "cursor");
125806
+ const source2 = join146(root2, "cursor");
125721
125807
  const target = cursorPluginRoot();
125722
125808
  steps.push({
125723
125809
  agent: "cursor",
@@ -125772,12 +125858,12 @@ async function installCodex(root2, dryRun, steps) {
125772
125858
  steps.push({ agent: "codex", command: commandLine("codex", addArgs), status: dryRun ? "planned" : "ran" });
125773
125859
  steps.push({
125774
125860
  agent: "codex",
125775
- command: `ensure ${shellQuote8(join145(codexHome(), "config.toml"))} registers local marketplace ${shellQuote8(MARKETPLACE_NAME)}`,
125861
+ command: `ensure ${shellQuote8(join146(codexHome(), "config.toml"))} registers local marketplace ${shellQuote8(MARKETPLACE_NAME)}`,
125776
125862
  status: dryRun ? "planned" : "ran"
125777
125863
  });
125778
125864
  steps.push({
125779
125865
  agent: "codex",
125780
- command: `ensure ${shellQuote8(join145(codexHome(), "config.toml"))} enables ${shellQuote8(PLUGIN_ID)}`,
125866
+ command: `ensure ${shellQuote8(join146(codexHome(), "config.toml"))} enables ${shellQuote8(PLUGIN_ID)}`,
125781
125867
  status: dryRun ? "planned" : "ran"
125782
125868
  });
125783
125869
  if (dryRun) {
@@ -125832,13 +125918,13 @@ function pluginRootCandidates() {
125832
125918
  return [resolve54(envRoot)];
125833
125919
  const candidates = [];
125834
125920
  for (const dir of packageCandidateDirs()) {
125835
- candidates.push(join146(dir, "plugins"));
125836
- candidates.push(join146(dir, "dist", "plugins"));
125921
+ candidates.push(join147(dir, "plugins"));
125922
+ candidates.push(join147(dir, "dist", "plugins"));
125837
125923
  }
125838
125924
  return [...new Set(candidates)];
125839
125925
  }
125840
125926
  function isInstallablePluginRoot(root2) {
125841
- return existsSync40(join146(root2, ".claude-plugin", "marketplace.json")) && existsSync40(join146(root2, ".agents", "plugins", "marketplace.json")) && existsSync40(join146(root2, "claude", ".claude-plugin", "plugin.json")) && existsSync40(join146(root2, "codex", ".codex-plugin", "plugin.json")) && existsSync40(join146(root2, "cursor", ".cursor-plugin", "plugin.json")) && existsSync40(join146(root2, "skills"));
125927
+ return existsSync40(join147(root2, ".claude-plugin", "marketplace.json")) && existsSync40(join147(root2, ".agents", "plugins", "marketplace.json")) && existsSync40(join147(root2, "claude", ".claude-plugin", "plugin.json")) && existsSync40(join147(root2, "codex", ".codex-plugin", "plugin.json")) && existsSync40(join147(root2, "cursor", ".cursor-plugin", "plugin.json")) && existsSync40(join147(root2, "skills"));
125842
125928
  }
125843
125929
  function resolveBundledPluginsRoot() {
125844
125930
  const candidates = pluginRootCandidates();
@@ -126104,10 +126190,10 @@ function readQuickstartPath() {
126104
126190
  try {
126105
126191
  let dir = dirname57(fileURLToPath12(import.meta.url));
126106
126192
  for (let i2 = 0;i2 < 8; i2++) {
126107
- const candidate = join147(dir, "docs", "quickstart.md");
126193
+ const candidate = join148(dir, "docs", "quickstart.md");
126108
126194
  if (existsSync41(candidate))
126109
126195
  return candidate;
126110
- const pkg = join147(dir, "package.json");
126196
+ const pkg = join148(dir, "package.json");
126111
126197
  if (existsSync41(pkg))
126112
126198
  return candidate;
126113
126199
  const parent2 = dirname57(dir);
@@ -126116,7 +126202,7 @@ function readQuickstartPath() {
126116
126202
  dir = parent2;
126117
126203
  }
126118
126204
  } catch {}
126119
- return join147(dirname57(fileURLToPath12(import.meta.url)), "docs", "quickstart.md");
126205
+ return join148(dirname57(fileURLToPath12(import.meta.url)), "docs", "quickstart.md");
126120
126206
  }
126121
126207
  var GREEN = "\x1B[32m";
126122
126208
  var RESET = "\x1B[0m";