@c4a/context-cli 0.7.13 → 0.7.14
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 +553 -461
- package/indexers/contracts/profile-contract.json +245 -245
- package/indexers/release-manifest.json +1 -1
- package/package.json +12 -12
- package/plugins/VERSION +1 -1
- package/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/plugins/claude/commands/context-inspect-search.md +18 -0
- package/plugins/claude/commands/context.md +11 -0
- package/plugins/codex/.codex-plugin/plugin.json +2 -2
- package/plugins/codex/skills/context/SKILL.md +11 -0
- package/plugins/codex/skills/context-inspect-search/SKILL.md +18 -0
- package/plugins/cursor/.cursor-plugin/plugin.json +1 -1
- package/plugins/cursor/commands/c4a-context-inspect-search.md +18 -0
- package/plugins/cursor/commands/c4a-context.md +11 -0
- package/plugins/skills/context/SKILL.md +11 -0
- package/plugins/skills/context-inspect-search/SKILL.md +18 -0
- package/providers/context/manifest.json +13 -13
- package/providers/context/provider.yaml +1 -1
- package/providers/context/resources/manuals/guides/knowledge-updates.md +44 -2
- package/providers/context/resources/manuals/guides/package-outputs.md +21 -0
- package/providers/context/resources/procedures/knowledge-updates.md +44 -2
- package/providers/context/resources/procedures/work-start-report.md +11 -0
- package/providers/context/resources/templates/work-start-report.md +7 -1
- package/providers/context/skills/work-production-stage/SKILL.md +3 -1
package/cli.js
CHANGED
|
@@ -68950,6 +68950,10 @@ function renderAgents(projectName, language) {
|
|
|
68950
68950
|
"- Context 完成只证明知识工作流状态,不证明 Git 提交范围安全。保留任务开始前已有的工作树变更,只按明确路径暂存;不要用 `git add -A` 把无关修改、删除或未跟踪目录带入提交。",
|
|
68951
68951
|
"- 发布知识包前可按产品需要定制 `src/package-templates/kb/wikis/index.md`;不要编辑生成后的 `dist/` 页面。",
|
|
68952
68952
|
"",
|
|
68953
|
+
"## 导航与分类",
|
|
68954
|
+
"",
|
|
68955
|
+
"新增或修订知识前,读取现有知识地图、总览和相关栏目正文,理解并复用分类意图。按当前 Route 的 knowledge-updates 指引安排文章、命名与顺序。新增来源或产品不自动新增顶层目录;确需调整顶层名称、用途或结构时,在开工报告或现有计划展示前后结构与复用不足的理由,取得具体方案确认后应用。已有明确批准不重复询问,常规落位不新增人审。将长期栏目用途简要维护在本文件或现有组织说明中。",
|
|
68956
|
+
"",
|
|
68953
68957
|
"## 图表风格(可修改)",
|
|
68954
68958
|
"",
|
|
68955
68959
|
"- 默认简约:约 1px 细线;文字与线条使用随主题变化的默认色,不加彩色装饰。Mermaid 不硬编码调色板、背景或主题初始化;线宽由支持它的展示端设置,不因此阻塞写作。",
|
|
@@ -68992,6 +68996,10 @@ function renderAgents(projectName, language) {
|
|
|
68992
68996
|
"- Context completion proves knowledge-workflow state, not Git commit safety. Preserve worktree changes that existed before the task, stage only explicit paths, and never use `git add -A` to mix unrelated modifications, deletions, or untracked directories into the deliverable.",
|
|
68993
68997
|
"- Customize `src/package-templates/kb/wikis/index.md` for the product before publishing a knowledge package; do not edit generated `dist/` pages.",
|
|
68994
68998
|
"",
|
|
68999
|
+
"## Navigation and Classification",
|
|
69000
|
+
"",
|
|
69001
|
+
"Before adding or revising knowledge, read the current map, overview and relevant category articles to understand and reuse their intent. Follow the current Route's knowledge-updates guidance for placement, names and order. A new source or product does not automatically warrant a top-level category. Present top-level name, purpose or structure changes with a before/after tree and reuse rationale in the work-start report or current plan, and obtain approval of the concrete proposal before applying it. Reuse explicit prior approval; ordinary placements add no review gate. Keep lasting category intent concise in this file or the existing organization guide.",
|
|
69002
|
+
"",
|
|
68995
69003
|
"## Diagram style (user editable)",
|
|
68996
69004
|
"",
|
|
68997
69005
|
"- Keep diagrams minimal: approximately 1px lines, theme-default text and stroke colors, no colorful decoration. Avoid fixed Mermaid palettes, backgrounds and theme initialization. Configure line width in a capable viewer; unsupported styling never blocks authoring.",
|
|
@@ -70080,11 +70088,70 @@ var init_packageOutputPaths = __esm(() => {
|
|
|
70080
70088
|
init_cliFeedback();
|
|
70081
70089
|
});
|
|
70082
70090
|
|
|
70091
|
+
// src/project/packageSiteAddress.ts
|
|
70092
|
+
import { readFile as readFile42, writeFile as writeFile12, rename as rename5 } from "node:fs/promises";
|
|
70093
|
+
import { join as join50 } from "node:path";
|
|
70094
|
+
function normalizeSiteUrl(value) {
|
|
70095
|
+
const url = new URL(value);
|
|
70096
|
+
if (!["https:", "http:"].includes(url.protocol) || url.username || url.password || url.search || url.hash) {
|
|
70097
|
+
throw new TypeError("Use an HTTP(S) site root without credentials, query or fragment");
|
|
70098
|
+
}
|
|
70099
|
+
url.pathname = `${url.pathname.replace(/\/+$/u, "")}/`;
|
|
70100
|
+
return url.href;
|
|
70101
|
+
}
|
|
70102
|
+
async function readPackageSiteUrl(root, pkg) {
|
|
70103
|
+
if (pkg.kind !== "package.kb" || !pkg.site)
|
|
70104
|
+
return;
|
|
70105
|
+
try {
|
|
70106
|
+
const map2 = JSON.parse(await readFile42(join50(root, packageSiteOutputDir(pkg), SITE_MAP_FILE), "utf8"));
|
|
70107
|
+
return typeof map2.site_url === "string" ? normalizeSiteUrl(map2.site_url) : undefined;
|
|
70108
|
+
} catch (error) {
|
|
70109
|
+
if (error.code === "ENOENT" || error instanceof SyntaxError || error instanceof TypeError)
|
|
70110
|
+
return;
|
|
70111
|
+
throw error;
|
|
70112
|
+
}
|
|
70113
|
+
}
|
|
70114
|
+
async function recordPackageSiteUrl(root, packageName, value) {
|
|
70115
|
+
const siteUrl = normalizeSiteUrl(value);
|
|
70116
|
+
return withProjectWriteLock(root, "record-site-url", async () => {
|
|
70117
|
+
const { loadContextProjectModule: loadContextProjectModule2 } = await Promise.resolve().then(() => (init_workspace(), exports_workspace));
|
|
70118
|
+
const loaded = await loadContextProjectModule2(root);
|
|
70119
|
+
const pkg = loaded.project.packages.find((candidate) => candidate.name === packageName);
|
|
70120
|
+
if (!pkg || pkg.kind !== "package.kb" || !pkg.site) {
|
|
70121
|
+
throw new TypeError("Select a declared knowledge package with a website");
|
|
70122
|
+
}
|
|
70123
|
+
const siteMap = join50(root, packageSiteOutputDir(pkg), SITE_MAP_FILE);
|
|
70124
|
+
let map2;
|
|
70125
|
+
try {
|
|
70126
|
+
map2 = JSON.parse(await readFile42(siteMap, "utf8"));
|
|
70127
|
+
} catch (error) {
|
|
70128
|
+
if (error.code === "ENOENT")
|
|
70129
|
+
throw new TypeError("Build the configured website before recording its deployment URL");
|
|
70130
|
+
throw error;
|
|
70131
|
+
}
|
|
70132
|
+
if (map2.protocol !== "context.site-output/v1" || !Array.isArray(map2.pages)) {
|
|
70133
|
+
throw new TypeError("Rebuild the website to restore a valid context-site-map.json");
|
|
70134
|
+
}
|
|
70135
|
+
const content3 = JSON.stringify({ ...map2, site_url: siteUrl }, null, 2) + `
|
|
70136
|
+
`;
|
|
70137
|
+
for (const path2 of [siteMap, join50(root, pkg.outDir, SITE_MAP_FILE)]) {
|
|
70138
|
+
await writeFile12(`${path2}.tmp`, content3);
|
|
70139
|
+
await rename5(`${path2}.tmp`, path2);
|
|
70140
|
+
}
|
|
70141
|
+
return { package: pkg.name, site_url: siteUrl, network_checked: false };
|
|
70142
|
+
});
|
|
70143
|
+
}
|
|
70144
|
+
var SITE_MAP_FILE = "context-site-map.json";
|
|
70145
|
+
var init_packageSiteAddress = __esm(() => {
|
|
70146
|
+
init_packageOutputPaths();
|
|
70147
|
+
init_writeLock();
|
|
70148
|
+
});
|
|
70149
|
+
|
|
70083
70150
|
// src/project/packageBuildReceipt.ts
|
|
70084
70151
|
import { createHash as createHash13 } from "node:crypto";
|
|
70085
70152
|
import { existsSync as existsSync15 } from "node:fs";
|
|
70086
|
-
import { readFile as
|
|
70087
|
-
import { join as
|
|
70153
|
+
import { readFile as readFile43 } from "node:fs/promises";
|
|
70154
|
+
import { join as join51, relative as relative15 } from "node:path";
|
|
70088
70155
|
function parsePackageLinkWarnings(value) {
|
|
70089
70156
|
if (!Array.isArray(value))
|
|
70090
70157
|
return [];
|
|
@@ -70099,7 +70166,7 @@ async function walkPackageFiles(root) {
|
|
|
70099
70166
|
for (const entry of entries2) {
|
|
70100
70167
|
if (IGNORED_PACKAGE_FS_ENTRIES.has(entry.name))
|
|
70101
70168
|
continue;
|
|
70102
|
-
const absPath =
|
|
70169
|
+
const absPath = join51(dir, entry.name);
|
|
70103
70170
|
if (entry.isDirectory()) {
|
|
70104
70171
|
await visit2(absPath);
|
|
70105
70172
|
continue;
|
|
@@ -70130,17 +70197,27 @@ function classifyOutputFile(path2, knowledgeGroups) {
|
|
|
70130
70197
|
}
|
|
70131
70198
|
async function packageOutputSnapshot(projectRoot, pkg, knowledgeGroups, previousOutputs = []) {
|
|
70132
70199
|
const previousByPath = new Map(previousOutputs.map((file) => [file.path, file]));
|
|
70133
|
-
const files = (await Promise.all(packageOutputDirs(pkg).map(async (output) => (await walkPackageFiles(
|
|
70200
|
+
const files = (await Promise.all(packageOutputDirs(pkg).map(async (output) => (await walkPackageFiles(join51(projectRoot, output))).map((file) => ({
|
|
70134
70201
|
...file,
|
|
70135
|
-
relPath: toPosixPath4(relative15(
|
|
70202
|
+
relPath: toPosixPath4(relative15(join51(projectRoot, pkg.outDir), file.absPath))
|
|
70136
70203
|
}))))).flat();
|
|
70137
70204
|
return Promise.all(files.map(async (file) => {
|
|
70138
70205
|
const current = classifyOutputFile(file.relPath, knowledgeGroups);
|
|
70139
70206
|
const previous2 = previousByPath.get(file.relPath);
|
|
70140
70207
|
const classification = current.kind === "file" && previous2 !== undefined ? { path: file.relPath, kind: previous2.kind, ...previous2.group === undefined ? {} : { group: previous2.group } } : current;
|
|
70208
|
+
let content3 = await readFile43(file.absPath);
|
|
70209
|
+
if (file.absPath === join51(projectRoot, pkg.outDir, "context-site-map.json") || file.absPath === join51(projectRoot, packageSiteOutputDir(pkg), "context-site-map.json")) {
|
|
70210
|
+
try {
|
|
70211
|
+
const map2 = JSON.parse(content3.toString());
|
|
70212
|
+
if (map2.protocol === "context.site-output/v1" && Array.isArray(map2.pages)) {
|
|
70213
|
+
delete map2.site_url;
|
|
70214
|
+
content3 = JSON.stringify(map2);
|
|
70215
|
+
}
|
|
70216
|
+
} catch {}
|
|
70217
|
+
}
|
|
70141
70218
|
return {
|
|
70142
70219
|
...classification,
|
|
70143
|
-
sha256: createHash13("sha256").update(
|
|
70220
|
+
sha256: createHash13("sha256").update(content3).digest("hex")
|
|
70144
70221
|
};
|
|
70145
70222
|
}));
|
|
70146
70223
|
}
|
|
@@ -70148,8 +70225,8 @@ async function packageOutputFingerprint(projectRoot, pkg, observed) {
|
|
|
70148
70225
|
const snapshot = observed ?? await packageOutputSnapshot(projectRoot, pkg, new Map);
|
|
70149
70226
|
return {
|
|
70150
70227
|
fingerprint: createHash13("sha256").update(JSON.stringify({
|
|
70151
|
-
outDirExists: existsSync15(
|
|
70152
|
-
siteDirExists: pkg.kind === "package.kb" && pkg.site ? existsSync15(
|
|
70228
|
+
outDirExists: existsSync15(join51(projectRoot, pkg.outDir)),
|
|
70229
|
+
siteDirExists: pkg.kind === "package.kb" && pkg.site ? existsSync15(join51(projectRoot, packageSiteOutputDir(pkg))) : undefined,
|
|
70153
70230
|
files: snapshot.map(({ path: path2, sha256 }) => ({ path: path2, sha256 }))
|
|
70154
70231
|
})).digest("hex"),
|
|
70155
70232
|
files: snapshot.length
|
|
@@ -70234,8 +70311,8 @@ var init_packageBuildReceipt = __esm(() => {
|
|
|
70234
70311
|
});
|
|
70235
70312
|
|
|
70236
70313
|
// src/project/knowledgeMapCoverage.ts
|
|
70237
|
-
import { readFile as
|
|
70238
|
-
import { join as
|
|
70314
|
+
import { readFile as readFile44 } from "node:fs/promises";
|
|
70315
|
+
import { join as join52 } from "node:path";
|
|
70239
70316
|
function knowledgeMapArticleTargets(files) {
|
|
70240
70317
|
return files.flatMap((file) => {
|
|
70241
70318
|
const meta = parseKnowledgeFrontmatter(file.content);
|
|
@@ -70251,10 +70328,10 @@ function knowledgeMapArticleTargets(files) {
|
|
|
70251
70328
|
async function approvedKnowledgeMapTargets(root) {
|
|
70252
70329
|
const metadata = await readApprovedKnowledgeMetadataIndex(root);
|
|
70253
70330
|
const articles = new Map(validateArticleStructureEntries(metadata.structure?.articles ?? []).map((article) => [article.path, article]));
|
|
70254
|
-
const files = await walkPackageFiles(
|
|
70331
|
+
const files = await walkPackageFiles(join52(root, "knowledge"));
|
|
70255
70332
|
const content3 = await Promise.all(files.filter((file) => isApprovedKnowledgeMarkdownPath(file.relPath) && !file.relPath.startsWith("assets/")).map(async (file) => ({
|
|
70256
70333
|
article: articles.get(file.relPath),
|
|
70257
|
-
content: hydrateApprovedKnowledgeMarkdown({ content: await
|
|
70334
|
+
content: hydrateApprovedKnowledgeMarkdown({ content: await readFile44(file.absPath, "utf8"), relPath: file.relPath, metadata })
|
|
70258
70335
|
})));
|
|
70259
70336
|
return knowledgeMapArticleTargets(content3);
|
|
70260
70337
|
}
|
|
@@ -70300,11 +70377,11 @@ var init_knowledgeMapCoverage = __esm(() => {
|
|
|
70300
70377
|
});
|
|
70301
70378
|
|
|
70302
70379
|
// src/project/knowledgeMap.ts
|
|
70303
|
-
import { readFile as
|
|
70304
|
-
import { join as
|
|
70380
|
+
import { readFile as readFile45 } from "node:fs/promises";
|
|
70381
|
+
import { join as join53 } from "node:path";
|
|
70305
70382
|
async function optionalText(root, path2) {
|
|
70306
70383
|
try {
|
|
70307
|
-
return await
|
|
70384
|
+
return await readFile45(join53(root, path2), "utf8");
|
|
70308
70385
|
} catch (error) {
|
|
70309
70386
|
if (error.code === "ENOENT")
|
|
70310
70387
|
return;
|
|
@@ -70357,8 +70434,8 @@ var init_knowledgeMap2 = __esm(() => {
|
|
|
70357
70434
|
});
|
|
70358
70435
|
|
|
70359
70436
|
// src/project/packageKnowledgeMap.ts
|
|
70360
|
-
import { readFile as
|
|
70361
|
-
import { join as
|
|
70437
|
+
import { readFile as readFile46, writeFile as writeFile13 } from "node:fs/promises";
|
|
70438
|
+
import { join as join54 } from "node:path";
|
|
70362
70439
|
function knowledgeMapSectionAnchor(key) {
|
|
70363
70440
|
return `section-${encodeURIComponent(key)}`;
|
|
70364
70441
|
}
|
|
@@ -70383,16 +70460,16 @@ async function writePackageKnowledgeMap(input) {
|
|
|
70383
70460
|
return [];
|
|
70384
70461
|
const projected = projectKnowledgeMap(input.structure, packageKnowledgeMapTargets(input.pkg, input.selected));
|
|
70385
70462
|
projected.warnings = projected.warnings.filter((warning) => !warning.target.startsWith("site:"));
|
|
70386
|
-
const root =
|
|
70387
|
-
const mapPath =
|
|
70463
|
+
const root = join54(input.projectRoot, input.pkg.outDir);
|
|
70464
|
+
const mapPath = join54(root, "context-knowledge-map.json");
|
|
70388
70465
|
try {
|
|
70389
|
-
await
|
|
70466
|
+
await readFile46(mapPath);
|
|
70390
70467
|
throw new TypeError("package template uses reserved context-knowledge-map.json; rename that template output");
|
|
70391
70468
|
} catch (error) {
|
|
70392
70469
|
if (error.code !== "ENOENT")
|
|
70393
70470
|
throw error;
|
|
70394
70471
|
}
|
|
70395
|
-
await
|
|
70472
|
+
await writeFile13(mapPath, JSON.stringify({ protocol: "context.knowledge-map-output/v1", knowledge_map_revision: input.structure.revision, ...projected }, null, 2) + `
|
|
70396
70473
|
`);
|
|
70397
70474
|
const lines = [];
|
|
70398
70475
|
const escape2 = (value) => value.replace(/[\\[\]<>]/gu, (char) => `\\${char}`).replace(/[\r\n]/gu, " ");
|
|
@@ -70405,15 +70482,15 @@ async function writePackageKnowledgeMap(input) {
|
|
|
70405
70482
|
}
|
|
70406
70483
|
render(projected.entries, 0);
|
|
70407
70484
|
if (lines.length) {
|
|
70408
|
-
const indexPath =
|
|
70485
|
+
const indexPath = join54(root, "index.md");
|
|
70409
70486
|
let existing = "";
|
|
70410
70487
|
try {
|
|
70411
|
-
existing = await
|
|
70488
|
+
existing = await readFile46(indexPath, "utf8");
|
|
70412
70489
|
} catch (error) {
|
|
70413
70490
|
if (error.code !== "ENOENT")
|
|
70414
70491
|
throw error;
|
|
70415
70492
|
}
|
|
70416
|
-
await
|
|
70493
|
+
await writeFile13(indexPath, `${existing.trimEnd()}
|
|
70417
70494
|
|
|
70418
70495
|
## Knowledge map
|
|
70419
70496
|
|
|
@@ -70431,8 +70508,8 @@ var init_packageKnowledgeMap = __esm(() => {
|
|
|
70431
70508
|
|
|
70432
70509
|
// src/project/packageLlms.ts
|
|
70433
70510
|
import { createHash as createHash14 } from "node:crypto";
|
|
70434
|
-
import { access as access4, mkdir as mkdir18, writeFile as
|
|
70435
|
-
import { dirname as dirname22, join as
|
|
70511
|
+
import { access as access4, mkdir as mkdir18, writeFile as writeFile14 } from "node:fs/promises";
|
|
70512
|
+
import { dirname as dirname22, join as join55, posix as posix5 } from "node:path";
|
|
70436
70513
|
function llmsArticles(pkg, selected) {
|
|
70437
70514
|
return selected.map((file) => {
|
|
70438
70515
|
const meta = parseKnowledgeFrontmatter(file.content);
|
|
@@ -70532,7 +70609,7 @@ async function writeLlmsDocuments(root, documents, options = {}) {
|
|
|
70532
70609
|
for (const [path2, content3] of documents.files) {
|
|
70533
70610
|
let exists = false;
|
|
70534
70611
|
try {
|
|
70535
|
-
await access4(
|
|
70612
|
+
await access4(join55(root, path2));
|
|
70536
70613
|
exists = true;
|
|
70537
70614
|
} catch (error) {
|
|
70538
70615
|
if (error.code !== "ENOENT")
|
|
@@ -70542,8 +70619,8 @@ async function writeLlmsDocuments(root, documents, options = {}) {
|
|
|
70542
70619
|
continue;
|
|
70543
70620
|
if (exists)
|
|
70544
70621
|
throw new Error(`Package template uses reserved LLMS output ${path2}; rename that template output.`);
|
|
70545
|
-
await mkdir18(dirname22(
|
|
70546
|
-
await
|
|
70622
|
+
await mkdir18(dirname22(join55(root, path2)), { recursive: true });
|
|
70623
|
+
await writeFile14(join55(root, path2), options.utf8Bom ? "\uFEFF" + content3.replace(/^\uFEFF/u, "") : content3, "utf8");
|
|
70547
70624
|
}
|
|
70548
70625
|
}
|
|
70549
70626
|
var PACKAGE_LLMS_VERSION = "knowledge-map-llms-v1", label = (text7) => text7.replace(/[\\[\]<>`*]/gu, "\\$&").replace(/[\r\n]/gu, " "), articlePath = (identity) => `llms/pages/${createHash14("sha256").update(identity).digest("hex").slice(0, 32)}.txt`;
|
|
@@ -71203,8 +71280,8 @@ var init_packageSiteBranding = __esm(() => {
|
|
|
71203
71280
|
|
|
71204
71281
|
// src/project/packageSiteExtensions.ts
|
|
71205
71282
|
import { createHash as createHash15 } from "node:crypto";
|
|
71206
|
-
import { lstat as lstat7, readdir as readdir14, readFile as
|
|
71207
|
-
import { join as
|
|
71283
|
+
import { lstat as lstat7, readdir as readdir14, readFile as readFile47, mkdir as mkdir19, writeFile as writeFile15, symlink } from "node:fs/promises";
|
|
71284
|
+
import { join as join56, dirname as dirname23, resolve as resolve19 } from "node:path";
|
|
71208
71285
|
function invalidSiteExtension(message) {
|
|
71209
71286
|
throw new ContextError(ExitCode.UserError, `Site extensions: ${message}. Update site.extensions, its src files or the knowledge-map target, then retry the build.`, {
|
|
71210
71287
|
reason_code: "invalid-site-extension"
|
|
@@ -71223,7 +71300,7 @@ async function readSiteExtensions(projectRoot, extensions) {
|
|
|
71223
71300
|
invalid(`unsafe root ${root}`);
|
|
71224
71301
|
let cursor = projectRoot;
|
|
71225
71302
|
for (const part of root.split("/")) {
|
|
71226
|
-
cursor =
|
|
71303
|
+
cursor = join56(cursor, part);
|
|
71227
71304
|
const info = await lstat7(cursor).catch((error) => {
|
|
71228
71305
|
if (error.code === "ENOENT")
|
|
71229
71306
|
invalid(`missing directory ${root}`);
|
|
@@ -71243,9 +71320,9 @@ async function readSiteExtensions(projectRoot, extensions) {
|
|
|
71243
71320
|
if (entry.isSymbolicLink())
|
|
71244
71321
|
invalid(`symlink at ${path2}`);
|
|
71245
71322
|
if (entry.isDirectory())
|
|
71246
|
-
await walk(
|
|
71323
|
+
await walk(join56(directory, entry.name), path2 + "/");
|
|
71247
71324
|
else if (entry.isFile())
|
|
71248
|
-
files.push({ path: path2, bytes: await
|
|
71325
|
+
files.push({ path: path2, bytes: await readFile47(join56(directory, entry.name)) });
|
|
71249
71326
|
}
|
|
71250
71327
|
}
|
|
71251
71328
|
await walk(cursor, "");
|
|
@@ -71265,7 +71342,7 @@ async function readSiteExtensions(projectRoot, extensions) {
|
|
|
71265
71342
|
hash3.update(file.path + "\x00").update(file.bytes).update("\x00");
|
|
71266
71343
|
for (const name2 of ["package.json", "bun.lock", "pnpm-lock.yaml", "package-lock.json"]) {
|
|
71267
71344
|
try {
|
|
71268
|
-
hash3.update(name2).update(await
|
|
71345
|
+
hash3.update(name2).update(await readFile47(join56(projectRoot, name2)));
|
|
71269
71346
|
} catch (error) {
|
|
71270
71347
|
if (error.code !== "ENOENT")
|
|
71271
71348
|
throw error;
|
|
@@ -71278,18 +71355,18 @@ function siteExtensionTargets(site) {
|
|
|
71278
71355
|
}
|
|
71279
71356
|
async function writeSiteExtensions(projectRoot, temporary, extensions) {
|
|
71280
71357
|
const { files } = await readSiteExtensions(projectRoot, extensions);
|
|
71281
|
-
const root =
|
|
71358
|
+
const root = join56(temporary, "_site");
|
|
71282
71359
|
for (const file of files) {
|
|
71283
|
-
const path2 =
|
|
71360
|
+
const path2 = join56(root, file.path);
|
|
71284
71361
|
await mkdir19(dirname23(path2), { recursive: true });
|
|
71285
|
-
await
|
|
71362
|
+
await writeFile15(path2, file.bytes);
|
|
71286
71363
|
}
|
|
71287
71364
|
if (extensions) {
|
|
71288
71365
|
try {
|
|
71289
71366
|
const modules = resolve19(projectRoot, "node_modules");
|
|
71290
71367
|
if ((await lstat7(modules)).isDirectory() || (await lstat7(modules)).isSymbolicLink()) {
|
|
71291
71368
|
await mkdir19(root, { recursive: true });
|
|
71292
|
-
await symlink(modules,
|
|
71369
|
+
await symlink(modules, join56(root, "node_modules"), "dir");
|
|
71293
71370
|
}
|
|
71294
71371
|
} catch (error) {
|
|
71295
71372
|
if (error.code !== "ENOENT")
|
|
@@ -71308,16 +71385,16 @@ async function writeSiteExtensions(projectRoot, temporary, extensions) {
|
|
|
71308
71385
|
imports.push(`const ${name2} = defineAsyncComponent(() => import(${JSON.stringify(`../../_site/${path2}`)}));`);
|
|
71309
71386
|
slots.push(`${JSON.stringify(name2)}: ${name2 === "floating" ? `() => h(resolveComponent('ClientOnly'), null, { default: () => h(${name2}) })` : `() => h(${name2})`}`);
|
|
71310
71387
|
}
|
|
71311
|
-
await
|
|
71388
|
+
await writeFile15(join56(temporary, ".vitepress/theme/extensions.js"), imports.join(`
|
|
71312
71389
|
`) + `
|
|
71313
71390
|
export default {${slots.join(",")}};
|
|
71314
71391
|
`);
|
|
71315
71392
|
for (const [key, path2] of Object.entries(extensions?.pages ?? {})) {
|
|
71316
|
-
await mkdir19(
|
|
71393
|
+
await mkdir19(join56(temporary, "custom"), { recursive: true });
|
|
71317
71394
|
const content3 = files.find((file) => file.path === path2).bytes.toString("utf8");
|
|
71318
71395
|
const metadata = parseKnowledgeFrontmatter(content3);
|
|
71319
71396
|
const title = metadata.title ?? /^#\s+(.+)$/m.exec(content3)?.[1] ?? key;
|
|
71320
|
-
await
|
|
71397
|
+
await writeFile15(join56(temporary, "custom", `${key}.md`), `---
|
|
71321
71398
|
${JSON.stringify({ layout: "page", ...metadata, title })}
|
|
71322
71399
|
---
|
|
71323
71400
|
<script setup>
|
|
@@ -71339,9 +71416,9 @@ var init_packageSiteExtensions = __esm(() => {
|
|
|
71339
71416
|
// src/project/packageSite.ts
|
|
71340
71417
|
import { createHash as createHash16 } from "node:crypto";
|
|
71341
71418
|
import { spawn as spawn3 } from "node:child_process";
|
|
71342
|
-
import { mkdir as mkdir20, mkdtemp, readFile as
|
|
71419
|
+
import { mkdir as mkdir20, mkdtemp, readFile as readFile48, writeFile as writeFile16, rm as rm11, symlink as symlink2, cp, access as access5, stat as stat6 } from "node:fs/promises";
|
|
71343
71420
|
import { createRequire as createRequire5 } from "node:module";
|
|
71344
|
-
import { dirname as dirname24, join as
|
|
71421
|
+
import { dirname as dirname24, join as join57, posix as posix6 } from "node:path";
|
|
71345
71422
|
function sitePagePath(identity) {
|
|
71346
71423
|
return `pages/${createHash16("sha256").update(identity).digest("hex").slice(0, 32)}.html`;
|
|
71347
71424
|
}
|
|
@@ -71454,7 +71531,7 @@ function siteSections(entries2) {
|
|
|
71454
71531
|
async function compileSite(root, outDir) {
|
|
71455
71532
|
const vitepressRoot = dirname24(require2.resolve("vitepress/package.json"));
|
|
71456
71533
|
await new Promise((resolve8, reject) => {
|
|
71457
|
-
const child = spawn3(process.versions.bun ? "node" : process.execPath, [
|
|
71534
|
+
const child = spawn3(process.versions.bun ? "node" : process.execPath, [join57(vitepressRoot, "bin/vitepress.js"), "build", root, "--outDir", outDir], { stdio: ["ignore", "pipe", "pipe"] });
|
|
71458
71535
|
let tail = "";
|
|
71459
71536
|
const receive = (chunk) => {
|
|
71460
71537
|
tail = (tail + chunk.toString()).slice(-16000);
|
|
@@ -71485,8 +71562,8 @@ async function writePackageSite(input) {
|
|
|
71485
71562
|
const base = options.base ?? "/";
|
|
71486
71563
|
const history = await readWorkspaceChangelog(projectRoot);
|
|
71487
71564
|
const historyDate = history[0]?.date ?? null;
|
|
71488
|
-
const root =
|
|
71489
|
-
const output =
|
|
71565
|
+
const root = join57(projectRoot, pkg.outDir);
|
|
71566
|
+
const output = join57(projectRoot, packageSiteOutputDir(pkg));
|
|
71490
71567
|
try {
|
|
71491
71568
|
await access5(output);
|
|
71492
71569
|
throw new Error("Website output already exists; build through the staged package workflow.");
|
|
@@ -71494,9 +71571,9 @@ async function writePackageSite(input) {
|
|
|
71494
71571
|
if (error.code !== "ENOENT")
|
|
71495
71572
|
throw error;
|
|
71496
71573
|
}
|
|
71497
|
-
const temporaryRoot =
|
|
71574
|
+
const temporaryRoot = join57(projectRoot, ".tmp");
|
|
71498
71575
|
await mkdir20(temporaryRoot, { recursive: true });
|
|
71499
|
-
const temporary = await mkdtemp(
|
|
71576
|
+
const temporary = await mkdtemp(join57(temporaryRoot, "website-"));
|
|
71500
71577
|
try {
|
|
71501
71578
|
const registry2 = await loadSourcesRegistry({ rootDir: projectRoot });
|
|
71502
71579
|
const sourceContent = new Map(selected.map((file) => [packageKnowledgeOutputPath(pkg, file.relPath), file]));
|
|
@@ -71506,7 +71583,7 @@ async function writePackageSite(input) {
|
|
|
71506
71583
|
for (const file of delivered) {
|
|
71507
71584
|
if (!/^(?:skills|wikis|guides|rules|feats)\/.*\.md$/u.test(file.relPath) || byPath.has(file.relPath))
|
|
71508
71585
|
continue;
|
|
71509
|
-
const content3 = await
|
|
71586
|
+
const content3 = await readFile48(file.absPath, "utf8");
|
|
71510
71587
|
const meta = parseKnowledgeFrontmatter(content3);
|
|
71511
71588
|
const page = {
|
|
71512
71589
|
package_path: file.relPath,
|
|
@@ -71517,20 +71594,20 @@ async function writePackageSite(input) {
|
|
|
71517
71594
|
}
|
|
71518
71595
|
const sections = siteSections(mapping.entries);
|
|
71519
71596
|
const resources = new Set(delivered.filter((file) => file.relPath.startsWith("others/assets/") || file.relPath.startsWith("skills/") && !file.relPath.endsWith(".md")).map((file) => file.relPath));
|
|
71520
|
-
const configRoot =
|
|
71521
|
-
await mkdir20(
|
|
71522
|
-
await mkdir20(
|
|
71597
|
+
const configRoot = join57(temporary, ".vitepress");
|
|
71598
|
+
await mkdir20(join57(configRoot, "theme"), { recursive: true });
|
|
71599
|
+
await mkdir20(join57(temporary, "node_modules"), { recursive: true });
|
|
71523
71600
|
const vitepressRoot = dirname24(require2.resolve("vitepress/package.json"));
|
|
71524
|
-
const vueRequire = createRequire5(
|
|
71601
|
+
const vueRequire = createRequire5(join57(vitepressRoot, "package.json"));
|
|
71525
71602
|
for (const [name2, path2] of [
|
|
71526
71603
|
["vitepress", vitepressRoot],
|
|
71527
71604
|
["vue", dirname24(vueRequire.resolve("vue/package.json"))],
|
|
71528
71605
|
["mermaid", dirname24(require2.resolve("mermaid/package.json"))]
|
|
71529
71606
|
]) {
|
|
71530
|
-
await symlink2(path2,
|
|
71607
|
+
await symlink2(path2, join57(temporary, "node_modules", name2), "dir");
|
|
71531
71608
|
}
|
|
71532
|
-
await
|
|
71533
|
-
await
|
|
71609
|
+
await writeFile16(join57(configRoot, "theme/index.js"), siteThemeScript);
|
|
71610
|
+
await writeFile16(join57(configRoot, "theme/style.css"), siteThemeCss);
|
|
71534
71611
|
await writeSiteExtensions(projectRoot, temporary, options.extensions);
|
|
71535
71612
|
const config = {
|
|
71536
71613
|
title: options.title ?? pkg.name,
|
|
@@ -71556,11 +71633,11 @@ async function writePackageSite(input) {
|
|
|
71556
71633
|
nav: [...sections.map((section) => ({ text: section.title, link: section.href })), { text: "更多", items: [{ text: "LLM Docs", link: "/llms/index.html" }, { text: "Changelog", link: "/changelog.html" }] }]
|
|
71557
71634
|
}
|
|
71558
71635
|
};
|
|
71559
|
-
await
|
|
71636
|
+
await writeFile16(join57(configRoot, "config.mjs"), `export default { ...${JSON.stringify(config)}, markdown: { ${siteMarkdownConfig} } };
|
|
71560
71637
|
`);
|
|
71561
|
-
await mkdir20(
|
|
71638
|
+
await mkdir20(join57(temporary, "pages"), { recursive: true });
|
|
71562
71639
|
for (const page of byPath.values()) {
|
|
71563
|
-
const content3 = await
|
|
71640
|
+
const content3 = await readFile48(join57(root, page.package_path), "utf8");
|
|
71564
71641
|
const original = sourceContent.get(page.package_path);
|
|
71565
71642
|
const provenance = articleProvenanceMarkdown(original?.article, registry2);
|
|
71566
71643
|
const pageContent = provenance && content3.endsWith(provenance) ? content3.slice(0, -provenance.length) : content3;
|
|
@@ -71568,7 +71645,7 @@ async function writePackageSite(input) {
|
|
|
71568
71645
|
const sources = siteArticleSources(original?.article, registry2);
|
|
71569
71646
|
const timestamp = parseKnowledgeFrontmatter(original?.content ?? content3).timestamp;
|
|
71570
71647
|
const updated = typeof timestamp === "string" && Number.isFinite(Date.parse(timestamp)) ? new Date(timestamp).toISOString() : null;
|
|
71571
|
-
await
|
|
71648
|
+
await writeFile16(join57(temporary, page.site_path.replace(/\.html$/u, ".md")), `---
|
|
71572
71649
|
title: ${JSON.stringify(page.title)}
|
|
71573
71650
|
contextSources: ${JSON.stringify(sources)}
|
|
71574
71651
|
contextUpdated: ${JSON.stringify(updated)}
|
|
@@ -71580,11 +71657,11 @@ ${body}`);
|
|
|
71580
71657
|
lines.push(`${" ".repeat(level)}- ${entry.href ? `[${mdLabel(entry.title)}](${entry.href})` : mdLabel(entry.title)}`);
|
|
71581
71658
|
menu(lines, entry.children, level + 1);
|
|
71582
71659
|
});
|
|
71583
|
-
await mkdir20(
|
|
71660
|
+
await mkdir20(join57(temporary, "sections"), { recursive: true });
|
|
71584
71661
|
for (const section of sections) {
|
|
71585
71662
|
const lines = [`# ${mdLabel(section.title)}`, ""];
|
|
71586
71663
|
menu(lines, section.entries, 0);
|
|
71587
|
-
await
|
|
71664
|
+
await writeFile16(join57(temporary, section.href.slice(1).replace(/\.html$/u, ".md")), lines.join(`
|
|
71588
71665
|
`) + `
|
|
71589
71666
|
`);
|
|
71590
71667
|
}
|
|
@@ -71603,12 +71680,12 @@ ${body}`);
|
|
|
71603
71680
|
};
|
|
71604
71681
|
const homeHero = options.extensions?.slots?.banner === undefined ? `hero: ${JSON.stringify(hero)}
|
|
71605
71682
|
` : "";
|
|
71606
|
-
await
|
|
71683
|
+
await writeFile16(join57(temporary, "index.md"), `---
|
|
71607
71684
|
layout: home
|
|
71608
71685
|
title: ${JSON.stringify(options.home?.title ?? options.title ?? pkg.name)}
|
|
71609
71686
|
${homeHero}---
|
|
71610
71687
|
`);
|
|
71611
|
-
await
|
|
71688
|
+
await writeFile16(join57(temporary, "changelog.md"), `---
|
|
71612
71689
|
title: Changelog
|
|
71613
71690
|
contextHistory: ${JSON.stringify(Buffer.from(JSON.stringify(history)).toString("base64"))}
|
|
71614
71691
|
---
|
|
@@ -71621,19 +71698,19 @@ contextHistory: ${JSON.stringify(Buffer.from(JSON.stringify(history)).toString("
|
|
|
71621
71698
|
assetsPrefix: "resources/",
|
|
71622
71699
|
articles: await Promise.all(llmsArticles(pkg, selected).map(async (article) => ({
|
|
71623
71700
|
...article,
|
|
71624
|
-
content: await
|
|
71701
|
+
content: await readFile48(join57(root, article.path), "utf8")
|
|
71625
71702
|
}))),
|
|
71626
71703
|
...structure ? { map: structure } : {}
|
|
71627
71704
|
});
|
|
71628
|
-
await writeLlmsDocuments(
|
|
71629
|
-
await mkdir20(
|
|
71705
|
+
await writeLlmsDocuments(join57(temporary, "public"), llms, { utf8Bom: true });
|
|
71706
|
+
await mkdir20(join57(temporary, "llms"), { recursive: true });
|
|
71630
71707
|
let landingNavigation = llms.navigationMarkdown;
|
|
71631
71708
|
for (const link of markdownReaderLinks(landingNavigation).reverse()) {
|
|
71632
71709
|
if (!link.target.startsWith(base))
|
|
71633
71710
|
continue;
|
|
71634
71711
|
landingNavigation = landingNavigation.slice(0, link.start) + `[${link.label}](</${link.target.slice(base.length)}>)` + landingNavigation.slice(link.end);
|
|
71635
71712
|
}
|
|
71636
|
-
await
|
|
71713
|
+
await writeFile16(join57(temporary, "llms/index.md"), `---
|
|
71637
71714
|
title: LLM Docs
|
|
71638
71715
|
---
|
|
71639
71716
|
|
|
@@ -71643,9 +71720,9 @@ title: LLM Docs
|
|
|
71643
71720
|
|
|
71644
71721
|
` + landingNavigation);
|
|
71645
71722
|
for (const path2 of resources) {
|
|
71646
|
-
const destination =
|
|
71723
|
+
const destination = join57(temporary, "public/resources", path2);
|
|
71647
71724
|
await mkdir20(dirname24(destination), { recursive: true });
|
|
71648
|
-
await cp(
|
|
71725
|
+
await cp(join57(root, path2), destination);
|
|
71649
71726
|
}
|
|
71650
71727
|
await compileSite(temporary, output);
|
|
71651
71728
|
for (const file of await walkPackageFiles(output)) {
|
|
@@ -71654,10 +71731,11 @@ title: LLM Docs
|
|
|
71654
71731
|
` : [".html", ".htm"].includes(extension2) ? `<!-- Intentionally empty. -->
|
|
71655
71732
|
` : null;
|
|
71656
71733
|
if (placeholder !== null && (await stat6(file.absPath)).size === 0) {
|
|
71657
|
-
await
|
|
71734
|
+
await writeFile16(file.absPath, placeholder);
|
|
71658
71735
|
}
|
|
71659
71736
|
}
|
|
71660
|
-
|
|
71737
|
+
const siteMapContent = JSON.stringify({
|
|
71738
|
+
...input.siteUrl ? { site_url: input.siteUrl } : {},
|
|
71661
71739
|
protocol: "context.site-output/v1",
|
|
71662
71740
|
knowledge_map_revision: structure?.revision ?? null,
|
|
71663
71741
|
base,
|
|
@@ -71667,7 +71745,9 @@ title: LLM Docs
|
|
|
71667
71745
|
sections: sections.map(({ key, title, href, pages, items }) => ({ key, title, href, pages, items })),
|
|
71668
71746
|
warnings: mapping.warnings
|
|
71669
71747
|
}, null, 2) + `
|
|
71670
|
-
|
|
71748
|
+
`;
|
|
71749
|
+
await writeFile16(join57(output, "context-site-map.json"), siteMapContent);
|
|
71750
|
+
await writeFile16(join57(projectRoot, pkg.outDir, "context-site-map.json"), siteMapContent);
|
|
71671
71751
|
return mapping;
|
|
71672
71752
|
} finally {
|
|
71673
71753
|
await rm11(temporary, { recursive: true, force: true });
|
|
@@ -71687,13 +71767,13 @@ var init_packageSite2 = __esm(() => {
|
|
|
71687
71767
|
init_packageSiteTheme();
|
|
71688
71768
|
init_packageSiteBranding();
|
|
71689
71769
|
init_packageSiteExtensions();
|
|
71690
|
-
PACKAGE_SITE_VERSION = `vitepress-site-
|
|
71770
|
+
PACKAGE_SITE_VERSION = `vitepress-site-v44-site-address:${createHash16("sha256").update(JSON.stringify([siteMarkdownConfig, siteThemeCss, siteThemeScript, siteThemeLabels("zh"), siteThemeLabels("en")])).digest("hex")}`;
|
|
71691
71771
|
require2 = createRequire5(import.meta.url);
|
|
71692
71772
|
});
|
|
71693
71773
|
|
|
71694
71774
|
// src/project/workspaceBuildVersion.ts
|
|
71695
|
-
import { join as
|
|
71696
|
-
import { mkdir as mkdir21, writeFile as
|
|
71775
|
+
import { join as join58 } from "node:path";
|
|
71776
|
+
import { mkdir as mkdir21, writeFile as writeFile17 } from "node:fs/promises";
|
|
71697
71777
|
async function workspaceVersionFingerprint(root) {
|
|
71698
71778
|
return { version: await workspaceVersion(root), changelog: await readWorkspaceChangelog(root) };
|
|
71699
71779
|
}
|
|
@@ -71704,8 +71784,8 @@ async function writePackageVersion(projectRoot, output) {
|
|
|
71704
71784
|
throw new TypeError(`Package template uses reserved version output ${path2}; rename that template output.`);
|
|
71705
71785
|
}
|
|
71706
71786
|
await mkdir21(output, { recursive: true });
|
|
71707
|
-
await
|
|
71708
|
-
await
|
|
71787
|
+
await writeFile17(join58(output, "CHANGELOG.md"), renderChangelog(info.changelog));
|
|
71788
|
+
await writeFile17(join58(output, "context-version.json"), JSON.stringify({ version: info.version }) + `
|
|
71709
71789
|
`);
|
|
71710
71790
|
}
|
|
71711
71791
|
var init_workspaceBuildVersion = __esm(() => {
|
|
@@ -71714,14 +71794,14 @@ var init_workspaceBuildVersion = __esm(() => {
|
|
|
71714
71794
|
|
|
71715
71795
|
// src/project/packageRenderCache.ts
|
|
71716
71796
|
import { createHash as createHash17 } from "node:crypto";
|
|
71717
|
-
import { readFile as
|
|
71718
|
-
import { join as
|
|
71797
|
+
import { readFile as readFile49 } from "node:fs/promises";
|
|
71798
|
+
import { join as join59 } from "node:path";
|
|
71719
71799
|
async function cachedPackageKnowledgeMarkdown(input) {
|
|
71720
71800
|
const fingerprint = digest3(`${PACKAGE_READER_MARKDOWN_VERSION}
|
|
71721
71801
|
${input.content}`);
|
|
71722
|
-
const path2 =
|
|
71802
|
+
const path2 = join59(input.projectRoot, ".tmp/context-runtime/package-render", `${digest3(input.key)}.json`);
|
|
71723
71803
|
try {
|
|
71724
|
-
const cached = JSON.parse(await
|
|
71804
|
+
const cached = JSON.parse(await readFile49(path2, "utf8"));
|
|
71725
71805
|
if (cached !== null && typeof cached === "object" && "fingerprint" in cached && cached.fingerprint === fingerprint && "markdown" in cached && typeof cached.markdown === "string") {
|
|
71726
71806
|
return cached.markdown;
|
|
71727
71807
|
}
|
|
@@ -71760,7 +71840,7 @@ var init_packageKnowledgeAdvisories = __esm(() => {
|
|
|
71760
71840
|
|
|
71761
71841
|
// src/project/packageMarkdownAnchors.ts
|
|
71762
71842
|
import { posix as posix7 } from "node:path";
|
|
71763
|
-
import { readFile as
|
|
71843
|
+
import { readFile as readFile50 } from "node:fs/promises";
|
|
71764
71844
|
function packageMarkdownAnchors(markdown) {
|
|
71765
71845
|
const anchors = new Set;
|
|
71766
71846
|
const used = new Set;
|
|
@@ -71823,7 +71903,7 @@ async function inspectPackageMarkdownDirectory(root) {
|
|
|
71823
71903
|
const files = (await walkPackageFiles(root)).filter((file) => /\.md$/iu.test(file.relPath));
|
|
71824
71904
|
const pages = new Map;
|
|
71825
71905
|
for (let offset = 0;offset < files.length; offset += 16) {
|
|
71826
|
-
const batch = await Promise.allSettled(files.slice(offset, offset + 16).map(async (file) => [file.relPath, await
|
|
71906
|
+
const batch = await Promise.allSettled(files.slice(offset, offset + 16).map(async (file) => [file.relPath, await readFile50(file.absPath, "utf8")]));
|
|
71827
71907
|
for (const result of batch) {
|
|
71828
71908
|
if (result.status === "rejected")
|
|
71829
71909
|
throw result.reason;
|
|
@@ -71840,23 +71920,23 @@ var init_packageMarkdownAnchors = __esm(() => {
|
|
|
71840
71920
|
});
|
|
71841
71921
|
|
|
71842
71922
|
// src/project/packageBuildStage.ts
|
|
71843
|
-
import { mkdir as mkdir22, mkdtemp as mkdtemp2, readFile as
|
|
71844
|
-
import { dirname as dirname25, join as
|
|
71923
|
+
import { mkdir as mkdir22, mkdtemp as mkdtemp2, readFile as readFile51, rename as rename6, rm as rm12, rmdir } from "node:fs/promises";
|
|
71924
|
+
import { dirname as dirname25, join as join60, relative as relative16 } from "node:path";
|
|
71845
71925
|
async function withStagedPackageOutput(projectRoot, pkg, render) {
|
|
71846
|
-
const tempRoot =
|
|
71926
|
+
const tempRoot = join60(projectRoot, ".tmp");
|
|
71847
71927
|
await mkdir22(tempRoot, { recursive: true });
|
|
71848
|
-
const stage = await mkdtemp2(
|
|
71849
|
-
const stagedPackage = { ...pkg, outDir: relative16(projectRoot,
|
|
71928
|
+
const stage = await mkdtemp2(join60(tempRoot, "package-build-"));
|
|
71929
|
+
const stagedPackage = { ...pkg, outDir: relative16(projectRoot, join60(stage, pkg.name)) };
|
|
71850
71930
|
try {
|
|
71851
|
-
await mkdir22(
|
|
71931
|
+
await mkdir22(join60(projectRoot, stagedPackage.outDir), { recursive: true });
|
|
71852
71932
|
const value = await render(stagedPackage);
|
|
71853
71933
|
await validatePackageIndexLinks({ projectRoot, pkg: stagedPackage });
|
|
71854
71934
|
const destinations = packageOutputDirs(pkg);
|
|
71855
71935
|
const staged = packageOutputDirs(stagedPackage);
|
|
71856
71936
|
for (const [index2, destination] of destinations.entries()) {
|
|
71857
|
-
const target =
|
|
71937
|
+
const target = join60(projectRoot, destination);
|
|
71858
71938
|
const previous2 = await walkPackageFiles(target);
|
|
71859
|
-
const next = await walkPackageFiles(
|
|
71939
|
+
const next = await walkPackageFiles(join60(projectRoot, staged[index2]));
|
|
71860
71940
|
const desired = new Set(next.map((file) => file.relPath));
|
|
71861
71941
|
for (const file of previous2) {
|
|
71862
71942
|
if (desired.has(file.relPath))
|
|
@@ -71874,9 +71954,9 @@ async function withStagedPackageOutput(projectRoot, pkg, render) {
|
|
|
71874
71954
|
}
|
|
71875
71955
|
for (let offset = 0;offset < next.length; offset += 8) {
|
|
71876
71956
|
const results = await Promise.allSettled(next.slice(offset, offset + 8).map(async (file) => {
|
|
71877
|
-
const output =
|
|
71878
|
-
const bytes = await
|
|
71879
|
-
const old = await
|
|
71957
|
+
const output = join60(target, file.relPath);
|
|
71958
|
+
const bytes = await readFile51(file.absPath);
|
|
71959
|
+
const old = await readFile51(output).catch((error) => {
|
|
71880
71960
|
if (error.code === "ENOENT")
|
|
71881
71961
|
return;
|
|
71882
71962
|
throw error;
|
|
@@ -71884,7 +71964,7 @@ async function withStagedPackageOutput(projectRoot, pkg, render) {
|
|
|
71884
71964
|
if (old?.equals(bytes))
|
|
71885
71965
|
return;
|
|
71886
71966
|
await mkdir22(dirname25(output), { recursive: true });
|
|
71887
|
-
await
|
|
71967
|
+
await rename6(file.absPath, output);
|
|
71888
71968
|
}));
|
|
71889
71969
|
for (const result of results)
|
|
71890
71970
|
if (result.status === "rejected")
|
|
@@ -71947,7 +72027,7 @@ var init_packageArticleLinks = __esm(() => {
|
|
|
71947
72027
|
});
|
|
71948
72028
|
|
|
71949
72029
|
// src/project/packageAssets.ts
|
|
71950
|
-
import { readFile as
|
|
72030
|
+
import { readFile as readFile52 } from "node:fs/promises";
|
|
71951
72031
|
import { dirname as dirname26, relative as relative17, sep as sep4 } from "node:path";
|
|
71952
72032
|
function posixPath2(value) {
|
|
71953
72033
|
return value.split(sep4).join("/");
|
|
@@ -71986,7 +72066,7 @@ async function projectPackageKnowledgeAssets(input) {
|
|
|
71986
72066
|
const paths = packageAssetPath(input.projectRoot, absolute);
|
|
71987
72067
|
let bytes;
|
|
71988
72068
|
try {
|
|
71989
|
-
bytes = await
|
|
72069
|
+
bytes = await readFile52(absolute);
|
|
71990
72070
|
} catch {
|
|
71991
72071
|
throw new ContextError(ExitCode.WorkspaceStateError, `knowledge resource is missing: ${paths.knowledgeRelPath}`, {
|
|
71992
72072
|
category: ErrorCategory.WorkspaceStateInvalid,
|
|
@@ -72260,7 +72340,7 @@ var init_packageAssetOptimization = __esm(() => {
|
|
|
72260
72340
|
// src/project/packageAssetDelivery.ts
|
|
72261
72341
|
import { execFile as execFile8 } from "node:child_process";
|
|
72262
72342
|
import { realpath as realpath7 } from "node:fs/promises";
|
|
72263
|
-
import { join as
|
|
72343
|
+
import { join as join61, relative as relative18, sep as sep5 } from "node:path";
|
|
72264
72344
|
import { promisify as promisify8 } from "node:util";
|
|
72265
72345
|
async function git(projectRoot, args) {
|
|
72266
72346
|
try {
|
|
@@ -72280,7 +72360,7 @@ async function git(projectRoot, args) {
|
|
|
72280
72360
|
}
|
|
72281
72361
|
}
|
|
72282
72362
|
function repositoryPath(repoRoot, projectRoot, asset) {
|
|
72283
|
-
const path2 = relative18(repoRoot,
|
|
72363
|
+
const path2 = relative18(repoRoot, join61(projectRoot, asset.knowledgeRelPath)).split(sep5).join("/");
|
|
72284
72364
|
if (path2 === ".." || path2.startsWith("../") || path2.startsWith("/")) {
|
|
72285
72365
|
throw new ContextError(ExitCode.WorkspaceStateError, "knowledge asset is outside the current Git repository", {
|
|
72286
72366
|
category: ErrorCategory.WorkspaceStateInvalid,
|
|
@@ -72459,8 +72539,8 @@ var init_packageAssetDelivery = __esm(() => {
|
|
|
72459
72539
|
|
|
72460
72540
|
// src/project/packageBuildContent.ts
|
|
72461
72541
|
import { existsSync as existsSync16 } from "node:fs";
|
|
72462
|
-
import { mkdir as mkdir23, readFile as
|
|
72463
|
-
import { dirname as dirname28, join as
|
|
72542
|
+
import { mkdir as mkdir23, readFile as readFile53, writeFile as writeFile18 } from "node:fs/promises";
|
|
72543
|
+
import { dirname as dirname28, join as join62 } from "node:path";
|
|
72464
72544
|
function globToRegExp(pattern) {
|
|
72465
72545
|
const normalized = toPosixPath4(pattern);
|
|
72466
72546
|
if (normalized.endsWith("/**")) {
|
|
@@ -72601,9 +72681,9 @@ async function writeRenderedPackageTemplate(input) {
|
|
|
72601
72681
|
templateRelPath: renderedRelPath,
|
|
72602
72682
|
logicalTemplateRelPath: renderedLogicalRelPath
|
|
72603
72683
|
});
|
|
72604
|
-
const outputPath =
|
|
72684
|
+
const outputPath = join62(input.projectRoot, input.pkg.outDir, renderedRelPath);
|
|
72605
72685
|
await mkdir23(dirname28(outputPath), { recursive: true });
|
|
72606
|
-
await
|
|
72686
|
+
await writeFile18(outputPath, renderTemplateText(file.content, contentVars), "utf8");
|
|
72607
72687
|
written++;
|
|
72608
72688
|
}
|
|
72609
72689
|
return { files: written, consumesKnowledge };
|
|
@@ -72634,7 +72714,7 @@ async function writeSelectedPackageKnowledge(input) {
|
|
|
72634
72714
|
for (let offset = 0;offset < projectedPages.length; offset += 8) {
|
|
72635
72715
|
const results = await Promise.allSettled(projectedPages.slice(offset, offset + 8).map(async (projected) => {
|
|
72636
72716
|
assertSafeRenderedPath2(projected.pageOutputPath, "knowledge path");
|
|
72637
|
-
const outputPath =
|
|
72717
|
+
const outputPath = join62(input.projectRoot, input.pkg.outDir, projected.pageOutputPath);
|
|
72638
72718
|
const rewritten = replaceMarkdownInlineLinkTargets(projected.content, (link) => {
|
|
72639
72719
|
for (const [inputPath, outputPath2] of delivered.targetByOriginal) {
|
|
72640
72720
|
if (link.target === packageMarkdownTarget(projected.pageOutputPath, inputPath)) {
|
|
@@ -72651,7 +72731,7 @@ async function writeSelectedPackageKnowledge(input) {
|
|
|
72651
72731
|
content: links.markdown
|
|
72652
72732
|
});
|
|
72653
72733
|
const file = byPath.get(approvedByOutput.get(projected.pageOutputPath));
|
|
72654
|
-
await
|
|
72734
|
+
await writeFile18(outputPath, markdown + articleProvenanceMarkdown(file?.article, registry2), "utf8");
|
|
72655
72735
|
return links.warnings;
|
|
72656
72736
|
}));
|
|
72657
72737
|
for (const result of results) {
|
|
@@ -72663,9 +72743,9 @@ async function writeSelectedPackageKnowledge(input) {
|
|
|
72663
72743
|
const deliveredAssets = new Map(delivered.assets.map((asset) => [asset.packageRelPath, asset]));
|
|
72664
72744
|
for (const asset of deliveredAssets.values()) {
|
|
72665
72745
|
assertSafeRenderedPath2(asset.packageRelPath, "package resource path");
|
|
72666
|
-
const outputPath =
|
|
72746
|
+
const outputPath = join62(input.projectRoot, input.pkg.outDir, asset.packageRelPath);
|
|
72667
72747
|
await mkdir23(dirname28(outputPath), { recursive: true });
|
|
72668
|
-
await
|
|
72748
|
+
await writeFile18(outputPath, asset.bytes);
|
|
72669
72749
|
}
|
|
72670
72750
|
return {
|
|
72671
72751
|
pages: projectedPages.length,
|
|
@@ -72678,9 +72758,9 @@ async function writeSelectedPackageKnowledge(input) {
|
|
|
72678
72758
|
async function appendLlmsKnowledge(input) {
|
|
72679
72759
|
if (packageKind2(input.pkg) !== "llms" || input.templateConsumesKnowledge || input.knowledgeCount === 0)
|
|
72680
72760
|
return 0;
|
|
72681
|
-
const outputPath =
|
|
72761
|
+
const outputPath = join62(input.projectRoot, input.pkg.outDir, "llms.txt");
|
|
72682
72762
|
const existed = existsSync16(outputPath);
|
|
72683
|
-
const existing = existed ? await
|
|
72763
|
+
const existing = existed ? await readFile53(outputPath, "utf8") : "";
|
|
72684
72764
|
const content3 = existing.trim().length > 0 ? `${existing.trimEnd()}
|
|
72685
72765
|
|
|
72686
72766
|
---
|
|
@@ -72689,7 +72769,7 @@ ${input.bundle}
|
|
|
72689
72769
|
` : `${input.bundle}
|
|
72690
72770
|
`;
|
|
72691
72771
|
await mkdir23(dirname28(outputPath), { recursive: true });
|
|
72692
|
-
await
|
|
72772
|
+
await writeFile18(outputPath, content3, "utf8");
|
|
72693
72773
|
return existed ? 0 : 1;
|
|
72694
72774
|
}
|
|
72695
72775
|
var init_packageBuildContent = __esm(() => {
|
|
@@ -72904,8 +72984,8 @@ __export(exports_packageBuilder, {
|
|
|
72904
72984
|
});
|
|
72905
72985
|
import { createHash as createHash19 } from "node:crypto";
|
|
72906
72986
|
import { existsSync as existsSync17 } from "node:fs";
|
|
72907
|
-
import { mkdir as mkdir24, readdir as readdir15, readFile as
|
|
72908
|
-
import { dirname as dirname29, join as
|
|
72987
|
+
import { mkdir as mkdir24, readdir as readdir15, readFile as readFile54, rm as rm13, writeFile as writeFile19 } from "node:fs/promises";
|
|
72988
|
+
import { dirname as dirname29, join as join63, resolve as resolve20 } from "node:path";
|
|
72909
72989
|
function packageAssetDeliverySummary(value) {
|
|
72910
72990
|
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
72911
72991
|
return;
|
|
@@ -72927,7 +73007,7 @@ function assertPackageOutputDir(pkg) {
|
|
|
72927
73007
|
}
|
|
72928
73008
|
function packageFingerprintPath(projectRoot, pkg) {
|
|
72929
73009
|
assertSafeRenderedPath2(`${pkg.name}.json`, "package fingerprint path");
|
|
72930
|
-
return
|
|
73010
|
+
return join63(projectRoot, PACKAGE_FINGERPRINT_ROOT, `${pkg.name}.json`);
|
|
72931
73011
|
}
|
|
72932
73012
|
async function listApprovedKnowledge(projectRoot) {
|
|
72933
73013
|
const metadata = await readApprovedKnowledgeMetadataIndex(projectRoot);
|
|
@@ -72968,7 +73048,7 @@ async function listTemplateFiles(projectRoot, templatePath) {
|
|
|
72968
73048
|
const files = await walkPackageFiles(templateRoot);
|
|
72969
73049
|
return Promise.all(files.filter((file) => file.relPath.split("/").at(-1) !== PACKAGE_TEMPLATE_REVIEW_FILE).map(async (file) => ({
|
|
72970
73050
|
...file,
|
|
72971
|
-
content: await
|
|
73051
|
+
content: await readFile54(file.absPath, "utf8")
|
|
72972
73052
|
})));
|
|
72973
73053
|
}
|
|
72974
73054
|
function stableHash2(value) {
|
|
@@ -73031,7 +73111,7 @@ async function readPackageManifest(projectRoot, pkg) {
|
|
|
73031
73111
|
if (!existsSync17(filePath2))
|
|
73032
73112
|
return null;
|
|
73033
73113
|
try {
|
|
73034
|
-
const parsed = JSON.parse(await
|
|
73114
|
+
const parsed = JSON.parse(await readFile54(filePath2, "utf8"));
|
|
73035
73115
|
if (parsed !== null && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
73036
73116
|
const candidate = parsed;
|
|
73037
73117
|
if (typeof candidate.builder_protocol === "string" && typeof candidate.fingerprint === "string" && typeof candidate.output_fingerprint === "string" && typeof candidate.output_files === "number" && Array.isArray(candidate.outputs)) {
|
|
@@ -73063,7 +73143,7 @@ async function readPackageManifest(projectRoot, pkg) {
|
|
|
73063
73143
|
async function writePackageFingerprint(input) {
|
|
73064
73144
|
const filePath2 = packageFingerprintPath(input.projectRoot, input.pkg);
|
|
73065
73145
|
await mkdir24(dirname29(filePath2), { recursive: true });
|
|
73066
|
-
await
|
|
73146
|
+
await writeFile19(filePath2, `${JSON.stringify({
|
|
73067
73147
|
package: input.pkg.name,
|
|
73068
73148
|
kind: packageKind2(input.pkg),
|
|
73069
73149
|
builder_protocol: PACKAGE_BUILDER_PROTOCOL_VERSION,
|
|
@@ -73078,12 +73158,12 @@ async function writePackageFingerprint(input) {
|
|
|
73078
73158
|
`, "utf8");
|
|
73079
73159
|
}
|
|
73080
73160
|
async function removeOrphanPackageDirs(projectRoot, packages) {
|
|
73081
|
-
const distRoot =
|
|
73161
|
+
const distRoot = join63(projectRoot, "dist");
|
|
73082
73162
|
if (!existsSync17(distRoot))
|
|
73083
73163
|
return;
|
|
73084
73164
|
const declaredNames = new Set(packages.flatMap((pkg) => packageOutputDirs(pkg).map((path2) => path2.slice("dist/".length))));
|
|
73085
73165
|
const entries2 = await readdir15(distRoot, { withFileTypes: true });
|
|
73086
|
-
await Promise.all(entries2.filter((entry) => entry.isDirectory() && !declaredNames.has(entry.name)).map((entry) => rm13(
|
|
73166
|
+
await Promise.all(entries2.filter((entry) => entry.isDirectory() && !declaredNames.has(entry.name)).map((entry) => rm13(join63(distRoot, entry.name), { recursive: true, force: true, maxRetries: 3, retryDelay: 100 })));
|
|
73087
73167
|
}
|
|
73088
73168
|
async function collectPackageFreshness(projectRoot, packages) {
|
|
73089
73169
|
assertDistinctPackageOutputs(packages);
|
|
@@ -73092,7 +73172,7 @@ async function collectPackageFreshness(projectRoot, packages) {
|
|
|
73092
73172
|
assertPackageOutputDir(pkg);
|
|
73093
73173
|
const selected = selectPackageKnowledge(approved, pkg);
|
|
73094
73174
|
assertSafeRenderedPath2(pkg.template.path, "package template path");
|
|
73095
|
-
const templateRoot =
|
|
73175
|
+
const templateRoot = join63(projectRoot, pkg.template.path);
|
|
73096
73176
|
const templateExists = existsSync17(templateRoot);
|
|
73097
73177
|
if (!templateExists) {
|
|
73098
73178
|
throw new ContextError(ExitCode.WorkspaceStateError, `package template path is missing: ${pkg.template.path}`, {
|
|
@@ -73283,6 +73363,7 @@ async function buildProjectPackagesInternal(projectRoot, options) {
|
|
|
73283
73363
|
files: selected,
|
|
73284
73364
|
...assetProcessor === undefined ? {} : { assetProcessor }
|
|
73285
73365
|
});
|
|
73366
|
+
const siteUrl = await readPackageSiteUrl(projectRoot, pkg);
|
|
73286
73367
|
const writtenKnowledge = await withStagedPackageOutput(projectRoot, pkg, async (stagedPkg) => {
|
|
73287
73368
|
const rendered = await writeRenderedPackageTemplate({
|
|
73288
73369
|
projectRoot,
|
|
@@ -73320,19 +73401,19 @@ async function buildProjectPackagesInternal(projectRoot, options) {
|
|
|
73320
73401
|
if (stagedPkg.kind === "package.llms") {
|
|
73321
73402
|
const articles = await Promise.all(llmsArticles(stagedPkg, selected).map(async (article) => ({
|
|
73322
73403
|
...article,
|
|
73323
|
-
content: await
|
|
73404
|
+
content: await readFile54(join63(projectRoot, stagedPkg.outDir, article.path), "utf8")
|
|
73324
73405
|
})));
|
|
73325
|
-
await writeLlmsDocuments(
|
|
73406
|
+
await writeLlmsDocuments(join63(projectRoot, stagedPkg.outDir), buildLlmsDocuments({
|
|
73326
73407
|
title: stagedPkg.name,
|
|
73327
73408
|
articles,
|
|
73328
73409
|
...reading ? { map: reading } : {}
|
|
73329
73410
|
}), { preserveIndex: true });
|
|
73330
73411
|
}
|
|
73331
|
-
await writePackageVersion(projectRoot,
|
|
73332
|
-
await writePackageSite({ projectRoot, pkg: stagedPkg, selected, ...reading ? { structure: reading } : {} });
|
|
73412
|
+
await writePackageVersion(projectRoot, join63(projectRoot, stagedPkg.outDir));
|
|
73413
|
+
await writePackageSite({ projectRoot, pkg: stagedPkg, selected, ...siteUrl ? { siteUrl } : {}, ...reading ? { structure: reading } : {} });
|
|
73333
73414
|
const linkWarnings = [
|
|
73334
73415
|
...writtenKnowledge2.linkWarnings,
|
|
73335
|
-
...await inspectPackageMarkdownDirectory(
|
|
73416
|
+
...await inspectPackageMarkdownDirectory(join63(projectRoot, stagedPkg.outDir))
|
|
73336
73417
|
];
|
|
73337
73418
|
return { ...writtenKnowledge2, linkWarnings };
|
|
73338
73419
|
});
|
|
@@ -73380,7 +73461,8 @@ async function buildProjectPackagesInternal(projectRoot, options) {
|
|
|
73380
73461
|
const revisionInterruptedProduction = !!production && !!await readApprovedRevision2(projectRoot);
|
|
73381
73462
|
await finishApprovedRevision(projectRoot);
|
|
73382
73463
|
const { readKnowledgeUpdate } = await Promise.resolve().then(() => (init_knowledgeUpdate(), exports_knowledgeUpdate));
|
|
73383
|
-
|
|
73464
|
+
const productionEnded = !production || dispatchProductionStage(production, productionCapabilitiesSchema.parse({})).state === "ended";
|
|
73465
|
+
if (productionEnded && !revisionInterruptedProduction && !production?.delivery && !maintenanceActive && !await readTaskRollback(projectRoot) && !await readApprovedRevision2(projectRoot) && !await readKnowledgeUpdate(projectRoot) && (await readProjectCloseStatus(projectRoot)).state === "ready") {
|
|
73384
73466
|
const { clearCompletedLifecycle: clearCompletedLifecycle2 } = await Promise.resolve().then(() => (init_lifecycleCleanup(), exports_lifecycleCleanup));
|
|
73385
73467
|
await clearCompletedLifecycle2(projectRoot);
|
|
73386
73468
|
}
|
|
@@ -73483,8 +73565,10 @@ async function runProjectBuildCommand(input) {
|
|
|
73483
73565
|
}
|
|
73484
73566
|
var import_yaml35, PACKAGE_FINGERPRINT_ROOT, PACKAGE_BUILDER_PROTOCOL_VERSION = "v23-sibling-site-output";
|
|
73485
73567
|
var init_packageBuilder = __esm(() => {
|
|
73568
|
+
init_packageSiteAddress();
|
|
73486
73569
|
init_knowledgeMap2();
|
|
73487
73570
|
init_approvedFileRead();
|
|
73571
|
+
init_productionStage();
|
|
73488
73572
|
init_productionStageStore();
|
|
73489
73573
|
init_productionDelivery();
|
|
73490
73574
|
init_writeLock();
|
|
@@ -73520,7 +73604,7 @@ var init_packageBuilder = __esm(() => {
|
|
|
73520
73604
|
init_packageTemplateReview();
|
|
73521
73605
|
init_approvedKnowledgeMetadata();
|
|
73522
73606
|
import_yaml35 = __toESM(require_dist(), 1);
|
|
73523
|
-
PACKAGE_FINGERPRINT_ROOT =
|
|
73607
|
+
PACKAGE_FINGERPRINT_ROOT = join63(".tmp", "context-runtime", "packages");
|
|
73524
73608
|
});
|
|
73525
73609
|
|
|
73526
73610
|
// src/project/taskRollback.ts
|
|
@@ -73530,8 +73614,8 @@ __export(exports_taskRollback, {
|
|
|
73530
73614
|
readTaskRollback: () => readTaskRollback,
|
|
73531
73615
|
finishTaskRollback: () => finishTaskRollback
|
|
73532
73616
|
});
|
|
73533
|
-
import { readFile as
|
|
73534
|
-
import { join as
|
|
73617
|
+
import { readFile as readFile55 } from "node:fs/promises";
|
|
73618
|
+
import { join as join64 } from "node:path";
|
|
73535
73619
|
async function readTaskRollback(projectRoot) {
|
|
73536
73620
|
const raw = await readJsonMaybe(projectRoot, await revisionStoragePath(projectRoot));
|
|
73537
73621
|
if (!raw || typeof raw !== "object" || !("protocol" in raw) || raw.protocol !== "context.task-rollback/v1")
|
|
@@ -73540,7 +73624,7 @@ async function readTaskRollback(projectRoot) {
|
|
|
73540
73624
|
}
|
|
73541
73625
|
async function contents(projectRoot, path2) {
|
|
73542
73626
|
try {
|
|
73543
|
-
return await
|
|
73627
|
+
return await readFile55(join64(projectRoot, path2), "utf8");
|
|
73544
73628
|
} catch (error) {
|
|
73545
73629
|
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT")
|
|
73546
73630
|
return;
|
|
@@ -73707,12 +73791,12 @@ __export(exports_knowledgeUpdate, {
|
|
|
73707
73791
|
completeKnowledgeUpdate: () => completeKnowledgeUpdate,
|
|
73708
73792
|
beginKnowledgeUpdate: () => beginKnowledgeUpdate
|
|
73709
73793
|
});
|
|
73710
|
-
import { readFile as
|
|
73711
|
-
import { join as
|
|
73794
|
+
import { readFile as readFile56 } from "node:fs/promises";
|
|
73795
|
+
import { join as join65 } from "node:path";
|
|
73712
73796
|
async function readKnowledgeUpdate(projectRoot) {
|
|
73713
73797
|
let value;
|
|
73714
73798
|
try {
|
|
73715
|
-
value = JSON.parse(await
|
|
73799
|
+
value = JSON.parse(await readFile56(join65(projectRoot, await revisionStoragePath(projectRoot)), "utf8"));
|
|
73716
73800
|
} catch (error) {
|
|
73717
73801
|
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT")
|
|
73718
73802
|
return;
|
|
@@ -73763,7 +73847,7 @@ async function beginKnowledgeUpdate(projectRoot, value) {
|
|
|
73763
73847
|
...input.changes === undefined ? {} : { changes: input.changes }
|
|
73764
73848
|
};
|
|
73765
73849
|
const request = updateSchema.parse({ ...payload, revision: indexerProtocolDigest(payload) });
|
|
73766
|
-
await atomicWriteFile(
|
|
73850
|
+
await atomicWriteFile(join65(projectRoot, await revisionStoragePath(projectRoot)), `${JSON.stringify(request)}
|
|
73767
73851
|
`);
|
|
73768
73852
|
return {
|
|
73769
73853
|
outcome: "update-prepared",
|
|
@@ -73808,7 +73892,7 @@ async function completeKnowledgeUpdate(input) {
|
|
|
73808
73892
|
if (input.new_topics.length && !input.structure_approved) {
|
|
73809
73893
|
const { revision: _revision, ...rest } = request;
|
|
73810
73894
|
const payload = { ...rest, structure_proposal: { decisions: input.decisions, scope_summary: input.scope_summary, new_topics: input.new_topics } };
|
|
73811
|
-
await atomicWriteFile(
|
|
73895
|
+
await atomicWriteFile(join65(input.projectRoot, await revisionStoragePath(input.projectRoot)), `${JSON.stringify({ ...payload, revision: indexerProtocolDigest(payload) })}
|
|
73812
73896
|
`);
|
|
73813
73897
|
return { outcome: "structure-review-required" };
|
|
73814
73898
|
}
|
|
@@ -73845,7 +73929,7 @@ async function completeUpdateStructureReview(input) {
|
|
|
73845
73929
|
const { revision: _revision, structure_proposal: _proposal, ...rest } = request;
|
|
73846
73930
|
const payload = { ...rest, changes: `${rest.changes ?? ""}
|
|
73847
73931
|
Structure feedback: ${input.feedback}` };
|
|
73848
|
-
await atomicWriteFile(
|
|
73932
|
+
await atomicWriteFile(join65(input.projectRoot, await revisionStoragePath(input.projectRoot)), `${JSON.stringify({ ...payload, revision: indexerProtocolDigest(payload) })}
|
|
73849
73933
|
`);
|
|
73850
73934
|
return { outcome: "structure-adjustment-required" };
|
|
73851
73935
|
});
|
|
@@ -74018,15 +74102,15 @@ __export(exports_knowledgeMaintenance, {
|
|
|
74018
74102
|
cancelKnowledgeMaintenance: () => cancelKnowledgeMaintenance,
|
|
74019
74103
|
advanceKnowledgeMaintenance: () => advanceKnowledgeMaintenance
|
|
74020
74104
|
});
|
|
74021
|
-
import { readFile as
|
|
74022
|
-
import { join as
|
|
74105
|
+
import { readFile as readFile57, readdir as readdir16, rm as rm14 } from "node:fs/promises";
|
|
74106
|
+
import { join as join66 } from "node:path";
|
|
74023
74107
|
async function deliveryDigest(root) {
|
|
74024
|
-
const directory =
|
|
74108
|
+
const directory = join66(root, ".tmp/context-runtime/packages");
|
|
74025
74109
|
try {
|
|
74026
74110
|
const files = (await readdir16(directory)).filter((name2) => name2.endsWith(".json")).sort();
|
|
74027
74111
|
if (!files.length)
|
|
74028
74112
|
return indexerProtocolDigest(null);
|
|
74029
|
-
return indexerProtocolDigest(await Promise.all(files.map((name2) =>
|
|
74113
|
+
return indexerProtocolDigest(await Promise.all(files.map((name2) => readFile57(join66(directory, name2), "utf8"))));
|
|
74030
74114
|
} catch (error) {
|
|
74031
74115
|
if (error.code === "ENOENT")
|
|
74032
74116
|
return indexerProtocolDigest(null);
|
|
@@ -74125,7 +74209,7 @@ async function observeKnowledgeMaintenance(root) {
|
|
|
74125
74209
|
async function maintenanceRevision(root) {
|
|
74126
74210
|
const observed = await observeKnowledgeMaintenance(root);
|
|
74127
74211
|
const localInputs = observed.state.active ? {
|
|
74128
|
-
revision: await
|
|
74212
|
+
revision: await readFile57(join66(root, MAINTENANCE_ROOT, "revision.json"), "utf8").catch((error) => {
|
|
74129
74213
|
if (error.code === "ENOENT")
|
|
74130
74214
|
return null;
|
|
74131
74215
|
throw error;
|
|
@@ -74202,7 +74286,7 @@ async function finishMaintenanceRevision(root, outcome = "completed") {
|
|
|
74202
74286
|
outcome = state.active.completion_outcome;
|
|
74203
74287
|
state.active.phase = "finishing";
|
|
74204
74288
|
await saveMaintenance(root, state);
|
|
74205
|
-
await rm14(
|
|
74289
|
+
await rm14(join66(root, MAINTENANCE_ROOT, "revision.json"), { force: true });
|
|
74206
74290
|
state.completed.push({ id: state.active.input.id, input_digest: indexerProtocolDigest(state.active.input), outcome });
|
|
74207
74291
|
delete state.active;
|
|
74208
74292
|
await saveMaintenance(root, state);
|
|
@@ -74236,8 +74320,8 @@ async function discardMaintenanceDraft(root) {
|
|
|
74236
74320
|
const owned = new Set([...request?.batch_candidates ?? [], ...request?.candidate ? [request.candidate] : []].map((item) => item.candidate_id));
|
|
74237
74321
|
if (candidates.some((item) => !owned.has(item.candidate_id)))
|
|
74238
74322
|
throw new TypeError("Unrelated Candidates are present; no draft was discarded. Inspect the current review before retrying cancellation.");
|
|
74239
|
-
await rm14(
|
|
74240
|
-
await rm14(
|
|
74323
|
+
await rm14(join66(root, CANDIDATE_LEDGER_FILE), { force: true });
|
|
74324
|
+
await rm14(join66(root, MAINTENANCE_ROOT, "revision.json"), { force: true });
|
|
74241
74325
|
const { closeProjectWorkspace: closeProjectWorkspace2 } = await Promise.resolve().then(() => (init_close(), exports_close));
|
|
74242
74326
|
const { buildProjectPackages: buildProjectPackages2 } = await Promise.resolve().then(() => (init_packageBuilder(), exports_packageBuilder));
|
|
74243
74327
|
await closeProjectWorkspace2(root);
|
|
@@ -74275,8 +74359,8 @@ __export(exports_approvedRevision, {
|
|
|
74275
74359
|
assertApprovedRevisionBase: () => assertApprovedRevisionBase,
|
|
74276
74360
|
APPROVED_REVISION_PATH: () => APPROVED_REVISION_PATH
|
|
74277
74361
|
});
|
|
74278
|
-
import { readFile as
|
|
74279
|
-
import { join as
|
|
74362
|
+
import { readFile as readFile58, realpath as realpath8, rm as rm15 } from "node:fs/promises";
|
|
74363
|
+
import { join as join67, relative as relative19, isAbsolute as isAbsolute12 } from "node:path";
|
|
74280
74364
|
function requestDigest(input) {
|
|
74281
74365
|
const scopes = input.processed_scopes?.filter((scope2) => input.target.source_refs.some((ref) => ref === scope2.source_ref || ref.startsWith(`${scope2.source_ref}#`) || ref.startsWith(`${scope2.source_ref}/`)));
|
|
74282
74366
|
const ids = new Set(scopes?.map((scope2) => scope2.requirement_ref));
|
|
@@ -74314,7 +74398,7 @@ function revisionCandidateFingerprint(revision, markdown, sections) {
|
|
|
74314
74398
|
}
|
|
74315
74399
|
async function readApprovedRevision(projectRoot) {
|
|
74316
74400
|
try {
|
|
74317
|
-
return parseApprovedRevision(JSON.parse(await
|
|
74401
|
+
return parseApprovedRevision(JSON.parse(await readFile58(join67(projectRoot, await revisionStoragePath(projectRoot)), "utf8")));
|
|
74318
74402
|
} catch (error) {
|
|
74319
74403
|
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT")
|
|
74320
74404
|
return;
|
|
@@ -74373,16 +74457,16 @@ async function resolveApprovedRevisionAuthor(projectRoot, request) {
|
|
|
74373
74457
|
}
|
|
74374
74458
|
async function targetBytes(projectRoot, path2) {
|
|
74375
74459
|
const project = await realpath8(projectRoot);
|
|
74376
|
-
const root = await realpath8(
|
|
74460
|
+
const root = await realpath8(join67(projectRoot, "knowledge"));
|
|
74377
74461
|
const rootRelative = relative19(project, root);
|
|
74378
74462
|
if (isAbsolute12(rootRelative) || rootRelative === ".." || rootRelative.startsWith("../")) {
|
|
74379
74463
|
throw new TypeError("Approved knowledge directory leaves the Context workspace");
|
|
74380
74464
|
}
|
|
74381
|
-
const target = await realpath8(
|
|
74465
|
+
const target = await realpath8(join67(root, path2));
|
|
74382
74466
|
const rel = relative19(root, target);
|
|
74383
74467
|
if (isAbsolute12(rel) || rel === ".." || rel.startsWith("../"))
|
|
74384
74468
|
throw new TypeError("Approved revision target leaves knowledge/");
|
|
74385
|
-
return
|
|
74469
|
+
return readFile58(target, "utf8");
|
|
74386
74470
|
}
|
|
74387
74471
|
async function assertApprovedRevisionBase(projectRoot, request) {
|
|
74388
74472
|
let current;
|
|
@@ -74534,7 +74618,7 @@ ${import_yaml36.default.stringify({ ...import_yaml36.default.parse(fields), type
|
|
|
74534
74618
|
revision: requestDigest(payload)
|
|
74535
74619
|
});
|
|
74536
74620
|
if (input.persist !== false)
|
|
74537
|
-
await atomicWriteFile(
|
|
74621
|
+
await atomicWriteFile(join67(input.projectRoot, await revisionStoragePath(input.projectRoot)), `${JSON.stringify(request)}
|
|
74538
74622
|
`);
|
|
74539
74623
|
return {
|
|
74540
74624
|
status: "author-reopened",
|
|
@@ -74645,17 +74729,17 @@ async function completeApprovedRevision(input) {
|
|
|
74645
74729
|
const { prepareRevisionBatchContinuation: prepareRevisionBatchContinuation3 } = await Promise.resolve().then(() => (init_approvedRevisionBatch(), exports_approvedRevisionBatch));
|
|
74646
74730
|
const next2 = await prepareRevisionBatchContinuation3(input.projectRoot, request, request.batch_candidates ?? []);
|
|
74647
74731
|
if (next2 || request.batch_candidates?.length || request.build_pending) {
|
|
74648
|
-
await atomicWriteFile(
|
|
74732
|
+
await atomicWriteFile(join67(input.projectRoot, await revisionStoragePath(input.projectRoot)), `${JSON.stringify(next2 ?? { ...request, review_ready: true })}
|
|
74649
74733
|
`);
|
|
74650
74734
|
} else {
|
|
74651
74735
|
await advanceApprovedRevision(input.projectRoot, request);
|
|
74652
74736
|
}
|
|
74653
74737
|
return;
|
|
74654
74738
|
}
|
|
74655
|
-
const current = await
|
|
74739
|
+
const current = await readFile58(join67(input.projectRoot, await revisionStoragePath(input.projectRoot)), "utf8");
|
|
74656
74740
|
let previous2;
|
|
74657
74741
|
try {
|
|
74658
|
-
previous2 = await
|
|
74742
|
+
previous2 = await readFile58(join67(input.projectRoot, CANDIDATE_LEDGER_FILE), "utf8");
|
|
74659
74743
|
} catch (error) {
|
|
74660
74744
|
if (!(error && typeof error === "object" && ("code" in error) && error.code === "ENOENT"))
|
|
74661
74745
|
throw error;
|
|
@@ -74737,7 +74821,7 @@ async function advanceApprovedRevision(projectRoot, request, buildPending = fals
|
|
|
74737
74821
|
return;
|
|
74738
74822
|
const { readProductionStage: readProductionStage2 } = await Promise.resolve().then(() => (init_productionStageStore(), exports_productionStageStore));
|
|
74739
74823
|
if (await readProductionStage2(projectRoot)) {
|
|
74740
|
-
await rm15(
|
|
74824
|
+
await rm15(join67(projectRoot, await revisionStoragePath(projectRoot)), { force: true });
|
|
74741
74825
|
return;
|
|
74742
74826
|
}
|
|
74743
74827
|
const { clearCompletedLifecycle: clearCompletedLifecycle2 } = await Promise.resolve().then(() => (init_lifecycleCleanup(), exports_lifecycleCleanup));
|
|
@@ -74808,12 +74892,12 @@ async function reopenApprovedRevision(input) {
|
|
|
74808
74892
|
}))
|
|
74809
74893
|
} : {}
|
|
74810
74894
|
} };
|
|
74811
|
-
const current = await
|
|
74895
|
+
const current = await readFile58(join67(input.projectRoot, await revisionStoragePath(input.projectRoot)), "utf8");
|
|
74812
74896
|
const content3 = `${JSON.stringify({ ...payload, revision: requestDigest(payload) })}
|
|
74813
74897
|
`;
|
|
74814
74898
|
let ledger;
|
|
74815
74899
|
try {
|
|
74816
|
-
ledger = await
|
|
74900
|
+
ledger = await readFile58(join67(input.projectRoot, CANDIDATE_LEDGER_FILE), "utf8");
|
|
74817
74901
|
} catch (error) {
|
|
74818
74902
|
if (!(error && typeof error === "object" && ("code" in error) && error.code === "ENOENT"))
|
|
74819
74903
|
throw error;
|
|
@@ -80856,7 +80940,7 @@ var require_acorn_jsx = __commonJS((exports, module) => {
|
|
|
80856
80940
|
|
|
80857
80941
|
// src/project/documentRun.ts
|
|
80858
80942
|
import { existsSync as existsSync18 } from "node:fs";
|
|
80859
|
-
import { join as
|
|
80943
|
+
import { join as join70 } from "node:path";
|
|
80860
80944
|
function isDocumentPhase(phase) {
|
|
80861
80945
|
return phase.kind === "phase.capture.file" || phase.kind === "phase.capture.lark";
|
|
80862
80946
|
}
|
|
@@ -81038,7 +81122,7 @@ async function previewDocumentPhase(input) {
|
|
|
81038
81122
|
},
|
|
81039
81123
|
snapshot: {
|
|
81040
81124
|
manifest,
|
|
81041
|
-
exists: existsSync18(
|
|
81125
|
+
exists: existsSync18(join70(input.projectRoot, manifest))
|
|
81042
81126
|
},
|
|
81043
81127
|
sourceRefExamples: [
|
|
81044
81128
|
`${sourceRefBase}/<doc-locator>#span:<heading-hint> L<start>-<end>@<hash>`
|
|
@@ -81057,8 +81141,8 @@ var init_documentRun = __esm(() => {
|
|
|
81057
81141
|
});
|
|
81058
81142
|
|
|
81059
81143
|
// src/lib/atomicFileBatch.ts
|
|
81060
|
-
import { lstat as lstat8, mkdir as mkdir26, mkdtemp as mkdtemp3, rename as
|
|
81061
|
-
import { dirname as dirname32, join as
|
|
81144
|
+
import { lstat as lstat8, mkdir as mkdir26, mkdtemp as mkdtemp3, rename as rename7, rm as rm16, writeFile as writeFile21 } from "node:fs/promises";
|
|
81145
|
+
import { dirname as dirname32, join as join71, resolve as resolve23 } from "node:path";
|
|
81062
81146
|
async function existingFileKind(path2) {
|
|
81063
81147
|
try {
|
|
81064
81148
|
const stats = await lstat8(path2);
|
|
@@ -81088,9 +81172,9 @@ async function applyAtomicFileBatch(input) {
|
|
|
81088
81172
|
for (const path2 of writesByPath.keys())
|
|
81089
81173
|
removalPaths.delete(path2);
|
|
81090
81174
|
await mkdir26(input.transactionRoot, { recursive: true });
|
|
81091
|
-
const transactionDir = await mkdtemp3(
|
|
81092
|
-
const stagedRoot =
|
|
81093
|
-
const backupRoot =
|
|
81175
|
+
const transactionDir = await mkdtemp3(join71(input.transactionRoot, "batch-"));
|
|
81176
|
+
const stagedRoot = join71(transactionDir, "staged");
|
|
81177
|
+
const backupRoot = join71(transactionDir, "backup");
|
|
81094
81178
|
const writes = [...writesByPath.values()].sort((left, right) => left.path.localeCompare(right.path));
|
|
81095
81179
|
const affectedPaths = [...new Set([...writesByPath.keys(), ...removalPaths])].sort();
|
|
81096
81180
|
const staged = new Map;
|
|
@@ -81100,21 +81184,21 @@ async function applyAtomicFileBatch(input) {
|
|
|
81100
81184
|
try {
|
|
81101
81185
|
await mkdir26(stagedRoot, { recursive: true });
|
|
81102
81186
|
for (const [index2, write] of writes.entries()) {
|
|
81103
|
-
const path2 =
|
|
81104
|
-
await
|
|
81187
|
+
const path2 = join71(stagedRoot, String(index2));
|
|
81188
|
+
await writeFile21(path2, write.bytes);
|
|
81105
81189
|
staged.set(write.path, path2);
|
|
81106
81190
|
}
|
|
81107
81191
|
for (const [index2, path2] of affectedPaths.entries()) {
|
|
81108
81192
|
if (await existingFileKind(path2) === "missing")
|
|
81109
81193
|
continue;
|
|
81110
|
-
const backupPath =
|
|
81194
|
+
const backupPath = join71(backupRoot, String(index2));
|
|
81111
81195
|
await mkdir26(dirname32(backupPath), { recursive: true });
|
|
81112
|
-
await
|
|
81196
|
+
await rename7(path2, backupPath);
|
|
81113
81197
|
backups.set(path2, backupPath);
|
|
81114
81198
|
}
|
|
81115
81199
|
for (const write of writes) {
|
|
81116
81200
|
await mkdir26(dirname32(write.path), { recursive: true });
|
|
81117
|
-
await
|
|
81201
|
+
await rename7(staged.get(write.path), write.path);
|
|
81118
81202
|
installed.push(write.path);
|
|
81119
81203
|
}
|
|
81120
81204
|
} catch (error) {
|
|
@@ -81126,7 +81210,7 @@ async function applyAtomicFileBatch(input) {
|
|
|
81126
81210
|
}
|
|
81127
81211
|
for (const [path2, backupPath] of [...backups.entries()].reverse()) {
|
|
81128
81212
|
await mkdir26(dirname32(path2), { recursive: true });
|
|
81129
|
-
await
|
|
81213
|
+
await rename7(backupPath, path2).catch((rollbackError) => {
|
|
81130
81214
|
rollbackFailures.push(`restore ${path2}: ${String(rollbackError)}`);
|
|
81131
81215
|
});
|
|
81132
81216
|
}
|
|
@@ -81144,8 +81228,8 @@ var init_atomicFileBatch = () => {};
|
|
|
81144
81228
|
|
|
81145
81229
|
// src/project/documentManifestRecovery.ts
|
|
81146
81230
|
import { createHash as createHash20 } from "node:crypto";
|
|
81147
|
-
import { readFile as
|
|
81148
|
-
import { join as
|
|
81231
|
+
import { readFile as readFile61 } from "node:fs/promises";
|
|
81232
|
+
import { join as join72 } from "node:path";
|
|
81149
81233
|
function recoverBatchEntries(value, sourceType, sourceName) {
|
|
81150
81234
|
const [batch, module, ...rest] = sourceName.split("/");
|
|
81151
81235
|
if (batch === undefined || module === undefined || rest.length > 0 || !/^\d{8}$/u.test(batch))
|
|
@@ -81168,7 +81252,7 @@ function recoverBatchEntries(value, sourceType, sourceName) {
|
|
|
81168
81252
|
async function readDocumentManifestForCapture(input) {
|
|
81169
81253
|
let bytes;
|
|
81170
81254
|
try {
|
|
81171
|
-
bytes = await
|
|
81255
|
+
bytes = await readFile61(join72(input.projectRoot, input.manifestPath));
|
|
81172
81256
|
} catch (error) {
|
|
81173
81257
|
if (error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR")) {
|
|
81174
81258
|
return { current: null, previous: null };
|
|
@@ -81185,10 +81269,10 @@ async function readDocumentManifestForCapture(input) {
|
|
|
81185
81269
|
return { current: current2, previous: previous2 };
|
|
81186
81270
|
} catch (error) {
|
|
81187
81271
|
const digest6 = createHash20("sha256").update(bytes).digest("hex");
|
|
81188
|
-
const backup =
|
|
81272
|
+
const backup = join72(".tmp", "context-runtime", "recovery", "document-manifests", `${digest6}.json`);
|
|
81189
81273
|
await applyAtomicFileBatch({
|
|
81190
|
-
transactionRoot:
|
|
81191
|
-
writes: [{ path:
|
|
81274
|
+
transactionRoot: join72(input.projectRoot, ".tmp", "context-runtime", "recovery", "manifest-transactions"),
|
|
81275
|
+
writes: [{ path: join72(input.projectRoot, backup), bytes }]
|
|
81192
81276
|
});
|
|
81193
81277
|
const recovered = recoverBatchEntries(current2, input.sourceType, input.sourceName);
|
|
81194
81278
|
return {
|
|
@@ -82181,8 +82265,8 @@ var init_workflowProvider = __esm(() => {
|
|
|
82181
82265
|
});
|
|
82182
82266
|
|
|
82183
82267
|
// src/project/productionStageRefresh.ts
|
|
82184
|
-
import { readFile as
|
|
82185
|
-
import { join as
|
|
82268
|
+
import { readFile as readFile65 } from "node:fs/promises";
|
|
82269
|
+
import { join as join80 } from "node:path";
|
|
82186
82270
|
async function refreshProductionStageSources(projectRoot, stage) {
|
|
82187
82271
|
const affected = new Set(stage.gaps.map((gap) => gap.scope));
|
|
82188
82272
|
const unavailable = new Map;
|
|
@@ -82222,14 +82306,14 @@ Restore the authorized source and retry preparation.
|
|
|
82222
82306
|
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)
|
|
82223
82307
|
});
|
|
82224
82308
|
const directory = productionStageDirectory(stage.id);
|
|
82225
|
-
const contents2 = new Map([...sourceMaterials].map(([scope2, content3]) => [
|
|
82226
|
-
contents2.set(
|
|
82309
|
+
const contents2 = new Map([...sourceMaterials].map(([scope2, content3]) => [join80(directory, productionSourceFile(scope2)), content3]));
|
|
82310
|
+
contents2.set(join80(directory, "manifest.json"), `${JSON.stringify(updated)}
|
|
82227
82311
|
`);
|
|
82228
82312
|
const targets = [];
|
|
82229
82313
|
for (const [path2, content3] of contents2) {
|
|
82230
82314
|
let previous2;
|
|
82231
82315
|
try {
|
|
82232
|
-
previous2 = await
|
|
82316
|
+
previous2 = await readFile65(await safeProjectTarget(projectRoot, path2), "utf8");
|
|
82233
82317
|
} catch (error) {
|
|
82234
82318
|
if (error.code !== "ENOENT")
|
|
82235
82319
|
throw error;
|
|
@@ -82353,7 +82437,7 @@ var init_productionReport = __esm(() => {
|
|
|
82353
82437
|
});
|
|
82354
82438
|
|
|
82355
82439
|
// src/project/productionPlanningRoute.ts
|
|
82356
|
-
import { join as
|
|
82440
|
+
import { join as join81 } from "node:path";
|
|
82357
82441
|
async function productionPlanningRoute(input, stage) {
|
|
82358
82442
|
const request = stage ? undefined : await productionPlanningRequest(input.projectRoot);
|
|
82359
82443
|
const present = !!stage || !!request;
|
|
@@ -82391,7 +82475,7 @@ async function productionPlanningRoute(input, stage) {
|
|
|
82391
82475
|
id: `production/${stage.id}/planning`,
|
|
82392
82476
|
kind: "context-view",
|
|
82393
82477
|
media_type: "text/markdown",
|
|
82394
|
-
path:
|
|
82478
|
+
path: join81(input.projectRoot, productionStageDirectory(stage.id), "planning.md"),
|
|
82395
82479
|
read_state: "read-required"
|
|
82396
82480
|
}] : []
|
|
82397
82481
|
],
|
|
@@ -82410,7 +82494,7 @@ var init_productionPlanningRoute = __esm(() => {
|
|
|
82410
82494
|
|
|
82411
82495
|
// src/project/productionWorkflowRoute.ts
|
|
82412
82496
|
import { existsSync as existsSync24 } from "node:fs";
|
|
82413
|
-
import { join as
|
|
82497
|
+
import { join as join82 } from "node:path";
|
|
82414
82498
|
async function productionWorkflowRoute(input) {
|
|
82415
82499
|
const stage = await readProductionStage(input.projectRoot);
|
|
82416
82500
|
if (!stage || !stage.planning_complete)
|
|
@@ -82428,7 +82512,7 @@ async function productionWorkflowRoute(input) {
|
|
|
82428
82512
|
const selected = new Set(dispatch.batches.flatMap((batch) => batch.tasks));
|
|
82429
82513
|
const context = { workspace: input.projectRoot, authorities: [...input.authorities], facts: { production: {
|
|
82430
82514
|
report_approved: stage.report_approved,
|
|
82431
|
-
prepared: !dispatch.batches.length || existsSync24(
|
|
82515
|
+
prepared: !dispatch.batches.length || existsSync24(join82(input.projectRoot, directory, "stage.md")) && stage.tasks.filter((task) => selected.has(task.id)).every((task) => task.status === "issued"),
|
|
82432
82516
|
writing_complete: dispatch.batches.length === 0,
|
|
82433
82517
|
complete: dispatch.state === "ended",
|
|
82434
82518
|
review_clear: rejected.length === 0,
|
|
@@ -82445,7 +82529,7 @@ async function productionWorkflowRoute(input) {
|
|
|
82445
82529
|
const resolved = await resolveRoute(provider, "indexer", "production", primary.routeId, context, evaluated.evaluation.revision);
|
|
82446
82530
|
const report = resolved.node === "confirm-production-report";
|
|
82447
82531
|
if (report)
|
|
82448
|
-
await writeProductionProjection(input.projectRoot,
|
|
82532
|
+
await writeProductionProjection(input.projectRoot, join82(directory, "plan.md"), productionPlanMarkdown(stage));
|
|
82449
82533
|
const prepare = resolved.node === "prepare-production-stage";
|
|
82450
82534
|
const writing = resolved.node === "work-production-stage";
|
|
82451
82535
|
const repair = resolved.node === "repair-production-articles";
|
|
@@ -82460,7 +82544,7 @@ async function productionWorkflowRoute(input) {
|
|
|
82460
82544
|
id: `production/${stage.id}/${report ? "plan" : "stage"}`,
|
|
82461
82545
|
kind: "context-view",
|
|
82462
82546
|
media_type: "text/markdown",
|
|
82463
|
-
path:
|
|
82547
|
+
path: join82(input.projectRoot, directory, path3),
|
|
82464
82548
|
read_state: "read-required"
|
|
82465
82549
|
});
|
|
82466
82550
|
if (report || writing)
|
|
@@ -82471,18 +82555,18 @@ async function productionWorkflowRoute(input) {
|
|
|
82471
82555
|
id: `production/${stage.id}/planning`,
|
|
82472
82556
|
kind: "context-view",
|
|
82473
82557
|
media_type: "text/markdown",
|
|
82474
|
-
path:
|
|
82558
|
+
path: join82(input.projectRoot, directory, "planning.md"),
|
|
82475
82559
|
read_state: "read-required"
|
|
82476
82560
|
});
|
|
82477
82561
|
}
|
|
82478
82562
|
if (repair) {
|
|
82479
|
-
await writeProductionProjection(input.projectRoot,
|
|
82563
|
+
await writeProductionProjection(input.projectRoot, join82(directory, "repair.md"), [
|
|
82480
82564
|
"# Revise rejected articles",
|
|
82481
82565
|
"",
|
|
82482
82566
|
...rejected.map((candidate) => `- ${candidate.path}: ${candidate.review.title}`),
|
|
82483
82567
|
"",
|
|
82484
82568
|
"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.",
|
|
82485
|
-
`Submit the plan amendment to ${path2} using ${
|
|
82569
|
+
`Submit the plan amendment to ${path2} using ${join82(directory, "planning.schema.json")}. Keep accepted task identities unchanged; the CLI assigns the revision tasks and preserves article identities.`,
|
|
82486
82570
|
"Once issued, repair the affected sections through the existing edits submission. Unchanged sections and references do not need resubmission.",
|
|
82487
82571
|
""
|
|
82488
82572
|
].join(`
|
|
@@ -82491,7 +82575,7 @@ async function productionWorkflowRoute(input) {
|
|
|
82491
82575
|
id: `production/${stage.id}/repair`,
|
|
82492
82576
|
kind: "context-view",
|
|
82493
82577
|
media_type: "text/markdown",
|
|
82494
|
-
path:
|
|
82578
|
+
path: join82(input.projectRoot, directory, "repair.md"),
|
|
82495
82579
|
read_state: "read-required"
|
|
82496
82580
|
});
|
|
82497
82581
|
}
|
|
@@ -82582,7 +82666,7 @@ var init_knowledgeMaintenanceRoute = __esm(() => {
|
|
|
82582
82666
|
});
|
|
82583
82667
|
|
|
82584
82668
|
// src/project/approvedRevisionContext.ts
|
|
82585
|
-
import { readFile as
|
|
82669
|
+
import { readFile as readFile66 } from "node:fs/promises";
|
|
82586
82670
|
async function approvedRevisionContext(root, target) {
|
|
82587
82671
|
const registry2 = await readProductionRequirements(root);
|
|
82588
82672
|
const requirements = registry2.requirements.filter((requirement2) => requirement2.target_scope.targets.some((source2) => target.source_refs.some((ref2) => ref2 === source2.source_ref || ref2.startsWith(`${source2.source_ref}#`) || ref2.startsWith(`${source2.source_ref}/`))));
|
|
@@ -82593,7 +82677,7 @@ async function approvedRevisionContext(root, target) {
|
|
|
82593
82677
|
const type = source_ref.slice(0, separator);
|
|
82594
82678
|
const name3 = source_ref.slice(separator + 1);
|
|
82595
82679
|
const path2 = await assertManagedDocumentPath(root, type, name3);
|
|
82596
|
-
const markdown = await
|
|
82680
|
+
const markdown = await readFile66(path2, "utf8");
|
|
82597
82681
|
const changes = type === "sessions" ? readSessionChanges(markdown) : undefined;
|
|
82598
82682
|
return {
|
|
82599
82683
|
source_ref,
|
|
@@ -87248,8 +87332,8 @@ var init_larkResourceCommand = __esm(() => {
|
|
|
87248
87332
|
|
|
87249
87333
|
// src/lib/larkResourceMaterialization.ts
|
|
87250
87334
|
import { createHash as createHash26 } from "node:crypto";
|
|
87251
|
-
import { mkdtemp as mkdtemp4, readFile as
|
|
87252
|
-
import { extname as extname13, join as
|
|
87335
|
+
import { mkdtemp as mkdtemp4, readFile as readFile69, readdir as readdir20, rm as rm19 } from "node:fs/promises";
|
|
87336
|
+
import { extname as extname13, join as join89 } from "node:path";
|
|
87253
87337
|
import { tmpdir } from "node:os";
|
|
87254
87338
|
function countByKind(items, status) {
|
|
87255
87339
|
const counts2 = new Map;
|
|
@@ -87354,10 +87438,10 @@ function findBooleanField(value, name3) {
|
|
|
87354
87438
|
}
|
|
87355
87439
|
async function downloadedFile(input) {
|
|
87356
87440
|
if (input.localPath !== undefined) {
|
|
87357
|
-
const bytes = await
|
|
87441
|
+
const bytes = await readFile69(input.localPath);
|
|
87358
87442
|
return { path: input.localPath, bytes, mediaType: mediaTypeFor(input.localPath, bytes) };
|
|
87359
87443
|
}
|
|
87360
|
-
const tempRoot = await mkdtemp4(
|
|
87444
|
+
const tempRoot = await mkdtemp4(join89(tmpdir(), "context-lark-resource-"));
|
|
87361
87445
|
try {
|
|
87362
87446
|
await runLarkResourceCommand(input.runner, [
|
|
87363
87447
|
"docs",
|
|
@@ -87378,7 +87462,7 @@ async function downloadedFile(input) {
|
|
|
87378
87462
|
if (entries2.length !== 1)
|
|
87379
87463
|
throw new Error(`media download produced ${entries2.length} files, expected exactly one`);
|
|
87380
87464
|
const path3 = entries2[0]?.name ?? "resource.bin";
|
|
87381
|
-
const bytes = await
|
|
87465
|
+
const bytes = await readFile69(join89(tempRoot, path3));
|
|
87382
87466
|
return { path: path3, bytes, mediaType: mediaTypeFor(path3, bytes) };
|
|
87383
87467
|
} finally {
|
|
87384
87468
|
await rm19(tempRoot, { recursive: true, force: true });
|
|
@@ -87469,9 +87553,9 @@ async function sheetMaterialization(resource, runner2, identity) {
|
|
|
87469
87553
|
const sheetId = resource.attributes["sheet-id"];
|
|
87470
87554
|
if (token === undefined || sheetId === undefined)
|
|
87471
87555
|
throw new Error("embedded Sheet requires token and sheet-id");
|
|
87472
|
-
const tempRoot = await mkdtemp4(
|
|
87556
|
+
const tempRoot = await mkdtemp4(join89(tmpdir(), "context-lark-sheet-"));
|
|
87473
87557
|
try {
|
|
87474
|
-
const outputPath =
|
|
87558
|
+
const outputPath = join89(tempRoot, "sheet.json");
|
|
87475
87559
|
const stdout = await runLarkResourceCommand(runner2, [
|
|
87476
87560
|
"sheets",
|
|
87477
87561
|
"+csv-get",
|
|
@@ -87491,7 +87575,7 @@ async function sheetMaterialization(resource, runner2, identity) {
|
|
|
87491
87575
|
if (findBooleanField(receipt2, "truncated") === true || findBooleanField(receipt2, "complete") === false) {
|
|
87492
87576
|
throw new Error("embedded Sheet read was truncated");
|
|
87493
87577
|
}
|
|
87494
|
-
const payload = JSON.parse(await
|
|
87578
|
+
const payload = JSON.parse(await readFile69(outputPath, "utf8"));
|
|
87495
87579
|
const csv = findStringField(payload, new Set(["annotated_csv", "csv", "content", "text"]));
|
|
87496
87580
|
if (csv === undefined)
|
|
87497
87581
|
throw new Error("embedded Sheet response has no CSV payload");
|
|
@@ -87627,7 +87711,7 @@ async function whiteboardMaterialization(resource, runner2, identity) {
|
|
|
87627
87711
|
if (token === undefined)
|
|
87628
87712
|
throw new Error(`${resource.kind} has no whiteboard token`);
|
|
87629
87713
|
const preview = await downloadedFile({ runner: runner2, identity, token, type: "whiteboard" });
|
|
87630
|
-
const tempRoot = await mkdtemp4(
|
|
87714
|
+
const tempRoot = await mkdtemp4(join89(tmpdir(), "context-lark-whiteboard-"));
|
|
87631
87715
|
let rawPayload;
|
|
87632
87716
|
try {
|
|
87633
87717
|
await runLarkResourceCommand(runner2, [
|
|
@@ -87645,7 +87729,7 @@ async function whiteboardMaterialization(resource, runner2, identity) {
|
|
|
87645
87729
|
"--format",
|
|
87646
87730
|
"json"
|
|
87647
87731
|
], { cwd: tempRoot });
|
|
87648
|
-
rawPayload = JSON.parse(await
|
|
87732
|
+
rawPayload = JSON.parse(await readFile69(join89(tempRoot, "raw.json"), "utf8"));
|
|
87649
87733
|
} finally {
|
|
87650
87734
|
await rm19(tempRoot, { recursive: true, force: true });
|
|
87651
87735
|
}
|
|
@@ -88490,8 +88574,8 @@ var init_sensitiveSourceLiteral = __esm(() => {
|
|
|
88490
88574
|
var LARK_DOCUMENT_NORMALIZER_VERSION = "lark-document-normalizer.v1";
|
|
88491
88575
|
|
|
88492
88576
|
// src/project/documentCaptureLark.ts
|
|
88493
|
-
import { readdir as readdir21, readFile as
|
|
88494
|
-
import { basename as basename10, extname as extname14, join as
|
|
88577
|
+
import { readdir as readdir21, readFile as readFile70 } from "node:fs/promises";
|
|
88578
|
+
import { basename as basename10, extname as extname14, join as join90 } from "node:path";
|
|
88495
88579
|
function titleFromMarkdown2(markdown, fallbackPath) {
|
|
88496
88580
|
const heading2 = markdown.split(`
|
|
88497
88581
|
`).find((line) => /^#\s+\S/u.test(line));
|
|
@@ -88510,7 +88594,7 @@ function countLines3(markdown) {
|
|
|
88510
88594
|
}
|
|
88511
88595
|
async function fileContentMatches(path3, content3) {
|
|
88512
88596
|
try {
|
|
88513
|
-
const current2 = await
|
|
88597
|
+
const current2 = await readFile70(path3);
|
|
88514
88598
|
const expected = typeof content3 === "string" ? Buffer.from(content3, "utf8") : Buffer.from(content3);
|
|
88515
88599
|
return current2.equals(expected);
|
|
88516
88600
|
} catch {
|
|
@@ -88518,7 +88602,7 @@ async function fileContentMatches(path3, content3) {
|
|
|
88518
88602
|
}
|
|
88519
88603
|
}
|
|
88520
88604
|
function sourceManifestPath2(entry) {
|
|
88521
|
-
return entry.snapshot?.manifest ??
|
|
88605
|
+
return entry.snapshot?.manifest ?? join90(entry.materializedAt, "manifest.json");
|
|
88522
88606
|
}
|
|
88523
88607
|
function larkRuntimeError(message, detail) {
|
|
88524
88608
|
return new ContextError(ExitCode.ExternalToolError, message, {
|
|
@@ -88644,7 +88728,7 @@ function assetManifestEntry(asset, assetRoot) {
|
|
|
88644
88728
|
};
|
|
88645
88729
|
}
|
|
88646
88730
|
async function listSnapshotAssetFiles(root2, assetRoot) {
|
|
88647
|
-
const assetsRoot =
|
|
88731
|
+
const assetsRoot = join90(root2, assetRoot);
|
|
88648
88732
|
const files = [];
|
|
88649
88733
|
const visit4 = async (dir, prefix = assetRoot) => {
|
|
88650
88734
|
let entries2;
|
|
@@ -88657,7 +88741,7 @@ async function listSnapshotAssetFiles(root2, assetRoot) {
|
|
|
88657
88741
|
}
|
|
88658
88742
|
for (const entry of entries2) {
|
|
88659
88743
|
const relPath = `${prefix}/${entry.name}`;
|
|
88660
|
-
const absolutePath =
|
|
88744
|
+
const absolutePath = join90(dir, entry.name);
|
|
88661
88745
|
if (entry.isDirectory()) {
|
|
88662
88746
|
await visit4(absolutePath, relPath);
|
|
88663
88747
|
continue;
|
|
@@ -88672,7 +88756,7 @@ async function listSnapshotAssetFiles(root2, assetRoot) {
|
|
|
88672
88756
|
}
|
|
88673
88757
|
async function staleSnapshotAssetPaths(input) {
|
|
88674
88758
|
const existingPaths = await listSnapshotAssetFiles(input.materializedAtAbsPath, input.assetRoot);
|
|
88675
|
-
return existingPaths.filter((path3) => !input.currentPaths.has(path3)).map((path3) =>
|
|
88759
|
+
return existingPaths.filter((path3) => !input.currentPaths.has(path3)).map((path3) => join90(input.materializedAtAbsPath, path3));
|
|
88676
88760
|
}
|
|
88677
88761
|
function normalizeLarkError(error, sourceName) {
|
|
88678
88762
|
if (error instanceof ContextError)
|
|
@@ -88780,9 +88864,9 @@ async function runCaptureLarkPhaseUnlocked(input) {
|
|
|
88780
88864
|
locator
|
|
88781
88865
|
}];
|
|
88782
88866
|
const manifestPath = sourceManifestPath2(entry);
|
|
88783
|
-
const manifestAbsPath =
|
|
88867
|
+
const manifestAbsPath = join90(input.projectRoot, manifestPath);
|
|
88784
88868
|
const materializedAt = entry.materializedAt;
|
|
88785
|
-
const materializedAtAbsPath =
|
|
88869
|
+
const materializedAtAbsPath = join90(input.projectRoot, materializedAt);
|
|
88786
88870
|
const manifest = createDocumentSnapshotManifest({
|
|
88787
88871
|
sourceType: "lark",
|
|
88788
88872
|
sourceName: resolved.sourceName,
|
|
@@ -88816,13 +88900,13 @@ async function runCaptureLarkPhaseUnlocked(input) {
|
|
|
88816
88900
|
}));
|
|
88817
88901
|
try {
|
|
88818
88902
|
const requestedWrites = [{
|
|
88819
|
-
path:
|
|
88903
|
+
path: join90(materializedAtAbsPath, documentPath),
|
|
88820
88904
|
bytes: normalized
|
|
88821
88905
|
}];
|
|
88822
88906
|
for (const asset of assets) {
|
|
88823
88907
|
if (asset.bytes !== undefined) {
|
|
88824
88908
|
requestedWrites.push({
|
|
88825
|
-
path:
|
|
88909
|
+
path: join90(materializedAtAbsPath, asset.entry.path),
|
|
88826
88910
|
bytes: asset.bytes
|
|
88827
88911
|
});
|
|
88828
88912
|
}
|
|
@@ -88839,7 +88923,7 @@ async function runCaptureLarkPhaseUnlocked(input) {
|
|
|
88839
88923
|
currentPaths: new Set(assets.filter((asset) => asset.bytes !== undefined).map((asset) => asset.entry.path))
|
|
88840
88924
|
});
|
|
88841
88925
|
await applyAtomicFileBatch({
|
|
88842
|
-
transactionRoot:
|
|
88926
|
+
transactionRoot: join90(input.projectRoot, ".tmp", "context-runtime", "capture-transactions"),
|
|
88843
88927
|
writes,
|
|
88844
88928
|
removals
|
|
88845
88929
|
});
|
|
@@ -88985,7 +89069,7 @@ __export(exports_articleRetirement, {
|
|
|
88985
89069
|
retireArticles: () => retireArticles,
|
|
88986
89070
|
articleRetirementSchema: () => articleRetirementSchema
|
|
88987
89071
|
});
|
|
88988
|
-
import { readFile as
|
|
89072
|
+
import { readFile as readFile76, readdir as readdir22 } from "node:fs/promises";
|
|
88989
89073
|
import { posix as posix10 } from "node:path";
|
|
88990
89074
|
function rebuildInput(revision) {
|
|
88991
89075
|
return JSON.stringify({ id: `retirement-${revision.slice(7)}`, operation: "rebuild", timing: "priority", targets: [] });
|
|
@@ -89006,7 +89090,7 @@ function invalid2(reason, message, details = {}) {
|
|
|
89006
89090
|
}
|
|
89007
89091
|
async function text9(root2, path3) {
|
|
89008
89092
|
try {
|
|
89009
|
-
return await
|
|
89093
|
+
return await readFile76(await safeProjectTarget(root2, path3), "utf8");
|
|
89010
89094
|
} catch (error) {
|
|
89011
89095
|
if (error.code === "ENOENT")
|
|
89012
89096
|
return;
|
|
@@ -89268,8 +89352,8 @@ __export(exports_writeLockRecovery, {
|
|
|
89268
89352
|
recoverWriterLock: () => recoverWriterLock,
|
|
89269
89353
|
inspectWriterLock: () => inspectWriterLock
|
|
89270
89354
|
});
|
|
89271
|
-
import { lstat as lstat10, mkdir as mkdir33, readFile as
|
|
89272
|
-
import { join as
|
|
89355
|
+
import { lstat as lstat10, mkdir as mkdir33, readFile as readFile77, readdir as readdir23, rename as rename8, rmdir as rmdir2 } from "node:fs/promises";
|
|
89356
|
+
import { join as join95 } from "node:path";
|
|
89273
89357
|
import { createHash as createHash28, randomUUID as randomUUID7 } from "node:crypto";
|
|
89274
89358
|
async function inspectWriterLock(root2) {
|
|
89275
89359
|
const path3 = await safeProjectTarget(root2, lockRelative);
|
|
@@ -89284,7 +89368,7 @@ async function inspectWriterLock(root2) {
|
|
|
89284
89368
|
if (!stat10.isDirectory() || stat10.isSymbolicLink())
|
|
89285
89369
|
throw new Error("Writer lock must be a real directory.");
|
|
89286
89370
|
const ownerPath = await safeProjectTarget(root2, `${lockRelative}/owner.json`);
|
|
89287
|
-
const bytes = await
|
|
89371
|
+
const bytes = await readFile77(ownerPath, "utf8");
|
|
89288
89372
|
const owner = JSON.parse(bytes);
|
|
89289
89373
|
if (owner.protocol !== "context.project-write-lock.v1" || !Number.isSafeInteger(owner.pid) || owner.pid <= 0) {
|
|
89290
89374
|
throw new Error("Writer lock owner is invalid; preserve the lock for diagnosis.");
|
|
@@ -89316,8 +89400,8 @@ async function recoverWriterLock(input) {
|
|
|
89316
89400
|
};
|
|
89317
89401
|
if (input.plan_digest !== before.digest)
|
|
89318
89402
|
throw new Error("Writer lock changed; preview recovery again.");
|
|
89319
|
-
const path3 =
|
|
89320
|
-
const guard =
|
|
89403
|
+
const path3 = join95(input.projectRoot, lockRelative);
|
|
89404
|
+
const guard = join95(path3, ".recovery");
|
|
89321
89405
|
await mkdir33(guard);
|
|
89322
89406
|
let archived = false;
|
|
89323
89407
|
try {
|
|
@@ -89328,7 +89412,7 @@ async function recoverWriterLock(input) {
|
|
|
89328
89412
|
if (names.some((name3) => name3 !== "owner.json" && name3 !== ".recovery"))
|
|
89329
89413
|
throw new Error("Unexpected lock contents; preserve for diagnosis.");
|
|
89330
89414
|
const archive = `.tmp/context-runtime/locks/recovered-write-${randomUUID7()}.lock`;
|
|
89331
|
-
await
|
|
89415
|
+
await rename8(path3, join95(input.projectRoot, archive));
|
|
89332
89416
|
archived = true;
|
|
89333
89417
|
return { action: "writer-lock-recovered", archived_lock: archive, next: "context task recover --format json" };
|
|
89334
89418
|
} finally {
|
|
@@ -89352,12 +89436,12 @@ __export(exports_taskRecovery, {
|
|
|
89352
89436
|
RECOVERY_COMMAND: () => RECOVERY_COMMAND
|
|
89353
89437
|
});
|
|
89354
89438
|
import { existsSync as existsSync26 } from "node:fs";
|
|
89355
|
-
import { dirname as dirname41, join as
|
|
89356
|
-
import { lstat as lstat11, readdir as readdir24, readFile as
|
|
89439
|
+
import { dirname as dirname41, join as join96 } from "node:path";
|
|
89440
|
+
import { lstat as lstat11, readdir as readdir24, readFile as readFile78 } from "node:fs/promises";
|
|
89357
89441
|
async function recoveryText(root2, path3) {
|
|
89358
89442
|
const target = await safeProjectTarget(root2, path3);
|
|
89359
89443
|
try {
|
|
89360
|
-
return await
|
|
89444
|
+
return await readFile78(target, "utf8");
|
|
89361
89445
|
} catch (error) {
|
|
89362
89446
|
if (error.code === "ENOENT")
|
|
89363
89447
|
return;
|
|
@@ -89370,7 +89454,7 @@ async function recoveryJournals(root2) {
|
|
|
89370
89454
|
await safeProjectTarget(root2, path3);
|
|
89371
89455
|
let stat10;
|
|
89372
89456
|
try {
|
|
89373
|
-
stat10 = await lstat11(
|
|
89457
|
+
stat10 = await lstat11(join96(root2, path3));
|
|
89374
89458
|
} catch (error) {
|
|
89375
89459
|
if (error.code === "ENOENT")
|
|
89376
89460
|
return;
|
|
@@ -89381,7 +89465,7 @@ async function recoveryJournals(root2) {
|
|
|
89381
89465
|
if (stat10.isDirectory()) {
|
|
89382
89466
|
if (depth > 3)
|
|
89383
89467
|
throw new TypeError("Unexpected transaction directory depth; preserve it for diagnosis.");
|
|
89384
|
-
for (const name3 of (await readdir24(
|
|
89468
|
+
for (const name3 of (await readdir24(join96(root2, path3))).sort())
|
|
89385
89469
|
await visit4(`${path3}/${name3}`, depth + 1);
|
|
89386
89470
|
} else if (stat10.isFile())
|
|
89387
89471
|
entries2.push({ path: path3, digest: indexerProtocolDigest(await recoveryText(root2, path3)) });
|
|
@@ -89393,8 +89477,8 @@ function recoveryResources() {
|
|
|
89393
89477
|
try {
|
|
89394
89478
|
const root2 = dirname41(contextWorkflowProviderPath());
|
|
89395
89479
|
const resources = {
|
|
89396
|
-
skill:
|
|
89397
|
-
issue_template:
|
|
89480
|
+
skill: join96(root2, "skills/recover-workspace/SKILL.md"),
|
|
89481
|
+
issue_template: join96(root2, "resources/templates/recovery-issue.md")
|
|
89398
89482
|
};
|
|
89399
89483
|
if (!Object.values(resources).every((path3) => existsSync26(path3)))
|
|
89400
89484
|
throw new Error("Recovery resources are absent from this Provider.");
|
|
@@ -89479,8 +89563,8 @@ var exports_taskLocalSourceAdjustment = {};
|
|
|
89479
89563
|
__export(exports_taskLocalSourceAdjustment, {
|
|
89480
89564
|
adjustLocalRevisionSources: () => adjustLocalRevisionSources
|
|
89481
89565
|
});
|
|
89482
|
-
import { readFile as
|
|
89483
|
-
import { join as
|
|
89566
|
+
import { readFile as readFile79 } from "node:fs/promises";
|
|
89567
|
+
import { join as join97 } from "node:path";
|
|
89484
89568
|
async function adjustLocalRevisionSources(root2, input) {
|
|
89485
89569
|
const { readMaintenance: readMaintenance2 } = await Promise.resolve().then(() => (init_maintenanceStorage(), exports_maintenanceStorage));
|
|
89486
89570
|
if ((await readMaintenance2(root2)).active && await readProductionStage(root2))
|
|
@@ -89504,7 +89588,7 @@ async function adjustLocalRevisionSources(root2, input) {
|
|
|
89504
89588
|
if (input.refresh && (!current2.refresh_sources || indexerProtocolDigest([...current2.refresh_sources].sort()) !== indexerProtocolDigest([...selected].sort()))) {
|
|
89505
89589
|
throw new TypeError("No matching acquisition adjustment exists. Run task adjust without refresh first.");
|
|
89506
89590
|
}
|
|
89507
|
-
const raw = await
|
|
89591
|
+
const raw = await readFile79(join97(root2, await revisionStoragePath(root2)), "utf8");
|
|
89508
89592
|
let next2;
|
|
89509
89593
|
const discardIds = new Set;
|
|
89510
89594
|
if (!input.refresh) {
|
|
@@ -89607,7 +89691,7 @@ ${input.instruction}` : revision.instruction
|
|
|
89607
89691
|
content: content3
|
|
89608
89692
|
}];
|
|
89609
89693
|
if (discardIds.size > 0) {
|
|
89610
|
-
const ledger = await
|
|
89694
|
+
const ledger = await readFile79(join97(root2, CANDIDATE_LEDGER_FILE), "utf8").catch((error) => {
|
|
89611
89695
|
if (error.code === "ENOENT")
|
|
89612
89696
|
return;
|
|
89613
89697
|
throw error;
|
|
@@ -89729,7 +89813,7 @@ var init_taskSourceAdjustment = __esm(() => {
|
|
|
89729
89813
|
});
|
|
89730
89814
|
|
|
89731
89815
|
// src/project/managedDocumentImport.ts
|
|
89732
|
-
import { readFile as
|
|
89816
|
+
import { readFile as readFile85 } from "node:fs/promises";
|
|
89733
89817
|
async function importManagedDocument(projectRoot, value) {
|
|
89734
89818
|
const input = inputSchema.parse(value);
|
|
89735
89819
|
if (input.type !== "sessions" && input.changes !== undefined)
|
|
@@ -89738,7 +89822,7 @@ async function importManagedDocument(projectRoot, value) {
|
|
|
89738
89822
|
const path3 = await assertManagedDocumentPath(projectRoot, input.type, input.name);
|
|
89739
89823
|
let previous3;
|
|
89740
89824
|
try {
|
|
89741
|
-
previous3 = await
|
|
89825
|
+
previous3 = await readFile85(path3, "utf8");
|
|
89742
89826
|
} catch (error) {
|
|
89743
89827
|
if (!(error && typeof error === "object" && ("code" in error) && error.code === "ENOENT"))
|
|
89744
89828
|
throw error;
|
|
@@ -89785,14 +89869,14 @@ var init_managedDocumentImport = __esm(() => {
|
|
|
89785
89869
|
});
|
|
89786
89870
|
|
|
89787
89871
|
// src/project/larkDocumentImport.ts
|
|
89788
|
-
import { readFile as
|
|
89872
|
+
import { readFile as readFile86 } from "node:fs/promises";
|
|
89789
89873
|
async function importLarkDocument(projectRoot, value) {
|
|
89790
89874
|
const input = schema3.parse(value);
|
|
89791
89875
|
const responsePages = [];
|
|
89792
89876
|
for (const path3 of input.response_files) {
|
|
89793
89877
|
assertActionInputWorkspace(projectRoot, path3);
|
|
89794
89878
|
const { resolve: resolve8 } = await import("node:path");
|
|
89795
|
-
responsePages.push(await
|
|
89879
|
+
responsePages.push(await readFile86(resolve8(projectRoot, path3), "utf8"));
|
|
89796
89880
|
}
|
|
89797
89881
|
const mediaFiles = {};
|
|
89798
89882
|
for (const [token, path3] of Object.entries(input.media_files ?? {})) {
|
|
@@ -89860,11 +89944,11 @@ var exports_managedDocumentRename = {};
|
|
|
89860
89944
|
__export(exports_managedDocumentRename, {
|
|
89861
89945
|
renameManagedDocument: () => renameManagedDocument
|
|
89862
89946
|
});
|
|
89863
|
-
import { readFile as
|
|
89864
|
-
import { join as
|
|
89947
|
+
import { readFile as readFile87 } from "node:fs/promises";
|
|
89948
|
+
import { join as join105, posix as posix11 } from "node:path";
|
|
89865
89949
|
async function optionalText2(path3) {
|
|
89866
89950
|
try {
|
|
89867
|
-
return await
|
|
89951
|
+
return await readFile87(path3, "utf8");
|
|
89868
89952
|
} catch (error) {
|
|
89869
89953
|
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT")
|
|
89870
89954
|
return;
|
|
@@ -89948,7 +90032,7 @@ async function renameManagedDocument(input) {
|
|
|
89948
90032
|
if (path3.split("/").includes("..") || path3.startsWith("/"))
|
|
89949
90033
|
throw new TypeError("Source references contain an unsafe knowledge path; repair it before renaming.");
|
|
89950
90034
|
await safeProjectTarget(input.projectRoot, path3);
|
|
89951
|
-
const before = await optionalText2(
|
|
90035
|
+
const before = await optionalText2(join105(input.projectRoot, path3));
|
|
89952
90036
|
if (before === undefined)
|
|
89953
90037
|
continue;
|
|
89954
90038
|
let after;
|
|
@@ -90037,7 +90121,7 @@ var init_managedDocumentRename = __esm(() => {
|
|
|
90037
90121
|
|
|
90038
90122
|
// src/cli.ts
|
|
90039
90123
|
import { existsSync as existsSync36, realpathSync as realpathSync3 } from "node:fs";
|
|
90040
|
-
import { dirname as dirname48, join as
|
|
90124
|
+
import { dirname as dirname48, join as join109 } from "node:path";
|
|
90041
90125
|
import { fileURLToPath as fileURLToPath10, pathToFileURL as pathToFileURL3 } from "node:url";
|
|
90042
90126
|
|
|
90043
90127
|
// ../../node_modules/.bun/commander@11.1.0/node_modules/commander/esm.mjs
|
|
@@ -90092,7 +90176,7 @@ init_dist();
|
|
|
90092
90176
|
init_cliFeedback();
|
|
90093
90177
|
init_errors3();
|
|
90094
90178
|
init_exitCode();
|
|
90095
|
-
import { join as
|
|
90179
|
+
import { join as join87 } from "node:path";
|
|
90096
90180
|
|
|
90097
90181
|
// src/project/status.ts
|
|
90098
90182
|
init_productionPlanning();
|
|
@@ -90103,13 +90187,13 @@ init_approvedRevisionBatch();
|
|
|
90103
90187
|
init_revisionDelivery();
|
|
90104
90188
|
init_workspacePreparation();
|
|
90105
90189
|
init_src2();
|
|
90106
|
-
import { join as
|
|
90190
|
+
import { join as join83 } from "node:path";
|
|
90107
90191
|
|
|
90108
90192
|
// src/project/statusReaders.ts
|
|
90109
90193
|
init_commandReadCache();
|
|
90110
90194
|
init_errors3();
|
|
90111
90195
|
import { existsSync as existsSync22, readFileSync as readFileSync8 } from "node:fs";
|
|
90112
|
-
import { join as
|
|
90196
|
+
import { join as join79 } from "node:path";
|
|
90113
90197
|
|
|
90114
90198
|
// src/project/documentCapture.ts
|
|
90115
90199
|
init_src3();
|
|
@@ -90117,8 +90201,8 @@ init_cliFeedback();
|
|
|
90117
90201
|
init_errors3();
|
|
90118
90202
|
init_exitCode();
|
|
90119
90203
|
import { createHash as createHash21 } from "node:crypto";
|
|
90120
|
-
import { mkdir as mkdir27, readdir as readdir18, readFile as
|
|
90121
|
-
import { basename as basename8, dirname as dirname33, extname as extname12, join as
|
|
90204
|
+
import { mkdir as mkdir27, readdir as readdir18, readFile as readFile62, rm as rm17, stat as stat9, writeFile as writeFile22 } from "node:fs/promises";
|
|
90205
|
+
import { basename as basename8, dirname as dirname33, extname as extname12, join as join73, relative as relative22, resolve as resolve24 } from "node:path";
|
|
90122
90206
|
|
|
90123
90207
|
// src/project/documentCaptureAssets.ts
|
|
90124
90208
|
init_src3();
|
|
@@ -90127,8 +90211,8 @@ init_errors3();
|
|
|
90127
90211
|
init_exitCode();
|
|
90128
90212
|
init_markdownLinks();
|
|
90129
90213
|
import { readFileSync as readFileSync6 } from "node:fs";
|
|
90130
|
-
import { mkdir as mkdir25, readFile as
|
|
90131
|
-
import { dirname as dirname30, isAbsolute as isAbsolute13, join as
|
|
90214
|
+
import { mkdir as mkdir25, readFile as readFile59, stat as stat7, writeFile as writeFile20 } from "node:fs/promises";
|
|
90215
|
+
import { dirname as dirname30, isAbsolute as isAbsolute13, join as join68, relative as relative20, resolve as resolve21 } from "node:path";
|
|
90132
90216
|
function runtimeError(message, detail) {
|
|
90133
90217
|
return new ContextError(ExitCode.UserError, message, {
|
|
90134
90218
|
category: ErrorCategory.UserInputInvalid,
|
|
@@ -90153,26 +90237,26 @@ function linkedAssetSnapshotPath(documentPath, target) {
|
|
|
90153
90237
|
const decoded = decodedAssetTarget(target);
|
|
90154
90238
|
if (/^[a-z][a-z0-9+.-]*:/iu.test(decoded) || decoded.startsWith("#") || decoded.startsWith("/"))
|
|
90155
90239
|
return;
|
|
90156
|
-
const candidate = toPosixPath5(
|
|
90240
|
+
const candidate = toPosixPath5(join68(dirname30(documentPath), decoded));
|
|
90157
90241
|
if (candidate !== "assets" && !candidate.startsWith("assets/"))
|
|
90158
90242
|
return;
|
|
90159
90243
|
return normalizeSnapshotRelativePath(candidate);
|
|
90160
90244
|
}
|
|
90161
90245
|
async function writeCaptureAssetIfChanged(path2, content3) {
|
|
90162
90246
|
try {
|
|
90163
|
-
const current = await
|
|
90247
|
+
const current = await readFile59(path2);
|
|
90164
90248
|
if (current.byteLength === content3.byteLength && current.equals(content3))
|
|
90165
90249
|
return;
|
|
90166
90250
|
} catch {}
|
|
90167
90251
|
await mkdir25(dirname30(path2), { recursive: true });
|
|
90168
|
-
await
|
|
90252
|
+
await writeFile20(path2, content3);
|
|
90169
90253
|
}
|
|
90170
90254
|
async function readLinkedCaptureAssets(input) {
|
|
90171
90255
|
const rootStat = await stat7(input.localRoot);
|
|
90172
90256
|
const boundaryRoot = rootStat.isFile() ? dirname30(input.localRoot) : input.localRoot;
|
|
90173
90257
|
const bySnapshotPath = new Map;
|
|
90174
90258
|
for (const file of input.files) {
|
|
90175
|
-
const markdown = await
|
|
90259
|
+
const markdown = await readFile59(file.absolutePath, "utf8");
|
|
90176
90260
|
for (const link of markdownInlineLinks(markdown)) {
|
|
90177
90261
|
const snapshotPath2 = linkedAssetSnapshotPath(file.snapshotPath, link.target);
|
|
90178
90262
|
if (snapshotPath2 === undefined)
|
|
@@ -90190,7 +90274,7 @@ async function readLinkedCaptureAssets(input) {
|
|
|
90190
90274
|
const assetStat = await stat7(absolutePath);
|
|
90191
90275
|
if (!assetStat.isFile())
|
|
90192
90276
|
throw new TypeError("asset target is not a file");
|
|
90193
|
-
bytes = await
|
|
90277
|
+
bytes = await readFile59(absolutePath);
|
|
90194
90278
|
} catch (error) {
|
|
90195
90279
|
const message = error instanceof Error ? error.message : String(error);
|
|
90196
90280
|
throw runtimeError(`file source ${input.sourceName} linked asset is unreadable: ${link.target}: ${message}`, {
|
|
@@ -90218,7 +90302,7 @@ function fileSnapshotLinkedAssetMismatchDiagnostic(input) {
|
|
|
90218
90302
|
for (const file of input.manifest.files) {
|
|
90219
90303
|
let markdown;
|
|
90220
90304
|
try {
|
|
90221
|
-
markdown = readFileSync6(
|
|
90305
|
+
markdown = readFileSync6(join68(input.projectRoot, input.materializedAt, file.path), "utf8");
|
|
90222
90306
|
} catch {
|
|
90223
90307
|
continue;
|
|
90224
90308
|
}
|
|
@@ -97835,7 +97919,7 @@ init_src3();
|
|
|
97835
97919
|
init_cliFeedback();
|
|
97836
97920
|
init_errors3();
|
|
97837
97921
|
init_exitCode();
|
|
97838
|
-
import { readFile as
|
|
97922
|
+
import { readFile as readFile60 } from "node:fs/promises";
|
|
97839
97923
|
import { dirname as dirname31, extname as extname10 } from "node:path";
|
|
97840
97924
|
var ROUTE_EVIDENCE_DOCUMENT_PATH = "__context_route_metadata.md";
|
|
97841
97925
|
function countLines(markdown) {
|
|
@@ -97930,7 +98014,7 @@ async function readRouteMetadataFiles(input) {
|
|
|
97930
98014
|
for (const file of input.files) {
|
|
97931
98015
|
let raw;
|
|
97932
98016
|
try {
|
|
97933
|
-
raw = await
|
|
98017
|
+
raw = await readFile60(file.absolutePath, "utf8");
|
|
97934
98018
|
} catch (error) {
|
|
97935
98019
|
const message = error instanceof Error ? error.message : String(error);
|
|
97936
98020
|
throw runtimeError2(`file source ${input.sourceName} metadata read failed: ${file.snapshotPath}: ${message}`, {
|
|
@@ -97982,7 +98066,7 @@ async function readRouteMetadataFiles(input) {
|
|
|
97982
98066
|
|
|
97983
98067
|
// src/project/documentSiteDetection.ts
|
|
97984
98068
|
import { readdir as readdir17, stat as stat8 } from "node:fs/promises";
|
|
97985
|
-
import { basename as basename7, extname as extname11, join as
|
|
98069
|
+
import { basename as basename7, extname as extname11, join as join69, relative as relative21, resolve as resolve22 } from "node:path";
|
|
97986
98070
|
var SKIPPED_DIRS = new Set([
|
|
97987
98071
|
".cache",
|
|
97988
98072
|
".git",
|
|
@@ -98065,7 +98149,7 @@ async function detectDocumentSiteFiles(input) {
|
|
|
98065
98149
|
return;
|
|
98066
98150
|
}
|
|
98067
98151
|
result.scannedEntryCount += 1;
|
|
98068
|
-
const absolutePath =
|
|
98152
|
+
const absolutePath = join69(dir, entry.name);
|
|
98069
98153
|
if (entry.isDirectory()) {
|
|
98070
98154
|
const lower = entry.name.toLowerCase();
|
|
98071
98155
|
if (SKIPPED_DIRS.has(lower))
|
|
@@ -98255,7 +98339,7 @@ async function walkMarkdownFiles(input) {
|
|
|
98255
98339
|
const visit3 = async (dir) => {
|
|
98256
98340
|
const entries2 = await readdir18(dir, { withFileTypes: true });
|
|
98257
98341
|
for (const entry of entries2) {
|
|
98258
|
-
const absolutePath =
|
|
98342
|
+
const absolutePath = join73(dir, entry.name);
|
|
98259
98343
|
if (entry.isDirectory()) {
|
|
98260
98344
|
await visit3(absolutePath);
|
|
98261
98345
|
continue;
|
|
@@ -98277,14 +98361,14 @@ async function walkMarkdownFiles(input) {
|
|
|
98277
98361
|
}
|
|
98278
98362
|
async function writeTextIfChanged(path2, content3) {
|
|
98279
98363
|
try {
|
|
98280
|
-
if (await
|
|
98364
|
+
if (await readFile62(path2, "utf8") === content3)
|
|
98281
98365
|
return;
|
|
98282
98366
|
} catch {}
|
|
98283
98367
|
await mkdir27(dirname33(path2), { recursive: true });
|
|
98284
|
-
await
|
|
98368
|
+
await writeFile22(path2, content3, "utf8");
|
|
98285
98369
|
}
|
|
98286
98370
|
function sourceManifestPath(entry) {
|
|
98287
|
-
return entry.snapshot?.manifest ??
|
|
98371
|
+
return entry.snapshot?.manifest ?? join73(entry.materializedAt, "manifest.json");
|
|
98288
98372
|
}
|
|
98289
98373
|
function runtimeError3(message, detail) {
|
|
98290
98374
|
return new ContextError(ExitCode.UserError, message, {
|
|
@@ -98357,7 +98441,7 @@ async function removeEmptySnapshotDirs(root, dir = root) {
|
|
|
98357
98441
|
for (const entry of entries2) {
|
|
98358
98442
|
if (!entry.isDirectory() || entry.name === ".tmp" || entry.name === ".cache")
|
|
98359
98443
|
continue;
|
|
98360
|
-
await removeEmptySnapshotDirs(root,
|
|
98444
|
+
await removeEmptySnapshotDirs(root, join73(dir, entry.name));
|
|
98361
98445
|
}
|
|
98362
98446
|
if (dir === root)
|
|
98363
98447
|
return;
|
|
@@ -98369,7 +98453,7 @@ async function removeEmptySnapshotDirs(root, dir = root) {
|
|
|
98369
98453
|
async function cleanupStaleSnapshotFiles(input) {
|
|
98370
98454
|
for (const path2 of input.previousPaths) {
|
|
98371
98455
|
if (!input.currentPaths.has(path2)) {
|
|
98372
|
-
await rm17(
|
|
98456
|
+
await rm17(join73(input.materializedAtAbsPath, path2), { force: true });
|
|
98373
98457
|
}
|
|
98374
98458
|
}
|
|
98375
98459
|
await removeEmptySnapshotDirs(input.materializedAtAbsPath);
|
|
@@ -98381,7 +98465,7 @@ async function readDocumentFiles(input) {
|
|
|
98381
98465
|
for (const file of input.files) {
|
|
98382
98466
|
let raw;
|
|
98383
98467
|
try {
|
|
98384
|
-
raw = await
|
|
98468
|
+
raw = await readFile62(file.absolutePath, "utf8");
|
|
98385
98469
|
} catch (error) {
|
|
98386
98470
|
const message = error instanceof Error ? error.message : String(error);
|
|
98387
98471
|
throw runtimeError3(`file source ${input.sourceName} document read failed: ${file.snapshotPath}: ${message}`, {
|
|
@@ -98550,9 +98634,9 @@ async function runCaptureFilePhaseUnlocked(input) {
|
|
|
98550
98634
|
documentSnapshot
|
|
98551
98635
|
});
|
|
98552
98636
|
const manifestPath = sourceManifestPath(entry);
|
|
98553
|
-
const manifestAbsPath =
|
|
98637
|
+
const manifestAbsPath = join73(input.projectRoot, manifestPath);
|
|
98554
98638
|
const materializedAt = entry.materializedAt;
|
|
98555
|
-
const materializedAtAbsPath =
|
|
98639
|
+
const materializedAtAbsPath = join73(input.projectRoot, materializedAt);
|
|
98556
98640
|
const manifestInput = {
|
|
98557
98641
|
sourceType: "file",
|
|
98558
98642
|
sourceName: resolved.sourceName,
|
|
@@ -98602,13 +98686,13 @@ async function runCaptureFilePhaseUnlocked(input) {
|
|
|
98602
98686
|
}));
|
|
98603
98687
|
try {
|
|
98604
98688
|
for (const file of snapshotFiles) {
|
|
98605
|
-
await writeTextIfChanged(
|
|
98689
|
+
await writeTextIfChanged(join73(materializedAtAbsPath, file.path), String(file.bytes));
|
|
98606
98690
|
}
|
|
98607
98691
|
for (const file of files.metadata) {
|
|
98608
|
-
await writeTextIfChanged(
|
|
98692
|
+
await writeTextIfChanged(join73(materializedAtAbsPath, file.snapshotPath), routeMetadata.rawByPath.get(file.snapshotPath) ?? "");
|
|
98609
98693
|
}
|
|
98610
98694
|
for (const asset of linkedAssets) {
|
|
98611
|
-
await writeCaptureAssetIfChanged(
|
|
98695
|
+
await writeCaptureAssetIfChanged(join73(materializedAtAbsPath, asset.snapshotPath), asset.bytes);
|
|
98612
98696
|
}
|
|
98613
98697
|
await writeTextIfChanged(manifestAbsPath, manifestContent);
|
|
98614
98698
|
await cleanupStaleSnapshotFiles({
|
|
@@ -98662,7 +98746,7 @@ async function runCaptureFilePhase(input) {
|
|
|
98662
98746
|
init_src3();
|
|
98663
98747
|
init_larkCaptureReport();
|
|
98664
98748
|
import { readFileSync as readFileSync7 } from "node:fs";
|
|
98665
|
-
import { join as
|
|
98749
|
+
import { join as join74 } from "node:path";
|
|
98666
98750
|
function readDocumentSnapshotCaptureReport(input) {
|
|
98667
98751
|
const summary = input.manifest.metadata?.capture?.report;
|
|
98668
98752
|
if (summary === undefined)
|
|
@@ -98671,7 +98755,7 @@ function readDocumentSnapshotCaptureReport(input) {
|
|
|
98671
98755
|
if (asset === undefined || asset.role !== "audit" || asset.content_hash === undefined) {
|
|
98672
98756
|
throw new TypeError(`snapshot capture report is not registered as a hashed audit asset: ${summary.path}`);
|
|
98673
98757
|
}
|
|
98674
|
-
const bytes = readFileSync7(
|
|
98758
|
+
const bytes = readFileSync7(join74(input.projectRoot, input.materializedAt, summary.path));
|
|
98675
98759
|
if (computeDocumentContentHash(bytes) !== asset.content_hash) {
|
|
98676
98760
|
throw new TypeError(`snapshot capture report hash does not match manifest: ${summary.path}`);
|
|
98677
98761
|
}
|
|
@@ -98742,17 +98826,17 @@ init_cliFeedback();
|
|
|
98742
98826
|
init_errors3();
|
|
98743
98827
|
init_exitCode();
|
|
98744
98828
|
import { existsSync as existsSync21 } from "node:fs";
|
|
98745
|
-
import { lstat as lstat9, mkdir as mkdir28, readFile as
|
|
98829
|
+
import { lstat as lstat9, mkdir as mkdir28, readFile as readFile64, readlink, realpath as realpath9, rm as rm18, symlink as symlink3 } from "node:fs/promises";
|
|
98746
98830
|
import { execFile as execFile9 } from "node:child_process";
|
|
98747
98831
|
import { promisify as promisify9 } from "node:util";
|
|
98748
|
-
import { dirname as dirname34, isAbsolute as isAbsolute14, join as
|
|
98832
|
+
import { dirname as dirname34, isAbsolute as isAbsolute14, join as join77, relative as relative23, resolve as resolve26 } from "node:path";
|
|
98749
98833
|
|
|
98750
98834
|
// src/project/repoSourceModules.ts
|
|
98751
98835
|
init_src();
|
|
98752
98836
|
init_src3();
|
|
98753
98837
|
import { existsSync as existsSync19 } from "node:fs";
|
|
98754
|
-
import { readFile as
|
|
98755
|
-
import { join as
|
|
98838
|
+
import { readFile as readFile63, readdir as readdir19 } from "node:fs/promises";
|
|
98839
|
+
import { join as join75, resolve as resolve25 } from "node:path";
|
|
98756
98840
|
async function rootNames(root) {
|
|
98757
98841
|
try {
|
|
98758
98842
|
return (await readdir19(root)).sort();
|
|
@@ -98761,11 +98845,11 @@ async function rootNames(root) {
|
|
|
98761
98845
|
}
|
|
98762
98846
|
}
|
|
98763
98847
|
async function packageEntries(root) {
|
|
98764
|
-
const path2 =
|
|
98848
|
+
const path2 = join75(root, "package.json");
|
|
98765
98849
|
if (!existsSync19(path2))
|
|
98766
98850
|
return [];
|
|
98767
98851
|
try {
|
|
98768
|
-
const value = JSON.parse(await
|
|
98852
|
+
const value = JSON.parse(await readFile63(path2, "utf8"));
|
|
98769
98853
|
const entries2 = [value.exports, value.main, value.module, value.bin].flatMap((item) => typeof item === "string" ? [item] : item !== null && typeof item === "object" ? Object.values(item).filter((entry) => typeof entry === "string") : []);
|
|
98770
98854
|
return [...new Set(entries2.map((entry) => entry.replace(/^\.\//u, "")))].sort();
|
|
98771
98855
|
} catch {
|
|
@@ -98773,9 +98857,9 @@ async function packageEntries(root) {
|
|
|
98773
98857
|
}
|
|
98774
98858
|
}
|
|
98775
98859
|
async function planningEvidence(inspectPath, module) {
|
|
98776
|
-
const root = module.path === "." ? inspectPath :
|
|
98860
|
+
const root = module.path === "." ? inspectPath : join75(inspectPath, module.path);
|
|
98777
98861
|
const names = await rootNames(root);
|
|
98778
|
-
const commonEntries = ["src/index.ts", "src/index.tsx", "src/main.ts", "src/main.tsx", "main.go"].filter((path2) => existsSync19(
|
|
98862
|
+
const commonEntries = ["src/index.ts", "src/index.tsx", "src/main.ts", "src/main.tsx", "main.go"].filter((path2) => existsSync19(join75(root, path2)));
|
|
98779
98863
|
const protocolNames = names.filter((name3) => /(?:openapi|swagger|schema|protocol|idl)/iu.test(name3) || /\.(?:proto|thrift)$/iu.test(name3));
|
|
98780
98864
|
const lifecycleNames = names.filter((name3) => /(?:generated|vendor|mirror|legacy|sync)/iu.test(name3));
|
|
98781
98865
|
return {
|
|
@@ -98813,7 +98897,7 @@ function suggestedModuleName(module) {
|
|
|
98813
98897
|
return slug || "module";
|
|
98814
98898
|
}
|
|
98815
98899
|
async function inspectRepoSourceModules(input) {
|
|
98816
|
-
const inspectPath = input.scopedAbs !== null && existsSync19(input.scopedAbs) ? input.scopedAbs :
|
|
98900
|
+
const inspectPath = input.scopedAbs !== null && existsSync19(input.scopedAbs) ? input.scopedAbs : join75(input.projectRoot, input.status.materializedAt);
|
|
98817
98901
|
const modules = existsSync19(inspectPath) ? await detectModuleBoundaries(inspectPath, input.status.head ?? input.status.ref, DEFAULT_PATH_FILTER) : [];
|
|
98818
98902
|
const recommended_sources = modules.filter((module) => module.path !== "." || modules.length === 1).map((module) => {
|
|
98819
98903
|
const local = sourceModuleLocalForDisplay({ source: input.source, status: input.status, module });
|
|
@@ -98855,7 +98939,7 @@ init_exitCode();
|
|
|
98855
98939
|
init_atomicWrite();
|
|
98856
98940
|
var import_yaml37 = __toESM(require_dist(), 1);
|
|
98857
98941
|
import { existsSync as existsSync20 } from "node:fs";
|
|
98858
|
-
import { join as
|
|
98942
|
+
import { join as join76 } from "node:path";
|
|
98859
98943
|
var SOURCE_NAME_PATTERN2 = /^[a-z0-9][a-z0-9._-]*$/u;
|
|
98860
98944
|
var REPO_DATE_NAMESPACE_PATTERN2 = /^\d{8}$/u;
|
|
98861
98945
|
function assertRepoModuleName(name3) {
|
|
@@ -98908,7 +98992,7 @@ function registryEntryToRecord(entry) {
|
|
|
98908
98992
|
};
|
|
98909
98993
|
}
|
|
98910
98994
|
function registryPath(projectRoot) {
|
|
98911
|
-
return
|
|
98995
|
+
return join76(projectRoot, DEFAULT_REPO_SOURCES_REGISTRY_PATH);
|
|
98912
98996
|
}
|
|
98913
98997
|
function defaultRepoMaterializedAt(source2) {
|
|
98914
98998
|
return `sources/repo/${source2.namespace}/${source2.module}`;
|
|
@@ -99010,13 +99094,13 @@ async function gitOutput(cwd, args) {
|
|
|
99010
99094
|
}
|
|
99011
99095
|
}
|
|
99012
99096
|
async function readGitOriginRemote(cwd) {
|
|
99013
|
-
const directConfigPath =
|
|
99014
|
-
let config = await
|
|
99097
|
+
const directConfigPath = join77(cwd, ".git", "config");
|
|
99098
|
+
let config = await readFile64(directConfigPath, "utf8").catch(() => "");
|
|
99015
99099
|
if (config.length === 0) {
|
|
99016
99100
|
const gitDir = await resolveGitDir(cwd);
|
|
99017
99101
|
if (gitDir === null)
|
|
99018
99102
|
return null;
|
|
99019
|
-
config = await
|
|
99103
|
+
config = await readFile64(join77(gitDir, "config"), "utf8").catch(() => "");
|
|
99020
99104
|
}
|
|
99021
99105
|
let inOriginBlock = false;
|
|
99022
99106
|
for (const line of config.split(/\r?\n/u)) {
|
|
@@ -99036,7 +99120,7 @@ async function readGitOriginRemote(cwd) {
|
|
|
99036
99120
|
async function resolveGitRoot(cwd) {
|
|
99037
99121
|
let current2 = resolve26(cwd);
|
|
99038
99122
|
while (true) {
|
|
99039
|
-
if (existsSync21(
|
|
99123
|
+
if (existsSync21(join77(current2, ".git")))
|
|
99040
99124
|
return current2;
|
|
99041
99125
|
const parent = dirname34(current2);
|
|
99042
99126
|
if (parent === current2)
|
|
@@ -99045,7 +99129,7 @@ async function resolveGitRoot(cwd) {
|
|
|
99045
99129
|
}
|
|
99046
99130
|
}
|
|
99047
99131
|
async function resolveGitDir(cwd) {
|
|
99048
|
-
const dotGit =
|
|
99132
|
+
const dotGit = join77(cwd, ".git");
|
|
99049
99133
|
if (!existsSync21(dotGit))
|
|
99050
99134
|
return null;
|
|
99051
99135
|
const stats = await lstat9(dotGit);
|
|
@@ -99053,7 +99137,7 @@ async function resolveGitDir(cwd) {
|
|
|
99053
99137
|
return dotGit;
|
|
99054
99138
|
if (!stats.isFile())
|
|
99055
99139
|
return null;
|
|
99056
|
-
const raw = await
|
|
99140
|
+
const raw = await readFile64(dotGit, "utf8").catch(() => "");
|
|
99057
99141
|
const match = /^gitdir:\s*(.+)\s*$/iu.exec(raw.trim());
|
|
99058
99142
|
if (match?.[1] === undefined)
|
|
99059
99143
|
return null;
|
|
@@ -99063,17 +99147,17 @@ async function readGitHead(cwd) {
|
|
|
99063
99147
|
const gitDir = await resolveGitDir(cwd);
|
|
99064
99148
|
if (gitDir === null)
|
|
99065
99149
|
return null;
|
|
99066
|
-
const headRaw = (await
|
|
99150
|
+
const headRaw = (await readFile64(join77(gitDir, "HEAD"), "utf8").catch(() => "")).trim();
|
|
99067
99151
|
if (/^[a-f0-9]{40}$/iu.test(headRaw))
|
|
99068
99152
|
return headRaw.toLowerCase();
|
|
99069
99153
|
const match = /^ref:\s*(.+)\s*$/iu.exec(headRaw);
|
|
99070
99154
|
const refPath = match?.[1];
|
|
99071
99155
|
if (refPath === undefined)
|
|
99072
99156
|
return null;
|
|
99073
|
-
const looseRef = (await
|
|
99157
|
+
const looseRef = (await readFile64(join77(gitDir, refPath), "utf8").catch(() => "")).trim();
|
|
99074
99158
|
if (/^[a-f0-9]{40}$/iu.test(looseRef))
|
|
99075
99159
|
return looseRef.toLowerCase();
|
|
99076
|
-
const packedRefs = await
|
|
99160
|
+
const packedRefs = await readFile64(join77(gitDir, "packed-refs"), "utf8").catch(() => "");
|
|
99077
99161
|
for (const line of packedRefs.split(/\r?\n/u)) {
|
|
99078
99162
|
if (line.startsWith("#") || line.startsWith("^"))
|
|
99079
99163
|
continue;
|
|
@@ -99084,7 +99168,7 @@ async function readGitHead(cwd) {
|
|
|
99084
99168
|
return null;
|
|
99085
99169
|
}
|
|
99086
99170
|
async function ensureMaterializedSymlink(input) {
|
|
99087
|
-
const linkPath =
|
|
99171
|
+
const linkPath = join77(input.projectRoot, input.materializedAt);
|
|
99088
99172
|
await mkdir28(dirname34(linkPath), { recursive: true });
|
|
99089
99173
|
if (existsSync21(linkPath)) {
|
|
99090
99174
|
const stats = await lstat9(linkPath);
|
|
@@ -99103,7 +99187,7 @@ async function ensureMaterializedSymlink(input) {
|
|
|
99103
99187
|
return true;
|
|
99104
99188
|
}
|
|
99105
99189
|
async function diagnoseMaterializedSymlink(input) {
|
|
99106
|
-
const linkPath =
|
|
99190
|
+
const linkPath = join77(input.projectRoot, input.materializedAt);
|
|
99107
99191
|
if (!existsSync21(linkPath)) {
|
|
99108
99192
|
input.diagnostics.push(`materialized path is missing: ${input.materializedAt}`);
|
|
99109
99193
|
input.agent_hints.push(`Run context source ensure ${input.sourceName} to materialize the local source link.`);
|
|
@@ -99326,7 +99410,7 @@ async function inspectRepoSource(input) {
|
|
|
99326
99410
|
const subpath = normalizeSubpath2(source2.subpath);
|
|
99327
99411
|
const scopedAbs = localAbs === null ? null : scopedLocalPath(localAbs, subpath);
|
|
99328
99412
|
const scopeExists = scopedAbs !== null && existsSync21(scopedAbs);
|
|
99329
|
-
let materialized = existsSync21(
|
|
99413
|
+
let materialized = existsSync21(join77(input.projectRoot, materializedAt));
|
|
99330
99414
|
const checkout = await inspectRepoCheckout({
|
|
99331
99415
|
source: source2,
|
|
99332
99416
|
localAbs,
|
|
@@ -99495,8 +99579,8 @@ init_approvedKnowledgeMetadata();
|
|
|
99495
99579
|
init_knowledgeAssets();
|
|
99496
99580
|
var import_yaml38 = __toESM(require_dist(), 1);
|
|
99497
99581
|
import { createHash as createHash22 } from "node:crypto";
|
|
99498
|
-
import { mkdir as mkdir29, writeFile as
|
|
99499
|
-
import { dirname as dirname35, join as
|
|
99582
|
+
import { mkdir as mkdir29, writeFile as writeFile23 } from "node:fs/promises";
|
|
99583
|
+
import { dirname as dirname35, join as join78 } from "node:path";
|
|
99500
99584
|
|
|
99501
99585
|
// src/project/entityId.ts
|
|
99502
99586
|
init_cliFeedback();
|
|
@@ -99515,7 +99599,7 @@ function assertSafeEntityId(id3) {
|
|
|
99515
99599
|
}
|
|
99516
99600
|
|
|
99517
99601
|
// src/project/reviewShared.ts
|
|
99518
|
-
var REVIEW_ACTION_ROOT2 =
|
|
99602
|
+
var REVIEW_ACTION_ROOT2 = join78(".tmp", "context-runtime", "review-actions");
|
|
99519
99603
|
var REVIEW_PAYLOAD_SCHEMA = "context.review.decisions.v1";
|
|
99520
99604
|
function isRecord14(value) {
|
|
99521
99605
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -99559,7 +99643,7 @@ async function buildApprovedArticleIndex(projectRoot) {
|
|
|
99559
99643
|
if (!isApprovedKnowledgeMarkdownPath(rel))
|
|
99560
99644
|
continue;
|
|
99561
99645
|
const { absPath, content: content3 } = file;
|
|
99562
|
-
const relPath =
|
|
99646
|
+
const relPath = join78("knowledge", collection, rel);
|
|
99563
99647
|
assetReferencesByRelPath.set(relPath, knowledgeAssetReferences({
|
|
99564
99648
|
pageRelPath: relPath,
|
|
99565
99649
|
content: content3
|
|
@@ -99572,7 +99656,7 @@ async function buildApprovedArticleIndex(projectRoot) {
|
|
|
99572
99656
|
continue;
|
|
99573
99657
|
const frontmatter2 = hydrateApprovedFrontmatter({
|
|
99574
99658
|
frontmatter: parsed,
|
|
99575
|
-
relPath:
|
|
99659
|
+
relPath: join78(collection, rel),
|
|
99576
99660
|
metadata
|
|
99577
99661
|
});
|
|
99578
99662
|
const article = articlesByPath.get(`${collection}/${rel}`);
|
|
@@ -99627,10 +99711,10 @@ ${yaml3}
|
|
|
99627
99711
|
}
|
|
99628
99712
|
async function writeReviewActionLog(input) {
|
|
99629
99713
|
const stamp = new Date().toISOString().replace(/[-:.TZ]/gu, "");
|
|
99630
|
-
const relPath =
|
|
99631
|
-
const path2 =
|
|
99714
|
+
const relPath = join78(REVIEW_ACTION_ROOT2, `${stamp}-${input.action}-${input.id.replace(/[\\/]+/gu, "_")}.json`);
|
|
99715
|
+
const path2 = join78(input.projectRoot, relPath);
|
|
99632
99716
|
await mkdir29(dirname35(path2), { recursive: true });
|
|
99633
|
-
await
|
|
99717
|
+
await writeFile23(path2, `${JSON.stringify({
|
|
99634
99718
|
action: input.action,
|
|
99635
99719
|
id: input.id,
|
|
99636
99720
|
...input.summary
|
|
@@ -99661,7 +99745,7 @@ async function countFiles(root, predicate) {
|
|
|
99661
99745
|
const entries2 = await readCommandDirectory(dir);
|
|
99662
99746
|
for (const entry of entries2) {
|
|
99663
99747
|
const rel = prefix.length === 0 ? entry.name : `${prefix}/${entry.name}`;
|
|
99664
|
-
const abs =
|
|
99748
|
+
const abs = join79(dir, entry.name);
|
|
99665
99749
|
if (entry.isDirectory())
|
|
99666
99750
|
await visit3(abs, rel);
|
|
99667
99751
|
else if (entry.isFile() && predicate(rel))
|
|
@@ -99852,7 +99936,7 @@ async function documentSourceSiteHint(input) {
|
|
|
99852
99936
|
});
|
|
99853
99937
|
}
|
|
99854
99938
|
function documentSnapshotReadiness(input) {
|
|
99855
|
-
const manifestPath =
|
|
99939
|
+
const manifestPath = join79(input.projectRoot, input.manifest);
|
|
99856
99940
|
if (!existsSync22(manifestPath)) {
|
|
99857
99941
|
return {
|
|
99858
99942
|
ready: false,
|
|
@@ -99922,7 +100006,7 @@ function documentSnapshotReadiness(input) {
|
|
|
99922
100006
|
const missingFiles = [
|
|
99923
100007
|
...manifest.files.map((file) => file.path),
|
|
99924
100008
|
...(manifest.assets ?? []).filter((asset) => asset.content_hash !== undefined).map((asset) => asset.path)
|
|
99925
|
-
].filter((path2) => !existsSync22(
|
|
100009
|
+
].filter((path2) => !existsSync22(join79(input.projectRoot, input.materializedAt, path2)));
|
|
99926
100010
|
if (missingFiles.length > 0) {
|
|
99927
100011
|
return {
|
|
99928
100012
|
ready: false,
|
|
@@ -100388,7 +100472,7 @@ async function collectProjectStatusSnapshotInternal(projectRoot, options = {}) {
|
|
|
100388
100472
|
const authoring = production && !production.delivery && (dispatchProductionStage(production, productionCapabilitiesSchema.parse({})).state !== "ended" || draftStatus.count > 0 && draftStatus.diagnostics.length === 0);
|
|
100389
100473
|
const deferDeliveryChecks = !maintenance && !localRevision && !localUpdate && !localRollback && (taskPreparation === "cleared" && !production || !!authoring);
|
|
100390
100474
|
const collectionsWithPages = new Set;
|
|
100391
|
-
const approvedPages = await countFiles(
|
|
100475
|
+
const approvedPages = await countFiles(join83(projectRoot, "knowledge"), (rel) => {
|
|
100392
100476
|
if (!isApprovedKnowledgeMarkdownPath(rel) || rel.startsWith("assets/"))
|
|
100393
100477
|
return false;
|
|
100394
100478
|
collectionsWithPages.add(rel.split("/")[0]);
|
|
@@ -100396,7 +100480,7 @@ async function collectProjectStatusSnapshotInternal(projectRoot, options = {}) {
|
|
|
100396
100480
|
});
|
|
100397
100481
|
const approvedCollections = KNOWLEDGE_COLLECTIONS.filter((collection) => collectionsWithPages.has(collection));
|
|
100398
100482
|
const closeStatus = deferDeliveryChecks ? { state: "not-checked", diagnostics: [] } : await readCloseStatus(projectRoot);
|
|
100399
|
-
const distFiles = await countFiles(
|
|
100483
|
+
const distFiles = await countFiles(join83(projectRoot, "dist"), () => true);
|
|
100400
100484
|
const verifyStatus = !deferDeliveryChecks && draftStatus.diagnostics.length === 0 ? await readVerifyStatus(projectRoot) : { issues: [], diagnostics: [] };
|
|
100401
100485
|
const pendingCapture = pendingDocumentCaptureCommands({
|
|
100402
100486
|
phases,
|
|
@@ -100765,14 +100849,14 @@ function bindWorkflowExecutionContext(result, context) {
|
|
|
100765
100849
|
// src/project/workflow/workflowRouteOutput.ts
|
|
100766
100850
|
init_atomicWrite();
|
|
100767
100851
|
import { createHash as createHash23 } from "node:crypto";
|
|
100768
|
-
import { join as
|
|
100852
|
+
import { join as join84 } from "node:path";
|
|
100769
100853
|
async function workflowRouteOutput(projectRoot, route) {
|
|
100770
100854
|
if (!route)
|
|
100771
100855
|
return null;
|
|
100772
100856
|
const body = `${JSON.stringify(route, null, 2)}
|
|
100773
100857
|
`;
|
|
100774
100858
|
const digest6 = createHash23("sha256").update(body).digest("hex");
|
|
100775
|
-
const file =
|
|
100859
|
+
const file = join84(projectRoot, ".tmp/context-runtime/routes", `${digest6}.json`);
|
|
100776
100860
|
await atomicWriteFile(file, body);
|
|
100777
100861
|
return {
|
|
100778
100862
|
file,
|
|
@@ -100788,7 +100872,7 @@ async function workflowRunResultFile(projectRoot, result) {
|
|
|
100788
100872
|
const body = `${JSON.stringify(result, null, 2)}
|
|
100789
100873
|
`;
|
|
100790
100874
|
const digest6 = createHash23("sha256").update(body).digest("hex");
|
|
100791
|
-
const file =
|
|
100875
|
+
const file = join84(projectRoot, ".tmp/context-runtime/action-results", `${digest6}.run.json`);
|
|
100792
100876
|
await atomicWriteFile(file, body);
|
|
100793
100877
|
return file;
|
|
100794
100878
|
}
|
|
@@ -104162,8 +104246,8 @@ function renderReviewMarkdown(markdown, pageTitle) {
|
|
|
104162
104246
|
|
|
104163
104247
|
// src/project/reviewHtml.ts
|
|
104164
104248
|
init_candidateLedger();
|
|
104165
|
-
import { mkdir as mkdir30, writeFile as
|
|
104166
|
-
import { dirname as dirname38, isAbsolute as isAbsolute15, join as
|
|
104249
|
+
import { mkdir as mkdir30, writeFile as writeFile24 } from "node:fs/promises";
|
|
104250
|
+
import { dirname as dirname38, isAbsolute as isAbsolute15, join as join85, resolve as resolve28 } from "node:path";
|
|
104167
104251
|
|
|
104168
104252
|
// src/project/reviewHtmlPresentation.ts
|
|
104169
104253
|
import { dirname as dirname37 } from "node:path";
|
|
@@ -104325,7 +104409,7 @@ var REVIEW_HTML_STYLES = `
|
|
|
104325
104409
|
`;
|
|
104326
104410
|
|
|
104327
104411
|
// src/project/reviewHtml.ts
|
|
104328
|
-
var REVIEW_HTML_ROOT =
|
|
104412
|
+
var REVIEW_HTML_ROOT = join85(".tmp", "context-runtime", "review");
|
|
104329
104413
|
async function collectReviewCandidates(projectRoot, collection) {
|
|
104330
104414
|
const rows = await readCandidateRecords(projectRoot);
|
|
104331
104415
|
const draftRows = rows.filter((row) => row.collection === collection && row.status === "draft");
|
|
@@ -104781,7 +104865,7 @@ function renderReviewHtml(candidates, reviewScope) {
|
|
|
104781
104865
|
}
|
|
104782
104866
|
function resolveOutputPath(projectRoot, outPath, reviewScope) {
|
|
104783
104867
|
if (outPath === undefined)
|
|
104784
|
-
return
|
|
104868
|
+
return join85(projectRoot, REVIEW_HTML_ROOT, `${reviewScope}.html`);
|
|
104785
104869
|
return isAbsolute15(outPath) ? outPath : resolve28(projectRoot, outPath);
|
|
104786
104870
|
}
|
|
104787
104871
|
async function writeReviewHtml(input) {
|
|
@@ -104792,7 +104876,7 @@ async function writeReviewHtml(input) {
|
|
|
104792
104876
|
const candidates = reviewScope === "all" ? await collectAllReviewCandidates(input.projectRoot) : await collectReviewCandidates(input.projectRoot, reviewScope);
|
|
104793
104877
|
const outPath = resolveOutputPath(input.projectRoot, input.out, reviewScope);
|
|
104794
104878
|
await mkdir30(dirname38(outPath), { recursive: true });
|
|
104795
|
-
await
|
|
104879
|
+
await writeFile24(outPath, renderReviewHtml(candidates, reviewScope), "utf8");
|
|
104796
104880
|
return {
|
|
104797
104881
|
path: outPath,
|
|
104798
104882
|
candidates: candidates.length,
|
|
@@ -104805,8 +104889,8 @@ async function writeReviewHtml(input) {
|
|
|
104805
104889
|
init_productionRequirements();
|
|
104806
104890
|
init_dist();
|
|
104807
104891
|
init_atomicWrite();
|
|
104808
|
-
import { mkdir as mkdir31, readFile as
|
|
104809
|
-
import { join as
|
|
104892
|
+
import { mkdir as mkdir31, readFile as readFile67 } from "node:fs/promises";
|
|
104893
|
+
import { join as join86 } from "node:path";
|
|
104810
104894
|
var REVIEW_BATCH_MAX_CANDIDATES = 6;
|
|
104811
104895
|
var REVIEW_BATCH_MAX_BYTES = 512 * 1024;
|
|
104812
104896
|
async function readerPurposes(projectRoot, sources) {
|
|
@@ -104885,12 +104969,12 @@ async function materializeCurrentReviewBatchSet(input) {
|
|
|
104885
104969
|
const batches = buildCurrentReviewBatchDocuments(input.candidates);
|
|
104886
104970
|
const setDigest = digestText(batches.map((batch) => `${batch.task_key}:${batch.digest}`).join(`
|
|
104887
104971
|
`));
|
|
104888
|
-
const root2 =
|
|
104972
|
+
const root2 = join86(input.projectRoot, ".tmp", "context-runtime", "review", `current-${setDigest.slice("sha256:".length)}`);
|
|
104889
104973
|
await mkdir31(root2, { recursive: true });
|
|
104890
104974
|
const entries2 = [];
|
|
104891
104975
|
for (const batch of batches) {
|
|
104892
|
-
const path4 =
|
|
104893
|
-
const existing = await
|
|
104976
|
+
const path4 = join86(input.projectRoot, ".tmp", "context-runtime", "review", `${batch.task_key}-${batch.digest.slice("sha256:".length)}.md`);
|
|
104977
|
+
const existing = await readFile67(path4, "utf8").catch((error) => {
|
|
104894
104978
|
if (error.code === "ENOENT")
|
|
104895
104979
|
return;
|
|
104896
104980
|
throw error;
|
|
@@ -104942,7 +105026,7 @@ async function materializeCurrentReviewBatchSet(input) {
|
|
|
104942
105026
|
].join(`
|
|
104943
105027
|
`);
|
|
104944
105028
|
const digest6 = digestText(content3);
|
|
104945
|
-
const path3 =
|
|
105029
|
+
const path3 = join86(root2, "index.md");
|
|
104946
105030
|
await atomicWriteFile(path3, `${content3}
|
|
104947
105031
|
`);
|
|
104948
105032
|
return {
|
|
@@ -104975,11 +105059,11 @@ function shellQuote6(value) {
|
|
|
104975
105059
|
}
|
|
104976
105060
|
function receiptSetPath(receipts) {
|
|
104977
105061
|
const token = digestText(JSON.stringify(receipts)).slice("sha256:".length);
|
|
104978
|
-
return
|
|
105062
|
+
return join87(".tmp", "context-runtime", "workflow", "read-receipts", `${token}.json`);
|
|
104979
105063
|
}
|
|
104980
105064
|
async function writeReceiptContinuation(input) {
|
|
104981
105065
|
const path3 = receiptSetPath(input.receipts);
|
|
104982
|
-
const absolutePath =
|
|
105066
|
+
const absolutePath = join87(input.projectRoot, path3);
|
|
104983
105067
|
await writeJsonAtomic(absolutePath, input.receipts);
|
|
104984
105068
|
const contextCommand = input.managed ? [
|
|
104985
105069
|
"context",
|
|
@@ -105074,7 +105158,7 @@ async function materializeContextWorkflowResource(input) {
|
|
|
105074
105158
|
const resourceId = workflowResourceId(input.resourceId);
|
|
105075
105159
|
const content3 = renderContextWorkflowResource(resourceId, status);
|
|
105076
105160
|
const location = await materializeResource(await loadContextWorkflowProvider(), resourceId, {
|
|
105077
|
-
cache:
|
|
105161
|
+
cache: join87(found.projectRoot, ".tmp", "context-runtime", "workflow", "resources"),
|
|
105078
105162
|
workspace: found.projectRoot,
|
|
105079
105163
|
revision: input.revision,
|
|
105080
105164
|
input: {
|
|
@@ -105106,7 +105190,7 @@ async function materializeContextWorkflowResource(input) {
|
|
|
105106
105190
|
receipts: afterReadReceipts
|
|
105107
105191
|
});
|
|
105108
105192
|
const directResources = (status.workflow.current?.resources.required ?? []).filter((resource) => resource.read_state === "read-required" && resource.path !== undefined && resource.digest !== undefined);
|
|
105109
|
-
const afterReadCommand = directResources.length === 0 ? continuation.command : `context resource acknowledge-current --revision ${shellQuote6(input.revision)}${authorityCommandOptions(authorities, "resource")} --resource-receipts ${shellQuote6(`@${
|
|
105193
|
+
const afterReadCommand = directResources.length === 0 ? continuation.command : `context resource acknowledge-current --revision ${shellQuote6(input.revision)}${authorityCommandOptions(authorities, "resource")} --resource-receipts ${shellQuote6(`@${join87(found.projectRoot, continuation.path)}`)} --format json`;
|
|
105110
105194
|
return {
|
|
105111
105195
|
protocol: "context.workflow.resource.v1",
|
|
105112
105196
|
id: resourceId,
|
|
@@ -105167,14 +105251,14 @@ async function acknowledgeCurrentWorkflowResources(input) {
|
|
|
105167
105251
|
const reevaluated = await reevaluateProjectStatusWorkflow({
|
|
105168
105252
|
snapshot,
|
|
105169
105253
|
resourceReceipts: normalizedReceipts,
|
|
105170
|
-
resourceReceiptsReference: `@${
|
|
105254
|
+
resourceReceiptsReference: `@${join87(found.projectRoot, continuation.path)}`
|
|
105171
105255
|
});
|
|
105172
105256
|
return {
|
|
105173
105257
|
...reevaluated,
|
|
105174
105258
|
resourceAcknowledgement: {
|
|
105175
105259
|
protocol: "context.workflow.resource-receipts.v1",
|
|
105176
105260
|
acknowledged: directResources.length,
|
|
105177
|
-
receiptReference: `@${
|
|
105261
|
+
receiptReference: `@${join87(found.projectRoot, continuation.path)}`
|
|
105178
105262
|
}
|
|
105179
105263
|
};
|
|
105180
105264
|
}
|
|
@@ -105220,9 +105304,9 @@ init_cliFeedback();
|
|
|
105220
105304
|
init_errors3();
|
|
105221
105305
|
init_exitCode();
|
|
105222
105306
|
init_workspace();
|
|
105223
|
-
import { readFile as
|
|
105224
|
-
import { isAbsolute as isAbsolute16, join as
|
|
105225
|
-
var RECEIPT_DIRECTORY =
|
|
105307
|
+
import { readFile as readFile68 } from "node:fs/promises";
|
|
105308
|
+
import { isAbsolute as isAbsolute16, join as join88, sep as sep6, resolve as resolve29 } from "node:path";
|
|
105309
|
+
var RECEIPT_DIRECTORY = join88(".tmp", "context-runtime", "workflow", "read-receipts");
|
|
105226
105310
|
function workflowResourceReceiptCwd(value, cwd) {
|
|
105227
105311
|
if (value === undefined || !value.startsWith("@"))
|
|
105228
105312
|
return cwd;
|
|
@@ -105240,7 +105324,7 @@ async function receiptDocument(value, cwd) {
|
|
|
105240
105324
|
let source2 = value;
|
|
105241
105325
|
if (value.startsWith("@")) {
|
|
105242
105326
|
try {
|
|
105243
|
-
source2 = await
|
|
105327
|
+
source2 = await readFile68(resolve29(cwd, value.slice(1)), "utf8");
|
|
105244
105328
|
} catch (error) {
|
|
105245
105329
|
const ioCode = error !== null && typeof error === "object" && "code" in error && typeof error.code === "string" ? error.code : undefined;
|
|
105246
105330
|
throw new ContextError(ExitCode.UserError, "resource read receipt file is unavailable", {
|
|
@@ -105486,17 +105570,17 @@ function compactJsonResult(result, verbose) {
|
|
|
105486
105570
|
|
|
105487
105571
|
// src/project/runLog.ts
|
|
105488
105572
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
105489
|
-
import { mkdir as mkdir32, writeFile as
|
|
105490
|
-
import { dirname as dirname39, join as
|
|
105573
|
+
import { mkdir as mkdir32, writeFile as writeFile25 } from "node:fs/promises";
|
|
105574
|
+
import { dirname as dirname39, join as join91 } from "node:path";
|
|
105491
105575
|
var createPhaseRunId = () => {
|
|
105492
105576
|
const timestamp = new Date().toISOString().replace(/[-:.TZ]/gu, "");
|
|
105493
105577
|
return `run_${timestamp}_${randomUUID5().slice(0, 8)}`;
|
|
105494
105578
|
};
|
|
105495
105579
|
async function writePhaseRunLog(input) {
|
|
105496
|
-
const relPath =
|
|
105497
|
-
const absPath =
|
|
105580
|
+
const relPath = join91(".tmp", "context-runtime", "runs", `${input.runId}.json`);
|
|
105581
|
+
const absPath = join91(input.projectRoot, relPath);
|
|
105498
105582
|
await mkdir32(dirname39(absPath), { recursive: true });
|
|
105499
|
-
await
|
|
105583
|
+
await writeFile25(absPath, `${JSON.stringify({
|
|
105500
105584
|
run_id: input.runId,
|
|
105501
105585
|
phase_id: input.phase.id,
|
|
105502
105586
|
phase_kind: input.phase.kind,
|
|
@@ -106441,7 +106525,7 @@ init_workflowFacts();
|
|
|
106441
106525
|
init_cliFeedback();
|
|
106442
106526
|
init_errors3();
|
|
106443
106527
|
init_exitCode();
|
|
106444
|
-
import { readFile as
|
|
106528
|
+
import { readFile as readFile73 } from "node:fs/promises";
|
|
106445
106529
|
import { isAbsolute as isAbsolute18, resolve as resolve30 } from "node:path";
|
|
106446
106530
|
|
|
106447
106531
|
// src/project/reviewApply.ts
|
|
@@ -106454,8 +106538,8 @@ init_writeLock();
|
|
|
106454
106538
|
init_reviewApplyIndexer();
|
|
106455
106539
|
init_approvedKnowledgeSnapshots();
|
|
106456
106540
|
import { existsSync as existsSync25 } from "node:fs";
|
|
106457
|
-
import { readFile as
|
|
106458
|
-
import { join as
|
|
106541
|
+
import { readFile as readFile71 } from "node:fs/promises";
|
|
106542
|
+
import { join as join92 } from "node:path";
|
|
106459
106543
|
|
|
106460
106544
|
// src/project/reviewCandidateAuthority.ts
|
|
106461
106545
|
init_src2();
|
|
@@ -106552,7 +106636,7 @@ async function prepareApprovedPage(input) {
|
|
|
106552
106636
|
next: "Refresh the current production or article revision, then reopen Review before approval."
|
|
106553
106637
|
});
|
|
106554
106638
|
}
|
|
106555
|
-
const relPath =
|
|
106639
|
+
const relPath = join92("knowledge", input.record.path);
|
|
106556
106640
|
const existingView = findApprovedPageForArticleId(input.record.indexer_candidate.artifact_ref, input.approvedPageIndex);
|
|
106557
106641
|
const previousPath = input.record.approved_revision?.previous_path;
|
|
106558
106642
|
if (previousPath !== undefined && (!isSafeKnowledgeTargetPath(previousPath.split("/")[0], previousPath) || previousPath.includes("\\")))
|
|
@@ -106567,13 +106651,13 @@ async function prepareApprovedPage(input) {
|
|
|
106567
106651
|
next: "Resolve the approved page path migration explicitly before approving this candidate."
|
|
106568
106652
|
});
|
|
106569
106653
|
}
|
|
106570
|
-
const absPath =
|
|
106571
|
-
const existing = existsSync25(absPath) ? await
|
|
106654
|
+
const absPath = join92(input.projectRoot, relPath);
|
|
106655
|
+
const existing = existsSync25(absPath) ? await readFile71(absPath, "utf8") : undefined;
|
|
106572
106656
|
let previous3;
|
|
106573
106657
|
if (previousPath !== undefined) {
|
|
106574
106658
|
if (existing !== undefined || existingView?.relPath !== `knowledge/${previousPath}`)
|
|
106575
106659
|
throw new TypeError("Page move destination or original identity changed; refresh its revision.");
|
|
106576
|
-
previous3 = { path: `knowledge/${previousPath}`, content: await
|
|
106660
|
+
previous3 = { path: `knowledge/${previousPath}`, content: await readFile71(join92(input.projectRoot, "knowledge", previousPath), "utf8") };
|
|
106577
106661
|
}
|
|
106578
106662
|
if (input.record.approved_revision !== undefined) {
|
|
106579
106663
|
const base = previous3?.content ?? existing;
|
|
@@ -106620,7 +106704,7 @@ async function prepareApprovedPage(input) {
|
|
|
106620
106704
|
}
|
|
106621
106705
|
async function readProjectFileMaybe(projectRoot, relPath) {
|
|
106622
106706
|
try {
|
|
106623
|
-
return await
|
|
106707
|
+
return await readFile71(join92(projectRoot, relPath), "utf8");
|
|
106624
106708
|
} catch (error) {
|
|
106625
106709
|
if (error !== null && typeof error === "object" && "code" in error && error.code === "ENOENT") {
|
|
106626
106710
|
return;
|
|
@@ -106813,7 +106897,7 @@ async function applyReviewDecisions(input) {
|
|
|
106813
106897
|
});
|
|
106814
106898
|
}
|
|
106815
106899
|
seenApprovedIds.set(approvedRef, row.candidate_id);
|
|
106816
|
-
const approvedPath =
|
|
106900
|
+
const approvedPath = join92("knowledge", row.path);
|
|
106817
106901
|
const previousPathCandidate = seenApprovedPaths.get(knowledgeTargetPathKey(approvedPath));
|
|
106818
106902
|
if (previousPathCandidate !== undefined) {
|
|
106819
106903
|
throw new ContextError(ExitCode.UserError, `multiple approved review decisions target the same knowledge path: ${approvedPath}`, {
|
|
@@ -106863,7 +106947,7 @@ async function applyReviewDecisions(input) {
|
|
|
106863
106947
|
for (const path3 of approvedPageIndex.byRelPath.keys()) {
|
|
106864
106948
|
if (pagesToWrite.some((page) => page.relPath === path3 || page.previous?.path === path3))
|
|
106865
106949
|
continue;
|
|
106866
|
-
const before = await
|
|
106950
|
+
const before = await readFile71(join92(input.projectRoot, path3), "utf8");
|
|
106867
106951
|
const local = path3.replace(/^knowledge\//u, "");
|
|
106868
106952
|
const after = moveKnowledgeLinkTargets2(before, local, local, moved);
|
|
106869
106953
|
navigationTargets.push(reviewFileTarget({ path: path3, baseContent: before, targetContent: after }));
|
|
@@ -106917,17 +107001,17 @@ async function applyReviewDecisions(input) {
|
|
|
106917
107001
|
}
|
|
106918
107002
|
|
|
106919
107003
|
// src/project/reviewMaintenance.ts
|
|
106920
|
-
import { readFile as
|
|
107004
|
+
import { readFile as readFile72, writeFile as writeFile26 } from "node:fs/promises";
|
|
106921
107005
|
init_writeLock();
|
|
106922
107006
|
init_verifyFrontmatter();
|
|
106923
107007
|
function deprecateApprovedPage(input) {
|
|
106924
107008
|
return withProjectWriteLock(input.projectRoot, "deprecate-article", async () => {
|
|
106925
107009
|
const page = await approvedPageForArticleId(input.projectRoot, input.viewRef);
|
|
106926
|
-
const original = await
|
|
107010
|
+
const original = await readFile72(page.path, "utf8");
|
|
106927
107011
|
const content3 = parseFrontmatterLoose(original).deprecated === true ? original : updateFrontmatter(original, (metadata) => ({ ...metadata, deprecated: true, timestamp: new Date().toISOString() }));
|
|
106928
107012
|
const changed = content3 !== original;
|
|
106929
107013
|
if (changed)
|
|
106930
|
-
await
|
|
107014
|
+
await writeFile26(page.path, content3, "utf8");
|
|
106931
107015
|
const actionLog = await writeReviewActionLog({
|
|
106932
107016
|
projectRoot: input.projectRoot,
|
|
106933
107017
|
action: "deprecate",
|
|
@@ -106943,12 +107027,12 @@ init_candidateLedger();
|
|
|
106943
107027
|
|
|
106944
107028
|
// src/project/localHtmlReport.ts
|
|
106945
107029
|
import { execFile as execFile10 } from "node:child_process";
|
|
106946
|
-
import { isAbsolute as isAbsolute17, join as
|
|
107030
|
+
import { isAbsolute as isAbsolute17, join as join93 } from "node:path";
|
|
106947
107031
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
106948
107032
|
import { promisify as promisify10 } from "node:util";
|
|
106949
107033
|
var execFileAsync5 = promisify10(execFile10);
|
|
106950
107034
|
function htmlReportReference(input) {
|
|
106951
|
-
const absolutePath = isAbsolute17(input.path) ? input.path :
|
|
107035
|
+
const absolutePath = isAbsolute17(input.path) ? input.path : join93(input.projectRoot, input.path);
|
|
106952
107036
|
return {
|
|
106953
107037
|
format: "html",
|
|
106954
107038
|
path: input.path,
|
|
@@ -107120,7 +107204,7 @@ function parseReviewPayloadText(raw) {
|
|
|
107120
107204
|
async function readReviewPayloadFile(filePath2) {
|
|
107121
107205
|
let raw;
|
|
107122
107206
|
try {
|
|
107123
|
-
raw = await
|
|
107207
|
+
raw = await readFile73(filePath2, "utf8");
|
|
107124
107208
|
} catch (error) {
|
|
107125
107209
|
const message = error instanceof Error ? error.message : String(error);
|
|
107126
107210
|
throw new ContextError(ExitCode.UserError, `review payload file cannot be read: ${filePath2}`, {
|
|
@@ -107951,8 +108035,8 @@ init_exitCode();
|
|
|
107951
108035
|
init_maintenanceStorage();
|
|
107952
108036
|
init_productionFeedback();
|
|
107953
108037
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
107954
|
-
import { readFile as
|
|
107955
|
-
import { join as
|
|
108038
|
+
import { readFile as readFile74 } from "node:fs/promises";
|
|
108039
|
+
import { join as join94 } from "node:path";
|
|
107956
108040
|
async function beginProductionRevision(input) {
|
|
107957
108041
|
return withProductionFeedback({ operation: "revision" }, () => withProjectWriteLock(input.projectRoot, "production-revision", async () => {
|
|
107958
108042
|
await recoverDurableMultiFileTransactions(input.projectRoot);
|
|
@@ -107991,7 +108075,7 @@ async function beginProductionRevision(input) {
|
|
|
107991
108075
|
const formal = approved.byPath.get(path3);
|
|
107992
108076
|
if (!prior && !formal)
|
|
107993
108077
|
throw invalid2("Write the current task first; there is no article draft to revise yet.");
|
|
107994
|
-
const markdown = prior?.body ?? await
|
|
108078
|
+
const markdown = prior?.body ?? await readFile74(await safeProjectTarget(input.projectRoot, join94("knowledge", path3)), "utf8");
|
|
107995
108079
|
const sections = prior?.indexer_candidate.sections.map((section) => ({ id: section.section_key, references: section.references })) ?? formal?.sections;
|
|
107996
108080
|
const sources = [];
|
|
107997
108081
|
for (const source2 of owner.sources) {
|
|
@@ -108168,7 +108252,7 @@ init_cliFeedback();
|
|
|
108168
108252
|
init_errors3();
|
|
108169
108253
|
init_exitCode();
|
|
108170
108254
|
var import_yaml40 = __toESM(require_dist(), 1);
|
|
108171
|
-
import { readFile as
|
|
108255
|
+
import { readFile as readFile75 } from "node:fs/promises";
|
|
108172
108256
|
function userInputError2(message, detail = {}) {
|
|
108173
108257
|
return new ContextError(ExitCode.UserError, message, {
|
|
108174
108258
|
category: ErrorCategory.UserInputInvalid,
|
|
@@ -108237,7 +108321,7 @@ async function readPayloadTextFromStdin(stdin) {
|
|
|
108237
108321
|
}
|
|
108238
108322
|
async function readPayloadText(path3) {
|
|
108239
108323
|
if (path3 !== "-")
|
|
108240
|
-
return
|
|
108324
|
+
return readFile75(path3, "utf8");
|
|
108241
108325
|
return readPayloadTextFromStdin(process.stdin);
|
|
108242
108326
|
}
|
|
108243
108327
|
async function readYamlOrJsonInput(input) {
|
|
@@ -108631,7 +108715,7 @@ init_atomicWrite();
|
|
|
108631
108715
|
var import_yaml43 = __toESM(require_dist(), 1);
|
|
108632
108716
|
import { Buffer as Buffer4 } from "node:buffer";
|
|
108633
108717
|
import { createHash as createHash29 } from "node:crypto";
|
|
108634
|
-
import { join as
|
|
108718
|
+
import { join as join98 } from "node:path";
|
|
108635
108719
|
var INLINE_LIMIT = 16 * 1024;
|
|
108636
108720
|
function record4(value) {
|
|
108637
108721
|
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : undefined;
|
|
@@ -108657,8 +108741,8 @@ async function prepareActionCompletionOutput(input) {
|
|
|
108657
108741
|
if (production && Buffer4.byteLength(full) <= INLINE_LIMIT)
|
|
108658
108742
|
return input.result;
|
|
108659
108743
|
const digest6 = createHash29("sha256").update(full).digest("hex");
|
|
108660
|
-
const root2 =
|
|
108661
|
-
const resultFile =
|
|
108744
|
+
const root2 = join98(input.projectRoot, ".tmp/context-runtime/action-results");
|
|
108745
|
+
const resultFile = join98(root2, `${digest6}.json`);
|
|
108662
108746
|
await atomicWriteFile(resultFile, full);
|
|
108663
108747
|
if (production)
|
|
108664
108748
|
return {
|
|
@@ -108669,7 +108753,7 @@ async function prepareActionCompletionOutput(input) {
|
|
|
108669
108753
|
...pick(result, ["next", "next_preparation"])
|
|
108670
108754
|
};
|
|
108671
108755
|
const next2 = record4(result.next) ?? record4(record4(result.workflow)?.current) ?? record4(record4(result.continuation)?.next);
|
|
108672
|
-
const nextFile = next2 === undefined ? undefined :
|
|
108756
|
+
const nextFile = next2 === undefined ? undefined : join98(root2, `${digest6}.next.json`);
|
|
108673
108757
|
if (nextFile !== undefined)
|
|
108674
108758
|
await atomicWriteFile(nextFile, serializeActionCompletion(next2, "json"));
|
|
108675
108759
|
const outcomes = (Array.isArray(result.outcomes) ? result.outcomes : []).map(record4).filter((item) => item !== undefined);
|
|
@@ -109072,7 +109156,7 @@ init_cliFeedback();
|
|
|
109072
109156
|
import { existsSync as existsSync27 } from "node:fs";
|
|
109073
109157
|
import { readdir as readdir25, rm as rm20 } from "node:fs/promises";
|
|
109074
109158
|
import { homedir } from "node:os";
|
|
109075
|
-
import { join as
|
|
109159
|
+
import { join as join99 } from "node:path";
|
|
109076
109160
|
var ORPHAN_MARKER = ".orphaned_at";
|
|
109077
109161
|
var CLAUDE_PLUGIN_CACHE_ROOT_ENV = "C4A_CLAUDE_PLUGIN_CACHE_ROOT";
|
|
109078
109162
|
var CLAUDE_PLUGIN_CACHE_HOME_ENV = "C4A_CLAUDE_PLUGIN_CACHE_HOME";
|
|
@@ -109089,19 +109173,19 @@ async function cleanClaudePluginCache(opts = {}) {
|
|
|
109089
109173
|
for (const mp of marketplaces) {
|
|
109090
109174
|
if (!mp.isDirectory())
|
|
109091
109175
|
continue;
|
|
109092
|
-
const mpDir =
|
|
109176
|
+
const mpDir = join99(cacheRoot, mp.name);
|
|
109093
109177
|
const plugins = await readdir25(mpDir, { withFileTypes: true });
|
|
109094
109178
|
for (const pl of plugins) {
|
|
109095
109179
|
if (!pl.isDirectory())
|
|
109096
109180
|
continue;
|
|
109097
|
-
const plDir =
|
|
109181
|
+
const plDir = join99(mpDir, pl.name);
|
|
109098
109182
|
const versions = await readdir25(plDir, { withFileTypes: true });
|
|
109099
109183
|
for (const ver of versions) {
|
|
109100
109184
|
if (!ver.isDirectory())
|
|
109101
109185
|
continue;
|
|
109102
109186
|
scanned += 1;
|
|
109103
|
-
const verDir =
|
|
109104
|
-
const markerPath =
|
|
109187
|
+
const verDir = join99(plDir, ver.name);
|
|
109188
|
+
const markerPath = join99(verDir, ORPHAN_MARKER);
|
|
109105
109189
|
if (!existsSync27(markerPath))
|
|
109106
109190
|
continue;
|
|
109107
109191
|
const label2 = `${mp.name}/${pl.name}/${ver.name}`;
|
|
@@ -109133,7 +109217,7 @@ function resolveClaudePluginCacheRoot(opts) {
|
|
|
109133
109217
|
if (explicitRoot)
|
|
109134
109218
|
return explicitRoot;
|
|
109135
109219
|
const home = opts.home ?? process.env[CLAUDE_PLUGIN_CACHE_HOME_ENV] ?? homedir();
|
|
109136
|
-
return
|
|
109220
|
+
return join99(home, ".claude", "plugins", "cache");
|
|
109137
109221
|
}
|
|
109138
109222
|
async function isEmptyDir(dir) {
|
|
109139
109223
|
try {
|
|
@@ -109165,13 +109249,13 @@ init_exitCode();
|
|
|
109165
109249
|
|
|
109166
109250
|
// src/lib/packageVersion.ts
|
|
109167
109251
|
import { existsSync as existsSync28, readFileSync as readFileSync9 } from "node:fs";
|
|
109168
|
-
import { dirname as dirname42, join as
|
|
109252
|
+
import { dirname as dirname42, join as join100 } from "node:path";
|
|
109169
109253
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
109170
109254
|
function readPackageVersion() {
|
|
109171
109255
|
try {
|
|
109172
109256
|
let dir = dirname42(fileURLToPath7(import.meta.url));
|
|
109173
109257
|
for (let depth = 0;depth < 8; depth += 1) {
|
|
109174
|
-
const packagePath =
|
|
109258
|
+
const packagePath = join100(dir, "package.json");
|
|
109175
109259
|
if (existsSync28(packagePath)) {
|
|
109176
109260
|
const parsed = JSON.parse(readFileSync9(packagePath, "utf8"));
|
|
109177
109261
|
if (typeof parsed.version === "string" && parsed.version.length > 0) {
|
|
@@ -109194,7 +109278,7 @@ function readPackageVersion() {
|
|
|
109194
109278
|
|
|
109195
109279
|
// src/project/sourceCommands.ts
|
|
109196
109280
|
init_src2();
|
|
109197
|
-
import { readFile as
|
|
109281
|
+
import { readFile as readFile88 } from "node:fs/promises";
|
|
109198
109282
|
import { isAbsolute as isAbsolute22, resolve as resolve37 } from "node:path";
|
|
109199
109283
|
init_cliFeedback();
|
|
109200
109284
|
init_errors3();
|
|
@@ -109553,11 +109637,11 @@ async function restoreRepositorySources(input) {
|
|
|
109553
109637
|
// src/project/sourceDocumentStatus.ts
|
|
109554
109638
|
init_src2();
|
|
109555
109639
|
import { existsSync as existsSync30 } from "node:fs";
|
|
109640
|
+
import { readFile as readFile81 } from "node:fs/promises";
|
|
109641
|
+
import { join as join102 } from "node:path";
|
|
109642
|
+
// src/project/sourceCommandViews.ts
|
|
109556
109643
|
import { readFile as readFile80 } from "node:fs/promises";
|
|
109557
109644
|
import { join as join101 } from "node:path";
|
|
109558
|
-
// src/project/sourceCommandViews.ts
|
|
109559
|
-
import { readFile as readFile79 } from "node:fs/promises";
|
|
109560
|
-
import { join as join100 } from "node:path";
|
|
109561
109645
|
init_workspace();
|
|
109562
109646
|
init_documentBatchManifest();
|
|
109563
109647
|
function repoSourceAgentView(source2) {
|
|
@@ -109620,7 +109704,7 @@ async function fileSourceAgentViewWithNextAction(input) {
|
|
|
109620
109704
|
};
|
|
109621
109705
|
}
|
|
109622
109706
|
function documentSourceManifestPath(source2) {
|
|
109623
|
-
return source2.snapshot?.manifest ??
|
|
109707
|
+
return source2.snapshot?.manifest ?? join101(source2.materializedAt, "manifest.json");
|
|
109624
109708
|
}
|
|
109625
109709
|
async function fileSourceDocumentSiteHint(input) {
|
|
109626
109710
|
const detection = await detectDocumentSiteFiles({
|
|
@@ -109630,7 +109714,7 @@ async function fileSourceDocumentSiteHint(input) {
|
|
|
109630
109714
|
let snapshotConfigured = false;
|
|
109631
109715
|
const manifest = documentSourceManifestPath(input.source);
|
|
109632
109716
|
try {
|
|
109633
|
-
const parsed = parseDocumentSnapshotForSource(JSON.parse(await
|
|
109717
|
+
const parsed = parseDocumentSnapshotForSource(JSON.parse(await readFile80(join101(input.projectRoot, manifest), "utf8")), input.source.name);
|
|
109634
109718
|
snapshotConfigured = manifestUsesMdxJsonDocs(parsed);
|
|
109635
109719
|
} catch {
|
|
109636
109720
|
snapshotConfigured = false;
|
|
@@ -109662,11 +109746,11 @@ async function larkSourceAgentViewWithNextAction(input) {
|
|
|
109662
109746
|
// src/project/sourceDocumentStatus.ts
|
|
109663
109747
|
init_documentBatchManifest();
|
|
109664
109748
|
function documentSourceManifestPath2(source2) {
|
|
109665
|
-
return source2.snapshot?.manifest ??
|
|
109749
|
+
return source2.snapshot?.manifest ?? join102(source2.materializedAt, "manifest.json");
|
|
109666
109750
|
}
|
|
109667
109751
|
async function documentSnapshotState(input) {
|
|
109668
109752
|
const manifest = documentSourceManifestPath2(input.source);
|
|
109669
|
-
const manifestPath =
|
|
109753
|
+
const manifestPath = join102(input.projectRoot, manifest);
|
|
109670
109754
|
if (!existsSync30(manifestPath)) {
|
|
109671
109755
|
return {
|
|
109672
109756
|
snapshotReady: false,
|
|
@@ -109677,7 +109761,7 @@ async function documentSnapshotState(input) {
|
|
|
109677
109761
|
};
|
|
109678
109762
|
}
|
|
109679
109763
|
try {
|
|
109680
|
-
const parsed = findDocumentSnapshotForSource(JSON.parse(await
|
|
109764
|
+
const parsed = findDocumentSnapshotForSource(JSON.parse(await readFile81(manifestPath, "utf8")), input.source.name);
|
|
109681
109765
|
if (parsed === null) {
|
|
109682
109766
|
return {
|
|
109683
109767
|
snapshotReady: false,
|
|
@@ -109745,7 +109829,7 @@ async function documentSnapshotState(input) {
|
|
|
109745
109829
|
const missing = [
|
|
109746
109830
|
...parsed.files.map((file) => file.path),
|
|
109747
109831
|
...(parsed.assets ?? []).filter((asset) => asset.content_hash !== undefined).map((asset) => asset.path)
|
|
109748
|
-
].find((path3) => !existsSync30(
|
|
109832
|
+
].find((path3) => !existsSync30(join102(input.projectRoot, input.source.materializedAt, path3)));
|
|
109749
109833
|
if (missing !== undefined) {
|
|
109750
109834
|
return {
|
|
109751
109835
|
snapshotReady: false,
|
|
@@ -109846,8 +109930,8 @@ init_errors3();
|
|
|
109846
109930
|
init_exitCode();
|
|
109847
109931
|
var import_yaml46 = __toESM(require_dist(), 1);
|
|
109848
109932
|
import { createHash as createHash30 } from "node:crypto";
|
|
109849
|
-
import { readFile as
|
|
109850
|
-
import { basename as basename12, extname as extname15, isAbsolute as isAbsolute20, join as
|
|
109933
|
+
import { readFile as readFile82, realpath as realpath11 } from "node:fs/promises";
|
|
109934
|
+
import { basename as basename12, extname as extname15, isAbsolute as isAbsolute20, join as join103, relative as relative27, resolve as resolve35 } from "node:path";
|
|
109851
109935
|
init_writeLock();
|
|
109852
109936
|
var SOURCE_NAME_PATTERN3 = /^[a-z0-9][a-z0-9._-]*$/u;
|
|
109853
109937
|
function isDateSourceNamespace(value) {
|
|
@@ -109943,7 +110027,7 @@ function assertSafeFileInclude(value) {
|
|
|
109943
110027
|
}
|
|
109944
110028
|
async function readRegistryDocument(projectRoot, registryPath2) {
|
|
109945
110029
|
try {
|
|
109946
|
-
const content3 = await
|
|
110030
|
+
const content3 = await readFile82(join103(projectRoot, registryPath2), "utf8");
|
|
109947
110031
|
return content3.trim().length === 0 ? { sources: [] } : import_yaml46.default.parse(content3);
|
|
109948
110032
|
} catch (error) {
|
|
109949
110033
|
if (error instanceof Error && "code" in error && error.code === "ENOENT")
|
|
@@ -110061,7 +110145,7 @@ async function addFileSourceUnlocked(input) {
|
|
|
110061
110145
|
const record6 = entry2;
|
|
110062
110146
|
return record6.name !== input.name && record6.id !== input.name;
|
|
110063
110147
|
}), nextEntry];
|
|
110064
|
-
await atomicWriteFile(
|
|
110148
|
+
await atomicWriteFile(join103(input.projectRoot, DEFAULT_FILE_SOURCES_REGISTRY_PATH), import_yaml46.default.stringify({ sources: nextSources }));
|
|
110065
110149
|
const updated = await loadSourcesRegistry({ rootDir: input.projectRoot });
|
|
110066
110150
|
const entry = updated.files.find((source2) => source2.name === input.name || source2.id === input.name);
|
|
110067
110151
|
if (entry === undefined) {
|
|
@@ -110117,7 +110201,7 @@ async function addLarkSourceUnlocked(input) {
|
|
|
110117
110201
|
const record6 = entry2;
|
|
110118
110202
|
return record6.name !== input.name && record6.id !== input.name;
|
|
110119
110203
|
}), nextEntry];
|
|
110120
|
-
await atomicWriteFile(
|
|
110204
|
+
await atomicWriteFile(join103(input.projectRoot, DEFAULT_LARK_SOURCES_REGISTRY_PATH), import_yaml46.default.stringify({ sources: nextSources }));
|
|
110121
110205
|
const updated = await loadSourcesRegistry({ rootDir: input.projectRoot });
|
|
110122
110206
|
const entry = updated.larks.find((source2) => source2.name === input.name || source2.id === input.name);
|
|
110123
110207
|
if (entry === undefined) {
|
|
@@ -110320,8 +110404,8 @@ init_writeLock();
|
|
|
110320
110404
|
var import_yaml47 = __toESM(require_dist(), 1);
|
|
110321
110405
|
import { existsSync as existsSync31 } from "node:fs";
|
|
110322
110406
|
import { createHash as createHash31 } from "node:crypto";
|
|
110323
|
-
import { readFile as
|
|
110324
|
-
import { isAbsolute as isAbsolute21, join as
|
|
110407
|
+
import { readFile as readFile83, readdir as readdir26, rm as rm22 } from "node:fs/promises";
|
|
110408
|
+
import { isAbsolute as isAbsolute21, join as join104, relative as relative28, resolve as resolve36, sep as sep8 } from "node:path";
|
|
110325
110409
|
function sourceIdentity(source2) {
|
|
110326
110410
|
if (source2.kind === "source.collection")
|
|
110327
110411
|
return;
|
|
@@ -110353,10 +110437,10 @@ function collectStrings(value, output) {
|
|
|
110353
110437
|
}
|
|
110354
110438
|
}
|
|
110355
110439
|
async function yamlReferences(input) {
|
|
110356
|
-
const absolutePath =
|
|
110440
|
+
const absolutePath = join104(input.projectRoot, input.path);
|
|
110357
110441
|
if (!existsSync31(absolutePath))
|
|
110358
110442
|
return false;
|
|
110359
|
-
const parsed = import_yaml47.default.parse(await
|
|
110443
|
+
const parsed = import_yaml47.default.parse(await readFile83(absolutePath, "utf8"));
|
|
110360
110444
|
const strings = [];
|
|
110361
110445
|
collectStrings(parsed, strings);
|
|
110362
110446
|
return strings.some((value) => stringReferencesSource(value, input.source));
|
|
@@ -110482,8 +110566,8 @@ async function registryRemovalWrite(projectRoot, source2) {
|
|
|
110482
110566
|
const path3 = registryPath2(source2.type);
|
|
110483
110567
|
if (path3 === null)
|
|
110484
110568
|
return;
|
|
110485
|
-
const absolutePath =
|
|
110486
|
-
const document4 = existsSync31(absolutePath) ? import_yaml47.default.parse(await
|
|
110569
|
+
const absolutePath = join104(projectRoot, path3);
|
|
110570
|
+
const document4 = existsSync31(absolutePath) ? import_yaml47.default.parse(await readFile83(absolutePath, "utf8")) : { sources: [] };
|
|
110487
110571
|
return {
|
|
110488
110572
|
path: absolutePath,
|
|
110489
110573
|
bytes: import_yaml47.default.stringify(removeDocumentEntry(document4, source2))
|
|
@@ -110501,7 +110585,7 @@ function safeManagedMaterializedPath(projectRoot, source2) {
|
|
|
110501
110585
|
return absolute;
|
|
110502
110586
|
}
|
|
110503
110587
|
function safeManagedManifestPath(projectRoot, source2) {
|
|
110504
|
-
const manifest = source2.manifest ??
|
|
110588
|
+
const manifest = source2.manifest ?? join104(source2.materializedAt, "manifest.json");
|
|
110505
110589
|
if (isAbsolute21(manifest))
|
|
110506
110590
|
throw unsafeOwnership(source2, manifest);
|
|
110507
110591
|
const absolute = resolve36(projectRoot, manifest);
|
|
@@ -110630,7 +110714,7 @@ async function createRemovalPlan(projectRoot, selector) {
|
|
|
110630
110714
|
source: source2,
|
|
110631
110715
|
registry: registryPath2(source2.type),
|
|
110632
110716
|
registryBytes: registryWrite?.bytes ?? null,
|
|
110633
|
-
managedBytes: source2.type === "note" || source2.type === "sessions" ? await
|
|
110717
|
+
managedBytes: source2.type === "note" || source2.type === "sessions" ? await readFile83(absoluteRemovals[0], "utf8") : null,
|
|
110634
110718
|
references,
|
|
110635
110719
|
cleanup,
|
|
110636
110720
|
manifestBytes: manifestWrite?.bytes ?? null
|
|
@@ -110663,10 +110747,10 @@ function publicRemovalResult(plan, action) {
|
|
|
110663
110747
|
};
|
|
110664
110748
|
}
|
|
110665
110749
|
async function pruneExtractRuntime(projectRoot, source2) {
|
|
110666
|
-
const fingerprintPath =
|
|
110750
|
+
const fingerprintPath = join104(projectRoot, ".tmp/context-runtime/extract/source-fingerprints.json");
|
|
110667
110751
|
const removedPhaseIds = new Set;
|
|
110668
110752
|
if (existsSync31(fingerprintPath)) {
|
|
110669
|
-
const parsed = JSON.parse(await
|
|
110753
|
+
const parsed = JSON.parse(await readFile83(fingerprintPath, "utf8"));
|
|
110670
110754
|
const phases = parsed.phases ?? {};
|
|
110671
110755
|
const next2 = Object.fromEntries(Object.entries(phases).filter(([phaseId, raw]) => {
|
|
110672
110756
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw))
|
|
@@ -110680,27 +110764,27 @@ async function pruneExtractRuntime(projectRoot, source2) {
|
|
|
110680
110764
|
await atomicWriteFile(fingerprintPath, `${JSON.stringify({ ...parsed, phases: next2 }, null, 2)}
|
|
110681
110765
|
`);
|
|
110682
110766
|
}
|
|
110683
|
-
const phaseOwnershipPath =
|
|
110767
|
+
const phaseOwnershipPath = join104(projectRoot, ".tmp/context-runtime/extract/custom-phase-candidates.json");
|
|
110684
110768
|
if (existsSync31(phaseOwnershipPath) && removedPhaseIds.size > 0) {
|
|
110685
|
-
const parsed = JSON.parse(await
|
|
110769
|
+
const parsed = JSON.parse(await readFile83(phaseOwnershipPath, "utf8"));
|
|
110686
110770
|
const phases = Object.fromEntries(Object.entries(parsed.phases ?? {}).filter(([phaseId]) => !removedPhaseIds.has(phaseId)));
|
|
110687
110771
|
await atomicWriteFile(phaseOwnershipPath, `${JSON.stringify({ ...parsed, phases }, null, 2)}
|
|
110688
110772
|
`);
|
|
110689
110773
|
}
|
|
110690
|
-
const symbolPath =
|
|
110774
|
+
const symbolPath = join104(projectRoot, ".tmp/context-runtime/extract/source-symbols.json");
|
|
110691
110775
|
if (existsSync31(symbolPath)) {
|
|
110692
|
-
const parsed = JSON.parse(await
|
|
110776
|
+
const parsed = JSON.parse(await readFile83(symbolPath, "utf8"));
|
|
110693
110777
|
const symbols = Array.isArray(parsed.symbols) ? parsed.symbols.filter((entry) => entry === null || typeof entry !== "object" || Array.isArray(entry) || entry.source !== source2.name) : [];
|
|
110694
110778
|
const phaseFingerprints = Object.fromEntries(Object.entries(parsed.phaseFingerprints ?? {}).filter(([phaseId]) => !removedPhaseIds.has(phaseId)));
|
|
110695
110779
|
await atomicWriteFile(symbolPath, `${JSON.stringify({ ...parsed, phaseFingerprints, symbols }, null, 2)}
|
|
110696
110780
|
`);
|
|
110697
110781
|
}
|
|
110698
|
-
const snapshotRoot =
|
|
110782
|
+
const snapshotRoot = join104(projectRoot, ".tmp/context-runtime/extract/candidates");
|
|
110699
110783
|
const visit4 = async (directory) => {
|
|
110700
110784
|
if (!existsSync31(directory))
|
|
110701
110785
|
return;
|
|
110702
110786
|
for (const entry of await readdir26(directory, { withFileTypes: true })) {
|
|
110703
|
-
const path3 =
|
|
110787
|
+
const path3 = join104(directory, entry.name);
|
|
110704
110788
|
if (entry.isDirectory()) {
|
|
110705
110789
|
await visit4(path3);
|
|
110706
110790
|
continue;
|
|
@@ -110708,7 +110792,7 @@ async function pruneExtractRuntime(projectRoot, source2) {
|
|
|
110708
110792
|
if (!entry.isFile() || !entry.name.endsWith(".json"))
|
|
110709
110793
|
continue;
|
|
110710
110794
|
try {
|
|
110711
|
-
const parsed = JSON.parse(await
|
|
110795
|
+
const parsed = JSON.parse(await readFile83(path3, "utf8"));
|
|
110712
110796
|
const refs = Array.isArray(parsed.source_refs) ? parsed.source_refs : [];
|
|
110713
110797
|
if (parsed.source === source2.name || refs.some((ref2) => typeof ref2 === "string" && stringReferencesSource(ref2, source2))) {
|
|
110714
110798
|
await rm22(path3, { force: true });
|
|
@@ -110750,7 +110834,7 @@ async function removeProjectSource(input) {
|
|
|
110750
110834
|
});
|
|
110751
110835
|
}
|
|
110752
110836
|
await applyAtomicFileBatch({
|
|
110753
|
-
transactionRoot:
|
|
110837
|
+
transactionRoot: join104(input.projectRoot, ".tmp", "context-runtime", "source-remove-transactions"),
|
|
110754
110838
|
writes: [...plan.registryWrite === undefined ? [] : [plan.registryWrite], ...plan.manifestWrite !== undefined ? [plan.manifestWrite] : []],
|
|
110755
110839
|
removals: plan.absoluteRemovals
|
|
110756
110840
|
});
|
|
@@ -110766,7 +110850,7 @@ init_workspace();
|
|
|
110766
110850
|
init_writeLock();
|
|
110767
110851
|
init_durableMultiFileTransaction();
|
|
110768
110852
|
init_durableSingleFileTransaction();
|
|
110769
|
-
import { readFile as
|
|
110853
|
+
import { readFile as readFile84 } from "node:fs/promises";
|
|
110770
110854
|
import ts from "typescript";
|
|
110771
110855
|
function generateSourceConfiguration(text10, selected) {
|
|
110772
110856
|
const file = ts.createSourceFile("index.ts", text10, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
|
|
@@ -110906,7 +110990,7 @@ function generateSourceConfiguration(text10, selected) {
|
|
|
110906
110990
|
async function configureRegisteredSources(projectRoot, selected) {
|
|
110907
110991
|
return withProjectWriteLock(projectRoot, "source-project-configuration", async () => {
|
|
110908
110992
|
const path3 = "src/index.ts";
|
|
110909
|
-
const config = JSON.parse(await
|
|
110993
|
+
const config = JSON.parse(await readFile84(await safeProjectTarget(projectRoot, "package.json"), "utf8"));
|
|
110910
110994
|
if (config.context?.entry !== path3)
|
|
110911
110995
|
return {
|
|
110912
110996
|
status: "manual",
|
|
@@ -110915,7 +110999,7 @@ async function configureRegisteredSources(projectRoot, selected) {
|
|
|
110915
110999
|
sources: selected
|
|
110916
111000
|
};
|
|
110917
111001
|
const target = await safeProjectTarget(projectRoot, path3);
|
|
110918
|
-
const text10 = await
|
|
111002
|
+
const text10 = await readFile84(target, "utf8");
|
|
110919
111003
|
const updated = generateSourceConfiguration(text10, selected);
|
|
110920
111004
|
if (updated === undefined)
|
|
110921
111005
|
return {
|
|
@@ -110995,7 +111079,7 @@ async function readIncludeList(projectRoot, path3) {
|
|
|
110995
111079
|
}
|
|
110996
111080
|
let content3;
|
|
110997
111081
|
try {
|
|
110998
|
-
content3 = await
|
|
111082
|
+
content3 = await readFile88(isAbsolute22(trimmed) ? resolve37(trimmed) : resolve37(projectRoot, trimmed), "utf8");
|
|
110999
111083
|
} catch (error) {
|
|
111000
111084
|
throw new ContextError(ExitCode.UserError, `cannot read include list: ${trimmed}`, {
|
|
111001
111085
|
category: ErrorCategory.UserInputInvalid,
|
|
@@ -111393,7 +111477,7 @@ init_exitCode();
|
|
|
111393
111477
|
var import_yaml50 = __toESM(require_dist(), 1);
|
|
111394
111478
|
import { constants as constants6, existsSync as existsSync32 } from "node:fs";
|
|
111395
111479
|
import { lstat as lstat13, open as open5, readdir as readdir27 } from "node:fs/promises";
|
|
111396
|
-
import { dirname as dirname44, join as
|
|
111480
|
+
import { dirname as dirname44, join as join106, resolve as resolve38 } from "node:path";
|
|
111397
111481
|
import { fileURLToPath as fileURLToPath8 } from "node:url";
|
|
111398
111482
|
function bundledSkillRoot() {
|
|
111399
111483
|
const directory = dirname44(fileURLToPath8(import.meta.url));
|
|
@@ -111423,7 +111507,7 @@ async function readProductionSkills(root2) {
|
|
|
111423
111507
|
const entries2 = (await readdir27(root2, { withFileTypes: true })).filter((entry) => entry.isDirectory()).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
111424
111508
|
const skills = [];
|
|
111425
111509
|
for (const directory of entries2) {
|
|
111426
|
-
const entry =
|
|
111510
|
+
const entry = join106(root2, directory.name, "SKILL.md");
|
|
111427
111511
|
if (!(await lstat13(entry)).isFile())
|
|
111428
111512
|
throw new TypeError(`Skill entry must be a regular file: ${entry}`);
|
|
111429
111513
|
const handle2 = await open5(entry, constants6.O_RDONLY | constants6.O_NOFOLLOW | constants6.O_NONBLOCK);
|
|
@@ -111831,7 +111915,7 @@ init_cliFeedback();
|
|
|
111831
111915
|
init_errors3();
|
|
111832
111916
|
init_exitCode();
|
|
111833
111917
|
import { existsSync as existsSync35 } from "node:fs";
|
|
111834
|
-
import { dirname as dirname47, join as
|
|
111918
|
+
import { dirname as dirname47, join as join108, resolve as resolve40 } from "node:path";
|
|
111835
111919
|
import { fileURLToPath as fileURLToPath9 } from "node:url";
|
|
111836
111920
|
|
|
111837
111921
|
// src/project/pluginInstallTargets.ts
|
|
@@ -111840,9 +111924,9 @@ init_errors3();
|
|
|
111840
111924
|
init_exitCode();
|
|
111841
111925
|
import { execFile as execFile12 } from "node:child_process";
|
|
111842
111926
|
import { existsSync as existsSync34 } from "node:fs";
|
|
111843
|
-
import { cp as cp2, mkdir as mkdir35, readdir as readdir28, readFile as
|
|
111927
|
+
import { cp as cp2, mkdir as mkdir35, readdir as readdir28, readFile as readFile89, rename as rename9, rm as rm23, writeFile as writeFile27 } from "node:fs/promises";
|
|
111844
111928
|
import { homedir as homedir2 } from "node:os";
|
|
111845
|
-
import { dirname as dirname46, join as
|
|
111929
|
+
import { dirname as dirname46, join as join107 } from "node:path";
|
|
111846
111930
|
import { promisify as promisify12 } from "node:util";
|
|
111847
111931
|
var execFileAsync7 = promisify12(execFile12);
|
|
111848
111932
|
var MARKETPLACE_NAME = "c4a";
|
|
@@ -111896,23 +111980,23 @@ async function claudePluginInstalled(pluginId) {
|
|
|
111896
111980
|
}
|
|
111897
111981
|
}
|
|
111898
111982
|
function codexHome() {
|
|
111899
|
-
return process.env.CODEX_HOME?.trim() ||
|
|
111983
|
+
return process.env.CODEX_HOME?.trim() || join107(homedir2(), ".codex");
|
|
111900
111984
|
}
|
|
111901
111985
|
function claudePluginCacheRoot() {
|
|
111902
111986
|
const explicitRoot = process.env[CLAUDE_PLUGIN_CACHE_ROOT_ENV2]?.trim();
|
|
111903
111987
|
if (explicitRoot)
|
|
111904
111988
|
return explicitRoot;
|
|
111905
111989
|
const home = process.env[CLAUDE_PLUGIN_CACHE_HOME_ENV2]?.trim() || homedir2();
|
|
111906
|
-
return
|
|
111990
|
+
return join107(home, ".claude", "plugins", "cache");
|
|
111907
111991
|
}
|
|
111908
111992
|
function sharedSkillsRoot() {
|
|
111909
|
-
return process.env[SHARED_SKILLS_ROOT_ENV]?.trim() ||
|
|
111993
|
+
return process.env[SHARED_SKILLS_ROOT_ENV]?.trim() || join107(homedir2(), ".agents", "skills");
|
|
111910
111994
|
}
|
|
111911
111995
|
function claudeSkillsRoot() {
|
|
111912
|
-
return process.env[CLAUDE_SKILLS_ROOT_ENV]?.trim() ||
|
|
111996
|
+
return process.env[CLAUDE_SKILLS_ROOT_ENV]?.trim() || join107(homedir2(), ".claude", "skills");
|
|
111913
111997
|
}
|
|
111914
111998
|
function cursorPluginRoot() {
|
|
111915
|
-
return process.env[CURSOR_PLUGIN_ROOT_ENV]?.trim() ||
|
|
111999
|
+
return process.env[CURSOR_PLUGIN_ROOT_ENV]?.trim() || join107(homedir2(), ".cursor", "plugins", "local", PLUGIN_NAME);
|
|
111916
112000
|
}
|
|
111917
112001
|
function blockHeader(line) {
|
|
111918
112002
|
const match = line.match(/^\s*\[([^\]]+)\]\s*$/u);
|
|
@@ -111963,8 +112047,8 @@ function pruneLegacyCodexConfigContent(content3) {
|
|
|
111963
112047
|
`), removed };
|
|
111964
112048
|
}
|
|
111965
112049
|
async function pruneLegacyCodexConfig(dryRun, steps) {
|
|
111966
|
-
const configPath =
|
|
111967
|
-
const current2 = await
|
|
112050
|
+
const configPath = join107(codexHome(), "config.toml");
|
|
112051
|
+
const current2 = await readFile89(configPath, "utf8").catch(() => "");
|
|
111968
112052
|
if (!current2)
|
|
111969
112053
|
return;
|
|
111970
112054
|
const next2 = pruneLegacyCodexConfigContent(current2);
|
|
@@ -111976,11 +112060,11 @@ async function pruneLegacyCodexConfig(dryRun, steps) {
|
|
|
111976
112060
|
status: dryRun ? "planned" : "ran"
|
|
111977
112061
|
});
|
|
111978
112062
|
if (!dryRun) {
|
|
111979
|
-
await
|
|
112063
|
+
await writeFile27(configPath, next2.content, "utf8");
|
|
111980
112064
|
}
|
|
111981
112065
|
}
|
|
111982
112066
|
async function pruneCodexPluginCacheForName(pluginName, keepVersion, dryRun, steps) {
|
|
111983
|
-
const cacheRoot =
|
|
112067
|
+
const cacheRoot = join107(codexHome(), "plugins", "cache", MARKETPLACE_NAME, pluginName);
|
|
111984
112068
|
if (!existsSync34(cacheRoot))
|
|
111985
112069
|
return;
|
|
111986
112070
|
const versions = (await readdir28(cacheRoot, { withFileTypes: true }).catch(() => [])).filter((entry) => entry.isDirectory() && entry.name !== keepVersion).map((entry) => entry.name).sort();
|
|
@@ -111992,7 +112076,7 @@ async function pruneCodexPluginCacheForName(pluginName, keepVersion, dryRun, ste
|
|
|
111992
112076
|
status: dryRun ? "planned" : "ran"
|
|
111993
112077
|
});
|
|
111994
112078
|
if (!dryRun)
|
|
111995
|
-
await Promise.all(versions.map((version3) => rm23(
|
|
112079
|
+
await Promise.all(versions.map((version3) => rm23(join107(cacheRoot, version3), { recursive: true, force: true })));
|
|
111996
112080
|
}
|
|
111997
112081
|
async function pruneCodexPluginCache(currentVersion, dryRun, steps) {
|
|
111998
112082
|
await pruneCodexPluginCacheForName(PLUGIN_NAME, currentVersion, dryRun, steps);
|
|
@@ -112016,15 +112100,15 @@ async function pruneClaudeOrphanContextCache(dryRun, steps) {
|
|
|
112016
112100
|
for (const marketplace of marketplaces) {
|
|
112017
112101
|
if (!marketplace.isDirectory())
|
|
112018
112102
|
continue;
|
|
112019
|
-
const pluginDir =
|
|
112103
|
+
const pluginDir = join107(cacheRoot, marketplace.name, PLUGIN_NAME);
|
|
112020
112104
|
if (!existsSync34(pluginDir))
|
|
112021
112105
|
continue;
|
|
112022
112106
|
const versions = await readdir28(pluginDir, { withFileTypes: true }).catch(() => []);
|
|
112023
112107
|
for (const version3 of versions) {
|
|
112024
112108
|
if (!version3.isDirectory())
|
|
112025
112109
|
continue;
|
|
112026
|
-
const versionDir =
|
|
112027
|
-
if (!existsSync34(
|
|
112110
|
+
const versionDir = join107(pluginDir, version3.name);
|
|
112111
|
+
if (!existsSync34(join107(versionDir, ORPHAN_MARKER2)))
|
|
112028
112112
|
continue;
|
|
112029
112113
|
removed.push(`${marketplace.name}/${PLUGIN_NAME}/${version3.name}`);
|
|
112030
112114
|
if (!dryRun) {
|
|
@@ -112034,7 +112118,7 @@ async function pruneClaudeOrphanContextCache(dryRun, steps) {
|
|
|
112034
112118
|
if (!dryRun && await isEmptyDir2(pluginDir)) {
|
|
112035
112119
|
await rm23(pluginDir, { recursive: true, force: true });
|
|
112036
112120
|
}
|
|
112037
|
-
const marketplaceDir =
|
|
112121
|
+
const marketplaceDir = join107(cacheRoot, marketplace.name);
|
|
112038
112122
|
if (!dryRun && await isEmptyDir2(marketplaceDir)) {
|
|
112039
112123
|
await rm23(marketplaceDir, { recursive: true, force: true });
|
|
112040
112124
|
}
|
|
@@ -112055,7 +112139,7 @@ async function pruneClaudeLegacyPluginCache(dryRun, steps) {
|
|
|
112055
112139
|
return;
|
|
112056
112140
|
const removed = [];
|
|
112057
112141
|
for (const pluginName of LEGACY_PLUGIN_NAMES) {
|
|
112058
|
-
const pluginDir =
|
|
112142
|
+
const pluginDir = join107(cacheRoot, MARKETPLACE_NAME, pluginName);
|
|
112059
112143
|
if (!existsSync34(pluginDir))
|
|
112060
112144
|
continue;
|
|
112061
112145
|
removed.push(`${MARKETPLACE_NAME}/${pluginName}`);
|
|
@@ -112072,11 +112156,11 @@ async function pruneClaudeLegacyPluginCache(dryRun, steps) {
|
|
|
112072
112156
|
}
|
|
112073
112157
|
}
|
|
112074
112158
|
async function pruneClaudeSupersededContextCache(root2, dryRun, steps) {
|
|
112075
|
-
const manifest = await
|
|
112159
|
+
const manifest = await readFile89(join107(root2, "claude", ".claude-plugin", "plugin.json"), "utf8").then((content3) => JSON.parse(content3)).catch(() => null);
|
|
112076
112160
|
const currentVersion = typeof manifest?.version === "string" ? manifest.version : null;
|
|
112077
112161
|
if (!currentVersion)
|
|
112078
112162
|
return;
|
|
112079
|
-
const pluginDir =
|
|
112163
|
+
const pluginDir = join107(claudePluginCacheRoot(), MARKETPLACE_NAME, PLUGIN_NAME);
|
|
112080
112164
|
const staleVersions = (await readdir28(pluginDir, { withFileTypes: true }).catch(() => [])).filter((entry) => entry.isDirectory() && entry.name !== currentVersion).map((entry) => entry.name);
|
|
112081
112165
|
if (staleVersions.length === 0)
|
|
112082
112166
|
return;
|
|
@@ -112086,7 +112170,7 @@ async function pruneClaudeSupersededContextCache(root2, dryRun, steps) {
|
|
|
112086
112170
|
status: dryRun ? "planned" : "ran"
|
|
112087
112171
|
});
|
|
112088
112172
|
if (!dryRun) {
|
|
112089
|
-
await Promise.all(staleVersions.map((version3) => rm23(
|
|
112173
|
+
await Promise.all(staleVersions.map((version3) => rm23(join107(pluginDir, version3), { recursive: true, force: true })));
|
|
112090
112174
|
}
|
|
112091
112175
|
}
|
|
112092
112176
|
function enableCodexPluginConfig(content3) {
|
|
@@ -112150,33 +112234,33 @@ source = ${JSON.stringify(root2)}
|
|
|
112150
112234
|
`;
|
|
112151
112235
|
}
|
|
112152
112236
|
async function ensureCodexPluginEnabled() {
|
|
112153
|
-
const configPath =
|
|
112237
|
+
const configPath = join107(codexHome(), "config.toml");
|
|
112154
112238
|
await mkdir35(dirname46(configPath), { recursive: true });
|
|
112155
|
-
const current2 = await
|
|
112239
|
+
const current2 = await readFile89(configPath, "utf8").catch(() => "");
|
|
112156
112240
|
const next2 = enableCodexPluginConfig(current2);
|
|
112157
112241
|
if (next2 !== current2) {
|
|
112158
|
-
await
|
|
112242
|
+
await writeFile27(configPath, next2, "utf8");
|
|
112159
112243
|
}
|
|
112160
112244
|
}
|
|
112161
112245
|
async function ensureCodexLocalMarketplace(root2) {
|
|
112162
|
-
const configPath =
|
|
112246
|
+
const configPath = join107(codexHome(), "config.toml");
|
|
112163
112247
|
await mkdir35(dirname46(configPath), { recursive: true });
|
|
112164
|
-
const current2 = await
|
|
112248
|
+
const current2 = await readFile89(configPath, "utf8").catch(() => "");
|
|
112165
112249
|
const next2 = upsertCodexLocalMarketplaceConfig(current2, root2);
|
|
112166
112250
|
if (next2 !== current2) {
|
|
112167
|
-
await
|
|
112251
|
+
await writeFile27(configPath, next2, "utf8");
|
|
112168
112252
|
}
|
|
112169
112253
|
}
|
|
112170
112254
|
async function codexPluginVersion(root2) {
|
|
112171
|
-
const manifestPath =
|
|
112172
|
-
const manifest = JSON.parse(await
|
|
112255
|
+
const manifestPath = join107(root2, "codex", ".codex-plugin", "plugin.json");
|
|
112256
|
+
const manifest = JSON.parse(await readFile89(manifestPath, "utf8"));
|
|
112173
112257
|
if (typeof manifest.version !== "string" || !/^[A-Za-z0-9][A-Za-z0-9._-]*$/u.test(manifest.version)) {
|
|
112174
112258
|
throw new Error(`Codex plugin manifest has an invalid version: ${manifestPath}`);
|
|
112175
112259
|
}
|
|
112176
112260
|
return manifest.version;
|
|
112177
112261
|
}
|
|
112178
112262
|
function codexPluginCacheDir(version3) {
|
|
112179
|
-
return
|
|
112263
|
+
return join107(codexHome(), "plugins", "cache", MARKETPLACE_NAME, PLUGIN_NAME, version3);
|
|
112180
112264
|
}
|
|
112181
112265
|
async function replaceDirectoryFromSource(source2, target) {
|
|
112182
112266
|
await mkdir35(dirname46(target), { recursive: true });
|
|
@@ -112187,19 +112271,19 @@ async function replaceDirectoryFromSource(source2, target) {
|
|
|
112187
112271
|
const hadPrevious = existsSync34(target);
|
|
112188
112272
|
try {
|
|
112189
112273
|
if (hadPrevious)
|
|
112190
|
-
await
|
|
112191
|
-
await
|
|
112274
|
+
await rename9(target, previous3);
|
|
112275
|
+
await rename9(temporary, target);
|
|
112192
112276
|
if (hadPrevious)
|
|
112193
112277
|
await rm23(previous3, { recursive: true, force: true });
|
|
112194
112278
|
} catch (error) {
|
|
112195
112279
|
await rm23(temporary, { recursive: true, force: true });
|
|
112196
112280
|
if (hadPrevious && !existsSync34(target) && existsSync34(previous3))
|
|
112197
|
-
await
|
|
112281
|
+
await rename9(previous3, target);
|
|
112198
112282
|
throw error;
|
|
112199
112283
|
}
|
|
112200
112284
|
}
|
|
112201
112285
|
async function materializeCodexPluginCache(root2, version3, dryRun, steps) {
|
|
112202
|
-
const source2 =
|
|
112286
|
+
const source2 = join107(root2, "codex");
|
|
112203
112287
|
const target = codexPluginCacheDir(version3);
|
|
112204
112288
|
steps.push({
|
|
112205
112289
|
agent: "codex",
|
|
@@ -112211,16 +112295,16 @@ async function materializeCodexPluginCache(root2, version3, dryRun, steps) {
|
|
|
112211
112295
|
await replaceDirectoryFromSource(source2, target);
|
|
112212
112296
|
}
|
|
112213
112297
|
async function bundledProviderSkillNames(root2) {
|
|
112214
|
-
const skillsRoot =
|
|
112298
|
+
const skillsRoot = join107(root2, "skills");
|
|
112215
112299
|
const entries2 = await readdir28(skillsRoot, { withFileTypes: true });
|
|
112216
112300
|
const names = [];
|
|
112217
112301
|
for (const entry of entries2) {
|
|
112218
112302
|
if (!entry.isDirectory() || entry.name === "context")
|
|
112219
112303
|
continue;
|
|
112220
|
-
const skillPath =
|
|
112304
|
+
const skillPath = join107(skillsRoot, entry.name, "SKILL.md");
|
|
112221
112305
|
if (!existsSync34(skillPath))
|
|
112222
112306
|
continue;
|
|
112223
|
-
const skill = await
|
|
112307
|
+
const skill = await readFile89(skillPath, "utf8");
|
|
112224
112308
|
if (!/^\s*context-role:\s*["']?indexer-provider["']?\s*$/mu.test(skill))
|
|
112225
112309
|
continue;
|
|
112226
112310
|
names.push(entry.name);
|
|
@@ -112232,10 +112316,10 @@ async function bundledProviderSkillNames(root2) {
|
|
|
112232
112316
|
return names;
|
|
112233
112317
|
}
|
|
112234
112318
|
async function materializeProviderSkills(root2, targetRoot, agent, dryRun, steps) {
|
|
112235
|
-
const sourceRoot2 =
|
|
112319
|
+
const sourceRoot2 = join107(root2, "skills");
|
|
112236
112320
|
for (const name3 of await bundledProviderSkillNames(root2)) {
|
|
112237
|
-
const source2 =
|
|
112238
|
-
const target =
|
|
112321
|
+
const source2 = join107(sourceRoot2, name3);
|
|
112322
|
+
const target = join107(targetRoot, name3);
|
|
112239
112323
|
steps.push({
|
|
112240
112324
|
agent,
|
|
112241
112325
|
command: `materialize lifecycle Provider skill: ${shellQuote8(source2)} -> ${shellQuote8(target)}`,
|
|
@@ -112246,7 +112330,7 @@ async function materializeProviderSkills(root2, targetRoot, agent, dryRun, steps
|
|
|
112246
112330
|
}
|
|
112247
112331
|
}
|
|
112248
112332
|
async function installCursor(root2, dryRun, steps) {
|
|
112249
|
-
const source2 =
|
|
112333
|
+
const source2 = join107(root2, "cursor");
|
|
112250
112334
|
const target = cursorPluginRoot();
|
|
112251
112335
|
steps.push({
|
|
112252
112336
|
agent: "cursor",
|
|
@@ -112301,12 +112385,12 @@ async function installCodex(root2, dryRun, steps) {
|
|
|
112301
112385
|
steps.push({ agent: "codex", command: commandLine("codex", addArgs), status: dryRun ? "planned" : "ran" });
|
|
112302
112386
|
steps.push({
|
|
112303
112387
|
agent: "codex",
|
|
112304
|
-
command: `ensure ${shellQuote8(
|
|
112388
|
+
command: `ensure ${shellQuote8(join107(codexHome(), "config.toml"))} registers local marketplace ${shellQuote8(MARKETPLACE_NAME)}`,
|
|
112305
112389
|
status: dryRun ? "planned" : "ran"
|
|
112306
112390
|
});
|
|
112307
112391
|
steps.push({
|
|
112308
112392
|
agent: "codex",
|
|
112309
|
-
command: `ensure ${shellQuote8(
|
|
112393
|
+
command: `ensure ${shellQuote8(join107(codexHome(), "config.toml"))} enables ${shellQuote8(PLUGIN_ID)}`,
|
|
112310
112394
|
status: dryRun ? "planned" : "ran"
|
|
112311
112395
|
});
|
|
112312
112396
|
if (dryRun) {
|
|
@@ -112361,13 +112445,13 @@ function pluginRootCandidates() {
|
|
|
112361
112445
|
return [resolve40(envRoot)];
|
|
112362
112446
|
const candidates = [];
|
|
112363
112447
|
for (const dir of packageCandidateDirs()) {
|
|
112364
|
-
candidates.push(
|
|
112365
|
-
candidates.push(
|
|
112448
|
+
candidates.push(join108(dir, "plugins"));
|
|
112449
|
+
candidates.push(join108(dir, "dist", "plugins"));
|
|
112366
112450
|
}
|
|
112367
112451
|
return [...new Set(candidates)];
|
|
112368
112452
|
}
|
|
112369
112453
|
function isInstallablePluginRoot(root2) {
|
|
112370
|
-
return existsSync35(
|
|
112454
|
+
return existsSync35(join108(root2, ".claude-plugin", "marketplace.json")) && existsSync35(join108(root2, ".agents", "plugins", "marketplace.json")) && existsSync35(join108(root2, "claude", ".claude-plugin", "plugin.json")) && existsSync35(join108(root2, "codex", ".codex-plugin", "plugin.json")) && existsSync35(join108(root2, "cursor", ".cursor-plugin", "plugin.json")) && existsSync35(join108(root2, "skills"));
|
|
112371
112455
|
}
|
|
112372
112456
|
function resolveBundledPluginsRoot() {
|
|
112373
112457
|
const candidates = pluginRootCandidates();
|
|
@@ -112528,6 +112612,7 @@ function registerPluginCommands(program2) {
|
|
|
112528
112612
|
}
|
|
112529
112613
|
|
|
112530
112614
|
// src/registerPackageCommands.ts
|
|
112615
|
+
init_packageSiteAddress();
|
|
112531
112616
|
init_cliFeedback();
|
|
112532
112617
|
init_errors3();
|
|
112533
112618
|
init_packageTemplateReview();
|
|
@@ -112535,6 +112620,13 @@ init_workspace();
|
|
|
112535
112620
|
init_exitCode();
|
|
112536
112621
|
function registerPackageCommands(program2) {
|
|
112537
112622
|
const packageCommand = program2.command("package").description("Inspect or resolve package output configuration");
|
|
112623
|
+
packageCommand.command("site-url <package-name> <url>").description("Record a deployed site root in existing site maps without network checks").action(async (packageName, url) => {
|
|
112624
|
+
const root2 = findContextProjectRoot(process.cwd())?.projectRoot;
|
|
112625
|
+
if (!root2)
|
|
112626
|
+
throw new TypeError("Run inside a Context workspace");
|
|
112627
|
+
process.stdout.write(JSON.stringify(await recordPackageSiteUrl(root2, packageName, url), null, 2) + `
|
|
112628
|
+
`);
|
|
112629
|
+
});
|
|
112538
112630
|
const packageTemplate = packageCommand.command("template").description("Manage package template review state");
|
|
112539
112631
|
packageTemplate.command("accept [package-name]").description("Explicitly accept an unchanged generated starter template").option("--all", "accept all unchanged generated starter templates").option("--format <format>", "output format: text | json", "text").action(async (packageName, options) => {
|
|
112540
112632
|
if (packageName === undefined === (options.all !== true)) {
|
|
@@ -112597,10 +112689,10 @@ function readQuickstartPath() {
|
|
|
112597
112689
|
try {
|
|
112598
112690
|
let dir = dirname48(fileURLToPath10(import.meta.url));
|
|
112599
112691
|
for (let i2 = 0;i2 < 8; i2++) {
|
|
112600
|
-
const candidate =
|
|
112692
|
+
const candidate = join109(dir, "docs", "quickstart.md");
|
|
112601
112693
|
if (existsSync36(candidate))
|
|
112602
112694
|
return candidate;
|
|
112603
|
-
const pkg =
|
|
112695
|
+
const pkg = join109(dir, "package.json");
|
|
112604
112696
|
if (existsSync36(pkg))
|
|
112605
112697
|
return candidate;
|
|
112606
112698
|
const parent = dirname48(dir);
|
|
@@ -112609,7 +112701,7 @@ function readQuickstartPath() {
|
|
|
112609
112701
|
dir = parent;
|
|
112610
112702
|
}
|
|
112611
112703
|
} catch {}
|
|
112612
|
-
return
|
|
112704
|
+
return join109(dirname48(fileURLToPath10(import.meta.url)), "docs", "quickstart.md");
|
|
112613
112705
|
}
|
|
112614
112706
|
var GREEN = "\x1B[32m";
|
|
112615
112707
|
var RESET = "\x1B[0m";
|