@c4a/context-cli 0.7.15 → 0.7.16
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/browser/diagrams.js +2826 -0
- package/cli.js +1267 -845
- package/indexers/bundles/context-code-indexer/LICENSE.third-party +25 -0
- package/indexers/bundles/context-code-indexer/references/diagram-behavior-examples.md +647 -0
- package/indexers/bundles/context-code-indexer/references/diagram-topology-examples.md +387 -0
- package/indexers/bundles/context-code-indexer/references/diagrams.md +347 -0
- package/indexers/bundles/context-markdown-indexer/LICENSE.third-party +25 -0
- package/indexers/bundles/context-markdown-indexer/references/diagram-behavior-examples.md +647 -0
- package/indexers/bundles/context-markdown-indexer/references/diagram-topology-examples.md +387 -0
- package/indexers/bundles/context-markdown-indexer/references/diagrams.md +347 -0
- package/indexers/bundles/context-note-indexer/LICENSE.third-party +25 -0
- package/indexers/bundles/context-note-indexer/references/diagram-behavior-examples.md +647 -0
- package/indexers/bundles/context-note-indexer/references/diagram-topology-examples.md +387 -0
- package/indexers/bundles/context-note-indexer/references/diagrams.md +347 -0
- package/indexers/bundles/context-sessions-indexer/LICENSE.third-party +25 -0
- package/indexers/bundles/context-sessions-indexer/references/diagram-behavior-examples.md +647 -0
- package/indexers/bundles/context-sessions-indexer/references/diagram-topology-examples.md +387 -0
- package/indexers/bundles/context-sessions-indexer/references/diagrams.md +347 -0
- package/indexers/contracts/profile-contract.json +245 -245
- package/indexers/release-manifest.json +57 -9
- package/package.json +13 -12
- package/parserEntryWorker.js +24 -0
- package/plugins/VERSION +1 -1
- package/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/plugins/codex/.codex-plugin/plugin.json +2 -2
- package/plugins/cursor/.cursor-plugin/plugin.json +1 -1
- package/plugins/skills/context-code-indexer/LICENSE.third-party +25 -0
- package/plugins/skills/context-code-indexer/references/diagram-behavior-examples.md +647 -0
- package/plugins/skills/context-code-indexer/references/diagram-topology-examples.md +387 -0
- package/plugins/skills/context-code-indexer/references/diagrams.md +347 -0
- package/plugins/skills/context-markdown-indexer/LICENSE.third-party +25 -0
- package/plugins/skills/context-markdown-indexer/references/diagram-behavior-examples.md +647 -0
- package/plugins/skills/context-markdown-indexer/references/diagram-topology-examples.md +387 -0
- package/plugins/skills/context-markdown-indexer/references/diagrams.md +347 -0
- package/plugins/skills/context-note-indexer/LICENSE.third-party +25 -0
- package/plugins/skills/context-note-indexer/references/diagram-behavior-examples.md +647 -0
- package/plugins/skills/context-note-indexer/references/diagram-topology-examples.md +387 -0
- package/plugins/skills/context-note-indexer/references/diagrams.md +347 -0
- package/plugins/skills/context-sessions-indexer/LICENSE.third-party +25 -0
- package/plugins/skills/context-sessions-indexer/references/diagram-behavior-examples.md +647 -0
- package/plugins/skills/context-sessions-indexer/references/diagram-topology-examples.md +387 -0
- package/plugins/skills/context-sessions-indexer/references/diagrams.md +347 -0
- package/providers/context/manifest.json +5 -5
- package/providers/context/provider.yaml +1 -1
- package/providers/context/resources/manuals/guides/package-outputs.md +36 -2
package/cli.js
CHANGED
|
@@ -33491,9 +33491,31 @@ var init_esm = __esm(() => {
|
|
|
33491
33491
|
esm_default = zodToJsonSchema;
|
|
33492
33492
|
});
|
|
33493
33493
|
|
|
33494
|
+
// ../context/src/siteTheme.ts
|
|
33495
|
+
var color, siteThemeColorsSchema, siteThemeSchema, DEFAULT_SITE_THEME;
|
|
33496
|
+
var init_siteTheme = __esm(() => {
|
|
33497
|
+
init_zod();
|
|
33498
|
+
color = exports_external.string().regex(/^#(?:[\da-f]{3}|[\da-f]{6}|[\da-f]{8})$/iu, "Use a hexadecimal CSS color (#RGB, #RRGGBB or #RRGGBBAA)");
|
|
33499
|
+
siteThemeColorsSchema = exports_external.object({
|
|
33500
|
+
brand: color.optional(),
|
|
33501
|
+
accent: color.optional(),
|
|
33502
|
+
background: color.optional(),
|
|
33503
|
+
surface: color.optional(),
|
|
33504
|
+
text: color.optional(),
|
|
33505
|
+
mutedText: color.optional(),
|
|
33506
|
+
border: color.optional()
|
|
33507
|
+
}).strict();
|
|
33508
|
+
siteThemeSchema = exports_external.object({ light: siteThemeColorsSchema.optional(), dark: siteThemeColorsSchema.optional() }).strict();
|
|
33509
|
+
DEFAULT_SITE_THEME = {
|
|
33510
|
+
light: { brand: "#2563eb", accent: "#00bec8", background: "#ffffff", surface: "#f8f9fc", text: "#161e2e", mutedText: "#646b7c", border: "#e7e9ef" },
|
|
33511
|
+
dark: { brand: "#8eb7ff", accent: "#b3cfff", background: "#171b24", surface: "#1b1d24", text: "#e2e4ed", mutedText: "#a1a6b7", border: "#303440" }
|
|
33512
|
+
};
|
|
33513
|
+
});
|
|
33514
|
+
|
|
33494
33515
|
// ../context/src/packageSite.ts
|
|
33495
33516
|
var siteHrefSchema, packageSiteHomeActionSchema, packageSiteHomeResourceSchema, packageSiteHomeSchema, packageSiteSchema;
|
|
33496
33517
|
var init_packageSite = __esm(() => {
|
|
33518
|
+
init_siteTheme();
|
|
33497
33519
|
init_zod();
|
|
33498
33520
|
siteHrefSchema = exports_external.string().trim().min(1).refine((value) => /^(?:https?:\/\/|mailto:|\/(?!\/)|#)/u.test(value), "Use an https URL, mailto URL, root-relative path, or page anchor");
|
|
33499
33521
|
packageSiteHomeActionSchema = exports_external.object({
|
|
@@ -33519,6 +33541,7 @@ var init_packageSite = __esm(() => {
|
|
|
33519
33541
|
resources: exports_external.array(packageSiteHomeResourceSchema).optional()
|
|
33520
33542
|
}).strict();
|
|
33521
33543
|
packageSiteSchema = exports_external.object({
|
|
33544
|
+
theme: siteThemeSchema.optional(),
|
|
33522
33545
|
title: exports_external.string().trim().min(1).optional(),
|
|
33523
33546
|
description: exports_external.string().optional(),
|
|
33524
33547
|
lang: exports_external.string().min(1).default("en-US"),
|
|
@@ -42570,6 +42593,7 @@ var init_indexerApprovedKnowledge = __esm(() => {
|
|
|
42570
42593
|
|
|
42571
42594
|
// ../context/src/index.ts
|
|
42572
42595
|
var init_src2 = __esm(() => {
|
|
42596
|
+
init_siteTheme();
|
|
42573
42597
|
init_packageSite();
|
|
42574
42598
|
init_packageSite();
|
|
42575
42599
|
init_contracts();
|
|
@@ -70071,6 +70095,52 @@ var init_close = __esm(() => {
|
|
|
70071
70095
|
STRUCTURE_PATH4 = join49(KNOWLEDGE_ROOT, "structure.yaml");
|
|
70072
70096
|
});
|
|
70073
70097
|
|
|
70098
|
+
// src/project/siteTheme.ts
|
|
70099
|
+
import { mkdir as mkdir18, readFile as readFile42, writeFile as writeFile12 } from "node:fs/promises";
|
|
70100
|
+
import { dirname as dirname22, join as join50 } from "node:path";
|
|
70101
|
+
async function resolveSiteTheme(root, overrides, scaffold = false) {
|
|
70102
|
+
const path2 = join50(root, SITE_THEME_FILE);
|
|
70103
|
+
let file = {};
|
|
70104
|
+
try {
|
|
70105
|
+
file = siteThemeSchema.parse(JSON.parse(await readFile42(path2, "utf8")));
|
|
70106
|
+
} catch (error) {
|
|
70107
|
+
if (error.code !== "ENOENT") {
|
|
70108
|
+
throw new ContextError(ExitCode.UserError, `Invalid ${SITE_THEME_FILE}: ${error instanceof Error ? error.message : String(error)}. Fix the theme or remove the optional file to use defaults.`, { reason_code: "invalid-site-theme" });
|
|
70109
|
+
}
|
|
70110
|
+
if (scaffold) {
|
|
70111
|
+
await mkdir18(dirname22(path2), { recursive: true });
|
|
70112
|
+
try {
|
|
70113
|
+
await writeFile12(path2, JSON.stringify(DEFAULT_SITE_THEME, null, 2) + `
|
|
70114
|
+
`, { flag: "wx" });
|
|
70115
|
+
} catch (writeError) {
|
|
70116
|
+
if (writeError.code !== "EEXIST")
|
|
70117
|
+
throw writeError;
|
|
70118
|
+
}
|
|
70119
|
+
return resolveSiteTheme(root, overrides);
|
|
70120
|
+
}
|
|
70121
|
+
}
|
|
70122
|
+
const inline2 = siteThemeSchema.parse(overrides ?? {});
|
|
70123
|
+
return { light: { ...DEFAULT_SITE_THEME.light, ...file.light, ...inline2.light }, dark: { ...DEFAULT_SITE_THEME.dark, ...file.dark, ...inline2.dark } };
|
|
70124
|
+
}
|
|
70125
|
+
function siteThemeVariables(theme) {
|
|
70126
|
+
const rules = (c) => Object.entries(c).map(([key, value]) => `--context-${key.replace(/[A-Z]/gu, (x) => "-" + x.toLowerCase())}:${value};`).join("") + `
|
|
70127
|
+
--vp-c-brand-1:var(--context-brand);--vp-c-brand-2:var(--context-accent);--vp-c-brand-3:var(--context-brand);
|
|
70128
|
+
--vp-c-brand-soft:color-mix(in srgb,var(--context-brand) 8%,transparent);
|
|
70129
|
+
--vp-c-bg:var(--context-background);--vp-c-bg-alt:var(--context-surface);--vp-c-bg-soft:var(--context-surface);--vp-c-bg-elv:var(--context-background);
|
|
70130
|
+
--vp-sidebar-bg-color:var(--context-surface);--vp-nav-bg-color:var(--context-background);--vp-local-search-bg:var(--context-background);
|
|
70131
|
+
--vp-c-text-1:var(--context-text);--vp-c-text-2:var(--context-muted-text);--vp-c-text-3:var(--context-muted-text);--vp-c-divider:var(--context-border);--vp-c-border:var(--context-border);
|
|
70132
|
+
--bg:var(--context-background);--side:var(--context-surface);--text:var(--context-text);--muted:var(--context-muted-text);--line:var(--context-border);--blue:var(--context-brand);`;
|
|
70133
|
+
return `:root{${rules(theme.light)}}.dark{${rules(theme.dark)}}
|
|
70134
|
+
.node.selected,blockquote{background:color-mix(in srgb,var(--context-brand) 8%,transparent)}blockquote{border-left-color:var(--context-accent)}
|
|
70135
|
+
`;
|
|
70136
|
+
}
|
|
70137
|
+
var SITE_THEME_FILE = "src/site/theme.json";
|
|
70138
|
+
var init_siteTheme2 = __esm(() => {
|
|
70139
|
+
init_src2();
|
|
70140
|
+
init_errors3();
|
|
70141
|
+
init_exitCode();
|
|
70142
|
+
});
|
|
70143
|
+
|
|
70074
70144
|
// src/project/packageOutputPaths.ts
|
|
70075
70145
|
import { posix as posix4 } from "node:path";
|
|
70076
70146
|
function packageSiteOutputDir(pkg) {
|
|
@@ -70099,8 +70169,8 @@ var init_packageOutputPaths = __esm(() => {
|
|
|
70099
70169
|
});
|
|
70100
70170
|
|
|
70101
70171
|
// src/project/packageSiteAddress.ts
|
|
70102
|
-
import { readFile as
|
|
70103
|
-
import { join as
|
|
70172
|
+
import { readFile as readFile43, writeFile as writeFile13, rename as rename5 } from "node:fs/promises";
|
|
70173
|
+
import { join as join51 } from "node:path";
|
|
70104
70174
|
function normalizeSiteUrl(value) {
|
|
70105
70175
|
const url = new URL(value);
|
|
70106
70176
|
if (!["https:", "http:"].includes(url.protocol) || url.username || url.password || url.search || url.hash) {
|
|
@@ -70113,7 +70183,7 @@ async function readPackageSiteUrl(root, pkg) {
|
|
|
70113
70183
|
if (pkg.kind !== "package.kb" || !pkg.site)
|
|
70114
70184
|
return;
|
|
70115
70185
|
try {
|
|
70116
|
-
const map2 = JSON.parse(await
|
|
70186
|
+
const map2 = JSON.parse(await readFile43(join51(root, packageSiteOutputDir(pkg), SITE_MAP_FILE), "utf8"));
|
|
70117
70187
|
return typeof map2.site_url === "string" ? normalizeSiteUrl(map2.site_url) : undefined;
|
|
70118
70188
|
} catch (error) {
|
|
70119
70189
|
if (error.code === "ENOENT" || error instanceof SyntaxError || error instanceof TypeError)
|
|
@@ -70130,10 +70200,10 @@ async function recordPackageSiteUrl(root, packageName, value) {
|
|
|
70130
70200
|
if (!pkg || pkg.kind !== "package.kb" || !pkg.site) {
|
|
70131
70201
|
throw new TypeError("Select a declared knowledge package with a website");
|
|
70132
70202
|
}
|
|
70133
|
-
const siteMap =
|
|
70203
|
+
const siteMap = join51(root, packageSiteOutputDir(pkg), SITE_MAP_FILE);
|
|
70134
70204
|
let map2;
|
|
70135
70205
|
try {
|
|
70136
|
-
map2 = JSON.parse(await
|
|
70206
|
+
map2 = JSON.parse(await readFile43(siteMap, "utf8"));
|
|
70137
70207
|
} catch (error) {
|
|
70138
70208
|
if (error.code === "ENOENT")
|
|
70139
70209
|
throw new TypeError("Build the configured website before recording its deployment URL");
|
|
@@ -70144,8 +70214,8 @@ async function recordPackageSiteUrl(root, packageName, value) {
|
|
|
70144
70214
|
}
|
|
70145
70215
|
const content3 = JSON.stringify({ ...map2, site_url: siteUrl }, null, 2) + `
|
|
70146
70216
|
`;
|
|
70147
|
-
for (const path2 of [siteMap,
|
|
70148
|
-
await
|
|
70217
|
+
for (const path2 of [siteMap, join51(root, pkg.outDir, SITE_MAP_FILE)]) {
|
|
70218
|
+
await writeFile13(`${path2}.tmp`, content3);
|
|
70149
70219
|
await rename5(`${path2}.tmp`, path2);
|
|
70150
70220
|
}
|
|
70151
70221
|
return { package: pkg.name, site_url: siteUrl, network_checked: false };
|
|
@@ -70160,8 +70230,8 @@ var init_packageSiteAddress = __esm(() => {
|
|
|
70160
70230
|
// src/project/packageBuildReceipt.ts
|
|
70161
70231
|
import { createHash as createHash13 } from "node:crypto";
|
|
70162
70232
|
import { existsSync as existsSync15 } from "node:fs";
|
|
70163
|
-
import { readFile as
|
|
70164
|
-
import { join as
|
|
70233
|
+
import { readFile as readFile44 } from "node:fs/promises";
|
|
70234
|
+
import { join as join52, relative as relative15 } from "node:path";
|
|
70165
70235
|
function parsePackageLinkWarnings(value) {
|
|
70166
70236
|
if (!Array.isArray(value))
|
|
70167
70237
|
return [];
|
|
@@ -70176,7 +70246,7 @@ async function walkPackageFiles(root) {
|
|
|
70176
70246
|
for (const entry of entries2) {
|
|
70177
70247
|
if (IGNORED_PACKAGE_FS_ENTRIES.has(entry.name))
|
|
70178
70248
|
continue;
|
|
70179
|
-
const absPath =
|
|
70249
|
+
const absPath = join52(dir, entry.name);
|
|
70180
70250
|
if (entry.isDirectory()) {
|
|
70181
70251
|
await visit2(absPath);
|
|
70182
70252
|
continue;
|
|
@@ -70207,16 +70277,16 @@ function classifyOutputFile(path2, knowledgeGroups) {
|
|
|
70207
70277
|
}
|
|
70208
70278
|
async function packageOutputSnapshot(projectRoot, pkg, knowledgeGroups, previousOutputs = []) {
|
|
70209
70279
|
const previousByPath = new Map(previousOutputs.map((file) => [file.path, file]));
|
|
70210
|
-
const files = (await Promise.all(packageOutputDirs(pkg).map(async (output) => (await walkPackageFiles(
|
|
70280
|
+
const files = (await Promise.all(packageOutputDirs(pkg).map(async (output) => (await walkPackageFiles(join52(projectRoot, output))).map((file) => ({
|
|
70211
70281
|
...file,
|
|
70212
|
-
relPath: toPosixPath4(relative15(
|
|
70282
|
+
relPath: toPosixPath4(relative15(join52(projectRoot, pkg.outDir), file.absPath))
|
|
70213
70283
|
}))))).flat();
|
|
70214
70284
|
return Promise.all(files.map(async (file) => {
|
|
70215
70285
|
const current = classifyOutputFile(file.relPath, knowledgeGroups);
|
|
70216
70286
|
const previous2 = previousByPath.get(file.relPath);
|
|
70217
70287
|
const classification = current.kind === "file" && previous2 !== undefined ? { path: file.relPath, kind: previous2.kind, ...previous2.group === undefined ? {} : { group: previous2.group } } : current;
|
|
70218
|
-
let content3 = await
|
|
70219
|
-
if (file.absPath ===
|
|
70288
|
+
let content3 = await readFile44(file.absPath);
|
|
70289
|
+
if (file.absPath === join52(projectRoot, pkg.outDir, "context-site-map.json") || file.absPath === join52(projectRoot, packageSiteOutputDir(pkg), "context-site-map.json")) {
|
|
70220
70290
|
try {
|
|
70221
70291
|
const map2 = JSON.parse(content3.toString());
|
|
70222
70292
|
if (map2.protocol === "context.site-output/v1" && Array.isArray(map2.pages)) {
|
|
@@ -70235,8 +70305,8 @@ async function packageOutputFingerprint(projectRoot, pkg, observed) {
|
|
|
70235
70305
|
const snapshot = observed ?? await packageOutputSnapshot(projectRoot, pkg, new Map);
|
|
70236
70306
|
return {
|
|
70237
70307
|
fingerprint: createHash13("sha256").update(JSON.stringify({
|
|
70238
|
-
outDirExists: existsSync15(
|
|
70239
|
-
siteDirExists: pkg.kind === "package.kb" && pkg.site ? existsSync15(
|
|
70308
|
+
outDirExists: existsSync15(join52(projectRoot, pkg.outDir)),
|
|
70309
|
+
siteDirExists: pkg.kind === "package.kb" && pkg.site ? existsSync15(join52(projectRoot, packageSiteOutputDir(pkg))) : undefined,
|
|
70240
70310
|
files: snapshot.map(({ path: path2, sha256 }) => ({ path: path2, sha256 }))
|
|
70241
70311
|
})).digest("hex"),
|
|
70242
70312
|
files: snapshot.length
|
|
@@ -70324,8 +70394,8 @@ var init_packageBuildReceipt = __esm(() => {
|
|
|
70324
70394
|
});
|
|
70325
70395
|
|
|
70326
70396
|
// src/project/knowledgeMapCoverage.ts
|
|
70327
|
-
import { readFile as
|
|
70328
|
-
import { join as
|
|
70397
|
+
import { readFile as readFile45 } from "node:fs/promises";
|
|
70398
|
+
import { join as join53 } from "node:path";
|
|
70329
70399
|
function knowledgeMapArticleTargets(files) {
|
|
70330
70400
|
return files.flatMap((file) => {
|
|
70331
70401
|
const meta = parseKnowledgeFrontmatter(file.content);
|
|
@@ -70341,10 +70411,10 @@ function knowledgeMapArticleTargets(files) {
|
|
|
70341
70411
|
async function approvedKnowledgeMapTargets(root) {
|
|
70342
70412
|
const metadata = await readApprovedKnowledgeMetadataIndex(root);
|
|
70343
70413
|
const articles = new Map(validateArticleStructureEntries(metadata.structure?.articles ?? []).map((article) => [article.path, article]));
|
|
70344
|
-
const files = await walkPackageFiles(
|
|
70414
|
+
const files = await walkPackageFiles(join53(root, "knowledge"));
|
|
70345
70415
|
const content3 = await Promise.all(files.filter((file) => isApprovedKnowledgeMarkdownPath(file.relPath) && !file.relPath.startsWith("assets/")).map(async (file) => ({
|
|
70346
70416
|
article: articles.get(file.relPath),
|
|
70347
|
-
content: hydrateApprovedKnowledgeMarkdown({ content: await
|
|
70417
|
+
content: hydrateApprovedKnowledgeMarkdown({ content: await readFile45(file.absPath, "utf8"), relPath: file.relPath, metadata })
|
|
70348
70418
|
})));
|
|
70349
70419
|
return knowledgeMapArticleTargets(content3);
|
|
70350
70420
|
}
|
|
@@ -70390,11 +70460,11 @@ var init_knowledgeMapCoverage = __esm(() => {
|
|
|
70390
70460
|
});
|
|
70391
70461
|
|
|
70392
70462
|
// src/project/knowledgeMap.ts
|
|
70393
|
-
import { readFile as
|
|
70394
|
-
import { join as
|
|
70463
|
+
import { readFile as readFile46 } from "node:fs/promises";
|
|
70464
|
+
import { join as join54 } from "node:path";
|
|
70395
70465
|
async function optionalText(root, path2) {
|
|
70396
70466
|
try {
|
|
70397
|
-
return await
|
|
70467
|
+
return await readFile46(join54(root, path2), "utf8");
|
|
70398
70468
|
} catch (error) {
|
|
70399
70469
|
if (error.code === "ENOENT")
|
|
70400
70470
|
return;
|
|
@@ -70447,8 +70517,8 @@ var init_knowledgeMap2 = __esm(() => {
|
|
|
70447
70517
|
});
|
|
70448
70518
|
|
|
70449
70519
|
// src/project/packageKnowledgeMap.ts
|
|
70450
|
-
import { readFile as
|
|
70451
|
-
import { join as
|
|
70520
|
+
import { readFile as readFile47, writeFile as writeFile14 } from "node:fs/promises";
|
|
70521
|
+
import { join as join55 } from "node:path";
|
|
70452
70522
|
function knowledgeMapSectionAnchor(key) {
|
|
70453
70523
|
return `section-${encodeURIComponent(key)}`;
|
|
70454
70524
|
}
|
|
@@ -70473,16 +70543,16 @@ async function writePackageKnowledgeMap(input) {
|
|
|
70473
70543
|
return [];
|
|
70474
70544
|
const projected = projectKnowledgeMap(input.structure, packageKnowledgeMapTargets(input.pkg, input.selected));
|
|
70475
70545
|
projected.warnings = projected.warnings.filter((warning) => !warning.target.startsWith("site:"));
|
|
70476
|
-
const root =
|
|
70477
|
-
const mapPath =
|
|
70546
|
+
const root = join55(input.projectRoot, input.pkg.outDir);
|
|
70547
|
+
const mapPath = join55(root, "context-knowledge-map.json");
|
|
70478
70548
|
try {
|
|
70479
|
-
await
|
|
70549
|
+
await readFile47(mapPath);
|
|
70480
70550
|
throw new TypeError("package template uses reserved context-knowledge-map.json; rename that template output");
|
|
70481
70551
|
} catch (error) {
|
|
70482
70552
|
if (error.code !== "ENOENT")
|
|
70483
70553
|
throw error;
|
|
70484
70554
|
}
|
|
70485
|
-
await
|
|
70555
|
+
await writeFile14(mapPath, JSON.stringify({ protocol: "context.knowledge-map-output/v1", knowledge_map_revision: input.structure.revision, ...projected }, null, 2) + `
|
|
70486
70556
|
`);
|
|
70487
70557
|
const lines = [];
|
|
70488
70558
|
const escape2 = (value) => value.replace(/[\\[\]<>]/gu, (char) => `\\${char}`).replace(/[\r\n]/gu, " ");
|
|
@@ -70495,15 +70565,15 @@ async function writePackageKnowledgeMap(input) {
|
|
|
70495
70565
|
}
|
|
70496
70566
|
render(projected.entries, 0);
|
|
70497
70567
|
if (lines.length) {
|
|
70498
|
-
const indexPath =
|
|
70568
|
+
const indexPath = join55(root, "index.md");
|
|
70499
70569
|
let existing = "";
|
|
70500
70570
|
try {
|
|
70501
|
-
existing = await
|
|
70571
|
+
existing = await readFile47(indexPath, "utf8");
|
|
70502
70572
|
} catch (error) {
|
|
70503
70573
|
if (error.code !== "ENOENT")
|
|
70504
70574
|
throw error;
|
|
70505
70575
|
}
|
|
70506
|
-
await
|
|
70576
|
+
await writeFile14(indexPath, `${existing.trimEnd()}
|
|
70507
70577
|
|
|
70508
70578
|
## Knowledge map
|
|
70509
70579
|
|
|
@@ -70521,8 +70591,8 @@ var init_packageKnowledgeMap = __esm(() => {
|
|
|
70521
70591
|
|
|
70522
70592
|
// src/project/packageLlms.ts
|
|
70523
70593
|
import { createHash as createHash14 } from "node:crypto";
|
|
70524
|
-
import { access as access4, mkdir as
|
|
70525
|
-
import { dirname as
|
|
70594
|
+
import { access as access4, mkdir as mkdir19, writeFile as writeFile15 } from "node:fs/promises";
|
|
70595
|
+
import { dirname as dirname23, join as join56, posix as posix5 } from "node:path";
|
|
70526
70596
|
function llmsArticles(pkg, selected) {
|
|
70527
70597
|
return selected.map((file) => {
|
|
70528
70598
|
const meta = parseKnowledgeFrontmatter(file.content);
|
|
@@ -70622,7 +70692,7 @@ async function writeLlmsDocuments(root, documents, options = {}) {
|
|
|
70622
70692
|
for (const [path2, content3] of documents.files) {
|
|
70623
70693
|
let exists = false;
|
|
70624
70694
|
try {
|
|
70625
|
-
await access4(
|
|
70695
|
+
await access4(join56(root, path2));
|
|
70626
70696
|
exists = true;
|
|
70627
70697
|
} catch (error) {
|
|
70628
70698
|
if (error.code !== "ENOENT")
|
|
@@ -70632,8 +70702,8 @@ async function writeLlmsDocuments(root, documents, options = {}) {
|
|
|
70632
70702
|
continue;
|
|
70633
70703
|
if (exists)
|
|
70634
70704
|
throw new Error(`Package template uses reserved LLMS output ${path2}; rename that template output.`);
|
|
70635
|
-
await
|
|
70636
|
-
await
|
|
70705
|
+
await mkdir19(dirname23(join56(root, path2)), { recursive: true });
|
|
70706
|
+
await writeFile15(join56(root, path2), options.utf8Bom ? "\uFEFF" + content3.replace(/^\uFEFF/u, "") : content3, "utf8");
|
|
70637
70707
|
}
|
|
70638
70708
|
}
|
|
70639
70709
|
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`;
|
|
@@ -70698,6 +70768,368 @@ function siteArticleSources(article, registry2) {
|
|
|
70698
70768
|
}
|
|
70699
70769
|
var encodedPath = (value) => value.split("/").map(encodeURIComponent).join("/");
|
|
70700
70770
|
|
|
70771
|
+
// src/project/diagramViewer.ts
|
|
70772
|
+
function createDiagramViewer(load) {
|
|
70773
|
+
const states = new Map;
|
|
70774
|
+
let queue = Promise.resolve();
|
|
70775
|
+
let serial = 0;
|
|
70776
|
+
let disposed = false;
|
|
70777
|
+
const instance = Math.random().toString(36).slice(2);
|
|
70778
|
+
const translations = {
|
|
70779
|
+
en: { fit: "Fit", original: "100%", zoomIn: "Zoom in", zoomOut: "Zoom out", expand: "Full screen", close: "Exit full screen", source: "Source", diagram: "Diagram", compact: "Compact style", intuitive: "Layered style", copy: "Copy", copied: "Copied", copyFailed: "Select and copy the source", layout: "Layout", loading: "Rendering diagram…", error: "Diagram could not be rendered. View the source below.", area: "Diagram. Use arrow keys to pan, plus or minus to zoom.", toolbar: "Diagram controls" },
|
|
70780
|
+
zh: { fit: "适配", original: "100%", zoomIn: "放大", zoomOut: "缩小", expand: "全屏", close: "退出全屏", source: "源码", diagram: "图表", compact: "紧凑风格", intuitive: "直观风格", copy: "复制", copied: "已复制", copyFailed: "请选中源码复制", layout: "布局", loading: "正在绘制图表…", error: "图表暂时无法渲染,请查看下方源码。", area: "图表。使用方向键平移,加减键缩放。", toolbar: "图表工具" }
|
|
70781
|
+
};
|
|
70782
|
+
function configuration(dark, layout, host) {
|
|
70783
|
+
const css = getComputedStyle(host);
|
|
70784
|
+
const color2 = (key, fallback) => css.getPropertyValue("--context-" + key).trim() || fallback;
|
|
70785
|
+
return {
|
|
70786
|
+
startOnLoad: false,
|
|
70787
|
+
securityLevel: "strict",
|
|
70788
|
+
suppressErrorRendering: true,
|
|
70789
|
+
secure: ["secure", "securityLevel", "startOnLoad", "maxTextSize", "maxEdges", "theme", "themeVariables", "themeCSS", "dompurifyConfig", "fontFamily", "htmlLabels", "flowchart", "sequence", "layout"],
|
|
70790
|
+
theme: "base",
|
|
70791
|
+
layout,
|
|
70792
|
+
dompurifyConfig: { FORBID_TAGS: ["img", "image", "script", "iframe", "object", "embed", "style", "link"] },
|
|
70793
|
+
themeVariables: {
|
|
70794
|
+
darkMode: dark,
|
|
70795
|
+
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif',
|
|
70796
|
+
fontSize: "15px",
|
|
70797
|
+
primaryColor: color2("surface", dark ? "#202735" : "#f5f8ff"),
|
|
70798
|
+
primaryTextColor: color2("text", dark ? "#e2e4ed" : "#161e2e"),
|
|
70799
|
+
primaryBorderColor: color2("border", dark ? "#8ea0bd" : "#8090aa"),
|
|
70800
|
+
lineColor: color2("muted-text", dark ? "#9faec5" : "#66758d"),
|
|
70801
|
+
secondaryColor: color2("surface", dark ? "#252c38" : "#f8f9fc"),
|
|
70802
|
+
tertiaryColor: color2("surface", dark ? "#202735" : "#f5f8ff"),
|
|
70803
|
+
clusterBkg: color2("surface", dark ? "#1b212d" : "#fafbfe"),
|
|
70804
|
+
clusterBorder: color2("border", dark ? "#475267" : "#d7deea"),
|
|
70805
|
+
edgeLabelBackground: color2("background", dark ? "#171b24" : "#ffffff"),
|
|
70806
|
+
actorBkg: color2("surface", dark ? "#202735" : "#f5f8ff"),
|
|
70807
|
+
actorTextColor: color2("text", dark ? "#e2e4ed" : "#161e2e"),
|
|
70808
|
+
signalColor: color2("muted-text", dark ? "#9faec5" : "#66758d"),
|
|
70809
|
+
signalTextColor: color2("text", dark ? "#e2e4ed" : "#161e2e")
|
|
70810
|
+
},
|
|
70811
|
+
flowchart: { useMaxWidth: false, nodeSpacing: 36, rankSpacing: 58, padding: 16, curve: "linear", wrappingWidth: 220, htmlLabels: false },
|
|
70812
|
+
sequence: { useMaxWidth: false, diagramMarginX: 24, diagramMarginY: 20, actorMargin: 48, messageMargin: 38, wrap: true },
|
|
70813
|
+
state: { useMaxWidth: false },
|
|
70814
|
+
er: { useMaxWidth: false }
|
|
70815
|
+
};
|
|
70816
|
+
}
|
|
70817
|
+
function prune() {
|
|
70818
|
+
for (const [node3, state] of states)
|
|
70819
|
+
if (!node3.isConnected) {
|
|
70820
|
+
state.observer?.disconnect();
|
|
70821
|
+
state.close();
|
|
70822
|
+
states.delete(node3);
|
|
70823
|
+
}
|
|
70824
|
+
}
|
|
70825
|
+
function mount(node3, source2, dark, language) {
|
|
70826
|
+
const prior = states.get(node3);
|
|
70827
|
+
prior?.observer?.disconnect();
|
|
70828
|
+
prior?.close();
|
|
70829
|
+
prior?.shell.remove();
|
|
70830
|
+
const t = language.startsWith("zh") ? translations.zh : translations.en;
|
|
70831
|
+
const shell = document.createElement("div");
|
|
70832
|
+
shell.className = "context-diagram-shell";
|
|
70833
|
+
const toolbar = document.createElement("div");
|
|
70834
|
+
toolbar.className = "context-diagram-tools";
|
|
70835
|
+
toolbar.setAttribute("role", "group");
|
|
70836
|
+
toolbar.setAttribute("aria-label", t.toolbar);
|
|
70837
|
+
const viewport = document.createElement("div");
|
|
70838
|
+
viewport.className = "context-diagram-viewport";
|
|
70839
|
+
viewport.tabIndex = 0;
|
|
70840
|
+
viewport.setAttribute("role", "region");
|
|
70841
|
+
viewport.setAttribute("aria-label", t.area);
|
|
70842
|
+
const canvas = document.createElement("div");
|
|
70843
|
+
canvas.className = "context-diagram-canvas";
|
|
70844
|
+
viewport.append(canvas);
|
|
70845
|
+
const status = document.createElement("div");
|
|
70846
|
+
status.className = "context-diagram-status";
|
|
70847
|
+
status.setAttribute("role", "status");
|
|
70848
|
+
status.textContent = t.loading;
|
|
70849
|
+
shell.append(toolbar, status, viewport);
|
|
70850
|
+
node3.append(shell);
|
|
70851
|
+
const state = {
|
|
70852
|
+
source: source2,
|
|
70853
|
+
signature: `${dark}:${language}`,
|
|
70854
|
+
revision: 0,
|
|
70855
|
+
shell,
|
|
70856
|
+
viewport,
|
|
70857
|
+
canvas,
|
|
70858
|
+
status,
|
|
70859
|
+
scale: prior?.scale ?? 1,
|
|
70860
|
+
width: 0,
|
|
70861
|
+
fit: prior?.fit ?? true,
|
|
70862
|
+
layout: prior?.layout ?? "elk",
|
|
70863
|
+
resize: () => {},
|
|
70864
|
+
close: () => {}
|
|
70865
|
+
};
|
|
70866
|
+
states.set(node3, state);
|
|
70867
|
+
node3.classList.add("context-rendered");
|
|
70868
|
+
const button = (text7, title, action) => {
|
|
70869
|
+
const element = document.createElement("button");
|
|
70870
|
+
element.type = "button";
|
|
70871
|
+
element.textContent = text7;
|
|
70872
|
+
element.title = title;
|
|
70873
|
+
element.setAttribute("aria-label", title);
|
|
70874
|
+
element.onclick = action;
|
|
70875
|
+
toolbar.append(element);
|
|
70876
|
+
return element;
|
|
70877
|
+
};
|
|
70878
|
+
const left = document.createElement("div");
|
|
70879
|
+
left.className = "context-diagram-left";
|
|
70880
|
+
const right = document.createElement("div");
|
|
70881
|
+
right.className = "context-diagram-right";
|
|
70882
|
+
toolbar.append(left, right);
|
|
70883
|
+
const sourceView = document.createElement("pre");
|
|
70884
|
+
sourceView.className = "context-diagram-source";
|
|
70885
|
+
const sourceCode = document.createElement("code");
|
|
70886
|
+
sourceCode.textContent = source2;
|
|
70887
|
+
sourceView.append(sourceCode);
|
|
70888
|
+
shell.append(sourceView);
|
|
70889
|
+
const percent = document.createElement("span");
|
|
70890
|
+
percent.className = "context-diagram-percent";
|
|
70891
|
+
function resize() {
|
|
70892
|
+
const svg = canvas.querySelector("svg");
|
|
70893
|
+
if (!svg || !state.width)
|
|
70894
|
+
return;
|
|
70895
|
+
if (state.fit)
|
|
70896
|
+
state.scale = Math.min(1, Math.max(0.1, (viewport.clientWidth - 32) / state.width));
|
|
70897
|
+
svg.style.width = `${state.width * state.scale}px`;
|
|
70898
|
+
svg.style.maxWidth = "none";
|
|
70899
|
+
svg.style.height = "auto";
|
|
70900
|
+
percent.textContent = `${Math.round(state.scale * 100)}%`;
|
|
70901
|
+
}
|
|
70902
|
+
state.resize = resize;
|
|
70903
|
+
function zoom(factor) {
|
|
70904
|
+
state.fit = false;
|
|
70905
|
+
state.scale = Math.min(4, Math.max(0.1, state.scale * factor));
|
|
70906
|
+
resize();
|
|
70907
|
+
}
|
|
70908
|
+
const fit = button(t.fit, t.fit, () => {
|
|
70909
|
+
state.fit = true;
|
|
70910
|
+
resize();
|
|
70911
|
+
viewport.scrollTo(0, 0);
|
|
70912
|
+
});
|
|
70913
|
+
button(t.original, t.original, () => {
|
|
70914
|
+
state.fit = false;
|
|
70915
|
+
state.scale = 1;
|
|
70916
|
+
resize();
|
|
70917
|
+
}).classList.add("context-diagram-original");
|
|
70918
|
+
button("−", t.zoomOut, () => zoom(1 / 1.2));
|
|
70919
|
+
button("+", t.zoomIn, () => zoom(1.2));
|
|
70920
|
+
toolbar.append(percent);
|
|
70921
|
+
const full = button(t.expand, t.expand, () => {
|
|
70922
|
+
const expanded = shell.classList.toggle("context-diagram-expanded");
|
|
70923
|
+
full.textContent = expanded ? t.close : t.expand;
|
|
70924
|
+
full.setAttribute("aria-label", full.textContent);
|
|
70925
|
+
full.title = full.textContent;
|
|
70926
|
+
full.setAttribute("aria-pressed", String(expanded));
|
|
70927
|
+
if (expanded) {
|
|
70928
|
+
document.addEventListener("keydown", escape2);
|
|
70929
|
+
viewport.focus();
|
|
70930
|
+
} else
|
|
70931
|
+
document.removeEventListener("keydown", escape2);
|
|
70932
|
+
resize();
|
|
70933
|
+
});
|
|
70934
|
+
function escape2(event) {
|
|
70935
|
+
if (event.key === "Escape") {
|
|
70936
|
+
state.close();
|
|
70937
|
+
full.focus();
|
|
70938
|
+
}
|
|
70939
|
+
}
|
|
70940
|
+
state.close = () => {
|
|
70941
|
+
shell.classList.remove("context-diagram-expanded");
|
|
70942
|
+
document.removeEventListener("keydown", escape2);
|
|
70943
|
+
full.textContent = t.expand;
|
|
70944
|
+
full.title = t.expand;
|
|
70945
|
+
full.setAttribute("aria-pressed", "false");
|
|
70946
|
+
resize();
|
|
70947
|
+
};
|
|
70948
|
+
const sourceButton = button(t.source, t.source, () => {
|
|
70949
|
+
node3.classList.toggle("context-show-source");
|
|
70950
|
+
updateSource();
|
|
70951
|
+
resize();
|
|
70952
|
+
});
|
|
70953
|
+
sourceButton.classList.add("context-diagram-source-toggle");
|
|
70954
|
+
const copy = button(t.copy, t.copy, () => {
|
|
70955
|
+
(async () => {
|
|
70956
|
+
try {
|
|
70957
|
+
if (navigator.clipboard?.writeText)
|
|
70958
|
+
await navigator.clipboard.writeText(source2);
|
|
70959
|
+
else {
|
|
70960
|
+
const selection = window.getSelection();
|
|
70961
|
+
const range = document.createRange();
|
|
70962
|
+
range.selectNodeContents(sourceCode);
|
|
70963
|
+
selection?.removeAllRanges();
|
|
70964
|
+
selection?.addRange(range);
|
|
70965
|
+
if (!document.execCommand("copy"))
|
|
70966
|
+
throw new Error("Copy unavailable");
|
|
70967
|
+
selection?.removeAllRanges();
|
|
70968
|
+
}
|
|
70969
|
+
copy.textContent = t.copied;
|
|
70970
|
+
} catch {
|
|
70971
|
+
copy.textContent = t.copyFailed;
|
|
70972
|
+
}
|
|
70973
|
+
})();
|
|
70974
|
+
});
|
|
70975
|
+
function updateSource() {
|
|
70976
|
+
const showing = node3.classList.contains("context-show-source");
|
|
70977
|
+
sourceView.hidden = !showing;
|
|
70978
|
+
viewport.hidden = showing;
|
|
70979
|
+
copy.hidden = !showing;
|
|
70980
|
+
sourceButton.textContent = showing ? t.diagram : t.source;
|
|
70981
|
+
sourceButton.setAttribute("aria-label", sourceButton.textContent);
|
|
70982
|
+
sourceButton.title = sourceButton.textContent;
|
|
70983
|
+
sourceButton.setAttribute("aria-pressed", String(showing));
|
|
70984
|
+
}
|
|
70985
|
+
const canChooseLayout = /^\s*(?:---[\s\S]*?---\s*)?(?:flowchart|graph)\b/u.test(source2);
|
|
70986
|
+
if (canChooseLayout) {
|
|
70987
|
+
const layout = button(state.layout === "elk" ? t.compact : t.intuitive, t.layout, () => {
|
|
70988
|
+
state.layout = state.layout === "elk" ? "dagre" : "elk";
|
|
70989
|
+
layout.textContent = state.layout === "elk" ? t.compact : t.intuitive;
|
|
70990
|
+
layout.setAttribute("aria-pressed", String(state.layout === "elk"));
|
|
70991
|
+
draw();
|
|
70992
|
+
});
|
|
70993
|
+
layout.setAttribute("aria-pressed", String(state.layout === "elk"));
|
|
70994
|
+
left.append(layout);
|
|
70995
|
+
}
|
|
70996
|
+
left.append(sourceButton, copy);
|
|
70997
|
+
for (const element of [...toolbar.children])
|
|
70998
|
+
if (element !== left && element !== right)
|
|
70999
|
+
right.append(element);
|
|
71000
|
+
right.append(fit, full);
|
|
71001
|
+
updateSource();
|
|
71002
|
+
viewport.onkeydown = (event) => {
|
|
71003
|
+
if (event.key === "+" || event.key === "=") {
|
|
71004
|
+
event.preventDefault();
|
|
71005
|
+
zoom(1.2);
|
|
71006
|
+
}
|
|
71007
|
+
if (event.key === "-") {
|
|
71008
|
+
event.preventDefault();
|
|
71009
|
+
zoom(1 / 1.2);
|
|
71010
|
+
}
|
|
71011
|
+
};
|
|
71012
|
+
let drag;
|
|
71013
|
+
viewport.onpointerdown = (event) => {
|
|
71014
|
+
if (event.button !== 0 || event.pointerType === "touch")
|
|
71015
|
+
return;
|
|
71016
|
+
drag = { x: event.clientX, y: event.clientY, left: viewport.scrollLeft, top: viewport.scrollTop };
|
|
71017
|
+
viewport.setPointerCapture(event.pointerId);
|
|
71018
|
+
};
|
|
71019
|
+
viewport.onpointermove = (event) => {
|
|
71020
|
+
if (drag) {
|
|
71021
|
+
viewport.scrollLeft = drag.left + drag.x - event.clientX;
|
|
71022
|
+
viewport.scrollTop = drag.top + drag.y - event.clientY;
|
|
71023
|
+
}
|
|
71024
|
+
};
|
|
71025
|
+
viewport.onpointerup = viewport.onpointercancel = () => {
|
|
71026
|
+
drag = undefined;
|
|
71027
|
+
};
|
|
71028
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
71029
|
+
state.observer = new ResizeObserver(resize);
|
|
71030
|
+
state.observer.observe(viewport);
|
|
71031
|
+
}
|
|
71032
|
+
function draw() {
|
|
71033
|
+
const revision = ++state.revision;
|
|
71034
|
+
status.hidden = false;
|
|
71035
|
+
status.textContent = t.loading;
|
|
71036
|
+
queue = queue.catch(() => {}).then(async () => {
|
|
71037
|
+
if (disposed || !node3.isConnected || states.get(node3) !== state || state.revision !== revision)
|
|
71038
|
+
return;
|
|
71039
|
+
const id3 = `context-diagram-${instance}-${++serial}`;
|
|
71040
|
+
try {
|
|
71041
|
+
if (/<(?:img|image|iframe|object|embed|script|style|link)\b/iu.test(source2) || /@\{[^}]*\bimg\s*:/iu.test(source2))
|
|
71042
|
+
throw new Error("Embedded resources are unsupported");
|
|
71043
|
+
const mermaid = await load();
|
|
71044
|
+
mermaid.initialize(configuration(dark, state.layout, node3));
|
|
71045
|
+
if (!await mermaid.parse(source2, { suppressErrors: true }))
|
|
71046
|
+
throw new Error("Invalid Mermaid");
|
|
71047
|
+
const { svg } = await mermaid.render(id3, source2);
|
|
71048
|
+
if (disposed || !node3.isConnected || states.get(node3) !== state || state.revision !== revision)
|
|
71049
|
+
return;
|
|
71050
|
+
canvas.innerHTML = svg;
|
|
71051
|
+
const element = canvas.querySelector("svg");
|
|
71052
|
+
if (!element)
|
|
71053
|
+
throw new Error("Missing SVG");
|
|
71054
|
+
state.width = element.viewBox.baseVal.width || element.getBoundingClientRect().width || 640;
|
|
71055
|
+
element.setAttribute("role", "img");
|
|
71056
|
+
if (!element.hasAttribute("aria-label") && !element.hasAttribute("aria-labelledby"))
|
|
71057
|
+
element.setAttribute("aria-label", t.area);
|
|
71058
|
+
status.hidden = true;
|
|
71059
|
+
resize();
|
|
71060
|
+
} catch (error) {
|
|
71061
|
+
status.title = error instanceof Error ? error.message : String(error);
|
|
71062
|
+
document.getElementById(`d${id3}`)?.remove();
|
|
71063
|
+
canvas.replaceChildren();
|
|
71064
|
+
status.hidden = false;
|
|
71065
|
+
status.textContent = t.error;
|
|
71066
|
+
node3.classList.add("context-show-source");
|
|
71067
|
+
updateSource();
|
|
71068
|
+
}
|
|
71069
|
+
});
|
|
71070
|
+
return queue;
|
|
71071
|
+
}
|
|
71072
|
+
return draw();
|
|
71073
|
+
}
|
|
71074
|
+
return {
|
|
71075
|
+
async render(root, options) {
|
|
71076
|
+
prune();
|
|
71077
|
+
for (const node3 of root.querySelectorAll("div.language-mermaid")) {
|
|
71078
|
+
if (!node3.isConnected)
|
|
71079
|
+
continue;
|
|
71080
|
+
const code = node3.querySelector("pre code");
|
|
71081
|
+
if (!code)
|
|
71082
|
+
continue;
|
|
71083
|
+
const source2 = code.textContent ?? "";
|
|
71084
|
+
const state = states.get(node3);
|
|
71085
|
+
if (state?.source === source2 && state.signature === `${options.dark}:${options.language}`)
|
|
71086
|
+
continue;
|
|
71087
|
+
await mount(node3, source2, options.dark, options.language);
|
|
71088
|
+
}
|
|
71089
|
+
await queue;
|
|
71090
|
+
},
|
|
71091
|
+
destroy() {
|
|
71092
|
+
disposed = true;
|
|
71093
|
+
for (const state of states.values()) {
|
|
71094
|
+
state.observer?.disconnect();
|
|
71095
|
+
state.close();
|
|
71096
|
+
}
|
|
71097
|
+
states.clear();
|
|
71098
|
+
}
|
|
71099
|
+
};
|
|
71100
|
+
}
|
|
71101
|
+
var DIAGRAM_VIEWER_SCRIPT;
|
|
71102
|
+
var init_diagramViewer = __esm(() => {
|
|
71103
|
+
DIAGRAM_VIEWER_SCRIPT = `(${createDiagramViewer.toString()})`;
|
|
71104
|
+
});
|
|
71105
|
+
|
|
71106
|
+
// src/project/diagramStyles.ts
|
|
71107
|
+
var DIAGRAM_STYLES;
|
|
71108
|
+
var init_diagramStyles = __esm(() => {
|
|
71109
|
+
DIAGRAM_STYLES = String.raw`
|
|
71110
|
+
.context-diagram-shell{--diagram-bg:var(--vp-c-bg,var(--bg,#fff));--diagram-text:var(--vp-c-text-1,var(--text,#161e2e));--diagram-muted:var(--vp-c-text-2,var(--muted,#646b7c));--diagram-line:var(--vp-c-divider,var(--line,#e7e9ef));--diagram-brand:var(--vp-c-brand-1,var(--blue,#2563eb));position:relative;color:var(--diagram-text);background:var(--diagram-bg);border:1px solid var(--diagram-line);border-radius:6px;margin:16px 0;overflow:hidden}
|
|
71111
|
+
.context-diagram-tools{position:absolute;top:0;left:0;right:0;z-index:2;background:var(--diagram-bg);display:flex;align-items:center;flex-wrap:wrap;gap:6px;padding:8px 10px;border-bottom:1px solid var(--diagram-line)}
|
|
71112
|
+
.context-diagram-tools button,.context-diagram-tools select{appearance:auto;box-sizing:border-box;min-height:28px;margin:0;padding:3px 9px;border:1px solid var(--diagram-line);border-radius:5px;background:var(--diagram-bg);color:var(--diagram-muted);font:12px/20px -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;cursor:pointer}
|
|
71113
|
+
.context-diagram-tools button:hover,.context-diagram-tools select:hover{border-color:var(--diagram-brand);color:var(--diagram-brand)}
|
|
71114
|
+
.context-diagram-tools :focus-visible,.context-diagram-viewport:focus-visible{outline:2px solid var(--diagram-brand);outline-offset:-2px}
|
|
71115
|
+
.context-diagram-percent{font-size:11px;color:var(--diagram-muted);min-width:34px;text-align:center}
|
|
71116
|
+
.context-diagram-viewport{overflow:auto;max-height:620px;min-height:60px;overscroll-behavior:contain;cursor:grab}
|
|
71117
|
+
.context-diagram-viewport:active{cursor:grabbing}.context-diagram-canvas{padding:16px;width:max-content;min-width:100%;box-sizing:border-box}
|
|
71118
|
+
.context-diagram-canvas svg{display:block;margin:auto;height:auto;max-width:none}.context-diagram-status{padding:12px 16px;font-size:13px;color:var(--diagram-muted)}
|
|
71119
|
+
.context-diagram-expanded{position:fixed!important;inset:16px!important;z-index:10000!important;margin:0!important;display:flex;flex-direction:column;box-shadow:0 0 0 100vmax #10182788}
|
|
71120
|
+
.context-diagram-expanded .context-diagram-viewport{flex:1;max-height:none}.context-diagram-expanded .context-diagram-tools{flex-shrink:0}
|
|
71121
|
+
.vp-doc div.language-mermaid.context-rendered{background:transparent;border:0}
|
|
71122
|
+
.context-rendered>pre,.context-rendered>.copy,.context-rendered>.lang{display:none!important}.context-diagram-shell [hidden]{display:none!important}
|
|
71123
|
+
.context-diagram-left,.context-diagram-right{display:flex;align-items:center;flex-wrap:wrap;gap:6px}.context-diagram-right{margin-left:auto}
|
|
71124
|
+
.context-diagram-tools{opacity:0;pointer-events:none;transition:opacity .15s}.context-diagram-shell:hover .context-diagram-tools,.context-diagram-shell:focus-within .context-diagram-tools{opacity:1;pointer-events:auto}
|
|
71125
|
+
.context-diagram-shell pre.context-diagram-source{margin:0;padding:16px;overflow:auto;max-height:620px;background:transparent;font-size:12px;line-height:1.6;white-space:pre}
|
|
71126
|
+
.context-diagram-source code{font:inherit!important;color:var(--diagram-text)!important;padding:0!important;background:transparent!important}
|
|
71127
|
+
.context-diagram-expanded .context-diagram-source{flex:1;max-height:none}
|
|
71128
|
+
@media(hover:none){.context-diagram-tools{opacity:1;pointer-events:auto}}
|
|
71129
|
+
@media(max-width:700px){.context-diagram-original,.context-diagram-source-toggle{display:none!important}.context-diagram-expanded{inset:4px!important}.context-diagram-tools{gap:4px;padding:6px}.context-diagram-tools button,.context-diagram-tools select{padding:3px 6px}}
|
|
71130
|
+
`;
|
|
71131
|
+
});
|
|
71132
|
+
|
|
70701
71133
|
// src/project/packageSiteTheme.ts
|
|
70702
71134
|
function siteThemeLabels(lang) {
|
|
70703
71135
|
return lang.startsWith("zh") ? {
|
|
@@ -70728,244 +71160,10 @@ function siteThemeLabels(lang) {
|
|
|
70728
71160
|
search: { provider: "local" }
|
|
70729
71161
|
};
|
|
70730
71162
|
}
|
|
70731
|
-
var siteMarkdownConfig, siteThemeScript, siteThemeCss
|
|
70732
|
-
.context-business-floating { position: fixed; right: max(20px, env(safe-area-inset-right)); bottom: max(20px, env(safe-area-inset-bottom)); z-index: 30; max-width: calc(100vw - 40px); }
|
|
70733
|
-
.context-history-cards { display: grid; gap: 16px; margin: 24px 0; }
|
|
70734
|
-
.context-history-card { border: 1px solid var(--vp-c-divider); border-radius: 12px; background: var(--vp-c-bg-soft); }
|
|
70735
|
-
.context-history-card summary { display: flex; align-items: baseline; flex-wrap: wrap; gap: 12px; padding: 20px; cursor: pointer; }
|
|
70736
|
-
.context-history-card summary::before { content: '▸'; }
|
|
70737
|
-
.context-history-card[open] summary::before { content: '▾'; }
|
|
70738
|
-
.context-history-card summary strong { color: var(--vp-c-brand-1); font-size: 13px; }
|
|
70739
|
-
.context-history-title { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
|
|
70740
|
-
.context-history-attribution { margin-left: auto; font-size: 13px; color: var(--vp-c-text-2); }
|
|
70741
|
-
.context-history-body { padding: 0 24px 20px; font-size: 13px; line-height: 1.8; overflow-wrap: anywhere; }
|
|
70742
|
-
.context-history-body ul { list-style: disc; padding-left: 20px; }
|
|
70743
|
-
.context-history-meta { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--vp-c-divider); color: var(--vp-c-text-2); }
|
|
70744
|
-
:root {
|
|
70745
|
-
--vp-font-family-base: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
|
|
70746
|
-
--vp-font-family-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
70747
|
-
--vp-c-brand-1: rgb(37, 99, 235); --vp-c-brand-2: #00bec8; --vp-c-brand-3: rgb(37, 99, 235);
|
|
70748
|
-
--context-accent: #00bec8;
|
|
70749
|
-
--vp-c-brand-soft: rgba(37, 99, 235, .08);
|
|
70750
|
-
--vp-sidebar-width: 280px;
|
|
70751
|
-
--vp-layout-max-width: 100%;
|
|
70752
|
-
--vp-nav-height: 64px;
|
|
70753
|
-
--vp-c-text-1: #161e2e; --vp-c-text-2: #646b7c;
|
|
70754
|
-
--vp-c-divider: #e7e9ef;
|
|
70755
|
-
--vp-sidebar-bg-color: #f8f9fc;
|
|
70756
|
-
}
|
|
70757
|
-
.dark {
|
|
70758
|
-
--vp-c-brand-1: #8eb7ff; --vp-c-brand-2: #b3cfff;
|
|
70759
|
-
--vp-c-brand-soft: rgba(142, 183, 255, .09);
|
|
70760
|
-
--vp-c-text-1: #e2e4ed; --vp-c-text-2: #a1a6b7;
|
|
70761
|
-
--vp-c-divider: #303440; --vp-sidebar-bg-color: #1b1d24;
|
|
70762
|
-
}
|
|
70763
|
-
.VPNavBar .wrapper { padding: 0 24px !important; }
|
|
70764
|
-
.VPNavBar .container { max-width: none !important; }
|
|
70765
|
-
.VPNav, .VPNavBar, .VPNavBar .wrapper { background: var(--vp-c-bg) !important; }
|
|
70766
|
-
.VPNavBar .title { position: static !important; padding: 0 !important; width: var(--vp-sidebar-width) !important; flex-shrink: 0; }
|
|
70767
|
-
.VPNavBarTitle .title { font-size: 15px; font-weight: 650; border: 0 !important; }
|
|
70768
|
-
.VPNavBar .content { flex: 1; min-width: 0; padding-left: 0 !important; }
|
|
70769
|
-
.VPNavBar .content-body { background: var(--vp-c-bg) !important; gap: 8px; }
|
|
70770
|
-
.VPNavBarMenu { order: -1; flex: 1; min-width: 0; }
|
|
70771
|
-
.context-language { display: inline-flex; align-items: center; padding: 5px 7px; border: 0; border-radius: 6px; color: var(--vp-c-text-2);
|
|
70772
|
-
background: transparent; white-space: nowrap; font-size: 12px; font-weight: 550; cursor: pointer; }
|
|
70773
|
-
.context-language:hover { color: var(--vp-c-brand-1); background: var(--vp-c-brand-soft); }
|
|
70774
|
-
.VPNavBarMenuLink { font-size: 13px !important; font-weight: 550 !important; padding: 0 16px !important; }
|
|
70775
|
-
.VPNavBarMenuLink.active { box-shadow: inset 0 -2px var(--vp-c-brand-1); }
|
|
70776
|
-
.VPNavBarSearch { flex: 0 0 376px !important; width: 376px; padding: 0 12px !important; }
|
|
70777
|
-
.VPNavBarSearch #local-search, .VPNavBarSearch .DocSearch-Button { width: 352px; }
|
|
70778
|
-
.VPNavBarSearch .DocSearch-Button { display: flex; align-items: center; }
|
|
70779
|
-
.VPNavBarSearch .DocSearch-Button-Container { display: flex; flex: 1; min-width: 0; align-items: center; }
|
|
70780
|
-
.VPNavBarSearch .DocSearch-Button-Keys { margin-left: auto; }
|
|
70781
|
-
.VPSidebar { border-top: 1px solid var(--vp-c-divider); border-right: 1px solid var(--vp-c-divider); scrollbar-width: thin; }
|
|
70782
|
-
.VPSidebar .group, .VPSidebar .group + .group { border: 0; padding-top: 0; }
|
|
70783
|
-
.VPSidebarItem .link { min-width: 0; overflow: hidden; }
|
|
70784
|
-
.VPSidebarItem .text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px !important; line-height: 20px !important; font-weight: 450 !important; }
|
|
70785
|
-
.VPSidebarItem.level-0 { padding-bottom: 0 !important; }
|
|
70786
|
-
.VPSidebarItem .indicator { display: none; }
|
|
70787
|
-
.VPSidebarItem .text { padding: 0 !important; }
|
|
70788
|
-
.VPSidebarItem .item { height: 38px; min-height: 38px; align-items: center; padding: 0 16px 0 26px; border-radius: 0; }
|
|
70789
|
-
.VPSidebarItem.is-link:not(.is-active) > .item > .link > p.text { color: var(--vp-c-text-2); }
|
|
70790
|
-
.VPSidebarItem.is-link:not(.is-active) > .item > .link:hover > p.text { color: var(--vp-c-brand-1); }
|
|
70791
|
-
.VPSidebarItem.is-active > .item { background: var(--vp-c-brand-soft); box-shadow: none; }
|
|
70792
|
-
.VPSidebarItem.is-active > .item .text { color: var(--vp-c-brand-1) !important; font-weight: 550 !important; }
|
|
70793
|
-
.VPSidebarItem .items { margin-left: 0; padding-left: 0 !important; border-left: 0 !important; }
|
|
70794
|
-
.VPSidebarItem.level-1 > .item { padding-left: 40px; }
|
|
70795
|
-
.VPSidebarItem.level-2 > .item { padding-left: 54px; }
|
|
70796
|
-
.VPSidebarItem.level-3 > .item { padding-left: 68px; }
|
|
70797
|
-
.VPSidebarItem.level-4 > .item { padding-left: 82px; }
|
|
70798
|
-
.VPSidebarItem.level-5 > .item { padding-left: 96px; }
|
|
70799
|
-
.VPSidebar .group { width: 100% !important; }
|
|
70800
|
-
.VPSidebarItem .item:hover { background: var(--vp-c-default-soft); }
|
|
70801
|
-
.VPDoc .container, .VPDoc > .container > .content, .VPDoc .content-container { max-width: none !important; min-width: 0 !important; }
|
|
70802
|
-
.VPDoc > .container > .content { flex: 1; }
|
|
70803
|
-
.VPDoc .aside { flex: 0 0 190px; width: 190px; max-width: 190px; padding-left: 24px; }
|
|
70804
|
-
.VPDoc .aside-container, .VPDoc .aside-curtain { width: 166px; }
|
|
70805
|
-
.VPDocAsideOutline .content { padding: 0 0 0 16px; }
|
|
70806
|
-
.VPDocAsideOutline .outline-title { font-size: 11px; font-weight: 600; letter-spacing: .03em; color: var(--vp-c-text-2); }
|
|
70807
|
-
.VPDocAsideOutline .outline-link { font-size: 12px !important; line-height: 20px !important; padding: 5px 0; white-space: normal; }
|
|
70808
|
-
.vp-doc { font-size: 16px; line-height: 1.8; color: var(--vp-c-text-1); }
|
|
70809
|
-
.vp-doc p, .vp-doc li { line-height: 1.8; }
|
|
70810
|
-
.vp-doc h1 { font-size: 36px; font-weight: 700; line-height: 1.3; letter-spacing: -.025em; margin-bottom: 28px; }
|
|
70811
|
-
.vp-doc h2 { font-size: 25px; font-weight: 650; line-height: 1.4; margin: 46px 0 22px; padding: 0 0 14px; border-top: 0; border-bottom: 1px solid var(--vp-c-divider); }
|
|
70812
|
-
.vp-doc h3 { font-size: 19px; font-weight: 600; line-height: 1.5; margin: 30px 0 14px; }
|
|
70813
|
-
.vp-doc a { color: inherit; font-weight: 500; text-decoration: none; border-bottom: 1px solid transparent; transition: color .15s, border-color .15s; }
|
|
70814
|
-
.vp-doc a:hover { color: var(--vp-c-brand-1); border-bottom-color: currentColor; }
|
|
70815
|
-
.vp-doc a.header-anchor { top: -0.06em !important; line-height: inherit; border: 0; color: var(--vp-c-brand-1); }
|
|
70816
|
-
.vp-doc blockquote { margin: 24px 0; padding: 16px 20px; border-left: 3px solid var(--context-accent); border-radius: 0 5px 5px 0; background: var(--vp-c-brand-soft); color: var(--vp-c-text-2); }
|
|
70817
|
-
.vp-doc blockquote p { margin: 0; font-size: 15px; }
|
|
70818
|
-
.vp-doc blockquote a { color: var(--vp-c-brand-1); }
|
|
70819
|
-
.vp-doc table { width: 100%; overflow-x: auto; font-size: 14px; border-collapse: collapse; margin: 24px 0; }
|
|
70820
|
-
.vp-doc th { background: var(--vp-sidebar-bg-color); font-weight: 600; }
|
|
70821
|
-
.vp-doc th, .vp-doc td { padding: 11px 14px; border-color: var(--vp-c-divider); line-height: 1.7; }
|
|
70822
|
-
.vp-doc tr:nth-child(2n) { background: var(--vp-c-bg); }
|
|
70823
|
-
.vp-doc :not(pre) > code { font-size: .88em; color: var(--vp-c-text-1); background: var(--vp-sidebar-bg-color); border: 1px solid var(--vp-c-divider); border-radius: 4px; }
|
|
70824
|
-
.vp-doc div[class*='language-'] { border: 1px solid var(--vp-c-divider); border-radius: 6px; }
|
|
70825
|
-
.vp-doc details { margin: 20px 0; border: 1px solid var(--vp-c-divider); border-radius: 6px; padding: 12px 16px; }
|
|
70826
|
-
.vp-doc summary { cursor: pointer; font-size: 14px; font-weight: 550; }
|
|
70827
|
-
.vp-doc img { max-width: 100%; height: auto; }
|
|
70828
|
-
.context-home { max-width: 100%; min-width: 0; overflow-x: clip; }
|
|
70829
|
-
.context-home .VPContent, .context-home .VPHome, .context-home .VPHero { max-width: 100%; min-width: 0; }
|
|
70830
|
-
.context-home .VPHome { padding-bottom: 0; }
|
|
70831
|
-
.context-home .VPHero { position: relative; padding: 132px 0 62px; }
|
|
70832
|
-
.context-home .VPHero::before { content: ''; position: absolute; top: -1px; right: 0; bottom: 0; left: calc(0px - var(--vp-sidebar-width)); pointer-events: none;
|
|
70833
|
-
background: linear-gradient(to bottom, transparent 58%, var(--vp-c-bg) 100%),
|
|
70834
|
-
radial-gradient(ellipse 58% 145% at 8% 18%, rgba(37,99,235,.16), transparent 72%),
|
|
70835
|
-
radial-gradient(ellipse 58% 150% at 68% 24%, rgba(0,190,200,.11), transparent 72%),
|
|
70836
|
-
linear-gradient(90deg, rgba(37,99,235,.045), rgba(0,190,200,.025) 68%, transparent); }
|
|
70837
|
-
.context-home .VPHero .container { position: relative; box-sizing: border-box; width: min(1180px, calc(100% - 104px)); max-width: none; min-width: 0; margin-left: 52px; margin-right: auto; }
|
|
70838
|
-
.context-home .VPHero .main { width: 100%; max-width: 980px; min-width: 0; }
|
|
70839
|
-
.context-home .VPHero .heading { display: block; width: 100%; min-width: 0; max-width: 100%; }
|
|
70840
|
-
.context-home .VPHero .name { display: block; width: 100%; max-width: 100%; overflow-wrap: anywhere; white-space: normal; color: transparent;
|
|
70841
|
-
background: linear-gradient(112deg, var(--vp-c-brand-1), var(--context-accent)); background-clip: text; -webkit-background-clip: text; }
|
|
70842
|
-
.context-home .VPHero .text { display: block; width: 100%; max-width: 100%; overflow-wrap: anywhere; word-break: break-word; white-space: normal;
|
|
70843
|
-
font-size: clamp(38px, 4.2vw, 60px); line-height: 1.08; letter-spacing: -.045em; }
|
|
70844
|
-
.context-home .VPHero .tagline { max-width: 820px; font-size: 18px; line-height: 1.75; }
|
|
70845
|
-
.context-home .VPHero .actions { width: 100%; min-width: 0; padding-top: 38px; flex-wrap: wrap; }
|
|
70846
|
-
.context-home .VPFeatures { display: none; }
|
|
70847
|
-
.context-home-section { width: min(1180px, calc(100% - 104px)); margin: 0 auto 0 52px; padding: 36px 0 44px; }
|
|
70848
|
-
.context-home-section + .context-home-section { border-top: 1px solid var(--vp-c-divider); }
|
|
70849
|
-
.context-home-map { padding-top: 0; }
|
|
70850
|
-
.context-home-resources { padding-top: 6px; border-top: 0 !important; }
|
|
70851
|
-
.context-home-section-heading { max-width: 700px; margin-bottom: 24px; }
|
|
70852
|
-
.context-home-section-heading h2 { margin: 2px 0 8px; border: 0; font-size: 28px; line-height: 1.3; letter-spacing: -.02em; }
|
|
70853
|
-
.context-home-section-heading > p:last-child { color: var(--vp-c-text-2); line-height: 1.7; }
|
|
70854
|
-
.context-home-kicker { margin: 0; color: var(--vp-c-brand-1); font-size: 11px; font-weight: 700; letter-spacing: .16em; }
|
|
70855
|
-
.context-home-map-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(290px, 100%), 1fr)); gap: 14px; }
|
|
70856
|
-
.context-home-map-card, .context-home-resource-card { border: 1px solid var(--vp-c-divider); background: color-mix(in srgb, var(--vp-c-bg) 88%, var(--vp-c-bg-soft));
|
|
70857
|
-
animation: context-home-rise .5s both; animation-delay: var(--context-home-delay); }
|
|
70858
|
-
.context-home-map-card { min-height: 224px; padding: 22px; border-radius: 14px; }
|
|
70859
|
-
.context-home-map-card:hover, .context-home-resource-card:hover { border-color: color-mix(in srgb, var(--vp-c-brand-1) 42%, var(--vp-c-divider));
|
|
70860
|
-
box-shadow: 0 14px 38px rgba(23,36,66,.08); transform: translateY(-2px); transition: border-color .18s, box-shadow .18s, transform .18s; }
|
|
70861
|
-
.context-home-map-card-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding-bottom: 13px; border-bottom: 1px solid var(--vp-c-divider); }
|
|
70862
|
-
.context-home-map-card h3, .context-home-resource-card h3 { margin: 0; font-size: 17px; line-height: 1.45; }
|
|
70863
|
-
.context-home-map-card h3 a { color: var(--vp-c-text-1); }
|
|
70864
|
-
.context-home-map-card-heading span { flex: none; color: var(--vp-c-text-2); font-size: 11px; }
|
|
70865
|
-
.context-home-map-card ul { margin: 14px 0 0; padding: 0; list-style: none; }
|
|
70866
|
-
.context-home-map-card li { margin: 7px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
70867
|
-
.context-home-map-card li a { color: var(--vp-c-text-2); font-size: 13px; }
|
|
70868
|
-
.context-home-map-card li a:hover, .context-home-map-more:hover { color: var(--vp-c-brand-1); }
|
|
70869
|
-
.context-home-map-more { display: inline-block; margin-top: 12px; color: var(--vp-c-brand-1); font-size: 12px; font-weight: 600; }
|
|
70870
|
-
.context-home-resource-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
|
|
70871
|
-
.context-home-resource-card { min-height: 118px; padding: 16px 18px; border-radius: 12px; }
|
|
70872
|
-
.context-home-resource-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
|
|
70873
|
-
.context-home-resource-actions { display: flex; flex: none; align-items: center; gap: 6px; }
|
|
70874
|
-
.context-home-resource-action, .context-home-install-action { display: inline-flex; align-items: center; min-height: 28px; padding: 4px 8px; border: 1px solid var(--vp-c-divider); border-radius: 6px;
|
|
70875
|
-
color: var(--vp-c-text-2); background: var(--vp-c-bg); font-size: 11px; font-weight: 600; line-height: 1; white-space: nowrap; }
|
|
70876
|
-
.context-home-resource-action:hover, .context-home-install-action:hover { border-color: var(--vp-c-brand-1); color: var(--vp-c-brand-1); }
|
|
70877
|
-
.context-home-install-action { cursor: pointer; background: var(--vp-c-brand-soft); }
|
|
70878
|
-
.context-home-resource-card p { margin: 8px 0 0; color: var(--vp-c-text-2); font-size: 13px; line-height: 1.55; }
|
|
70879
|
-
.context-home-powered { width: min(1180px, calc(100% - 104px)); margin: 24px auto 0 52px; padding: 22px 0 30px; border-top: 1px solid var(--vp-c-divider);
|
|
70880
|
-
color: var(--vp-c-text-2); font-size: 11px; text-align: right; }
|
|
70881
|
-
.context-home-powered a { color: inherit; }
|
|
70882
|
-
@keyframes context-home-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
|
|
70883
|
-
@media (min-width: 960px) {
|
|
70884
|
-
.VPSidebar { top: var(--vp-nav-height) !important; width: var(--vp-sidebar-width) !important; padding: 12px 0 48px !important; }
|
|
70885
|
-
.VPSidebar .curtain { display: none; }
|
|
70886
|
-
.VPContent.has-sidebar { padding-left: var(--vp-sidebar-width) !important; padding-right: 0 !important; }
|
|
70887
|
-
.context-empty-sidebar .VPContent { padding-left: var(--vp-sidebar-width) !important; padding-right: 0 !important; }
|
|
70888
|
-
.context-home .VPContent { padding-left: var(--vp-sidebar-width) !important; padding-right: 0 !important; }
|
|
70889
|
-
.VPNavBar .content { padding-right: 32px !important; }
|
|
70890
|
-
.VPDoc { padding: 44px 36px 80px !important; }
|
|
70891
|
-
.VPDoc > .container > .content { padding: 0 24px 80px 0 !important; }
|
|
70892
|
-
}
|
|
70893
|
-
@media (min-width: 1600px) { .VPDoc { padding-left: 52px !important; padding-right: 36px !important; } }
|
|
70894
|
-
@media (min-width: 960px) and (max-width: 1279px) {
|
|
70895
|
-
.VPNavBar .title { width: 220px !important; }
|
|
70896
|
-
.VPNavBarMenuLink { padding: 0 9px !important; }
|
|
70897
|
-
.VPNavBarSearch { flex-basis: 168px !important; width: 168px; }
|
|
70898
|
-
.VPNavBarSearch .DocSearch-Button { width: 144px; }
|
|
70899
|
-
.context-home .VPHero .main { max-width: 100%; }
|
|
70900
|
-
.context-home-resource-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
70901
|
-
}
|
|
70902
|
-
@media (min-width: 1280px) and (max-width: 1599px) {
|
|
70903
|
-
.VPNavBarSearch { flex-basis: 248px !important; width: 248px; }
|
|
70904
|
-
.VPNavBarSearch #local-search, .VPNavBarSearch .DocSearch-Button { width: 224px; }
|
|
70905
|
-
}
|
|
70906
|
-
.context-mobile-directory { display: none; }
|
|
70907
|
-
@media (max-width: 959px) {
|
|
70908
|
-
.VPNavBar .wrapper { padding: 0 16px !important; }
|
|
70909
|
-
.VPNavBar .title { flex: 1; min-width: 0; }
|
|
70910
|
-
.VPNavBarTitle .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
70911
|
-
.VPNavBar .content { flex: 0 0 auto; }
|
|
70912
|
-
.VPSidebar { width: min(340px, calc(100vw - 40px)) !important; max-width: none; padding: 0 0 32px !important; }
|
|
70913
|
-
.context-mobile-directory { display: block; position: sticky; top: 0; z-index: 2; padding: 12px 16px; margin-bottom: 8px; border-bottom: 1px solid var(--vp-c-divider); background: var(--vp-sidebar-bg-color); }
|
|
70914
|
-
.context-mobile-directory-heading { display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 600; }
|
|
70915
|
-
.context-mobile-directory-heading button { width: 36px; height: 36px; font-size: 24px; font-weight: 400; color: var(--vp-c-text-2); }
|
|
70916
|
-
.context-mobile-sections { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
|
|
70917
|
-
.context-mobile-sections a { padding: 5px 9px; border-radius: 5px; font-size: 12px; color: var(--vp-c-text-2); }
|
|
70918
|
-
.context-mobile-sections a.active { background: var(--vp-c-brand-soft); color: var(--vp-c-brand-1); }
|
|
70919
|
-
.VPNavScreen { bottom: auto !important; max-height: calc(100dvh - var(--vp-nav-height)); padding: 0 20px !important; border-bottom: 1px solid var(--vp-c-divider); box-shadow: 0 12px 24px rgba(0,0,0,.08); }
|
|
70920
|
-
.VPNavScreen > .container { max-width: none !important; padding: 8px 0 16px !important; }
|
|
70921
|
-
.VPNavScreenMenuLink { padding: 9px 0 !important; font-size: 13px !important; }
|
|
70922
|
-
.VPNavScreen .menu + .appearance { margin-top: 14px; }
|
|
70923
|
-
|
|
70924
|
-
.VPNavBar .title { width: auto !important; }
|
|
70925
|
-
.vp-doc h1 { font-size: 28px; }
|
|
70926
|
-
.vp-doc h2 { font-size: 22px; }
|
|
70927
|
-
.VPDoc { padding: 32px 36px 64px !important; }
|
|
70928
|
-
.vp-doc a.header-anchor { margin-left: -0.8em; }
|
|
70929
|
-
.context-home .VPHero { padding-top: 104px; padding-bottom: 66px; }
|
|
70930
|
-
.context-home .VPHero::before { left: 0; }
|
|
70931
|
-
.context-home .VPHero .container { width: min(calc(100% - 36px), 680px); margin-left: auto; margin-right: auto; }
|
|
70932
|
-
.context-home .VPHero .text { font-size: 40px; }
|
|
70933
|
-
.context-home .VPHero .tagline { font-size: 16px; }
|
|
70934
|
-
.context-home-section, .context-home-powered { width: min(calc(100% - 36px), 680px); margin-left: auto; margin-right: auto; }
|
|
70935
|
-
.context-home-resource-grid { grid-template-columns: 1fr; }
|
|
70936
|
-
}
|
|
70937
|
-
@media (max-width: 1279px) {
|
|
70938
|
-
.VPNavBarMenu { display: none !important; }
|
|
70939
|
-
.VPNavBarHamburger { display: flex !important; }
|
|
70940
|
-
.VPNavScreen { display: block !important; }
|
|
70941
|
-
.VPNavScreen { bottom: auto !important; max-height: calc(100dvh - var(--vp-nav-height)); overflow-y: auto; }
|
|
70942
|
-
.VPNavBarSearch { flex: 0 0 48px !important; width: 48px; padding: 0 4px !important; }
|
|
70943
|
-
.VPNavBarSearch #local-search, .VPNavBarSearch .DocSearch-Button { width: 40px; }
|
|
70944
|
-
.VPNavBarSearch .DocSearch-Button-Placeholder, .VPNavBarSearch .DocSearch-Button-Keys { display: none !important; }
|
|
70945
|
-
}
|
|
70946
|
-
@media (prefers-reduced-motion: reduce) {
|
|
70947
|
-
.context-home-map-card, .context-home-resource-card { animation: none; }
|
|
70948
|
-
.context-home-map-card:hover, .context-home-resource-card:hover { transform: none; }
|
|
70949
|
-
}
|
|
70950
|
-
.context-sources { margin-top: 0; margin-bottom: 24px; padding: 16px 20px; border: 1px solid var(--vp-c-divider); border-radius: 8px; background: var(--vp-sidebar-bg-color); color: var(--vp-c-text-2); font-size: 12px; line-height: 1.7; overflow-wrap: anywhere; }
|
|
70951
|
-
.context-sources-header { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 8px; }
|
|
70952
|
-
.context-sources-title { font-weight: 550; }
|
|
70953
|
-
.context-provenance { margin-bottom: 24px; }
|
|
70954
|
-
.context-provenance .context-sources { margin-bottom: 10px; }
|
|
70955
|
-
.context-article-updated { margin-top: 0; text-align: right; color: var(--vp-c-text-2); font-size: 12px; line-height: 1.7; }
|
|
70956
|
-
.context-sources ul { list-style: none; margin: 0; padding: 0; }
|
|
70957
|
-
.context-sources li + li { margin-top: 6px; }
|
|
70958
|
-
.context-sources a { color: inherit; text-decoration: none; border-bottom: 1px solid transparent; }
|
|
70959
|
-
.context-sources a:hover { color: var(--vp-c-brand-1); border-color: currentColor; }
|
|
70960
|
-
.context-diagram { overflow: auto; padding: 20px; background: var(--vp-c-bg); }
|
|
70961
|
-
.context-diagram svg { height: auto; }
|
|
70962
|
-
.context-diagram .node rect, .context-diagram .node polygon, .context-diagram .node circle,
|
|
70963
|
-
.context-diagram .flowchart-link { stroke-width: 1px !important; }
|
|
70964
|
-
.context-rendered:not(.context-show-source) pre, .context-rendered:not(.context-show-source) > .copy,
|
|
70965
|
-
.context-rendered:not(.context-show-source) > .lang { display: none; }
|
|
70966
|
-
.context-diagram-toggle { display: block; padding: 8px 14px; color: var(--vp-c-text-2); font-size: 12px; }
|
|
70967
|
-
`;
|
|
71163
|
+
var siteMarkdownConfig, siteThemeScript, siteThemeCss;
|
|
70968
71164
|
var init_packageSiteTheme = __esm(() => {
|
|
71165
|
+
init_diagramViewer();
|
|
71166
|
+
init_diagramStyles();
|
|
70969
71167
|
siteMarkdownConfig = String.raw`
|
|
70970
71168
|
html: false,
|
|
70971
71169
|
attrs: { disable: true },
|
|
@@ -71028,7 +71226,7 @@ var init_packageSiteTheme = __esm(() => {
|
|
|
71028
71226
|
siteThemeScript = String.raw`
|
|
71029
71227
|
import DefaultTheme from 'vitepress/theme-without-fonts';
|
|
71030
71228
|
import { useData, useRoute, dataSymbol } from 'vitepress';
|
|
71031
|
-
import { onMounted, nextTick, watch, computed, ref, provide, h } from 'vue';
|
|
71229
|
+
import { onMounted, onUnmounted, nextTick, watch, computed, ref, provide, h } from 'vue';
|
|
71032
71230
|
import './style.css';
|
|
71033
71231
|
import extensions from './extensions.js';
|
|
71034
71232
|
export default {
|
|
@@ -71040,6 +71238,7 @@ export default {
|
|
|
71040
71238
|
const sections = computed(() => data.theme.value.contextSections || []);
|
|
71041
71239
|
const home = computed(() => data.theme.value.contextHome || {});
|
|
71042
71240
|
const selected = ref('');
|
|
71241
|
+
const allSources = ref(false);
|
|
71043
71242
|
const mounted = ref(false);
|
|
71044
71243
|
const language = ref('zh');
|
|
71045
71244
|
const copiedCommand = ref('');
|
|
@@ -71142,6 +71341,7 @@ export default {
|
|
|
71142
71341
|
part('hour') + ':' + part('minute') + ':' + part('second') + ' ' + part('timeZoneName');
|
|
71143
71342
|
});
|
|
71144
71343
|
watch(() => route.path, () => {
|
|
71344
|
+
allSources.value = false;
|
|
71145
71345
|
const base = data.site.value.base;
|
|
71146
71346
|
const path = route.path.startsWith(base) ? '/' + route.path.slice(base.length) : route.path;
|
|
71147
71347
|
const direct = sections.value.find(section => section.href === path);
|
|
@@ -71208,9 +71408,11 @@ export default {
|
|
|
71208
71408
|
h('div', { class: 'context-sources-header' }, [
|
|
71209
71409
|
h('div', { class: 'context-sources-title' }, chinese.value ? '来源与溯源' : 'Sources'),
|
|
71210
71410
|
]),
|
|
71211
|
-
h('ul', sources.map(source => h('li', source.href
|
|
71411
|
+
h('ul', (allSources.value ? sources : sources.slice(0, 10)).map(source => h('li', source.href
|
|
71212
71412
|
? h('a', { href: source.href, target: '_blank', rel: 'noopener noreferrer' }, source.label)
|
|
71213
71413
|
: source.label))),
|
|
71414
|
+
sources.length > 10 && !allSources.value ? h('button', { type: 'button', class: 'context-sources-more',
|
|
71415
|
+
onClick: () => { allSources.value = true; } }, chinese.value ? '查看更多' : 'Show more') : null,
|
|
71214
71416
|
]) : null,
|
|
71215
71417
|
(data.frontmatter.value.contextUpdated || data.theme.value.contextUpdated)
|
|
71216
71418
|
? h('div', { class: 'context-article-updated' }, [
|
|
@@ -71230,56 +71432,252 @@ export default {
|
|
|
71230
71432
|
setup() {
|
|
71231
71433
|
const route = useRoute();
|
|
71232
71434
|
const { isDark } = useData();
|
|
71233
|
-
|
|
71234
|
-
|
|
71435
|
+
const viewer = ${DIAGRAM_VIEWER_SCRIPT}(async () => {
|
|
71436
|
+
const [{ default: mermaid }, { default: elk }] = await Promise.all([import('mermaid'), import('@mermaid-js/layout-elk')]);
|
|
71437
|
+
mermaid.registerLayoutLoaders(elk);
|
|
71438
|
+
return mermaid;
|
|
71439
|
+
});
|
|
71235
71440
|
const render = async () => {
|
|
71236
|
-
const current = ++generation;
|
|
71237
71441
|
await nextTick();
|
|
71238
|
-
|
|
71239
|
-
if (!nodes.length) return;
|
|
71240
|
-
queue = queue.catch(() => {}).then(async () => {
|
|
71241
|
-
if (current !== generation) return;
|
|
71242
|
-
const { default: mermaid } = await import('mermaid');
|
|
71243
|
-
mermaid.initialize({ startOnLoad: false, securityLevel: 'strict', theme: 'base',
|
|
71244
|
-
themeVariables: { darkMode: isDark.value, fontFamily: 'system-ui, sans-serif',
|
|
71245
|
-
primaryColor: isDark.value ? '#202127' : '#ffffff',
|
|
71246
|
-
primaryTextColor: isDark.value ? '#dfdfe5' : '#161e2e',
|
|
71247
|
-
primaryBorderColor: isDark.value ? '#92929a' : '#73737b',
|
|
71248
|
-
lineColor: isDark.value ? '#92929a' : '#73737b',
|
|
71249
|
-
secondaryColor: isDark.value ? '#292a30' : '#f6f6f7',
|
|
71250
|
-
tertiaryColor: isDark.value ? '#292a30' : '#f6f6f7' } });
|
|
71251
|
-
for (const [index, node] of nodes.entries()) {
|
|
71252
|
-
if (current !== generation || !node.isConnected) return;
|
|
71253
|
-
const code = node.querySelector('pre code');
|
|
71254
|
-
if (!code) continue;
|
|
71255
|
-
const source = code.textContent || '';
|
|
71256
|
-
let output = node.querySelector('.context-diagram');
|
|
71257
|
-
if (!output) { output = document.createElement('div'); output.className = 'context-diagram'; node.append(output); }
|
|
71258
|
-
const renderId = 'context-diagram-' + current + '-' + index;
|
|
71259
|
-
try {
|
|
71260
|
-
if (!await mermaid.parse(source, { suppressErrors: true })) throw new Error('Invalid diagram');
|
|
71261
|
-
const { svg } = await mermaid.render(renderId, source);
|
|
71262
|
-
if (current !== generation || !node.isConnected) return;
|
|
71263
|
-
output.innerHTML = svg;
|
|
71264
|
-
node.classList.add('context-rendered');
|
|
71265
|
-
if (!node.querySelector('.context-diagram-toggle')) {
|
|
71266
|
-
const toggle = document.createElement('button');
|
|
71267
|
-
toggle.className = 'context-diagram-toggle'; toggle.textContent = 'Diagram / source';
|
|
71268
|
-
toggle.onclick = () => node.classList.toggle('context-show-source');
|
|
71269
|
-
node.append(toggle);
|
|
71270
|
-
}
|
|
71271
|
-
} catch {
|
|
71272
|
-
document.getElementById('d' + renderId)?.remove();
|
|
71273
|
-
output.remove(); node.classList.remove('context-rendered');
|
|
71274
|
-
}
|
|
71275
|
-
}
|
|
71276
|
-
});
|
|
71277
|
-
await queue;
|
|
71442
|
+
await viewer.render(document, { dark: isDark.value, language: document.documentElement.lang || 'en' });
|
|
71278
71443
|
};
|
|
71279
71444
|
onMounted(render);
|
|
71445
|
+
onUnmounted(() => viewer.destroy());
|
|
71280
71446
|
watch([() => route.path, isDark], render);
|
|
71281
71447
|
}
|
|
71282
71448
|
};
|
|
71449
|
+
`;
|
|
71450
|
+
siteThemeCss = `
|
|
71451
|
+
.context-business-floating { position: fixed; right: max(20px, env(safe-area-inset-right)); bottom: max(20px, env(safe-area-inset-bottom)); z-index: 30; max-width: calc(100vw - 40px); }
|
|
71452
|
+
.context-history-cards { display: grid; gap: 16px; margin: 24px 0; }
|
|
71453
|
+
.context-history-card { border: 1px solid var(--vp-c-divider); border-radius: 12px; background: var(--vp-c-bg-soft); }
|
|
71454
|
+
.context-history-card summary { display: flex; align-items: baseline; flex-wrap: wrap; gap: 12px; padding: 20px; cursor: pointer; }
|
|
71455
|
+
.context-history-card summary::before { content: '▸'; }
|
|
71456
|
+
.context-history-card[open] summary::before { content: '▾'; }
|
|
71457
|
+
.context-history-card summary strong { color: var(--vp-c-brand-1); font-size: 13px; }
|
|
71458
|
+
.context-history-title { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
|
|
71459
|
+
.context-history-attribution { margin-left: auto; font-size: 13px; color: var(--vp-c-text-2); }
|
|
71460
|
+
.context-history-body { padding: 0 24px 20px; font-size: 13px; line-height: 1.8; overflow-wrap: anywhere; }
|
|
71461
|
+
.context-history-body ul { list-style: disc; padding-left: 20px; }
|
|
71462
|
+
.context-history-meta { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--vp-c-divider); color: var(--vp-c-text-2); }
|
|
71463
|
+
:root {
|
|
71464
|
+
--vp-font-family-base: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
|
|
71465
|
+
--vp-font-family-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
71466
|
+
--vp-c-brand-1: rgb(37, 99, 235); --vp-c-brand-2: #00bec8; --vp-c-brand-3: rgb(37, 99, 235);
|
|
71467
|
+
--context-accent: #00bec8;
|
|
71468
|
+
--vp-c-brand-soft: rgba(37, 99, 235, .08);
|
|
71469
|
+
--vp-sidebar-width: 280px;
|
|
71470
|
+
--vp-layout-max-width: 100%;
|
|
71471
|
+
--vp-nav-height: 64px;
|
|
71472
|
+
--vp-c-text-1: #161e2e; --vp-c-text-2: #646b7c;
|
|
71473
|
+
--vp-c-divider: #e7e9ef;
|
|
71474
|
+
--vp-sidebar-bg-color: #f8f9fc;
|
|
71475
|
+
}
|
|
71476
|
+
.dark {
|
|
71477
|
+
--vp-c-brand-1: #8eb7ff; --vp-c-brand-2: #b3cfff;
|
|
71478
|
+
--vp-c-brand-soft: rgba(142, 183, 255, .09);
|
|
71479
|
+
--vp-c-text-1: #e2e4ed; --vp-c-text-2: #a1a6b7;
|
|
71480
|
+
--vp-c-divider: #303440; --vp-sidebar-bg-color: #1b1d24;
|
|
71481
|
+
}
|
|
71482
|
+
.VPNavBar .wrapper { padding: 0 24px !important; }
|
|
71483
|
+
.VPNavBar .container { max-width: none !important; }
|
|
71484
|
+
.VPNav, .VPNavBar, .VPNavBar .wrapper { background: var(--vp-c-bg) !important; }
|
|
71485
|
+
.VPNavBar .title { position: static !important; padding: 0 !important; width: var(--vp-sidebar-width) !important; flex-shrink: 0; }
|
|
71486
|
+
.VPNavBarTitle .title { font-size: 15px; font-weight: 650; border: 0 !important; }
|
|
71487
|
+
.VPNavBar .content { flex: 1; min-width: 0; padding-left: 0 !important; }
|
|
71488
|
+
.VPNavBar .content-body { background: var(--vp-c-bg) !important; gap: 8px; }
|
|
71489
|
+
.VPNavBarMenu { order: -1; flex: 1; min-width: 0; }
|
|
71490
|
+
.context-language { display: inline-flex; align-items: center; padding: 5px 7px; border: 0; border-radius: 6px; color: var(--vp-c-text-2);
|
|
71491
|
+
background: transparent; white-space: nowrap; font-size: 12px; font-weight: 550; cursor: pointer; }
|
|
71492
|
+
.context-language:hover { color: var(--vp-c-brand-1); background: var(--vp-c-brand-soft); }
|
|
71493
|
+
.VPNavBarMenuLink { font-size: 13px !important; font-weight: 550 !important; padding: 0 16px !important; }
|
|
71494
|
+
.VPNavBarMenuLink.active { box-shadow: inset 0 -2px var(--vp-c-brand-1); }
|
|
71495
|
+
.VPNavBarSearch { flex: 0 0 376px !important; width: 376px; padding: 0 12px !important; }
|
|
71496
|
+
.VPNavBarSearch #local-search, .VPNavBarSearch .DocSearch-Button { width: 352px; }
|
|
71497
|
+
.VPNavBarSearch .DocSearch-Button { display: flex; align-items: center; }
|
|
71498
|
+
.VPNavBarSearch .DocSearch-Button-Container { display: flex; flex: 1; min-width: 0; align-items: center; }
|
|
71499
|
+
.VPNavBarSearch .DocSearch-Button-Keys { margin-left: auto; }
|
|
71500
|
+
.VPSidebar { border-top: 1px solid var(--vp-c-divider); border-right: 1px solid var(--vp-c-divider); scrollbar-width: thin; }
|
|
71501
|
+
.VPSidebar .group, .VPSidebar .group + .group { border: 0; padding-top: 0; }
|
|
71502
|
+
.VPSidebarItem .link { min-width: 0; overflow: hidden; }
|
|
71503
|
+
.VPSidebarItem .text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px !important; line-height: 20px !important; font-weight: 450 !important; }
|
|
71504
|
+
.VPSidebarItem.level-0 { padding-bottom: 0 !important; }
|
|
71505
|
+
.VPSidebarItem .indicator { display: none; }
|
|
71506
|
+
.VPSidebarItem .text { padding: 0 !important; }
|
|
71507
|
+
.VPSidebarItem .item { height: 38px; min-height: 38px; align-items: center; padding: 0 16px 0 26px; border-radius: 0; }
|
|
71508
|
+
.VPSidebarItem.is-link:not(.is-active) > .item > .link > p.text { color: var(--vp-c-text-2); }
|
|
71509
|
+
.VPSidebarItem.is-link:not(.is-active) > .item > .link:hover > p.text { color: var(--vp-c-brand-1); }
|
|
71510
|
+
.VPSidebarItem.is-active > .item { background: var(--vp-c-brand-soft); box-shadow: none; }
|
|
71511
|
+
.VPSidebarItem.is-active > .item .text { color: var(--vp-c-brand-1) !important; font-weight: 550 !important; }
|
|
71512
|
+
.VPSidebarItem .items { margin-left: 0; padding-left: 0 !important; border-left: 0 !important; }
|
|
71513
|
+
.VPSidebarItem.level-1 > .item { padding-left: 40px; }
|
|
71514
|
+
.VPSidebarItem.level-2 > .item { padding-left: 54px; }
|
|
71515
|
+
.VPSidebarItem.level-3 > .item { padding-left: 68px; }
|
|
71516
|
+
.VPSidebarItem.level-4 > .item { padding-left: 82px; }
|
|
71517
|
+
.VPSidebarItem.level-5 > .item { padding-left: 96px; }
|
|
71518
|
+
.VPSidebar .group { width: 100% !important; }
|
|
71519
|
+
.VPSidebarItem .item:hover { background: var(--vp-c-default-soft); }
|
|
71520
|
+
.VPDoc .container, .VPDoc > .container > .content, .VPDoc .content-container { max-width: none !important; min-width: 0 !important; }
|
|
71521
|
+
.VPDoc > .container > .content { flex: 1; }
|
|
71522
|
+
.VPDoc .aside { flex: 0 0 190px; width: 190px; max-width: 190px; padding-left: 24px; }
|
|
71523
|
+
.VPDoc .aside-container, .VPDoc .aside-curtain { width: 166px; }
|
|
71524
|
+
.VPDocAsideOutline .content { padding: 0 0 0 16px; }
|
|
71525
|
+
.VPDocAsideOutline .outline-title { font-size: 11px; font-weight: 600; letter-spacing: .03em; color: var(--vp-c-text-2); }
|
|
71526
|
+
.VPDocAsideOutline .outline-link { font-size: 12px !important; line-height: 20px !important; padding: 5px 0; white-space: normal; }
|
|
71527
|
+
.vp-doc { font-size: 16px; line-height: 1.8; color: var(--vp-c-text-1); }
|
|
71528
|
+
.vp-doc p, .vp-doc li { line-height: 1.8; }
|
|
71529
|
+
.vp-doc h1 { font-size: 36px; font-weight: 700; line-height: 1.3; letter-spacing: -.025em; margin-bottom: 28px; }
|
|
71530
|
+
.vp-doc h2 { font-size: 25px; font-weight: 650; line-height: 1.4; margin: 46px 0 22px; padding: 0 0 14px; border-top: 0; border-bottom: 1px solid var(--vp-c-divider); }
|
|
71531
|
+
.vp-doc h3 { font-size: 19px; font-weight: 600; line-height: 1.5; margin: 30px 0 14px; }
|
|
71532
|
+
.vp-doc a { color: inherit; font-weight: 500; text-decoration: none; border-bottom: 1px solid transparent; transition: color .15s, border-color .15s; }
|
|
71533
|
+
.vp-doc a:hover { color: var(--vp-c-brand-1); border-bottom-color: currentColor; }
|
|
71534
|
+
.vp-doc a.header-anchor { top: -0.06em !important; line-height: inherit; border: 0; color: var(--vp-c-brand-1); }
|
|
71535
|
+
.vp-doc blockquote { margin: 24px 0; padding: 16px 20px; border-left: 3px solid var(--context-accent); border-radius: 0 5px 5px 0; background: var(--vp-c-brand-soft); color: var(--vp-c-text-2); }
|
|
71536
|
+
.vp-doc blockquote p { margin: 0; font-size: 15px; }
|
|
71537
|
+
.vp-doc blockquote a { color: var(--vp-c-brand-1); }
|
|
71538
|
+
.vp-doc table { width: 100%; overflow-x: auto; font-size: 14px; border-collapse: collapse; margin: 24px 0; }
|
|
71539
|
+
.vp-doc th { background: var(--vp-sidebar-bg-color); font-weight: 600; }
|
|
71540
|
+
.vp-doc th, .vp-doc td { padding: 11px 14px; border-color: var(--vp-c-divider); line-height: 1.7; }
|
|
71541
|
+
.vp-doc tr:nth-child(2n) { background: var(--vp-c-bg); }
|
|
71542
|
+
.vp-doc :not(pre) > code { font-size: .88em; color: var(--vp-c-text-1); background: var(--vp-sidebar-bg-color); border: 1px solid var(--vp-c-divider); border-radius: 4px; }
|
|
71543
|
+
.vp-doc div[class*='language-'] { border: 1px solid var(--vp-c-divider); border-radius: 6px; }
|
|
71544
|
+
.vp-doc details { margin: 20px 0; border: 1px solid var(--vp-c-divider); border-radius: 6px; padding: 12px 16px; }
|
|
71545
|
+
.vp-doc summary { cursor: pointer; font-size: 14px; font-weight: 550; }
|
|
71546
|
+
.vp-doc img { max-width: 100%; height: auto; }
|
|
71547
|
+
.context-home { max-width: 100%; min-width: 0; overflow-x: clip; }
|
|
71548
|
+
.context-home .VPContent, .context-home .VPHome, .context-home .VPHero { max-width: 100%; min-width: 0; }
|
|
71549
|
+
.context-home .VPHome { padding-bottom: 0; }
|
|
71550
|
+
.context-home .VPHero { position: relative; padding: 132px 0 62px; }
|
|
71551
|
+
.context-home .VPHero::before { content: ''; position: absolute; top: -1px; right: 0; bottom: 0; left: calc(0px - var(--vp-sidebar-width)); pointer-events: none;
|
|
71552
|
+
background: linear-gradient(to bottom, transparent 58%, var(--vp-c-bg) 100%),
|
|
71553
|
+
radial-gradient(ellipse 58% 145% at 8% 18%, rgba(37,99,235,.16), transparent 72%),
|
|
71554
|
+
radial-gradient(ellipse 58% 150% at 68% 24%, rgba(0,190,200,.11), transparent 72%),
|
|
71555
|
+
linear-gradient(90deg, rgba(37,99,235,.045), rgba(0,190,200,.025) 68%, transparent); }
|
|
71556
|
+
.context-home .VPHero .container { position: relative; box-sizing: border-box; width: min(1180px, calc(100% - 104px)); max-width: none; min-width: 0; margin-left: 52px; margin-right: auto; }
|
|
71557
|
+
.context-home .VPHero .main { width: 100%; max-width: 980px; min-width: 0; }
|
|
71558
|
+
.context-home .VPHero .heading { display: block; width: 100%; min-width: 0; max-width: 100%; }
|
|
71559
|
+
.context-home .VPHero .name { display: block; width: 100%; max-width: 100%; overflow-wrap: anywhere; white-space: normal; color: transparent;
|
|
71560
|
+
background: linear-gradient(112deg, var(--vp-c-brand-1), var(--context-accent)); background-clip: text; -webkit-background-clip: text; }
|
|
71561
|
+
.context-home .VPHero .text { display: block; width: 100%; max-width: 100%; overflow-wrap: anywhere; word-break: break-word; white-space: normal;
|
|
71562
|
+
font-size: clamp(38px, 4.2vw, 60px); line-height: 1.08; letter-spacing: -.045em; }
|
|
71563
|
+
.context-home .VPHero .tagline { max-width: 820px; font-size: 18px; line-height: 1.75; }
|
|
71564
|
+
.context-home .VPHero .actions { width: 100%; min-width: 0; padding-top: 38px; flex-wrap: wrap; }
|
|
71565
|
+
.context-home .VPFeatures { display: none; }
|
|
71566
|
+
.context-home-section { width: min(1180px, calc(100% - 104px)); margin: 0 auto 0 52px; padding: 36px 0 44px; }
|
|
71567
|
+
.context-home-section + .context-home-section { border-top: 1px solid var(--vp-c-divider); }
|
|
71568
|
+
.context-home-map { padding-top: 0; }
|
|
71569
|
+
.context-home-resources { padding-top: 6px; border-top: 0 !important; }
|
|
71570
|
+
.context-home-section-heading { max-width: 700px; margin-bottom: 24px; }
|
|
71571
|
+
.context-home-section-heading h2 { margin: 2px 0 8px; border: 0; font-size: 28px; line-height: 1.3; letter-spacing: -.02em; }
|
|
71572
|
+
.context-home-section-heading > p:last-child { color: var(--vp-c-text-2); line-height: 1.7; }
|
|
71573
|
+
.context-home-kicker { margin: 0; color: var(--vp-c-brand-1); font-size: 11px; font-weight: 700; letter-spacing: .16em; }
|
|
71574
|
+
.context-home-map-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(290px, 100%), 1fr)); gap: 14px; }
|
|
71575
|
+
.context-home-map-card, .context-home-resource-card { border: 1px solid var(--vp-c-divider); background: color-mix(in srgb, var(--vp-c-bg) 88%, var(--vp-c-bg-soft));
|
|
71576
|
+
animation: context-home-rise .5s both; animation-delay: var(--context-home-delay); }
|
|
71577
|
+
.context-home-map-card { min-height: 224px; padding: 22px; border-radius: 14px; }
|
|
71578
|
+
.context-home-map-card:hover, .context-home-resource-card:hover { border-color: color-mix(in srgb, var(--vp-c-brand-1) 42%, var(--vp-c-divider));
|
|
71579
|
+
box-shadow: 0 14px 38px rgba(23,36,66,.08); transform: translateY(-2px); transition: border-color .18s, box-shadow .18s, transform .18s; }
|
|
71580
|
+
.context-home-map-card-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding-bottom: 13px; border-bottom: 1px solid var(--vp-c-divider); }
|
|
71581
|
+
.context-home-map-card h3, .context-home-resource-card h3 { margin: 0; font-size: 17px; line-height: 1.45; }
|
|
71582
|
+
.context-home-map-card h3 a { color: var(--vp-c-text-1); }
|
|
71583
|
+
.context-home-map-card-heading span { flex: none; color: var(--vp-c-text-2); font-size: 11px; }
|
|
71584
|
+
.context-home-map-card ul { margin: 14px 0 0; padding: 0; list-style: none; }
|
|
71585
|
+
.context-home-map-card li { margin: 7px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
71586
|
+
.context-home-map-card li a { color: var(--vp-c-text-2); font-size: 13px; }
|
|
71587
|
+
.context-home-map-card li a:hover, .context-home-map-more:hover { color: var(--vp-c-brand-1); }
|
|
71588
|
+
.context-home-map-more { display: inline-block; margin-top: 12px; color: var(--vp-c-brand-1); font-size: 12px; font-weight: 600; }
|
|
71589
|
+
.context-home-resource-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
|
|
71590
|
+
.context-home-resource-card { min-height: 118px; padding: 16px 18px; border-radius: 12px; }
|
|
71591
|
+
.context-home-resource-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
|
|
71592
|
+
.context-home-resource-actions { display: flex; flex: none; align-items: center; gap: 6px; }
|
|
71593
|
+
.context-home-resource-action, .context-home-install-action { display: inline-flex; align-items: center; min-height: 28px; padding: 4px 8px; border: 1px solid var(--vp-c-divider); border-radius: 6px;
|
|
71594
|
+
color: var(--vp-c-text-2); background: var(--vp-c-bg); font-size: 11px; font-weight: 600; line-height: 1; white-space: nowrap; }
|
|
71595
|
+
.context-home-resource-action:hover, .context-home-install-action:hover { border-color: var(--vp-c-brand-1); color: var(--vp-c-brand-1); }
|
|
71596
|
+
.context-home-install-action { cursor: pointer; background: var(--vp-c-brand-soft); }
|
|
71597
|
+
.context-home-resource-card p { margin: 8px 0 0; color: var(--vp-c-text-2); font-size: 13px; line-height: 1.55; }
|
|
71598
|
+
.context-home-powered { width: min(1180px, calc(100% - 104px)); margin: 24px auto 0 52px; padding: 22px 0 30px; border-top: 1px solid var(--vp-c-divider);
|
|
71599
|
+
color: var(--vp-c-text-2); font-size: 11px; text-align: right; }
|
|
71600
|
+
.context-home-powered a { color: inherit; }
|
|
71601
|
+
@keyframes context-home-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
|
|
71602
|
+
@media (min-width: 960px) {
|
|
71603
|
+
.VPSidebar { top: var(--vp-nav-height) !important; width: var(--vp-sidebar-width) !important; padding: 12px 0 48px !important; }
|
|
71604
|
+
.VPSidebar .curtain { display: none; }
|
|
71605
|
+
.VPContent.has-sidebar { padding-left: var(--vp-sidebar-width) !important; padding-right: 0 !important; }
|
|
71606
|
+
.context-empty-sidebar .VPContent { padding-left: var(--vp-sidebar-width) !important; padding-right: 0 !important; }
|
|
71607
|
+
.context-home .VPContent { padding-left: var(--vp-sidebar-width) !important; padding-right: 0 !important; }
|
|
71608
|
+
.VPNavBar .content { padding-right: 32px !important; }
|
|
71609
|
+
.VPDoc { padding: 44px 36px 80px !important; }
|
|
71610
|
+
.VPDoc > .container > .content { padding: 0 24px 80px 0 !important; }
|
|
71611
|
+
}
|
|
71612
|
+
@media (min-width: 1600px) { .VPDoc { padding-left: 52px !important; padding-right: 36px !important; } }
|
|
71613
|
+
@media (min-width: 960px) and (max-width: 1279px) {
|
|
71614
|
+
.VPNavBar .title { width: 220px !important; }
|
|
71615
|
+
.VPNavBarMenuLink { padding: 0 9px !important; }
|
|
71616
|
+
.VPNavBarSearch { flex-basis: 168px !important; width: 168px; }
|
|
71617
|
+
.VPNavBarSearch .DocSearch-Button { width: 144px; }
|
|
71618
|
+
.context-home .VPHero .main { max-width: 100%; }
|
|
71619
|
+
.context-home-resource-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
71620
|
+
}
|
|
71621
|
+
@media (min-width: 1280px) and (max-width: 1599px) {
|
|
71622
|
+
.VPNavBarSearch { flex-basis: 248px !important; width: 248px; }
|
|
71623
|
+
.VPNavBarSearch #local-search, .VPNavBarSearch .DocSearch-Button { width: 224px; }
|
|
71624
|
+
}
|
|
71625
|
+
.context-mobile-directory { display: none; }
|
|
71626
|
+
@media (max-width: 959px) {
|
|
71627
|
+
.VPNavBar .wrapper { padding: 0 16px !important; }
|
|
71628
|
+
.VPNavBar .title { flex: 1; min-width: 0; }
|
|
71629
|
+
.VPNavBarTitle .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
71630
|
+
.VPNavBar .content { flex: 0 0 auto; }
|
|
71631
|
+
.VPSidebar { width: min(340px, calc(100vw - 40px)) !important; max-width: none; padding: 0 0 32px !important; }
|
|
71632
|
+
.context-mobile-directory { display: block; position: sticky; top: 0; z-index: 2; padding: 12px 16px; margin-bottom: 8px; border-bottom: 1px solid var(--vp-c-divider); background: var(--vp-sidebar-bg-color); }
|
|
71633
|
+
.context-mobile-directory-heading { display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 600; }
|
|
71634
|
+
.context-mobile-directory-heading button { width: 36px; height: 36px; font-size: 24px; font-weight: 400; color: var(--vp-c-text-2); }
|
|
71635
|
+
.context-mobile-sections { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
|
|
71636
|
+
.context-mobile-sections a { padding: 5px 9px; border-radius: 5px; font-size: 12px; color: var(--vp-c-text-2); }
|
|
71637
|
+
.context-mobile-sections a.active { background: var(--vp-c-brand-soft); color: var(--vp-c-brand-1); }
|
|
71638
|
+
.VPNavScreen { bottom: auto !important; max-height: calc(100dvh - var(--vp-nav-height)); padding: 0 20px !important; border-bottom: 1px solid var(--vp-c-divider); box-shadow: 0 12px 24px rgba(0,0,0,.08); }
|
|
71639
|
+
.VPNavScreen > .container { max-width: none !important; padding: 8px 0 16px !important; }
|
|
71640
|
+
.VPNavScreenMenuLink { padding: 9px 0 !important; font-size: 13px !important; }
|
|
71641
|
+
.VPNavScreen .menu + .appearance { margin-top: 14px; }
|
|
71642
|
+
|
|
71643
|
+
.VPNavBar .title { width: auto !important; }
|
|
71644
|
+
.vp-doc h1 { font-size: 28px; }
|
|
71645
|
+
.vp-doc h2 { font-size: 22px; }
|
|
71646
|
+
.VPDoc { padding: 32px 36px 64px !important; }
|
|
71647
|
+
.vp-doc a.header-anchor { margin-left: -0.8em; }
|
|
71648
|
+
.context-home .VPHero { padding-top: 104px; padding-bottom: 66px; }
|
|
71649
|
+
.context-home .VPHero::before { left: 0; }
|
|
71650
|
+
.context-home .VPHero .container { width: min(calc(100% - 36px), 680px); margin-left: auto; margin-right: auto; }
|
|
71651
|
+
.context-home .VPHero .text { font-size: 40px; }
|
|
71652
|
+
.context-home .VPHero .tagline { font-size: 16px; }
|
|
71653
|
+
.context-home-section, .context-home-powered { width: min(calc(100% - 36px), 680px); margin-left: auto; margin-right: auto; }
|
|
71654
|
+
.context-home-resource-grid { grid-template-columns: 1fr; }
|
|
71655
|
+
}
|
|
71656
|
+
@media (max-width: 1279px) {
|
|
71657
|
+
.VPNavBarMenu { display: none !important; }
|
|
71658
|
+
.VPNavBarHamburger { display: flex !important; }
|
|
71659
|
+
.VPNavScreen { display: block !important; }
|
|
71660
|
+
.VPNavScreen { bottom: auto !important; max-height: calc(100dvh - var(--vp-nav-height)); overflow-y: auto; }
|
|
71661
|
+
.VPNavBarSearch { flex: 0 0 48px !important; width: 48px; padding: 0 4px !important; }
|
|
71662
|
+
.VPNavBarSearch #local-search, .VPNavBarSearch .DocSearch-Button { width: 40px; }
|
|
71663
|
+
.VPNavBarSearch .DocSearch-Button-Placeholder, .VPNavBarSearch .DocSearch-Button-Keys { display: none !important; }
|
|
71664
|
+
}
|
|
71665
|
+
@media (prefers-reduced-motion: reduce) {
|
|
71666
|
+
.context-home-map-card, .context-home-resource-card { animation: none; }
|
|
71667
|
+
.context-home-map-card:hover, .context-home-resource-card:hover { transform: none; }
|
|
71668
|
+
}
|
|
71669
|
+
.context-sources { margin-top: 0; margin-bottom: 24px; padding: 16px 20px; border: 1px solid var(--vp-c-divider); border-radius: 8px; background: var(--vp-sidebar-bg-color); color: var(--vp-c-text-2); font-size: 12px; line-height: 1.7; overflow-wrap: anywhere; }
|
|
71670
|
+
.context-sources-header { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 8px; }
|
|
71671
|
+
.context-sources-title { font-weight: 550; }
|
|
71672
|
+
.context-sources-more { color: var(--vp-c-brand-1); font-size: 13px; padding: 4px 0; cursor: pointer; }
|
|
71673
|
+
.context-provenance { margin-bottom: 24px; }
|
|
71674
|
+
.context-provenance .context-sources { margin-bottom: 10px; }
|
|
71675
|
+
.context-article-updated { margin-top: 0; text-align: right; color: var(--vp-c-text-2); font-size: 12px; line-height: 1.7; }
|
|
71676
|
+
.context-sources ul { list-style: none; margin: 0; padding: 0; }
|
|
71677
|
+
.context-sources li + li { margin-top: 6px; }
|
|
71678
|
+
.context-sources a { color: inherit; text-decoration: none; border-bottom: 1px solid transparent; }
|
|
71679
|
+
.context-sources a:hover { color: var(--vp-c-brand-1); border-color: currentColor; }
|
|
71680
|
+
${DIAGRAM_STYLES}
|
|
71283
71681
|
`;
|
|
71284
71682
|
});
|
|
71285
71683
|
|
|
@@ -71295,8 +71693,8 @@ var init_packageSiteBranding = __esm(() => {
|
|
|
71295
71693
|
|
|
71296
71694
|
// src/project/packageSiteExtensions.ts
|
|
71297
71695
|
import { createHash as createHash15 } from "node:crypto";
|
|
71298
|
-
import { lstat as lstat7, readdir as readdir14, readFile as
|
|
71299
|
-
import { join as
|
|
71696
|
+
import { lstat as lstat7, readdir as readdir14, readFile as readFile48, mkdir as mkdir20, writeFile as writeFile16, symlink } from "node:fs/promises";
|
|
71697
|
+
import { join as join57, dirname as dirname24, resolve as resolve19 } from "node:path";
|
|
71300
71698
|
function invalidSiteExtension(message) {
|
|
71301
71699
|
throw new ContextError(ExitCode.UserError, `Site extensions: ${message}. Update site.extensions, its src files or the knowledge-map target, then retry the build.`, {
|
|
71302
71700
|
reason_code: "invalid-site-extension"
|
|
@@ -71315,7 +71713,7 @@ async function readSiteExtensions(projectRoot, extensions) {
|
|
|
71315
71713
|
invalid(`unsafe root ${root}`);
|
|
71316
71714
|
let cursor = projectRoot;
|
|
71317
71715
|
for (const part of root.split("/")) {
|
|
71318
|
-
cursor =
|
|
71716
|
+
cursor = join57(cursor, part);
|
|
71319
71717
|
const info = await lstat7(cursor).catch((error) => {
|
|
71320
71718
|
if (error.code === "ENOENT")
|
|
71321
71719
|
invalid(`missing directory ${root}`);
|
|
@@ -71335,9 +71733,9 @@ async function readSiteExtensions(projectRoot, extensions) {
|
|
|
71335
71733
|
if (entry.isSymbolicLink())
|
|
71336
71734
|
invalid(`symlink at ${path2}`);
|
|
71337
71735
|
if (entry.isDirectory())
|
|
71338
|
-
await walk(
|
|
71736
|
+
await walk(join57(directory, entry.name), path2 + "/");
|
|
71339
71737
|
else if (entry.isFile())
|
|
71340
|
-
files.push({ path: path2, bytes: await
|
|
71738
|
+
files.push({ path: path2, bytes: await readFile48(join57(directory, entry.name)) });
|
|
71341
71739
|
}
|
|
71342
71740
|
}
|
|
71343
71741
|
await walk(cursor, "");
|
|
@@ -71357,7 +71755,7 @@ async function readSiteExtensions(projectRoot, extensions) {
|
|
|
71357
71755
|
hash3.update(file.path + "\x00").update(file.bytes).update("\x00");
|
|
71358
71756
|
for (const name2 of ["package.json", "bun.lock", "pnpm-lock.yaml", "package-lock.json"]) {
|
|
71359
71757
|
try {
|
|
71360
|
-
hash3.update(name2).update(await
|
|
71758
|
+
hash3.update(name2).update(await readFile48(join57(projectRoot, name2)));
|
|
71361
71759
|
} catch (error) {
|
|
71362
71760
|
if (error.code !== "ENOENT")
|
|
71363
71761
|
throw error;
|
|
@@ -71370,18 +71768,18 @@ function siteExtensionTargets(site) {
|
|
|
71370
71768
|
}
|
|
71371
71769
|
async function writeSiteExtensions(projectRoot, temporary, extensions) {
|
|
71372
71770
|
const { files } = await readSiteExtensions(projectRoot, extensions);
|
|
71373
|
-
const root =
|
|
71771
|
+
const root = join57(temporary, "_site");
|
|
71374
71772
|
for (const file of files) {
|
|
71375
|
-
const path2 =
|
|
71376
|
-
await
|
|
71377
|
-
await
|
|
71773
|
+
const path2 = join57(root, file.path);
|
|
71774
|
+
await mkdir20(dirname24(path2), { recursive: true });
|
|
71775
|
+
await writeFile16(path2, file.bytes);
|
|
71378
71776
|
}
|
|
71379
71777
|
if (extensions) {
|
|
71380
71778
|
try {
|
|
71381
71779
|
const modules = resolve19(projectRoot, "node_modules");
|
|
71382
71780
|
if ((await lstat7(modules)).isDirectory() || (await lstat7(modules)).isSymbolicLink()) {
|
|
71383
|
-
await
|
|
71384
|
-
await symlink(modules,
|
|
71781
|
+
await mkdir20(root, { recursive: true });
|
|
71782
|
+
await symlink(modules, join57(root, "node_modules"), "dir");
|
|
71385
71783
|
}
|
|
71386
71784
|
} catch (error) {
|
|
71387
71785
|
if (error.code !== "ENOENT")
|
|
@@ -71400,16 +71798,16 @@ async function writeSiteExtensions(projectRoot, temporary, extensions) {
|
|
|
71400
71798
|
imports.push(`const ${name2} = defineAsyncComponent(() => import(${JSON.stringify(`../../_site/${path2}`)}));`);
|
|
71401
71799
|
slots.push(`${JSON.stringify(name2)}: ${name2 === "floating" ? `() => h(resolveComponent('ClientOnly'), null, { default: () => h(${name2}) })` : `() => h(${name2})`}`);
|
|
71402
71800
|
}
|
|
71403
|
-
await
|
|
71801
|
+
await writeFile16(join57(temporary, ".vitepress/theme/extensions.js"), imports.join(`
|
|
71404
71802
|
`) + `
|
|
71405
71803
|
export default {${slots.join(",")}};
|
|
71406
71804
|
`);
|
|
71407
71805
|
for (const [key, path2] of Object.entries(extensions?.pages ?? {})) {
|
|
71408
|
-
await
|
|
71806
|
+
await mkdir20(join57(temporary, "custom"), { recursive: true });
|
|
71409
71807
|
const content3 = files.find((file) => file.path === path2).bytes.toString("utf8");
|
|
71410
71808
|
const metadata = parseKnowledgeFrontmatter(content3);
|
|
71411
71809
|
const title = metadata.title ?? /^#\s+(.+)$/m.exec(content3)?.[1] ?? key;
|
|
71412
|
-
await
|
|
71810
|
+
await writeFile16(join57(temporary, "custom", `${key}.md`), `---
|
|
71413
71811
|
${JSON.stringify({ layout: "page", ...metadata, title })}
|
|
71414
71812
|
---
|
|
71415
71813
|
<script setup>
|
|
@@ -71431,9 +71829,9 @@ var init_packageSiteExtensions = __esm(() => {
|
|
|
71431
71829
|
// src/project/packageSite.ts
|
|
71432
71830
|
import { createHash as createHash16 } from "node:crypto";
|
|
71433
71831
|
import { spawn as spawn3 } from "node:child_process";
|
|
71434
|
-
import { mkdir as
|
|
71832
|
+
import { mkdir as mkdir21, mkdtemp, readFile as readFile49, writeFile as writeFile17, rm as rm11, symlink as symlink2, cp, access as access5, stat as stat6 } from "node:fs/promises";
|
|
71435
71833
|
import { createRequire as createRequire5 } from "node:module";
|
|
71436
|
-
import { dirname as
|
|
71834
|
+
import { dirname as dirname25, join as join58, posix as posix6 } from "node:path";
|
|
71437
71835
|
function sitePagePath(identity) {
|
|
71438
71836
|
return `pages/${createHash16("sha256").update(identity).digest("hex").slice(0, 32)}.html`;
|
|
71439
71837
|
}
|
|
@@ -71552,9 +71950,9 @@ function siteSections(entries2) {
|
|
|
71552
71950
|
}));
|
|
71553
71951
|
}
|
|
71554
71952
|
async function compileSite(root, outDir) {
|
|
71555
|
-
const vitepressRoot =
|
|
71953
|
+
const vitepressRoot = dirname25(require2.resolve("vitepress/package.json"));
|
|
71556
71954
|
await new Promise((resolve8, reject) => {
|
|
71557
|
-
const child = spawn3(process.versions.bun ? "node" : process.execPath, [
|
|
71955
|
+
const child = spawn3(process.versions.bun ? "node" : process.execPath, [join58(vitepressRoot, "bin/vitepress.js"), "build", root, "--outDir", outDir], { stdio: ["ignore", "pipe", "pipe"] });
|
|
71558
71956
|
let tail = "";
|
|
71559
71957
|
const receive = (chunk) => {
|
|
71560
71958
|
tail = (tail + chunk.toString()).slice(-16000);
|
|
@@ -71585,8 +71983,8 @@ async function writePackageSite(input) {
|
|
|
71585
71983
|
const base = options.base ?? "/";
|
|
71586
71984
|
const history = await readWorkspaceChangelog(projectRoot);
|
|
71587
71985
|
const historyDate = history[0]?.date ?? null;
|
|
71588
|
-
const root =
|
|
71589
|
-
const output =
|
|
71986
|
+
const root = join58(projectRoot, pkg.outDir);
|
|
71987
|
+
const output = join58(projectRoot, packageSiteOutputDir(pkg));
|
|
71590
71988
|
try {
|
|
71591
71989
|
await access5(output);
|
|
71592
71990
|
throw new Error("Website output already exists; build through the staged package workflow.");
|
|
@@ -71594,9 +71992,9 @@ async function writePackageSite(input) {
|
|
|
71594
71992
|
if (error.code !== "ENOENT")
|
|
71595
71993
|
throw error;
|
|
71596
71994
|
}
|
|
71597
|
-
const temporaryRoot =
|
|
71598
|
-
await
|
|
71599
|
-
const temporary = await mkdtemp(
|
|
71995
|
+
const temporaryRoot = join58(projectRoot, ".tmp");
|
|
71996
|
+
await mkdir21(temporaryRoot, { recursive: true });
|
|
71997
|
+
const temporary = await mkdtemp(join58(temporaryRoot, "website-"));
|
|
71600
71998
|
try {
|
|
71601
71999
|
const registry2 = await loadSourcesRegistry({ rootDir: projectRoot });
|
|
71602
72000
|
const sourceContent = new Map(selected.map((file) => [packageKnowledgeOutputPath(pkg, file.relPath), file]));
|
|
@@ -71606,7 +72004,7 @@ async function writePackageSite(input) {
|
|
|
71606
72004
|
for (const file of delivered) {
|
|
71607
72005
|
if (!/^(?:skills|wikis|guides|rules|feats)\/.*\.md$/u.test(file.relPath) || byPath.has(file.relPath))
|
|
71608
72006
|
continue;
|
|
71609
|
-
const content3 = await
|
|
72007
|
+
const content3 = await readFile49(file.absPath, "utf8");
|
|
71610
72008
|
const meta = parseKnowledgeFrontmatter(content3);
|
|
71611
72009
|
const page = {
|
|
71612
72010
|
package_path: file.relPath,
|
|
@@ -71617,20 +72015,22 @@ async function writePackageSite(input) {
|
|
|
71617
72015
|
}
|
|
71618
72016
|
const sections = siteSections(mapping.entries);
|
|
71619
72017
|
const resources = new Set(delivered.filter((file) => file.relPath.startsWith("others/assets/") || file.relPath.startsWith("skills/") && !file.relPath.endsWith(".md")).map((file) => file.relPath));
|
|
71620
|
-
const configRoot =
|
|
71621
|
-
await
|
|
71622
|
-
await
|
|
71623
|
-
const vitepressRoot =
|
|
71624
|
-
const vueRequire = createRequire5(
|
|
72018
|
+
const configRoot = join58(temporary, ".vitepress");
|
|
72019
|
+
await mkdir21(join58(configRoot, "theme"), { recursive: true });
|
|
72020
|
+
await mkdir21(join58(temporary, "node_modules"), { recursive: true });
|
|
72021
|
+
const vitepressRoot = dirname25(require2.resolve("vitepress/package.json"));
|
|
72022
|
+
const vueRequire = createRequire5(join58(vitepressRoot, "package.json"));
|
|
71625
72023
|
for (const [name2, path2] of [
|
|
71626
72024
|
["vitepress", vitepressRoot],
|
|
71627
|
-
["vue",
|
|
71628
|
-
["mermaid",
|
|
72025
|
+
["vue", dirname25(vueRequire.resolve("vue/package.json"))],
|
|
72026
|
+
["@mermaid-js/layout-elk", dirname25(require2.resolve("@mermaid-js/layout-elk/package.json"))],
|
|
72027
|
+
["mermaid", dirname25(require2.resolve("mermaid/package.json"))]
|
|
71629
72028
|
]) {
|
|
71630
|
-
await
|
|
72029
|
+
await mkdir21(dirname25(join58(temporary, "node_modules", name2)), { recursive: true });
|
|
72030
|
+
await symlink2(path2, join58(temporary, "node_modules", name2), "dir");
|
|
71631
72031
|
}
|
|
71632
|
-
await
|
|
71633
|
-
await
|
|
72032
|
+
await writeFile17(join58(configRoot, "theme/index.js"), siteThemeScript);
|
|
72033
|
+
await writeFile17(join58(configRoot, "theme/style.css"), siteThemeCss + siteThemeVariables(await resolveSiteTheme(projectRoot, options.theme, true)));
|
|
71634
72034
|
await writeSiteExtensions(projectRoot, temporary, options.extensions);
|
|
71635
72035
|
const config = {
|
|
71636
72036
|
title: options.title ?? pkg.name,
|
|
@@ -71656,11 +72056,11 @@ async function writePackageSite(input) {
|
|
|
71656
72056
|
nav: [...sections.map((section) => ({ text: section.title, link: section.href })), { text: "更多", items: [{ text: "LLM Docs", link: "/llms/index.html" }, { text: "Changelog", link: "/changelog.html" }] }]
|
|
71657
72057
|
}
|
|
71658
72058
|
};
|
|
71659
|
-
await
|
|
72059
|
+
await writeFile17(join58(configRoot, "config.mjs"), `export default { ...${JSON.stringify(config)}, markdown: { ${siteMarkdownConfig} } };
|
|
71660
72060
|
`);
|
|
71661
|
-
await
|
|
72061
|
+
await mkdir21(join58(temporary, "pages"), { recursive: true });
|
|
71662
72062
|
for (const page of byPath.values()) {
|
|
71663
|
-
const content3 = await
|
|
72063
|
+
const content3 = await readFile49(join58(root, page.package_path), "utf8");
|
|
71664
72064
|
const original = sourceContent.get(page.package_path);
|
|
71665
72065
|
const provenance = articleProvenanceMarkdown(original?.article, registry2);
|
|
71666
72066
|
const pageContent = provenance && content3.endsWith(provenance) ? content3.slice(0, -provenance.length) : content3;
|
|
@@ -71668,7 +72068,7 @@ async function writePackageSite(input) {
|
|
|
71668
72068
|
const sources = siteArticleSources(original?.article, registry2);
|
|
71669
72069
|
const timestamp = parseKnowledgeFrontmatter(original?.content ?? content3).timestamp;
|
|
71670
72070
|
const updated = typeof timestamp === "string" && Number.isFinite(Date.parse(timestamp)) ? new Date(timestamp).toISOString() : null;
|
|
71671
|
-
await
|
|
72071
|
+
await writeFile17(join58(temporary, page.site_path.replace(/\.html$/u, ".md")), `---
|
|
71672
72072
|
title: ${JSON.stringify(page.title)}
|
|
71673
72073
|
contextSources: ${JSON.stringify(sources)}
|
|
71674
72074
|
contextUpdated: ${JSON.stringify(updated)}
|
|
@@ -71680,11 +72080,11 @@ ${body}`);
|
|
|
71680
72080
|
lines.push(`${" ".repeat(level)}- ${entry.href ? `[${mdLabel(entry.title)}](${entry.href})` : mdLabel(entry.title)}`);
|
|
71681
72081
|
menu(lines, entry.children, level + 1);
|
|
71682
72082
|
});
|
|
71683
|
-
await
|
|
72083
|
+
await mkdir21(join58(temporary, "sections"), { recursive: true });
|
|
71684
72084
|
for (const section of sections) {
|
|
71685
72085
|
const lines = [`# ${mdLabel(section.title)}`, ""];
|
|
71686
72086
|
menu(lines, section.entries, 0);
|
|
71687
|
-
await
|
|
72087
|
+
await writeFile17(join58(temporary, section.href.slice(1).replace(/\.html$/u, ".md")), lines.join(`
|
|
71688
72088
|
`) + `
|
|
71689
72089
|
`);
|
|
71690
72090
|
}
|
|
@@ -71703,12 +72103,12 @@ ${body}`);
|
|
|
71703
72103
|
};
|
|
71704
72104
|
const homeHero = options.extensions?.slots?.banner === undefined ? `hero: ${JSON.stringify(hero)}
|
|
71705
72105
|
` : "";
|
|
71706
|
-
await
|
|
72106
|
+
await writeFile17(join58(temporary, "index.md"), `---
|
|
71707
72107
|
layout: home
|
|
71708
72108
|
title: ${JSON.stringify(options.home?.title ?? options.title ?? pkg.name)}
|
|
71709
72109
|
${homeHero}---
|
|
71710
72110
|
`);
|
|
71711
|
-
await
|
|
72111
|
+
await writeFile17(join58(temporary, "changelog.md"), `---
|
|
71712
72112
|
title: Changelog
|
|
71713
72113
|
contextHistory: ${JSON.stringify(Buffer.from(JSON.stringify(history)).toString("base64"))}
|
|
71714
72114
|
---
|
|
@@ -71721,19 +72121,19 @@ contextHistory: ${JSON.stringify(Buffer.from(JSON.stringify(history)).toString("
|
|
|
71721
72121
|
assetsPrefix: "resources/",
|
|
71722
72122
|
articles: await Promise.all(llmsArticles(pkg, selected).map(async (article) => ({
|
|
71723
72123
|
...article,
|
|
71724
|
-
content: await
|
|
72124
|
+
content: await readFile49(join58(root, article.path), "utf8")
|
|
71725
72125
|
}))),
|
|
71726
72126
|
...structure ? { map: structure } : {}
|
|
71727
72127
|
});
|
|
71728
|
-
await writeLlmsDocuments(
|
|
71729
|
-
await
|
|
72128
|
+
await writeLlmsDocuments(join58(temporary, "public"), llms, { utf8Bom: true });
|
|
72129
|
+
await mkdir21(join58(temporary, "llms"), { recursive: true });
|
|
71730
72130
|
let landingNavigation = llms.navigationMarkdown;
|
|
71731
72131
|
for (const link of markdownReaderLinks(landingNavigation).reverse()) {
|
|
71732
72132
|
if (!link.target.startsWith(base))
|
|
71733
72133
|
continue;
|
|
71734
72134
|
landingNavigation = landingNavigation.slice(0, link.start) + `[${link.label}](</${link.target.slice(base.length)}>)` + landingNavigation.slice(link.end);
|
|
71735
72135
|
}
|
|
71736
|
-
await
|
|
72136
|
+
await writeFile17(join58(temporary, "llms/index.md"), `---
|
|
71737
72137
|
title: LLM Docs
|
|
71738
72138
|
---
|
|
71739
72139
|
|
|
@@ -71743,9 +72143,9 @@ title: LLM Docs
|
|
|
71743
72143
|
|
|
71744
72144
|
` + landingNavigation);
|
|
71745
72145
|
for (const path2 of resources) {
|
|
71746
|
-
const destination =
|
|
71747
|
-
await
|
|
71748
|
-
await cp(
|
|
72146
|
+
const destination = join58(temporary, "public/resources", path2);
|
|
72147
|
+
await mkdir21(dirname25(destination), { recursive: true });
|
|
72148
|
+
await cp(join58(root, path2), destination);
|
|
71749
72149
|
}
|
|
71750
72150
|
await compileSite(temporary, output);
|
|
71751
72151
|
for (const file of await walkPackageFiles(output)) {
|
|
@@ -71754,7 +72154,7 @@ title: LLM Docs
|
|
|
71754
72154
|
` : [".html", ".htm"].includes(extension2) ? `<!-- Intentionally empty. -->
|
|
71755
72155
|
` : null;
|
|
71756
72156
|
if (placeholder !== null && (await stat6(file.absPath)).size === 0) {
|
|
71757
|
-
await
|
|
72157
|
+
await writeFile17(file.absPath, placeholder);
|
|
71758
72158
|
}
|
|
71759
72159
|
}
|
|
71760
72160
|
const siteMapContent = JSON.stringify({
|
|
@@ -71769,8 +72169,8 @@ title: LLM Docs
|
|
|
71769
72169
|
warnings: mapping.warnings
|
|
71770
72170
|
}, null, 2) + `
|
|
71771
72171
|
`;
|
|
71772
|
-
await
|
|
71773
|
-
await
|
|
72172
|
+
await writeFile17(join58(output, "context-site-map.json"), siteMapContent);
|
|
72173
|
+
await writeFile17(join58(projectRoot, pkg.outDir, "context-site-map.json"), siteMapContent);
|
|
71774
72174
|
return mapping;
|
|
71775
72175
|
} finally {
|
|
71776
72176
|
await rm11(temporary, { recursive: true, force: true });
|
|
@@ -71778,6 +72178,7 @@ title: LLM Docs
|
|
|
71778
72178
|
}
|
|
71779
72179
|
var PACKAGE_SITE_VERSION, require2, encodePath = (path2) => path2.split("/").map(encodeURIComponent).join("/"), mdLabel = (value) => value.replace(/[\\[\]<>`*]/gu, "\\$&").replace(/[\r\n]/gu, " ");
|
|
71780
72180
|
var init_packageSite2 = __esm(() => {
|
|
72181
|
+
init_siteTheme2();
|
|
71781
72182
|
init_packageOutputPaths();
|
|
71782
72183
|
init_workspaceChangelog();
|
|
71783
72184
|
init_packageLlms();
|
|
@@ -71790,13 +72191,13 @@ var init_packageSite2 = __esm(() => {
|
|
|
71790
72191
|
init_packageSiteTheme();
|
|
71791
72192
|
init_packageSiteBranding();
|
|
71792
72193
|
init_packageSiteExtensions();
|
|
71793
|
-
PACKAGE_SITE_VERSION = `vitepress-site-v44-site-address:${createHash16("sha256").update(JSON.stringify([siteMarkdownConfig, siteThemeCss, siteThemeScript, siteThemeLabels("zh"), siteThemeLabels("en")])).digest("hex")}`;
|
|
72194
|
+
PACKAGE_SITE_VERSION = `vitepress-site-v44-site-address:${createHash16("sha256").update(JSON.stringify([siteThemeVariables.toString(), siteMarkdownConfig, siteThemeCss, siteThemeScript, siteThemeLabels("zh"), siteThemeLabels("en")])).digest("hex")}`;
|
|
71794
72195
|
require2 = createRequire5(import.meta.url);
|
|
71795
72196
|
});
|
|
71796
72197
|
|
|
71797
72198
|
// src/project/workspaceBuildVersion.ts
|
|
71798
|
-
import { join as
|
|
71799
|
-
import { mkdir as
|
|
72199
|
+
import { join as join59 } from "node:path";
|
|
72200
|
+
import { mkdir as mkdir22, writeFile as writeFile18 } from "node:fs/promises";
|
|
71800
72201
|
async function workspaceVersionFingerprint(root) {
|
|
71801
72202
|
return { version: await workspaceVersion(root), changelog: await readWorkspaceChangelog(root) };
|
|
71802
72203
|
}
|
|
@@ -71806,9 +72207,9 @@ async function writePackageVersion(projectRoot, output) {
|
|
|
71806
72207
|
if (await optionalWorkspaceText(output, path2) !== undefined)
|
|
71807
72208
|
throw new TypeError(`Package template uses reserved version output ${path2}; rename that template output.`);
|
|
71808
72209
|
}
|
|
71809
|
-
await
|
|
71810
|
-
await
|
|
71811
|
-
await
|
|
72210
|
+
await mkdir22(output, { recursive: true });
|
|
72211
|
+
await writeFile18(join59(output, "CHANGELOG.md"), renderChangelog(info.changelog));
|
|
72212
|
+
await writeFile18(join59(output, "context-version.json"), JSON.stringify({ version: info.version }) + `
|
|
71812
72213
|
`);
|
|
71813
72214
|
}
|
|
71814
72215
|
var init_workspaceBuildVersion = __esm(() => {
|
|
@@ -71817,14 +72218,14 @@ var init_workspaceBuildVersion = __esm(() => {
|
|
|
71817
72218
|
|
|
71818
72219
|
// src/project/packageRenderCache.ts
|
|
71819
72220
|
import { createHash as createHash17 } from "node:crypto";
|
|
71820
|
-
import { readFile as
|
|
71821
|
-
import { join as
|
|
72221
|
+
import { readFile as readFile50 } from "node:fs/promises";
|
|
72222
|
+
import { join as join60 } from "node:path";
|
|
71822
72223
|
async function cachedPackageKnowledgeMarkdown(input) {
|
|
71823
72224
|
const fingerprint = digest3(`${PACKAGE_READER_MARKDOWN_VERSION}
|
|
71824
72225
|
${input.content}`);
|
|
71825
|
-
const path2 =
|
|
72226
|
+
const path2 = join60(input.projectRoot, ".tmp/context-runtime/package-render", `${digest3(input.key)}.json`);
|
|
71826
72227
|
try {
|
|
71827
|
-
const cached = JSON.parse(await
|
|
72228
|
+
const cached = JSON.parse(await readFile50(path2, "utf8"));
|
|
71828
72229
|
if (cached !== null && typeof cached === "object" && "fingerprint" in cached && cached.fingerprint === fingerprint && "markdown" in cached && typeof cached.markdown === "string") {
|
|
71829
72230
|
return cached.markdown;
|
|
71830
72231
|
}
|
|
@@ -71863,7 +72264,7 @@ var init_packageKnowledgeAdvisories = __esm(() => {
|
|
|
71863
72264
|
|
|
71864
72265
|
// src/project/packageMarkdownAnchors.ts
|
|
71865
72266
|
import { posix as posix7 } from "node:path";
|
|
71866
|
-
import { readFile as
|
|
72267
|
+
import { readFile as readFile51 } from "node:fs/promises";
|
|
71867
72268
|
function packageMarkdownAnchors(markdown) {
|
|
71868
72269
|
const anchors = new Set;
|
|
71869
72270
|
const used = new Set;
|
|
@@ -71926,7 +72327,7 @@ async function inspectPackageMarkdownDirectory(root) {
|
|
|
71926
72327
|
const files = (await walkPackageFiles(root)).filter((file) => /\.md$/iu.test(file.relPath));
|
|
71927
72328
|
const pages = new Map;
|
|
71928
72329
|
for (let offset = 0;offset < files.length; offset += 16) {
|
|
71929
|
-
const batch = await Promise.allSettled(files.slice(offset, offset + 16).map(async (file) => [file.relPath, await
|
|
72330
|
+
const batch = await Promise.allSettled(files.slice(offset, offset + 16).map(async (file) => [file.relPath, await readFile51(file.absPath, "utf8")]));
|
|
71930
72331
|
for (const result of batch) {
|
|
71931
72332
|
if (result.status === "rejected")
|
|
71932
72333
|
throw result.reason;
|
|
@@ -71943,50 +72344,50 @@ var init_packageMarkdownAnchors = __esm(() => {
|
|
|
71943
72344
|
});
|
|
71944
72345
|
|
|
71945
72346
|
// src/project/packageBuildStage.ts
|
|
71946
|
-
import { mkdir as
|
|
71947
|
-
import { dirname as
|
|
72347
|
+
import { mkdir as mkdir23, mkdtemp as mkdtemp2, readFile as readFile52, rename as rename6, rm as rm12, rmdir } from "node:fs/promises";
|
|
72348
|
+
import { dirname as dirname26, join as join61, relative as relative16 } from "node:path";
|
|
71948
72349
|
async function withStagedPackageOutput(projectRoot, pkg, render) {
|
|
71949
|
-
const tempRoot =
|
|
71950
|
-
await
|
|
71951
|
-
const stage = await mkdtemp2(
|
|
71952
|
-
const stagedPackage = { ...pkg, outDir: relative16(projectRoot,
|
|
72350
|
+
const tempRoot = join61(projectRoot, ".tmp");
|
|
72351
|
+
await mkdir23(tempRoot, { recursive: true });
|
|
72352
|
+
const stage = await mkdtemp2(join61(tempRoot, "package-build-"));
|
|
72353
|
+
const stagedPackage = { ...pkg, outDir: relative16(projectRoot, join61(stage, pkg.name)) };
|
|
71953
72354
|
try {
|
|
71954
|
-
await
|
|
72355
|
+
await mkdir23(join61(projectRoot, stagedPackage.outDir), { recursive: true });
|
|
71955
72356
|
const value = await render(stagedPackage);
|
|
71956
72357
|
await validatePackageIndexLinks({ projectRoot, pkg: stagedPackage });
|
|
71957
72358
|
const destinations = packageOutputDirs(pkg);
|
|
71958
72359
|
const staged = packageOutputDirs(stagedPackage);
|
|
71959
72360
|
for (const [index2, destination] of destinations.entries()) {
|
|
71960
|
-
const target =
|
|
72361
|
+
const target = join61(projectRoot, destination);
|
|
71961
72362
|
const previous2 = await walkPackageFiles(target);
|
|
71962
|
-
const next = await walkPackageFiles(
|
|
72363
|
+
const next = await walkPackageFiles(join61(projectRoot, staged[index2]));
|
|
71963
72364
|
const desired = new Set(next.map((file) => file.relPath));
|
|
71964
72365
|
for (const file of previous2) {
|
|
71965
72366
|
if (desired.has(file.relPath))
|
|
71966
72367
|
continue;
|
|
71967
72368
|
await rm12(file.absPath);
|
|
71968
|
-
let directory =
|
|
72369
|
+
let directory = dirname26(file.absPath);
|
|
71969
72370
|
while (directory !== target) {
|
|
71970
72371
|
try {
|
|
71971
72372
|
await rmdir(directory);
|
|
71972
72373
|
} catch {
|
|
71973
72374
|
break;
|
|
71974
72375
|
}
|
|
71975
|
-
directory =
|
|
72376
|
+
directory = dirname26(directory);
|
|
71976
72377
|
}
|
|
71977
72378
|
}
|
|
71978
72379
|
for (let offset = 0;offset < next.length; offset += 8) {
|
|
71979
72380
|
const results = await Promise.allSettled(next.slice(offset, offset + 8).map(async (file) => {
|
|
71980
|
-
const output =
|
|
71981
|
-
const bytes = await
|
|
71982
|
-
const old = await
|
|
72381
|
+
const output = join61(target, file.relPath);
|
|
72382
|
+
const bytes = await readFile52(file.absPath);
|
|
72383
|
+
const old = await readFile52(output).catch((error) => {
|
|
71983
72384
|
if (error.code === "ENOENT")
|
|
71984
72385
|
return;
|
|
71985
72386
|
throw error;
|
|
71986
72387
|
});
|
|
71987
72388
|
if (old?.equals(bytes))
|
|
71988
72389
|
return;
|
|
71989
|
-
await
|
|
72390
|
+
await mkdir23(dirname26(output), { recursive: true });
|
|
71990
72391
|
await rename6(file.absPath, output);
|
|
71991
72392
|
}));
|
|
71992
72393
|
for (const result of results)
|
|
@@ -72050,8 +72451,8 @@ var init_packageArticleLinks = __esm(() => {
|
|
|
72050
72451
|
});
|
|
72051
72452
|
|
|
72052
72453
|
// src/project/packageAssets.ts
|
|
72053
|
-
import { readFile as
|
|
72054
|
-
import { dirname as
|
|
72454
|
+
import { readFile as readFile53 } from "node:fs/promises";
|
|
72455
|
+
import { dirname as dirname27, relative as relative17, sep as sep4 } from "node:path";
|
|
72055
72456
|
function posixPath2(value) {
|
|
72056
72457
|
return value.split(sep4).join("/");
|
|
72057
72458
|
}
|
|
@@ -72073,7 +72474,7 @@ function packageAssetPath(projectRoot, absolute) {
|
|
|
72073
72474
|
};
|
|
72074
72475
|
}
|
|
72075
72476
|
function packageMarkdownTarget(pageOutputPath, assetOutputPath) {
|
|
72076
|
-
const target = posixPath2(relative17(
|
|
72477
|
+
const target = posixPath2(relative17(dirname27(pageOutputPath), assetOutputPath));
|
|
72077
72478
|
return target.startsWith(".") ? target : `./${target}`;
|
|
72078
72479
|
}
|
|
72079
72480
|
async function projectPackageKnowledgeAssets(input) {
|
|
@@ -72089,7 +72490,7 @@ async function projectPackageKnowledgeAssets(input) {
|
|
|
72089
72490
|
const paths = packageAssetPath(input.projectRoot, absolute);
|
|
72090
72491
|
let bytes;
|
|
72091
72492
|
try {
|
|
72092
|
-
bytes = await
|
|
72493
|
+
bytes = await readFile53(absolute);
|
|
72093
72494
|
} catch {
|
|
72094
72495
|
throw new ContextError(ExitCode.WorkspaceStateError, `knowledge resource is missing: ${paths.knowledgeRelPath}`, {
|
|
72095
72496
|
category: ErrorCategory.WorkspaceStateInvalid,
|
|
@@ -72118,7 +72519,7 @@ var init_packageAssets = __esm(() => {
|
|
|
72118
72519
|
// src/project/packageAssetOptimization.ts
|
|
72119
72520
|
import { createHash as createHash18 } from "node:crypto";
|
|
72120
72521
|
import { createRequire as createRequire6 } from "node:module";
|
|
72121
|
-
import { dirname as
|
|
72522
|
+
import { dirname as dirname28, extname as extname8 } from "node:path";
|
|
72122
72523
|
function isPng(bytes) {
|
|
72123
72524
|
return bytes.byteLength >= 8 && bytes[0] === 137 && bytes[1] === 80 && bytes[2] === 78 && bytes[3] === 71 && bytes[4] === 13 && bytes[5] === 10 && bytes[6] === 26 && bytes[7] === 10;
|
|
72124
72525
|
}
|
|
@@ -72172,7 +72573,7 @@ function isWebp(bytes) {
|
|
|
72172
72573
|
}
|
|
72173
72574
|
function contentAddressedWebpPath(asset, bytes) {
|
|
72174
72575
|
const digest4 = createHash18("sha256").update(bytes).digest("hex");
|
|
72175
|
-
return `${
|
|
72576
|
+
return `${dirname28(asset.packageRelPath)}/${digest4}.webp`;
|
|
72176
72577
|
}
|
|
72177
72578
|
async function loadSharpProcessor() {
|
|
72178
72579
|
const requireFromCli2 = createRequire6(import.meta.url);
|
|
@@ -72385,7 +72786,7 @@ var init_packageAssetOptimization = __esm(() => {
|
|
|
72385
72786
|
// src/project/packageAssetDelivery.ts
|
|
72386
72787
|
import { execFile as execFile8 } from "node:child_process";
|
|
72387
72788
|
import { realpath as realpath7 } from "node:fs/promises";
|
|
72388
|
-
import { join as
|
|
72789
|
+
import { join as join62, relative as relative18, sep as sep5 } from "node:path";
|
|
72389
72790
|
import { promisify as promisify8 } from "node:util";
|
|
72390
72791
|
async function git(projectRoot, args) {
|
|
72391
72792
|
try {
|
|
@@ -72405,7 +72806,7 @@ async function git(projectRoot, args) {
|
|
|
72405
72806
|
}
|
|
72406
72807
|
}
|
|
72407
72808
|
function repositoryPath(repoRoot, projectRoot, asset) {
|
|
72408
|
-
const path2 = relative18(repoRoot,
|
|
72809
|
+
const path2 = relative18(repoRoot, join62(projectRoot, asset.knowledgeRelPath)).split(sep5).join("/");
|
|
72409
72810
|
if (path2 === ".." || path2.startsWith("../") || path2.startsWith("/")) {
|
|
72410
72811
|
throw new ContextError(ExitCode.WorkspaceStateError, "knowledge asset is outside the current Git repository", {
|
|
72411
72812
|
category: ErrorCategory.WorkspaceStateInvalid,
|
|
@@ -72585,8 +72986,8 @@ var init_packageAssetDelivery = __esm(() => {
|
|
|
72585
72986
|
|
|
72586
72987
|
// src/project/packageBuildContent.ts
|
|
72587
72988
|
import { existsSync as existsSync16 } from "node:fs";
|
|
72588
|
-
import { mkdir as
|
|
72589
|
-
import { dirname as
|
|
72989
|
+
import { mkdir as mkdir24, readFile as readFile54, writeFile as writeFile19 } from "node:fs/promises";
|
|
72990
|
+
import { dirname as dirname29, join as join63 } from "node:path";
|
|
72590
72991
|
function globToRegExp(pattern) {
|
|
72591
72992
|
const normalized = toPosixPath4(pattern);
|
|
72592
72993
|
if (normalized.endsWith("/**")) {
|
|
@@ -72727,9 +73128,9 @@ async function writeRenderedPackageTemplate(input) {
|
|
|
72727
73128
|
templateRelPath: renderedRelPath,
|
|
72728
73129
|
logicalTemplateRelPath: renderedLogicalRelPath
|
|
72729
73130
|
});
|
|
72730
|
-
const outputPath =
|
|
72731
|
-
await
|
|
72732
|
-
await
|
|
73131
|
+
const outputPath = join63(input.projectRoot, input.pkg.outDir, renderedRelPath);
|
|
73132
|
+
await mkdir24(dirname29(outputPath), { recursive: true });
|
|
73133
|
+
await writeFile19(outputPath, renderTemplateText(file.content, contentVars), "utf8");
|
|
72733
73134
|
written++;
|
|
72734
73135
|
}
|
|
72735
73136
|
return { files: written, consumesKnowledge };
|
|
@@ -72760,7 +73161,7 @@ async function writeSelectedPackageKnowledge(input) {
|
|
|
72760
73161
|
for (let offset = 0;offset < projectedPages.length; offset += 8) {
|
|
72761
73162
|
const results = await Promise.allSettled(projectedPages.slice(offset, offset + 8).map(async (projected) => {
|
|
72762
73163
|
assertSafeRenderedPath2(projected.pageOutputPath, "knowledge path");
|
|
72763
|
-
const outputPath =
|
|
73164
|
+
const outputPath = join63(input.projectRoot, input.pkg.outDir, projected.pageOutputPath);
|
|
72764
73165
|
let mediaContent = projected.content;
|
|
72765
73166
|
const omitted = new Set((delivered.omittedImages ?? []).map((path2) => packageMarkdownTarget(projected.pageOutputPath, path2)));
|
|
72766
73167
|
for (const link of markdownReaderLinks(mediaContent).reverse()) {
|
|
@@ -72777,7 +73178,7 @@ async function writeSelectedPackageKnowledge(input) {
|
|
|
72777
73178
|
}
|
|
72778
73179
|
return;
|
|
72779
73180
|
});
|
|
72780
|
-
await
|
|
73181
|
+
await mkdir24(dirname29(outputPath), { recursive: true });
|
|
72781
73182
|
const links = projectPackageArticleLinks({ markdown: rewritten, approvedPath: approvedByOutput.get(projected.pageOutputPath), outputPath: projected.pageOutputPath, selected: outputByApproved });
|
|
72782
73183
|
const markdown = await cachedPackageKnowledgeMarkdown({
|
|
72783
73184
|
projectRoot: input.projectRoot,
|
|
@@ -72785,7 +73186,7 @@ async function writeSelectedPackageKnowledge(input) {
|
|
|
72785
73186
|
content: links.markdown
|
|
72786
73187
|
});
|
|
72787
73188
|
const file = byPath.get(approvedByOutput.get(projected.pageOutputPath));
|
|
72788
|
-
await
|
|
73189
|
+
await writeFile19(outputPath, markdown + articleProvenanceMarkdown(file?.article, registry2), "utf8");
|
|
72789
73190
|
return links.warnings;
|
|
72790
73191
|
}));
|
|
72791
73192
|
for (const result of results) {
|
|
@@ -72797,9 +73198,9 @@ async function writeSelectedPackageKnowledge(input) {
|
|
|
72797
73198
|
const deliveredAssets = new Map(delivered.assets.map((asset) => [asset.packageRelPath, asset]));
|
|
72798
73199
|
for (const asset of deliveredAssets.values()) {
|
|
72799
73200
|
assertSafeRenderedPath2(asset.packageRelPath, "package resource path");
|
|
72800
|
-
const outputPath =
|
|
72801
|
-
await
|
|
72802
|
-
await
|
|
73201
|
+
const outputPath = join63(input.projectRoot, input.pkg.outDir, asset.packageRelPath);
|
|
73202
|
+
await mkdir24(dirname29(outputPath), { recursive: true });
|
|
73203
|
+
await writeFile19(outputPath, asset.bytes);
|
|
72803
73204
|
}
|
|
72804
73205
|
return {
|
|
72805
73206
|
pages: projectedPages.length,
|
|
@@ -72812,9 +73213,9 @@ async function writeSelectedPackageKnowledge(input) {
|
|
|
72812
73213
|
async function appendLlmsKnowledge(input) {
|
|
72813
73214
|
if (packageKind2(input.pkg) !== "llms" || input.templateConsumesKnowledge || input.knowledgeCount === 0)
|
|
72814
73215
|
return 0;
|
|
72815
|
-
const outputPath =
|
|
73216
|
+
const outputPath = join63(input.projectRoot, input.pkg.outDir, "llms.txt");
|
|
72816
73217
|
const existed = existsSync16(outputPath);
|
|
72817
|
-
const existing = existed ? await
|
|
73218
|
+
const existing = existed ? await readFile54(outputPath, "utf8") : "";
|
|
72818
73219
|
const content3 = existing.trim().length > 0 ? `${existing.trimEnd()}
|
|
72819
73220
|
|
|
72820
73221
|
---
|
|
@@ -72822,8 +73223,8 @@ async function appendLlmsKnowledge(input) {
|
|
|
72822
73223
|
${input.bundle}
|
|
72823
73224
|
` : `${input.bundle}
|
|
72824
73225
|
`;
|
|
72825
|
-
await
|
|
72826
|
-
await
|
|
73226
|
+
await mkdir24(dirname29(outputPath), { recursive: true });
|
|
73227
|
+
await writeFile19(outputPath, content3, "utf8");
|
|
72827
73228
|
return existed ? 0 : 1;
|
|
72828
73229
|
}
|
|
72829
73230
|
var init_packageBuildContent = __esm(() => {
|
|
@@ -73038,8 +73439,8 @@ __export(exports_packageBuilder, {
|
|
|
73038
73439
|
});
|
|
73039
73440
|
import { createHash as createHash19 } from "node:crypto";
|
|
73040
73441
|
import { existsSync as existsSync17 } from "node:fs";
|
|
73041
|
-
import { mkdir as
|
|
73042
|
-
import { dirname as
|
|
73442
|
+
import { mkdir as mkdir25, readdir as readdir15, readFile as readFile55, rm as rm13, writeFile as writeFile20 } from "node:fs/promises";
|
|
73443
|
+
import { dirname as dirname30, join as join64, resolve as resolve20 } from "node:path";
|
|
73043
73444
|
function packageAssetDeliverySummary(value) {
|
|
73044
73445
|
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
73045
73446
|
return;
|
|
@@ -73061,7 +73462,7 @@ function assertPackageOutputDir(pkg) {
|
|
|
73061
73462
|
}
|
|
73062
73463
|
function packageFingerprintPath(projectRoot, pkg) {
|
|
73063
73464
|
assertSafeRenderedPath2(`${pkg.name}.json`, "package fingerprint path");
|
|
73064
|
-
return
|
|
73465
|
+
return join64(projectRoot, PACKAGE_FINGERPRINT_ROOT, `${pkg.name}.json`);
|
|
73065
73466
|
}
|
|
73066
73467
|
async function listApprovedKnowledge(projectRoot) {
|
|
73067
73468
|
const metadata = await readApprovedKnowledgeMetadataIndex(projectRoot);
|
|
@@ -73102,7 +73503,7 @@ async function listTemplateFiles(projectRoot, templatePath) {
|
|
|
73102
73503
|
const files = await walkPackageFiles(templateRoot);
|
|
73103
73504
|
return Promise.all(files.filter((file) => file.relPath.split("/").at(-1) !== PACKAGE_TEMPLATE_REVIEW_FILE).map(async (file) => ({
|
|
73104
73505
|
...file,
|
|
73105
|
-
content: await
|
|
73506
|
+
content: await readFile55(file.absPath, "utf8")
|
|
73106
73507
|
})));
|
|
73107
73508
|
}
|
|
73108
73509
|
function stableHash2(value) {
|
|
@@ -73129,8 +73530,10 @@ async function packageInputFingerprint(input) {
|
|
|
73129
73530
|
...input.pkg.assets === undefined ? {} : { definition: input.pkg.assets }
|
|
73130
73531
|
}) : null;
|
|
73131
73532
|
const siteRegistry = await loadSourcesRegistry({ rootDir: input.projectRoot });
|
|
73533
|
+
const siteTheme = input.pkg.kind === "package.kb" && input.pkg.site ? await resolveSiteTheme(input.projectRoot, input.pkg.site.theme, true) : null;
|
|
73132
73534
|
return stableHash2({
|
|
73133
73535
|
siteExtensions: input.pkg.kind === "package.kb" && input.pkg.site ? (await readSiteExtensions(input.projectRoot, input.pkg.site.extensions)).digest : null,
|
|
73536
|
+
siteTheme,
|
|
73134
73537
|
siteSources: siteRegistry ? input.selected.map((file) => siteArticleSources(file.article, siteRegistry)) : null,
|
|
73135
73538
|
builder: PACKAGE_BUILDER_PROTOCOL_VERSION,
|
|
73136
73539
|
readerProjection: PACKAGE_READER_MARKDOWN_VERSION,
|
|
@@ -73165,7 +73568,7 @@ async function readPackageManifest(projectRoot, pkg) {
|
|
|
73165
73568
|
if (!existsSync17(filePath2))
|
|
73166
73569
|
return null;
|
|
73167
73570
|
try {
|
|
73168
|
-
const parsed = JSON.parse(await
|
|
73571
|
+
const parsed = JSON.parse(await readFile55(filePath2, "utf8"));
|
|
73169
73572
|
if (parsed !== null && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
73170
73573
|
const candidate = parsed;
|
|
73171
73574
|
if (typeof candidate.builder_protocol === "string" && typeof candidate.fingerprint === "string" && typeof candidate.output_fingerprint === "string" && typeof candidate.output_files === "number" && Array.isArray(candidate.outputs)) {
|
|
@@ -73196,8 +73599,8 @@ async function readPackageManifest(projectRoot, pkg) {
|
|
|
73196
73599
|
}
|
|
73197
73600
|
async function writePackageFingerprint(input) {
|
|
73198
73601
|
const filePath2 = packageFingerprintPath(input.projectRoot, input.pkg);
|
|
73199
|
-
await
|
|
73200
|
-
await
|
|
73602
|
+
await mkdir25(dirname30(filePath2), { recursive: true });
|
|
73603
|
+
await writeFile20(filePath2, `${JSON.stringify({
|
|
73201
73604
|
package: input.pkg.name,
|
|
73202
73605
|
kind: packageKind2(input.pkg),
|
|
73203
73606
|
builder_protocol: PACKAGE_BUILDER_PROTOCOL_VERSION,
|
|
@@ -73212,12 +73615,12 @@ async function writePackageFingerprint(input) {
|
|
|
73212
73615
|
`, "utf8");
|
|
73213
73616
|
}
|
|
73214
73617
|
async function removeOrphanPackageDirs(projectRoot, packages) {
|
|
73215
|
-
const distRoot =
|
|
73618
|
+
const distRoot = join64(projectRoot, "dist");
|
|
73216
73619
|
if (!existsSync17(distRoot))
|
|
73217
73620
|
return;
|
|
73218
73621
|
const declaredNames = new Set(packages.flatMap((pkg) => packageOutputDirs(pkg).map((path2) => path2.slice("dist/".length))));
|
|
73219
73622
|
const entries2 = await readdir15(distRoot, { withFileTypes: true });
|
|
73220
|
-
await Promise.all(entries2.filter((entry) => entry.isDirectory() && !declaredNames.has(entry.name)).map((entry) => rm13(
|
|
73623
|
+
await Promise.all(entries2.filter((entry) => entry.isDirectory() && !declaredNames.has(entry.name)).map((entry) => rm13(join64(distRoot, entry.name), { recursive: true, force: true, maxRetries: 3, retryDelay: 100 })));
|
|
73221
73624
|
}
|
|
73222
73625
|
async function collectPackageFreshness(projectRoot, packages) {
|
|
73223
73626
|
assertDistinctPackageOutputs(packages);
|
|
@@ -73226,7 +73629,7 @@ async function collectPackageFreshness(projectRoot, packages) {
|
|
|
73226
73629
|
assertPackageOutputDir(pkg);
|
|
73227
73630
|
const selected = selectPackageKnowledge(approved, pkg);
|
|
73228
73631
|
assertSafeRenderedPath2(pkg.template.path, "package template path");
|
|
73229
|
-
const templateRoot =
|
|
73632
|
+
const templateRoot = join64(projectRoot, pkg.template.path);
|
|
73230
73633
|
const templateExists = existsSync17(templateRoot);
|
|
73231
73634
|
if (!templateExists) {
|
|
73232
73635
|
throw new ContextError(ExitCode.WorkspaceStateError, `package template path is missing: ${pkg.template.path}`, {
|
|
@@ -73455,19 +73858,19 @@ async function buildProjectPackagesInternal(projectRoot, options) {
|
|
|
73455
73858
|
if (stagedPkg.kind === "package.llms") {
|
|
73456
73859
|
const articles = await Promise.all(llmsArticles(stagedPkg, selected).map(async (article) => ({
|
|
73457
73860
|
...article,
|
|
73458
|
-
content: await
|
|
73861
|
+
content: await readFile55(join64(projectRoot, stagedPkg.outDir, article.path), "utf8")
|
|
73459
73862
|
})));
|
|
73460
|
-
await writeLlmsDocuments(
|
|
73863
|
+
await writeLlmsDocuments(join64(projectRoot, stagedPkg.outDir), buildLlmsDocuments({
|
|
73461
73864
|
title: stagedPkg.name,
|
|
73462
73865
|
articles,
|
|
73463
73866
|
...reading ? { map: reading } : {}
|
|
73464
73867
|
}), { preserveIndex: true });
|
|
73465
73868
|
}
|
|
73466
|
-
await writePackageVersion(projectRoot,
|
|
73869
|
+
await writePackageVersion(projectRoot, join64(projectRoot, stagedPkg.outDir));
|
|
73467
73870
|
await writePackageSite({ projectRoot, pkg: stagedPkg, selected, ...siteUrl ? { siteUrl } : {}, ...reading ? { structure: reading } : {} });
|
|
73468
73871
|
const linkWarnings = [
|
|
73469
73872
|
...writtenKnowledge2.linkWarnings,
|
|
73470
|
-
...await inspectPackageMarkdownDirectory(
|
|
73873
|
+
...await inspectPackageMarkdownDirectory(join64(projectRoot, stagedPkg.outDir))
|
|
73471
73874
|
];
|
|
73472
73875
|
return { ...writtenKnowledge2, linkWarnings };
|
|
73473
73876
|
});
|
|
@@ -73619,6 +74022,7 @@ async function runProjectBuildCommand(input) {
|
|
|
73619
74022
|
}
|
|
73620
74023
|
var import_yaml35, PACKAGE_FINGERPRINT_ROOT, PACKAGE_BUILDER_PROTOCOL_VERSION = "v23-sibling-site-output";
|
|
73621
74024
|
var init_packageBuilder = __esm(() => {
|
|
74025
|
+
init_siteTheme2();
|
|
73622
74026
|
init_packageSiteAddress();
|
|
73623
74027
|
init_knowledgeMap2();
|
|
73624
74028
|
init_approvedFileRead();
|
|
@@ -73658,7 +74062,7 @@ var init_packageBuilder = __esm(() => {
|
|
|
73658
74062
|
init_packageTemplateReview();
|
|
73659
74063
|
init_approvedKnowledgeMetadata();
|
|
73660
74064
|
import_yaml35 = __toESM(require_dist(), 1);
|
|
73661
|
-
PACKAGE_FINGERPRINT_ROOT =
|
|
74065
|
+
PACKAGE_FINGERPRINT_ROOT = join64(".tmp", "context-runtime", "packages");
|
|
73662
74066
|
});
|
|
73663
74067
|
|
|
73664
74068
|
// src/project/taskRollback.ts
|
|
@@ -73668,8 +74072,8 @@ __export(exports_taskRollback, {
|
|
|
73668
74072
|
readTaskRollback: () => readTaskRollback,
|
|
73669
74073
|
finishTaskRollback: () => finishTaskRollback
|
|
73670
74074
|
});
|
|
73671
|
-
import { readFile as
|
|
73672
|
-
import { join as
|
|
74075
|
+
import { readFile as readFile56 } from "node:fs/promises";
|
|
74076
|
+
import { join as join65 } from "node:path";
|
|
73673
74077
|
async function readTaskRollback(projectRoot) {
|
|
73674
74078
|
const raw = await readJsonMaybe(projectRoot, await revisionStoragePath(projectRoot));
|
|
73675
74079
|
if (!raw || typeof raw !== "object" || !("protocol" in raw) || raw.protocol !== "context.task-rollback/v1")
|
|
@@ -73678,7 +74082,7 @@ async function readTaskRollback(projectRoot) {
|
|
|
73678
74082
|
}
|
|
73679
74083
|
async function contents(projectRoot, path2) {
|
|
73680
74084
|
try {
|
|
73681
|
-
return await
|
|
74085
|
+
return await readFile56(join65(projectRoot, path2), "utf8");
|
|
73682
74086
|
} catch (error) {
|
|
73683
74087
|
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT")
|
|
73684
74088
|
return;
|
|
@@ -73845,12 +74249,12 @@ __export(exports_knowledgeUpdate, {
|
|
|
73845
74249
|
completeKnowledgeUpdate: () => completeKnowledgeUpdate,
|
|
73846
74250
|
beginKnowledgeUpdate: () => beginKnowledgeUpdate
|
|
73847
74251
|
});
|
|
73848
|
-
import { readFile as
|
|
73849
|
-
import { join as
|
|
74252
|
+
import { readFile as readFile57 } from "node:fs/promises";
|
|
74253
|
+
import { join as join66 } from "node:path";
|
|
73850
74254
|
async function readKnowledgeUpdate(projectRoot) {
|
|
73851
74255
|
let value;
|
|
73852
74256
|
try {
|
|
73853
|
-
value = JSON.parse(await
|
|
74257
|
+
value = JSON.parse(await readFile57(join66(projectRoot, await revisionStoragePath(projectRoot)), "utf8"));
|
|
73854
74258
|
} catch (error) {
|
|
73855
74259
|
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT")
|
|
73856
74260
|
return;
|
|
@@ -73901,7 +74305,7 @@ async function beginKnowledgeUpdate(projectRoot, value) {
|
|
|
73901
74305
|
...input.changes === undefined ? {} : { changes: input.changes }
|
|
73902
74306
|
};
|
|
73903
74307
|
const request = updateSchema.parse({ ...payload, revision: indexerProtocolDigest(payload) });
|
|
73904
|
-
await atomicWriteFile(
|
|
74308
|
+
await atomicWriteFile(join66(projectRoot, await revisionStoragePath(projectRoot)), `${JSON.stringify(request)}
|
|
73905
74309
|
`);
|
|
73906
74310
|
return {
|
|
73907
74311
|
outcome: "update-prepared",
|
|
@@ -73946,7 +74350,7 @@ async function completeKnowledgeUpdate(input) {
|
|
|
73946
74350
|
if (input.new_topics.length && !input.structure_approved) {
|
|
73947
74351
|
const { revision: _revision, ...rest } = request;
|
|
73948
74352
|
const payload = { ...rest, structure_proposal: { decisions: input.decisions, scope_summary: input.scope_summary, new_topics: input.new_topics } };
|
|
73949
|
-
await atomicWriteFile(
|
|
74353
|
+
await atomicWriteFile(join66(input.projectRoot, await revisionStoragePath(input.projectRoot)), `${JSON.stringify({ ...payload, revision: indexerProtocolDigest(payload) })}
|
|
73950
74354
|
`);
|
|
73951
74355
|
return { outcome: "structure-review-required" };
|
|
73952
74356
|
}
|
|
@@ -73983,7 +74387,7 @@ async function completeUpdateStructureReview(input) {
|
|
|
73983
74387
|
const { revision: _revision, structure_proposal: _proposal, ...rest } = request;
|
|
73984
74388
|
const payload = { ...rest, changes: `${rest.changes ?? ""}
|
|
73985
74389
|
Structure feedback: ${input.feedback}` };
|
|
73986
|
-
await atomicWriteFile(
|
|
74390
|
+
await atomicWriteFile(join66(input.projectRoot, await revisionStoragePath(input.projectRoot)), `${JSON.stringify({ ...payload, revision: indexerProtocolDigest(payload) })}
|
|
73987
74391
|
`);
|
|
73988
74392
|
return { outcome: "structure-adjustment-required" };
|
|
73989
74393
|
});
|
|
@@ -74156,15 +74560,15 @@ __export(exports_knowledgeMaintenance, {
|
|
|
74156
74560
|
cancelKnowledgeMaintenance: () => cancelKnowledgeMaintenance,
|
|
74157
74561
|
advanceKnowledgeMaintenance: () => advanceKnowledgeMaintenance
|
|
74158
74562
|
});
|
|
74159
|
-
import { readFile as
|
|
74160
|
-
import { join as
|
|
74563
|
+
import { readFile as readFile58, readdir as readdir16, rm as rm14 } from "node:fs/promises";
|
|
74564
|
+
import { join as join67 } from "node:path";
|
|
74161
74565
|
async function deliveryDigest(root) {
|
|
74162
|
-
const directory =
|
|
74566
|
+
const directory = join67(root, ".tmp/context-runtime/packages");
|
|
74163
74567
|
try {
|
|
74164
74568
|
const files = (await readdir16(directory)).filter((name2) => name2.endsWith(".json")).sort();
|
|
74165
74569
|
if (!files.length)
|
|
74166
74570
|
return indexerProtocolDigest(null);
|
|
74167
|
-
return indexerProtocolDigest(await Promise.all(files.map((name2) =>
|
|
74571
|
+
return indexerProtocolDigest(await Promise.all(files.map((name2) => readFile58(join67(directory, name2), "utf8"))));
|
|
74168
74572
|
} catch (error) {
|
|
74169
74573
|
if (error.code === "ENOENT")
|
|
74170
74574
|
return indexerProtocolDigest(null);
|
|
@@ -74263,7 +74667,7 @@ async function observeKnowledgeMaintenance(root) {
|
|
|
74263
74667
|
async function maintenanceRevision(root) {
|
|
74264
74668
|
const observed = await observeKnowledgeMaintenance(root);
|
|
74265
74669
|
const localInputs = observed.state.active ? {
|
|
74266
|
-
revision: await
|
|
74670
|
+
revision: await readFile58(join67(root, MAINTENANCE_ROOT, "revision.json"), "utf8").catch((error) => {
|
|
74267
74671
|
if (error.code === "ENOENT")
|
|
74268
74672
|
return null;
|
|
74269
74673
|
throw error;
|
|
@@ -74340,7 +74744,7 @@ async function finishMaintenanceRevision(root, outcome = "completed") {
|
|
|
74340
74744
|
outcome = state.active.completion_outcome;
|
|
74341
74745
|
state.active.phase = "finishing";
|
|
74342
74746
|
await saveMaintenance(root, state);
|
|
74343
|
-
await rm14(
|
|
74747
|
+
await rm14(join67(root, MAINTENANCE_ROOT, "revision.json"), { force: true });
|
|
74344
74748
|
state.completed.push({ id: state.active.input.id, input_digest: indexerProtocolDigest(state.active.input), outcome });
|
|
74345
74749
|
delete state.active;
|
|
74346
74750
|
await saveMaintenance(root, state);
|
|
@@ -74374,8 +74778,8 @@ async function discardMaintenanceDraft(root) {
|
|
|
74374
74778
|
const owned = new Set([...request?.batch_candidates ?? [], ...request?.candidate ? [request.candidate] : []].map((item) => item.candidate_id));
|
|
74375
74779
|
if (candidates.some((item) => !owned.has(item.candidate_id)))
|
|
74376
74780
|
throw new TypeError("Unrelated Candidates are present; no draft was discarded. Inspect the current review before retrying cancellation.");
|
|
74377
|
-
await rm14(
|
|
74378
|
-
await rm14(
|
|
74781
|
+
await rm14(join67(root, CANDIDATE_LEDGER_FILE), { force: true });
|
|
74782
|
+
await rm14(join67(root, MAINTENANCE_ROOT, "revision.json"), { force: true });
|
|
74379
74783
|
const { closeProjectWorkspace: closeProjectWorkspace2 } = await Promise.resolve().then(() => (init_close(), exports_close));
|
|
74380
74784
|
const { buildProjectPackages: buildProjectPackages2 } = await Promise.resolve().then(() => (init_packageBuilder(), exports_packageBuilder));
|
|
74381
74785
|
await closeProjectWorkspace2(root);
|
|
@@ -74413,8 +74817,8 @@ __export(exports_approvedRevision, {
|
|
|
74413
74817
|
assertApprovedRevisionBase: () => assertApprovedRevisionBase,
|
|
74414
74818
|
APPROVED_REVISION_PATH: () => APPROVED_REVISION_PATH
|
|
74415
74819
|
});
|
|
74416
|
-
import { readFile as
|
|
74417
|
-
import { join as
|
|
74820
|
+
import { readFile as readFile59, realpath as realpath8, rm as rm15 } from "node:fs/promises";
|
|
74821
|
+
import { join as join68, relative as relative19, isAbsolute as isAbsolute12 } from "node:path";
|
|
74418
74822
|
function requestDigest(input) {
|
|
74419
74823
|
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}/`)));
|
|
74420
74824
|
const ids = new Set(scopes?.map((scope2) => scope2.requirement_ref));
|
|
@@ -74452,7 +74856,7 @@ function revisionCandidateFingerprint(revision, markdown, sections) {
|
|
|
74452
74856
|
}
|
|
74453
74857
|
async function readApprovedRevision(projectRoot) {
|
|
74454
74858
|
try {
|
|
74455
|
-
return parseApprovedRevision(JSON.parse(await
|
|
74859
|
+
return parseApprovedRevision(JSON.parse(await readFile59(join68(projectRoot, await revisionStoragePath(projectRoot)), "utf8")));
|
|
74456
74860
|
} catch (error) {
|
|
74457
74861
|
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT")
|
|
74458
74862
|
return;
|
|
@@ -74511,16 +74915,16 @@ async function resolveApprovedRevisionAuthor(projectRoot, request) {
|
|
|
74511
74915
|
}
|
|
74512
74916
|
async function targetBytes(projectRoot, path2) {
|
|
74513
74917
|
const project = await realpath8(projectRoot);
|
|
74514
|
-
const root = await realpath8(
|
|
74918
|
+
const root = await realpath8(join68(projectRoot, "knowledge"));
|
|
74515
74919
|
const rootRelative = relative19(project, root);
|
|
74516
74920
|
if (isAbsolute12(rootRelative) || rootRelative === ".." || rootRelative.startsWith("../")) {
|
|
74517
74921
|
throw new TypeError("Approved knowledge directory leaves the Context workspace");
|
|
74518
74922
|
}
|
|
74519
|
-
const target = await realpath8(
|
|
74923
|
+
const target = await realpath8(join68(root, path2));
|
|
74520
74924
|
const rel = relative19(root, target);
|
|
74521
74925
|
if (isAbsolute12(rel) || rel === ".." || rel.startsWith("../"))
|
|
74522
74926
|
throw new TypeError("Approved revision target leaves knowledge/");
|
|
74523
|
-
return
|
|
74927
|
+
return readFile59(target, "utf8");
|
|
74524
74928
|
}
|
|
74525
74929
|
async function assertApprovedRevisionBase(projectRoot, request) {
|
|
74526
74930
|
let current;
|
|
@@ -74672,7 +75076,7 @@ ${import_yaml36.default.stringify({ ...import_yaml36.default.parse(fields), type
|
|
|
74672
75076
|
revision: requestDigest(payload)
|
|
74673
75077
|
});
|
|
74674
75078
|
if (input.persist !== false)
|
|
74675
|
-
await atomicWriteFile(
|
|
75079
|
+
await atomicWriteFile(join68(input.projectRoot, await revisionStoragePath(input.projectRoot)), `${JSON.stringify(request)}
|
|
74676
75080
|
`);
|
|
74677
75081
|
return {
|
|
74678
75082
|
status: "author-reopened",
|
|
@@ -74783,17 +75187,17 @@ async function completeApprovedRevision(input) {
|
|
|
74783
75187
|
const { prepareRevisionBatchContinuation: prepareRevisionBatchContinuation3 } = await Promise.resolve().then(() => (init_approvedRevisionBatch(), exports_approvedRevisionBatch));
|
|
74784
75188
|
const next2 = await prepareRevisionBatchContinuation3(input.projectRoot, request, request.batch_candidates ?? []);
|
|
74785
75189
|
if (next2 || request.batch_candidates?.length || request.build_pending) {
|
|
74786
|
-
await atomicWriteFile(
|
|
75190
|
+
await atomicWriteFile(join68(input.projectRoot, await revisionStoragePath(input.projectRoot)), `${JSON.stringify(next2 ?? { ...request, review_ready: true })}
|
|
74787
75191
|
`);
|
|
74788
75192
|
} else {
|
|
74789
75193
|
await advanceApprovedRevision(input.projectRoot, request);
|
|
74790
75194
|
}
|
|
74791
75195
|
return;
|
|
74792
75196
|
}
|
|
74793
|
-
const current = await
|
|
75197
|
+
const current = await readFile59(join68(input.projectRoot, await revisionStoragePath(input.projectRoot)), "utf8");
|
|
74794
75198
|
let previous2;
|
|
74795
75199
|
try {
|
|
74796
|
-
previous2 = await
|
|
75200
|
+
previous2 = await readFile59(join68(input.projectRoot, CANDIDATE_LEDGER_FILE), "utf8");
|
|
74797
75201
|
} catch (error) {
|
|
74798
75202
|
if (!(error && typeof error === "object" && ("code" in error) && error.code === "ENOENT"))
|
|
74799
75203
|
throw error;
|
|
@@ -74875,7 +75279,7 @@ async function advanceApprovedRevision(projectRoot, request, buildPending = fals
|
|
|
74875
75279
|
return;
|
|
74876
75280
|
const { readProductionStage: readProductionStage2 } = await Promise.resolve().then(() => (init_productionStageStore(), exports_productionStageStore));
|
|
74877
75281
|
if (await readProductionStage2(projectRoot)) {
|
|
74878
|
-
await rm15(
|
|
75282
|
+
await rm15(join68(projectRoot, await revisionStoragePath(projectRoot)), { force: true });
|
|
74879
75283
|
return;
|
|
74880
75284
|
}
|
|
74881
75285
|
const { clearCompletedLifecycle: clearCompletedLifecycle2 } = await Promise.resolve().then(() => (init_lifecycleCleanup(), exports_lifecycleCleanup));
|
|
@@ -74946,12 +75350,12 @@ async function reopenApprovedRevision(input) {
|
|
|
74946
75350
|
}))
|
|
74947
75351
|
} : {}
|
|
74948
75352
|
} };
|
|
74949
|
-
const current = await
|
|
75353
|
+
const current = await readFile59(join68(input.projectRoot, await revisionStoragePath(input.projectRoot)), "utf8");
|
|
74950
75354
|
const content3 = `${JSON.stringify({ ...payload, revision: requestDigest(payload) })}
|
|
74951
75355
|
`;
|
|
74952
75356
|
let ledger;
|
|
74953
75357
|
try {
|
|
74954
|
-
ledger = await
|
|
75358
|
+
ledger = await readFile59(join68(input.projectRoot, CANDIDATE_LEDGER_FILE), "utf8");
|
|
74955
75359
|
} catch (error) {
|
|
74956
75360
|
if (!(error && typeof error === "object" && ("code" in error) && error.code === "ENOENT"))
|
|
74957
75361
|
throw error;
|
|
@@ -80994,7 +81398,7 @@ var require_acorn_jsx = __commonJS((exports, module) => {
|
|
|
80994
81398
|
|
|
80995
81399
|
// src/project/documentRun.ts
|
|
80996
81400
|
import { existsSync as existsSync18 } from "node:fs";
|
|
80997
|
-
import { join as
|
|
81401
|
+
import { join as join71 } from "node:path";
|
|
80998
81402
|
function isDocumentPhase(phase) {
|
|
80999
81403
|
return phase.kind === "phase.capture.file" || phase.kind === "phase.capture.lark";
|
|
81000
81404
|
}
|
|
@@ -81176,7 +81580,7 @@ async function previewDocumentPhase(input) {
|
|
|
81176
81580
|
},
|
|
81177
81581
|
snapshot: {
|
|
81178
81582
|
manifest,
|
|
81179
|
-
exists: existsSync18(
|
|
81583
|
+
exists: existsSync18(join71(input.projectRoot, manifest))
|
|
81180
81584
|
},
|
|
81181
81585
|
sourceRefExamples: [
|
|
81182
81586
|
`${sourceRefBase}/<doc-locator>#span:<heading-hint> L<start>-<end>@<hash>`
|
|
@@ -81195,8 +81599,8 @@ var init_documentRun = __esm(() => {
|
|
|
81195
81599
|
});
|
|
81196
81600
|
|
|
81197
81601
|
// src/lib/atomicFileBatch.ts
|
|
81198
|
-
import { lstat as lstat8, mkdir as
|
|
81199
|
-
import { dirname as
|
|
81602
|
+
import { lstat as lstat8, mkdir as mkdir27, mkdtemp as mkdtemp3, rename as rename7, rm as rm16, writeFile as writeFile22 } from "node:fs/promises";
|
|
81603
|
+
import { dirname as dirname33, join as join72, resolve as resolve23 } from "node:path";
|
|
81200
81604
|
async function existingFileKind(path2) {
|
|
81201
81605
|
try {
|
|
81202
81606
|
const stats = await lstat8(path2);
|
|
@@ -81225,10 +81629,10 @@ async function applyAtomicFileBatch(input) {
|
|
|
81225
81629
|
const removalPaths = new Set((input.removals ?? []).map((path2) => resolve23(path2)));
|
|
81226
81630
|
for (const path2 of writesByPath.keys())
|
|
81227
81631
|
removalPaths.delete(path2);
|
|
81228
|
-
await
|
|
81229
|
-
const transactionDir = await mkdtemp3(
|
|
81230
|
-
const stagedRoot =
|
|
81231
|
-
const backupRoot =
|
|
81632
|
+
await mkdir27(input.transactionRoot, { recursive: true });
|
|
81633
|
+
const transactionDir = await mkdtemp3(join72(input.transactionRoot, "batch-"));
|
|
81634
|
+
const stagedRoot = join72(transactionDir, "staged");
|
|
81635
|
+
const backupRoot = join72(transactionDir, "backup");
|
|
81232
81636
|
const writes = [...writesByPath.values()].sort((left, right) => left.path.localeCompare(right.path));
|
|
81233
81637
|
const affectedPaths = [...new Set([...writesByPath.keys(), ...removalPaths])].sort();
|
|
81234
81638
|
const staged = new Map;
|
|
@@ -81236,22 +81640,22 @@ async function applyAtomicFileBatch(input) {
|
|
|
81236
81640
|
const installed = [];
|
|
81237
81641
|
let preserveTransaction = false;
|
|
81238
81642
|
try {
|
|
81239
|
-
await
|
|
81643
|
+
await mkdir27(stagedRoot, { recursive: true });
|
|
81240
81644
|
for (const [index2, write] of writes.entries()) {
|
|
81241
|
-
const path2 =
|
|
81242
|
-
await
|
|
81645
|
+
const path2 = join72(stagedRoot, String(index2));
|
|
81646
|
+
await writeFile22(path2, write.bytes);
|
|
81243
81647
|
staged.set(write.path, path2);
|
|
81244
81648
|
}
|
|
81245
81649
|
for (const [index2, path2] of affectedPaths.entries()) {
|
|
81246
81650
|
if (await existingFileKind(path2) === "missing")
|
|
81247
81651
|
continue;
|
|
81248
|
-
const backupPath =
|
|
81249
|
-
await
|
|
81652
|
+
const backupPath = join72(backupRoot, String(index2));
|
|
81653
|
+
await mkdir27(dirname33(backupPath), { recursive: true });
|
|
81250
81654
|
await rename7(path2, backupPath);
|
|
81251
81655
|
backups.set(path2, backupPath);
|
|
81252
81656
|
}
|
|
81253
81657
|
for (const write of writes) {
|
|
81254
|
-
await
|
|
81658
|
+
await mkdir27(dirname33(write.path), { recursive: true });
|
|
81255
81659
|
await rename7(staged.get(write.path), write.path);
|
|
81256
81660
|
installed.push(write.path);
|
|
81257
81661
|
}
|
|
@@ -81263,7 +81667,7 @@ async function applyAtomicFileBatch(input) {
|
|
|
81263
81667
|
});
|
|
81264
81668
|
}
|
|
81265
81669
|
for (const [path2, backupPath] of [...backups.entries()].reverse()) {
|
|
81266
|
-
await
|
|
81670
|
+
await mkdir27(dirname33(path2), { recursive: true });
|
|
81267
81671
|
await rename7(backupPath, path2).catch((rollbackError) => {
|
|
81268
81672
|
rollbackFailures.push(`restore ${path2}: ${String(rollbackError)}`);
|
|
81269
81673
|
});
|
|
@@ -81282,8 +81686,8 @@ var init_atomicFileBatch = () => {};
|
|
|
81282
81686
|
|
|
81283
81687
|
// src/project/documentManifestRecovery.ts
|
|
81284
81688
|
import { createHash as createHash20 } from "node:crypto";
|
|
81285
|
-
import { readFile as
|
|
81286
|
-
import { join as
|
|
81689
|
+
import { readFile as readFile62 } from "node:fs/promises";
|
|
81690
|
+
import { join as join73 } from "node:path";
|
|
81287
81691
|
function recoverBatchEntries(value, sourceType, sourceName) {
|
|
81288
81692
|
const [batch, module, ...rest] = sourceName.split("/");
|
|
81289
81693
|
if (batch === undefined || module === undefined || rest.length > 0 || !/^\d{8}$/u.test(batch))
|
|
@@ -81306,7 +81710,7 @@ function recoverBatchEntries(value, sourceType, sourceName) {
|
|
|
81306
81710
|
async function readDocumentManifestForCapture(input) {
|
|
81307
81711
|
let bytes;
|
|
81308
81712
|
try {
|
|
81309
|
-
bytes = await
|
|
81713
|
+
bytes = await readFile62(join73(input.projectRoot, input.manifestPath));
|
|
81310
81714
|
} catch (error) {
|
|
81311
81715
|
if (error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR")) {
|
|
81312
81716
|
return { current: null, previous: null };
|
|
@@ -81323,10 +81727,10 @@ async function readDocumentManifestForCapture(input) {
|
|
|
81323
81727
|
return { current: current2, previous: previous2 };
|
|
81324
81728
|
} catch (error) {
|
|
81325
81729
|
const digest6 = createHash20("sha256").update(bytes).digest("hex");
|
|
81326
|
-
const backup =
|
|
81730
|
+
const backup = join73(".tmp", "context-runtime", "recovery", "document-manifests", `${digest6}.json`);
|
|
81327
81731
|
await applyAtomicFileBatch({
|
|
81328
|
-
transactionRoot:
|
|
81329
|
-
writes: [{ path:
|
|
81732
|
+
transactionRoot: join73(input.projectRoot, ".tmp", "context-runtime", "recovery", "manifest-transactions"),
|
|
81733
|
+
writes: [{ path: join73(input.projectRoot, backup), bytes }]
|
|
81330
81734
|
});
|
|
81331
81735
|
const recovered = recoverBatchEntries(current2, input.sourceType, input.sourceName);
|
|
81332
81736
|
return {
|
|
@@ -81949,10 +82353,10 @@ var init_workflowHostPlans = __esm(() => {
|
|
|
81949
82353
|
|
|
81950
82354
|
// src/project/workflow/workflowProvider.ts
|
|
81951
82355
|
import { existsSync as existsSync23 } from "node:fs";
|
|
81952
|
-
import { dirname as
|
|
82356
|
+
import { dirname as dirname37, resolve as resolve27 } from "node:path";
|
|
81953
82357
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
81954
82358
|
function providerCandidates() {
|
|
81955
|
-
const moduleDir2 =
|
|
82359
|
+
const moduleDir2 = dirname37(fileURLToPath5(import.meta.url));
|
|
81956
82360
|
return [
|
|
81957
82361
|
...process.env.C4A_CONTEXT_WORKFLOW_PROVIDER ? [resolve27(process.env.C4A_CONTEXT_WORKFLOW_PROVIDER)] : [],
|
|
81958
82362
|
resolve27(moduleDir2, "providers", "context", "manifest.json"),
|
|
@@ -82319,8 +82723,8 @@ var init_workflowProvider = __esm(() => {
|
|
|
82319
82723
|
});
|
|
82320
82724
|
|
|
82321
82725
|
// src/project/productionStageRefresh.ts
|
|
82322
|
-
import { readFile as
|
|
82323
|
-
import { join as
|
|
82726
|
+
import { readFile as readFile66 } from "node:fs/promises";
|
|
82727
|
+
import { join as join81 } from "node:path";
|
|
82324
82728
|
async function refreshProductionStageSources(projectRoot, stage) {
|
|
82325
82729
|
const affected = new Set(stage.gaps.map((gap) => gap.scope));
|
|
82326
82730
|
const unavailable = new Map;
|
|
@@ -82360,14 +82764,14 @@ Restore the authorized source and retry preparation.
|
|
|
82360
82764
|
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)
|
|
82361
82765
|
});
|
|
82362
82766
|
const directory = productionStageDirectory(stage.id);
|
|
82363
|
-
const contents2 = new Map([...sourceMaterials].map(([scope2, content3]) => [
|
|
82364
|
-
contents2.set(
|
|
82767
|
+
const contents2 = new Map([...sourceMaterials].map(([scope2, content3]) => [join81(directory, productionSourceFile(scope2)), content3]));
|
|
82768
|
+
contents2.set(join81(directory, "manifest.json"), `${JSON.stringify(updated)}
|
|
82365
82769
|
`);
|
|
82366
82770
|
const targets = [];
|
|
82367
82771
|
for (const [path2, content3] of contents2) {
|
|
82368
82772
|
let previous2;
|
|
82369
82773
|
try {
|
|
82370
|
-
previous2 = await
|
|
82774
|
+
previous2 = await readFile66(await safeProjectTarget(projectRoot, path2), "utf8");
|
|
82371
82775
|
} catch (error) {
|
|
82372
82776
|
if (error.code !== "ENOENT")
|
|
82373
82777
|
throw error;
|
|
@@ -82491,7 +82895,7 @@ var init_productionReport = __esm(() => {
|
|
|
82491
82895
|
});
|
|
82492
82896
|
|
|
82493
82897
|
// src/project/productionPlanningRoute.ts
|
|
82494
|
-
import { join as
|
|
82898
|
+
import { join as join82 } from "node:path";
|
|
82495
82899
|
async function productionPlanningRoute(input, stage) {
|
|
82496
82900
|
const request = stage ? undefined : await productionPlanningRequest(input.projectRoot);
|
|
82497
82901
|
const present = !!stage || !!request;
|
|
@@ -82529,7 +82933,7 @@ async function productionPlanningRoute(input, stage) {
|
|
|
82529
82933
|
id: `production/${stage.id}/planning`,
|
|
82530
82934
|
kind: "context-view",
|
|
82531
82935
|
media_type: "text/markdown",
|
|
82532
|
-
path:
|
|
82936
|
+
path: join82(input.projectRoot, productionStageDirectory(stage.id), "planning.md"),
|
|
82533
82937
|
read_state: "read-required"
|
|
82534
82938
|
}] : []
|
|
82535
82939
|
],
|
|
@@ -82548,7 +82952,7 @@ var init_productionPlanningRoute = __esm(() => {
|
|
|
82548
82952
|
|
|
82549
82953
|
// src/project/productionWorkflowRoute.ts
|
|
82550
82954
|
import { existsSync as existsSync24 } from "node:fs";
|
|
82551
|
-
import { join as
|
|
82955
|
+
import { join as join83 } from "node:path";
|
|
82552
82956
|
async function productionWorkflowRoute(input) {
|
|
82553
82957
|
const stage = await readProductionStage(input.projectRoot);
|
|
82554
82958
|
if (!stage || !stage.planning_complete)
|
|
@@ -82566,7 +82970,7 @@ async function productionWorkflowRoute(input) {
|
|
|
82566
82970
|
const selected = new Set(dispatch.batches.flatMap((batch) => batch.tasks));
|
|
82567
82971
|
const context = { workspace: input.projectRoot, authorities: [...input.authorities], facts: { production: {
|
|
82568
82972
|
report_approved: stage.report_approved,
|
|
82569
|
-
prepared: !dispatch.batches.length || existsSync24(
|
|
82973
|
+
prepared: !dispatch.batches.length || existsSync24(join83(input.projectRoot, directory, "stage.md")) && stage.tasks.filter((task) => selected.has(task.id)).every((task) => task.status === "issued"),
|
|
82570
82974
|
writing_complete: dispatch.batches.length === 0,
|
|
82571
82975
|
complete: dispatch.state === "ended",
|
|
82572
82976
|
review_clear: rejected.length === 0,
|
|
@@ -82583,7 +82987,7 @@ async function productionWorkflowRoute(input) {
|
|
|
82583
82987
|
const resolved = await resolveRoute(provider, "indexer", "production", primary.routeId, context, evaluated.evaluation.revision);
|
|
82584
82988
|
const report = resolved.node === "confirm-production-report";
|
|
82585
82989
|
if (report)
|
|
82586
|
-
await writeProductionProjection(input.projectRoot,
|
|
82990
|
+
await writeProductionProjection(input.projectRoot, join83(directory, "plan.md"), productionPlanMarkdown(stage));
|
|
82587
82991
|
const prepare = resolved.node === "prepare-production-stage";
|
|
82588
82992
|
const writing = resolved.node === "work-production-stage";
|
|
82589
82993
|
const repair = resolved.node === "repair-production-articles";
|
|
@@ -82598,7 +83002,7 @@ async function productionWorkflowRoute(input) {
|
|
|
82598
83002
|
id: `production/${stage.id}/${report ? "plan" : "stage"}`,
|
|
82599
83003
|
kind: "context-view",
|
|
82600
83004
|
media_type: "text/markdown",
|
|
82601
|
-
path:
|
|
83005
|
+
path: join83(input.projectRoot, directory, path3),
|
|
82602
83006
|
read_state: "read-required"
|
|
82603
83007
|
});
|
|
82604
83008
|
if (report || writing)
|
|
@@ -82609,18 +83013,18 @@ async function productionWorkflowRoute(input) {
|
|
|
82609
83013
|
id: `production/${stage.id}/planning`,
|
|
82610
83014
|
kind: "context-view",
|
|
82611
83015
|
media_type: "text/markdown",
|
|
82612
|
-
path:
|
|
83016
|
+
path: join83(input.projectRoot, directory, "planning.md"),
|
|
82613
83017
|
read_state: "read-required"
|
|
82614
83018
|
});
|
|
82615
83019
|
}
|
|
82616
83020
|
if (repair) {
|
|
82617
|
-
await writeProductionProjection(input.projectRoot,
|
|
83021
|
+
await writeProductionProjection(input.projectRoot, join83(directory, "repair.md"), [
|
|
82618
83022
|
"# Revise rejected articles",
|
|
82619
83023
|
"",
|
|
82620
83024
|
...rejected.map((candidate) => `- ${candidate.path}: ${candidate.review.title}`),
|
|
82621
83025
|
"",
|
|
82622
83026
|
"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.",
|
|
82623
|
-
`Submit the plan amendment to ${path2} using ${
|
|
83027
|
+
`Submit the plan amendment to ${path2} using ${join83(directory, "planning.schema.json")}. Keep accepted task identities unchanged; the CLI assigns the revision tasks and preserves article identities.`,
|
|
82624
83028
|
"Once issued, repair the affected sections through the existing edits submission. Unchanged sections and references do not need resubmission.",
|
|
82625
83029
|
""
|
|
82626
83030
|
].join(`
|
|
@@ -82629,7 +83033,7 @@ async function productionWorkflowRoute(input) {
|
|
|
82629
83033
|
id: `production/${stage.id}/repair`,
|
|
82630
83034
|
kind: "context-view",
|
|
82631
83035
|
media_type: "text/markdown",
|
|
82632
|
-
path:
|
|
83036
|
+
path: join83(input.projectRoot, directory, "repair.md"),
|
|
82633
83037
|
read_state: "read-required"
|
|
82634
83038
|
});
|
|
82635
83039
|
}
|
|
@@ -82720,7 +83124,7 @@ var init_knowledgeMaintenanceRoute = __esm(() => {
|
|
|
82720
83124
|
});
|
|
82721
83125
|
|
|
82722
83126
|
// src/project/approvedRevisionContext.ts
|
|
82723
|
-
import { readFile as
|
|
83127
|
+
import { readFile as readFile67 } from "node:fs/promises";
|
|
82724
83128
|
async function approvedRevisionContext(root, target) {
|
|
82725
83129
|
const registry2 = await readProductionRequirements(root);
|
|
82726
83130
|
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}/`))));
|
|
@@ -82731,7 +83135,7 @@ async function approvedRevisionContext(root, target) {
|
|
|
82731
83135
|
const type = source_ref.slice(0, separator);
|
|
82732
83136
|
const name3 = source_ref.slice(separator + 1);
|
|
82733
83137
|
const path2 = await assertManagedDocumentPath(root, type, name3);
|
|
82734
|
-
const markdown = await
|
|
83138
|
+
const markdown = await readFile67(path2, "utf8");
|
|
82735
83139
|
const changes = type === "sessions" ? readSessionChanges(markdown) : undefined;
|
|
82736
83140
|
return {
|
|
82737
83141
|
source_ref,
|
|
@@ -87412,8 +87816,8 @@ var init_larkResourceCommand = __esm(() => {
|
|
|
87412
87816
|
|
|
87413
87817
|
// src/lib/larkResourceMaterialization.ts
|
|
87414
87818
|
import { createHash as createHash27 } from "node:crypto";
|
|
87415
|
-
import { mkdtemp as mkdtemp4, readFile as
|
|
87416
|
-
import { extname as extname13, join as
|
|
87819
|
+
import { mkdtemp as mkdtemp4, readFile as readFile73, readdir as readdir21, rm as rm19 } from "node:fs/promises";
|
|
87820
|
+
import { extname as extname13, join as join92 } from "node:path";
|
|
87417
87821
|
import { tmpdir } from "node:os";
|
|
87418
87822
|
function countByKind(items, status) {
|
|
87419
87823
|
const counts2 = new Map;
|
|
@@ -87518,10 +87922,10 @@ function findBooleanField(value, name3) {
|
|
|
87518
87922
|
}
|
|
87519
87923
|
async function downloadedFile(input) {
|
|
87520
87924
|
if (input.localPath !== undefined) {
|
|
87521
|
-
const bytes = await
|
|
87925
|
+
const bytes = await readFile73(input.localPath);
|
|
87522
87926
|
return { path: input.localPath, bytes, mediaType: mediaTypeFor(input.localPath, bytes) };
|
|
87523
87927
|
}
|
|
87524
|
-
const tempRoot = await mkdtemp4(
|
|
87928
|
+
const tempRoot = await mkdtemp4(join92(tmpdir(), "context-lark-resource-"));
|
|
87525
87929
|
try {
|
|
87526
87930
|
await runLarkResourceCommand(input.runner, [
|
|
87527
87931
|
"docs",
|
|
@@ -87542,7 +87946,7 @@ async function downloadedFile(input) {
|
|
|
87542
87946
|
if (entries2.length !== 1)
|
|
87543
87947
|
throw new Error(`media download produced ${entries2.length} files, expected exactly one`);
|
|
87544
87948
|
const path3 = entries2[0]?.name ?? "resource.bin";
|
|
87545
|
-
const bytes = await
|
|
87949
|
+
const bytes = await readFile73(join92(tempRoot, path3));
|
|
87546
87950
|
return { path: path3, bytes, mediaType: mediaTypeFor(path3, bytes) };
|
|
87547
87951
|
} finally {
|
|
87548
87952
|
await rm19(tempRoot, { recursive: true, force: true });
|
|
@@ -87633,9 +88037,9 @@ async function sheetMaterialization(resource, runner2, identity) {
|
|
|
87633
88037
|
const sheetId = resource.attributes["sheet-id"];
|
|
87634
88038
|
if (token === undefined || sheetId === undefined)
|
|
87635
88039
|
throw new Error("embedded Sheet requires token and sheet-id");
|
|
87636
|
-
const tempRoot = await mkdtemp4(
|
|
88040
|
+
const tempRoot = await mkdtemp4(join92(tmpdir(), "context-lark-sheet-"));
|
|
87637
88041
|
try {
|
|
87638
|
-
const outputPath =
|
|
88042
|
+
const outputPath = join92(tempRoot, "sheet.json");
|
|
87639
88043
|
const stdout = await runLarkResourceCommand(runner2, [
|
|
87640
88044
|
"sheets",
|
|
87641
88045
|
"+csv-get",
|
|
@@ -87655,7 +88059,7 @@ async function sheetMaterialization(resource, runner2, identity) {
|
|
|
87655
88059
|
if (findBooleanField(receipt2, "truncated") === true || findBooleanField(receipt2, "complete") === false) {
|
|
87656
88060
|
throw new Error("embedded Sheet read was truncated");
|
|
87657
88061
|
}
|
|
87658
|
-
const payload = JSON.parse(await
|
|
88062
|
+
const payload = JSON.parse(await readFile73(outputPath, "utf8"));
|
|
87659
88063
|
const csv = findStringField(payload, new Set(["annotated_csv", "csv", "content", "text"]));
|
|
87660
88064
|
if (csv === undefined)
|
|
87661
88065
|
throw new Error("embedded Sheet response has no CSV payload");
|
|
@@ -87791,7 +88195,7 @@ async function whiteboardMaterialization(resource, runner2, identity) {
|
|
|
87791
88195
|
if (token === undefined)
|
|
87792
88196
|
throw new Error(`${resource.kind} has no whiteboard token`);
|
|
87793
88197
|
const preview = await downloadedFile({ runner: runner2, identity, token, type: "whiteboard" });
|
|
87794
|
-
const tempRoot = await mkdtemp4(
|
|
88198
|
+
const tempRoot = await mkdtemp4(join92(tmpdir(), "context-lark-whiteboard-"));
|
|
87795
88199
|
let rawPayload;
|
|
87796
88200
|
try {
|
|
87797
88201
|
await runLarkResourceCommand(runner2, [
|
|
@@ -87809,7 +88213,7 @@ async function whiteboardMaterialization(resource, runner2, identity) {
|
|
|
87809
88213
|
"--format",
|
|
87810
88214
|
"json"
|
|
87811
88215
|
], { cwd: tempRoot });
|
|
87812
|
-
rawPayload = JSON.parse(await
|
|
88216
|
+
rawPayload = JSON.parse(await readFile73(join92(tempRoot, "raw.json"), "utf8"));
|
|
87813
88217
|
} finally {
|
|
87814
88218
|
await rm19(tempRoot, { recursive: true, force: true });
|
|
87815
88219
|
}
|
|
@@ -88661,8 +89065,8 @@ var init_sensitiveSourceLiteral = __esm(() => {
|
|
|
88661
89065
|
var LARK_DOCUMENT_NORMALIZER_VERSION = "lark-document-normalizer.v1";
|
|
88662
89066
|
|
|
88663
89067
|
// src/project/documentCaptureLark.ts
|
|
88664
|
-
import { readdir as readdir22, readFile as
|
|
88665
|
-
import { basename as basename10, extname as extname14, join as
|
|
89068
|
+
import { readdir as readdir22, readFile as readFile74 } from "node:fs/promises";
|
|
89069
|
+
import { basename as basename10, extname as extname14, join as join93 } from "node:path";
|
|
88666
89070
|
function titleFromMarkdown2(markdown, fallbackPath) {
|
|
88667
89071
|
const heading2 = markdown.split(`
|
|
88668
89072
|
`).find((line) => /^#\s+\S/u.test(line));
|
|
@@ -88681,7 +89085,7 @@ function countLines3(markdown) {
|
|
|
88681
89085
|
}
|
|
88682
89086
|
async function fileContentMatches(path3, content3) {
|
|
88683
89087
|
try {
|
|
88684
|
-
const current2 = await
|
|
89088
|
+
const current2 = await readFile74(path3);
|
|
88685
89089
|
const expected = typeof content3 === "string" ? Buffer.from(content3, "utf8") : Buffer.from(content3);
|
|
88686
89090
|
return current2.equals(expected);
|
|
88687
89091
|
} catch {
|
|
@@ -88689,7 +89093,7 @@ async function fileContentMatches(path3, content3) {
|
|
|
88689
89093
|
}
|
|
88690
89094
|
}
|
|
88691
89095
|
function sourceManifestPath2(entry) {
|
|
88692
|
-
return entry.snapshot?.manifest ??
|
|
89096
|
+
return entry.snapshot?.manifest ?? join93(entry.materializedAt, "manifest.json");
|
|
88693
89097
|
}
|
|
88694
89098
|
function larkRuntimeError(message, detail) {
|
|
88695
89099
|
return new ContextError(ExitCode.ExternalToolError, message, {
|
|
@@ -88815,7 +89219,7 @@ function assetManifestEntry(asset, assetRoot) {
|
|
|
88815
89219
|
};
|
|
88816
89220
|
}
|
|
88817
89221
|
async function listSnapshotAssetFiles(root2, assetRoot) {
|
|
88818
|
-
const assetsRoot =
|
|
89222
|
+
const assetsRoot = join93(root2, assetRoot);
|
|
88819
89223
|
const files = [];
|
|
88820
89224
|
const visit4 = async (dir, prefix = assetRoot) => {
|
|
88821
89225
|
let entries2;
|
|
@@ -88828,7 +89232,7 @@ async function listSnapshotAssetFiles(root2, assetRoot) {
|
|
|
88828
89232
|
}
|
|
88829
89233
|
for (const entry of entries2) {
|
|
88830
89234
|
const relPath = `${prefix}/${entry.name}`;
|
|
88831
|
-
const absolutePath =
|
|
89235
|
+
const absolutePath = join93(dir, entry.name);
|
|
88832
89236
|
if (entry.isDirectory()) {
|
|
88833
89237
|
await visit4(absolutePath, relPath);
|
|
88834
89238
|
continue;
|
|
@@ -88843,7 +89247,7 @@ async function listSnapshotAssetFiles(root2, assetRoot) {
|
|
|
88843
89247
|
}
|
|
88844
89248
|
async function staleSnapshotAssetPaths(input) {
|
|
88845
89249
|
const existingPaths = await listSnapshotAssetFiles(input.materializedAtAbsPath, input.assetRoot);
|
|
88846
|
-
return existingPaths.filter((path3) => !input.currentPaths.has(path3)).map((path3) =>
|
|
89250
|
+
return existingPaths.filter((path3) => !input.currentPaths.has(path3)).map((path3) => join93(input.materializedAtAbsPath, path3));
|
|
88847
89251
|
}
|
|
88848
89252
|
function normalizeLarkError(error, sourceName) {
|
|
88849
89253
|
if (error instanceof ContextError)
|
|
@@ -88951,9 +89355,9 @@ async function runCaptureLarkPhaseUnlocked(input) {
|
|
|
88951
89355
|
locator
|
|
88952
89356
|
}];
|
|
88953
89357
|
const manifestPath = sourceManifestPath2(entry);
|
|
88954
|
-
const manifestAbsPath =
|
|
89358
|
+
const manifestAbsPath = join93(input.projectRoot, manifestPath);
|
|
88955
89359
|
const materializedAt = entry.materializedAt;
|
|
88956
|
-
const materializedAtAbsPath =
|
|
89360
|
+
const materializedAtAbsPath = join93(input.projectRoot, materializedAt);
|
|
88957
89361
|
const manifest = createDocumentSnapshotManifest({
|
|
88958
89362
|
sourceType: "lark",
|
|
88959
89363
|
sourceName: resolved.sourceName,
|
|
@@ -88987,13 +89391,13 @@ async function runCaptureLarkPhaseUnlocked(input) {
|
|
|
88987
89391
|
}));
|
|
88988
89392
|
try {
|
|
88989
89393
|
const requestedWrites = [{
|
|
88990
|
-
path:
|
|
89394
|
+
path: join93(materializedAtAbsPath, documentPath),
|
|
88991
89395
|
bytes: normalized
|
|
88992
89396
|
}];
|
|
88993
89397
|
for (const asset of assets) {
|
|
88994
89398
|
if (asset.bytes !== undefined) {
|
|
88995
89399
|
requestedWrites.push({
|
|
88996
|
-
path:
|
|
89400
|
+
path: join93(materializedAtAbsPath, asset.entry.path),
|
|
88997
89401
|
bytes: asset.bytes
|
|
88998
89402
|
});
|
|
88999
89403
|
}
|
|
@@ -89010,7 +89414,7 @@ async function runCaptureLarkPhaseUnlocked(input) {
|
|
|
89010
89414
|
currentPaths: new Set(assets.filter((asset) => asset.bytes !== undefined).map((asset) => asset.entry.path))
|
|
89011
89415
|
});
|
|
89012
89416
|
await applyAtomicFileBatch({
|
|
89013
|
-
transactionRoot:
|
|
89417
|
+
transactionRoot: join93(input.projectRoot, ".tmp", "context-runtime", "capture-transactions"),
|
|
89014
89418
|
writes,
|
|
89015
89419
|
removals
|
|
89016
89420
|
});
|
|
@@ -89113,7 +89517,7 @@ __export(exports_actionInputWorkspace, {
|
|
|
89113
89517
|
assertActionInputWorkspace: () => assertActionInputWorkspace
|
|
89114
89518
|
});
|
|
89115
89519
|
import { realpathSync as realpathSync2 } from "node:fs";
|
|
89116
|
-
import { dirname as
|
|
89520
|
+
import { dirname as dirname40, resolve as resolve31 } from "node:path";
|
|
89117
89521
|
function assertActionInputWorkspace(cwd, inputPath) {
|
|
89118
89522
|
if (inputPath === "-")
|
|
89119
89523
|
return;
|
|
@@ -89126,7 +89530,7 @@ function assertActionInputWorkspace(cwd, inputPath) {
|
|
|
89126
89530
|
} catch {
|
|
89127
89531
|
return;
|
|
89128
89532
|
}
|
|
89129
|
-
const owner = findContextProjectRoot(
|
|
89533
|
+
const owner = findContextProjectRoot(dirname40(file));
|
|
89130
89534
|
if (owner === null || realpathSync2(owner.projectRoot) === realpathSync2(current2.projectRoot))
|
|
89131
89535
|
return;
|
|
89132
89536
|
throw new ContextError(ExitCode.WorkspaceStateError, "The completion input belongs to a different Context workspace. Run the workflow CLI and read/write this task's .tmp files in the same intended workspace. No tasks were submitted.", {
|
|
@@ -89156,7 +89560,7 @@ __export(exports_articleRetirement, {
|
|
|
89156
89560
|
retireArticles: () => retireArticles,
|
|
89157
89561
|
articleRetirementSchema: () => articleRetirementSchema
|
|
89158
89562
|
});
|
|
89159
|
-
import { readFile as
|
|
89563
|
+
import { readFile as readFile80, readdir as readdir23 } from "node:fs/promises";
|
|
89160
89564
|
import { posix as posix10 } from "node:path";
|
|
89161
89565
|
function rebuildInput(revision) {
|
|
89162
89566
|
return JSON.stringify({ id: `retirement-${revision.slice(7)}`, operation: "rebuild", timing: "priority", targets: [] });
|
|
@@ -89177,7 +89581,7 @@ function invalid2(reason, message, details = {}) {
|
|
|
89177
89581
|
}
|
|
89178
89582
|
async function text9(root2, path3) {
|
|
89179
89583
|
try {
|
|
89180
|
-
return await
|
|
89584
|
+
return await readFile80(await safeProjectTarget(root2, path3), "utf8");
|
|
89181
89585
|
} catch (error) {
|
|
89182
89586
|
if (error.code === "ENOENT")
|
|
89183
89587
|
return;
|
|
@@ -89439,8 +89843,8 @@ __export(exports_writeLockRecovery, {
|
|
|
89439
89843
|
recoverWriterLock: () => recoverWriterLock,
|
|
89440
89844
|
inspectWriterLock: () => inspectWriterLock
|
|
89441
89845
|
});
|
|
89442
|
-
import { lstat as lstat10, mkdir as
|
|
89443
|
-
import { join as
|
|
89846
|
+
import { lstat as lstat10, mkdir as mkdir34, readFile as readFile81, readdir as readdir24, rename as rename8, rmdir as rmdir2 } from "node:fs/promises";
|
|
89847
|
+
import { join as join98 } from "node:path";
|
|
89444
89848
|
import { createHash as createHash29, randomUUID as randomUUID7 } from "node:crypto";
|
|
89445
89849
|
async function inspectWriterLock(root2) {
|
|
89446
89850
|
const path3 = await safeProjectTarget(root2, lockRelative);
|
|
@@ -89455,7 +89859,7 @@ async function inspectWriterLock(root2) {
|
|
|
89455
89859
|
if (!stat10.isDirectory() || stat10.isSymbolicLink())
|
|
89456
89860
|
throw new Error("Writer lock must be a real directory.");
|
|
89457
89861
|
const ownerPath = await safeProjectTarget(root2, `${lockRelative}/owner.json`);
|
|
89458
|
-
const bytes = await
|
|
89862
|
+
const bytes = await readFile81(ownerPath, "utf8");
|
|
89459
89863
|
const owner = JSON.parse(bytes);
|
|
89460
89864
|
if (owner.protocol !== "context.project-write-lock.v1" || !Number.isSafeInteger(owner.pid) || owner.pid <= 0) {
|
|
89461
89865
|
throw new Error("Writer lock owner is invalid; preserve the lock for diagnosis.");
|
|
@@ -89487,9 +89891,9 @@ async function recoverWriterLock(input) {
|
|
|
89487
89891
|
};
|
|
89488
89892
|
if (input.plan_digest !== before.digest)
|
|
89489
89893
|
throw new Error("Writer lock changed; preview recovery again.");
|
|
89490
|
-
const path3 =
|
|
89491
|
-
const guard =
|
|
89492
|
-
await
|
|
89894
|
+
const path3 = join98(input.projectRoot, lockRelative);
|
|
89895
|
+
const guard = join98(path3, ".recovery");
|
|
89896
|
+
await mkdir34(guard);
|
|
89493
89897
|
let archived = false;
|
|
89494
89898
|
try {
|
|
89495
89899
|
const current2 = await inspectWriterLock(input.projectRoot);
|
|
@@ -89499,7 +89903,7 @@ async function recoverWriterLock(input) {
|
|
|
89499
89903
|
if (names.some((name3) => name3 !== "owner.json" && name3 !== ".recovery"))
|
|
89500
89904
|
throw new Error("Unexpected lock contents; preserve for diagnosis.");
|
|
89501
89905
|
const archive = `.tmp/context-runtime/locks/recovered-write-${randomUUID7()}.lock`;
|
|
89502
|
-
await rename8(path3,
|
|
89906
|
+
await rename8(path3, join98(input.projectRoot, archive));
|
|
89503
89907
|
archived = true;
|
|
89504
89908
|
return { action: "writer-lock-recovered", archived_lock: archive, next: "context task recover --format json" };
|
|
89505
89909
|
} finally {
|
|
@@ -89523,12 +89927,12 @@ __export(exports_taskRecovery, {
|
|
|
89523
89927
|
RECOVERY_COMMAND: () => RECOVERY_COMMAND
|
|
89524
89928
|
});
|
|
89525
89929
|
import { existsSync as existsSync26 } from "node:fs";
|
|
89526
|
-
import { dirname as
|
|
89527
|
-
import { lstat as lstat11, readdir as readdir25, readFile as
|
|
89930
|
+
import { dirname as dirname41, join as join99 } from "node:path";
|
|
89931
|
+
import { lstat as lstat11, readdir as readdir25, readFile as readFile82 } from "node:fs/promises";
|
|
89528
89932
|
async function recoveryText(root2, path3) {
|
|
89529
89933
|
const target = await safeProjectTarget(root2, path3);
|
|
89530
89934
|
try {
|
|
89531
|
-
return await
|
|
89935
|
+
return await readFile82(target, "utf8");
|
|
89532
89936
|
} catch (error) {
|
|
89533
89937
|
if (error.code === "ENOENT")
|
|
89534
89938
|
return;
|
|
@@ -89541,7 +89945,7 @@ async function recoveryJournals(root2) {
|
|
|
89541
89945
|
await safeProjectTarget(root2, path3);
|
|
89542
89946
|
let stat10;
|
|
89543
89947
|
try {
|
|
89544
|
-
stat10 = await lstat11(
|
|
89948
|
+
stat10 = await lstat11(join99(root2, path3));
|
|
89545
89949
|
} catch (error) {
|
|
89546
89950
|
if (error.code === "ENOENT")
|
|
89547
89951
|
return;
|
|
@@ -89552,7 +89956,7 @@ async function recoveryJournals(root2) {
|
|
|
89552
89956
|
if (stat10.isDirectory()) {
|
|
89553
89957
|
if (depth > 3)
|
|
89554
89958
|
throw new TypeError("Unexpected transaction directory depth; preserve it for diagnosis.");
|
|
89555
|
-
for (const name3 of (await readdir25(
|
|
89959
|
+
for (const name3 of (await readdir25(join99(root2, path3))).sort())
|
|
89556
89960
|
await visit4(`${path3}/${name3}`, depth + 1);
|
|
89557
89961
|
} else if (stat10.isFile())
|
|
89558
89962
|
entries2.push({ path: path3, digest: indexerProtocolDigest(await recoveryText(root2, path3)) });
|
|
@@ -89562,10 +89966,10 @@ async function recoveryJournals(root2) {
|
|
|
89562
89966
|
}
|
|
89563
89967
|
function recoveryResources() {
|
|
89564
89968
|
try {
|
|
89565
|
-
const root2 =
|
|
89969
|
+
const root2 = dirname41(contextWorkflowProviderPath());
|
|
89566
89970
|
const resources = {
|
|
89567
|
-
skill:
|
|
89568
|
-
issue_template:
|
|
89971
|
+
skill: join99(root2, "skills/recover-workspace/SKILL.md"),
|
|
89972
|
+
issue_template: join99(root2, "resources/templates/recovery-issue.md")
|
|
89569
89973
|
};
|
|
89570
89974
|
if (!Object.values(resources).every((path3) => existsSync26(path3)))
|
|
89571
89975
|
throw new Error("Recovery resources are absent from this Provider.");
|
|
@@ -89650,8 +90054,8 @@ var exports_taskLocalSourceAdjustment = {};
|
|
|
89650
90054
|
__export(exports_taskLocalSourceAdjustment, {
|
|
89651
90055
|
adjustLocalRevisionSources: () => adjustLocalRevisionSources
|
|
89652
90056
|
});
|
|
89653
|
-
import { readFile as
|
|
89654
|
-
import { join as
|
|
90057
|
+
import { readFile as readFile83 } from "node:fs/promises";
|
|
90058
|
+
import { join as join100 } from "node:path";
|
|
89655
90059
|
async function adjustLocalRevisionSources(root2, input) {
|
|
89656
90060
|
const { readMaintenance: readMaintenance2 } = await Promise.resolve().then(() => (init_maintenanceStorage(), exports_maintenanceStorage));
|
|
89657
90061
|
if ((await readMaintenance2(root2)).active && await readProductionStage(root2))
|
|
@@ -89675,7 +90079,7 @@ async function adjustLocalRevisionSources(root2, input) {
|
|
|
89675
90079
|
if (input.refresh && (!current2.refresh_sources || indexerProtocolDigest([...current2.refresh_sources].sort()) !== indexerProtocolDigest([...selected].sort()))) {
|
|
89676
90080
|
throw new TypeError("No matching acquisition adjustment exists. Run task adjust without refresh first.");
|
|
89677
90081
|
}
|
|
89678
|
-
const raw = await
|
|
90082
|
+
const raw = await readFile83(join100(root2, await revisionStoragePath(root2)), "utf8");
|
|
89679
90083
|
let next2;
|
|
89680
90084
|
const discardIds = new Set;
|
|
89681
90085
|
if (!input.refresh) {
|
|
@@ -89778,7 +90182,7 @@ ${input.instruction}` : revision.instruction
|
|
|
89778
90182
|
content: content3
|
|
89779
90183
|
}];
|
|
89780
90184
|
if (discardIds.size > 0) {
|
|
89781
|
-
const ledger = await
|
|
90185
|
+
const ledger = await readFile83(join100(root2, CANDIDATE_LEDGER_FILE), "utf8").catch((error) => {
|
|
89782
90186
|
if (error.code === "ENOENT")
|
|
89783
90187
|
return;
|
|
89784
90188
|
throw error;
|
|
@@ -89900,7 +90304,7 @@ var init_taskSourceAdjustment = __esm(() => {
|
|
|
89900
90304
|
});
|
|
89901
90305
|
|
|
89902
90306
|
// src/project/managedDocumentImport.ts
|
|
89903
|
-
import { readFile as
|
|
90307
|
+
import { readFile as readFile89 } from "node:fs/promises";
|
|
89904
90308
|
async function importManagedDocument(projectRoot, value) {
|
|
89905
90309
|
const input = inputSchema.parse(value);
|
|
89906
90310
|
if (input.type !== "sessions" && input.changes !== undefined)
|
|
@@ -89909,7 +90313,7 @@ async function importManagedDocument(projectRoot, value) {
|
|
|
89909
90313
|
const path3 = await assertManagedDocumentPath(projectRoot, input.type, input.name);
|
|
89910
90314
|
let previous3;
|
|
89911
90315
|
try {
|
|
89912
|
-
previous3 = await
|
|
90316
|
+
previous3 = await readFile89(path3, "utf8");
|
|
89913
90317
|
} catch (error) {
|
|
89914
90318
|
if (!(error && typeof error === "object" && ("code" in error) && error.code === "ENOENT"))
|
|
89915
90319
|
throw error;
|
|
@@ -89956,14 +90360,14 @@ var init_managedDocumentImport = __esm(() => {
|
|
|
89956
90360
|
});
|
|
89957
90361
|
|
|
89958
90362
|
// src/project/larkDocumentImport.ts
|
|
89959
|
-
import { readFile as
|
|
90363
|
+
import { readFile as readFile90 } from "node:fs/promises";
|
|
89960
90364
|
async function importLarkDocument(projectRoot, value) {
|
|
89961
90365
|
const input = schema3.parse(value);
|
|
89962
90366
|
const responsePages = [];
|
|
89963
90367
|
for (const path3 of input.response_files) {
|
|
89964
90368
|
assertActionInputWorkspace(projectRoot, path3);
|
|
89965
90369
|
const { resolve: resolve8 } = await import("node:path");
|
|
89966
|
-
responsePages.push(await
|
|
90370
|
+
responsePages.push(await readFile90(resolve8(projectRoot, path3), "utf8"));
|
|
89967
90371
|
}
|
|
89968
90372
|
const mediaFiles = {};
|
|
89969
90373
|
for (const [token, path3] of Object.entries(input.media_files ?? {})) {
|
|
@@ -90031,11 +90435,11 @@ var exports_managedDocumentRename = {};
|
|
|
90031
90435
|
__export(exports_managedDocumentRename, {
|
|
90032
90436
|
renameManagedDocument: () => renameManagedDocument
|
|
90033
90437
|
});
|
|
90034
|
-
import { readFile as
|
|
90035
|
-
import { join as
|
|
90438
|
+
import { readFile as readFile91 } from "node:fs/promises";
|
|
90439
|
+
import { join as join108, posix as posix11 } from "node:path";
|
|
90036
90440
|
async function optionalText2(path3) {
|
|
90037
90441
|
try {
|
|
90038
|
-
return await
|
|
90442
|
+
return await readFile91(path3, "utf8");
|
|
90039
90443
|
} catch (error) {
|
|
90040
90444
|
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT")
|
|
90041
90445
|
return;
|
|
@@ -90119,7 +90523,7 @@ async function renameManagedDocument(input) {
|
|
|
90119
90523
|
if (path3.split("/").includes("..") || path3.startsWith("/"))
|
|
90120
90524
|
throw new TypeError("Source references contain an unsafe knowledge path; repair it before renaming.");
|
|
90121
90525
|
await safeProjectTarget(input.projectRoot, path3);
|
|
90122
|
-
const before = await optionalText2(
|
|
90526
|
+
const before = await optionalText2(join108(input.projectRoot, path3));
|
|
90123
90527
|
if (before === undefined)
|
|
90124
90528
|
continue;
|
|
90125
90529
|
let after;
|
|
@@ -90208,8 +90612,8 @@ var init_managedDocumentRename = __esm(() => {
|
|
|
90208
90612
|
|
|
90209
90613
|
// src/cli.ts
|
|
90210
90614
|
import { existsSync as existsSync36, realpathSync as realpathSync3 } from "node:fs";
|
|
90211
|
-
import { dirname as
|
|
90212
|
-
import { fileURLToPath as
|
|
90615
|
+
import { dirname as dirname48, join as join112 } from "node:path";
|
|
90616
|
+
import { fileURLToPath as fileURLToPath11, pathToFileURL as pathToFileURL3 } from "node:url";
|
|
90213
90617
|
|
|
90214
90618
|
// ../../node_modules/.bun/commander@11.1.0/node_modules/commander/esm.mjs
|
|
90215
90619
|
var import__ = __toESM(require_commander(), 1);
|
|
@@ -90263,7 +90667,7 @@ init_dist();
|
|
|
90263
90667
|
init_cliFeedback();
|
|
90264
90668
|
init_errors3();
|
|
90265
90669
|
init_exitCode();
|
|
90266
|
-
import { join as
|
|
90670
|
+
import { join as join90 } from "node:path";
|
|
90267
90671
|
|
|
90268
90672
|
// src/project/status.ts
|
|
90269
90673
|
init_productionPlanning();
|
|
@@ -90274,13 +90678,13 @@ init_approvedRevisionBatch();
|
|
|
90274
90678
|
init_revisionDelivery();
|
|
90275
90679
|
init_workspacePreparation();
|
|
90276
90680
|
init_src2();
|
|
90277
|
-
import { join as
|
|
90681
|
+
import { join as join84 } from "node:path";
|
|
90278
90682
|
|
|
90279
90683
|
// src/project/statusReaders.ts
|
|
90280
90684
|
init_commandReadCache();
|
|
90281
90685
|
init_errors3();
|
|
90282
90686
|
import { existsSync as existsSync22, readFileSync as readFileSync8 } from "node:fs";
|
|
90283
|
-
import { join as
|
|
90687
|
+
import { join as join80 } from "node:path";
|
|
90284
90688
|
|
|
90285
90689
|
// src/project/documentCapture.ts
|
|
90286
90690
|
init_src3();
|
|
@@ -90288,8 +90692,8 @@ init_cliFeedback();
|
|
|
90288
90692
|
init_errors3();
|
|
90289
90693
|
init_exitCode();
|
|
90290
90694
|
import { createHash as createHash21 } from "node:crypto";
|
|
90291
|
-
import { mkdir as
|
|
90292
|
-
import { basename as basename8, dirname as
|
|
90695
|
+
import { mkdir as mkdir28, readdir as readdir18, readFile as readFile63, rm as rm17, stat as stat9, writeFile as writeFile23 } from "node:fs/promises";
|
|
90696
|
+
import { basename as basename8, dirname as dirname34, extname as extname12, join as join74, relative as relative22, resolve as resolve24 } from "node:path";
|
|
90293
90697
|
|
|
90294
90698
|
// src/project/documentCaptureAssets.ts
|
|
90295
90699
|
init_src3();
|
|
@@ -90298,8 +90702,8 @@ init_errors3();
|
|
|
90298
90702
|
init_exitCode();
|
|
90299
90703
|
init_markdownLinks();
|
|
90300
90704
|
import { readFileSync as readFileSync6 } from "node:fs";
|
|
90301
|
-
import { mkdir as
|
|
90302
|
-
import { dirname as
|
|
90705
|
+
import { mkdir as mkdir26, readFile as readFile60, stat as stat7, writeFile as writeFile21 } from "node:fs/promises";
|
|
90706
|
+
import { dirname as dirname31, isAbsolute as isAbsolute13, join as join69, relative as relative20, resolve as resolve21 } from "node:path";
|
|
90303
90707
|
function runtimeError(message, detail) {
|
|
90304
90708
|
return new ContextError(ExitCode.UserError, message, {
|
|
90305
90709
|
category: ErrorCategory.UserInputInvalid,
|
|
@@ -90324,31 +90728,31 @@ function linkedAssetSnapshotPath(documentPath, target) {
|
|
|
90324
90728
|
const decoded = decodedAssetTarget(target);
|
|
90325
90729
|
if (/^[a-z][a-z0-9+.-]*:/iu.test(decoded) || decoded.startsWith("#") || decoded.startsWith("/"))
|
|
90326
90730
|
return;
|
|
90327
|
-
const candidate = toPosixPath5(
|
|
90731
|
+
const candidate = toPosixPath5(join69(dirname31(documentPath), decoded));
|
|
90328
90732
|
if (candidate !== "assets" && !candidate.startsWith("assets/"))
|
|
90329
90733
|
return;
|
|
90330
90734
|
return normalizeSnapshotRelativePath(candidate);
|
|
90331
90735
|
}
|
|
90332
90736
|
async function writeCaptureAssetIfChanged(path2, content3) {
|
|
90333
90737
|
try {
|
|
90334
|
-
const current = await
|
|
90738
|
+
const current = await readFile60(path2);
|
|
90335
90739
|
if (current.byteLength === content3.byteLength && current.equals(content3))
|
|
90336
90740
|
return;
|
|
90337
90741
|
} catch {}
|
|
90338
|
-
await
|
|
90339
|
-
await
|
|
90742
|
+
await mkdir26(dirname31(path2), { recursive: true });
|
|
90743
|
+
await writeFile21(path2, content3);
|
|
90340
90744
|
}
|
|
90341
90745
|
async function readLinkedCaptureAssets(input) {
|
|
90342
90746
|
const rootStat = await stat7(input.localRoot);
|
|
90343
|
-
const boundaryRoot = rootStat.isFile() ?
|
|
90747
|
+
const boundaryRoot = rootStat.isFile() ? dirname31(input.localRoot) : input.localRoot;
|
|
90344
90748
|
const bySnapshotPath = new Map;
|
|
90345
90749
|
for (const file of input.files) {
|
|
90346
|
-
const markdown = await
|
|
90750
|
+
const markdown = await readFile60(file.absolutePath, "utf8");
|
|
90347
90751
|
for (const link of markdownInlineLinks(markdown)) {
|
|
90348
90752
|
const snapshotPath2 = linkedAssetSnapshotPath(file.snapshotPath, link.target);
|
|
90349
90753
|
if (snapshotPath2 === undefined)
|
|
90350
90754
|
continue;
|
|
90351
|
-
const absolutePath = resolve21(
|
|
90755
|
+
const absolutePath = resolve21(dirname31(file.absolutePath), decodedAssetTarget(link.target));
|
|
90352
90756
|
if (!isWithinPath(boundaryRoot, absolutePath)) {
|
|
90353
90757
|
throw runtimeError(`file source ${input.sourceName} asset escapes the source boundary: ${link.target}`, {
|
|
90354
90758
|
sourceName: input.sourceName,
|
|
@@ -90361,7 +90765,7 @@ async function readLinkedCaptureAssets(input) {
|
|
|
90361
90765
|
const assetStat = await stat7(absolutePath);
|
|
90362
90766
|
if (!assetStat.isFile())
|
|
90363
90767
|
throw new TypeError("asset target is not a file");
|
|
90364
|
-
bytes = await
|
|
90768
|
+
bytes = await readFile60(absolutePath);
|
|
90365
90769
|
} catch (error) {
|
|
90366
90770
|
const message = error instanceof Error ? error.message : String(error);
|
|
90367
90771
|
throw runtimeError(`file source ${input.sourceName} linked asset is unreadable: ${link.target}: ${message}`, {
|
|
@@ -90389,7 +90793,7 @@ function fileSnapshotLinkedAssetMismatchDiagnostic(input) {
|
|
|
90389
90793
|
for (const file of input.manifest.files) {
|
|
90390
90794
|
let markdown;
|
|
90391
90795
|
try {
|
|
90392
|
-
markdown = readFileSync6(
|
|
90796
|
+
markdown = readFileSync6(join69(input.projectRoot, input.materializedAt, file.path), "utf8");
|
|
90393
90797
|
} catch {
|
|
90394
90798
|
continue;
|
|
90395
90799
|
}
|
|
@@ -96663,7 +97067,7 @@ init_dev4();
|
|
|
96663
97067
|
init_development();
|
|
96664
97068
|
|
|
96665
97069
|
// ../../node_modules/.bun/estree-util-visit@2.0.0/node_modules/estree-util-visit/lib/color.node.js
|
|
96666
|
-
function
|
|
97070
|
+
function color2(d) {
|
|
96667
97071
|
return "\x1B[33m" + d + "\x1B[39m";
|
|
96668
97072
|
}
|
|
96669
97073
|
|
|
@@ -96686,7 +97090,7 @@ function visit2(tree, visitor) {
|
|
|
96686
97090
|
build(tree, undefined, undefined, [])();
|
|
96687
97091
|
function build(node3, key, index2, parents) {
|
|
96688
97092
|
if (nodelike(node3)) {
|
|
96689
|
-
visit3.displayName = "node (" +
|
|
97093
|
+
visit3.displayName = "node (" + color2(node3.type) + ")";
|
|
96690
97094
|
}
|
|
96691
97095
|
return visit3;
|
|
96692
97096
|
function visit3() {
|
|
@@ -98006,8 +98410,8 @@ init_src3();
|
|
|
98006
98410
|
init_cliFeedback();
|
|
98007
98411
|
init_errors3();
|
|
98008
98412
|
init_exitCode();
|
|
98009
|
-
import { readFile as
|
|
98010
|
-
import { dirname as
|
|
98413
|
+
import { readFile as readFile61 } from "node:fs/promises";
|
|
98414
|
+
import { dirname as dirname32, extname as extname10 } from "node:path";
|
|
98011
98415
|
var ROUTE_EVIDENCE_DOCUMENT_PATH = "__context_route_metadata.md";
|
|
98012
98416
|
function countLines(markdown) {
|
|
98013
98417
|
if (markdown.length === 0)
|
|
@@ -98043,7 +98447,7 @@ function parseRouteMetadata(raw, path2) {
|
|
|
98043
98447
|
function normalizeRouteHint(input) {
|
|
98044
98448
|
const { route, metadataSourcePath, metadataSnapshotPath, snapshotPathBySourcePath } = input;
|
|
98045
98449
|
const normalized = route.replace(/^\.\//u, "").replace(/^\/+/u, "");
|
|
98046
|
-
const baseDir =
|
|
98450
|
+
const baseDir = dirname32(metadataSourcePath) === "." ? "" : dirname32(metadataSourcePath);
|
|
98047
98451
|
const documentSourcePath = normalizeSnapshotRelativePath(`${baseDir.length > 0 ? `${baseDir}/` : ""}${normalized}.mdx`);
|
|
98048
98452
|
const documentPath = snapshotPathBySourcePath.get(documentSourcePath) ?? documentSourcePath;
|
|
98049
98453
|
return {
|
|
@@ -98101,7 +98505,7 @@ async function readRouteMetadataFiles(input) {
|
|
|
98101
98505
|
for (const file of input.files) {
|
|
98102
98506
|
let raw;
|
|
98103
98507
|
try {
|
|
98104
|
-
raw = await
|
|
98508
|
+
raw = await readFile61(file.absolutePath, "utf8");
|
|
98105
98509
|
} catch (error) {
|
|
98106
98510
|
const message = error instanceof Error ? error.message : String(error);
|
|
98107
98511
|
throw runtimeError2(`file source ${input.sourceName} metadata read failed: ${file.snapshotPath}: ${message}`, {
|
|
@@ -98153,7 +98557,7 @@ async function readRouteMetadataFiles(input) {
|
|
|
98153
98557
|
|
|
98154
98558
|
// src/project/documentSiteDetection.ts
|
|
98155
98559
|
import { readdir as readdir17, stat as stat8 } from "node:fs/promises";
|
|
98156
|
-
import { basename as basename7, extname as extname11, join as
|
|
98560
|
+
import { basename as basename7, extname as extname11, join as join70, relative as relative21, resolve as resolve22 } from "node:path";
|
|
98157
98561
|
var SKIPPED_DIRS = new Set([
|
|
98158
98562
|
".cache",
|
|
98159
98563
|
".git",
|
|
@@ -98236,7 +98640,7 @@ async function detectDocumentSiteFiles(input) {
|
|
|
98236
98640
|
return;
|
|
98237
98641
|
}
|
|
98238
98642
|
result.scannedEntryCount += 1;
|
|
98239
|
-
const absolutePath =
|
|
98643
|
+
const absolutePath = join70(dir, entry.name);
|
|
98240
98644
|
if (entry.isDirectory()) {
|
|
98241
98645
|
const lower = entry.name.toLowerCase();
|
|
98242
98646
|
if (SKIPPED_DIRS.has(lower))
|
|
@@ -98426,7 +98830,7 @@ async function walkMarkdownFiles(input) {
|
|
|
98426
98830
|
const visit3 = async (dir) => {
|
|
98427
98831
|
const entries2 = await readdir18(dir, { withFileTypes: true });
|
|
98428
98832
|
for (const entry of entries2) {
|
|
98429
|
-
const absolutePath =
|
|
98833
|
+
const absolutePath = join74(dir, entry.name);
|
|
98430
98834
|
if (entry.isDirectory()) {
|
|
98431
98835
|
await visit3(absolutePath);
|
|
98432
98836
|
continue;
|
|
@@ -98448,14 +98852,14 @@ async function walkMarkdownFiles(input) {
|
|
|
98448
98852
|
}
|
|
98449
98853
|
async function writeTextIfChanged(path2, content3) {
|
|
98450
98854
|
try {
|
|
98451
|
-
if (await
|
|
98855
|
+
if (await readFile63(path2, "utf8") === content3)
|
|
98452
98856
|
return;
|
|
98453
98857
|
} catch {}
|
|
98454
|
-
await
|
|
98455
|
-
await
|
|
98858
|
+
await mkdir28(dirname34(path2), { recursive: true });
|
|
98859
|
+
await writeFile23(path2, content3, "utf8");
|
|
98456
98860
|
}
|
|
98457
98861
|
function sourceManifestPath(entry) {
|
|
98458
|
-
return entry.snapshot?.manifest ??
|
|
98862
|
+
return entry.snapshot?.manifest ?? join74(entry.materializedAt, "manifest.json");
|
|
98459
98863
|
}
|
|
98460
98864
|
function runtimeError3(message, detail) {
|
|
98461
98865
|
return new ContextError(ExitCode.UserError, message, {
|
|
@@ -98528,7 +98932,7 @@ async function removeEmptySnapshotDirs(root, dir = root) {
|
|
|
98528
98932
|
for (const entry of entries2) {
|
|
98529
98933
|
if (!entry.isDirectory() || entry.name === ".tmp" || entry.name === ".cache")
|
|
98530
98934
|
continue;
|
|
98531
|
-
await removeEmptySnapshotDirs(root,
|
|
98935
|
+
await removeEmptySnapshotDirs(root, join74(dir, entry.name));
|
|
98532
98936
|
}
|
|
98533
98937
|
if (dir === root)
|
|
98534
98938
|
return;
|
|
@@ -98540,7 +98944,7 @@ async function removeEmptySnapshotDirs(root, dir = root) {
|
|
|
98540
98944
|
async function cleanupStaleSnapshotFiles(input) {
|
|
98541
98945
|
for (const path2 of input.previousPaths) {
|
|
98542
98946
|
if (!input.currentPaths.has(path2)) {
|
|
98543
|
-
await rm17(
|
|
98947
|
+
await rm17(join74(input.materializedAtAbsPath, path2), { force: true });
|
|
98544
98948
|
}
|
|
98545
98949
|
}
|
|
98546
98950
|
await removeEmptySnapshotDirs(input.materializedAtAbsPath);
|
|
@@ -98552,7 +98956,7 @@ async function readDocumentFiles(input) {
|
|
|
98552
98956
|
for (const file of input.files) {
|
|
98553
98957
|
let raw;
|
|
98554
98958
|
try {
|
|
98555
|
-
raw = await
|
|
98959
|
+
raw = await readFile63(file.absolutePath, "utf8");
|
|
98556
98960
|
} catch (error) {
|
|
98557
98961
|
const message = error instanceof Error ? error.message : String(error);
|
|
98558
98962
|
throw runtimeError3(`file source ${input.sourceName} document read failed: ${file.snapshotPath}: ${message}`, {
|
|
@@ -98721,9 +99125,9 @@ async function runCaptureFilePhaseUnlocked(input) {
|
|
|
98721
99125
|
documentSnapshot
|
|
98722
99126
|
});
|
|
98723
99127
|
const manifestPath = sourceManifestPath(entry);
|
|
98724
|
-
const manifestAbsPath =
|
|
99128
|
+
const manifestAbsPath = join74(input.projectRoot, manifestPath);
|
|
98725
99129
|
const materializedAt = entry.materializedAt;
|
|
98726
|
-
const materializedAtAbsPath =
|
|
99130
|
+
const materializedAtAbsPath = join74(input.projectRoot, materializedAt);
|
|
98727
99131
|
const manifestInput = {
|
|
98728
99132
|
sourceType: "file",
|
|
98729
99133
|
sourceName: resolved.sourceName,
|
|
@@ -98773,13 +99177,13 @@ async function runCaptureFilePhaseUnlocked(input) {
|
|
|
98773
99177
|
}));
|
|
98774
99178
|
try {
|
|
98775
99179
|
for (const file of snapshotFiles) {
|
|
98776
|
-
await writeTextIfChanged(
|
|
99180
|
+
await writeTextIfChanged(join74(materializedAtAbsPath, file.path), String(file.bytes));
|
|
98777
99181
|
}
|
|
98778
99182
|
for (const file of files.metadata) {
|
|
98779
|
-
await writeTextIfChanged(
|
|
99183
|
+
await writeTextIfChanged(join74(materializedAtAbsPath, file.snapshotPath), routeMetadata.rawByPath.get(file.snapshotPath) ?? "");
|
|
98780
99184
|
}
|
|
98781
99185
|
for (const asset of linkedAssets) {
|
|
98782
|
-
await writeCaptureAssetIfChanged(
|
|
99186
|
+
await writeCaptureAssetIfChanged(join74(materializedAtAbsPath, asset.snapshotPath), asset.bytes);
|
|
98783
99187
|
}
|
|
98784
99188
|
await writeTextIfChanged(manifestAbsPath, manifestContent);
|
|
98785
99189
|
await cleanupStaleSnapshotFiles({
|
|
@@ -98833,7 +99237,7 @@ async function runCaptureFilePhase(input) {
|
|
|
98833
99237
|
init_src3();
|
|
98834
99238
|
init_larkCaptureReport();
|
|
98835
99239
|
import { readFileSync as readFileSync7 } from "node:fs";
|
|
98836
|
-
import { join as
|
|
99240
|
+
import { join as join75 } from "node:path";
|
|
98837
99241
|
function readDocumentSnapshotCaptureReport(input) {
|
|
98838
99242
|
const summary = input.manifest.metadata?.capture?.report;
|
|
98839
99243
|
if (summary === undefined)
|
|
@@ -98842,7 +99246,7 @@ function readDocumentSnapshotCaptureReport(input) {
|
|
|
98842
99246
|
if (asset === undefined || asset.role !== "audit" || asset.content_hash === undefined) {
|
|
98843
99247
|
throw new TypeError(`snapshot capture report is not registered as a hashed audit asset: ${summary.path}`);
|
|
98844
99248
|
}
|
|
98845
|
-
const bytes = readFileSync7(
|
|
99249
|
+
const bytes = readFileSync7(join75(input.projectRoot, input.materializedAt, summary.path));
|
|
98846
99250
|
if (computeDocumentContentHash(bytes) !== asset.content_hash) {
|
|
98847
99251
|
throw new TypeError(`snapshot capture report hash does not match manifest: ${summary.path}`);
|
|
98848
99252
|
}
|
|
@@ -98913,17 +99317,17 @@ init_cliFeedback();
|
|
|
98913
99317
|
init_errors3();
|
|
98914
99318
|
init_exitCode();
|
|
98915
99319
|
import { existsSync as existsSync21 } from "node:fs";
|
|
98916
|
-
import { lstat as lstat9, mkdir as
|
|
99320
|
+
import { lstat as lstat9, mkdir as mkdir29, readFile as readFile65, readlink, realpath as realpath9, rm as rm18, symlink as symlink3 } from "node:fs/promises";
|
|
98917
99321
|
import { execFile as execFile9 } from "node:child_process";
|
|
98918
99322
|
import { promisify as promisify9 } from "node:util";
|
|
98919
|
-
import { dirname as
|
|
99323
|
+
import { dirname as dirname35, isAbsolute as isAbsolute14, join as join78, relative as relative23, resolve as resolve26 } from "node:path";
|
|
98920
99324
|
|
|
98921
99325
|
// src/project/repoSourceModules.ts
|
|
98922
99326
|
init_src();
|
|
98923
99327
|
init_src3();
|
|
98924
99328
|
import { existsSync as existsSync19 } from "node:fs";
|
|
98925
|
-
import { readFile as
|
|
98926
|
-
import { join as
|
|
99329
|
+
import { readFile as readFile64, readdir as readdir19 } from "node:fs/promises";
|
|
99330
|
+
import { join as join76, resolve as resolve25 } from "node:path";
|
|
98927
99331
|
async function rootNames(root) {
|
|
98928
99332
|
try {
|
|
98929
99333
|
return (await readdir19(root)).sort();
|
|
@@ -98932,11 +99336,11 @@ async function rootNames(root) {
|
|
|
98932
99336
|
}
|
|
98933
99337
|
}
|
|
98934
99338
|
async function packageEntries(root) {
|
|
98935
|
-
const path2 =
|
|
99339
|
+
const path2 = join76(root, "package.json");
|
|
98936
99340
|
if (!existsSync19(path2))
|
|
98937
99341
|
return [];
|
|
98938
99342
|
try {
|
|
98939
|
-
const value = JSON.parse(await
|
|
99343
|
+
const value = JSON.parse(await readFile64(path2, "utf8"));
|
|
98940
99344
|
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") : []);
|
|
98941
99345
|
return [...new Set(entries2.map((entry) => entry.replace(/^\.\//u, "")))].sort();
|
|
98942
99346
|
} catch {
|
|
@@ -98944,9 +99348,9 @@ async function packageEntries(root) {
|
|
|
98944
99348
|
}
|
|
98945
99349
|
}
|
|
98946
99350
|
async function planningEvidence(inspectPath, module) {
|
|
98947
|
-
const root = module.path === "." ? inspectPath :
|
|
99351
|
+
const root = module.path === "." ? inspectPath : join76(inspectPath, module.path);
|
|
98948
99352
|
const names = await rootNames(root);
|
|
98949
|
-
const commonEntries = ["src/index.ts", "src/index.tsx", "src/main.ts", "src/main.tsx", "main.go"].filter((path2) => existsSync19(
|
|
99353
|
+
const commonEntries = ["src/index.ts", "src/index.tsx", "src/main.ts", "src/main.tsx", "main.go"].filter((path2) => existsSync19(join76(root, path2)));
|
|
98950
99354
|
const protocolNames = names.filter((name3) => /(?:openapi|swagger|schema|protocol|idl)/iu.test(name3) || /\.(?:proto|thrift)$/iu.test(name3));
|
|
98951
99355
|
const lifecycleNames = names.filter((name3) => /(?:generated|vendor|mirror|legacy|sync)/iu.test(name3));
|
|
98952
99356
|
return {
|
|
@@ -98984,7 +99388,7 @@ function suggestedModuleName(module) {
|
|
|
98984
99388
|
return slug || "module";
|
|
98985
99389
|
}
|
|
98986
99390
|
async function inspectRepoSourceModules(input) {
|
|
98987
|
-
const inspectPath = input.scopedAbs !== null && existsSync19(input.scopedAbs) ? input.scopedAbs :
|
|
99391
|
+
const inspectPath = input.scopedAbs !== null && existsSync19(input.scopedAbs) ? input.scopedAbs : join76(input.projectRoot, input.status.materializedAt);
|
|
98988
99392
|
const modules = existsSync19(inspectPath) ? await detectModuleBoundaries(inspectPath, input.status.head ?? input.status.ref, DEFAULT_PATH_FILTER) : [];
|
|
98989
99393
|
const recommended_sources = modules.filter((module) => module.path !== "." || modules.length === 1).map((module) => {
|
|
98990
99394
|
const local = sourceModuleLocalForDisplay({ source: input.source, status: input.status, module });
|
|
@@ -99026,7 +99430,7 @@ init_exitCode();
|
|
|
99026
99430
|
init_atomicWrite();
|
|
99027
99431
|
var import_yaml37 = __toESM(require_dist(), 1);
|
|
99028
99432
|
import { existsSync as existsSync20 } from "node:fs";
|
|
99029
|
-
import { join as
|
|
99433
|
+
import { join as join77 } from "node:path";
|
|
99030
99434
|
var SOURCE_NAME_PATTERN2 = /^[a-z0-9][a-z0-9._-]*$/u;
|
|
99031
99435
|
var REPO_DATE_NAMESPACE_PATTERN2 = /^\d{8}$/u;
|
|
99032
99436
|
function assertRepoModuleName(name3) {
|
|
@@ -99079,7 +99483,7 @@ function registryEntryToRecord(entry) {
|
|
|
99079
99483
|
};
|
|
99080
99484
|
}
|
|
99081
99485
|
function registryPath(projectRoot) {
|
|
99082
|
-
return
|
|
99486
|
+
return join77(projectRoot, DEFAULT_REPO_SOURCES_REGISTRY_PATH);
|
|
99083
99487
|
}
|
|
99084
99488
|
function defaultRepoMaterializedAt(source2) {
|
|
99085
99489
|
return `sources/repo/${source2.namespace}/${source2.module}`;
|
|
@@ -99156,7 +99560,7 @@ async function localPathForRegistry(input) {
|
|
|
99156
99560
|
async function inferNamedLocalPath(projectRoot, module) {
|
|
99157
99561
|
const candidates = [
|
|
99158
99562
|
resolve26(projectRoot, module),
|
|
99159
|
-
resolve26(
|
|
99563
|
+
resolve26(dirname35(projectRoot), module)
|
|
99160
99564
|
];
|
|
99161
99565
|
const matches = new Map;
|
|
99162
99566
|
for (const candidate of candidates) {
|
|
@@ -99181,13 +99585,13 @@ async function gitOutput(cwd, args) {
|
|
|
99181
99585
|
}
|
|
99182
99586
|
}
|
|
99183
99587
|
async function readGitOriginRemote(cwd) {
|
|
99184
|
-
const directConfigPath =
|
|
99185
|
-
let config = await
|
|
99588
|
+
const directConfigPath = join78(cwd, ".git", "config");
|
|
99589
|
+
let config = await readFile65(directConfigPath, "utf8").catch(() => "");
|
|
99186
99590
|
if (config.length === 0) {
|
|
99187
99591
|
const gitDir = await resolveGitDir(cwd);
|
|
99188
99592
|
if (gitDir === null)
|
|
99189
99593
|
return null;
|
|
99190
|
-
config = await
|
|
99594
|
+
config = await readFile65(join78(gitDir, "config"), "utf8").catch(() => "");
|
|
99191
99595
|
}
|
|
99192
99596
|
let inOriginBlock = false;
|
|
99193
99597
|
for (const line of config.split(/\r?\n/u)) {
|
|
@@ -99207,16 +99611,16 @@ async function readGitOriginRemote(cwd) {
|
|
|
99207
99611
|
async function resolveGitRoot(cwd) {
|
|
99208
99612
|
let current2 = resolve26(cwd);
|
|
99209
99613
|
while (true) {
|
|
99210
|
-
if (existsSync21(
|
|
99614
|
+
if (existsSync21(join78(current2, ".git")))
|
|
99211
99615
|
return current2;
|
|
99212
|
-
const parent =
|
|
99616
|
+
const parent = dirname35(current2);
|
|
99213
99617
|
if (parent === current2)
|
|
99214
99618
|
return null;
|
|
99215
99619
|
current2 = parent;
|
|
99216
99620
|
}
|
|
99217
99621
|
}
|
|
99218
99622
|
async function resolveGitDir(cwd) {
|
|
99219
|
-
const dotGit =
|
|
99623
|
+
const dotGit = join78(cwd, ".git");
|
|
99220
99624
|
if (!existsSync21(dotGit))
|
|
99221
99625
|
return null;
|
|
99222
99626
|
const stats = await lstat9(dotGit);
|
|
@@ -99224,7 +99628,7 @@ async function resolveGitDir(cwd) {
|
|
|
99224
99628
|
return dotGit;
|
|
99225
99629
|
if (!stats.isFile())
|
|
99226
99630
|
return null;
|
|
99227
|
-
const raw = await
|
|
99631
|
+
const raw = await readFile65(dotGit, "utf8").catch(() => "");
|
|
99228
99632
|
const match = /^gitdir:\s*(.+)\s*$/iu.exec(raw.trim());
|
|
99229
99633
|
if (match?.[1] === undefined)
|
|
99230
99634
|
return null;
|
|
@@ -99234,17 +99638,17 @@ async function readGitHead(cwd) {
|
|
|
99234
99638
|
const gitDir = await resolveGitDir(cwd);
|
|
99235
99639
|
if (gitDir === null)
|
|
99236
99640
|
return null;
|
|
99237
|
-
const headRaw = (await
|
|
99641
|
+
const headRaw = (await readFile65(join78(gitDir, "HEAD"), "utf8").catch(() => "")).trim();
|
|
99238
99642
|
if (/^[a-f0-9]{40}$/iu.test(headRaw))
|
|
99239
99643
|
return headRaw.toLowerCase();
|
|
99240
99644
|
const match = /^ref:\s*(.+)\s*$/iu.exec(headRaw);
|
|
99241
99645
|
const refPath = match?.[1];
|
|
99242
99646
|
if (refPath === undefined)
|
|
99243
99647
|
return null;
|
|
99244
|
-
const looseRef = (await
|
|
99648
|
+
const looseRef = (await readFile65(join78(gitDir, refPath), "utf8").catch(() => "")).trim();
|
|
99245
99649
|
if (/^[a-f0-9]{40}$/iu.test(looseRef))
|
|
99246
99650
|
return looseRef.toLowerCase();
|
|
99247
|
-
const packedRefs = await
|
|
99651
|
+
const packedRefs = await readFile65(join78(gitDir, "packed-refs"), "utf8").catch(() => "");
|
|
99248
99652
|
for (const line of packedRefs.split(/\r?\n/u)) {
|
|
99249
99653
|
if (line.startsWith("#") || line.startsWith("^"))
|
|
99250
99654
|
continue;
|
|
@@ -99255,8 +99659,8 @@ async function readGitHead(cwd) {
|
|
|
99255
99659
|
return null;
|
|
99256
99660
|
}
|
|
99257
99661
|
async function ensureMaterializedSymlink(input) {
|
|
99258
|
-
const linkPath =
|
|
99259
|
-
await
|
|
99662
|
+
const linkPath = join78(input.projectRoot, input.materializedAt);
|
|
99663
|
+
await mkdir29(dirname35(linkPath), { recursive: true });
|
|
99260
99664
|
if (existsSync21(linkPath)) {
|
|
99261
99665
|
const stats = await lstat9(linkPath);
|
|
99262
99666
|
if (!stats.isSymbolicLink()) {
|
|
@@ -99264,17 +99668,17 @@ async function ensureMaterializedSymlink(input) {
|
|
|
99264
99668
|
return false;
|
|
99265
99669
|
}
|
|
99266
99670
|
const current2 = await readlink(linkPath);
|
|
99267
|
-
const currentAbs = resolve26(
|
|
99671
|
+
const currentAbs = resolve26(dirname35(linkPath), current2);
|
|
99268
99672
|
if (currentAbs === input.localAbs)
|
|
99269
99673
|
return true;
|
|
99270
99674
|
await rm18(linkPath);
|
|
99271
99675
|
}
|
|
99272
|
-
const relTarget = relative23(
|
|
99676
|
+
const relTarget = relative23(dirname35(linkPath), input.localAbs) || ".";
|
|
99273
99677
|
await symlink3(relTarget, linkPath);
|
|
99274
99678
|
return true;
|
|
99275
99679
|
}
|
|
99276
99680
|
async function diagnoseMaterializedSymlink(input) {
|
|
99277
|
-
const linkPath =
|
|
99681
|
+
const linkPath = join78(input.projectRoot, input.materializedAt);
|
|
99278
99682
|
if (!existsSync21(linkPath)) {
|
|
99279
99683
|
input.diagnostics.push(`materialized path is missing: ${input.materializedAt}`);
|
|
99280
99684
|
input.agent_hints.push(`Run context source ensure ${input.sourceName} to materialize the local source link.`);
|
|
@@ -99286,9 +99690,9 @@ async function diagnoseMaterializedSymlink(input) {
|
|
|
99286
99690
|
return false;
|
|
99287
99691
|
}
|
|
99288
99692
|
const current2 = await readlink(linkPath);
|
|
99289
|
-
const currentAbs = resolve26(
|
|
99693
|
+
const currentAbs = resolve26(dirname35(linkPath), current2);
|
|
99290
99694
|
if (currentAbs !== input.localAbs) {
|
|
99291
|
-
input.diagnostics.push(`materialized path points to ${current2}, expected local checkout ${relative23(
|
|
99695
|
+
input.diagnostics.push(`materialized path points to ${current2}, expected local checkout ${relative23(dirname35(linkPath), input.localAbs) || "."}`);
|
|
99292
99696
|
input.agent_hints.push(`Run context source ensure ${input.sourceName} to refresh the local source link.`);
|
|
99293
99697
|
return false;
|
|
99294
99698
|
}
|
|
@@ -99497,7 +99901,7 @@ async function inspectRepoSource(input) {
|
|
|
99497
99901
|
const subpath = normalizeSubpath2(source2.subpath);
|
|
99498
99902
|
const scopedAbs = localAbs === null ? null : scopedLocalPath(localAbs, subpath);
|
|
99499
99903
|
const scopeExists = scopedAbs !== null && existsSync21(scopedAbs);
|
|
99500
|
-
let materialized = existsSync21(
|
|
99904
|
+
let materialized = existsSync21(join78(input.projectRoot, materializedAt));
|
|
99501
99905
|
const checkout = await inspectRepoCheckout({
|
|
99502
99906
|
source: source2,
|
|
99503
99907
|
localAbs,
|
|
@@ -99666,8 +100070,8 @@ init_approvedKnowledgeMetadata();
|
|
|
99666
100070
|
init_knowledgeAssets();
|
|
99667
100071
|
var import_yaml38 = __toESM(require_dist(), 1);
|
|
99668
100072
|
import { createHash as createHash22 } from "node:crypto";
|
|
99669
|
-
import { mkdir as
|
|
99670
|
-
import { dirname as
|
|
100073
|
+
import { mkdir as mkdir30, writeFile as writeFile24 } from "node:fs/promises";
|
|
100074
|
+
import { dirname as dirname36, join as join79 } from "node:path";
|
|
99671
100075
|
|
|
99672
100076
|
// src/project/entityId.ts
|
|
99673
100077
|
init_cliFeedback();
|
|
@@ -99686,7 +100090,7 @@ function assertSafeEntityId(id3) {
|
|
|
99686
100090
|
}
|
|
99687
100091
|
|
|
99688
100092
|
// src/project/reviewShared.ts
|
|
99689
|
-
var REVIEW_ACTION_ROOT2 =
|
|
100093
|
+
var REVIEW_ACTION_ROOT2 = join79(".tmp", "context-runtime", "review-actions");
|
|
99690
100094
|
var REVIEW_PAYLOAD_SCHEMA = "context.review.decisions.v1";
|
|
99691
100095
|
function isRecord14(value) {
|
|
99692
100096
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -99730,7 +100134,7 @@ async function buildApprovedArticleIndex(projectRoot) {
|
|
|
99730
100134
|
if (!isApprovedKnowledgeMarkdownPath(rel))
|
|
99731
100135
|
continue;
|
|
99732
100136
|
const { absPath, content: content3 } = file;
|
|
99733
|
-
const relPath =
|
|
100137
|
+
const relPath = join79("knowledge", collection, rel);
|
|
99734
100138
|
assetReferencesByRelPath.set(relPath, knowledgeAssetReferences({
|
|
99735
100139
|
pageRelPath: relPath,
|
|
99736
100140
|
content: content3
|
|
@@ -99743,7 +100147,7 @@ async function buildApprovedArticleIndex(projectRoot) {
|
|
|
99743
100147
|
continue;
|
|
99744
100148
|
const frontmatter2 = hydrateApprovedFrontmatter({
|
|
99745
100149
|
frontmatter: parsed,
|
|
99746
|
-
relPath:
|
|
100150
|
+
relPath: join79(collection, rel),
|
|
99747
100151
|
metadata
|
|
99748
100152
|
});
|
|
99749
100153
|
const article = articlesByPath.get(`${collection}/${rel}`);
|
|
@@ -99798,10 +100202,10 @@ ${yaml3}
|
|
|
99798
100202
|
}
|
|
99799
100203
|
async function writeReviewActionLog(input) {
|
|
99800
100204
|
const stamp = new Date().toISOString().replace(/[-:.TZ]/gu, "");
|
|
99801
|
-
const relPath =
|
|
99802
|
-
const path2 =
|
|
99803
|
-
await
|
|
99804
|
-
await
|
|
100205
|
+
const relPath = join79(REVIEW_ACTION_ROOT2, `${stamp}-${input.action}-${input.id.replace(/[\\/]+/gu, "_")}.json`);
|
|
100206
|
+
const path2 = join79(input.projectRoot, relPath);
|
|
100207
|
+
await mkdir30(dirname36(path2), { recursive: true });
|
|
100208
|
+
await writeFile24(path2, `${JSON.stringify({
|
|
99805
100209
|
action: input.action,
|
|
99806
100210
|
id: input.id,
|
|
99807
100211
|
...input.summary
|
|
@@ -99832,7 +100236,7 @@ async function countFiles(root, predicate) {
|
|
|
99832
100236
|
const entries2 = await readCommandDirectory(dir);
|
|
99833
100237
|
for (const entry of entries2) {
|
|
99834
100238
|
const rel = prefix.length === 0 ? entry.name : `${prefix}/${entry.name}`;
|
|
99835
|
-
const abs =
|
|
100239
|
+
const abs = join80(dir, entry.name);
|
|
99836
100240
|
if (entry.isDirectory())
|
|
99837
100241
|
await visit3(abs, rel);
|
|
99838
100242
|
else if (entry.isFile() && predicate(rel))
|
|
@@ -100023,7 +100427,7 @@ async function documentSourceSiteHint(input) {
|
|
|
100023
100427
|
});
|
|
100024
100428
|
}
|
|
100025
100429
|
function documentSnapshotReadiness(input) {
|
|
100026
|
-
const manifestPath =
|
|
100430
|
+
const manifestPath = join80(input.projectRoot, input.manifest);
|
|
100027
100431
|
if (!existsSync22(manifestPath)) {
|
|
100028
100432
|
return {
|
|
100029
100433
|
ready: false,
|
|
@@ -100093,7 +100497,7 @@ function documentSnapshotReadiness(input) {
|
|
|
100093
100497
|
const missingFiles = [
|
|
100094
100498
|
...manifest.files.map((file) => file.path),
|
|
100095
100499
|
...(manifest.assets ?? []).filter((asset) => asset.content_hash !== undefined).map((asset) => asset.path)
|
|
100096
|
-
].filter((path2) => !existsSync22(
|
|
100500
|
+
].filter((path2) => !existsSync22(join80(input.projectRoot, input.materializedAt, path2)));
|
|
100097
100501
|
if (missingFiles.length > 0) {
|
|
100098
100502
|
return {
|
|
100099
100503
|
ready: false,
|
|
@@ -100559,7 +100963,7 @@ async function collectProjectStatusSnapshotInternal(projectRoot, options = {}) {
|
|
|
100559
100963
|
const authoring = production && !production.delivery && (dispatchProductionStage(production, productionCapabilitiesSchema.parse({})).state !== "ended" || draftStatus.count > 0 && draftStatus.diagnostics.length === 0);
|
|
100560
100964
|
const deferDeliveryChecks = !maintenance && !localRevision && !localUpdate && !localRollback && (taskPreparation === "cleared" && !production || !!authoring);
|
|
100561
100965
|
const collectionsWithPages = new Set;
|
|
100562
|
-
const approvedPages = await countFiles(
|
|
100966
|
+
const approvedPages = await countFiles(join84(projectRoot, "knowledge"), (rel) => {
|
|
100563
100967
|
if (!isApprovedKnowledgeMarkdownPath(rel) || rel.startsWith("assets/"))
|
|
100564
100968
|
return false;
|
|
100565
100969
|
collectionsWithPages.add(rel.split("/")[0]);
|
|
@@ -100567,7 +100971,7 @@ async function collectProjectStatusSnapshotInternal(projectRoot, options = {}) {
|
|
|
100567
100971
|
});
|
|
100568
100972
|
const approvedCollections = KNOWLEDGE_COLLECTIONS.filter((collection) => collectionsWithPages.has(collection));
|
|
100569
100973
|
const closeStatus = deferDeliveryChecks ? { state: "not-checked", diagnostics: [] } : await readCloseStatus(projectRoot);
|
|
100570
|
-
const distFiles = await countFiles(
|
|
100974
|
+
const distFiles = await countFiles(join84(projectRoot, "dist"), () => true);
|
|
100571
100975
|
const verifyStatus = !deferDeliveryChecks && draftStatus.diagnostics.length === 0 ? await readVerifyStatus(projectRoot) : { issues: [], diagnostics: [] };
|
|
100572
100976
|
const pendingCapture = pendingDocumentCaptureCommands({
|
|
100573
100977
|
phases,
|
|
@@ -100936,14 +101340,14 @@ function bindWorkflowExecutionContext(result, context) {
|
|
|
100936
101340
|
// src/project/workflow/workflowRouteOutput.ts
|
|
100937
101341
|
init_atomicWrite();
|
|
100938
101342
|
import { createHash as createHash23 } from "node:crypto";
|
|
100939
|
-
import { join as
|
|
101343
|
+
import { join as join85 } from "node:path";
|
|
100940
101344
|
async function workflowRouteOutput(projectRoot, route) {
|
|
100941
101345
|
if (!route)
|
|
100942
101346
|
return null;
|
|
100943
101347
|
const body = `${JSON.stringify(route, null, 2)}
|
|
100944
101348
|
`;
|
|
100945
101349
|
const digest6 = createHash23("sha256").update(body).digest("hex");
|
|
100946
|
-
const file =
|
|
101350
|
+
const file = join85(projectRoot, ".tmp/context-runtime/routes", `${digest6}.json`);
|
|
100947
101351
|
await atomicWriteFile(file, body);
|
|
100948
101352
|
return {
|
|
100949
101353
|
file,
|
|
@@ -100959,7 +101363,7 @@ async function workflowRunResultFile(projectRoot, result) {
|
|
|
100959
101363
|
const body = `${JSON.stringify(result, null, 2)}
|
|
100960
101364
|
`;
|
|
100961
101365
|
const digest6 = createHash23("sha256").update(body).digest("hex");
|
|
100962
|
-
const file =
|
|
101366
|
+
const file = join85(projectRoot, ".tmp/context-runtime/action-results", `${digest6}.run.json`);
|
|
100963
101367
|
await atomicWriteFile(file, body);
|
|
100964
101368
|
return file;
|
|
100965
101369
|
}
|
|
@@ -101100,16 +101504,18 @@ init_workflowTypes();
|
|
|
101100
101504
|
|
|
101101
101505
|
// src/project/reviewHtml.ts
|
|
101102
101506
|
init_candidateLedger();
|
|
101103
|
-
import { mkdir as
|
|
101104
|
-
import {
|
|
101507
|
+
import { mkdir as mkdir31, readFile as readFile70, writeFile as writeFile25 } from "node:fs/promises";
|
|
101508
|
+
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
101509
|
+
import { dirname as dirname38, isAbsolute as isAbsolute15, join as join88, resolve as resolve28 } from "node:path";
|
|
101105
101510
|
|
|
101106
101511
|
// src/project/reviewSiteModel.ts
|
|
101512
|
+
init_siteTheme2();
|
|
101107
101513
|
init_src2();
|
|
101108
101514
|
init_unified();
|
|
101109
101515
|
init_remark_parse();
|
|
101110
101516
|
var import_yaml40 = __toESM(require_dist(), 1);
|
|
101111
|
-
import { readFile as
|
|
101112
|
-
import { join as
|
|
101517
|
+
import { readFile as readFile69 } from "node:fs/promises";
|
|
101518
|
+
import { join as join87 } from "node:path";
|
|
101113
101519
|
import { execFile as execFile10 } from "node:child_process";
|
|
101114
101520
|
import { promisify as promisify10 } from "node:util";
|
|
101115
101521
|
import { createHash as createHash24 } from "node:crypto";
|
|
@@ -101190,7 +101596,7 @@ function looksLikeANode(value) {
|
|
|
101190
101596
|
return value !== null && typeof value === "object" && "type" in value;
|
|
101191
101597
|
}
|
|
101192
101598
|
// ../../node_modules/.bun/unist-util-visit-parents@6.0.2/node_modules/unist-util-visit-parents/lib/color.node.js
|
|
101193
|
-
function
|
|
101599
|
+
function color3(d) {
|
|
101194
101600
|
return "\x1B[33m" + d + "\x1B[39m";
|
|
101195
101601
|
}
|
|
101196
101602
|
|
|
@@ -101215,7 +101621,7 @@ function visitParents(tree, test, visitor, reverse) {
|
|
|
101215
101621
|
if (typeof value.type === "string") {
|
|
101216
101622
|
const name3 = typeof value.tagName === "string" ? value.tagName : typeof value.name === "string" ? value.name : undefined;
|
|
101217
101623
|
Object.defineProperty(visit3, "name", {
|
|
101218
|
-
value: "node (" +
|
|
101624
|
+
value: "node (" + color3(node3.type + (name3 ? "<" + name3 + ">" : "")) + ")"
|
|
101219
101625
|
});
|
|
101220
101626
|
}
|
|
101221
101627
|
return visit3;
|
|
@@ -104074,10 +104480,10 @@ function remarkGfm(options) {
|
|
|
104074
104480
|
init_workspace();
|
|
104075
104481
|
|
|
104076
104482
|
// src/project/reviewFeedback.ts
|
|
104077
|
-
import { readdir as readdir20, readFile as
|
|
104078
|
-
import { join as
|
|
104483
|
+
import { readdir as readdir20, readFile as readFile68 } from "node:fs/promises";
|
|
104484
|
+
import { join as join86 } from "node:path";
|
|
104079
104485
|
async function readPendingReviewFeedback(root2, candidates) {
|
|
104080
|
-
const directory =
|
|
104486
|
+
const directory = join86(root2, ".tmp/context-runtime/review-feedback");
|
|
104081
104487
|
let files;
|
|
104082
104488
|
try {
|
|
104083
104489
|
files = await readdir20(directory);
|
|
@@ -104090,7 +104496,7 @@ async function readPendingReviewFeedback(root2, candidates) {
|
|
|
104090
104496
|
const results = new Map;
|
|
104091
104497
|
const receipts = [];
|
|
104092
104498
|
for (const file of files.filter((f) => /^[a-f0-9]+\.json$/u.test(f)).sort()) {
|
|
104093
|
-
const receipt2 = JSON.parse(await
|
|
104499
|
+
const receipt2 = JSON.parse(await readFile68(join86(directory, file), "utf8"));
|
|
104094
104500
|
receipts.push(receipt2);
|
|
104095
104501
|
}
|
|
104096
104502
|
for (const receipt2 of receipts.sort((a, b) => a.created_at.localeCompare(b.created_at))) {
|
|
@@ -104156,7 +104562,7 @@ function renderReviewMarkdown(markdown, pageTitle) {
|
|
|
104156
104562
|
case "inlineCode":
|
|
104157
104563
|
return `<code>${value}</code>`;
|
|
104158
104564
|
case "code":
|
|
104159
|
-
return `<pre><code>${value}</code></pre>`;
|
|
104565
|
+
return node3.lang === "mermaid" ? `<div class="language-mermaid"><pre><code>${value}</code></pre></div>` : `<pre><code>${value}</code></pre>`;
|
|
104160
104566
|
case "blockquote":
|
|
104161
104567
|
return `<blockquote>${children()}</blockquote>`;
|
|
104162
104568
|
case "list":
|
|
@@ -104200,7 +104606,7 @@ var title = (s, fallback) => {
|
|
|
104200
104606
|
};
|
|
104201
104607
|
async function optional2(path3) {
|
|
104202
104608
|
try {
|
|
104203
|
-
return await
|
|
104609
|
+
return await readFile69(path3, "utf8");
|
|
104204
104610
|
} catch (e) {
|
|
104205
104611
|
if (e.code === "ENOENT")
|
|
104206
104612
|
return;
|
|
@@ -104210,7 +104616,7 @@ async function optional2(path3) {
|
|
|
104210
104616
|
async function reviewSiteBaselineHash(root2, reviewedPaths) {
|
|
104211
104617
|
const files = await readApprovedMarkdownFiles(root2);
|
|
104212
104618
|
return hash3(JSON.stringify([
|
|
104213
|
-
await optional2(
|
|
104619
|
+
await optional2(join87(root2, "src/knowledge-map.yaml")) ?? null,
|
|
104214
104620
|
files.map((f) => [f.relPath, reviewedPaths.includes(f.relPath) ? hash3(f.content) : title(f.content, f.relPath)]).sort((a, b) => a[0].localeCompare(b[0]))
|
|
104215
104621
|
]));
|
|
104216
104622
|
}
|
|
@@ -104323,11 +104729,13 @@ async function collectReviewSiteModel(root2, candidates) {
|
|
|
104323
104729
|
for (const [i2, p] of unplaced.entries())
|
|
104324
104730
|
nodes.push({ key: `review-page-${p.id}`, parent: "review-unplaced", title: p.title, order: i2, page: p.id, change: p.change });
|
|
104325
104731
|
}
|
|
104326
|
-
const pkgText = await optional2(
|
|
104732
|
+
const pkgText = await optional2(join87(root2, "package.json"));
|
|
104327
104733
|
const pkg = pkgText ? JSON.parse(pkgText) : {};
|
|
104328
|
-
const project = await optional2(
|
|
104734
|
+
const project = await optional2(join87(root2, "src/index.ts")) === undefined ? undefined : await loadContextProjectModule(root2);
|
|
104329
104735
|
const siteTitle = project?.project.packages.flatMap((p) => p.kind === "package.kb" && p.site?.title ? [p.site.title] : [])[0];
|
|
104330
|
-
|
|
104736
|
+
const sitePackages = project?.project.packages.flatMap((p) => p.kind === "package.kb" && p.site ? [p.site] : []) ?? [];
|
|
104737
|
+
const themeCss = siteThemeVariables(await resolveSiteTheme(root2, sitePackages.length === 1 ? sitePackages[0]?.theme : undefined));
|
|
104738
|
+
return { themeCss, title: siteTitle ?? pkg.name ?? "Knowledge review", baselineHash: await reviewSiteBaselineHash(root2, candidates.map((c) => c.record.approved_revision?.previous_path ?? c.record.path)), nodes, pages, navigationBaseline };
|
|
104331
104739
|
}
|
|
104332
104740
|
var reviewHtmlJson = (value) => JSON.stringify(value).replace(/</gu, "\\u003c").replace(/\u2028/gu, "\\u2028").replace(/\u2029/gu, "\\u2029");
|
|
104333
104741
|
|
|
@@ -104442,7 +104850,7 @@ function localizeBody(){document.querySelectorAll('[data-label]').forEach(el=>{e
|
|
|
104442
104850
|
function workspaceTree(){const tree={};for(const p of candidates){let node=tree;for(const part of ('knowledge/'+p.path).split('/'))node=node[part]??=( {} );node.$page=p}function lines(node,level=0){return Object.entries(node).filter(([k])=>k!=='$page').sort(([a],[b])=>a.localeCompare(b)).map(([k,v])=>'<div style="padding-left:'+level*18+'px">'+(v.$page?'<button data-page="'+escape(v.$page.id)+'">'+escape(k)+'</button>'+badge(v.$page.change)+(state(v.$page)!=='pending'?badge(state(v.$page)):''):escape(k)+'/')+'</div>'+lines(v,level+1)).join('')}return '<div class="workspace-tree">'+lines(tree)+'</div>'}
|
|
104443
104851
|
function renderHome(){const c=totals();$('article').innerHTML='<h1>'+t('home')+'</h1><p class="stats">'+candidates.length+' '+(language==='zh'?'篇候选正文':'candidate pages')+' · '+c.approved+' '+t('approved')+' '+badge('new')+' '+badge('modify')+'</p>'+(DATA.navigationBaseline==='current'?'<p class="note">'+t('baseline')+'</p>':'')+(DATA.nodes.some(n=>n.key==='review-unplaced')?'<p class="note">'+t('placement')+'</p>':'')+'<h2>'+t('navigate')+'</h2>'+DATA.nodes.filter(n=>!n.parent).map(n=>{const ids=new Set([n,...descendants(n.key)].map(x=>x.page));const pages=candidates.filter(p=>ids.has(p.id));return pages.length?'<section class="home-group"><h3>'+nodeLabel(n)+badge(nodeChange(n))+'</h3><div class="cards">'+pages.map(p=>'<button data-page="'+escape(p.id)+'">'+escape(p.title)+badge(p.change)+(state(p)!=='pending'?badge(state(p)):'')+'</button>').join('')+'</div></section>':''}).join('')+'<h2>'+t('files')+'</h2>'+workspaceTree()}
|
|
104444
104852
|
function controls(){const p=DATA.pages.find(p=>p.id===selected),s=p?state(p):'pending';$('footer').hidden=!p?.candidate_id;if(!p?.candidate_id)return;$('revision-note').value=notes.get(p.candidate_id)||'';$('revision-note').placeholder=t('note');$('revision-note').disabled=s==='approved'||s==='rejected';for(const [id,v,label]of[['revise-btn','revised','revise'],['reject-btn','rejected','reject'],['approve-btn','approved','approve']]){const b=$(id);b.disabled=s!=='pending'&&s!==v;b.className='btn '+(s===v?'chosen':v==='approved'?'primary':'');b.innerHTML=s===v?'<span class="normal">'+t(v)+'</span><span class="hover-label">'+t('cancel')+'</span>':t(label);b.title=s===v?t('cancel'):''}}
|
|
104445
|
-
function render(){document.body.classList.toggle('home',selected===null);renderNav();updateCounts();if(selected===null)renderHome();else{const p=DATA.pages.find(p=>p.id===selected);$('article').innerHTML=p?'<h1>'+escape(p.title)+badge(p.change)+(p.candidate_id&&state(p)!=='pending'?badge(state(p)):'')+'</h1>'+(p.previousPath?'<p class="note">'+escape(p.previousPath)+' → '+escape(p.path)+'</p>':'')+(p.candidate_id?p.html:'<div class="unchanged">'+t('unchanged')+'</div>')+(p.sources.length?'<details><summary>'+(language==='zh'?'来源引用':'Sources')+'</summary><ul>'+p.sources.map(s=>'<li>'+escape(s)+'</li>').join('')+'</ul></details>':''):''}controls();localizeBody()}
|
|
104853
|
+
function render(){document.body.classList.toggle('home',selected===null);renderNav();updateCounts();if(selected===null)renderHome();else{const p=DATA.pages.find(p=>p.id===selected);$('article').innerHTML=p?'<h1>'+escape(p.title)+badge(p.change)+(p.candidate_id&&state(p)!=='pending'?badge(state(p)):'')+'</h1>'+(p.previousPath?'<p class="note">'+escape(p.previousPath)+' → '+escape(p.path)+'</p>':'')+(p.candidate_id?p.html:'<div class="unchanged">'+t('unchanged')+'</div>')+(p.sources.length?'<details><summary>'+(language==='zh'?'来源引用':'Sources')+'</summary><ul>'+p.sources.map(s=>'<li>'+escape(s)+'</li>').join('')+'</ul></details>':''):''}controls();localizeBody();globalThis.contextDiagramViewer?.render($('article'),{dark:document.body.classList.contains('dark'),language})}
|
|
104446
104854
|
function setDecision(id,value){const current=decisions.get(id);if(current===value){decisions.delete(id);notes.delete(id)}else if(!current){if(value==='revised'){$('revision-note').focus();return}decisions.set(id,value)}render()}
|
|
104447
104855
|
function setAllDecision(value){for(const p of candidates)if(!decisions.has(p.candidate_id))decisions.set(p.candidate_id,value);render()}
|
|
104448
104856
|
function payloadText(){const statuses=ordered.map(p=>state(p));return feedbackCodec.encode({scope:SCOPE.label,idsHash:SCOPE.ids_sha256,contentHash:SCOPE.candidates_sha256,baselineHash:DATA.baselineHash,statuses,repairs:ordered.flatMap((p,index)=>state(p)==='revised'?[{index,instruction:notes.get(p.candidate_id)}]:[])})}
|
|
@@ -104459,17 +104867,19 @@ function updateBulkConfirmation(){const remaining=addedRoots.length?Math.max(0,M
|
|
|
104459
104867
|
function openBulkConfirmation(){clearInterval(bulkTimer);$('bulk-ack').checked=false;$('bulk-roots').hidden=!addedRoots.length;$('bulk-roots-title').textContent=t('newRoots');$('bulk-roots-list').innerHTML=addedRoots.map(n=>'<li>'+escape(nodeTitle(n))+'</li>').join('');$('bulk-ack-label').textContent=t('ackRoots');bulkDeadline=Date.now()+8000;updateBulkConfirmation();$('bulk-dialog').showModal();if(addedRoots.length)bulkTimer=setInterval(()=>{if(!updateBulkConfirmation())clearInterval(bulkTimer)},200)}
|
|
104460
104868
|
$('bulk-ack').onchange=updateBulkConfirmation;
|
|
104461
104869
|
$('bulk-dialog').onclose=()=>clearInterval(bulkTimer);
|
|
104462
|
-
$('all-approved').onclick=openBulkConfirmation;$('bulk-confirm').onclick=()=>{updateBulkConfirmation();if(!$('bulk-dialog').open||$('bulk-confirm').disabled)return;setAllDecision('approved');clearInterval(bulkTimer);$('bulk-dialog').close()};$('bulk-cancel').onclick=()=>{clearInterval(bulkTimer);$('bulk-dialog').close()};$('all-rejected').onclick=()=>setAllDecision('rejected');$('payload-open').onclick=copyPayload;$('payload-close').onclick=()=>$('copy-dialog').close();$('guide-close').onclick=dismissGuide;$('theme').onclick=()=>document.body.classList.toggle('dark');$('language').onclick=()=>{language=language==='zh'?'en':'zh';labels();render()};
|
|
104870
|
+
$('all-approved').onclick=openBulkConfirmation;$('bulk-confirm').onclick=()=>{updateBulkConfirmation();if(!$('bulk-dialog').open||$('bulk-confirm').disabled)return;setAllDecision('approved');clearInterval(bulkTimer);$('bulk-dialog').close()};$('bulk-cancel').onclick=()=>{clearInterval(bulkTimer);$('bulk-dialog').close()};$('all-rejected').onclick=()=>setAllDecision('rejected');$('payload-open').onclick=copyPayload;$('payload-close').onclick=()=>$('copy-dialog').close();$('guide-close').onclick=dismissGuide;$('theme').onclick=()=>{document.body.classList.toggle('dark');globalThis.contextDiagramViewer?.render($('article'),{dark:document.body.classList.contains('dark'),language})};$('language').onclick=()=>{language=language==='zh'?'en':'zh';labels();render()};
|
|
104463
104871
|
labels();render();const deadline=Date.now()+10000;guideTimer=setInterval(()=>{const left=Math.max(0,Math.ceil((deadline-Date.now())/1000));$('guide-countdown').textContent=left+'s';if(!left)dismissGuide()},250);
|
|
104464
104872
|
`;
|
|
104465
104873
|
|
|
104466
104874
|
// src/project/reviewSiteStyles.ts
|
|
104875
|
+
init_diagramStyles();
|
|
104467
104876
|
var REVIEW_SITE_STYLES = String.raw`
|
|
104468
104877
|
:root{--blue:#2563eb;--text:#161e2e;--muted:#646b7c;--line:#e7e9ef;--bg:#fff;--side:#f8f9fc;--red:#c63848;--amber:#a4660a}*{box-sizing:border-box}body{margin:0;color:var(--text);background:var(--bg);font:14px/1.75 -apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC",sans-serif}button,input,textarea{font:inherit}button{cursor:pointer}button:disabled{opacity:.35;cursor:not-allowed}[hidden]{display:none!important}header{height:64px;padding:0 24px;display:flex;align-items:center;border-bottom:1px solid var(--line);position:sticky;top:0;background:var(--bg);z-index:5}#home{border:0;background:none;color:var(--text);width:280px;flex-shrink:0;text-align:left;font-size:15px;font-weight:650;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}nav{display:flex;flex:1;min-width:0;overflow:auto;align-self:stretch}nav button{border:0;background:none;color:var(--text);padding:0 16px;font-size:13px;font-weight:550;white-space:nowrap}nav .active{box-shadow:inset 0 -2px var(--blue)}.new,nav .new{color:var(--red)}.modify,nav .modify{color:var(--amber)}.badge{display:inline-block;margin-left:7px;padding:1px 6px;font-size:10px;line-height:18px;vertical-align:middle;border-radius:4px;font-weight:600;letter-spacing:0}.badge.new{background:#fff0f1}.badge.modify,.badge.revised{background:#fff4dd;color:var(--amber)}.badge.approved{background:#e9f7ef;color:#258451}.badge.rejected{background:#f4edf0;color:#9e4458}.tools{display:flex;align-items:center;gap:8px;position:relative;margin-left:12px}.btn{border:1px solid var(--line);border-radius:6px;background:var(--bg);color:var(--text);padding:5px 10px;font-size:12px;line-height:22px;white-space:nowrap}.primary{color:white;background:var(--blue);border-color:var(--blue)}#theme,#language{margin-left:8px;flex-shrink:0}.counter{position:relative;padding:8px;white-space:nowrap;font-size:12px;font-weight:700;color:var(--blue)}.counter-pop{display:none;position:absolute;top:100%;right:0;min-width:320px;padding:15px;background:var(--bg);border:1px solid var(--line);border-radius:10px;box-shadow:0 8px 30px #17244220;color:var(--text);font-weight:400}.counter:hover .counter-pop,.counter:focus .counter-pop{display:block}.counter-grid{display:grid;grid-template-columns:1fr 1fr;gap:16px;font-size:11px}.counter-grid b{display:block;font-size:20px}.counter-pop p{border-top:1px solid var(--line);padding-top:10px}.layout{display:grid;grid-template-columns:280px minmax(0,1fr)}aside{height:calc(100vh - 64px);position:sticky;top:64px;overflow:auto;background:var(--side);border-right:1px solid var(--line);padding:12px 0 80px}.node{display:block;width:100%;text-align:left;border:0;background:none;min-height:32px;padding:6px 16px;font-size:13px;font-weight:450;line-height:20px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--muted)}.node.new{color:var(--red)}.node.modify{color:var(--amber)}.node.selected{background:#2563eb14}.caret{float:right}.node:hover{background:#8e96aa1a}main{min-width:0;padding:44px 60px 100px 36px}h1{font-size:36px;line-height:1.3;letter-spacing:-.025em;margin:0 0 28px}h2{font-size:25px;line-height:1.4;font-weight:650;margin:46px 0 22px;border-bottom:1px solid var(--line);padding-bottom:14px}h3{font-size:19px;margin:30px 0 14px}article{font-size:16px;line-height:1.8}article>h1>.badge{margin-left:12px}article a{color:inherit}article a:hover{color:var(--blue)}article table{border-collapse:collapse;font-size:14px;display:block;overflow:auto}article th,article td{border:1px solid var(--line);padding:11px 14px}article th{background:var(--side)}pre{overflow:auto;background:var(--side);padding:16px}blockquote{padding:16px 20px;margin:24px 0;border-left:3px solid #00bec8;background:#2563eb14;color:var(--muted)}.home .layout{display:block}.home aside{display:none}.home main{width:1120px;max-width:calc(100% - 280px);margin-left:280px;padding-top:32px}.home article{font-size:14px}.home h1{font-size:28px;margin-bottom:12px}.home h2{font-size:19px;margin:24px 0 12px;padding-bottom:10px}.home h3{font-size:15px;margin:16px 0 10px}.stats{font-size:12px;color:var(--muted)}.cards{display:grid;grid-template-columns:repeat(auto-fit,minmax(270px,1fr));gap:8px}.cards button{border:1px solid var(--line);border-radius:7px;background:var(--bg);color:var(--text);text-align:left;font-size:13px;line-height:20px;padding:10px 14px}.cards button:hover{border-color:var(--blue)}.unchanged{border:1px dashed var(--line);border-radius:8px;padding:24px;text-align:center;color:var(--muted);font-size:13px}.changed{position:relative;border-left:3px solid #e8b051;background:#fffaf0;color:#8f5607;padding:24px 18px 12px;margin:20px 0}.changed>.badge{position:absolute;right:12px;top:6px}.changed details{color:var(--muted)}.workspace-tree{font:12px/1.9 ui-monospace,monospace;border:1px solid var(--line);border-radius:8px;padding:16px;background:var(--side);overflow:auto}.workspace-tree button{border:0;background:none;color:var(--text);padding:0;font:inherit;white-space:nowrap}.note{font-size:12px;color:var(--muted)}footer{position:fixed;bottom:0;left:280px;right:0;background:var(--bg);border-top:1px solid var(--line);padding:12px 35px;display:flex;gap:10px;z-index:4}footer input{flex:1;min-width:0;border:0;outline:0;background:transparent;color:var(--text);font-size:14px;padding:8px 0}footer .btn{min-width:76px}.chosen{color:var(--blue);border-color:var(--blue);background:var(--bg)}.hover-label{display:none}.chosen:hover .normal{display:none}.chosen:hover .hover-label{display:inline}dialog{width:560px;max-width:90vw;background:var(--bg);color:var(--text);border:1px solid var(--line);border-radius:10px;padding:20px;font-size:13px;line-height:1.65}dialog::backdrop{background:#131b3255}dialog h2{font-size:17px;margin:0 0 12px;border:0;padding:0}dialog textarea{width:100%;height:130px;border:1px solid var(--line);border-radius:6px;padding:10px;font:11px/1.6 monospace;background:var(--side);color:var(--text)}#copy-warning{color:var(--amber)}.bulk-ack{display:flex;align-items:center;gap:8px;font-size:13px}.bulk-ack input{accent-color:var(--blue)}#bulk-roots-list{margin:8px 0 12px;padding-left:22px;color:var(--red)}.dialog-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:18px}.guide{position:absolute;right:0;top:calc(100% + 18px);width:300px;background:var(--bg);border:1px solid var(--line);border-radius:10px;padding:15px;box-shadow:0 10px 35px #17244224;font-size:12px}.guide:before{content:'';position:absolute;top:-7px;right:42px;width:12px;height:12px;background:var(--bg);border-top:1px solid var(--line);border-left:1px solid var(--line);transform:rotate(45deg)}#guide-countdown{float:right;color:var(--muted);font-size:11px}.dark{--bg:#171b24;--side:#1b1d24;--text:#e2e4ed;--muted:#a1a6b7;--line:#303440;--blue:#8eb7ff}.dark .changed{background:#302919;color:#f2cf85}@media(min-width:1600px){main,.home main{padding-left:52px}}@media(max-width:1250px){#home{width:190px}nav button{padding:0 8px}.tools{gap:4px}}@media(max-width:1050px){header{height:auto;flex-wrap:wrap;min-height:64px}nav{order:3;flex-basis:100%;height:44px}.tools{margin-left:auto}}@media(max-width:700px){.layout{display:block}aside{position:relative;top:0;height:200px}main,.home main{width:100%;max-width:100%;margin:0;padding:24px 20px 90px}footer{left:0;padding:10px;flex-wrap:wrap}footer input{flex-basis:100%}.tools{flex-wrap:wrap}h1{font-size:28px}}
|
|
104878
|
+
${DIAGRAM_STYLES}
|
|
104469
104879
|
`;
|
|
104470
104880
|
|
|
104471
104881
|
// src/project/reviewHtml.ts
|
|
104472
|
-
var REVIEW_HTML_ROOT =
|
|
104882
|
+
var REVIEW_HTML_ROOT = join88(".tmp", "context-runtime", "review");
|
|
104473
104883
|
async function collectReviewCandidates(projectRoot, collection) {
|
|
104474
104884
|
const rows = await readCandidateRecords(projectRoot);
|
|
104475
104885
|
const draftRows = rows.filter((row) => row.collection === collection && row.status === "draft");
|
|
@@ -104486,23 +104896,23 @@ async function collectAllReviewCandidates(projectRoot) {
|
|
|
104486
104896
|
snapshot: await readReviewCandidateSnapshot(projectRoot, record4)
|
|
104487
104897
|
})));
|
|
104488
104898
|
}
|
|
104489
|
-
function renderReviewHtml(candidates, reviewScope, model) {
|
|
104899
|
+
function renderReviewHtml(candidates, reviewScope, model, diagramScript) {
|
|
104490
104900
|
const scope2 = {
|
|
104491
104901
|
label: reviewScope,
|
|
104492
104902
|
ids_sha256: candidateIdsHash(candidates.map((c) => c.record.candidate_id).sort()),
|
|
104493
104903
|
candidates_sha256: candidateSetHash(candidates.map((c) => c.record))
|
|
104494
104904
|
};
|
|
104495
|
-
return `<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${escapeReviewHtml(model.title)} · Review</title><style>${REVIEW_SITE_STYLES}</style></head><body>
|
|
104905
|
+
return `<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${escapeReviewHtml(model.title)} · Review</title><style>${REVIEW_SITE_STYLES}${model.themeCss ?? ""}</style></head><body>
|
|
104496
104906
|
<header><button id="home">${escapeReviewHtml(model.title)}</button><nav id="top"></nav><div class="tools"><div class="counter" tabindex="0"><span id="counts"></span><div class="counter-pop" id="counter-pop"></div></div><button class="btn" id="all-approved"></button><button class="btn" id="all-rejected"></button><button class="btn primary" id="payload-open"></button><div class="guide" id="copy-guide"><span id="guide-countdown">10s</span><p id="guide-text"></p><button class="btn" id="guide-close"></button></div></div><button class="btn" id="theme" aria-label="Theme">◐</button><button class="btn" id="language"></button></header>
|
|
104497
104907
|
<div class="layout"><aside id="tree"></aside><main><article id="article"></article></main></div>
|
|
104498
104908
|
<footer id="footer" hidden><input id="revision-note" aria-label="Revision instructions"><button class="btn" id="revise-btn"></button><button class="btn" id="reject-btn"></button><button class="btn primary" id="approve-btn"></button></footer>
|
|
104499
104909
|
<dialog id="bulk-dialog"><h2 id="bulk-title"></h2><p id="bulk-message"></p><div id="bulk-roots" hidden><strong id="bulk-roots-title"></strong><ul id="bulk-roots-list"></ul><label class="bulk-ack"><input type="checkbox" id="bulk-ack"><span id="bulk-ack-label"></span></label></div><div class="dialog-actions"><button class="btn" id="bulk-cancel"></button><button class="btn primary" id="bulk-confirm"></button></div></dialog>
|
|
104500
104910
|
<dialog id="copy-dialog"><h2 id="copy-title"></h2><p id="copy-summary"></p><p id="copy-instructions"></p><textarea id="payload" readonly aria-label="Review code"></textarea><p id="copy-warning"></p><button class="btn" id="payload-close"></button></dialog>
|
|
104501
|
-
<script>const DATA=${reviewHtmlJson(model)};const SCOPE=${reviewHtmlJson(scope2)};const feedbackCodec=(${createReviewFeedbackCodec.toString()})();${REVIEW_SITE_CLIENT}</script></body></html>`;
|
|
104911
|
+
${diagramScript ? `<script>${diagramScript}</script>` : ""}<script>const DATA=${reviewHtmlJson(model)};const SCOPE=${reviewHtmlJson(scope2)};const feedbackCodec=(${createReviewFeedbackCodec.toString()})();${REVIEW_SITE_CLIENT}</script></body></html>`;
|
|
104502
104912
|
}
|
|
104503
104913
|
function resolveOutputPath(projectRoot, outPath, reviewScope) {
|
|
104504
104914
|
if (outPath === undefined)
|
|
104505
|
-
return
|
|
104915
|
+
return join88(projectRoot, REVIEW_HTML_ROOT, `${reviewScope}.html`);
|
|
104506
104916
|
return isAbsolute15(outPath) ? outPath : resolve28(projectRoot, outPath);
|
|
104507
104917
|
}
|
|
104508
104918
|
async function writeReviewHtml(input) {
|
|
@@ -104512,8 +104922,20 @@ async function writeReviewHtml(input) {
|
|
|
104512
104922
|
}
|
|
104513
104923
|
const candidates = reviewScope === "all" ? await collectAllReviewCandidates(input.projectRoot) : await collectReviewCandidates(input.projectRoot, reviewScope);
|
|
104514
104924
|
const outPath = resolveOutputPath(input.projectRoot, input.out, reviewScope);
|
|
104515
|
-
await
|
|
104516
|
-
|
|
104925
|
+
await mkdir31(dirname38(outPath), { recursive: true });
|
|
104926
|
+
const model = await collectReviewSiteModel(input.projectRoot, candidates);
|
|
104927
|
+
let diagramScript = "";
|
|
104928
|
+
if (model.pages.some((page) => page.html.includes('class="language-mermaid"'))) {
|
|
104929
|
+
const here = dirname38(fileURLToPath6(import.meta.url));
|
|
104930
|
+
try {
|
|
104931
|
+
diagramScript = await readFile70(join88(here, "browser/diagrams.js"), "utf8");
|
|
104932
|
+
} catch (error) {
|
|
104933
|
+
if (error.code !== "ENOENT")
|
|
104934
|
+
throw error;
|
|
104935
|
+
diagramScript = await readFile70(resolve28(here, "../../dist/browser/diagrams.js"), "utf8");
|
|
104936
|
+
}
|
|
104937
|
+
}
|
|
104938
|
+
await writeFile25(outPath, renderReviewHtml(candidates, reviewScope, model, diagramScript), "utf8");
|
|
104517
104939
|
return {
|
|
104518
104940
|
path: outPath,
|
|
104519
104941
|
candidates: candidates.length,
|
|
@@ -104526,8 +104948,8 @@ async function writeReviewHtml(input) {
|
|
|
104526
104948
|
init_productionRequirements();
|
|
104527
104949
|
init_dist();
|
|
104528
104950
|
init_atomicWrite();
|
|
104529
|
-
import { mkdir as
|
|
104530
|
-
import { join as
|
|
104951
|
+
import { mkdir as mkdir32, readFile as readFile71 } from "node:fs/promises";
|
|
104952
|
+
import { join as join89 } from "node:path";
|
|
104531
104953
|
var REVIEW_BATCH_MAX_CANDIDATES = 6;
|
|
104532
104954
|
var REVIEW_BATCH_MAX_BYTES = 512 * 1024;
|
|
104533
104955
|
async function readerPurposes(projectRoot, sources) {
|
|
@@ -104607,12 +105029,12 @@ async function materializeCurrentReviewBatchSet(input) {
|
|
|
104607
105029
|
const batches = buildCurrentReviewBatchDocuments(input.candidates);
|
|
104608
105030
|
const setDigest = digestText(batches.map((batch) => `${batch.task_key}:${batch.digest}`).join(`
|
|
104609
105031
|
`));
|
|
104610
|
-
const root2 =
|
|
104611
|
-
await
|
|
105032
|
+
const root2 = join89(input.projectRoot, ".tmp", "context-runtime", "review", `current-${setDigest.slice("sha256:".length)}`);
|
|
105033
|
+
await mkdir32(root2, { recursive: true });
|
|
104612
105034
|
const entries2 = [];
|
|
104613
105035
|
for (const batch of batches) {
|
|
104614
|
-
const path4 =
|
|
104615
|
-
const existing = await
|
|
105036
|
+
const path4 = join89(input.projectRoot, ".tmp", "context-runtime", "review", `${batch.task_key}-${batch.digest.slice("sha256:".length)}.md`);
|
|
105037
|
+
const existing = await readFile71(path4, "utf8").catch((error) => {
|
|
104616
105038
|
if (error.code === "ENOENT")
|
|
104617
105039
|
return;
|
|
104618
105040
|
throw error;
|
|
@@ -104665,7 +105087,7 @@ async function materializeCurrentReviewBatchSet(input) {
|
|
|
104665
105087
|
].join(`
|
|
104666
105088
|
`);
|
|
104667
105089
|
const digest6 = digestText(content3);
|
|
104668
|
-
const path3 =
|
|
105090
|
+
const path3 = join89(root2, "index.md");
|
|
104669
105091
|
await atomicWriteFile(path3, `${content3}
|
|
104670
105092
|
`);
|
|
104671
105093
|
return {
|
|
@@ -104698,11 +105120,11 @@ function shellQuote6(value) {
|
|
|
104698
105120
|
}
|
|
104699
105121
|
function receiptSetPath(receipts) {
|
|
104700
105122
|
const token = digestText(JSON.stringify(receipts)).slice("sha256:".length);
|
|
104701
|
-
return
|
|
105123
|
+
return join90(".tmp", "context-runtime", "workflow", "read-receipts", `${token}.json`);
|
|
104702
105124
|
}
|
|
104703
105125
|
async function writeReceiptContinuation(input) {
|
|
104704
105126
|
const path3 = receiptSetPath(input.receipts);
|
|
104705
|
-
const absolutePath =
|
|
105127
|
+
const absolutePath = join90(input.projectRoot, path3);
|
|
104706
105128
|
await writeJsonAtomic(absolutePath, input.receipts);
|
|
104707
105129
|
const contextCommand = input.managed ? [
|
|
104708
105130
|
"context",
|
|
@@ -104797,7 +105219,7 @@ async function materializeContextWorkflowResource(input) {
|
|
|
104797
105219
|
const resourceId = workflowResourceId(input.resourceId);
|
|
104798
105220
|
const content3 = renderContextWorkflowResource(resourceId, status);
|
|
104799
105221
|
const location = await materializeResource(await loadContextWorkflowProvider(), resourceId, {
|
|
104800
|
-
cache:
|
|
105222
|
+
cache: join90(found.projectRoot, ".tmp", "context-runtime", "workflow", "resources"),
|
|
104801
105223
|
workspace: found.projectRoot,
|
|
104802
105224
|
revision: input.revision,
|
|
104803
105225
|
input: {
|
|
@@ -104829,7 +105251,7 @@ async function materializeContextWorkflowResource(input) {
|
|
|
104829
105251
|
receipts: afterReadReceipts
|
|
104830
105252
|
});
|
|
104831
105253
|
const directResources = (status.workflow.current?.resources.required ?? []).filter((resource) => resource.read_state === "read-required" && resource.path !== undefined && resource.digest !== undefined);
|
|
104832
|
-
const afterReadCommand = directResources.length === 0 ? continuation.command : `context resource acknowledge-current --revision ${shellQuote6(input.revision)}${authorityCommandOptions(authorities, "resource")} --resource-receipts ${shellQuote6(`@${
|
|
105254
|
+
const afterReadCommand = directResources.length === 0 ? continuation.command : `context resource acknowledge-current --revision ${shellQuote6(input.revision)}${authorityCommandOptions(authorities, "resource")} --resource-receipts ${shellQuote6(`@${join90(found.projectRoot, continuation.path)}`)} --format json`;
|
|
104833
105255
|
return {
|
|
104834
105256
|
protocol: "context.workflow.resource.v1",
|
|
104835
105257
|
id: resourceId,
|
|
@@ -104890,14 +105312,14 @@ async function acknowledgeCurrentWorkflowResources(input) {
|
|
|
104890
105312
|
const reevaluated = await reevaluateProjectStatusWorkflow({
|
|
104891
105313
|
snapshot,
|
|
104892
105314
|
resourceReceipts: normalizedReceipts,
|
|
104893
|
-
resourceReceiptsReference: `@${
|
|
105315
|
+
resourceReceiptsReference: `@${join90(found.projectRoot, continuation.path)}`
|
|
104894
105316
|
});
|
|
104895
105317
|
return {
|
|
104896
105318
|
...reevaluated,
|
|
104897
105319
|
resourceAcknowledgement: {
|
|
104898
105320
|
protocol: "context.workflow.resource-receipts.v1",
|
|
104899
105321
|
acknowledged: directResources.length,
|
|
104900
|
-
receiptReference: `@${
|
|
105322
|
+
receiptReference: `@${join90(found.projectRoot, continuation.path)}`
|
|
104901
105323
|
}
|
|
104902
105324
|
};
|
|
104903
105325
|
}
|
|
@@ -104943,9 +105365,9 @@ init_cliFeedback();
|
|
|
104943
105365
|
init_errors3();
|
|
104944
105366
|
init_exitCode();
|
|
104945
105367
|
init_workspace();
|
|
104946
|
-
import { readFile as
|
|
104947
|
-
import { isAbsolute as isAbsolute16, join as
|
|
104948
|
-
var RECEIPT_DIRECTORY =
|
|
105368
|
+
import { readFile as readFile72 } from "node:fs/promises";
|
|
105369
|
+
import { isAbsolute as isAbsolute16, join as join91, sep as sep6, resolve as resolve29 } from "node:path";
|
|
105370
|
+
var RECEIPT_DIRECTORY = join91(".tmp", "context-runtime", "workflow", "read-receipts");
|
|
104949
105371
|
function workflowResourceReceiptCwd(value, cwd) {
|
|
104950
105372
|
if (value === undefined || !value.startsWith("@"))
|
|
104951
105373
|
return cwd;
|
|
@@ -104963,7 +105385,7 @@ async function receiptDocument(value, cwd) {
|
|
|
104963
105385
|
let source2 = value;
|
|
104964
105386
|
if (value.startsWith("@")) {
|
|
104965
105387
|
try {
|
|
104966
|
-
source2 = await
|
|
105388
|
+
source2 = await readFile72(resolve29(cwd, value.slice(1)), "utf8");
|
|
104967
105389
|
} catch (error) {
|
|
104968
105390
|
const ioCode = error !== null && typeof error === "object" && "code" in error && typeof error.code === "string" ? error.code : undefined;
|
|
104969
105391
|
throw new ContextError(ExitCode.UserError, "resource read receipt file is unavailable", {
|
|
@@ -105064,7 +105486,7 @@ function registerContextWorkflowResourceCommands(program2) {
|
|
|
105064
105486
|
}
|
|
105065
105487
|
|
|
105066
105488
|
// src/commands/runProject.ts
|
|
105067
|
-
import { fileURLToPath as
|
|
105489
|
+
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
105068
105490
|
init_cliFeedback();
|
|
105069
105491
|
init_errors3();
|
|
105070
105492
|
|
|
@@ -105209,17 +105631,17 @@ function compactJsonResult(result, verbose) {
|
|
|
105209
105631
|
|
|
105210
105632
|
// src/project/runLog.ts
|
|
105211
105633
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
105212
|
-
import { mkdir as
|
|
105213
|
-
import { dirname as
|
|
105634
|
+
import { mkdir as mkdir33, writeFile as writeFile26 } from "node:fs/promises";
|
|
105635
|
+
import { dirname as dirname39, join as join94 } from "node:path";
|
|
105214
105636
|
var createPhaseRunId = () => {
|
|
105215
105637
|
const timestamp = new Date().toISOString().replace(/[-:.TZ]/gu, "");
|
|
105216
105638
|
return `run_${timestamp}_${randomUUID5().slice(0, 8)}`;
|
|
105217
105639
|
};
|
|
105218
105640
|
async function writePhaseRunLog(input) {
|
|
105219
|
-
const relPath =
|
|
105220
|
-
const absPath =
|
|
105221
|
-
await
|
|
105222
|
-
await
|
|
105641
|
+
const relPath = join94(".tmp", "context-runtime", "runs", `${input.runId}.json`);
|
|
105642
|
+
const absPath = join94(input.projectRoot, relPath);
|
|
105643
|
+
await mkdir33(dirname39(absPath), { recursive: true });
|
|
105644
|
+
await writeFile26(absPath, `${JSON.stringify({
|
|
105223
105645
|
run_id: input.runId,
|
|
105224
105646
|
phase_id: input.phase.id,
|
|
105225
105647
|
phase_kind: input.phase.kind,
|
|
@@ -106303,7 +106725,7 @@ function createReviewCodeCodec() {
|
|
|
106303
106725
|
init_cliFeedback();
|
|
106304
106726
|
init_errors3();
|
|
106305
106727
|
init_exitCode();
|
|
106306
|
-
import { readFile as
|
|
106728
|
+
import { readFile as readFile77 } from "node:fs/promises";
|
|
106307
106729
|
import { isAbsolute as isAbsolute18, resolve as resolve30 } from "node:path";
|
|
106308
106730
|
|
|
106309
106731
|
// src/project/reviewApply.ts
|
|
@@ -106316,8 +106738,8 @@ init_writeLock();
|
|
|
106316
106738
|
init_reviewApplyIndexer();
|
|
106317
106739
|
init_approvedKnowledgeSnapshots();
|
|
106318
106740
|
import { existsSync as existsSync25 } from "node:fs";
|
|
106319
|
-
import { readFile as
|
|
106320
|
-
import { join as
|
|
106741
|
+
import { readFile as readFile75 } from "node:fs/promises";
|
|
106742
|
+
import { join as join95 } from "node:path";
|
|
106321
106743
|
|
|
106322
106744
|
// src/project/reviewCandidateAuthority.ts
|
|
106323
106745
|
init_src2();
|
|
@@ -106414,7 +106836,7 @@ async function prepareApprovedPage(input) {
|
|
|
106414
106836
|
next: "Refresh the current production or article revision, then reopen Review before approval."
|
|
106415
106837
|
});
|
|
106416
106838
|
}
|
|
106417
|
-
const relPath =
|
|
106839
|
+
const relPath = join95("knowledge", input.record.path);
|
|
106418
106840
|
const existingView = findApprovedPageForArticleId(input.record.indexer_candidate.artifact_ref, input.approvedPageIndex);
|
|
106419
106841
|
const previousPath = input.record.approved_revision?.previous_path;
|
|
106420
106842
|
if (previousPath !== undefined && (!isSafeKnowledgeTargetPath(previousPath.split("/")[0], previousPath) || previousPath.includes("\\")))
|
|
@@ -106429,13 +106851,13 @@ async function prepareApprovedPage(input) {
|
|
|
106429
106851
|
next: "Resolve the approved page path migration explicitly before approving this candidate."
|
|
106430
106852
|
});
|
|
106431
106853
|
}
|
|
106432
|
-
const absPath =
|
|
106433
|
-
const existing = existsSync25(absPath) ? await
|
|
106854
|
+
const absPath = join95(input.projectRoot, relPath);
|
|
106855
|
+
const existing = existsSync25(absPath) ? await readFile75(absPath, "utf8") : undefined;
|
|
106434
106856
|
let previous3;
|
|
106435
106857
|
if (previousPath !== undefined) {
|
|
106436
106858
|
if (existing !== undefined || existingView?.relPath !== `knowledge/${previousPath}`)
|
|
106437
106859
|
throw new TypeError("Page move destination or original identity changed; refresh its revision.");
|
|
106438
|
-
previous3 = { path: `knowledge/${previousPath}`, content: await
|
|
106860
|
+
previous3 = { path: `knowledge/${previousPath}`, content: await readFile75(join95(input.projectRoot, "knowledge", previousPath), "utf8") };
|
|
106439
106861
|
}
|
|
106440
106862
|
if (input.record.approved_revision !== undefined) {
|
|
106441
106863
|
const base = previous3?.content ?? existing;
|
|
@@ -106482,7 +106904,7 @@ async function prepareApprovedPage(input) {
|
|
|
106482
106904
|
}
|
|
106483
106905
|
async function readProjectFileMaybe(projectRoot, relPath) {
|
|
106484
106906
|
try {
|
|
106485
|
-
return await
|
|
106907
|
+
return await readFile75(join95(projectRoot, relPath), "utf8");
|
|
106486
106908
|
} catch (error) {
|
|
106487
106909
|
if (error !== null && typeof error === "object" && "code" in error && error.code === "ENOENT") {
|
|
106488
106910
|
return;
|
|
@@ -106705,7 +107127,7 @@ async function applyReviewDecisions(input) {
|
|
|
106705
107127
|
});
|
|
106706
107128
|
}
|
|
106707
107129
|
seenApprovedIds.set(approvedRef, row.candidate_id);
|
|
106708
|
-
const approvedPath =
|
|
107130
|
+
const approvedPath = join95("knowledge", row.path);
|
|
106709
107131
|
const previousPathCandidate = seenApprovedPaths.get(knowledgeTargetPathKey(approvedPath));
|
|
106710
107132
|
if (previousPathCandidate !== undefined) {
|
|
106711
107133
|
throw new ContextError(ExitCode.UserError, `multiple approved review decisions target the same knowledge path: ${approvedPath}`, {
|
|
@@ -106755,7 +107177,7 @@ async function applyReviewDecisions(input) {
|
|
|
106755
107177
|
for (const path3 of approvedPageIndex.byRelPath.keys()) {
|
|
106756
107178
|
if (pagesToWrite.some((page) => page.relPath === path3 || page.previous?.path === path3))
|
|
106757
107179
|
continue;
|
|
106758
|
-
const before = await
|
|
107180
|
+
const before = await readFile75(join95(input.projectRoot, path3), "utf8");
|
|
106759
107181
|
const local = path3.replace(/^knowledge\//u, "");
|
|
106760
107182
|
const after = moveKnowledgeLinkTargets2(before, local, local, moved);
|
|
106761
107183
|
navigationTargets.push(reviewFileTarget({ path: path3, baseContent: before, targetContent: after }));
|
|
@@ -106811,17 +107233,17 @@ async function applyReviewDecisions(input) {
|
|
|
106811
107233
|
}
|
|
106812
107234
|
|
|
106813
107235
|
// src/project/reviewMaintenance.ts
|
|
106814
|
-
import { readFile as
|
|
107236
|
+
import { readFile as readFile76, writeFile as writeFile27 } from "node:fs/promises";
|
|
106815
107237
|
init_writeLock();
|
|
106816
107238
|
init_verifyFrontmatter();
|
|
106817
107239
|
function deprecateApprovedPage(input) {
|
|
106818
107240
|
return withProjectWriteLock(input.projectRoot, "deprecate-article", async () => {
|
|
106819
107241
|
const page = await approvedPageForArticleId(input.projectRoot, input.viewRef);
|
|
106820
|
-
const original = await
|
|
107242
|
+
const original = await readFile76(page.path, "utf8");
|
|
106821
107243
|
const content3 = parseFrontmatterLoose(original).deprecated === true ? original : updateFrontmatter(original, (metadata) => ({ ...metadata, deprecated: true, timestamp: new Date().toISOString() }));
|
|
106822
107244
|
const changed = content3 !== original;
|
|
106823
107245
|
if (changed)
|
|
106824
|
-
await
|
|
107246
|
+
await writeFile27(page.path, content3, "utf8");
|
|
106825
107247
|
const actionLog = await writeReviewActionLog({
|
|
106826
107248
|
projectRoot: input.projectRoot,
|
|
106827
107249
|
action: "deprecate",
|
|
@@ -106837,12 +107259,12 @@ init_candidateLedger();
|
|
|
106837
107259
|
|
|
106838
107260
|
// src/project/localHtmlReport.ts
|
|
106839
107261
|
import { execFile as execFile11 } from "node:child_process";
|
|
106840
|
-
import { isAbsolute as isAbsolute17, join as
|
|
107262
|
+
import { isAbsolute as isAbsolute17, join as join96 } from "node:path";
|
|
106841
107263
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
106842
107264
|
import { promisify as promisify11 } from "node:util";
|
|
106843
107265
|
var execFileAsync5 = promisify11(execFile11);
|
|
106844
107266
|
function htmlReportReference(input) {
|
|
106845
|
-
const absolutePath = isAbsolute17(input.path) ? input.path :
|
|
107267
|
+
const absolutePath = isAbsolute17(input.path) ? input.path : join96(input.projectRoot, input.path);
|
|
106846
107268
|
return {
|
|
106847
107269
|
format: "html",
|
|
106848
107270
|
path: input.path,
|
|
@@ -107014,7 +107436,7 @@ function parseReviewPayloadText(raw) {
|
|
|
107014
107436
|
async function readReviewPayloadFile(filePath2) {
|
|
107015
107437
|
let raw;
|
|
107016
107438
|
try {
|
|
107017
|
-
raw = await
|
|
107439
|
+
raw = await readFile77(filePath2, "utf8");
|
|
107018
107440
|
} catch (error) {
|
|
107019
107441
|
const message = error instanceof Error ? error.message : String(error);
|
|
107020
107442
|
throw new ContextError(ExitCode.UserError, `review payload file cannot be read: ${filePath2}`, {
|
|
@@ -107668,7 +108090,7 @@ async function runProjectUntil(input) {
|
|
|
107668
108090
|
const resourceReceipts = input.resourceReceiptsReference === undefined ? undefined : await parseWorkflowResourceReceipts(input.resourceReceiptsReference, found.projectRoot);
|
|
107669
108091
|
const runtime = new WorkspaceExecutionRuntime({
|
|
107670
108092
|
projectRoot: found.projectRoot,
|
|
107671
|
-
cliEntryPath:
|
|
108093
|
+
cliEntryPath: fileURLToPath7(input.cliModuleUrl),
|
|
107672
108094
|
inProcess: createWorkflowInProcessExecutor()
|
|
107673
108095
|
});
|
|
107674
108096
|
let result;
|
|
@@ -107865,8 +108287,8 @@ init_exitCode();
|
|
|
107865
108287
|
init_maintenanceStorage();
|
|
107866
108288
|
init_productionFeedback();
|
|
107867
108289
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
107868
|
-
import { readFile as
|
|
107869
|
-
import { join as
|
|
108290
|
+
import { readFile as readFile78 } from "node:fs/promises";
|
|
108291
|
+
import { join as join97 } from "node:path";
|
|
107870
108292
|
async function beginProductionRevision(input) {
|
|
107871
108293
|
return withProductionFeedback({ operation: "revision" }, () => withProjectWriteLock(input.projectRoot, "production-revision", async () => {
|
|
107872
108294
|
await recoverDurableMultiFileTransactions(input.projectRoot);
|
|
@@ -107905,7 +108327,7 @@ async function beginProductionRevision(input) {
|
|
|
107905
108327
|
const formal = approved.byPath.get(path3);
|
|
107906
108328
|
if (!prior && !formal)
|
|
107907
108329
|
throw invalid2("Write the current task first; there is no article draft to revise yet.");
|
|
107908
|
-
const markdown = prior?.body ?? await
|
|
108330
|
+
const markdown = prior?.body ?? await readFile78(await safeProjectTarget(input.projectRoot, join97("knowledge", path3)), "utf8");
|
|
107909
108331
|
const sections = prior?.indexer_candidate.sections.map((section) => ({ id: section.section_key, references: section.references })) ?? formal?.sections;
|
|
107910
108332
|
const sources = [];
|
|
107911
108333
|
for (const source2 of owner.sources) {
|
|
@@ -108082,7 +108504,7 @@ init_cliFeedback();
|
|
|
108082
108504
|
init_errors3();
|
|
108083
108505
|
init_exitCode();
|
|
108084
108506
|
var import_yaml41 = __toESM(require_dist(), 1);
|
|
108085
|
-
import { readFile as
|
|
108507
|
+
import { readFile as readFile79 } from "node:fs/promises";
|
|
108086
108508
|
function userInputError2(message, detail = {}) {
|
|
108087
108509
|
return new ContextError(ExitCode.UserError, message, {
|
|
108088
108510
|
category: ErrorCategory.UserInputInvalid,
|
|
@@ -108151,7 +108573,7 @@ async function readPayloadTextFromStdin(stdin) {
|
|
|
108151
108573
|
}
|
|
108152
108574
|
async function readPayloadText(path3) {
|
|
108153
108575
|
if (path3 !== "-")
|
|
108154
|
-
return
|
|
108576
|
+
return readFile79(path3, "utf8");
|
|
108155
108577
|
return readPayloadTextFromStdin(process.stdin);
|
|
108156
108578
|
}
|
|
108157
108579
|
async function readYamlOrJsonInput(input) {
|
|
@@ -108545,7 +108967,7 @@ init_atomicWrite();
|
|
|
108545
108967
|
var import_yaml44 = __toESM(require_dist(), 1);
|
|
108546
108968
|
import { Buffer as Buffer4 } from "node:buffer";
|
|
108547
108969
|
import { createHash as createHash30 } from "node:crypto";
|
|
108548
|
-
import { join as
|
|
108970
|
+
import { join as join101 } from "node:path";
|
|
108549
108971
|
var INLINE_LIMIT = 16 * 1024;
|
|
108550
108972
|
function record4(value) {
|
|
108551
108973
|
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : undefined;
|
|
@@ -108571,8 +108993,8 @@ async function prepareActionCompletionOutput(input) {
|
|
|
108571
108993
|
if (production && Buffer4.byteLength(full) <= INLINE_LIMIT)
|
|
108572
108994
|
return input.result;
|
|
108573
108995
|
const digest6 = createHash30("sha256").update(full).digest("hex");
|
|
108574
|
-
const root2 =
|
|
108575
|
-
const resultFile =
|
|
108996
|
+
const root2 = join101(input.projectRoot, ".tmp/context-runtime/action-results");
|
|
108997
|
+
const resultFile = join101(root2, `${digest6}.json`);
|
|
108576
108998
|
await atomicWriteFile(resultFile, full);
|
|
108577
108999
|
if (production)
|
|
108578
109000
|
return {
|
|
@@ -108583,7 +109005,7 @@ async function prepareActionCompletionOutput(input) {
|
|
|
108583
109005
|
...pick(result, ["next", "next_preparation"])
|
|
108584
109006
|
};
|
|
108585
109007
|
const next2 = record4(result.next) ?? record4(record4(result.workflow)?.current) ?? record4(record4(result.continuation)?.next);
|
|
108586
|
-
const nextFile = next2 === undefined ? undefined :
|
|
109008
|
+
const nextFile = next2 === undefined ? undefined : join101(root2, `${digest6}.next.json`);
|
|
108587
109009
|
if (nextFile !== undefined)
|
|
108588
109010
|
await atomicWriteFile(nextFile, serializeActionCompletion(next2, "json"));
|
|
108589
109011
|
const outcomes = (Array.isArray(result.outcomes) ? result.outcomes : []).map(record4).filter((item) => item !== undefined);
|
|
@@ -108986,7 +109408,7 @@ init_cliFeedback();
|
|
|
108986
109408
|
import { existsSync as existsSync27 } from "node:fs";
|
|
108987
109409
|
import { readdir as readdir26, rm as rm20 } from "node:fs/promises";
|
|
108988
109410
|
import { homedir } from "node:os";
|
|
108989
|
-
import { join as
|
|
109411
|
+
import { join as join102 } from "node:path";
|
|
108990
109412
|
var ORPHAN_MARKER = ".orphaned_at";
|
|
108991
109413
|
var CLAUDE_PLUGIN_CACHE_ROOT_ENV = "C4A_CLAUDE_PLUGIN_CACHE_ROOT";
|
|
108992
109414
|
var CLAUDE_PLUGIN_CACHE_HOME_ENV = "C4A_CLAUDE_PLUGIN_CACHE_HOME";
|
|
@@ -109003,19 +109425,19 @@ async function cleanClaudePluginCache(opts = {}) {
|
|
|
109003
109425
|
for (const mp of marketplaces) {
|
|
109004
109426
|
if (!mp.isDirectory())
|
|
109005
109427
|
continue;
|
|
109006
|
-
const mpDir =
|
|
109428
|
+
const mpDir = join102(cacheRoot, mp.name);
|
|
109007
109429
|
const plugins = await readdir26(mpDir, { withFileTypes: true });
|
|
109008
109430
|
for (const pl of plugins) {
|
|
109009
109431
|
if (!pl.isDirectory())
|
|
109010
109432
|
continue;
|
|
109011
|
-
const plDir =
|
|
109433
|
+
const plDir = join102(mpDir, pl.name);
|
|
109012
109434
|
const versions = await readdir26(plDir, { withFileTypes: true });
|
|
109013
109435
|
for (const ver of versions) {
|
|
109014
109436
|
if (!ver.isDirectory())
|
|
109015
109437
|
continue;
|
|
109016
109438
|
scanned += 1;
|
|
109017
|
-
const verDir =
|
|
109018
|
-
const markerPath =
|
|
109439
|
+
const verDir = join102(plDir, ver.name);
|
|
109440
|
+
const markerPath = join102(verDir, ORPHAN_MARKER);
|
|
109019
109441
|
if (!existsSync27(markerPath))
|
|
109020
109442
|
continue;
|
|
109021
109443
|
const label2 = `${mp.name}/${pl.name}/${ver.name}`;
|
|
@@ -109047,7 +109469,7 @@ function resolveClaudePluginCacheRoot(opts) {
|
|
|
109047
109469
|
if (explicitRoot)
|
|
109048
109470
|
return explicitRoot;
|
|
109049
109471
|
const home = opts.home ?? process.env[CLAUDE_PLUGIN_CACHE_HOME_ENV] ?? homedir();
|
|
109050
|
-
return
|
|
109472
|
+
return join102(home, ".claude", "plugins", "cache");
|
|
109051
109473
|
}
|
|
109052
109474
|
async function isEmptyDir(dir) {
|
|
109053
109475
|
try {
|
|
@@ -109079,13 +109501,13 @@ init_exitCode();
|
|
|
109079
109501
|
|
|
109080
109502
|
// src/lib/packageVersion.ts
|
|
109081
109503
|
import { existsSync as existsSync28, readFileSync as readFileSync9 } from "node:fs";
|
|
109082
|
-
import { dirname as
|
|
109083
|
-
import { fileURLToPath as
|
|
109504
|
+
import { dirname as dirname42, join as join103 } from "node:path";
|
|
109505
|
+
import { fileURLToPath as fileURLToPath8 } from "node:url";
|
|
109084
109506
|
function readPackageVersion() {
|
|
109085
109507
|
try {
|
|
109086
|
-
let dir =
|
|
109508
|
+
let dir = dirname42(fileURLToPath8(import.meta.url));
|
|
109087
109509
|
for (let depth = 0;depth < 8; depth += 1) {
|
|
109088
|
-
const packagePath =
|
|
109510
|
+
const packagePath = join103(dir, "package.json");
|
|
109089
109511
|
if (existsSync28(packagePath)) {
|
|
109090
109512
|
const parsed = JSON.parse(readFileSync9(packagePath, "utf8"));
|
|
109091
109513
|
if (typeof parsed.version === "string" && parsed.version.length > 0) {
|
|
@@ -109093,7 +109515,7 @@ function readPackageVersion() {
|
|
|
109093
109515
|
}
|
|
109094
109516
|
break;
|
|
109095
109517
|
}
|
|
109096
|
-
const parent =
|
|
109518
|
+
const parent = dirname42(dir);
|
|
109097
109519
|
if (parent === dir)
|
|
109098
109520
|
break;
|
|
109099
109521
|
dir = parent;
|
|
@@ -109108,7 +109530,7 @@ function readPackageVersion() {
|
|
|
109108
109530
|
|
|
109109
109531
|
// src/project/sourceCommands.ts
|
|
109110
109532
|
init_src2();
|
|
109111
|
-
import { readFile as
|
|
109533
|
+
import { readFile as readFile92 } from "node:fs/promises";
|
|
109112
109534
|
import { isAbsolute as isAbsolute22, resolve as resolve37 } from "node:path";
|
|
109113
109535
|
init_cliFeedback();
|
|
109114
109536
|
init_errors3();
|
|
@@ -109121,8 +109543,8 @@ init_errors3();
|
|
|
109121
109543
|
init_exitCode();
|
|
109122
109544
|
import { execFile as execFile12 } from "node:child_process";
|
|
109123
109545
|
import { existsSync as existsSync29 } from "node:fs";
|
|
109124
|
-
import { lstat as lstat12, mkdir as
|
|
109125
|
-
import { basename as basename11, dirname as
|
|
109546
|
+
import { lstat as lstat12, mkdir as mkdir35, readlink as readlink2, realpath as realpath10, rm as rm21, symlink as symlink4 } from "node:fs/promises";
|
|
109547
|
+
import { basename as basename11, dirname as dirname43, isAbsolute as isAbsolute19, relative as relative26, resolve as resolve34 } from "node:path";
|
|
109126
109548
|
import { promisify as promisify12 } from "node:util";
|
|
109127
109549
|
init_writeLock();
|
|
109128
109550
|
var execFileAsync6 = promisify12(execFile12);
|
|
@@ -109307,7 +109729,7 @@ async function cloneCheckout(input) {
|
|
|
109307
109729
|
next: `Use local mode with path ${JSON.stringify(target)} after inspecting the existing checkout.`
|
|
109308
109730
|
});
|
|
109309
109731
|
}
|
|
109310
|
-
await
|
|
109732
|
+
await mkdir35(dirname43(target), { recursive: true });
|
|
109311
109733
|
const cloneArgs = ["clone", "--no-checkout", "--depth=1", "--filter=blob:none", input.remote, target];
|
|
109312
109734
|
try {
|
|
109313
109735
|
await execFileAsync6("git", cloneArgs, { encoding: "utf8", maxBuffer: 4 * 1024 * 1024 });
|
|
@@ -109356,7 +109778,7 @@ async function bindLocalAlias(input) {
|
|
|
109356
109778
|
const stats = await lstat12(alias).catch(() => null);
|
|
109357
109779
|
if (stats !== null) {
|
|
109358
109780
|
if (stats.isSymbolicLink()) {
|
|
109359
|
-
const actual = resolve34(
|
|
109781
|
+
const actual = resolve34(dirname43(alias), await readlink2(alias));
|
|
109360
109782
|
const actualReal = await realpath10(actual).catch(() => null);
|
|
109361
109783
|
if (actualReal !== null && actualReal === await realpath10(input.checkout))
|
|
109362
109784
|
return;
|
|
@@ -109372,8 +109794,8 @@ async function bindLocalAlias(input) {
|
|
|
109372
109794
|
});
|
|
109373
109795
|
}
|
|
109374
109796
|
}
|
|
109375
|
-
await
|
|
109376
|
-
await symlink4(relative26(
|
|
109797
|
+
await mkdir35(dirname43(alias), { recursive: true });
|
|
109798
|
+
await symlink4(relative26(dirname43(alias), input.checkout) || ".", alias);
|
|
109377
109799
|
}
|
|
109378
109800
|
function selectPhysicalGroup(sources, selector) {
|
|
109379
109801
|
const direct = selectRepoSources(sources, selector);
|
|
@@ -109467,11 +109889,11 @@ async function restoreRepositorySources(input) {
|
|
|
109467
109889
|
// src/project/sourceDocumentStatus.ts
|
|
109468
109890
|
init_src2();
|
|
109469
109891
|
import { existsSync as existsSync30 } from "node:fs";
|
|
109470
|
-
import { readFile as
|
|
109471
|
-
import { join as
|
|
109892
|
+
import { readFile as readFile85 } from "node:fs/promises";
|
|
109893
|
+
import { join as join105 } from "node:path";
|
|
109472
109894
|
// src/project/sourceCommandViews.ts
|
|
109473
|
-
import { readFile as
|
|
109474
|
-
import { join as
|
|
109895
|
+
import { readFile as readFile84 } from "node:fs/promises";
|
|
109896
|
+
import { join as join104 } from "node:path";
|
|
109475
109897
|
init_workspace();
|
|
109476
109898
|
init_documentBatchManifest();
|
|
109477
109899
|
function repoSourceAgentView(source2) {
|
|
@@ -109534,7 +109956,7 @@ async function fileSourceAgentViewWithNextAction(input) {
|
|
|
109534
109956
|
};
|
|
109535
109957
|
}
|
|
109536
109958
|
function documentSourceManifestPath(source2) {
|
|
109537
|
-
return source2.snapshot?.manifest ??
|
|
109959
|
+
return source2.snapshot?.manifest ?? join104(source2.materializedAt, "manifest.json");
|
|
109538
109960
|
}
|
|
109539
109961
|
async function fileSourceDocumentSiteHint(input) {
|
|
109540
109962
|
const detection = await detectDocumentSiteFiles({
|
|
@@ -109544,7 +109966,7 @@ async function fileSourceDocumentSiteHint(input) {
|
|
|
109544
109966
|
let snapshotConfigured = false;
|
|
109545
109967
|
const manifest = documentSourceManifestPath(input.source);
|
|
109546
109968
|
try {
|
|
109547
|
-
const parsed = parseDocumentSnapshotForSource(JSON.parse(await
|
|
109969
|
+
const parsed = parseDocumentSnapshotForSource(JSON.parse(await readFile84(join104(input.projectRoot, manifest), "utf8")), input.source.name);
|
|
109548
109970
|
snapshotConfigured = manifestUsesMdxJsonDocs(parsed);
|
|
109549
109971
|
} catch {
|
|
109550
109972
|
snapshotConfigured = false;
|
|
@@ -109576,11 +109998,11 @@ async function larkSourceAgentViewWithNextAction(input) {
|
|
|
109576
109998
|
// src/project/sourceDocumentStatus.ts
|
|
109577
109999
|
init_documentBatchManifest();
|
|
109578
110000
|
function documentSourceManifestPath2(source2) {
|
|
109579
|
-
return source2.snapshot?.manifest ??
|
|
110001
|
+
return source2.snapshot?.manifest ?? join105(source2.materializedAt, "manifest.json");
|
|
109580
110002
|
}
|
|
109581
110003
|
async function documentSnapshotState(input) {
|
|
109582
110004
|
const manifest = documentSourceManifestPath2(input.source);
|
|
109583
|
-
const manifestPath =
|
|
110005
|
+
const manifestPath = join105(input.projectRoot, manifest);
|
|
109584
110006
|
if (!existsSync30(manifestPath)) {
|
|
109585
110007
|
return {
|
|
109586
110008
|
snapshotReady: false,
|
|
@@ -109591,7 +110013,7 @@ async function documentSnapshotState(input) {
|
|
|
109591
110013
|
};
|
|
109592
110014
|
}
|
|
109593
110015
|
try {
|
|
109594
|
-
const parsed = findDocumentSnapshotForSource(JSON.parse(await
|
|
110016
|
+
const parsed = findDocumentSnapshotForSource(JSON.parse(await readFile85(manifestPath, "utf8")), input.source.name);
|
|
109595
110017
|
if (parsed === null) {
|
|
109596
110018
|
return {
|
|
109597
110019
|
snapshotReady: false,
|
|
@@ -109659,7 +110081,7 @@ async function documentSnapshotState(input) {
|
|
|
109659
110081
|
const missing = [
|
|
109660
110082
|
...parsed.files.map((file) => file.path),
|
|
109661
110083
|
...(parsed.assets ?? []).filter((asset) => asset.content_hash !== undefined).map((asset) => asset.path)
|
|
109662
|
-
].find((path3) => !existsSync30(
|
|
110084
|
+
].find((path3) => !existsSync30(join105(input.projectRoot, input.source.materializedAt, path3)));
|
|
109663
110085
|
if (missing !== undefined) {
|
|
109664
110086
|
return {
|
|
109665
110087
|
snapshotReady: false,
|
|
@@ -109760,8 +110182,8 @@ init_errors3();
|
|
|
109760
110182
|
init_exitCode();
|
|
109761
110183
|
var import_yaml47 = __toESM(require_dist(), 1);
|
|
109762
110184
|
import { createHash as createHash31 } from "node:crypto";
|
|
109763
|
-
import { readFile as
|
|
109764
|
-
import { basename as basename12, extname as extname15, isAbsolute as isAbsolute20, join as
|
|
110185
|
+
import { readFile as readFile86, realpath as realpath11 } from "node:fs/promises";
|
|
110186
|
+
import { basename as basename12, extname as extname15, isAbsolute as isAbsolute20, join as join106, relative as relative27, resolve as resolve35 } from "node:path";
|
|
109765
110187
|
init_writeLock();
|
|
109766
110188
|
var SOURCE_NAME_PATTERN3 = /^[a-z0-9][a-z0-9._-]*$/u;
|
|
109767
110189
|
function isDateSourceNamespace(value) {
|
|
@@ -109857,7 +110279,7 @@ function assertSafeFileInclude(value) {
|
|
|
109857
110279
|
}
|
|
109858
110280
|
async function readRegistryDocument(projectRoot, registryPath2) {
|
|
109859
110281
|
try {
|
|
109860
|
-
const content3 = await
|
|
110282
|
+
const content3 = await readFile86(join106(projectRoot, registryPath2), "utf8");
|
|
109861
110283
|
return content3.trim().length === 0 ? { sources: [] } : import_yaml47.default.parse(content3);
|
|
109862
110284
|
} catch (error) {
|
|
109863
110285
|
if (error instanceof Error && "code" in error && error.code === "ENOENT")
|
|
@@ -109975,7 +110397,7 @@ async function addFileSourceUnlocked(input) {
|
|
|
109975
110397
|
const record6 = entry2;
|
|
109976
110398
|
return record6.name !== input.name && record6.id !== input.name;
|
|
109977
110399
|
}), nextEntry];
|
|
109978
|
-
await atomicWriteFile(
|
|
110400
|
+
await atomicWriteFile(join106(input.projectRoot, DEFAULT_FILE_SOURCES_REGISTRY_PATH), import_yaml47.default.stringify({ sources: nextSources }));
|
|
109979
110401
|
const updated = await loadSourcesRegistry({ rootDir: input.projectRoot });
|
|
109980
110402
|
const entry = updated.files.find((source2) => source2.name === input.name || source2.id === input.name);
|
|
109981
110403
|
if (entry === undefined) {
|
|
@@ -110031,7 +110453,7 @@ async function addLarkSourceUnlocked(input) {
|
|
|
110031
110453
|
const record6 = entry2;
|
|
110032
110454
|
return record6.name !== input.name && record6.id !== input.name;
|
|
110033
110455
|
}), nextEntry];
|
|
110034
|
-
await atomicWriteFile(
|
|
110456
|
+
await atomicWriteFile(join106(input.projectRoot, DEFAULT_LARK_SOURCES_REGISTRY_PATH), import_yaml47.default.stringify({ sources: nextSources }));
|
|
110035
110457
|
const updated = await loadSourcesRegistry({ rootDir: input.projectRoot });
|
|
110036
110458
|
const entry = updated.larks.find((source2) => source2.name === input.name || source2.id === input.name);
|
|
110037
110459
|
if (entry === undefined) {
|
|
@@ -110234,8 +110656,8 @@ init_writeLock();
|
|
|
110234
110656
|
var import_yaml48 = __toESM(require_dist(), 1);
|
|
110235
110657
|
import { existsSync as existsSync31 } from "node:fs";
|
|
110236
110658
|
import { createHash as createHash32 } from "node:crypto";
|
|
110237
|
-
import { readFile as
|
|
110238
|
-
import { isAbsolute as isAbsolute21, join as
|
|
110659
|
+
import { readFile as readFile87, readdir as readdir27, rm as rm22 } from "node:fs/promises";
|
|
110660
|
+
import { isAbsolute as isAbsolute21, join as join107, relative as relative28, resolve as resolve36, sep as sep8 } from "node:path";
|
|
110239
110661
|
function sourceIdentity(source2) {
|
|
110240
110662
|
if (source2.kind === "source.collection")
|
|
110241
110663
|
return;
|
|
@@ -110267,10 +110689,10 @@ function collectStrings(value, output) {
|
|
|
110267
110689
|
}
|
|
110268
110690
|
}
|
|
110269
110691
|
async function yamlReferences(input) {
|
|
110270
|
-
const absolutePath =
|
|
110692
|
+
const absolutePath = join107(input.projectRoot, input.path);
|
|
110271
110693
|
if (!existsSync31(absolutePath))
|
|
110272
110694
|
return false;
|
|
110273
|
-
const parsed = import_yaml48.default.parse(await
|
|
110695
|
+
const parsed = import_yaml48.default.parse(await readFile87(absolutePath, "utf8"));
|
|
110274
110696
|
const strings = [];
|
|
110275
110697
|
collectStrings(parsed, strings);
|
|
110276
110698
|
return strings.some((value) => stringReferencesSource(value, input.source));
|
|
@@ -110396,8 +110818,8 @@ async function registryRemovalWrite(projectRoot, source2) {
|
|
|
110396
110818
|
const path3 = registryPath2(source2.type);
|
|
110397
110819
|
if (path3 === null)
|
|
110398
110820
|
return;
|
|
110399
|
-
const absolutePath =
|
|
110400
|
-
const document4 = existsSync31(absolutePath) ? import_yaml48.default.parse(await
|
|
110821
|
+
const absolutePath = join107(projectRoot, path3);
|
|
110822
|
+
const document4 = existsSync31(absolutePath) ? import_yaml48.default.parse(await readFile87(absolutePath, "utf8")) : { sources: [] };
|
|
110401
110823
|
return {
|
|
110402
110824
|
path: absolutePath,
|
|
110403
110825
|
bytes: import_yaml48.default.stringify(removeDocumentEntry(document4, source2))
|
|
@@ -110415,7 +110837,7 @@ function safeManagedMaterializedPath(projectRoot, source2) {
|
|
|
110415
110837
|
return absolute;
|
|
110416
110838
|
}
|
|
110417
110839
|
function safeManagedManifestPath(projectRoot, source2) {
|
|
110418
|
-
const manifest = source2.manifest ??
|
|
110840
|
+
const manifest = source2.manifest ?? join107(source2.materializedAt, "manifest.json");
|
|
110419
110841
|
if (isAbsolute21(manifest))
|
|
110420
110842
|
throw unsafeOwnership(source2, manifest);
|
|
110421
110843
|
const absolute = resolve36(projectRoot, manifest);
|
|
@@ -110544,7 +110966,7 @@ async function createRemovalPlan(projectRoot, selector) {
|
|
|
110544
110966
|
source: source2,
|
|
110545
110967
|
registry: registryPath2(source2.type),
|
|
110546
110968
|
registryBytes: registryWrite?.bytes ?? null,
|
|
110547
|
-
managedBytes: source2.type === "note" || source2.type === "sessions" ? await
|
|
110969
|
+
managedBytes: source2.type === "note" || source2.type === "sessions" ? await readFile87(absoluteRemovals[0], "utf8") : null,
|
|
110548
110970
|
references,
|
|
110549
110971
|
cleanup,
|
|
110550
110972
|
manifestBytes: manifestWrite?.bytes ?? null
|
|
@@ -110577,10 +110999,10 @@ function publicRemovalResult(plan, action) {
|
|
|
110577
110999
|
};
|
|
110578
111000
|
}
|
|
110579
111001
|
async function pruneExtractRuntime(projectRoot, source2) {
|
|
110580
|
-
const fingerprintPath =
|
|
111002
|
+
const fingerprintPath = join107(projectRoot, ".tmp/context-runtime/extract/source-fingerprints.json");
|
|
110581
111003
|
const removedPhaseIds = new Set;
|
|
110582
111004
|
if (existsSync31(fingerprintPath)) {
|
|
110583
|
-
const parsed = JSON.parse(await
|
|
111005
|
+
const parsed = JSON.parse(await readFile87(fingerprintPath, "utf8"));
|
|
110584
111006
|
const phases = parsed.phases ?? {};
|
|
110585
111007
|
const next2 = Object.fromEntries(Object.entries(phases).filter(([phaseId, raw]) => {
|
|
110586
111008
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw))
|
|
@@ -110594,27 +111016,27 @@ async function pruneExtractRuntime(projectRoot, source2) {
|
|
|
110594
111016
|
await atomicWriteFile(fingerprintPath, `${JSON.stringify({ ...parsed, phases: next2 }, null, 2)}
|
|
110595
111017
|
`);
|
|
110596
111018
|
}
|
|
110597
|
-
const phaseOwnershipPath =
|
|
111019
|
+
const phaseOwnershipPath = join107(projectRoot, ".tmp/context-runtime/extract/custom-phase-candidates.json");
|
|
110598
111020
|
if (existsSync31(phaseOwnershipPath) && removedPhaseIds.size > 0) {
|
|
110599
|
-
const parsed = JSON.parse(await
|
|
111021
|
+
const parsed = JSON.parse(await readFile87(phaseOwnershipPath, "utf8"));
|
|
110600
111022
|
const phases = Object.fromEntries(Object.entries(parsed.phases ?? {}).filter(([phaseId]) => !removedPhaseIds.has(phaseId)));
|
|
110601
111023
|
await atomicWriteFile(phaseOwnershipPath, `${JSON.stringify({ ...parsed, phases }, null, 2)}
|
|
110602
111024
|
`);
|
|
110603
111025
|
}
|
|
110604
|
-
const symbolPath =
|
|
111026
|
+
const symbolPath = join107(projectRoot, ".tmp/context-runtime/extract/source-symbols.json");
|
|
110605
111027
|
if (existsSync31(symbolPath)) {
|
|
110606
|
-
const parsed = JSON.parse(await
|
|
111028
|
+
const parsed = JSON.parse(await readFile87(symbolPath, "utf8"));
|
|
110607
111029
|
const symbols = Array.isArray(parsed.symbols) ? parsed.symbols.filter((entry) => entry === null || typeof entry !== "object" || Array.isArray(entry) || entry.source !== source2.name) : [];
|
|
110608
111030
|
const phaseFingerprints = Object.fromEntries(Object.entries(parsed.phaseFingerprints ?? {}).filter(([phaseId]) => !removedPhaseIds.has(phaseId)));
|
|
110609
111031
|
await atomicWriteFile(symbolPath, `${JSON.stringify({ ...parsed, phaseFingerprints, symbols }, null, 2)}
|
|
110610
111032
|
`);
|
|
110611
111033
|
}
|
|
110612
|
-
const snapshotRoot =
|
|
111034
|
+
const snapshotRoot = join107(projectRoot, ".tmp/context-runtime/extract/candidates");
|
|
110613
111035
|
const visit4 = async (directory) => {
|
|
110614
111036
|
if (!existsSync31(directory))
|
|
110615
111037
|
return;
|
|
110616
111038
|
for (const entry of await readdir27(directory, { withFileTypes: true })) {
|
|
110617
|
-
const path3 =
|
|
111039
|
+
const path3 = join107(directory, entry.name);
|
|
110618
111040
|
if (entry.isDirectory()) {
|
|
110619
111041
|
await visit4(path3);
|
|
110620
111042
|
continue;
|
|
@@ -110622,7 +111044,7 @@ async function pruneExtractRuntime(projectRoot, source2) {
|
|
|
110622
111044
|
if (!entry.isFile() || !entry.name.endsWith(".json"))
|
|
110623
111045
|
continue;
|
|
110624
111046
|
try {
|
|
110625
|
-
const parsed = JSON.parse(await
|
|
111047
|
+
const parsed = JSON.parse(await readFile87(path3, "utf8"));
|
|
110626
111048
|
const refs = Array.isArray(parsed.source_refs) ? parsed.source_refs : [];
|
|
110627
111049
|
if (parsed.source === source2.name || refs.some((ref2) => typeof ref2 === "string" && stringReferencesSource(ref2, source2))) {
|
|
110628
111050
|
await rm22(path3, { force: true });
|
|
@@ -110664,7 +111086,7 @@ async function removeProjectSource(input) {
|
|
|
110664
111086
|
});
|
|
110665
111087
|
}
|
|
110666
111088
|
await applyAtomicFileBatch({
|
|
110667
|
-
transactionRoot:
|
|
111089
|
+
transactionRoot: join107(input.projectRoot, ".tmp", "context-runtime", "source-remove-transactions"),
|
|
110668
111090
|
writes: [...plan.registryWrite === undefined ? [] : [plan.registryWrite], ...plan.manifestWrite !== undefined ? [plan.manifestWrite] : []],
|
|
110669
111091
|
removals: plan.absoluteRemovals
|
|
110670
111092
|
});
|
|
@@ -110680,7 +111102,7 @@ init_workspace();
|
|
|
110680
111102
|
init_writeLock();
|
|
110681
111103
|
init_durableMultiFileTransaction();
|
|
110682
111104
|
init_durableSingleFileTransaction();
|
|
110683
|
-
import { readFile as
|
|
111105
|
+
import { readFile as readFile88 } from "node:fs/promises";
|
|
110684
111106
|
import ts from "typescript";
|
|
110685
111107
|
function generateSourceConfiguration(text10, selected) {
|
|
110686
111108
|
const file = ts.createSourceFile("index.ts", text10, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
|
|
@@ -110820,7 +111242,7 @@ function generateSourceConfiguration(text10, selected) {
|
|
|
110820
111242
|
async function configureRegisteredSources(projectRoot, selected) {
|
|
110821
111243
|
return withProjectWriteLock(projectRoot, "source-project-configuration", async () => {
|
|
110822
111244
|
const path3 = "src/index.ts";
|
|
110823
|
-
const config = JSON.parse(await
|
|
111245
|
+
const config = JSON.parse(await readFile88(await safeProjectTarget(projectRoot, "package.json"), "utf8"));
|
|
110824
111246
|
if (config.context?.entry !== path3)
|
|
110825
111247
|
return {
|
|
110826
111248
|
status: "manual",
|
|
@@ -110829,7 +111251,7 @@ async function configureRegisteredSources(projectRoot, selected) {
|
|
|
110829
111251
|
sources: selected
|
|
110830
111252
|
};
|
|
110831
111253
|
const target = await safeProjectTarget(projectRoot, path3);
|
|
110832
|
-
const text10 = await
|
|
111254
|
+
const text10 = await readFile88(target, "utf8");
|
|
110833
111255
|
const updated = generateSourceConfiguration(text10, selected);
|
|
110834
111256
|
if (updated === undefined)
|
|
110835
111257
|
return {
|
|
@@ -110909,7 +111331,7 @@ async function readIncludeList(projectRoot, path3) {
|
|
|
110909
111331
|
}
|
|
110910
111332
|
let content3;
|
|
110911
111333
|
try {
|
|
110912
|
-
content3 = await
|
|
111334
|
+
content3 = await readFile92(isAbsolute22(trimmed) ? resolve37(trimmed) : resolve37(projectRoot, trimmed), "utf8");
|
|
110913
111335
|
} catch (error) {
|
|
110914
111336
|
throw new ContextError(ExitCode.UserError, `cannot read include list: ${trimmed}`, {
|
|
110915
111337
|
category: ErrorCategory.UserInputInvalid,
|
|
@@ -111307,10 +111729,10 @@ init_exitCode();
|
|
|
111307
111729
|
var import_yaml51 = __toESM(require_dist(), 1);
|
|
111308
111730
|
import { constants as constants6, existsSync as existsSync32 } from "node:fs";
|
|
111309
111731
|
import { lstat as lstat13, open as open5, readdir as readdir28 } from "node:fs/promises";
|
|
111310
|
-
import { dirname as
|
|
111311
|
-
import { fileURLToPath as
|
|
111732
|
+
import { dirname as dirname44, join as join109, resolve as resolve38 } from "node:path";
|
|
111733
|
+
import { fileURLToPath as fileURLToPath9 } from "node:url";
|
|
111312
111734
|
function bundledSkillRoot() {
|
|
111313
|
-
const directory =
|
|
111735
|
+
const directory = dirname44(fileURLToPath9(import.meta.url));
|
|
111314
111736
|
const root2 = [resolve38(directory, "indexers/bundles"), resolve38(directory, "../../dist/indexers/bundles")].find((path3) => existsSync32(path3));
|
|
111315
111737
|
if (!root2)
|
|
111316
111738
|
throw new TypeError("Bundled skill files are unavailable; build or reinstall the Context CLI.");
|
|
@@ -111337,7 +111759,7 @@ async function readProductionSkills(root2) {
|
|
|
111337
111759
|
const entries2 = (await readdir28(root2, { withFileTypes: true })).filter((entry) => entry.isDirectory()).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
111338
111760
|
const skills = [];
|
|
111339
111761
|
for (const directory of entries2) {
|
|
111340
|
-
const entry =
|
|
111762
|
+
const entry = join109(root2, directory.name, "SKILL.md");
|
|
111341
111763
|
if (!(await lstat13(entry)).isFile())
|
|
111342
111764
|
throw new TypeError(`Skill entry must be a regular file: ${entry}`);
|
|
111343
111765
|
const handle2 = await open5(entry, constants6.O_RDONLY | constants6.O_NOFOLLOW | constants6.O_NONBLOCK);
|
|
@@ -111472,7 +111894,7 @@ init_exitCode();
|
|
|
111472
111894
|
init_workflowProvider();
|
|
111473
111895
|
init_workspace();
|
|
111474
111896
|
import { existsSync as existsSync33 } from "node:fs";
|
|
111475
|
-
import { dirname as
|
|
111897
|
+
import { dirname as dirname45, resolve as resolve39 } from "node:path";
|
|
111476
111898
|
function shellQuote7(value) {
|
|
111477
111899
|
return /^[A-Za-z0-9._/=-]+$/u.test(value) ? value : `'${value.replaceAll("'", `'"'"'`)}'`;
|
|
111478
111900
|
}
|
|
@@ -111505,10 +111927,10 @@ function readyResult(input, projectRoot, relocation) {
|
|
|
111505
111927
|
return {
|
|
111506
111928
|
schema: "context.entry.v1",
|
|
111507
111929
|
guidance: {
|
|
111508
|
-
knowledge_updates: { path: resolve39(
|
|
111509
|
-
workspace_prepare: { path: resolve39(
|
|
111510
|
-
workspace_commit: { path: resolve39(
|
|
111511
|
-
workspace_restore: { path: resolve39(
|
|
111930
|
+
knowledge_updates: { path: resolve39(dirname45(contextWorkflowProviderPath()), "resources/procedures/knowledge-updates.md") },
|
|
111931
|
+
workspace_prepare: { path: resolve39(dirname45(contextWorkflowProviderPath()), "resources/procedures/workspace-prepare.md") },
|
|
111932
|
+
workspace_commit: { path: resolve39(dirname45(contextWorkflowProviderPath()), "resources/procedures/workspace-commit.md") },
|
|
111933
|
+
workspace_restore: { path: resolve39(dirname45(contextWorkflowProviderPath()), "resources/procedures/workspace-restore.md") }
|
|
111512
111934
|
},
|
|
111513
111935
|
state: relocation ? "workspace-relocation-required" : "workspace-ready",
|
|
111514
111936
|
cwd: resolve39(input.cwd),
|
|
@@ -111745,8 +112167,8 @@ init_cliFeedback();
|
|
|
111745
112167
|
init_errors3();
|
|
111746
112168
|
init_exitCode();
|
|
111747
112169
|
import { existsSync as existsSync35 } from "node:fs";
|
|
111748
|
-
import { dirname as
|
|
111749
|
-
import { fileURLToPath as
|
|
112170
|
+
import { dirname as dirname47, join as join111, resolve as resolve40 } from "node:path";
|
|
112171
|
+
import { fileURLToPath as fileURLToPath10 } from "node:url";
|
|
111750
112172
|
|
|
111751
112173
|
// src/project/pluginInstallTargets.ts
|
|
111752
112174
|
init_cliFeedback();
|
|
@@ -111754,9 +112176,9 @@ init_errors3();
|
|
|
111754
112176
|
init_exitCode();
|
|
111755
112177
|
import { execFile as execFile13 } from "node:child_process";
|
|
111756
112178
|
import { existsSync as existsSync34 } from "node:fs";
|
|
111757
|
-
import { cp as cp2, mkdir as
|
|
112179
|
+
import { cp as cp2, mkdir as mkdir36, readdir as readdir29, readFile as readFile93, rename as rename9, rm as rm23, writeFile as writeFile28 } from "node:fs/promises";
|
|
111758
112180
|
import { homedir as homedir2 } from "node:os";
|
|
111759
|
-
import { dirname as
|
|
112181
|
+
import { dirname as dirname46, join as join110 } from "node:path";
|
|
111760
112182
|
import { promisify as promisify13 } from "node:util";
|
|
111761
112183
|
var execFileAsync7 = promisify13(execFile13);
|
|
111762
112184
|
var MARKETPLACE_NAME = "c4a";
|
|
@@ -111810,23 +112232,23 @@ async function claudePluginInstalled(pluginId) {
|
|
|
111810
112232
|
}
|
|
111811
112233
|
}
|
|
111812
112234
|
function codexHome() {
|
|
111813
|
-
return process.env.CODEX_HOME?.trim() ||
|
|
112235
|
+
return process.env.CODEX_HOME?.trim() || join110(homedir2(), ".codex");
|
|
111814
112236
|
}
|
|
111815
112237
|
function claudePluginCacheRoot() {
|
|
111816
112238
|
const explicitRoot = process.env[CLAUDE_PLUGIN_CACHE_ROOT_ENV2]?.trim();
|
|
111817
112239
|
if (explicitRoot)
|
|
111818
112240
|
return explicitRoot;
|
|
111819
112241
|
const home = process.env[CLAUDE_PLUGIN_CACHE_HOME_ENV2]?.trim() || homedir2();
|
|
111820
|
-
return
|
|
112242
|
+
return join110(home, ".claude", "plugins", "cache");
|
|
111821
112243
|
}
|
|
111822
112244
|
function sharedSkillsRoot() {
|
|
111823
|
-
return process.env[SHARED_SKILLS_ROOT_ENV]?.trim() ||
|
|
112245
|
+
return process.env[SHARED_SKILLS_ROOT_ENV]?.trim() || join110(homedir2(), ".agents", "skills");
|
|
111824
112246
|
}
|
|
111825
112247
|
function claudeSkillsRoot() {
|
|
111826
|
-
return process.env[CLAUDE_SKILLS_ROOT_ENV]?.trim() ||
|
|
112248
|
+
return process.env[CLAUDE_SKILLS_ROOT_ENV]?.trim() || join110(homedir2(), ".claude", "skills");
|
|
111827
112249
|
}
|
|
111828
112250
|
function cursorPluginRoot() {
|
|
111829
|
-
return process.env[CURSOR_PLUGIN_ROOT_ENV]?.trim() ||
|
|
112251
|
+
return process.env[CURSOR_PLUGIN_ROOT_ENV]?.trim() || join110(homedir2(), ".cursor", "plugins", "local", PLUGIN_NAME);
|
|
111830
112252
|
}
|
|
111831
112253
|
function blockHeader(line) {
|
|
111832
112254
|
const match = line.match(/^\s*\[([^\]]+)\]\s*$/u);
|
|
@@ -111877,8 +112299,8 @@ function pruneLegacyCodexConfigContent(content3) {
|
|
|
111877
112299
|
`), removed };
|
|
111878
112300
|
}
|
|
111879
112301
|
async function pruneLegacyCodexConfig(dryRun, steps) {
|
|
111880
|
-
const configPath =
|
|
111881
|
-
const current2 = await
|
|
112302
|
+
const configPath = join110(codexHome(), "config.toml");
|
|
112303
|
+
const current2 = await readFile93(configPath, "utf8").catch(() => "");
|
|
111882
112304
|
if (!current2)
|
|
111883
112305
|
return;
|
|
111884
112306
|
const next2 = pruneLegacyCodexConfigContent(current2);
|
|
@@ -111890,11 +112312,11 @@ async function pruneLegacyCodexConfig(dryRun, steps) {
|
|
|
111890
112312
|
status: dryRun ? "planned" : "ran"
|
|
111891
112313
|
});
|
|
111892
112314
|
if (!dryRun) {
|
|
111893
|
-
await
|
|
112315
|
+
await writeFile28(configPath, next2.content, "utf8");
|
|
111894
112316
|
}
|
|
111895
112317
|
}
|
|
111896
112318
|
async function pruneCodexPluginCacheForName(pluginName, keepVersion, dryRun, steps) {
|
|
111897
|
-
const cacheRoot =
|
|
112319
|
+
const cacheRoot = join110(codexHome(), "plugins", "cache", MARKETPLACE_NAME, pluginName);
|
|
111898
112320
|
if (!existsSync34(cacheRoot))
|
|
111899
112321
|
return;
|
|
111900
112322
|
const versions = (await readdir29(cacheRoot, { withFileTypes: true }).catch(() => [])).filter((entry) => entry.isDirectory() && entry.name !== keepVersion).map((entry) => entry.name).sort();
|
|
@@ -111906,7 +112328,7 @@ async function pruneCodexPluginCacheForName(pluginName, keepVersion, dryRun, ste
|
|
|
111906
112328
|
status: dryRun ? "planned" : "ran"
|
|
111907
112329
|
});
|
|
111908
112330
|
if (!dryRun)
|
|
111909
|
-
await Promise.all(versions.map((version3) => rm23(
|
|
112331
|
+
await Promise.all(versions.map((version3) => rm23(join110(cacheRoot, version3), { recursive: true, force: true })));
|
|
111910
112332
|
}
|
|
111911
112333
|
async function pruneCodexPluginCache(currentVersion, dryRun, steps) {
|
|
111912
112334
|
await pruneCodexPluginCacheForName(PLUGIN_NAME, currentVersion, dryRun, steps);
|
|
@@ -111930,15 +112352,15 @@ async function pruneClaudeOrphanContextCache(dryRun, steps) {
|
|
|
111930
112352
|
for (const marketplace of marketplaces) {
|
|
111931
112353
|
if (!marketplace.isDirectory())
|
|
111932
112354
|
continue;
|
|
111933
|
-
const pluginDir =
|
|
112355
|
+
const pluginDir = join110(cacheRoot, marketplace.name, PLUGIN_NAME);
|
|
111934
112356
|
if (!existsSync34(pluginDir))
|
|
111935
112357
|
continue;
|
|
111936
112358
|
const versions = await readdir29(pluginDir, { withFileTypes: true }).catch(() => []);
|
|
111937
112359
|
for (const version3 of versions) {
|
|
111938
112360
|
if (!version3.isDirectory())
|
|
111939
112361
|
continue;
|
|
111940
|
-
const versionDir =
|
|
111941
|
-
if (!existsSync34(
|
|
112362
|
+
const versionDir = join110(pluginDir, version3.name);
|
|
112363
|
+
if (!existsSync34(join110(versionDir, ORPHAN_MARKER2)))
|
|
111942
112364
|
continue;
|
|
111943
112365
|
removed.push(`${marketplace.name}/${PLUGIN_NAME}/${version3.name}`);
|
|
111944
112366
|
if (!dryRun) {
|
|
@@ -111948,7 +112370,7 @@ async function pruneClaudeOrphanContextCache(dryRun, steps) {
|
|
|
111948
112370
|
if (!dryRun && await isEmptyDir2(pluginDir)) {
|
|
111949
112371
|
await rm23(pluginDir, { recursive: true, force: true });
|
|
111950
112372
|
}
|
|
111951
|
-
const marketplaceDir =
|
|
112373
|
+
const marketplaceDir = join110(cacheRoot, marketplace.name);
|
|
111952
112374
|
if (!dryRun && await isEmptyDir2(marketplaceDir)) {
|
|
111953
112375
|
await rm23(marketplaceDir, { recursive: true, force: true });
|
|
111954
112376
|
}
|
|
@@ -111969,7 +112391,7 @@ async function pruneClaudeLegacyPluginCache(dryRun, steps) {
|
|
|
111969
112391
|
return;
|
|
111970
112392
|
const removed = [];
|
|
111971
112393
|
for (const pluginName of LEGACY_PLUGIN_NAMES) {
|
|
111972
|
-
const pluginDir =
|
|
112394
|
+
const pluginDir = join110(cacheRoot, MARKETPLACE_NAME, pluginName);
|
|
111973
112395
|
if (!existsSync34(pluginDir))
|
|
111974
112396
|
continue;
|
|
111975
112397
|
removed.push(`${MARKETPLACE_NAME}/${pluginName}`);
|
|
@@ -111986,11 +112408,11 @@ async function pruneClaudeLegacyPluginCache(dryRun, steps) {
|
|
|
111986
112408
|
}
|
|
111987
112409
|
}
|
|
111988
112410
|
async function pruneClaudeSupersededContextCache(root2, dryRun, steps) {
|
|
111989
|
-
const manifest = await
|
|
112411
|
+
const manifest = await readFile93(join110(root2, "claude", ".claude-plugin", "plugin.json"), "utf8").then((content3) => JSON.parse(content3)).catch(() => null);
|
|
111990
112412
|
const currentVersion = typeof manifest?.version === "string" ? manifest.version : null;
|
|
111991
112413
|
if (!currentVersion)
|
|
111992
112414
|
return;
|
|
111993
|
-
const pluginDir =
|
|
112415
|
+
const pluginDir = join110(claudePluginCacheRoot(), MARKETPLACE_NAME, PLUGIN_NAME);
|
|
111994
112416
|
const staleVersions = (await readdir29(pluginDir, { withFileTypes: true }).catch(() => [])).filter((entry) => entry.isDirectory() && entry.name !== currentVersion).map((entry) => entry.name);
|
|
111995
112417
|
if (staleVersions.length === 0)
|
|
111996
112418
|
return;
|
|
@@ -112000,7 +112422,7 @@ async function pruneClaudeSupersededContextCache(root2, dryRun, steps) {
|
|
|
112000
112422
|
status: dryRun ? "planned" : "ran"
|
|
112001
112423
|
});
|
|
112002
112424
|
if (!dryRun) {
|
|
112003
|
-
await Promise.all(staleVersions.map((version3) => rm23(
|
|
112425
|
+
await Promise.all(staleVersions.map((version3) => rm23(join110(pluginDir, version3), { recursive: true, force: true })));
|
|
112004
112426
|
}
|
|
112005
112427
|
}
|
|
112006
112428
|
function enableCodexPluginConfig(content3) {
|
|
@@ -112064,36 +112486,36 @@ source = ${JSON.stringify(root2)}
|
|
|
112064
112486
|
`;
|
|
112065
112487
|
}
|
|
112066
112488
|
async function ensureCodexPluginEnabled() {
|
|
112067
|
-
const configPath =
|
|
112068
|
-
await
|
|
112069
|
-
const current2 = await
|
|
112489
|
+
const configPath = join110(codexHome(), "config.toml");
|
|
112490
|
+
await mkdir36(dirname46(configPath), { recursive: true });
|
|
112491
|
+
const current2 = await readFile93(configPath, "utf8").catch(() => "");
|
|
112070
112492
|
const next2 = enableCodexPluginConfig(current2);
|
|
112071
112493
|
if (next2 !== current2) {
|
|
112072
|
-
await
|
|
112494
|
+
await writeFile28(configPath, next2, "utf8");
|
|
112073
112495
|
}
|
|
112074
112496
|
}
|
|
112075
112497
|
async function ensureCodexLocalMarketplace(root2) {
|
|
112076
|
-
const configPath =
|
|
112077
|
-
await
|
|
112078
|
-
const current2 = await
|
|
112498
|
+
const configPath = join110(codexHome(), "config.toml");
|
|
112499
|
+
await mkdir36(dirname46(configPath), { recursive: true });
|
|
112500
|
+
const current2 = await readFile93(configPath, "utf8").catch(() => "");
|
|
112079
112501
|
const next2 = upsertCodexLocalMarketplaceConfig(current2, root2);
|
|
112080
112502
|
if (next2 !== current2) {
|
|
112081
|
-
await
|
|
112503
|
+
await writeFile28(configPath, next2, "utf8");
|
|
112082
112504
|
}
|
|
112083
112505
|
}
|
|
112084
112506
|
async function codexPluginVersion(root2) {
|
|
112085
|
-
const manifestPath =
|
|
112086
|
-
const manifest = JSON.parse(await
|
|
112507
|
+
const manifestPath = join110(root2, "codex", ".codex-plugin", "plugin.json");
|
|
112508
|
+
const manifest = JSON.parse(await readFile93(manifestPath, "utf8"));
|
|
112087
112509
|
if (typeof manifest.version !== "string" || !/^[A-Za-z0-9][A-Za-z0-9._-]*$/u.test(manifest.version)) {
|
|
112088
112510
|
throw new Error(`Codex plugin manifest has an invalid version: ${manifestPath}`);
|
|
112089
112511
|
}
|
|
112090
112512
|
return manifest.version;
|
|
112091
112513
|
}
|
|
112092
112514
|
function codexPluginCacheDir(version3) {
|
|
112093
|
-
return
|
|
112515
|
+
return join110(codexHome(), "plugins", "cache", MARKETPLACE_NAME, PLUGIN_NAME, version3);
|
|
112094
112516
|
}
|
|
112095
112517
|
async function replaceDirectoryFromSource(source2, target) {
|
|
112096
|
-
await
|
|
112518
|
+
await mkdir36(dirname46(target), { recursive: true });
|
|
112097
112519
|
const temporary = `${target}.tmp-${process.pid}-${Date.now()}`;
|
|
112098
112520
|
const previous3 = `${target}.previous-${process.pid}-${Date.now()}`;
|
|
112099
112521
|
await rm23(temporary, { recursive: true, force: true });
|
|
@@ -112113,7 +112535,7 @@ async function replaceDirectoryFromSource(source2, target) {
|
|
|
112113
112535
|
}
|
|
112114
112536
|
}
|
|
112115
112537
|
async function materializeCodexPluginCache(root2, version3, dryRun, steps) {
|
|
112116
|
-
const source2 =
|
|
112538
|
+
const source2 = join110(root2, "codex");
|
|
112117
112539
|
const target = codexPluginCacheDir(version3);
|
|
112118
112540
|
steps.push({
|
|
112119
112541
|
agent: "codex",
|
|
@@ -112125,16 +112547,16 @@ async function materializeCodexPluginCache(root2, version3, dryRun, steps) {
|
|
|
112125
112547
|
await replaceDirectoryFromSource(source2, target);
|
|
112126
112548
|
}
|
|
112127
112549
|
async function bundledProviderSkillNames(root2) {
|
|
112128
|
-
const skillsRoot =
|
|
112550
|
+
const skillsRoot = join110(root2, "skills");
|
|
112129
112551
|
const entries2 = await readdir29(skillsRoot, { withFileTypes: true });
|
|
112130
112552
|
const names = [];
|
|
112131
112553
|
for (const entry of entries2) {
|
|
112132
112554
|
if (!entry.isDirectory() || entry.name === "context")
|
|
112133
112555
|
continue;
|
|
112134
|
-
const skillPath =
|
|
112556
|
+
const skillPath = join110(skillsRoot, entry.name, "SKILL.md");
|
|
112135
112557
|
if (!existsSync34(skillPath))
|
|
112136
112558
|
continue;
|
|
112137
|
-
const skill = await
|
|
112559
|
+
const skill = await readFile93(skillPath, "utf8");
|
|
112138
112560
|
if (!/^\s*context-role:\s*["']?indexer-provider["']?\s*$/mu.test(skill))
|
|
112139
112561
|
continue;
|
|
112140
112562
|
names.push(entry.name);
|
|
@@ -112146,10 +112568,10 @@ async function bundledProviderSkillNames(root2) {
|
|
|
112146
112568
|
return names;
|
|
112147
112569
|
}
|
|
112148
112570
|
async function materializeProviderSkills(root2, targetRoot, agent, dryRun, steps) {
|
|
112149
|
-
const sourceRoot2 =
|
|
112571
|
+
const sourceRoot2 = join110(root2, "skills");
|
|
112150
112572
|
for (const name3 of await bundledProviderSkillNames(root2)) {
|
|
112151
|
-
const source2 =
|
|
112152
|
-
const target =
|
|
112573
|
+
const source2 = join110(sourceRoot2, name3);
|
|
112574
|
+
const target = join110(targetRoot, name3);
|
|
112153
112575
|
steps.push({
|
|
112154
112576
|
agent,
|
|
112155
112577
|
command: `materialize lifecycle Provider skill: ${shellQuote8(source2)} -> ${shellQuote8(target)}`,
|
|
@@ -112160,7 +112582,7 @@ async function materializeProviderSkills(root2, targetRoot, agent, dryRun, steps
|
|
|
112160
112582
|
}
|
|
112161
112583
|
}
|
|
112162
112584
|
async function installCursor(root2, dryRun, steps) {
|
|
112163
|
-
const source2 =
|
|
112585
|
+
const source2 = join110(root2, "cursor");
|
|
112164
112586
|
const target = cursorPluginRoot();
|
|
112165
112587
|
steps.push({
|
|
112166
112588
|
agent: "cursor",
|
|
@@ -112215,12 +112637,12 @@ async function installCodex(root2, dryRun, steps) {
|
|
|
112215
112637
|
steps.push({ agent: "codex", command: commandLine("codex", addArgs), status: dryRun ? "planned" : "ran" });
|
|
112216
112638
|
steps.push({
|
|
112217
112639
|
agent: "codex",
|
|
112218
|
-
command: `ensure ${shellQuote8(
|
|
112640
|
+
command: `ensure ${shellQuote8(join110(codexHome(), "config.toml"))} registers local marketplace ${shellQuote8(MARKETPLACE_NAME)}`,
|
|
112219
112641
|
status: dryRun ? "planned" : "ran"
|
|
112220
112642
|
});
|
|
112221
112643
|
steps.push({
|
|
112222
112644
|
agent: "codex",
|
|
112223
|
-
command: `ensure ${shellQuote8(
|
|
112645
|
+
command: `ensure ${shellQuote8(join110(codexHome(), "config.toml"))} enables ${shellQuote8(PLUGIN_ID)}`,
|
|
112224
112646
|
status: dryRun ? "planned" : "ran"
|
|
112225
112647
|
});
|
|
112226
112648
|
if (dryRun) {
|
|
@@ -112259,10 +112681,10 @@ function pluginAgentOption(value) {
|
|
|
112259
112681
|
}
|
|
112260
112682
|
function packageCandidateDirs() {
|
|
112261
112683
|
const dirs = [];
|
|
112262
|
-
let dir =
|
|
112684
|
+
let dir = dirname47(fileURLToPath10(import.meta.url));
|
|
112263
112685
|
for (let index2 = 0;index2 < 8; index2++) {
|
|
112264
112686
|
dirs.push(dir);
|
|
112265
|
-
const parent =
|
|
112687
|
+
const parent = dirname47(dir);
|
|
112266
112688
|
if (parent === dir)
|
|
112267
112689
|
break;
|
|
112268
112690
|
dir = parent;
|
|
@@ -112275,13 +112697,13 @@ function pluginRootCandidates() {
|
|
|
112275
112697
|
return [resolve40(envRoot)];
|
|
112276
112698
|
const candidates = [];
|
|
112277
112699
|
for (const dir of packageCandidateDirs()) {
|
|
112278
|
-
candidates.push(
|
|
112279
|
-
candidates.push(
|
|
112700
|
+
candidates.push(join111(dir, "plugins"));
|
|
112701
|
+
candidates.push(join111(dir, "dist", "plugins"));
|
|
112280
112702
|
}
|
|
112281
112703
|
return [...new Set(candidates)];
|
|
112282
112704
|
}
|
|
112283
112705
|
function isInstallablePluginRoot(root2) {
|
|
112284
|
-
return existsSync35(
|
|
112706
|
+
return existsSync35(join111(root2, ".claude-plugin", "marketplace.json")) && existsSync35(join111(root2, ".agents", "plugins", "marketplace.json")) && existsSync35(join111(root2, "claude", ".claude-plugin", "plugin.json")) && existsSync35(join111(root2, "codex", ".codex-plugin", "plugin.json")) && existsSync35(join111(root2, "cursor", ".cursor-plugin", "plugin.json")) && existsSync35(join111(root2, "skills"));
|
|
112285
112707
|
}
|
|
112286
112708
|
function resolveBundledPluginsRoot() {
|
|
112287
112709
|
const candidates = pluginRootCandidates();
|
|
@@ -112517,21 +112939,21 @@ function inferErrorCategory(message) {
|
|
|
112517
112939
|
}
|
|
112518
112940
|
function readQuickstartPath() {
|
|
112519
112941
|
try {
|
|
112520
|
-
let dir =
|
|
112942
|
+
let dir = dirname48(fileURLToPath11(import.meta.url));
|
|
112521
112943
|
for (let i2 = 0;i2 < 8; i2++) {
|
|
112522
|
-
const candidate =
|
|
112944
|
+
const candidate = join112(dir, "docs", "quickstart.md");
|
|
112523
112945
|
if (existsSync36(candidate))
|
|
112524
112946
|
return candidate;
|
|
112525
|
-
const pkg =
|
|
112947
|
+
const pkg = join112(dir, "package.json");
|
|
112526
112948
|
if (existsSync36(pkg))
|
|
112527
112949
|
return candidate;
|
|
112528
|
-
const parent =
|
|
112950
|
+
const parent = dirname48(dir);
|
|
112529
112951
|
if (parent === dir)
|
|
112530
112952
|
break;
|
|
112531
112953
|
dir = parent;
|
|
112532
112954
|
}
|
|
112533
112955
|
} catch {}
|
|
112534
|
-
return
|
|
112956
|
+
return join112(dirname48(fileURLToPath11(import.meta.url)), "docs", "quickstart.md");
|
|
112535
112957
|
}
|
|
112536
112958
|
var GREEN = "\x1B[32m";
|
|
112537
112959
|
var RESET = "\x1B[0m";
|
|
@@ -112673,7 +113095,7 @@ function createCliProgram() {
|
|
|
112673
113095
|
format: options.format === "json" ? "json" : "text",
|
|
112674
113096
|
afterApply: (projectRoot) => continueAfterProjectReview({
|
|
112675
113097
|
projectRoot,
|
|
112676
|
-
cliEntryPath:
|
|
113098
|
+
cliEntryPath: fileURLToPath11(import.meta.url),
|
|
112677
113099
|
managed: program2.opts().workflowManaged === true,
|
|
112678
113100
|
authorities: contextWorkflowAuthorities({
|
|
112679
113101
|
managed: program2.opts().workflowManaged === true,
|
|
@@ -112698,7 +113120,7 @@ function createCliProgram() {
|
|
|
112698
113120
|
format: options.format === "json" ? "json" : "text",
|
|
112699
113121
|
afterApply: (projectRoot) => continueAfterProjectReview({
|
|
112700
113122
|
projectRoot,
|
|
112701
|
-
cliEntryPath:
|
|
113123
|
+
cliEntryPath: fileURLToPath11(import.meta.url),
|
|
112702
113124
|
managed: options.managed === true || program2.opts().workflowManaged === true,
|
|
112703
113125
|
authorities: contextWorkflowAuthorities({
|
|
112704
113126
|
managed: options.managed === true || program2.opts().workflowManaged === true,
|
|
@@ -112719,7 +113141,7 @@ function createCliProgram() {
|
|
|
112719
113141
|
status: "approved",
|
|
112720
113142
|
afterApply: (projectRoot) => continueAfterProjectReview({
|
|
112721
113143
|
projectRoot,
|
|
112722
|
-
cliEntryPath:
|
|
113144
|
+
cliEntryPath: fileURLToPath11(import.meta.url),
|
|
112723
113145
|
managed: program2.opts().workflowManaged === true,
|
|
112724
113146
|
authorities: contextWorkflowAuthorities({
|
|
112725
113147
|
managed: program2.opts().workflowManaged === true,
|
|
@@ -112743,7 +113165,7 @@ function createCliProgram() {
|
|
|
112743
113165
|
status: "rejected",
|
|
112744
113166
|
afterApply: (projectRoot) => continueAfterProjectReview({
|
|
112745
113167
|
projectRoot,
|
|
112746
|
-
cliEntryPath:
|
|
113168
|
+
cliEntryPath: fileURLToPath11(import.meta.url),
|
|
112747
113169
|
managed: program2.opts().workflowManaged === true,
|
|
112748
113170
|
authorities: contextWorkflowAuthorities({
|
|
112749
113171
|
managed: program2.opts().workflowManaged === true,
|