@c4a/context-cli 0.7.102 → 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 +885 -591
- package/indexers/contracts/profile-contract.json +245 -245
- package/indexers/release-manifest.json +1 -1
- package/package.json +12 -12
- package/parserEntryWorker.js +2 -0
- package/plugins/VERSION +1 -1
- package/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/plugins/claude/commands/context.md +9 -3
- package/plugins/claude/resources/context/routine-update.md +2 -1
- package/plugins/claude/resources/context/version-alignment.md +9 -4
- package/plugins/claude/skills/context-plan/references/knowledge-migration.md +1 -1
- package/plugins/codex/.codex-plugin/plugin.json +2 -2
- package/plugins/codex/skills/context/SKILL.md +9 -3
- package/plugins/codex/skills/context/references/routine-update.md +2 -1
- package/plugins/codex/skills/context/references/version-alignment.md +9 -4
- package/plugins/codex/skills/context-plan/references/knowledge-migration.md +1 -1
- package/plugins/cursor/.cursor-plugin/plugin.json +1 -1
- package/plugins/cursor/commands/c4a-context.md +9 -3
- package/plugins/cursor/resources/context/routine-update.md +2 -1
- package/plugins/cursor/resources/context/version-alignment.md +9 -4
- package/plugins/cursor/skills/context-plan/references/knowledge-migration.md +1 -1
- package/plugins/skills/context/SKILL.md +9 -3
- package/plugins/skills/context/references/routine-update.md +2 -1
- package/plugins/skills/context/references/version-alignment.md +9 -4
- package/plugins/skills/context-plan/references/knowledge-migration.md +1 -1
- package/providers/context/manifest.json +13 -13
- package/providers/context/provider.yaml +1 -1
- package/providers/context/resources/manuals/guides/package-outputs.md +36 -0
- package/providers/context/resources/manuals/guides/page-customization.md +16 -3
- package/providers/context/resources/manuals/reference/project-api.md +11 -1
- package/providers/context/resources/procedures/document-capture.md +11 -5
- package/providers/context/resources/procedures/production-stage-files.md +4 -0
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
|
-
|
|
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;
|
|
@@ -87746,6 +87788,7 @@ function renderReadme(projectName, language) {
|
|
|
87746
87788
|
"- `node_modules/@c4a/context/docs/README.md`",
|
|
87747
87789
|
"- `node_modules/@c4a/context/docs/reference/project-api.md`",
|
|
87748
87790
|
"- `node_modules/@c4a/context/docs/reference/package-templates.md`",
|
|
87791
|
+
"- 这些文档随工作区 SDK 安装;`context status` 报告 `version_alignment` 时先按其说明升级 SDK,否则文档可能落后于运行中的 CLI。",
|
|
87749
87792
|
""
|
|
87750
87793
|
].join(`
|
|
87751
87794
|
`);
|
|
@@ -87787,6 +87830,7 @@ function renderReadme(projectName, language) {
|
|
|
87787
87830
|
"- `node_modules/@c4a/context/docs/README.md`",
|
|
87788
87831
|
"- `node_modules/@c4a/context/docs/reference/project-api.md`",
|
|
87789
87832
|
"- `node_modules/@c4a/context/docs/reference/package-templates.md`",
|
|
87833
|
+
"- These docs come with the workspace SDK; when `context status` reports `version_alignment`, upgrade the SDK as it says first, or they may lag the running CLI.",
|
|
87790
87834
|
""
|
|
87791
87835
|
].join(`
|
|
87792
87836
|
`);
|
|
@@ -87837,6 +87881,7 @@ function renderAgents(projectName, language) {
|
|
|
87837
87881
|
"- SDK 总入口:`node_modules/@c4a/context/docs/README.md`。",
|
|
87838
87882
|
"- 项目声明:`node_modules/@c4a/context/docs/reference/project-api.md`。",
|
|
87839
87883
|
"- 包模板:`node_modules/@c4a/context/docs/reference/package-templates.md`。",
|
|
87884
|
+
"- 这些文档随工作区 SDK 安装;`context status` 报告 `version_alignment` 时先按其说明升级 SDK,否则文档可能落后于运行中的 CLI。",
|
|
87840
87885
|
""
|
|
87841
87886
|
].join(`
|
|
87842
87887
|
`);
|
|
@@ -87885,6 +87930,7 @@ function renderAgents(projectName, language) {
|
|
|
87885
87930
|
"- General SDK index: `node_modules/@c4a/context/docs/README.md`.",
|
|
87886
87931
|
"- Project declarations: `node_modules/@c4a/context/docs/reference/project-api.md`.",
|
|
87887
87932
|
"- Package templates: `node_modules/@c4a/context/docs/reference/package-templates.md`.",
|
|
87933
|
+
"- These docs come with the workspace SDK; when `context status` reports `version_alignment`, upgrade the SDK as it says first, or they may lag the running CLI.",
|
|
87888
87934
|
""
|
|
87889
87935
|
].join(`
|
|
87890
87936
|
`);
|
|
@@ -88045,6 +88091,7 @@ var exports_workspace = {};
|
|
|
88045
88091
|
__export(exports_workspace, {
|
|
88046
88092
|
resolveContextProjectInitTarget: () => resolveContextProjectInitTarget,
|
|
88047
88093
|
resolveContextPackageTemplatesRoot: () => resolveContextPackageTemplatesRoot,
|
|
88094
|
+
readCurrentPackageVersion: () => readCurrentPackageVersion,
|
|
88048
88095
|
projectLanguage: () => projectLanguage,
|
|
88049
88096
|
loadContextProjectModule: () => loadContextProjectModule,
|
|
88050
88097
|
isContextProjectRoot: () => isContextProjectRoot,
|
|
@@ -91318,34 +91365,23 @@ var init_packageAssetDelivery = __esm(() => {
|
|
|
91318
91365
|
import { existsSync as existsSync17 } from "node:fs";
|
|
91319
91366
|
import { mkdir as mkdir27, readFile as readFile68, writeFile as writeFile20 } from "node:fs/promises";
|
|
91320
91367
|
import { dirname as dirname33, join as join78 } from "node:path";
|
|
91321
|
-
function
|
|
91322
|
-
const
|
|
91323
|
-
|
|
91324
|
-
|
|
91325
|
-
|
|
91326
|
-
|
|
91327
|
-
|
|
91328
|
-
|
|
91329
|
-
|
|
91330
|
-
|
|
91331
|
-
|
|
91332
|
-
out += ".*";
|
|
91333
|
-
index3++;
|
|
91334
|
-
} else if (char === "*") {
|
|
91335
|
-
out += "[^/]*";
|
|
91336
|
-
} else if (char === "?") {
|
|
91337
|
-
out += "[^/]";
|
|
91338
|
-
} else {
|
|
91339
|
-
out += char?.replace(/[.+^${}()|[\]\\]/gu, "\\$&") ?? "";
|
|
91340
|
-
}
|
|
91341
|
-
}
|
|
91342
|
-
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)}`;
|
|
91343
91379
|
}
|
|
91344
91380
|
function matchesAny(path2, patterns) {
|
|
91345
|
-
return
|
|
91381
|
+
return matchesKnowledgePattern(path2, patterns);
|
|
91346
91382
|
}
|
|
91347
91383
|
function matchingPatterns(path2, patterns) {
|
|
91348
|
-
return
|
|
91384
|
+
return matchingKnowledgePatterns(path2, patterns);
|
|
91349
91385
|
}
|
|
91350
91386
|
function selectionReasonsForFile(file, pkg) {
|
|
91351
91387
|
const internalCollection = file.relPath.split("/")[0];
|
|
@@ -91356,7 +91392,7 @@ function selectionReasonsForFile(file, pkg) {
|
|
|
91356
91392
|
return null;
|
|
91357
91393
|
if (pkg.select?.collections?.length)
|
|
91358
91394
|
reasons.push({ kind: "collection", value: internalCollection });
|
|
91359
|
-
const okfRoot = okfRootForCollection(internalCollection);
|
|
91395
|
+
const okfRoot = okfPackagePathForKnowledgePath(file.relPath, pkg.kind === "package.kb" ? pkg.rules : undefined).startsWith("guides/") ? "guides" : okfRootForCollection(internalCollection);
|
|
91360
91396
|
if (pkg.select?.okfRoots?.length && !pkg.select.okfRoots.includes(okfRoot))
|
|
91361
91397
|
return null;
|
|
91362
91398
|
if (pkg.select?.okfRoots?.length)
|
|
@@ -91524,7 +91560,9 @@ async function writeSelectedPackageKnowledge(input) {
|
|
|
91524
91560
|
content: links.markdown
|
|
91525
91561
|
});
|
|
91526
91562
|
const file = byPath.get(approvedByOutput.get(projected.pageOutputPath));
|
|
91527
|
-
|
|
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");
|
|
91528
91566
|
return links.warnings;
|
|
91529
91567
|
}));
|
|
91530
91568
|
for (const result of results) {
|
|
@@ -93906,12 +93944,89 @@ var init_packageSiteLocales = __esm(() => {
|
|
|
93906
93944
|
htmlEscapes = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" };
|
|
93907
93945
|
});
|
|
93908
93946
|
|
|
93947
|
+
// src/project/siteCustomPageLinks.ts
|
|
93948
|
+
var exports_siteCustomPageLinks = {};
|
|
93949
|
+
__export(exports_siteCustomPageLinks, {
|
|
93950
|
+
htmlContentLinks: () => htmlContentLinks,
|
|
93951
|
+
htmlAnchorIds: () => htmlAnchorIds,
|
|
93952
|
+
customPageLinkProblems: () => customPageLinkProblems
|
|
93953
|
+
});
|
|
93954
|
+
import { existsSync as existsSync19 } from "node:fs";
|
|
93955
|
+
import { readFile as readFile71 } from "node:fs/promises";
|
|
93956
|
+
import { join as join81, posix as posix10 } from "node:path";
|
|
93957
|
+
function decode2(value) {
|
|
93958
|
+
const text8 = value.replace(/&(amp|lt|gt|quot|#39|apos);/gu, (_, name3) => ENTITIES[name3] ?? _);
|
|
93959
|
+
try {
|
|
93960
|
+
return decodeURIComponent(text8);
|
|
93961
|
+
} catch {
|
|
93962
|
+
return text8;
|
|
93963
|
+
}
|
|
93964
|
+
}
|
|
93965
|
+
function htmlAnchorIds(html) {
|
|
93966
|
+
return new Set([...html.matchAll(/\sid="([^"]+)"/gu)].map((match) => decode2(match[1])));
|
|
93967
|
+
}
|
|
93968
|
+
function htmlContentLinks(html) {
|
|
93969
|
+
const start2 = html.indexOf("<main");
|
|
93970
|
+
const end = html.indexOf("</main>", start2);
|
|
93971
|
+
const body = start2 >= 0 && end > start2 ? html.slice(start2, end) : html;
|
|
93972
|
+
return [...body.matchAll(/<a\s[^>]*href="([^"]*)"/gu)].map((match) => decode2(match[1]));
|
|
93973
|
+
}
|
|
93974
|
+
async function customPageLinkProblems(output, base, keys) {
|
|
93975
|
+
const problems = [];
|
|
93976
|
+
const anchors = new Map;
|
|
93977
|
+
const idsOf = async (file) => {
|
|
93978
|
+
let ids = anchors.get(file);
|
|
93979
|
+
if (!ids) {
|
|
93980
|
+
ids = htmlAnchorIds(await readFile71(join81(output, file), "utf8"));
|
|
93981
|
+
anchors.set(file, ids);
|
|
93982
|
+
}
|
|
93983
|
+
return ids;
|
|
93984
|
+
};
|
|
93985
|
+
const prefix = base.endsWith("/") ? base : `${base}/`;
|
|
93986
|
+
for (const key of keys) {
|
|
93987
|
+
const page = `custom/${key}.html`;
|
|
93988
|
+
if (!existsSync19(join81(output, page)))
|
|
93989
|
+
continue;
|
|
93990
|
+
for (const href of htmlContentLinks(await readFile71(join81(output, page), "utf8"))) {
|
|
93991
|
+
if (!href || /^[a-z][a-z0-9+.-]*:/iu.test(href) || href.startsWith("//"))
|
|
93992
|
+
continue;
|
|
93993
|
+
const [rawPath = "", fragment2] = href.split("#", 2);
|
|
93994
|
+
const path2 = rawPath.split("?", 1)[0];
|
|
93995
|
+
let target;
|
|
93996
|
+
if (path2 === "")
|
|
93997
|
+
target = page;
|
|
93998
|
+
else if (path2.startsWith("/")) {
|
|
93999
|
+
if (!path2.startsWith(prefix) && `${path2}/` !== prefix)
|
|
94000
|
+
continue;
|
|
94001
|
+
target = path2.slice(prefix.length);
|
|
94002
|
+
} else
|
|
94003
|
+
target = posix10.normalize(posix10.join(posix10.dirname(page), path2));
|
|
94004
|
+
if (target === "" || target.endsWith("/"))
|
|
94005
|
+
target += "index.html";
|
|
94006
|
+
else if (!posix10.extname(target))
|
|
94007
|
+
target += ".html";
|
|
94008
|
+
if (target.startsWith("..") || !existsSync19(join81(output, target))) {
|
|
94009
|
+
problems.push(`${page}: link ${href} has no target`);
|
|
94010
|
+
continue;
|
|
94011
|
+
}
|
|
94012
|
+
if (fragment2 && target.endsWith(".html") && !(await idsOf(target)).has(decode2(fragment2))) {
|
|
94013
|
+
problems.push(`${page}: link ${href} points to a missing anchor in ${target}`);
|
|
94014
|
+
}
|
|
94015
|
+
}
|
|
94016
|
+
}
|
|
94017
|
+
return problems;
|
|
94018
|
+
}
|
|
94019
|
+
var ENTITIES;
|
|
94020
|
+
var init_siteCustomPageLinks = __esm(() => {
|
|
94021
|
+
ENTITIES = { amp: "&", lt: "<", gt: ">", quot: '"', "#39": "'", apos: "'" };
|
|
94022
|
+
});
|
|
94023
|
+
|
|
93909
94024
|
// src/project/packageSite.ts
|
|
93910
94025
|
import { createHash as createHash26 } from "node:crypto";
|
|
93911
94026
|
import { spawn as spawn4 } from "node:child_process";
|
|
93912
|
-
import { mkdir as mkdir30, mkdtemp as mkdtemp3, readFile as
|
|
94027
|
+
import { mkdir as mkdir30, mkdtemp as mkdtemp3, readFile as readFile72, writeFile as writeFile23, rm as rm18, symlink as symlink4, cp as cp2, access as access5, stat as stat9 } from "node:fs/promises";
|
|
93913
94028
|
import { createRequire as createRequire5 } from "node:module";
|
|
93914
|
-
import { dirname as dirname36, join as
|
|
94029
|
+
import { dirname as dirname36, join as join82, posix as posix11 } from "node:path";
|
|
93915
94030
|
function sitePagePath(identity) {
|
|
93916
94031
|
return `pages/${createHash26("sha256").update(identity).digest("hex").slice(0, 32)}.html`;
|
|
93917
94032
|
}
|
|
@@ -93937,7 +94052,7 @@ function createSiteNavigation(pkg, selected, structure) {
|
|
|
93937
94052
|
approved_path: `knowledge/${file.relPath}`,
|
|
93938
94053
|
package_path: packageKnowledgeOutputPath(pkg, file.relPath),
|
|
93939
94054
|
site_path: path2,
|
|
93940
|
-
title: typeof meta.title === "string" ? meta.title :
|
|
94055
|
+
title: typeof meta.title === "string" ? meta.title : posix11.basename(file.relPath, ".md")
|
|
93941
94056
|
};
|
|
93942
94057
|
});
|
|
93943
94058
|
for (const [key, href] of siteExtensionTargets(pkg.kind === "package.kb" ? pkg.site : undefined)) {
|
|
@@ -93991,7 +94106,7 @@ function siteMarkdown(content3, from, pages, files) {
|
|
|
93991
94106
|
const [pathPart, fragment2] = link.target.split(/#(.*)/su);
|
|
93992
94107
|
let path2;
|
|
93993
94108
|
try {
|
|
93994
|
-
path2 =
|
|
94109
|
+
path2 = posix11.normalize(posix11.join(posix11.dirname(from), decodeURIComponent(pathPart.split("?")[0])));
|
|
93995
94110
|
} catch {
|
|
93996
94111
|
continue;
|
|
93997
94112
|
}
|
|
@@ -94031,7 +94146,7 @@ function siteSections(entries2) {
|
|
|
94031
94146
|
async function compileSite(root, outDir) {
|
|
94032
94147
|
const vitepressRoot = dirname36(require2.resolve("vitepress/package.json"));
|
|
94033
94148
|
await new Promise((resolve8, reject) => {
|
|
94034
|
-
const child = spawn4(process.versions.bun ? "node" : process.execPath, [
|
|
94149
|
+
const child = spawn4(process.versions.bun ? "node" : process.execPath, [join82(vitepressRoot, "bin/vitepress.js"), "build", root, "--outDir", outDir], { stdio: ["ignore", "pipe", "pipe"] });
|
|
94035
94150
|
let tail = "";
|
|
94036
94151
|
const receive = (chunk) => {
|
|
94037
94152
|
tail = (tail + chunk.toString()).slice(-16000);
|
|
@@ -94091,15 +94206,15 @@ async function siteSourceMaps(input) {
|
|
|
94091
94206
|
file.article.sections.forEach((section) => section.references.forEach(({ source_ref: ref2, locator }) => {
|
|
94092
94207
|
const note = ref2.startsWith("note:") ? input.registry.notes.find((entry) => ref2 === `note:${entry.id}`) : undefined;
|
|
94093
94208
|
const lark = ref2.startsWith("lark:") ? input.registry.larks.find((entry) => ref2 === `lark:${entry.id}` || ref2 === `lark:${entry.name}`) : undefined;
|
|
94094
|
-
const path2 = note ? note.materializedAt : lark && !lark.title ?
|
|
94095
|
-
if (path2 && !
|
|
94209
|
+
const path2 = note ? note.materializedAt : lark && !lark.title ? posix11.join(lark.materializedAt, locator.path) : undefined;
|
|
94210
|
+
if (path2 && !posix11.normalize(path2).startsWith("../"))
|
|
94096
94211
|
documents.set(siteDocumentKey(ref2, locator.path), path2);
|
|
94097
94212
|
}));
|
|
94098
94213
|
articles.push({ article: file.article, href: `/${page.site_path}`, titles: titles2, sectionTitles });
|
|
94099
94214
|
}
|
|
94100
94215
|
const titles = new Map;
|
|
94101
94216
|
for (const [key, file] of documents) {
|
|
94102
|
-
const content3 = await
|
|
94217
|
+
const content3 = await readFile72(join82(input.projectRoot, file), "utf8").catch(() => {
|
|
94103
94218
|
return;
|
|
94104
94219
|
});
|
|
94105
94220
|
const title = content3 && (/^title:[ \t]*["']?(.+?)["']?[ \t]*$/mu.exec(/^---\r?\n([\s\S]*?)\r?\n---/u.exec(content3)?.[1] ?? "")?.[1] ?? /^#[ \t]+(.+?)[ \t#]*$/mu.exec(content3)?.[1]);
|
|
@@ -94121,8 +94236,8 @@ async function writePackageSite(input) {
|
|
|
94121
94236
|
const base = options.base ?? "/";
|
|
94122
94237
|
const history = await readWorkspaceChangelog(projectRoot);
|
|
94123
94238
|
const historyDate = history[0]?.date ?? null;
|
|
94124
|
-
const root =
|
|
94125
|
-
const output =
|
|
94239
|
+
const root = join82(projectRoot, pkg.outDir);
|
|
94240
|
+
const output = join82(projectRoot, packageSiteOutputDir(pkg));
|
|
94126
94241
|
try {
|
|
94127
94242
|
await access5(output);
|
|
94128
94243
|
throw new Error("Website output already exists; build through the staged package workflow.");
|
|
@@ -94130,9 +94245,9 @@ async function writePackageSite(input) {
|
|
|
94130
94245
|
if (error.code !== "ENOENT")
|
|
94131
94246
|
throw error;
|
|
94132
94247
|
}
|
|
94133
|
-
const temporaryRoot =
|
|
94248
|
+
const temporaryRoot = join82(projectRoot, ".tmp");
|
|
94134
94249
|
await mkdir30(temporaryRoot, { recursive: true });
|
|
94135
|
-
const temporary = await mkdtemp3(
|
|
94250
|
+
const temporary = await mkdtemp3(join82(temporaryRoot, "website-"));
|
|
94136
94251
|
try {
|
|
94137
94252
|
const registry2 = await loadSourcesRegistry({ rootDir: projectRoot });
|
|
94138
94253
|
const repositoryRemote = await optionalRepoGit(projectRoot, ["remote", "get-url", "origin"]);
|
|
@@ -94147,22 +94262,22 @@ async function writePackageSite(input) {
|
|
|
94147
94262
|
continue;
|
|
94148
94263
|
if (!/^(?:skills|wikis|guides|rules|feats)\/.*\.md$/u.test(file.relPath) || byPath.has(file.relPath))
|
|
94149
94264
|
continue;
|
|
94150
|
-
const content3 = await
|
|
94265
|
+
const content3 = await readFile72(file.absPath, "utf8");
|
|
94151
94266
|
const meta = parseKnowledgeFrontmatter(content3);
|
|
94152
94267
|
const page = {
|
|
94153
94268
|
package_path: file.relPath,
|
|
94154
94269
|
site_path: sitePagePath(`index:${file.relPath}`),
|
|
94155
|
-
title: typeof meta.title === "string" ? meta.title : typeof meta.name === "string" ? meta.name : /^#\s+(.+)$/mu.exec(content3)?.[1] ??
|
|
94270
|
+
title: typeof meta.title === "string" ? meta.title : typeof meta.name === "string" ? meta.name : /^#\s+(.+)$/mu.exec(content3)?.[1] ?? posix11.basename(file.relPath, ".md")
|
|
94156
94271
|
};
|
|
94157
94272
|
byPath.set(file.relPath, page);
|
|
94158
94273
|
}
|
|
94159
94274
|
const sections = siteSections(mapping.entries);
|
|
94160
94275
|
const resources = new Set(delivered.filter((file) => file.relPath.startsWith("others/assets/") || file.relPath.startsWith("skills/") && !file.relPath.endsWith(".md")).map((file) => file.relPath));
|
|
94161
|
-
const configRoot =
|
|
94162
|
-
await mkdir30(
|
|
94163
|
-
await mkdir30(
|
|
94276
|
+
const configRoot = join82(temporary, ".vitepress");
|
|
94277
|
+
await mkdir30(join82(configRoot, "theme"), { recursive: true });
|
|
94278
|
+
await mkdir30(join82(temporary, "node_modules"), { recursive: true });
|
|
94164
94279
|
const vitepressRoot = dirname36(require2.resolve("vitepress/package.json"));
|
|
94165
|
-
const vueRequire = createRequire5(
|
|
94280
|
+
const vueRequire = createRequire5(join82(vitepressRoot, "package.json"));
|
|
94166
94281
|
for (const [name3, path2] of [
|
|
94167
94282
|
["vitepress", vitepressRoot],
|
|
94168
94283
|
["vue", dirname36(vueRequire.resolve("vue/package.json"))],
|
|
@@ -94170,17 +94285,17 @@ async function writePackageSite(input) {
|
|
|
94170
94285
|
["mermaid", dirname36(require2.resolve("mermaid/package.json"))],
|
|
94171
94286
|
["markdown-it-cjk-friendly", dirname36(require2.resolve("markdown-it-cjk-friendly/package.json"))]
|
|
94172
94287
|
]) {
|
|
94173
|
-
await mkdir30(dirname36(
|
|
94174
|
-
await symlink4(path2,
|
|
94288
|
+
await mkdir30(dirname36(join82(temporary, "node_modules", name3)), { recursive: true });
|
|
94289
|
+
await symlink4(path2, join82(temporary, "node_modules", name3), "dir");
|
|
94175
94290
|
}
|
|
94176
94291
|
const readers = siteReaderLocales(options, pkg.name);
|
|
94177
94292
|
const marker = createLocaleMarker();
|
|
94178
94293
|
const theme = await resolveSiteTheme(projectRoot, options.theme, true);
|
|
94179
|
-
await writeFile23(
|
|
94180
|
-
await writeFile23(
|
|
94294
|
+
await writeFile23(join82(configRoot, "theme/index.js"), siteThemeScript);
|
|
94295
|
+
await writeFile23(join82(configRoot, "theme/style.css"), siteThemeCss + siteLocaleCss(readers) + siteThemeVariables(theme));
|
|
94181
94296
|
await writeSiteExtensions(projectRoot, temporary, options.extensions);
|
|
94182
94297
|
const localizer = await createSiteLocalizer({ projectRoot, readers, marker, selected, byPath, resources });
|
|
94183
|
-
await mkdir30(
|
|
94298
|
+
await mkdir30(join82(temporary, "pages"), { recursive: true });
|
|
94184
94299
|
const primaryBody = (page, packageContent) => {
|
|
94185
94300
|
let content3 = packageContent;
|
|
94186
94301
|
if (page.package_path === "wikis/index.md" && typeof pkg.repoContentPage !== "object") {
|
|
@@ -94220,9 +94335,9 @@ ${titles ? `contextTitles: ${JSON.stringify(titles)}
|
|
|
94220
94335
|
`;
|
|
94221
94336
|
};
|
|
94222
94337
|
for (const page of byPath.values()) {
|
|
94223
|
-
const content3 = await
|
|
94338
|
+
const content3 = await readFile72(join82(root, page.package_path), "utf8");
|
|
94224
94339
|
const localized = await localizer.page(page, primaryBody(page, content3));
|
|
94225
|
-
await writeFile23(
|
|
94340
|
+
await writeFile23(join82(temporary, page.site_path.replace(/\.html$/u, ".md")), `${pageFrontmatter(page, content3, localized.titles)}
|
|
94226
94341
|
${localized.body}`);
|
|
94227
94342
|
}
|
|
94228
94343
|
const themeSections = sections.map((section) => ({
|
|
@@ -94281,7 +94396,7 @@ ${localized.body}`);
|
|
|
94281
94396
|
contextLocales: { primary: readers.primary, tags: readers.tags, labels: readers.labels, titles: readers.titles, preferenceKey: readers.preferenceKey }
|
|
94282
94397
|
}
|
|
94283
94398
|
};
|
|
94284
|
-
await writeFile23(
|
|
94399
|
+
await writeFile23(join82(configRoot, "config.mjs"), `${siteMarkdownImports()}const contextLocaleMarker = ${JSON.stringify(readers.translated ? marker : null)};
|
|
94285
94400
|
` + `export default { ...${JSON.stringify(config)}, markdown: { ${siteMarkdownConfig} },
|
|
94286
94401
|
` + ` transformHtml: html => html.replace(/<script id="check-dark-mode">[\\s\\S]*?<\\/script>/u, "") };
|
|
94287
94402
|
`);
|
|
@@ -94297,9 +94412,9 @@ ${localized.body}`);
|
|
|
94297
94412
|
menu(lines, entries2, 0, tag);
|
|
94298
94413
|
lines.push("", "</div>", "");
|
|
94299
94414
|
};
|
|
94300
|
-
await mkdir30(
|
|
94415
|
+
await mkdir30(join82(temporary, "sections"), { recursive: true });
|
|
94301
94416
|
for (const section of sections) {
|
|
94302
|
-
await writeFile23(
|
|
94417
|
+
await writeFile23(join82(temporary, section.href.slice(1).replace(/\.html$/u, ".md")), localizer.variants((tag) => {
|
|
94303
94418
|
const lines = [`# ${mdLabel(localizer.entryTitle(tag, section.entry))}`, "", '<div class="context-section-grid">', ""];
|
|
94304
94419
|
const grouped = section.entries.some((entry) => entry.children.length > 0);
|
|
94305
94420
|
let articles = [];
|
|
@@ -94338,12 +94453,12 @@ ${localized.body}`);
|
|
|
94338
94453
|
` : "";
|
|
94339
94454
|
const homeHero = options.extensions?.slots?.banner === undefined ? `hero: ${JSON.stringify(hero)}
|
|
94340
94455
|
${heroActions}` : "";
|
|
94341
|
-
await writeFile23(
|
|
94456
|
+
await writeFile23(join82(temporary, "index.md"), `---
|
|
94342
94457
|
layout: home
|
|
94343
94458
|
title: ${JSON.stringify(options.home?.title ?? options.title ?? pkg.name)}
|
|
94344
94459
|
${homeHero}---
|
|
94345
94460
|
`);
|
|
94346
|
-
await writeFile23(
|
|
94461
|
+
await writeFile23(join82(temporary, "changelog.md"), `---
|
|
94347
94462
|
title: Changelog
|
|
94348
94463
|
contextHistory: ${JSON.stringify(Buffer.from(JSON.stringify(history)).toString("base64"))}
|
|
94349
94464
|
---
|
|
@@ -94356,19 +94471,19 @@ contextHistory: ${JSON.stringify(Buffer.from(JSON.stringify(history)).toString("
|
|
|
94356
94471
|
assetsPrefix: "resources/",
|
|
94357
94472
|
articles: await Promise.all(llmsArticles(pkg, selected).map(async (article) => ({
|
|
94358
94473
|
...article,
|
|
94359
|
-
content: await
|
|
94474
|
+
content: await readFile72(join82(root, article.path), "utf8")
|
|
94360
94475
|
}))),
|
|
94361
94476
|
...structure ? { map: structure } : {}
|
|
94362
94477
|
});
|
|
94363
|
-
await writeLlmsDocuments(
|
|
94364
|
-
await mkdir30(
|
|
94478
|
+
await writeLlmsDocuments(join82(temporary, "public"), llms, { utf8Bom: true });
|
|
94479
|
+
await mkdir30(join82(temporary, "llms"), { recursive: true });
|
|
94365
94480
|
let landingNavigation = llms.navigationMarkdown;
|
|
94366
94481
|
for (const link of markdownReaderLinks(landingNavigation).reverse()) {
|
|
94367
94482
|
if (!link.target.startsWith(base))
|
|
94368
94483
|
continue;
|
|
94369
94484
|
landingNavigation = landingNavigation.slice(0, link.start) + `[${link.label}](</${link.target.slice(base.length)}>)` + landingNavigation.slice(link.end);
|
|
94370
94485
|
}
|
|
94371
|
-
await writeFile23(
|
|
94486
|
+
await writeFile23(join82(temporary, "llms/index.md"), `---
|
|
94372
94487
|
title: LLM Docs
|
|
94373
94488
|
---
|
|
94374
94489
|
|
|
@@ -94378,16 +94493,26 @@ title: LLM Docs
|
|
|
94378
94493
|
|
|
94379
94494
|
` + landingNavigation);
|
|
94380
94495
|
for (const path2 of resources) {
|
|
94381
|
-
const destination =
|
|
94496
|
+
const destination = join82(temporary, "public/resources", path2);
|
|
94382
94497
|
await mkdir30(dirname36(destination), { recursive: true });
|
|
94383
|
-
await cp2(
|
|
94498
|
+
await cp2(join82(root, path2), destination);
|
|
94384
94499
|
}
|
|
94385
94500
|
await compileSite(temporary, output);
|
|
94501
|
+
const customPages = Object.keys(options.extensions?.pages ?? {});
|
|
94502
|
+
if (customPages.length) {
|
|
94503
|
+
const { customPageLinkProblems: customPageLinkProblems2 } = await Promise.resolve().then(() => (init_siteCustomPageLinks(), exports_siteCustomPageLinks));
|
|
94504
|
+
const problems = await customPageLinkProblems2(output, base, customPages);
|
|
94505
|
+
if (problems.length)
|
|
94506
|
+
throw new Error(`Custom website pages contain ${problems.length} broken link(s). Existing package was preserved. Fix the links in the custom pages (heading anchors follow the website's rule, for example "_3v架构" for "3V架构") and rerun context build.
|
|
94507
|
+
${problems.slice(0, 50).join(`
|
|
94508
|
+
`)}${problems.length > 50 ? `
|
|
94509
|
+
… and ${problems.length - 50} more` : ""}`);
|
|
94510
|
+
}
|
|
94386
94511
|
const originLinks = [...navigation.nav, ...navigation.more].filter((item) => item.origin).map((item) => item.link);
|
|
94387
94512
|
for (const file of await walkPackageFiles(output)) {
|
|
94388
|
-
const extension2 =
|
|
94513
|
+
const extension2 = posix11.extname(file.relPath).toLowerCase();
|
|
94389
94514
|
if (extension2 === ".html" && originLinks.length) {
|
|
94390
|
-
const html = await
|
|
94515
|
+
const html = await readFile72(file.absPath, "utf8");
|
|
94391
94516
|
const restored = restoreOriginNavLinks(html, base, originLinks);
|
|
94392
94517
|
if (restored !== html)
|
|
94393
94518
|
await writeFile23(file.absPath, restored);
|
|
@@ -94412,11 +94537,11 @@ title: LLM Docs
|
|
|
94412
94537
|
warnings: mapping.warnings
|
|
94413
94538
|
}, null, 2) + `
|
|
94414
94539
|
`;
|
|
94415
|
-
const packageSiteMap =
|
|
94416
|
-
const distributedSiteMap =
|
|
94540
|
+
const packageSiteMap = join82(projectRoot, pkg.outDir, "context-site-map.json");
|
|
94541
|
+
const distributedSiteMap = join82(projectRoot, pkg.outDir, packageDistributionMetadataPath("context-site-map.json"));
|
|
94417
94542
|
await mkdir30(dirname36(distributedSiteMap), { recursive: true });
|
|
94418
94543
|
await Promise.all([
|
|
94419
|
-
writeFile23(
|
|
94544
|
+
writeFile23(join82(output, "context-site-map.json"), siteMapContent),
|
|
94420
94545
|
writeFile23(packageSiteMap, siteMapContent),
|
|
94421
94546
|
writeFile23(distributedSiteMap, siteMapContent)
|
|
94422
94547
|
]);
|
|
@@ -94463,7 +94588,7 @@ var init_packageSite2 = __esm(() => {
|
|
|
94463
94588
|
});
|
|
94464
94589
|
|
|
94465
94590
|
// src/project/workspaceBuildVersion.ts
|
|
94466
|
-
import { join as
|
|
94591
|
+
import { join as join83 } from "node:path";
|
|
94467
94592
|
import { mkdir as mkdir31, writeFile as writeFile24 } from "node:fs/promises";
|
|
94468
94593
|
async function workspaceVersionFingerprint(root) {
|
|
94469
94594
|
return { version: await workspaceVersion(root), changelog: await readWorkspaceChangelog(root) };
|
|
@@ -94475,8 +94600,8 @@ async function writePackageVersion(projectRoot, output) {
|
|
|
94475
94600
|
throw new TypeError(`Package template uses reserved version output ${path2}; rename that template output.`);
|
|
94476
94601
|
}
|
|
94477
94602
|
await mkdir31(output, { recursive: true });
|
|
94478
|
-
await writeFile24(
|
|
94479
|
-
await writeFile24(
|
|
94603
|
+
await writeFile24(join83(output, "CHANGELOG.md"), renderChangelog(info2.changelog));
|
|
94604
|
+
await writeFile24(join83(output, "context-version.json"), JSON.stringify({ version: info2.version }) + `
|
|
94480
94605
|
`);
|
|
94481
94606
|
}
|
|
94482
94607
|
var init_workspaceBuildVersion = __esm(() => {
|
|
@@ -94484,23 +94609,23 @@ var init_workspaceBuildVersion = __esm(() => {
|
|
|
94484
94609
|
});
|
|
94485
94610
|
|
|
94486
94611
|
// src/project/packageBuildStage.ts
|
|
94487
|
-
import { mkdir as mkdir32, mkdtemp as mkdtemp4, readFile as
|
|
94488
|
-
import { dirname as dirname37, join as
|
|
94612
|
+
import { mkdir as mkdir32, mkdtemp as mkdtemp4, readFile as readFile73, rename as rename9, rm as rm19, rmdir } from "node:fs/promises";
|
|
94613
|
+
import { dirname as dirname37, join as join84, relative as relative27 } from "node:path";
|
|
94489
94614
|
async function withStagedPackageOutput(projectRoot, pkg, render) {
|
|
94490
|
-
const tempRoot =
|
|
94615
|
+
const tempRoot = join84(projectRoot, ".tmp");
|
|
94491
94616
|
await mkdir32(tempRoot, { recursive: true });
|
|
94492
|
-
const stage = await mkdtemp4(
|
|
94493
|
-
const stagedPackage = { ...pkg, outDir: relative27(projectRoot,
|
|
94617
|
+
const stage = await mkdtemp4(join84(tempRoot, "package-build-"));
|
|
94618
|
+
const stagedPackage = { ...pkg, outDir: relative27(projectRoot, join84(stage, pkg.name)) };
|
|
94494
94619
|
try {
|
|
94495
|
-
await mkdir32(
|
|
94620
|
+
await mkdir32(join84(projectRoot, stagedPackage.outDir), { recursive: true });
|
|
94496
94621
|
const value = await render(stagedPackage);
|
|
94497
94622
|
await validatePackageIndexLinks({ projectRoot, pkg: stagedPackage });
|
|
94498
94623
|
const destinations = packageOutputDirs(pkg);
|
|
94499
94624
|
const staged = packageOutputDirs(stagedPackage);
|
|
94500
94625
|
for (const [index3, destination] of destinations.entries()) {
|
|
94501
|
-
const target =
|
|
94626
|
+
const target = join84(projectRoot, destination);
|
|
94502
94627
|
const previous2 = await walkPackageFiles(target);
|
|
94503
|
-
const next = await walkPackageFiles(
|
|
94628
|
+
const next = await walkPackageFiles(join84(projectRoot, staged[index3]));
|
|
94504
94629
|
const desired = new Set(next.map((file) => file.relPath));
|
|
94505
94630
|
for (const file of previous2) {
|
|
94506
94631
|
if (desired.has(file.relPath))
|
|
@@ -94518,9 +94643,9 @@ async function withStagedPackageOutput(projectRoot, pkg, render) {
|
|
|
94518
94643
|
}
|
|
94519
94644
|
for (let offset2 = 0;offset2 < next.length; offset2 += 8) {
|
|
94520
94645
|
const results = await Promise.allSettled(next.slice(offset2, offset2 + 8).map(async (file) => {
|
|
94521
|
-
const output =
|
|
94522
|
-
const bytes = await
|
|
94523
|
-
const old = await
|
|
94646
|
+
const output = join84(target, file.relPath);
|
|
94647
|
+
const bytes = await readFile73(file.absPath);
|
|
94648
|
+
const old = await readFile73(output).catch((error) => {
|
|
94524
94649
|
if (error.code === "ENOENT")
|
|
94525
94650
|
return;
|
|
94526
94651
|
throw error;
|
|
@@ -94549,7 +94674,7 @@ var init_packageBuildStage = __esm(() => {
|
|
|
94549
94674
|
// src/runtimeEventOutbox.ts
|
|
94550
94675
|
import {
|
|
94551
94676
|
closeSync,
|
|
94552
|
-
existsSync as
|
|
94677
|
+
existsSync as existsSync20,
|
|
94553
94678
|
mkdirSync as mkdirSync2,
|
|
94554
94679
|
openSync,
|
|
94555
94680
|
readFileSync as readFileSync7,
|
|
@@ -94558,7 +94683,7 @@ import {
|
|
|
94558
94683
|
unlinkSync,
|
|
94559
94684
|
writeFileSync as writeFileSync2
|
|
94560
94685
|
} from "node:fs";
|
|
94561
|
-
import { dirname as dirname38, join as
|
|
94686
|
+
import { dirname as dirname38, join as join85 } from "node:path";
|
|
94562
94687
|
function isRecord12(value) {
|
|
94563
94688
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
94564
94689
|
}
|
|
@@ -94576,10 +94701,10 @@ function parseEvent(value) {
|
|
|
94576
94701
|
};
|
|
94577
94702
|
}
|
|
94578
94703
|
function runtimeEventOutboxPath(projectRoot) {
|
|
94579
|
-
return
|
|
94704
|
+
return join85(projectRoot, OUTBOX_RELATIVE_PATH);
|
|
94580
94705
|
}
|
|
94581
94706
|
function readRuntimeEventOutboxFile(path2) {
|
|
94582
|
-
if (!
|
|
94707
|
+
if (!existsSync20(path2))
|
|
94583
94708
|
return [];
|
|
94584
94709
|
const pending = new Map;
|
|
94585
94710
|
try {
|
|
@@ -94707,20 +94832,20 @@ function acknowledgeRuntimeEventOutbox(projectRoot, eventIds) {
|
|
|
94707
94832
|
}
|
|
94708
94833
|
var OUTBOX_EVENT_SCHEMA = "context.runtime-event-outbox.event.v1", OUTBOX_ACK_SCHEMA = "context.runtime-event-outbox.ack.v1", OUTBOX_RELATIVE_PATH, OUTBOX_LOCK_STALE_MS = 30000, OUTBOX_LOCK_RETRY_MS = 10, OUTBOX_LOCK_RETRIES = 100;
|
|
94709
94834
|
var init_runtimeEventOutbox = __esm(() => {
|
|
94710
|
-
OUTBOX_RELATIVE_PATH =
|
|
94835
|
+
OUTBOX_RELATIVE_PATH = join85(".tmp", "context-runtime", "logs", "outbox.jsonl");
|
|
94711
94836
|
});
|
|
94712
94837
|
|
|
94713
94838
|
// src/runtimeEvents.ts
|
|
94714
94839
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
94715
94840
|
import {
|
|
94716
|
-
existsSync as
|
|
94841
|
+
existsSync as existsSync21,
|
|
94717
94842
|
mkdirSync as mkdirSync3,
|
|
94718
94843
|
readFileSync as readFileSync8,
|
|
94719
94844
|
renameSync as renameSync2,
|
|
94720
94845
|
writeFileSync as writeFileSync3
|
|
94721
94846
|
} from "node:fs";
|
|
94722
94847
|
import { spawn as spawn5 } from "node:child_process";
|
|
94723
|
-
import { dirname as dirname39, join as
|
|
94848
|
+
import { dirname as dirname39, join as join86 } from "node:path";
|
|
94724
94849
|
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
94725
94850
|
function isRecord13(value) {
|
|
94726
94851
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -94823,8 +94948,8 @@ function readRuntimePackageMetadata() {
|
|
|
94823
94948
|
try {
|
|
94824
94949
|
let dir = dirname39(fileURLToPath6(import.meta.url));
|
|
94825
94950
|
for (let index3 = 0;index3 < 8; index3++) {
|
|
94826
|
-
const packagePath =
|
|
94827
|
-
if (
|
|
94951
|
+
const packagePath = join86(dir, "package.json");
|
|
94952
|
+
if (existsSync21(packagePath)) {
|
|
94828
94953
|
const parsed = JSON.parse(readFileSync8(packagePath, "utf8"));
|
|
94829
94954
|
if (isRecord13(parsed)) {
|
|
94830
94955
|
return {
|
|
@@ -94960,7 +95085,7 @@ function dispatchCommand(sink, batch, cwd) {
|
|
|
94960
95085
|
});
|
|
94961
95086
|
}
|
|
94962
95087
|
function runtimeEventStatePath(cwd) {
|
|
94963
|
-
return
|
|
95088
|
+
return join86(cwd, ".tmp", "context-runtime", RUNTIME_EVENT_STATE_FILE);
|
|
94964
95089
|
}
|
|
94965
95090
|
function readRuntimeEventState(cwd) {
|
|
94966
95091
|
try {
|
|
@@ -95238,6 +95363,101 @@ var init_runtimeEvents = __esm(() => {
|
|
|
95238
95363
|
RUNTIME_EVENT_SINK_DESCRIPTION_MAX_BYTES = 16 * 1024;
|
|
95239
95364
|
});
|
|
95240
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
|
+
|
|
95241
95461
|
// src/project/packageTemplateGuard.ts
|
|
95242
95462
|
function validatePackageTemplateContract(pkg, templateFiles2) {
|
|
95243
95463
|
if (pkg.kind === "package.kb") {
|
|
@@ -95422,8 +95642,8 @@ var init_packageTemplateGuard = __esm(() => {
|
|
|
95422
95642
|
});
|
|
95423
95643
|
|
|
95424
95644
|
// src/project/approvedKnowledgeSnapshots.ts
|
|
95425
|
-
import { readFile as
|
|
95426
|
-
import { join as
|
|
95645
|
+
import { readFile as readFile76 } from "node:fs/promises";
|
|
95646
|
+
import { join as join89 } from "node:path";
|
|
95427
95647
|
function approvedKnowledgeSnapshotsFromStructure(structure) {
|
|
95428
95648
|
return validateArticleStructureEntries(structure?.articles ?? []);
|
|
95429
95649
|
}
|
|
@@ -95432,7 +95652,7 @@ async function prepareApprovedKnowledgeSnapshotTarget(input) {
|
|
|
95432
95652
|
return;
|
|
95433
95653
|
let before;
|
|
95434
95654
|
try {
|
|
95435
|
-
before = await
|
|
95655
|
+
before = await readFile76(join89(input.projectRoot, STRUCTURE_PATH2), "utf8");
|
|
95436
95656
|
} catch (error) {
|
|
95437
95657
|
if (error.code !== "ENOENT")
|
|
95438
95658
|
throw error;
|
|
@@ -95610,12 +95830,12 @@ function approvedStructureInputHash(input) {
|
|
|
95610
95830
|
var init_approvedStructureInputHash = () => {};
|
|
95611
95831
|
|
|
95612
95832
|
// src/project/verifyApprovedStructure.ts
|
|
95613
|
-
import { existsSync as
|
|
95614
|
-
import { join as
|
|
95833
|
+
import { existsSync as existsSync22 } from "node:fs";
|
|
95834
|
+
import { join as join90 } from "node:path";
|
|
95615
95835
|
async function validateApprovedStructure(input) {
|
|
95616
95836
|
const issue = (code, path3, message) => input.issues.push({ severity: "error", code, path: path3, message });
|
|
95617
|
-
const path2 =
|
|
95618
|
-
if (!input.structureOverride && !
|
|
95837
|
+
const path2 = join90(input.projectRoot, STRUCTURE_PATH3);
|
|
95838
|
+
if (!input.structureOverride && !existsSync22(path2))
|
|
95619
95839
|
return;
|
|
95620
95840
|
let parsed;
|
|
95621
95841
|
let articles;
|
|
@@ -95771,8 +95991,8 @@ var init_verifyDiagnostics = __esm(() => {
|
|
|
95771
95991
|
});
|
|
95772
95992
|
|
|
95773
95993
|
// src/project/verify.ts
|
|
95774
|
-
import { existsSync as
|
|
95775
|
-
import { join as
|
|
95994
|
+
import { existsSync as existsSync23 } from "node:fs";
|
|
95995
|
+
import { join as join91 } from "node:path";
|
|
95776
95996
|
function evidenceStatusForIssues(issues) {
|
|
95777
95997
|
if (issues.some((issue) => issue.severity === "error"))
|
|
95778
95998
|
return "fail";
|
|
@@ -95846,7 +96066,7 @@ async function verifyProjectWorkspace(projectRoot, options = {}) {
|
|
|
95846
96066
|
pageRelPath: `knowledge/${file.relPath}`,
|
|
95847
96067
|
content: content3
|
|
95848
96068
|
})) {
|
|
95849
|
-
if (!
|
|
96069
|
+
if (!existsSync23(join91(projectRoot, assetPath))) {
|
|
95850
96070
|
issues.push({
|
|
95851
96071
|
severity: "error",
|
|
95852
96072
|
code: "approved-resource-missing",
|
|
@@ -95984,9 +96204,9 @@ __export(exports_packageBuilder, {
|
|
|
95984
96204
|
buildProjectPackages: () => buildProjectPackages
|
|
95985
96205
|
});
|
|
95986
96206
|
import { createHash as createHash28 } from "node:crypto";
|
|
95987
|
-
import { existsSync as
|
|
95988
|
-
import { mkdir as mkdir33, readdir as readdir21, readFile as
|
|
95989
|
-
import { dirname as dirname40, join as
|
|
96207
|
+
import { existsSync as existsSync24 } from "node:fs";
|
|
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";
|
|
95990
96210
|
function packageAssetDeliverySummary(value) {
|
|
95991
96211
|
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
95992
96212
|
return;
|
|
@@ -96008,7 +96228,7 @@ function assertPackageOutputDir(pkg) {
|
|
|
96008
96228
|
}
|
|
96009
96229
|
function packageFingerprintPath(projectRoot, pkg) {
|
|
96010
96230
|
assertSafeRenderedPath(`${pkg.name}.json`, "package fingerprint path");
|
|
96011
|
-
return
|
|
96231
|
+
return join92(projectRoot, PACKAGE_FINGERPRINT_ROOT, `${pkg.name}.json`);
|
|
96012
96232
|
}
|
|
96013
96233
|
async function listApprovedKnowledge(projectRoot) {
|
|
96014
96234
|
const metadata = await readApprovedKnowledgeMetadataIndex(projectRoot);
|
|
@@ -96039,7 +96259,7 @@ function isDeprecatedKnowledge(content3) {
|
|
|
96039
96259
|
async function listTemplateFiles(projectRoot, templatePath) {
|
|
96040
96260
|
assertSafeRenderedPath(templatePath, "package template path");
|
|
96041
96261
|
const templateRoot = resolve31(projectRoot, templatePath);
|
|
96042
|
-
if (!
|
|
96262
|
+
if (!existsSync24(templateRoot)) {
|
|
96043
96263
|
throw new ContextError(ExitCode.WorkspaceStateError, `package template path is missing: ${templatePath}`, {
|
|
96044
96264
|
category: ErrorCategory.WorkspaceStateInvalid,
|
|
96045
96265
|
path: templatePath,
|
|
@@ -96049,7 +96269,7 @@ async function listTemplateFiles(projectRoot, templatePath) {
|
|
|
96049
96269
|
const files = await walkPackageFiles(templateRoot);
|
|
96050
96270
|
return Promise.all(files.filter((file) => file.relPath.split("/").at(-1) !== PACKAGE_TEMPLATE_REVIEW_FILE).map(async (file) => ({
|
|
96051
96271
|
...file,
|
|
96052
|
-
content: await
|
|
96272
|
+
content: await readFile77(file.absPath, "utf8")
|
|
96053
96273
|
})));
|
|
96054
96274
|
}
|
|
96055
96275
|
function stableHash2(value) {
|
|
@@ -96091,6 +96311,7 @@ async function packageInputFingerprint(input) {
|
|
|
96091
96311
|
name: input.pkg.name,
|
|
96092
96312
|
select: input.pkg.select ?? null,
|
|
96093
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 } : {},
|
|
96094
96315
|
assets: input.pkg.kind === "package.kb" ? input.pkg.assets ?? null : null,
|
|
96095
96316
|
...input.pkg.kind === "package.kb" && input.pkg.site ? { site: { ...input.pkg.site, renderer: PACKAGE_SITE_VERSION } } : {},
|
|
96096
96317
|
template: input.pkg.template,
|
|
@@ -96114,10 +96335,10 @@ async function packageInputFingerprint(input) {
|
|
|
96114
96335
|
}
|
|
96115
96336
|
async function readPackageManifest(projectRoot, pkg) {
|
|
96116
96337
|
const filePath2 = packageFingerprintPath(projectRoot, pkg);
|
|
96117
|
-
if (!
|
|
96338
|
+
if (!existsSync24(filePath2))
|
|
96118
96339
|
return null;
|
|
96119
96340
|
try {
|
|
96120
|
-
const parsed = JSON.parse(await
|
|
96341
|
+
const parsed = JSON.parse(await readFile77(filePath2, "utf8"));
|
|
96121
96342
|
if (parsed !== null && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
96122
96343
|
const candidate = parsed;
|
|
96123
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)) {
|
|
@@ -96164,12 +96385,12 @@ async function writePackageFingerprint(input) {
|
|
|
96164
96385
|
`, "utf8");
|
|
96165
96386
|
}
|
|
96166
96387
|
async function removeOrphanPackageDirs(projectRoot, packages) {
|
|
96167
|
-
const distRoot =
|
|
96168
|
-
if (!
|
|
96388
|
+
const distRoot = join92(projectRoot, "dist");
|
|
96389
|
+
if (!existsSync24(distRoot))
|
|
96169
96390
|
return;
|
|
96170
96391
|
const declaredNames = new Set(packages.flatMap((pkg) => packageOutputDirs(pkg).map((path2) => path2.slice("dist/".length))));
|
|
96171
96392
|
const entries2 = await readdir21(distRoot, { withFileTypes: true });
|
|
96172
|
-
await Promise.all(entries2.filter((entry) => entry.isDirectory() && !declaredNames.has(entry.name)).map((entry) => rm20(
|
|
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 })));
|
|
96173
96394
|
}
|
|
96174
96395
|
async function collectPackageFreshness(projectRoot, packages) {
|
|
96175
96396
|
assertDistinctPackageOutputs(packages);
|
|
@@ -96178,8 +96399,8 @@ async function collectPackageFreshness(projectRoot, packages) {
|
|
|
96178
96399
|
assertPackageOutputDir(pkg);
|
|
96179
96400
|
const selected = selectPackageKnowledge(approved, pkg);
|
|
96180
96401
|
assertSafeRenderedPath(pkg.template.path, "package template path");
|
|
96181
|
-
const templateRoot =
|
|
96182
|
-
const templateExists =
|
|
96402
|
+
const templateRoot = join92(projectRoot, pkg.template.path);
|
|
96403
|
+
const templateExists = existsSync24(templateRoot);
|
|
96183
96404
|
if (!templateExists) {
|
|
96184
96405
|
throw new ContextError(ExitCode.WorkspaceStateError, `package template path is missing: ${pkg.template.path}`, {
|
|
96185
96406
|
category: ErrorCategory.WorkspaceStateInvalid,
|
|
@@ -96345,11 +96566,13 @@ async function buildProjectPackagesInternal(projectRoot, options) {
|
|
|
96345
96566
|
if (previousManifest?.builderProtocol === PACKAGE_BUILDER_PROTOCOL_VERSION && previousManifest.fingerprint === fingerprint && previousManifest.assetDelivery !== undefined) {
|
|
96346
96567
|
const existingOutput = await packageOutputFingerprint(projectRoot, pkg);
|
|
96347
96568
|
if (existingOutput.fingerprint === previousManifest.outputFingerprint) {
|
|
96569
|
+
const unchangedRules = await inspectPackageRules(projectRoot, pkg);
|
|
96348
96570
|
summaries.push({
|
|
96349
96571
|
name: pkg.name,
|
|
96350
96572
|
kind: packageKind(pkg),
|
|
96351
96573
|
outDir: pkg.outDir,
|
|
96352
96574
|
...pkg.kind === "package.kb" && pkg.site ? { siteOutDir: packageSiteOutputDir(pkg) } : {},
|
|
96575
|
+
...unchangedRules ? { rules: unchangedRules } : {},
|
|
96353
96576
|
inputs: selected.length,
|
|
96354
96577
|
files: existingOutput.files,
|
|
96355
96578
|
state: "unchanged",
|
|
@@ -96429,19 +96652,19 @@ async function buildProjectPackagesInternal(projectRoot, options) {
|
|
|
96429
96652
|
if (stagedPkg.kind === "package.llms") {
|
|
96430
96653
|
const articles = await Promise.all(llmsArticles(stagedPkg, selected).map(async (article) => ({
|
|
96431
96654
|
...article,
|
|
96432
|
-
content: await
|
|
96655
|
+
content: await readFile77(join92(projectRoot, stagedPkg.outDir, article.path), "utf8")
|
|
96433
96656
|
})));
|
|
96434
|
-
await writeLlmsDocuments(
|
|
96657
|
+
await writeLlmsDocuments(join92(projectRoot, stagedPkg.outDir), buildLlmsDocuments({
|
|
96435
96658
|
title: stagedPkg.name,
|
|
96436
96659
|
articles,
|
|
96437
96660
|
...reading ? { map: reading } : {}
|
|
96438
96661
|
}), { preserveIndex: true });
|
|
96439
96662
|
}
|
|
96440
|
-
await writePackageVersion(projectRoot,
|
|
96663
|
+
await writePackageVersion(projectRoot, join92(projectRoot, stagedPkg.outDir));
|
|
96441
96664
|
await writePackageSite({ projectRoot, pkg: stagedPkg, selected, ...siteUrl ? { siteUrl } : {}, ...reading ? { structure: reading } : {} });
|
|
96442
96665
|
const linkWarnings = [
|
|
96443
96666
|
...writtenKnowledge2.linkWarnings,
|
|
96444
|
-
...await inspectPackageMarkdownDirectory(
|
|
96667
|
+
...await inspectPackageMarkdownDirectory(join92(projectRoot, stagedPkg.outDir))
|
|
96445
96668
|
];
|
|
96446
96669
|
return { ...writtenKnowledge2, linkWarnings };
|
|
96447
96670
|
});
|
|
@@ -96459,9 +96682,11 @@ async function buildProjectPackagesInternal(projectRoot, options) {
|
|
|
96459
96682
|
assetDelivery: writtenKnowledge.assetDelivery,
|
|
96460
96683
|
linkWarnings: writtenKnowledge.linkWarnings
|
|
96461
96684
|
});
|
|
96685
|
+
const rulesReport = await inspectPackageRules(projectRoot, pkg);
|
|
96462
96686
|
summaries.push({
|
|
96463
96687
|
name: pkg.name,
|
|
96464
96688
|
...pkg.kind === "package.kb" && pkg.site ? { siteOutDir: packageSiteOutputDir(pkg) } : {},
|
|
96689
|
+
...rulesReport ? { rules: rulesReport } : {},
|
|
96465
96690
|
kind: packageKind(pkg),
|
|
96466
96691
|
outDir: pkg.outDir,
|
|
96467
96692
|
inputs: selected.length,
|
|
@@ -96573,6 +96798,7 @@ var init_packageBuilder = __esm(() => {
|
|
|
96573
96798
|
init_packageIndexes();
|
|
96574
96799
|
init_packageNavigation();
|
|
96575
96800
|
init_packageBuildReceipt();
|
|
96801
|
+
init_packageRulesSize();
|
|
96576
96802
|
init_packageBuildContent();
|
|
96577
96803
|
init_packageTemplateGuard();
|
|
96578
96804
|
init_packageAssets();
|
|
@@ -96586,7 +96812,7 @@ var init_packageBuilder = __esm(() => {
|
|
|
96586
96812
|
init_siteTranslation();
|
|
96587
96813
|
init_approvedKnowledgeMetadata();
|
|
96588
96814
|
import_yaml44 = __toESM(require_dist(), 1);
|
|
96589
|
-
PACKAGE_FINGERPRINT_ROOT =
|
|
96815
|
+
PACKAGE_FINGERPRINT_ROOT = join92(".tmp", "context-runtime", "packages");
|
|
96590
96816
|
});
|
|
96591
96817
|
|
|
96592
96818
|
// src/project/knowledgeMaintenance.ts
|
|
@@ -96601,15 +96827,15 @@ __export(exports_knowledgeMaintenance, {
|
|
|
96601
96827
|
cancelKnowledgeMaintenance: () => cancelKnowledgeMaintenance,
|
|
96602
96828
|
advanceKnowledgeMaintenance: () => advanceKnowledgeMaintenance
|
|
96603
96829
|
});
|
|
96604
|
-
import { readFile as
|
|
96605
|
-
import { join as
|
|
96830
|
+
import { readFile as readFile78, readdir as readdir22, rm as rm21 } from "node:fs/promises";
|
|
96831
|
+
import { join as join93 } from "node:path";
|
|
96606
96832
|
async function deliveryDigest(root) {
|
|
96607
|
-
const directory =
|
|
96833
|
+
const directory = join93(root, ".tmp/context-runtime/packages");
|
|
96608
96834
|
try {
|
|
96609
96835
|
const files = (await readdir22(directory)).filter((name3) => name3.endsWith(".json")).sort();
|
|
96610
96836
|
if (!files.length)
|
|
96611
96837
|
return indexerProtocolDigest(null);
|
|
96612
|
-
return indexerProtocolDigest(await Promise.all(files.map((name3) =>
|
|
96838
|
+
return indexerProtocolDigest(await Promise.all(files.map((name3) => readFile78(join93(directory, name3), "utf8"))));
|
|
96613
96839
|
} catch (error) {
|
|
96614
96840
|
if (error.code === "ENOENT")
|
|
96615
96841
|
return indexerProtocolDigest(null);
|
|
@@ -96752,7 +96978,7 @@ async function observeKnowledgeMaintenance(root) {
|
|
|
96752
96978
|
async function maintenanceRevision(root) {
|
|
96753
96979
|
const observed = await observeKnowledgeMaintenance(root);
|
|
96754
96980
|
const localInputs = observed.state.active ? {
|
|
96755
|
-
revision: await
|
|
96981
|
+
revision: await readFile78(join93(root, MAINTENANCE_ROOT, "revision.json"), "utf8").catch((error) => {
|
|
96756
96982
|
if (error.code === "ENOENT")
|
|
96757
96983
|
return null;
|
|
96758
96984
|
throw error;
|
|
@@ -96865,7 +97091,7 @@ async function finishMaintenanceRevision(root, outcome = "completed") {
|
|
|
96865
97091
|
outcome = state.active.completion_outcome;
|
|
96866
97092
|
state.active.phase = "finishing";
|
|
96867
97093
|
await saveMaintenance(root, state);
|
|
96868
|
-
await rm21(
|
|
97094
|
+
await rm21(join93(root, MAINTENANCE_ROOT, "revision.json"), { force: true });
|
|
96869
97095
|
state.completed.push({ id: state.active.input.id, input_digest: indexerProtocolDigest(state.active.input), outcome });
|
|
96870
97096
|
delete state.active;
|
|
96871
97097
|
await saveMaintenance(root, state);
|
|
@@ -96899,8 +97125,8 @@ async function discardMaintenanceDraft(root) {
|
|
|
96899
97125
|
const owned = new Set([...request?.batch_candidates ?? [], ...request?.candidate ? [request.candidate] : []].map((item) => item.candidate_id));
|
|
96900
97126
|
if (candidates.some((item) => !owned.has(item.candidate_id)))
|
|
96901
97127
|
throw new TypeError("Unrelated Candidates are present; no draft was discarded. Inspect the current review before retrying cancellation.");
|
|
96902
|
-
await rm21(
|
|
96903
|
-
await rm21(
|
|
97128
|
+
await rm21(join93(root, CANDIDATE_LEDGER_FILE), { force: true });
|
|
97129
|
+
await rm21(join93(root, MAINTENANCE_ROOT, "revision.json"), { force: true });
|
|
96904
97130
|
const { closeProjectWorkspace } = await Promise.resolve().then(() => (init_close(), exports_close));
|
|
96905
97131
|
const { buildProjectPackages: buildProjectPackages2 } = await Promise.resolve().then(() => (init_packageBuilder(), exports_packageBuilder));
|
|
96906
97132
|
await closeProjectWorkspace(root);
|
|
@@ -96928,8 +97154,8 @@ __export(exports_taskRollback, {
|
|
|
96928
97154
|
readTaskRollback: () => readTaskRollback,
|
|
96929
97155
|
finishTaskRollback: () => finishTaskRollback
|
|
96930
97156
|
});
|
|
96931
|
-
import { readFile as
|
|
96932
|
-
import { join as
|
|
97157
|
+
import { readFile as readFile79, rm as rm22 } from "node:fs/promises";
|
|
97158
|
+
import { join as join94 } from "node:path";
|
|
96933
97159
|
async function productionScope(projectRoot) {
|
|
96934
97160
|
const { readProductionStage: readProductionStage2 } = await Promise.resolve().then(() => (init_productionStageStore(), exports_productionStageStore));
|
|
96935
97161
|
const stage = await readProductionStage2(projectRoot);
|
|
@@ -96970,7 +97196,7 @@ async function readTaskRollback(projectRoot) {
|
|
|
96970
97196
|
}
|
|
96971
97197
|
async function contents(projectRoot, path2) {
|
|
96972
97198
|
try {
|
|
96973
|
-
return await
|
|
97199
|
+
return await readFile79(join94(projectRoot, path2), "utf8");
|
|
96974
97200
|
} catch (error) {
|
|
96975
97201
|
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT")
|
|
96976
97202
|
return;
|
|
@@ -97118,7 +97344,7 @@ async function finishTaskRollback(projectRoot) {
|
|
|
97118
97344
|
const production = await readProductionStage2(projectRoot);
|
|
97119
97345
|
const recorded = rollback.production;
|
|
97120
97346
|
if (production && recorded !== undefined && (recorded === null || !recorded.discard || recorded.stage !== production.id)) {
|
|
97121
|
-
await rm22(
|
|
97347
|
+
await rm22(join94(projectRoot, await revisionStoragePath(projectRoot)), { force: true });
|
|
97122
97348
|
return {
|
|
97123
97349
|
action: "finished",
|
|
97124
97350
|
production: recorded?.stage === production.id ? "resumed" : "kept",
|
|
@@ -97251,9 +97477,9 @@ __export(exports_close, {
|
|
|
97251
97477
|
approvedStructureInputHashFor: () => approvedStructureInputHashFor,
|
|
97252
97478
|
approvedKnowledgeInputHash: () => approvedKnowledgeInputHash
|
|
97253
97479
|
});
|
|
97254
|
-
import { existsSync as
|
|
97480
|
+
import { existsSync as existsSync25 } from "node:fs";
|
|
97255
97481
|
import { mkdir as mkdir34, writeFile as writeFile26 } from "node:fs/promises";
|
|
97256
|
-
import { dirname as dirname41, join as
|
|
97482
|
+
import { dirname as dirname41, join as join95 } from "node:path";
|
|
97257
97483
|
function parseFrontmatter4(content3) {
|
|
97258
97484
|
const match = /^---\r?\n([\s\S]*?)\r?\n---/u.exec(content3);
|
|
97259
97485
|
if (match?.[1] === undefined)
|
|
@@ -97325,7 +97551,7 @@ async function deriveApprovedStructure(projectRoot) {
|
|
|
97325
97551
|
}
|
|
97326
97552
|
async function writeApprovedStructureProjection(projectRoot) {
|
|
97327
97553
|
const { inputHash, structure, compactFiles } = await deriveApprovedStructure(projectRoot);
|
|
97328
|
-
const outputPath =
|
|
97554
|
+
const outputPath = join95(projectRoot, STRUCTURE_PATH4);
|
|
97329
97555
|
await mkdir34(dirname41(outputPath), { recursive: true });
|
|
97330
97556
|
await writeFile26(outputPath, import_yaml45.default.stringify(structure), "utf8");
|
|
97331
97557
|
await Promise.all(compactFiles.map((file) => writeFile26(file.absPath, file.content, "utf8")));
|
|
@@ -97336,11 +97562,11 @@ function referencesReceipt() {
|
|
|
97336
97562
|
}
|
|
97337
97563
|
async function readProjectCloseStatus(projectRoot) {
|
|
97338
97564
|
const approved = await approvedKnowledgeFiles(projectRoot);
|
|
97339
|
-
const structurePath =
|
|
97340
|
-
if (approved.length === 0 && !
|
|
97565
|
+
const structurePath = join95(projectRoot, STRUCTURE_PATH4);
|
|
97566
|
+
if (approved.length === 0 && !existsSync25(structurePath))
|
|
97341
97567
|
return { state: "missing", diagnostics: [] };
|
|
97342
97568
|
const inputHash = await approvedKnowledgeInputHash(projectRoot);
|
|
97343
|
-
if (!
|
|
97569
|
+
if (!existsSync25(structurePath))
|
|
97344
97570
|
return { state: "missing", inputHash, diagnostics: [`close structure is missing: ${STRUCTURE_PATH4}`] };
|
|
97345
97571
|
try {
|
|
97346
97572
|
const parsed = await readApprovedStructureValue(projectRoot);
|
|
@@ -97400,7 +97626,7 @@ async function closeProjectWorkspace(projectRoot) {
|
|
|
97400
97626
|
next: "Fix context verify errors, then rerun context close --format json."
|
|
97401
97627
|
});
|
|
97402
97628
|
}
|
|
97403
|
-
const outputPath =
|
|
97629
|
+
const outputPath = join95(projectRoot, STRUCTURE_PATH4);
|
|
97404
97630
|
await mkdir34(dirname41(outputPath), { recursive: true });
|
|
97405
97631
|
await writeFile26(outputPath, `${import_yaml45.default.stringify(structure)}`, "utf8");
|
|
97406
97632
|
await Promise.all(compactFiles.map((file) => writeFile26(file.absPath, file.content, "utf8")));
|
|
@@ -97477,7 +97703,7 @@ var init_close = __esm(() => {
|
|
|
97477
97703
|
init_knowledgeAssetRepair();
|
|
97478
97704
|
init_approvedKnowledgeMetadata();
|
|
97479
97705
|
import_yaml45 = __toESM(require_dist(), 1);
|
|
97480
|
-
STRUCTURE_PATH4 =
|
|
97706
|
+
STRUCTURE_PATH4 = join95(KNOWLEDGE_ROOT, "structure.yaml");
|
|
97481
97707
|
});
|
|
97482
97708
|
|
|
97483
97709
|
// src/project/processedScopeStorage.ts
|
|
@@ -97490,8 +97716,8 @@ __export(exports_processedScopeStorage, {
|
|
|
97490
97716
|
commitProcessedScopes: () => commitProcessedScopes,
|
|
97491
97717
|
captureProcessedScopes: () => captureProcessedScopes
|
|
97492
97718
|
});
|
|
97493
|
-
import { access as access6, readFile as
|
|
97494
|
-
import { dirname as dirname42, join as
|
|
97719
|
+
import { access as access6, readFile as readFile80 } from "node:fs/promises";
|
|
97720
|
+
import { dirname as dirname42, join as join96 } from "node:path";
|
|
97495
97721
|
async function currentScopeSourceVersion(projectRoot, sourceRef) {
|
|
97496
97722
|
if (sourceRef.startsWith("repo-content:"))
|
|
97497
97723
|
return repoContentWorkingVersion(projectRoot, sourceRef);
|
|
@@ -97517,7 +97743,7 @@ async function currentScopeSourceVersion(projectRoot, sourceRef) {
|
|
|
97517
97743
|
throw new TypeError(`Source must identify one registered document: ${sourceRef}`);
|
|
97518
97744
|
const entry = entries2[0];
|
|
97519
97745
|
const manifest = entry.snapshot?.manifest ?? `${entry.materializedAt}/manifest.json`;
|
|
97520
|
-
return parseDocumentSnapshotForSource(JSON.parse(await
|
|
97746
|
+
return parseDocumentSnapshotForSource(JSON.parse(await readFile80(join96(projectRoot, manifest), "utf8")), entry.name).snapshot_hash;
|
|
97521
97747
|
}
|
|
97522
97748
|
async function sourceMaterialAvailable(projectRoot, sourceRef) {
|
|
97523
97749
|
try {
|
|
@@ -97540,10 +97766,10 @@ async function sourceMaterialAvailable(projectRoot, sourceRef) {
|
|
|
97540
97766
|
if (entries2.length !== 1)
|
|
97541
97767
|
return false;
|
|
97542
97768
|
const manifestPath = entries2[0].snapshot?.manifest ?? `${entries2[0].materializedAt}/manifest.json`;
|
|
97543
|
-
const snapshot = parseDocumentSnapshotForSource(JSON.parse(await
|
|
97544
|
-
const base =
|
|
97769
|
+
const snapshot = parseDocumentSnapshotForSource(JSON.parse(await readFile80(join96(projectRoot, manifestPath), "utf8")), entries2[0].name);
|
|
97770
|
+
const base = join96(projectRoot, dirname42(manifestPath));
|
|
97545
97771
|
for (const file of snapshot.files)
|
|
97546
|
-
await access6(
|
|
97772
|
+
await access6(join96(base, file.path));
|
|
97547
97773
|
return true;
|
|
97548
97774
|
} catch {
|
|
97549
97775
|
return false;
|
|
@@ -97581,7 +97807,7 @@ async function commitProcessedScopes(projectRoot, scopes) {
|
|
|
97581
97807
|
const { articles } = await inspectSettledReferences(projectRoot, repoContent, scopes.map((scope2) => scope2.source_ref), settled);
|
|
97582
97808
|
const { approvedStructureInputHashFor: approvedStructureInputHashFor2 } = await Promise.resolve().then(() => (init_close(), exports_close));
|
|
97583
97809
|
const input_hash = structure.parsed.input_hash === await approvedStructureInputHashFor2(projectRoot, previous2) ? await approvedStructureInputHashFor2(projectRoot, articles) : structure.parsed.input_hash;
|
|
97584
|
-
await atomicWriteFile(
|
|
97810
|
+
await atomicWriteFile(join96(projectRoot, structure.path), import_yaml46.default.stringify({ ...structure.parsed, input_hash, articles, processed_scopes: processed }));
|
|
97585
97811
|
}
|
|
97586
97812
|
async function invalidateChangedProcessedRequirements(projectRoot, previous2, current3) {
|
|
97587
97813
|
const targets = new Map(current3.map((requirement2) => [requirement2.id, indexerProtocolDigest(requirement2)]));
|
|
@@ -97595,7 +97821,7 @@ async function invalidateChangedProcessedRequirements(projectRoot, previous2, cu
|
|
|
97595
97821
|
const retained = scopes.filter((scope2) => !changed.has(scope2.requirement_ref));
|
|
97596
97822
|
if (retained.length === scopes.length)
|
|
97597
97823
|
return;
|
|
97598
|
-
await atomicWriteFile(
|
|
97824
|
+
await atomicWriteFile(join96(projectRoot, structure.path), import_yaml46.default.stringify({ ...structure.parsed, processed_scopes: retained }));
|
|
97599
97825
|
}
|
|
97600
97826
|
async function migrateUnchangedScopeReferences(projectRoot, scopes) {
|
|
97601
97827
|
const structure = await readKnowledgeStructure(projectRoot);
|
|
@@ -97614,7 +97840,7 @@ async function migrateUnchangedScopeReferences(projectRoot, scopes) {
|
|
|
97614
97840
|
}
|
|
97615
97841
|
const { approvedStructureInputHashFor: approvedStructureInputHashFor2 } = await Promise.resolve().then(() => (init_close(), exports_close));
|
|
97616
97842
|
const input_hash = structure.parsed.input_hash === await approvedStructureInputHashFor2(projectRoot, previous2) ? await approvedStructureInputHashFor2(projectRoot, second.articles) : structure.parsed.input_hash;
|
|
97617
|
-
await atomicWriteFile(
|
|
97843
|
+
await atomicWriteFile(join96(projectRoot, structure.path), import_yaml46.default.stringify({ ...structure.parsed, input_hash, articles: second.articles }));
|
|
97618
97844
|
return previous2.flatMap((article) => article.sections.flatMap((section) => section.references.flatMap((before, index3) => {
|
|
97619
97845
|
const after = second.articles.find((item) => item.path === article.path).sections.find((item) => item.id === section.id).references[index3];
|
|
97620
97846
|
return indexerProtocolDigest(before) === indexerProtocolDigest(after) ? [] : [{ article: article.path, section: section.id, before, after }];
|
|
@@ -97633,7 +97859,7 @@ var init_processedScopeStorage = __esm(() => {
|
|
|
97633
97859
|
});
|
|
97634
97860
|
|
|
97635
97861
|
// src/project/codeAnalysisInput.ts
|
|
97636
|
-
import { readFile as
|
|
97862
|
+
import { readFile as readFile81 } from "node:fs/promises";
|
|
97637
97863
|
import { relative as relative28, resolve as resolve32 } from "node:path";
|
|
97638
97864
|
function safeCodeSourcePath(root, normalizedPath) {
|
|
97639
97865
|
const absolute = resolve32(root, normalizedPath);
|
|
@@ -97676,7 +97902,7 @@ function sourceFileSystem(root, tracked, texts, readSource) {
|
|
|
97676
97902
|
return {
|
|
97677
97903
|
readFile: async (path2) => {
|
|
97678
97904
|
const normalized = assertTrackedFile(path2);
|
|
97679
|
-
return contents2.has(normalized) ? contents2.get(normalized) : readSource ? readSource(normalized) :
|
|
97905
|
+
return contents2.has(normalized) ? contents2.get(normalized) : readSource ? readSource(normalized) : readFile81(safeCodeSourcePath(root, normalized), "utf8");
|
|
97680
97906
|
},
|
|
97681
97907
|
async readdir(path2) {
|
|
97682
97908
|
const normalized = normalizedVirtualPath(path2);
|
|
@@ -97738,7 +97964,7 @@ async function prepareCodeAnalysisInput(input) {
|
|
|
97738
97964
|
var init_codeAnalysisInput = () => {};
|
|
97739
97965
|
|
|
97740
97966
|
// src/project/revisionProtocolDeclarations.ts
|
|
97741
|
-
import { posix as
|
|
97967
|
+
import { posix as posix12 } from "node:path";
|
|
97742
97968
|
async function loadRevisionProtocolDependencies(capability, loadedModule, initial, trackedPaths, readSource) {
|
|
97743
97969
|
const isProto = capability === "parser.proto";
|
|
97744
97970
|
const exportName = isProto ? "lexProto" : "lexThrift";
|
|
@@ -97770,7 +97996,7 @@ async function loadRevisionProtocolDependencies(capability, loadedModule, initia
|
|
|
97770
97996
|
if (!name3 || name3.startsWith("/") || name3.includes("\\") || name3.split("/").some((part) => !part || part === "." || part === "..")) {
|
|
97771
97997
|
throw new TypeError(`Protocol import ${name3} in ${path2} escapes the captured source scope`);
|
|
97772
97998
|
}
|
|
97773
|
-
const candidates = isProto ? [name3] : [
|
|
97999
|
+
const candidates = isProto ? [name3] : [posix12.join(posix12.dirname(path2), name3), name3];
|
|
97774
98000
|
const dependency = candidates.find((candidate) => tracked.has(candidate));
|
|
97775
98001
|
if (!dependency)
|
|
97776
98002
|
throw new TypeError(`Protocol import ${name3} in ${path2} is missing from the captured source scope`);
|
|
@@ -97863,7 +98089,7 @@ __export(exports_approvedRevisionPrograms, {
|
|
|
97863
98089
|
});
|
|
97864
98090
|
import { execFile as execFile16 } from "node:child_process";
|
|
97865
98091
|
import { promisify as promisify13 } from "node:util";
|
|
97866
|
-
import { extname as extname11, join as
|
|
98092
|
+
import { extname as extname11, join as join97 } from "node:path";
|
|
97867
98093
|
import { createRequire as createRequire6 } from "node:module";
|
|
97868
98094
|
import { pathToFileURL } from "node:url";
|
|
97869
98095
|
async function prepareRevisionProgramBlocks(root, sourceRefs, scopes, references) {
|
|
@@ -97879,7 +98105,7 @@ async function prepareRevisionProgramBlocks(root, sourceRefs, scopes, references
|
|
|
97879
98105
|
if (entries2.length !== 1)
|
|
97880
98106
|
throw new TypeError(`Regeneration requires one registered source: ${source2}`);
|
|
97881
98107
|
const entry = entries2[0];
|
|
97882
|
-
const directory =
|
|
98108
|
+
const directory = join97(root, entry.materializedAt);
|
|
97883
98109
|
const paths = [...new Set(references.filter((reference2) => reference2.source_ref === source2).map((reference2) => reference2.locator.path))];
|
|
97884
98110
|
if (!paths.length)
|
|
97885
98111
|
continue;
|
|
@@ -98011,7 +98237,7 @@ var exports_approvedPageMove = {};
|
|
|
98011
98237
|
__export(exports_approvedPageMove, {
|
|
98012
98238
|
moveKnowledgeLinkTargets: () => moveKnowledgeLinkTargets
|
|
98013
98239
|
});
|
|
98014
|
-
import { posix as
|
|
98240
|
+
import { posix as posix13 } from "node:path";
|
|
98015
98241
|
function moveKnowledgeLinkTargets(content3, pagePath, previousPath, moves) {
|
|
98016
98242
|
return replaceMarkdownInlineLinkTargets(content3, (link) => {
|
|
98017
98243
|
const target = link.target;
|
|
@@ -98035,11 +98261,11 @@ function moveKnowledgeLinkTargets(content3, pagePath, previousPath, moves) {
|
|
|
98035
98261
|
if (!path2 || path2.startsWith("/") && !path2.startsWith("/knowledge/"))
|
|
98036
98262
|
return;
|
|
98037
98263
|
const rooted = path2.startsWith("knowledge/") || path2.startsWith("/knowledge/");
|
|
98038
|
-
const resolved = rooted ? path2.replace(/^\/?knowledge\//u, "") :
|
|
98264
|
+
const resolved = rooted ? path2.replace(/^\/?knowledge\//u, "") : posix13.normalize(posix13.join(posix13.dirname(previousPath), path2));
|
|
98039
98265
|
const destination = moves.get(resolved) ?? resolved;
|
|
98040
|
-
if (destination === resolved && (rooted ||
|
|
98266
|
+
if (destination === resolved && (rooted || posix13.dirname(pagePath) === posix13.dirname(previousPath)))
|
|
98041
98267
|
return;
|
|
98042
|
-
const rewritten = rooted ? `${path2.startsWith("/") ? "/" : ""}knowledge/${destination}` :
|
|
98268
|
+
const rewritten = rooted ? `${path2.startsWith("/") ? "/" : ""}knowledge/${destination}` : posix13.relative(posix13.dirname(pagePath), destination);
|
|
98043
98269
|
return `${encodeURI(rewritten)}${match[2]}`;
|
|
98044
98270
|
});
|
|
98045
98271
|
}
|
|
@@ -98065,8 +98291,8 @@ __export(exports_approvedRevision, {
|
|
|
98065
98291
|
assertApprovedRevisionBase: () => assertApprovedRevisionBase,
|
|
98066
98292
|
APPROVED_REVISION_PATH: () => APPROVED_REVISION_PATH
|
|
98067
98293
|
});
|
|
98068
|
-
import { readFile as
|
|
98069
|
-
import { join as
|
|
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";
|
|
98070
98296
|
function requestDigest(input) {
|
|
98071
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}/`)));
|
|
98072
98298
|
const ids = new Set(scopes?.map((scope2) => scope2.requirement_ref));
|
|
@@ -98104,7 +98330,7 @@ function revisionCandidateFingerprint(revision, markdown, sections) {
|
|
|
98104
98330
|
}
|
|
98105
98331
|
async function readApprovedRevision(projectRoot) {
|
|
98106
98332
|
try {
|
|
98107
|
-
return parseApprovedRevision(JSON.parse(await
|
|
98333
|
+
return parseApprovedRevision(JSON.parse(await readFile82(join98(projectRoot, await revisionStoragePath(projectRoot)), "utf8")));
|
|
98108
98334
|
} catch (error) {
|
|
98109
98335
|
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT")
|
|
98110
98336
|
return;
|
|
@@ -98163,16 +98389,16 @@ async function resolveApprovedRevisionAuthor(projectRoot, request) {
|
|
|
98163
98389
|
}
|
|
98164
98390
|
async function targetBytes(projectRoot, path2) {
|
|
98165
98391
|
const project = await realpath14(projectRoot);
|
|
98166
|
-
const root = await realpath14(
|
|
98392
|
+
const root = await realpath14(join98(projectRoot, "knowledge"));
|
|
98167
98393
|
const rootRelative = relative29(project, root);
|
|
98168
98394
|
if (isAbsolute16(rootRelative) || rootRelative === ".." || rootRelative.startsWith("../")) {
|
|
98169
98395
|
throw new TypeError("Approved knowledge directory leaves the Context workspace");
|
|
98170
98396
|
}
|
|
98171
|
-
const target = await realpath14(
|
|
98397
|
+
const target = await realpath14(join98(root, path2));
|
|
98172
98398
|
const rel = relative29(root, target);
|
|
98173
98399
|
if (isAbsolute16(rel) || rel === ".." || rel.startsWith("../"))
|
|
98174
98400
|
throw new TypeError("Approved revision target leaves knowledge/");
|
|
98175
|
-
return
|
|
98401
|
+
return readFile82(target, "utf8");
|
|
98176
98402
|
}
|
|
98177
98403
|
async function assertApprovedRevisionBase(projectRoot, request) {
|
|
98178
98404
|
let current3;
|
|
@@ -98325,7 +98551,7 @@ ${import_yaml47.default.stringify({ ...import_yaml47.default.parse(fields), type
|
|
|
98325
98551
|
revision: requestDigest(payload)
|
|
98326
98552
|
});
|
|
98327
98553
|
if (input.persist !== false) {
|
|
98328
|
-
await atomicWriteFile(
|
|
98554
|
+
await atomicWriteFile(join98(input.projectRoot, await revisionStoragePath(input.projectRoot)), `${JSON.stringify(request)}
|
|
98329
98555
|
`);
|
|
98330
98556
|
markSubmissionState("committed");
|
|
98331
98557
|
}
|
|
@@ -98453,7 +98679,7 @@ async function completeApprovedRevision(input) {
|
|
|
98453
98679
|
const { prepareRevisionBatchContinuation: prepareRevisionBatchContinuation3 } = await Promise.resolve().then(() => (init_approvedRevisionBatch(), exports_approvedRevisionBatch));
|
|
98454
98680
|
const next2 = await prepareRevisionBatchContinuation3(input.projectRoot, request, request.batch_candidates ?? []);
|
|
98455
98681
|
if (next2 || request.batch_candidates?.length || request.build_pending) {
|
|
98456
|
-
await atomicWriteFile(
|
|
98682
|
+
await atomicWriteFile(join98(input.projectRoot, await revisionStoragePath(input.projectRoot)), `${JSON.stringify(next2 ?? { ...request, review_ready: true })}
|
|
98457
98683
|
`);
|
|
98458
98684
|
markSubmissionState("committed");
|
|
98459
98685
|
} else {
|
|
@@ -98461,10 +98687,10 @@ async function completeApprovedRevision(input) {
|
|
|
98461
98687
|
}
|
|
98462
98688
|
return;
|
|
98463
98689
|
}
|
|
98464
|
-
const current3 = await
|
|
98690
|
+
const current3 = await readFile82(join98(input.projectRoot, await revisionStoragePath(input.projectRoot)), "utf8");
|
|
98465
98691
|
let previous2;
|
|
98466
98692
|
try {
|
|
98467
|
-
previous2 = await
|
|
98693
|
+
previous2 = await readFile82(join98(input.projectRoot, CANDIDATE_LEDGER_FILE), "utf8");
|
|
98468
98694
|
} catch (error) {
|
|
98469
98695
|
if (!(error && typeof error === "object" && ("code" in error) && error.code === "ENOENT"))
|
|
98470
98696
|
throw error;
|
|
@@ -98559,7 +98785,7 @@ async function advanceApprovedRevision(projectRoot, request, buildPending = fals
|
|
|
98559
98785
|
return;
|
|
98560
98786
|
const { readProductionStage: readProductionStage2 } = await Promise.resolve().then(() => (init_productionStageStore(), exports_productionStageStore));
|
|
98561
98787
|
if (await readProductionStage2(projectRoot)) {
|
|
98562
|
-
await rm23(
|
|
98788
|
+
await rm23(join98(projectRoot, await revisionStoragePath(projectRoot)), { force: true });
|
|
98563
98789
|
return;
|
|
98564
98790
|
}
|
|
98565
98791
|
const { clearCompletedLifecycle: clearCompletedLifecycle2 } = await Promise.resolve().then(() => (init_lifecycleCleanup(), exports_lifecycleCleanup));
|
|
@@ -98663,12 +98889,12 @@ Additional request: ${input.instruction.trim()}` : input.instruction.trim();
|
|
|
98663
98889
|
}))
|
|
98664
98890
|
} : {}
|
|
98665
98891
|
} };
|
|
98666
|
-
const current3 = await
|
|
98892
|
+
const current3 = await readFile82(join98(input.projectRoot, await revisionStoragePath(input.projectRoot)), "utf8");
|
|
98667
98893
|
const content3 = `${JSON.stringify({ ...payload, revision: requestDigest(payload) })}
|
|
98668
98894
|
`;
|
|
98669
98895
|
let ledger;
|
|
98670
98896
|
try {
|
|
98671
|
-
ledger = await
|
|
98897
|
+
ledger = await readFile82(join98(input.projectRoot, CANDIDATE_LEDGER_FILE), "utf8");
|
|
98672
98898
|
} catch (error) {
|
|
98673
98899
|
if (!(error && typeof error === "object" && ("code" in error) && error.code === "ENOENT"))
|
|
98674
98900
|
throw error;
|
|
@@ -98788,8 +99014,8 @@ var init_sourceInputMutation = __esm(() => {
|
|
|
98788
99014
|
|
|
98789
99015
|
// src/project/documentCapture.ts
|
|
98790
99016
|
import { createHash as createHash29 } from "node:crypto";
|
|
98791
|
-
import { lstat as lstat15, mkdir as mkdir35, readdir as readdir23, readFile as
|
|
98792
|
-
import { basename as basename7, dirname as dirname43, extname as extname12, join as
|
|
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";
|
|
98793
99019
|
function toPosixPath7(path2) {
|
|
98794
99020
|
return path2.split(/[\\/]+/u).filter((part) => part.length > 0).join("/");
|
|
98795
99021
|
}
|
|
@@ -98927,7 +99153,7 @@ async function walkMarkdownFiles(input) {
|
|
|
98927
99153
|
const visit3 = async (dir) => {
|
|
98928
99154
|
const entries2 = await readdir23(dir, { withFileTypes: true });
|
|
98929
99155
|
for (const entry of entries2) {
|
|
98930
|
-
const absolutePath =
|
|
99156
|
+
const absolutePath = join99(dir, entry.name);
|
|
98931
99157
|
if (entry.isSymbolicLink() && input.rejectSymlinks === true) {
|
|
98932
99158
|
throw new ContextError(ExitCode.UserError, `file source contains a symbolic link: ${toPosixPath7(relative30(input.localRoot, absolutePath))}`, {
|
|
98933
99159
|
category: ErrorCategory.UserInputInvalid,
|
|
@@ -98957,14 +99183,14 @@ async function walkMarkdownFiles(input) {
|
|
|
98957
99183
|
}
|
|
98958
99184
|
async function writeTextIfChanged(path2, content3) {
|
|
98959
99185
|
try {
|
|
98960
|
-
if (await
|
|
99186
|
+
if (await readFile83(path2, "utf8") === content3)
|
|
98961
99187
|
return;
|
|
98962
99188
|
} catch {}
|
|
98963
99189
|
await mkdir35(dirname43(path2), { recursive: true });
|
|
98964
99190
|
await writeFile27(path2, content3, "utf8");
|
|
98965
99191
|
}
|
|
98966
99192
|
function sourceManifestPath(entry) {
|
|
98967
|
-
return entry.snapshot?.manifest ??
|
|
99193
|
+
return entry.snapshot?.manifest ?? join99(entry.materializedAt, "manifest.json");
|
|
98968
99194
|
}
|
|
98969
99195
|
function runtimeError2(message, detail) {
|
|
98970
99196
|
return new ContextError(ExitCode.UserError, message, {
|
|
@@ -99069,7 +99295,7 @@ async function removeEmptySnapshotDirs(root, dir = root) {
|
|
|
99069
99295
|
for (const entry of entries2) {
|
|
99070
99296
|
if (!entry.isDirectory() || entry.name === ".tmp" || entry.name === ".cache")
|
|
99071
99297
|
continue;
|
|
99072
|
-
await removeEmptySnapshotDirs(root,
|
|
99298
|
+
await removeEmptySnapshotDirs(root, join99(dir, entry.name));
|
|
99073
99299
|
}
|
|
99074
99300
|
if (dir === root)
|
|
99075
99301
|
return;
|
|
@@ -99081,7 +99307,7 @@ async function removeEmptySnapshotDirs(root, dir = root) {
|
|
|
99081
99307
|
async function cleanupStaleSnapshotFiles(input) {
|
|
99082
99308
|
for (const path2 of input.previousPaths) {
|
|
99083
99309
|
if (!input.currentPaths.has(path2)) {
|
|
99084
|
-
await rm24(
|
|
99310
|
+
await rm24(join99(input.materializedAtAbsPath, path2), { force: true });
|
|
99085
99311
|
}
|
|
99086
99312
|
}
|
|
99087
99313
|
await removeEmptySnapshotDirs(input.materializedAtAbsPath);
|
|
@@ -99093,7 +99319,7 @@ async function readDocumentFiles(input) {
|
|
|
99093
99319
|
for (const file of input.files) {
|
|
99094
99320
|
let raw;
|
|
99095
99321
|
try {
|
|
99096
|
-
raw = await
|
|
99322
|
+
raw = await readFile83(file.absolutePath, "utf8");
|
|
99097
99323
|
} catch (error) {
|
|
99098
99324
|
const message = error instanceof Error ? error.message : String(error);
|
|
99099
99325
|
throw runtimeError2(`file source ${input.sourceName} document read failed: ${file.snapshotPath}: ${message}`, {
|
|
@@ -99294,9 +99520,9 @@ async function runCaptureFilePhaseUnlocked(input) {
|
|
|
99294
99520
|
routeMetadata,
|
|
99295
99521
|
documentSnapshot
|
|
99296
99522
|
});
|
|
99297
|
-
const manifestAbsPath =
|
|
99523
|
+
const manifestAbsPath = join99(input.projectRoot, manifestPath);
|
|
99298
99524
|
const materializedAt = entry.materializedAt;
|
|
99299
|
-
const materializedAtAbsPath =
|
|
99525
|
+
const materializedAtAbsPath = join99(input.projectRoot, materializedAt);
|
|
99300
99526
|
const manifestInput = {
|
|
99301
99527
|
sourceType: "file",
|
|
99302
99528
|
sourceName: resolved.sourceName,
|
|
@@ -99348,13 +99574,13 @@ async function runCaptureFilePhaseUnlocked(input) {
|
|
|
99348
99574
|
}));
|
|
99349
99575
|
try {
|
|
99350
99576
|
for (const file of snapshotFiles) {
|
|
99351
|
-
await writeTextIfChanged(
|
|
99577
|
+
await writeTextIfChanged(join99(materializedAtAbsPath, file.path), String(file.bytes));
|
|
99352
99578
|
}
|
|
99353
99579
|
for (const file of files.metadata) {
|
|
99354
|
-
await writeTextIfChanged(
|
|
99580
|
+
await writeTextIfChanged(join99(materializedAtAbsPath, file.snapshotPath), routeMetadata.rawByPath.get(file.snapshotPath) ?? "");
|
|
99355
99581
|
}
|
|
99356
99582
|
for (const asset of linkedAssets) {
|
|
99357
|
-
await writeCaptureAssetIfChanged(
|
|
99583
|
+
await writeCaptureAssetIfChanged(join99(materializedAtAbsPath, asset.snapshotPath), asset.bytes);
|
|
99358
99584
|
}
|
|
99359
99585
|
await writeTextIfChanged(manifestAbsPath, manifestContent);
|
|
99360
99586
|
await cleanupStaleSnapshotFiles({
|
|
@@ -99556,7 +99782,7 @@ var init_entityId = __esm(() => {
|
|
|
99556
99782
|
// src/project/reviewShared.ts
|
|
99557
99783
|
import { createHash as createHash30 } from "node:crypto";
|
|
99558
99784
|
import { mkdir as mkdir36, writeFile as writeFile28 } from "node:fs/promises";
|
|
99559
|
-
import { dirname as dirname44, join as
|
|
99785
|
+
import { dirname as dirname44, join as join100 } from "node:path";
|
|
99560
99786
|
function isRecord14(value) {
|
|
99561
99787
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
99562
99788
|
}
|
|
@@ -99599,7 +99825,7 @@ async function buildApprovedArticleIndex(projectRoot) {
|
|
|
99599
99825
|
if (!isApprovedKnowledgeMarkdownPath(rel))
|
|
99600
99826
|
continue;
|
|
99601
99827
|
const { absPath, content: content3 } = file;
|
|
99602
|
-
const relPath =
|
|
99828
|
+
const relPath = join100("knowledge", collection, rel);
|
|
99603
99829
|
assetReferencesByRelPath.set(relPath, knowledgeAssetReferences({
|
|
99604
99830
|
pageRelPath: relPath,
|
|
99605
99831
|
content: content3
|
|
@@ -99612,7 +99838,7 @@ async function buildApprovedArticleIndex(projectRoot) {
|
|
|
99612
99838
|
continue;
|
|
99613
99839
|
const frontmatter2 = hydrateApprovedFrontmatter({
|
|
99614
99840
|
frontmatter: parsed,
|
|
99615
|
-
relPath:
|
|
99841
|
+
relPath: join100(collection, rel),
|
|
99616
99842
|
metadata
|
|
99617
99843
|
});
|
|
99618
99844
|
const article = articlesByPath.get(`${collection}/${rel}`);
|
|
@@ -99667,8 +99893,8 @@ ${yaml3}
|
|
|
99667
99893
|
}
|
|
99668
99894
|
async function writeReviewActionLog(input) {
|
|
99669
99895
|
const stamp = new Date().toISOString().replace(/[-:.TZ]/gu, "");
|
|
99670
|
-
const relPath =
|
|
99671
|
-
const path2 =
|
|
99896
|
+
const relPath = join100(REVIEW_ACTION_ROOT2, `${stamp}-${input.action}-${input.id.replace(/[\\/]+/gu, "_")}.json`);
|
|
99897
|
+
const path2 = join100(input.projectRoot, relPath);
|
|
99672
99898
|
await mkdir36(dirname44(path2), { recursive: true });
|
|
99673
99899
|
await writeFile28(path2, `${JSON.stringify({
|
|
99674
99900
|
action: input.action,
|
|
@@ -99701,7 +99927,7 @@ var init_reviewShared = __esm(() => {
|
|
|
99701
99927
|
init_knowledgeAssets();
|
|
99702
99928
|
init_entityId();
|
|
99703
99929
|
import_yaml48 = __toESM(require_dist(), 1);
|
|
99704
|
-
REVIEW_ACTION_ROOT2 =
|
|
99930
|
+
REVIEW_ACTION_ROOT2 = join100(".tmp", "context-runtime", "review-actions");
|
|
99705
99931
|
});
|
|
99706
99932
|
|
|
99707
99933
|
// src/project/managedDocumentStatus.ts
|
|
@@ -99776,17 +100002,17 @@ __export(exports_statusReaders, {
|
|
|
99776
100002
|
loadStatusPhases: () => loadStatusPhases,
|
|
99777
100003
|
countFiles: () => countFiles
|
|
99778
100004
|
});
|
|
99779
|
-
import { existsSync as
|
|
99780
|
-
import { join as
|
|
100005
|
+
import { existsSync as existsSync26, readFileSync as readFileSync9 } from "node:fs";
|
|
100006
|
+
import { join as join101 } from "node:path";
|
|
99781
100007
|
async function countFiles(root, predicate) {
|
|
99782
|
-
if (!
|
|
100008
|
+
if (!existsSync26(root))
|
|
99783
100009
|
return 0;
|
|
99784
100010
|
let count = 0;
|
|
99785
100011
|
const visit3 = async (dir, prefix = "") => {
|
|
99786
100012
|
const entries2 = await readCommandDirectory(dir);
|
|
99787
100013
|
for (const entry of entries2) {
|
|
99788
100014
|
const rel = prefix.length === 0 ? entry.name : `${prefix}/${entry.name}`;
|
|
99789
|
-
const abs =
|
|
100015
|
+
const abs = join101(dir, entry.name);
|
|
99790
100016
|
if (entry.isDirectory())
|
|
99791
100017
|
await visit3(abs, rel);
|
|
99792
100018
|
else if (entry.isFile() && predicate(rel))
|
|
@@ -99988,8 +100214,8 @@ async function documentSourceSiteHint(input) {
|
|
|
99988
100214
|
});
|
|
99989
100215
|
}
|
|
99990
100216
|
function documentSnapshotReadiness(input) {
|
|
99991
|
-
const manifestPath =
|
|
99992
|
-
if (!
|
|
100217
|
+
const manifestPath = join101(input.projectRoot, input.manifest);
|
|
100218
|
+
if (!existsSync26(manifestPath)) {
|
|
99993
100219
|
return {
|
|
99994
100220
|
ready: false,
|
|
99995
100221
|
diagnostics: [`snapshot is missing: ${input.manifest}`],
|
|
@@ -100069,7 +100295,7 @@ function documentSnapshotReadiness(input) {
|
|
|
100069
100295
|
const missingFiles = [
|
|
100070
100296
|
...manifest.files.map((file) => file.path),
|
|
100071
100297
|
...(manifest.assets ?? []).filter((asset) => asset.content_hash !== undefined).map((asset) => asset.path)
|
|
100072
|
-
].filter((path2) => !
|
|
100298
|
+
].filter((path2) => !existsSync26(join101(input.projectRoot, input.materializedAt, path2)));
|
|
100073
100299
|
if (missingFiles.length > 0) {
|
|
100074
100300
|
return {
|
|
100075
100301
|
ready: false,
|
|
@@ -100116,12 +100342,12 @@ var init_statusReaders = __esm(() => {
|
|
|
100116
100342
|
|
|
100117
100343
|
// src/project/documentCaptureAvailability.ts
|
|
100118
100344
|
import { createHash as createHash31 } from "node:crypto";
|
|
100119
|
-
import { readFile as
|
|
100120
|
-
import { join as
|
|
100345
|
+
import { readFile as readFile84, rm as rm25 } from "node:fs/promises";
|
|
100346
|
+
import { join as join102 } from "node:path";
|
|
100121
100347
|
import { isDeepStrictEqual } from "node:util";
|
|
100122
100348
|
function receiptPath(root, phaseId) {
|
|
100123
100349
|
const key = createHash31("sha256").update(phaseId).digest("hex");
|
|
100124
|
-
return
|
|
100350
|
+
return join102(root, ".tmp/context-runtime/document-acquisition", `${key}.json`);
|
|
100125
100351
|
}
|
|
100126
100352
|
async function identity(root, phase) {
|
|
100127
100353
|
const resolved = await resolveDocumentPhaseSource({ projectRoot: root, phase });
|
|
@@ -100156,7 +100382,7 @@ async function runDocumentCaptureWithAvailability(root, phase, capture2) {
|
|
|
100156
100382
|
...Array.isArray(error.detail.access_events) ? { access_events: error.detail.access_events } : {},
|
|
100157
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."
|
|
100158
100384
|
};
|
|
100159
|
-
await applyAtomicFileBatch({ transactionRoot:
|
|
100385
|
+
await applyAtomicFileBatch({ transactionRoot: join102(root, ".tmp/context-runtime/transactions"), writes: [{ path: path2, bytes: `${JSON.stringify({ configuration, warning }, null, 2)}
|
|
100160
100386
|
` }] });
|
|
100161
100387
|
return {
|
|
100162
100388
|
kind: "document.capture.warning",
|
|
@@ -100173,7 +100399,7 @@ async function attachDocumentAcquisitionWarnings(root, phases, sources) {
|
|
|
100173
100399
|
continue;
|
|
100174
100400
|
let receipt2;
|
|
100175
100401
|
try {
|
|
100176
|
-
receipt2 = JSON.parse(await
|
|
100402
|
+
receipt2 = JSON.parse(await readFile84(receiptPath(root, phase.id), "utf8"));
|
|
100177
100403
|
} catch {
|
|
100178
100404
|
continue;
|
|
100179
100405
|
}
|
|
@@ -100590,7 +100816,7 @@ var init_workflowHostPlans = __esm(() => {
|
|
|
100590
100816
|
});
|
|
100591
100817
|
|
|
100592
100818
|
// src/project/workflow/workflowProvider.ts
|
|
100593
|
-
import { existsSync as
|
|
100819
|
+
import { existsSync as existsSync27 } from "node:fs";
|
|
100594
100820
|
import { dirname as dirname45, resolve as resolve34 } from "node:path";
|
|
100595
100821
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
100596
100822
|
function providerCandidates() {
|
|
@@ -100602,7 +100828,7 @@ function providerCandidates() {
|
|
|
100602
100828
|
];
|
|
100603
100829
|
}
|
|
100604
100830
|
function contextWorkflowProviderPath() {
|
|
100605
|
-
const candidate = providerCandidates().find((path2) =>
|
|
100831
|
+
const candidate = providerCandidates().find((path2) => existsSync27(path2));
|
|
100606
100832
|
if (candidate === undefined) {
|
|
100607
100833
|
throw new Error("Context workflow Provider is missing. Rebuild @c4a/context-cli or reinstall the published package.");
|
|
100608
100834
|
}
|
|
@@ -101315,8 +101541,8 @@ function pendingDocumentCaptureCommands(input) {
|
|
|
101315
101541
|
}
|
|
101316
101542
|
|
|
101317
101543
|
// src/project/productionStageRefresh.ts
|
|
101318
|
-
import { readFile as
|
|
101319
|
-
import { join as
|
|
101544
|
+
import { readFile as readFile85 } from "node:fs/promises";
|
|
101545
|
+
import { join as join103 } from "node:path";
|
|
101320
101546
|
async function refreshProductionStageSources(projectRoot, stage) {
|
|
101321
101547
|
const active = activeProductionSources(stage);
|
|
101322
101548
|
const affected = new Set(stage.gaps.filter((gap) => active.has(gap.scope)).map((gap) => gap.scope));
|
|
@@ -101361,14 +101587,14 @@ Restore the authorized source and retry preparation.
|
|
|
101361
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)
|
|
101362
101588
|
});
|
|
101363
101589
|
const directory = productionStageDirectory(stage.id);
|
|
101364
|
-
const contents2 = new Map([...sourceMaterials].map(([scope2, content3]) => [
|
|
101365
|
-
contents2.set(
|
|
101590
|
+
const contents2 = new Map([...sourceMaterials].map(([scope2, content3]) => [join103(directory, productionSourceFile(scope2)), content3]));
|
|
101591
|
+
contents2.set(join103(directory, "manifest.json"), `${JSON.stringify(updated)}
|
|
101366
101592
|
`);
|
|
101367
101593
|
const targets = [];
|
|
101368
101594
|
for (const [path2, content3] of contents2) {
|
|
101369
101595
|
let previous2;
|
|
101370
101596
|
try {
|
|
101371
|
-
previous2 = await
|
|
101597
|
+
previous2 = await readFile85(await safeProjectTarget(projectRoot, path2), "utf8");
|
|
101372
101598
|
} catch (error) {
|
|
101373
101599
|
if (error.code !== "ENOENT")
|
|
101374
101600
|
throw error;
|
|
@@ -101493,7 +101719,7 @@ var init_productionReport = __esm(() => {
|
|
|
101493
101719
|
});
|
|
101494
101720
|
|
|
101495
101721
|
// src/project/productionPlanningRoute.ts
|
|
101496
|
-
import { join as
|
|
101722
|
+
import { join as join104 } from "node:path";
|
|
101497
101723
|
async function productionPlanningRoute(input, stage) {
|
|
101498
101724
|
const request = stage ? undefined : await productionPlanningRequest(input.projectRoot);
|
|
101499
101725
|
const present = !!stage || !!request;
|
|
@@ -101531,7 +101757,7 @@ async function productionPlanningRoute(input, stage) {
|
|
|
101531
101757
|
id: `production/${stage.id}/planning`,
|
|
101532
101758
|
kind: "context-view",
|
|
101533
101759
|
media_type: "text/markdown",
|
|
101534
|
-
path:
|
|
101760
|
+
path: join104(input.projectRoot, productionStageDirectory(stage.id), "planning.md"),
|
|
101535
101761
|
read_state: "read-required"
|
|
101536
101762
|
}] : []
|
|
101537
101763
|
],
|
|
@@ -101558,8 +101784,8 @@ var init_productionPlanningRoute = __esm(() => {
|
|
|
101558
101784
|
});
|
|
101559
101785
|
|
|
101560
101786
|
// src/project/productionWorkflowRoute.ts
|
|
101561
|
-
import { existsSync as
|
|
101562
|
-
import { join as
|
|
101787
|
+
import { existsSync as existsSync28 } from "node:fs";
|
|
101788
|
+
import { join as join105 } from "node:path";
|
|
101563
101789
|
async function productionWorkflowRoute(input) {
|
|
101564
101790
|
const stage = await readProductionStage(input.projectRoot);
|
|
101565
101791
|
if (!stage || !stage.planning_complete)
|
|
@@ -101577,7 +101803,7 @@ async function productionWorkflowRoute(input) {
|
|
|
101577
101803
|
const selected = new Set(dispatch2.batches.flatMap((batch) => batch.tasks));
|
|
101578
101804
|
const context = { workspace: input.projectRoot, authorities: [...input.authorities], facts: { production: {
|
|
101579
101805
|
report_approved: stage.report_approved,
|
|
101580
|
-
prepared: !dispatch2.batches.length ||
|
|
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"),
|
|
101581
101807
|
writing_complete: dispatch2.batches.length === 0,
|
|
101582
101808
|
complete: dispatch2.state === "ended",
|
|
101583
101809
|
review_clear: rejected.length === 0,
|
|
@@ -101594,7 +101820,7 @@ async function productionWorkflowRoute(input) {
|
|
|
101594
101820
|
const resolved = await resolveRoute(provider, "indexer", "production", primary.routeId, context, evaluated.evaluation.revision);
|
|
101595
101821
|
const report = resolved.node === "confirm-production-report";
|
|
101596
101822
|
if (report)
|
|
101597
|
-
await writeProductionProjection(input.projectRoot,
|
|
101823
|
+
await writeProductionProjection(input.projectRoot, join105(directory, "plan.md"), productionPlanMarkdown(stage));
|
|
101598
101824
|
const prepare = resolved.node === "prepare-production-stage";
|
|
101599
101825
|
const writing = resolved.node === "work-production-stage";
|
|
101600
101826
|
const repair = resolved.node === "repair-production-articles";
|
|
@@ -101609,7 +101835,7 @@ async function productionWorkflowRoute(input) {
|
|
|
101609
101835
|
id: `production/${stage.id}/${report ? "plan" : "stage"}`,
|
|
101610
101836
|
kind: "context-view",
|
|
101611
101837
|
media_type: "text/markdown",
|
|
101612
|
-
path:
|
|
101838
|
+
path: join105(input.projectRoot, directory, path3),
|
|
101613
101839
|
read_state: "read-required"
|
|
101614
101840
|
});
|
|
101615
101841
|
if (report || writing)
|
|
@@ -101620,18 +101846,18 @@ async function productionWorkflowRoute(input) {
|
|
|
101620
101846
|
id: `production/${stage.id}/planning`,
|
|
101621
101847
|
kind: "context-view",
|
|
101622
101848
|
media_type: "text/markdown",
|
|
101623
|
-
path:
|
|
101849
|
+
path: join105(input.projectRoot, directory, "planning.md"),
|
|
101624
101850
|
read_state: "read-required"
|
|
101625
101851
|
});
|
|
101626
101852
|
}
|
|
101627
101853
|
if (repair) {
|
|
101628
|
-
await writeProductionProjection(input.projectRoot,
|
|
101854
|
+
await writeProductionProjection(input.projectRoot, join105(directory, "repair.md"), [
|
|
101629
101855
|
"# Revise rejected articles",
|
|
101630
101856
|
"",
|
|
101631
101857
|
...rejected.map((candidate) => `- ${candidate.path}: ${candidate.review.title}`),
|
|
101632
101858
|
"",
|
|
101633
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.",
|
|
101634
|
-
`Submit the plan amendment to ${path2} using ${
|
|
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.`,
|
|
101635
101861
|
"Once issued, repair the affected sections through the existing edits submission. Unchanged sections and references do not need resubmission.",
|
|
101636
101862
|
""
|
|
101637
101863
|
].join(`
|
|
@@ -101640,7 +101866,7 @@ async function productionWorkflowRoute(input) {
|
|
|
101640
101866
|
id: `production/${stage.id}/repair`,
|
|
101641
101867
|
kind: "context-view",
|
|
101642
101868
|
media_type: "text/markdown",
|
|
101643
|
-
path:
|
|
101869
|
+
path: join105(input.projectRoot, directory, "repair.md"),
|
|
101644
101870
|
read_state: "read-required"
|
|
101645
101871
|
});
|
|
101646
101872
|
}
|
|
@@ -101739,7 +101965,7 @@ var init_knowledgeMaintenanceRoute = __esm(() => {
|
|
|
101739
101965
|
});
|
|
101740
101966
|
|
|
101741
101967
|
// src/project/approvedRevisionContext.ts
|
|
101742
|
-
import { readFile as
|
|
101968
|
+
import { readFile as readFile86 } from "node:fs/promises";
|
|
101743
101969
|
async function approvedRevisionContext(root, target) {
|
|
101744
101970
|
const registry2 = await readProductionRequirements(root);
|
|
101745
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}/`))));
|
|
@@ -101750,7 +101976,7 @@ async function approvedRevisionContext(root, target) {
|
|
|
101750
101976
|
const type = source_ref.slice(0, separator);
|
|
101751
101977
|
const name3 = source_ref.slice(separator + 1);
|
|
101752
101978
|
const path2 = await assertManagedDocumentPath(root, type, name3);
|
|
101753
|
-
const markdown = await
|
|
101979
|
+
const markdown = await readFile86(path2, "utf8");
|
|
101754
101980
|
const changes = type === "sessions" ? readSessionChanges(markdown) : undefined;
|
|
101755
101981
|
return {
|
|
101756
101982
|
source_ref,
|
|
@@ -101781,15 +102007,15 @@ var exports_approvedRevisionRoute = {};
|
|
|
101781
102007
|
__export(exports_approvedRevisionRoute, {
|
|
101782
102008
|
buildApprovedRevisionRoute: () => buildApprovedRevisionRoute
|
|
101783
102009
|
});
|
|
101784
|
-
import { existsSync as
|
|
101785
|
-
import { join as
|
|
102010
|
+
import { existsSync as existsSync29 } from "node:fs";
|
|
102011
|
+
import { join as join106 } from "node:path";
|
|
101786
102012
|
async function sourceUpdateRouteInput(projectRoot, update) {
|
|
101787
102013
|
const { reference_evidence: evidence, ...rest } = update;
|
|
101788
102014
|
if (!evidence?.length)
|
|
101789
102015
|
return rest;
|
|
101790
102016
|
const file = `.tmp/context-runtime/source-update/evidence-${update.revision.replace(/^sha256:/u, "")}.json`;
|
|
101791
|
-
if (!
|
|
101792
|
-
await atomicWriteFile(
|
|
102017
|
+
if (!existsSync29(join106(projectRoot, file)))
|
|
102018
|
+
await atomicWriteFile(join106(projectRoot, file), `${JSON.stringify(evidence, null, 2)}
|
|
101793
102019
|
`);
|
|
101794
102020
|
return { ...rest, reference_evidence_file: file, reference_evidence_count: evidence.length };
|
|
101795
102021
|
}
|
|
@@ -101954,6 +102180,34 @@ var init_indexerCurrentWorkflowRoute = __esm(() => {
|
|
|
101954
102180
|
init_productionWorkflowRoute();
|
|
101955
102181
|
});
|
|
101956
102182
|
|
|
102183
|
+
// src/project/productionCaptureScope.ts
|
|
102184
|
+
function documentSourceMatches(source2, ref2) {
|
|
102185
|
+
return [source2.name, source2.id].filter(Boolean).some((name3) => ref2 === `${source2.type}:${name3}` || ref2 === `docs:${name3}` || ref2.startsWith(`${source2.type}:${name3}#`) || ref2.startsWith(`${source2.type}:${name3}/`));
|
|
102186
|
+
}
|
|
102187
|
+
function documentSourceSettled(source2) {
|
|
102188
|
+
return source2.snapshotReady || source2.acquisitionWarning !== undefined;
|
|
102189
|
+
}
|
|
102190
|
+
function productionCaptureDocuments(stage, documents) {
|
|
102191
|
+
const requested = productionRequestedSources(stage);
|
|
102192
|
+
const own5 = documents.filter((source2) => requested.some((ref2) => documentSourceMatches(source2, ref2)));
|
|
102193
|
+
const deferred = documents.filter((source2) => !own5.includes(source2) && !documentSourceSettled(source2)).map(documentRef);
|
|
102194
|
+
return { documents: own5, deferred };
|
|
102195
|
+
}
|
|
102196
|
+
function capturedRequirementTargets(requirements, documents) {
|
|
102197
|
+
const ready = requirements.requirements.filter((item) => {
|
|
102198
|
+
const refs = [...item.target_scope.targets, ...item.evidence_source_scope?.targets ?? []].map((target) => target.source_ref);
|
|
102199
|
+
return documents.filter((source2) => refs.some((ref2) => documentSourceMatches(source2, ref2))).every(documentSourceSettled);
|
|
102200
|
+
});
|
|
102201
|
+
const targets = [...new Set(ready.flatMap((item) => item.target_scope.targets.map((target) => target.source_ref)))];
|
|
102202
|
+
const readyRefs = ready.flatMap((item) => [...item.target_scope.targets, ...item.evidence_source_scope?.targets ?? []].map((target) => target.source_ref));
|
|
102203
|
+
const deferred = documents.filter((source2) => !documentSourceSettled(source2) && !readyRefs.some((ref2) => documentSourceMatches(source2, ref2))).map(documentRef);
|
|
102204
|
+
return { targets, deferred };
|
|
102205
|
+
}
|
|
102206
|
+
var documentRef = (source2) => `${source2.type}:${source2.name}`;
|
|
102207
|
+
var init_productionCaptureScope = __esm(() => {
|
|
102208
|
+
init_productionScope();
|
|
102209
|
+
});
|
|
102210
|
+
|
|
101957
102211
|
// src/project/status.ts
|
|
101958
102212
|
var exports_status = {};
|
|
101959
102213
|
__export(exports_status, {
|
|
@@ -101962,7 +102216,7 @@ __export(exports_status, {
|
|
|
101962
102216
|
collectProjectStatusSnapshot: () => collectProjectStatusSnapshot,
|
|
101963
102217
|
collectProjectStatus: () => collectProjectStatus
|
|
101964
102218
|
});
|
|
101965
|
-
import { join as
|
|
102219
|
+
import { join as join107 } from "node:path";
|
|
101966
102220
|
async function recordWorkflowEvaluation(projectRoot, workflow) {
|
|
101967
102221
|
const current3 = workflow.current;
|
|
101968
102222
|
await recordAgentGraphEvaluation({
|
|
@@ -102014,7 +102268,7 @@ async function collectProjectStatusSnapshotInternal(projectRoot, options = {}) {
|
|
|
102014
102268
|
const navigationOnly = !maintenance && !localRevision && !localUpdate && !localRollback && taskPreparation === "cleared" && !production && phaseStatus.projectEntryValid && await navigationOnlyChange(projectRoot, phaseStatus.packages);
|
|
102015
102269
|
const deferDeliveryChecks = !maintenance && !localRevision && !localUpdate && !localRollback && !navigationOnly && (taskPreparation === "cleared" && !production || !!authoring);
|
|
102016
102270
|
const collectionsWithPages = new Set;
|
|
102017
|
-
const approvedPages = await countFiles(
|
|
102271
|
+
const approvedPages = await countFiles(join107(projectRoot, "knowledge"), (rel) => {
|
|
102018
102272
|
if (!isApprovedKnowledgeMarkdownPath(rel) || rel.startsWith("assets/"))
|
|
102019
102273
|
return false;
|
|
102020
102274
|
collectionsWithPages.add(rel.split("/")[0]);
|
|
@@ -102022,9 +102276,10 @@ async function collectProjectStatusSnapshotInternal(projectRoot, options = {}) {
|
|
|
102022
102276
|
});
|
|
102023
102277
|
const approvedCollections = KNOWLEDGE_COLLECTIONS.filter((collection) => collectionsWithPages.has(collection));
|
|
102024
102278
|
const closeStatus = deferDeliveryChecks ? { state: "not-checked", diagnostics: [] } : await readCloseStatus(projectRoot);
|
|
102025
|
-
const distFiles = await countFiles(
|
|
102279
|
+
const distFiles = await countFiles(join107(projectRoot, "dist"), () => true);
|
|
102026
102280
|
const verifyStatus = !deferDeliveryChecks && draftStatus.diagnostics.length === 0 ? await readVerifyStatus(projectRoot) : { issues: [], diagnostics: [] };
|
|
102027
|
-
const
|
|
102281
|
+
const productionCapture = !localRevision && production ? productionCaptureDocuments(production, documentSources) : undefined;
|
|
102282
|
+
const revisionDocuments = localRevision ? documentSources.filter((source2) => localRevision.target.source_refs.some((ref2) => documentSourceMatches(source2, ref2))) : productionCapture?.documents ?? documentSources;
|
|
102028
102283
|
const pendingCapture = pendingDocumentCaptureCommands({
|
|
102029
102284
|
phases,
|
|
102030
102285
|
documentSources: revisionDocuments
|
|
@@ -102110,12 +102365,15 @@ async function collectProjectStatusSnapshotInternal(projectRoot, options = {}) {
|
|
|
102110
102365
|
});
|
|
102111
102366
|
const statusProjectionStarted = performance.now();
|
|
102112
102367
|
const baseWorkflow = projectContextWorkflowStatus(workflowSnapshot);
|
|
102113
|
-
const
|
|
102368
|
+
const indexerRoute = await projectCurrentIndexerWorkflowRoute({
|
|
102114
102369
|
projectRoot,
|
|
102115
102370
|
route: baseWorkflow.current,
|
|
102116
102371
|
authorities,
|
|
102117
102372
|
managed: options.managed === true
|
|
102118
102373
|
});
|
|
102374
|
+
const capturePlanning = !production && !localRevision && !localUpdate ? await productionStartForCapturedSources(projectRoot, indexerRoute, documentSources) : undefined;
|
|
102375
|
+
const currentRoute2 = capturePlanning?.route ?? indexerRoute;
|
|
102376
|
+
const deferredCaptureSources = productionCapture?.deferred ?? capturePlanning?.deferred ?? [];
|
|
102119
102377
|
const workflow = {
|
|
102120
102378
|
...baseWorkflow,
|
|
102121
102379
|
...currentRoute2 === undefined ? {} : { current: currentRoute2 },
|
|
@@ -102153,6 +102411,7 @@ async function collectProjectStatusSnapshotInternal(projectRoot, options = {}) {
|
|
|
102153
102411
|
packages: packageFreshness,
|
|
102154
102412
|
packageTemplateReviews,
|
|
102155
102413
|
pendingCapturePhases: pendingCapture.phaseIds,
|
|
102414
|
+
...deferredCaptureSources.length ? { deferredCaptureSources } : {},
|
|
102156
102415
|
evidenceStatus,
|
|
102157
102416
|
evidenceWarnings,
|
|
102158
102417
|
close: closeStatus,
|
|
@@ -102268,6 +102527,29 @@ async function navigationOnlyChange(projectRoot, packages) {
|
|
|
102268
102527
|
const freshness = await readPackageFreshnessStatus(projectRoot, packages);
|
|
102269
102528
|
return freshness.diagnostics.length > 0 || freshness.packages.length < packages.length || freshness.packages.some((item) => item.state !== "ready");
|
|
102270
102529
|
}
|
|
102530
|
+
async function productionStartForCapturedSources(projectRoot, route, documents) {
|
|
102531
|
+
if (!route || !["authorize-document-capture", "capture-next"].includes(route.node))
|
|
102532
|
+
return;
|
|
102533
|
+
const inspected = await inspectProductionRequirements(projectRoot).catch(() => {
|
|
102534
|
+
return;
|
|
102535
|
+
});
|
|
102536
|
+
if (!inspected)
|
|
102537
|
+
return;
|
|
102538
|
+
const { targets, deferred } = capturedRequirementTargets(inspected.requirements, documents);
|
|
102539
|
+
if (targets.length === 0 || deferred.length === 0)
|
|
102540
|
+
return;
|
|
102541
|
+
const request = await productionPlanningRequest(projectRoot).catch(() => {
|
|
102542
|
+
return;
|
|
102543
|
+
});
|
|
102544
|
+
if (!request)
|
|
102545
|
+
return;
|
|
102546
|
+
const command2 = `context action prepare-current --revision ${request.revision} ${targets.map((target) => `--source ${target}`).join(" ")} --format json`;
|
|
102547
|
+
return { deferred, route: {
|
|
102548
|
+
...route,
|
|
102549
|
+
summary: [route.summary, `To start production now for requirements whose documents are already captured, run ${command2}. These documents stay registered and are captured when their read permission is given: ${deferred.join(", ")}.`].filter(Boolean).join(" "),
|
|
102550
|
+
commands: [...route.commands, { command: command2, effect: "write", availability: "immediate", managed_execution: "agent-required" }]
|
|
102551
|
+
} };
|
|
102552
|
+
}
|
|
102271
102553
|
var init_status = __esm(() => {
|
|
102272
102554
|
init_documentCaptureAvailability();
|
|
102273
102555
|
init_productionPlanning();
|
|
@@ -102292,6 +102574,9 @@ var init_status = __esm(() => {
|
|
|
102292
102574
|
init_workspaceChangelog();
|
|
102293
102575
|
init_indexerCurrentWorkflowRoute();
|
|
102294
102576
|
init_productionStageStore();
|
|
102577
|
+
init_productionCaptureScope();
|
|
102578
|
+
init_productionRequirements();
|
|
102579
|
+
init_productionPlanning();
|
|
102295
102580
|
init_productionStage();
|
|
102296
102581
|
init_candidateLedger();
|
|
102297
102582
|
init_commandReadCache();
|
|
@@ -102337,6 +102622,7 @@ function formatProjectStatus(status, options = {}) {
|
|
|
102337
102622
|
`- dist files: ${status.distFiles}`,
|
|
102338
102623
|
`- phases: ${options.full ? status.phases.join(", ") || "none" : status.phases.length}`,
|
|
102339
102624
|
`- pending capture phases: ${status.pendingCapturePhases.length}`,
|
|
102625
|
+
...status.deferredCaptureSources?.length ? [`- deferred capture: ${status.deferredCaptureSources.join(", ")}`] : [],
|
|
102340
102626
|
`- indexer registry: ${status.indexerRegistry.state}`,
|
|
102341
102627
|
`- indexer candidate compile: ${status.indexerCandidateCompile.state}`,
|
|
102342
102628
|
`- close: ${status.close.state}`,
|
|
@@ -102473,14 +102759,14 @@ __export(exports_workflowRouteOutput, {
|
|
|
102473
102759
|
});
|
|
102474
102760
|
import { Buffer as Buffer4 } from "node:buffer";
|
|
102475
102761
|
import { createHash as createHash32 } from "node:crypto";
|
|
102476
|
-
import { join as
|
|
102762
|
+
import { join as join108 } from "node:path";
|
|
102477
102763
|
async function workflowRouteOutput(projectRoot, route, options = {}) {
|
|
102478
102764
|
if (!route)
|
|
102479
102765
|
return null;
|
|
102480
102766
|
const body = `${JSON.stringify(route, null, 2)}
|
|
102481
102767
|
`;
|
|
102482
102768
|
const digest7 = createHash32("sha256").update(body).digest("hex");
|
|
102483
|
-
const file =
|
|
102769
|
+
const file = join108(projectRoot, ".tmp/context-runtime/routes", `${digest7}.json`);
|
|
102484
102770
|
await atomicWriteFile(file, body);
|
|
102485
102771
|
const routeBytes = Buffer4.byteLength(body);
|
|
102486
102772
|
const inlineByteLimit = Math.max(0, Math.min(WORKFLOW_ROUTE_INLINE_BYTE_LIMIT, options.inlineByteLimit ?? WORKFLOW_ROUTE_INLINE_BYTE_LIMIT));
|
|
@@ -102502,7 +102788,7 @@ async function workflowRunResultFile(projectRoot, result) {
|
|
|
102502
102788
|
const body = `${JSON.stringify(result, null, 2)}
|
|
102503
102789
|
`;
|
|
102504
102790
|
const digest7 = createHash32("sha256").update(body).digest("hex");
|
|
102505
|
-
const file =
|
|
102791
|
+
const file = join108(projectRoot, ".tmp/context-runtime/action-results", `${digest7}.run.json`);
|
|
102506
102792
|
await atomicWriteFile(file, body);
|
|
102507
102793
|
return file;
|
|
102508
102794
|
}
|
|
@@ -102521,15 +102807,15 @@ __export(exports_originalRevisions, {
|
|
|
102521
102807
|
originalRevisionReviewHtml: () => originalRevisionReviewHtml,
|
|
102522
102808
|
ORIGINAL_REVISION_PROPOSALS_PATH: () => ORIGINAL_REVISION_PROPOSALS_PATH
|
|
102523
102809
|
});
|
|
102524
|
-
import { readFile as
|
|
102525
|
-
import { join as
|
|
102810
|
+
import { readFile as readFile87, rm as rm26 } from "node:fs/promises";
|
|
102811
|
+
import { join as join109 } from "node:path";
|
|
102526
102812
|
function inputError(message, reasonCode) {
|
|
102527
102813
|
return new ContextError(ExitCode.UserError, message, { category: ErrorCategory.UserInputInvalid, reason_code: reasonCode });
|
|
102528
102814
|
}
|
|
102529
102815
|
async function readOriginalRevisionProposals(projectRoot) {
|
|
102530
102816
|
let content3;
|
|
102531
102817
|
try {
|
|
102532
|
-
content3 = await
|
|
102818
|
+
content3 = await readFile87(join109(projectRoot, ORIGINAL_REVISION_PROPOSALS_PATH), "utf8");
|
|
102533
102819
|
} catch (error) {
|
|
102534
102820
|
if (error.code === "ENOENT")
|
|
102535
102821
|
return [];
|
|
@@ -102542,7 +102828,7 @@ async function readOriginalRevisionProposals(projectRoot) {
|
|
|
102542
102828
|
return parsed.data.revisions;
|
|
102543
102829
|
}
|
|
102544
102830
|
async function writeProposals(projectRoot, proposals) {
|
|
102545
|
-
const path2 =
|
|
102831
|
+
const path2 = join109(projectRoot, ORIGINAL_REVISION_PROPOSALS_PATH);
|
|
102546
102832
|
if (proposals.length === 0) {
|
|
102547
102833
|
await rm26(path2, { force: true });
|
|
102548
102834
|
return;
|
|
@@ -102657,6 +102943,8 @@ async function projectStatusSummary(status, projectRoot) {
|
|
|
102657
102943
|
const completedCollections = [...status.approvedCollections].sort();
|
|
102658
102944
|
const { readOriginalRevisionProposals: readOriginalRevisionProposals2 } = await Promise.resolve().then(() => (init_originalRevisions(), exports_originalRevisions));
|
|
102659
102945
|
const originalRevisions = await readOriginalRevisionProposals2(projectRoot).then((revisions) => ({ proposed: revisions.length }), (error) => ({ problem: error instanceof Error ? error.message : String(error) }));
|
|
102946
|
+
const { inspectSdkAlignment: inspectSdkAlignment2 } = await Promise.resolve().then(() => (init_sdkAlignment(), exports_sdkAlignment));
|
|
102947
|
+
const sdkAlignment = await inspectSdkAlignment2(projectRoot);
|
|
102660
102948
|
return {
|
|
102661
102949
|
...status.sourceUpdate ? { source_update: {
|
|
102662
102950
|
...status.sourceUpdate,
|
|
@@ -102677,6 +102965,7 @@ async function projectStatusSummary(status, projectRoot) {
|
|
|
102677
102965
|
message: "Revisions proposed for pages kept as written await a decision; apply it to the article, record it in the changelog, then resolve the proposal. Fully managed and routine runs keep the revisions locally."
|
|
102678
102966
|
}
|
|
102679
102967
|
} } : {},
|
|
102968
|
+
...sdkAlignment ? { version_alignment: sdkAlignment } : {},
|
|
102680
102969
|
...status.executionMode !== undefined ? { executionMode: status.executionMode } : {},
|
|
102681
102970
|
...complete ? {
|
|
102682
102971
|
completedScope: {
|
|
@@ -102694,6 +102983,7 @@ async function projectStatusSummary(status, projectRoot) {
|
|
|
102694
102983
|
},
|
|
102695
102984
|
progress: {
|
|
102696
102985
|
pendingCapturePhases: status.pendingCapturePhases.length,
|
|
102986
|
+
...status.deferredCaptureSources?.length ? { deferredCaptureSources: status.deferredCaptureSources } : {},
|
|
102697
102987
|
indexerRegistry: status.indexerRegistry.state,
|
|
102698
102988
|
indexerCandidateCompile: status.indexerCandidateCompile.state
|
|
102699
102989
|
},
|
|
@@ -102808,8 +103098,8 @@ __export(exports_articleRetirement, {
|
|
|
102808
103098
|
batchDraftReader: () => batchDraftReader,
|
|
102809
103099
|
articleRetirementSchema: () => articleRetirementSchema
|
|
102810
103100
|
});
|
|
102811
|
-
import { readFile as
|
|
102812
|
-
import { posix as
|
|
103101
|
+
import { readFile as readFile89, readdir as readdir25 } from "node:fs/promises";
|
|
103102
|
+
import { posix as posix14 } from "node:path";
|
|
102813
103103
|
function rebuildInput(revision) {
|
|
102814
103104
|
return JSON.stringify({ id: `retirement-${revision.slice(7)}`, operation: "rebuild", timing: "priority", targets: [] });
|
|
102815
103105
|
}
|
|
@@ -102829,7 +103119,7 @@ function invalid2(reason, message, details = {}) {
|
|
|
102829
103119
|
}
|
|
102830
103120
|
async function text11(root2, path3) {
|
|
102831
103121
|
try {
|
|
102832
|
-
return await
|
|
103122
|
+
return await readFile89(await safeProjectTarget(root2, path3), "utf8");
|
|
102833
103123
|
} catch (error) {
|
|
102834
103124
|
if (error.code === "ENOENT")
|
|
102835
103125
|
return;
|
|
@@ -102993,7 +103283,7 @@ async function planArticleRetirement(root2, value, read, options = {}) {
|
|
|
102993
103283
|
const rooted = /^\/?knowledge\//u.test(target);
|
|
102994
103284
|
if (target.startsWith("/") && !rooted)
|
|
102995
103285
|
return;
|
|
102996
|
-
let resolved = knowledge ? target : rooted ? target.replace(/^\/?knowledge\//u, "") :
|
|
103286
|
+
let resolved = knowledge ? target : rooted ? target.replace(/^\/?knowledge\//u, "") : posix14.normalize(posix14.join(posix14.dirname(article.path), target));
|
|
102997
103287
|
if (knowledge && !resolved.endsWith(".md"))
|
|
102998
103288
|
resolved += ".md";
|
|
102999
103289
|
if (!selected.has(resolved))
|
|
@@ -103007,7 +103297,7 @@ async function planArticleRetirement(root2, value, read, options = {}) {
|
|
|
103007
103297
|
blockers.push({ path: path3, target: link2.target, reason: replacement ? "Repair fragment links explicitly before retirement." : "Repair this incoming link or supply an approved replacement." });
|
|
103008
103298
|
return;
|
|
103009
103299
|
}
|
|
103010
|
-
return knowledge ? `knowledge:${target.endsWith(".md") ? replacement : replacement.replace(/\.md$/u, "")}${match[2]}` : `${encodeURI(rooted ? `${target.startsWith("/") ? "/" : ""}knowledge/${replacement}` :
|
|
103300
|
+
return knowledge ? `knowledge:${target.endsWith(".md") ? replacement : replacement.replace(/\.md$/u, "")}${match[2]}` : `${encodeURI(rooted ? `${target.startsWith("/") ? "/" : ""}knowledge/${replacement}` : posix14.relative(posix14.dirname(article.path), replacement))}${match[2]}`;
|
|
103011
103301
|
});
|
|
103012
103302
|
change(path3, bytes, content3);
|
|
103013
103303
|
}
|
|
@@ -107888,7 +108178,7 @@ var init_larkResourceCommand = __esm(() => {
|
|
|
107888
108178
|
|
|
107889
108179
|
// src/lib/larkMediaDownload.ts
|
|
107890
108180
|
import { readdir as readdir26, rm as rm27 } from "node:fs/promises";
|
|
107891
|
-
import { join as
|
|
108181
|
+
import { join as join117 } from "node:path";
|
|
107892
108182
|
async function downloadLarkMedia(input) {
|
|
107893
108183
|
const shared = ["--as", input.identity, "--token", input.token, "--output", "./resource", "--format", "json"];
|
|
107894
108184
|
try {
|
|
@@ -107898,7 +108188,7 @@ async function downloadLarkMedia(input) {
|
|
|
107898
108188
|
if (!input.allowPreview || !isLarkResourcePermissionDenied(error))
|
|
107899
108189
|
throw error;
|
|
107900
108190
|
for (const entry of await readdir26(input.cwd))
|
|
107901
|
-
await rm27(
|
|
108191
|
+
await rm27(join117(input.cwd, entry), { recursive: true, force: true });
|
|
107902
108192
|
await runLarkResourceCommand(input.runner, ["docs", "+media-preview", ...shared], { cwd: input.cwd });
|
|
107903
108193
|
return "preview";
|
|
107904
108194
|
}
|
|
@@ -107908,9 +108198,9 @@ var init_larkMediaDownload = __esm(() => {
|
|
|
107908
108198
|
});
|
|
107909
108199
|
|
|
107910
108200
|
// src/lib/larkWhiteboardExport.ts
|
|
107911
|
-
import { mkdtemp as mkdtemp5, readFile as
|
|
108201
|
+
import { mkdtemp as mkdtemp5, readFile as readFile95, rm as rm28 } from "node:fs/promises";
|
|
107912
108202
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
107913
|
-
import { join as
|
|
108203
|
+
import { join as join118 } from "node:path";
|
|
107914
108204
|
function stableJson2(value) {
|
|
107915
108205
|
if (value === undefined)
|
|
107916
108206
|
return "null";
|
|
@@ -107940,7 +108230,7 @@ function canonicalWhiteboardPayload(value) {
|
|
|
107940
108230
|
};
|
|
107941
108231
|
}
|
|
107942
108232
|
async function exportLarkWhiteboardRaw(runner2, identity2, token) {
|
|
107943
|
-
const tempRoot = await mkdtemp5(
|
|
108233
|
+
const tempRoot = await mkdtemp5(join118(tmpdir2(), "context-lark-whiteboard-"));
|
|
107944
108234
|
try {
|
|
107945
108235
|
await runLarkResourceCommand(runner2, [
|
|
107946
108236
|
"whiteboard",
|
|
@@ -107957,7 +108247,7 @@ async function exportLarkWhiteboardRaw(runner2, identity2, token) {
|
|
|
107957
108247
|
"--format",
|
|
107958
108248
|
"json"
|
|
107959
108249
|
], { cwd: tempRoot });
|
|
107960
|
-
const rawPayload = JSON.parse(await
|
|
108250
|
+
const rawPayload = JSON.parse(await readFile95(join118(tempRoot, "raw.json"), "utf8"));
|
|
107961
108251
|
return Buffer.from(`${stableJson2(canonicalWhiteboardPayload(rawPayload))}
|
|
107962
108252
|
`, "utf8");
|
|
107963
108253
|
} finally {
|
|
@@ -107996,8 +108286,8 @@ var init_larkImagePolicy = __esm(() => {
|
|
|
107996
108286
|
|
|
107997
108287
|
// src/lib/larkResourceMaterialization.ts
|
|
107998
108288
|
import { createHash as createHash36 } from "node:crypto";
|
|
107999
|
-
import { mkdtemp as mkdtemp6, readFile as
|
|
108000
|
-
import { extname as extname13, join as
|
|
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";
|
|
108001
108291
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
108002
108292
|
function countByKind(items, status) {
|
|
108003
108293
|
const counts2 = new Map;
|
|
@@ -108102,17 +108392,17 @@ function findBooleanField(value, name3) {
|
|
|
108102
108392
|
}
|
|
108103
108393
|
async function downloadedFile(input) {
|
|
108104
108394
|
if (input.localPath !== undefined) {
|
|
108105
|
-
const bytes = await
|
|
108395
|
+
const bytes = await readFile96(input.localPath);
|
|
108106
108396
|
return { path: input.localPath, bytes, mediaType: mediaTypeFor(input.localPath, bytes), representation: "original" };
|
|
108107
108397
|
}
|
|
108108
|
-
const tempRoot = await mkdtemp6(
|
|
108398
|
+
const tempRoot = await mkdtemp6(join119(tmpdir3(), "context-lark-resource-"));
|
|
108109
108399
|
try {
|
|
108110
108400
|
const representation = await downloadLarkMedia({ ...input, cwd: tempRoot });
|
|
108111
108401
|
const entries2 = (await readdir27(tempRoot, { withFileTypes: true })).filter((entry) => entry.isFile());
|
|
108112
108402
|
if (entries2.length !== 1)
|
|
108113
108403
|
throw new Error(`media download produced ${entries2.length} files, expected exactly one`);
|
|
108114
108404
|
const path3 = entries2[0]?.name ?? "resource.bin";
|
|
108115
|
-
const bytes = await
|
|
108405
|
+
const bytes = await readFile96(join119(tempRoot, path3));
|
|
108116
108406
|
return { path: path3, bytes, mediaType: mediaTypeFor(path3, bytes), representation };
|
|
108117
108407
|
} finally {
|
|
108118
108408
|
await rm29(tempRoot, { recursive: true, force: true });
|
|
@@ -108184,9 +108474,9 @@ async function sheetMaterialization(resource, runner2, identity2) {
|
|
|
108184
108474
|
const sheetId = resource.attributes["sheet-id"];
|
|
108185
108475
|
if (token === undefined || sheetId === undefined)
|
|
108186
108476
|
throw new Error("embedded Sheet requires token and sheet-id");
|
|
108187
|
-
const tempRoot = await mkdtemp6(
|
|
108477
|
+
const tempRoot = await mkdtemp6(join119(tmpdir3(), "context-lark-sheet-"));
|
|
108188
108478
|
try {
|
|
108189
|
-
const outputPath =
|
|
108479
|
+
const outputPath = join119(tempRoot, "sheet.json");
|
|
108190
108480
|
const stdout = await runLarkResourceCommand(runner2, [
|
|
108191
108481
|
"sheets",
|
|
108192
108482
|
"+csv-get",
|
|
@@ -108206,7 +108496,7 @@ async function sheetMaterialization(resource, runner2, identity2) {
|
|
|
108206
108496
|
if (findBooleanField(receipt2, "truncated") === true || findBooleanField(receipt2, "complete") === false) {
|
|
108207
108497
|
throw new Error("embedded Sheet read was truncated");
|
|
108208
108498
|
}
|
|
108209
|
-
const payload = JSON.parse(await
|
|
108499
|
+
const payload = JSON.parse(await readFile96(outputPath, "utf8"));
|
|
108210
108500
|
const csv = findStringField(payload, new Set(["annotated_csv", "csv", "content", "text"]));
|
|
108211
108501
|
if (csv === undefined)
|
|
108212
108502
|
throw new Error("embedded Sheet response has no CSV payload");
|
|
@@ -109377,8 +109667,8 @@ var init_sensitiveSourceLiteral = __esm(() => {
|
|
|
109377
109667
|
|
|
109378
109668
|
// src/project/larkSnapshotBundle.ts
|
|
109379
109669
|
import { createHash as createHash37 } from "node:crypto";
|
|
109380
|
-
import { lstat as lstat16, mkdir as mkdir39, readFile as
|
|
109381
|
-
import { basename as basename9, dirname as dirname47, isAbsolute as isAbsolute19, join as
|
|
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";
|
|
109382
109672
|
import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
|
|
109383
109673
|
function normalizedSnapshotResourcePolicy(policy) {
|
|
109384
109674
|
return { ...policy, images: policy.images ?? "bundle", gifs: policy.gifs ?? "bundle" };
|
|
@@ -109419,13 +109709,13 @@ async function readFileEntry(root2, entry) {
|
|
|
109419
109709
|
const parts = safePath(entry.path).split("/");
|
|
109420
109710
|
let current3 = root2;
|
|
109421
109711
|
for (const [index3, part] of parts.entries()) {
|
|
109422
|
-
current3 =
|
|
109712
|
+
current3 = join120(current3, part);
|
|
109423
109713
|
const stat11 = await lstat16(current3);
|
|
109424
109714
|
if (stat11.isSymbolicLink() || (index3 === parts.length - 1 ? !stat11.isFile() : !stat11.isDirectory())) {
|
|
109425
109715
|
throw larkSnapshotError(`Snapshot entry is not a regular file: ${entry.path}`, "path-invalid");
|
|
109426
109716
|
}
|
|
109427
109717
|
}
|
|
109428
|
-
const bytes = await
|
|
109718
|
+
const bytes = await readFile97(current3);
|
|
109429
109719
|
if (digest7(bytes) !== entry.sha256)
|
|
109430
109720
|
throw larkSnapshotError(`Snapshot content changed: ${entry.path}`, "digest-mismatch");
|
|
109431
109721
|
return bytes;
|
|
@@ -109488,13 +109778,13 @@ async function writeLarkSnapshotBundle(input) {
|
|
|
109488
109778
|
};
|
|
109489
109779
|
schema2.parse(manifest);
|
|
109490
109780
|
for (const [path3, bytes] of files) {
|
|
109491
|
-
await mkdir39(dirname47(
|
|
109492
|
-
await writeFile30(
|
|
109781
|
+
await mkdir39(dirname47(join120(root2, path3)), { recursive: true });
|
|
109782
|
+
await writeFile30(join120(root2, path3), bytes, { flag: "wx", mode: 384 });
|
|
109493
109783
|
}
|
|
109494
109784
|
await validateBundle(root2, manifest);
|
|
109495
|
-
await writeFile30(
|
|
109785
|
+
await writeFile30(join120(root2, `${FILE2}.pending`), `${JSON.stringify(manifest, null, 2)}
|
|
109496
109786
|
`, { flag: "wx", mode: 384 });
|
|
109497
|
-
await rename10(
|
|
109787
|
+
await rename10(join120(root2, `${FILE2}.pending`), join120(root2, FILE2));
|
|
109498
109788
|
return manifest;
|
|
109499
109789
|
}
|
|
109500
109790
|
async function validateBundle(root2, manifest) {
|
|
@@ -109568,11 +109858,11 @@ async function validateBundle(root2, manifest) {
|
|
|
109568
109858
|
async function readLarkSnapshotBundle(directory, target) {
|
|
109569
109859
|
try {
|
|
109570
109860
|
const root2 = await assertSnapshotDirectory(directory);
|
|
109571
|
-
const path3 =
|
|
109861
|
+
const path3 = join120(root2, FILE2);
|
|
109572
109862
|
const stat11 = await lstat16(path3);
|
|
109573
109863
|
if (stat11.isSymbolicLink() || !stat11.isFile())
|
|
109574
109864
|
throw larkSnapshotError("Snapshot receipt must be a regular file", "path-invalid");
|
|
109575
|
-
const manifest = schema2.parse(JSON.parse(await
|
|
109865
|
+
const manifest = schema2.parse(JSON.parse(await readFile97(path3, "utf8")));
|
|
109576
109866
|
assertTarget(manifest.url, target);
|
|
109577
109867
|
return await validateBundle(root2, manifest);
|
|
109578
109868
|
} catch (error) {
|
|
@@ -109596,8 +109886,8 @@ async function reserveSnapshotDirectory(directory, workspaceRoot) {
|
|
|
109596
109886
|
ancestor = dirname47(ancestor);
|
|
109597
109887
|
}
|
|
109598
109888
|
}
|
|
109599
|
-
const parent2 =
|
|
109600
|
-
const output =
|
|
109889
|
+
const parent2 = join120(ancestor, ...missing2);
|
|
109890
|
+
const output = join120(parent2, basename9(requested));
|
|
109601
109891
|
const { findContextProjectRoot: findContextProjectRoot2 } = await Promise.resolve().then(() => (init_workspace(), exports_workspace));
|
|
109602
109892
|
const owner = findContextProjectRoot2(parent2)?.projectRoot ?? workspaceRoot;
|
|
109603
109893
|
if (owner !== undefined) {
|
|
@@ -109671,8 +109961,8 @@ var init_larkSnapshotBundle = __esm(() => {
|
|
|
109671
109961
|
|
|
109672
109962
|
// src/project/documentCaptureLark.ts
|
|
109673
109963
|
import { createHash as createHash38 } from "node:crypto";
|
|
109674
|
-
import { readdir as readdir28, readFile as
|
|
109675
|
-
import { basename as basename10, extname as extname14, join as
|
|
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";
|
|
109676
109966
|
function titleFromMarkdown2(markdown, fallbackPath) {
|
|
109677
109967
|
const heading2 = markdown.split(`
|
|
109678
109968
|
`).find((line) => /^#\s+\S/u.test(line));
|
|
@@ -109691,7 +109981,7 @@ function countLines3(markdown) {
|
|
|
109691
109981
|
}
|
|
109692
109982
|
async function fileContentMatches(path3, content3) {
|
|
109693
109983
|
try {
|
|
109694
|
-
const current3 = await
|
|
109984
|
+
const current3 = await readFile98(path3);
|
|
109695
109985
|
const expected = typeof content3 === "string" ? Buffer.from(content3, "utf8") : Buffer.from(content3);
|
|
109696
109986
|
return current3.equals(expected);
|
|
109697
109987
|
} catch {
|
|
@@ -109699,7 +109989,7 @@ async function fileContentMatches(path3, content3) {
|
|
|
109699
109989
|
}
|
|
109700
109990
|
}
|
|
109701
109991
|
function sourceManifestPath2(entry) {
|
|
109702
|
-
return entry.snapshot?.manifest ??
|
|
109992
|
+
return entry.snapshot?.manifest ?? join121(entry.materializedAt, "manifest.json");
|
|
109703
109993
|
}
|
|
109704
109994
|
function larkRuntimeError(message, detail) {
|
|
109705
109995
|
return new ContextError(ExitCode.ExternalToolError, message, {
|
|
@@ -109832,7 +110122,7 @@ function assetManifestEntry(asset, assetRoot) {
|
|
|
109832
110122
|
};
|
|
109833
110123
|
}
|
|
109834
110124
|
async function listSnapshotAssetFiles(root2, assetRoot) {
|
|
109835
|
-
const assetsRoot =
|
|
110125
|
+
const assetsRoot = join121(root2, assetRoot);
|
|
109836
110126
|
const files = [];
|
|
109837
110127
|
const visit4 = async (dir, prefix = assetRoot) => {
|
|
109838
110128
|
let entries2;
|
|
@@ -109845,7 +110135,7 @@ async function listSnapshotAssetFiles(root2, assetRoot) {
|
|
|
109845
110135
|
}
|
|
109846
110136
|
for (const entry of entries2) {
|
|
109847
110137
|
const relPath = `${prefix}/${entry.name}`;
|
|
109848
|
-
const absolutePath =
|
|
110138
|
+
const absolutePath = join121(dir, entry.name);
|
|
109849
110139
|
if (entry.isDirectory()) {
|
|
109850
110140
|
await visit4(absolutePath, relPath);
|
|
109851
110141
|
continue;
|
|
@@ -109860,7 +110150,7 @@ async function listSnapshotAssetFiles(root2, assetRoot) {
|
|
|
109860
110150
|
}
|
|
109861
110151
|
async function staleSnapshotAssetPaths(input) {
|
|
109862
110152
|
const existingPaths = await listSnapshotAssetFiles(input.materializedAtAbsPath, input.assetRoot);
|
|
109863
|
-
return existingPaths.filter((path3) => !input.currentPaths.has(path3)).map((path3) =>
|
|
110153
|
+
return existingPaths.filter((path3) => !input.currentPaths.has(path3)).map((path3) => join121(input.materializedAtAbsPath, path3));
|
|
109864
110154
|
}
|
|
109865
110155
|
function normalizeLarkError(error, sourceName) {
|
|
109866
110156
|
if (error instanceof ContextError)
|
|
@@ -109924,7 +110214,7 @@ async function runCaptureLarkPhaseUnlocked(input) {
|
|
|
109924
110214
|
const target = larkTarget(entry);
|
|
109925
110215
|
const manifestPath = sourceManifestPath2(entry);
|
|
109926
110216
|
const materializedAt = entry.materializedAt;
|
|
109927
|
-
const materializedAtAbsPath =
|
|
110217
|
+
const materializedAtAbsPath = join121(input.projectRoot, materializedAt);
|
|
109928
110218
|
const { current: currentManifestFile, previous: previousManifest, recovery } = await readDocumentManifestForCapture({
|
|
109929
110219
|
projectRoot: input.projectRoot,
|
|
109930
110220
|
manifestPath,
|
|
@@ -110071,7 +110361,7 @@ async function runCaptureLarkPhaseUnlocked(input) {
|
|
|
110071
110361
|
title: title2,
|
|
110072
110362
|
locator
|
|
110073
110363
|
}];
|
|
110074
|
-
const manifestAbsPath =
|
|
110364
|
+
const manifestAbsPath = join121(input.projectRoot, manifestPath);
|
|
110075
110365
|
const manifest = createDocumentSnapshotManifest({
|
|
110076
110366
|
sourceType: "lark",
|
|
110077
110367
|
sourceName: resolved.sourceName,
|
|
@@ -110101,13 +110391,13 @@ async function runCaptureLarkPhaseUnlocked(input) {
|
|
|
110101
110391
|
const cacheDiagnostics = [];
|
|
110102
110392
|
try {
|
|
110103
110393
|
const requestedWrites = [{
|
|
110104
|
-
path:
|
|
110394
|
+
path: join121(materializedAtAbsPath, documentPath),
|
|
110105
110395
|
bytes: normalized
|
|
110106
110396
|
}];
|
|
110107
110397
|
for (const asset of assets) {
|
|
110108
110398
|
if (asset.bytes !== undefined) {
|
|
110109
110399
|
requestedWrites.push({
|
|
110110
|
-
path:
|
|
110400
|
+
path: join121(materializedAtAbsPath, asset.entry.path),
|
|
110111
110401
|
bytes: asset.bytes
|
|
110112
110402
|
});
|
|
110113
110403
|
}
|
|
@@ -110141,7 +110431,7 @@ async function runCaptureLarkPhaseUnlocked(input) {
|
|
|
110141
110431
|
if (relativePath in capturedFiles)
|
|
110142
110432
|
continue;
|
|
110143
110433
|
try {
|
|
110144
|
-
capturedFiles[relativePath] = `sha256:${createHash38("sha256").update(await
|
|
110434
|
+
capturedFiles[relativePath] = `sha256:${createHash38("sha256").update(await readFile98(join121(input.projectRoot, relativePath))).digest("hex")}`;
|
|
110145
110435
|
} catch (error) {
|
|
110146
110436
|
if (error.code === "ENOENT")
|
|
110147
110437
|
capturedFiles[relativePath] = null;
|
|
@@ -110150,7 +110440,7 @@ async function runCaptureLarkPhaseUnlocked(input) {
|
|
|
110150
110440
|
}
|
|
110151
110441
|
}
|
|
110152
110442
|
await applyAtomicFileBatch({
|
|
110153
|
-
transactionRoot:
|
|
110443
|
+
transactionRoot: join121(input.projectRoot, ".tmp", "context-runtime", "capture-transactions"),
|
|
110154
110444
|
writes,
|
|
110155
110445
|
removals
|
|
110156
110446
|
});
|
|
@@ -110335,8 +110625,8 @@ __export(exports_writeLockRecovery, {
|
|
|
110335
110625
|
recoverWriterLock: () => recoverWriterLock,
|
|
110336
110626
|
inspectWriterLock: () => inspectWriterLock
|
|
110337
110627
|
});
|
|
110338
|
-
import { lstat as lstat17, mkdir as mkdir41, readFile as
|
|
110339
|
-
import { join as
|
|
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";
|
|
110340
110630
|
import { createHash as createHash40, randomUUID as randomUUID8 } from "node:crypto";
|
|
110341
110631
|
async function inspectWriterLock(root2) {
|
|
110342
110632
|
const path3 = await safeProjectTarget(root2, lockRelative);
|
|
@@ -110351,7 +110641,7 @@ async function inspectWriterLock(root2) {
|
|
|
110351
110641
|
if (!stat11.isDirectory() || stat11.isSymbolicLink())
|
|
110352
110642
|
throw new Error("Writer lock must be a real directory.");
|
|
110353
110643
|
const ownerPath = await safeProjectTarget(root2, `${lockRelative}/owner.json`);
|
|
110354
|
-
const bytes = await
|
|
110644
|
+
const bytes = await readFile104(ownerPath, "utf8");
|
|
110355
110645
|
const owner = JSON.parse(bytes);
|
|
110356
110646
|
if (owner.protocol !== "context.project-write-lock.v1" || !Number.isSafeInteger(owner.pid) || owner.pid <= 0) {
|
|
110357
110647
|
throw new Error("Writer lock owner is invalid; preserve the lock for diagnosis.");
|
|
@@ -110387,8 +110677,8 @@ async function recoverWriterLock(input) {
|
|
|
110387
110677
|
};
|
|
110388
110678
|
if (input.plan_digest !== revision)
|
|
110389
110679
|
throw new Error("Writer lock or transactions changed; preview recovery again.");
|
|
110390
|
-
const path3 =
|
|
110391
|
-
const guard =
|
|
110680
|
+
const path3 = join126(input.projectRoot, lockRelative);
|
|
110681
|
+
const guard = join126(path3, ".recovery");
|
|
110392
110682
|
await mkdir41(guard);
|
|
110393
110683
|
let archived = false;
|
|
110394
110684
|
try {
|
|
@@ -110399,7 +110689,7 @@ async function recoverWriterLock(input) {
|
|
|
110399
110689
|
if (names.some((name3) => name3 !== "owner.json" && name3 !== ".recovery"))
|
|
110400
110690
|
throw new Error("Unexpected lock contents; preserve for diagnosis.");
|
|
110401
110691
|
const archive = `.tmp/context-runtime/locks/recovered-write-${randomUUID8()}.lock`;
|
|
110402
|
-
await rename11(path3,
|
|
110692
|
+
await rename11(path3, join126(input.projectRoot, archive));
|
|
110403
110693
|
archived = true;
|
|
110404
110694
|
const receipts = await withProjectWriteLock(input.projectRoot, "recover-writer-transactions", async () => {
|
|
110405
110695
|
if (JSON.stringify(await recoveryJournals(input.projectRoot)) !== JSON.stringify(journals)) {
|
|
@@ -110431,13 +110721,13 @@ __export(exports_taskRecovery, {
|
|
|
110431
110721
|
TRANSACTIONS_PATH: () => TRANSACTIONS_PATH,
|
|
110432
110722
|
RECOVERY_COMMAND: () => RECOVERY_COMMAND
|
|
110433
110723
|
});
|
|
110434
|
-
import { existsSync as
|
|
110435
|
-
import { basename as basename11, dirname as dirname50, join as
|
|
110436
|
-
import { lstat as lstat18, readdir as readdir30, readFile as
|
|
110724
|
+
import { existsSync as existsSync32 } from "node:fs";
|
|
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";
|
|
110437
110727
|
async function recoveryText(root2, path3) {
|
|
110438
110728
|
const target = await safeProjectTarget(root2, path3);
|
|
110439
110729
|
try {
|
|
110440
|
-
return await
|
|
110730
|
+
return await readFile105(target, "utf8");
|
|
110441
110731
|
} catch (error) {
|
|
110442
110732
|
if (error.code === "ENOENT")
|
|
110443
110733
|
return;
|
|
@@ -110450,7 +110740,7 @@ async function recoveryJournals(root2) {
|
|
|
110450
110740
|
await safeProjectTarget(root2, path3);
|
|
110451
110741
|
let stat11;
|
|
110452
110742
|
try {
|
|
110453
|
-
stat11 = await lstat18(
|
|
110743
|
+
stat11 = await lstat18(join127(root2, path3));
|
|
110454
110744
|
} catch (error) {
|
|
110455
110745
|
if (error.code === "ENOENT")
|
|
110456
110746
|
return;
|
|
@@ -110461,7 +110751,7 @@ async function recoveryJournals(root2) {
|
|
|
110461
110751
|
if (stat11.isDirectory()) {
|
|
110462
110752
|
if (depth > 3)
|
|
110463
110753
|
throw new TypeError("Unexpected transaction directory depth; preserve it for diagnosis.");
|
|
110464
|
-
for (const name3 of (await readdir30(
|
|
110754
|
+
for (const name3 of (await readdir30(join127(root2, path3))).sort())
|
|
110465
110755
|
await visit4(`${path3}/${name3}`, depth + 1);
|
|
110466
110756
|
} else if (stat11.isFile())
|
|
110467
110757
|
entries2.push({ path: path3, digest: indexerProtocolDigest(await recoveryText(root2, path3)) });
|
|
@@ -110473,10 +110763,10 @@ function recoveryResources() {
|
|
|
110473
110763
|
try {
|
|
110474
110764
|
const root2 = dirname50(contextWorkflowProviderPath());
|
|
110475
110765
|
const resources = {
|
|
110476
|
-
skill:
|
|
110477
|
-
issue_template:
|
|
110766
|
+
skill: join127(root2, "skills/recover-workspace/SKILL.md"),
|
|
110767
|
+
issue_template: join127(root2, "resources/templates/recovery-issue.md")
|
|
110478
110768
|
};
|
|
110479
|
-
if (!Object.values(resources).every((path3) =>
|
|
110769
|
+
if (!Object.values(resources).every((path3) => existsSync32(path3)))
|
|
110480
110770
|
throw new Error("Recovery resources are absent from this Provider.");
|
|
110481
110771
|
return resources;
|
|
110482
110772
|
} catch {
|
|
@@ -110589,8 +110879,8 @@ var exports_taskLocalSourceAdjustment = {};
|
|
|
110589
110879
|
__export(exports_taskLocalSourceAdjustment, {
|
|
110590
110880
|
adjustLocalRevisionSources: () => adjustLocalRevisionSources
|
|
110591
110881
|
});
|
|
110592
|
-
import { readFile as
|
|
110593
|
-
import { join as
|
|
110882
|
+
import { readFile as readFile106 } from "node:fs/promises";
|
|
110883
|
+
import { join as join128 } from "node:path";
|
|
110594
110884
|
async function adjustLocalRevisionSources(root2, input) {
|
|
110595
110885
|
const { readMaintenance: readMaintenance2 } = await Promise.resolve().then(() => (init_maintenanceStorage(), exports_maintenanceStorage));
|
|
110596
110886
|
if ((await readMaintenance2(root2)).active && await readProductionStage(root2))
|
|
@@ -110636,7 +110926,7 @@ async function adjustLocalRevisionSources(root2, input) {
|
|
|
110636
110926
|
if (input.refresh && (!current3.refresh_sources || indexerProtocolDigest([...current3.refresh_sources].sort()) !== indexerProtocolDigest([...selected].sort()))) {
|
|
110637
110927
|
throw new TypeError("No matching acquisition adjustment exists. Run task adjust without refresh first.");
|
|
110638
110928
|
}
|
|
110639
|
-
const raw = await
|
|
110929
|
+
const raw = await readFile106(join128(root2, await revisionStoragePath(root2)), "utf8");
|
|
110640
110930
|
let next2;
|
|
110641
110931
|
const discardIds = new Set;
|
|
110642
110932
|
if (!refresh) {
|
|
@@ -110751,7 +111041,7 @@ ${input.instruction}` : revision.instruction
|
|
|
110751
111041
|
content: content3
|
|
110752
111042
|
}];
|
|
110753
111043
|
if (discardIds.size > 0) {
|
|
110754
|
-
const ledger = await
|
|
111044
|
+
const ledger = await readFile106(join128(root2, CANDIDATE_LEDGER_FILE), "utf8").catch((error) => {
|
|
110755
111045
|
if (error.code === "ENOENT")
|
|
110756
111046
|
return;
|
|
110757
111047
|
throw error;
|
|
@@ -111099,7 +111389,7 @@ __export(exports_approvedRevisionSubmission, {
|
|
|
111099
111389
|
prepareApprovedRevisionSubmission: () => prepareApprovedRevisionSubmission,
|
|
111100
111390
|
completeApprovedRevisionSubmission: () => completeApprovedRevisionSubmission
|
|
111101
111391
|
});
|
|
111102
|
-
import { join as
|
|
111392
|
+
import { join as join130 } from "node:path";
|
|
111103
111393
|
function paused(message, managed, authorities = []) {
|
|
111104
111394
|
return new ContextError(ExitCode.WorkspaceStateError, message, {
|
|
111105
111395
|
category: ErrorCategory.WorkspaceStateInvalid,
|
|
@@ -111154,9 +111444,9 @@ async function prepareApprovedRevisionSubmission(input) {
|
|
|
111154
111444
|
const { route, requests, contexts, issued } = await issueRevisionBatch(input);
|
|
111155
111445
|
const stage = stageId(issued);
|
|
111156
111446
|
const directory = productionAgentDirectory(stage);
|
|
111157
|
-
await atomicWriteFile(await safeProjectTarget(input.projectRoot,
|
|
111447
|
+
await atomicWriteFile(await safeProjectTarget(input.projectRoot, join130(directory, "issued.json")), JSON.stringify(issued));
|
|
111158
111448
|
for (const [index3, request] of requests.entries()) {
|
|
111159
|
-
await atomicWriteFile(await safeProjectTarget(input.projectRoot,
|
|
111449
|
+
await atomicWriteFile(await safeProjectTarget(input.projectRoot, join130(directory, `${issued.tasks[index3].task}.input.json`)), JSON.stringify({
|
|
111160
111450
|
stage: "approved-revision",
|
|
111161
111451
|
revision: request.revision,
|
|
111162
111452
|
instruction: request.instruction,
|
|
@@ -111171,7 +111461,7 @@ async function prepareApprovedRevisionSubmission(input) {
|
|
|
111171
111461
|
tasks: issued.tasks.map((task, index3) => ({
|
|
111172
111462
|
...task,
|
|
111173
111463
|
path: requests[index3].target.path,
|
|
111174
|
-
task_input:
|
|
111464
|
+
task_input: join130(directory, `${task.task}.input.json`)
|
|
111175
111465
|
})),
|
|
111176
111466
|
submission: { stage, tasks: issued.tasks.map((task) => ({ task: task.task, input: task.input, edits: `${task.task}.edits.json` })) },
|
|
111177
111467
|
next_action: {
|
|
@@ -111399,7 +111689,7 @@ var init_approvedRevisionSubmission = __esm(() => {
|
|
|
111399
111689
|
});
|
|
111400
111690
|
|
|
111401
111691
|
// src/project/managedDocumentImport.ts
|
|
111402
|
-
import { readFile as
|
|
111692
|
+
import { readFile as readFile115 } from "node:fs/promises";
|
|
111403
111693
|
async function importManagedDocument(projectRoot2, value) {
|
|
111404
111694
|
const input = inputSchema.parse(value);
|
|
111405
111695
|
if (input.type !== "sessions" && input.changes !== undefined)
|
|
@@ -111408,7 +111698,7 @@ async function importManagedDocument(projectRoot2, value) {
|
|
|
111408
111698
|
const path3 = await assertManagedDocumentPath(projectRoot2, input.type, input.name);
|
|
111409
111699
|
let previous3;
|
|
111410
111700
|
try {
|
|
111411
|
-
previous3 = await
|
|
111701
|
+
previous3 = await readFile115(path3, "utf8");
|
|
111412
111702
|
} catch (error) {
|
|
111413
111703
|
if (!(error && typeof error === "object" && ("code" in error) && error.code === "ENOENT"))
|
|
111414
111704
|
throw error;
|
|
@@ -111455,7 +111745,7 @@ var init_managedDocumentImport = __esm(() => {
|
|
|
111455
111745
|
});
|
|
111456
111746
|
|
|
111457
111747
|
// src/project/larkDocumentImport.ts
|
|
111458
|
-
import { readFile as
|
|
111748
|
+
import { readFile as readFile116 } from "node:fs/promises";
|
|
111459
111749
|
import { resolve as resolve48 } from "node:path";
|
|
111460
111750
|
async function importLarkDocument(projectRoot2, value) {
|
|
111461
111751
|
const input = schema4.parse(value);
|
|
@@ -111472,7 +111762,7 @@ async function importLarkDocument(projectRoot2, value) {
|
|
|
111472
111762
|
const responsePages = [];
|
|
111473
111763
|
for (const path3 of input.response_files) {
|
|
111474
111764
|
assertActionInputWorkspace(projectRoot2, path3);
|
|
111475
|
-
responsePages.push(await
|
|
111765
|
+
responsePages.push(await readFile116(resolve48(projectRoot2, path3), "utf8"));
|
|
111476
111766
|
}
|
|
111477
111767
|
const mediaFiles = {};
|
|
111478
111768
|
for (const [token, path3] of Object.entries(input.media_files ?? {})) {
|
|
@@ -111539,11 +111829,11 @@ var exports_managedDocumentRename = {};
|
|
|
111539
111829
|
__export(exports_managedDocumentRename, {
|
|
111540
111830
|
renameManagedDocument: () => renameManagedDocument
|
|
111541
111831
|
});
|
|
111542
|
-
import { readFile as
|
|
111543
|
-
import { join as
|
|
111832
|
+
import { readFile as readFile117 } from "node:fs/promises";
|
|
111833
|
+
import { join as join142, posix as posix15 } from "node:path";
|
|
111544
111834
|
async function optionalText3(path3) {
|
|
111545
111835
|
try {
|
|
111546
|
-
return await
|
|
111836
|
+
return await readFile117(path3, "utf8");
|
|
111547
111837
|
} catch (error) {
|
|
111548
111838
|
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT")
|
|
111549
111839
|
return;
|
|
@@ -111627,7 +111917,7 @@ async function renameManagedDocument(input) {
|
|
|
111627
111917
|
if (path3.split("/").includes("..") || path3.startsWith("/"))
|
|
111628
111918
|
throw new TypeError("Source references contain an unsafe knowledge path; repair it before renaming.");
|
|
111629
111919
|
await safeProjectTarget(input.projectRoot, path3);
|
|
111630
|
-
const before = await optionalText3(
|
|
111920
|
+
const before = await optionalText3(join142(input.projectRoot, path3));
|
|
111631
111921
|
if (before === undefined)
|
|
111632
111922
|
continue;
|
|
111633
111923
|
let after;
|
|
@@ -111640,7 +111930,7 @@ async function renameManagedDocument(input) {
|
|
|
111640
111930
|
references: section.references.map((citation) => citation.source_ref !== input.source_ref ? citation : {
|
|
111641
111931
|
...citation,
|
|
111642
111932
|
source_ref: nextRef,
|
|
111643
|
-
locator: { ...citation.locator, path:
|
|
111933
|
+
locator: { ...citation.locator, path: posix15.basename(input.name) }
|
|
111644
111934
|
})
|
|
111645
111935
|
})) }));
|
|
111646
111936
|
updated.articles = rewritten;
|
|
@@ -111666,11 +111956,11 @@ async function renameManagedDocument(input) {
|
|
|
111666
111956
|
return;
|
|
111667
111957
|
}
|
|
111668
111958
|
const rooted = destination.startsWith("sources/") || destination.startsWith("/sources/");
|
|
111669
|
-
const resolved = rooted ? destination.replace(/^\//u, "") :
|
|
111959
|
+
const resolved = rooted ? destination.replace(/^\//u, "") : posix15.normalize(posix15.join(posix15.dirname(path3), destination));
|
|
111670
111960
|
if (resolved !== `sources/${type}/${oldName}`)
|
|
111671
111961
|
return;
|
|
111672
111962
|
const renamed = `sources/${type}/${input.name}`;
|
|
111673
|
-
return encodeURI(rooted ? `${destination.startsWith("/") ? "/" : ""}${renamed}` :
|
|
111963
|
+
return encodeURI(rooted ? `${destination.startsWith("/") ? "/" : ""}${renamed}` : posix15.relative(posix15.dirname(path3), renamed)) + match2[2];
|
|
111674
111964
|
});
|
|
111675
111965
|
if (before === after)
|
|
111676
111966
|
continue;
|
|
@@ -111719,7 +112009,7 @@ var exports_originalRevisionsCommand = {};
|
|
|
111719
112009
|
__export(exports_originalRevisionsCommand, {
|
|
111720
112010
|
runOriginalRevisionsCommand: () => runOriginalRevisionsCommand
|
|
111721
112011
|
});
|
|
111722
|
-
import { readFile as
|
|
112012
|
+
import { readFile as readFile121 } from "node:fs/promises";
|
|
111723
112013
|
import { resolve as resolve56 } from "node:path";
|
|
111724
112014
|
async function readInput(cwd, source2) {
|
|
111725
112015
|
const raw = source2 === "-" ? await new Promise((resolveInput, reject) => {
|
|
@@ -111730,7 +112020,7 @@ async function readInput(cwd, source2) {
|
|
|
111730
112020
|
});
|
|
111731
112021
|
process.stdin.on("end", () => resolveInput(data2));
|
|
111732
112022
|
process.stdin.on("error", reject);
|
|
111733
|
-
}) : await
|
|
112023
|
+
}) : await readFile121(resolve56(cwd, source2), "utf8");
|
|
111734
112024
|
return import_yaml68.default.parse(raw);
|
|
111735
112025
|
}
|
|
111736
112026
|
async function runOriginalRevisionsCommand(input) {
|
|
@@ -111784,8 +112074,8 @@ var init_originalRevisionsCommand = __esm(() => {
|
|
|
111784
112074
|
});
|
|
111785
112075
|
|
|
111786
112076
|
// src/cli.ts
|
|
111787
|
-
import { existsSync as
|
|
111788
|
-
import { dirname as dirname57, join as
|
|
112077
|
+
import { existsSync as existsSync41, realpathSync as realpathSync3 } from "node:fs";
|
|
112078
|
+
import { dirname as dirname57, join as join148 } from "node:path";
|
|
111789
112079
|
import { fileURLToPath as fileURLToPath12, pathToFileURL as pathToFileURL3 } from "node:url";
|
|
111790
112080
|
|
|
111791
112081
|
// ../../node_modules/.bun/commander@11.1.0/node_modules/commander/esm.mjs
|
|
@@ -111824,15 +112114,15 @@ init_workflowFacts();
|
|
|
111824
112114
|
init_workflowProvider();
|
|
111825
112115
|
init_workflowResourceRender();
|
|
111826
112116
|
init_workflowTypes();
|
|
111827
|
-
import { join as
|
|
112117
|
+
import { join as join115 } from "node:path";
|
|
111828
112118
|
|
|
111829
112119
|
// src/project/reviewHtml.ts
|
|
111830
112120
|
init_originalRevisions();
|
|
111831
112121
|
init_candidateLedger();
|
|
111832
112122
|
init_reviewShared();
|
|
111833
|
-
import { copyFile, mkdir as mkdir37, readFile as
|
|
112123
|
+
import { copyFile, mkdir as mkdir37, readFile as readFile92, writeFile as writeFile29 } from "node:fs/promises";
|
|
111834
112124
|
import { fileURLToPath as fileURLToPath8 } from "node:url";
|
|
111835
|
-
import { dirname as dirname46, isAbsolute as isAbsolute17, join as
|
|
112125
|
+
import { dirname as dirname46, isAbsolute as isAbsolute17, join as join113, resolve as resolve35 } from "node:path";
|
|
111836
112126
|
|
|
111837
112127
|
// src/project/reviewSiteModel.ts
|
|
111838
112128
|
init_siteTheme2();
|
|
@@ -111840,8 +112130,8 @@ init_src2();
|
|
|
111840
112130
|
init_unified();
|
|
111841
112131
|
init_remark_parse();
|
|
111842
112132
|
var import_yaml52 = __toESM(require_dist(), 1);
|
|
111843
|
-
import { readFile as
|
|
111844
|
-
import { join as
|
|
112133
|
+
import { readFile as readFile90 } from "node:fs/promises";
|
|
112134
|
+
import { join as join111 } from "node:path";
|
|
111845
112135
|
import { execFile as execFile17 } from "node:child_process";
|
|
111846
112136
|
import { promisify as promisify14 } from "node:util";
|
|
111847
112137
|
import { createHash as createHash33 } from "node:crypto";
|
|
@@ -114806,10 +115096,10 @@ function remarkGfm(options) {
|
|
|
114806
115096
|
init_workspace();
|
|
114807
115097
|
|
|
114808
115098
|
// src/project/reviewFeedback.ts
|
|
114809
|
-
import { readdir as readdir24, readFile as
|
|
114810
|
-
import { join as
|
|
115099
|
+
import { readdir as readdir24, readFile as readFile88 } from "node:fs/promises";
|
|
115100
|
+
import { join as join110 } from "node:path";
|
|
114811
115101
|
async function readPendingReviewFeedback(root2, candidates) {
|
|
114812
|
-
const directory =
|
|
115102
|
+
const directory = join110(root2, ".tmp/context-runtime/review-feedback");
|
|
114813
115103
|
let files;
|
|
114814
115104
|
try {
|
|
114815
115105
|
files = await readdir24(directory);
|
|
@@ -114822,7 +115112,7 @@ async function readPendingReviewFeedback(root2, candidates) {
|
|
|
114822
115112
|
const results = new Map;
|
|
114823
115113
|
const receipts = [];
|
|
114824
115114
|
for (const file of files.filter((f) => /^[a-f0-9]+\.json$/u.test(f)).sort()) {
|
|
114825
|
-
const receipt2 = JSON.parse(await
|
|
115115
|
+
const receipt2 = JSON.parse(await readFile88(join110(directory, file), "utf8"));
|
|
114826
115116
|
receipts.push(receipt2);
|
|
114827
115117
|
}
|
|
114828
115118
|
for (const receipt2 of receipts.sort((a2, b) => a2.created_at.localeCompare(b.created_at))) {
|
|
@@ -114932,7 +115222,7 @@ var title = (s, fallback) => {
|
|
|
114932
115222
|
};
|
|
114933
115223
|
async function optional2(path3) {
|
|
114934
115224
|
try {
|
|
114935
|
-
return await
|
|
115225
|
+
return await readFile90(path3, "utf8");
|
|
114936
115226
|
} catch (e) {
|
|
114937
115227
|
if (e.code === "ENOENT")
|
|
114938
115228
|
return;
|
|
@@ -114969,7 +115259,7 @@ async function reviewSiteBaselineHash(root2, reviewedPaths) {
|
|
|
114969
115259
|
const displayed = new Set([...reviewedPaths, ...(metadata.structure?.articles ?? []).filter((a2) => navigation.changedArticles.has(a2.article_id)).map((a2) => a2.path)]);
|
|
114970
115260
|
return hash4(JSON.stringify([
|
|
114971
115261
|
navigation.baseline,
|
|
114972
|
-
await optional2(
|
|
115262
|
+
await optional2(join111(root2, "src/knowledge-map.yaml")) ?? null,
|
|
114973
115263
|
navigation.planned ? [navigation.planned.retired, navigation.planned.knowledge_map ?? null] : null,
|
|
114974
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]))
|
|
114975
115265
|
]));
|
|
@@ -115082,9 +115372,9 @@ async function collectReviewSiteModel(root2, candidates) {
|
|
|
115082
115372
|
nodes.push({ key: `review-page-${p.id}`, parent: "review-unplaced", title: p.title, order: i2, page: p.id, change: p.change });
|
|
115083
115373
|
}
|
|
115084
115374
|
const navigationChanges = navigationBaseline === "empty" ? [] : reviewNavigationChanges(baseline?.entries ?? [], current3?.entries ?? [], pages);
|
|
115085
|
-
const pkgText = await optional2(
|
|
115375
|
+
const pkgText = await optional2(join111(root2, "package.json"));
|
|
115086
115376
|
const pkg = pkgText ? JSON.parse(pkgText) : {};
|
|
115087
|
-
const project = await optional2(
|
|
115377
|
+
const project = await optional2(join111(root2, "src/index.ts")) === undefined ? undefined : await loadContextProjectModule(root2);
|
|
115088
115378
|
const siteTitle = project?.project.packages.flatMap((p) => p.kind === "package.kb" && p.site?.title ? [p.site.title] : [])[0];
|
|
115089
115379
|
const sitePackages = project?.project.packages.flatMap((p) => p.kind === "package.kb" && p.site ? [p.site] : []) ?? [];
|
|
115090
115380
|
const themeCss = siteThemeVariables(await resolveSiteTheme(root2, sitePackages.length === 1 ? sitePackages[0]?.theme : undefined));
|
|
@@ -115151,9 +115441,9 @@ init_errors3();
|
|
|
115151
115441
|
init_cliFeedback();
|
|
115152
115442
|
init_exitCode();
|
|
115153
115443
|
init_reviewShared();
|
|
115154
|
-
import { readFile as
|
|
115155
|
-
import { join as
|
|
115156
|
-
var scopePath = (root2, scope2) =>
|
|
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`);
|
|
115157
115447
|
async function saveReviewReportScope(root2, scope2, candidates, baselineHash, reportPath) {
|
|
115158
115448
|
const ids = candidates.map((candidate) => candidate.record.candidate_id).sort();
|
|
115159
115449
|
const value = {
|
|
@@ -115173,7 +115463,7 @@ async function saveReviewReportScope(root2, scope2, candidates, baselineHash, re
|
|
|
115173
115463
|
}
|
|
115174
115464
|
async function readConfirmedReviewScope(root2, scope2) {
|
|
115175
115465
|
try {
|
|
115176
|
-
const value = JSON.parse(await
|
|
115466
|
+
const value = JSON.parse(await readFile91(scopePath(root2, scope2), "utf8"));
|
|
115177
115467
|
if (!value || typeof value !== "object" || !("scope" in value) || !("baseline_hash" in value))
|
|
115178
115468
|
throw new Error("Missing report scope");
|
|
115179
115469
|
const parsed = value;
|
|
@@ -115715,7 +116005,7 @@ button:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
|
|
|
115715
116005
|
|
|
115716
116006
|
// src/project/reviewHtml.ts
|
|
115717
116007
|
init_knowledgeMap2();
|
|
115718
|
-
var REVIEW_HTML_ROOT =
|
|
116008
|
+
var REVIEW_HTML_ROOT = join113(".tmp", "context-runtime", "review");
|
|
115719
116009
|
async function collectReviewCandidates(projectRoot, collection) {
|
|
115720
116010
|
const rows = await readCandidateRecords(projectRoot);
|
|
115721
116011
|
const draftRows = rows.filter((row) => row.collection === collection && row.status === "draft");
|
|
@@ -115765,13 +116055,13 @@ ${diagramScript ? `<script>${diagramScript}</script>` : ""}<script>const DATA=${
|
|
|
115765
116055
|
}
|
|
115766
116056
|
function resolveOutputPath(projectRoot, outPath, reviewScope) {
|
|
115767
116057
|
if (outPath === undefined)
|
|
115768
|
-
return
|
|
116058
|
+
return join113(projectRoot, REVIEW_HTML_ROOT, `${reviewScope}.html`);
|
|
115769
116059
|
return isAbsolute17(outPath) ? outPath : resolve35(projectRoot, outPath);
|
|
115770
116060
|
}
|
|
115771
|
-
var APPLIED_REVIEW_REPORT_ROOT =
|
|
116061
|
+
var APPLIED_REVIEW_REPORT_ROOT = join113(".tmp", "review-reports");
|
|
115772
116062
|
async function archiveAppliedReviewReport(projectRoot, reportPath, scope2) {
|
|
115773
116063
|
const stamp = new Date().toISOString().replace(/[:.]/gu, "-");
|
|
115774
|
-
const target =
|
|
116064
|
+
const target = join113(projectRoot, APPLIED_REVIEW_REPORT_ROOT, `${stamp}-${scope2}.html`);
|
|
115775
116065
|
await mkdir37(dirname46(target), { recursive: true });
|
|
115776
116066
|
await copyFile(reportPath, target);
|
|
115777
116067
|
return target;
|
|
@@ -115817,11 +116107,11 @@ async function writeReviewHtml(input) {
|
|
|
115817
116107
|
if (model.pages.some((page) => page.html.includes('class="language-mermaid"'))) {
|
|
115818
116108
|
const here = dirname46(fileURLToPath8(import.meta.url));
|
|
115819
116109
|
try {
|
|
115820
|
-
diagramScript = await
|
|
116110
|
+
diagramScript = await readFile92(join113(here, "browser/diagrams.js"), "utf8");
|
|
115821
116111
|
} catch (error) {
|
|
115822
116112
|
if (error.code !== "ENOENT")
|
|
115823
116113
|
throw error;
|
|
115824
|
-
diagramScript = await
|
|
116114
|
+
diagramScript = await readFile92(resolve35(here, "../../dist/browser/diagrams.js"), "utf8");
|
|
115825
116115
|
}
|
|
115826
116116
|
}
|
|
115827
116117
|
await writeFile29(outPath, renderReviewHtml(model, diagramScript), "utf8");
|
|
@@ -115865,8 +116155,8 @@ init_productionRequirements();
|
|
|
115865
116155
|
init_dist();
|
|
115866
116156
|
init_atomicWrite();
|
|
115867
116157
|
init_reviewShared();
|
|
115868
|
-
import { mkdir as mkdir38, readFile as
|
|
115869
|
-
import { join as
|
|
116158
|
+
import { mkdir as mkdir38, readFile as readFile93 } from "node:fs/promises";
|
|
116159
|
+
import { join as join114 } from "node:path";
|
|
115870
116160
|
var REVIEW_BATCH_MAX_CANDIDATES = 6;
|
|
115871
116161
|
var REVIEW_BATCH_MAX_BYTES = 512 * 1024;
|
|
115872
116162
|
async function readerPurposes(projectRoot, sources) {
|
|
@@ -115946,12 +116236,12 @@ async function materializeCurrentReviewBatchSet(input) {
|
|
|
115946
116236
|
const batches = buildCurrentReviewBatchDocuments(input.candidates);
|
|
115947
116237
|
const setDigest = digestText(batches.map((batch) => `${batch.task_key}:${batch.digest}`).join(`
|
|
115948
116238
|
`));
|
|
115949
|
-
const root2 =
|
|
116239
|
+
const root2 = join114(input.projectRoot, ".tmp", "context-runtime", "review", `current-${setDigest.slice("sha256:".length)}`);
|
|
115950
116240
|
await mkdir38(root2, { recursive: true });
|
|
115951
116241
|
const entries2 = [];
|
|
115952
116242
|
for (const batch of batches) {
|
|
115953
|
-
const path4 =
|
|
115954
|
-
const existing = await
|
|
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) => {
|
|
115955
116245
|
if (error.code === "ENOENT")
|
|
115956
116246
|
return;
|
|
115957
116247
|
throw error;
|
|
@@ -116004,7 +116294,7 @@ async function materializeCurrentReviewBatchSet(input) {
|
|
|
116004
116294
|
].join(`
|
|
116005
116295
|
`);
|
|
116006
116296
|
const digest7 = digestText(content3);
|
|
116007
|
-
const path3 =
|
|
116297
|
+
const path3 = join114(root2, "index.md");
|
|
116008
116298
|
await atomicWriteFile(path3, `${content3}
|
|
116009
116299
|
`);
|
|
116010
116300
|
return {
|
|
@@ -116038,11 +116328,11 @@ function shellQuote6(value) {
|
|
|
116038
116328
|
}
|
|
116039
116329
|
function receiptSetPath(receipts) {
|
|
116040
116330
|
const token = digestText(JSON.stringify(receipts)).slice("sha256:".length);
|
|
116041
|
-
return
|
|
116331
|
+
return join115(".tmp", "context-runtime", "workflow", "read-receipts", `${token}.json`);
|
|
116042
116332
|
}
|
|
116043
116333
|
async function writeReceiptContinuation(input) {
|
|
116044
116334
|
const path3 = receiptSetPath(input.receipts);
|
|
116045
|
-
const absolutePath =
|
|
116335
|
+
const absolutePath = join115(input.projectRoot, path3);
|
|
116046
116336
|
await writeJsonAtomic(absolutePath, input.receipts);
|
|
116047
116337
|
const contextCommand = input.managed ? [
|
|
116048
116338
|
"context",
|
|
@@ -116137,7 +116427,7 @@ async function materializeContextWorkflowResource(input) {
|
|
|
116137
116427
|
const resourceId = workflowResourceId(input.resourceId);
|
|
116138
116428
|
const content3 = renderContextWorkflowResource(resourceId, status);
|
|
116139
116429
|
const location = await materializeResource(await loadContextWorkflowProvider(), resourceId, {
|
|
116140
|
-
cache:
|
|
116430
|
+
cache: join115(found.projectRoot, ".tmp", "context-runtime", "workflow", "resources"),
|
|
116141
116431
|
workspace: found.projectRoot,
|
|
116142
116432
|
revision: input.revision,
|
|
116143
116433
|
input: {
|
|
@@ -116169,7 +116459,7 @@ async function materializeContextWorkflowResource(input) {
|
|
|
116169
116459
|
receipts: afterReadReceipts
|
|
116170
116460
|
});
|
|
116171
116461
|
const directResources = (status.workflow.current?.resources.required ?? []).filter((resource) => resource.read_state === "read-required" && resource.path !== undefined && resource.digest !== undefined);
|
|
116172
|
-
const afterReadCommand = directResources.length === 0 ? continuation.command : `context resource acknowledge-current --revision ${shellQuote6(input.revision)}${authorityCommandOptions(authorities, "resource")} --resource-receipts ${shellQuote6(`@${
|
|
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`;
|
|
116173
116463
|
return {
|
|
116174
116464
|
protocol: "context.workflow.resource.v1",
|
|
116175
116465
|
id: resourceId,
|
|
@@ -116230,14 +116520,14 @@ async function acknowledgeCurrentWorkflowResources(input) {
|
|
|
116230
116520
|
const reevaluated = await reevaluateProjectStatusWorkflow({
|
|
116231
116521
|
snapshot,
|
|
116232
116522
|
resourceReceipts: normalizedReceipts,
|
|
116233
|
-
resourceReceiptsReference: `@${
|
|
116523
|
+
resourceReceiptsReference: `@${join115(found.projectRoot, continuation.path)}`
|
|
116234
116524
|
});
|
|
116235
116525
|
return {
|
|
116236
116526
|
...reevaluated,
|
|
116237
116527
|
resourceAcknowledgement: {
|
|
116238
116528
|
protocol: "context.workflow.resource-receipts.v1",
|
|
116239
116529
|
acknowledged: directResources.length,
|
|
116240
|
-
receiptReference: `@${
|
|
116530
|
+
receiptReference: `@${join115(found.projectRoot, continuation.path)}`,
|
|
116241
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."
|
|
116242
116532
|
}
|
|
116243
116533
|
};
|
|
@@ -116284,9 +116574,9 @@ init_cliFeedback();
|
|
|
116284
116574
|
init_errors3();
|
|
116285
116575
|
init_exitCode();
|
|
116286
116576
|
init_workspace();
|
|
116287
|
-
import { readFile as
|
|
116288
|
-
import { isAbsolute as isAbsolute18, join as
|
|
116289
|
-
var RECEIPT_DIRECTORY =
|
|
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");
|
|
116290
116580
|
function workflowResourceReceiptCwd(value, cwd) {
|
|
116291
116581
|
if (value === undefined || !value.startsWith("@"))
|
|
116292
116582
|
return cwd;
|
|
@@ -116304,7 +116594,7 @@ async function receiptDocument(value, cwd) {
|
|
|
116304
116594
|
let source2 = value;
|
|
116305
116595
|
if (value.startsWith("@")) {
|
|
116306
116596
|
try {
|
|
116307
|
-
source2 = await
|
|
116597
|
+
source2 = await readFile94(resolve36(cwd, value.slice(1)), "utf8");
|
|
116308
116598
|
} catch (error) {
|
|
116309
116599
|
const ioCode = error !== null && typeof error === "object" && "code" in error && typeof error.code === "string" ? error.code : undefined;
|
|
116310
116600
|
throw new ContextError(ExitCode.UserError, "resource read receipt file is unavailable", {
|
|
@@ -116566,14 +116856,14 @@ function compactJsonResult(result, verbose) {
|
|
|
116566
116856
|
// src/project/runLog.ts
|
|
116567
116857
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
116568
116858
|
import { mkdir as mkdir40, writeFile as writeFile31 } from "node:fs/promises";
|
|
116569
|
-
import { dirname as dirname48, join as
|
|
116859
|
+
import { dirname as dirname48, join as join122 } from "node:path";
|
|
116570
116860
|
var createPhaseRunId = () => {
|
|
116571
116861
|
const timestamp = new Date().toISOString().replace(/[-:.TZ]/gu, "");
|
|
116572
116862
|
return `run_${timestamp}_${randomUUID6().slice(0, 8)}`;
|
|
116573
116863
|
};
|
|
116574
116864
|
async function writePhaseRunLog(input) {
|
|
116575
|
-
const relPath =
|
|
116576
|
-
const absPath =
|
|
116865
|
+
const relPath = join122(".tmp", "context-runtime", "runs", `${input.runId}.json`);
|
|
116866
|
+
const absPath = join122(input.projectRoot, relPath);
|
|
116577
116867
|
await mkdir40(dirname48(absPath), { recursive: true });
|
|
116578
116868
|
await writeFile31(absPath, `${JSON.stringify({
|
|
116579
116869
|
run_id: input.runId,
|
|
@@ -117612,7 +117902,7 @@ function createReviewCodeCodec() {
|
|
|
117612
117902
|
const identity2 = checksum(code3);
|
|
117613
117903
|
return Array.from({ length: total }, (_, i2) => `CRP1.${identity2}.${i2 + 1}.${total}.${code3.slice(i2 * 900, (i2 + 1) * 900)}`);
|
|
117614
117904
|
}
|
|
117615
|
-
function
|
|
117905
|
+
function decode3(input) {
|
|
117616
117906
|
if (input.length > 250000)
|
|
117617
117907
|
throw new Error("Review code exceeds the supported size");
|
|
117618
117908
|
const lines = input.trim().split(/\s+/);
|
|
@@ -117667,7 +117957,7 @@ function createReviewCodeCodec() {
|
|
|
117667
117957
|
throw new Error("Review contains no decisions");
|
|
117668
117958
|
return { scope: scope2, count, idsHash: unhash(ids), contentHash: unhash(content3), statuses };
|
|
117669
117959
|
}
|
|
117670
|
-
return { encode, decode:
|
|
117960
|
+
return { encode, decode: decode3 };
|
|
117671
117961
|
}
|
|
117672
117962
|
|
|
117673
117963
|
// src/project/reviewFeedbackCode.ts
|
|
@@ -117719,7 +118009,7 @@ ${repairs}` : "";
|
|
|
117719
118009
|
throw new Error("Review feedback is too large; shorten instructions or review a smaller scope");
|
|
117720
118010
|
return code3;
|
|
117721
118011
|
}
|
|
117722
|
-
function
|
|
118012
|
+
function decode3(raw) {
|
|
117723
118013
|
const code3 = raw.trim();
|
|
117724
118014
|
if (code3.length > 250000)
|
|
117725
118015
|
throw new Error("Review feedback exceeds supported size");
|
|
@@ -117752,7 +118042,7 @@ ${lines.join(`
|
|
|
117752
118042
|
throw new Error("Noncanonical review feedback encoding");
|
|
117753
118043
|
return value;
|
|
117754
118044
|
}
|
|
117755
|
-
return { encode, decode:
|
|
118045
|
+
return { encode, decode: decode3 };
|
|
117756
118046
|
}
|
|
117757
118047
|
|
|
117758
118048
|
// src/project/reviewLegacy.ts
|
|
@@ -117803,8 +118093,8 @@ async function readLegacyReviewPayload(raw, projectRoot) {
|
|
|
117803
118093
|
init_cliFeedback();
|
|
117804
118094
|
init_errors3();
|
|
117805
118095
|
init_exitCode();
|
|
117806
|
-
import { existsSync as
|
|
117807
|
-
import { readFile as
|
|
118096
|
+
import { existsSync as existsSync31 } from "node:fs";
|
|
118097
|
+
import { readFile as readFile101 } from "node:fs/promises";
|
|
117808
118098
|
import { isAbsolute as isAbsolute21, resolve as resolve38 } from "node:path";
|
|
117809
118099
|
|
|
117810
118100
|
// src/project/reviewApply.ts
|
|
@@ -117820,9 +118110,9 @@ init_reviewCandidateAuthority();
|
|
|
117820
118110
|
init_durableMultiFileTransaction();
|
|
117821
118111
|
init_durableSingleFileTransaction();
|
|
117822
118112
|
init_reviewShared();
|
|
117823
|
-
import { existsSync as
|
|
117824
|
-
import { readFile as
|
|
117825
|
-
import { join as
|
|
118113
|
+
import { existsSync as existsSync30 } from "node:fs";
|
|
118114
|
+
import { readFile as readFile99 } from "node:fs/promises";
|
|
118115
|
+
import { join as join123 } from "node:path";
|
|
117826
118116
|
function existingTimestamp(markdown) {
|
|
117827
118117
|
if (markdown === undefined)
|
|
117828
118118
|
return;
|
|
@@ -117849,7 +118139,7 @@ async function prepareApprovedPage(input) {
|
|
|
117849
118139
|
next: "Refresh the current production or article revision, then reopen Review before approval."
|
|
117850
118140
|
});
|
|
117851
118141
|
}
|
|
117852
|
-
const relPath =
|
|
118142
|
+
const relPath = join123("knowledge", input.record.path);
|
|
117853
118143
|
const existingView = findApprovedPageForArticleId(input.record.indexer_candidate.artifact_ref, input.approvedPageIndex);
|
|
117854
118144
|
const previousPath = input.record.approved_revision?.previous_path;
|
|
117855
118145
|
if (previousPath !== undefined && (!isSafeKnowledgeTargetPath(previousPath.split("/")[0], previousPath) || previousPath.includes("\\")))
|
|
@@ -117864,13 +118154,13 @@ async function prepareApprovedPage(input) {
|
|
|
117864
118154
|
next: "Resolve the approved page path migration explicitly before approving this candidate."
|
|
117865
118155
|
});
|
|
117866
118156
|
}
|
|
117867
|
-
const absPath =
|
|
117868
|
-
const existing =
|
|
118157
|
+
const absPath = join123(input.projectRoot, relPath);
|
|
118158
|
+
const existing = existsSync30(absPath) ? await readFile99(absPath, "utf8") : undefined;
|
|
117869
118159
|
let previous3;
|
|
117870
118160
|
if (previousPath !== undefined) {
|
|
117871
118161
|
if (existing !== undefined || existingView?.relPath !== `knowledge/${previousPath}`)
|
|
117872
118162
|
throw new TypeError("Page move destination or original identity changed; refresh its revision.");
|
|
117873
|
-
previous3 = { path: `knowledge/${previousPath}`, content: await
|
|
118163
|
+
previous3 = { path: `knowledge/${previousPath}`, content: await readFile99(join123(input.projectRoot, "knowledge", previousPath), "utf8") };
|
|
117874
118164
|
}
|
|
117875
118165
|
if (input.record.approved_revision !== undefined) {
|
|
117876
118166
|
const base = previous3?.content ?? existing;
|
|
@@ -117917,7 +118207,7 @@ async function prepareApprovedPage(input) {
|
|
|
117917
118207
|
}
|
|
117918
118208
|
async function readProjectFileMaybe(projectRoot, relPath) {
|
|
117919
118209
|
try {
|
|
117920
|
-
return await
|
|
118210
|
+
return await readFile99(join123(projectRoot, relPath), "utf8");
|
|
117921
118211
|
} catch (error) {
|
|
117922
118212
|
if (error !== null && typeof error === "object" && "code" in error && error.code === "ENOENT") {
|
|
117923
118213
|
return;
|
|
@@ -118138,7 +118428,7 @@ async function applyReviewDecisions(input) {
|
|
|
118138
118428
|
});
|
|
118139
118429
|
}
|
|
118140
118430
|
seenApprovedIds.set(approvedRef, row.candidate_id);
|
|
118141
|
-
const approvedPath =
|
|
118431
|
+
const approvedPath = join123("knowledge", row.path);
|
|
118142
118432
|
const previousPathCandidate = seenApprovedPaths.get(knowledgeTargetPathKey(approvedPath));
|
|
118143
118433
|
if (previousPathCandidate !== undefined) {
|
|
118144
118434
|
throw new ContextError(ExitCode.UserError, `multiple approved review decisions target the same knowledge path: ${approvedPath}`, {
|
|
@@ -118188,7 +118478,7 @@ async function applyReviewDecisions(input) {
|
|
|
118188
118478
|
for (const path3 of approvedPageIndex.byRelPath.keys()) {
|
|
118189
118479
|
if (pagesToWrite.some((page) => page.relPath === path3 || page.previous?.path === path3))
|
|
118190
118480
|
continue;
|
|
118191
|
-
const before = await
|
|
118481
|
+
const before = await readFile99(join123(input.projectRoot, path3), "utf8");
|
|
118192
118482
|
const local = path3.replace(/^knowledge\//u, "");
|
|
118193
118483
|
const after = moveKnowledgeLinkTargets2(before, local, local, moved);
|
|
118194
118484
|
navigationTargets.push(reviewFileTarget({ path: path3, baseContent: before, targetContent: after }));
|
|
@@ -118254,11 +118544,11 @@ async function applyReviewDecisions(input) {
|
|
|
118254
118544
|
init_reviewShared();
|
|
118255
118545
|
init_writeLock();
|
|
118256
118546
|
init_verifyFrontmatter();
|
|
118257
|
-
import { readFile as
|
|
118547
|
+
import { readFile as readFile100, writeFile as writeFile32 } from "node:fs/promises";
|
|
118258
118548
|
function deprecateApprovedPage(input) {
|
|
118259
118549
|
return withProjectWriteLock(input.projectRoot, "deprecate-article", async () => {
|
|
118260
118550
|
const page = await approvedPageForArticleId(input.projectRoot, input.viewRef);
|
|
118261
|
-
const original = await
|
|
118551
|
+
const original = await readFile100(page.path, "utf8");
|
|
118262
118552
|
const content3 = parseFrontmatterLoose(original).deprecated === true ? original : updateFrontmatter(original, (metadata) => ({ ...metadata, deprecated: true, timestamp: new Date().toISOString() }));
|
|
118263
118553
|
const changed = content3 !== original;
|
|
118264
118554
|
if (changed)
|
|
@@ -118279,12 +118569,12 @@ init_candidateLedger();
|
|
|
118279
118569
|
|
|
118280
118570
|
// src/project/localHtmlReport.ts
|
|
118281
118571
|
import { execFile as execFile18 } from "node:child_process";
|
|
118282
|
-
import { isAbsolute as isAbsolute20, join as
|
|
118572
|
+
import { isAbsolute as isAbsolute20, join as join124 } from "node:path";
|
|
118283
118573
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
118284
118574
|
import { promisify as promisify15 } from "node:util";
|
|
118285
118575
|
var execFileAsync4 = promisify15(execFile18);
|
|
118286
118576
|
function htmlReportReference(input) {
|
|
118287
|
-
const absolutePath = isAbsolute20(input.path) ? input.path :
|
|
118577
|
+
const absolutePath = isAbsolute20(input.path) ? input.path : join124(input.projectRoot, input.path);
|
|
118288
118578
|
return {
|
|
118289
118579
|
format: "html",
|
|
118290
118580
|
path: input.path,
|
|
@@ -118470,7 +118760,7 @@ function parseReviewPayloadText(raw) {
|
|
|
118470
118760
|
async function readReviewPayloadFile(filePath2, projectRoot) {
|
|
118471
118761
|
let raw;
|
|
118472
118762
|
try {
|
|
118473
|
-
raw = await
|
|
118763
|
+
raw = await readFile101(filePath2, "utf8");
|
|
118474
118764
|
} catch (error) {
|
|
118475
118765
|
const message = error instanceof Error ? error.message : String(error);
|
|
118476
118766
|
throw new ContextError(ExitCode.UserError, `review payload file cannot be read: ${filePath2}`, {
|
|
@@ -118729,7 +119019,7 @@ async function runReviewApproveAllCommand(input) {
|
|
|
118729
119019
|
}
|
|
118730
119020
|
});
|
|
118731
119021
|
const scope2 = scoped2.collection ?? "all";
|
|
118732
|
-
const confirmedReport = typeof confirmedScope?.report_path === "string" &&
|
|
119022
|
+
const confirmedReport = typeof confirmedScope?.report_path === "string" && existsSync31(confirmedScope.report_path) ? confirmedScope.report_path : undefined;
|
|
118733
119023
|
const shown = report?.path ?? confirmedReport;
|
|
118734
119024
|
const reportPath2 = shown ? await archiveAppliedReviewReport(projectRoot, shown, scope2) : undefined;
|
|
118735
119025
|
return { scoped: scoped2, reportPath: reportPath2, result: result2 };
|
|
@@ -119073,7 +119363,7 @@ init_cliFeedback();
|
|
|
119073
119363
|
init_errors3();
|
|
119074
119364
|
init_exitCode();
|
|
119075
119365
|
var import_yaml53 = __toESM(require_dist(), 1);
|
|
119076
|
-
import { readFile as
|
|
119366
|
+
import { readFile as readFile102 } from "node:fs/promises";
|
|
119077
119367
|
function userInputError2(message, detail = {}) {
|
|
119078
119368
|
return new ContextError(ExitCode.UserError, message, {
|
|
119079
119369
|
category: ErrorCategory.UserInputInvalid,
|
|
@@ -119142,7 +119432,7 @@ async function readPayloadTextFromStdin(stdin) {
|
|
|
119142
119432
|
}
|
|
119143
119433
|
async function readPayloadText(path3) {
|
|
119144
119434
|
if (path3 !== "-")
|
|
119145
|
-
return
|
|
119435
|
+
return readFile102(path3, "utf8");
|
|
119146
119436
|
return readPayloadTextFromStdin(process.stdin);
|
|
119147
119437
|
}
|
|
119148
119438
|
function unquotedColonText(message) {
|
|
@@ -119472,8 +119762,8 @@ init_exitCode();
|
|
|
119472
119762
|
init_maintenanceStorage();
|
|
119473
119763
|
init_productionFeedback();
|
|
119474
119764
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
119475
|
-
import { readFile as
|
|
119476
|
-
import { join as
|
|
119765
|
+
import { readFile as readFile103 } from "node:fs/promises";
|
|
119766
|
+
import { join as join125 } from "node:path";
|
|
119477
119767
|
async function beginProductionRevision(input) {
|
|
119478
119768
|
return withProductionFeedback({ operation: "revision" }, () => withProjectWriteLock(input.projectRoot, "production-revision", async () => {
|
|
119479
119769
|
await recoverDurableMultiFileTransactions(input.projectRoot);
|
|
@@ -119512,7 +119802,7 @@ async function beginProductionRevision(input) {
|
|
|
119512
119802
|
const formal = approved.byPath.get(path3);
|
|
119513
119803
|
if (!prior && !formal)
|
|
119514
119804
|
throw invalid3("Write the current task first; there is no article draft to revise yet.");
|
|
119515
|
-
const markdown = prior?.body ?? await
|
|
119805
|
+
const markdown = prior?.body ?? await readFile103(await safeProjectTarget(input.projectRoot, join125("knowledge", path3)), "utf8");
|
|
119516
119806
|
const sections = prior?.indexer_candidate.sections.map((section) => ({ id: section.section_key, references: section.references })) ?? formal?.sections;
|
|
119517
119807
|
const sources = [];
|
|
119518
119808
|
for (const source2 of owner.sources) {
|
|
@@ -119969,6 +120259,7 @@ init_workspaceChangelog();
|
|
|
119969
120259
|
init_status();
|
|
119970
120260
|
init_workflowCommandOptions();
|
|
119971
120261
|
init_workflowExecutionContext();
|
|
120262
|
+
init_sdkAlignment();
|
|
119972
120263
|
function registerVersionCommands(program2) {
|
|
119973
120264
|
const command3 = program2.command("version").description("Inspect formal changes and record a knowledge workspace SemVer and changelog");
|
|
119974
120265
|
command3.command("inspect").option("--base <ref>", "Git commit or tag to compare; defaults to the current version tag or HEAD").option("--format <format>", "json", "json").action(async (options) => {
|
|
@@ -119979,8 +120270,10 @@ function registerVersionCommands(program2) {
|
|
|
119979
120270
|
const first = status.version === "0.0.0";
|
|
119980
120271
|
const [major, minor, patch] = status.version.split(".").map(Number);
|
|
119981
120272
|
const suggested = status.reusable_version ?? (first ? "0.1.0" : `${major}.${minor}.${patch + 1}`);
|
|
120273
|
+
const sdkAlignment = await inspectSdkAlignment(root2);
|
|
119982
120274
|
process.stdout.write(JSON.stringify({
|
|
119983
120275
|
...status,
|
|
120276
|
+
...sdkAlignment ? { version_alignment: sdkAlignment } : {},
|
|
119984
120277
|
next_action: { command: "context version record --input <file> --format json" },
|
|
119985
120278
|
input_example: {
|
|
119986
120279
|
expected_digest: status.expected_digest,
|
|
@@ -120032,7 +120325,8 @@ function registerVersionCommands(program2) {
|
|
|
120032
120325
|
...execution,
|
|
120033
120326
|
...resourceReceipts === undefined ? {} : { resourceReceipts }
|
|
120034
120327
|
});
|
|
120035
|
-
|
|
120328
|
+
const sdkAlignment = await inspectSdkAlignment(root2);
|
|
120329
|
+
result = { version: recorded.version, outcome: recorded.outcome ?? "recorded", ...sdkAlignment ? { version_alignment: sdkAlignment } : {}, workflow: status.workflow };
|
|
120036
120330
|
} catch (error) {
|
|
120037
120331
|
result = { ...recorded, next_action: { command: workflowStatusCommand(execution) }, outcome: recorded.outcome ?? "recorded", next_preparation: {
|
|
120038
120332
|
message: error instanceof Error ? error.message : String(error),
|
|
@@ -120046,7 +120340,7 @@ function registerVersionCommands(program2) {
|
|
|
120046
120340
|
|
|
120047
120341
|
// src/commands/translateCommands.ts
|
|
120048
120342
|
init_workspace();
|
|
120049
|
-
import { isAbsolute as isAbsolute22, join as
|
|
120343
|
+
import { isAbsolute as isAbsolute22, join as join129 } from "node:path";
|
|
120050
120344
|
init_status();
|
|
120051
120345
|
init_workflowCommandOptions();
|
|
120052
120346
|
init_workflowExecutionContext();
|
|
@@ -120140,7 +120434,7 @@ function registerTranslateCommands(program2) {
|
|
|
120140
120434
|
readFailureNext: "Check the input path",
|
|
120141
120435
|
parseFailureNext: "Use valid YAML or JSON"
|
|
120142
120436
|
}));
|
|
120143
|
-
const saved = await submitSiteTranslation(root2, await projectPackages(root2), value, (file) => isAbsolute22(file) ? file :
|
|
120437
|
+
const saved = await submitSiteTranslation(root2, await projectPackages(root2), value, (file) => isAbsolute22(file) ? file : join129(root2, file));
|
|
120144
120438
|
write(await withWorkflow(root2, { outcome: "submitted", ...saved }));
|
|
120145
120439
|
});
|
|
120146
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) => {
|
|
@@ -120238,7 +120532,7 @@ init_workflowRouteOutput();
|
|
|
120238
120532
|
var import_yaml57 = __toESM(require_dist(), 1);
|
|
120239
120533
|
import { Buffer as Buffer5 } from "node:buffer";
|
|
120240
120534
|
import { createHash as createHash41 } from "node:crypto";
|
|
120241
|
-
import { join as
|
|
120535
|
+
import { join as join131 } from "node:path";
|
|
120242
120536
|
var INLINE_LIMIT = 16 * 1024;
|
|
120243
120537
|
function record4(value) {
|
|
120244
120538
|
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : undefined;
|
|
@@ -120264,8 +120558,8 @@ async function prepareActionCompletionOutput(input) {
|
|
|
120264
120558
|
if (production && Buffer5.byteLength(full) <= INLINE_LIMIT)
|
|
120265
120559
|
return input.result;
|
|
120266
120560
|
const digest8 = createHash41("sha256").update(full).digest("hex");
|
|
120267
|
-
const root2 =
|
|
120268
|
-
const resultFile =
|
|
120561
|
+
const root2 = join131(input.projectRoot, ".tmp/context-runtime/action-results");
|
|
120562
|
+
const resultFile = join131(root2, `${digest8}.json`);
|
|
120269
120563
|
await atomicWriteFile(resultFile, full);
|
|
120270
120564
|
if (production)
|
|
120271
120565
|
return {
|
|
@@ -120546,10 +120840,10 @@ function registerProjectActionCommands(program2) {
|
|
|
120546
120840
|
|
|
120547
120841
|
// src/commands/cleanClaudePluginCache.ts
|
|
120548
120842
|
init_cliFeedback();
|
|
120549
|
-
import { existsSync as
|
|
120843
|
+
import { existsSync as existsSync33 } from "node:fs";
|
|
120550
120844
|
import { readdir as readdir31, rm as rm30 } from "node:fs/promises";
|
|
120551
120845
|
import { homedir } from "node:os";
|
|
120552
|
-
import { join as
|
|
120846
|
+
import { join as join132 } from "node:path";
|
|
120553
120847
|
var ORPHAN_MARKER = ".orphaned_at";
|
|
120554
120848
|
var CLAUDE_PLUGIN_CACHE_ROOT_ENV = "C4A_CLAUDE_PLUGIN_CACHE_ROOT";
|
|
120555
120849
|
var CLAUDE_PLUGIN_CACHE_HOME_ENV = "C4A_CLAUDE_PLUGIN_CACHE_HOME";
|
|
@@ -120558,7 +120852,7 @@ async function cleanClaudePluginCache(opts = {}) {
|
|
|
120558
120852
|
const lines = [];
|
|
120559
120853
|
let removed = 0;
|
|
120560
120854
|
let scanned = 0;
|
|
120561
|
-
if (!
|
|
120855
|
+
if (!existsSync33(cacheRoot)) {
|
|
120562
120856
|
lines.push("· claude plugin cache: missing — nothing to clean");
|
|
120563
120857
|
return { lines, removed, scanned };
|
|
120564
120858
|
}
|
|
@@ -120566,20 +120860,20 @@ async function cleanClaudePluginCache(opts = {}) {
|
|
|
120566
120860
|
for (const mp of marketplaces) {
|
|
120567
120861
|
if (!mp.isDirectory())
|
|
120568
120862
|
continue;
|
|
120569
|
-
const mpDir =
|
|
120863
|
+
const mpDir = join132(cacheRoot, mp.name);
|
|
120570
120864
|
const plugins = await readdir31(mpDir, { withFileTypes: true });
|
|
120571
120865
|
for (const pl of plugins) {
|
|
120572
120866
|
if (!pl.isDirectory())
|
|
120573
120867
|
continue;
|
|
120574
|
-
const plDir =
|
|
120868
|
+
const plDir = join132(mpDir, pl.name);
|
|
120575
120869
|
const versions = await readdir31(plDir, { withFileTypes: true });
|
|
120576
120870
|
for (const ver of versions) {
|
|
120577
120871
|
if (!ver.isDirectory())
|
|
120578
120872
|
continue;
|
|
120579
120873
|
scanned += 1;
|
|
120580
|
-
const verDir =
|
|
120581
|
-
const markerPath =
|
|
120582
|
-
if (!
|
|
120874
|
+
const verDir = join132(plDir, ver.name);
|
|
120875
|
+
const markerPath = join132(verDir, ORPHAN_MARKER);
|
|
120876
|
+
if (!existsSync33(markerPath))
|
|
120583
120877
|
continue;
|
|
120584
120878
|
const label2 = `${mp.name}/${pl.name}/${ver.name}`;
|
|
120585
120879
|
if (opts.dryRun) {
|
|
@@ -120610,7 +120904,7 @@ function resolveClaudePluginCacheRoot(opts) {
|
|
|
120610
120904
|
if (explicitRoot)
|
|
120611
120905
|
return explicitRoot;
|
|
120612
120906
|
const home = opts.home ?? process.env[CLAUDE_PLUGIN_CACHE_HOME_ENV] ?? homedir();
|
|
120613
|
-
return
|
|
120907
|
+
return join132(home, ".claude", "plugins", "cache");
|
|
120614
120908
|
}
|
|
120615
120909
|
async function isEmptyDir(dir) {
|
|
120616
120910
|
try {
|
|
@@ -120646,7 +120940,7 @@ init_statusCommand();
|
|
|
120646
120940
|
// src/project/sourceCommands.ts
|
|
120647
120941
|
init_repoContentLinks();
|
|
120648
120942
|
init_src2();
|
|
120649
|
-
import { readFile as
|
|
120943
|
+
import { readFile as readFile118 } from "node:fs/promises";
|
|
120650
120944
|
import { isAbsolute as isAbsolute26, resolve as resolve49 } from "node:path";
|
|
120651
120945
|
init_cliFeedback();
|
|
120652
120946
|
init_errors3();
|
|
@@ -120663,7 +120957,7 @@ init_repoSources();
|
|
|
120663
120957
|
init_repoSourceRegistry();
|
|
120664
120958
|
init_writeLock();
|
|
120665
120959
|
import { execFile as execFile19 } from "node:child_process";
|
|
120666
|
-
import { existsSync as
|
|
120960
|
+
import { existsSync as existsSync34 } from "node:fs";
|
|
120667
120961
|
import { lstat as lstat19, mkdir as mkdir42, readlink as readlink3, realpath as realpath16, rm as rm31, symlink as symlink5 } from "node:fs/promises";
|
|
120668
120962
|
import { basename as basename12, dirname as dirname51, isAbsolute as isAbsolute23, relative as relative34, resolve as resolve43 } from "node:path";
|
|
120669
120963
|
import { promisify as promisify16 } from "node:util";
|
|
@@ -120820,7 +121114,7 @@ async function git4(cwd, args) {
|
|
|
120820
121114
|
}
|
|
120821
121115
|
async function resolveGitRoot2(path3) {
|
|
120822
121116
|
const root2 = await git4(path3, ["rev-parse", "--show-toplevel"]);
|
|
120823
|
-
if (root2.length === 0 || !
|
|
121117
|
+
if (root2.length === 0 || !existsSync34(root2)) {
|
|
120824
121118
|
throw userInputError3(`local repository path is not a Git checkout: ${path3}`, { path: path3 });
|
|
120825
121119
|
}
|
|
120826
121120
|
return realpath16(root2);
|
|
@@ -120845,7 +121139,7 @@ async function verifyCheckout(input) {
|
|
|
120845
121139
|
}
|
|
120846
121140
|
async function cloneCheckout(input) {
|
|
120847
121141
|
const target = resolve43(input.projectRoot, input.target ?? `.tmp/repo/${repositorySlug(input.remote)}-${input.ref.slice(0, 12)}`);
|
|
120848
|
-
if (
|
|
121142
|
+
if (existsSync34(target)) {
|
|
120849
121143
|
throw userInputError3(`clone target already exists: ${target}`, {
|
|
120850
121144
|
target,
|
|
120851
121145
|
next: `Use local mode with path ${JSON.stringify(target)} after inspecting the existing checkout.`
|
|
@@ -121013,17 +121307,17 @@ async function restoreRepositorySources(input) {
|
|
|
121013
121307
|
// src/project/sourceDocumentStatus.ts
|
|
121014
121308
|
init_src2();
|
|
121015
121309
|
init_documentCapture();
|
|
121016
|
-
import { existsSync as
|
|
121017
|
-
import { readFile as
|
|
121018
|
-
import { join as
|
|
121310
|
+
import { existsSync as existsSync35 } from "node:fs";
|
|
121311
|
+
import { readFile as readFile108 } from "node:fs/promises";
|
|
121312
|
+
import { join as join134 } from "node:path";
|
|
121019
121313
|
|
|
121020
121314
|
// src/project/sourceCommandViews.ts
|
|
121021
121315
|
init_fileSourceOrigins();
|
|
121022
121316
|
init_documentSiteDetection();
|
|
121023
121317
|
init_workspace();
|
|
121024
121318
|
init_documentBatchManifest();
|
|
121025
|
-
import { readFile as
|
|
121026
|
-
import { join as
|
|
121319
|
+
import { readFile as readFile107 } from "node:fs/promises";
|
|
121320
|
+
import { join as join133 } from "node:path";
|
|
121027
121321
|
function repoSourceAgentView(source2) {
|
|
121028
121322
|
return {
|
|
121029
121323
|
id: source2.id ?? source2.name,
|
|
@@ -121088,7 +121382,7 @@ async function fileSourceAgentViewWithNextAction(input) {
|
|
|
121088
121382
|
};
|
|
121089
121383
|
}
|
|
121090
121384
|
function documentSourceManifestPath(source2) {
|
|
121091
|
-
return source2.snapshot?.manifest ??
|
|
121385
|
+
return source2.snapshot?.manifest ?? join133(source2.materializedAt, "manifest.json");
|
|
121092
121386
|
}
|
|
121093
121387
|
async function fileSourceDocumentSiteHint(input) {
|
|
121094
121388
|
const detection = await detectDocumentSiteFiles({
|
|
@@ -121098,7 +121392,7 @@ async function fileSourceDocumentSiteHint(input) {
|
|
|
121098
121392
|
let snapshotConfigured = false;
|
|
121099
121393
|
const manifest = documentSourceManifestPath(input.source);
|
|
121100
121394
|
try {
|
|
121101
|
-
const parsed = parseDocumentSnapshotForSource(JSON.parse(await
|
|
121395
|
+
const parsed = parseDocumentSnapshotForSource(JSON.parse(await readFile107(join133(input.projectRoot, manifest), "utf8")), input.source.name);
|
|
121102
121396
|
snapshotConfigured = manifestUsesMdxJsonDocs(parsed);
|
|
121103
121397
|
} catch {
|
|
121104
121398
|
snapshotConfigured = false;
|
|
@@ -121131,12 +121425,12 @@ async function larkSourceAgentViewWithNextAction(input) {
|
|
|
121131
121425
|
init_documentBatchManifest();
|
|
121132
121426
|
init_documentSnapshotFidelity();
|
|
121133
121427
|
function documentSourceManifestPath2(source2) {
|
|
121134
|
-
return source2.snapshot?.manifest ??
|
|
121428
|
+
return source2.snapshot?.manifest ?? join134(source2.materializedAt, "manifest.json");
|
|
121135
121429
|
}
|
|
121136
121430
|
async function documentSnapshotState(input) {
|
|
121137
121431
|
const manifest = documentSourceManifestPath2(input.source);
|
|
121138
|
-
const manifestPath =
|
|
121139
|
-
if (!
|
|
121432
|
+
const manifestPath = join134(input.projectRoot, manifest);
|
|
121433
|
+
if (!existsSync35(manifestPath)) {
|
|
121140
121434
|
return {
|
|
121141
121435
|
snapshotReady: false,
|
|
121142
121436
|
state: "needs-capture",
|
|
@@ -121146,7 +121440,7 @@ async function documentSnapshotState(input) {
|
|
|
121146
121440
|
};
|
|
121147
121441
|
}
|
|
121148
121442
|
try {
|
|
121149
|
-
const parsed = findDocumentSnapshotForSource(JSON.parse(await
|
|
121443
|
+
const parsed = findDocumentSnapshotForSource(JSON.parse(await readFile108(manifestPath, "utf8")), input.source.name);
|
|
121150
121444
|
if (parsed === null) {
|
|
121151
121445
|
return {
|
|
121152
121446
|
snapshotReady: false,
|
|
@@ -121214,7 +121508,7 @@ async function documentSnapshotState(input) {
|
|
|
121214
121508
|
const missing2 = [
|
|
121215
121509
|
...parsed.files.map((file) => file.path),
|
|
121216
121510
|
...(parsed.assets ?? []).filter((asset) => asset.content_hash !== undefined).map((asset) => asset.path)
|
|
121217
|
-
].find((path3) => !
|
|
121511
|
+
].find((path3) => !existsSync35(join134(input.projectRoot, input.source.materializedAt, path3)));
|
|
121218
121512
|
if (missing2 !== undefined) {
|
|
121219
121513
|
return {
|
|
121220
121514
|
snapshotReady: false,
|
|
@@ -121315,8 +121609,8 @@ init_errors3();
|
|
|
121315
121609
|
init_exitCode();
|
|
121316
121610
|
var import_yaml59 = __toESM(require_dist(), 1);
|
|
121317
121611
|
import { createHash as createHash42 } from "node:crypto";
|
|
121318
|
-
import { readFile as
|
|
121319
|
-
import { basename as basename13, extname as extname15, isAbsolute as isAbsolute24, join as
|
|
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";
|
|
121320
121614
|
init_writeLock();
|
|
121321
121615
|
var SOURCE_NAME_PATTERN3 = /^[a-z0-9][a-z0-9._-]*$/u;
|
|
121322
121616
|
function isDateSourceNamespace(value) {
|
|
@@ -121412,7 +121706,7 @@ function assertSafeFileInclude(value) {
|
|
|
121412
121706
|
}
|
|
121413
121707
|
async function readRegistryDocument(projectRoot2, registryPath2) {
|
|
121414
121708
|
try {
|
|
121415
|
-
const content3 = await
|
|
121709
|
+
const content3 = await readFile109(join135(projectRoot2, registryPath2), "utf8");
|
|
121416
121710
|
return content3.trim().length === 0 ? { sources: [] } : import_yaml59.default.parse(content3);
|
|
121417
121711
|
} catch (error) {
|
|
121418
121712
|
if (error instanceof Error && "code" in error && error.code === "ENOENT")
|
|
@@ -121502,10 +121796,10 @@ function flatRawSource(sources, name3) {
|
|
|
121502
121796
|
}
|
|
121503
121797
|
async function ensureOriginInstallRootIgnored(projectRoot2, kind) {
|
|
121504
121798
|
const line = `${fileSourceOriginInstallRoot(kind)}/`;
|
|
121505
|
-
const path3 =
|
|
121799
|
+
const path3 = join135(projectRoot2, ".gitignore");
|
|
121506
121800
|
let current3 = "";
|
|
121507
121801
|
try {
|
|
121508
|
-
current3 = await
|
|
121802
|
+
current3 = await readFile109(path3, "utf8");
|
|
121509
121803
|
} catch {
|
|
121510
121804
|
current3 = "";
|
|
121511
121805
|
}
|
|
@@ -121603,7 +121897,7 @@ async function addFileSourceUnlocked(input) {
|
|
|
121603
121897
|
sourceName: input.name
|
|
121604
121898
|
});
|
|
121605
121899
|
}
|
|
121606
|
-
await atomicWriteFile(
|
|
121900
|
+
await atomicWriteFile(join135(input.projectRoot, DEFAULT_FILE_SOURCES_REGISTRY_PATH), import_yaml59.default.stringify({ sources: nextSources }));
|
|
121607
121901
|
const gitignoreUpdated = origin !== undefined && await ensureOriginInstallRootIgnored(input.projectRoot, origin.kind);
|
|
121608
121902
|
const updated = await loadSourcesRegistry({ rootDir: input.projectRoot });
|
|
121609
121903
|
const entry = updated.files.find((source2) => source2.name === input.name || source2.id === input.name);
|
|
@@ -121664,7 +121958,7 @@ async function addLarkSourceUnlocked(input) {
|
|
|
121664
121958
|
const record6 = entry2;
|
|
121665
121959
|
return record6.name !== input.name && record6.id !== input.name;
|
|
121666
121960
|
}), nextEntry];
|
|
121667
|
-
await atomicWriteFile(
|
|
121961
|
+
await atomicWriteFile(join135(input.projectRoot, DEFAULT_LARK_SOURCES_REGISTRY_PATH), import_yaml59.default.stringify({ sources: nextSources }));
|
|
121668
121962
|
const updated = await loadSourcesRegistry({ rootDir: input.projectRoot });
|
|
121669
121963
|
const entry = updated.larks.find((source2) => source2.name === input.name || source2.id === input.name);
|
|
121670
121964
|
if (entry === undefined) {
|
|
@@ -121696,18 +121990,18 @@ init_cliFeedback();
|
|
|
121696
121990
|
init_errors3();
|
|
121697
121991
|
init_exitCode();
|
|
121698
121992
|
var import_yaml60 = __toESM(require_dist(), 1);
|
|
121699
|
-
import { readFile as
|
|
121700
|
-
import { join as
|
|
121993
|
+
import { readFile as readFile110 } from "node:fs/promises";
|
|
121994
|
+
import { join as join136 } from "node:path";
|
|
121701
121995
|
import { isDeepStrictEqual as isDeepStrictEqual3 } from "node:util";
|
|
121702
121996
|
function identityKeys(entry) {
|
|
121703
121997
|
return new Set([entry.name, entry.id]);
|
|
121704
121998
|
}
|
|
121705
121999
|
async function createLarkBatchRegistration(projectRoot2, namespace) {
|
|
121706
122000
|
const registry2 = await loadSourcesRegistry({ rootDir: projectRoot2 });
|
|
121707
|
-
const registryPath2 =
|
|
122001
|
+
const registryPath2 = join136(projectRoot2, DEFAULT_LARK_SOURCES_REGISTRY_PATH);
|
|
121708
122002
|
let committedSources;
|
|
121709
122003
|
try {
|
|
121710
|
-
const text12 = await
|
|
122004
|
+
const text12 = await readFile110(registryPath2, "utf8");
|
|
121711
122005
|
committedSources = text12.trim().length === 0 ? [] : import_yaml60.default.parse(text12).sources ?? [];
|
|
121712
122006
|
} catch (error) {
|
|
121713
122007
|
if (!(error instanceof Error && ("code" in error) && error.code === "ENOENT"))
|
|
@@ -121825,8 +122119,8 @@ init_cliFeedback();
|
|
|
121825
122119
|
init_errors3();
|
|
121826
122120
|
init_exitCode();
|
|
121827
122121
|
import { createHash as createHash43 } from "node:crypto";
|
|
121828
|
-
import { lstat as lstat20, readFile as
|
|
121829
|
-
import { join as
|
|
122122
|
+
import { lstat as lstat20, readFile as readFile111 } from "node:fs/promises";
|
|
122123
|
+
import { join as join137, resolve as resolve45 } from "node:path";
|
|
121830
122124
|
var INPUT_SCHEMA = "context.source-batch.input.v1";
|
|
121831
122125
|
var STATE_SCHEMA = "context.source-batch.state.v1";
|
|
121832
122126
|
var RUNTIME_PARTS = [".tmp", "context-runtime", "source-batches"];
|
|
@@ -121877,14 +122171,14 @@ function paths(projectRoot2, jobId) {
|
|
|
121877
122171
|
throw journalError("source-batch-id-invalid", "Source batch checkpoint ID must contain exactly 32 lowercase hexadecimal characters.");
|
|
121878
122172
|
}
|
|
121879
122173
|
const directory = resolve45(projectRoot2, ...RUNTIME_PARTS, jobId);
|
|
121880
|
-
return { inputPath:
|
|
122174
|
+
return { inputPath: join137(directory, "input.json"), statePath: join137(directory, "state.json") };
|
|
121881
122175
|
}
|
|
121882
122176
|
async function assertJournalPath(projectRoot2, jobId, filename) {
|
|
121883
122177
|
paths(projectRoot2, jobId);
|
|
121884
122178
|
let current3 = resolve45(projectRoot2);
|
|
121885
122179
|
const parts = [...RUNTIME_PARTS, jobId, filename];
|
|
121886
122180
|
for (const [index3, part] of parts.entries()) {
|
|
121887
|
-
current3 =
|
|
122181
|
+
current3 = join137(current3, part);
|
|
121888
122182
|
let stat11;
|
|
121889
122183
|
try {
|
|
121890
122184
|
stat11 = await lstat20(current3);
|
|
@@ -121915,7 +122209,7 @@ async function loadSourceBatchJournal(input) {
|
|
|
121915
122209
|
const { inputPath } = paths(input.projectRoot, input.jobId);
|
|
121916
122210
|
try {
|
|
121917
122211
|
await assertJournalPath(input.projectRoot, input.jobId, "input.json");
|
|
121918
|
-
const stored = JSON.parse(await
|
|
122212
|
+
const stored = JSON.parse(await readFile111(inputPath, "utf8"));
|
|
121919
122213
|
if (stored === null || typeof stored !== "object" || Array.isArray(stored)) {
|
|
121920
122214
|
throw journalError("source-batch-input-invalid", "Source batch checkpoint input must be an object.");
|
|
121921
122215
|
}
|
|
@@ -122018,7 +122312,7 @@ async function readSourceBatchJournalStatus(input) {
|
|
|
122018
122312
|
let warning;
|
|
122019
122313
|
try {
|
|
122020
122314
|
await assertJournalPath(journal.projectRoot, journal.jobId, "state.json");
|
|
122021
|
-
const parsed = JSON.parse(await
|
|
122315
|
+
const parsed = JSON.parse(await readFile111(journal.statePath, "utf8"));
|
|
122022
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))) {
|
|
122023
122317
|
throw journalError("source-batch-state-invalid", "Source batch checkpoint progress is invalid.");
|
|
122024
122318
|
}
|
|
@@ -122616,13 +122910,13 @@ init_exitCode();
|
|
|
122616
122910
|
|
|
122617
122911
|
// src/project/wikiDiscovery.ts
|
|
122618
122912
|
import { mkdir as mkdir44 } from "node:fs/promises";
|
|
122619
|
-
import { join as
|
|
122913
|
+
import { join as join139, relative as relative37 } from "node:path";
|
|
122620
122914
|
|
|
122621
122915
|
// src/project/wikiDiscoveryStore.ts
|
|
122622
122916
|
init_atomicWrite();
|
|
122623
122917
|
import { createHash as createHash44, randomUUID as randomUUID9 } from "node:crypto";
|
|
122624
|
-
import { link as link2, lstat as lstat21, mkdir as mkdir43, readFile as
|
|
122625
|
-
import { join as
|
|
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";
|
|
122626
122920
|
function wikiDiscoveryDigest(value) {
|
|
122627
122921
|
return createHash44("sha256").update(value).digest("hex");
|
|
122628
122922
|
}
|
|
@@ -122636,7 +122930,7 @@ async function assertWikiDiscoveryPath(root2, path3) {
|
|
|
122636
122930
|
throw new WikiDiscoveryError("unsafe-checkpoint-path", false, "Discovery checkpoint must stay inside its workspace");
|
|
122637
122931
|
let current3 = base;
|
|
122638
122932
|
for (const part of parts) {
|
|
122639
|
-
current3 =
|
|
122933
|
+
current3 = join138(current3, part);
|
|
122640
122934
|
try {
|
|
122641
122935
|
if ((await lstat21(current3)).isSymbolicLink()) {
|
|
122642
122936
|
throw new WikiDiscoveryError("unsafe-checkpoint-path", false, "Discovery checkpoint paths must not contain symbolic links");
|
|
@@ -122652,7 +122946,7 @@ async function readWikiDiscoveryJson(path3) {
|
|
|
122652
122946
|
try {
|
|
122653
122947
|
if ((await lstat21(path3)).isSymbolicLink())
|
|
122654
122948
|
throw new WikiDiscoveryError("unsafe-checkpoint-path", false, "Discovery checkpoint must not be a symbolic link");
|
|
122655
|
-
return JSON.parse(await
|
|
122949
|
+
return JSON.parse(await readFile112(path3, "utf8"));
|
|
122656
122950
|
} catch (error) {
|
|
122657
122951
|
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT")
|
|
122658
122952
|
return;
|
|
@@ -122665,12 +122959,12 @@ async function saveWikiDiscoveryJson(path3, value) {
|
|
|
122665
122959
|
}
|
|
122666
122960
|
async function loadWikiDiscoveryReceipts(directory) {
|
|
122667
122961
|
const result = new Map;
|
|
122668
|
-
await assertWikiDiscoveryPath(directory,
|
|
122669
|
-
await mkdir43(
|
|
122670
|
-
for (const file of await readdir32(
|
|
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"))) {
|
|
122671
122965
|
if (!/^[a-f0-9]{64}\.json$/u.test(file))
|
|
122672
122966
|
continue;
|
|
122673
|
-
const value = await readWikiDiscoveryJson(
|
|
122967
|
+
const value = await readWikiDiscoveryJson(join138(directory, "pages", file));
|
|
122674
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) {
|
|
122675
122969
|
throw new WikiDiscoveryError("checkpoint-invalid", false, "Discovery page checkpoint is invalid; preserve it for inspection");
|
|
122676
122970
|
}
|
|
@@ -122689,14 +122983,14 @@ function ownerRunning(pid) {
|
|
|
122689
122983
|
}
|
|
122690
122984
|
}
|
|
122691
122985
|
async function acquireWikiDiscoveryLease(directory) {
|
|
122692
|
-
const leases =
|
|
122986
|
+
const leases = join138(directory, "leases");
|
|
122693
122987
|
await assertWikiDiscoveryPath(directory, leases);
|
|
122694
122988
|
await mkdir43(leases, { recursive: true });
|
|
122695
122989
|
for (let attempt = 0;attempt < 8; attempt++) {
|
|
122696
122990
|
const files = (await readdir32(leases)).filter((file) => /^\d{12}\.json$/u.test(file)).sort();
|
|
122697
122991
|
const latest = files.at(-1);
|
|
122698
122992
|
if (latest) {
|
|
122699
|
-
const current3 = await readWikiDiscoveryJson(
|
|
122993
|
+
const current3 = await readWikiDiscoveryJson(join138(leases, latest));
|
|
122700
122994
|
if (!current3 || !Number.isSafeInteger(current3.pid) || current3.pid <= 0 || typeof current3.token !== "string" || typeof current3.released !== "boolean") {
|
|
122701
122995
|
throw new WikiDiscoveryError("checkpoint-invalid", false, "Discovery lease is invalid; preserve it for inspection");
|
|
122702
122996
|
}
|
|
@@ -122705,9 +122999,9 @@ async function acquireWikiDiscoveryLease(directory) {
|
|
|
122705
122999
|
}
|
|
122706
123000
|
}
|
|
122707
123001
|
const sequence = latest ? Number(latest.slice(0, 12)) + 1 : 1;
|
|
122708
|
-
const path3 =
|
|
123002
|
+
const path3 = join138(leases, `${String(sequence).padStart(12, "0")}.json`);
|
|
122709
123003
|
const owner = { pid: process.pid, token: randomUUID9(), released: false };
|
|
122710
|
-
const temporary =
|
|
123004
|
+
const temporary = join138(leases, `.lease-${owner.token}`);
|
|
122711
123005
|
await writeFile33(temporary, JSON.stringify(owner), { flag: "wx", mode: 384 });
|
|
122712
123006
|
try {
|
|
122713
123007
|
await link2(temporary, path3);
|
|
@@ -122832,7 +123126,7 @@ async function discoverLarkWiki(input) {
|
|
|
122832
123126
|
throw new WikiDiscoveryError("invalid-concurrency", false, "Wiki concurrency must be an integer from 1 to 4");
|
|
122833
123127
|
}
|
|
122834
123128
|
const jobId = wikiDiscoveryDigest(url);
|
|
122835
|
-
const directory =
|
|
123129
|
+
const directory = join139(input.projectRoot, ".tmp", "context-runtime", "wiki-discovery", jobId);
|
|
122836
123130
|
await assertWikiDiscoveryPath(input.projectRoot, directory);
|
|
122837
123131
|
await mkdir44(directory, { recursive: true });
|
|
122838
123132
|
const release = await acquireWikiDiscoveryLease(directory);
|
|
@@ -122844,7 +123138,7 @@ async function discoverLarkWiki(input) {
|
|
|
122844
123138
|
}
|
|
122845
123139
|
async function runDiscovery(input, job) {
|
|
122846
123140
|
const { directory, url, identity: identity2 } = job;
|
|
122847
|
-
const metadataPath =
|
|
123141
|
+
const metadataPath = join139(directory, "job.json");
|
|
122848
123142
|
let metadata = await readWikiDiscoveryJson(metadataPath);
|
|
122849
123143
|
if (metadata && (metadata.protocol !== "context.wiki-discovery.v1" || metadata.url !== url || metadata.identity !== identity2)) {
|
|
122850
123144
|
throw new WikiDiscoveryError("job-identity-mismatch", false, "Resume must preserve the discovery's original URL and identity");
|
|
@@ -122893,7 +123187,7 @@ async function runDiscovery(input, job) {
|
|
|
122893
123187
|
}
|
|
122894
123188
|
const key = wikiDiscoveryPageKey(cursor);
|
|
122895
123189
|
try {
|
|
122896
|
-
await saveWikiDiscoveryJson(
|
|
123190
|
+
await saveWikiDiscoveryJson(join139(directory, "pages", `${key}.json`), receipt2);
|
|
122897
123191
|
receipts.set(key, receipt2);
|
|
122898
123192
|
} catch {
|
|
122899
123193
|
checkpointError = "A discovery page could not be checkpointed; saved pages remain reusable and unsaved pages must be requested again";
|
|
@@ -122911,7 +123205,7 @@ async function finishDiscovery(input, state) {
|
|
|
122911
123205
|
const { directory, url, identity: identity2, jobId, metadata, view } = state;
|
|
122912
123206
|
let checkpointError = state.checkpointError;
|
|
122913
123207
|
let status = input.signal?.aborted ? "paused" : checkpointError || view.pending.length || view.failed.length || !metadata.root ? "partial" : "completed";
|
|
122914
|
-
const manifestPath =
|
|
123208
|
+
const manifestPath = join139(directory, "manifest.json");
|
|
122915
123209
|
try {
|
|
122916
123210
|
await saveWikiDiscoveryJson(manifestPath, {
|
|
122917
123211
|
protocol: "context.wiki-discovery.manifest.v1",
|
|
@@ -123089,10 +123383,10 @@ init_documentBatchManifest();
|
|
|
123089
123383
|
init_workspace();
|
|
123090
123384
|
init_writeLock();
|
|
123091
123385
|
var import_yaml63 = __toESM(require_dist(), 1);
|
|
123092
|
-
import { existsSync as
|
|
123386
|
+
import { existsSync as existsSync36 } from "node:fs";
|
|
123093
123387
|
import { createHash as createHash45 } from "node:crypto";
|
|
123094
|
-
import { readFile as
|
|
123095
|
-
import { isAbsolute as isAbsolute25, join as
|
|
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";
|
|
123096
123390
|
function sourceIdentity(source2) {
|
|
123097
123391
|
if (source2.kind === "source.collection")
|
|
123098
123392
|
return;
|
|
@@ -123124,10 +123418,10 @@ function collectStrings(value, output) {
|
|
|
123124
123418
|
}
|
|
123125
123419
|
}
|
|
123126
123420
|
async function yamlReferences(input) {
|
|
123127
|
-
const absolutePath =
|
|
123128
|
-
if (!
|
|
123421
|
+
const absolutePath = join140(input.projectRoot, input.path);
|
|
123422
|
+
if (!existsSync36(absolutePath))
|
|
123129
123423
|
return false;
|
|
123130
|
-
const parsed = import_yaml63.default.parse(await
|
|
123424
|
+
const parsed = import_yaml63.default.parse(await readFile113(absolutePath, "utf8"));
|
|
123131
123425
|
const strings = [];
|
|
123132
123426
|
collectStrings(parsed, strings);
|
|
123133
123427
|
return strings.some((value) => stringReferencesSource(value, input.source));
|
|
@@ -123273,8 +123567,8 @@ async function registryRemovalWrite(projectRoot2, source2) {
|
|
|
123273
123567
|
const path3 = registryPath2(source2.type);
|
|
123274
123568
|
if (path3 === null)
|
|
123275
123569
|
return;
|
|
123276
|
-
const absolutePath =
|
|
123277
|
-
const document4 =
|
|
123570
|
+
const absolutePath = join140(projectRoot2, path3);
|
|
123571
|
+
const document4 = existsSync36(absolutePath) ? import_yaml63.default.parse(await readFile113(absolutePath, "utf8")) : { sources: [] };
|
|
123278
123572
|
return {
|
|
123279
123573
|
path: absolutePath,
|
|
123280
123574
|
bytes: import_yaml63.default.stringify(removeDocumentEntry(document4, source2))
|
|
@@ -123292,7 +123586,7 @@ function safeManagedMaterializedPath(projectRoot2, source2) {
|
|
|
123292
123586
|
return absolute;
|
|
123293
123587
|
}
|
|
123294
123588
|
function safeManagedManifestPath(projectRoot2, source2) {
|
|
123295
|
-
const manifest = source2.manifest ??
|
|
123589
|
+
const manifest = source2.manifest ?? join140(source2.materializedAt, "manifest.json");
|
|
123296
123590
|
if (isAbsolute25(manifest))
|
|
123297
123591
|
throw unsafeOwnership(source2, manifest);
|
|
123298
123592
|
const absolute = resolve47(projectRoot2, manifest);
|
|
@@ -123407,7 +123701,7 @@ async function createRemovalPlan(projectRoot2, selector) {
|
|
|
123407
123701
|
}
|
|
123408
123702
|
} else {
|
|
123409
123703
|
const materializedPath = safeManagedMaterializedPath(projectRoot2, source2);
|
|
123410
|
-
if (materializedPath !== undefined && sharedMaterializedBy.length === 0 &&
|
|
123704
|
+
if (materializedPath !== undefined && sharedMaterializedBy.length === 0 && existsSync36(materializedPath)) {
|
|
123411
123705
|
absoluteRemovals.push(materializedPath);
|
|
123412
123706
|
cleanup = {
|
|
123413
123707
|
mode: "exclusive-materialization",
|
|
@@ -123421,7 +123715,7 @@ async function createRemovalPlan(projectRoot2, selector) {
|
|
|
123421
123715
|
source: source2,
|
|
123422
123716
|
registry: registryPath2(source2.type),
|
|
123423
123717
|
registryBytes: registryWrite?.bytes ?? null,
|
|
123424
|
-
managedBytes: source2.type === "note" || source2.type === "sessions" ? await
|
|
123718
|
+
managedBytes: source2.type === "note" || source2.type === "sessions" ? await readFile113(absoluteRemovals[0], "utf8") : null,
|
|
123425
123719
|
references,
|
|
123426
123720
|
cleanup,
|
|
123427
123721
|
manifestBytes: manifestWrite?.bytes ?? null
|
|
@@ -123454,10 +123748,10 @@ function publicRemovalResult(plan, action) {
|
|
|
123454
123748
|
};
|
|
123455
123749
|
}
|
|
123456
123750
|
async function pruneExtractRuntime(projectRoot2, source2) {
|
|
123457
|
-
const fingerprintPath =
|
|
123751
|
+
const fingerprintPath = join140(projectRoot2, ".tmp/context-runtime/extract/source-fingerprints.json");
|
|
123458
123752
|
const removedPhaseIds = new Set;
|
|
123459
|
-
if (
|
|
123460
|
-
const parsed = JSON.parse(await
|
|
123753
|
+
if (existsSync36(fingerprintPath)) {
|
|
123754
|
+
const parsed = JSON.parse(await readFile113(fingerprintPath, "utf8"));
|
|
123461
123755
|
const phases = parsed.phases ?? {};
|
|
123462
123756
|
const next2 = Object.fromEntries(Object.entries(phases).filter(([phaseId, raw]) => {
|
|
123463
123757
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw))
|
|
@@ -123471,27 +123765,27 @@ async function pruneExtractRuntime(projectRoot2, source2) {
|
|
|
123471
123765
|
await atomicWriteFile(fingerprintPath, `${JSON.stringify({ ...parsed, phases: next2 }, null, 2)}
|
|
123472
123766
|
`);
|
|
123473
123767
|
}
|
|
123474
|
-
const phaseOwnershipPath =
|
|
123475
|
-
if (
|
|
123476
|
-
const parsed = JSON.parse(await
|
|
123768
|
+
const phaseOwnershipPath = join140(projectRoot2, ".tmp/context-runtime/extract/custom-phase-candidates.json");
|
|
123769
|
+
if (existsSync36(phaseOwnershipPath) && removedPhaseIds.size > 0) {
|
|
123770
|
+
const parsed = JSON.parse(await readFile113(phaseOwnershipPath, "utf8"));
|
|
123477
123771
|
const phases = Object.fromEntries(Object.entries(parsed.phases ?? {}).filter(([phaseId]) => !removedPhaseIds.has(phaseId)));
|
|
123478
123772
|
await atomicWriteFile(phaseOwnershipPath, `${JSON.stringify({ ...parsed, phases }, null, 2)}
|
|
123479
123773
|
`);
|
|
123480
123774
|
}
|
|
123481
|
-
const symbolPath =
|
|
123482
|
-
if (
|
|
123483
|
-
const parsed = JSON.parse(await
|
|
123775
|
+
const symbolPath = join140(projectRoot2, ".tmp/context-runtime/extract/source-symbols.json");
|
|
123776
|
+
if (existsSync36(symbolPath)) {
|
|
123777
|
+
const parsed = JSON.parse(await readFile113(symbolPath, "utf8"));
|
|
123484
123778
|
const symbols = Array.isArray(parsed.symbols) ? parsed.symbols.filter((entry) => entry === null || typeof entry !== "object" || Array.isArray(entry) || entry.source !== source2.name) : [];
|
|
123485
123779
|
const phaseFingerprints = Object.fromEntries(Object.entries(parsed.phaseFingerprints ?? {}).filter(([phaseId]) => !removedPhaseIds.has(phaseId)));
|
|
123486
123780
|
await atomicWriteFile(symbolPath, `${JSON.stringify({ ...parsed, phaseFingerprints, symbols }, null, 2)}
|
|
123487
123781
|
`);
|
|
123488
123782
|
}
|
|
123489
|
-
const snapshotRoot =
|
|
123783
|
+
const snapshotRoot = join140(projectRoot2, ".tmp/context-runtime/extract/candidates");
|
|
123490
123784
|
const visit4 = async (directory) => {
|
|
123491
|
-
if (!
|
|
123785
|
+
if (!existsSync36(directory))
|
|
123492
123786
|
return;
|
|
123493
123787
|
for (const entry of await readdir33(directory, { withFileTypes: true })) {
|
|
123494
|
-
const path3 =
|
|
123788
|
+
const path3 = join140(directory, entry.name);
|
|
123495
123789
|
if (entry.isDirectory()) {
|
|
123496
123790
|
await visit4(path3);
|
|
123497
123791
|
continue;
|
|
@@ -123499,7 +123793,7 @@ async function pruneExtractRuntime(projectRoot2, source2) {
|
|
|
123499
123793
|
if (!entry.isFile() || !entry.name.endsWith(".json"))
|
|
123500
123794
|
continue;
|
|
123501
123795
|
try {
|
|
123502
|
-
const parsed = JSON.parse(await
|
|
123796
|
+
const parsed = JSON.parse(await readFile113(path3, "utf8"));
|
|
123503
123797
|
const refs = Array.isArray(parsed.source_refs) ? parsed.source_refs : [];
|
|
123504
123798
|
if (parsed.source === source2.name || refs.some((ref2) => typeof ref2 === "string" && stringReferencesSource(ref2, source2))) {
|
|
123505
123799
|
await rm33(path3, { force: true });
|
|
@@ -123541,7 +123835,7 @@ async function removeProjectSource(input) {
|
|
|
123541
123835
|
});
|
|
123542
123836
|
}
|
|
123543
123837
|
await applyAtomicFileBatch({
|
|
123544
|
-
transactionRoot:
|
|
123838
|
+
transactionRoot: join140(input.projectRoot, ".tmp", "context-runtime", "source-remove-transactions"),
|
|
123545
123839
|
writes: [...plan.registryWrite === undefined ? [] : [plan.registryWrite], ...plan.manifestWrite !== undefined ? [plan.manifestWrite] : []],
|
|
123546
123840
|
removals: plan.absoluteRemovals
|
|
123547
123841
|
});
|
|
@@ -123557,7 +123851,7 @@ init_workspace();
|
|
|
123557
123851
|
init_writeLock();
|
|
123558
123852
|
init_durableMultiFileTransaction();
|
|
123559
123853
|
init_durableSingleFileTransaction();
|
|
123560
|
-
import { readFile as
|
|
123854
|
+
import { readFile as readFile114 } from "node:fs/promises";
|
|
123561
123855
|
import ts from "typescript";
|
|
123562
123856
|
function generateSourceConfiguration(text12, selected) {
|
|
123563
123857
|
const file = ts.createSourceFile("index.ts", text12, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
|
|
@@ -123697,7 +123991,7 @@ function generateSourceConfiguration(text12, selected) {
|
|
|
123697
123991
|
async function configureRegisteredSources(projectRoot2, selected) {
|
|
123698
123992
|
return withProjectWriteLock(projectRoot2, "source-project-configuration", async () => {
|
|
123699
123993
|
const path3 = "src/index.ts";
|
|
123700
|
-
const config = JSON.parse(await
|
|
123994
|
+
const config = JSON.parse(await readFile114(await safeProjectTarget(projectRoot2, "package.json"), "utf8"));
|
|
123701
123995
|
if (config.context?.entry !== path3)
|
|
123702
123996
|
return {
|
|
123703
123997
|
status: "manual",
|
|
@@ -123706,7 +124000,7 @@ async function configureRegisteredSources(projectRoot2, selected) {
|
|
|
123706
124000
|
sources: selected
|
|
123707
124001
|
};
|
|
123708
124002
|
const target = await safeProjectTarget(projectRoot2, path3);
|
|
123709
|
-
const text12 = await
|
|
124003
|
+
const text12 = await readFile114(target, "utf8");
|
|
123710
124004
|
const updated = generateSourceConfiguration(text12, selected);
|
|
123711
124005
|
if (updated === undefined)
|
|
123712
124006
|
return {
|
|
@@ -123742,7 +124036,7 @@ init_sourceInputMutation();
|
|
|
123742
124036
|
init_writeLock();
|
|
123743
124037
|
import { execFile as execFile20 } from "node:child_process";
|
|
123744
124038
|
import { promisify as promisify17 } from "node:util";
|
|
123745
|
-
import { join as
|
|
124039
|
+
import { join as join141 } from "node:path";
|
|
123746
124040
|
var exec6 = promisify17(execFile20);
|
|
123747
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();
|
|
123748
124042
|
async function restoreDocumentSnapshot(projectRoot2, value) {
|
|
@@ -123834,8 +124128,8 @@ async function restoreDocumentSnapshot(projectRoot2, value) {
|
|
|
123834
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)));
|
|
123835
124129
|
const removalTargets = await Promise.all(removals.map((path3) => safeProjectTarget(projectRoot2, path3)));
|
|
123836
124130
|
await applyAtomicFileBatch({
|
|
123837
|
-
transactionRoot:
|
|
123838
|
-
writes: [...selected.files].map(([path3, bytes]) => ({ path:
|
|
124131
|
+
transactionRoot: join141(projectRoot2, ".tmp/context-runtime/capture-transactions"),
|
|
124132
|
+
writes: [...selected.files].map(([path3, bytes]) => ({ path: join141(projectRoot2, path3), bytes })).concat([
|
|
123839
124133
|
{ path: manifestTarget, bytes: Buffer.from(renderDocumentManifestFile(next2)) }
|
|
123840
124134
|
]),
|
|
123841
124135
|
removals: removalTargets
|
|
@@ -123908,7 +124202,7 @@ async function readIncludeList(projectRoot2, path3) {
|
|
|
123908
124202
|
}
|
|
123909
124203
|
let content3;
|
|
123910
124204
|
try {
|
|
123911
|
-
content3 = await
|
|
124205
|
+
content3 = await readFile118(isAbsolute26(trimmed) ? resolve49(trimmed) : resolve49(projectRoot2, trimmed), "utf8");
|
|
123912
124206
|
} catch (error) {
|
|
123913
124207
|
throw new ContextError(ExitCode.UserError, `cannot read include list: ${trimmed}`, {
|
|
123914
124208
|
category: ErrorCategory.UserInputInvalid,
|
|
@@ -124368,13 +124662,13 @@ init_errors3();
|
|
|
124368
124662
|
init_cliFeedback();
|
|
124369
124663
|
init_exitCode();
|
|
124370
124664
|
var import_yaml66 = __toESM(require_dist(), 1);
|
|
124371
|
-
import { constants as constants6, existsSync as
|
|
124665
|
+
import { constants as constants6, existsSync as existsSync37 } from "node:fs";
|
|
124372
124666
|
import { lstat as lstat22, open as open5, readdir as readdir34 } from "node:fs/promises";
|
|
124373
|
-
import { dirname as dirname52, join as
|
|
124667
|
+
import { dirname as dirname52, join as join143, resolve as resolve50 } from "node:path";
|
|
124374
124668
|
import { fileURLToPath as fileURLToPath10 } from "node:url";
|
|
124375
124669
|
function bundledSkillRoot() {
|
|
124376
124670
|
const directory = dirname52(fileURLToPath10(import.meta.url));
|
|
124377
|
-
const root2 = [resolve50(directory, "indexers/bundles"), resolve50(directory, "../../dist/indexers/bundles")].find((path3) =>
|
|
124671
|
+
const root2 = [resolve50(directory, "indexers/bundles"), resolve50(directory, "../../dist/indexers/bundles")].find((path3) => existsSync37(path3));
|
|
124378
124672
|
if (!root2)
|
|
124379
124673
|
throw new TypeError("Bundled skill files are unavailable; build or reinstall the Context CLI.");
|
|
124380
124674
|
return root2;
|
|
@@ -124400,7 +124694,7 @@ async function readProductionSkills(root2) {
|
|
|
124400
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);
|
|
124401
124695
|
const skills = [];
|
|
124402
124696
|
for (const directory of entries2) {
|
|
124403
|
-
const entry =
|
|
124697
|
+
const entry = join143(root2, directory.name, "SKILL.md");
|
|
124404
124698
|
if (!(await lstat22(entry)).isFile())
|
|
124405
124699
|
throw new TypeError(`Skill entry must be a regular file: ${entry}`);
|
|
124406
124700
|
const handle3 = await open5(entry, constants6.O_RDONLY | constants6.O_NOFOLLOW | constants6.O_NONBLOCK);
|
|
@@ -124537,7 +124831,7 @@ init_exitCode();
|
|
|
124537
124831
|
// src/project/entryCommand.ts
|
|
124538
124832
|
init_workflowProvider();
|
|
124539
124833
|
init_workspace();
|
|
124540
|
-
import { existsSync as
|
|
124834
|
+
import { existsSync as existsSync38 } from "node:fs";
|
|
124541
124835
|
import { dirname as dirname53, resolve as resolve51 } from "node:path";
|
|
124542
124836
|
function shellQuote7(value) {
|
|
124543
124837
|
return /^[A-Za-z0-9._/=-]+$/u.test(value) ? value : `'${value.replaceAll("'", `'"'"'`)}'`;
|
|
@@ -124594,7 +124888,7 @@ function resolveContextEntry(input) {
|
|
|
124594
124888
|
const cwd = resolve51(input.cwd);
|
|
124595
124889
|
if (input.projectDir !== undefined) {
|
|
124596
124890
|
const target2 = resolveContextProjectInitTarget(cwd, input.projectDir);
|
|
124597
|
-
if (
|
|
124891
|
+
if (existsSync38(target2) && isContextProjectRoot(target2)) {
|
|
124598
124892
|
return readyResult(input, target2, target2 !== cwd);
|
|
124599
124893
|
}
|
|
124600
124894
|
return {
|
|
@@ -124603,7 +124897,7 @@ function resolveContextEntry(input) {
|
|
|
124603
124897
|
cwd,
|
|
124604
124898
|
workspace: {
|
|
124605
124899
|
root: target2,
|
|
124606
|
-
exists:
|
|
124900
|
+
exists: existsSync38(target2)
|
|
124607
124901
|
},
|
|
124608
124902
|
next_action: {
|
|
124609
124903
|
kind: "initialize-workspace",
|
|
@@ -124647,7 +124941,7 @@ function resolveContextEntry(input) {
|
|
|
124647
124941
|
cwd,
|
|
124648
124942
|
workspace: {
|
|
124649
124943
|
root: target,
|
|
124650
|
-
exists:
|
|
124944
|
+
exists: existsSync38(target)
|
|
124651
124945
|
},
|
|
124652
124946
|
next_action: {
|
|
124653
124947
|
kind: "initialize-workspace",
|
|
@@ -124814,8 +125108,8 @@ init_cliFeedback();
|
|
|
124814
125108
|
init_errors3();
|
|
124815
125109
|
init_exitCode();
|
|
124816
125110
|
import { createHash as createHash46 } from "node:crypto";
|
|
124817
|
-
import { cp as cp3, lstat as lstat23, mkdir as mkdir45, mkdtemp as mkdtemp7, readFile as
|
|
124818
|
-
import { dirname as dirname54, join as
|
|
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";
|
|
124819
125113
|
var MARKER = ".context-skill-install.json";
|
|
124820
125114
|
function conflict(path3) {
|
|
124821
125115
|
throw new ContextError(ExitCode.UserError, `Local skill install conflict: ${path3}`, {
|
|
@@ -124846,7 +125140,7 @@ async function digest9(root2) {
|
|
|
124846
125140
|
for (const name3 of (await readdir35(dir)).sort()) {
|
|
124847
125141
|
if (!prefix && name3 === MARKER)
|
|
124848
125142
|
continue;
|
|
124849
|
-
const path3 =
|
|
125143
|
+
const path3 = join144(dir, name3);
|
|
124850
125144
|
const entry = await lstat23(path3);
|
|
124851
125145
|
if (entry.isSymbolicLink())
|
|
124852
125146
|
conflict(path3);
|
|
@@ -124854,7 +125148,7 @@ async function digest9(root2) {
|
|
|
124854
125148
|
if (entry.isDirectory())
|
|
124855
125149
|
await visit4(path3, `${prefix}${name3}/`);
|
|
124856
125150
|
else if (entry.isFile())
|
|
124857
|
-
hash5.update(await
|
|
125151
|
+
hash5.update(await readFile119(path3));
|
|
124858
125152
|
else
|
|
124859
125153
|
conflict(path3);
|
|
124860
125154
|
}
|
|
@@ -124865,12 +125159,12 @@ async function digest9(root2) {
|
|
|
124865
125159
|
async function assertOwnedDirectory(target, existing) {
|
|
124866
125160
|
if (!existing.isDirectory() || existing.isSymbolicLink())
|
|
124867
125161
|
conflict(target);
|
|
124868
|
-
const markerPath =
|
|
125162
|
+
const markerPath = join144(target, MARKER);
|
|
124869
125163
|
if (!(await stat11(markerPath))?.isFile())
|
|
124870
125164
|
conflict(target);
|
|
124871
125165
|
let marker;
|
|
124872
125166
|
try {
|
|
124873
|
-
marker = JSON.parse(await
|
|
125167
|
+
marker = JSON.parse(await readFile119(markerPath, "utf8"));
|
|
124874
125168
|
} catch {
|
|
124875
125169
|
conflict(target);
|
|
124876
125170
|
}
|
|
@@ -124881,24 +125175,24 @@ async function installLocalSkills(root2, path3, dryRun, agent) {
|
|
|
124881
125175
|
if (!path3.trim())
|
|
124882
125176
|
conflict("--local requires a non-empty path");
|
|
124883
125177
|
const targetRoot = resolve52(path3);
|
|
124884
|
-
const skillsRoot =
|
|
125178
|
+
const skillsRoot = join144(targetRoot, "skills");
|
|
124885
125179
|
await checkParents(skillsRoot);
|
|
124886
|
-
const sourceRoot =
|
|
125180
|
+
const sourceRoot = join144(root2, "skills");
|
|
124887
125181
|
const commandPlans = [];
|
|
124888
125182
|
const commandEntries = new Set;
|
|
124889
125183
|
if (agent === "claude" || agent === "cursor") {
|
|
124890
|
-
for (const name3 of await readdir35(
|
|
125184
|
+
for (const name3 of await readdir35(join144(root2, "claude", "commands"))) {
|
|
124891
125185
|
if (name3.endsWith(".md"))
|
|
124892
125186
|
commandEntries.add(name3.slice(0, -3));
|
|
124893
125187
|
}
|
|
124894
|
-
const commandsRoot =
|
|
125188
|
+
const commandsRoot = join144(targetRoot, "commands");
|
|
124895
125189
|
await checkParents(commandsRoot);
|
|
124896
|
-
for (const entry of await readdir35(
|
|
125190
|
+
for (const entry of await readdir35(join144(root2, agent, "commands"), { withFileTypes: true })) {
|
|
124897
125191
|
if (!entry.isFile() || !entry.name.endsWith(".md"))
|
|
124898
125192
|
continue;
|
|
124899
|
-
const content3 = await
|
|
124900
|
-
const target =
|
|
124901
|
-
const marker =
|
|
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`);
|
|
124902
125196
|
for (const file of [target, marker]) {
|
|
124903
125197
|
const existing = await stat11(file);
|
|
124904
125198
|
if (existing && (!existing.isFile() || existing.isSymbolicLink()))
|
|
@@ -124907,11 +125201,11 @@ async function installLocalSkills(root2, path3, dryRun, agent) {
|
|
|
124907
125201
|
if (await stat11(target)) {
|
|
124908
125202
|
let previous3;
|
|
124909
125203
|
try {
|
|
124910
|
-
previous3 = JSON.parse(await
|
|
125204
|
+
previous3 = JSON.parse(await readFile119(marker, "utf8"));
|
|
124911
125205
|
} catch {
|
|
124912
125206
|
conflict(target);
|
|
124913
125207
|
}
|
|
124914
|
-
const current3 = createHash46("sha256").update(await
|
|
125208
|
+
const current3 = createHash46("sha256").update(await readFile119(target)).digest("hex");
|
|
124915
125209
|
if (previous3?.owner !== "context-plugin-local" || previous3.digest !== current3)
|
|
124916
125210
|
conflict(target);
|
|
124917
125211
|
} else if (await stat11(marker))
|
|
@@ -124919,14 +125213,14 @@ async function installLocalSkills(root2, path3, dryRun, agent) {
|
|
|
124919
125213
|
commandPlans.push({ name: entry.name, target, marker, content: content3, hash: createHash46("sha256").update(content3).digest("hex") });
|
|
124920
125214
|
}
|
|
124921
125215
|
if (!commandPlans.length)
|
|
124922
|
-
conflict(
|
|
125216
|
+
conflict(join144(root2, agent, "commands"));
|
|
124923
125217
|
}
|
|
124924
125218
|
const plans = [];
|
|
124925
125219
|
for (const entry of (await readdir35(sourceRoot, { withFileTypes: true })).sort((a2, b) => a2.name.localeCompare(b.name))) {
|
|
124926
|
-
if (!entry.isDirectory() || !await stat11(
|
|
125220
|
+
if (!entry.isDirectory() || !await stat11(join144(sourceRoot, entry.name, "SKILL.md")))
|
|
124927
125221
|
continue;
|
|
124928
|
-
const source2 =
|
|
124929
|
-
const target =
|
|
125222
|
+
const source2 = join144(sourceRoot, entry.name);
|
|
125223
|
+
const target = join144(skillsRoot, entry.name);
|
|
124930
125224
|
if (commandEntries.has(entry.name) && !["context-plan", "context-repo-content"].includes(entry.name)) {
|
|
124931
125225
|
if (await stat11(target))
|
|
124932
125226
|
conflict(`${target} (use a fresh host directory to avoid duplicate command/skill entries)`);
|
|
@@ -124940,16 +125234,16 @@ async function installLocalSkills(root2, path3, dryRun, agent) {
|
|
|
124940
125234
|
if (!plans.length)
|
|
124941
125235
|
conflict(sourceRoot);
|
|
124942
125236
|
const resourcePlans = [];
|
|
124943
|
-
const resourcesRoot =
|
|
125237
|
+
const resourcesRoot = join144(targetRoot, "resources");
|
|
124944
125238
|
if (agent === "claude" || agent === "cursor") {
|
|
124945
|
-
const resourceSource =
|
|
125239
|
+
const resourceSource = join144(root2, agent, "resources");
|
|
124946
125240
|
if (await stat11(resourceSource)) {
|
|
124947
125241
|
await checkParents(resourcesRoot);
|
|
124948
125242
|
for (const entry of (await readdir35(resourceSource, { withFileTypes: true })).sort((a2, b) => a2.name.localeCompare(b.name))) {
|
|
124949
125243
|
if (!entry.isDirectory())
|
|
124950
125244
|
continue;
|
|
124951
|
-
const source2 =
|
|
124952
|
-
const target =
|
|
125245
|
+
const source2 = join144(resourceSource, entry.name);
|
|
125246
|
+
const target = join144(resourcesRoot, entry.name);
|
|
124953
125247
|
const existing = await stat11(target);
|
|
124954
125248
|
if (existing)
|
|
124955
125249
|
await assertOwnedDirectory(target, existing);
|
|
@@ -124963,15 +125257,15 @@ async function installLocalSkills(root2, path3, dryRun, agent) {
|
|
|
124963
125257
|
await mkdir45(resourcesRoot, { recursive: true });
|
|
124964
125258
|
for (const plan of [...plans, ...resourcePlans]) {
|
|
124965
125259
|
const resource = resourcePlans.includes(plan);
|
|
124966
|
-
const staging = await mkdtemp7(
|
|
124967
|
-
const candidate =
|
|
124968
|
-
const previous3 =
|
|
125260
|
+
const staging = await mkdtemp7(join144(dirname54(plan.target), ".context-install-"));
|
|
125261
|
+
const candidate = join144(staging, "candidate");
|
|
125262
|
+
const previous3 = join144(staging, "previous");
|
|
124969
125263
|
let moved = false;
|
|
124970
125264
|
try {
|
|
124971
125265
|
await cp3(plan.source, candidate, { recursive: true });
|
|
124972
125266
|
if (!resource && (agent === "claude" || agent === "cursor" && ["context-plan", "context-repo-content"].includes(plan.name))) {
|
|
124973
|
-
const skillFile =
|
|
124974
|
-
const content3 = await
|
|
125267
|
+
const skillFile = join144(candidate, "SKILL.md");
|
|
125268
|
+
const content3 = await readFile119(skillFile, "utf8");
|
|
124975
125269
|
const parts = /^(---\r?\n)([\s\S]*?)(\r?\n---(?:\r?\n|$))/.exec(content3);
|
|
124976
125270
|
if (parts && (["context-plan", "context-repo-content"].includes(plan.name) || /^\s*context-public-entry:\s*["']?false["']?\s*$/mu.test(parts[2]))) {
|
|
124977
125271
|
const frontmatter2 = parts[2].replace(/^user-invocable:.*\r?\n?/mu, "");
|
|
@@ -124979,7 +125273,7 @@ async function installLocalSkills(root2, path3, dryRun, agent) {
|
|
|
124979
125273
|
${frontmatter2}${parts[3]}${content3.slice(parts[0].length)}`);
|
|
124980
125274
|
}
|
|
124981
125275
|
}
|
|
124982
|
-
await writeFile34(
|
|
125276
|
+
await writeFile34(join144(candidate, MARKER), JSON.stringify({ owner: "context-plugin-local", digest: await digest9(candidate) }) + `
|
|
124983
125277
|
`);
|
|
124984
125278
|
if (plan.exists) {
|
|
124985
125279
|
await rename12(plan.target, previous3);
|
|
@@ -125003,12 +125297,12 @@ ${frontmatter2}${parts[3]}${content3.slice(parts[0].length)}`);
|
|
|
125003
125297
|
}
|
|
125004
125298
|
for (const command3 of commandPlans) {
|
|
125005
125299
|
await mkdir45(dirname54(command3.target), { recursive: true });
|
|
125006
|
-
const staging = await mkdtemp7(
|
|
125007
|
-
await writeFile34(
|
|
125008
|
-
await writeFile34(
|
|
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 }) + `
|
|
125009
125303
|
`);
|
|
125010
|
-
await rename12(
|
|
125011
|
-
await rename12(
|
|
125304
|
+
await rename12(join144(staging, "command"), command3.target);
|
|
125305
|
+
await rename12(join144(staging, "marker"), command3.marker);
|
|
125012
125306
|
await rm34(staging, { recursive: true, force: true });
|
|
125013
125307
|
}
|
|
125014
125308
|
}
|
|
@@ -125033,10 +125327,10 @@ init_cliFeedback();
|
|
|
125033
125327
|
init_errors3();
|
|
125034
125328
|
init_exitCode();
|
|
125035
125329
|
import { lstat as lstat24 } from "node:fs/promises";
|
|
125036
|
-
import { join as
|
|
125330
|
+
import { join as join145, resolve as resolve53 } from "node:path";
|
|
125037
125331
|
var HOST_DIRS = { claude: ".claude", cursor: ".cursor", codex: ".agents" };
|
|
125038
125332
|
async function detectLocalAgent(agent, repo) {
|
|
125039
|
-
const path3 =
|
|
125333
|
+
const path3 = join145(repo, HOST_DIRS[agent]);
|
|
125040
125334
|
try {
|
|
125041
125335
|
const entry = await lstat24(path3);
|
|
125042
125336
|
if (!entry.isDirectory() || entry.isSymbolicLink()) {
|
|
@@ -125061,7 +125355,7 @@ async function installAutoLocalSkills(root2, path3, dryRun, detect = detectLocal
|
|
|
125061
125355
|
if (selectedAgent ? selectedAgent === "all" || agent === selectedAgent : await detect(agent, repo))
|
|
125062
125356
|
agents.push(agent);
|
|
125063
125357
|
}
|
|
125064
|
-
const targets = agents.length ? agents.map((agent) => ({ agent, path:
|
|
125358
|
+
const targets = agents.length ? agents.map((agent) => ({ agent, path: join145(repo, HOST_DIRS[agent]) })) : [{ path: join145(repo, ".agents") }];
|
|
125065
125359
|
const previews = [];
|
|
125066
125360
|
for (const target of targets)
|
|
125067
125361
|
previews.push(await installLocalSkills(root2, target.path, true, target.agent));
|
|
@@ -125093,8 +125387,8 @@ init_exitCode();
|
|
|
125093
125387
|
init_cliFeedback();
|
|
125094
125388
|
init_errors3();
|
|
125095
125389
|
init_exitCode();
|
|
125096
|
-
import { existsSync as
|
|
125097
|
-
import { dirname as dirname56, join as
|
|
125390
|
+
import { existsSync as existsSync40 } from "node:fs";
|
|
125391
|
+
import { dirname as dirname56, join as join147, resolve as resolve54 } from "node:path";
|
|
125098
125392
|
import { fileURLToPath as fileURLToPath11 } from "node:url";
|
|
125099
125393
|
|
|
125100
125394
|
// src/project/pluginInstallTargets.ts
|
|
@@ -125102,10 +125396,10 @@ init_cliFeedback();
|
|
|
125102
125396
|
init_errors3();
|
|
125103
125397
|
init_exitCode();
|
|
125104
125398
|
import { execFile as execFile21 } from "node:child_process";
|
|
125105
|
-
import { existsSync as
|
|
125106
|
-
import { cp as cp4, mkdir as mkdir46, readdir as readdir36, readFile as
|
|
125399
|
+
import { existsSync as existsSync39 } from "node:fs";
|
|
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";
|
|
125107
125401
|
import { homedir as homedir2 } from "node:os";
|
|
125108
|
-
import { dirname as dirname55, join as
|
|
125402
|
+
import { dirname as dirname55, join as join146 } from "node:path";
|
|
125109
125403
|
import { promisify as promisify18 } from "node:util";
|
|
125110
125404
|
var execFileAsync6 = promisify18(execFile21);
|
|
125111
125405
|
var MARKETPLACE_NAME = "c4a";
|
|
@@ -125159,23 +125453,23 @@ async function claudePluginInstalled(pluginId) {
|
|
|
125159
125453
|
}
|
|
125160
125454
|
}
|
|
125161
125455
|
function codexHome() {
|
|
125162
|
-
return process.env.CODEX_HOME?.trim() ||
|
|
125456
|
+
return process.env.CODEX_HOME?.trim() || join146(homedir2(), ".codex");
|
|
125163
125457
|
}
|
|
125164
125458
|
function claudePluginCacheRoot() {
|
|
125165
125459
|
const explicitRoot = process.env[CLAUDE_PLUGIN_CACHE_ROOT_ENV2]?.trim();
|
|
125166
125460
|
if (explicitRoot)
|
|
125167
125461
|
return explicitRoot;
|
|
125168
125462
|
const home = process.env[CLAUDE_PLUGIN_CACHE_HOME_ENV2]?.trim() || homedir2();
|
|
125169
|
-
return
|
|
125463
|
+
return join146(home, ".claude", "plugins", "cache");
|
|
125170
125464
|
}
|
|
125171
125465
|
function sharedSkillsRoot() {
|
|
125172
|
-
return process.env[SHARED_SKILLS_ROOT_ENV]?.trim() ||
|
|
125466
|
+
return process.env[SHARED_SKILLS_ROOT_ENV]?.trim() || join146(homedir2(), ".agents", "skills");
|
|
125173
125467
|
}
|
|
125174
125468
|
function claudeSkillsRoot() {
|
|
125175
|
-
return process.env[CLAUDE_SKILLS_ROOT_ENV]?.trim() ||
|
|
125469
|
+
return process.env[CLAUDE_SKILLS_ROOT_ENV]?.trim() || join146(homedir2(), ".claude", "skills");
|
|
125176
125470
|
}
|
|
125177
125471
|
function cursorPluginRoot() {
|
|
125178
|
-
return process.env[CURSOR_PLUGIN_ROOT_ENV]?.trim() ||
|
|
125472
|
+
return process.env[CURSOR_PLUGIN_ROOT_ENV]?.trim() || join146(homedir2(), ".cursor", "plugins", "local", PLUGIN_NAME);
|
|
125179
125473
|
}
|
|
125180
125474
|
function blockHeader(line) {
|
|
125181
125475
|
const match = line.match(/^\s*\[([^\]]+)\]\s*$/u);
|
|
@@ -125226,8 +125520,8 @@ function pruneLegacyCodexConfigContent(content3) {
|
|
|
125226
125520
|
`), removed };
|
|
125227
125521
|
}
|
|
125228
125522
|
async function pruneLegacyCodexConfig(dryRun, steps) {
|
|
125229
|
-
const configPath =
|
|
125230
|
-
const current3 = await
|
|
125523
|
+
const configPath = join146(codexHome(), "config.toml");
|
|
125524
|
+
const current3 = await readFile120(configPath, "utf8").catch(() => "");
|
|
125231
125525
|
if (!current3)
|
|
125232
125526
|
return;
|
|
125233
125527
|
const next2 = pruneLegacyCodexConfigContent(current3);
|
|
@@ -125243,8 +125537,8 @@ async function pruneLegacyCodexConfig(dryRun, steps) {
|
|
|
125243
125537
|
}
|
|
125244
125538
|
}
|
|
125245
125539
|
async function pruneCodexPluginCacheForName(pluginName, keepVersion, dryRun, steps) {
|
|
125246
|
-
const cacheRoot =
|
|
125247
|
-
if (!
|
|
125540
|
+
const cacheRoot = join146(codexHome(), "plugins", "cache", MARKETPLACE_NAME, pluginName);
|
|
125541
|
+
if (!existsSync39(cacheRoot))
|
|
125248
125542
|
return;
|
|
125249
125543
|
const versions = (await readdir36(cacheRoot, { withFileTypes: true }).catch(() => [])).filter((entry) => entry.isDirectory() && entry.name !== keepVersion).map((entry) => entry.name).sort();
|
|
125250
125544
|
if (versions.length === 0)
|
|
@@ -125255,7 +125549,7 @@ async function pruneCodexPluginCacheForName(pluginName, keepVersion, dryRun, ste
|
|
|
125255
125549
|
status: dryRun ? "planned" : "ran"
|
|
125256
125550
|
});
|
|
125257
125551
|
if (!dryRun)
|
|
125258
|
-
await Promise.all(versions.map((version3) => rm35(
|
|
125552
|
+
await Promise.all(versions.map((version3) => rm35(join146(cacheRoot, version3), { recursive: true, force: true })));
|
|
125259
125553
|
}
|
|
125260
125554
|
async function pruneCodexPluginCache(currentVersion, dryRun, steps) {
|
|
125261
125555
|
await pruneCodexPluginCacheForName(PLUGIN_NAME, currentVersion, dryRun, steps);
|
|
@@ -125272,22 +125566,22 @@ async function isEmptyDir2(dir) {
|
|
|
125272
125566
|
}
|
|
125273
125567
|
async function pruneClaudeOrphanContextCache(dryRun, steps) {
|
|
125274
125568
|
const cacheRoot = claudePluginCacheRoot();
|
|
125275
|
-
if (!
|
|
125569
|
+
if (!existsSync39(cacheRoot))
|
|
125276
125570
|
return;
|
|
125277
125571
|
const removed = [];
|
|
125278
125572
|
const marketplaces = await readdir36(cacheRoot, { withFileTypes: true }).catch(() => []);
|
|
125279
125573
|
for (const marketplace of marketplaces) {
|
|
125280
125574
|
if (!marketplace.isDirectory())
|
|
125281
125575
|
continue;
|
|
125282
|
-
const pluginDir =
|
|
125283
|
-
if (!
|
|
125576
|
+
const pluginDir = join146(cacheRoot, marketplace.name, PLUGIN_NAME);
|
|
125577
|
+
if (!existsSync39(pluginDir))
|
|
125284
125578
|
continue;
|
|
125285
125579
|
const versions = await readdir36(pluginDir, { withFileTypes: true }).catch(() => []);
|
|
125286
125580
|
for (const version3 of versions) {
|
|
125287
125581
|
if (!version3.isDirectory())
|
|
125288
125582
|
continue;
|
|
125289
|
-
const versionDir =
|
|
125290
|
-
if (!
|
|
125583
|
+
const versionDir = join146(pluginDir, version3.name);
|
|
125584
|
+
if (!existsSync39(join146(versionDir, ORPHAN_MARKER2)))
|
|
125291
125585
|
continue;
|
|
125292
125586
|
removed.push(`${marketplace.name}/${PLUGIN_NAME}/${version3.name}`);
|
|
125293
125587
|
if (!dryRun) {
|
|
@@ -125297,7 +125591,7 @@ async function pruneClaudeOrphanContextCache(dryRun, steps) {
|
|
|
125297
125591
|
if (!dryRun && await isEmptyDir2(pluginDir)) {
|
|
125298
125592
|
await rm35(pluginDir, { recursive: true, force: true });
|
|
125299
125593
|
}
|
|
125300
|
-
const marketplaceDir =
|
|
125594
|
+
const marketplaceDir = join146(cacheRoot, marketplace.name);
|
|
125301
125595
|
if (!dryRun && await isEmptyDir2(marketplaceDir)) {
|
|
125302
125596
|
await rm35(marketplaceDir, { recursive: true, force: true });
|
|
125303
125597
|
}
|
|
@@ -125314,12 +125608,12 @@ async function pruneClaudeLegacyPluginCache(dryRun, steps) {
|
|
|
125314
125608
|
if (LEGACY_PLUGIN_NAMES.length === 0)
|
|
125315
125609
|
return;
|
|
125316
125610
|
const cacheRoot = claudePluginCacheRoot();
|
|
125317
|
-
if (!
|
|
125611
|
+
if (!existsSync39(cacheRoot))
|
|
125318
125612
|
return;
|
|
125319
125613
|
const removed = [];
|
|
125320
125614
|
for (const pluginName of LEGACY_PLUGIN_NAMES) {
|
|
125321
|
-
const pluginDir =
|
|
125322
|
-
if (!
|
|
125615
|
+
const pluginDir = join146(cacheRoot, MARKETPLACE_NAME, pluginName);
|
|
125616
|
+
if (!existsSync39(pluginDir))
|
|
125323
125617
|
continue;
|
|
125324
125618
|
removed.push(`${MARKETPLACE_NAME}/${pluginName}`);
|
|
125325
125619
|
if (!dryRun) {
|
|
@@ -125335,11 +125629,11 @@ async function pruneClaudeLegacyPluginCache(dryRun, steps) {
|
|
|
125335
125629
|
}
|
|
125336
125630
|
}
|
|
125337
125631
|
async function pruneClaudeSupersededContextCache(root2, dryRun, steps) {
|
|
125338
|
-
const manifest = await
|
|
125632
|
+
const manifest = await readFile120(join146(root2, "claude", ".claude-plugin", "plugin.json"), "utf8").then((content3) => JSON.parse(content3)).catch(() => null);
|
|
125339
125633
|
const currentVersion = typeof manifest?.version === "string" ? manifest.version : null;
|
|
125340
125634
|
if (!currentVersion)
|
|
125341
125635
|
return;
|
|
125342
|
-
const pluginDir =
|
|
125636
|
+
const pluginDir = join146(claudePluginCacheRoot(), MARKETPLACE_NAME, PLUGIN_NAME);
|
|
125343
125637
|
const staleVersions = (await readdir36(pluginDir, { withFileTypes: true }).catch(() => [])).filter((entry) => entry.isDirectory() && entry.name !== currentVersion).map((entry) => entry.name);
|
|
125344
125638
|
if (staleVersions.length === 0)
|
|
125345
125639
|
return;
|
|
@@ -125349,7 +125643,7 @@ async function pruneClaudeSupersededContextCache(root2, dryRun, steps) {
|
|
|
125349
125643
|
status: dryRun ? "planned" : "ran"
|
|
125350
125644
|
});
|
|
125351
125645
|
if (!dryRun) {
|
|
125352
|
-
await Promise.all(staleVersions.map((version3) => rm35(
|
|
125646
|
+
await Promise.all(staleVersions.map((version3) => rm35(join146(pluginDir, version3), { recursive: true, force: true })));
|
|
125353
125647
|
}
|
|
125354
125648
|
}
|
|
125355
125649
|
function enableCodexPluginConfig(content3) {
|
|
@@ -125413,33 +125707,33 @@ source = ${JSON.stringify(root2)}
|
|
|
125413
125707
|
`;
|
|
125414
125708
|
}
|
|
125415
125709
|
async function ensureCodexPluginEnabled() {
|
|
125416
|
-
const configPath =
|
|
125710
|
+
const configPath = join146(codexHome(), "config.toml");
|
|
125417
125711
|
await mkdir46(dirname55(configPath), { recursive: true });
|
|
125418
|
-
const current3 = await
|
|
125712
|
+
const current3 = await readFile120(configPath, "utf8").catch(() => "");
|
|
125419
125713
|
const next2 = enableCodexPluginConfig(current3);
|
|
125420
125714
|
if (next2 !== current3) {
|
|
125421
125715
|
await writeFile35(configPath, next2, "utf8");
|
|
125422
125716
|
}
|
|
125423
125717
|
}
|
|
125424
125718
|
async function ensureCodexLocalMarketplace(root2) {
|
|
125425
|
-
const configPath =
|
|
125719
|
+
const configPath = join146(codexHome(), "config.toml");
|
|
125426
125720
|
await mkdir46(dirname55(configPath), { recursive: true });
|
|
125427
|
-
const current3 = await
|
|
125721
|
+
const current3 = await readFile120(configPath, "utf8").catch(() => "");
|
|
125428
125722
|
const next2 = upsertCodexLocalMarketplaceConfig(current3, root2);
|
|
125429
125723
|
if (next2 !== current3) {
|
|
125430
125724
|
await writeFile35(configPath, next2, "utf8");
|
|
125431
125725
|
}
|
|
125432
125726
|
}
|
|
125433
125727
|
async function codexPluginVersion(root2) {
|
|
125434
|
-
const manifestPath =
|
|
125435
|
-
const manifest = JSON.parse(await
|
|
125728
|
+
const manifestPath = join146(root2, "codex", ".codex-plugin", "plugin.json");
|
|
125729
|
+
const manifest = JSON.parse(await readFile120(manifestPath, "utf8"));
|
|
125436
125730
|
if (typeof manifest.version !== "string" || !/^[A-Za-z0-9][A-Za-z0-9._-]*$/u.test(manifest.version)) {
|
|
125437
125731
|
throw new Error(`Codex plugin manifest has an invalid version: ${manifestPath}`);
|
|
125438
125732
|
}
|
|
125439
125733
|
return manifest.version;
|
|
125440
125734
|
}
|
|
125441
125735
|
function codexPluginCacheDir(version3) {
|
|
125442
|
-
return
|
|
125736
|
+
return join146(codexHome(), "plugins", "cache", MARKETPLACE_NAME, PLUGIN_NAME, version3);
|
|
125443
125737
|
}
|
|
125444
125738
|
async function replaceDirectoryFromSource(source2, target) {
|
|
125445
125739
|
await mkdir46(dirname55(target), { recursive: true });
|
|
@@ -125447,7 +125741,7 @@ async function replaceDirectoryFromSource(source2, target) {
|
|
|
125447
125741
|
const previous3 = `${target}.previous-${process.pid}-${Date.now()}`;
|
|
125448
125742
|
await rm35(temporary, { recursive: true, force: true });
|
|
125449
125743
|
await cp4(source2, temporary, { recursive: true, force: true });
|
|
125450
|
-
const hadPrevious =
|
|
125744
|
+
const hadPrevious = existsSync39(target);
|
|
125451
125745
|
try {
|
|
125452
125746
|
if (hadPrevious)
|
|
125453
125747
|
await rename13(target, previous3);
|
|
@@ -125456,13 +125750,13 @@ async function replaceDirectoryFromSource(source2, target) {
|
|
|
125456
125750
|
await rm35(previous3, { recursive: true, force: true });
|
|
125457
125751
|
} catch (error) {
|
|
125458
125752
|
await rm35(temporary, { recursive: true, force: true });
|
|
125459
|
-
if (hadPrevious && !
|
|
125753
|
+
if (hadPrevious && !existsSync39(target) && existsSync39(previous3))
|
|
125460
125754
|
await rename13(previous3, target);
|
|
125461
125755
|
throw error;
|
|
125462
125756
|
}
|
|
125463
125757
|
}
|
|
125464
125758
|
async function materializeCodexPluginCache(root2, version3, dryRun, steps) {
|
|
125465
|
-
const source2 =
|
|
125759
|
+
const source2 = join146(root2, "codex");
|
|
125466
125760
|
const target = codexPluginCacheDir(version3);
|
|
125467
125761
|
steps.push({
|
|
125468
125762
|
agent: "codex",
|
|
@@ -125474,16 +125768,16 @@ async function materializeCodexPluginCache(root2, version3, dryRun, steps) {
|
|
|
125474
125768
|
await replaceDirectoryFromSource(source2, target);
|
|
125475
125769
|
}
|
|
125476
125770
|
async function bundledProviderSkillNames(root2) {
|
|
125477
|
-
const skillsRoot =
|
|
125771
|
+
const skillsRoot = join146(root2, "skills");
|
|
125478
125772
|
const entries2 = await readdir36(skillsRoot, { withFileTypes: true });
|
|
125479
125773
|
const names = [];
|
|
125480
125774
|
for (const entry of entries2) {
|
|
125481
125775
|
if (!entry.isDirectory() || entry.name === "context")
|
|
125482
125776
|
continue;
|
|
125483
|
-
const skillPath =
|
|
125484
|
-
if (!
|
|
125777
|
+
const skillPath = join146(skillsRoot, entry.name, "SKILL.md");
|
|
125778
|
+
if (!existsSync39(skillPath))
|
|
125485
125779
|
continue;
|
|
125486
|
-
const skill = await
|
|
125780
|
+
const skill = await readFile120(skillPath, "utf8");
|
|
125487
125781
|
if (!/^\s*context-role:\s*["']?indexer-provider["']?\s*$/mu.test(skill))
|
|
125488
125782
|
continue;
|
|
125489
125783
|
names.push(entry.name);
|
|
@@ -125495,10 +125789,10 @@ async function bundledProviderSkillNames(root2) {
|
|
|
125495
125789
|
return names;
|
|
125496
125790
|
}
|
|
125497
125791
|
async function materializeProviderSkills(root2, targetRoot, agent, dryRun, steps) {
|
|
125498
|
-
const sourceRoot =
|
|
125792
|
+
const sourceRoot = join146(root2, "skills");
|
|
125499
125793
|
for (const name3 of await bundledProviderSkillNames(root2)) {
|
|
125500
|
-
const source2 =
|
|
125501
|
-
const target =
|
|
125794
|
+
const source2 = join146(sourceRoot, name3);
|
|
125795
|
+
const target = join146(targetRoot, name3);
|
|
125502
125796
|
steps.push({
|
|
125503
125797
|
agent,
|
|
125504
125798
|
command: `materialize lifecycle Provider skill: ${shellQuote8(source2)} -> ${shellQuote8(target)}`,
|
|
@@ -125509,7 +125803,7 @@ async function materializeProviderSkills(root2, targetRoot, agent, dryRun, steps
|
|
|
125509
125803
|
}
|
|
125510
125804
|
}
|
|
125511
125805
|
async function installCursor(root2, dryRun, steps) {
|
|
125512
|
-
const source2 =
|
|
125806
|
+
const source2 = join146(root2, "cursor");
|
|
125513
125807
|
const target = cursorPluginRoot();
|
|
125514
125808
|
steps.push({
|
|
125515
125809
|
agent: "cursor",
|
|
@@ -125564,12 +125858,12 @@ async function installCodex(root2, dryRun, steps) {
|
|
|
125564
125858
|
steps.push({ agent: "codex", command: commandLine("codex", addArgs), status: dryRun ? "planned" : "ran" });
|
|
125565
125859
|
steps.push({
|
|
125566
125860
|
agent: "codex",
|
|
125567
|
-
command: `ensure ${shellQuote8(
|
|
125861
|
+
command: `ensure ${shellQuote8(join146(codexHome(), "config.toml"))} registers local marketplace ${shellQuote8(MARKETPLACE_NAME)}`,
|
|
125568
125862
|
status: dryRun ? "planned" : "ran"
|
|
125569
125863
|
});
|
|
125570
125864
|
steps.push({
|
|
125571
125865
|
agent: "codex",
|
|
125572
|
-
command: `ensure ${shellQuote8(
|
|
125866
|
+
command: `ensure ${shellQuote8(join146(codexHome(), "config.toml"))} enables ${shellQuote8(PLUGIN_ID)}`,
|
|
125573
125867
|
status: dryRun ? "planned" : "ran"
|
|
125574
125868
|
});
|
|
125575
125869
|
if (dryRun) {
|
|
@@ -125624,13 +125918,13 @@ function pluginRootCandidates() {
|
|
|
125624
125918
|
return [resolve54(envRoot)];
|
|
125625
125919
|
const candidates = [];
|
|
125626
125920
|
for (const dir of packageCandidateDirs()) {
|
|
125627
|
-
candidates.push(
|
|
125628
|
-
candidates.push(
|
|
125921
|
+
candidates.push(join147(dir, "plugins"));
|
|
125922
|
+
candidates.push(join147(dir, "dist", "plugins"));
|
|
125629
125923
|
}
|
|
125630
125924
|
return [...new Set(candidates)];
|
|
125631
125925
|
}
|
|
125632
125926
|
function isInstallablePluginRoot(root2) {
|
|
125633
|
-
return
|
|
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"));
|
|
125634
125928
|
}
|
|
125635
125929
|
function resolveBundledPluginsRoot() {
|
|
125636
125930
|
const candidates = pluginRootCandidates();
|
|
@@ -125896,11 +126190,11 @@ function readQuickstartPath() {
|
|
|
125896
126190
|
try {
|
|
125897
126191
|
let dir = dirname57(fileURLToPath12(import.meta.url));
|
|
125898
126192
|
for (let i2 = 0;i2 < 8; i2++) {
|
|
125899
|
-
const candidate =
|
|
125900
|
-
if (
|
|
126193
|
+
const candidate = join148(dir, "docs", "quickstart.md");
|
|
126194
|
+
if (existsSync41(candidate))
|
|
125901
126195
|
return candidate;
|
|
125902
|
-
const pkg =
|
|
125903
|
-
if (
|
|
126196
|
+
const pkg = join148(dir, "package.json");
|
|
126197
|
+
if (existsSync41(pkg))
|
|
125904
126198
|
return candidate;
|
|
125905
126199
|
const parent2 = dirname57(dir);
|
|
125906
126200
|
if (parent2 === dir)
|
|
@@ -125908,7 +126202,7 @@ function readQuickstartPath() {
|
|
|
125908
126202
|
dir = parent2;
|
|
125909
126203
|
}
|
|
125910
126204
|
} catch {}
|
|
125911
|
-
return
|
|
126205
|
+
return join148(dirname57(fileURLToPath12(import.meta.url)), "docs", "quickstart.md");
|
|
125912
126206
|
}
|
|
125913
126207
|
var GREEN = "\x1B[32m";
|
|
125914
126208
|
var RESET = "\x1B[0m";
|