@c4a/context-cli 0.7.84 → 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 +204 -118
- 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: "本页目录" },
|
|
@@ -87359,6 +87409,12 @@ var init_packageSiteTheme = __esm(() => {
|
|
|
87359
87409
|
state.md.options.html = /^(?:_site|custom)\//.test(state.env.relativePath || '');
|
|
87360
87410
|
});
|
|
87361
87411
|
md.block.ruler.disable('snippet');
|
|
87412
|
+
// CommonMark only closes **bold** after punctuation when whitespace or
|
|
87413
|
+
// punctuation follows, so Chinese such as **用 MCP?**在 stays literal.
|
|
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);
|
|
87362
87418
|
const linkOpen = md.renderer.rules.link_open;
|
|
87363
87419
|
md.renderer.rules.link_open = (tokens, index, options, env, self) => {
|
|
87364
87420
|
// Let VitePress normalize the base and .md URL before adding a target;
|
|
@@ -88123,7 +88179,7 @@ var init_packageSiteBranding = __esm(() => {
|
|
|
88123
88179
|
|
|
88124
88180
|
// src/project/packageSiteExtensions.ts
|
|
88125
88181
|
import { createHash as createHash18 } from "node:crypto";
|
|
88126
|
-
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";
|
|
88127
88183
|
import { join as join69, dirname as dirname30, resolve as resolve26 } from "node:path";
|
|
88128
88184
|
function invalidSiteExtension(message) {
|
|
88129
88185
|
throw new ContextError(ExitCode.UserError, `Site extensions: ${message}. Update site.extensions, its src files or the knowledge-map target, then retry the build.`, {
|
|
@@ -88156,7 +88212,7 @@ async function readSiteExtensions(projectRoot, extensions) {
|
|
|
88156
88212
|
}
|
|
88157
88213
|
const files = [];
|
|
88158
88214
|
async function walk(directory, prefix) {
|
|
88159
|
-
for (const entry of (await
|
|
88215
|
+
for (const entry of (await readdir17(directory, { withFileTypes: true })).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
88160
88216
|
if (entry.name.startsWith(".") || ["node_modules", "dist"].includes(entry.name))
|
|
88161
88217
|
continue;
|
|
88162
88218
|
const path2 = prefix + entry.name;
|
|
@@ -88291,8 +88347,8 @@ function projectPackageArticleLinks(input) {
|
|
|
88291
88347
|
edits.push({ start: link.start, end: link.end, text: `${link.label} (not included in this package; knowledge source: \`${coordinate}\`)` });
|
|
88292
88348
|
continue;
|
|
88293
88349
|
}
|
|
88294
|
-
const
|
|
88295
|
-
const target =
|
|
88350
|
+
const relative22 = posix8.relative(posix8.dirname(input.outputPath), output);
|
|
88351
|
+
const target = relative22.split("/").map((segment2) => encodeURIComponent(segment2)).join("/") + suffix;
|
|
88296
88352
|
edits.push({ start: link.start, end: link.end, text: `[${link.label}](<${target}>)` });
|
|
88297
88353
|
}
|
|
88298
88354
|
let markdown = input.markdown;
|
|
@@ -88334,7 +88390,7 @@ var init_packageRenderCache = __esm(() => {
|
|
|
88334
88390
|
|
|
88335
88391
|
// src/project/packageAssets.ts
|
|
88336
88392
|
import { readFile as readFile62 } from "node:fs/promises";
|
|
88337
|
-
import { dirname as dirname31, relative as
|
|
88393
|
+
import { dirname as dirname31, relative as relative22, sep as sep6 } from "node:path";
|
|
88338
88394
|
function posixPath2(value) {
|
|
88339
88395
|
return value.split(sep6).join("/");
|
|
88340
88396
|
}
|
|
@@ -88346,7 +88402,7 @@ function decodedTarget2(value) {
|
|
|
88346
88402
|
}
|
|
88347
88403
|
}
|
|
88348
88404
|
function packageAssetPath(projectRoot, absolute) {
|
|
88349
|
-
const knowledgeRelPath = posixPath2(
|
|
88405
|
+
const knowledgeRelPath = posixPath2(relative22(projectRoot, absolute));
|
|
88350
88406
|
const prefix = "knowledge/assets/";
|
|
88351
88407
|
if (!knowledgeRelPath.startsWith(prefix))
|
|
88352
88408
|
throw new TypeError(`knowledge asset is outside ${prefix}: ${knowledgeRelPath}`);
|
|
@@ -88356,7 +88412,7 @@ function packageAssetPath(projectRoot, absolute) {
|
|
|
88356
88412
|
};
|
|
88357
88413
|
}
|
|
88358
88414
|
function packageMarkdownTarget(pageOutputPath, assetOutputPath) {
|
|
88359
|
-
const target = posixPath2(
|
|
88415
|
+
const target = posixPath2(relative22(dirname31(pageOutputPath), assetOutputPath));
|
|
88360
88416
|
return target.startsWith(".") ? target : `./${target}`;
|
|
88361
88417
|
}
|
|
88362
88418
|
async function projectPackageKnowledgeAssets(input) {
|
|
@@ -88668,7 +88724,7 @@ var init_packageAssetOptimization = __esm(() => {
|
|
|
88668
88724
|
// src/project/packageAssetDelivery.ts
|
|
88669
88725
|
import { execFile as execFile8 } from "node:child_process";
|
|
88670
88726
|
import { realpath as realpath10 } from "node:fs/promises";
|
|
88671
|
-
import { join as join71, relative as
|
|
88727
|
+
import { join as join71, relative as relative23, sep as sep7 } from "node:path";
|
|
88672
88728
|
import { promisify as promisify8 } from "node:util";
|
|
88673
88729
|
async function git(projectRoot, args) {
|
|
88674
88730
|
try {
|
|
@@ -88688,7 +88744,7 @@ async function git(projectRoot, args) {
|
|
|
88688
88744
|
}
|
|
88689
88745
|
}
|
|
88690
88746
|
function repositoryPath(repoRoot, projectRoot, asset) {
|
|
88691
|
-
const path2 =
|
|
88747
|
+
const path2 = relative23(repoRoot, join71(projectRoot, asset.knowledgeRelPath)).split(sep7).join("/");
|
|
88692
88748
|
if (path2 === ".." || path2.startsWith("../") || path2.startsWith("/")) {
|
|
88693
88749
|
throw new ContextError(ExitCode.WorkspaceStateError, "knowledge asset is outside the current Git repository", {
|
|
88694
88750
|
category: ErrorCategory.WorkspaceStateInvalid,
|
|
@@ -89142,8 +89198,8 @@ var init_packageBuildContent = __esm(() => {
|
|
|
89142
89198
|
// src/project/siteTranslation.ts
|
|
89143
89199
|
import { createHash as createHash21 } from "node:crypto";
|
|
89144
89200
|
import { existsSync as existsSync19 } from "node:fs";
|
|
89145
|
-
import { mkdir as mkdir26, readFile as readFile64, readdir as
|
|
89146
|
-
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";
|
|
89147
89203
|
function sha256(value) {
|
|
89148
89204
|
return createHash21("sha256").update(value).digest("hex");
|
|
89149
89205
|
}
|
|
@@ -89204,8 +89260,8 @@ async function readMapTranslation(projectRoot, locale) {
|
|
|
89204
89260
|
async function listTranslationFiles(root) {
|
|
89205
89261
|
if (!existsSync19(root))
|
|
89206
89262
|
return [];
|
|
89207
|
-
const entries2 = await
|
|
89208
|
-
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("/"));
|
|
89209
89265
|
}
|
|
89210
89266
|
async function selectedArticles(projectRoot, packages) {
|
|
89211
89267
|
const approved = await listApprovedKnowledge(projectRoot);
|
|
@@ -89444,7 +89500,7 @@ async function submitSiteTranslation(projectRoot, packages, input, resolveInput)
|
|
|
89444
89500
|
issues.push({ locale: article.locale, target: article.approved_path, issues: ["Unknown locale or approved article."] });
|
|
89445
89501
|
continue;
|
|
89446
89502
|
}
|
|
89447
|
-
const draftPath2 =
|
|
89503
|
+
const draftPath2 = relative24(resolve27(projectRoot), resolve27(resolveInput(article.file))).split("\\").join("/");
|
|
89448
89504
|
if (draftPath2.startsWith(`${DRAFT_ROOT}/`))
|
|
89449
89505
|
drafts.push(draftPath2);
|
|
89450
89506
|
const content3 = await optionalText2(resolveInput(article.file));
|
|
@@ -89970,7 +90026,8 @@ async function writePackageSite(input) {
|
|
|
89970
90026
|
["vitepress", vitepressRoot],
|
|
89971
90027
|
["vue", dirname35(vueRequire.resolve("vue/package.json"))],
|
|
89972
90028
|
["@mermaid-js/layout-elk", dirname35(require2.resolve("@mermaid-js/layout-elk/package.json"))],
|
|
89973
|
-
["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"))]
|
|
89974
90031
|
]) {
|
|
89975
90032
|
await mkdir27(dirname35(join74(temporary, "node_modules", name3)), { recursive: true });
|
|
89976
90033
|
await symlink2(path2, join74(temporary, "node_modules", name3), "dir");
|
|
@@ -90072,7 +90129,7 @@ ${localized.body}`);
|
|
|
90072
90129
|
contextLocales: { primary: readers.primary, tags: readers.tags, labels: readers.labels, titles: readers.titles, preferenceKey: readers.preferenceKey }
|
|
90073
90130
|
}
|
|
90074
90131
|
};
|
|
90075
|
-
await writeFile22(join74(configRoot, "config.mjs"),
|
|
90132
|
+
await writeFile22(join74(configRoot, "config.mjs"), `${siteMarkdownImports()}const contextLocaleMarker = ${JSON.stringify(readers.translated ? marker : null)};
|
|
90076
90133
|
` + `export default { ...${JSON.stringify(config)}, markdown: { ${siteMarkdownConfig} },
|
|
90077
90134
|
` + ` transformHtml: html => html.replace(/<script id="check-dark-mode">[\\s\\S]*?<\\/script>/u, "") };
|
|
90078
90135
|
`);
|
|
@@ -90241,6 +90298,7 @@ var init_packageSite2 = __esm(() => {
|
|
|
90241
90298
|
PACKAGE_SITE_VERSION = `vitepress-site-v50-light-shared-preferences:${createHash22("sha256").update(JSON.stringify([
|
|
90242
90299
|
readPackageVersion(),
|
|
90243
90300
|
siteThemeVariables.toString(),
|
|
90301
|
+
siteMarkdownImports(),
|
|
90244
90302
|
siteMarkdownConfig,
|
|
90245
90303
|
siteThemeCss,
|
|
90246
90304
|
siteThemeScript,
|
|
@@ -90273,12 +90331,12 @@ var init_workspaceBuildVersion = __esm(() => {
|
|
|
90273
90331
|
|
|
90274
90332
|
// src/project/packageBuildStage.ts
|
|
90275
90333
|
import { mkdir as mkdir29, mkdtemp as mkdtemp3, readFile as readFile66, rename as rename9, rm as rm15, rmdir } from "node:fs/promises";
|
|
90276
|
-
import { dirname as dirname36, join as join76, relative as
|
|
90334
|
+
import { dirname as dirname36, join as join76, relative as relative25 } from "node:path";
|
|
90277
90335
|
async function withStagedPackageOutput(projectRoot, pkg, render) {
|
|
90278
90336
|
const tempRoot = join76(projectRoot, ".tmp");
|
|
90279
90337
|
await mkdir29(tempRoot, { recursive: true });
|
|
90280
90338
|
const stage = await mkdtemp3(join76(tempRoot, "package-build-"));
|
|
90281
|
-
const stagedPackage = { ...pkg, outDir:
|
|
90339
|
+
const stagedPackage = { ...pkg, outDir: relative25(projectRoot, join76(stage, pkg.name)) };
|
|
90282
90340
|
try {
|
|
90283
90341
|
await mkdir29(join76(projectRoot, stagedPackage.outDir), { recursive: true });
|
|
90284
90342
|
const value = await render(stagedPackage);
|
|
@@ -90553,8 +90611,8 @@ var init_newKnowledgePage = __esm(() => {
|
|
|
90553
90611
|
});
|
|
90554
90612
|
|
|
90555
90613
|
// src/project/repoContentLinks.ts
|
|
90556
|
-
import { lstat as lstat14, mkdir as mkdir30, readdir as
|
|
90557
|
-
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";
|
|
90558
90616
|
function repoContentLinksNeedRepair(results) {
|
|
90559
90617
|
return results.some((item) => item.status === "missing" || item.status === "mismatch");
|
|
90560
90618
|
}
|
|
@@ -90599,7 +90657,7 @@ async function inspectRepoContentLinks(projectRoot, repair = false) {
|
|
|
90599
90657
|
async function obsolete(directory, prefix = "") {
|
|
90600
90658
|
if (!await info(directory))
|
|
90601
90659
|
return;
|
|
90602
|
-
for (const file of await
|
|
90660
|
+
for (const file of await readdir19(directory, { withFileTypes: true })) {
|
|
90603
90661
|
const mount = prefix + file.name;
|
|
90604
90662
|
const path2 = join77(directory, file.name);
|
|
90605
90663
|
if (file.isSymbolicLink() && !expected.has(mount)) {
|
|
@@ -90630,7 +90688,7 @@ async function inspectRepoContentLinks(projectRoot, repair = false) {
|
|
|
90630
90688
|
continue;
|
|
90631
90689
|
}
|
|
90632
90690
|
const existing = await info(path2);
|
|
90633
|
-
const target =
|
|
90691
|
+
const target = relative26(parent, entry.absolutePath).split("\\").join("/");
|
|
90634
90692
|
if (existing?.isSymbolicLink() && await readlink(path2) === target) {
|
|
90635
90693
|
results.push({ ...base, status: "ready" });
|
|
90636
90694
|
continue;
|
|
@@ -90929,7 +90987,7 @@ __export(exports_packageBuilder, {
|
|
|
90929
90987
|
});
|
|
90930
90988
|
import { createHash as createHash23 } from "node:crypto";
|
|
90931
90989
|
import { existsSync as existsSync20 } from "node:fs";
|
|
90932
|
-
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";
|
|
90933
90991
|
import { dirname as dirname38, join as join79, resolve as resolve28 } from "node:path";
|
|
90934
90992
|
function packageAssetDeliverySummary(value) {
|
|
90935
90993
|
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
@@ -91112,7 +91170,7 @@ async function removeOrphanPackageDirs(projectRoot, packages) {
|
|
|
91112
91170
|
if (!existsSync20(distRoot))
|
|
91113
91171
|
return;
|
|
91114
91172
|
const declaredNames = new Set(packages.flatMap((pkg) => packageOutputDirs(pkg).map((path2) => path2.slice("dist/".length))));
|
|
91115
|
-
const entries2 = await
|
|
91173
|
+
const entries2 = await readdir20(distRoot, { withFileTypes: true });
|
|
91116
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 })));
|
|
91117
91175
|
}
|
|
91118
91176
|
async function collectPackageFreshness(projectRoot, packages) {
|
|
@@ -91209,6 +91267,7 @@ async function buildProjectPackagesInternal(projectRoot, options) {
|
|
|
91209
91267
|
}
|
|
91210
91268
|
const approved = await listApprovedKnowledge(projectRoot);
|
|
91211
91269
|
const querySkillMigrations = await migrateLegacyQuerySkills(projectRoot, packages);
|
|
91270
|
+
const querySkillRefreshes = await refreshSharedQuerySkills(projectRoot, packages);
|
|
91212
91271
|
const templateReviews = await inspectPackageTemplateReviews(projectRoot, packages);
|
|
91213
91272
|
const unresolvedTemplateReviews = templateReviews.filter((review) => review.state === "review-required" || review.state === "invalid");
|
|
91214
91273
|
if (unresolvedTemplateReviews.length > 0) {
|
|
@@ -91247,13 +91306,19 @@ async function buildProjectPackagesInternal(projectRoot, options) {
|
|
|
91247
91306
|
}
|
|
91248
91307
|
}
|
|
91249
91308
|
const summaries = [];
|
|
91250
|
-
const agentHints = querySkillMigrations.map((migration) => ({
|
|
91309
|
+
const agentHints = [...querySkillMigrations.map((migration) => ({
|
|
91251
91310
|
reason_code: "package-query-skill-migrated",
|
|
91252
91311
|
severity: "info",
|
|
91253
91312
|
package_name: migration.packageName,
|
|
91254
91313
|
template_path: migration.templatePath,
|
|
91255
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.`
|
|
91256
|
-
}))
|
|
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
|
+
}))];
|
|
91257
91322
|
for (const pkg of packages) {
|
|
91258
91323
|
assertPackageOutputDir(pkg);
|
|
91259
91324
|
const selected = selectPackageKnowledge(approved, pkg);
|
|
@@ -92486,12 +92551,12 @@ __export(exports_knowledgeMaintenance, {
|
|
|
92486
92551
|
cancelKnowledgeMaintenance: () => cancelKnowledgeMaintenance,
|
|
92487
92552
|
advanceKnowledgeMaintenance: () => advanceKnowledgeMaintenance
|
|
92488
92553
|
});
|
|
92489
|
-
import { readFile as readFile71, readdir as
|
|
92554
|
+
import { readFile as readFile71, readdir as readdir21, rm as rm17 } from "node:fs/promises";
|
|
92490
92555
|
import { join as join84 } from "node:path";
|
|
92491
92556
|
async function deliveryDigest(root) {
|
|
92492
92557
|
const directory = join84(root, ".tmp/context-runtime/packages");
|
|
92493
92558
|
try {
|
|
92494
|
-
const files = (await
|
|
92559
|
+
const files = (await readdir21(directory)).filter((name3) => name3.endsWith(".json")).sort();
|
|
92495
92560
|
if (!files.length)
|
|
92496
92561
|
return indexerProtocolDigest(null);
|
|
92497
92562
|
return indexerProtocolDigest(await Promise.all(files.map((name3) => readFile71(join84(directory, name3), "utf8"))));
|
|
@@ -92744,7 +92809,7 @@ __export(exports_approvedRevision, {
|
|
|
92744
92809
|
APPROVED_REVISION_PATH: () => APPROVED_REVISION_PATH
|
|
92745
92810
|
});
|
|
92746
92811
|
import { readFile as readFile72, realpath as realpath11, rm as rm18 } from "node:fs/promises";
|
|
92747
|
-
import { join as join85, relative as
|
|
92812
|
+
import { join as join85, relative as relative27, isAbsolute as isAbsolute15 } from "node:path";
|
|
92748
92813
|
function requestDigest(input) {
|
|
92749
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}/`)));
|
|
92750
92815
|
const ids = new Set(scopes?.map((scope2) => scope2.requirement_ref));
|
|
@@ -92842,12 +92907,12 @@ async function resolveApprovedRevisionAuthor(projectRoot, request) {
|
|
|
92842
92907
|
async function targetBytes(projectRoot, path2) {
|
|
92843
92908
|
const project = await realpath11(projectRoot);
|
|
92844
92909
|
const root = await realpath11(join85(projectRoot, "knowledge"));
|
|
92845
|
-
const rootRelative =
|
|
92910
|
+
const rootRelative = relative27(project, root);
|
|
92846
92911
|
if (isAbsolute15(rootRelative) || rootRelative === ".." || rootRelative.startsWith("../")) {
|
|
92847
92912
|
throw new TypeError("Approved knowledge directory leaves the Context workspace");
|
|
92848
92913
|
}
|
|
92849
92914
|
const target = await realpath11(join85(root, path2));
|
|
92850
|
-
const rel =
|
|
92915
|
+
const rel = relative27(root, target);
|
|
92851
92916
|
if (isAbsolute15(rel) || rel === ".." || rel.startsWith("../"))
|
|
92852
92917
|
throw new TypeError("Approved revision target leaves knowledge/");
|
|
92853
92918
|
return readFile72(target, "utf8");
|
|
@@ -93393,8 +93458,8 @@ var init_sourceInputMutation = __esm(() => {
|
|
|
93393
93458
|
|
|
93394
93459
|
// src/project/documentCapture.ts
|
|
93395
93460
|
import { createHash as createHash24 } from "node:crypto";
|
|
93396
|
-
import { mkdir as mkdir33, readdir as
|
|
93397
|
-
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";
|
|
93398
93463
|
function toPosixPath7(path2) {
|
|
93399
93464
|
return path2.split(/[\\/]+/u).filter((part) => part.length > 0).join("/");
|
|
93400
93465
|
}
|
|
@@ -93515,7 +93580,7 @@ async function walkMarkdownFiles(input) {
|
|
|
93515
93580
|
const documents = [];
|
|
93516
93581
|
const metadata = [];
|
|
93517
93582
|
const visit3 = async (dir) => {
|
|
93518
|
-
const entries2 = await
|
|
93583
|
+
const entries2 = await readdir22(dir, { withFileTypes: true });
|
|
93519
93584
|
for (const entry of entries2) {
|
|
93520
93585
|
const absolutePath = join86(dir, entry.name);
|
|
93521
93586
|
if (entry.isDirectory()) {
|
|
@@ -93524,7 +93589,7 @@ async function walkMarkdownFiles(input) {
|
|
|
93524
93589
|
}
|
|
93525
93590
|
if (!entry.isFile())
|
|
93526
93591
|
continue;
|
|
93527
|
-
const sourcePath = normalizeSnapshotRelativePath(toPosixPath7(
|
|
93592
|
+
const sourcePath = normalizeSnapshotRelativePath(toPosixPath7(relative28(input.localRoot, absolutePath)));
|
|
93528
93593
|
if (matchesDocumentInclude(sourcePath, input.include, input.documentExtensions)) {
|
|
93529
93594
|
documents.push({ absolutePath, sourcePath, snapshotPath: sourcePath });
|
|
93530
93595
|
} else if (matchesMetadataInclude(sourcePath, input.include, input.routeMetadataFile)) {
|
|
@@ -93610,7 +93675,7 @@ function assertFileSnapshotMaterializedAt(source2) {
|
|
|
93610
93675
|
async function removeEmptySnapshotDirs(root, dir = root) {
|
|
93611
93676
|
let entries2;
|
|
93612
93677
|
try {
|
|
93613
|
-
entries2 = await
|
|
93678
|
+
entries2 = await readdir22(dir, { withFileTypes: true });
|
|
93614
93679
|
} catch (error) {
|
|
93615
93680
|
if (error instanceof Error && "code" in error && error.code === "ENOENT")
|
|
93616
93681
|
return;
|
|
@@ -93623,7 +93688,7 @@ async function removeEmptySnapshotDirs(root, dir = root) {
|
|
|
93623
93688
|
}
|
|
93624
93689
|
if (dir === root)
|
|
93625
93690
|
return;
|
|
93626
|
-
const remaining = await
|
|
93691
|
+
const remaining = await readdir22(dir);
|
|
93627
93692
|
if (remaining.length === 0) {
|
|
93628
93693
|
await rm19(dir, { recursive: true, force: true });
|
|
93629
93694
|
}
|
|
@@ -94156,11 +94221,11 @@ function larkSnapshotIdentityDiagnostic(source2, manifest) {
|
|
|
94156
94221
|
|
|
94157
94222
|
// src/project/repoSourceModules.ts
|
|
94158
94223
|
import { existsSync as existsSync22 } from "node:fs";
|
|
94159
|
-
import { readFile as readFile74, readdir as
|
|
94224
|
+
import { readFile as readFile74, readdir as readdir23 } from "node:fs/promises";
|
|
94160
94225
|
import { join as join88, resolve as resolve30 } from "node:path";
|
|
94161
94226
|
async function rootNames(root) {
|
|
94162
94227
|
try {
|
|
94163
|
-
return (await
|
|
94228
|
+
return (await readdir23(root)).sort();
|
|
94164
94229
|
} catch {
|
|
94165
94230
|
return [];
|
|
94166
94231
|
}
|
|
@@ -94371,7 +94436,7 @@ import { existsSync as existsSync24 } from "node:fs";
|
|
|
94371
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";
|
|
94372
94437
|
import { execFile as execFile10 } from "node:child_process";
|
|
94373
94438
|
import { promisify as promisify10 } from "node:util";
|
|
94374
|
-
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";
|
|
94375
94440
|
function nonEmpty(value) {
|
|
94376
94441
|
if (value == null)
|
|
94377
94442
|
return null;
|
|
@@ -94424,7 +94489,7 @@ function scopedLocalPath(rootAbs, subpath) {
|
|
|
94424
94489
|
async function localPathForRegistry(input) {
|
|
94425
94490
|
const projectGitRoot = await resolveGitRoot(input.projectRoot);
|
|
94426
94491
|
const sameRepository = projectGitRoot !== null && await realpath12(projectGitRoot) === await realpath12(input.gitRootAbs);
|
|
94427
|
-
return !isAbsolute16(input.originalLocal) || sameRepository ?
|
|
94492
|
+
return !isAbsolute16(input.originalLocal) || sameRepository ? relative29(input.projectRoot, input.gitRootAbs) || "." : input.gitRootAbs;
|
|
94428
94493
|
}
|
|
94429
94494
|
async function inferNamedLocalPath(projectRoot, module) {
|
|
94430
94495
|
const candidates = [
|
|
@@ -94441,7 +94506,7 @@ async function inferNamedLocalPath(projectRoot, module) {
|
|
|
94441
94506
|
const stats = await lstat15(canonical).catch(() => null);
|
|
94442
94507
|
if (stats?.isDirectory() !== true || await resolveGitRoot(canonical) === null)
|
|
94443
94508
|
continue;
|
|
94444
|
-
matches.set(canonical,
|
|
94509
|
+
matches.set(canonical, relative29(projectRoot, candidate) || ".");
|
|
94445
94510
|
}
|
|
94446
94511
|
return matches.size === 1 ? [...matches.values()][0] : undefined;
|
|
94447
94512
|
}
|
|
@@ -94542,7 +94607,7 @@ async function ensureMaterializedSymlink(input) {
|
|
|
94542
94607
|
return true;
|
|
94543
94608
|
await rm20(linkPath);
|
|
94544
94609
|
}
|
|
94545
|
-
const relTarget =
|
|
94610
|
+
const relTarget = relative29(dirname41(linkPath), input.localAbs) || ".";
|
|
94546
94611
|
await symlink4(relTarget, linkPath);
|
|
94547
94612
|
return true;
|
|
94548
94613
|
}
|
|
@@ -94561,7 +94626,7 @@ async function diagnoseMaterializedSymlink(input) {
|
|
|
94561
94626
|
const current2 = await readlink2(linkPath);
|
|
94562
94627
|
const currentAbs = resolve31(dirname41(linkPath), current2);
|
|
94563
94628
|
if (currentAbs !== input.localAbs) {
|
|
94564
|
-
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) || "."}`);
|
|
94565
94630
|
input.agent_hints.push(`Run context source ensure ${input.sourceName} to refresh the local source link.`);
|
|
94566
94631
|
return false;
|
|
94567
94632
|
}
|
|
@@ -94653,7 +94718,7 @@ async function normalizeAddInput(input, existing) {
|
|
|
94653
94718
|
if (originalLocalAbs !== null && existsSync24(originalLocalAbs)) {
|
|
94654
94719
|
gitRootAbs = await resolveGitRoot(originalLocalAbs);
|
|
94655
94720
|
if (gitRootAbs !== null && localWasResolvedFromInput) {
|
|
94656
|
-
const detectedSubpath = normalizeSubpath2(
|
|
94721
|
+
const detectedSubpath = normalizeSubpath2(relative29(gitRootAbs, originalLocalAbs));
|
|
94657
94722
|
local = await localPathForRegistry({
|
|
94658
94723
|
projectRoot: input.projectRoot,
|
|
94659
94724
|
originalLocal,
|
|
@@ -100828,8 +100893,27 @@ function safeFence2(value, language = "") {
|
|
|
100828
100893
|
${value.trim()}
|
|
100829
100894
|
${fence}`;
|
|
100830
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
|
+
}
|
|
100831
100915
|
function renderChildren(nodes, ctx) {
|
|
100832
|
-
return nodes.map((node3) => renderNode(node3, ctx)).join("");
|
|
100916
|
+
return mergeAdjacentStyles(nodes, ctx).map((node3) => renderNode(node3, ctx)).join("");
|
|
100833
100917
|
}
|
|
100834
100918
|
function renderList(nodes, ctx, ordered) {
|
|
100835
100919
|
const items = nodes.filter((node3) => elementName2(node3) === "li");
|
|
@@ -101034,7 +101118,8 @@ ${"#".repeat(Math.min(Math.max(level, 1), 6))} ${normalizeInline2(renderChildren
|
|
|
101034
101118
|
if (["p", "paragraph", "div", "section"].includes(name3)) {
|
|
101035
101119
|
ctx.tracker.convert(name3);
|
|
101036
101120
|
const body2 = renderChildren(nodes, { ...ctx, mode: "inline" });
|
|
101037
|
-
return ctx.mode === "inline" ? body2
|
|
101121
|
+
return ctx.mode === "inline" ? `${body2}
|
|
101122
|
+
` : `
|
|
101038
101123
|
|
|
101039
101124
|
${body2}
|
|
101040
101125
|
|
|
@@ -101046,15 +101131,15 @@ ${body2}
|
|
|
101046
101131
|
}
|
|
101047
101132
|
if (name3 === "b" || name3 === "strong") {
|
|
101048
101133
|
ctx.tracker.convert(name3);
|
|
101049
|
-
return
|
|
101134
|
+
return wrapInline(renderChildren(nodes, { ...ctx, mode: "inline" }), "**");
|
|
101050
101135
|
}
|
|
101051
101136
|
if (name3 === "i" || name3 === "em") {
|
|
101052
101137
|
ctx.tracker.convert(name3);
|
|
101053
|
-
return
|
|
101138
|
+
return wrapInline(renderChildren(nodes, { ...ctx, mode: "inline" }), "*");
|
|
101054
101139
|
}
|
|
101055
101140
|
if (name3 === "s" || name3 === "del" || name3 === "strike") {
|
|
101056
101141
|
ctx.tracker.convert(name3);
|
|
101057
|
-
return
|
|
101142
|
+
return wrapInline(renderChildren(nodes, { ...ctx, mode: "inline" }), "~~");
|
|
101058
101143
|
}
|
|
101059
101144
|
if (name3 === "a") {
|
|
101060
101145
|
ctx.tracker.convert(name3);
|
|
@@ -101234,7 +101319,7 @@ function projectLarkDocxXmlBlock(input) {
|
|
|
101234
101319
|
fidelity: tracker.report()
|
|
101235
101320
|
};
|
|
101236
101321
|
}
|
|
101237
|
-
var parser, PRESENTATION_ONLY_ATTRIBUTES;
|
|
101322
|
+
var parser, PRESENTATION_ONLY_ATTRIBUTES, INLINE_STYLES;
|
|
101238
101323
|
var init_larkDocxXml = __esm(() => {
|
|
101239
101324
|
init_fxp();
|
|
101240
101325
|
init_larkDocxResources();
|
|
@@ -101262,6 +101347,7 @@ var init_larkDocxXml = __esm(() => {
|
|
|
101262
101347
|
"scale",
|
|
101263
101348
|
"view-type"
|
|
101264
101349
|
]);
|
|
101350
|
+
INLINE_STYLES = new Set(["b", "strong", "i", "em", "s", "del", "strike"]);
|
|
101265
101351
|
});
|
|
101266
101352
|
|
|
101267
101353
|
// src/lib/larkResourceScheduler.ts
|
|
@@ -101488,7 +101574,7 @@ var init_larkResourceCommand = __esm(() => {
|
|
|
101488
101574
|
});
|
|
101489
101575
|
|
|
101490
101576
|
// src/lib/larkMediaDownload.ts
|
|
101491
|
-
import { readdir as
|
|
101577
|
+
import { readdir as readdir25, rm as rm22 } from "node:fs/promises";
|
|
101492
101578
|
import { join as join106 } from "node:path";
|
|
101493
101579
|
async function downloadLarkMedia(input) {
|
|
101494
101580
|
const shared = ["--as", input.identity, "--token", input.token, "--output", "./resource", "--format", "json"];
|
|
@@ -101498,7 +101584,7 @@ async function downloadLarkMedia(input) {
|
|
|
101498
101584
|
} catch (error) {
|
|
101499
101585
|
if (!input.allowPreview || !isLarkResourcePermissionDenied(error))
|
|
101500
101586
|
throw error;
|
|
101501
|
-
for (const entry of await
|
|
101587
|
+
for (const entry of await readdir25(input.cwd))
|
|
101502
101588
|
await rm22(join106(input.cwd, entry), { recursive: true, force: true });
|
|
101503
101589
|
await runLarkResourceCommand(input.runner, ["docs", "+media-preview", ...shared], { cwd: input.cwd });
|
|
101504
101590
|
return "preview";
|
|
@@ -101597,7 +101683,7 @@ var init_larkImagePolicy = __esm(() => {
|
|
|
101597
101683
|
|
|
101598
101684
|
// src/lib/larkResourceMaterialization.ts
|
|
101599
101685
|
import { createHash as createHash31 } from "node:crypto";
|
|
101600
|
-
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";
|
|
101601
101687
|
import { extname as extname13, join as join108 } from "node:path";
|
|
101602
101688
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
101603
101689
|
function countByKind(items, status) {
|
|
@@ -101709,7 +101795,7 @@ async function downloadedFile(input) {
|
|
|
101709
101795
|
const tempRoot = await mkdtemp5(join108(tmpdir2(), "context-lark-resource-"));
|
|
101710
101796
|
try {
|
|
101711
101797
|
const representation = await downloadLarkMedia({ ...input, cwd: tempRoot });
|
|
101712
|
-
const entries2 = (await
|
|
101798
|
+
const entries2 = (await readdir26(tempRoot, { withFileTypes: true })).filter((entry) => entry.isFile());
|
|
101713
101799
|
if (entries2.length !== 1)
|
|
101714
101800
|
throw new Error(`media download produced ${entries2.length} files, expected exactly one`);
|
|
101715
101801
|
const path3 = entries2[0]?.name ?? "resource.bin";
|
|
@@ -102923,7 +103009,7 @@ var init_sensitiveSourceLiteral = __esm(() => {
|
|
|
102923
103009
|
// src/project/larkSnapshotBundle.ts
|
|
102924
103010
|
import { createHash as createHash32 } from "node:crypto";
|
|
102925
103011
|
import { lstat as lstat16, mkdir as mkdir38, readFile as readFile87, realpath as realpath13, rename as rename10, writeFile as writeFile29 } from "node:fs/promises";
|
|
102926
|
-
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";
|
|
102927
103013
|
import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
|
|
102928
103014
|
function normalizedSnapshotResourcePolicy(policy) {
|
|
102929
103015
|
return { ...policy, images: policy.images ?? "bundle", gifs: policy.gifs ?? "bundle" };
|
|
@@ -103145,7 +103231,7 @@ async function reserveSnapshotDirectory(directory, workspaceRoot) {
|
|
|
103145
103231
|
const { findContextProjectRoot: findContextProjectRoot2 } = await Promise.resolve().then(() => (init_workspace(), exports_workspace));
|
|
103146
103232
|
const owner = findContextProjectRoot2(parent)?.projectRoot ?? workspaceRoot;
|
|
103147
103233
|
if (owner !== undefined) {
|
|
103148
|
-
const rel =
|
|
103234
|
+
const rel = relative30(await realpath13(owner), output);
|
|
103149
103235
|
if (["sources", "knowledge", "dist", "src", ".tmp/context-runtime"].some((part) => rel === part || rel.startsWith(`${part.split("/").join(sep10)}${sep10}`))) {
|
|
103150
103236
|
throw larkSnapshotError("Standalone fetch cannot write into managed workspace state; choose a separate scratch directory", "path-invalid");
|
|
103151
103237
|
}
|
|
@@ -103214,7 +103300,7 @@ var init_larkSnapshotBundle = __esm(() => {
|
|
|
103214
103300
|
});
|
|
103215
103301
|
|
|
103216
103302
|
// src/project/documentCaptureLark.ts
|
|
103217
|
-
import { readdir as
|
|
103303
|
+
import { readdir as readdir27, readFile as readFile88 } from "node:fs/promises";
|
|
103218
103304
|
import { basename as basename11, extname as extname14, join as join110 } from "node:path";
|
|
103219
103305
|
function titleFromMarkdown2(markdown, fallbackPath) {
|
|
103220
103306
|
const heading2 = markdown.split(`
|
|
@@ -103374,7 +103460,7 @@ async function listSnapshotAssetFiles(root2, assetRoot) {
|
|
|
103374
103460
|
const visit4 = async (dir, prefix = assetRoot) => {
|
|
103375
103461
|
let entries2;
|
|
103376
103462
|
try {
|
|
103377
|
-
entries2 = await
|
|
103463
|
+
entries2 = await readdir27(dir, { withFileTypes: true });
|
|
103378
103464
|
} catch (error) {
|
|
103379
103465
|
if (error instanceof Error && "code" in error && error.code === "ENOENT")
|
|
103380
103466
|
return;
|
|
@@ -103727,7 +103813,7 @@ __export(exports_articleRetirement, {
|
|
|
103727
103813
|
retireArticles: () => retireArticles,
|
|
103728
103814
|
articleRetirementSchema: () => articleRetirementSchema
|
|
103729
103815
|
});
|
|
103730
|
-
import { readFile as readFile94, readdir as
|
|
103816
|
+
import { readFile as readFile94, readdir as readdir28 } from "node:fs/promises";
|
|
103731
103817
|
import { posix as posix13 } from "node:path";
|
|
103732
103818
|
function rebuildInput(revision) {
|
|
103733
103819
|
return JSON.stringify({ id: `retirement-${revision.slice(7)}`, operation: "rebuild", timing: "priority", targets: [] });
|
|
@@ -103860,7 +103946,7 @@ async function retireArticles(input) {
|
|
|
103860
103946
|
}
|
|
103861
103947
|
async function inspectTemplates(directory2) {
|
|
103862
103948
|
const absolute = await safeProjectTarget(input.projectRoot, directory2);
|
|
103863
|
-
const entries2 = await
|
|
103949
|
+
const entries2 = await readdir28(absolute, { withFileTypes: true }).catch((error) => {
|
|
103864
103950
|
if (error.code === "ENOENT")
|
|
103865
103951
|
return [];
|
|
103866
103952
|
throw error;
|
|
@@ -104010,7 +104096,7 @@ __export(exports_writeLockRecovery, {
|
|
|
104010
104096
|
recoverWriterLock: () => recoverWriterLock,
|
|
104011
104097
|
inspectWriterLock: () => inspectWriterLock
|
|
104012
104098
|
});
|
|
104013
|
-
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";
|
|
104014
104100
|
import { join as join115 } from "node:path";
|
|
104015
104101
|
import { createHash as createHash34, randomUUID as randomUUID8 } from "node:crypto";
|
|
104016
104102
|
async function inspectWriterLock(root2) {
|
|
@@ -104066,7 +104152,7 @@ async function recoverWriterLock(input) {
|
|
|
104066
104152
|
const current2 = await inspectWriterLock(input.projectRoot);
|
|
104067
104153
|
if (current2?.digest !== before.digest || current2.process_state !== "not-running")
|
|
104068
104154
|
throw new Error("Writer lock changed or owner resumed; keep the lock.");
|
|
104069
|
-
const names = await
|
|
104155
|
+
const names = await readdir29(path3);
|
|
104070
104156
|
if (names.some((name3) => name3 !== "owner.json" && name3 !== ".recovery"))
|
|
104071
104157
|
throw new Error("Unexpected lock contents; preserve for diagnosis.");
|
|
104072
104158
|
const archive = `.tmp/context-runtime/locks/recovered-write-${randomUUID8()}.lock`;
|
|
@@ -104095,7 +104181,7 @@ __export(exports_taskRecovery, {
|
|
|
104095
104181
|
});
|
|
104096
104182
|
import { existsSync as existsSync29 } from "node:fs";
|
|
104097
104183
|
import { dirname as dirname48, join as join116 } from "node:path";
|
|
104098
|
-
import { lstat as lstat18, readdir as
|
|
104184
|
+
import { lstat as lstat18, readdir as readdir30, readFile as readFile96 } from "node:fs/promises";
|
|
104099
104185
|
async function recoveryText(root2, path3) {
|
|
104100
104186
|
const target = await safeProjectTarget(root2, path3);
|
|
104101
104187
|
try {
|
|
@@ -104123,7 +104209,7 @@ async function recoveryJournals(root2) {
|
|
|
104123
104209
|
if (stat12.isDirectory()) {
|
|
104124
104210
|
if (depth > 3)
|
|
104125
104211
|
throw new TypeError("Unexpected transaction directory depth; preserve it for diagnosis.");
|
|
104126
|
-
for (const name3 of (await
|
|
104212
|
+
for (const name3 of (await readdir30(join116(root2, path3))).sort())
|
|
104127
104213
|
await visit4(`${path3}/${name3}`, depth + 1);
|
|
104128
104214
|
} else if (stat12.isFile())
|
|
104129
104215
|
entries2.push({ path: path3, digest: indexerProtocolDigest(await recoveryText(root2, path3)) });
|
|
@@ -108946,13 +109032,13 @@ function remarkGfm(options) {
|
|
|
108946
109032
|
init_workspace();
|
|
108947
109033
|
|
|
108948
109034
|
// src/project/reviewFeedback.ts
|
|
108949
|
-
import { readdir as
|
|
109035
|
+
import { readdir as readdir24, readFile as readFile79 } from "node:fs/promises";
|
|
108950
109036
|
import { join as join99 } from "node:path";
|
|
108951
109037
|
async function readPendingReviewFeedback(root2, candidates) {
|
|
108952
109038
|
const directory = join99(root2, ".tmp/context-runtime/review-feedback");
|
|
108953
109039
|
let files;
|
|
108954
109040
|
try {
|
|
108955
|
-
files = await
|
|
109041
|
+
files = await readdir24(directory);
|
|
108956
109042
|
} catch (e) {
|
|
108957
109043
|
if (e.code === "ENOENT")
|
|
108958
109044
|
return [];
|
|
@@ -114118,7 +114204,7 @@ init_cliFeedback();
|
|
|
114118
114204
|
init_exitCode();
|
|
114119
114205
|
init_productionFeedback();
|
|
114120
114206
|
var import_yaml53 = __toESM(require_dist(), 1);
|
|
114121
|
-
import { relative as
|
|
114207
|
+
import { relative as relative31, resolve as resolve38 } from "node:path";
|
|
114122
114208
|
async function completeCurrentProductionAction(input) {
|
|
114123
114209
|
return withProductionFeedback({ operation: "action", file: input.submissionPath }, () => withProjectWriteLock(input.projectRoot, "production-action", async () => {
|
|
114124
114210
|
await recoverDurableMultiFileTransactions(input.projectRoot);
|
|
@@ -114134,7 +114220,7 @@ async function completeCurrentProductionAction(input) {
|
|
|
114134
114220
|
throw invalid3("Stage files do not use the retired Author preview. Submit the current task files.");
|
|
114135
114221
|
if (!input.submissionPath || input.submissionPath === "-")
|
|
114136
114222
|
throw invalid3("Production requires a stage-local manifest file, not stdin.");
|
|
114137
|
-
const path3 =
|
|
114223
|
+
const path3 = relative31(resolve38(input.projectRoot, productionAgentDirectory(stage.id)), resolve38(input.cwd, input.submissionPath));
|
|
114138
114224
|
const manifest = await readProductionFile({ projectRoot: input.projectRoot, stage: stage.id, path: path3 });
|
|
114139
114225
|
const value = import_yaml53.default.parse(manifest.text, { uniqueKeys: true });
|
|
114140
114226
|
if (!value || typeof value !== "object" || !("stage" in value) || value.stage !== stage.id) {
|
|
@@ -114288,12 +114374,12 @@ init_cliFeedback();
|
|
|
114288
114374
|
init_exitCode();
|
|
114289
114375
|
init_productionFeedback();
|
|
114290
114376
|
var import_yaml54 = __toESM(require_dist(), 1);
|
|
114291
|
-
import { relative as
|
|
114377
|
+
import { relative as relative32, resolve as resolve39 } from "node:path";
|
|
114292
114378
|
var productionKnownTasksSchema = productionPlanInputSchema.omit({ stage: true });
|
|
114293
114379
|
async function prepareKnownProductionTasks(input) {
|
|
114294
114380
|
return withProductionFeedback({ operation: "known-tasks", file: input.path, schema: productionKnownTasksSchema }, () => withProjectWriteLock(input.projectRoot, "production-known-tasks", async () => {
|
|
114295
114381
|
await recoverDurableMultiFileTransactions(input.projectRoot);
|
|
114296
|
-
const path3 =
|
|
114382
|
+
const path3 = relative32(resolve39(input.projectRoot, ".tmp/agent-work"), resolve39(input.cwd, input.path));
|
|
114297
114383
|
const fixed2 = await readProductionPlanningFile({ projectRoot: input.projectRoot, path: path3 });
|
|
114298
114384
|
const invalid3 = (message) => new ContextError(ExitCode.UserError, message, {
|
|
114299
114385
|
category: ErrorCategory.UserInputInvalid,
|
|
@@ -114446,7 +114532,7 @@ function registerProjectActionCommands(program2) {
|
|
|
114446
114532
|
// src/commands/cleanClaudePluginCache.ts
|
|
114447
114533
|
init_cliFeedback();
|
|
114448
114534
|
import { existsSync as existsSync30 } from "node:fs";
|
|
114449
|
-
import { readdir as
|
|
114535
|
+
import { readdir as readdir31, rm as rm25 } from "node:fs/promises";
|
|
114450
114536
|
import { homedir } from "node:os";
|
|
114451
114537
|
import { join as join120 } from "node:path";
|
|
114452
114538
|
var ORPHAN_MARKER = ".orphaned_at";
|
|
@@ -114461,17 +114547,17 @@ async function cleanClaudePluginCache(opts = {}) {
|
|
|
114461
114547
|
lines.push("· claude plugin cache: missing — nothing to clean");
|
|
114462
114548
|
return { lines, removed, scanned };
|
|
114463
114549
|
}
|
|
114464
|
-
const marketplaces = await
|
|
114550
|
+
const marketplaces = await readdir31(cacheRoot, { withFileTypes: true });
|
|
114465
114551
|
for (const mp of marketplaces) {
|
|
114466
114552
|
if (!mp.isDirectory())
|
|
114467
114553
|
continue;
|
|
114468
114554
|
const mpDir = join120(cacheRoot, mp.name);
|
|
114469
|
-
const plugins = await
|
|
114555
|
+
const plugins = await readdir31(mpDir, { withFileTypes: true });
|
|
114470
114556
|
for (const pl of plugins) {
|
|
114471
114557
|
if (!pl.isDirectory())
|
|
114472
114558
|
continue;
|
|
114473
114559
|
const plDir = join120(mpDir, pl.name);
|
|
114474
|
-
const versions = await
|
|
114560
|
+
const versions = await readdir31(plDir, { withFileTypes: true });
|
|
114475
114561
|
for (const ver of versions) {
|
|
114476
114562
|
if (!ver.isDirectory())
|
|
114477
114563
|
continue;
|
|
@@ -114513,7 +114599,7 @@ function resolveClaudePluginCacheRoot(opts) {
|
|
|
114513
114599
|
}
|
|
114514
114600
|
async function isEmptyDir(dir) {
|
|
114515
114601
|
try {
|
|
114516
|
-
const entries2 = await
|
|
114602
|
+
const entries2 = await readdir31(dir);
|
|
114517
114603
|
return entries2.length === 0;
|
|
114518
114604
|
} catch {
|
|
114519
114605
|
return false;
|
|
@@ -114561,7 +114647,7 @@ init_writeLock();
|
|
|
114561
114647
|
import { execFile as execFile13 } from "node:child_process";
|
|
114562
114648
|
import { existsSync as existsSync31 } from "node:fs";
|
|
114563
114649
|
import { lstat as lstat19, mkdir as mkdir41, readlink as readlink3, realpath as realpath14, rm as rm26, symlink as symlink5 } from "node:fs/promises";
|
|
114564
|
-
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";
|
|
114565
114651
|
import { promisify as promisify13 } from "node:util";
|
|
114566
114652
|
var execFileAsync6 = promisify13(execFile13);
|
|
114567
114653
|
var RECOVERY_SCHEMA = "context.repository-source-recovery.v1";
|
|
@@ -114811,7 +114897,7 @@ async function bindLocalAlias(input) {
|
|
|
114811
114897
|
}
|
|
114812
114898
|
}
|
|
114813
114899
|
await mkdir41(dirname49(alias), { recursive: true });
|
|
114814
|
-
await symlink5(
|
|
114900
|
+
await symlink5(relative33(dirname49(alias), input.checkout) || ".", alias);
|
|
114815
114901
|
}
|
|
114816
114902
|
function selectPhysicalGroup(sources, selector) {
|
|
114817
114903
|
const direct = selectRepoSources(sources, selector);
|
|
@@ -114871,7 +114957,7 @@ async function restoreRepositorySources(input) {
|
|
|
114871
114957
|
await bindLocalAlias({ projectRoot: input.projectRoot, declaredLocal: source2.local, checkout });
|
|
114872
114958
|
continue;
|
|
114873
114959
|
}
|
|
114874
|
-
const nextLocal =
|
|
114960
|
+
const nextLocal = relative33(input.projectRoot, checkout).startsWith("..") ? checkout : relative33(input.projectRoot, checkout) || ".";
|
|
114875
114961
|
if (source2.local !== nextLocal) {
|
|
114876
114962
|
source2.local = nextLocal;
|
|
114877
114963
|
registryChanged = true;
|
|
@@ -115203,7 +115289,7 @@ init_exitCode();
|
|
|
115203
115289
|
var import_yaml55 = __toESM(require_dist(), 1);
|
|
115204
115290
|
import { createHash as createHash36 } from "node:crypto";
|
|
115205
115291
|
import { readFile as readFile100, realpath as realpath15 } from "node:fs/promises";
|
|
115206
|
-
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";
|
|
115207
115293
|
init_writeLock();
|
|
115208
115294
|
var SOURCE_NAME_PATTERN3 = /^[a-z0-9][a-z0-9._-]*$/u;
|
|
115209
115295
|
function isDateSourceNamespace(value) {
|
|
@@ -115268,7 +115354,7 @@ async function normalizeFileSourceLocal(projectRoot2, value) {
|
|
|
115268
115354
|
const canonicalProjectRoot = await realpathOrResolve(projectRoot2);
|
|
115269
115355
|
const rawAbsolute = isAbsolute24(trimmed) ? resolve41(trimmed) : resolve41(canonicalProjectRoot, trimmed);
|
|
115270
115356
|
const absolute = await realpathOrResolve(rawAbsolute);
|
|
115271
|
-
const normalized =
|
|
115357
|
+
const normalized = relative34(canonicalProjectRoot, absolute).replaceAll("\\", "/");
|
|
115272
115358
|
if (normalized.length === 0 || normalized === "." || isAbsolute24(normalized) || normalized.split("/").some((part) => part.length === 0 || part === ".")) {
|
|
115273
115359
|
throw new ContextError(ExitCode.UserError, `cannot safely store file source local path as project-relative path: ${value}`, {
|
|
115274
115360
|
category: ErrorCategory.UserInputInvalid,
|
|
@@ -116428,13 +116514,13 @@ init_exitCode();
|
|
|
116428
116514
|
|
|
116429
116515
|
// src/project/wikiDiscovery.ts
|
|
116430
116516
|
import { mkdir as mkdir43 } from "node:fs/promises";
|
|
116431
|
-
import { join as join127, relative as
|
|
116517
|
+
import { join as join127, relative as relative36 } from "node:path";
|
|
116432
116518
|
|
|
116433
116519
|
// src/project/wikiDiscoveryStore.ts
|
|
116434
116520
|
init_atomicWrite();
|
|
116435
116521
|
import { createHash as createHash38, randomUUID as randomUUID9 } from "node:crypto";
|
|
116436
|
-
import { link as link2, lstat as lstat21, mkdir as mkdir42, readFile as readFile103, readdir as
|
|
116437
|
-
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";
|
|
116438
116524
|
function wikiDiscoveryDigest(value) {
|
|
116439
116525
|
return createHash38("sha256").update(value).digest("hex");
|
|
116440
116526
|
}
|
|
@@ -116443,7 +116529,7 @@ function wikiDiscoveryPageKey(cursor) {
|
|
|
116443
116529
|
}
|
|
116444
116530
|
async function assertWikiDiscoveryPath(root2, path3) {
|
|
116445
116531
|
const base = resolve43(root2);
|
|
116446
|
-
const parts =
|
|
116532
|
+
const parts = relative35(base, resolve43(path3)).split(sep11);
|
|
116447
116533
|
if (parts[0] === "..")
|
|
116448
116534
|
throw new WikiDiscoveryError("unsafe-checkpoint-path", false, "Discovery checkpoint must stay inside its workspace");
|
|
116449
116535
|
let current2 = base;
|
|
@@ -116479,7 +116565,7 @@ async function loadWikiDiscoveryReceipts(directory) {
|
|
|
116479
116565
|
const result = new Map;
|
|
116480
116566
|
await assertWikiDiscoveryPath(directory, join126(directory, "pages"));
|
|
116481
116567
|
await mkdir42(join126(directory, "pages"), { recursive: true });
|
|
116482
|
-
for (const file of await
|
|
116568
|
+
for (const file of await readdir32(join126(directory, "pages"))) {
|
|
116483
116569
|
if (!/^[a-f0-9]{64}\.json$/u.test(file))
|
|
116484
116570
|
continue;
|
|
116485
116571
|
const value = await readWikiDiscoveryJson(join126(directory, "pages", file));
|
|
@@ -116505,7 +116591,7 @@ async function acquireWikiDiscoveryLease(directory) {
|
|
|
116505
116591
|
await assertWikiDiscoveryPath(directory, leases);
|
|
116506
116592
|
await mkdir42(leases, { recursive: true });
|
|
116507
116593
|
for (let attempt = 0;attempt < 8; attempt++) {
|
|
116508
|
-
const files = (await
|
|
116594
|
+
const files = (await readdir32(leases)).filter((file) => /^\d{12}\.json$/u.test(file)).sort();
|
|
116509
116595
|
const latest = files.at(-1);
|
|
116510
116596
|
if (latest) {
|
|
116511
116597
|
const current2 = await readWikiDiscoveryJson(join126(leases, latest));
|
|
@@ -116747,7 +116833,7 @@ async function finishDiscovery(input, state) {
|
|
|
116747
116833
|
status,
|
|
116748
116834
|
url,
|
|
116749
116835
|
identity: identity2,
|
|
116750
|
-
manifest:
|
|
116836
|
+
manifest: relative36(input.projectRoot, manifestPath),
|
|
116751
116837
|
counts: progress(view),
|
|
116752
116838
|
failures: view.failed.slice(0, 10),
|
|
116753
116839
|
failures_truncated: view.failed.length > 10,
|
|
@@ -116903,8 +116989,8 @@ init_writeLock();
|
|
|
116903
116989
|
var import_yaml59 = __toESM(require_dist(), 1);
|
|
116904
116990
|
import { existsSync as existsSync33 } from "node:fs";
|
|
116905
116991
|
import { createHash as createHash39 } from "node:crypto";
|
|
116906
|
-
import { readFile as readFile104, readdir as
|
|
116907
|
-
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";
|
|
116908
116994
|
function sourceIdentity(source2) {
|
|
116909
116995
|
if (source2.kind === "source.collection")
|
|
116910
116996
|
return;
|
|
@@ -117077,7 +117163,7 @@ function safeManagedMaterializedPath(projectRoot2, source2) {
|
|
|
117077
117163
|
return;
|
|
117078
117164
|
const absolute = resolve44(projectRoot2, source2.materializedAt);
|
|
117079
117165
|
const expectedRoot = resolve44(projectRoot2, "sources", source2.type);
|
|
117080
|
-
const rel =
|
|
117166
|
+
const rel = relative37(expectedRoot, absolute);
|
|
117081
117167
|
if (rel.length === 0 || rel === ".." || rel.startsWith(`..${sep12}`) || isAbsolute25(rel)) {
|
|
117082
117168
|
return;
|
|
117083
117169
|
}
|
|
@@ -117089,7 +117175,7 @@ function safeManagedManifestPath(projectRoot2, source2) {
|
|
|
117089
117175
|
throw unsafeOwnership(source2, manifest);
|
|
117090
117176
|
const absolute = resolve44(projectRoot2, manifest);
|
|
117091
117177
|
const expectedRoot = resolve44(projectRoot2, "sources", source2.type);
|
|
117092
|
-
const rel =
|
|
117178
|
+
const rel = relative37(expectedRoot, absolute);
|
|
117093
117179
|
if (rel.length === 0 || rel === ".." || rel.startsWith(`..${sep12}`) || isAbsolute25(rel)) {
|
|
117094
117180
|
throw unsafeOwnership(source2, manifest);
|
|
117095
117181
|
}
|
|
@@ -117100,7 +117186,7 @@ function safeManagedSnapshotChild(projectRoot2, source2, path3) {
|
|
|
117100
117186
|
if (materializedRoot === undefined || isAbsolute25(path3))
|
|
117101
117187
|
throw unsafeOwnership(source2, path3);
|
|
117102
117188
|
const absolute = resolve44(materializedRoot, path3);
|
|
117103
|
-
const rel =
|
|
117189
|
+
const rel = relative37(materializedRoot, absolute);
|
|
117104
117190
|
if (rel.length === 0 || rel === ".." || rel.startsWith(`..${sep12}`) || isAbsolute25(rel)) {
|
|
117105
117191
|
throw unsafeOwnership(source2, path3);
|
|
117106
117192
|
}
|
|
@@ -117116,7 +117202,7 @@ function unsafeOwnership(source2, path3) {
|
|
|
117116
117202
|
});
|
|
117117
117203
|
}
|
|
117118
117204
|
function projectRelative(projectRoot2, path3) {
|
|
117119
|
-
return
|
|
117205
|
+
return relative37(projectRoot2, path3).split(sep12).join("/");
|
|
117120
117206
|
}
|
|
117121
117207
|
function digest7(value) {
|
|
117122
117208
|
return `sha256:${createHash39("sha256").update(JSON.stringify(value)).digest("hex")}`;
|
|
@@ -117282,7 +117368,7 @@ async function pruneExtractRuntime(projectRoot2, source2) {
|
|
|
117282
117368
|
const visit4 = async (directory) => {
|
|
117283
117369
|
if (!existsSync33(directory))
|
|
117284
117370
|
return;
|
|
117285
|
-
for (const entry of await
|
|
117371
|
+
for (const entry of await readdir33(directory, { withFileTypes: true })) {
|
|
117286
117372
|
const path3 = join128(directory, entry.name);
|
|
117287
117373
|
if (entry.isDirectory()) {
|
|
117288
117374
|
await visit4(path3);
|
|
@@ -118014,7 +118100,7 @@ init_cliFeedback();
|
|
|
118014
118100
|
init_exitCode();
|
|
118015
118101
|
var import_yaml62 = __toESM(require_dist(), 1);
|
|
118016
118102
|
import { constants as constants6, existsSync as existsSync34 } from "node:fs";
|
|
118017
|
-
import { lstat as lstat22, open as open5, readdir as
|
|
118103
|
+
import { lstat as lstat22, open as open5, readdir as readdir34 } from "node:fs/promises";
|
|
118018
118104
|
import { dirname as dirname50, join as join130, resolve as resolve47 } from "node:path";
|
|
118019
118105
|
import { fileURLToPath as fileURLToPath10 } from "node:url";
|
|
118020
118106
|
function bundledSkillRoot() {
|
|
@@ -118042,7 +118128,7 @@ async function listProductionSkills(root2) {
|
|
|
118042
118128
|
}
|
|
118043
118129
|
}
|
|
118044
118130
|
async function readProductionSkills(root2) {
|
|
118045
|
-
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);
|
|
118046
118132
|
const skills = [];
|
|
118047
118133
|
for (const directory of entries2) {
|
|
118048
118134
|
const entry = join130(root2, directory.name, "SKILL.md");
|
|
@@ -118074,13 +118160,13 @@ async function readProductionSkills(root2) {
|
|
|
118074
118160
|
// src/project/indexerBenchmarkActions.ts
|
|
118075
118161
|
init_src2();
|
|
118076
118162
|
import { realpath as realpath16 } from "node:fs/promises";
|
|
118077
|
-
import { isAbsolute as isAbsolute27, relative as
|
|
118163
|
+
import { isAbsolute as isAbsolute27, relative as relative38 } from "node:path";
|
|
118078
118164
|
async function assertOracleOutsideAgentWorkspace(input) {
|
|
118079
118165
|
const [workspace, oracle] = await Promise.all([
|
|
118080
118166
|
realpath16(input.projectRoot),
|
|
118081
118167
|
realpath16(input.oraclePath)
|
|
118082
118168
|
]);
|
|
118083
|
-
const relation =
|
|
118169
|
+
const relation = relative38(workspace, oracle);
|
|
118084
118170
|
if (relation.length === 0 || !relation.startsWith("..") && !isAbsolute27(relation)) {
|
|
118085
118171
|
throw new TypeError("benchmark oracle must be loaded from outside the execution Agent workspace");
|
|
118086
118172
|
}
|
|
@@ -118453,7 +118539,7 @@ init_cliFeedback();
|
|
|
118453
118539
|
init_errors3();
|
|
118454
118540
|
init_exitCode();
|
|
118455
118541
|
import { createHash as createHash40 } from "node:crypto";
|
|
118456
|
-
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";
|
|
118457
118543
|
import { dirname as dirname52, join as join131, resolve as resolve49 } from "node:path";
|
|
118458
118544
|
var MARKER = ".context-skill-install.json";
|
|
118459
118545
|
function conflict(path3) {
|
|
@@ -118482,7 +118568,7 @@ async function checkParents(path3) {
|
|
|
118482
118568
|
async function digest8(root2) {
|
|
118483
118569
|
const hash5 = createHash40("sha256");
|
|
118484
118570
|
async function visit4(dir, prefix) {
|
|
118485
|
-
for (const name3 of (await
|
|
118571
|
+
for (const name3 of (await readdir35(dir)).sort()) {
|
|
118486
118572
|
if (!prefix && name3 === MARKER)
|
|
118487
118573
|
continue;
|
|
118488
118574
|
const path3 = join131(dir, name3);
|
|
@@ -118511,13 +118597,13 @@ async function installLocalSkills(root2, path3, dryRun, agent) {
|
|
|
118511
118597
|
const commandPlans = [];
|
|
118512
118598
|
const commandEntries = new Set;
|
|
118513
118599
|
if (agent === "claude" || agent === "cursor") {
|
|
118514
|
-
for (const name3 of await
|
|
118600
|
+
for (const name3 of await readdir35(join131(root2, "claude", "commands"))) {
|
|
118515
118601
|
if (name3.endsWith(".md"))
|
|
118516
118602
|
commandEntries.add(name3.slice(0, -3));
|
|
118517
118603
|
}
|
|
118518
118604
|
const commandsRoot = join131(targetRoot, "commands");
|
|
118519
118605
|
await checkParents(commandsRoot);
|
|
118520
|
-
for (const entry of await
|
|
118606
|
+
for (const entry of await readdir35(join131(root2, agent, "commands"), { withFileTypes: true })) {
|
|
118521
118607
|
if (!entry.isFile() || !entry.name.endsWith(".md"))
|
|
118522
118608
|
continue;
|
|
118523
118609
|
let content3 = await readFile110(join131(root2, agent, "commands", entry.name), "utf8");
|
|
@@ -118553,7 +118639,7 @@ ${frontmatter2[2].replace(/^disable-model-invocation:.*\r?\n?/mu, "")}${frontmat
|
|
|
118553
118639
|
conflict(join131(root2, agent, "commands"));
|
|
118554
118640
|
}
|
|
118555
118641
|
const plans = [];
|
|
118556
|
-
for (const entry of (await
|
|
118642
|
+
for (const entry of (await readdir35(sourceRoot2, { withFileTypes: true })).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
118557
118643
|
if (!entry.isDirectory() || !await stat12(join131(sourceRoot2, entry.name, "SKILL.md")))
|
|
118558
118644
|
continue;
|
|
118559
118645
|
const source2 = join131(sourceRoot2, entry.name);
|
|
@@ -118725,7 +118811,7 @@ init_errors3();
|
|
|
118725
118811
|
init_exitCode();
|
|
118726
118812
|
import { execFile as execFile14 } from "node:child_process";
|
|
118727
118813
|
import { existsSync as existsSync36 } from "node:fs";
|
|
118728
|
-
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";
|
|
118729
118815
|
import { homedir as homedir2 } from "node:os";
|
|
118730
118816
|
import { dirname as dirname53, join as join133 } from "node:path";
|
|
118731
118817
|
import { promisify as promisify14 } from "node:util";
|
|
@@ -118868,7 +118954,7 @@ async function pruneCodexPluginCacheForName(pluginName, keepVersion, dryRun, ste
|
|
|
118868
118954
|
const cacheRoot = join133(codexHome(), "plugins", "cache", MARKETPLACE_NAME, pluginName);
|
|
118869
118955
|
if (!existsSync36(cacheRoot))
|
|
118870
118956
|
return;
|
|
118871
|
-
const versions = (await
|
|
118957
|
+
const versions = (await readdir36(cacheRoot, { withFileTypes: true }).catch(() => [])).filter((entry) => entry.isDirectory() && entry.name !== keepVersion).map((entry) => entry.name).sort();
|
|
118872
118958
|
if (versions.length === 0)
|
|
118873
118959
|
return;
|
|
118874
118960
|
steps.push({
|
|
@@ -118887,7 +118973,7 @@ async function pruneCodexPluginCache(currentVersion, dryRun, steps) {
|
|
|
118887
118973
|
}
|
|
118888
118974
|
async function isEmptyDir2(dir) {
|
|
118889
118975
|
try {
|
|
118890
|
-
return (await
|
|
118976
|
+
return (await readdir36(dir)).length === 0;
|
|
118891
118977
|
} catch {
|
|
118892
118978
|
return false;
|
|
118893
118979
|
}
|
|
@@ -118897,14 +118983,14 @@ async function pruneClaudeOrphanContextCache(dryRun, steps) {
|
|
|
118897
118983
|
if (!existsSync36(cacheRoot))
|
|
118898
118984
|
return;
|
|
118899
118985
|
const removed = [];
|
|
118900
|
-
const marketplaces = await
|
|
118986
|
+
const marketplaces = await readdir36(cacheRoot, { withFileTypes: true }).catch(() => []);
|
|
118901
118987
|
for (const marketplace of marketplaces) {
|
|
118902
118988
|
if (!marketplace.isDirectory())
|
|
118903
118989
|
continue;
|
|
118904
118990
|
const pluginDir = join133(cacheRoot, marketplace.name, PLUGIN_NAME);
|
|
118905
118991
|
if (!existsSync36(pluginDir))
|
|
118906
118992
|
continue;
|
|
118907
|
-
const versions = await
|
|
118993
|
+
const versions = await readdir36(pluginDir, { withFileTypes: true }).catch(() => []);
|
|
118908
118994
|
for (const version3 of versions) {
|
|
118909
118995
|
if (!version3.isDirectory())
|
|
118910
118996
|
continue;
|
|
@@ -118962,7 +119048,7 @@ async function pruneClaudeSupersededContextCache(root2, dryRun, steps) {
|
|
|
118962
119048
|
if (!currentVersion)
|
|
118963
119049
|
return;
|
|
118964
119050
|
const pluginDir = join133(claudePluginCacheRoot(), MARKETPLACE_NAME, PLUGIN_NAME);
|
|
118965
|
-
const staleVersions = (await
|
|
119051
|
+
const staleVersions = (await readdir36(pluginDir, { withFileTypes: true }).catch(() => [])).filter((entry) => entry.isDirectory() && entry.name !== currentVersion).map((entry) => entry.name);
|
|
118966
119052
|
if (staleVersions.length === 0)
|
|
118967
119053
|
return;
|
|
118968
119054
|
steps.push({
|
|
@@ -119097,7 +119183,7 @@ async function materializeCodexPluginCache(root2, version3, dryRun, steps) {
|
|
|
119097
119183
|
}
|
|
119098
119184
|
async function bundledProviderSkillNames(root2) {
|
|
119099
119185
|
const skillsRoot = join133(root2, "skills");
|
|
119100
|
-
const entries2 = await
|
|
119186
|
+
const entries2 = await readdir36(skillsRoot, { withFileTypes: true });
|
|
119101
119187
|
const names = [];
|
|
119102
119188
|
for (const entry of entries2) {
|
|
119103
119189
|
if (!entry.isDirectory() || entry.name === "context")
|