@c4a/context-cli 0.7.13 → 0.7.14-beta.1
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 +542 -460
- 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/codex/.codex-plugin/plugin.json +2 -2
- 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/skills/context-inspect-search/SKILL.md +18 -0
- package/providers/context/manifest.json +5 -5
- package/providers/context/provider.yaml +1 -1
- package/providers/context/resources/manuals/guides/package-outputs.md +21 -0
package/cli.js
CHANGED
|
@@ -70080,11 +70080,70 @@ var init_packageOutputPaths = __esm(() => {
|
|
|
70080
70080
|
init_cliFeedback();
|
|
70081
70081
|
});
|
|
70082
70082
|
|
|
70083
|
+
// src/project/packageSiteAddress.ts
|
|
70084
|
+
import { readFile as readFile42, writeFile as writeFile12, rename as rename5 } from "node:fs/promises";
|
|
70085
|
+
import { join as join50 } from "node:path";
|
|
70086
|
+
function normalizeSiteUrl(value) {
|
|
70087
|
+
const url = new URL(value);
|
|
70088
|
+
if (!["https:", "http:"].includes(url.protocol) || url.username || url.password || url.search || url.hash) {
|
|
70089
|
+
throw new TypeError("Use an HTTP(S) site root without credentials, query or fragment");
|
|
70090
|
+
}
|
|
70091
|
+
url.pathname = `${url.pathname.replace(/\/+$/u, "")}/`;
|
|
70092
|
+
return url.href;
|
|
70093
|
+
}
|
|
70094
|
+
async function readPackageSiteUrl(root, pkg) {
|
|
70095
|
+
if (pkg.kind !== "package.kb" || !pkg.site)
|
|
70096
|
+
return;
|
|
70097
|
+
try {
|
|
70098
|
+
const map2 = JSON.parse(await readFile42(join50(root, packageSiteOutputDir(pkg), SITE_MAP_FILE), "utf8"));
|
|
70099
|
+
return typeof map2.site_url === "string" ? normalizeSiteUrl(map2.site_url) : undefined;
|
|
70100
|
+
} catch (error) {
|
|
70101
|
+
if (error.code === "ENOENT" || error instanceof SyntaxError || error instanceof TypeError)
|
|
70102
|
+
return;
|
|
70103
|
+
throw error;
|
|
70104
|
+
}
|
|
70105
|
+
}
|
|
70106
|
+
async function recordPackageSiteUrl(root, packageName, value) {
|
|
70107
|
+
const siteUrl = normalizeSiteUrl(value);
|
|
70108
|
+
return withProjectWriteLock(root, "record-site-url", async () => {
|
|
70109
|
+
const { loadContextProjectModule: loadContextProjectModule2 } = await Promise.resolve().then(() => (init_workspace(), exports_workspace));
|
|
70110
|
+
const loaded = await loadContextProjectModule2(root);
|
|
70111
|
+
const pkg = loaded.project.packages.find((candidate) => candidate.name === packageName);
|
|
70112
|
+
if (!pkg || pkg.kind !== "package.kb" || !pkg.site) {
|
|
70113
|
+
throw new TypeError("Select a declared knowledge package with a website");
|
|
70114
|
+
}
|
|
70115
|
+
const siteMap = join50(root, packageSiteOutputDir(pkg), SITE_MAP_FILE);
|
|
70116
|
+
let map2;
|
|
70117
|
+
try {
|
|
70118
|
+
map2 = JSON.parse(await readFile42(siteMap, "utf8"));
|
|
70119
|
+
} catch (error) {
|
|
70120
|
+
if (error.code === "ENOENT")
|
|
70121
|
+
throw new TypeError("Build the configured website before recording its deployment URL");
|
|
70122
|
+
throw error;
|
|
70123
|
+
}
|
|
70124
|
+
if (map2.protocol !== "context.site-output/v1" || !Array.isArray(map2.pages)) {
|
|
70125
|
+
throw new TypeError("Rebuild the website to restore a valid context-site-map.json");
|
|
70126
|
+
}
|
|
70127
|
+
const content3 = JSON.stringify({ ...map2, site_url: siteUrl }, null, 2) + `
|
|
70128
|
+
`;
|
|
70129
|
+
for (const path2 of [siteMap, join50(root, pkg.outDir, SITE_MAP_FILE)]) {
|
|
70130
|
+
await writeFile12(`${path2}.tmp`, content3);
|
|
70131
|
+
await rename5(`${path2}.tmp`, path2);
|
|
70132
|
+
}
|
|
70133
|
+
return { package: pkg.name, site_url: siteUrl, network_checked: false };
|
|
70134
|
+
});
|
|
70135
|
+
}
|
|
70136
|
+
var SITE_MAP_FILE = "context-site-map.json";
|
|
70137
|
+
var init_packageSiteAddress = __esm(() => {
|
|
70138
|
+
init_packageOutputPaths();
|
|
70139
|
+
init_writeLock();
|
|
70140
|
+
});
|
|
70141
|
+
|
|
70083
70142
|
// src/project/packageBuildReceipt.ts
|
|
70084
70143
|
import { createHash as createHash13 } from "node:crypto";
|
|
70085
70144
|
import { existsSync as existsSync15 } from "node:fs";
|
|
70086
|
-
import { readFile as
|
|
70087
|
-
import { join as
|
|
70145
|
+
import { readFile as readFile43 } from "node:fs/promises";
|
|
70146
|
+
import { join as join51, relative as relative15 } from "node:path";
|
|
70088
70147
|
function parsePackageLinkWarnings(value) {
|
|
70089
70148
|
if (!Array.isArray(value))
|
|
70090
70149
|
return [];
|
|
@@ -70099,7 +70158,7 @@ async function walkPackageFiles(root) {
|
|
|
70099
70158
|
for (const entry of entries2) {
|
|
70100
70159
|
if (IGNORED_PACKAGE_FS_ENTRIES.has(entry.name))
|
|
70101
70160
|
continue;
|
|
70102
|
-
const absPath =
|
|
70161
|
+
const absPath = join51(dir, entry.name);
|
|
70103
70162
|
if (entry.isDirectory()) {
|
|
70104
70163
|
await visit2(absPath);
|
|
70105
70164
|
continue;
|
|
@@ -70130,17 +70189,27 @@ function classifyOutputFile(path2, knowledgeGroups) {
|
|
|
70130
70189
|
}
|
|
70131
70190
|
async function packageOutputSnapshot(projectRoot, pkg, knowledgeGroups, previousOutputs = []) {
|
|
70132
70191
|
const previousByPath = new Map(previousOutputs.map((file) => [file.path, file]));
|
|
70133
|
-
const files = (await Promise.all(packageOutputDirs(pkg).map(async (output) => (await walkPackageFiles(
|
|
70192
|
+
const files = (await Promise.all(packageOutputDirs(pkg).map(async (output) => (await walkPackageFiles(join51(projectRoot, output))).map((file) => ({
|
|
70134
70193
|
...file,
|
|
70135
|
-
relPath: toPosixPath4(relative15(
|
|
70194
|
+
relPath: toPosixPath4(relative15(join51(projectRoot, pkg.outDir), file.absPath))
|
|
70136
70195
|
}))))).flat();
|
|
70137
70196
|
return Promise.all(files.map(async (file) => {
|
|
70138
70197
|
const current = classifyOutputFile(file.relPath, knowledgeGroups);
|
|
70139
70198
|
const previous2 = previousByPath.get(file.relPath);
|
|
70140
70199
|
const classification = current.kind === "file" && previous2 !== undefined ? { path: file.relPath, kind: previous2.kind, ...previous2.group === undefined ? {} : { group: previous2.group } } : current;
|
|
70200
|
+
let content3 = await readFile43(file.absPath);
|
|
70201
|
+
if (file.absPath === join51(projectRoot, pkg.outDir, "context-site-map.json") || file.absPath === join51(projectRoot, packageSiteOutputDir(pkg), "context-site-map.json")) {
|
|
70202
|
+
try {
|
|
70203
|
+
const map2 = JSON.parse(content3.toString());
|
|
70204
|
+
if (map2.protocol === "context.site-output/v1" && Array.isArray(map2.pages)) {
|
|
70205
|
+
delete map2.site_url;
|
|
70206
|
+
content3 = JSON.stringify(map2);
|
|
70207
|
+
}
|
|
70208
|
+
} catch {}
|
|
70209
|
+
}
|
|
70141
70210
|
return {
|
|
70142
70211
|
...classification,
|
|
70143
|
-
sha256: createHash13("sha256").update(
|
|
70212
|
+
sha256: createHash13("sha256").update(content3).digest("hex")
|
|
70144
70213
|
};
|
|
70145
70214
|
}));
|
|
70146
70215
|
}
|
|
@@ -70148,8 +70217,8 @@ async function packageOutputFingerprint(projectRoot, pkg, observed) {
|
|
|
70148
70217
|
const snapshot = observed ?? await packageOutputSnapshot(projectRoot, pkg, new Map);
|
|
70149
70218
|
return {
|
|
70150
70219
|
fingerprint: createHash13("sha256").update(JSON.stringify({
|
|
70151
|
-
outDirExists: existsSync15(
|
|
70152
|
-
siteDirExists: pkg.kind === "package.kb" && pkg.site ? existsSync15(
|
|
70220
|
+
outDirExists: existsSync15(join51(projectRoot, pkg.outDir)),
|
|
70221
|
+
siteDirExists: pkg.kind === "package.kb" && pkg.site ? existsSync15(join51(projectRoot, packageSiteOutputDir(pkg))) : undefined,
|
|
70153
70222
|
files: snapshot.map(({ path: path2, sha256 }) => ({ path: path2, sha256 }))
|
|
70154
70223
|
})).digest("hex"),
|
|
70155
70224
|
files: snapshot.length
|
|
@@ -70234,8 +70303,8 @@ var init_packageBuildReceipt = __esm(() => {
|
|
|
70234
70303
|
});
|
|
70235
70304
|
|
|
70236
70305
|
// src/project/knowledgeMapCoverage.ts
|
|
70237
|
-
import { readFile as
|
|
70238
|
-
import { join as
|
|
70306
|
+
import { readFile as readFile44 } from "node:fs/promises";
|
|
70307
|
+
import { join as join52 } from "node:path";
|
|
70239
70308
|
function knowledgeMapArticleTargets(files) {
|
|
70240
70309
|
return files.flatMap((file) => {
|
|
70241
70310
|
const meta = parseKnowledgeFrontmatter(file.content);
|
|
@@ -70251,10 +70320,10 @@ function knowledgeMapArticleTargets(files) {
|
|
|
70251
70320
|
async function approvedKnowledgeMapTargets(root) {
|
|
70252
70321
|
const metadata = await readApprovedKnowledgeMetadataIndex(root);
|
|
70253
70322
|
const articles = new Map(validateArticleStructureEntries(metadata.structure?.articles ?? []).map((article) => [article.path, article]));
|
|
70254
|
-
const files = await walkPackageFiles(
|
|
70323
|
+
const files = await walkPackageFiles(join52(root, "knowledge"));
|
|
70255
70324
|
const content3 = await Promise.all(files.filter((file) => isApprovedKnowledgeMarkdownPath(file.relPath) && !file.relPath.startsWith("assets/")).map(async (file) => ({
|
|
70256
70325
|
article: articles.get(file.relPath),
|
|
70257
|
-
content: hydrateApprovedKnowledgeMarkdown({ content: await
|
|
70326
|
+
content: hydrateApprovedKnowledgeMarkdown({ content: await readFile44(file.absPath, "utf8"), relPath: file.relPath, metadata })
|
|
70258
70327
|
})));
|
|
70259
70328
|
return knowledgeMapArticleTargets(content3);
|
|
70260
70329
|
}
|
|
@@ -70300,11 +70369,11 @@ var init_knowledgeMapCoverage = __esm(() => {
|
|
|
70300
70369
|
});
|
|
70301
70370
|
|
|
70302
70371
|
// src/project/knowledgeMap.ts
|
|
70303
|
-
import { readFile as
|
|
70304
|
-
import { join as
|
|
70372
|
+
import { readFile as readFile45 } from "node:fs/promises";
|
|
70373
|
+
import { join as join53 } from "node:path";
|
|
70305
70374
|
async function optionalText(root, path2) {
|
|
70306
70375
|
try {
|
|
70307
|
-
return await
|
|
70376
|
+
return await readFile45(join53(root, path2), "utf8");
|
|
70308
70377
|
} catch (error) {
|
|
70309
70378
|
if (error.code === "ENOENT")
|
|
70310
70379
|
return;
|
|
@@ -70357,8 +70426,8 @@ var init_knowledgeMap2 = __esm(() => {
|
|
|
70357
70426
|
});
|
|
70358
70427
|
|
|
70359
70428
|
// src/project/packageKnowledgeMap.ts
|
|
70360
|
-
import { readFile as
|
|
70361
|
-
import { join as
|
|
70429
|
+
import { readFile as readFile46, writeFile as writeFile13 } from "node:fs/promises";
|
|
70430
|
+
import { join as join54 } from "node:path";
|
|
70362
70431
|
function knowledgeMapSectionAnchor(key) {
|
|
70363
70432
|
return `section-${encodeURIComponent(key)}`;
|
|
70364
70433
|
}
|
|
@@ -70383,16 +70452,16 @@ async function writePackageKnowledgeMap(input) {
|
|
|
70383
70452
|
return [];
|
|
70384
70453
|
const projected = projectKnowledgeMap(input.structure, packageKnowledgeMapTargets(input.pkg, input.selected));
|
|
70385
70454
|
projected.warnings = projected.warnings.filter((warning) => !warning.target.startsWith("site:"));
|
|
70386
|
-
const root =
|
|
70387
|
-
const mapPath =
|
|
70455
|
+
const root = join54(input.projectRoot, input.pkg.outDir);
|
|
70456
|
+
const mapPath = join54(root, "context-knowledge-map.json");
|
|
70388
70457
|
try {
|
|
70389
|
-
await
|
|
70458
|
+
await readFile46(mapPath);
|
|
70390
70459
|
throw new TypeError("package template uses reserved context-knowledge-map.json; rename that template output");
|
|
70391
70460
|
} catch (error) {
|
|
70392
70461
|
if (error.code !== "ENOENT")
|
|
70393
70462
|
throw error;
|
|
70394
70463
|
}
|
|
70395
|
-
await
|
|
70464
|
+
await writeFile13(mapPath, JSON.stringify({ protocol: "context.knowledge-map-output/v1", knowledge_map_revision: input.structure.revision, ...projected }, null, 2) + `
|
|
70396
70465
|
`);
|
|
70397
70466
|
const lines = [];
|
|
70398
70467
|
const escape2 = (value) => value.replace(/[\\[\]<>]/gu, (char) => `\\${char}`).replace(/[\r\n]/gu, " ");
|
|
@@ -70405,15 +70474,15 @@ async function writePackageKnowledgeMap(input) {
|
|
|
70405
70474
|
}
|
|
70406
70475
|
render(projected.entries, 0);
|
|
70407
70476
|
if (lines.length) {
|
|
70408
|
-
const indexPath =
|
|
70477
|
+
const indexPath = join54(root, "index.md");
|
|
70409
70478
|
let existing = "";
|
|
70410
70479
|
try {
|
|
70411
|
-
existing = await
|
|
70480
|
+
existing = await readFile46(indexPath, "utf8");
|
|
70412
70481
|
} catch (error) {
|
|
70413
70482
|
if (error.code !== "ENOENT")
|
|
70414
70483
|
throw error;
|
|
70415
70484
|
}
|
|
70416
|
-
await
|
|
70485
|
+
await writeFile13(indexPath, `${existing.trimEnd()}
|
|
70417
70486
|
|
|
70418
70487
|
## Knowledge map
|
|
70419
70488
|
|
|
@@ -70431,8 +70500,8 @@ var init_packageKnowledgeMap = __esm(() => {
|
|
|
70431
70500
|
|
|
70432
70501
|
// src/project/packageLlms.ts
|
|
70433
70502
|
import { createHash as createHash14 } from "node:crypto";
|
|
70434
|
-
import { access as access4, mkdir as mkdir18, writeFile as
|
|
70435
|
-
import { dirname as dirname22, join as
|
|
70503
|
+
import { access as access4, mkdir as mkdir18, writeFile as writeFile14 } from "node:fs/promises";
|
|
70504
|
+
import { dirname as dirname22, join as join55, posix as posix5 } from "node:path";
|
|
70436
70505
|
function llmsArticles(pkg, selected) {
|
|
70437
70506
|
return selected.map((file) => {
|
|
70438
70507
|
const meta = parseKnowledgeFrontmatter(file.content);
|
|
@@ -70532,7 +70601,7 @@ async function writeLlmsDocuments(root, documents, options = {}) {
|
|
|
70532
70601
|
for (const [path2, content3] of documents.files) {
|
|
70533
70602
|
let exists = false;
|
|
70534
70603
|
try {
|
|
70535
|
-
await access4(
|
|
70604
|
+
await access4(join55(root, path2));
|
|
70536
70605
|
exists = true;
|
|
70537
70606
|
} catch (error) {
|
|
70538
70607
|
if (error.code !== "ENOENT")
|
|
@@ -70542,8 +70611,8 @@ async function writeLlmsDocuments(root, documents, options = {}) {
|
|
|
70542
70611
|
continue;
|
|
70543
70612
|
if (exists)
|
|
70544
70613
|
throw new Error(`Package template uses reserved LLMS output ${path2}; rename that template output.`);
|
|
70545
|
-
await mkdir18(dirname22(
|
|
70546
|
-
await
|
|
70614
|
+
await mkdir18(dirname22(join55(root, path2)), { recursive: true });
|
|
70615
|
+
await writeFile14(join55(root, path2), options.utf8Bom ? "\uFEFF" + content3.replace(/^\uFEFF/u, "") : content3, "utf8");
|
|
70547
70616
|
}
|
|
70548
70617
|
}
|
|
70549
70618
|
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 +71272,8 @@ var init_packageSiteBranding = __esm(() => {
|
|
|
71203
71272
|
|
|
71204
71273
|
// src/project/packageSiteExtensions.ts
|
|
71205
71274
|
import { createHash as createHash15 } from "node:crypto";
|
|
71206
|
-
import { lstat as lstat7, readdir as readdir14, readFile as
|
|
71207
|
-
import { join as
|
|
71275
|
+
import { lstat as lstat7, readdir as readdir14, readFile as readFile47, mkdir as mkdir19, writeFile as writeFile15, symlink } from "node:fs/promises";
|
|
71276
|
+
import { join as join56, dirname as dirname23, resolve as resolve19 } from "node:path";
|
|
71208
71277
|
function invalidSiteExtension(message) {
|
|
71209
71278
|
throw new ContextError(ExitCode.UserError, `Site extensions: ${message}. Update site.extensions, its src files or the knowledge-map target, then retry the build.`, {
|
|
71210
71279
|
reason_code: "invalid-site-extension"
|
|
@@ -71223,7 +71292,7 @@ async function readSiteExtensions(projectRoot, extensions) {
|
|
|
71223
71292
|
invalid(`unsafe root ${root}`);
|
|
71224
71293
|
let cursor = projectRoot;
|
|
71225
71294
|
for (const part of root.split("/")) {
|
|
71226
|
-
cursor =
|
|
71295
|
+
cursor = join56(cursor, part);
|
|
71227
71296
|
const info = await lstat7(cursor).catch((error) => {
|
|
71228
71297
|
if (error.code === "ENOENT")
|
|
71229
71298
|
invalid(`missing directory ${root}`);
|
|
@@ -71243,9 +71312,9 @@ async function readSiteExtensions(projectRoot, extensions) {
|
|
|
71243
71312
|
if (entry.isSymbolicLink())
|
|
71244
71313
|
invalid(`symlink at ${path2}`);
|
|
71245
71314
|
if (entry.isDirectory())
|
|
71246
|
-
await walk(
|
|
71315
|
+
await walk(join56(directory, entry.name), path2 + "/");
|
|
71247
71316
|
else if (entry.isFile())
|
|
71248
|
-
files.push({ path: path2, bytes: await
|
|
71317
|
+
files.push({ path: path2, bytes: await readFile47(join56(directory, entry.name)) });
|
|
71249
71318
|
}
|
|
71250
71319
|
}
|
|
71251
71320
|
await walk(cursor, "");
|
|
@@ -71265,7 +71334,7 @@ async function readSiteExtensions(projectRoot, extensions) {
|
|
|
71265
71334
|
hash3.update(file.path + "\x00").update(file.bytes).update("\x00");
|
|
71266
71335
|
for (const name2 of ["package.json", "bun.lock", "pnpm-lock.yaml", "package-lock.json"]) {
|
|
71267
71336
|
try {
|
|
71268
|
-
hash3.update(name2).update(await
|
|
71337
|
+
hash3.update(name2).update(await readFile47(join56(projectRoot, name2)));
|
|
71269
71338
|
} catch (error) {
|
|
71270
71339
|
if (error.code !== "ENOENT")
|
|
71271
71340
|
throw error;
|
|
@@ -71278,18 +71347,18 @@ function siteExtensionTargets(site) {
|
|
|
71278
71347
|
}
|
|
71279
71348
|
async function writeSiteExtensions(projectRoot, temporary, extensions) {
|
|
71280
71349
|
const { files } = await readSiteExtensions(projectRoot, extensions);
|
|
71281
|
-
const root =
|
|
71350
|
+
const root = join56(temporary, "_site");
|
|
71282
71351
|
for (const file of files) {
|
|
71283
|
-
const path2 =
|
|
71352
|
+
const path2 = join56(root, file.path);
|
|
71284
71353
|
await mkdir19(dirname23(path2), { recursive: true });
|
|
71285
|
-
await
|
|
71354
|
+
await writeFile15(path2, file.bytes);
|
|
71286
71355
|
}
|
|
71287
71356
|
if (extensions) {
|
|
71288
71357
|
try {
|
|
71289
71358
|
const modules = resolve19(projectRoot, "node_modules");
|
|
71290
71359
|
if ((await lstat7(modules)).isDirectory() || (await lstat7(modules)).isSymbolicLink()) {
|
|
71291
71360
|
await mkdir19(root, { recursive: true });
|
|
71292
|
-
await symlink(modules,
|
|
71361
|
+
await symlink(modules, join56(root, "node_modules"), "dir");
|
|
71293
71362
|
}
|
|
71294
71363
|
} catch (error) {
|
|
71295
71364
|
if (error.code !== "ENOENT")
|
|
@@ -71308,16 +71377,16 @@ async function writeSiteExtensions(projectRoot, temporary, extensions) {
|
|
|
71308
71377
|
imports.push(`const ${name2} = defineAsyncComponent(() => import(${JSON.stringify(`../../_site/${path2}`)}));`);
|
|
71309
71378
|
slots.push(`${JSON.stringify(name2)}: ${name2 === "floating" ? `() => h(resolveComponent('ClientOnly'), null, { default: () => h(${name2}) })` : `() => h(${name2})`}`);
|
|
71310
71379
|
}
|
|
71311
|
-
await
|
|
71380
|
+
await writeFile15(join56(temporary, ".vitepress/theme/extensions.js"), imports.join(`
|
|
71312
71381
|
`) + `
|
|
71313
71382
|
export default {${slots.join(",")}};
|
|
71314
71383
|
`);
|
|
71315
71384
|
for (const [key, path2] of Object.entries(extensions?.pages ?? {})) {
|
|
71316
|
-
await mkdir19(
|
|
71385
|
+
await mkdir19(join56(temporary, "custom"), { recursive: true });
|
|
71317
71386
|
const content3 = files.find((file) => file.path === path2).bytes.toString("utf8");
|
|
71318
71387
|
const metadata = parseKnowledgeFrontmatter(content3);
|
|
71319
71388
|
const title = metadata.title ?? /^#\s+(.+)$/m.exec(content3)?.[1] ?? key;
|
|
71320
|
-
await
|
|
71389
|
+
await writeFile15(join56(temporary, "custom", `${key}.md`), `---
|
|
71321
71390
|
${JSON.stringify({ layout: "page", ...metadata, title })}
|
|
71322
71391
|
---
|
|
71323
71392
|
<script setup>
|
|
@@ -71339,9 +71408,9 @@ var init_packageSiteExtensions = __esm(() => {
|
|
|
71339
71408
|
// src/project/packageSite.ts
|
|
71340
71409
|
import { createHash as createHash16 } from "node:crypto";
|
|
71341
71410
|
import { spawn as spawn3 } from "node:child_process";
|
|
71342
|
-
import { mkdir as mkdir20, mkdtemp, readFile as
|
|
71411
|
+
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
71412
|
import { createRequire as createRequire5 } from "node:module";
|
|
71344
|
-
import { dirname as dirname24, join as
|
|
71413
|
+
import { dirname as dirname24, join as join57, posix as posix6 } from "node:path";
|
|
71345
71414
|
function sitePagePath(identity) {
|
|
71346
71415
|
return `pages/${createHash16("sha256").update(identity).digest("hex").slice(0, 32)}.html`;
|
|
71347
71416
|
}
|
|
@@ -71454,7 +71523,7 @@ function siteSections(entries2) {
|
|
|
71454
71523
|
async function compileSite(root, outDir) {
|
|
71455
71524
|
const vitepressRoot = dirname24(require2.resolve("vitepress/package.json"));
|
|
71456
71525
|
await new Promise((resolve8, reject) => {
|
|
71457
|
-
const child = spawn3(process.versions.bun ? "node" : process.execPath, [
|
|
71526
|
+
const child = spawn3(process.versions.bun ? "node" : process.execPath, [join57(vitepressRoot, "bin/vitepress.js"), "build", root, "--outDir", outDir], { stdio: ["ignore", "pipe", "pipe"] });
|
|
71458
71527
|
let tail = "";
|
|
71459
71528
|
const receive = (chunk) => {
|
|
71460
71529
|
tail = (tail + chunk.toString()).slice(-16000);
|
|
@@ -71485,8 +71554,8 @@ async function writePackageSite(input) {
|
|
|
71485
71554
|
const base = options.base ?? "/";
|
|
71486
71555
|
const history = await readWorkspaceChangelog(projectRoot);
|
|
71487
71556
|
const historyDate = history[0]?.date ?? null;
|
|
71488
|
-
const root =
|
|
71489
|
-
const output =
|
|
71557
|
+
const root = join57(projectRoot, pkg.outDir);
|
|
71558
|
+
const output = join57(projectRoot, packageSiteOutputDir(pkg));
|
|
71490
71559
|
try {
|
|
71491
71560
|
await access5(output);
|
|
71492
71561
|
throw new Error("Website output already exists; build through the staged package workflow.");
|
|
@@ -71494,9 +71563,9 @@ async function writePackageSite(input) {
|
|
|
71494
71563
|
if (error.code !== "ENOENT")
|
|
71495
71564
|
throw error;
|
|
71496
71565
|
}
|
|
71497
|
-
const temporaryRoot =
|
|
71566
|
+
const temporaryRoot = join57(projectRoot, ".tmp");
|
|
71498
71567
|
await mkdir20(temporaryRoot, { recursive: true });
|
|
71499
|
-
const temporary = await mkdtemp(
|
|
71568
|
+
const temporary = await mkdtemp(join57(temporaryRoot, "website-"));
|
|
71500
71569
|
try {
|
|
71501
71570
|
const registry2 = await loadSourcesRegistry({ rootDir: projectRoot });
|
|
71502
71571
|
const sourceContent = new Map(selected.map((file) => [packageKnowledgeOutputPath(pkg, file.relPath), file]));
|
|
@@ -71506,7 +71575,7 @@ async function writePackageSite(input) {
|
|
|
71506
71575
|
for (const file of delivered) {
|
|
71507
71576
|
if (!/^(?:skills|wikis|guides|rules|feats)\/.*\.md$/u.test(file.relPath) || byPath.has(file.relPath))
|
|
71508
71577
|
continue;
|
|
71509
|
-
const content3 = await
|
|
71578
|
+
const content3 = await readFile48(file.absPath, "utf8");
|
|
71510
71579
|
const meta = parseKnowledgeFrontmatter(content3);
|
|
71511
71580
|
const page = {
|
|
71512
71581
|
package_path: file.relPath,
|
|
@@ -71517,20 +71586,20 @@ async function writePackageSite(input) {
|
|
|
71517
71586
|
}
|
|
71518
71587
|
const sections = siteSections(mapping.entries);
|
|
71519
71588
|
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(
|
|
71589
|
+
const configRoot = join57(temporary, ".vitepress");
|
|
71590
|
+
await mkdir20(join57(configRoot, "theme"), { recursive: true });
|
|
71591
|
+
await mkdir20(join57(temporary, "node_modules"), { recursive: true });
|
|
71523
71592
|
const vitepressRoot = dirname24(require2.resolve("vitepress/package.json"));
|
|
71524
|
-
const vueRequire = createRequire5(
|
|
71593
|
+
const vueRequire = createRequire5(join57(vitepressRoot, "package.json"));
|
|
71525
71594
|
for (const [name2, path2] of [
|
|
71526
71595
|
["vitepress", vitepressRoot],
|
|
71527
71596
|
["vue", dirname24(vueRequire.resolve("vue/package.json"))],
|
|
71528
71597
|
["mermaid", dirname24(require2.resolve("mermaid/package.json"))]
|
|
71529
71598
|
]) {
|
|
71530
|
-
await symlink2(path2,
|
|
71599
|
+
await symlink2(path2, join57(temporary, "node_modules", name2), "dir");
|
|
71531
71600
|
}
|
|
71532
|
-
await
|
|
71533
|
-
await
|
|
71601
|
+
await writeFile16(join57(configRoot, "theme/index.js"), siteThemeScript);
|
|
71602
|
+
await writeFile16(join57(configRoot, "theme/style.css"), siteThemeCss);
|
|
71534
71603
|
await writeSiteExtensions(projectRoot, temporary, options.extensions);
|
|
71535
71604
|
const config = {
|
|
71536
71605
|
title: options.title ?? pkg.name,
|
|
@@ -71556,11 +71625,11 @@ async function writePackageSite(input) {
|
|
|
71556
71625
|
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
71626
|
}
|
|
71558
71627
|
};
|
|
71559
|
-
await
|
|
71628
|
+
await writeFile16(join57(configRoot, "config.mjs"), `export default { ...${JSON.stringify(config)}, markdown: { ${siteMarkdownConfig} } };
|
|
71560
71629
|
`);
|
|
71561
|
-
await mkdir20(
|
|
71630
|
+
await mkdir20(join57(temporary, "pages"), { recursive: true });
|
|
71562
71631
|
for (const page of byPath.values()) {
|
|
71563
|
-
const content3 = await
|
|
71632
|
+
const content3 = await readFile48(join57(root, page.package_path), "utf8");
|
|
71564
71633
|
const original = sourceContent.get(page.package_path);
|
|
71565
71634
|
const provenance = articleProvenanceMarkdown(original?.article, registry2);
|
|
71566
71635
|
const pageContent = provenance && content3.endsWith(provenance) ? content3.slice(0, -provenance.length) : content3;
|
|
@@ -71568,7 +71637,7 @@ async function writePackageSite(input) {
|
|
|
71568
71637
|
const sources = siteArticleSources(original?.article, registry2);
|
|
71569
71638
|
const timestamp = parseKnowledgeFrontmatter(original?.content ?? content3).timestamp;
|
|
71570
71639
|
const updated = typeof timestamp === "string" && Number.isFinite(Date.parse(timestamp)) ? new Date(timestamp).toISOString() : null;
|
|
71571
|
-
await
|
|
71640
|
+
await writeFile16(join57(temporary, page.site_path.replace(/\.html$/u, ".md")), `---
|
|
71572
71641
|
title: ${JSON.stringify(page.title)}
|
|
71573
71642
|
contextSources: ${JSON.stringify(sources)}
|
|
71574
71643
|
contextUpdated: ${JSON.stringify(updated)}
|
|
@@ -71580,11 +71649,11 @@ ${body}`);
|
|
|
71580
71649
|
lines.push(`${" ".repeat(level)}- ${entry.href ? `[${mdLabel(entry.title)}](${entry.href})` : mdLabel(entry.title)}`);
|
|
71581
71650
|
menu(lines, entry.children, level + 1);
|
|
71582
71651
|
});
|
|
71583
|
-
await mkdir20(
|
|
71652
|
+
await mkdir20(join57(temporary, "sections"), { recursive: true });
|
|
71584
71653
|
for (const section of sections) {
|
|
71585
71654
|
const lines = [`# ${mdLabel(section.title)}`, ""];
|
|
71586
71655
|
menu(lines, section.entries, 0);
|
|
71587
|
-
await
|
|
71656
|
+
await writeFile16(join57(temporary, section.href.slice(1).replace(/\.html$/u, ".md")), lines.join(`
|
|
71588
71657
|
`) + `
|
|
71589
71658
|
`);
|
|
71590
71659
|
}
|
|
@@ -71603,12 +71672,12 @@ ${body}`);
|
|
|
71603
71672
|
};
|
|
71604
71673
|
const homeHero = options.extensions?.slots?.banner === undefined ? `hero: ${JSON.stringify(hero)}
|
|
71605
71674
|
` : "";
|
|
71606
|
-
await
|
|
71675
|
+
await writeFile16(join57(temporary, "index.md"), `---
|
|
71607
71676
|
layout: home
|
|
71608
71677
|
title: ${JSON.stringify(options.home?.title ?? options.title ?? pkg.name)}
|
|
71609
71678
|
${homeHero}---
|
|
71610
71679
|
`);
|
|
71611
|
-
await
|
|
71680
|
+
await writeFile16(join57(temporary, "changelog.md"), `---
|
|
71612
71681
|
title: Changelog
|
|
71613
71682
|
contextHistory: ${JSON.stringify(Buffer.from(JSON.stringify(history)).toString("base64"))}
|
|
71614
71683
|
---
|
|
@@ -71621,19 +71690,19 @@ contextHistory: ${JSON.stringify(Buffer.from(JSON.stringify(history)).toString("
|
|
|
71621
71690
|
assetsPrefix: "resources/",
|
|
71622
71691
|
articles: await Promise.all(llmsArticles(pkg, selected).map(async (article) => ({
|
|
71623
71692
|
...article,
|
|
71624
|
-
content: await
|
|
71693
|
+
content: await readFile48(join57(root, article.path), "utf8")
|
|
71625
71694
|
}))),
|
|
71626
71695
|
...structure ? { map: structure } : {}
|
|
71627
71696
|
});
|
|
71628
|
-
await writeLlmsDocuments(
|
|
71629
|
-
await mkdir20(
|
|
71697
|
+
await writeLlmsDocuments(join57(temporary, "public"), llms, { utf8Bom: true });
|
|
71698
|
+
await mkdir20(join57(temporary, "llms"), { recursive: true });
|
|
71630
71699
|
let landingNavigation = llms.navigationMarkdown;
|
|
71631
71700
|
for (const link of markdownReaderLinks(landingNavigation).reverse()) {
|
|
71632
71701
|
if (!link.target.startsWith(base))
|
|
71633
71702
|
continue;
|
|
71634
71703
|
landingNavigation = landingNavigation.slice(0, link.start) + `[${link.label}](</${link.target.slice(base.length)}>)` + landingNavigation.slice(link.end);
|
|
71635
71704
|
}
|
|
71636
|
-
await
|
|
71705
|
+
await writeFile16(join57(temporary, "llms/index.md"), `---
|
|
71637
71706
|
title: LLM Docs
|
|
71638
71707
|
---
|
|
71639
71708
|
|
|
@@ -71643,9 +71712,9 @@ title: LLM Docs
|
|
|
71643
71712
|
|
|
71644
71713
|
` + landingNavigation);
|
|
71645
71714
|
for (const path2 of resources) {
|
|
71646
|
-
const destination =
|
|
71715
|
+
const destination = join57(temporary, "public/resources", path2);
|
|
71647
71716
|
await mkdir20(dirname24(destination), { recursive: true });
|
|
71648
|
-
await cp(
|
|
71717
|
+
await cp(join57(root, path2), destination);
|
|
71649
71718
|
}
|
|
71650
71719
|
await compileSite(temporary, output);
|
|
71651
71720
|
for (const file of await walkPackageFiles(output)) {
|
|
@@ -71654,10 +71723,11 @@ title: LLM Docs
|
|
|
71654
71723
|
` : [".html", ".htm"].includes(extension2) ? `<!-- Intentionally empty. -->
|
|
71655
71724
|
` : null;
|
|
71656
71725
|
if (placeholder !== null && (await stat6(file.absPath)).size === 0) {
|
|
71657
|
-
await
|
|
71726
|
+
await writeFile16(file.absPath, placeholder);
|
|
71658
71727
|
}
|
|
71659
71728
|
}
|
|
71660
|
-
|
|
71729
|
+
const siteMapContent = JSON.stringify({
|
|
71730
|
+
...input.siteUrl ? { site_url: input.siteUrl } : {},
|
|
71661
71731
|
protocol: "context.site-output/v1",
|
|
71662
71732
|
knowledge_map_revision: structure?.revision ?? null,
|
|
71663
71733
|
base,
|
|
@@ -71667,7 +71737,9 @@ title: LLM Docs
|
|
|
71667
71737
|
sections: sections.map(({ key, title, href, pages, items }) => ({ key, title, href, pages, items })),
|
|
71668
71738
|
warnings: mapping.warnings
|
|
71669
71739
|
}, null, 2) + `
|
|
71670
|
-
|
|
71740
|
+
`;
|
|
71741
|
+
await writeFile16(join57(output, "context-site-map.json"), siteMapContent);
|
|
71742
|
+
await writeFile16(join57(projectRoot, pkg.outDir, "context-site-map.json"), siteMapContent);
|
|
71671
71743
|
return mapping;
|
|
71672
71744
|
} finally {
|
|
71673
71745
|
await rm11(temporary, { recursive: true, force: true });
|
|
@@ -71687,13 +71759,13 @@ var init_packageSite2 = __esm(() => {
|
|
|
71687
71759
|
init_packageSiteTheme();
|
|
71688
71760
|
init_packageSiteBranding();
|
|
71689
71761
|
init_packageSiteExtensions();
|
|
71690
|
-
PACKAGE_SITE_VERSION = `vitepress-site-
|
|
71762
|
+
PACKAGE_SITE_VERSION = `vitepress-site-v44-site-address:${createHash16("sha256").update(JSON.stringify([siteMarkdownConfig, siteThemeCss, siteThemeScript, siteThemeLabels("zh"), siteThemeLabels("en")])).digest("hex")}`;
|
|
71691
71763
|
require2 = createRequire5(import.meta.url);
|
|
71692
71764
|
});
|
|
71693
71765
|
|
|
71694
71766
|
// src/project/workspaceBuildVersion.ts
|
|
71695
|
-
import { join as
|
|
71696
|
-
import { mkdir as mkdir21, writeFile as
|
|
71767
|
+
import { join as join58 } from "node:path";
|
|
71768
|
+
import { mkdir as mkdir21, writeFile as writeFile17 } from "node:fs/promises";
|
|
71697
71769
|
async function workspaceVersionFingerprint(root) {
|
|
71698
71770
|
return { version: await workspaceVersion(root), changelog: await readWorkspaceChangelog(root) };
|
|
71699
71771
|
}
|
|
@@ -71704,8 +71776,8 @@ async function writePackageVersion(projectRoot, output) {
|
|
|
71704
71776
|
throw new TypeError(`Package template uses reserved version output ${path2}; rename that template output.`);
|
|
71705
71777
|
}
|
|
71706
71778
|
await mkdir21(output, { recursive: true });
|
|
71707
|
-
await
|
|
71708
|
-
await
|
|
71779
|
+
await writeFile17(join58(output, "CHANGELOG.md"), renderChangelog(info.changelog));
|
|
71780
|
+
await writeFile17(join58(output, "context-version.json"), JSON.stringify({ version: info.version }) + `
|
|
71709
71781
|
`);
|
|
71710
71782
|
}
|
|
71711
71783
|
var init_workspaceBuildVersion = __esm(() => {
|
|
@@ -71714,14 +71786,14 @@ var init_workspaceBuildVersion = __esm(() => {
|
|
|
71714
71786
|
|
|
71715
71787
|
// src/project/packageRenderCache.ts
|
|
71716
71788
|
import { createHash as createHash17 } from "node:crypto";
|
|
71717
|
-
import { readFile as
|
|
71718
|
-
import { join as
|
|
71789
|
+
import { readFile as readFile49 } from "node:fs/promises";
|
|
71790
|
+
import { join as join59 } from "node:path";
|
|
71719
71791
|
async function cachedPackageKnowledgeMarkdown(input) {
|
|
71720
71792
|
const fingerprint = digest3(`${PACKAGE_READER_MARKDOWN_VERSION}
|
|
71721
71793
|
${input.content}`);
|
|
71722
|
-
const path2 =
|
|
71794
|
+
const path2 = join59(input.projectRoot, ".tmp/context-runtime/package-render", `${digest3(input.key)}.json`);
|
|
71723
71795
|
try {
|
|
71724
|
-
const cached = JSON.parse(await
|
|
71796
|
+
const cached = JSON.parse(await readFile49(path2, "utf8"));
|
|
71725
71797
|
if (cached !== null && typeof cached === "object" && "fingerprint" in cached && cached.fingerprint === fingerprint && "markdown" in cached && typeof cached.markdown === "string") {
|
|
71726
71798
|
return cached.markdown;
|
|
71727
71799
|
}
|
|
@@ -71760,7 +71832,7 @@ var init_packageKnowledgeAdvisories = __esm(() => {
|
|
|
71760
71832
|
|
|
71761
71833
|
// src/project/packageMarkdownAnchors.ts
|
|
71762
71834
|
import { posix as posix7 } from "node:path";
|
|
71763
|
-
import { readFile as
|
|
71835
|
+
import { readFile as readFile50 } from "node:fs/promises";
|
|
71764
71836
|
function packageMarkdownAnchors(markdown) {
|
|
71765
71837
|
const anchors = new Set;
|
|
71766
71838
|
const used = new Set;
|
|
@@ -71823,7 +71895,7 @@ async function inspectPackageMarkdownDirectory(root) {
|
|
|
71823
71895
|
const files = (await walkPackageFiles(root)).filter((file) => /\.md$/iu.test(file.relPath));
|
|
71824
71896
|
const pages = new Map;
|
|
71825
71897
|
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
|
|
71898
|
+
const batch = await Promise.allSettled(files.slice(offset, offset + 16).map(async (file) => [file.relPath, await readFile50(file.absPath, "utf8")]));
|
|
71827
71899
|
for (const result of batch) {
|
|
71828
71900
|
if (result.status === "rejected")
|
|
71829
71901
|
throw result.reason;
|
|
@@ -71840,23 +71912,23 @@ var init_packageMarkdownAnchors = __esm(() => {
|
|
|
71840
71912
|
});
|
|
71841
71913
|
|
|
71842
71914
|
// src/project/packageBuildStage.ts
|
|
71843
|
-
import { mkdir as mkdir22, mkdtemp as mkdtemp2, readFile as
|
|
71844
|
-
import { dirname as dirname25, join as
|
|
71915
|
+
import { mkdir as mkdir22, mkdtemp as mkdtemp2, readFile as readFile51, rename as rename6, rm as rm12, rmdir } from "node:fs/promises";
|
|
71916
|
+
import { dirname as dirname25, join as join60, relative as relative16 } from "node:path";
|
|
71845
71917
|
async function withStagedPackageOutput(projectRoot, pkg, render) {
|
|
71846
|
-
const tempRoot =
|
|
71918
|
+
const tempRoot = join60(projectRoot, ".tmp");
|
|
71847
71919
|
await mkdir22(tempRoot, { recursive: true });
|
|
71848
|
-
const stage = await mkdtemp2(
|
|
71849
|
-
const stagedPackage = { ...pkg, outDir: relative16(projectRoot,
|
|
71920
|
+
const stage = await mkdtemp2(join60(tempRoot, "package-build-"));
|
|
71921
|
+
const stagedPackage = { ...pkg, outDir: relative16(projectRoot, join60(stage, pkg.name)) };
|
|
71850
71922
|
try {
|
|
71851
|
-
await mkdir22(
|
|
71923
|
+
await mkdir22(join60(projectRoot, stagedPackage.outDir), { recursive: true });
|
|
71852
71924
|
const value = await render(stagedPackage);
|
|
71853
71925
|
await validatePackageIndexLinks({ projectRoot, pkg: stagedPackage });
|
|
71854
71926
|
const destinations = packageOutputDirs(pkg);
|
|
71855
71927
|
const staged = packageOutputDirs(stagedPackage);
|
|
71856
71928
|
for (const [index2, destination] of destinations.entries()) {
|
|
71857
|
-
const target =
|
|
71929
|
+
const target = join60(projectRoot, destination);
|
|
71858
71930
|
const previous2 = await walkPackageFiles(target);
|
|
71859
|
-
const next = await walkPackageFiles(
|
|
71931
|
+
const next = await walkPackageFiles(join60(projectRoot, staged[index2]));
|
|
71860
71932
|
const desired = new Set(next.map((file) => file.relPath));
|
|
71861
71933
|
for (const file of previous2) {
|
|
71862
71934
|
if (desired.has(file.relPath))
|
|
@@ -71874,9 +71946,9 @@ async function withStagedPackageOutput(projectRoot, pkg, render) {
|
|
|
71874
71946
|
}
|
|
71875
71947
|
for (let offset = 0;offset < next.length; offset += 8) {
|
|
71876
71948
|
const results = await Promise.allSettled(next.slice(offset, offset + 8).map(async (file) => {
|
|
71877
|
-
const output =
|
|
71878
|
-
const bytes = await
|
|
71879
|
-
const old = await
|
|
71949
|
+
const output = join60(target, file.relPath);
|
|
71950
|
+
const bytes = await readFile51(file.absPath);
|
|
71951
|
+
const old = await readFile51(output).catch((error) => {
|
|
71880
71952
|
if (error.code === "ENOENT")
|
|
71881
71953
|
return;
|
|
71882
71954
|
throw error;
|
|
@@ -71884,7 +71956,7 @@ async function withStagedPackageOutput(projectRoot, pkg, render) {
|
|
|
71884
71956
|
if (old?.equals(bytes))
|
|
71885
71957
|
return;
|
|
71886
71958
|
await mkdir22(dirname25(output), { recursive: true });
|
|
71887
|
-
await
|
|
71959
|
+
await rename6(file.absPath, output);
|
|
71888
71960
|
}));
|
|
71889
71961
|
for (const result of results)
|
|
71890
71962
|
if (result.status === "rejected")
|
|
@@ -71947,7 +72019,7 @@ var init_packageArticleLinks = __esm(() => {
|
|
|
71947
72019
|
});
|
|
71948
72020
|
|
|
71949
72021
|
// src/project/packageAssets.ts
|
|
71950
|
-
import { readFile as
|
|
72022
|
+
import { readFile as readFile52 } from "node:fs/promises";
|
|
71951
72023
|
import { dirname as dirname26, relative as relative17, sep as sep4 } from "node:path";
|
|
71952
72024
|
function posixPath2(value) {
|
|
71953
72025
|
return value.split(sep4).join("/");
|
|
@@ -71986,7 +72058,7 @@ async function projectPackageKnowledgeAssets(input) {
|
|
|
71986
72058
|
const paths = packageAssetPath(input.projectRoot, absolute);
|
|
71987
72059
|
let bytes;
|
|
71988
72060
|
try {
|
|
71989
|
-
bytes = await
|
|
72061
|
+
bytes = await readFile52(absolute);
|
|
71990
72062
|
} catch {
|
|
71991
72063
|
throw new ContextError(ExitCode.WorkspaceStateError, `knowledge resource is missing: ${paths.knowledgeRelPath}`, {
|
|
71992
72064
|
category: ErrorCategory.WorkspaceStateInvalid,
|
|
@@ -72260,7 +72332,7 @@ var init_packageAssetOptimization = __esm(() => {
|
|
|
72260
72332
|
// src/project/packageAssetDelivery.ts
|
|
72261
72333
|
import { execFile as execFile8 } from "node:child_process";
|
|
72262
72334
|
import { realpath as realpath7 } from "node:fs/promises";
|
|
72263
|
-
import { join as
|
|
72335
|
+
import { join as join61, relative as relative18, sep as sep5 } from "node:path";
|
|
72264
72336
|
import { promisify as promisify8 } from "node:util";
|
|
72265
72337
|
async function git(projectRoot, args) {
|
|
72266
72338
|
try {
|
|
@@ -72280,7 +72352,7 @@ async function git(projectRoot, args) {
|
|
|
72280
72352
|
}
|
|
72281
72353
|
}
|
|
72282
72354
|
function repositoryPath(repoRoot, projectRoot, asset) {
|
|
72283
|
-
const path2 = relative18(repoRoot,
|
|
72355
|
+
const path2 = relative18(repoRoot, join61(projectRoot, asset.knowledgeRelPath)).split(sep5).join("/");
|
|
72284
72356
|
if (path2 === ".." || path2.startsWith("../") || path2.startsWith("/")) {
|
|
72285
72357
|
throw new ContextError(ExitCode.WorkspaceStateError, "knowledge asset is outside the current Git repository", {
|
|
72286
72358
|
category: ErrorCategory.WorkspaceStateInvalid,
|
|
@@ -72459,8 +72531,8 @@ var init_packageAssetDelivery = __esm(() => {
|
|
|
72459
72531
|
|
|
72460
72532
|
// src/project/packageBuildContent.ts
|
|
72461
72533
|
import { existsSync as existsSync16 } from "node:fs";
|
|
72462
|
-
import { mkdir as mkdir23, readFile as
|
|
72463
|
-
import { dirname as dirname28, join as
|
|
72534
|
+
import { mkdir as mkdir23, readFile as readFile53, writeFile as writeFile18 } from "node:fs/promises";
|
|
72535
|
+
import { dirname as dirname28, join as join62 } from "node:path";
|
|
72464
72536
|
function globToRegExp(pattern) {
|
|
72465
72537
|
const normalized = toPosixPath4(pattern);
|
|
72466
72538
|
if (normalized.endsWith("/**")) {
|
|
@@ -72601,9 +72673,9 @@ async function writeRenderedPackageTemplate(input) {
|
|
|
72601
72673
|
templateRelPath: renderedRelPath,
|
|
72602
72674
|
logicalTemplateRelPath: renderedLogicalRelPath
|
|
72603
72675
|
});
|
|
72604
|
-
const outputPath =
|
|
72676
|
+
const outputPath = join62(input.projectRoot, input.pkg.outDir, renderedRelPath);
|
|
72605
72677
|
await mkdir23(dirname28(outputPath), { recursive: true });
|
|
72606
|
-
await
|
|
72678
|
+
await writeFile18(outputPath, renderTemplateText(file.content, contentVars), "utf8");
|
|
72607
72679
|
written++;
|
|
72608
72680
|
}
|
|
72609
72681
|
return { files: written, consumesKnowledge };
|
|
@@ -72634,7 +72706,7 @@ async function writeSelectedPackageKnowledge(input) {
|
|
|
72634
72706
|
for (let offset = 0;offset < projectedPages.length; offset += 8) {
|
|
72635
72707
|
const results = await Promise.allSettled(projectedPages.slice(offset, offset + 8).map(async (projected) => {
|
|
72636
72708
|
assertSafeRenderedPath2(projected.pageOutputPath, "knowledge path");
|
|
72637
|
-
const outputPath =
|
|
72709
|
+
const outputPath = join62(input.projectRoot, input.pkg.outDir, projected.pageOutputPath);
|
|
72638
72710
|
const rewritten = replaceMarkdownInlineLinkTargets(projected.content, (link) => {
|
|
72639
72711
|
for (const [inputPath, outputPath2] of delivered.targetByOriginal) {
|
|
72640
72712
|
if (link.target === packageMarkdownTarget(projected.pageOutputPath, inputPath)) {
|
|
@@ -72651,7 +72723,7 @@ async function writeSelectedPackageKnowledge(input) {
|
|
|
72651
72723
|
content: links.markdown
|
|
72652
72724
|
});
|
|
72653
72725
|
const file = byPath.get(approvedByOutput.get(projected.pageOutputPath));
|
|
72654
|
-
await
|
|
72726
|
+
await writeFile18(outputPath, markdown + articleProvenanceMarkdown(file?.article, registry2), "utf8");
|
|
72655
72727
|
return links.warnings;
|
|
72656
72728
|
}));
|
|
72657
72729
|
for (const result of results) {
|
|
@@ -72663,9 +72735,9 @@ async function writeSelectedPackageKnowledge(input) {
|
|
|
72663
72735
|
const deliveredAssets = new Map(delivered.assets.map((asset) => [asset.packageRelPath, asset]));
|
|
72664
72736
|
for (const asset of deliveredAssets.values()) {
|
|
72665
72737
|
assertSafeRenderedPath2(asset.packageRelPath, "package resource path");
|
|
72666
|
-
const outputPath =
|
|
72738
|
+
const outputPath = join62(input.projectRoot, input.pkg.outDir, asset.packageRelPath);
|
|
72667
72739
|
await mkdir23(dirname28(outputPath), { recursive: true });
|
|
72668
|
-
await
|
|
72740
|
+
await writeFile18(outputPath, asset.bytes);
|
|
72669
72741
|
}
|
|
72670
72742
|
return {
|
|
72671
72743
|
pages: projectedPages.length,
|
|
@@ -72678,9 +72750,9 @@ async function writeSelectedPackageKnowledge(input) {
|
|
|
72678
72750
|
async function appendLlmsKnowledge(input) {
|
|
72679
72751
|
if (packageKind2(input.pkg) !== "llms" || input.templateConsumesKnowledge || input.knowledgeCount === 0)
|
|
72680
72752
|
return 0;
|
|
72681
|
-
const outputPath =
|
|
72753
|
+
const outputPath = join62(input.projectRoot, input.pkg.outDir, "llms.txt");
|
|
72682
72754
|
const existed = existsSync16(outputPath);
|
|
72683
|
-
const existing = existed ? await
|
|
72755
|
+
const existing = existed ? await readFile53(outputPath, "utf8") : "";
|
|
72684
72756
|
const content3 = existing.trim().length > 0 ? `${existing.trimEnd()}
|
|
72685
72757
|
|
|
72686
72758
|
---
|
|
@@ -72689,7 +72761,7 @@ ${input.bundle}
|
|
|
72689
72761
|
` : `${input.bundle}
|
|
72690
72762
|
`;
|
|
72691
72763
|
await mkdir23(dirname28(outputPath), { recursive: true });
|
|
72692
|
-
await
|
|
72764
|
+
await writeFile18(outputPath, content3, "utf8");
|
|
72693
72765
|
return existed ? 0 : 1;
|
|
72694
72766
|
}
|
|
72695
72767
|
var init_packageBuildContent = __esm(() => {
|
|
@@ -72904,8 +72976,8 @@ __export(exports_packageBuilder, {
|
|
|
72904
72976
|
});
|
|
72905
72977
|
import { createHash as createHash19 } from "node:crypto";
|
|
72906
72978
|
import { existsSync as existsSync17 } from "node:fs";
|
|
72907
|
-
import { mkdir as mkdir24, readdir as readdir15, readFile as
|
|
72908
|
-
import { dirname as dirname29, join as
|
|
72979
|
+
import { mkdir as mkdir24, readdir as readdir15, readFile as readFile54, rm as rm13, writeFile as writeFile19 } from "node:fs/promises";
|
|
72980
|
+
import { dirname as dirname29, join as join63, resolve as resolve20 } from "node:path";
|
|
72909
72981
|
function packageAssetDeliverySummary(value) {
|
|
72910
72982
|
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
72911
72983
|
return;
|
|
@@ -72927,7 +72999,7 @@ function assertPackageOutputDir(pkg) {
|
|
|
72927
72999
|
}
|
|
72928
73000
|
function packageFingerprintPath(projectRoot, pkg) {
|
|
72929
73001
|
assertSafeRenderedPath2(`${pkg.name}.json`, "package fingerprint path");
|
|
72930
|
-
return
|
|
73002
|
+
return join63(projectRoot, PACKAGE_FINGERPRINT_ROOT, `${pkg.name}.json`);
|
|
72931
73003
|
}
|
|
72932
73004
|
async function listApprovedKnowledge(projectRoot) {
|
|
72933
73005
|
const metadata = await readApprovedKnowledgeMetadataIndex(projectRoot);
|
|
@@ -72968,7 +73040,7 @@ async function listTemplateFiles(projectRoot, templatePath) {
|
|
|
72968
73040
|
const files = await walkPackageFiles(templateRoot);
|
|
72969
73041
|
return Promise.all(files.filter((file) => file.relPath.split("/").at(-1) !== PACKAGE_TEMPLATE_REVIEW_FILE).map(async (file) => ({
|
|
72970
73042
|
...file,
|
|
72971
|
-
content: await
|
|
73043
|
+
content: await readFile54(file.absPath, "utf8")
|
|
72972
73044
|
})));
|
|
72973
73045
|
}
|
|
72974
73046
|
function stableHash2(value) {
|
|
@@ -73031,7 +73103,7 @@ async function readPackageManifest(projectRoot, pkg) {
|
|
|
73031
73103
|
if (!existsSync17(filePath2))
|
|
73032
73104
|
return null;
|
|
73033
73105
|
try {
|
|
73034
|
-
const parsed = JSON.parse(await
|
|
73106
|
+
const parsed = JSON.parse(await readFile54(filePath2, "utf8"));
|
|
73035
73107
|
if (parsed !== null && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
73036
73108
|
const candidate = parsed;
|
|
73037
73109
|
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 +73135,7 @@ async function readPackageManifest(projectRoot, pkg) {
|
|
|
73063
73135
|
async function writePackageFingerprint(input) {
|
|
73064
73136
|
const filePath2 = packageFingerprintPath(input.projectRoot, input.pkg);
|
|
73065
73137
|
await mkdir24(dirname29(filePath2), { recursive: true });
|
|
73066
|
-
await
|
|
73138
|
+
await writeFile19(filePath2, `${JSON.stringify({
|
|
73067
73139
|
package: input.pkg.name,
|
|
73068
73140
|
kind: packageKind2(input.pkg),
|
|
73069
73141
|
builder_protocol: PACKAGE_BUILDER_PROTOCOL_VERSION,
|
|
@@ -73078,12 +73150,12 @@ async function writePackageFingerprint(input) {
|
|
|
73078
73150
|
`, "utf8");
|
|
73079
73151
|
}
|
|
73080
73152
|
async function removeOrphanPackageDirs(projectRoot, packages) {
|
|
73081
|
-
const distRoot =
|
|
73153
|
+
const distRoot = join63(projectRoot, "dist");
|
|
73082
73154
|
if (!existsSync17(distRoot))
|
|
73083
73155
|
return;
|
|
73084
73156
|
const declaredNames = new Set(packages.flatMap((pkg) => packageOutputDirs(pkg).map((path2) => path2.slice("dist/".length))));
|
|
73085
73157
|
const entries2 = await readdir15(distRoot, { withFileTypes: true });
|
|
73086
|
-
await Promise.all(entries2.filter((entry) => entry.isDirectory() && !declaredNames.has(entry.name)).map((entry) => rm13(
|
|
73158
|
+
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
73159
|
}
|
|
73088
73160
|
async function collectPackageFreshness(projectRoot, packages) {
|
|
73089
73161
|
assertDistinctPackageOutputs(packages);
|
|
@@ -73092,7 +73164,7 @@ async function collectPackageFreshness(projectRoot, packages) {
|
|
|
73092
73164
|
assertPackageOutputDir(pkg);
|
|
73093
73165
|
const selected = selectPackageKnowledge(approved, pkg);
|
|
73094
73166
|
assertSafeRenderedPath2(pkg.template.path, "package template path");
|
|
73095
|
-
const templateRoot =
|
|
73167
|
+
const templateRoot = join63(projectRoot, pkg.template.path);
|
|
73096
73168
|
const templateExists = existsSync17(templateRoot);
|
|
73097
73169
|
if (!templateExists) {
|
|
73098
73170
|
throw new ContextError(ExitCode.WorkspaceStateError, `package template path is missing: ${pkg.template.path}`, {
|
|
@@ -73283,6 +73355,7 @@ async function buildProjectPackagesInternal(projectRoot, options) {
|
|
|
73283
73355
|
files: selected,
|
|
73284
73356
|
...assetProcessor === undefined ? {} : { assetProcessor }
|
|
73285
73357
|
});
|
|
73358
|
+
const siteUrl = await readPackageSiteUrl(projectRoot, pkg);
|
|
73286
73359
|
const writtenKnowledge = await withStagedPackageOutput(projectRoot, pkg, async (stagedPkg) => {
|
|
73287
73360
|
const rendered = await writeRenderedPackageTemplate({
|
|
73288
73361
|
projectRoot,
|
|
@@ -73320,19 +73393,19 @@ async function buildProjectPackagesInternal(projectRoot, options) {
|
|
|
73320
73393
|
if (stagedPkg.kind === "package.llms") {
|
|
73321
73394
|
const articles = await Promise.all(llmsArticles(stagedPkg, selected).map(async (article) => ({
|
|
73322
73395
|
...article,
|
|
73323
|
-
content: await
|
|
73396
|
+
content: await readFile54(join63(projectRoot, stagedPkg.outDir, article.path), "utf8")
|
|
73324
73397
|
})));
|
|
73325
|
-
await writeLlmsDocuments(
|
|
73398
|
+
await writeLlmsDocuments(join63(projectRoot, stagedPkg.outDir), buildLlmsDocuments({
|
|
73326
73399
|
title: stagedPkg.name,
|
|
73327
73400
|
articles,
|
|
73328
73401
|
...reading ? { map: reading } : {}
|
|
73329
73402
|
}), { preserveIndex: true });
|
|
73330
73403
|
}
|
|
73331
|
-
await writePackageVersion(projectRoot,
|
|
73332
|
-
await writePackageSite({ projectRoot, pkg: stagedPkg, selected, ...reading ? { structure: reading } : {} });
|
|
73404
|
+
await writePackageVersion(projectRoot, join63(projectRoot, stagedPkg.outDir));
|
|
73405
|
+
await writePackageSite({ projectRoot, pkg: stagedPkg, selected, ...siteUrl ? { siteUrl } : {}, ...reading ? { structure: reading } : {} });
|
|
73333
73406
|
const linkWarnings = [
|
|
73334
73407
|
...writtenKnowledge2.linkWarnings,
|
|
73335
|
-
...await inspectPackageMarkdownDirectory(
|
|
73408
|
+
...await inspectPackageMarkdownDirectory(join63(projectRoot, stagedPkg.outDir))
|
|
73336
73409
|
];
|
|
73337
73410
|
return { ...writtenKnowledge2, linkWarnings };
|
|
73338
73411
|
});
|
|
@@ -73483,6 +73556,7 @@ async function runProjectBuildCommand(input) {
|
|
|
73483
73556
|
}
|
|
73484
73557
|
var import_yaml35, PACKAGE_FINGERPRINT_ROOT, PACKAGE_BUILDER_PROTOCOL_VERSION = "v23-sibling-site-output";
|
|
73485
73558
|
var init_packageBuilder = __esm(() => {
|
|
73559
|
+
init_packageSiteAddress();
|
|
73486
73560
|
init_knowledgeMap2();
|
|
73487
73561
|
init_approvedFileRead();
|
|
73488
73562
|
init_productionStageStore();
|
|
@@ -73520,7 +73594,7 @@ var init_packageBuilder = __esm(() => {
|
|
|
73520
73594
|
init_packageTemplateReview();
|
|
73521
73595
|
init_approvedKnowledgeMetadata();
|
|
73522
73596
|
import_yaml35 = __toESM(require_dist(), 1);
|
|
73523
|
-
PACKAGE_FINGERPRINT_ROOT =
|
|
73597
|
+
PACKAGE_FINGERPRINT_ROOT = join63(".tmp", "context-runtime", "packages");
|
|
73524
73598
|
});
|
|
73525
73599
|
|
|
73526
73600
|
// src/project/taskRollback.ts
|
|
@@ -73530,8 +73604,8 @@ __export(exports_taskRollback, {
|
|
|
73530
73604
|
readTaskRollback: () => readTaskRollback,
|
|
73531
73605
|
finishTaskRollback: () => finishTaskRollback
|
|
73532
73606
|
});
|
|
73533
|
-
import { readFile as
|
|
73534
|
-
import { join as
|
|
73607
|
+
import { readFile as readFile55 } from "node:fs/promises";
|
|
73608
|
+
import { join as join64 } from "node:path";
|
|
73535
73609
|
async function readTaskRollback(projectRoot) {
|
|
73536
73610
|
const raw = await readJsonMaybe(projectRoot, await revisionStoragePath(projectRoot));
|
|
73537
73611
|
if (!raw || typeof raw !== "object" || !("protocol" in raw) || raw.protocol !== "context.task-rollback/v1")
|
|
@@ -73540,7 +73614,7 @@ async function readTaskRollback(projectRoot) {
|
|
|
73540
73614
|
}
|
|
73541
73615
|
async function contents(projectRoot, path2) {
|
|
73542
73616
|
try {
|
|
73543
|
-
return await
|
|
73617
|
+
return await readFile55(join64(projectRoot, path2), "utf8");
|
|
73544
73618
|
} catch (error) {
|
|
73545
73619
|
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT")
|
|
73546
73620
|
return;
|
|
@@ -73707,12 +73781,12 @@ __export(exports_knowledgeUpdate, {
|
|
|
73707
73781
|
completeKnowledgeUpdate: () => completeKnowledgeUpdate,
|
|
73708
73782
|
beginKnowledgeUpdate: () => beginKnowledgeUpdate
|
|
73709
73783
|
});
|
|
73710
|
-
import { readFile as
|
|
73711
|
-
import { join as
|
|
73784
|
+
import { readFile as readFile56 } from "node:fs/promises";
|
|
73785
|
+
import { join as join65 } from "node:path";
|
|
73712
73786
|
async function readKnowledgeUpdate(projectRoot) {
|
|
73713
73787
|
let value;
|
|
73714
73788
|
try {
|
|
73715
|
-
value = JSON.parse(await
|
|
73789
|
+
value = JSON.parse(await readFile56(join65(projectRoot, await revisionStoragePath(projectRoot)), "utf8"));
|
|
73716
73790
|
} catch (error) {
|
|
73717
73791
|
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT")
|
|
73718
73792
|
return;
|
|
@@ -73763,7 +73837,7 @@ async function beginKnowledgeUpdate(projectRoot, value) {
|
|
|
73763
73837
|
...input.changes === undefined ? {} : { changes: input.changes }
|
|
73764
73838
|
};
|
|
73765
73839
|
const request = updateSchema.parse({ ...payload, revision: indexerProtocolDigest(payload) });
|
|
73766
|
-
await atomicWriteFile(
|
|
73840
|
+
await atomicWriteFile(join65(projectRoot, await revisionStoragePath(projectRoot)), `${JSON.stringify(request)}
|
|
73767
73841
|
`);
|
|
73768
73842
|
return {
|
|
73769
73843
|
outcome: "update-prepared",
|
|
@@ -73808,7 +73882,7 @@ async function completeKnowledgeUpdate(input) {
|
|
|
73808
73882
|
if (input.new_topics.length && !input.structure_approved) {
|
|
73809
73883
|
const { revision: _revision, ...rest } = request;
|
|
73810
73884
|
const payload = { ...rest, structure_proposal: { decisions: input.decisions, scope_summary: input.scope_summary, new_topics: input.new_topics } };
|
|
73811
|
-
await atomicWriteFile(
|
|
73885
|
+
await atomicWriteFile(join65(input.projectRoot, await revisionStoragePath(input.projectRoot)), `${JSON.stringify({ ...payload, revision: indexerProtocolDigest(payload) })}
|
|
73812
73886
|
`);
|
|
73813
73887
|
return { outcome: "structure-review-required" };
|
|
73814
73888
|
}
|
|
@@ -73845,7 +73919,7 @@ async function completeUpdateStructureReview(input) {
|
|
|
73845
73919
|
const { revision: _revision, structure_proposal: _proposal, ...rest } = request;
|
|
73846
73920
|
const payload = { ...rest, changes: `${rest.changes ?? ""}
|
|
73847
73921
|
Structure feedback: ${input.feedback}` };
|
|
73848
|
-
await atomicWriteFile(
|
|
73922
|
+
await atomicWriteFile(join65(input.projectRoot, await revisionStoragePath(input.projectRoot)), `${JSON.stringify({ ...payload, revision: indexerProtocolDigest(payload) })}
|
|
73849
73923
|
`);
|
|
73850
73924
|
return { outcome: "structure-adjustment-required" };
|
|
73851
73925
|
});
|
|
@@ -74018,15 +74092,15 @@ __export(exports_knowledgeMaintenance, {
|
|
|
74018
74092
|
cancelKnowledgeMaintenance: () => cancelKnowledgeMaintenance,
|
|
74019
74093
|
advanceKnowledgeMaintenance: () => advanceKnowledgeMaintenance
|
|
74020
74094
|
});
|
|
74021
|
-
import { readFile as
|
|
74022
|
-
import { join as
|
|
74095
|
+
import { readFile as readFile57, readdir as readdir16, rm as rm14 } from "node:fs/promises";
|
|
74096
|
+
import { join as join66 } from "node:path";
|
|
74023
74097
|
async function deliveryDigest(root) {
|
|
74024
|
-
const directory =
|
|
74098
|
+
const directory = join66(root, ".tmp/context-runtime/packages");
|
|
74025
74099
|
try {
|
|
74026
74100
|
const files = (await readdir16(directory)).filter((name2) => name2.endsWith(".json")).sort();
|
|
74027
74101
|
if (!files.length)
|
|
74028
74102
|
return indexerProtocolDigest(null);
|
|
74029
|
-
return indexerProtocolDigest(await Promise.all(files.map((name2) =>
|
|
74103
|
+
return indexerProtocolDigest(await Promise.all(files.map((name2) => readFile57(join66(directory, name2), "utf8"))));
|
|
74030
74104
|
} catch (error) {
|
|
74031
74105
|
if (error.code === "ENOENT")
|
|
74032
74106
|
return indexerProtocolDigest(null);
|
|
@@ -74125,7 +74199,7 @@ async function observeKnowledgeMaintenance(root) {
|
|
|
74125
74199
|
async function maintenanceRevision(root) {
|
|
74126
74200
|
const observed = await observeKnowledgeMaintenance(root);
|
|
74127
74201
|
const localInputs = observed.state.active ? {
|
|
74128
|
-
revision: await
|
|
74202
|
+
revision: await readFile57(join66(root, MAINTENANCE_ROOT, "revision.json"), "utf8").catch((error) => {
|
|
74129
74203
|
if (error.code === "ENOENT")
|
|
74130
74204
|
return null;
|
|
74131
74205
|
throw error;
|
|
@@ -74202,7 +74276,7 @@ async function finishMaintenanceRevision(root, outcome = "completed") {
|
|
|
74202
74276
|
outcome = state.active.completion_outcome;
|
|
74203
74277
|
state.active.phase = "finishing";
|
|
74204
74278
|
await saveMaintenance(root, state);
|
|
74205
|
-
await rm14(
|
|
74279
|
+
await rm14(join66(root, MAINTENANCE_ROOT, "revision.json"), { force: true });
|
|
74206
74280
|
state.completed.push({ id: state.active.input.id, input_digest: indexerProtocolDigest(state.active.input), outcome });
|
|
74207
74281
|
delete state.active;
|
|
74208
74282
|
await saveMaintenance(root, state);
|
|
@@ -74236,8 +74310,8 @@ async function discardMaintenanceDraft(root) {
|
|
|
74236
74310
|
const owned = new Set([...request?.batch_candidates ?? [], ...request?.candidate ? [request.candidate] : []].map((item) => item.candidate_id));
|
|
74237
74311
|
if (candidates.some((item) => !owned.has(item.candidate_id)))
|
|
74238
74312
|
throw new TypeError("Unrelated Candidates are present; no draft was discarded. Inspect the current review before retrying cancellation.");
|
|
74239
|
-
await rm14(
|
|
74240
|
-
await rm14(
|
|
74313
|
+
await rm14(join66(root, CANDIDATE_LEDGER_FILE), { force: true });
|
|
74314
|
+
await rm14(join66(root, MAINTENANCE_ROOT, "revision.json"), { force: true });
|
|
74241
74315
|
const { closeProjectWorkspace: closeProjectWorkspace2 } = await Promise.resolve().then(() => (init_close(), exports_close));
|
|
74242
74316
|
const { buildProjectPackages: buildProjectPackages2 } = await Promise.resolve().then(() => (init_packageBuilder(), exports_packageBuilder));
|
|
74243
74317
|
await closeProjectWorkspace2(root);
|
|
@@ -74275,8 +74349,8 @@ __export(exports_approvedRevision, {
|
|
|
74275
74349
|
assertApprovedRevisionBase: () => assertApprovedRevisionBase,
|
|
74276
74350
|
APPROVED_REVISION_PATH: () => APPROVED_REVISION_PATH
|
|
74277
74351
|
});
|
|
74278
|
-
import { readFile as
|
|
74279
|
-
import { join as
|
|
74352
|
+
import { readFile as readFile58, realpath as realpath8, rm as rm15 } from "node:fs/promises";
|
|
74353
|
+
import { join as join67, relative as relative19, isAbsolute as isAbsolute12 } from "node:path";
|
|
74280
74354
|
function requestDigest(input) {
|
|
74281
74355
|
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
74356
|
const ids = new Set(scopes?.map((scope2) => scope2.requirement_ref));
|
|
@@ -74314,7 +74388,7 @@ function revisionCandidateFingerprint(revision, markdown, sections) {
|
|
|
74314
74388
|
}
|
|
74315
74389
|
async function readApprovedRevision(projectRoot) {
|
|
74316
74390
|
try {
|
|
74317
|
-
return parseApprovedRevision(JSON.parse(await
|
|
74391
|
+
return parseApprovedRevision(JSON.parse(await readFile58(join67(projectRoot, await revisionStoragePath(projectRoot)), "utf8")));
|
|
74318
74392
|
} catch (error) {
|
|
74319
74393
|
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT")
|
|
74320
74394
|
return;
|
|
@@ -74373,16 +74447,16 @@ async function resolveApprovedRevisionAuthor(projectRoot, request) {
|
|
|
74373
74447
|
}
|
|
74374
74448
|
async function targetBytes(projectRoot, path2) {
|
|
74375
74449
|
const project = await realpath8(projectRoot);
|
|
74376
|
-
const root = await realpath8(
|
|
74450
|
+
const root = await realpath8(join67(projectRoot, "knowledge"));
|
|
74377
74451
|
const rootRelative = relative19(project, root);
|
|
74378
74452
|
if (isAbsolute12(rootRelative) || rootRelative === ".." || rootRelative.startsWith("../")) {
|
|
74379
74453
|
throw new TypeError("Approved knowledge directory leaves the Context workspace");
|
|
74380
74454
|
}
|
|
74381
|
-
const target = await realpath8(
|
|
74455
|
+
const target = await realpath8(join67(root, path2));
|
|
74382
74456
|
const rel = relative19(root, target);
|
|
74383
74457
|
if (isAbsolute12(rel) || rel === ".." || rel.startsWith("../"))
|
|
74384
74458
|
throw new TypeError("Approved revision target leaves knowledge/");
|
|
74385
|
-
return
|
|
74459
|
+
return readFile58(target, "utf8");
|
|
74386
74460
|
}
|
|
74387
74461
|
async function assertApprovedRevisionBase(projectRoot, request) {
|
|
74388
74462
|
let current;
|
|
@@ -74534,7 +74608,7 @@ ${import_yaml36.default.stringify({ ...import_yaml36.default.parse(fields), type
|
|
|
74534
74608
|
revision: requestDigest(payload)
|
|
74535
74609
|
});
|
|
74536
74610
|
if (input.persist !== false)
|
|
74537
|
-
await atomicWriteFile(
|
|
74611
|
+
await atomicWriteFile(join67(input.projectRoot, await revisionStoragePath(input.projectRoot)), `${JSON.stringify(request)}
|
|
74538
74612
|
`);
|
|
74539
74613
|
return {
|
|
74540
74614
|
status: "author-reopened",
|
|
@@ -74645,17 +74719,17 @@ async function completeApprovedRevision(input) {
|
|
|
74645
74719
|
const { prepareRevisionBatchContinuation: prepareRevisionBatchContinuation3 } = await Promise.resolve().then(() => (init_approvedRevisionBatch(), exports_approvedRevisionBatch));
|
|
74646
74720
|
const next2 = await prepareRevisionBatchContinuation3(input.projectRoot, request, request.batch_candidates ?? []);
|
|
74647
74721
|
if (next2 || request.batch_candidates?.length || request.build_pending) {
|
|
74648
|
-
await atomicWriteFile(
|
|
74722
|
+
await atomicWriteFile(join67(input.projectRoot, await revisionStoragePath(input.projectRoot)), `${JSON.stringify(next2 ?? { ...request, review_ready: true })}
|
|
74649
74723
|
`);
|
|
74650
74724
|
} else {
|
|
74651
74725
|
await advanceApprovedRevision(input.projectRoot, request);
|
|
74652
74726
|
}
|
|
74653
74727
|
return;
|
|
74654
74728
|
}
|
|
74655
|
-
const current = await
|
|
74729
|
+
const current = await readFile58(join67(input.projectRoot, await revisionStoragePath(input.projectRoot)), "utf8");
|
|
74656
74730
|
let previous2;
|
|
74657
74731
|
try {
|
|
74658
|
-
previous2 = await
|
|
74732
|
+
previous2 = await readFile58(join67(input.projectRoot, CANDIDATE_LEDGER_FILE), "utf8");
|
|
74659
74733
|
} catch (error) {
|
|
74660
74734
|
if (!(error && typeof error === "object" && ("code" in error) && error.code === "ENOENT"))
|
|
74661
74735
|
throw error;
|
|
@@ -74737,7 +74811,7 @@ async function advanceApprovedRevision(projectRoot, request, buildPending = fals
|
|
|
74737
74811
|
return;
|
|
74738
74812
|
const { readProductionStage: readProductionStage2 } = await Promise.resolve().then(() => (init_productionStageStore(), exports_productionStageStore));
|
|
74739
74813
|
if (await readProductionStage2(projectRoot)) {
|
|
74740
|
-
await rm15(
|
|
74814
|
+
await rm15(join67(projectRoot, await revisionStoragePath(projectRoot)), { force: true });
|
|
74741
74815
|
return;
|
|
74742
74816
|
}
|
|
74743
74817
|
const { clearCompletedLifecycle: clearCompletedLifecycle2 } = await Promise.resolve().then(() => (init_lifecycleCleanup(), exports_lifecycleCleanup));
|
|
@@ -74808,12 +74882,12 @@ async function reopenApprovedRevision(input) {
|
|
|
74808
74882
|
}))
|
|
74809
74883
|
} : {}
|
|
74810
74884
|
} };
|
|
74811
|
-
const current = await
|
|
74885
|
+
const current = await readFile58(join67(input.projectRoot, await revisionStoragePath(input.projectRoot)), "utf8");
|
|
74812
74886
|
const content3 = `${JSON.stringify({ ...payload, revision: requestDigest(payload) })}
|
|
74813
74887
|
`;
|
|
74814
74888
|
let ledger;
|
|
74815
74889
|
try {
|
|
74816
|
-
ledger = await
|
|
74890
|
+
ledger = await readFile58(join67(input.projectRoot, CANDIDATE_LEDGER_FILE), "utf8");
|
|
74817
74891
|
} catch (error) {
|
|
74818
74892
|
if (!(error && typeof error === "object" && ("code" in error) && error.code === "ENOENT"))
|
|
74819
74893
|
throw error;
|
|
@@ -80856,7 +80930,7 @@ var require_acorn_jsx = __commonJS((exports, module) => {
|
|
|
80856
80930
|
|
|
80857
80931
|
// src/project/documentRun.ts
|
|
80858
80932
|
import { existsSync as existsSync18 } from "node:fs";
|
|
80859
|
-
import { join as
|
|
80933
|
+
import { join as join70 } from "node:path";
|
|
80860
80934
|
function isDocumentPhase(phase) {
|
|
80861
80935
|
return phase.kind === "phase.capture.file" || phase.kind === "phase.capture.lark";
|
|
80862
80936
|
}
|
|
@@ -81038,7 +81112,7 @@ async function previewDocumentPhase(input) {
|
|
|
81038
81112
|
},
|
|
81039
81113
|
snapshot: {
|
|
81040
81114
|
manifest,
|
|
81041
|
-
exists: existsSync18(
|
|
81115
|
+
exists: existsSync18(join70(input.projectRoot, manifest))
|
|
81042
81116
|
},
|
|
81043
81117
|
sourceRefExamples: [
|
|
81044
81118
|
`${sourceRefBase}/<doc-locator>#span:<heading-hint> L<start>-<end>@<hash>`
|
|
@@ -81057,8 +81131,8 @@ var init_documentRun = __esm(() => {
|
|
|
81057
81131
|
});
|
|
81058
81132
|
|
|
81059
81133
|
// src/lib/atomicFileBatch.ts
|
|
81060
|
-
import { lstat as lstat8, mkdir as mkdir26, mkdtemp as mkdtemp3, rename as
|
|
81061
|
-
import { dirname as dirname32, join as
|
|
81134
|
+
import { lstat as lstat8, mkdir as mkdir26, mkdtemp as mkdtemp3, rename as rename7, rm as rm16, writeFile as writeFile21 } from "node:fs/promises";
|
|
81135
|
+
import { dirname as dirname32, join as join71, resolve as resolve23 } from "node:path";
|
|
81062
81136
|
async function existingFileKind(path2) {
|
|
81063
81137
|
try {
|
|
81064
81138
|
const stats = await lstat8(path2);
|
|
@@ -81088,9 +81162,9 @@ async function applyAtomicFileBatch(input) {
|
|
|
81088
81162
|
for (const path2 of writesByPath.keys())
|
|
81089
81163
|
removalPaths.delete(path2);
|
|
81090
81164
|
await mkdir26(input.transactionRoot, { recursive: true });
|
|
81091
|
-
const transactionDir = await mkdtemp3(
|
|
81092
|
-
const stagedRoot =
|
|
81093
|
-
const backupRoot =
|
|
81165
|
+
const transactionDir = await mkdtemp3(join71(input.transactionRoot, "batch-"));
|
|
81166
|
+
const stagedRoot = join71(transactionDir, "staged");
|
|
81167
|
+
const backupRoot = join71(transactionDir, "backup");
|
|
81094
81168
|
const writes = [...writesByPath.values()].sort((left, right) => left.path.localeCompare(right.path));
|
|
81095
81169
|
const affectedPaths = [...new Set([...writesByPath.keys(), ...removalPaths])].sort();
|
|
81096
81170
|
const staged = new Map;
|
|
@@ -81100,21 +81174,21 @@ async function applyAtomicFileBatch(input) {
|
|
|
81100
81174
|
try {
|
|
81101
81175
|
await mkdir26(stagedRoot, { recursive: true });
|
|
81102
81176
|
for (const [index2, write] of writes.entries()) {
|
|
81103
|
-
const path2 =
|
|
81104
|
-
await
|
|
81177
|
+
const path2 = join71(stagedRoot, String(index2));
|
|
81178
|
+
await writeFile21(path2, write.bytes);
|
|
81105
81179
|
staged.set(write.path, path2);
|
|
81106
81180
|
}
|
|
81107
81181
|
for (const [index2, path2] of affectedPaths.entries()) {
|
|
81108
81182
|
if (await existingFileKind(path2) === "missing")
|
|
81109
81183
|
continue;
|
|
81110
|
-
const backupPath =
|
|
81184
|
+
const backupPath = join71(backupRoot, String(index2));
|
|
81111
81185
|
await mkdir26(dirname32(backupPath), { recursive: true });
|
|
81112
|
-
await
|
|
81186
|
+
await rename7(path2, backupPath);
|
|
81113
81187
|
backups.set(path2, backupPath);
|
|
81114
81188
|
}
|
|
81115
81189
|
for (const write of writes) {
|
|
81116
81190
|
await mkdir26(dirname32(write.path), { recursive: true });
|
|
81117
|
-
await
|
|
81191
|
+
await rename7(staged.get(write.path), write.path);
|
|
81118
81192
|
installed.push(write.path);
|
|
81119
81193
|
}
|
|
81120
81194
|
} catch (error) {
|
|
@@ -81126,7 +81200,7 @@ async function applyAtomicFileBatch(input) {
|
|
|
81126
81200
|
}
|
|
81127
81201
|
for (const [path2, backupPath] of [...backups.entries()].reverse()) {
|
|
81128
81202
|
await mkdir26(dirname32(path2), { recursive: true });
|
|
81129
|
-
await
|
|
81203
|
+
await rename7(backupPath, path2).catch((rollbackError) => {
|
|
81130
81204
|
rollbackFailures.push(`restore ${path2}: ${String(rollbackError)}`);
|
|
81131
81205
|
});
|
|
81132
81206
|
}
|
|
@@ -81144,8 +81218,8 @@ var init_atomicFileBatch = () => {};
|
|
|
81144
81218
|
|
|
81145
81219
|
// src/project/documentManifestRecovery.ts
|
|
81146
81220
|
import { createHash as createHash20 } from "node:crypto";
|
|
81147
|
-
import { readFile as
|
|
81148
|
-
import { join as
|
|
81221
|
+
import { readFile as readFile61 } from "node:fs/promises";
|
|
81222
|
+
import { join as join72 } from "node:path";
|
|
81149
81223
|
function recoverBatchEntries(value, sourceType, sourceName) {
|
|
81150
81224
|
const [batch, module, ...rest] = sourceName.split("/");
|
|
81151
81225
|
if (batch === undefined || module === undefined || rest.length > 0 || !/^\d{8}$/u.test(batch))
|
|
@@ -81168,7 +81242,7 @@ function recoverBatchEntries(value, sourceType, sourceName) {
|
|
|
81168
81242
|
async function readDocumentManifestForCapture(input) {
|
|
81169
81243
|
let bytes;
|
|
81170
81244
|
try {
|
|
81171
|
-
bytes = await
|
|
81245
|
+
bytes = await readFile61(join72(input.projectRoot, input.manifestPath));
|
|
81172
81246
|
} catch (error) {
|
|
81173
81247
|
if (error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR")) {
|
|
81174
81248
|
return { current: null, previous: null };
|
|
@@ -81185,10 +81259,10 @@ async function readDocumentManifestForCapture(input) {
|
|
|
81185
81259
|
return { current: current2, previous: previous2 };
|
|
81186
81260
|
} catch (error) {
|
|
81187
81261
|
const digest6 = createHash20("sha256").update(bytes).digest("hex");
|
|
81188
|
-
const backup =
|
|
81262
|
+
const backup = join72(".tmp", "context-runtime", "recovery", "document-manifests", `${digest6}.json`);
|
|
81189
81263
|
await applyAtomicFileBatch({
|
|
81190
|
-
transactionRoot:
|
|
81191
|
-
writes: [{ path:
|
|
81264
|
+
transactionRoot: join72(input.projectRoot, ".tmp", "context-runtime", "recovery", "manifest-transactions"),
|
|
81265
|
+
writes: [{ path: join72(input.projectRoot, backup), bytes }]
|
|
81192
81266
|
});
|
|
81193
81267
|
const recovered = recoverBatchEntries(current2, input.sourceType, input.sourceName);
|
|
81194
81268
|
return {
|
|
@@ -82181,8 +82255,8 @@ var init_workflowProvider = __esm(() => {
|
|
|
82181
82255
|
});
|
|
82182
82256
|
|
|
82183
82257
|
// src/project/productionStageRefresh.ts
|
|
82184
|
-
import { readFile as
|
|
82185
|
-
import { join as
|
|
82258
|
+
import { readFile as readFile65 } from "node:fs/promises";
|
|
82259
|
+
import { join as join80 } from "node:path";
|
|
82186
82260
|
async function refreshProductionStageSources(projectRoot, stage) {
|
|
82187
82261
|
const affected = new Set(stage.gaps.map((gap) => gap.scope));
|
|
82188
82262
|
const unavailable = new Map;
|
|
@@ -82222,14 +82296,14 @@ Restore the authorized source and retry preparation.
|
|
|
82222
82296
|
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
82297
|
});
|
|
82224
82298
|
const directory = productionStageDirectory(stage.id);
|
|
82225
|
-
const contents2 = new Map([...sourceMaterials].map(([scope2, content3]) => [
|
|
82226
|
-
contents2.set(
|
|
82299
|
+
const contents2 = new Map([...sourceMaterials].map(([scope2, content3]) => [join80(directory, productionSourceFile(scope2)), content3]));
|
|
82300
|
+
contents2.set(join80(directory, "manifest.json"), `${JSON.stringify(updated)}
|
|
82227
82301
|
`);
|
|
82228
82302
|
const targets = [];
|
|
82229
82303
|
for (const [path2, content3] of contents2) {
|
|
82230
82304
|
let previous2;
|
|
82231
82305
|
try {
|
|
82232
|
-
previous2 = await
|
|
82306
|
+
previous2 = await readFile65(await safeProjectTarget(projectRoot, path2), "utf8");
|
|
82233
82307
|
} catch (error) {
|
|
82234
82308
|
if (error.code !== "ENOENT")
|
|
82235
82309
|
throw error;
|
|
@@ -82353,7 +82427,7 @@ var init_productionReport = __esm(() => {
|
|
|
82353
82427
|
});
|
|
82354
82428
|
|
|
82355
82429
|
// src/project/productionPlanningRoute.ts
|
|
82356
|
-
import { join as
|
|
82430
|
+
import { join as join81 } from "node:path";
|
|
82357
82431
|
async function productionPlanningRoute(input, stage) {
|
|
82358
82432
|
const request = stage ? undefined : await productionPlanningRequest(input.projectRoot);
|
|
82359
82433
|
const present = !!stage || !!request;
|
|
@@ -82391,7 +82465,7 @@ async function productionPlanningRoute(input, stage) {
|
|
|
82391
82465
|
id: `production/${stage.id}/planning`,
|
|
82392
82466
|
kind: "context-view",
|
|
82393
82467
|
media_type: "text/markdown",
|
|
82394
|
-
path:
|
|
82468
|
+
path: join81(input.projectRoot, productionStageDirectory(stage.id), "planning.md"),
|
|
82395
82469
|
read_state: "read-required"
|
|
82396
82470
|
}] : []
|
|
82397
82471
|
],
|
|
@@ -82410,7 +82484,7 @@ var init_productionPlanningRoute = __esm(() => {
|
|
|
82410
82484
|
|
|
82411
82485
|
// src/project/productionWorkflowRoute.ts
|
|
82412
82486
|
import { existsSync as existsSync24 } from "node:fs";
|
|
82413
|
-
import { join as
|
|
82487
|
+
import { join as join82 } from "node:path";
|
|
82414
82488
|
async function productionWorkflowRoute(input) {
|
|
82415
82489
|
const stage = await readProductionStage(input.projectRoot);
|
|
82416
82490
|
if (!stage || !stage.planning_complete)
|
|
@@ -82428,7 +82502,7 @@ async function productionWorkflowRoute(input) {
|
|
|
82428
82502
|
const selected = new Set(dispatch.batches.flatMap((batch) => batch.tasks));
|
|
82429
82503
|
const context = { workspace: input.projectRoot, authorities: [...input.authorities], facts: { production: {
|
|
82430
82504
|
report_approved: stage.report_approved,
|
|
82431
|
-
prepared: !dispatch.batches.length || existsSync24(
|
|
82505
|
+
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
82506
|
writing_complete: dispatch.batches.length === 0,
|
|
82433
82507
|
complete: dispatch.state === "ended",
|
|
82434
82508
|
review_clear: rejected.length === 0,
|
|
@@ -82445,7 +82519,7 @@ async function productionWorkflowRoute(input) {
|
|
|
82445
82519
|
const resolved = await resolveRoute(provider, "indexer", "production", primary.routeId, context, evaluated.evaluation.revision);
|
|
82446
82520
|
const report = resolved.node === "confirm-production-report";
|
|
82447
82521
|
if (report)
|
|
82448
|
-
await writeProductionProjection(input.projectRoot,
|
|
82522
|
+
await writeProductionProjection(input.projectRoot, join82(directory, "plan.md"), productionPlanMarkdown(stage));
|
|
82449
82523
|
const prepare = resolved.node === "prepare-production-stage";
|
|
82450
82524
|
const writing = resolved.node === "work-production-stage";
|
|
82451
82525
|
const repair = resolved.node === "repair-production-articles";
|
|
@@ -82460,7 +82534,7 @@ async function productionWorkflowRoute(input) {
|
|
|
82460
82534
|
id: `production/${stage.id}/${report ? "plan" : "stage"}`,
|
|
82461
82535
|
kind: "context-view",
|
|
82462
82536
|
media_type: "text/markdown",
|
|
82463
|
-
path:
|
|
82537
|
+
path: join82(input.projectRoot, directory, path3),
|
|
82464
82538
|
read_state: "read-required"
|
|
82465
82539
|
});
|
|
82466
82540
|
if (report || writing)
|
|
@@ -82471,18 +82545,18 @@ async function productionWorkflowRoute(input) {
|
|
|
82471
82545
|
id: `production/${stage.id}/planning`,
|
|
82472
82546
|
kind: "context-view",
|
|
82473
82547
|
media_type: "text/markdown",
|
|
82474
|
-
path:
|
|
82548
|
+
path: join82(input.projectRoot, directory, "planning.md"),
|
|
82475
82549
|
read_state: "read-required"
|
|
82476
82550
|
});
|
|
82477
82551
|
}
|
|
82478
82552
|
if (repair) {
|
|
82479
|
-
await writeProductionProjection(input.projectRoot,
|
|
82553
|
+
await writeProductionProjection(input.projectRoot, join82(directory, "repair.md"), [
|
|
82480
82554
|
"# Revise rejected articles",
|
|
82481
82555
|
"",
|
|
82482
82556
|
...rejected.map((candidate) => `- ${candidate.path}: ${candidate.review.title}`),
|
|
82483
82557
|
"",
|
|
82484
82558
|
"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 ${
|
|
82559
|
+
`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
82560
|
"Once issued, repair the affected sections through the existing edits submission. Unchanged sections and references do not need resubmission.",
|
|
82487
82561
|
""
|
|
82488
82562
|
].join(`
|
|
@@ -82491,7 +82565,7 @@ async function productionWorkflowRoute(input) {
|
|
|
82491
82565
|
id: `production/${stage.id}/repair`,
|
|
82492
82566
|
kind: "context-view",
|
|
82493
82567
|
media_type: "text/markdown",
|
|
82494
|
-
path:
|
|
82568
|
+
path: join82(input.projectRoot, directory, "repair.md"),
|
|
82495
82569
|
read_state: "read-required"
|
|
82496
82570
|
});
|
|
82497
82571
|
}
|
|
@@ -82582,7 +82656,7 @@ var init_knowledgeMaintenanceRoute = __esm(() => {
|
|
|
82582
82656
|
});
|
|
82583
82657
|
|
|
82584
82658
|
// src/project/approvedRevisionContext.ts
|
|
82585
|
-
import { readFile as
|
|
82659
|
+
import { readFile as readFile66 } from "node:fs/promises";
|
|
82586
82660
|
async function approvedRevisionContext(root, target) {
|
|
82587
82661
|
const registry2 = await readProductionRequirements(root);
|
|
82588
82662
|
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 +82667,7 @@ async function approvedRevisionContext(root, target) {
|
|
|
82593
82667
|
const type = source_ref.slice(0, separator);
|
|
82594
82668
|
const name3 = source_ref.slice(separator + 1);
|
|
82595
82669
|
const path2 = await assertManagedDocumentPath(root, type, name3);
|
|
82596
|
-
const markdown = await
|
|
82670
|
+
const markdown = await readFile66(path2, "utf8");
|
|
82597
82671
|
const changes = type === "sessions" ? readSessionChanges(markdown) : undefined;
|
|
82598
82672
|
return {
|
|
82599
82673
|
source_ref,
|
|
@@ -87248,8 +87322,8 @@ var init_larkResourceCommand = __esm(() => {
|
|
|
87248
87322
|
|
|
87249
87323
|
// src/lib/larkResourceMaterialization.ts
|
|
87250
87324
|
import { createHash as createHash26 } from "node:crypto";
|
|
87251
|
-
import { mkdtemp as mkdtemp4, readFile as
|
|
87252
|
-
import { extname as extname13, join as
|
|
87325
|
+
import { mkdtemp as mkdtemp4, readFile as readFile69, readdir as readdir20, rm as rm19 } from "node:fs/promises";
|
|
87326
|
+
import { extname as extname13, join as join89 } from "node:path";
|
|
87253
87327
|
import { tmpdir } from "node:os";
|
|
87254
87328
|
function countByKind(items, status) {
|
|
87255
87329
|
const counts2 = new Map;
|
|
@@ -87354,10 +87428,10 @@ function findBooleanField(value, name3) {
|
|
|
87354
87428
|
}
|
|
87355
87429
|
async function downloadedFile(input) {
|
|
87356
87430
|
if (input.localPath !== undefined) {
|
|
87357
|
-
const bytes = await
|
|
87431
|
+
const bytes = await readFile69(input.localPath);
|
|
87358
87432
|
return { path: input.localPath, bytes, mediaType: mediaTypeFor(input.localPath, bytes) };
|
|
87359
87433
|
}
|
|
87360
|
-
const tempRoot = await mkdtemp4(
|
|
87434
|
+
const tempRoot = await mkdtemp4(join89(tmpdir(), "context-lark-resource-"));
|
|
87361
87435
|
try {
|
|
87362
87436
|
await runLarkResourceCommand(input.runner, [
|
|
87363
87437
|
"docs",
|
|
@@ -87378,7 +87452,7 @@ async function downloadedFile(input) {
|
|
|
87378
87452
|
if (entries2.length !== 1)
|
|
87379
87453
|
throw new Error(`media download produced ${entries2.length} files, expected exactly one`);
|
|
87380
87454
|
const path3 = entries2[0]?.name ?? "resource.bin";
|
|
87381
|
-
const bytes = await
|
|
87455
|
+
const bytes = await readFile69(join89(tempRoot, path3));
|
|
87382
87456
|
return { path: path3, bytes, mediaType: mediaTypeFor(path3, bytes) };
|
|
87383
87457
|
} finally {
|
|
87384
87458
|
await rm19(tempRoot, { recursive: true, force: true });
|
|
@@ -87469,9 +87543,9 @@ async function sheetMaterialization(resource, runner2, identity) {
|
|
|
87469
87543
|
const sheetId = resource.attributes["sheet-id"];
|
|
87470
87544
|
if (token === undefined || sheetId === undefined)
|
|
87471
87545
|
throw new Error("embedded Sheet requires token and sheet-id");
|
|
87472
|
-
const tempRoot = await mkdtemp4(
|
|
87546
|
+
const tempRoot = await mkdtemp4(join89(tmpdir(), "context-lark-sheet-"));
|
|
87473
87547
|
try {
|
|
87474
|
-
const outputPath =
|
|
87548
|
+
const outputPath = join89(tempRoot, "sheet.json");
|
|
87475
87549
|
const stdout = await runLarkResourceCommand(runner2, [
|
|
87476
87550
|
"sheets",
|
|
87477
87551
|
"+csv-get",
|
|
@@ -87491,7 +87565,7 @@ async function sheetMaterialization(resource, runner2, identity) {
|
|
|
87491
87565
|
if (findBooleanField(receipt2, "truncated") === true || findBooleanField(receipt2, "complete") === false) {
|
|
87492
87566
|
throw new Error("embedded Sheet read was truncated");
|
|
87493
87567
|
}
|
|
87494
|
-
const payload = JSON.parse(await
|
|
87568
|
+
const payload = JSON.parse(await readFile69(outputPath, "utf8"));
|
|
87495
87569
|
const csv = findStringField(payload, new Set(["annotated_csv", "csv", "content", "text"]));
|
|
87496
87570
|
if (csv === undefined)
|
|
87497
87571
|
throw new Error("embedded Sheet response has no CSV payload");
|
|
@@ -87627,7 +87701,7 @@ async function whiteboardMaterialization(resource, runner2, identity) {
|
|
|
87627
87701
|
if (token === undefined)
|
|
87628
87702
|
throw new Error(`${resource.kind} has no whiteboard token`);
|
|
87629
87703
|
const preview = await downloadedFile({ runner: runner2, identity, token, type: "whiteboard" });
|
|
87630
|
-
const tempRoot = await mkdtemp4(
|
|
87704
|
+
const tempRoot = await mkdtemp4(join89(tmpdir(), "context-lark-whiteboard-"));
|
|
87631
87705
|
let rawPayload;
|
|
87632
87706
|
try {
|
|
87633
87707
|
await runLarkResourceCommand(runner2, [
|
|
@@ -87645,7 +87719,7 @@ async function whiteboardMaterialization(resource, runner2, identity) {
|
|
|
87645
87719
|
"--format",
|
|
87646
87720
|
"json"
|
|
87647
87721
|
], { cwd: tempRoot });
|
|
87648
|
-
rawPayload = JSON.parse(await
|
|
87722
|
+
rawPayload = JSON.parse(await readFile69(join89(tempRoot, "raw.json"), "utf8"));
|
|
87649
87723
|
} finally {
|
|
87650
87724
|
await rm19(tempRoot, { recursive: true, force: true });
|
|
87651
87725
|
}
|
|
@@ -88490,8 +88564,8 @@ var init_sensitiveSourceLiteral = __esm(() => {
|
|
|
88490
88564
|
var LARK_DOCUMENT_NORMALIZER_VERSION = "lark-document-normalizer.v1";
|
|
88491
88565
|
|
|
88492
88566
|
// src/project/documentCaptureLark.ts
|
|
88493
|
-
import { readdir as readdir21, readFile as
|
|
88494
|
-
import { basename as basename10, extname as extname14, join as
|
|
88567
|
+
import { readdir as readdir21, readFile as readFile70 } from "node:fs/promises";
|
|
88568
|
+
import { basename as basename10, extname as extname14, join as join90 } from "node:path";
|
|
88495
88569
|
function titleFromMarkdown2(markdown, fallbackPath) {
|
|
88496
88570
|
const heading2 = markdown.split(`
|
|
88497
88571
|
`).find((line) => /^#\s+\S/u.test(line));
|
|
@@ -88510,7 +88584,7 @@ function countLines3(markdown) {
|
|
|
88510
88584
|
}
|
|
88511
88585
|
async function fileContentMatches(path3, content3) {
|
|
88512
88586
|
try {
|
|
88513
|
-
const current2 = await
|
|
88587
|
+
const current2 = await readFile70(path3);
|
|
88514
88588
|
const expected = typeof content3 === "string" ? Buffer.from(content3, "utf8") : Buffer.from(content3);
|
|
88515
88589
|
return current2.equals(expected);
|
|
88516
88590
|
} catch {
|
|
@@ -88518,7 +88592,7 @@ async function fileContentMatches(path3, content3) {
|
|
|
88518
88592
|
}
|
|
88519
88593
|
}
|
|
88520
88594
|
function sourceManifestPath2(entry) {
|
|
88521
|
-
return entry.snapshot?.manifest ??
|
|
88595
|
+
return entry.snapshot?.manifest ?? join90(entry.materializedAt, "manifest.json");
|
|
88522
88596
|
}
|
|
88523
88597
|
function larkRuntimeError(message, detail) {
|
|
88524
88598
|
return new ContextError(ExitCode.ExternalToolError, message, {
|
|
@@ -88644,7 +88718,7 @@ function assetManifestEntry(asset, assetRoot) {
|
|
|
88644
88718
|
};
|
|
88645
88719
|
}
|
|
88646
88720
|
async function listSnapshotAssetFiles(root2, assetRoot) {
|
|
88647
|
-
const assetsRoot =
|
|
88721
|
+
const assetsRoot = join90(root2, assetRoot);
|
|
88648
88722
|
const files = [];
|
|
88649
88723
|
const visit4 = async (dir, prefix = assetRoot) => {
|
|
88650
88724
|
let entries2;
|
|
@@ -88657,7 +88731,7 @@ async function listSnapshotAssetFiles(root2, assetRoot) {
|
|
|
88657
88731
|
}
|
|
88658
88732
|
for (const entry of entries2) {
|
|
88659
88733
|
const relPath = `${prefix}/${entry.name}`;
|
|
88660
|
-
const absolutePath =
|
|
88734
|
+
const absolutePath = join90(dir, entry.name);
|
|
88661
88735
|
if (entry.isDirectory()) {
|
|
88662
88736
|
await visit4(absolutePath, relPath);
|
|
88663
88737
|
continue;
|
|
@@ -88672,7 +88746,7 @@ async function listSnapshotAssetFiles(root2, assetRoot) {
|
|
|
88672
88746
|
}
|
|
88673
88747
|
async function staleSnapshotAssetPaths(input) {
|
|
88674
88748
|
const existingPaths = await listSnapshotAssetFiles(input.materializedAtAbsPath, input.assetRoot);
|
|
88675
|
-
return existingPaths.filter((path3) => !input.currentPaths.has(path3)).map((path3) =>
|
|
88749
|
+
return existingPaths.filter((path3) => !input.currentPaths.has(path3)).map((path3) => join90(input.materializedAtAbsPath, path3));
|
|
88676
88750
|
}
|
|
88677
88751
|
function normalizeLarkError(error, sourceName) {
|
|
88678
88752
|
if (error instanceof ContextError)
|
|
@@ -88780,9 +88854,9 @@ async function runCaptureLarkPhaseUnlocked(input) {
|
|
|
88780
88854
|
locator
|
|
88781
88855
|
}];
|
|
88782
88856
|
const manifestPath = sourceManifestPath2(entry);
|
|
88783
|
-
const manifestAbsPath =
|
|
88857
|
+
const manifestAbsPath = join90(input.projectRoot, manifestPath);
|
|
88784
88858
|
const materializedAt = entry.materializedAt;
|
|
88785
|
-
const materializedAtAbsPath =
|
|
88859
|
+
const materializedAtAbsPath = join90(input.projectRoot, materializedAt);
|
|
88786
88860
|
const manifest = createDocumentSnapshotManifest({
|
|
88787
88861
|
sourceType: "lark",
|
|
88788
88862
|
sourceName: resolved.sourceName,
|
|
@@ -88816,13 +88890,13 @@ async function runCaptureLarkPhaseUnlocked(input) {
|
|
|
88816
88890
|
}));
|
|
88817
88891
|
try {
|
|
88818
88892
|
const requestedWrites = [{
|
|
88819
|
-
path:
|
|
88893
|
+
path: join90(materializedAtAbsPath, documentPath),
|
|
88820
88894
|
bytes: normalized
|
|
88821
88895
|
}];
|
|
88822
88896
|
for (const asset of assets) {
|
|
88823
88897
|
if (asset.bytes !== undefined) {
|
|
88824
88898
|
requestedWrites.push({
|
|
88825
|
-
path:
|
|
88899
|
+
path: join90(materializedAtAbsPath, asset.entry.path),
|
|
88826
88900
|
bytes: asset.bytes
|
|
88827
88901
|
});
|
|
88828
88902
|
}
|
|
@@ -88839,7 +88913,7 @@ async function runCaptureLarkPhaseUnlocked(input) {
|
|
|
88839
88913
|
currentPaths: new Set(assets.filter((asset) => asset.bytes !== undefined).map((asset) => asset.entry.path))
|
|
88840
88914
|
});
|
|
88841
88915
|
await applyAtomicFileBatch({
|
|
88842
|
-
transactionRoot:
|
|
88916
|
+
transactionRoot: join90(input.projectRoot, ".tmp", "context-runtime", "capture-transactions"),
|
|
88843
88917
|
writes,
|
|
88844
88918
|
removals
|
|
88845
88919
|
});
|
|
@@ -88985,7 +89059,7 @@ __export(exports_articleRetirement, {
|
|
|
88985
89059
|
retireArticles: () => retireArticles,
|
|
88986
89060
|
articleRetirementSchema: () => articleRetirementSchema
|
|
88987
89061
|
});
|
|
88988
|
-
import { readFile as
|
|
89062
|
+
import { readFile as readFile76, readdir as readdir22 } from "node:fs/promises";
|
|
88989
89063
|
import { posix as posix10 } from "node:path";
|
|
88990
89064
|
function rebuildInput(revision) {
|
|
88991
89065
|
return JSON.stringify({ id: `retirement-${revision.slice(7)}`, operation: "rebuild", timing: "priority", targets: [] });
|
|
@@ -89006,7 +89080,7 @@ function invalid2(reason, message, details = {}) {
|
|
|
89006
89080
|
}
|
|
89007
89081
|
async function text9(root2, path3) {
|
|
89008
89082
|
try {
|
|
89009
|
-
return await
|
|
89083
|
+
return await readFile76(await safeProjectTarget(root2, path3), "utf8");
|
|
89010
89084
|
} catch (error) {
|
|
89011
89085
|
if (error.code === "ENOENT")
|
|
89012
89086
|
return;
|
|
@@ -89268,8 +89342,8 @@ __export(exports_writeLockRecovery, {
|
|
|
89268
89342
|
recoverWriterLock: () => recoverWriterLock,
|
|
89269
89343
|
inspectWriterLock: () => inspectWriterLock
|
|
89270
89344
|
});
|
|
89271
|
-
import { lstat as lstat10, mkdir as mkdir33, readFile as
|
|
89272
|
-
import { join as
|
|
89345
|
+
import { lstat as lstat10, mkdir as mkdir33, readFile as readFile77, readdir as readdir23, rename as rename8, rmdir as rmdir2 } from "node:fs/promises";
|
|
89346
|
+
import { join as join95 } from "node:path";
|
|
89273
89347
|
import { createHash as createHash28, randomUUID as randomUUID7 } from "node:crypto";
|
|
89274
89348
|
async function inspectWriterLock(root2) {
|
|
89275
89349
|
const path3 = await safeProjectTarget(root2, lockRelative);
|
|
@@ -89284,7 +89358,7 @@ async function inspectWriterLock(root2) {
|
|
|
89284
89358
|
if (!stat10.isDirectory() || stat10.isSymbolicLink())
|
|
89285
89359
|
throw new Error("Writer lock must be a real directory.");
|
|
89286
89360
|
const ownerPath = await safeProjectTarget(root2, `${lockRelative}/owner.json`);
|
|
89287
|
-
const bytes = await
|
|
89361
|
+
const bytes = await readFile77(ownerPath, "utf8");
|
|
89288
89362
|
const owner = JSON.parse(bytes);
|
|
89289
89363
|
if (owner.protocol !== "context.project-write-lock.v1" || !Number.isSafeInteger(owner.pid) || owner.pid <= 0) {
|
|
89290
89364
|
throw new Error("Writer lock owner is invalid; preserve the lock for diagnosis.");
|
|
@@ -89316,8 +89390,8 @@ async function recoverWriterLock(input) {
|
|
|
89316
89390
|
};
|
|
89317
89391
|
if (input.plan_digest !== before.digest)
|
|
89318
89392
|
throw new Error("Writer lock changed; preview recovery again.");
|
|
89319
|
-
const path3 =
|
|
89320
|
-
const guard =
|
|
89393
|
+
const path3 = join95(input.projectRoot, lockRelative);
|
|
89394
|
+
const guard = join95(path3, ".recovery");
|
|
89321
89395
|
await mkdir33(guard);
|
|
89322
89396
|
let archived = false;
|
|
89323
89397
|
try {
|
|
@@ -89328,7 +89402,7 @@ async function recoverWriterLock(input) {
|
|
|
89328
89402
|
if (names.some((name3) => name3 !== "owner.json" && name3 !== ".recovery"))
|
|
89329
89403
|
throw new Error("Unexpected lock contents; preserve for diagnosis.");
|
|
89330
89404
|
const archive = `.tmp/context-runtime/locks/recovered-write-${randomUUID7()}.lock`;
|
|
89331
|
-
await
|
|
89405
|
+
await rename8(path3, join95(input.projectRoot, archive));
|
|
89332
89406
|
archived = true;
|
|
89333
89407
|
return { action: "writer-lock-recovered", archived_lock: archive, next: "context task recover --format json" };
|
|
89334
89408
|
} finally {
|
|
@@ -89352,12 +89426,12 @@ __export(exports_taskRecovery, {
|
|
|
89352
89426
|
RECOVERY_COMMAND: () => RECOVERY_COMMAND
|
|
89353
89427
|
});
|
|
89354
89428
|
import { existsSync as existsSync26 } from "node:fs";
|
|
89355
|
-
import { dirname as dirname41, join as
|
|
89356
|
-
import { lstat as lstat11, readdir as readdir24, readFile as
|
|
89429
|
+
import { dirname as dirname41, join as join96 } from "node:path";
|
|
89430
|
+
import { lstat as lstat11, readdir as readdir24, readFile as readFile78 } from "node:fs/promises";
|
|
89357
89431
|
async function recoveryText(root2, path3) {
|
|
89358
89432
|
const target = await safeProjectTarget(root2, path3);
|
|
89359
89433
|
try {
|
|
89360
|
-
return await
|
|
89434
|
+
return await readFile78(target, "utf8");
|
|
89361
89435
|
} catch (error) {
|
|
89362
89436
|
if (error.code === "ENOENT")
|
|
89363
89437
|
return;
|
|
@@ -89370,7 +89444,7 @@ async function recoveryJournals(root2) {
|
|
|
89370
89444
|
await safeProjectTarget(root2, path3);
|
|
89371
89445
|
let stat10;
|
|
89372
89446
|
try {
|
|
89373
|
-
stat10 = await lstat11(
|
|
89447
|
+
stat10 = await lstat11(join96(root2, path3));
|
|
89374
89448
|
} catch (error) {
|
|
89375
89449
|
if (error.code === "ENOENT")
|
|
89376
89450
|
return;
|
|
@@ -89381,7 +89455,7 @@ async function recoveryJournals(root2) {
|
|
|
89381
89455
|
if (stat10.isDirectory()) {
|
|
89382
89456
|
if (depth > 3)
|
|
89383
89457
|
throw new TypeError("Unexpected transaction directory depth; preserve it for diagnosis.");
|
|
89384
|
-
for (const name3 of (await readdir24(
|
|
89458
|
+
for (const name3 of (await readdir24(join96(root2, path3))).sort())
|
|
89385
89459
|
await visit4(`${path3}/${name3}`, depth + 1);
|
|
89386
89460
|
} else if (stat10.isFile())
|
|
89387
89461
|
entries2.push({ path: path3, digest: indexerProtocolDigest(await recoveryText(root2, path3)) });
|
|
@@ -89393,8 +89467,8 @@ function recoveryResources() {
|
|
|
89393
89467
|
try {
|
|
89394
89468
|
const root2 = dirname41(contextWorkflowProviderPath());
|
|
89395
89469
|
const resources = {
|
|
89396
|
-
skill:
|
|
89397
|
-
issue_template:
|
|
89470
|
+
skill: join96(root2, "skills/recover-workspace/SKILL.md"),
|
|
89471
|
+
issue_template: join96(root2, "resources/templates/recovery-issue.md")
|
|
89398
89472
|
};
|
|
89399
89473
|
if (!Object.values(resources).every((path3) => existsSync26(path3)))
|
|
89400
89474
|
throw new Error("Recovery resources are absent from this Provider.");
|
|
@@ -89479,8 +89553,8 @@ var exports_taskLocalSourceAdjustment = {};
|
|
|
89479
89553
|
__export(exports_taskLocalSourceAdjustment, {
|
|
89480
89554
|
adjustLocalRevisionSources: () => adjustLocalRevisionSources
|
|
89481
89555
|
});
|
|
89482
|
-
import { readFile as
|
|
89483
|
-
import { join as
|
|
89556
|
+
import { readFile as readFile79 } from "node:fs/promises";
|
|
89557
|
+
import { join as join97 } from "node:path";
|
|
89484
89558
|
async function adjustLocalRevisionSources(root2, input) {
|
|
89485
89559
|
const { readMaintenance: readMaintenance2 } = await Promise.resolve().then(() => (init_maintenanceStorage(), exports_maintenanceStorage));
|
|
89486
89560
|
if ((await readMaintenance2(root2)).active && await readProductionStage(root2))
|
|
@@ -89504,7 +89578,7 @@ async function adjustLocalRevisionSources(root2, input) {
|
|
|
89504
89578
|
if (input.refresh && (!current2.refresh_sources || indexerProtocolDigest([...current2.refresh_sources].sort()) !== indexerProtocolDigest([...selected].sort()))) {
|
|
89505
89579
|
throw new TypeError("No matching acquisition adjustment exists. Run task adjust without refresh first.");
|
|
89506
89580
|
}
|
|
89507
|
-
const raw = await
|
|
89581
|
+
const raw = await readFile79(join97(root2, await revisionStoragePath(root2)), "utf8");
|
|
89508
89582
|
let next2;
|
|
89509
89583
|
const discardIds = new Set;
|
|
89510
89584
|
if (!input.refresh) {
|
|
@@ -89607,7 +89681,7 @@ ${input.instruction}` : revision.instruction
|
|
|
89607
89681
|
content: content3
|
|
89608
89682
|
}];
|
|
89609
89683
|
if (discardIds.size > 0) {
|
|
89610
|
-
const ledger = await
|
|
89684
|
+
const ledger = await readFile79(join97(root2, CANDIDATE_LEDGER_FILE), "utf8").catch((error) => {
|
|
89611
89685
|
if (error.code === "ENOENT")
|
|
89612
89686
|
return;
|
|
89613
89687
|
throw error;
|
|
@@ -89729,7 +89803,7 @@ var init_taskSourceAdjustment = __esm(() => {
|
|
|
89729
89803
|
});
|
|
89730
89804
|
|
|
89731
89805
|
// src/project/managedDocumentImport.ts
|
|
89732
|
-
import { readFile as
|
|
89806
|
+
import { readFile as readFile85 } from "node:fs/promises";
|
|
89733
89807
|
async function importManagedDocument(projectRoot, value) {
|
|
89734
89808
|
const input = inputSchema.parse(value);
|
|
89735
89809
|
if (input.type !== "sessions" && input.changes !== undefined)
|
|
@@ -89738,7 +89812,7 @@ async function importManagedDocument(projectRoot, value) {
|
|
|
89738
89812
|
const path3 = await assertManagedDocumentPath(projectRoot, input.type, input.name);
|
|
89739
89813
|
let previous3;
|
|
89740
89814
|
try {
|
|
89741
|
-
previous3 = await
|
|
89815
|
+
previous3 = await readFile85(path3, "utf8");
|
|
89742
89816
|
} catch (error) {
|
|
89743
89817
|
if (!(error && typeof error === "object" && ("code" in error) && error.code === "ENOENT"))
|
|
89744
89818
|
throw error;
|
|
@@ -89785,14 +89859,14 @@ var init_managedDocumentImport = __esm(() => {
|
|
|
89785
89859
|
});
|
|
89786
89860
|
|
|
89787
89861
|
// src/project/larkDocumentImport.ts
|
|
89788
|
-
import { readFile as
|
|
89862
|
+
import { readFile as readFile86 } from "node:fs/promises";
|
|
89789
89863
|
async function importLarkDocument(projectRoot, value) {
|
|
89790
89864
|
const input = schema3.parse(value);
|
|
89791
89865
|
const responsePages = [];
|
|
89792
89866
|
for (const path3 of input.response_files) {
|
|
89793
89867
|
assertActionInputWorkspace(projectRoot, path3);
|
|
89794
89868
|
const { resolve: resolve8 } = await import("node:path");
|
|
89795
|
-
responsePages.push(await
|
|
89869
|
+
responsePages.push(await readFile86(resolve8(projectRoot, path3), "utf8"));
|
|
89796
89870
|
}
|
|
89797
89871
|
const mediaFiles = {};
|
|
89798
89872
|
for (const [token, path3] of Object.entries(input.media_files ?? {})) {
|
|
@@ -89860,11 +89934,11 @@ var exports_managedDocumentRename = {};
|
|
|
89860
89934
|
__export(exports_managedDocumentRename, {
|
|
89861
89935
|
renameManagedDocument: () => renameManagedDocument
|
|
89862
89936
|
});
|
|
89863
|
-
import { readFile as
|
|
89864
|
-
import { join as
|
|
89937
|
+
import { readFile as readFile87 } from "node:fs/promises";
|
|
89938
|
+
import { join as join105, posix as posix11 } from "node:path";
|
|
89865
89939
|
async function optionalText2(path3) {
|
|
89866
89940
|
try {
|
|
89867
|
-
return await
|
|
89941
|
+
return await readFile87(path3, "utf8");
|
|
89868
89942
|
} catch (error) {
|
|
89869
89943
|
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT")
|
|
89870
89944
|
return;
|
|
@@ -89948,7 +90022,7 @@ async function renameManagedDocument(input) {
|
|
|
89948
90022
|
if (path3.split("/").includes("..") || path3.startsWith("/"))
|
|
89949
90023
|
throw new TypeError("Source references contain an unsafe knowledge path; repair it before renaming.");
|
|
89950
90024
|
await safeProjectTarget(input.projectRoot, path3);
|
|
89951
|
-
const before = await optionalText2(
|
|
90025
|
+
const before = await optionalText2(join105(input.projectRoot, path3));
|
|
89952
90026
|
if (before === undefined)
|
|
89953
90027
|
continue;
|
|
89954
90028
|
let after;
|
|
@@ -90037,7 +90111,7 @@ var init_managedDocumentRename = __esm(() => {
|
|
|
90037
90111
|
|
|
90038
90112
|
// src/cli.ts
|
|
90039
90113
|
import { existsSync as existsSync36, realpathSync as realpathSync3 } from "node:fs";
|
|
90040
|
-
import { dirname as dirname48, join as
|
|
90114
|
+
import { dirname as dirname48, join as join109 } from "node:path";
|
|
90041
90115
|
import { fileURLToPath as fileURLToPath10, pathToFileURL as pathToFileURL3 } from "node:url";
|
|
90042
90116
|
|
|
90043
90117
|
// ../../node_modules/.bun/commander@11.1.0/node_modules/commander/esm.mjs
|
|
@@ -90092,7 +90166,7 @@ init_dist();
|
|
|
90092
90166
|
init_cliFeedback();
|
|
90093
90167
|
init_errors3();
|
|
90094
90168
|
init_exitCode();
|
|
90095
|
-
import { join as
|
|
90169
|
+
import { join as join87 } from "node:path";
|
|
90096
90170
|
|
|
90097
90171
|
// src/project/status.ts
|
|
90098
90172
|
init_productionPlanning();
|
|
@@ -90103,13 +90177,13 @@ init_approvedRevisionBatch();
|
|
|
90103
90177
|
init_revisionDelivery();
|
|
90104
90178
|
init_workspacePreparation();
|
|
90105
90179
|
init_src2();
|
|
90106
|
-
import { join as
|
|
90180
|
+
import { join as join83 } from "node:path";
|
|
90107
90181
|
|
|
90108
90182
|
// src/project/statusReaders.ts
|
|
90109
90183
|
init_commandReadCache();
|
|
90110
90184
|
init_errors3();
|
|
90111
90185
|
import { existsSync as existsSync22, readFileSync as readFileSync8 } from "node:fs";
|
|
90112
|
-
import { join as
|
|
90186
|
+
import { join as join79 } from "node:path";
|
|
90113
90187
|
|
|
90114
90188
|
// src/project/documentCapture.ts
|
|
90115
90189
|
init_src3();
|
|
@@ -90117,8 +90191,8 @@ init_cliFeedback();
|
|
|
90117
90191
|
init_errors3();
|
|
90118
90192
|
init_exitCode();
|
|
90119
90193
|
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
|
|
90194
|
+
import { mkdir as mkdir27, readdir as readdir18, readFile as readFile62, rm as rm17, stat as stat9, writeFile as writeFile22 } from "node:fs/promises";
|
|
90195
|
+
import { basename as basename8, dirname as dirname33, extname as extname12, join as join73, relative as relative22, resolve as resolve24 } from "node:path";
|
|
90122
90196
|
|
|
90123
90197
|
// src/project/documentCaptureAssets.ts
|
|
90124
90198
|
init_src3();
|
|
@@ -90127,8 +90201,8 @@ init_errors3();
|
|
|
90127
90201
|
init_exitCode();
|
|
90128
90202
|
init_markdownLinks();
|
|
90129
90203
|
import { readFileSync as readFileSync6 } from "node:fs";
|
|
90130
|
-
import { mkdir as mkdir25, readFile as
|
|
90131
|
-
import { dirname as dirname30, isAbsolute as isAbsolute13, join as
|
|
90204
|
+
import { mkdir as mkdir25, readFile as readFile59, stat as stat7, writeFile as writeFile20 } from "node:fs/promises";
|
|
90205
|
+
import { dirname as dirname30, isAbsolute as isAbsolute13, join as join68, relative as relative20, resolve as resolve21 } from "node:path";
|
|
90132
90206
|
function runtimeError(message, detail) {
|
|
90133
90207
|
return new ContextError(ExitCode.UserError, message, {
|
|
90134
90208
|
category: ErrorCategory.UserInputInvalid,
|
|
@@ -90153,26 +90227,26 @@ function linkedAssetSnapshotPath(documentPath, target) {
|
|
|
90153
90227
|
const decoded = decodedAssetTarget(target);
|
|
90154
90228
|
if (/^[a-z][a-z0-9+.-]*:/iu.test(decoded) || decoded.startsWith("#") || decoded.startsWith("/"))
|
|
90155
90229
|
return;
|
|
90156
|
-
const candidate = toPosixPath5(
|
|
90230
|
+
const candidate = toPosixPath5(join68(dirname30(documentPath), decoded));
|
|
90157
90231
|
if (candidate !== "assets" && !candidate.startsWith("assets/"))
|
|
90158
90232
|
return;
|
|
90159
90233
|
return normalizeSnapshotRelativePath(candidate);
|
|
90160
90234
|
}
|
|
90161
90235
|
async function writeCaptureAssetIfChanged(path2, content3) {
|
|
90162
90236
|
try {
|
|
90163
|
-
const current = await
|
|
90237
|
+
const current = await readFile59(path2);
|
|
90164
90238
|
if (current.byteLength === content3.byteLength && current.equals(content3))
|
|
90165
90239
|
return;
|
|
90166
90240
|
} catch {}
|
|
90167
90241
|
await mkdir25(dirname30(path2), { recursive: true });
|
|
90168
|
-
await
|
|
90242
|
+
await writeFile20(path2, content3);
|
|
90169
90243
|
}
|
|
90170
90244
|
async function readLinkedCaptureAssets(input) {
|
|
90171
90245
|
const rootStat = await stat7(input.localRoot);
|
|
90172
90246
|
const boundaryRoot = rootStat.isFile() ? dirname30(input.localRoot) : input.localRoot;
|
|
90173
90247
|
const bySnapshotPath = new Map;
|
|
90174
90248
|
for (const file of input.files) {
|
|
90175
|
-
const markdown = await
|
|
90249
|
+
const markdown = await readFile59(file.absolutePath, "utf8");
|
|
90176
90250
|
for (const link of markdownInlineLinks(markdown)) {
|
|
90177
90251
|
const snapshotPath2 = linkedAssetSnapshotPath(file.snapshotPath, link.target);
|
|
90178
90252
|
if (snapshotPath2 === undefined)
|
|
@@ -90190,7 +90264,7 @@ async function readLinkedCaptureAssets(input) {
|
|
|
90190
90264
|
const assetStat = await stat7(absolutePath);
|
|
90191
90265
|
if (!assetStat.isFile())
|
|
90192
90266
|
throw new TypeError("asset target is not a file");
|
|
90193
|
-
bytes = await
|
|
90267
|
+
bytes = await readFile59(absolutePath);
|
|
90194
90268
|
} catch (error) {
|
|
90195
90269
|
const message = error instanceof Error ? error.message : String(error);
|
|
90196
90270
|
throw runtimeError(`file source ${input.sourceName} linked asset is unreadable: ${link.target}: ${message}`, {
|
|
@@ -90218,7 +90292,7 @@ function fileSnapshotLinkedAssetMismatchDiagnostic(input) {
|
|
|
90218
90292
|
for (const file of input.manifest.files) {
|
|
90219
90293
|
let markdown;
|
|
90220
90294
|
try {
|
|
90221
|
-
markdown = readFileSync6(
|
|
90295
|
+
markdown = readFileSync6(join68(input.projectRoot, input.materializedAt, file.path), "utf8");
|
|
90222
90296
|
} catch {
|
|
90223
90297
|
continue;
|
|
90224
90298
|
}
|
|
@@ -97835,7 +97909,7 @@ init_src3();
|
|
|
97835
97909
|
init_cliFeedback();
|
|
97836
97910
|
init_errors3();
|
|
97837
97911
|
init_exitCode();
|
|
97838
|
-
import { readFile as
|
|
97912
|
+
import { readFile as readFile60 } from "node:fs/promises";
|
|
97839
97913
|
import { dirname as dirname31, extname as extname10 } from "node:path";
|
|
97840
97914
|
var ROUTE_EVIDENCE_DOCUMENT_PATH = "__context_route_metadata.md";
|
|
97841
97915
|
function countLines(markdown) {
|
|
@@ -97930,7 +98004,7 @@ async function readRouteMetadataFiles(input) {
|
|
|
97930
98004
|
for (const file of input.files) {
|
|
97931
98005
|
let raw;
|
|
97932
98006
|
try {
|
|
97933
|
-
raw = await
|
|
98007
|
+
raw = await readFile60(file.absolutePath, "utf8");
|
|
97934
98008
|
} catch (error) {
|
|
97935
98009
|
const message = error instanceof Error ? error.message : String(error);
|
|
97936
98010
|
throw runtimeError2(`file source ${input.sourceName} metadata read failed: ${file.snapshotPath}: ${message}`, {
|
|
@@ -97982,7 +98056,7 @@ async function readRouteMetadataFiles(input) {
|
|
|
97982
98056
|
|
|
97983
98057
|
// src/project/documentSiteDetection.ts
|
|
97984
98058
|
import { readdir as readdir17, stat as stat8 } from "node:fs/promises";
|
|
97985
|
-
import { basename as basename7, extname as extname11, join as
|
|
98059
|
+
import { basename as basename7, extname as extname11, join as join69, relative as relative21, resolve as resolve22 } from "node:path";
|
|
97986
98060
|
var SKIPPED_DIRS = new Set([
|
|
97987
98061
|
".cache",
|
|
97988
98062
|
".git",
|
|
@@ -98065,7 +98139,7 @@ async function detectDocumentSiteFiles(input) {
|
|
|
98065
98139
|
return;
|
|
98066
98140
|
}
|
|
98067
98141
|
result.scannedEntryCount += 1;
|
|
98068
|
-
const absolutePath =
|
|
98142
|
+
const absolutePath = join69(dir, entry.name);
|
|
98069
98143
|
if (entry.isDirectory()) {
|
|
98070
98144
|
const lower = entry.name.toLowerCase();
|
|
98071
98145
|
if (SKIPPED_DIRS.has(lower))
|
|
@@ -98255,7 +98329,7 @@ async function walkMarkdownFiles(input) {
|
|
|
98255
98329
|
const visit3 = async (dir) => {
|
|
98256
98330
|
const entries2 = await readdir18(dir, { withFileTypes: true });
|
|
98257
98331
|
for (const entry of entries2) {
|
|
98258
|
-
const absolutePath =
|
|
98332
|
+
const absolutePath = join73(dir, entry.name);
|
|
98259
98333
|
if (entry.isDirectory()) {
|
|
98260
98334
|
await visit3(absolutePath);
|
|
98261
98335
|
continue;
|
|
@@ -98277,14 +98351,14 @@ async function walkMarkdownFiles(input) {
|
|
|
98277
98351
|
}
|
|
98278
98352
|
async function writeTextIfChanged(path2, content3) {
|
|
98279
98353
|
try {
|
|
98280
|
-
if (await
|
|
98354
|
+
if (await readFile62(path2, "utf8") === content3)
|
|
98281
98355
|
return;
|
|
98282
98356
|
} catch {}
|
|
98283
98357
|
await mkdir27(dirname33(path2), { recursive: true });
|
|
98284
|
-
await
|
|
98358
|
+
await writeFile22(path2, content3, "utf8");
|
|
98285
98359
|
}
|
|
98286
98360
|
function sourceManifestPath(entry) {
|
|
98287
|
-
return entry.snapshot?.manifest ??
|
|
98361
|
+
return entry.snapshot?.manifest ?? join73(entry.materializedAt, "manifest.json");
|
|
98288
98362
|
}
|
|
98289
98363
|
function runtimeError3(message, detail) {
|
|
98290
98364
|
return new ContextError(ExitCode.UserError, message, {
|
|
@@ -98357,7 +98431,7 @@ async function removeEmptySnapshotDirs(root, dir = root) {
|
|
|
98357
98431
|
for (const entry of entries2) {
|
|
98358
98432
|
if (!entry.isDirectory() || entry.name === ".tmp" || entry.name === ".cache")
|
|
98359
98433
|
continue;
|
|
98360
|
-
await removeEmptySnapshotDirs(root,
|
|
98434
|
+
await removeEmptySnapshotDirs(root, join73(dir, entry.name));
|
|
98361
98435
|
}
|
|
98362
98436
|
if (dir === root)
|
|
98363
98437
|
return;
|
|
@@ -98369,7 +98443,7 @@ async function removeEmptySnapshotDirs(root, dir = root) {
|
|
|
98369
98443
|
async function cleanupStaleSnapshotFiles(input) {
|
|
98370
98444
|
for (const path2 of input.previousPaths) {
|
|
98371
98445
|
if (!input.currentPaths.has(path2)) {
|
|
98372
|
-
await rm17(
|
|
98446
|
+
await rm17(join73(input.materializedAtAbsPath, path2), { force: true });
|
|
98373
98447
|
}
|
|
98374
98448
|
}
|
|
98375
98449
|
await removeEmptySnapshotDirs(input.materializedAtAbsPath);
|
|
@@ -98381,7 +98455,7 @@ async function readDocumentFiles(input) {
|
|
|
98381
98455
|
for (const file of input.files) {
|
|
98382
98456
|
let raw;
|
|
98383
98457
|
try {
|
|
98384
|
-
raw = await
|
|
98458
|
+
raw = await readFile62(file.absolutePath, "utf8");
|
|
98385
98459
|
} catch (error) {
|
|
98386
98460
|
const message = error instanceof Error ? error.message : String(error);
|
|
98387
98461
|
throw runtimeError3(`file source ${input.sourceName} document read failed: ${file.snapshotPath}: ${message}`, {
|
|
@@ -98550,9 +98624,9 @@ async function runCaptureFilePhaseUnlocked(input) {
|
|
|
98550
98624
|
documentSnapshot
|
|
98551
98625
|
});
|
|
98552
98626
|
const manifestPath = sourceManifestPath(entry);
|
|
98553
|
-
const manifestAbsPath =
|
|
98627
|
+
const manifestAbsPath = join73(input.projectRoot, manifestPath);
|
|
98554
98628
|
const materializedAt = entry.materializedAt;
|
|
98555
|
-
const materializedAtAbsPath =
|
|
98629
|
+
const materializedAtAbsPath = join73(input.projectRoot, materializedAt);
|
|
98556
98630
|
const manifestInput = {
|
|
98557
98631
|
sourceType: "file",
|
|
98558
98632
|
sourceName: resolved.sourceName,
|
|
@@ -98602,13 +98676,13 @@ async function runCaptureFilePhaseUnlocked(input) {
|
|
|
98602
98676
|
}));
|
|
98603
98677
|
try {
|
|
98604
98678
|
for (const file of snapshotFiles) {
|
|
98605
|
-
await writeTextIfChanged(
|
|
98679
|
+
await writeTextIfChanged(join73(materializedAtAbsPath, file.path), String(file.bytes));
|
|
98606
98680
|
}
|
|
98607
98681
|
for (const file of files.metadata) {
|
|
98608
|
-
await writeTextIfChanged(
|
|
98682
|
+
await writeTextIfChanged(join73(materializedAtAbsPath, file.snapshotPath), routeMetadata.rawByPath.get(file.snapshotPath) ?? "");
|
|
98609
98683
|
}
|
|
98610
98684
|
for (const asset of linkedAssets) {
|
|
98611
|
-
await writeCaptureAssetIfChanged(
|
|
98685
|
+
await writeCaptureAssetIfChanged(join73(materializedAtAbsPath, asset.snapshotPath), asset.bytes);
|
|
98612
98686
|
}
|
|
98613
98687
|
await writeTextIfChanged(manifestAbsPath, manifestContent);
|
|
98614
98688
|
await cleanupStaleSnapshotFiles({
|
|
@@ -98662,7 +98736,7 @@ async function runCaptureFilePhase(input) {
|
|
|
98662
98736
|
init_src3();
|
|
98663
98737
|
init_larkCaptureReport();
|
|
98664
98738
|
import { readFileSync as readFileSync7 } from "node:fs";
|
|
98665
|
-
import { join as
|
|
98739
|
+
import { join as join74 } from "node:path";
|
|
98666
98740
|
function readDocumentSnapshotCaptureReport(input) {
|
|
98667
98741
|
const summary = input.manifest.metadata?.capture?.report;
|
|
98668
98742
|
if (summary === undefined)
|
|
@@ -98671,7 +98745,7 @@ function readDocumentSnapshotCaptureReport(input) {
|
|
|
98671
98745
|
if (asset === undefined || asset.role !== "audit" || asset.content_hash === undefined) {
|
|
98672
98746
|
throw new TypeError(`snapshot capture report is not registered as a hashed audit asset: ${summary.path}`);
|
|
98673
98747
|
}
|
|
98674
|
-
const bytes = readFileSync7(
|
|
98748
|
+
const bytes = readFileSync7(join74(input.projectRoot, input.materializedAt, summary.path));
|
|
98675
98749
|
if (computeDocumentContentHash(bytes) !== asset.content_hash) {
|
|
98676
98750
|
throw new TypeError(`snapshot capture report hash does not match manifest: ${summary.path}`);
|
|
98677
98751
|
}
|
|
@@ -98742,17 +98816,17 @@ init_cliFeedback();
|
|
|
98742
98816
|
init_errors3();
|
|
98743
98817
|
init_exitCode();
|
|
98744
98818
|
import { existsSync as existsSync21 } from "node:fs";
|
|
98745
|
-
import { lstat as lstat9, mkdir as mkdir28, readFile as
|
|
98819
|
+
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
98820
|
import { execFile as execFile9 } from "node:child_process";
|
|
98747
98821
|
import { promisify as promisify9 } from "node:util";
|
|
98748
|
-
import { dirname as dirname34, isAbsolute as isAbsolute14, join as
|
|
98822
|
+
import { dirname as dirname34, isAbsolute as isAbsolute14, join as join77, relative as relative23, resolve as resolve26 } from "node:path";
|
|
98749
98823
|
|
|
98750
98824
|
// src/project/repoSourceModules.ts
|
|
98751
98825
|
init_src();
|
|
98752
98826
|
init_src3();
|
|
98753
98827
|
import { existsSync as existsSync19 } from "node:fs";
|
|
98754
|
-
import { readFile as
|
|
98755
|
-
import { join as
|
|
98828
|
+
import { readFile as readFile63, readdir as readdir19 } from "node:fs/promises";
|
|
98829
|
+
import { join as join75, resolve as resolve25 } from "node:path";
|
|
98756
98830
|
async function rootNames(root) {
|
|
98757
98831
|
try {
|
|
98758
98832
|
return (await readdir19(root)).sort();
|
|
@@ -98761,11 +98835,11 @@ async function rootNames(root) {
|
|
|
98761
98835
|
}
|
|
98762
98836
|
}
|
|
98763
98837
|
async function packageEntries(root) {
|
|
98764
|
-
const path2 =
|
|
98838
|
+
const path2 = join75(root, "package.json");
|
|
98765
98839
|
if (!existsSync19(path2))
|
|
98766
98840
|
return [];
|
|
98767
98841
|
try {
|
|
98768
|
-
const value = JSON.parse(await
|
|
98842
|
+
const value = JSON.parse(await readFile63(path2, "utf8"));
|
|
98769
98843
|
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
98844
|
return [...new Set(entries2.map((entry) => entry.replace(/^\.\//u, "")))].sort();
|
|
98771
98845
|
} catch {
|
|
@@ -98773,9 +98847,9 @@ async function packageEntries(root) {
|
|
|
98773
98847
|
}
|
|
98774
98848
|
}
|
|
98775
98849
|
async function planningEvidence(inspectPath, module) {
|
|
98776
|
-
const root = module.path === "." ? inspectPath :
|
|
98850
|
+
const root = module.path === "." ? inspectPath : join75(inspectPath, module.path);
|
|
98777
98851
|
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(
|
|
98852
|
+
const commonEntries = ["src/index.ts", "src/index.tsx", "src/main.ts", "src/main.tsx", "main.go"].filter((path2) => existsSync19(join75(root, path2)));
|
|
98779
98853
|
const protocolNames = names.filter((name3) => /(?:openapi|swagger|schema|protocol|idl)/iu.test(name3) || /\.(?:proto|thrift)$/iu.test(name3));
|
|
98780
98854
|
const lifecycleNames = names.filter((name3) => /(?:generated|vendor|mirror|legacy|sync)/iu.test(name3));
|
|
98781
98855
|
return {
|
|
@@ -98813,7 +98887,7 @@ function suggestedModuleName(module) {
|
|
|
98813
98887
|
return slug || "module";
|
|
98814
98888
|
}
|
|
98815
98889
|
async function inspectRepoSourceModules(input) {
|
|
98816
|
-
const inspectPath = input.scopedAbs !== null && existsSync19(input.scopedAbs) ? input.scopedAbs :
|
|
98890
|
+
const inspectPath = input.scopedAbs !== null && existsSync19(input.scopedAbs) ? input.scopedAbs : join75(input.projectRoot, input.status.materializedAt);
|
|
98817
98891
|
const modules = existsSync19(inspectPath) ? await detectModuleBoundaries(inspectPath, input.status.head ?? input.status.ref, DEFAULT_PATH_FILTER) : [];
|
|
98818
98892
|
const recommended_sources = modules.filter((module) => module.path !== "." || modules.length === 1).map((module) => {
|
|
98819
98893
|
const local = sourceModuleLocalForDisplay({ source: input.source, status: input.status, module });
|
|
@@ -98855,7 +98929,7 @@ init_exitCode();
|
|
|
98855
98929
|
init_atomicWrite();
|
|
98856
98930
|
var import_yaml37 = __toESM(require_dist(), 1);
|
|
98857
98931
|
import { existsSync as existsSync20 } from "node:fs";
|
|
98858
|
-
import { join as
|
|
98932
|
+
import { join as join76 } from "node:path";
|
|
98859
98933
|
var SOURCE_NAME_PATTERN2 = /^[a-z0-9][a-z0-9._-]*$/u;
|
|
98860
98934
|
var REPO_DATE_NAMESPACE_PATTERN2 = /^\d{8}$/u;
|
|
98861
98935
|
function assertRepoModuleName(name3) {
|
|
@@ -98908,7 +98982,7 @@ function registryEntryToRecord(entry) {
|
|
|
98908
98982
|
};
|
|
98909
98983
|
}
|
|
98910
98984
|
function registryPath(projectRoot) {
|
|
98911
|
-
return
|
|
98985
|
+
return join76(projectRoot, DEFAULT_REPO_SOURCES_REGISTRY_PATH);
|
|
98912
98986
|
}
|
|
98913
98987
|
function defaultRepoMaterializedAt(source2) {
|
|
98914
98988
|
return `sources/repo/${source2.namespace}/${source2.module}`;
|
|
@@ -99010,13 +99084,13 @@ async function gitOutput(cwd, args) {
|
|
|
99010
99084
|
}
|
|
99011
99085
|
}
|
|
99012
99086
|
async function readGitOriginRemote(cwd) {
|
|
99013
|
-
const directConfigPath =
|
|
99014
|
-
let config = await
|
|
99087
|
+
const directConfigPath = join77(cwd, ".git", "config");
|
|
99088
|
+
let config = await readFile64(directConfigPath, "utf8").catch(() => "");
|
|
99015
99089
|
if (config.length === 0) {
|
|
99016
99090
|
const gitDir = await resolveGitDir(cwd);
|
|
99017
99091
|
if (gitDir === null)
|
|
99018
99092
|
return null;
|
|
99019
|
-
config = await
|
|
99093
|
+
config = await readFile64(join77(gitDir, "config"), "utf8").catch(() => "");
|
|
99020
99094
|
}
|
|
99021
99095
|
let inOriginBlock = false;
|
|
99022
99096
|
for (const line of config.split(/\r?\n/u)) {
|
|
@@ -99036,7 +99110,7 @@ async function readGitOriginRemote(cwd) {
|
|
|
99036
99110
|
async function resolveGitRoot(cwd) {
|
|
99037
99111
|
let current2 = resolve26(cwd);
|
|
99038
99112
|
while (true) {
|
|
99039
|
-
if (existsSync21(
|
|
99113
|
+
if (existsSync21(join77(current2, ".git")))
|
|
99040
99114
|
return current2;
|
|
99041
99115
|
const parent = dirname34(current2);
|
|
99042
99116
|
if (parent === current2)
|
|
@@ -99045,7 +99119,7 @@ async function resolveGitRoot(cwd) {
|
|
|
99045
99119
|
}
|
|
99046
99120
|
}
|
|
99047
99121
|
async function resolveGitDir(cwd) {
|
|
99048
|
-
const dotGit =
|
|
99122
|
+
const dotGit = join77(cwd, ".git");
|
|
99049
99123
|
if (!existsSync21(dotGit))
|
|
99050
99124
|
return null;
|
|
99051
99125
|
const stats = await lstat9(dotGit);
|
|
@@ -99053,7 +99127,7 @@ async function resolveGitDir(cwd) {
|
|
|
99053
99127
|
return dotGit;
|
|
99054
99128
|
if (!stats.isFile())
|
|
99055
99129
|
return null;
|
|
99056
|
-
const raw = await
|
|
99130
|
+
const raw = await readFile64(dotGit, "utf8").catch(() => "");
|
|
99057
99131
|
const match = /^gitdir:\s*(.+)\s*$/iu.exec(raw.trim());
|
|
99058
99132
|
if (match?.[1] === undefined)
|
|
99059
99133
|
return null;
|
|
@@ -99063,17 +99137,17 @@ async function readGitHead(cwd) {
|
|
|
99063
99137
|
const gitDir = await resolveGitDir(cwd);
|
|
99064
99138
|
if (gitDir === null)
|
|
99065
99139
|
return null;
|
|
99066
|
-
const headRaw = (await
|
|
99140
|
+
const headRaw = (await readFile64(join77(gitDir, "HEAD"), "utf8").catch(() => "")).trim();
|
|
99067
99141
|
if (/^[a-f0-9]{40}$/iu.test(headRaw))
|
|
99068
99142
|
return headRaw.toLowerCase();
|
|
99069
99143
|
const match = /^ref:\s*(.+)\s*$/iu.exec(headRaw);
|
|
99070
99144
|
const refPath = match?.[1];
|
|
99071
99145
|
if (refPath === undefined)
|
|
99072
99146
|
return null;
|
|
99073
|
-
const looseRef = (await
|
|
99147
|
+
const looseRef = (await readFile64(join77(gitDir, refPath), "utf8").catch(() => "")).trim();
|
|
99074
99148
|
if (/^[a-f0-9]{40}$/iu.test(looseRef))
|
|
99075
99149
|
return looseRef.toLowerCase();
|
|
99076
|
-
const packedRefs = await
|
|
99150
|
+
const packedRefs = await readFile64(join77(gitDir, "packed-refs"), "utf8").catch(() => "");
|
|
99077
99151
|
for (const line of packedRefs.split(/\r?\n/u)) {
|
|
99078
99152
|
if (line.startsWith("#") || line.startsWith("^"))
|
|
99079
99153
|
continue;
|
|
@@ -99084,7 +99158,7 @@ async function readGitHead(cwd) {
|
|
|
99084
99158
|
return null;
|
|
99085
99159
|
}
|
|
99086
99160
|
async function ensureMaterializedSymlink(input) {
|
|
99087
|
-
const linkPath =
|
|
99161
|
+
const linkPath = join77(input.projectRoot, input.materializedAt);
|
|
99088
99162
|
await mkdir28(dirname34(linkPath), { recursive: true });
|
|
99089
99163
|
if (existsSync21(linkPath)) {
|
|
99090
99164
|
const stats = await lstat9(linkPath);
|
|
@@ -99103,7 +99177,7 @@ async function ensureMaterializedSymlink(input) {
|
|
|
99103
99177
|
return true;
|
|
99104
99178
|
}
|
|
99105
99179
|
async function diagnoseMaterializedSymlink(input) {
|
|
99106
|
-
const linkPath =
|
|
99180
|
+
const linkPath = join77(input.projectRoot, input.materializedAt);
|
|
99107
99181
|
if (!existsSync21(linkPath)) {
|
|
99108
99182
|
input.diagnostics.push(`materialized path is missing: ${input.materializedAt}`);
|
|
99109
99183
|
input.agent_hints.push(`Run context source ensure ${input.sourceName} to materialize the local source link.`);
|
|
@@ -99326,7 +99400,7 @@ async function inspectRepoSource(input) {
|
|
|
99326
99400
|
const subpath = normalizeSubpath2(source2.subpath);
|
|
99327
99401
|
const scopedAbs = localAbs === null ? null : scopedLocalPath(localAbs, subpath);
|
|
99328
99402
|
const scopeExists = scopedAbs !== null && existsSync21(scopedAbs);
|
|
99329
|
-
let materialized = existsSync21(
|
|
99403
|
+
let materialized = existsSync21(join77(input.projectRoot, materializedAt));
|
|
99330
99404
|
const checkout = await inspectRepoCheckout({
|
|
99331
99405
|
source: source2,
|
|
99332
99406
|
localAbs,
|
|
@@ -99495,8 +99569,8 @@ init_approvedKnowledgeMetadata();
|
|
|
99495
99569
|
init_knowledgeAssets();
|
|
99496
99570
|
var import_yaml38 = __toESM(require_dist(), 1);
|
|
99497
99571
|
import { createHash as createHash22 } from "node:crypto";
|
|
99498
|
-
import { mkdir as mkdir29, writeFile as
|
|
99499
|
-
import { dirname as dirname35, join as
|
|
99572
|
+
import { mkdir as mkdir29, writeFile as writeFile23 } from "node:fs/promises";
|
|
99573
|
+
import { dirname as dirname35, join as join78 } from "node:path";
|
|
99500
99574
|
|
|
99501
99575
|
// src/project/entityId.ts
|
|
99502
99576
|
init_cliFeedback();
|
|
@@ -99515,7 +99589,7 @@ function assertSafeEntityId(id3) {
|
|
|
99515
99589
|
}
|
|
99516
99590
|
|
|
99517
99591
|
// src/project/reviewShared.ts
|
|
99518
|
-
var REVIEW_ACTION_ROOT2 =
|
|
99592
|
+
var REVIEW_ACTION_ROOT2 = join78(".tmp", "context-runtime", "review-actions");
|
|
99519
99593
|
var REVIEW_PAYLOAD_SCHEMA = "context.review.decisions.v1";
|
|
99520
99594
|
function isRecord14(value) {
|
|
99521
99595
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -99559,7 +99633,7 @@ async function buildApprovedArticleIndex(projectRoot) {
|
|
|
99559
99633
|
if (!isApprovedKnowledgeMarkdownPath(rel))
|
|
99560
99634
|
continue;
|
|
99561
99635
|
const { absPath, content: content3 } = file;
|
|
99562
|
-
const relPath =
|
|
99636
|
+
const relPath = join78("knowledge", collection, rel);
|
|
99563
99637
|
assetReferencesByRelPath.set(relPath, knowledgeAssetReferences({
|
|
99564
99638
|
pageRelPath: relPath,
|
|
99565
99639
|
content: content3
|
|
@@ -99572,7 +99646,7 @@ async function buildApprovedArticleIndex(projectRoot) {
|
|
|
99572
99646
|
continue;
|
|
99573
99647
|
const frontmatter2 = hydrateApprovedFrontmatter({
|
|
99574
99648
|
frontmatter: parsed,
|
|
99575
|
-
relPath:
|
|
99649
|
+
relPath: join78(collection, rel),
|
|
99576
99650
|
metadata
|
|
99577
99651
|
});
|
|
99578
99652
|
const article = articlesByPath.get(`${collection}/${rel}`);
|
|
@@ -99627,10 +99701,10 @@ ${yaml3}
|
|
|
99627
99701
|
}
|
|
99628
99702
|
async function writeReviewActionLog(input) {
|
|
99629
99703
|
const stamp = new Date().toISOString().replace(/[-:.TZ]/gu, "");
|
|
99630
|
-
const relPath =
|
|
99631
|
-
const path2 =
|
|
99704
|
+
const relPath = join78(REVIEW_ACTION_ROOT2, `${stamp}-${input.action}-${input.id.replace(/[\\/]+/gu, "_")}.json`);
|
|
99705
|
+
const path2 = join78(input.projectRoot, relPath);
|
|
99632
99706
|
await mkdir29(dirname35(path2), { recursive: true });
|
|
99633
|
-
await
|
|
99707
|
+
await writeFile23(path2, `${JSON.stringify({
|
|
99634
99708
|
action: input.action,
|
|
99635
99709
|
id: input.id,
|
|
99636
99710
|
...input.summary
|
|
@@ -99661,7 +99735,7 @@ async function countFiles(root, predicate) {
|
|
|
99661
99735
|
const entries2 = await readCommandDirectory(dir);
|
|
99662
99736
|
for (const entry of entries2) {
|
|
99663
99737
|
const rel = prefix.length === 0 ? entry.name : `${prefix}/${entry.name}`;
|
|
99664
|
-
const abs =
|
|
99738
|
+
const abs = join79(dir, entry.name);
|
|
99665
99739
|
if (entry.isDirectory())
|
|
99666
99740
|
await visit3(abs, rel);
|
|
99667
99741
|
else if (entry.isFile() && predicate(rel))
|
|
@@ -99852,7 +99926,7 @@ async function documentSourceSiteHint(input) {
|
|
|
99852
99926
|
});
|
|
99853
99927
|
}
|
|
99854
99928
|
function documentSnapshotReadiness(input) {
|
|
99855
|
-
const manifestPath =
|
|
99929
|
+
const manifestPath = join79(input.projectRoot, input.manifest);
|
|
99856
99930
|
if (!existsSync22(manifestPath)) {
|
|
99857
99931
|
return {
|
|
99858
99932
|
ready: false,
|
|
@@ -99922,7 +99996,7 @@ function documentSnapshotReadiness(input) {
|
|
|
99922
99996
|
const missingFiles = [
|
|
99923
99997
|
...manifest.files.map((file) => file.path),
|
|
99924
99998
|
...(manifest.assets ?? []).filter((asset) => asset.content_hash !== undefined).map((asset) => asset.path)
|
|
99925
|
-
].filter((path2) => !existsSync22(
|
|
99999
|
+
].filter((path2) => !existsSync22(join79(input.projectRoot, input.materializedAt, path2)));
|
|
99926
100000
|
if (missingFiles.length > 0) {
|
|
99927
100001
|
return {
|
|
99928
100002
|
ready: false,
|
|
@@ -100388,7 +100462,7 @@ async function collectProjectStatusSnapshotInternal(projectRoot, options = {}) {
|
|
|
100388
100462
|
const authoring = production && !production.delivery && (dispatchProductionStage(production, productionCapabilitiesSchema.parse({})).state !== "ended" || draftStatus.count > 0 && draftStatus.diagnostics.length === 0);
|
|
100389
100463
|
const deferDeliveryChecks = !maintenance && !localRevision && !localUpdate && !localRollback && (taskPreparation === "cleared" && !production || !!authoring);
|
|
100390
100464
|
const collectionsWithPages = new Set;
|
|
100391
|
-
const approvedPages = await countFiles(
|
|
100465
|
+
const approvedPages = await countFiles(join83(projectRoot, "knowledge"), (rel) => {
|
|
100392
100466
|
if (!isApprovedKnowledgeMarkdownPath(rel) || rel.startsWith("assets/"))
|
|
100393
100467
|
return false;
|
|
100394
100468
|
collectionsWithPages.add(rel.split("/")[0]);
|
|
@@ -100396,7 +100470,7 @@ async function collectProjectStatusSnapshotInternal(projectRoot, options = {}) {
|
|
|
100396
100470
|
});
|
|
100397
100471
|
const approvedCollections = KNOWLEDGE_COLLECTIONS.filter((collection) => collectionsWithPages.has(collection));
|
|
100398
100472
|
const closeStatus = deferDeliveryChecks ? { state: "not-checked", diagnostics: [] } : await readCloseStatus(projectRoot);
|
|
100399
|
-
const distFiles = await countFiles(
|
|
100473
|
+
const distFiles = await countFiles(join83(projectRoot, "dist"), () => true);
|
|
100400
100474
|
const verifyStatus = !deferDeliveryChecks && draftStatus.diagnostics.length === 0 ? await readVerifyStatus(projectRoot) : { issues: [], diagnostics: [] };
|
|
100401
100475
|
const pendingCapture = pendingDocumentCaptureCommands({
|
|
100402
100476
|
phases,
|
|
@@ -100765,14 +100839,14 @@ function bindWorkflowExecutionContext(result, context) {
|
|
|
100765
100839
|
// src/project/workflow/workflowRouteOutput.ts
|
|
100766
100840
|
init_atomicWrite();
|
|
100767
100841
|
import { createHash as createHash23 } from "node:crypto";
|
|
100768
|
-
import { join as
|
|
100842
|
+
import { join as join84 } from "node:path";
|
|
100769
100843
|
async function workflowRouteOutput(projectRoot, route) {
|
|
100770
100844
|
if (!route)
|
|
100771
100845
|
return null;
|
|
100772
100846
|
const body = `${JSON.stringify(route, null, 2)}
|
|
100773
100847
|
`;
|
|
100774
100848
|
const digest6 = createHash23("sha256").update(body).digest("hex");
|
|
100775
|
-
const file =
|
|
100849
|
+
const file = join84(projectRoot, ".tmp/context-runtime/routes", `${digest6}.json`);
|
|
100776
100850
|
await atomicWriteFile(file, body);
|
|
100777
100851
|
return {
|
|
100778
100852
|
file,
|
|
@@ -100788,7 +100862,7 @@ async function workflowRunResultFile(projectRoot, result) {
|
|
|
100788
100862
|
const body = `${JSON.stringify(result, null, 2)}
|
|
100789
100863
|
`;
|
|
100790
100864
|
const digest6 = createHash23("sha256").update(body).digest("hex");
|
|
100791
|
-
const file =
|
|
100865
|
+
const file = join84(projectRoot, ".tmp/context-runtime/action-results", `${digest6}.run.json`);
|
|
100792
100866
|
await atomicWriteFile(file, body);
|
|
100793
100867
|
return file;
|
|
100794
100868
|
}
|
|
@@ -104162,8 +104236,8 @@ function renderReviewMarkdown(markdown, pageTitle) {
|
|
|
104162
104236
|
|
|
104163
104237
|
// src/project/reviewHtml.ts
|
|
104164
104238
|
init_candidateLedger();
|
|
104165
|
-
import { mkdir as mkdir30, writeFile as
|
|
104166
|
-
import { dirname as dirname38, isAbsolute as isAbsolute15, join as
|
|
104239
|
+
import { mkdir as mkdir30, writeFile as writeFile24 } from "node:fs/promises";
|
|
104240
|
+
import { dirname as dirname38, isAbsolute as isAbsolute15, join as join85, resolve as resolve28 } from "node:path";
|
|
104167
104241
|
|
|
104168
104242
|
// src/project/reviewHtmlPresentation.ts
|
|
104169
104243
|
import { dirname as dirname37 } from "node:path";
|
|
@@ -104325,7 +104399,7 @@ var REVIEW_HTML_STYLES = `
|
|
|
104325
104399
|
`;
|
|
104326
104400
|
|
|
104327
104401
|
// src/project/reviewHtml.ts
|
|
104328
|
-
var REVIEW_HTML_ROOT =
|
|
104402
|
+
var REVIEW_HTML_ROOT = join85(".tmp", "context-runtime", "review");
|
|
104329
104403
|
async function collectReviewCandidates(projectRoot, collection) {
|
|
104330
104404
|
const rows = await readCandidateRecords(projectRoot);
|
|
104331
104405
|
const draftRows = rows.filter((row) => row.collection === collection && row.status === "draft");
|
|
@@ -104781,7 +104855,7 @@ function renderReviewHtml(candidates, reviewScope) {
|
|
|
104781
104855
|
}
|
|
104782
104856
|
function resolveOutputPath(projectRoot, outPath, reviewScope) {
|
|
104783
104857
|
if (outPath === undefined)
|
|
104784
|
-
return
|
|
104858
|
+
return join85(projectRoot, REVIEW_HTML_ROOT, `${reviewScope}.html`);
|
|
104785
104859
|
return isAbsolute15(outPath) ? outPath : resolve28(projectRoot, outPath);
|
|
104786
104860
|
}
|
|
104787
104861
|
async function writeReviewHtml(input) {
|
|
@@ -104792,7 +104866,7 @@ async function writeReviewHtml(input) {
|
|
|
104792
104866
|
const candidates = reviewScope === "all" ? await collectAllReviewCandidates(input.projectRoot) : await collectReviewCandidates(input.projectRoot, reviewScope);
|
|
104793
104867
|
const outPath = resolveOutputPath(input.projectRoot, input.out, reviewScope);
|
|
104794
104868
|
await mkdir30(dirname38(outPath), { recursive: true });
|
|
104795
|
-
await
|
|
104869
|
+
await writeFile24(outPath, renderReviewHtml(candidates, reviewScope), "utf8");
|
|
104796
104870
|
return {
|
|
104797
104871
|
path: outPath,
|
|
104798
104872
|
candidates: candidates.length,
|
|
@@ -104805,8 +104879,8 @@ async function writeReviewHtml(input) {
|
|
|
104805
104879
|
init_productionRequirements();
|
|
104806
104880
|
init_dist();
|
|
104807
104881
|
init_atomicWrite();
|
|
104808
|
-
import { mkdir as mkdir31, readFile as
|
|
104809
|
-
import { join as
|
|
104882
|
+
import { mkdir as mkdir31, readFile as readFile67 } from "node:fs/promises";
|
|
104883
|
+
import { join as join86 } from "node:path";
|
|
104810
104884
|
var REVIEW_BATCH_MAX_CANDIDATES = 6;
|
|
104811
104885
|
var REVIEW_BATCH_MAX_BYTES = 512 * 1024;
|
|
104812
104886
|
async function readerPurposes(projectRoot, sources) {
|
|
@@ -104885,12 +104959,12 @@ async function materializeCurrentReviewBatchSet(input) {
|
|
|
104885
104959
|
const batches = buildCurrentReviewBatchDocuments(input.candidates);
|
|
104886
104960
|
const setDigest = digestText(batches.map((batch) => `${batch.task_key}:${batch.digest}`).join(`
|
|
104887
104961
|
`));
|
|
104888
|
-
const root2 =
|
|
104962
|
+
const root2 = join86(input.projectRoot, ".tmp", "context-runtime", "review", `current-${setDigest.slice("sha256:".length)}`);
|
|
104889
104963
|
await mkdir31(root2, { recursive: true });
|
|
104890
104964
|
const entries2 = [];
|
|
104891
104965
|
for (const batch of batches) {
|
|
104892
|
-
const path4 =
|
|
104893
|
-
const existing = await
|
|
104966
|
+
const path4 = join86(input.projectRoot, ".tmp", "context-runtime", "review", `${batch.task_key}-${batch.digest.slice("sha256:".length)}.md`);
|
|
104967
|
+
const existing = await readFile67(path4, "utf8").catch((error) => {
|
|
104894
104968
|
if (error.code === "ENOENT")
|
|
104895
104969
|
return;
|
|
104896
104970
|
throw error;
|
|
@@ -104942,7 +105016,7 @@ async function materializeCurrentReviewBatchSet(input) {
|
|
|
104942
105016
|
].join(`
|
|
104943
105017
|
`);
|
|
104944
105018
|
const digest6 = digestText(content3);
|
|
104945
|
-
const path3 =
|
|
105019
|
+
const path3 = join86(root2, "index.md");
|
|
104946
105020
|
await atomicWriteFile(path3, `${content3}
|
|
104947
105021
|
`);
|
|
104948
105022
|
return {
|
|
@@ -104975,11 +105049,11 @@ function shellQuote6(value) {
|
|
|
104975
105049
|
}
|
|
104976
105050
|
function receiptSetPath(receipts) {
|
|
104977
105051
|
const token = digestText(JSON.stringify(receipts)).slice("sha256:".length);
|
|
104978
|
-
return
|
|
105052
|
+
return join87(".tmp", "context-runtime", "workflow", "read-receipts", `${token}.json`);
|
|
104979
105053
|
}
|
|
104980
105054
|
async function writeReceiptContinuation(input) {
|
|
104981
105055
|
const path3 = receiptSetPath(input.receipts);
|
|
104982
|
-
const absolutePath =
|
|
105056
|
+
const absolutePath = join87(input.projectRoot, path3);
|
|
104983
105057
|
await writeJsonAtomic(absolutePath, input.receipts);
|
|
104984
105058
|
const contextCommand = input.managed ? [
|
|
104985
105059
|
"context",
|
|
@@ -105074,7 +105148,7 @@ async function materializeContextWorkflowResource(input) {
|
|
|
105074
105148
|
const resourceId = workflowResourceId(input.resourceId);
|
|
105075
105149
|
const content3 = renderContextWorkflowResource(resourceId, status);
|
|
105076
105150
|
const location = await materializeResource(await loadContextWorkflowProvider(), resourceId, {
|
|
105077
|
-
cache:
|
|
105151
|
+
cache: join87(found.projectRoot, ".tmp", "context-runtime", "workflow", "resources"),
|
|
105078
105152
|
workspace: found.projectRoot,
|
|
105079
105153
|
revision: input.revision,
|
|
105080
105154
|
input: {
|
|
@@ -105106,7 +105180,7 @@ async function materializeContextWorkflowResource(input) {
|
|
|
105106
105180
|
receipts: afterReadReceipts
|
|
105107
105181
|
});
|
|
105108
105182
|
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(`@${
|
|
105183
|
+
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
105184
|
return {
|
|
105111
105185
|
protocol: "context.workflow.resource.v1",
|
|
105112
105186
|
id: resourceId,
|
|
@@ -105167,14 +105241,14 @@ async function acknowledgeCurrentWorkflowResources(input) {
|
|
|
105167
105241
|
const reevaluated = await reevaluateProjectStatusWorkflow({
|
|
105168
105242
|
snapshot,
|
|
105169
105243
|
resourceReceipts: normalizedReceipts,
|
|
105170
|
-
resourceReceiptsReference: `@${
|
|
105244
|
+
resourceReceiptsReference: `@${join87(found.projectRoot, continuation.path)}`
|
|
105171
105245
|
});
|
|
105172
105246
|
return {
|
|
105173
105247
|
...reevaluated,
|
|
105174
105248
|
resourceAcknowledgement: {
|
|
105175
105249
|
protocol: "context.workflow.resource-receipts.v1",
|
|
105176
105250
|
acknowledged: directResources.length,
|
|
105177
|
-
receiptReference: `@${
|
|
105251
|
+
receiptReference: `@${join87(found.projectRoot, continuation.path)}`
|
|
105178
105252
|
}
|
|
105179
105253
|
};
|
|
105180
105254
|
}
|
|
@@ -105220,9 +105294,9 @@ init_cliFeedback();
|
|
|
105220
105294
|
init_errors3();
|
|
105221
105295
|
init_exitCode();
|
|
105222
105296
|
init_workspace();
|
|
105223
|
-
import { readFile as
|
|
105224
|
-
import { isAbsolute as isAbsolute16, join as
|
|
105225
|
-
var RECEIPT_DIRECTORY =
|
|
105297
|
+
import { readFile as readFile68 } from "node:fs/promises";
|
|
105298
|
+
import { isAbsolute as isAbsolute16, join as join88, sep as sep6, resolve as resolve29 } from "node:path";
|
|
105299
|
+
var RECEIPT_DIRECTORY = join88(".tmp", "context-runtime", "workflow", "read-receipts");
|
|
105226
105300
|
function workflowResourceReceiptCwd(value, cwd) {
|
|
105227
105301
|
if (value === undefined || !value.startsWith("@"))
|
|
105228
105302
|
return cwd;
|
|
@@ -105240,7 +105314,7 @@ async function receiptDocument(value, cwd) {
|
|
|
105240
105314
|
let source2 = value;
|
|
105241
105315
|
if (value.startsWith("@")) {
|
|
105242
105316
|
try {
|
|
105243
|
-
source2 = await
|
|
105317
|
+
source2 = await readFile68(resolve29(cwd, value.slice(1)), "utf8");
|
|
105244
105318
|
} catch (error) {
|
|
105245
105319
|
const ioCode = error !== null && typeof error === "object" && "code" in error && typeof error.code === "string" ? error.code : undefined;
|
|
105246
105320
|
throw new ContextError(ExitCode.UserError, "resource read receipt file is unavailable", {
|
|
@@ -105486,17 +105560,17 @@ function compactJsonResult(result, verbose) {
|
|
|
105486
105560
|
|
|
105487
105561
|
// src/project/runLog.ts
|
|
105488
105562
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
105489
|
-
import { mkdir as mkdir32, writeFile as
|
|
105490
|
-
import { dirname as dirname39, join as
|
|
105563
|
+
import { mkdir as mkdir32, writeFile as writeFile25 } from "node:fs/promises";
|
|
105564
|
+
import { dirname as dirname39, join as join91 } from "node:path";
|
|
105491
105565
|
var createPhaseRunId = () => {
|
|
105492
105566
|
const timestamp = new Date().toISOString().replace(/[-:.TZ]/gu, "");
|
|
105493
105567
|
return `run_${timestamp}_${randomUUID5().slice(0, 8)}`;
|
|
105494
105568
|
};
|
|
105495
105569
|
async function writePhaseRunLog(input) {
|
|
105496
|
-
const relPath =
|
|
105497
|
-
const absPath =
|
|
105570
|
+
const relPath = join91(".tmp", "context-runtime", "runs", `${input.runId}.json`);
|
|
105571
|
+
const absPath = join91(input.projectRoot, relPath);
|
|
105498
105572
|
await mkdir32(dirname39(absPath), { recursive: true });
|
|
105499
|
-
await
|
|
105573
|
+
await writeFile25(absPath, `${JSON.stringify({
|
|
105500
105574
|
run_id: input.runId,
|
|
105501
105575
|
phase_id: input.phase.id,
|
|
105502
105576
|
phase_kind: input.phase.kind,
|
|
@@ -106441,7 +106515,7 @@ init_workflowFacts();
|
|
|
106441
106515
|
init_cliFeedback();
|
|
106442
106516
|
init_errors3();
|
|
106443
106517
|
init_exitCode();
|
|
106444
|
-
import { readFile as
|
|
106518
|
+
import { readFile as readFile73 } from "node:fs/promises";
|
|
106445
106519
|
import { isAbsolute as isAbsolute18, resolve as resolve30 } from "node:path";
|
|
106446
106520
|
|
|
106447
106521
|
// src/project/reviewApply.ts
|
|
@@ -106454,8 +106528,8 @@ init_writeLock();
|
|
|
106454
106528
|
init_reviewApplyIndexer();
|
|
106455
106529
|
init_approvedKnowledgeSnapshots();
|
|
106456
106530
|
import { existsSync as existsSync25 } from "node:fs";
|
|
106457
|
-
import { readFile as
|
|
106458
|
-
import { join as
|
|
106531
|
+
import { readFile as readFile71 } from "node:fs/promises";
|
|
106532
|
+
import { join as join92 } from "node:path";
|
|
106459
106533
|
|
|
106460
106534
|
// src/project/reviewCandidateAuthority.ts
|
|
106461
106535
|
init_src2();
|
|
@@ -106552,7 +106626,7 @@ async function prepareApprovedPage(input) {
|
|
|
106552
106626
|
next: "Refresh the current production or article revision, then reopen Review before approval."
|
|
106553
106627
|
});
|
|
106554
106628
|
}
|
|
106555
|
-
const relPath =
|
|
106629
|
+
const relPath = join92("knowledge", input.record.path);
|
|
106556
106630
|
const existingView = findApprovedPageForArticleId(input.record.indexer_candidate.artifact_ref, input.approvedPageIndex);
|
|
106557
106631
|
const previousPath = input.record.approved_revision?.previous_path;
|
|
106558
106632
|
if (previousPath !== undefined && (!isSafeKnowledgeTargetPath(previousPath.split("/")[0], previousPath) || previousPath.includes("\\")))
|
|
@@ -106567,13 +106641,13 @@ async function prepareApprovedPage(input) {
|
|
|
106567
106641
|
next: "Resolve the approved page path migration explicitly before approving this candidate."
|
|
106568
106642
|
});
|
|
106569
106643
|
}
|
|
106570
|
-
const absPath =
|
|
106571
|
-
const existing = existsSync25(absPath) ? await
|
|
106644
|
+
const absPath = join92(input.projectRoot, relPath);
|
|
106645
|
+
const existing = existsSync25(absPath) ? await readFile71(absPath, "utf8") : undefined;
|
|
106572
106646
|
let previous3;
|
|
106573
106647
|
if (previousPath !== undefined) {
|
|
106574
106648
|
if (existing !== undefined || existingView?.relPath !== `knowledge/${previousPath}`)
|
|
106575
106649
|
throw new TypeError("Page move destination or original identity changed; refresh its revision.");
|
|
106576
|
-
previous3 = { path: `knowledge/${previousPath}`, content: await
|
|
106650
|
+
previous3 = { path: `knowledge/${previousPath}`, content: await readFile71(join92(input.projectRoot, "knowledge", previousPath), "utf8") };
|
|
106577
106651
|
}
|
|
106578
106652
|
if (input.record.approved_revision !== undefined) {
|
|
106579
106653
|
const base = previous3?.content ?? existing;
|
|
@@ -106620,7 +106694,7 @@ async function prepareApprovedPage(input) {
|
|
|
106620
106694
|
}
|
|
106621
106695
|
async function readProjectFileMaybe(projectRoot, relPath) {
|
|
106622
106696
|
try {
|
|
106623
|
-
return await
|
|
106697
|
+
return await readFile71(join92(projectRoot, relPath), "utf8");
|
|
106624
106698
|
} catch (error) {
|
|
106625
106699
|
if (error !== null && typeof error === "object" && "code" in error && error.code === "ENOENT") {
|
|
106626
106700
|
return;
|
|
@@ -106813,7 +106887,7 @@ async function applyReviewDecisions(input) {
|
|
|
106813
106887
|
});
|
|
106814
106888
|
}
|
|
106815
106889
|
seenApprovedIds.set(approvedRef, row.candidate_id);
|
|
106816
|
-
const approvedPath =
|
|
106890
|
+
const approvedPath = join92("knowledge", row.path);
|
|
106817
106891
|
const previousPathCandidate = seenApprovedPaths.get(knowledgeTargetPathKey(approvedPath));
|
|
106818
106892
|
if (previousPathCandidate !== undefined) {
|
|
106819
106893
|
throw new ContextError(ExitCode.UserError, `multiple approved review decisions target the same knowledge path: ${approvedPath}`, {
|
|
@@ -106863,7 +106937,7 @@ async function applyReviewDecisions(input) {
|
|
|
106863
106937
|
for (const path3 of approvedPageIndex.byRelPath.keys()) {
|
|
106864
106938
|
if (pagesToWrite.some((page) => page.relPath === path3 || page.previous?.path === path3))
|
|
106865
106939
|
continue;
|
|
106866
|
-
const before = await
|
|
106940
|
+
const before = await readFile71(join92(input.projectRoot, path3), "utf8");
|
|
106867
106941
|
const local = path3.replace(/^knowledge\//u, "");
|
|
106868
106942
|
const after = moveKnowledgeLinkTargets2(before, local, local, moved);
|
|
106869
106943
|
navigationTargets.push(reviewFileTarget({ path: path3, baseContent: before, targetContent: after }));
|
|
@@ -106917,17 +106991,17 @@ async function applyReviewDecisions(input) {
|
|
|
106917
106991
|
}
|
|
106918
106992
|
|
|
106919
106993
|
// src/project/reviewMaintenance.ts
|
|
106920
|
-
import { readFile as
|
|
106994
|
+
import { readFile as readFile72, writeFile as writeFile26 } from "node:fs/promises";
|
|
106921
106995
|
init_writeLock();
|
|
106922
106996
|
init_verifyFrontmatter();
|
|
106923
106997
|
function deprecateApprovedPage(input) {
|
|
106924
106998
|
return withProjectWriteLock(input.projectRoot, "deprecate-article", async () => {
|
|
106925
106999
|
const page = await approvedPageForArticleId(input.projectRoot, input.viewRef);
|
|
106926
|
-
const original = await
|
|
107000
|
+
const original = await readFile72(page.path, "utf8");
|
|
106927
107001
|
const content3 = parseFrontmatterLoose(original).deprecated === true ? original : updateFrontmatter(original, (metadata) => ({ ...metadata, deprecated: true, timestamp: new Date().toISOString() }));
|
|
106928
107002
|
const changed = content3 !== original;
|
|
106929
107003
|
if (changed)
|
|
106930
|
-
await
|
|
107004
|
+
await writeFile26(page.path, content3, "utf8");
|
|
106931
107005
|
const actionLog = await writeReviewActionLog({
|
|
106932
107006
|
projectRoot: input.projectRoot,
|
|
106933
107007
|
action: "deprecate",
|
|
@@ -106943,12 +107017,12 @@ init_candidateLedger();
|
|
|
106943
107017
|
|
|
106944
107018
|
// src/project/localHtmlReport.ts
|
|
106945
107019
|
import { execFile as execFile10 } from "node:child_process";
|
|
106946
|
-
import { isAbsolute as isAbsolute17, join as
|
|
107020
|
+
import { isAbsolute as isAbsolute17, join as join93 } from "node:path";
|
|
106947
107021
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
106948
107022
|
import { promisify as promisify10 } from "node:util";
|
|
106949
107023
|
var execFileAsync5 = promisify10(execFile10);
|
|
106950
107024
|
function htmlReportReference(input) {
|
|
106951
|
-
const absolutePath = isAbsolute17(input.path) ? input.path :
|
|
107025
|
+
const absolutePath = isAbsolute17(input.path) ? input.path : join93(input.projectRoot, input.path);
|
|
106952
107026
|
return {
|
|
106953
107027
|
format: "html",
|
|
106954
107028
|
path: input.path,
|
|
@@ -107120,7 +107194,7 @@ function parseReviewPayloadText(raw) {
|
|
|
107120
107194
|
async function readReviewPayloadFile(filePath2) {
|
|
107121
107195
|
let raw;
|
|
107122
107196
|
try {
|
|
107123
|
-
raw = await
|
|
107197
|
+
raw = await readFile73(filePath2, "utf8");
|
|
107124
107198
|
} catch (error) {
|
|
107125
107199
|
const message = error instanceof Error ? error.message : String(error);
|
|
107126
107200
|
throw new ContextError(ExitCode.UserError, `review payload file cannot be read: ${filePath2}`, {
|
|
@@ -107951,8 +108025,8 @@ init_exitCode();
|
|
|
107951
108025
|
init_maintenanceStorage();
|
|
107952
108026
|
init_productionFeedback();
|
|
107953
108027
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
107954
|
-
import { readFile as
|
|
107955
|
-
import { join as
|
|
108028
|
+
import { readFile as readFile74 } from "node:fs/promises";
|
|
108029
|
+
import { join as join94 } from "node:path";
|
|
107956
108030
|
async function beginProductionRevision(input) {
|
|
107957
108031
|
return withProductionFeedback({ operation: "revision" }, () => withProjectWriteLock(input.projectRoot, "production-revision", async () => {
|
|
107958
108032
|
await recoverDurableMultiFileTransactions(input.projectRoot);
|
|
@@ -107991,7 +108065,7 @@ async function beginProductionRevision(input) {
|
|
|
107991
108065
|
const formal = approved.byPath.get(path3);
|
|
107992
108066
|
if (!prior && !formal)
|
|
107993
108067
|
throw invalid2("Write the current task first; there is no article draft to revise yet.");
|
|
107994
|
-
const markdown = prior?.body ?? await
|
|
108068
|
+
const markdown = prior?.body ?? await readFile74(await safeProjectTarget(input.projectRoot, join94("knowledge", path3)), "utf8");
|
|
107995
108069
|
const sections = prior?.indexer_candidate.sections.map((section) => ({ id: section.section_key, references: section.references })) ?? formal?.sections;
|
|
107996
108070
|
const sources = [];
|
|
107997
108071
|
for (const source2 of owner.sources) {
|
|
@@ -108168,7 +108242,7 @@ init_cliFeedback();
|
|
|
108168
108242
|
init_errors3();
|
|
108169
108243
|
init_exitCode();
|
|
108170
108244
|
var import_yaml40 = __toESM(require_dist(), 1);
|
|
108171
|
-
import { readFile as
|
|
108245
|
+
import { readFile as readFile75 } from "node:fs/promises";
|
|
108172
108246
|
function userInputError2(message, detail = {}) {
|
|
108173
108247
|
return new ContextError(ExitCode.UserError, message, {
|
|
108174
108248
|
category: ErrorCategory.UserInputInvalid,
|
|
@@ -108237,7 +108311,7 @@ async function readPayloadTextFromStdin(stdin) {
|
|
|
108237
108311
|
}
|
|
108238
108312
|
async function readPayloadText(path3) {
|
|
108239
108313
|
if (path3 !== "-")
|
|
108240
|
-
return
|
|
108314
|
+
return readFile75(path3, "utf8");
|
|
108241
108315
|
return readPayloadTextFromStdin(process.stdin);
|
|
108242
108316
|
}
|
|
108243
108317
|
async function readYamlOrJsonInput(input) {
|
|
@@ -108631,7 +108705,7 @@ init_atomicWrite();
|
|
|
108631
108705
|
var import_yaml43 = __toESM(require_dist(), 1);
|
|
108632
108706
|
import { Buffer as Buffer4 } from "node:buffer";
|
|
108633
108707
|
import { createHash as createHash29 } from "node:crypto";
|
|
108634
|
-
import { join as
|
|
108708
|
+
import { join as join98 } from "node:path";
|
|
108635
108709
|
var INLINE_LIMIT = 16 * 1024;
|
|
108636
108710
|
function record4(value) {
|
|
108637
108711
|
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : undefined;
|
|
@@ -108657,8 +108731,8 @@ async function prepareActionCompletionOutput(input) {
|
|
|
108657
108731
|
if (production && Buffer4.byteLength(full) <= INLINE_LIMIT)
|
|
108658
108732
|
return input.result;
|
|
108659
108733
|
const digest6 = createHash29("sha256").update(full).digest("hex");
|
|
108660
|
-
const root2 =
|
|
108661
|
-
const resultFile =
|
|
108734
|
+
const root2 = join98(input.projectRoot, ".tmp/context-runtime/action-results");
|
|
108735
|
+
const resultFile = join98(root2, `${digest6}.json`);
|
|
108662
108736
|
await atomicWriteFile(resultFile, full);
|
|
108663
108737
|
if (production)
|
|
108664
108738
|
return {
|
|
@@ -108669,7 +108743,7 @@ async function prepareActionCompletionOutput(input) {
|
|
|
108669
108743
|
...pick(result, ["next", "next_preparation"])
|
|
108670
108744
|
};
|
|
108671
108745
|
const next2 = record4(result.next) ?? record4(record4(result.workflow)?.current) ?? record4(record4(result.continuation)?.next);
|
|
108672
|
-
const nextFile = next2 === undefined ? undefined :
|
|
108746
|
+
const nextFile = next2 === undefined ? undefined : join98(root2, `${digest6}.next.json`);
|
|
108673
108747
|
if (nextFile !== undefined)
|
|
108674
108748
|
await atomicWriteFile(nextFile, serializeActionCompletion(next2, "json"));
|
|
108675
108749
|
const outcomes = (Array.isArray(result.outcomes) ? result.outcomes : []).map(record4).filter((item) => item !== undefined);
|
|
@@ -109072,7 +109146,7 @@ init_cliFeedback();
|
|
|
109072
109146
|
import { existsSync as existsSync27 } from "node:fs";
|
|
109073
109147
|
import { readdir as readdir25, rm as rm20 } from "node:fs/promises";
|
|
109074
109148
|
import { homedir } from "node:os";
|
|
109075
|
-
import { join as
|
|
109149
|
+
import { join as join99 } from "node:path";
|
|
109076
109150
|
var ORPHAN_MARKER = ".orphaned_at";
|
|
109077
109151
|
var CLAUDE_PLUGIN_CACHE_ROOT_ENV = "C4A_CLAUDE_PLUGIN_CACHE_ROOT";
|
|
109078
109152
|
var CLAUDE_PLUGIN_CACHE_HOME_ENV = "C4A_CLAUDE_PLUGIN_CACHE_HOME";
|
|
@@ -109089,19 +109163,19 @@ async function cleanClaudePluginCache(opts = {}) {
|
|
|
109089
109163
|
for (const mp of marketplaces) {
|
|
109090
109164
|
if (!mp.isDirectory())
|
|
109091
109165
|
continue;
|
|
109092
|
-
const mpDir =
|
|
109166
|
+
const mpDir = join99(cacheRoot, mp.name);
|
|
109093
109167
|
const plugins = await readdir25(mpDir, { withFileTypes: true });
|
|
109094
109168
|
for (const pl of plugins) {
|
|
109095
109169
|
if (!pl.isDirectory())
|
|
109096
109170
|
continue;
|
|
109097
|
-
const plDir =
|
|
109171
|
+
const plDir = join99(mpDir, pl.name);
|
|
109098
109172
|
const versions = await readdir25(plDir, { withFileTypes: true });
|
|
109099
109173
|
for (const ver of versions) {
|
|
109100
109174
|
if (!ver.isDirectory())
|
|
109101
109175
|
continue;
|
|
109102
109176
|
scanned += 1;
|
|
109103
|
-
const verDir =
|
|
109104
|
-
const markerPath =
|
|
109177
|
+
const verDir = join99(plDir, ver.name);
|
|
109178
|
+
const markerPath = join99(verDir, ORPHAN_MARKER);
|
|
109105
109179
|
if (!existsSync27(markerPath))
|
|
109106
109180
|
continue;
|
|
109107
109181
|
const label2 = `${mp.name}/${pl.name}/${ver.name}`;
|
|
@@ -109133,7 +109207,7 @@ function resolveClaudePluginCacheRoot(opts) {
|
|
|
109133
109207
|
if (explicitRoot)
|
|
109134
109208
|
return explicitRoot;
|
|
109135
109209
|
const home = opts.home ?? process.env[CLAUDE_PLUGIN_CACHE_HOME_ENV] ?? homedir();
|
|
109136
|
-
return
|
|
109210
|
+
return join99(home, ".claude", "plugins", "cache");
|
|
109137
109211
|
}
|
|
109138
109212
|
async function isEmptyDir(dir) {
|
|
109139
109213
|
try {
|
|
@@ -109165,13 +109239,13 @@ init_exitCode();
|
|
|
109165
109239
|
|
|
109166
109240
|
// src/lib/packageVersion.ts
|
|
109167
109241
|
import { existsSync as existsSync28, readFileSync as readFileSync9 } from "node:fs";
|
|
109168
|
-
import { dirname as dirname42, join as
|
|
109242
|
+
import { dirname as dirname42, join as join100 } from "node:path";
|
|
109169
109243
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
109170
109244
|
function readPackageVersion() {
|
|
109171
109245
|
try {
|
|
109172
109246
|
let dir = dirname42(fileURLToPath7(import.meta.url));
|
|
109173
109247
|
for (let depth = 0;depth < 8; depth += 1) {
|
|
109174
|
-
const packagePath =
|
|
109248
|
+
const packagePath = join100(dir, "package.json");
|
|
109175
109249
|
if (existsSync28(packagePath)) {
|
|
109176
109250
|
const parsed = JSON.parse(readFileSync9(packagePath, "utf8"));
|
|
109177
109251
|
if (typeof parsed.version === "string" && parsed.version.length > 0) {
|
|
@@ -109194,7 +109268,7 @@ function readPackageVersion() {
|
|
|
109194
109268
|
|
|
109195
109269
|
// src/project/sourceCommands.ts
|
|
109196
109270
|
init_src2();
|
|
109197
|
-
import { readFile as
|
|
109271
|
+
import { readFile as readFile88 } from "node:fs/promises";
|
|
109198
109272
|
import { isAbsolute as isAbsolute22, resolve as resolve37 } from "node:path";
|
|
109199
109273
|
init_cliFeedback();
|
|
109200
109274
|
init_errors3();
|
|
@@ -109553,11 +109627,11 @@ async function restoreRepositorySources(input) {
|
|
|
109553
109627
|
// src/project/sourceDocumentStatus.ts
|
|
109554
109628
|
init_src2();
|
|
109555
109629
|
import { existsSync as existsSync30 } from "node:fs";
|
|
109630
|
+
import { readFile as readFile81 } from "node:fs/promises";
|
|
109631
|
+
import { join as join102 } from "node:path";
|
|
109632
|
+
// src/project/sourceCommandViews.ts
|
|
109556
109633
|
import { readFile as readFile80 } from "node:fs/promises";
|
|
109557
109634
|
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
109635
|
init_workspace();
|
|
109562
109636
|
init_documentBatchManifest();
|
|
109563
109637
|
function repoSourceAgentView(source2) {
|
|
@@ -109620,7 +109694,7 @@ async function fileSourceAgentViewWithNextAction(input) {
|
|
|
109620
109694
|
};
|
|
109621
109695
|
}
|
|
109622
109696
|
function documentSourceManifestPath(source2) {
|
|
109623
|
-
return source2.snapshot?.manifest ??
|
|
109697
|
+
return source2.snapshot?.manifest ?? join101(source2.materializedAt, "manifest.json");
|
|
109624
109698
|
}
|
|
109625
109699
|
async function fileSourceDocumentSiteHint(input) {
|
|
109626
109700
|
const detection = await detectDocumentSiteFiles({
|
|
@@ -109630,7 +109704,7 @@ async function fileSourceDocumentSiteHint(input) {
|
|
|
109630
109704
|
let snapshotConfigured = false;
|
|
109631
109705
|
const manifest = documentSourceManifestPath(input.source);
|
|
109632
109706
|
try {
|
|
109633
|
-
const parsed = parseDocumentSnapshotForSource(JSON.parse(await
|
|
109707
|
+
const parsed = parseDocumentSnapshotForSource(JSON.parse(await readFile80(join101(input.projectRoot, manifest), "utf8")), input.source.name);
|
|
109634
109708
|
snapshotConfigured = manifestUsesMdxJsonDocs(parsed);
|
|
109635
109709
|
} catch {
|
|
109636
109710
|
snapshotConfigured = false;
|
|
@@ -109662,11 +109736,11 @@ async function larkSourceAgentViewWithNextAction(input) {
|
|
|
109662
109736
|
// src/project/sourceDocumentStatus.ts
|
|
109663
109737
|
init_documentBatchManifest();
|
|
109664
109738
|
function documentSourceManifestPath2(source2) {
|
|
109665
|
-
return source2.snapshot?.manifest ??
|
|
109739
|
+
return source2.snapshot?.manifest ?? join102(source2.materializedAt, "manifest.json");
|
|
109666
109740
|
}
|
|
109667
109741
|
async function documentSnapshotState(input) {
|
|
109668
109742
|
const manifest = documentSourceManifestPath2(input.source);
|
|
109669
|
-
const manifestPath =
|
|
109743
|
+
const manifestPath = join102(input.projectRoot, manifest);
|
|
109670
109744
|
if (!existsSync30(manifestPath)) {
|
|
109671
109745
|
return {
|
|
109672
109746
|
snapshotReady: false,
|
|
@@ -109677,7 +109751,7 @@ async function documentSnapshotState(input) {
|
|
|
109677
109751
|
};
|
|
109678
109752
|
}
|
|
109679
109753
|
try {
|
|
109680
|
-
const parsed = findDocumentSnapshotForSource(JSON.parse(await
|
|
109754
|
+
const parsed = findDocumentSnapshotForSource(JSON.parse(await readFile81(manifestPath, "utf8")), input.source.name);
|
|
109681
109755
|
if (parsed === null) {
|
|
109682
109756
|
return {
|
|
109683
109757
|
snapshotReady: false,
|
|
@@ -109745,7 +109819,7 @@ async function documentSnapshotState(input) {
|
|
|
109745
109819
|
const missing = [
|
|
109746
109820
|
...parsed.files.map((file) => file.path),
|
|
109747
109821
|
...(parsed.assets ?? []).filter((asset) => asset.content_hash !== undefined).map((asset) => asset.path)
|
|
109748
|
-
].find((path3) => !existsSync30(
|
|
109822
|
+
].find((path3) => !existsSync30(join102(input.projectRoot, input.source.materializedAt, path3)));
|
|
109749
109823
|
if (missing !== undefined) {
|
|
109750
109824
|
return {
|
|
109751
109825
|
snapshotReady: false,
|
|
@@ -109846,8 +109920,8 @@ init_errors3();
|
|
|
109846
109920
|
init_exitCode();
|
|
109847
109921
|
var import_yaml46 = __toESM(require_dist(), 1);
|
|
109848
109922
|
import { createHash as createHash30 } from "node:crypto";
|
|
109849
|
-
import { readFile as
|
|
109850
|
-
import { basename as basename12, extname as extname15, isAbsolute as isAbsolute20, join as
|
|
109923
|
+
import { readFile as readFile82, realpath as realpath11 } from "node:fs/promises";
|
|
109924
|
+
import { basename as basename12, extname as extname15, isAbsolute as isAbsolute20, join as join103, relative as relative27, resolve as resolve35 } from "node:path";
|
|
109851
109925
|
init_writeLock();
|
|
109852
109926
|
var SOURCE_NAME_PATTERN3 = /^[a-z0-9][a-z0-9._-]*$/u;
|
|
109853
109927
|
function isDateSourceNamespace(value) {
|
|
@@ -109943,7 +110017,7 @@ function assertSafeFileInclude(value) {
|
|
|
109943
110017
|
}
|
|
109944
110018
|
async function readRegistryDocument(projectRoot, registryPath2) {
|
|
109945
110019
|
try {
|
|
109946
|
-
const content3 = await
|
|
110020
|
+
const content3 = await readFile82(join103(projectRoot, registryPath2), "utf8");
|
|
109947
110021
|
return content3.trim().length === 0 ? { sources: [] } : import_yaml46.default.parse(content3);
|
|
109948
110022
|
} catch (error) {
|
|
109949
110023
|
if (error instanceof Error && "code" in error && error.code === "ENOENT")
|
|
@@ -110061,7 +110135,7 @@ async function addFileSourceUnlocked(input) {
|
|
|
110061
110135
|
const record6 = entry2;
|
|
110062
110136
|
return record6.name !== input.name && record6.id !== input.name;
|
|
110063
110137
|
}), nextEntry];
|
|
110064
|
-
await atomicWriteFile(
|
|
110138
|
+
await atomicWriteFile(join103(input.projectRoot, DEFAULT_FILE_SOURCES_REGISTRY_PATH), import_yaml46.default.stringify({ sources: nextSources }));
|
|
110065
110139
|
const updated = await loadSourcesRegistry({ rootDir: input.projectRoot });
|
|
110066
110140
|
const entry = updated.files.find((source2) => source2.name === input.name || source2.id === input.name);
|
|
110067
110141
|
if (entry === undefined) {
|
|
@@ -110117,7 +110191,7 @@ async function addLarkSourceUnlocked(input) {
|
|
|
110117
110191
|
const record6 = entry2;
|
|
110118
110192
|
return record6.name !== input.name && record6.id !== input.name;
|
|
110119
110193
|
}), nextEntry];
|
|
110120
|
-
await atomicWriteFile(
|
|
110194
|
+
await atomicWriteFile(join103(input.projectRoot, DEFAULT_LARK_SOURCES_REGISTRY_PATH), import_yaml46.default.stringify({ sources: nextSources }));
|
|
110121
110195
|
const updated = await loadSourcesRegistry({ rootDir: input.projectRoot });
|
|
110122
110196
|
const entry = updated.larks.find((source2) => source2.name === input.name || source2.id === input.name);
|
|
110123
110197
|
if (entry === undefined) {
|
|
@@ -110320,8 +110394,8 @@ init_writeLock();
|
|
|
110320
110394
|
var import_yaml47 = __toESM(require_dist(), 1);
|
|
110321
110395
|
import { existsSync as existsSync31 } from "node:fs";
|
|
110322
110396
|
import { createHash as createHash31 } from "node:crypto";
|
|
110323
|
-
import { readFile as
|
|
110324
|
-
import { isAbsolute as isAbsolute21, join as
|
|
110397
|
+
import { readFile as readFile83, readdir as readdir26, rm as rm22 } from "node:fs/promises";
|
|
110398
|
+
import { isAbsolute as isAbsolute21, join as join104, relative as relative28, resolve as resolve36, sep as sep8 } from "node:path";
|
|
110325
110399
|
function sourceIdentity(source2) {
|
|
110326
110400
|
if (source2.kind === "source.collection")
|
|
110327
110401
|
return;
|
|
@@ -110353,10 +110427,10 @@ function collectStrings(value, output) {
|
|
|
110353
110427
|
}
|
|
110354
110428
|
}
|
|
110355
110429
|
async function yamlReferences(input) {
|
|
110356
|
-
const absolutePath =
|
|
110430
|
+
const absolutePath = join104(input.projectRoot, input.path);
|
|
110357
110431
|
if (!existsSync31(absolutePath))
|
|
110358
110432
|
return false;
|
|
110359
|
-
const parsed = import_yaml47.default.parse(await
|
|
110433
|
+
const parsed = import_yaml47.default.parse(await readFile83(absolutePath, "utf8"));
|
|
110360
110434
|
const strings = [];
|
|
110361
110435
|
collectStrings(parsed, strings);
|
|
110362
110436
|
return strings.some((value) => stringReferencesSource(value, input.source));
|
|
@@ -110482,8 +110556,8 @@ async function registryRemovalWrite(projectRoot, source2) {
|
|
|
110482
110556
|
const path3 = registryPath2(source2.type);
|
|
110483
110557
|
if (path3 === null)
|
|
110484
110558
|
return;
|
|
110485
|
-
const absolutePath =
|
|
110486
|
-
const document4 = existsSync31(absolutePath) ? import_yaml47.default.parse(await
|
|
110559
|
+
const absolutePath = join104(projectRoot, path3);
|
|
110560
|
+
const document4 = existsSync31(absolutePath) ? import_yaml47.default.parse(await readFile83(absolutePath, "utf8")) : { sources: [] };
|
|
110487
110561
|
return {
|
|
110488
110562
|
path: absolutePath,
|
|
110489
110563
|
bytes: import_yaml47.default.stringify(removeDocumentEntry(document4, source2))
|
|
@@ -110501,7 +110575,7 @@ function safeManagedMaterializedPath(projectRoot, source2) {
|
|
|
110501
110575
|
return absolute;
|
|
110502
110576
|
}
|
|
110503
110577
|
function safeManagedManifestPath(projectRoot, source2) {
|
|
110504
|
-
const manifest = source2.manifest ??
|
|
110578
|
+
const manifest = source2.manifest ?? join104(source2.materializedAt, "manifest.json");
|
|
110505
110579
|
if (isAbsolute21(manifest))
|
|
110506
110580
|
throw unsafeOwnership(source2, manifest);
|
|
110507
110581
|
const absolute = resolve36(projectRoot, manifest);
|
|
@@ -110630,7 +110704,7 @@ async function createRemovalPlan(projectRoot, selector) {
|
|
|
110630
110704
|
source: source2,
|
|
110631
110705
|
registry: registryPath2(source2.type),
|
|
110632
110706
|
registryBytes: registryWrite?.bytes ?? null,
|
|
110633
|
-
managedBytes: source2.type === "note" || source2.type === "sessions" ? await
|
|
110707
|
+
managedBytes: source2.type === "note" || source2.type === "sessions" ? await readFile83(absoluteRemovals[0], "utf8") : null,
|
|
110634
110708
|
references,
|
|
110635
110709
|
cleanup,
|
|
110636
110710
|
manifestBytes: manifestWrite?.bytes ?? null
|
|
@@ -110663,10 +110737,10 @@ function publicRemovalResult(plan, action) {
|
|
|
110663
110737
|
};
|
|
110664
110738
|
}
|
|
110665
110739
|
async function pruneExtractRuntime(projectRoot, source2) {
|
|
110666
|
-
const fingerprintPath =
|
|
110740
|
+
const fingerprintPath = join104(projectRoot, ".tmp/context-runtime/extract/source-fingerprints.json");
|
|
110667
110741
|
const removedPhaseIds = new Set;
|
|
110668
110742
|
if (existsSync31(fingerprintPath)) {
|
|
110669
|
-
const parsed = JSON.parse(await
|
|
110743
|
+
const parsed = JSON.parse(await readFile83(fingerprintPath, "utf8"));
|
|
110670
110744
|
const phases = parsed.phases ?? {};
|
|
110671
110745
|
const next2 = Object.fromEntries(Object.entries(phases).filter(([phaseId, raw]) => {
|
|
110672
110746
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw))
|
|
@@ -110680,27 +110754,27 @@ async function pruneExtractRuntime(projectRoot, source2) {
|
|
|
110680
110754
|
await atomicWriteFile(fingerprintPath, `${JSON.stringify({ ...parsed, phases: next2 }, null, 2)}
|
|
110681
110755
|
`);
|
|
110682
110756
|
}
|
|
110683
|
-
const phaseOwnershipPath =
|
|
110757
|
+
const phaseOwnershipPath = join104(projectRoot, ".tmp/context-runtime/extract/custom-phase-candidates.json");
|
|
110684
110758
|
if (existsSync31(phaseOwnershipPath) && removedPhaseIds.size > 0) {
|
|
110685
|
-
const parsed = JSON.parse(await
|
|
110759
|
+
const parsed = JSON.parse(await readFile83(phaseOwnershipPath, "utf8"));
|
|
110686
110760
|
const phases = Object.fromEntries(Object.entries(parsed.phases ?? {}).filter(([phaseId]) => !removedPhaseIds.has(phaseId)));
|
|
110687
110761
|
await atomicWriteFile(phaseOwnershipPath, `${JSON.stringify({ ...parsed, phases }, null, 2)}
|
|
110688
110762
|
`);
|
|
110689
110763
|
}
|
|
110690
|
-
const symbolPath =
|
|
110764
|
+
const symbolPath = join104(projectRoot, ".tmp/context-runtime/extract/source-symbols.json");
|
|
110691
110765
|
if (existsSync31(symbolPath)) {
|
|
110692
|
-
const parsed = JSON.parse(await
|
|
110766
|
+
const parsed = JSON.parse(await readFile83(symbolPath, "utf8"));
|
|
110693
110767
|
const symbols = Array.isArray(parsed.symbols) ? parsed.symbols.filter((entry) => entry === null || typeof entry !== "object" || Array.isArray(entry) || entry.source !== source2.name) : [];
|
|
110694
110768
|
const phaseFingerprints = Object.fromEntries(Object.entries(parsed.phaseFingerprints ?? {}).filter(([phaseId]) => !removedPhaseIds.has(phaseId)));
|
|
110695
110769
|
await atomicWriteFile(symbolPath, `${JSON.stringify({ ...parsed, phaseFingerprints, symbols }, null, 2)}
|
|
110696
110770
|
`);
|
|
110697
110771
|
}
|
|
110698
|
-
const snapshotRoot =
|
|
110772
|
+
const snapshotRoot = join104(projectRoot, ".tmp/context-runtime/extract/candidates");
|
|
110699
110773
|
const visit4 = async (directory) => {
|
|
110700
110774
|
if (!existsSync31(directory))
|
|
110701
110775
|
return;
|
|
110702
110776
|
for (const entry of await readdir26(directory, { withFileTypes: true })) {
|
|
110703
|
-
const path3 =
|
|
110777
|
+
const path3 = join104(directory, entry.name);
|
|
110704
110778
|
if (entry.isDirectory()) {
|
|
110705
110779
|
await visit4(path3);
|
|
110706
110780
|
continue;
|
|
@@ -110708,7 +110782,7 @@ async function pruneExtractRuntime(projectRoot, source2) {
|
|
|
110708
110782
|
if (!entry.isFile() || !entry.name.endsWith(".json"))
|
|
110709
110783
|
continue;
|
|
110710
110784
|
try {
|
|
110711
|
-
const parsed = JSON.parse(await
|
|
110785
|
+
const parsed = JSON.parse(await readFile83(path3, "utf8"));
|
|
110712
110786
|
const refs = Array.isArray(parsed.source_refs) ? parsed.source_refs : [];
|
|
110713
110787
|
if (parsed.source === source2.name || refs.some((ref2) => typeof ref2 === "string" && stringReferencesSource(ref2, source2))) {
|
|
110714
110788
|
await rm22(path3, { force: true });
|
|
@@ -110750,7 +110824,7 @@ async function removeProjectSource(input) {
|
|
|
110750
110824
|
});
|
|
110751
110825
|
}
|
|
110752
110826
|
await applyAtomicFileBatch({
|
|
110753
|
-
transactionRoot:
|
|
110827
|
+
transactionRoot: join104(input.projectRoot, ".tmp", "context-runtime", "source-remove-transactions"),
|
|
110754
110828
|
writes: [...plan.registryWrite === undefined ? [] : [plan.registryWrite], ...plan.manifestWrite !== undefined ? [plan.manifestWrite] : []],
|
|
110755
110829
|
removals: plan.absoluteRemovals
|
|
110756
110830
|
});
|
|
@@ -110766,7 +110840,7 @@ init_workspace();
|
|
|
110766
110840
|
init_writeLock();
|
|
110767
110841
|
init_durableMultiFileTransaction();
|
|
110768
110842
|
init_durableSingleFileTransaction();
|
|
110769
|
-
import { readFile as
|
|
110843
|
+
import { readFile as readFile84 } from "node:fs/promises";
|
|
110770
110844
|
import ts from "typescript";
|
|
110771
110845
|
function generateSourceConfiguration(text10, selected) {
|
|
110772
110846
|
const file = ts.createSourceFile("index.ts", text10, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
|
|
@@ -110906,7 +110980,7 @@ function generateSourceConfiguration(text10, selected) {
|
|
|
110906
110980
|
async function configureRegisteredSources(projectRoot, selected) {
|
|
110907
110981
|
return withProjectWriteLock(projectRoot, "source-project-configuration", async () => {
|
|
110908
110982
|
const path3 = "src/index.ts";
|
|
110909
|
-
const config = JSON.parse(await
|
|
110983
|
+
const config = JSON.parse(await readFile84(await safeProjectTarget(projectRoot, "package.json"), "utf8"));
|
|
110910
110984
|
if (config.context?.entry !== path3)
|
|
110911
110985
|
return {
|
|
110912
110986
|
status: "manual",
|
|
@@ -110915,7 +110989,7 @@ async function configureRegisteredSources(projectRoot, selected) {
|
|
|
110915
110989
|
sources: selected
|
|
110916
110990
|
};
|
|
110917
110991
|
const target = await safeProjectTarget(projectRoot, path3);
|
|
110918
|
-
const text10 = await
|
|
110992
|
+
const text10 = await readFile84(target, "utf8");
|
|
110919
110993
|
const updated = generateSourceConfiguration(text10, selected);
|
|
110920
110994
|
if (updated === undefined)
|
|
110921
110995
|
return {
|
|
@@ -110995,7 +111069,7 @@ async function readIncludeList(projectRoot, path3) {
|
|
|
110995
111069
|
}
|
|
110996
111070
|
let content3;
|
|
110997
111071
|
try {
|
|
110998
|
-
content3 = await
|
|
111072
|
+
content3 = await readFile88(isAbsolute22(trimmed) ? resolve37(trimmed) : resolve37(projectRoot, trimmed), "utf8");
|
|
110999
111073
|
} catch (error) {
|
|
111000
111074
|
throw new ContextError(ExitCode.UserError, `cannot read include list: ${trimmed}`, {
|
|
111001
111075
|
category: ErrorCategory.UserInputInvalid,
|
|
@@ -111393,7 +111467,7 @@ init_exitCode();
|
|
|
111393
111467
|
var import_yaml50 = __toESM(require_dist(), 1);
|
|
111394
111468
|
import { constants as constants6, existsSync as existsSync32 } from "node:fs";
|
|
111395
111469
|
import { lstat as lstat13, open as open5, readdir as readdir27 } from "node:fs/promises";
|
|
111396
|
-
import { dirname as dirname44, join as
|
|
111470
|
+
import { dirname as dirname44, join as join106, resolve as resolve38 } from "node:path";
|
|
111397
111471
|
import { fileURLToPath as fileURLToPath8 } from "node:url";
|
|
111398
111472
|
function bundledSkillRoot() {
|
|
111399
111473
|
const directory = dirname44(fileURLToPath8(import.meta.url));
|
|
@@ -111423,7 +111497,7 @@ async function readProductionSkills(root2) {
|
|
|
111423
111497
|
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
111498
|
const skills = [];
|
|
111425
111499
|
for (const directory of entries2) {
|
|
111426
|
-
const entry =
|
|
111500
|
+
const entry = join106(root2, directory.name, "SKILL.md");
|
|
111427
111501
|
if (!(await lstat13(entry)).isFile())
|
|
111428
111502
|
throw new TypeError(`Skill entry must be a regular file: ${entry}`);
|
|
111429
111503
|
const handle2 = await open5(entry, constants6.O_RDONLY | constants6.O_NOFOLLOW | constants6.O_NONBLOCK);
|
|
@@ -111831,7 +111905,7 @@ init_cliFeedback();
|
|
|
111831
111905
|
init_errors3();
|
|
111832
111906
|
init_exitCode();
|
|
111833
111907
|
import { existsSync as existsSync35 } from "node:fs";
|
|
111834
|
-
import { dirname as dirname47, join as
|
|
111908
|
+
import { dirname as dirname47, join as join108, resolve as resolve40 } from "node:path";
|
|
111835
111909
|
import { fileURLToPath as fileURLToPath9 } from "node:url";
|
|
111836
111910
|
|
|
111837
111911
|
// src/project/pluginInstallTargets.ts
|
|
@@ -111840,9 +111914,9 @@ init_errors3();
|
|
|
111840
111914
|
init_exitCode();
|
|
111841
111915
|
import { execFile as execFile12 } from "node:child_process";
|
|
111842
111916
|
import { existsSync as existsSync34 } from "node:fs";
|
|
111843
|
-
import { cp as cp2, mkdir as mkdir35, readdir as readdir28, readFile as
|
|
111917
|
+
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
111918
|
import { homedir as homedir2 } from "node:os";
|
|
111845
|
-
import { dirname as dirname46, join as
|
|
111919
|
+
import { dirname as dirname46, join as join107 } from "node:path";
|
|
111846
111920
|
import { promisify as promisify12 } from "node:util";
|
|
111847
111921
|
var execFileAsync7 = promisify12(execFile12);
|
|
111848
111922
|
var MARKETPLACE_NAME = "c4a";
|
|
@@ -111896,23 +111970,23 @@ async function claudePluginInstalled(pluginId) {
|
|
|
111896
111970
|
}
|
|
111897
111971
|
}
|
|
111898
111972
|
function codexHome() {
|
|
111899
|
-
return process.env.CODEX_HOME?.trim() ||
|
|
111973
|
+
return process.env.CODEX_HOME?.trim() || join107(homedir2(), ".codex");
|
|
111900
111974
|
}
|
|
111901
111975
|
function claudePluginCacheRoot() {
|
|
111902
111976
|
const explicitRoot = process.env[CLAUDE_PLUGIN_CACHE_ROOT_ENV2]?.trim();
|
|
111903
111977
|
if (explicitRoot)
|
|
111904
111978
|
return explicitRoot;
|
|
111905
111979
|
const home = process.env[CLAUDE_PLUGIN_CACHE_HOME_ENV2]?.trim() || homedir2();
|
|
111906
|
-
return
|
|
111980
|
+
return join107(home, ".claude", "plugins", "cache");
|
|
111907
111981
|
}
|
|
111908
111982
|
function sharedSkillsRoot() {
|
|
111909
|
-
return process.env[SHARED_SKILLS_ROOT_ENV]?.trim() ||
|
|
111983
|
+
return process.env[SHARED_SKILLS_ROOT_ENV]?.trim() || join107(homedir2(), ".agents", "skills");
|
|
111910
111984
|
}
|
|
111911
111985
|
function claudeSkillsRoot() {
|
|
111912
|
-
return process.env[CLAUDE_SKILLS_ROOT_ENV]?.trim() ||
|
|
111986
|
+
return process.env[CLAUDE_SKILLS_ROOT_ENV]?.trim() || join107(homedir2(), ".claude", "skills");
|
|
111913
111987
|
}
|
|
111914
111988
|
function cursorPluginRoot() {
|
|
111915
|
-
return process.env[CURSOR_PLUGIN_ROOT_ENV]?.trim() ||
|
|
111989
|
+
return process.env[CURSOR_PLUGIN_ROOT_ENV]?.trim() || join107(homedir2(), ".cursor", "plugins", "local", PLUGIN_NAME);
|
|
111916
111990
|
}
|
|
111917
111991
|
function blockHeader(line) {
|
|
111918
111992
|
const match = line.match(/^\s*\[([^\]]+)\]\s*$/u);
|
|
@@ -111963,8 +112037,8 @@ function pruneLegacyCodexConfigContent(content3) {
|
|
|
111963
112037
|
`), removed };
|
|
111964
112038
|
}
|
|
111965
112039
|
async function pruneLegacyCodexConfig(dryRun, steps) {
|
|
111966
|
-
const configPath =
|
|
111967
|
-
const current2 = await
|
|
112040
|
+
const configPath = join107(codexHome(), "config.toml");
|
|
112041
|
+
const current2 = await readFile89(configPath, "utf8").catch(() => "");
|
|
111968
112042
|
if (!current2)
|
|
111969
112043
|
return;
|
|
111970
112044
|
const next2 = pruneLegacyCodexConfigContent(current2);
|
|
@@ -111976,11 +112050,11 @@ async function pruneLegacyCodexConfig(dryRun, steps) {
|
|
|
111976
112050
|
status: dryRun ? "planned" : "ran"
|
|
111977
112051
|
});
|
|
111978
112052
|
if (!dryRun) {
|
|
111979
|
-
await
|
|
112053
|
+
await writeFile27(configPath, next2.content, "utf8");
|
|
111980
112054
|
}
|
|
111981
112055
|
}
|
|
111982
112056
|
async function pruneCodexPluginCacheForName(pluginName, keepVersion, dryRun, steps) {
|
|
111983
|
-
const cacheRoot =
|
|
112057
|
+
const cacheRoot = join107(codexHome(), "plugins", "cache", MARKETPLACE_NAME, pluginName);
|
|
111984
112058
|
if (!existsSync34(cacheRoot))
|
|
111985
112059
|
return;
|
|
111986
112060
|
const versions = (await readdir28(cacheRoot, { withFileTypes: true }).catch(() => [])).filter((entry) => entry.isDirectory() && entry.name !== keepVersion).map((entry) => entry.name).sort();
|
|
@@ -111992,7 +112066,7 @@ async function pruneCodexPluginCacheForName(pluginName, keepVersion, dryRun, ste
|
|
|
111992
112066
|
status: dryRun ? "planned" : "ran"
|
|
111993
112067
|
});
|
|
111994
112068
|
if (!dryRun)
|
|
111995
|
-
await Promise.all(versions.map((version3) => rm23(
|
|
112069
|
+
await Promise.all(versions.map((version3) => rm23(join107(cacheRoot, version3), { recursive: true, force: true })));
|
|
111996
112070
|
}
|
|
111997
112071
|
async function pruneCodexPluginCache(currentVersion, dryRun, steps) {
|
|
111998
112072
|
await pruneCodexPluginCacheForName(PLUGIN_NAME, currentVersion, dryRun, steps);
|
|
@@ -112016,15 +112090,15 @@ async function pruneClaudeOrphanContextCache(dryRun, steps) {
|
|
|
112016
112090
|
for (const marketplace of marketplaces) {
|
|
112017
112091
|
if (!marketplace.isDirectory())
|
|
112018
112092
|
continue;
|
|
112019
|
-
const pluginDir =
|
|
112093
|
+
const pluginDir = join107(cacheRoot, marketplace.name, PLUGIN_NAME);
|
|
112020
112094
|
if (!existsSync34(pluginDir))
|
|
112021
112095
|
continue;
|
|
112022
112096
|
const versions = await readdir28(pluginDir, { withFileTypes: true }).catch(() => []);
|
|
112023
112097
|
for (const version3 of versions) {
|
|
112024
112098
|
if (!version3.isDirectory())
|
|
112025
112099
|
continue;
|
|
112026
|
-
const versionDir =
|
|
112027
|
-
if (!existsSync34(
|
|
112100
|
+
const versionDir = join107(pluginDir, version3.name);
|
|
112101
|
+
if (!existsSync34(join107(versionDir, ORPHAN_MARKER2)))
|
|
112028
112102
|
continue;
|
|
112029
112103
|
removed.push(`${marketplace.name}/${PLUGIN_NAME}/${version3.name}`);
|
|
112030
112104
|
if (!dryRun) {
|
|
@@ -112034,7 +112108,7 @@ async function pruneClaudeOrphanContextCache(dryRun, steps) {
|
|
|
112034
112108
|
if (!dryRun && await isEmptyDir2(pluginDir)) {
|
|
112035
112109
|
await rm23(pluginDir, { recursive: true, force: true });
|
|
112036
112110
|
}
|
|
112037
|
-
const marketplaceDir =
|
|
112111
|
+
const marketplaceDir = join107(cacheRoot, marketplace.name);
|
|
112038
112112
|
if (!dryRun && await isEmptyDir2(marketplaceDir)) {
|
|
112039
112113
|
await rm23(marketplaceDir, { recursive: true, force: true });
|
|
112040
112114
|
}
|
|
@@ -112055,7 +112129,7 @@ async function pruneClaudeLegacyPluginCache(dryRun, steps) {
|
|
|
112055
112129
|
return;
|
|
112056
112130
|
const removed = [];
|
|
112057
112131
|
for (const pluginName of LEGACY_PLUGIN_NAMES) {
|
|
112058
|
-
const pluginDir =
|
|
112132
|
+
const pluginDir = join107(cacheRoot, MARKETPLACE_NAME, pluginName);
|
|
112059
112133
|
if (!existsSync34(pluginDir))
|
|
112060
112134
|
continue;
|
|
112061
112135
|
removed.push(`${MARKETPLACE_NAME}/${pluginName}`);
|
|
@@ -112072,11 +112146,11 @@ async function pruneClaudeLegacyPluginCache(dryRun, steps) {
|
|
|
112072
112146
|
}
|
|
112073
112147
|
}
|
|
112074
112148
|
async function pruneClaudeSupersededContextCache(root2, dryRun, steps) {
|
|
112075
|
-
const manifest = await
|
|
112149
|
+
const manifest = await readFile89(join107(root2, "claude", ".claude-plugin", "plugin.json"), "utf8").then((content3) => JSON.parse(content3)).catch(() => null);
|
|
112076
112150
|
const currentVersion = typeof manifest?.version === "string" ? manifest.version : null;
|
|
112077
112151
|
if (!currentVersion)
|
|
112078
112152
|
return;
|
|
112079
|
-
const pluginDir =
|
|
112153
|
+
const pluginDir = join107(claudePluginCacheRoot(), MARKETPLACE_NAME, PLUGIN_NAME);
|
|
112080
112154
|
const staleVersions = (await readdir28(pluginDir, { withFileTypes: true }).catch(() => [])).filter((entry) => entry.isDirectory() && entry.name !== currentVersion).map((entry) => entry.name);
|
|
112081
112155
|
if (staleVersions.length === 0)
|
|
112082
112156
|
return;
|
|
@@ -112086,7 +112160,7 @@ async function pruneClaudeSupersededContextCache(root2, dryRun, steps) {
|
|
|
112086
112160
|
status: dryRun ? "planned" : "ran"
|
|
112087
112161
|
});
|
|
112088
112162
|
if (!dryRun) {
|
|
112089
|
-
await Promise.all(staleVersions.map((version3) => rm23(
|
|
112163
|
+
await Promise.all(staleVersions.map((version3) => rm23(join107(pluginDir, version3), { recursive: true, force: true })));
|
|
112090
112164
|
}
|
|
112091
112165
|
}
|
|
112092
112166
|
function enableCodexPluginConfig(content3) {
|
|
@@ -112150,33 +112224,33 @@ source = ${JSON.stringify(root2)}
|
|
|
112150
112224
|
`;
|
|
112151
112225
|
}
|
|
112152
112226
|
async function ensureCodexPluginEnabled() {
|
|
112153
|
-
const configPath =
|
|
112227
|
+
const configPath = join107(codexHome(), "config.toml");
|
|
112154
112228
|
await mkdir35(dirname46(configPath), { recursive: true });
|
|
112155
|
-
const current2 = await
|
|
112229
|
+
const current2 = await readFile89(configPath, "utf8").catch(() => "");
|
|
112156
112230
|
const next2 = enableCodexPluginConfig(current2);
|
|
112157
112231
|
if (next2 !== current2) {
|
|
112158
|
-
await
|
|
112232
|
+
await writeFile27(configPath, next2, "utf8");
|
|
112159
112233
|
}
|
|
112160
112234
|
}
|
|
112161
112235
|
async function ensureCodexLocalMarketplace(root2) {
|
|
112162
|
-
const configPath =
|
|
112236
|
+
const configPath = join107(codexHome(), "config.toml");
|
|
112163
112237
|
await mkdir35(dirname46(configPath), { recursive: true });
|
|
112164
|
-
const current2 = await
|
|
112238
|
+
const current2 = await readFile89(configPath, "utf8").catch(() => "");
|
|
112165
112239
|
const next2 = upsertCodexLocalMarketplaceConfig(current2, root2);
|
|
112166
112240
|
if (next2 !== current2) {
|
|
112167
|
-
await
|
|
112241
|
+
await writeFile27(configPath, next2, "utf8");
|
|
112168
112242
|
}
|
|
112169
112243
|
}
|
|
112170
112244
|
async function codexPluginVersion(root2) {
|
|
112171
|
-
const manifestPath =
|
|
112172
|
-
const manifest = JSON.parse(await
|
|
112245
|
+
const manifestPath = join107(root2, "codex", ".codex-plugin", "plugin.json");
|
|
112246
|
+
const manifest = JSON.parse(await readFile89(manifestPath, "utf8"));
|
|
112173
112247
|
if (typeof manifest.version !== "string" || !/^[A-Za-z0-9][A-Za-z0-9._-]*$/u.test(manifest.version)) {
|
|
112174
112248
|
throw new Error(`Codex plugin manifest has an invalid version: ${manifestPath}`);
|
|
112175
112249
|
}
|
|
112176
112250
|
return manifest.version;
|
|
112177
112251
|
}
|
|
112178
112252
|
function codexPluginCacheDir(version3) {
|
|
112179
|
-
return
|
|
112253
|
+
return join107(codexHome(), "plugins", "cache", MARKETPLACE_NAME, PLUGIN_NAME, version3);
|
|
112180
112254
|
}
|
|
112181
112255
|
async function replaceDirectoryFromSource(source2, target) {
|
|
112182
112256
|
await mkdir35(dirname46(target), { recursive: true });
|
|
@@ -112187,19 +112261,19 @@ async function replaceDirectoryFromSource(source2, target) {
|
|
|
112187
112261
|
const hadPrevious = existsSync34(target);
|
|
112188
112262
|
try {
|
|
112189
112263
|
if (hadPrevious)
|
|
112190
|
-
await
|
|
112191
|
-
await
|
|
112264
|
+
await rename9(target, previous3);
|
|
112265
|
+
await rename9(temporary, target);
|
|
112192
112266
|
if (hadPrevious)
|
|
112193
112267
|
await rm23(previous3, { recursive: true, force: true });
|
|
112194
112268
|
} catch (error) {
|
|
112195
112269
|
await rm23(temporary, { recursive: true, force: true });
|
|
112196
112270
|
if (hadPrevious && !existsSync34(target) && existsSync34(previous3))
|
|
112197
|
-
await
|
|
112271
|
+
await rename9(previous3, target);
|
|
112198
112272
|
throw error;
|
|
112199
112273
|
}
|
|
112200
112274
|
}
|
|
112201
112275
|
async function materializeCodexPluginCache(root2, version3, dryRun, steps) {
|
|
112202
|
-
const source2 =
|
|
112276
|
+
const source2 = join107(root2, "codex");
|
|
112203
112277
|
const target = codexPluginCacheDir(version3);
|
|
112204
112278
|
steps.push({
|
|
112205
112279
|
agent: "codex",
|
|
@@ -112211,16 +112285,16 @@ async function materializeCodexPluginCache(root2, version3, dryRun, steps) {
|
|
|
112211
112285
|
await replaceDirectoryFromSource(source2, target);
|
|
112212
112286
|
}
|
|
112213
112287
|
async function bundledProviderSkillNames(root2) {
|
|
112214
|
-
const skillsRoot =
|
|
112288
|
+
const skillsRoot = join107(root2, "skills");
|
|
112215
112289
|
const entries2 = await readdir28(skillsRoot, { withFileTypes: true });
|
|
112216
112290
|
const names = [];
|
|
112217
112291
|
for (const entry of entries2) {
|
|
112218
112292
|
if (!entry.isDirectory() || entry.name === "context")
|
|
112219
112293
|
continue;
|
|
112220
|
-
const skillPath =
|
|
112294
|
+
const skillPath = join107(skillsRoot, entry.name, "SKILL.md");
|
|
112221
112295
|
if (!existsSync34(skillPath))
|
|
112222
112296
|
continue;
|
|
112223
|
-
const skill = await
|
|
112297
|
+
const skill = await readFile89(skillPath, "utf8");
|
|
112224
112298
|
if (!/^\s*context-role:\s*["']?indexer-provider["']?\s*$/mu.test(skill))
|
|
112225
112299
|
continue;
|
|
112226
112300
|
names.push(entry.name);
|
|
@@ -112232,10 +112306,10 @@ async function bundledProviderSkillNames(root2) {
|
|
|
112232
112306
|
return names;
|
|
112233
112307
|
}
|
|
112234
112308
|
async function materializeProviderSkills(root2, targetRoot, agent, dryRun, steps) {
|
|
112235
|
-
const sourceRoot2 =
|
|
112309
|
+
const sourceRoot2 = join107(root2, "skills");
|
|
112236
112310
|
for (const name3 of await bundledProviderSkillNames(root2)) {
|
|
112237
|
-
const source2 =
|
|
112238
|
-
const target =
|
|
112311
|
+
const source2 = join107(sourceRoot2, name3);
|
|
112312
|
+
const target = join107(targetRoot, name3);
|
|
112239
112313
|
steps.push({
|
|
112240
112314
|
agent,
|
|
112241
112315
|
command: `materialize lifecycle Provider skill: ${shellQuote8(source2)} -> ${shellQuote8(target)}`,
|
|
@@ -112246,7 +112320,7 @@ async function materializeProviderSkills(root2, targetRoot, agent, dryRun, steps
|
|
|
112246
112320
|
}
|
|
112247
112321
|
}
|
|
112248
112322
|
async function installCursor(root2, dryRun, steps) {
|
|
112249
|
-
const source2 =
|
|
112323
|
+
const source2 = join107(root2, "cursor");
|
|
112250
112324
|
const target = cursorPluginRoot();
|
|
112251
112325
|
steps.push({
|
|
112252
112326
|
agent: "cursor",
|
|
@@ -112301,12 +112375,12 @@ async function installCodex(root2, dryRun, steps) {
|
|
|
112301
112375
|
steps.push({ agent: "codex", command: commandLine("codex", addArgs), status: dryRun ? "planned" : "ran" });
|
|
112302
112376
|
steps.push({
|
|
112303
112377
|
agent: "codex",
|
|
112304
|
-
command: `ensure ${shellQuote8(
|
|
112378
|
+
command: `ensure ${shellQuote8(join107(codexHome(), "config.toml"))} registers local marketplace ${shellQuote8(MARKETPLACE_NAME)}`,
|
|
112305
112379
|
status: dryRun ? "planned" : "ran"
|
|
112306
112380
|
});
|
|
112307
112381
|
steps.push({
|
|
112308
112382
|
agent: "codex",
|
|
112309
|
-
command: `ensure ${shellQuote8(
|
|
112383
|
+
command: `ensure ${shellQuote8(join107(codexHome(), "config.toml"))} enables ${shellQuote8(PLUGIN_ID)}`,
|
|
112310
112384
|
status: dryRun ? "planned" : "ran"
|
|
112311
112385
|
});
|
|
112312
112386
|
if (dryRun) {
|
|
@@ -112361,13 +112435,13 @@ function pluginRootCandidates() {
|
|
|
112361
112435
|
return [resolve40(envRoot)];
|
|
112362
112436
|
const candidates = [];
|
|
112363
112437
|
for (const dir of packageCandidateDirs()) {
|
|
112364
|
-
candidates.push(
|
|
112365
|
-
candidates.push(
|
|
112438
|
+
candidates.push(join108(dir, "plugins"));
|
|
112439
|
+
candidates.push(join108(dir, "dist", "plugins"));
|
|
112366
112440
|
}
|
|
112367
112441
|
return [...new Set(candidates)];
|
|
112368
112442
|
}
|
|
112369
112443
|
function isInstallablePluginRoot(root2) {
|
|
112370
|
-
return existsSync35(
|
|
112444
|
+
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
112445
|
}
|
|
112372
112446
|
function resolveBundledPluginsRoot() {
|
|
112373
112447
|
const candidates = pluginRootCandidates();
|
|
@@ -112528,6 +112602,7 @@ function registerPluginCommands(program2) {
|
|
|
112528
112602
|
}
|
|
112529
112603
|
|
|
112530
112604
|
// src/registerPackageCommands.ts
|
|
112605
|
+
init_packageSiteAddress();
|
|
112531
112606
|
init_cliFeedback();
|
|
112532
112607
|
init_errors3();
|
|
112533
112608
|
init_packageTemplateReview();
|
|
@@ -112535,6 +112610,13 @@ init_workspace();
|
|
|
112535
112610
|
init_exitCode();
|
|
112536
112611
|
function registerPackageCommands(program2) {
|
|
112537
112612
|
const packageCommand = program2.command("package").description("Inspect or resolve package output configuration");
|
|
112613
|
+
packageCommand.command("site-url <package-name> <url>").description("Record a deployed site root in existing site maps without network checks").action(async (packageName, url) => {
|
|
112614
|
+
const root2 = findContextProjectRoot(process.cwd())?.projectRoot;
|
|
112615
|
+
if (!root2)
|
|
112616
|
+
throw new TypeError("Run inside a Context workspace");
|
|
112617
|
+
process.stdout.write(JSON.stringify(await recordPackageSiteUrl(root2, packageName, url), null, 2) + `
|
|
112618
|
+
`);
|
|
112619
|
+
});
|
|
112538
112620
|
const packageTemplate = packageCommand.command("template").description("Manage package template review state");
|
|
112539
112621
|
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
112622
|
if (packageName === undefined === (options.all !== true)) {
|
|
@@ -112597,10 +112679,10 @@ function readQuickstartPath() {
|
|
|
112597
112679
|
try {
|
|
112598
112680
|
let dir = dirname48(fileURLToPath10(import.meta.url));
|
|
112599
112681
|
for (let i2 = 0;i2 < 8; i2++) {
|
|
112600
|
-
const candidate =
|
|
112682
|
+
const candidate = join109(dir, "docs", "quickstart.md");
|
|
112601
112683
|
if (existsSync36(candidate))
|
|
112602
112684
|
return candidate;
|
|
112603
|
-
const pkg =
|
|
112685
|
+
const pkg = join109(dir, "package.json");
|
|
112604
112686
|
if (existsSync36(pkg))
|
|
112605
112687
|
return candidate;
|
|
112606
112688
|
const parent = dirname48(dir);
|
|
@@ -112609,7 +112691,7 @@ function readQuickstartPath() {
|
|
|
112609
112691
|
dir = parent;
|
|
112610
112692
|
}
|
|
112611
112693
|
} catch {}
|
|
112612
|
-
return
|
|
112694
|
+
return join109(dirname48(fileURLToPath10(import.meta.url)), "docs", "quickstart.md");
|
|
112613
112695
|
}
|
|
112614
112696
|
var GREEN = "\x1B[32m";
|
|
112615
112697
|
var RESET = "\x1B[0m";
|