@c4a/context-cli 0.7.85 → 0.7.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +202 -140
- package/indexers/contracts/profile-contract.json +245 -245
- package/indexers/release-manifest.json +1 -1
- package/package.json +13 -12
- 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/providers/context/manifest.json +7 -7
- package/providers/context/provider.yaml +1 -1
- package/providers/context/resources/manuals/guides/package-outputs.md +8 -2
- package/providers/context/resources/manuals/reference/package-templates.md +2 -1
package/cli.js
CHANGED
|
@@ -86493,12 +86493,32 @@ var init_knowledgeMap2 = __esm(() => {
|
|
|
86493
86493
|
|
|
86494
86494
|
// src/project/packageQuerySkillMigration.ts
|
|
86495
86495
|
import { existsSync as existsSync17 } from "node:fs";
|
|
86496
|
-
import { cp, mkdir as mkdir22, readFile as readFile58, rm as rm12 } from "node:fs/promises";
|
|
86497
|
-
import { dirname as dirname28, join as join66, resolve as resolve25 } from "node:path";
|
|
86498
|
-
async function
|
|
86499
|
-
const skill = await readFile58(join66(
|
|
86496
|
+
import { cp, mkdir as mkdir22, readdir as readdir16, readFile as readFile58, rm as rm12 } from "node:fs/promises";
|
|
86497
|
+
import { dirname as dirname28, join as join66, relative as relative21, resolve as resolve25 } from "node:path";
|
|
86498
|
+
async function skillLanguage(skillRoot) {
|
|
86499
|
+
const skill = await readFile58(join66(skillRoot, "SKILL.md"), "utf8").catch(() => "");
|
|
86500
86500
|
return /\p{Script=Han}/u.test(skill) ? "zh-CN" : "en";
|
|
86501
86501
|
}
|
|
86502
|
+
function shippedKbRoot(language) {
|
|
86503
|
+
const shippedRoot = resolveContextPackageTemplatesRoot();
|
|
86504
|
+
return join66(language === "zh-CN" ? join66(dirname28(shippedRoot), "package-templates.zh-CN") : shippedRoot, "kb");
|
|
86505
|
+
}
|
|
86506
|
+
async function treeFiles(root) {
|
|
86507
|
+
const entries2 = await readdir16(root, { recursive: true, withFileTypes: true });
|
|
86508
|
+
const files = new Map;
|
|
86509
|
+
for (const entry of entries2) {
|
|
86510
|
+
if (!entry.isFile())
|
|
86511
|
+
continue;
|
|
86512
|
+
const parent = entry.parentPath ?? entry.path ?? root;
|
|
86513
|
+
const path2 = join66(parent, entry.name);
|
|
86514
|
+
files.set(relative21(root, path2).split("\\").join("/"), await readFile58(path2, "utf8"));
|
|
86515
|
+
}
|
|
86516
|
+
return files;
|
|
86517
|
+
}
|
|
86518
|
+
async function sameTree(left, right) {
|
|
86519
|
+
const [a, b] = await Promise.all([treeFiles(left), treeFiles(right)]);
|
|
86520
|
+
return a.size === b.size && [...a].every(([path2, content3]) => b.get(path2) === content3);
|
|
86521
|
+
}
|
|
86502
86522
|
async function migrateLegacyQuerySkill(projectRoot, pkg) {
|
|
86503
86523
|
if (pkg.kind !== "package.kb")
|
|
86504
86524
|
return;
|
|
@@ -86508,9 +86528,8 @@ async function migrateLegacyQuerySkill(projectRoot, pkg) {
|
|
|
86508
86528
|
return;
|
|
86509
86529
|
const reviewState = (await inspectPackageTemplateReview(projectRoot, pkg)).state;
|
|
86510
86530
|
const starterUntouched = reviewState === "review-required" || reviewState === "starter-accepted";
|
|
86511
|
-
const language = await
|
|
86512
|
-
const
|
|
86513
|
-
const shippedKb = join66(language === "zh-CN" ? join66(dirname28(shippedRoot), "package-templates.zh-CN") : shippedRoot, "kb");
|
|
86531
|
+
const language = await skillLanguage(legacyRoot);
|
|
86532
|
+
const shippedKb = shippedKbRoot(language);
|
|
86514
86533
|
const target = join66(templateRoot, "skills", QUERY_SKILL);
|
|
86515
86534
|
await rm12(legacyRoot, { recursive: true, force: true });
|
|
86516
86535
|
if (!existsSync17(target))
|
|
@@ -86533,6 +86552,33 @@ async function migrateLegacyQuerySkills(projectRoot, packages) {
|
|
|
86533
86552
|
}
|
|
86534
86553
|
return results;
|
|
86535
86554
|
}
|
|
86555
|
+
async function refreshSharedQuerySkill(projectRoot, pkg) {
|
|
86556
|
+
if (pkg.kind !== "package.kb")
|
|
86557
|
+
return;
|
|
86558
|
+
const templateRoot = resolve25(projectRoot, pkg.template.path);
|
|
86559
|
+
const target = join66(templateRoot, "skills", QUERY_SKILL);
|
|
86560
|
+
if (!existsSync17(target))
|
|
86561
|
+
return;
|
|
86562
|
+
const language = await skillLanguage(target);
|
|
86563
|
+
const shipped = join66(shippedKbRoot(language), "skills", QUERY_SKILL);
|
|
86564
|
+
if (await sameTree(target, shipped))
|
|
86565
|
+
return;
|
|
86566
|
+
const reviewState = (await inspectPackageTemplateReview(projectRoot, pkg)).state;
|
|
86567
|
+
await rm12(target, { recursive: true, force: true });
|
|
86568
|
+
await cp(shipped, target, { recursive: true });
|
|
86569
|
+
if (reviewState === "review-required" || reviewState === "starter-accepted")
|
|
86570
|
+
await refreshStarterTemplateDigest(templateRoot);
|
|
86571
|
+
return { packageName: pkg.name, templatePath: pkg.template.path, language };
|
|
86572
|
+
}
|
|
86573
|
+
async function refreshSharedQuerySkills(projectRoot, packages) {
|
|
86574
|
+
const results = [];
|
|
86575
|
+
for (const pkg of packages) {
|
|
86576
|
+
const result = await refreshSharedQuerySkill(projectRoot, pkg);
|
|
86577
|
+
if (result !== undefined)
|
|
86578
|
+
results.push(result);
|
|
86579
|
+
}
|
|
86580
|
+
return results;
|
|
86581
|
+
}
|
|
86536
86582
|
var LEGACY_QUERY_SKILL = "knowledge-query", QUERY_SKILL = "context-knowledge-query", SEARCH_GUIDE = "others/context/search-guide.md";
|
|
86537
86583
|
var init_packageQuerySkillMigration = __esm(() => {
|
|
86538
86584
|
init_packageTemplateReview();
|
|
@@ -87317,6 +87363,10 @@ var init_diagramStyles = __esm(() => {
|
|
|
87317
87363
|
});
|
|
87318
87364
|
|
|
87319
87365
|
// src/project/packageSiteTheme.ts
|
|
87366
|
+
function siteMarkdownImports(cjkFriendly = "markdown-it-cjk-friendly") {
|
|
87367
|
+
return `import contextCjkFriendly from ${JSON.stringify(cjkFriendly)};
|
|
87368
|
+
`;
|
|
87369
|
+
}
|
|
87320
87370
|
function siteThemeLabels(lang) {
|
|
87321
87371
|
return lang.startsWith("zh") ? {
|
|
87322
87372
|
outline: { level: [2, 3], label: "本页目录" },
|
|
@@ -87361,28 +87411,10 @@ var init_packageSiteTheme = __esm(() => {
|
|
|
87361
87411
|
md.block.ruler.disable('snippet');
|
|
87362
87412
|
// CommonMark only closes **bold** after punctuation when whitespace or
|
|
87363
87413
|
// punctuation follows, so Chinese such as **用 MCP?**在 stays literal.
|
|
87364
|
-
//
|
|
87365
|
-
//
|
|
87366
|
-
|
|
87367
|
-
|
|
87368
|
-
md.inline.State = class extends InlineState {
|
|
87369
|
-
scanDelims(start, canSplitWord) {
|
|
87370
|
-
const scanned = super.scanDelims(start, canSplitWord);
|
|
87371
|
-
const end = start + scanned.length;
|
|
87372
|
-
// Whole code points, so extension-plane Han counts too.
|
|
87373
|
-
const before = Array.from(this.src.slice(Math.max(0, start - 2), start)).pop() ?? ' ';
|
|
87374
|
-
const after = Array.from(this.src.slice(end, Math.min(end + 2, this.posMax)))[0] ?? ' ';
|
|
87375
|
-
const lastCjk = cjkLetter.test(before), nextCjk = cjkLetter.test(after);
|
|
87376
|
-
if (!lastCjk && !nextCjk) return scanned;
|
|
87377
|
-
const { isMdAsciiPunct, isPunctChar, isWhiteSpace } = md.utils;
|
|
87378
|
-
const lastCode = before.codePointAt(0), nextCode = after.codePointAt(0);
|
|
87379
|
-
const lastPunct = isMdAsciiPunct(lastCode) || isPunctChar(before), nextPunct = isMdAsciiPunct(nextCode) || isPunctChar(after);
|
|
87380
|
-
const lastSpace = isWhiteSpace(lastCode), nextSpace = isWhiteSpace(nextCode);
|
|
87381
|
-
const left = !nextSpace && (!nextPunct || lastSpace || lastPunct || lastCjk);
|
|
87382
|
-
const right = !lastSpace && (!lastPunct || nextSpace || nextPunct || nextCjk);
|
|
87383
|
-
return { ...scanned, can_open: left && (canSplitWord || !right || lastPunct), can_close: right && (canSplitWord || !left || nextPunct) };
|
|
87384
|
-
}
|
|
87385
|
-
};
|
|
87414
|
+
// Apply the CJK-friendly amendment (markdown-it-cjk-friendly): a CJK
|
|
87415
|
+
// character beside a * run counts like whitespace; _ and runs with no CJK
|
|
87416
|
+
// character beside them keep the CommonMark result.
|
|
87417
|
+
md.use(contextCjkFriendly);
|
|
87386
87418
|
const linkOpen = md.renderer.rules.link_open;
|
|
87387
87419
|
md.renderer.rules.link_open = (tokens, index, options, env, self) => {
|
|
87388
87420
|
// Let VitePress normalize the base and .md URL before adding a target;
|
|
@@ -88147,7 +88179,7 @@ var init_packageSiteBranding = __esm(() => {
|
|
|
88147
88179
|
|
|
88148
88180
|
// src/project/packageSiteExtensions.ts
|
|
88149
88181
|
import { createHash as createHash18 } from "node:crypto";
|
|
88150
|
-
import { lstat as lstat13, readdir as
|
|
88182
|
+
import { lstat as lstat13, readdir as readdir17, readFile as readFile60, mkdir as mkdir24, writeFile as writeFile19, symlink } from "node:fs/promises";
|
|
88151
88183
|
import { join as join69, dirname as dirname30, resolve as resolve26 } from "node:path";
|
|
88152
88184
|
function invalidSiteExtension(message) {
|
|
88153
88185
|
throw new ContextError(ExitCode.UserError, `Site extensions: ${message}. Update site.extensions, its src files or the knowledge-map target, then retry the build.`, {
|
|
@@ -88180,7 +88212,7 @@ async function readSiteExtensions(projectRoot, extensions) {
|
|
|
88180
88212
|
}
|
|
88181
88213
|
const files = [];
|
|
88182
88214
|
async function walk(directory, prefix) {
|
|
88183
|
-
for (const entry of (await
|
|
88215
|
+
for (const entry of (await readdir17(directory, { withFileTypes: true })).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
88184
88216
|
if (entry.name.startsWith(".") || ["node_modules", "dist"].includes(entry.name))
|
|
88185
88217
|
continue;
|
|
88186
88218
|
const path2 = prefix + entry.name;
|
|
@@ -88315,8 +88347,8 @@ function projectPackageArticleLinks(input) {
|
|
|
88315
88347
|
edits.push({ start: link.start, end: link.end, text: `${link.label} (not included in this package; knowledge source: \`${coordinate}\`)` });
|
|
88316
88348
|
continue;
|
|
88317
88349
|
}
|
|
88318
|
-
const
|
|
88319
|
-
const target =
|
|
88350
|
+
const relative22 = posix8.relative(posix8.dirname(input.outputPath), output);
|
|
88351
|
+
const target = relative22.split("/").map((segment2) => encodeURIComponent(segment2)).join("/") + suffix;
|
|
88320
88352
|
edits.push({ start: link.start, end: link.end, text: `[${link.label}](<${target}>)` });
|
|
88321
88353
|
}
|
|
88322
88354
|
let markdown = input.markdown;
|
|
@@ -88358,7 +88390,7 @@ var init_packageRenderCache = __esm(() => {
|
|
|
88358
88390
|
|
|
88359
88391
|
// src/project/packageAssets.ts
|
|
88360
88392
|
import { readFile as readFile62 } from "node:fs/promises";
|
|
88361
|
-
import { dirname as dirname31, relative as
|
|
88393
|
+
import { dirname as dirname31, relative as relative22, sep as sep6 } from "node:path";
|
|
88362
88394
|
function posixPath2(value) {
|
|
88363
88395
|
return value.split(sep6).join("/");
|
|
88364
88396
|
}
|
|
@@ -88370,7 +88402,7 @@ function decodedTarget2(value) {
|
|
|
88370
88402
|
}
|
|
88371
88403
|
}
|
|
88372
88404
|
function packageAssetPath(projectRoot, absolute) {
|
|
88373
|
-
const knowledgeRelPath = posixPath2(
|
|
88405
|
+
const knowledgeRelPath = posixPath2(relative22(projectRoot, absolute));
|
|
88374
88406
|
const prefix = "knowledge/assets/";
|
|
88375
88407
|
if (!knowledgeRelPath.startsWith(prefix))
|
|
88376
88408
|
throw new TypeError(`knowledge asset is outside ${prefix}: ${knowledgeRelPath}`);
|
|
@@ -88380,7 +88412,7 @@ function packageAssetPath(projectRoot, absolute) {
|
|
|
88380
88412
|
};
|
|
88381
88413
|
}
|
|
88382
88414
|
function packageMarkdownTarget(pageOutputPath, assetOutputPath) {
|
|
88383
|
-
const target = posixPath2(
|
|
88415
|
+
const target = posixPath2(relative22(dirname31(pageOutputPath), assetOutputPath));
|
|
88384
88416
|
return target.startsWith(".") ? target : `./${target}`;
|
|
88385
88417
|
}
|
|
88386
88418
|
async function projectPackageKnowledgeAssets(input) {
|
|
@@ -88692,7 +88724,7 @@ var init_packageAssetOptimization = __esm(() => {
|
|
|
88692
88724
|
// src/project/packageAssetDelivery.ts
|
|
88693
88725
|
import { execFile as execFile8 } from "node:child_process";
|
|
88694
88726
|
import { realpath as realpath10 } from "node:fs/promises";
|
|
88695
|
-
import { join as join71, relative as
|
|
88727
|
+
import { join as join71, relative as relative23, sep as sep7 } from "node:path";
|
|
88696
88728
|
import { promisify as promisify8 } from "node:util";
|
|
88697
88729
|
async function git(projectRoot, args) {
|
|
88698
88730
|
try {
|
|
@@ -88712,7 +88744,7 @@ async function git(projectRoot, args) {
|
|
|
88712
88744
|
}
|
|
88713
88745
|
}
|
|
88714
88746
|
function repositoryPath(repoRoot, projectRoot, asset) {
|
|
88715
|
-
const path2 =
|
|
88747
|
+
const path2 = relative23(repoRoot, join71(projectRoot, asset.knowledgeRelPath)).split(sep7).join("/");
|
|
88716
88748
|
if (path2 === ".." || path2.startsWith("../") || path2.startsWith("/")) {
|
|
88717
88749
|
throw new ContextError(ExitCode.WorkspaceStateError, "knowledge asset is outside the current Git repository", {
|
|
88718
88750
|
category: ErrorCategory.WorkspaceStateInvalid,
|
|
@@ -89166,8 +89198,8 @@ var init_packageBuildContent = __esm(() => {
|
|
|
89166
89198
|
// src/project/siteTranslation.ts
|
|
89167
89199
|
import { createHash as createHash21 } from "node:crypto";
|
|
89168
89200
|
import { existsSync as existsSync19 } from "node:fs";
|
|
89169
|
-
import { mkdir as mkdir26, readFile as readFile64, readdir as
|
|
89170
|
-
import { dirname as dirname34, join as join73, relative as
|
|
89201
|
+
import { mkdir as mkdir26, readFile as readFile64, readdir as readdir18, rename as rename8, rm as rm13, writeFile as writeFile21 } from "node:fs/promises";
|
|
89202
|
+
import { dirname as dirname34, join as join73, relative as relative24, resolve as resolve27 } from "node:path";
|
|
89171
89203
|
function sha256(value) {
|
|
89172
89204
|
return createHash21("sha256").update(value).digest("hex");
|
|
89173
89205
|
}
|
|
@@ -89228,8 +89260,8 @@ async function readMapTranslation(projectRoot, locale) {
|
|
|
89228
89260
|
async function listTranslationFiles(root) {
|
|
89229
89261
|
if (!existsSync19(root))
|
|
89230
89262
|
return [];
|
|
89231
|
-
const entries2 = await
|
|
89232
|
-
return entries2.filter((entry) => entry.isFile() && entry.name.endsWith(".md")).map((entry) =>
|
|
89263
|
+
const entries2 = await readdir18(root, { withFileTypes: true, recursive: true });
|
|
89264
|
+
return entries2.filter((entry) => entry.isFile() && entry.name.endsWith(".md")).map((entry) => relative24(root, join73(entry.parentPath, entry.name)).split("\\").join("/"));
|
|
89233
89265
|
}
|
|
89234
89266
|
async function selectedArticles(projectRoot, packages) {
|
|
89235
89267
|
const approved = await listApprovedKnowledge(projectRoot);
|
|
@@ -89468,7 +89500,7 @@ async function submitSiteTranslation(projectRoot, packages, input, resolveInput)
|
|
|
89468
89500
|
issues.push({ locale: article.locale, target: article.approved_path, issues: ["Unknown locale or approved article."] });
|
|
89469
89501
|
continue;
|
|
89470
89502
|
}
|
|
89471
|
-
const draftPath2 =
|
|
89503
|
+
const draftPath2 = relative24(resolve27(projectRoot), resolve27(resolveInput(article.file))).split("\\").join("/");
|
|
89472
89504
|
if (draftPath2.startsWith(`${DRAFT_ROOT}/`))
|
|
89473
89505
|
drafts.push(draftPath2);
|
|
89474
89506
|
const content3 = await optionalText2(resolveInput(article.file));
|
|
@@ -89994,7 +90026,8 @@ async function writePackageSite(input) {
|
|
|
89994
90026
|
["vitepress", vitepressRoot],
|
|
89995
90027
|
["vue", dirname35(vueRequire.resolve("vue/package.json"))],
|
|
89996
90028
|
["@mermaid-js/layout-elk", dirname35(require2.resolve("@mermaid-js/layout-elk/package.json"))],
|
|
89997
|
-
["mermaid", dirname35(require2.resolve("mermaid/package.json"))]
|
|
90029
|
+
["mermaid", dirname35(require2.resolve("mermaid/package.json"))],
|
|
90030
|
+
["markdown-it-cjk-friendly", dirname35(require2.resolve("markdown-it-cjk-friendly/package.json"))]
|
|
89998
90031
|
]) {
|
|
89999
90032
|
await mkdir27(dirname35(join74(temporary, "node_modules", name3)), { recursive: true });
|
|
90000
90033
|
await symlink2(path2, join74(temporary, "node_modules", name3), "dir");
|
|
@@ -90096,7 +90129,7 @@ ${localized.body}`);
|
|
|
90096
90129
|
contextLocales: { primary: readers.primary, tags: readers.tags, labels: readers.labels, titles: readers.titles, preferenceKey: readers.preferenceKey }
|
|
90097
90130
|
}
|
|
90098
90131
|
};
|
|
90099
|
-
await writeFile22(join74(configRoot, "config.mjs"),
|
|
90132
|
+
await writeFile22(join74(configRoot, "config.mjs"), `${siteMarkdownImports()}const contextLocaleMarker = ${JSON.stringify(readers.translated ? marker : null)};
|
|
90100
90133
|
` + `export default { ...${JSON.stringify(config)}, markdown: { ${siteMarkdownConfig} },
|
|
90101
90134
|
` + ` transformHtml: html => html.replace(/<script id="check-dark-mode">[\\s\\S]*?<\\/script>/u, "") };
|
|
90102
90135
|
`);
|
|
@@ -90265,6 +90298,7 @@ var init_packageSite2 = __esm(() => {
|
|
|
90265
90298
|
PACKAGE_SITE_VERSION = `vitepress-site-v50-light-shared-preferences:${createHash22("sha256").update(JSON.stringify([
|
|
90266
90299
|
readPackageVersion(),
|
|
90267
90300
|
siteThemeVariables.toString(),
|
|
90301
|
+
siteMarkdownImports(),
|
|
90268
90302
|
siteMarkdownConfig,
|
|
90269
90303
|
siteThemeCss,
|
|
90270
90304
|
siteThemeScript,
|
|
@@ -90297,12 +90331,12 @@ var init_workspaceBuildVersion = __esm(() => {
|
|
|
90297
90331
|
|
|
90298
90332
|
// src/project/packageBuildStage.ts
|
|
90299
90333
|
import { mkdir as mkdir29, mkdtemp as mkdtemp3, readFile as readFile66, rename as rename9, rm as rm15, rmdir } from "node:fs/promises";
|
|
90300
|
-
import { dirname as dirname36, join as join76, relative as
|
|
90334
|
+
import { dirname as dirname36, join as join76, relative as relative25 } from "node:path";
|
|
90301
90335
|
async function withStagedPackageOutput(projectRoot, pkg, render) {
|
|
90302
90336
|
const tempRoot = join76(projectRoot, ".tmp");
|
|
90303
90337
|
await mkdir29(tempRoot, { recursive: true });
|
|
90304
90338
|
const stage = await mkdtemp3(join76(tempRoot, "package-build-"));
|
|
90305
|
-
const stagedPackage = { ...pkg, outDir:
|
|
90339
|
+
const stagedPackage = { ...pkg, outDir: relative25(projectRoot, join76(stage, pkg.name)) };
|
|
90306
90340
|
try {
|
|
90307
90341
|
await mkdir29(join76(projectRoot, stagedPackage.outDir), { recursive: true });
|
|
90308
90342
|
const value = await render(stagedPackage);
|
|
@@ -90577,8 +90611,8 @@ var init_newKnowledgePage = __esm(() => {
|
|
|
90577
90611
|
});
|
|
90578
90612
|
|
|
90579
90613
|
// src/project/repoContentLinks.ts
|
|
90580
|
-
import { lstat as lstat14, mkdir as mkdir30, readdir as
|
|
90581
|
-
import { dirname as dirname37, join as join77, relative as
|
|
90614
|
+
import { lstat as lstat14, mkdir as mkdir30, readdir as readdir19, readlink, symlink as symlink3, unlink as unlink2 } from "node:fs/promises";
|
|
90615
|
+
import { dirname as dirname37, join as join77, relative as relative26 } from "node:path";
|
|
90582
90616
|
function repoContentLinksNeedRepair(results) {
|
|
90583
90617
|
return results.some((item) => item.status === "missing" || item.status === "mismatch");
|
|
90584
90618
|
}
|
|
@@ -90623,7 +90657,7 @@ async function inspectRepoContentLinks(projectRoot, repair = false) {
|
|
|
90623
90657
|
async function obsolete(directory, prefix = "") {
|
|
90624
90658
|
if (!await info(directory))
|
|
90625
90659
|
return;
|
|
90626
|
-
for (const file of await
|
|
90660
|
+
for (const file of await readdir19(directory, { withFileTypes: true })) {
|
|
90627
90661
|
const mount = prefix + file.name;
|
|
90628
90662
|
const path2 = join77(directory, file.name);
|
|
90629
90663
|
if (file.isSymbolicLink() && !expected.has(mount)) {
|
|
@@ -90654,7 +90688,7 @@ async function inspectRepoContentLinks(projectRoot, repair = false) {
|
|
|
90654
90688
|
continue;
|
|
90655
90689
|
}
|
|
90656
90690
|
const existing = await info(path2);
|
|
90657
|
-
const target =
|
|
90691
|
+
const target = relative26(parent, entry.absolutePath).split("\\").join("/");
|
|
90658
90692
|
if (existing?.isSymbolicLink() && await readlink(path2) === target) {
|
|
90659
90693
|
results.push({ ...base, status: "ready" });
|
|
90660
90694
|
continue;
|
|
@@ -90953,7 +90987,7 @@ __export(exports_packageBuilder, {
|
|
|
90953
90987
|
});
|
|
90954
90988
|
import { createHash as createHash23 } from "node:crypto";
|
|
90955
90989
|
import { existsSync as existsSync20 } from "node:fs";
|
|
90956
|
-
import { mkdir as mkdir31, readdir as
|
|
90990
|
+
import { mkdir as mkdir31, readdir as readdir20, readFile as readFile68, rm as rm16, writeFile as writeFile24 } from "node:fs/promises";
|
|
90957
90991
|
import { dirname as dirname38, join as join79, resolve as resolve28 } from "node:path";
|
|
90958
90992
|
function packageAssetDeliverySummary(value) {
|
|
90959
90993
|
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
@@ -91136,7 +91170,7 @@ async function removeOrphanPackageDirs(projectRoot, packages) {
|
|
|
91136
91170
|
if (!existsSync20(distRoot))
|
|
91137
91171
|
return;
|
|
91138
91172
|
const declaredNames = new Set(packages.flatMap((pkg) => packageOutputDirs(pkg).map((path2) => path2.slice("dist/".length))));
|
|
91139
|
-
const entries2 = await
|
|
91173
|
+
const entries2 = await readdir20(distRoot, { withFileTypes: true });
|
|
91140
91174
|
await Promise.all(entries2.filter((entry) => entry.isDirectory() && !declaredNames.has(entry.name)).map((entry) => rm16(join79(distRoot, entry.name), { recursive: true, force: true, maxRetries: 3, retryDelay: 100 })));
|
|
91141
91175
|
}
|
|
91142
91176
|
async function collectPackageFreshness(projectRoot, packages) {
|
|
@@ -91233,6 +91267,7 @@ async function buildProjectPackagesInternal(projectRoot, options) {
|
|
|
91233
91267
|
}
|
|
91234
91268
|
const approved = await listApprovedKnowledge(projectRoot);
|
|
91235
91269
|
const querySkillMigrations = await migrateLegacyQuerySkills(projectRoot, packages);
|
|
91270
|
+
const querySkillRefreshes = await refreshSharedQuerySkills(projectRoot, packages);
|
|
91236
91271
|
const templateReviews = await inspectPackageTemplateReviews(projectRoot, packages);
|
|
91237
91272
|
const unresolvedTemplateReviews = templateReviews.filter((review) => review.state === "review-required" || review.state === "invalid");
|
|
91238
91273
|
if (unresolvedTemplateReviews.length > 0) {
|
|
@@ -91271,13 +91306,19 @@ async function buildProjectPackagesInternal(projectRoot, options) {
|
|
|
91271
91306
|
}
|
|
91272
91307
|
}
|
|
91273
91308
|
const summaries = [];
|
|
91274
|
-
const agentHints = querySkillMigrations.map((migration) => ({
|
|
91309
|
+
const agentHints = [...querySkillMigrations.map((migration) => ({
|
|
91275
91310
|
reason_code: "package-query-skill-migrated",
|
|
91276
91311
|
severity: "info",
|
|
91277
91312
|
package_name: migration.packageName,
|
|
91278
91313
|
template_path: migration.templatePath,
|
|
91279
91314
|
message: `Replaced the retired ${LEGACY_QUERY_SKILL} Skill with ${QUERY_SKILL} in the package template; package-specific search hints belong in others/context/search-guide.md.`
|
|
91280
|
-
}))
|
|
91315
|
+
})), ...querySkillRefreshes.map((refresh) => ({
|
|
91316
|
+
reason_code: "package-query-skill-refreshed",
|
|
91317
|
+
severity: "info",
|
|
91318
|
+
package_name: refresh.packageName,
|
|
91319
|
+
template_path: refresh.templatePath,
|
|
91320
|
+
message: `Updated the shared ${QUERY_SKILL} Skill in the package template to this Context version; it is managed by Context, and package-specific search hints belong in others/context/search-guide.md.`
|
|
91321
|
+
}))];
|
|
91281
91322
|
for (const pkg of packages) {
|
|
91282
91323
|
assertPackageOutputDir(pkg);
|
|
91283
91324
|
const selected = selectPackageKnowledge(approved, pkg);
|
|
@@ -92510,12 +92551,12 @@ __export(exports_knowledgeMaintenance, {
|
|
|
92510
92551
|
cancelKnowledgeMaintenance: () => cancelKnowledgeMaintenance,
|
|
92511
92552
|
advanceKnowledgeMaintenance: () => advanceKnowledgeMaintenance
|
|
92512
92553
|
});
|
|
92513
|
-
import { readFile as readFile71, readdir as
|
|
92554
|
+
import { readFile as readFile71, readdir as readdir21, rm as rm17 } from "node:fs/promises";
|
|
92514
92555
|
import { join as join84 } from "node:path";
|
|
92515
92556
|
async function deliveryDigest(root) {
|
|
92516
92557
|
const directory = join84(root, ".tmp/context-runtime/packages");
|
|
92517
92558
|
try {
|
|
92518
|
-
const files = (await
|
|
92559
|
+
const files = (await readdir21(directory)).filter((name3) => name3.endsWith(".json")).sort();
|
|
92519
92560
|
if (!files.length)
|
|
92520
92561
|
return indexerProtocolDigest(null);
|
|
92521
92562
|
return indexerProtocolDigest(await Promise.all(files.map((name3) => readFile71(join84(directory, name3), "utf8"))));
|
|
@@ -92768,7 +92809,7 @@ __export(exports_approvedRevision, {
|
|
|
92768
92809
|
APPROVED_REVISION_PATH: () => APPROVED_REVISION_PATH
|
|
92769
92810
|
});
|
|
92770
92811
|
import { readFile as readFile72, realpath as realpath11, rm as rm18 } from "node:fs/promises";
|
|
92771
|
-
import { join as join85, relative as
|
|
92812
|
+
import { join as join85, relative as relative27, isAbsolute as isAbsolute15 } from "node:path";
|
|
92772
92813
|
function requestDigest(input) {
|
|
92773
92814
|
const scopes = input.processed_scopes?.filter((scope2) => input.target.source_refs.some((ref2) => repoContentScopeMatches(scope2.source_ref, ref2) || ref2.startsWith(`${scope2.source_ref}#`) || ref2.startsWith(`${scope2.source_ref}/`)));
|
|
92774
92815
|
const ids = new Set(scopes?.map((scope2) => scope2.requirement_ref));
|
|
@@ -92866,12 +92907,12 @@ async function resolveApprovedRevisionAuthor(projectRoot, request) {
|
|
|
92866
92907
|
async function targetBytes(projectRoot, path2) {
|
|
92867
92908
|
const project = await realpath11(projectRoot);
|
|
92868
92909
|
const root = await realpath11(join85(projectRoot, "knowledge"));
|
|
92869
|
-
const rootRelative =
|
|
92910
|
+
const rootRelative = relative27(project, root);
|
|
92870
92911
|
if (isAbsolute15(rootRelative) || rootRelative === ".." || rootRelative.startsWith("../")) {
|
|
92871
92912
|
throw new TypeError("Approved knowledge directory leaves the Context workspace");
|
|
92872
92913
|
}
|
|
92873
92914
|
const target = await realpath11(join85(root, path2));
|
|
92874
|
-
const rel =
|
|
92915
|
+
const rel = relative27(root, target);
|
|
92875
92916
|
if (isAbsolute15(rel) || rel === ".." || rel.startsWith("../"))
|
|
92876
92917
|
throw new TypeError("Approved revision target leaves knowledge/");
|
|
92877
92918
|
return readFile72(target, "utf8");
|
|
@@ -93417,8 +93458,8 @@ var init_sourceInputMutation = __esm(() => {
|
|
|
93417
93458
|
|
|
93418
93459
|
// src/project/documentCapture.ts
|
|
93419
93460
|
import { createHash as createHash24 } from "node:crypto";
|
|
93420
|
-
import { mkdir as mkdir33, readdir as
|
|
93421
|
-
import { basename as basename8, dirname as dirname40, extname as extname12, join as join86, relative as
|
|
93461
|
+
import { mkdir as mkdir33, readdir as readdir22, readFile as readFile73, rm as rm19, stat as stat11, writeFile as writeFile26 } from "node:fs/promises";
|
|
93462
|
+
import { basename as basename8, dirname as dirname40, extname as extname12, join as join86, relative as relative28, resolve as resolve29 } from "node:path";
|
|
93422
93463
|
function toPosixPath7(path2) {
|
|
93423
93464
|
return path2.split(/[\\/]+/u).filter((part) => part.length > 0).join("/");
|
|
93424
93465
|
}
|
|
@@ -93539,7 +93580,7 @@ async function walkMarkdownFiles(input) {
|
|
|
93539
93580
|
const documents = [];
|
|
93540
93581
|
const metadata = [];
|
|
93541
93582
|
const visit3 = async (dir) => {
|
|
93542
|
-
const entries2 = await
|
|
93583
|
+
const entries2 = await readdir22(dir, { withFileTypes: true });
|
|
93543
93584
|
for (const entry of entries2) {
|
|
93544
93585
|
const absolutePath = join86(dir, entry.name);
|
|
93545
93586
|
if (entry.isDirectory()) {
|
|
@@ -93548,7 +93589,7 @@ async function walkMarkdownFiles(input) {
|
|
|
93548
93589
|
}
|
|
93549
93590
|
if (!entry.isFile())
|
|
93550
93591
|
continue;
|
|
93551
|
-
const sourcePath = normalizeSnapshotRelativePath(toPosixPath7(
|
|
93592
|
+
const sourcePath = normalizeSnapshotRelativePath(toPosixPath7(relative28(input.localRoot, absolutePath)));
|
|
93552
93593
|
if (matchesDocumentInclude(sourcePath, input.include, input.documentExtensions)) {
|
|
93553
93594
|
documents.push({ absolutePath, sourcePath, snapshotPath: sourcePath });
|
|
93554
93595
|
} else if (matchesMetadataInclude(sourcePath, input.include, input.routeMetadataFile)) {
|
|
@@ -93634,7 +93675,7 @@ function assertFileSnapshotMaterializedAt(source2) {
|
|
|
93634
93675
|
async function removeEmptySnapshotDirs(root, dir = root) {
|
|
93635
93676
|
let entries2;
|
|
93636
93677
|
try {
|
|
93637
|
-
entries2 = await
|
|
93678
|
+
entries2 = await readdir22(dir, { withFileTypes: true });
|
|
93638
93679
|
} catch (error) {
|
|
93639
93680
|
if (error instanceof Error && "code" in error && error.code === "ENOENT")
|
|
93640
93681
|
return;
|
|
@@ -93647,7 +93688,7 @@ async function removeEmptySnapshotDirs(root, dir = root) {
|
|
|
93647
93688
|
}
|
|
93648
93689
|
if (dir === root)
|
|
93649
93690
|
return;
|
|
93650
|
-
const remaining = await
|
|
93691
|
+
const remaining = await readdir22(dir);
|
|
93651
93692
|
if (remaining.length === 0) {
|
|
93652
93693
|
await rm19(dir, { recursive: true, force: true });
|
|
93653
93694
|
}
|
|
@@ -94180,11 +94221,11 @@ function larkSnapshotIdentityDiagnostic(source2, manifest) {
|
|
|
94180
94221
|
|
|
94181
94222
|
// src/project/repoSourceModules.ts
|
|
94182
94223
|
import { existsSync as existsSync22 } from "node:fs";
|
|
94183
|
-
import { readFile as readFile74, readdir as
|
|
94224
|
+
import { readFile as readFile74, readdir as readdir23 } from "node:fs/promises";
|
|
94184
94225
|
import { join as join88, resolve as resolve30 } from "node:path";
|
|
94185
94226
|
async function rootNames(root) {
|
|
94186
94227
|
try {
|
|
94187
|
-
return (await
|
|
94228
|
+
return (await readdir23(root)).sort();
|
|
94188
94229
|
} catch {
|
|
94189
94230
|
return [];
|
|
94190
94231
|
}
|
|
@@ -94395,7 +94436,7 @@ import { existsSync as existsSync24 } from "node:fs";
|
|
|
94395
94436
|
import { lstat as lstat15, mkdir as mkdir34, readFile as readFile75, readlink as readlink2, realpath as realpath12, rm as rm20, symlink as symlink4 } from "node:fs/promises";
|
|
94396
94437
|
import { execFile as execFile10 } from "node:child_process";
|
|
94397
94438
|
import { promisify as promisify10 } from "node:util";
|
|
94398
|
-
import { dirname as dirname41, isAbsolute as isAbsolute16, join as join90, relative as
|
|
94439
|
+
import { dirname as dirname41, isAbsolute as isAbsolute16, join as join90, relative as relative29, resolve as resolve31 } from "node:path";
|
|
94399
94440
|
function nonEmpty(value) {
|
|
94400
94441
|
if (value == null)
|
|
94401
94442
|
return null;
|
|
@@ -94448,7 +94489,7 @@ function scopedLocalPath(rootAbs, subpath) {
|
|
|
94448
94489
|
async function localPathForRegistry(input) {
|
|
94449
94490
|
const projectGitRoot = await resolveGitRoot(input.projectRoot);
|
|
94450
94491
|
const sameRepository = projectGitRoot !== null && await realpath12(projectGitRoot) === await realpath12(input.gitRootAbs);
|
|
94451
|
-
return !isAbsolute16(input.originalLocal) || sameRepository ?
|
|
94492
|
+
return !isAbsolute16(input.originalLocal) || sameRepository ? relative29(input.projectRoot, input.gitRootAbs) || "." : input.gitRootAbs;
|
|
94452
94493
|
}
|
|
94453
94494
|
async function inferNamedLocalPath(projectRoot, module) {
|
|
94454
94495
|
const candidates = [
|
|
@@ -94465,7 +94506,7 @@ async function inferNamedLocalPath(projectRoot, module) {
|
|
|
94465
94506
|
const stats = await lstat15(canonical).catch(() => null);
|
|
94466
94507
|
if (stats?.isDirectory() !== true || await resolveGitRoot(canonical) === null)
|
|
94467
94508
|
continue;
|
|
94468
|
-
matches.set(canonical,
|
|
94509
|
+
matches.set(canonical, relative29(projectRoot, candidate) || ".");
|
|
94469
94510
|
}
|
|
94470
94511
|
return matches.size === 1 ? [...matches.values()][0] : undefined;
|
|
94471
94512
|
}
|
|
@@ -94566,7 +94607,7 @@ async function ensureMaterializedSymlink(input) {
|
|
|
94566
94607
|
return true;
|
|
94567
94608
|
await rm20(linkPath);
|
|
94568
94609
|
}
|
|
94569
|
-
const relTarget =
|
|
94610
|
+
const relTarget = relative29(dirname41(linkPath), input.localAbs) || ".";
|
|
94570
94611
|
await symlink4(relTarget, linkPath);
|
|
94571
94612
|
return true;
|
|
94572
94613
|
}
|
|
@@ -94585,7 +94626,7 @@ async function diagnoseMaterializedSymlink(input) {
|
|
|
94585
94626
|
const current2 = await readlink2(linkPath);
|
|
94586
94627
|
const currentAbs = resolve31(dirname41(linkPath), current2);
|
|
94587
94628
|
if (currentAbs !== input.localAbs) {
|
|
94588
|
-
input.diagnostics.push(`materialized path points to ${current2}, expected local checkout ${
|
|
94629
|
+
input.diagnostics.push(`materialized path points to ${current2}, expected local checkout ${relative29(dirname41(linkPath), input.localAbs) || "."}`);
|
|
94589
94630
|
input.agent_hints.push(`Run context source ensure ${input.sourceName} to refresh the local source link.`);
|
|
94590
94631
|
return false;
|
|
94591
94632
|
}
|
|
@@ -94677,7 +94718,7 @@ async function normalizeAddInput(input, existing) {
|
|
|
94677
94718
|
if (originalLocalAbs !== null && existsSync24(originalLocalAbs)) {
|
|
94678
94719
|
gitRootAbs = await resolveGitRoot(originalLocalAbs);
|
|
94679
94720
|
if (gitRootAbs !== null && localWasResolvedFromInput) {
|
|
94680
|
-
const detectedSubpath = normalizeSubpath2(
|
|
94721
|
+
const detectedSubpath = normalizeSubpath2(relative29(gitRootAbs, originalLocalAbs));
|
|
94681
94722
|
local = await localPathForRegistry({
|
|
94682
94723
|
projectRoot: input.projectRoot,
|
|
94683
94724
|
originalLocal,
|
|
@@ -100852,8 +100893,27 @@ function safeFence2(value, language = "") {
|
|
|
100852
100893
|
${value.trim()}
|
|
100853
100894
|
${fence}`;
|
|
100854
100895
|
}
|
|
100896
|
+
function mergeAdjacentStyles(nodes, ctx) {
|
|
100897
|
+
const merged = [];
|
|
100898
|
+
for (const node3 of nodes) {
|
|
100899
|
+
const name3 = elementName2(node3);
|
|
100900
|
+
const previous3 = merged.at(-1);
|
|
100901
|
+
if (name3 !== undefined && INLINE_STYLES.has(name3) && previous3 !== undefined && elementName2(previous3) === name3 && Object.keys(attributes(node3)).length === 0 && Object.keys(attributes(previous3)).length === 0) {
|
|
100902
|
+
ctx.tracker.discover(name3);
|
|
100903
|
+
ctx.tracker.convert(name3);
|
|
100904
|
+
merged[merged.length - 1] = { [name3]: [...elementChildren2(previous3, name3), ...elementChildren2(node3, name3)] };
|
|
100905
|
+
continue;
|
|
100906
|
+
}
|
|
100907
|
+
merged.push(node3);
|
|
100908
|
+
}
|
|
100909
|
+
return merged;
|
|
100910
|
+
}
|
|
100911
|
+
function wrapInline(body2, marker) {
|
|
100912
|
+
const match = /^(\s*)([\s\S]*?)(\s*)$/u.exec(body2);
|
|
100913
|
+
return match[2] === "" ? body2 : `${match[1]}${marker}${match[2]}${marker}${match[3]}`;
|
|
100914
|
+
}
|
|
100855
100915
|
function renderChildren(nodes, ctx) {
|
|
100856
|
-
return nodes.map((node3) => renderNode(node3, ctx)).join("");
|
|
100916
|
+
return mergeAdjacentStyles(nodes, ctx).map((node3) => renderNode(node3, ctx)).join("");
|
|
100857
100917
|
}
|
|
100858
100918
|
function renderList(nodes, ctx, ordered) {
|
|
100859
100919
|
const items = nodes.filter((node3) => elementName2(node3) === "li");
|
|
@@ -101058,7 +101118,8 @@ ${"#".repeat(Math.min(Math.max(level, 1), 6))} ${normalizeInline2(renderChildren
|
|
|
101058
101118
|
if (["p", "paragraph", "div", "section"].includes(name3)) {
|
|
101059
101119
|
ctx.tracker.convert(name3);
|
|
101060
101120
|
const body2 = renderChildren(nodes, { ...ctx, mode: "inline" });
|
|
101061
|
-
return ctx.mode === "inline" ? body2
|
|
101121
|
+
return ctx.mode === "inline" ? `${body2}
|
|
101122
|
+
` : `
|
|
101062
101123
|
|
|
101063
101124
|
${body2}
|
|
101064
101125
|
|
|
@@ -101070,15 +101131,15 @@ ${body2}
|
|
|
101070
101131
|
}
|
|
101071
101132
|
if (name3 === "b" || name3 === "strong") {
|
|
101072
101133
|
ctx.tracker.convert(name3);
|
|
101073
|
-
return
|
|
101134
|
+
return wrapInline(renderChildren(nodes, { ...ctx, mode: "inline" }), "**");
|
|
101074
101135
|
}
|
|
101075
101136
|
if (name3 === "i" || name3 === "em") {
|
|
101076
101137
|
ctx.tracker.convert(name3);
|
|
101077
|
-
return
|
|
101138
|
+
return wrapInline(renderChildren(nodes, { ...ctx, mode: "inline" }), "*");
|
|
101078
101139
|
}
|
|
101079
101140
|
if (name3 === "s" || name3 === "del" || name3 === "strike") {
|
|
101080
101141
|
ctx.tracker.convert(name3);
|
|
101081
|
-
return
|
|
101142
|
+
return wrapInline(renderChildren(nodes, { ...ctx, mode: "inline" }), "~~");
|
|
101082
101143
|
}
|
|
101083
101144
|
if (name3 === "a") {
|
|
101084
101145
|
ctx.tracker.convert(name3);
|
|
@@ -101258,7 +101319,7 @@ function projectLarkDocxXmlBlock(input) {
|
|
|
101258
101319
|
fidelity: tracker.report()
|
|
101259
101320
|
};
|
|
101260
101321
|
}
|
|
101261
|
-
var parser, PRESENTATION_ONLY_ATTRIBUTES;
|
|
101322
|
+
var parser, PRESENTATION_ONLY_ATTRIBUTES, INLINE_STYLES;
|
|
101262
101323
|
var init_larkDocxXml = __esm(() => {
|
|
101263
101324
|
init_fxp();
|
|
101264
101325
|
init_larkDocxResources();
|
|
@@ -101286,6 +101347,7 @@ var init_larkDocxXml = __esm(() => {
|
|
|
101286
101347
|
"scale",
|
|
101287
101348
|
"view-type"
|
|
101288
101349
|
]);
|
|
101350
|
+
INLINE_STYLES = new Set(["b", "strong", "i", "em", "s", "del", "strike"]);
|
|
101289
101351
|
});
|
|
101290
101352
|
|
|
101291
101353
|
// src/lib/larkResourceScheduler.ts
|
|
@@ -101512,7 +101574,7 @@ var init_larkResourceCommand = __esm(() => {
|
|
|
101512
101574
|
});
|
|
101513
101575
|
|
|
101514
101576
|
// src/lib/larkMediaDownload.ts
|
|
101515
|
-
import { readdir as
|
|
101577
|
+
import { readdir as readdir25, rm as rm22 } from "node:fs/promises";
|
|
101516
101578
|
import { join as join106 } from "node:path";
|
|
101517
101579
|
async function downloadLarkMedia(input) {
|
|
101518
101580
|
const shared = ["--as", input.identity, "--token", input.token, "--output", "./resource", "--format", "json"];
|
|
@@ -101522,7 +101584,7 @@ async function downloadLarkMedia(input) {
|
|
|
101522
101584
|
} catch (error) {
|
|
101523
101585
|
if (!input.allowPreview || !isLarkResourcePermissionDenied(error))
|
|
101524
101586
|
throw error;
|
|
101525
|
-
for (const entry of await
|
|
101587
|
+
for (const entry of await readdir25(input.cwd))
|
|
101526
101588
|
await rm22(join106(input.cwd, entry), { recursive: true, force: true });
|
|
101527
101589
|
await runLarkResourceCommand(input.runner, ["docs", "+media-preview", ...shared], { cwd: input.cwd });
|
|
101528
101590
|
return "preview";
|
|
@@ -101621,7 +101683,7 @@ var init_larkImagePolicy = __esm(() => {
|
|
|
101621
101683
|
|
|
101622
101684
|
// src/lib/larkResourceMaterialization.ts
|
|
101623
101685
|
import { createHash as createHash31 } from "node:crypto";
|
|
101624
|
-
import { mkdtemp as mkdtemp5, readFile as readFile86, readdir as
|
|
101686
|
+
import { mkdtemp as mkdtemp5, readFile as readFile86, readdir as readdir26, rm as rm24 } from "node:fs/promises";
|
|
101625
101687
|
import { extname as extname13, join as join108 } from "node:path";
|
|
101626
101688
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
101627
101689
|
function countByKind(items, status) {
|
|
@@ -101733,7 +101795,7 @@ async function downloadedFile(input) {
|
|
|
101733
101795
|
const tempRoot = await mkdtemp5(join108(tmpdir2(), "context-lark-resource-"));
|
|
101734
101796
|
try {
|
|
101735
101797
|
const representation = await downloadLarkMedia({ ...input, cwd: tempRoot });
|
|
101736
|
-
const entries2 = (await
|
|
101798
|
+
const entries2 = (await readdir26(tempRoot, { withFileTypes: true })).filter((entry) => entry.isFile());
|
|
101737
101799
|
if (entries2.length !== 1)
|
|
101738
101800
|
throw new Error(`media download produced ${entries2.length} files, expected exactly one`);
|
|
101739
101801
|
const path3 = entries2[0]?.name ?? "resource.bin";
|
|
@@ -102947,7 +103009,7 @@ var init_sensitiveSourceLiteral = __esm(() => {
|
|
|
102947
103009
|
// src/project/larkSnapshotBundle.ts
|
|
102948
103010
|
import { createHash as createHash32 } from "node:crypto";
|
|
102949
103011
|
import { lstat as lstat16, mkdir as mkdir38, readFile as readFile87, realpath as realpath13, rename as rename10, writeFile as writeFile29 } from "node:fs/promises";
|
|
102950
|
-
import { basename as basename10, dirname as dirname45, isAbsolute as isAbsolute19, join as join109, relative as
|
|
103012
|
+
import { basename as basename10, dirname as dirname45, isAbsolute as isAbsolute19, join as join109, relative as relative30, resolve as resolve35, sep as sep10 } from "node:path";
|
|
102951
103013
|
import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
|
|
102952
103014
|
function normalizedSnapshotResourcePolicy(policy) {
|
|
102953
103015
|
return { ...policy, images: policy.images ?? "bundle", gifs: policy.gifs ?? "bundle" };
|
|
@@ -103169,7 +103231,7 @@ async function reserveSnapshotDirectory(directory, workspaceRoot) {
|
|
|
103169
103231
|
const { findContextProjectRoot: findContextProjectRoot2 } = await Promise.resolve().then(() => (init_workspace(), exports_workspace));
|
|
103170
103232
|
const owner = findContextProjectRoot2(parent)?.projectRoot ?? workspaceRoot;
|
|
103171
103233
|
if (owner !== undefined) {
|
|
103172
|
-
const rel =
|
|
103234
|
+
const rel = relative30(await realpath13(owner), output);
|
|
103173
103235
|
if (["sources", "knowledge", "dist", "src", ".tmp/context-runtime"].some((part) => rel === part || rel.startsWith(`${part.split("/").join(sep10)}${sep10}`))) {
|
|
103174
103236
|
throw larkSnapshotError("Standalone fetch cannot write into managed workspace state; choose a separate scratch directory", "path-invalid");
|
|
103175
103237
|
}
|
|
@@ -103238,7 +103300,7 @@ var init_larkSnapshotBundle = __esm(() => {
|
|
|
103238
103300
|
});
|
|
103239
103301
|
|
|
103240
103302
|
// src/project/documentCaptureLark.ts
|
|
103241
|
-
import { readdir as
|
|
103303
|
+
import { readdir as readdir27, readFile as readFile88 } from "node:fs/promises";
|
|
103242
103304
|
import { basename as basename11, extname as extname14, join as join110 } from "node:path";
|
|
103243
103305
|
function titleFromMarkdown2(markdown, fallbackPath) {
|
|
103244
103306
|
const heading2 = markdown.split(`
|
|
@@ -103398,7 +103460,7 @@ async function listSnapshotAssetFiles(root2, assetRoot) {
|
|
|
103398
103460
|
const visit4 = async (dir, prefix = assetRoot) => {
|
|
103399
103461
|
let entries2;
|
|
103400
103462
|
try {
|
|
103401
|
-
entries2 = await
|
|
103463
|
+
entries2 = await readdir27(dir, { withFileTypes: true });
|
|
103402
103464
|
} catch (error) {
|
|
103403
103465
|
if (error instanceof Error && "code" in error && error.code === "ENOENT")
|
|
103404
103466
|
return;
|
|
@@ -103751,7 +103813,7 @@ __export(exports_articleRetirement, {
|
|
|
103751
103813
|
retireArticles: () => retireArticles,
|
|
103752
103814
|
articleRetirementSchema: () => articleRetirementSchema
|
|
103753
103815
|
});
|
|
103754
|
-
import { readFile as readFile94, readdir as
|
|
103816
|
+
import { readFile as readFile94, readdir as readdir28 } from "node:fs/promises";
|
|
103755
103817
|
import { posix as posix13 } from "node:path";
|
|
103756
103818
|
function rebuildInput(revision) {
|
|
103757
103819
|
return JSON.stringify({ id: `retirement-${revision.slice(7)}`, operation: "rebuild", timing: "priority", targets: [] });
|
|
@@ -103884,7 +103946,7 @@ async function retireArticles(input) {
|
|
|
103884
103946
|
}
|
|
103885
103947
|
async function inspectTemplates(directory2) {
|
|
103886
103948
|
const absolute = await safeProjectTarget(input.projectRoot, directory2);
|
|
103887
|
-
const entries2 = await
|
|
103949
|
+
const entries2 = await readdir28(absolute, { withFileTypes: true }).catch((error) => {
|
|
103888
103950
|
if (error.code === "ENOENT")
|
|
103889
103951
|
return [];
|
|
103890
103952
|
throw error;
|
|
@@ -104034,7 +104096,7 @@ __export(exports_writeLockRecovery, {
|
|
|
104034
104096
|
recoverWriterLock: () => recoverWriterLock,
|
|
104035
104097
|
inspectWriterLock: () => inspectWriterLock
|
|
104036
104098
|
});
|
|
104037
|
-
import { lstat as lstat17, mkdir as mkdir40, readFile as readFile95, readdir as
|
|
104099
|
+
import { lstat as lstat17, mkdir as mkdir40, readFile as readFile95, readdir as readdir29, rename as rename11, rmdir as rmdir2 } from "node:fs/promises";
|
|
104038
104100
|
import { join as join115 } from "node:path";
|
|
104039
104101
|
import { createHash as createHash34, randomUUID as randomUUID8 } from "node:crypto";
|
|
104040
104102
|
async function inspectWriterLock(root2) {
|
|
@@ -104090,7 +104152,7 @@ async function recoverWriterLock(input) {
|
|
|
104090
104152
|
const current2 = await inspectWriterLock(input.projectRoot);
|
|
104091
104153
|
if (current2?.digest !== before.digest || current2.process_state !== "not-running")
|
|
104092
104154
|
throw new Error("Writer lock changed or owner resumed; keep the lock.");
|
|
104093
|
-
const names = await
|
|
104155
|
+
const names = await readdir29(path3);
|
|
104094
104156
|
if (names.some((name3) => name3 !== "owner.json" && name3 !== ".recovery"))
|
|
104095
104157
|
throw new Error("Unexpected lock contents; preserve for diagnosis.");
|
|
104096
104158
|
const archive = `.tmp/context-runtime/locks/recovered-write-${randomUUID8()}.lock`;
|
|
@@ -104119,7 +104181,7 @@ __export(exports_taskRecovery, {
|
|
|
104119
104181
|
});
|
|
104120
104182
|
import { existsSync as existsSync29 } from "node:fs";
|
|
104121
104183
|
import { dirname as dirname48, join as join116 } from "node:path";
|
|
104122
|
-
import { lstat as lstat18, readdir as
|
|
104184
|
+
import { lstat as lstat18, readdir as readdir30, readFile as readFile96 } from "node:fs/promises";
|
|
104123
104185
|
async function recoveryText(root2, path3) {
|
|
104124
104186
|
const target = await safeProjectTarget(root2, path3);
|
|
104125
104187
|
try {
|
|
@@ -104147,7 +104209,7 @@ async function recoveryJournals(root2) {
|
|
|
104147
104209
|
if (stat12.isDirectory()) {
|
|
104148
104210
|
if (depth > 3)
|
|
104149
104211
|
throw new TypeError("Unexpected transaction directory depth; preserve it for diagnosis.");
|
|
104150
|
-
for (const name3 of (await
|
|
104212
|
+
for (const name3 of (await readdir30(join116(root2, path3))).sort())
|
|
104151
104213
|
await visit4(`${path3}/${name3}`, depth + 1);
|
|
104152
104214
|
} else if (stat12.isFile())
|
|
104153
104215
|
entries2.push({ path: path3, digest: indexerProtocolDigest(await recoveryText(root2, path3)) });
|
|
@@ -108970,13 +109032,13 @@ function remarkGfm(options) {
|
|
|
108970
109032
|
init_workspace();
|
|
108971
109033
|
|
|
108972
109034
|
// src/project/reviewFeedback.ts
|
|
108973
|
-
import { readdir as
|
|
109035
|
+
import { readdir as readdir24, readFile as readFile79 } from "node:fs/promises";
|
|
108974
109036
|
import { join as join99 } from "node:path";
|
|
108975
109037
|
async function readPendingReviewFeedback(root2, candidates) {
|
|
108976
109038
|
const directory = join99(root2, ".tmp/context-runtime/review-feedback");
|
|
108977
109039
|
let files;
|
|
108978
109040
|
try {
|
|
108979
|
-
files = await
|
|
109041
|
+
files = await readdir24(directory);
|
|
108980
109042
|
} catch (e) {
|
|
108981
109043
|
if (e.code === "ENOENT")
|
|
108982
109044
|
return [];
|
|
@@ -114142,7 +114204,7 @@ init_cliFeedback();
|
|
|
114142
114204
|
init_exitCode();
|
|
114143
114205
|
init_productionFeedback();
|
|
114144
114206
|
var import_yaml53 = __toESM(require_dist(), 1);
|
|
114145
|
-
import { relative as
|
|
114207
|
+
import { relative as relative31, resolve as resolve38 } from "node:path";
|
|
114146
114208
|
async function completeCurrentProductionAction(input) {
|
|
114147
114209
|
return withProductionFeedback({ operation: "action", file: input.submissionPath }, () => withProjectWriteLock(input.projectRoot, "production-action", async () => {
|
|
114148
114210
|
await recoverDurableMultiFileTransactions(input.projectRoot);
|
|
@@ -114158,7 +114220,7 @@ async function completeCurrentProductionAction(input) {
|
|
|
114158
114220
|
throw invalid3("Stage files do not use the retired Author preview. Submit the current task files.");
|
|
114159
114221
|
if (!input.submissionPath || input.submissionPath === "-")
|
|
114160
114222
|
throw invalid3("Production requires a stage-local manifest file, not stdin.");
|
|
114161
|
-
const path3 =
|
|
114223
|
+
const path3 = relative31(resolve38(input.projectRoot, productionAgentDirectory(stage.id)), resolve38(input.cwd, input.submissionPath));
|
|
114162
114224
|
const manifest = await readProductionFile({ projectRoot: input.projectRoot, stage: stage.id, path: path3 });
|
|
114163
114225
|
const value = import_yaml53.default.parse(manifest.text, { uniqueKeys: true });
|
|
114164
114226
|
if (!value || typeof value !== "object" || !("stage" in value) || value.stage !== stage.id) {
|
|
@@ -114312,12 +114374,12 @@ init_cliFeedback();
|
|
|
114312
114374
|
init_exitCode();
|
|
114313
114375
|
init_productionFeedback();
|
|
114314
114376
|
var import_yaml54 = __toESM(require_dist(), 1);
|
|
114315
|
-
import { relative as
|
|
114377
|
+
import { relative as relative32, resolve as resolve39 } from "node:path";
|
|
114316
114378
|
var productionKnownTasksSchema = productionPlanInputSchema.omit({ stage: true });
|
|
114317
114379
|
async function prepareKnownProductionTasks(input) {
|
|
114318
114380
|
return withProductionFeedback({ operation: "known-tasks", file: input.path, schema: productionKnownTasksSchema }, () => withProjectWriteLock(input.projectRoot, "production-known-tasks", async () => {
|
|
114319
114381
|
await recoverDurableMultiFileTransactions(input.projectRoot);
|
|
114320
|
-
const path3 =
|
|
114382
|
+
const path3 = relative32(resolve39(input.projectRoot, ".tmp/agent-work"), resolve39(input.cwd, input.path));
|
|
114321
114383
|
const fixed2 = await readProductionPlanningFile({ projectRoot: input.projectRoot, path: path3 });
|
|
114322
114384
|
const invalid3 = (message) => new ContextError(ExitCode.UserError, message, {
|
|
114323
114385
|
category: ErrorCategory.UserInputInvalid,
|
|
@@ -114470,7 +114532,7 @@ function registerProjectActionCommands(program2) {
|
|
|
114470
114532
|
// src/commands/cleanClaudePluginCache.ts
|
|
114471
114533
|
init_cliFeedback();
|
|
114472
114534
|
import { existsSync as existsSync30 } from "node:fs";
|
|
114473
|
-
import { readdir as
|
|
114535
|
+
import { readdir as readdir31, rm as rm25 } from "node:fs/promises";
|
|
114474
114536
|
import { homedir } from "node:os";
|
|
114475
114537
|
import { join as join120 } from "node:path";
|
|
114476
114538
|
var ORPHAN_MARKER = ".orphaned_at";
|
|
@@ -114485,17 +114547,17 @@ async function cleanClaudePluginCache(opts = {}) {
|
|
|
114485
114547
|
lines.push("· claude plugin cache: missing — nothing to clean");
|
|
114486
114548
|
return { lines, removed, scanned };
|
|
114487
114549
|
}
|
|
114488
|
-
const marketplaces = await
|
|
114550
|
+
const marketplaces = await readdir31(cacheRoot, { withFileTypes: true });
|
|
114489
114551
|
for (const mp of marketplaces) {
|
|
114490
114552
|
if (!mp.isDirectory())
|
|
114491
114553
|
continue;
|
|
114492
114554
|
const mpDir = join120(cacheRoot, mp.name);
|
|
114493
|
-
const plugins = await
|
|
114555
|
+
const plugins = await readdir31(mpDir, { withFileTypes: true });
|
|
114494
114556
|
for (const pl of plugins) {
|
|
114495
114557
|
if (!pl.isDirectory())
|
|
114496
114558
|
continue;
|
|
114497
114559
|
const plDir = join120(mpDir, pl.name);
|
|
114498
|
-
const versions = await
|
|
114560
|
+
const versions = await readdir31(plDir, { withFileTypes: true });
|
|
114499
114561
|
for (const ver of versions) {
|
|
114500
114562
|
if (!ver.isDirectory())
|
|
114501
114563
|
continue;
|
|
@@ -114537,7 +114599,7 @@ function resolveClaudePluginCacheRoot(opts) {
|
|
|
114537
114599
|
}
|
|
114538
114600
|
async function isEmptyDir(dir) {
|
|
114539
114601
|
try {
|
|
114540
|
-
const entries2 = await
|
|
114602
|
+
const entries2 = await readdir31(dir);
|
|
114541
114603
|
return entries2.length === 0;
|
|
114542
114604
|
} catch {
|
|
114543
114605
|
return false;
|
|
@@ -114585,7 +114647,7 @@ init_writeLock();
|
|
|
114585
114647
|
import { execFile as execFile13 } from "node:child_process";
|
|
114586
114648
|
import { existsSync as existsSync31 } from "node:fs";
|
|
114587
114649
|
import { lstat as lstat19, mkdir as mkdir41, readlink as readlink3, realpath as realpath14, rm as rm26, symlink as symlink5 } from "node:fs/promises";
|
|
114588
|
-
import { basename as basename12, dirname as dirname49, isAbsolute as isAbsolute23, relative as
|
|
114650
|
+
import { basename as basename12, dirname as dirname49, isAbsolute as isAbsolute23, relative as relative33, resolve as resolve40 } from "node:path";
|
|
114589
114651
|
import { promisify as promisify13 } from "node:util";
|
|
114590
114652
|
var execFileAsync6 = promisify13(execFile13);
|
|
114591
114653
|
var RECOVERY_SCHEMA = "context.repository-source-recovery.v1";
|
|
@@ -114835,7 +114897,7 @@ async function bindLocalAlias(input) {
|
|
|
114835
114897
|
}
|
|
114836
114898
|
}
|
|
114837
114899
|
await mkdir41(dirname49(alias), { recursive: true });
|
|
114838
|
-
await symlink5(
|
|
114900
|
+
await symlink5(relative33(dirname49(alias), input.checkout) || ".", alias);
|
|
114839
114901
|
}
|
|
114840
114902
|
function selectPhysicalGroup(sources, selector) {
|
|
114841
114903
|
const direct = selectRepoSources(sources, selector);
|
|
@@ -114895,7 +114957,7 @@ async function restoreRepositorySources(input) {
|
|
|
114895
114957
|
await bindLocalAlias({ projectRoot: input.projectRoot, declaredLocal: source2.local, checkout });
|
|
114896
114958
|
continue;
|
|
114897
114959
|
}
|
|
114898
|
-
const nextLocal =
|
|
114960
|
+
const nextLocal = relative33(input.projectRoot, checkout).startsWith("..") ? checkout : relative33(input.projectRoot, checkout) || ".";
|
|
114899
114961
|
if (source2.local !== nextLocal) {
|
|
114900
114962
|
source2.local = nextLocal;
|
|
114901
114963
|
registryChanged = true;
|
|
@@ -115227,7 +115289,7 @@ init_exitCode();
|
|
|
115227
115289
|
var import_yaml55 = __toESM(require_dist(), 1);
|
|
115228
115290
|
import { createHash as createHash36 } from "node:crypto";
|
|
115229
115291
|
import { readFile as readFile100, realpath as realpath15 } from "node:fs/promises";
|
|
115230
|
-
import { basename as basename13, extname as extname15, isAbsolute as isAbsolute24, join as join123, relative as
|
|
115292
|
+
import { basename as basename13, extname as extname15, isAbsolute as isAbsolute24, join as join123, relative as relative34, resolve as resolve41 } from "node:path";
|
|
115231
115293
|
init_writeLock();
|
|
115232
115294
|
var SOURCE_NAME_PATTERN3 = /^[a-z0-9][a-z0-9._-]*$/u;
|
|
115233
115295
|
function isDateSourceNamespace(value) {
|
|
@@ -115292,7 +115354,7 @@ async function normalizeFileSourceLocal(projectRoot2, value) {
|
|
|
115292
115354
|
const canonicalProjectRoot = await realpathOrResolve(projectRoot2);
|
|
115293
115355
|
const rawAbsolute = isAbsolute24(trimmed) ? resolve41(trimmed) : resolve41(canonicalProjectRoot, trimmed);
|
|
115294
115356
|
const absolute = await realpathOrResolve(rawAbsolute);
|
|
115295
|
-
const normalized =
|
|
115357
|
+
const normalized = relative34(canonicalProjectRoot, absolute).replaceAll("\\", "/");
|
|
115296
115358
|
if (normalized.length === 0 || normalized === "." || isAbsolute24(normalized) || normalized.split("/").some((part) => part.length === 0 || part === ".")) {
|
|
115297
115359
|
throw new ContextError(ExitCode.UserError, `cannot safely store file source local path as project-relative path: ${value}`, {
|
|
115298
115360
|
category: ErrorCategory.UserInputInvalid,
|
|
@@ -116452,13 +116514,13 @@ init_exitCode();
|
|
|
116452
116514
|
|
|
116453
116515
|
// src/project/wikiDiscovery.ts
|
|
116454
116516
|
import { mkdir as mkdir43 } from "node:fs/promises";
|
|
116455
|
-
import { join as join127, relative as
|
|
116517
|
+
import { join as join127, relative as relative36 } from "node:path";
|
|
116456
116518
|
|
|
116457
116519
|
// src/project/wikiDiscoveryStore.ts
|
|
116458
116520
|
init_atomicWrite();
|
|
116459
116521
|
import { createHash as createHash38, randomUUID as randomUUID9 } from "node:crypto";
|
|
116460
|
-
import { link as link2, lstat as lstat21, mkdir as mkdir42, readFile as readFile103, readdir as
|
|
116461
|
-
import { join as join126, relative as
|
|
116522
|
+
import { link as link2, lstat as lstat21, mkdir as mkdir42, readFile as readFile103, readdir as readdir32, rm as rm27, writeFile as writeFile32 } from "node:fs/promises";
|
|
116523
|
+
import { join as join126, relative as relative35, resolve as resolve43, sep as sep11 } from "node:path";
|
|
116462
116524
|
function wikiDiscoveryDigest(value) {
|
|
116463
116525
|
return createHash38("sha256").update(value).digest("hex");
|
|
116464
116526
|
}
|
|
@@ -116467,7 +116529,7 @@ function wikiDiscoveryPageKey(cursor) {
|
|
|
116467
116529
|
}
|
|
116468
116530
|
async function assertWikiDiscoveryPath(root2, path3) {
|
|
116469
116531
|
const base = resolve43(root2);
|
|
116470
|
-
const parts =
|
|
116532
|
+
const parts = relative35(base, resolve43(path3)).split(sep11);
|
|
116471
116533
|
if (parts[0] === "..")
|
|
116472
116534
|
throw new WikiDiscoveryError("unsafe-checkpoint-path", false, "Discovery checkpoint must stay inside its workspace");
|
|
116473
116535
|
let current2 = base;
|
|
@@ -116503,7 +116565,7 @@ async function loadWikiDiscoveryReceipts(directory) {
|
|
|
116503
116565
|
const result = new Map;
|
|
116504
116566
|
await assertWikiDiscoveryPath(directory, join126(directory, "pages"));
|
|
116505
116567
|
await mkdir42(join126(directory, "pages"), { recursive: true });
|
|
116506
|
-
for (const file of await
|
|
116568
|
+
for (const file of await readdir32(join126(directory, "pages"))) {
|
|
116507
116569
|
if (!/^[a-f0-9]{64}\.json$/u.test(file))
|
|
116508
116570
|
continue;
|
|
116509
116571
|
const value = await readWikiDiscoveryJson(join126(directory, "pages", file));
|
|
@@ -116529,7 +116591,7 @@ async function acquireWikiDiscoveryLease(directory) {
|
|
|
116529
116591
|
await assertWikiDiscoveryPath(directory, leases);
|
|
116530
116592
|
await mkdir42(leases, { recursive: true });
|
|
116531
116593
|
for (let attempt = 0;attempt < 8; attempt++) {
|
|
116532
|
-
const files = (await
|
|
116594
|
+
const files = (await readdir32(leases)).filter((file) => /^\d{12}\.json$/u.test(file)).sort();
|
|
116533
116595
|
const latest = files.at(-1);
|
|
116534
116596
|
if (latest) {
|
|
116535
116597
|
const current2 = await readWikiDiscoveryJson(join126(leases, latest));
|
|
@@ -116771,7 +116833,7 @@ async function finishDiscovery(input, state) {
|
|
|
116771
116833
|
status,
|
|
116772
116834
|
url,
|
|
116773
116835
|
identity: identity2,
|
|
116774
|
-
manifest:
|
|
116836
|
+
manifest: relative36(input.projectRoot, manifestPath),
|
|
116775
116837
|
counts: progress(view),
|
|
116776
116838
|
failures: view.failed.slice(0, 10),
|
|
116777
116839
|
failures_truncated: view.failed.length > 10,
|
|
@@ -116927,8 +116989,8 @@ init_writeLock();
|
|
|
116927
116989
|
var import_yaml59 = __toESM(require_dist(), 1);
|
|
116928
116990
|
import { existsSync as existsSync33 } from "node:fs";
|
|
116929
116991
|
import { createHash as createHash39 } from "node:crypto";
|
|
116930
|
-
import { readFile as readFile104, readdir as
|
|
116931
|
-
import { isAbsolute as isAbsolute25, join as join128, relative as
|
|
116992
|
+
import { readFile as readFile104, readdir as readdir33, rm as rm28 } from "node:fs/promises";
|
|
116993
|
+
import { isAbsolute as isAbsolute25, join as join128, relative as relative37, resolve as resolve44, sep as sep12 } from "node:path";
|
|
116932
116994
|
function sourceIdentity(source2) {
|
|
116933
116995
|
if (source2.kind === "source.collection")
|
|
116934
116996
|
return;
|
|
@@ -117101,7 +117163,7 @@ function safeManagedMaterializedPath(projectRoot2, source2) {
|
|
|
117101
117163
|
return;
|
|
117102
117164
|
const absolute = resolve44(projectRoot2, source2.materializedAt);
|
|
117103
117165
|
const expectedRoot = resolve44(projectRoot2, "sources", source2.type);
|
|
117104
|
-
const rel =
|
|
117166
|
+
const rel = relative37(expectedRoot, absolute);
|
|
117105
117167
|
if (rel.length === 0 || rel === ".." || rel.startsWith(`..${sep12}`) || isAbsolute25(rel)) {
|
|
117106
117168
|
return;
|
|
117107
117169
|
}
|
|
@@ -117113,7 +117175,7 @@ function safeManagedManifestPath(projectRoot2, source2) {
|
|
|
117113
117175
|
throw unsafeOwnership(source2, manifest);
|
|
117114
117176
|
const absolute = resolve44(projectRoot2, manifest);
|
|
117115
117177
|
const expectedRoot = resolve44(projectRoot2, "sources", source2.type);
|
|
117116
|
-
const rel =
|
|
117178
|
+
const rel = relative37(expectedRoot, absolute);
|
|
117117
117179
|
if (rel.length === 0 || rel === ".." || rel.startsWith(`..${sep12}`) || isAbsolute25(rel)) {
|
|
117118
117180
|
throw unsafeOwnership(source2, manifest);
|
|
117119
117181
|
}
|
|
@@ -117124,7 +117186,7 @@ function safeManagedSnapshotChild(projectRoot2, source2, path3) {
|
|
|
117124
117186
|
if (materializedRoot === undefined || isAbsolute25(path3))
|
|
117125
117187
|
throw unsafeOwnership(source2, path3);
|
|
117126
117188
|
const absolute = resolve44(materializedRoot, path3);
|
|
117127
|
-
const rel =
|
|
117189
|
+
const rel = relative37(materializedRoot, absolute);
|
|
117128
117190
|
if (rel.length === 0 || rel === ".." || rel.startsWith(`..${sep12}`) || isAbsolute25(rel)) {
|
|
117129
117191
|
throw unsafeOwnership(source2, path3);
|
|
117130
117192
|
}
|
|
@@ -117140,7 +117202,7 @@ function unsafeOwnership(source2, path3) {
|
|
|
117140
117202
|
});
|
|
117141
117203
|
}
|
|
117142
117204
|
function projectRelative(projectRoot2, path3) {
|
|
117143
|
-
return
|
|
117205
|
+
return relative37(projectRoot2, path3).split(sep12).join("/");
|
|
117144
117206
|
}
|
|
117145
117207
|
function digest7(value) {
|
|
117146
117208
|
return `sha256:${createHash39("sha256").update(JSON.stringify(value)).digest("hex")}`;
|
|
@@ -117306,7 +117368,7 @@ async function pruneExtractRuntime(projectRoot2, source2) {
|
|
|
117306
117368
|
const visit4 = async (directory) => {
|
|
117307
117369
|
if (!existsSync33(directory))
|
|
117308
117370
|
return;
|
|
117309
|
-
for (const entry of await
|
|
117371
|
+
for (const entry of await readdir33(directory, { withFileTypes: true })) {
|
|
117310
117372
|
const path3 = join128(directory, entry.name);
|
|
117311
117373
|
if (entry.isDirectory()) {
|
|
117312
117374
|
await visit4(path3);
|
|
@@ -118038,7 +118100,7 @@ init_cliFeedback();
|
|
|
118038
118100
|
init_exitCode();
|
|
118039
118101
|
var import_yaml62 = __toESM(require_dist(), 1);
|
|
118040
118102
|
import { constants as constants6, existsSync as existsSync34 } from "node:fs";
|
|
118041
|
-
import { lstat as lstat22, open as open5, readdir as
|
|
118103
|
+
import { lstat as lstat22, open as open5, readdir as readdir34 } from "node:fs/promises";
|
|
118042
118104
|
import { dirname as dirname50, join as join130, resolve as resolve47 } from "node:path";
|
|
118043
118105
|
import { fileURLToPath as fileURLToPath10 } from "node:url";
|
|
118044
118106
|
function bundledSkillRoot() {
|
|
@@ -118066,7 +118128,7 @@ async function listProductionSkills(root2) {
|
|
|
118066
118128
|
}
|
|
118067
118129
|
}
|
|
118068
118130
|
async function readProductionSkills(root2) {
|
|
118069
|
-
const entries2 = (await
|
|
118131
|
+
const entries2 = (await readdir34(root2, { withFileTypes: true })).filter((entry) => entry.isDirectory()).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
118070
118132
|
const skills = [];
|
|
118071
118133
|
for (const directory of entries2) {
|
|
118072
118134
|
const entry = join130(root2, directory.name, "SKILL.md");
|
|
@@ -118098,13 +118160,13 @@ async function readProductionSkills(root2) {
|
|
|
118098
118160
|
// src/project/indexerBenchmarkActions.ts
|
|
118099
118161
|
init_src2();
|
|
118100
118162
|
import { realpath as realpath16 } from "node:fs/promises";
|
|
118101
|
-
import { isAbsolute as isAbsolute27, relative as
|
|
118163
|
+
import { isAbsolute as isAbsolute27, relative as relative38 } from "node:path";
|
|
118102
118164
|
async function assertOracleOutsideAgentWorkspace(input) {
|
|
118103
118165
|
const [workspace, oracle] = await Promise.all([
|
|
118104
118166
|
realpath16(input.projectRoot),
|
|
118105
118167
|
realpath16(input.oraclePath)
|
|
118106
118168
|
]);
|
|
118107
|
-
const relation =
|
|
118169
|
+
const relation = relative38(workspace, oracle);
|
|
118108
118170
|
if (relation.length === 0 || !relation.startsWith("..") && !isAbsolute27(relation)) {
|
|
118109
118171
|
throw new TypeError("benchmark oracle must be loaded from outside the execution Agent workspace");
|
|
118110
118172
|
}
|
|
@@ -118477,7 +118539,7 @@ init_cliFeedback();
|
|
|
118477
118539
|
init_errors3();
|
|
118478
118540
|
init_exitCode();
|
|
118479
118541
|
import { createHash as createHash40 } from "node:crypto";
|
|
118480
|
-
import { cp as cp3, lstat as lstat23, mkdir as mkdir44, mkdtemp as mkdtemp6, readFile as readFile110, readdir as
|
|
118542
|
+
import { cp as cp3, lstat as lstat23, mkdir as mkdir44, mkdtemp as mkdtemp6, readFile as readFile110, readdir as readdir35, rename as rename12, rm as rm29, writeFile as writeFile33 } from "node:fs/promises";
|
|
118481
118543
|
import { dirname as dirname52, join as join131, resolve as resolve49 } from "node:path";
|
|
118482
118544
|
var MARKER = ".context-skill-install.json";
|
|
118483
118545
|
function conflict(path3) {
|
|
@@ -118506,7 +118568,7 @@ async function checkParents(path3) {
|
|
|
118506
118568
|
async function digest8(root2) {
|
|
118507
118569
|
const hash5 = createHash40("sha256");
|
|
118508
118570
|
async function visit4(dir, prefix) {
|
|
118509
|
-
for (const name3 of (await
|
|
118571
|
+
for (const name3 of (await readdir35(dir)).sort()) {
|
|
118510
118572
|
if (!prefix && name3 === MARKER)
|
|
118511
118573
|
continue;
|
|
118512
118574
|
const path3 = join131(dir, name3);
|
|
@@ -118535,13 +118597,13 @@ async function installLocalSkills(root2, path3, dryRun, agent) {
|
|
|
118535
118597
|
const commandPlans = [];
|
|
118536
118598
|
const commandEntries = new Set;
|
|
118537
118599
|
if (agent === "claude" || agent === "cursor") {
|
|
118538
|
-
for (const name3 of await
|
|
118600
|
+
for (const name3 of await readdir35(join131(root2, "claude", "commands"))) {
|
|
118539
118601
|
if (name3.endsWith(".md"))
|
|
118540
118602
|
commandEntries.add(name3.slice(0, -3));
|
|
118541
118603
|
}
|
|
118542
118604
|
const commandsRoot = join131(targetRoot, "commands");
|
|
118543
118605
|
await checkParents(commandsRoot);
|
|
118544
|
-
for (const entry of await
|
|
118606
|
+
for (const entry of await readdir35(join131(root2, agent, "commands"), { withFileTypes: true })) {
|
|
118545
118607
|
if (!entry.isFile() || !entry.name.endsWith(".md"))
|
|
118546
118608
|
continue;
|
|
118547
118609
|
let content3 = await readFile110(join131(root2, agent, "commands", entry.name), "utf8");
|
|
@@ -118577,7 +118639,7 @@ ${frontmatter2[2].replace(/^disable-model-invocation:.*\r?\n?/mu, "")}${frontmat
|
|
|
118577
118639
|
conflict(join131(root2, agent, "commands"));
|
|
118578
118640
|
}
|
|
118579
118641
|
const plans = [];
|
|
118580
|
-
for (const entry of (await
|
|
118642
|
+
for (const entry of (await readdir35(sourceRoot2, { withFileTypes: true })).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
118581
118643
|
if (!entry.isDirectory() || !await stat12(join131(sourceRoot2, entry.name, "SKILL.md")))
|
|
118582
118644
|
continue;
|
|
118583
118645
|
const source2 = join131(sourceRoot2, entry.name);
|
|
@@ -118749,7 +118811,7 @@ init_errors3();
|
|
|
118749
118811
|
init_exitCode();
|
|
118750
118812
|
import { execFile as execFile14 } from "node:child_process";
|
|
118751
118813
|
import { existsSync as existsSync36 } from "node:fs";
|
|
118752
|
-
import { cp as cp4, mkdir as mkdir45, readdir as
|
|
118814
|
+
import { cp as cp4, mkdir as mkdir45, readdir as readdir36, readFile as readFile111, rename as rename13, rm as rm30, writeFile as writeFile34 } from "node:fs/promises";
|
|
118753
118815
|
import { homedir as homedir2 } from "node:os";
|
|
118754
118816
|
import { dirname as dirname53, join as join133 } from "node:path";
|
|
118755
118817
|
import { promisify as promisify14 } from "node:util";
|
|
@@ -118892,7 +118954,7 @@ async function pruneCodexPluginCacheForName(pluginName, keepVersion, dryRun, ste
|
|
|
118892
118954
|
const cacheRoot = join133(codexHome(), "plugins", "cache", MARKETPLACE_NAME, pluginName);
|
|
118893
118955
|
if (!existsSync36(cacheRoot))
|
|
118894
118956
|
return;
|
|
118895
|
-
const versions = (await
|
|
118957
|
+
const versions = (await readdir36(cacheRoot, { withFileTypes: true }).catch(() => [])).filter((entry) => entry.isDirectory() && entry.name !== keepVersion).map((entry) => entry.name).sort();
|
|
118896
118958
|
if (versions.length === 0)
|
|
118897
118959
|
return;
|
|
118898
118960
|
steps.push({
|
|
@@ -118911,7 +118973,7 @@ async function pruneCodexPluginCache(currentVersion, dryRun, steps) {
|
|
|
118911
118973
|
}
|
|
118912
118974
|
async function isEmptyDir2(dir) {
|
|
118913
118975
|
try {
|
|
118914
|
-
return (await
|
|
118976
|
+
return (await readdir36(dir)).length === 0;
|
|
118915
118977
|
} catch {
|
|
118916
118978
|
return false;
|
|
118917
118979
|
}
|
|
@@ -118921,14 +118983,14 @@ async function pruneClaudeOrphanContextCache(dryRun, steps) {
|
|
|
118921
118983
|
if (!existsSync36(cacheRoot))
|
|
118922
118984
|
return;
|
|
118923
118985
|
const removed = [];
|
|
118924
|
-
const marketplaces = await
|
|
118986
|
+
const marketplaces = await readdir36(cacheRoot, { withFileTypes: true }).catch(() => []);
|
|
118925
118987
|
for (const marketplace of marketplaces) {
|
|
118926
118988
|
if (!marketplace.isDirectory())
|
|
118927
118989
|
continue;
|
|
118928
118990
|
const pluginDir = join133(cacheRoot, marketplace.name, PLUGIN_NAME);
|
|
118929
118991
|
if (!existsSync36(pluginDir))
|
|
118930
118992
|
continue;
|
|
118931
|
-
const versions = await
|
|
118993
|
+
const versions = await readdir36(pluginDir, { withFileTypes: true }).catch(() => []);
|
|
118932
118994
|
for (const version3 of versions) {
|
|
118933
118995
|
if (!version3.isDirectory())
|
|
118934
118996
|
continue;
|
|
@@ -118986,7 +119048,7 @@ async function pruneClaudeSupersededContextCache(root2, dryRun, steps) {
|
|
|
118986
119048
|
if (!currentVersion)
|
|
118987
119049
|
return;
|
|
118988
119050
|
const pluginDir = join133(claudePluginCacheRoot(), MARKETPLACE_NAME, PLUGIN_NAME);
|
|
118989
|
-
const staleVersions = (await
|
|
119051
|
+
const staleVersions = (await readdir36(pluginDir, { withFileTypes: true }).catch(() => [])).filter((entry) => entry.isDirectory() && entry.name !== currentVersion).map((entry) => entry.name);
|
|
118990
119052
|
if (staleVersions.length === 0)
|
|
118991
119053
|
return;
|
|
118992
119054
|
steps.push({
|
|
@@ -119121,7 +119183,7 @@ async function materializeCodexPluginCache(root2, version3, dryRun, steps) {
|
|
|
119121
119183
|
}
|
|
119122
119184
|
async function bundledProviderSkillNames(root2) {
|
|
119123
119185
|
const skillsRoot = join133(root2, "skills");
|
|
119124
|
-
const entries2 = await
|
|
119186
|
+
const entries2 = await readdir36(skillsRoot, { withFileTypes: true });
|
|
119125
119187
|
const names = [];
|
|
119126
119188
|
for (const entry of entries2) {
|
|
119127
119189
|
if (!entry.isDirectory() || entry.name === "context")
|