@c4a/context-cli 0.7.96 → 0.7.98
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/README.md +4 -1
- package/README.zh-CN.md +2 -0
- package/cli.js +780 -345
- package/indexers/contracts/profile-contract.json +245 -245
- package/indexers/release-manifest.json +1 -1
- package/package.json +12 -12
- package/parserEntryWorker.js +7 -4
- package/plugins/VERSION +1 -1
- package/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/plugins/claude/commands/context.md +1 -1
- package/plugins/codex/.codex-plugin/plugin.json +2 -2
- package/plugins/codex/skills/context/SKILL.md +1 -1
- package/plugins/cursor/.cursor-plugin/plugin.json +1 -1
- package/plugins/cursor/commands/c4a-context.md +1 -1
- package/plugins/skills/context/SKILL.md +1 -1
- package/providers/context/manifest.json +12 -12
- package/providers/context/provider.yaml +1 -1
- package/providers/context/resources/manuals/guides/knowledge-updates.md +10 -1
- package/providers/context/resources/manuals/guides/lark-resources.md +11 -2
- package/providers/context/resources/procedures/document-capture.md +7 -1
- package/providers/context/resources/procedures/knowledge-updates.md +10 -1
- package/providers/context/resources/procedures/production-stage-files.md +6 -2
package/cli.js
CHANGED
|
@@ -41212,7 +41212,7 @@ var import_yaml8, DEFAULT_REPO_SOURCES_REGISTRY_PATH = "sources/repo/index.yaml"
|
|
|
41212
41212
|
}
|
|
41213
41213
|
}
|
|
41214
41214
|
}
|
|
41215
|
-
}, loadSourcesRegistry = async (options = {}) => {
|
|
41215
|
+
}, SOURCES_REGISTRY_EXCLUSION, loadSourcesRegistry = async (options = {}) => {
|
|
41216
41216
|
const rootDir = options.rootDir ?? process.cwd();
|
|
41217
41217
|
const repoRegistryPath = options.repoRegistryPath ?? options.registryPath ?? DEFAULT_REPO_SOURCES_REGISTRY_PATH;
|
|
41218
41218
|
const fileRegistryPath = options.fileRegistryPath ?? DEFAULT_FILE_SOURCES_REGISTRY_PATH;
|
|
@@ -41220,6 +41220,8 @@ var import_yaml8, DEFAULT_REPO_SOURCES_REGISTRY_PATH = "sources/repo/index.yaml"
|
|
|
41220
41220
|
const repoAbsolutePath = resolve7(rootDir, repoRegistryPath);
|
|
41221
41221
|
const fileAbsolutePath = resolve7(rootDir, fileRegistryPath);
|
|
41222
41222
|
const larkAbsolutePath = resolve7(rootDir, larkRegistryPath);
|
|
41223
|
+
const excluded = globalThis[SOURCES_REGISTRY_EXCLUSION];
|
|
41224
|
+
const included = (entry) => !(excluded instanceof Set && (excluded.has(entry.name) || excluded.has(entry.id)));
|
|
41223
41225
|
const repoRegistry = parseRepoSourcesRegistry(await readYamlIfPresent(repoAbsolutePath, { sources: [] }), repoRegistryPath, repoAbsolutePath);
|
|
41224
41226
|
const files = parseFileSourcesRegistry(await readYamlIfPresent(fileAbsolutePath, { sources: [] }), fileRegistryPath);
|
|
41225
41227
|
const larks = parseLarkSourcesRegistry(await readYamlIfPresent(larkAbsolutePath, { sources: [] }), larkRegistryPath);
|
|
@@ -41235,9 +41237,9 @@ var import_yaml8, DEFAULT_REPO_SOURCES_REGISTRY_PATH = "sources/repo/index.yaml"
|
|
|
41235
41237
|
file: fileAbsolutePath,
|
|
41236
41238
|
lark: larkAbsolutePath
|
|
41237
41239
|
},
|
|
41238
|
-
repos: repoRegistry.repos,
|
|
41239
|
-
files,
|
|
41240
|
-
larks,
|
|
41240
|
+
repos: repoRegistry.repos.filter(included),
|
|
41241
|
+
files: files.filter(included),
|
|
41242
|
+
larks: larks.filter(included),
|
|
41241
41243
|
notes: await discoverManagedDocuments(rootDir, "note"),
|
|
41242
41244
|
sessions: await discoverManagedDocuments(rootDir, "sessions")
|
|
41243
41245
|
};
|
|
@@ -41304,6 +41306,7 @@ var init_sources = __esm(() => {
|
|
|
41304
41306
|
larkSourcesRegistrySchema = exports_external.object({
|
|
41305
41307
|
sources: exports_external.array(exports_external.union([larkSourceRegistryEntrySchema, larkSourceBatchSchema])).default([])
|
|
41306
41308
|
}).strict();
|
|
41309
|
+
SOURCES_REGISTRY_EXCLUSION = Symbol.for("c4a.context.sources-registry-exclusion");
|
|
41307
41310
|
});
|
|
41308
41311
|
|
|
41309
41312
|
// ../context/src/processedScopes.ts
|
|
@@ -69867,6 +69870,15 @@ var init_durableMultiFileTransaction = __esm(() => {
|
|
|
69867
69870
|
});
|
|
69868
69871
|
|
|
69869
69872
|
// src/project/productionRequirements.ts
|
|
69873
|
+
var exports_productionRequirements = {};
|
|
69874
|
+
__export(exports_productionRequirements, {
|
|
69875
|
+
validateProductionRequirements: () => validateProductionRequirements,
|
|
69876
|
+
readProductionRequirements: () => readProductionRequirements,
|
|
69877
|
+
productionSourceIsExcluded: () => productionSourceIsExcluded,
|
|
69878
|
+
productionRequirementsSchema: () => productionRequirementsSchema,
|
|
69879
|
+
inspectProductionRequirements: () => inspectProductionRequirements,
|
|
69880
|
+
PRODUCTION_REQUIREMENTS_PATH: () => PRODUCTION_REQUIREMENTS_PATH
|
|
69881
|
+
});
|
|
69870
69882
|
import { readFile as readFile13 } from "node:fs/promises";
|
|
69871
69883
|
async function readProductionRequirements(projectRoot) {
|
|
69872
69884
|
const inspected = await inspectProductionRequirements(projectRoot);
|
|
@@ -70012,6 +70024,85 @@ function approvedContextSectionsInMarkdown(content3) {
|
|
|
70012
70024
|
return result;
|
|
70013
70025
|
}
|
|
70014
70026
|
|
|
70027
|
+
// src/lib/gitProgress.ts
|
|
70028
|
+
import { spawn as spawn2 } from "node:child_process";
|
|
70029
|
+
function redactRemoteCredentials(text5) {
|
|
70030
|
+
return text5.replace(/\/\/[^/@\s]+@/gu, "//");
|
|
70031
|
+
}
|
|
70032
|
+
function progressCount(line) {
|
|
70033
|
+
const match = /^(?:remote:\s*)?([A-Za-z][A-Za-z ]*?):\s+(?:\d+%\s+\((\d+)\/\d+\)|(\d+))/u.exec(line);
|
|
70034
|
+
if (!match)
|
|
70035
|
+
return;
|
|
70036
|
+
const size = /,\s*(\d+(?:\.\d+)?)\s*(bytes|[KMGT]iB)(?!\/s)/u.exec(line.slice(match[0].length));
|
|
70037
|
+
return { phase: match[1], count: Number(match[2] ?? match[3]), bytes: size ? Number(size[1]) * UNITS[size[2]] : 0 };
|
|
70038
|
+
}
|
|
70039
|
+
async function runGitWithProgress(args, options) {
|
|
70040
|
+
const idleMs = options.idleMs ?? 5 * 60000, limitMs = options.limitMs ?? 30 * 60000, reportMs = options.reportMs ?? 30000;
|
|
70041
|
+
const command = args.findIndex((arg) => arg === "fetch" || arg === "clone");
|
|
70042
|
+
const argv = command < 0 ? [...args] : [...args.slice(0, command + 1), "--progress", ...args.slice(command + 1)];
|
|
70043
|
+
const child = spawn2(options.bin ?? "git", argv, { cwd: options.cwd, env: options.env ?? process.env, stdio: ["ignore", "pipe", "pipe"] });
|
|
70044
|
+
const started = Date.now();
|
|
70045
|
+
let lastProgress = started, lastReport = started, lastLine = "", stdout = "", tail = "";
|
|
70046
|
+
const counts2 = new Map;
|
|
70047
|
+
child.stdout.on("data", (chunk) => {
|
|
70048
|
+
stdout += String(chunk);
|
|
70049
|
+
});
|
|
70050
|
+
child.stderr.on("data", (chunk) => {
|
|
70051
|
+
const text5 = String(chunk);
|
|
70052
|
+
tail = (tail + text5).slice(-4000);
|
|
70053
|
+
for (const line of text5.split(/[\r\n]+/u).map((part) => part.trim()).filter(Boolean)) {
|
|
70054
|
+
const progress = progressCount(line);
|
|
70055
|
+
if (!progress)
|
|
70056
|
+
continue;
|
|
70057
|
+
lastLine = line;
|
|
70058
|
+
const previous2 = counts2.get(progress.phase);
|
|
70059
|
+
if (!previous2 || progress.count > previous2.count || progress.bytes > previous2.bytes) {
|
|
70060
|
+
counts2.set(progress.phase, { count: Math.max(progress.count, previous2?.count ?? 0), bytes: Math.max(progress.bytes, previous2?.bytes ?? 0) });
|
|
70061
|
+
lastProgress = Date.now();
|
|
70062
|
+
}
|
|
70063
|
+
}
|
|
70064
|
+
});
|
|
70065
|
+
let stopped;
|
|
70066
|
+
const timer = setInterval(() => {
|
|
70067
|
+
const now = Date.now();
|
|
70068
|
+
if (now - started > limitMs)
|
|
70069
|
+
stopped = new GitProgressError(`${options.label} stopped after ${Math.round(limitMs / 60000)} minutes ` + `(still running; last progress: ${redactRemoteCredentials(lastLine) || "none"}). Report this to the user before retrying.`, "too-long");
|
|
70070
|
+
else if (now - lastProgress > idleMs)
|
|
70071
|
+
stopped = new GitProgressError(`${options.label} made no progress for ${Math.round(idleMs / 60000)} minutes ` + `(last progress: ${redactRemoteCredentials(lastLine) || "none"}).`, "no-progress");
|
|
70072
|
+
if (stopped) {
|
|
70073
|
+
child.kill("SIGKILL");
|
|
70074
|
+
return;
|
|
70075
|
+
}
|
|
70076
|
+
if (now - lastReport >= reportMs && lastLine) {
|
|
70077
|
+
lastReport = now;
|
|
70078
|
+
process.stderr.write(`[context] ${options.label}: ${redactRemoteCredentials(lastLine)}
|
|
70079
|
+
`);
|
|
70080
|
+
}
|
|
70081
|
+
}, Math.min(1000, idleMs, limitMs));
|
|
70082
|
+
const code = await new Promise((resolve8, reject) => {
|
|
70083
|
+
child.once("error", reject);
|
|
70084
|
+
child.once("close", resolve8);
|
|
70085
|
+
}).finally(() => clearInterval(timer));
|
|
70086
|
+
if (stopped)
|
|
70087
|
+
throw stopped;
|
|
70088
|
+
if (code !== 0) {
|
|
70089
|
+
const line = tail.split(/[\r\n]+/u).map((part) => part.trim()).find((part) => /^(fatal|error):/iu.test(part)) ?? tail.trim().split(/[\r\n]+/u).pop() ?? "";
|
|
70090
|
+
throw new GitProgressError(`${options.label} failed: ${redactRemoteCredentials(line).slice(0, 300) || `exit ${code}`}`, "failed");
|
|
70091
|
+
}
|
|
70092
|
+
return stdout;
|
|
70093
|
+
}
|
|
70094
|
+
var GitProgressError, UNITS;
|
|
70095
|
+
var init_gitProgress = __esm(() => {
|
|
70096
|
+
GitProgressError = class GitProgressError extends Error {
|
|
70097
|
+
kind;
|
|
70098
|
+
constructor(message, kind) {
|
|
70099
|
+
super(message);
|
|
70100
|
+
this.kind = kind;
|
|
70101
|
+
}
|
|
70102
|
+
};
|
|
70103
|
+
UNITS = { bytes: 1, KiB: 1024, MiB: 1024 ** 2, GiB: 1024 ** 3, TiB: 1024 ** 4 };
|
|
70104
|
+
});
|
|
70105
|
+
|
|
70015
70106
|
// src/project/repoContentGit.ts
|
|
70016
70107
|
import { execFile as execFile2 } from "node:child_process";
|
|
70017
70108
|
import { promisify as promisify2 } from "node:util";
|
|
@@ -70437,7 +70528,7 @@ var init_repoContentEvidence = __esm(() => {
|
|
|
70437
70528
|
});
|
|
70438
70529
|
|
|
70439
70530
|
// src/project/gitObjectReader.ts
|
|
70440
|
-
import { execFile as execFile3, spawn as
|
|
70531
|
+
import { execFile as execFile3, spawn as spawn3 } from "node:child_process";
|
|
70441
70532
|
async function missingReason(root, expression) {
|
|
70442
70533
|
const separator = expression.indexOf(":./");
|
|
70443
70534
|
const commit = expression.slice(0, separator), path2 = expression.slice(separator + 3);
|
|
@@ -70549,7 +70640,7 @@ function createGitObjectReader(options = {}) {
|
|
|
70549
70640
|
progress();
|
|
70550
70641
|
}
|
|
70551
70642
|
function start2() {
|
|
70552
|
-
const process2 =
|
|
70643
|
+
const process2 = spawn3("git", ["-C", root, "cat-file", "--batch", "-z"], { env: { ...globalThis.process.env, GIT_NO_LAZY_FETCH: "1" } });
|
|
70553
70644
|
child = process2;
|
|
70554
70645
|
process2.stdout.on("data", (chunk) => {
|
|
70555
70646
|
if (child === process2)
|
|
@@ -70653,12 +70744,15 @@ function inside(root, path2) {
|
|
|
70653
70744
|
throw new SourceUnavailableError("Article source path escapes its captured scope", "source-path-outside-scope");
|
|
70654
70745
|
}
|
|
70655
70746
|
}
|
|
70656
|
-
function commitAvailability(fetched, fetch = true) {
|
|
70747
|
+
function commitAvailability(fetched, fetch = true, failures) {
|
|
70657
70748
|
return (directory, commit) => {
|
|
70658
70749
|
const key = `${directory}\x00${commit}`;
|
|
70659
70750
|
let result = fetched.get(key);
|
|
70660
70751
|
if (!result) {
|
|
70661
|
-
result = execute("git", ["-C", directory, "cat-file", "-e", `${commit}^{commit}`], { timeout: 5000, env: { ...process.env, GIT_NO_LAZY_FETCH: "1" } }).then(() => true, () => !fetch ? false :
|
|
70752
|
+
result = execute("git", ["-C", directory, "cat-file", "-e", `${commit}^{commit}`], { timeout: 5000, env: { ...process.env, GIT_NO_LAZY_FETCH: "1" } }).then(() => true, () => !fetch ? false : runGitWithProgress(["-C", directory, "fetch", "--depth=1", "origin", commit], { env: { ...process.env, GIT_TERMINAL_PROMPT: "0" }, label: `git fetch of commit ${commit.slice(0, 12)}` }).then(() => true, (error) => {
|
|
70753
|
+
failures?.set(commit, error instanceof Error ? error.message : String(error));
|
|
70754
|
+
return false;
|
|
70755
|
+
}));
|
|
70662
70756
|
fetched.set(key, result);
|
|
70663
70757
|
}
|
|
70664
70758
|
return result;
|
|
@@ -70670,7 +70764,8 @@ function missingCommit(commit) {
|
|
|
70670
70764
|
async function fetchSourceCommits(projectRoot, requests) {
|
|
70671
70765
|
const workspace = await realpath5(projectRoot);
|
|
70672
70766
|
const registry2 = await loadSourcesRegistry({ rootDir: projectRoot });
|
|
70673
|
-
const
|
|
70767
|
+
const failed = new Map;
|
|
70768
|
+
const available = commitAvailability(new Map, true, failed);
|
|
70674
70769
|
for (const request of requests) {
|
|
70675
70770
|
if (!request.source_ref.startsWith("repo:"))
|
|
70676
70771
|
continue;
|
|
@@ -70685,6 +70780,7 @@ async function fetchSourceCommits(projectRoot, requests) {
|
|
|
70685
70780
|
if (root)
|
|
70686
70781
|
await available(root, commit);
|
|
70687
70782
|
}
|
|
70783
|
+
return failed;
|
|
70688
70784
|
}
|
|
70689
70785
|
async function registeredRepoHistoryReader(projectRoot) {
|
|
70690
70786
|
const workspace = await realpath5(projectRoot);
|
|
@@ -70813,8 +70909,10 @@ async function registeredArticleSourceReader(projectRoot) {
|
|
|
70813
70909
|
pending = (async () => {
|
|
70814
70910
|
try {
|
|
70815
70911
|
const { root, files, commit } = await scope2(sourceRef);
|
|
70816
|
-
if (files && !files.has(path2))
|
|
70817
|
-
|
|
70912
|
+
if (files && !files.has(path2)) {
|
|
70913
|
+
const owned = [...files.keys()];
|
|
70914
|
+
throw new SourceUnavailableError(`Source path ${path2} is not owned by the registered document ${sourceRef}; cite one of its files: ` + `${owned.slice(0, 10).join(", ")}${owned.length > 10 ? `, and ${owned.length - 10} more` : ""}.`, "source-path-unregistered");
|
|
70915
|
+
}
|
|
70818
70916
|
const lexical = resolve19(root, path2);
|
|
70819
70917
|
inside(root, lexical);
|
|
70820
70918
|
let bytes;
|
|
@@ -70855,6 +70953,7 @@ async function registeredArticleSourceReader(projectRoot) {
|
|
|
70855
70953
|
}
|
|
70856
70954
|
var execute;
|
|
70857
70955
|
var init_articleSourceReader = __esm(() => {
|
|
70956
|
+
init_gitProgress();
|
|
70858
70957
|
init_src2();
|
|
70859
70958
|
init_documentBatchManifest();
|
|
70860
70959
|
init_repoContentEvidence();
|
|
@@ -78317,9 +78416,9 @@ async function collectReferenceEvidence(root, references, previous2 = [], cited
|
|
|
78317
78416
|
}));
|
|
78318
78417
|
}
|
|
78319
78418
|
function articleReferenceHistoryReader(root, previous2 = []) {
|
|
78320
|
-
|
|
78419
|
+
let repoHistory;
|
|
78321
78420
|
const objects = commandGitObjectReader();
|
|
78322
|
-
|
|
78421
|
+
let registry2;
|
|
78323
78422
|
const logs = new Map;
|
|
78324
78423
|
function verified(reference2, text5, commit) {
|
|
78325
78424
|
try {
|
|
@@ -78334,7 +78433,7 @@ function articleReferenceHistoryReader(root, previous2 = []) {
|
|
|
78334
78433
|
if (reference2.source_ref.startsWith("repo:")) {
|
|
78335
78434
|
for (const scope2 of versions) {
|
|
78336
78435
|
try {
|
|
78337
|
-
const text5 = await (await repoHistory)(reference2.source_ref, reference2.locator.path, scope2.processed_version);
|
|
78436
|
+
const text5 = await (await (repoHistory ??= registeredRepoHistoryReader(root)))(reference2.source_ref, reference2.locator.path, scope2.processed_version);
|
|
78338
78437
|
const result = verified(reference2, text5, scope2.processed_version);
|
|
78339
78438
|
if (result)
|
|
78340
78439
|
return result;
|
|
@@ -78343,7 +78442,7 @@ function articleReferenceHistoryReader(root, previous2 = []) {
|
|
|
78343
78442
|
return baseline === undefined ? undefined : { region: baseline };
|
|
78344
78443
|
}
|
|
78345
78444
|
const [kind, name2] = reference2.source_ref.split(":", 2);
|
|
78346
|
-
const sources = await registry2;
|
|
78445
|
+
const sources = await (registry2 ??= loadSourcesRegistry({ rootDir: root }));
|
|
78347
78446
|
const entries = kind === "lark" ? sources.larks : kind === "file" ? sources.files : kind === "note" ? sources.notes : kind === "sessions" ? sources.sessions : [];
|
|
78348
78447
|
const entry = entries.find((candidate) => candidate.id === name2 || candidate.name === name2);
|
|
78349
78448
|
if (!entry)
|
|
@@ -81049,6 +81148,27 @@ import { execFile as execFile8 } from "node:child_process";
|
|
|
81049
81148
|
import { promisify as promisify7 } from "node:util";
|
|
81050
81149
|
import { readFile as readFile30 } from "node:fs/promises";
|
|
81051
81150
|
import { basename as basename5, join as join35 } from "node:path";
|
|
81151
|
+
async function checkoutMatchesCommit(root, ref2, files) {
|
|
81152
|
+
const timeout = 30000 + files * 2;
|
|
81153
|
+
let reason = "";
|
|
81154
|
+
for (let attempt = 0;attempt < 2; attempt++) {
|
|
81155
|
+
try {
|
|
81156
|
+
await execute2("git", ["-C", root, "diff", "--quiet", ref2, "--", "."], {
|
|
81157
|
+
timeout,
|
|
81158
|
+
maxBuffer: 64 * 1024,
|
|
81159
|
+
env: { ...process.env, GIT_OPTIONAL_LOCKS: "0" }
|
|
81160
|
+
});
|
|
81161
|
+
return { state: "same" };
|
|
81162
|
+
} catch (error) {
|
|
81163
|
+
const failure = error;
|
|
81164
|
+
if (failure.code === 1)
|
|
81165
|
+
return { state: "differs" };
|
|
81166
|
+
reason = failure.killed ? `timed out after ${Math.round(timeout / 1000)} s` : String(failure.stderr ?? (error instanceof Error ? error.message : error)).trim().split(`
|
|
81167
|
+
`)[0].slice(0, 200);
|
|
81168
|
+
}
|
|
81169
|
+
}
|
|
81170
|
+
return { state: "unchecked", reason };
|
|
81171
|
+
}
|
|
81052
81172
|
function productionDocumentSkeleton(path2, markdown) {
|
|
81053
81173
|
const lines = markdown.split(/\r?\n/u);
|
|
81054
81174
|
let title;
|
|
@@ -81160,10 +81280,6 @@ This entire source is explicitly excluded from every selected requirement; no in
|
|
|
81160
81280
|
const repo = registry2.repos.find((repo2) => repo2.id === name3 || repo2.name === name3);
|
|
81161
81281
|
if (!/^[a-f0-9]{40}(?:[a-f0-9]{24})?$/u.test(repo.ref))
|
|
81162
81282
|
throw new TypeError("Planning requires a captured fixed commit, not a moving ref");
|
|
81163
|
-
await execute2("git", ["-C", root, "diff", "--quiet", repo.ref, "--", "."], {
|
|
81164
|
-
timeout: 5000,
|
|
81165
|
-
maxBuffer: 64 * 1024
|
|
81166
|
-
});
|
|
81167
81283
|
const targets = input.requirements.requirements.flatMap((item) => [
|
|
81168
81284
|
...item.target_scope.targets,
|
|
81169
81285
|
...item.evidence_source_scope?.targets ?? []
|
|
@@ -81171,10 +81287,14 @@ This entire source is explicitly excluded from every selected requirement; no in
|
|
|
81171
81287
|
const modules = [...new Set(targets.flatMap((target) => target.module_refs ?? []))];
|
|
81172
81288
|
const result = await execute2("git", ["-C", root, "ls-tree", "-r", "--name-only", "-z", repo.ref], {
|
|
81173
81289
|
encoding: "utf8",
|
|
81174
|
-
timeout:
|
|
81175
|
-
maxBuffer:
|
|
81290
|
+
timeout: 60000,
|
|
81291
|
+
maxBuffer: 64 * 1024 * 1024
|
|
81176
81292
|
});
|
|
81177
|
-
const
|
|
81293
|
+
const tracked = result.stdout.split("\x00").filter(Boolean);
|
|
81294
|
+
const checkout = await checkoutMatchesCommit(root, repo.ref, tracked.length);
|
|
81295
|
+
if (checkout.state === "differs")
|
|
81296
|
+
throw new TypeError(`The checkout differs from the registered commit ${repo.ref}; restore it (context source recovery-plan --format json) before planning`);
|
|
81297
|
+
const files = tracked.filter((path2) => !sourceExcludes(input.requirements, scope2, path2));
|
|
81178
81298
|
const directories = new Map;
|
|
81179
81299
|
for (const file of files) {
|
|
81180
81300
|
const directory = file.includes("/") ? file.split("/")[0] : "(root)";
|
|
@@ -81188,6 +81308,7 @@ This entire source is explicitly excluded from every selected requirement; no in
|
|
|
81188
81308
|
...modules.length ? [`Module focus: ${modules.join(", ")}`] : [],
|
|
81189
81309
|
"Choose relevant directories while investigating. Module names are work guidance, not inferred path permissions; put useful reading scope in the task brief without a separate mapping or receipt.",
|
|
81190
81310
|
`Complete authorized tracked-file count: ${files.length}`,
|
|
81311
|
+
...checkout.state === "unchecked" ? [`Checkout check did not complete (${checkout.reason}); the skeleton is read from the registered commit. Read source files through the commit, not the working tree.`] : [],
|
|
81191
81312
|
"",
|
|
81192
81313
|
"## Directory skeleton",
|
|
81193
81314
|
"",
|
|
@@ -81256,6 +81377,15 @@ var init_productionPlanningMaterials = __esm(() => {
|
|
|
81256
81377
|
});
|
|
81257
81378
|
|
|
81258
81379
|
// src/project/submittedSourceLocator.ts
|
|
81380
|
+
function assertNoCaptureGap(locator, capturedText) {
|
|
81381
|
+
const lines = capturedText.replace(/\r\n/gu, `
|
|
81382
|
+
`).split(`
|
|
81383
|
+
`).slice(locator.start_line - 1, locator.end_line);
|
|
81384
|
+
const gapOnly = (line) => CAPTURE_GAP.test(line) && line.replace(new RegExp(CAPTURE_GAP.source, "gu"), "").replace(/<br\s*\/?>|[|>\s]/giu, "") === "";
|
|
81385
|
+
const gap = lines.findIndex(gapOnly);
|
|
81386
|
+
if (gap >= 0)
|
|
81387
|
+
throw new SubmissionInputError(`${locator.path}:${locator.start_line + gap} is a capture gap (the resource was not captured), ` + "not evidence. Cite only captured lines; the missing content cannot support a claim until it is captured.");
|
|
81388
|
+
}
|
|
81259
81389
|
function resolveSubmittedSourceLocator(input, capturedText) {
|
|
81260
81390
|
const locator = submittedSourceLocatorSchema.parse(input);
|
|
81261
81391
|
if ("start_line" in locator)
|
|
@@ -81311,11 +81441,208 @@ function resolveSubmittedSourceLocator(input, capturedText) {
|
|
|
81311
81441
|
throw new SubmissionInputError(`Source locator matched ${matches.length} regions in ${locator.path}; candidates: ${matches.slice(0, 5).map((m) => `${m.start_line}-${m.end_line}`).join(", ") || "none"}. Use a unique heading/quote or explicit start_line/end_line.`);
|
|
81312
81442
|
return articleSourceLocatorSchema.parse({ path: locator.path, ...matches[0] });
|
|
81313
81443
|
}
|
|
81314
|
-
var submittedSourceLocatorSchema;
|
|
81444
|
+
var submittedSourceLocatorSchema, CAPTURE_GAP;
|
|
81315
81445
|
var init_submittedSourceLocator = __esm(() => {
|
|
81316
81446
|
init_src2();
|
|
81317
81447
|
init_productionFeedback();
|
|
81318
81448
|
submittedSourceLocatorSchema = articleSourceLocatorInputSchema;
|
|
81449
|
+
CAPTURE_GAP = /(?:> ?)?Resource unavailable: .+? \([^;()]+; [^()]+\)\. <!-- [^>]+ -->/u;
|
|
81450
|
+
});
|
|
81451
|
+
|
|
81452
|
+
// src/project/approvedRevisionReferences.ts
|
|
81453
|
+
async function resolveSubmittedReference(context, id3, at2, reference2) {
|
|
81454
|
+
if (!context.inScope(reference2.source_ref))
|
|
81455
|
+
throw new SubmissionInputError(`Fragment ${id3} cites ${reference2.source_ref}, which is outside this revision; allowed sources: ${context.sourceRefs.join(", ")}. ` + "To cite new independent evidence, register it as a source, associate it with the selected requirement in src/indexers.yaml, then run context task adjust for this revision.", [...at2, "source_ref"], "source-outside-revision");
|
|
81456
|
+
const submitted = reference2.locator;
|
|
81457
|
+
const previous2 = context.previous.find((section) => section.id === id3)?.references ?? [];
|
|
81458
|
+
const kept = "start_line" in submitted ? previous2.find((old) => old.source_ref === reference2.source_ref && old.locator.path === submitted.path && old.locator.start_line === submitted.start_line && old.locator.end_line === submitted.end_line) : undefined;
|
|
81459
|
+
if (kept) {
|
|
81460
|
+
const observed = await relocateUnchangedReference(context.projectRoot, context.readSource, kept);
|
|
81461
|
+
if (observed.state === "current" || observed.state === "moved")
|
|
81462
|
+
return observed.reference;
|
|
81463
|
+
throw new SubmissionInputError(`Fragment ${id3}: ${reference2.source_ref} ${kept.locator.path}:${kept.locator.start_line}-${kept.locator.end_line} ` + `repeats an earlier citation, so it keeps that evidence, which is ${observed.state} in the current source. ` + "To keep the earlier evidence, cite its current position. To cite the text now at these lines (it may be the correct new content), use a quote or heading locator.", [...at2, "locator"], "kept-reference-unresolved");
|
|
81464
|
+
}
|
|
81465
|
+
const text5 = await context.readSource(reference2.source_ref, reference2.locator.path, true);
|
|
81466
|
+
let locator;
|
|
81467
|
+
try {
|
|
81468
|
+
locator = resolveSubmittedSourceLocator(reference2.locator, text5);
|
|
81469
|
+
assertNoCaptureGap(locator, text5);
|
|
81470
|
+
} catch (error) {
|
|
81471
|
+
if (error instanceof SubmissionInputError)
|
|
81472
|
+
throw new SubmissionInputError(`Fragment ${id3}: ${error.message}`, [...at2, "locator"]);
|
|
81473
|
+
throw error;
|
|
81474
|
+
}
|
|
81475
|
+
let resolved;
|
|
81476
|
+
try {
|
|
81477
|
+
resolved = createArticleSourceReference(reference2.source_ref, locator, text5);
|
|
81478
|
+
} catch (error) {
|
|
81479
|
+
if (!(error instanceof RangeError))
|
|
81480
|
+
throw error;
|
|
81481
|
+
throw new SubmissionInputError(`Fragment ${id3}: ${reference2.source_ref} ${locator.path}:${locator.start_line}-${locator.end_line} ` + `is outside the file, which has ${text5.replace(/\r\n/gu, `
|
|
81482
|
+
`).split(`
|
|
81483
|
+
`).length} lines. Cite existing lines, or use a quote or heading locator.`, [...at2, "locator"], "locator-out-of-range");
|
|
81484
|
+
}
|
|
81485
|
+
if (context.remember)
|
|
81486
|
+
rememberArticleRegion(context.projectRoot, resolved, text5);
|
|
81487
|
+
return resolved;
|
|
81488
|
+
}
|
|
81489
|
+
async function prepareRevisionReferences(input) {
|
|
81490
|
+
const edits = new Map(input.edits?.map((edit) => [edit.section_id, edit]));
|
|
81491
|
+
if (edits.size !== (input.edits?.length ?? 0))
|
|
81492
|
+
throw new TypeError("Repeated revision fragment identity");
|
|
81493
|
+
for (const id3 of edits.keys())
|
|
81494
|
+
if (!input.sectionIds.includes(id3)) {
|
|
81495
|
+
throw new TypeError(`Reference edit targets a missing fragment: ${id3}`);
|
|
81496
|
+
}
|
|
81497
|
+
let read;
|
|
81498
|
+
const inScope = (source2) => input.sourceRefs.some((scope2) => repoContentScopeMatches(scope2, source2));
|
|
81499
|
+
const context = {
|
|
81500
|
+
projectRoot: input.projectRoot,
|
|
81501
|
+
remember: input.remember !== false,
|
|
81502
|
+
previous: input.previous,
|
|
81503
|
+
sourceRefs: input.sourceRefs,
|
|
81504
|
+
inScope,
|
|
81505
|
+
readSource: Object.assign(async (source2, path2) => {
|
|
81506
|
+
if (!inScope(source2))
|
|
81507
|
+
throw new TypeError(`Source is outside this revision: ${source2}`);
|
|
81508
|
+
read ??= await registeredArticleSourceReader(input.projectRoot);
|
|
81509
|
+
return read(source2, path2, true);
|
|
81510
|
+
}, { incomplete: async (source2) => {
|
|
81511
|
+
read ??= await registeredArticleSourceReader(input.projectRoot);
|
|
81512
|
+
return await read.incomplete?.(source2) ?? false;
|
|
81513
|
+
} })
|
|
81514
|
+
};
|
|
81515
|
+
const result = [];
|
|
81516
|
+
const problems = [];
|
|
81517
|
+
for (const id3 of input.sectionIds) {
|
|
81518
|
+
const edit = edits.get(id3);
|
|
81519
|
+
if (edit?.references !== undefined) {
|
|
81520
|
+
const at2 = ["sections", input.edits.indexOf(edit), "references"];
|
|
81521
|
+
const references2 = [];
|
|
81522
|
+
for (const [index2, reference2] of edit.references.entries()) {
|
|
81523
|
+
try {
|
|
81524
|
+
references2.push(await resolveSubmittedReference(context, id3, [...at2, index2], reference2));
|
|
81525
|
+
} catch (error) {
|
|
81526
|
+
if (error instanceof SourceReadError || error instanceof SourceUnavailableError) {
|
|
81527
|
+
problems.push(new SubmissionInputError(`Fragment ${id3}: ${reference2.source_ref} ${reference2.locator.path}: ${error.message}`, [...at2, index2, "source_ref"], String(error.detail?.reason_code ?? "source-unavailable")));
|
|
81528
|
+
} else if (error instanceof SubmissionInputError)
|
|
81529
|
+
problems.push(error);
|
|
81530
|
+
else
|
|
81531
|
+
throw error;
|
|
81532
|
+
}
|
|
81533
|
+
}
|
|
81534
|
+
try {
|
|
81535
|
+
result.push({ id: id3, references: articleFragmentReferences(references2) });
|
|
81536
|
+
} catch (error) {
|
|
81537
|
+
if (error instanceof ZodError)
|
|
81538
|
+
problems.push(new SubmissionInputError(`Fragment ${id3}: ${error.issues.map((issue) => issue.message).join("; ")}`, at2));
|
|
81539
|
+
else
|
|
81540
|
+
throw error;
|
|
81541
|
+
}
|
|
81542
|
+
continue;
|
|
81543
|
+
}
|
|
81544
|
+
const references = [];
|
|
81545
|
+
const retained = input.previous.find((section) => section.id === id3)?.references ?? [];
|
|
81546
|
+
for (const [index2, reference2] of retained.entries()) {
|
|
81547
|
+
references.push(await retainReference(input, context, id3, ["fragments", id3, "references", index2], reference2, problems));
|
|
81548
|
+
}
|
|
81549
|
+
result.push({ id: id3, references });
|
|
81550
|
+
}
|
|
81551
|
+
if (problems.length === 1)
|
|
81552
|
+
throw problems[0];
|
|
81553
|
+
if (problems.length)
|
|
81554
|
+
throw new SubmissionInputErrors(problems);
|
|
81555
|
+
return result;
|
|
81556
|
+
}
|
|
81557
|
+
async function retainReference(input, context, id3, at2, reference2, problems) {
|
|
81558
|
+
const changed = input.changedBodies?.has(id3) === true;
|
|
81559
|
+
const where = `${reference2.source_ref} ${reference2.locator.path}:${reference2.locator.start_line}-${reference2.locator.end_line}`;
|
|
81560
|
+
let observed;
|
|
81561
|
+
try {
|
|
81562
|
+
observed = await relocateUnchangedReference(context.projectRoot, context.readSource, reference2);
|
|
81563
|
+
} catch (error) {
|
|
81564
|
+
if (!(error instanceof SourceReadError))
|
|
81565
|
+
throw error;
|
|
81566
|
+
if (changed)
|
|
81567
|
+
problems.push(new SubmissionInputError(`Fragment ${id3}: the text changed, but ${where} cannot be checked: ${error.message}`, at2, "reference-unverifiable"));
|
|
81568
|
+
return reference2;
|
|
81569
|
+
}
|
|
81570
|
+
if (observed.state === "current" || observed.state === "moved")
|
|
81571
|
+
return observed.reference;
|
|
81572
|
+
if (observed.state === "unavailable" && (observed.reason ?? "") in LOCAL_SOURCE_REASONS) {
|
|
81573
|
+
if (changed)
|
|
81574
|
+
problems.push(new SubmissionInputError(`Fragment ${id3}: the text changed, but ${where} cannot be checked on this machine (${observed.reason}). Make the source available, then submit again.`, at2, "reference-unverifiable"));
|
|
81575
|
+
return reference2;
|
|
81576
|
+
}
|
|
81577
|
+
if (citesScope(input.processedScopes ?? [], reference2.source_ref)) {
|
|
81578
|
+
const hint = await input.suggest?.(reference2).catch(() => {
|
|
81579
|
+
return;
|
|
81580
|
+
});
|
|
81581
|
+
problems.push(new SubmissionInputError(`Fragment ${id3}: ${where} is ${observed.state}${observed.reason ? ` (${observed.reason})` : ""} in the source version this revision processes. ` + `Rewrite the paragraph, cite its current text${hint ? ` (${hint})` : ""}, or remove the citation.`, at2, "processed-reference-stale"));
|
|
81582
|
+
return reference2;
|
|
81583
|
+
}
|
|
81584
|
+
input.onReminder?.({
|
|
81585
|
+
section_id: id3,
|
|
81586
|
+
state: observed.state,
|
|
81587
|
+
...observed.reason ? { reason: observed.reason } : {},
|
|
81588
|
+
source_ref: reference2.source_ref,
|
|
81589
|
+
locator: reference2.locator
|
|
81590
|
+
});
|
|
81591
|
+
return reference2;
|
|
81592
|
+
}
|
|
81593
|
+
async function suggestedCitation(projectRoot, reference2, sections) {
|
|
81594
|
+
const history = await articleReferenceHistoryReader(projectRoot, readProcessedScopes((await readKnowledgeStructure(projectRoot)).parsed))(reference2);
|
|
81595
|
+
if (!history?.text)
|
|
81596
|
+
return;
|
|
81597
|
+
const current3 = await (await registeredArticleSourceReader(projectRoot))(reference2.source_ref, reference2.locator.path, true);
|
|
81598
|
+
const cited = sections.flatMap((section) => section.references.map((item) => ({
|
|
81599
|
+
source_ref: item.source_ref,
|
|
81600
|
+
path: item.locator.path,
|
|
81601
|
+
start_line: item.locator.start_line,
|
|
81602
|
+
end_line: item.locator.end_line
|
|
81603
|
+
})));
|
|
81604
|
+
const suggested = await suggestedRange(projectRoot, reference2, history.text, current3, cited);
|
|
81605
|
+
if (!suggested)
|
|
81606
|
+
return;
|
|
81607
|
+
return "quote" in suggested.locator ? `the old text now maps to lines ${suggested.start_line}-${suggested.end_line}; cite them with a quote locator` : `the old text now maps to lines ${suggested.start_line}-${suggested.end_line}`;
|
|
81608
|
+
}
|
|
81609
|
+
function removedCitations(previous2, next) {
|
|
81610
|
+
const removed = [];
|
|
81611
|
+
for (const section of previous2) {
|
|
81612
|
+
const current3 = next.find((item) => item.id === section.id)?.references ?? [];
|
|
81613
|
+
for (const reference2 of section.references) {
|
|
81614
|
+
const kept = current3.some((item) => item.source_ref === reference2.source_ref && item.locator.path === reference2.locator.path && item.content_digest === reference2.content_digest);
|
|
81615
|
+
if (!kept)
|
|
81616
|
+
removed.push({
|
|
81617
|
+
section_id: section.id,
|
|
81618
|
+
source_ref: reference2.source_ref,
|
|
81619
|
+
path: reference2.locator.path,
|
|
81620
|
+
start_line: reference2.locator.start_line,
|
|
81621
|
+
end_line: reference2.locator.end_line
|
|
81622
|
+
});
|
|
81623
|
+
}
|
|
81624
|
+
}
|
|
81625
|
+
return removed;
|
|
81626
|
+
}
|
|
81627
|
+
function citationNotes(removed, reminders) {
|
|
81628
|
+
return {
|
|
81629
|
+
...removed.length ? { removed_citations: [...removed], removed_citations_note: REMOVED_CITATIONS_NOTE } : {},
|
|
81630
|
+
...reminders.length ? { reference_warnings: [...reminders], reference_warning_instruction: REFERENCE_REMINDER_NOTE } : {}
|
|
81631
|
+
};
|
|
81632
|
+
}
|
|
81633
|
+
var citesScope = (scopes, ref2) => scopes.some((scope2) => repoContentScopeMatches(scope2, ref2) || ref2.startsWith(`${scope2}#`) || ref2.startsWith(`${scope2}/`)), REFERENCE_REMINDER_NOTE = "These paragraphs keep citations their sources no longer confirm. The sources are outside what this revision processes, so the citations were kept; check them in a source update or a separate revision.", REMOVED_CITATIONS_NOTE = "These earlier citations are no longer in their sections. If you meant to replace or remove them, nothing needs doing; otherwise repeat each with its earlier lines to keep that evidence.";
|
|
81634
|
+
var init_approvedRevisionReferences = __esm(() => {
|
|
81635
|
+
init_zod();
|
|
81636
|
+
init_submittedSourceLocator();
|
|
81637
|
+
init_productionFeedback();
|
|
81638
|
+
init_src2();
|
|
81639
|
+
init_articleRegionBaselines();
|
|
81640
|
+
init_settledReferenceRelocation();
|
|
81641
|
+
init_articleSourceReader();
|
|
81642
|
+
init_gitObjectReader();
|
|
81643
|
+
init_articleReferenceObservation();
|
|
81644
|
+
init_packageBuildInventory();
|
|
81645
|
+
init_src2();
|
|
81319
81646
|
});
|
|
81320
81647
|
|
|
81321
81648
|
// src/project/productionArticleEdits.ts
|
|
@@ -81484,6 +81811,19 @@ function articleError(task, file, message, section) {
|
|
|
81484
81811
|
next: "Fix this task's indicated file or fragment, then resubmit only failed tasks using the existing input handles."
|
|
81485
81812
|
});
|
|
81486
81813
|
}
|
|
81814
|
+
function earlierCitation(base, retained, fragment2, ref2) {
|
|
81815
|
+
if (!("start_line" in ref2.locator))
|
|
81816
|
+
return;
|
|
81817
|
+
const signed = (value) => !!value.content_digest && ("start_line" in value.locator);
|
|
81818
|
+
const same = (value) => value.source_ref === ref2.source_ref && value.locator.path === ref2.locator.path && value.locator.start_line === ref2.locator.start_line && value.locator.end_line === ref2.locator.end_line;
|
|
81819
|
+
const from = (references) => references?.filter(signed).find(same);
|
|
81820
|
+
return from(base?.sections.find((section) => section.id === fragment2)?.references) ?? from(retained?.get(fragment2));
|
|
81821
|
+
}
|
|
81822
|
+
function outsideSourceMessage(task, source2, authorization) {
|
|
81823
|
+
const owners = authorization?.requirements.length ? `requirement ${authorization.requirements.join(", ")}` : "the requirement that owns this article";
|
|
81824
|
+
const replaced = [task.id, ...authorization?.dependents ?? []];
|
|
81825
|
+
return `Source is outside this task's authorized inputs: ${source2}. Cite only ${task.sources.map((item) => item.scope).join(", ")}, ` + `or authorize it: add ${source2} to evidence_source_scope of ${owners} in src/indexers.yaml, then submit a plan amendment ` + `whose replaces lists ${replaced.join(", ")}${replaced.length > 1 ? " (this task and the tasks that depend on it)" : ""} with a new task that includes the source.`;
|
|
81826
|
+
}
|
|
81487
81827
|
async function prepareProductionArticle(input) {
|
|
81488
81828
|
const { task } = input;
|
|
81489
81829
|
let files = input.files;
|
|
@@ -81560,33 +81900,50 @@ async function prepareProductionArticle(input) {
|
|
|
81560
81900
|
if (oversized.length)
|
|
81561
81901
|
throw articleError(task, files.references.path, `Split the claims or choose sufficient references for these fragments: ${oversized.join("; ")}.`);
|
|
81562
81902
|
const read = input.sourceReader ?? await registeredArticleSourceReader(input.projectRoot);
|
|
81903
|
+
const observe = createArticleReferenceObserver(read);
|
|
81563
81904
|
const allowed = new Set(task.sources.map((source2) => source2.scope));
|
|
81905
|
+
const problems = [];
|
|
81564
81906
|
const sections = [];
|
|
81565
81907
|
for (const fragment2 of fragments) {
|
|
81566
81908
|
const references = [];
|
|
81567
81909
|
for (const ref2 of byId.get(fragment2.id)) {
|
|
81568
81910
|
try {
|
|
81911
|
+
const earlier = earlierCitation(input.trustedBase ?? input.base, retained, fragment2.id, ref2);
|
|
81569
81912
|
const inherited = retained?.get(fragment2.id)?.some((value) => value.source_ref === ref2.source_ref && indexerProtocolDigest(value.locator) === indexerProtocolDigest(ref2.locator));
|
|
81570
|
-
const trusted = inherited
|
|
81571
|
-
if (!trusted
|
|
81572
|
-
throw new TypeError(
|
|
81573
|
-
|
|
81574
|
-
|
|
81575
|
-
|
|
81576
|
-
|
|
81577
|
-
|
|
81913
|
+
const trusted = inherited && earlier && input.trustedBase?.sections.find((section) => section.id === fragment2.id)?.references.some((value) => value.content_digest === earlier.content_digest);
|
|
81914
|
+
if (!trusted && ![...allowed].some((scope2) => repoContentScopeMatches(scope2, ref2.source_ref)))
|
|
81915
|
+
throw new TypeError(outsideSourceMessage(task, ref2.source_ref, await input.authorization?.()));
|
|
81916
|
+
if (earlier) {
|
|
81917
|
+
const observed = await observe(earlier);
|
|
81918
|
+
if (observed.state === "current" || observed.state === "moved") {
|
|
81919
|
+
references.push(observed.reference);
|
|
81920
|
+
continue;
|
|
81921
|
+
}
|
|
81922
|
+
const hint = observed.state === "not-found" ? await suggestedCitation(input.projectRoot, earlier, signedSections(input.trustedBase)).catch(() => {
|
|
81923
|
+
return;
|
|
81924
|
+
}) : undefined;
|
|
81925
|
+
throw new TypeError(`${earlier.source_ref} ${earlier.locator.path}:${earlier.locator.start_line}-${earlier.locator.end_line} repeats an earlier citation, ` + `which is ${observed.state}${observed.reason ? ` (${observed.reason})` : ""} in the current source. ` + `Rewrite the fragment, cite its current text${hint ? ` (${hint})` : ""} with a quote or new lines, or remove the citation.`);
|
|
81578
81926
|
}
|
|
81579
|
-
|
|
81927
|
+
const text5 = await read(ref2.source_ref, ref2.locator.path, true);
|
|
81928
|
+
const locator = resolveSubmittedSourceLocator(ref2.locator, text5);
|
|
81929
|
+
assertNoCaptureGap(locator, text5);
|
|
81930
|
+
const reference2 = createArticleSourceReference(ref2.source_ref, locator, text5);
|
|
81931
|
+
if (!input.preview)
|
|
81932
|
+
rememberArticleRegion(input.projectRoot, reference2, text5);
|
|
81580
81933
|
references.push(reference2);
|
|
81581
81934
|
} catch (error) {
|
|
81582
|
-
|
|
81935
|
+
if (error instanceof ContextError && error.detail?.reason_code !== "source-read-failed" && !(error instanceof SourceUnavailableError))
|
|
81936
|
+
throw error;
|
|
81937
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
81938
|
+
problems.push({ section: fragment2.id, message: error instanceof RangeError && "start_line" in ref2.locator ? `${ref2.source_ref} ${ref2.locator.path}:${ref2.locator.start_line}-${ref2.locator.end_line}: ${message}` : message });
|
|
81583
81939
|
}
|
|
81584
81940
|
}
|
|
81585
81941
|
let unique;
|
|
81586
81942
|
try {
|
|
81587
81943
|
unique = articleFragmentReferences(references);
|
|
81588
81944
|
} catch (error) {
|
|
81589
|
-
|
|
81945
|
+
problems.push({ section: fragment2.id, message: error instanceof ZodError ? error.issues.map((issue) => issue.message).join("; ") : error instanceof Error ? error.message : String(error) });
|
|
81946
|
+
continue;
|
|
81590
81947
|
}
|
|
81591
81948
|
sections.push({
|
|
81592
81949
|
section_ref: `${task.article_id}#${fragment2.id}`,
|
|
@@ -81596,6 +81953,11 @@ async function prepareProductionArticle(input) {
|
|
|
81596
81953
|
markdown_digest: indexerProtocolDigest(fragment2.readerVisibleBody)
|
|
81597
81954
|
});
|
|
81598
81955
|
}
|
|
81956
|
+
if (problems.length) {
|
|
81957
|
+
const error = articleError(task, files.references.path, problems.length === 1 ? problems[0].message : `${problems.length} reference problems: ${problems.map((item, index2) => `(${index2 + 1}) ${item.section}: ${item.message}`).join(" ")}`, problems[0].section);
|
|
81958
|
+
error.detail.problems = problems;
|
|
81959
|
+
throw error;
|
|
81960
|
+
}
|
|
81599
81961
|
const fingerprint = indexerProtocolDigest({ input: task.input, markdown, sections });
|
|
81600
81962
|
return parseCandidateRecord({
|
|
81601
81963
|
candidate_id: indexerCandidateId(fingerprint),
|
|
@@ -81623,7 +81985,10 @@ async function prepareProductionArticle(input) {
|
|
|
81623
81985
|
updated: new Date().toISOString()
|
|
81624
81986
|
}, 1);
|
|
81625
81987
|
}
|
|
81626
|
-
var import_yaml23, productionReferencesSchema
|
|
81988
|
+
var import_yaml23, productionReferencesSchema, signedSections = (base) => (base?.sections ?? []).map((section) => ({
|
|
81989
|
+
id: section.id,
|
|
81990
|
+
references: section.references.filter((value) => !!value.content_digest && ("start_line" in value.locator))
|
|
81991
|
+
}));
|
|
81627
81992
|
var init_productionArticle = __esm(() => {
|
|
81628
81993
|
init_submittedSourceLocator();
|
|
81629
81994
|
init_zod();
|
|
@@ -81633,6 +81998,9 @@ var init_productionArticle = __esm(() => {
|
|
|
81633
81998
|
init_exitCode();
|
|
81634
81999
|
init_candidateLedger();
|
|
81635
82000
|
init_articleSourceReader();
|
|
82001
|
+
init_articleReferenceObservation();
|
|
82002
|
+
init_approvedRevisionReferences();
|
|
82003
|
+
init_gitObjectReader();
|
|
81636
82004
|
init_articleRegionBaselines();
|
|
81637
82005
|
init_productionArticleEdits();
|
|
81638
82006
|
init_okfTypes();
|
|
@@ -81780,7 +82148,10 @@ function writeTarget3(path2, previous2, content3) {
|
|
|
81780
82148
|
content: content3
|
|
81781
82149
|
};
|
|
81782
82150
|
}
|
|
81783
|
-
|
|
82151
|
+
function completeProductionSubmission(input) {
|
|
82152
|
+
return completeProductionSubmissionImpl(input);
|
|
82153
|
+
}
|
|
82154
|
+
async function completeProductionSubmissionImpl(input) {
|
|
81784
82155
|
return withProjectWriteLock(input.projectRoot, "production-submit", async () => {
|
|
81785
82156
|
await recoverDurableMultiFileTransactions(input.projectRoot);
|
|
81786
82157
|
const snapshot = await readProductionStageSnapshot(input.projectRoot);
|
|
@@ -81880,7 +82251,7 @@ async function completeProductionSubmission(input) {
|
|
|
81880
82251
|
if (files.edits) {
|
|
81881
82252
|
base = await readProductionRepairDraft({ projectRoot: input.projectRoot, stage: stage.id, task }) ?? base;
|
|
81882
82253
|
}
|
|
81883
|
-
retainDraft = !!files.content && !!files.references;
|
|
82254
|
+
retainDraft = !input.preview && !!files.content && !!files.references;
|
|
81884
82255
|
const candidate = await measureContextDebugOperation({ projectRoot: input.projectRoot, operation: "production.submit.validate" }, () => prepareProductionArticle({
|
|
81885
82256
|
projectRoot: input.projectRoot,
|
|
81886
82257
|
task,
|
|
@@ -81889,7 +82260,9 @@ async function completeProductionSubmission(input) {
|
|
|
81889
82260
|
approvedBaseDigest: target.approvedBaseDigest,
|
|
81890
82261
|
...base ? { base } : {},
|
|
81891
82262
|
...target.base ? { trustedBase: target.base } : {},
|
|
81892
|
-
visibility: target.visibility
|
|
82263
|
+
visibility: target.visibility,
|
|
82264
|
+
preview: input.preview === true,
|
|
82265
|
+
authorization: () => productionAuthorization(input.projectRoot, stage, task)
|
|
81893
82266
|
}));
|
|
81894
82267
|
const key = knowledgeTargetPathKey(candidate.path);
|
|
81895
82268
|
byPath.set(key, [...(byPath.get(key) ?? []).filter((item) => item.article_id !== task.article_id), candidate]);
|
|
@@ -81897,22 +82270,35 @@ async function completeProductionSubmission(input) {
|
|
|
81897
82270
|
pending.set(task.id, { candidate, digest: contentDigest });
|
|
81898
82271
|
} catch (error) {
|
|
81899
82272
|
const detail = error && typeof error === "object" && "detail" in error ? error.detail : undefined;
|
|
81900
|
-
|
|
82273
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
82274
|
+
let note = "";
|
|
81901
82275
|
if (retainDraft) {
|
|
81902
82276
|
try {
|
|
81903
82277
|
await retainProductionRepairDraft({ projectRoot: input.projectRoot, stage: stage.id, task, files });
|
|
81904
82278
|
} catch {
|
|
81905
|
-
|
|
82279
|
+
note = " The temporary repair draft could not be retained; resubmit the complete draft.";
|
|
81906
82280
|
}
|
|
81907
82281
|
}
|
|
81908
|
-
|
|
81909
|
-
|
|
81910
|
-
|
|
81911
|
-
|
|
81912
|
-
|
|
81913
|
-
|
|
82282
|
+
const problems = Array.isArray(detail?.problems) ? detail.problems : [{ section: detail?.section, message: reason }];
|
|
82283
|
+
for (const item of problems) {
|
|
82284
|
+
result.failed.push({
|
|
82285
|
+
task: task.id,
|
|
82286
|
+
reason: item.message + note,
|
|
82287
|
+
...typeof detail?.file === "string" ? { file: detail.file } : {},
|
|
82288
|
+
...typeof item.section === "string" ? { section: item.section } : {}
|
|
82289
|
+
});
|
|
82290
|
+
}
|
|
81914
82291
|
}
|
|
81915
82292
|
}
|
|
82293
|
+
if (input.preview) {
|
|
82294
|
+
const order2 = new Map(fixed2.tasks.map((task, index2) => [task.task, index2]));
|
|
82295
|
+
return {
|
|
82296
|
+
protocol: "context.production-submission-preview/v1",
|
|
82297
|
+
written: false,
|
|
82298
|
+
ok: [...result.accepted.map((item) => item.task), ...pending.keys()].sort((a, b) => order2.get(a) - order2.get(b)),
|
|
82299
|
+
failed: result.failed
|
|
82300
|
+
};
|
|
82301
|
+
}
|
|
81916
82302
|
if (pending.size) {
|
|
81917
82303
|
const changedArticles = new Set([...pending.values()].map((proposal) => proposal.candidate.article_id));
|
|
81918
82304
|
const nextCandidates = [
|
|
@@ -81977,6 +82363,24 @@ async function completeProductionSubmission(input) {
|
|
|
81977
82363
|
return result;
|
|
81978
82364
|
});
|
|
81979
82365
|
}
|
|
82366
|
+
async function productionAuthorization(projectRoot, stage, task) {
|
|
82367
|
+
const { readProductionRequirements: readProductionRequirements2 } = await Promise.resolve().then(() => (init_productionRequirements(), exports_productionRequirements));
|
|
82368
|
+
const sources = new Set(task.sources.map((source2) => source2.scope));
|
|
82369
|
+
const requirements = await readProductionRequirements2(projectRoot).then((value) => value.requirements.filter((item) => [...item.target_scope.targets, ...item.evidence_source_scope?.targets ?? []].some((target) => sources.has(target.source_ref))).map((item) => item.id), () => []);
|
|
82370
|
+
const dependents = [];
|
|
82371
|
+
for (let added = true;added; ) {
|
|
82372
|
+
added = false;
|
|
82373
|
+
for (const other of stage.tasks) {
|
|
82374
|
+
if (dependents.includes(other.id) || ["accepted", "excluded", "replaced"].includes(other.status))
|
|
82375
|
+
continue;
|
|
82376
|
+
if (other.after.some((id3) => id3 === task.id || dependents.includes(id3))) {
|
|
82377
|
+
dependents.push(other.id);
|
|
82378
|
+
added = true;
|
|
82379
|
+
}
|
|
82380
|
+
}
|
|
82381
|
+
}
|
|
82382
|
+
return { requirements, dependents };
|
|
82383
|
+
}
|
|
81980
82384
|
var init_productionSubmission = __esm(() => {
|
|
81981
82385
|
init_submissionState();
|
|
81982
82386
|
init_src2();
|
|
@@ -82702,6 +83106,12 @@ var init_siteTheme2 = __esm(() => {
|
|
|
82702
83106
|
});
|
|
82703
83107
|
|
|
82704
83108
|
// src/project/workspaceContentSnapshot.ts
|
|
83109
|
+
var exports_workspaceContentSnapshot = {};
|
|
83110
|
+
__export(exports_workspaceContentSnapshot, {
|
|
83111
|
+
workspaceContentSnapshot: () => workspaceContentSnapshot,
|
|
83112
|
+
observeWorkspaceContent: () => observeWorkspaceContent,
|
|
83113
|
+
excludedWorkspaceContent: () => excludedWorkspaceContent
|
|
83114
|
+
});
|
|
82705
83115
|
import { createHash as createHash15 } from "node:crypto";
|
|
82706
83116
|
import { execFile as execFile10 } from "node:child_process";
|
|
82707
83117
|
import { lstat as lstat8, readFile as readFile38, readdir as readdir9, realpath as realpath9 } from "node:fs/promises";
|
|
@@ -85160,7 +85570,7 @@ import {
|
|
|
85160
85570
|
renameSync as renameSync2,
|
|
85161
85571
|
writeFileSync as writeFileSync3
|
|
85162
85572
|
} from "node:fs";
|
|
85163
|
-
import { spawn as
|
|
85573
|
+
import { spawn as spawn4 } from "node:child_process";
|
|
85164
85574
|
import { dirname as dirname25, join as join60 } from "node:path";
|
|
85165
85575
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
85166
85576
|
function isRecord10(value) {
|
|
@@ -85237,7 +85647,7 @@ async function describeRuntimeEventSink(sink, cwd) {
|
|
|
85237
85647
|
}, RUNTIME_EVENT_SINK_DESCRIPTION_TIMEOUT_MS);
|
|
85238
85648
|
let child;
|
|
85239
85649
|
try {
|
|
85240
|
-
const spawned =
|
|
85650
|
+
const spawned = spawn4(sink.command, describeArgs, {
|
|
85241
85651
|
cwd,
|
|
85242
85652
|
env: process.env,
|
|
85243
85653
|
shell: false,
|
|
@@ -85352,7 +85762,7 @@ function dispatchCommand(sink, batch, cwd) {
|
|
|
85352
85762
|
})();
|
|
85353
85763
|
};
|
|
85354
85764
|
try {
|
|
85355
|
-
const child =
|
|
85765
|
+
const child = spawn4(sink.command, sink.args, {
|
|
85356
85766
|
cwd,
|
|
85357
85767
|
env: process.env,
|
|
85358
85768
|
shell: false,
|
|
@@ -87915,7 +88325,37 @@ function createLarkCaptureReport(input) {
|
|
|
87915
88325
|
...descriptor?.title === undefined ? {} : { title: descriptor.title },
|
|
87916
88326
|
attributes: descriptor?.attributes ?? {}
|
|
87917
88327
|
};
|
|
87918
|
-
})
|
|
88328
|
+
}),
|
|
88329
|
+
...input.access === undefined ? {} : { access: input.access }
|
|
88330
|
+
};
|
|
88331
|
+
}
|
|
88332
|
+
function parseAccess(value) {
|
|
88333
|
+
if (value === undefined)
|
|
88334
|
+
return;
|
|
88335
|
+
if (!isRecord13(value) || value.identity !== "user" && value.identity !== "bot") {
|
|
88336
|
+
throw new TypeError("Lark capture report access.identity must be user or bot");
|
|
88337
|
+
}
|
|
88338
|
+
const fallback = value.fallback;
|
|
88339
|
+
if (fallback !== undefined && (!isRecord13(fallback) || fallback.from !== "bot" || typeof fallback.cause !== "string")) {
|
|
88340
|
+
throw new TypeError("Lark capture report access.fallback must name the bot and a cause");
|
|
88341
|
+
}
|
|
88342
|
+
if (value.events !== undefined && !Array.isArray(value.events))
|
|
88343
|
+
throw new TypeError("Lark capture report access.events must be an array");
|
|
88344
|
+
const events = value.events?.map((event, index2) => {
|
|
88345
|
+
if (!isRecord13(event) || typeof event.kind !== "string" || typeof event.message !== "string" || event.app_id !== undefined && typeof event.app_id !== "string" || event.changed_access !== undefined && typeof event.changed_access !== "boolean") {
|
|
88346
|
+
throw new TypeError(`Lark capture report access.events[${index2}] must have kind and message`);
|
|
88347
|
+
}
|
|
88348
|
+
return {
|
|
88349
|
+
kind: event.kind,
|
|
88350
|
+
message: event.message,
|
|
88351
|
+
...event.app_id === undefined ? {} : { app_id: event.app_id },
|
|
88352
|
+
...event.changed_access === undefined ? {} : { changed_access: event.changed_access }
|
|
88353
|
+
};
|
|
88354
|
+
});
|
|
88355
|
+
return {
|
|
88356
|
+
identity: value.identity,
|
|
88357
|
+
...fallback === undefined ? {} : { fallback: { from: "bot", cause: fallback.cause } },
|
|
88358
|
+
...events === undefined ? {} : { events }
|
|
87919
88359
|
};
|
|
87920
88360
|
}
|
|
87921
88361
|
function parseLarkCaptureReport(value) {
|
|
@@ -87951,6 +88391,7 @@ function parseLarkCaptureReport(value) {
|
|
|
87951
88391
|
if (materialization === undefined) {
|
|
87952
88392
|
throw new TypeError("Lark capture report resource_materialization is required");
|
|
87953
88393
|
}
|
|
88394
|
+
const access4 = parseAccess(value.access);
|
|
87954
88395
|
return {
|
|
87955
88396
|
schema_version: LARK_CAPTURE_REPORT_SCHEMA_VERSION,
|
|
87956
88397
|
fidelity,
|
|
@@ -87959,7 +88400,8 @@ function parseLarkCaptureReport(value) {
|
|
|
87959
88400
|
...item,
|
|
87960
88401
|
...enriched[index2]?.title === undefined ? {} : { title: enriched[index2].title },
|
|
87961
88402
|
attributes: enriched[index2]?.attributes ?? {}
|
|
87962
|
-
}))
|
|
88403
|
+
})),
|
|
88404
|
+
...access4 === undefined ? {} : { access: access4 }
|
|
87963
88405
|
};
|
|
87964
88406
|
}
|
|
87965
88407
|
function captureReportMaterialization(report) {
|
|
@@ -87968,6 +88410,18 @@ function captureReportMaterialization(report) {
|
|
|
87968
88410
|
items: report.resources.map(materializationItem)
|
|
87969
88411
|
};
|
|
87970
88412
|
}
|
|
88413
|
+
function sameLarkAccess(left, right) {
|
|
88414
|
+
const canonical = (value) => Array.isArray(value) ? value.map(canonical) : isRecord13(value) ? Object.fromEntries(Object.keys(value).sort().map((key) => [key, canonical(value[key])])) : value;
|
|
88415
|
+
return JSON.stringify(canonical(left)) === JSON.stringify(canonical(right));
|
|
88416
|
+
}
|
|
88417
|
+
function larkAccessDiagnostics(access4) {
|
|
88418
|
+
return [
|
|
88419
|
+
...access4?.fallback === undefined ? [] : [
|
|
88420
|
+
`warning: lark.capture.identity-fallback: the bot could not read this document (${access4.fallback.cause}), so it was read as the user. ` + "Content only that user can see is now in the snapshot, and later bot captures may not be able to read it; " + "ask the document's owner to share it with the bot"
|
|
88421
|
+
],
|
|
88422
|
+
...(access4?.events ?? []).map((event) => `info: lark.capture.${event.kind}: ${event.message}`)
|
|
88423
|
+
];
|
|
88424
|
+
}
|
|
87971
88425
|
var LARK_CAPTURE_REPORT_SCHEMA_VERSION = "context.lark-capture-report.v1";
|
|
87972
88426
|
var init_larkCaptureReport = __esm(() => {
|
|
87973
88427
|
init_src3();
|
|
@@ -88008,6 +88462,7 @@ function documentSnapshotFidelityState(manifest, captureReport) {
|
|
|
88008
88462
|
...(resources?.items ?? []).filter((item) => item.status === "failed" && item.required && !isNonBlockingDocumentResourceFailureReasonCode(item.reason_code)).map((item) => `lark.capture.resource-materialization-failed: ${item.kind}: ${item.reason ?? item.locator}`)
|
|
88009
88463
|
],
|
|
88010
88464
|
warnings: [
|
|
88465
|
+
...larkAccessDiagnostics(captureReport?.access).map((line) => line.replace(/^(?:warning|info): /u, "")),
|
|
88011
88466
|
...report === undefined ? [] : render((issue) => issue.impact === "projection" || issue.severity === "warning"),
|
|
88012
88467
|
...(resources?.items ?? []).filter((item) => item.reason_code === "document.resource.preview" || item.status === "failed" && (!item.required || isNonBlockingDocumentResourceFailureReasonCode(item.reason_code))).map((item) => `${item.reason_code ?? "lark.capture.resource-materialization-warning"}: ${item.kind}: ${item.reason ?? item.locator}`)
|
|
88013
88468
|
]
|
|
@@ -88154,13 +88609,6 @@ async function missingObjects(root, commit, paths) {
|
|
|
88154
88609
|
return checked.split(`
|
|
88155
88610
|
`).filter((line) => line.endsWith(" missing")).map((line) => line.split(" ")[0]);
|
|
88156
88611
|
}
|
|
88157
|
-
function failureSummary(error) {
|
|
88158
|
-
const text7 = error && typeof error === "object" && "stderr" in error ? String(error.stderr ?? "") : String(error);
|
|
88159
|
-
const line = text7.split(`
|
|
88160
|
-
`).map((part) => part.trim()).find((part) => /^(fatal|error):/iu.test(part)) ?? text7.split(`
|
|
88161
|
-
`)[0]?.trim() ?? "";
|
|
88162
|
-
return line.replace(/\/\/[^/@\s]+@/gu, "//").slice(0, 200) || "fetch failed";
|
|
88163
|
-
}
|
|
88164
88612
|
async function prepareRepositoryContents(projectRoot, requests) {
|
|
88165
88613
|
const registry2 = await loadSourcesRegistry({ rootDir: projectRoot });
|
|
88166
88614
|
const results = [];
|
|
@@ -88187,7 +88635,9 @@ async function prepareRepositoryContents(projectRoot, requests) {
|
|
|
88187
88635
|
else {
|
|
88188
88636
|
try {
|
|
88189
88637
|
for (let index2 = 0;index2 < missing2.length; index2 += FETCH_BATCH) {
|
|
88190
|
-
await
|
|
88638
|
+
await runGitWithProgress([
|
|
88639
|
+
"-C",
|
|
88640
|
+
root,
|
|
88191
88641
|
"-c",
|
|
88192
88642
|
"fetch.negotiationAlgorithm=noop",
|
|
88193
88643
|
"fetch",
|
|
@@ -88197,10 +88647,10 @@ async function prepareRepositoryContents(projectRoot, requests) {
|
|
|
88197
88647
|
"--filter=blob:none",
|
|
88198
88648
|
remote,
|
|
88199
88649
|
...missing2.slice(index2, index2 + FETCH_BATCH)
|
|
88200
|
-
], { env: { ...process.env, GIT_TERMINAL_PROMPT: "0" },
|
|
88650
|
+
], { env: { ...process.env, GIT_TERMINAL_PROMPT: "0" }, label: `git fetch of ${request.source_ref} contents` });
|
|
88201
88651
|
}
|
|
88202
88652
|
} catch (error) {
|
|
88203
|
-
result.reason =
|
|
88653
|
+
result.reason = redactRemoteCredentials(error instanceof Error ? error.message : String(error)).slice(0, 400);
|
|
88204
88654
|
}
|
|
88205
88655
|
result.unresolved = (await missingObjects(root, commit, paths)).length;
|
|
88206
88656
|
if (!result.unresolved)
|
|
@@ -88214,6 +88664,7 @@ async function prepareRepositoryContents(projectRoot, requests) {
|
|
|
88214
88664
|
var execute3, offline, FETCH_BATCH = 1000, PATH_BATCH = 500;
|
|
88215
88665
|
var init_repoContentPrefetch = __esm(() => {
|
|
88216
88666
|
init_src2();
|
|
88667
|
+
init_gitProgress();
|
|
88217
88668
|
execute3 = promisify10(execFile12);
|
|
88218
88669
|
offline = { ...process.env, GIT_NO_LAZY_FETCH: "1" };
|
|
88219
88670
|
});
|
|
@@ -88327,10 +88778,11 @@ async function readKnowledgeUpdate(projectRoot) {
|
|
|
88327
88778
|
throw new TypeError("Source update request digest is invalid");
|
|
88328
88779
|
return update;
|
|
88329
88780
|
}
|
|
88330
|
-
function stopOnUnreadableSources(unresolved, prepared2, network) {
|
|
88781
|
+
function stopOnUnreadableSources(unresolved, prepared2, network, fetchFailures = new Map, registered = new Map) {
|
|
88331
88782
|
const missingCommits = [...new Set(unresolved.filter((item) => item.reason === "source-history-missing").map((item) => item.reference.source_ref))];
|
|
88332
88783
|
if (missingCommits.length) {
|
|
88333
|
-
|
|
88784
|
+
const why = missingCommits.map((source2) => fetchFailures.get(registered.get(source2) ?? "")).filter(Boolean);
|
|
88785
|
+
throw new TypeError(`The registered commit of ${missingCommits.join(", ")} is not in its source checkout${network ? " and could not be fetched" : ""}` + `${why.length ? ` (${why.join("; ")})` : ""}. ` + "Check that the registered commit SHA exists in the remote repository. " + (network ? "If it does, fetch and check out the registered commit in the source checkout (see context source list --format json), then rerun context update --pending --format json." : "context update --pending fetches it; an explicit update reads only what the checkout has, so fetch and check out the commit first, then rerun this update."));
|
|
88334
88786
|
}
|
|
88335
88787
|
const contentMissing = [...new Set(unresolved.filter((item) => item.reason === "source-content-missing").map((item) => item.reference.source_ref))];
|
|
88336
88788
|
if (contentMissing.length) {
|
|
@@ -88394,15 +88846,16 @@ async function beginKnowledgeUpdate(projectRoot, value, options = {}) {
|
|
|
88394
88846
|
});
|
|
88395
88847
|
const network = options.pending === true;
|
|
88396
88848
|
let prepared2 = [];
|
|
88849
|
+
let fetchFailures = new Map;
|
|
88397
88850
|
if (network) {
|
|
88398
|
-
await fetchSourceCommits(projectRoot, [
|
|
88851
|
+
fetchFailures = await fetchSourceCommits(projectRoot, [
|
|
88399
88852
|
...repoScopes.map((source_ref) => ({ source_ref })),
|
|
88400
88853
|
...comparisons.map((item) => ({ source_ref: item.source_ref, commit: item.from }))
|
|
88401
88854
|
]);
|
|
88402
88855
|
prepared2 = await prepareRepositoryContents(projectRoot, repoScopes.map((source2) => ({ source_ref: source2, paths: citedPaths(source2, cited) })));
|
|
88403
88856
|
}
|
|
88404
88857
|
const inspected = await inspectSettledReferences(projectRoot, cited, scopes.map((scope2) => scope2.source_ref), settled);
|
|
88405
|
-
stopOnUnreadableSources(inspected.unresolved, prepared2, network);
|
|
88858
|
+
stopOnUnreadableSources(inspected.unresolved, prepared2, network, fetchFailures, new Map(scopes.map((scope2) => [scope2.source_ref, scope2.processed_version])));
|
|
88406
88859
|
if (network)
|
|
88407
88860
|
await prepareRepositoryContents(projectRoot, repoScopes.flatMap((source2) => {
|
|
88408
88861
|
const scope2 = scopes.find((item) => item.source_ref === source2);
|
|
@@ -94502,7 +94955,7 @@ var init_packageSiteLocales = __esm(() => {
|
|
|
94502
94955
|
|
|
94503
94956
|
// src/project/packageSite.ts
|
|
94504
94957
|
import { createHash as createHash27 } from "node:crypto";
|
|
94505
|
-
import { spawn as
|
|
94958
|
+
import { spawn as spawn5 } from "node:child_process";
|
|
94506
94959
|
import { mkdir as mkdir30, mkdtemp as mkdtemp3, readFile as readFile72, writeFile as writeFile23, rm as rm18, symlink as symlink4, cp as cp2, access as access5, stat as stat9 } from "node:fs/promises";
|
|
94507
94960
|
import { createRequire as createRequire5 } from "node:module";
|
|
94508
94961
|
import { dirname as dirname38, join as join86, posix as posix10 } from "node:path";
|
|
@@ -94625,7 +95078,7 @@ function siteSections(entries2) {
|
|
|
94625
95078
|
async function compileSite(root, outDir) {
|
|
94626
95079
|
const vitepressRoot = dirname38(require2.resolve("vitepress/package.json"));
|
|
94627
95080
|
await new Promise((resolve8, reject) => {
|
|
94628
|
-
const child =
|
|
95081
|
+
const child = spawn5(process.versions.bun ? "node" : process.execPath, [join86(vitepressRoot, "bin/vitepress.js"), "build", root, "--outDir", outDir], { stdio: ["ignore", "pipe", "pipe"] });
|
|
94629
95082
|
let tail = "";
|
|
94630
95083
|
const receive = (chunk) => {
|
|
94631
95084
|
tail = (tail + chunk.toString()).slice(-16000);
|
|
@@ -97208,201 +97661,6 @@ var init_approvedRevisionEdits = __esm(() => {
|
|
|
97208
97661
|
init_approvedRevisionPrograms();
|
|
97209
97662
|
});
|
|
97210
97663
|
|
|
97211
|
-
// src/project/approvedRevisionReferences.ts
|
|
97212
|
-
async function resolveSubmittedReference(context, id3, at2, reference2) {
|
|
97213
|
-
if (!context.inScope(reference2.source_ref))
|
|
97214
|
-
throw new SubmissionInputError(`Fragment ${id3} cites ${reference2.source_ref}, which is outside this revision; allowed sources: ${context.sourceRefs.join(", ")}. ` + "To cite new independent evidence, register it as a source, associate it with the selected requirement in src/indexers.yaml, then run context task adjust for this revision.", [...at2, "source_ref"], "source-outside-revision");
|
|
97215
|
-
const submitted = reference2.locator;
|
|
97216
|
-
const previous2 = context.previous.find((section) => section.id === id3)?.references ?? [];
|
|
97217
|
-
const kept = "start_line" in submitted ? previous2.find((old) => old.source_ref === reference2.source_ref && old.locator.path === submitted.path && old.locator.start_line === submitted.start_line && old.locator.end_line === submitted.end_line) : undefined;
|
|
97218
|
-
if (kept) {
|
|
97219
|
-
const observed = await relocateUnchangedReference(context.projectRoot, context.readSource, kept);
|
|
97220
|
-
if (observed.state === "current" || observed.state === "moved")
|
|
97221
|
-
return observed.reference;
|
|
97222
|
-
throw new SubmissionInputError(`Fragment ${id3}: ${reference2.source_ref} ${kept.locator.path}:${kept.locator.start_line}-${kept.locator.end_line} ` + `repeats an earlier citation, so it keeps that evidence, which is ${observed.state} in the current source. ` + "To keep the earlier evidence, cite its current position. To cite the text now at these lines (it may be the correct new content), use a quote or heading locator.", [...at2, "locator"], "kept-reference-unresolved");
|
|
97223
|
-
}
|
|
97224
|
-
const text8 = await context.readSource(reference2.source_ref, reference2.locator.path, true);
|
|
97225
|
-
let locator;
|
|
97226
|
-
try {
|
|
97227
|
-
locator = resolveSubmittedSourceLocator(reference2.locator, text8);
|
|
97228
|
-
} catch (error) {
|
|
97229
|
-
if (error instanceof SubmissionInputError)
|
|
97230
|
-
throw new SubmissionInputError(`Fragment ${id3}: ${error.message}`, [...at2, "locator"]);
|
|
97231
|
-
throw error;
|
|
97232
|
-
}
|
|
97233
|
-
let resolved;
|
|
97234
|
-
try {
|
|
97235
|
-
resolved = createArticleSourceReference(reference2.source_ref, locator, text8);
|
|
97236
|
-
} catch (error) {
|
|
97237
|
-
if (!(error instanceof RangeError))
|
|
97238
|
-
throw error;
|
|
97239
|
-
throw new SubmissionInputError(`Fragment ${id3}: ${reference2.source_ref} ${locator.path}:${locator.start_line}-${locator.end_line} ` + `is outside the file, which has ${text8.replace(/\r\n/gu, `
|
|
97240
|
-
`).split(`
|
|
97241
|
-
`).length} lines. Cite existing lines, or use a quote or heading locator.`, [...at2, "locator"], "locator-out-of-range");
|
|
97242
|
-
}
|
|
97243
|
-
if (context.remember)
|
|
97244
|
-
rememberArticleRegion(context.projectRoot, resolved, text8);
|
|
97245
|
-
return resolved;
|
|
97246
|
-
}
|
|
97247
|
-
async function prepareRevisionReferences(input) {
|
|
97248
|
-
const edits = new Map(input.edits?.map((edit) => [edit.section_id, edit]));
|
|
97249
|
-
if (edits.size !== (input.edits?.length ?? 0))
|
|
97250
|
-
throw new TypeError("Repeated revision fragment identity");
|
|
97251
|
-
for (const id3 of edits.keys())
|
|
97252
|
-
if (!input.sectionIds.includes(id3)) {
|
|
97253
|
-
throw new TypeError(`Reference edit targets a missing fragment: ${id3}`);
|
|
97254
|
-
}
|
|
97255
|
-
let read;
|
|
97256
|
-
const inScope = (source2) => input.sourceRefs.some((scope2) => repoContentScopeMatches(scope2, source2));
|
|
97257
|
-
const context = {
|
|
97258
|
-
projectRoot: input.projectRoot,
|
|
97259
|
-
remember: input.remember !== false,
|
|
97260
|
-
previous: input.previous,
|
|
97261
|
-
sourceRefs: input.sourceRefs,
|
|
97262
|
-
inScope,
|
|
97263
|
-
readSource: Object.assign(async (source2, path2) => {
|
|
97264
|
-
if (!inScope(source2))
|
|
97265
|
-
throw new TypeError(`Source is outside this revision: ${source2}`);
|
|
97266
|
-
read ??= await registeredArticleSourceReader(input.projectRoot);
|
|
97267
|
-
return read(source2, path2, true);
|
|
97268
|
-
}, { incomplete: async (source2) => {
|
|
97269
|
-
read ??= await registeredArticleSourceReader(input.projectRoot);
|
|
97270
|
-
return await read.incomplete?.(source2) ?? false;
|
|
97271
|
-
} })
|
|
97272
|
-
};
|
|
97273
|
-
const result = [];
|
|
97274
|
-
const problems = [];
|
|
97275
|
-
for (const id3 of input.sectionIds) {
|
|
97276
|
-
const edit = edits.get(id3);
|
|
97277
|
-
if (edit?.references !== undefined) {
|
|
97278
|
-
const at2 = ["sections", input.edits.indexOf(edit), "references"];
|
|
97279
|
-
const references2 = [];
|
|
97280
|
-
for (const [index3, reference2] of edit.references.entries()) {
|
|
97281
|
-
try {
|
|
97282
|
-
references2.push(await resolveSubmittedReference(context, id3, [...at2, index3], reference2));
|
|
97283
|
-
} catch (error) {
|
|
97284
|
-
if (error instanceof SourceReadError || error instanceof SourceUnavailableError) {
|
|
97285
|
-
problems.push(new SubmissionInputError(`Fragment ${id3}: ${reference2.source_ref} ${reference2.locator.path}: ${error.message}`, [...at2, index3, "source_ref"], String(error.detail?.reason_code ?? "source-unavailable")));
|
|
97286
|
-
} else if (error instanceof SubmissionInputError)
|
|
97287
|
-
problems.push(error);
|
|
97288
|
-
else
|
|
97289
|
-
throw error;
|
|
97290
|
-
}
|
|
97291
|
-
}
|
|
97292
|
-
try {
|
|
97293
|
-
result.push({ id: id3, references: articleFragmentReferences(references2) });
|
|
97294
|
-
} catch (error) {
|
|
97295
|
-
if (error instanceof ZodError)
|
|
97296
|
-
problems.push(new SubmissionInputError(`Fragment ${id3}: ${error.issues.map((issue) => issue.message).join("; ")}`, at2));
|
|
97297
|
-
else
|
|
97298
|
-
throw error;
|
|
97299
|
-
}
|
|
97300
|
-
continue;
|
|
97301
|
-
}
|
|
97302
|
-
const references = [];
|
|
97303
|
-
const retained = input.previous.find((section) => section.id === id3)?.references ?? [];
|
|
97304
|
-
for (const [index3, reference2] of retained.entries()) {
|
|
97305
|
-
references.push(await retainReference(input, context, id3, ["fragments", id3, "references", index3], reference2, problems));
|
|
97306
|
-
}
|
|
97307
|
-
result.push({ id: id3, references });
|
|
97308
|
-
}
|
|
97309
|
-
if (problems.length === 1)
|
|
97310
|
-
throw problems[0];
|
|
97311
|
-
if (problems.length)
|
|
97312
|
-
throw new SubmissionInputErrors(problems);
|
|
97313
|
-
return result;
|
|
97314
|
-
}
|
|
97315
|
-
async function retainReference(input, context, id3, at2, reference2, problems) {
|
|
97316
|
-
const changed = input.changedBodies?.has(id3) === true;
|
|
97317
|
-
const where = `${reference2.source_ref} ${reference2.locator.path}:${reference2.locator.start_line}-${reference2.locator.end_line}`;
|
|
97318
|
-
let observed;
|
|
97319
|
-
try {
|
|
97320
|
-
observed = await relocateUnchangedReference(context.projectRoot, context.readSource, reference2);
|
|
97321
|
-
} catch (error) {
|
|
97322
|
-
if (!(error instanceof SourceReadError))
|
|
97323
|
-
throw error;
|
|
97324
|
-
if (changed)
|
|
97325
|
-
problems.push(new SubmissionInputError(`Fragment ${id3}: the text changed, but ${where} cannot be checked: ${error.message}`, at2, "reference-unverifiable"));
|
|
97326
|
-
return reference2;
|
|
97327
|
-
}
|
|
97328
|
-
if (observed.state === "current" || observed.state === "moved")
|
|
97329
|
-
return observed.reference;
|
|
97330
|
-
if (observed.state === "unavailable" && (observed.reason ?? "") in LOCAL_SOURCE_REASONS) {
|
|
97331
|
-
if (changed)
|
|
97332
|
-
problems.push(new SubmissionInputError(`Fragment ${id3}: the text changed, but ${where} cannot be checked on this machine (${observed.reason}). Make the source available, then submit again.`, at2, "reference-unverifiable"));
|
|
97333
|
-
return reference2;
|
|
97334
|
-
}
|
|
97335
|
-
if (citesScope(input.processedScopes ?? [], reference2.source_ref)) {
|
|
97336
|
-
const hint = await input.suggest?.(reference2).catch(() => {
|
|
97337
|
-
return;
|
|
97338
|
-
});
|
|
97339
|
-
problems.push(new SubmissionInputError(`Fragment ${id3}: ${where} is ${observed.state}${observed.reason ? ` (${observed.reason})` : ""} in the source version this revision processes. ` + `Rewrite the paragraph, cite its current text${hint ? ` (${hint})` : ""}, or remove the citation.`, at2, "processed-reference-stale"));
|
|
97340
|
-
return reference2;
|
|
97341
|
-
}
|
|
97342
|
-
input.onReminder?.({
|
|
97343
|
-
section_id: id3,
|
|
97344
|
-
state: observed.state,
|
|
97345
|
-
...observed.reason ? { reason: observed.reason } : {},
|
|
97346
|
-
source_ref: reference2.source_ref,
|
|
97347
|
-
locator: reference2.locator
|
|
97348
|
-
});
|
|
97349
|
-
return reference2;
|
|
97350
|
-
}
|
|
97351
|
-
async function suggestedCitation(projectRoot, reference2, sections) {
|
|
97352
|
-
const history = await articleReferenceHistoryReader(projectRoot, readProcessedScopes((await readKnowledgeStructure(projectRoot)).parsed))(reference2);
|
|
97353
|
-
if (!history?.text)
|
|
97354
|
-
return;
|
|
97355
|
-
const current3 = await (await registeredArticleSourceReader(projectRoot))(reference2.source_ref, reference2.locator.path, true);
|
|
97356
|
-
const cited = sections.flatMap((section) => section.references.map((item) => ({
|
|
97357
|
-
source_ref: item.source_ref,
|
|
97358
|
-
path: item.locator.path,
|
|
97359
|
-
start_line: item.locator.start_line,
|
|
97360
|
-
end_line: item.locator.end_line
|
|
97361
|
-
})));
|
|
97362
|
-
const suggested = await suggestedRange(projectRoot, reference2, history.text, current3, cited);
|
|
97363
|
-
if (!suggested)
|
|
97364
|
-
return;
|
|
97365
|
-
return "quote" in suggested.locator ? `the old text now maps to lines ${suggested.start_line}-${suggested.end_line}; cite them with a quote locator` : `the old text now maps to lines ${suggested.start_line}-${suggested.end_line}`;
|
|
97366
|
-
}
|
|
97367
|
-
function removedCitations(previous2, next) {
|
|
97368
|
-
const removed = [];
|
|
97369
|
-
for (const section of previous2) {
|
|
97370
|
-
const current3 = next.find((item) => item.id === section.id)?.references ?? [];
|
|
97371
|
-
for (const reference2 of section.references) {
|
|
97372
|
-
const kept = current3.some((item) => item.source_ref === reference2.source_ref && item.locator.path === reference2.locator.path && item.content_digest === reference2.content_digest);
|
|
97373
|
-
if (!kept)
|
|
97374
|
-
removed.push({
|
|
97375
|
-
section_id: section.id,
|
|
97376
|
-
source_ref: reference2.source_ref,
|
|
97377
|
-
path: reference2.locator.path,
|
|
97378
|
-
start_line: reference2.locator.start_line,
|
|
97379
|
-
end_line: reference2.locator.end_line
|
|
97380
|
-
});
|
|
97381
|
-
}
|
|
97382
|
-
}
|
|
97383
|
-
return removed;
|
|
97384
|
-
}
|
|
97385
|
-
function citationNotes(removed, reminders) {
|
|
97386
|
-
return {
|
|
97387
|
-
...removed.length ? { removed_citations: [...removed], removed_citations_note: REMOVED_CITATIONS_NOTE } : {},
|
|
97388
|
-
...reminders.length ? { reference_warnings: [...reminders], reference_warning_instruction: REFERENCE_REMINDER_NOTE } : {}
|
|
97389
|
-
};
|
|
97390
|
-
}
|
|
97391
|
-
var citesScope = (scopes, ref2) => scopes.some((scope2) => repoContentScopeMatches(scope2, ref2) || ref2.startsWith(`${scope2}#`) || ref2.startsWith(`${scope2}/`)), REFERENCE_REMINDER_NOTE = "These paragraphs keep citations their sources no longer confirm. The sources are outside what this revision processes, so the citations were kept; check them in a source update or a separate revision.", REMOVED_CITATIONS_NOTE = "These earlier citations are no longer in their sections. If you meant to replace or remove them, nothing needs doing; otherwise repeat each with its earlier lines to keep that evidence.";
|
|
97392
|
-
var init_approvedRevisionReferences = __esm(() => {
|
|
97393
|
-
init_zod();
|
|
97394
|
-
init_submittedSourceLocator();
|
|
97395
|
-
init_productionFeedback();
|
|
97396
|
-
init_src2();
|
|
97397
|
-
init_articleRegionBaselines();
|
|
97398
|
-
init_settledReferenceRelocation();
|
|
97399
|
-
init_articleSourceReader();
|
|
97400
|
-
init_gitObjectReader();
|
|
97401
|
-
init_articleReferenceObservation();
|
|
97402
|
-
init_packageBuildInventory();
|
|
97403
|
-
init_src2();
|
|
97404
|
-
});
|
|
97405
|
-
|
|
97406
97664
|
// src/project/approvedPageMove.ts
|
|
97407
97665
|
var exports_approvedPageMove = {};
|
|
97408
97666
|
__export(exports_approvedPageMove, {
|
|
@@ -99375,6 +99633,9 @@ async function runDocumentCaptureWithAvailability(root, phase, capture2) {
|
|
|
99375
99633
|
state: source2.snapshotReady ? "retained-snapshot" : "deferred-no-evidence",
|
|
99376
99634
|
...source2.snapshotHash ? { snapshot_hash: source2.snapshotHash } : {},
|
|
99377
99635
|
retry_command: `context run ${phase.id}`,
|
|
99636
|
+
...typeof error.detail.next === "string" ? { next: error.detail.next } : {},
|
|
99637
|
+
...typeof error.detail.stderr === "string" ? { stderr: error.detail.stderr } : {},
|
|
99638
|
+
...Array.isArray(error.detail.access_events) ? { access_events: error.detail.access_events } : {},
|
|
99378
99639
|
message: source2.snapshotReady ? "Document refresh unavailable. Retain the validated registered snapshot; it is not confirmed current upstream." : "Document acquisition unavailable. Keep this source registered as a pending evidence gap; do not cite it or invent content. Unrelated work may continue."
|
|
99379
99640
|
};
|
|
99380
99641
|
await applyAtomicFileBatch({ transactionRoot: join99(root, ".tmp/context-runtime/transactions"), writes: [{ path: path2, bytes: `${JSON.stringify({ configuration, warning }, null, 2)}
|
|
@@ -99531,7 +99792,7 @@ function createContextWorkflowFacts(observation, authorities) {
|
|
|
99531
99792
|
const buildLogPending = runtimeEvents.configured && runtimeEvents.pending_kinds.includes("package.build.completed");
|
|
99532
99793
|
return {
|
|
99533
99794
|
workspace: {
|
|
99534
|
-
task_start_authorized: observation.taskPreparation !== "cleared",
|
|
99795
|
+
task_start_authorized: observation.taskPreparation !== "cleared" || outputOnlyMaintenance,
|
|
99535
99796
|
project_entry_valid: observation.projectEntryValid,
|
|
99536
99797
|
state_valid: workspaceStateValid(observation)
|
|
99537
99798
|
},
|
|
@@ -101232,7 +101493,8 @@ async function collectProjectStatusSnapshotInternal(projectRoot, options = {}) {
|
|
|
101232
101493
|
const maintenanceState = await readMaintenance2(projectRoot);
|
|
101233
101494
|
const maintenance = maintenanceState.active;
|
|
101234
101495
|
const authoring = production && !production.delivery && (dispatchProductionStage(production, productionCapabilitiesSchema.parse({})).state !== "ended" || draftStatus.count > 0 && draftStatus.diagnostics.length === 0);
|
|
101235
|
-
const
|
|
101496
|
+
const navigationOnly = !maintenance && !localRevision && !localUpdate && !localRollback && taskPreparation === "cleared" && !production && phaseStatus.projectEntryValid && await navigationOnlyChange(projectRoot, phaseStatus.packages);
|
|
101497
|
+
const deferDeliveryChecks = !maintenance && !localRevision && !localUpdate && !localRollback && !navigationOnly && (taskPreparation === "cleared" && !production || !!authoring);
|
|
101236
101498
|
const collectionsWithPages = new Set;
|
|
101237
101499
|
const approvedPages = await countFiles(join104(projectRoot, "knowledge"), (rel) => {
|
|
101238
101500
|
if (!isApprovedKnowledgeMarkdownPath(rel) || rel.startsWith("assets/"))
|
|
@@ -101266,7 +101528,7 @@ async function collectProjectStatusSnapshotInternal(projectRoot, options = {}) {
|
|
|
101266
101528
|
const indexerDrafts = productionCandidates.filter((candidate) => candidate.status === "draft");
|
|
101267
101529
|
const indexerRejected = productionCandidates.filter((candidate) => candidate.status === "rejected");
|
|
101268
101530
|
const draftCollections = [...new Set(indexerDrafts.map((candidate) => candidate.collection))].sort();
|
|
101269
|
-
const maintenanceOutputOnly = maintenance?.input.operation === "rebuild" || maintenance?.phase === "finishing" || maintenance?.phase === "cancelling" && indexerDrafts.length === 0;
|
|
101531
|
+
const maintenanceOutputOnly = navigationOnly || maintenance?.input.operation === "rebuild" || maintenance?.phase === "finishing" || maintenance?.phase === "cancelling" && indexerDrafts.length === 0;
|
|
101270
101532
|
const sourceUpdate = !maintenance && !localRevision && !localUpdate && !localRollback && !production && draftStatus.count === 0 && approvedPages > 0 ? await Promise.resolve().then(() => (init_pendingSourceUpdates(), exports_pendingSourceUpdates)).then(({ inspectPendingSourceUpdates: inspectPendingSourceUpdates2 }) => inspectPendingSourceUpdates2(projectRoot)) : undefined;
|
|
101271
101533
|
const observation = {
|
|
101272
101534
|
versionCurrent: phaseStatus.projectEntryValid && !deferDeliveryChecks ? (await inspectWorkspaceVersion(projectRoot)).current : false,
|
|
@@ -101466,6 +101728,28 @@ async function reevaluateProjectStatusWorkflow(input) {
|
|
|
101466
101728
|
async function collectProjectStatus(projectRoot, options = {}) {
|
|
101467
101729
|
return (await collectProjectStatusSnapshot(projectRoot, options)).status;
|
|
101468
101730
|
}
|
|
101731
|
+
async function navigationOnlyChange(projectRoot, packages) {
|
|
101732
|
+
const { KNOWLEDGE_MAP_PATH: KNOWLEDGE_MAP_PATH2 } = await Promise.resolve().then(() => (init_knowledgeMap2(), exports_knowledgeMap));
|
|
101733
|
+
const { excludedWorkspaceContent: excludedWorkspaceContent2 } = await Promise.resolve().then(() => (init_workspaceContentSnapshot(), exports_workspaceContentSnapshot));
|
|
101734
|
+
const { execFile: execFile17 } = await import("node:child_process");
|
|
101735
|
+
const git4 = (...args) => new Promise((done) => execFile17("git", ["-C", projectRoot, ...args], { env: { ...process.env, GIT_OPTIONAL_LOCKS: "0" }, timeout: 30000, maxBuffer: 67108864 }, (error, stdout) => done(error ? undefined : stdout)));
|
|
101736
|
+
const recorded = (await git4("log", "-1", "--format=%H", "--", "changelog.yaml"))?.trim();
|
|
101737
|
+
if (recorded) {
|
|
101738
|
+
const changed = [
|
|
101739
|
+
...(await git4("diff", "--name-only", "--relative", recorded, "--"))?.split(`
|
|
101740
|
+
`) ?? [],
|
|
101741
|
+
...(await git4("ls-files", "--others", "--exclude-standard"))?.split(`
|
|
101742
|
+
`) ?? []
|
|
101743
|
+
].filter((path2) => path2 && path2 !== "package.json" && !excludedWorkspaceContent2(path2));
|
|
101744
|
+
if (changed.includes(KNOWLEDGE_MAP_PATH2) && changed.every((path2) => path2 === KNOWLEDGE_MAP_PATH2 || !/^(?:knowledge|sources|src)\//u.test(path2)))
|
|
101745
|
+
return true;
|
|
101746
|
+
}
|
|
101747
|
+
const latest = (await readWorkspaceChangelog(projectRoot).catch(() => []))[0];
|
|
101748
|
+
if (!latest || !latest.triggers.every((trigger) => trigger.kind === "navigation"))
|
|
101749
|
+
return false;
|
|
101750
|
+
const freshness = await readPackageFreshnessStatus(projectRoot, packages);
|
|
101751
|
+
return freshness.diagnostics.length > 0 || freshness.packages.length < packages.length || freshness.packages.some((item) => item.state !== "ready");
|
|
101752
|
+
}
|
|
101469
101753
|
var init_status = __esm(() => {
|
|
101470
101754
|
init_documentCaptureAvailability();
|
|
101471
101755
|
init_productionPlanning();
|
|
@@ -106915,14 +107199,19 @@ async function runLarkResourceCommand(runner2, args, options) {
|
|
|
106915
107199
|
}
|
|
106916
107200
|
return result.stdout;
|
|
106917
107201
|
}
|
|
107202
|
+
function larkPermissionGuidance(error) {
|
|
107203
|
+
const stderr = error instanceof Error && "stderr" in error && typeof error.stderr === "string" ? error.stderr : "";
|
|
107204
|
+
const scope2 = error instanceof LarkResourceCommandError && error.missingScope || hasMissingScope(errorDetail(stderr)) || hasMissingScope(stderr);
|
|
107205
|
+
return scope2 ? "Request the missing permission for the app at https://open.larkoffice.com/app, then capture again." : "Ask the document's owner to share it with the capturing identity, then capture again.";
|
|
107206
|
+
}
|
|
106918
107207
|
function isLarkResourcePermissionDenied(error) {
|
|
106919
107208
|
if (!(error instanceof Error))
|
|
106920
107209
|
return false;
|
|
106921
107210
|
const stderr = "stderr" in error && typeof error.stderr === "string" ? error.stderr : "";
|
|
106922
107211
|
const detail = error instanceof LarkResourceCommandError ? { type: error.errorType, subtype: error.errorSubtype, code: error.code } : errorDetail(stderr);
|
|
106923
|
-
return error instanceof LarkResourceCommandError && error.missingScope || hasMissingScope(detail) || hasMissingScope(stderr) || String(detail?.code) === "403" || detail?.type === "authorization" && ["permission_denied", "access_denied", "missing_scope"].includes(String(detail.subtype ?? ""));
|
|
107212
|
+
return error instanceof LarkResourceCommandError && error.missingScope || hasMissingScope(detail) || hasMissingScope(stderr) || String(detail?.code) === "403" || String(detail?.code) === LARK_DOCUMENT_ACCESS_DENIED_CODE || errorDetail(error.message)?.code === Number(LARK_DOCUMENT_ACCESS_DENIED_CODE) || detail?.type === "authorization" && ["permission_denied", "access_denied", "missing_scope"].includes(String(detail.subtype ?? ""));
|
|
106924
107213
|
}
|
|
106925
|
-
var LarkResourceCommandError;
|
|
107214
|
+
var LarkResourceCommandError, LARK_DOCUMENT_ACCESS_DENIED_CODE = "3380004";
|
|
106926
107215
|
var init_larkResourceCommand = __esm(() => {
|
|
106927
107216
|
LarkResourceCommandError = class LarkResourceCommandError extends Error {
|
|
106928
107217
|
errorType;
|
|
@@ -107649,7 +107938,7 @@ async function materializeLarkResources(input) {
|
|
|
107649
107938
|
required,
|
|
107650
107939
|
asset_paths: [],
|
|
107651
107940
|
...reasonCode === undefined ? {} : { reason_code: reasonCode },
|
|
107652
|
-
reason: error instanceof Error ? error.message : String(error)
|
|
107941
|
+
reason: `${error instanceof Error ? error.message : String(error)}${reasonCode === DOCUMENT_RESOURCE_PERMISSION_DENIED_REASON_CODE ? ` ${larkPermissionGuidance(error)}` : ""}`
|
|
107653
107942
|
});
|
|
107654
107943
|
}
|
|
107655
107944
|
};
|
|
@@ -107790,6 +108079,8 @@ function credentialFailure(result) {
|
|
|
107790
108079
|
continue;
|
|
107791
108080
|
const type = "type" in error ? error.type : undefined;
|
|
107792
108081
|
const subtype = "subtype" in error ? error.subtype : undefined;
|
|
108082
|
+
if ("code" in error && String(error.code) === LARK_DOCUMENT_ACCESS_DENIED_CODE)
|
|
108083
|
+
return true;
|
|
107793
108084
|
if (type === "authorization" || type === "authentication" || ["missing_scope", "permission_denied", "access_denied", "need_user_authorization"].includes(String(subtype))) {
|
|
107794
108085
|
return true;
|
|
107795
108086
|
}
|
|
@@ -107797,9 +108088,28 @@ function credentialFailure(result) {
|
|
|
107797
108088
|
}
|
|
107798
108089
|
return result.exitCode !== 0 && /reason=(?:bot_unavailable|not_authorized)\b|\b(?:missing_scope|permission_denied|access_denied)\b/iu.test(result.stderr);
|
|
107799
108090
|
}
|
|
108091
|
+
function failureCause(result) {
|
|
108092
|
+
for (const output of [result.stderr, result.stdout]) {
|
|
108093
|
+
const start2 = output.indexOf("{");
|
|
108094
|
+
if (start2 < 0)
|
|
108095
|
+
continue;
|
|
108096
|
+
try {
|
|
108097
|
+
const parsed = JSON.parse(output.slice(start2));
|
|
108098
|
+
const error = parsed && typeof parsed === "object" && "error" in parsed ? parsed.error : undefined;
|
|
108099
|
+
if (!error || typeof error !== "object")
|
|
108100
|
+
continue;
|
|
108101
|
+
const field = (key) => (key in error) ? String(error[key]) : undefined;
|
|
108102
|
+
if (field("code") !== undefined)
|
|
108103
|
+
return `lark error ${field("code")}`;
|
|
108104
|
+
return [field("type"), field("subtype")].filter(Boolean).join("/") || "credential failure";
|
|
108105
|
+
} catch {}
|
|
108106
|
+
}
|
|
108107
|
+
return /reason=(\w+)/u.exec(result.stderr)?.[1] ?? "credential failure";
|
|
108108
|
+
}
|
|
107800
108109
|
function createLarkReadSession(runner2, initial, fallback = initial === "bot") {
|
|
107801
108110
|
let identity2 = initial;
|
|
107802
108111
|
let usedFallback = false;
|
|
108112
|
+
let fallbackCause;
|
|
107803
108113
|
let readingDocument = false;
|
|
107804
108114
|
let locked = false;
|
|
107805
108115
|
const restart = new Error("Restart document with user identity");
|
|
@@ -107814,8 +108124,10 @@ function createLarkReadSession(runner2, initial, fallback = initial === "bot") {
|
|
|
107814
108124
|
withIdentity.push("--as", selected);
|
|
107815
108125
|
const result = await runner2(withIdentity, options);
|
|
107816
108126
|
identity2 = selected;
|
|
107817
|
-
if (readingDocument && identity2 === "bot" && fallback && !usedFallback && !args.includes("--help") && credentialFailure(result))
|
|
108127
|
+
if (readingDocument && identity2 === "bot" && fallback && !usedFallback && !args.includes("--help") && credentialFailure(result)) {
|
|
108128
|
+
fallbackCause = failureCause(result);
|
|
107818
108129
|
throw restart;
|
|
108130
|
+
}
|
|
107819
108131
|
return result;
|
|
107820
108132
|
};
|
|
107821
108133
|
async function readDocument(read) {
|
|
@@ -107835,19 +108147,28 @@ function createLarkReadSession(runner2, initial, fallback = initial === "bot") {
|
|
|
107835
108147
|
locked = true;
|
|
107836
108148
|
}
|
|
107837
108149
|
}
|
|
107838
|
-
return {
|
|
107839
|
-
|
|
107840
|
-
|
|
107841
|
-
|
|
107842
|
-
|
|
108150
|
+
return {
|
|
108151
|
+
run,
|
|
108152
|
+
readDocument,
|
|
108153
|
+
get identity() {
|
|
108154
|
+
return identity2;
|
|
108155
|
+
},
|
|
108156
|
+
get usedFallback() {
|
|
108157
|
+
return usedFallback;
|
|
108158
|
+
},
|
|
108159
|
+
get fallbackCause() {
|
|
108160
|
+
return fallbackCause;
|
|
108161
|
+
}
|
|
108162
|
+
};
|
|
107843
108163
|
}
|
|
107844
108164
|
var init_larkReadIdentity = __esm(() => {
|
|
107845
108165
|
init_errors3();
|
|
107846
108166
|
init_exitCode();
|
|
108167
|
+
init_larkResourceCommand();
|
|
107847
108168
|
});
|
|
107848
108169
|
|
|
107849
108170
|
// src/lib/feishu.ts
|
|
107850
|
-
import { spawn as
|
|
108171
|
+
import { spawn as spawn6 } from "node:child_process";
|
|
107851
108172
|
async function detectDocsFetchCapabilities(runner2) {
|
|
107852
108173
|
const result = await runner2(["docs", "+fetch", "--help"]).catch(() => ({
|
|
107853
108174
|
stdout: "",
|
|
@@ -108219,17 +108540,25 @@ async function fetchFeishuDocSnapshot(input, runner2 = defaultRunner) {
|
|
|
108219
108540
|
}
|
|
108220
108541
|
});
|
|
108221
108542
|
}
|
|
108222
|
-
|
|
108543
|
+
const identityFallback = identityFetch.fallback || session.usedFallback;
|
|
108544
|
+
const access7 = {
|
|
108545
|
+
identity: accessIdentity,
|
|
108546
|
+
...session.usedFallback ? { fallback: { from: "bot", cause: session.fallbackCause ?? "credential failure" } } : {},
|
|
108547
|
+
...input.accessEvents?.length ? { events: [...input.accessEvents] } : {}
|
|
108548
|
+
};
|
|
108549
|
+
const sameAccess = !input.accessEvents?.some((event) => event.changed_access) && (input.unchangedAccess === undefined ? !identityFallback : sameLarkAccess(input.unchangedAccess, access7));
|
|
108550
|
+
if (sameAccess && revisionId !== undefined && revisionId === input.unchangedRevisionId && fidelity.evidence_status !== "error" && fidelity.projection_status !== "error" || input.requireCompleteBody === true && (fidelity.evidence_status === "error" || fidelity.projection_status === "error")) {
|
|
108223
108551
|
return {
|
|
108224
108552
|
markdown: body2,
|
|
108225
108553
|
...title2 === undefined ? {} : { title: title2 },
|
|
108226
108554
|
...revisionId === undefined ? {} : { revisionId },
|
|
108227
|
-
...revisionId === input.unchangedRevisionId && fidelity.evidence_status !== "error" && fidelity.projection_status !== "error" ? { unchanged: true } : {},
|
|
108555
|
+
...sameAccess && revisionId === input.unchangedRevisionId && fidelity.evidence_status !== "error" && fidelity.projection_status !== "error" ? { unchanged: true } : {},
|
|
108228
108556
|
assets,
|
|
108229
108557
|
fidelity,
|
|
108230
108558
|
resourceMaterialization,
|
|
108231
108559
|
accessIdentity,
|
|
108232
|
-
identityFallback
|
|
108560
|
+
identityFallback,
|
|
108561
|
+
access: access7
|
|
108233
108562
|
};
|
|
108234
108563
|
}
|
|
108235
108564
|
const resources = [...new Map([...projection?.resources ?? [], ...larkMarkdownImageResources(body2)].map((resource) => [resource.locator, resource])).values()];
|
|
@@ -108275,7 +108604,8 @@ async function fetchFeishuDocSnapshot(input, runner2 = defaultRunner) {
|
|
|
108275
108604
|
assets.push(captureReportAsset({
|
|
108276
108605
|
fidelity,
|
|
108277
108606
|
resourceMaterialization,
|
|
108278
|
-
resources
|
|
108607
|
+
resources,
|
|
108608
|
+
access: access7
|
|
108279
108609
|
}));
|
|
108280
108610
|
if (title2 !== undefined && title2.length > 0 && !/^#\s/.test(body2)) {
|
|
108281
108611
|
return {
|
|
@@ -108288,7 +108618,8 @@ ${body2}`,
|
|
|
108288
108618
|
fidelity,
|
|
108289
108619
|
resourceMaterialization,
|
|
108290
108620
|
accessIdentity,
|
|
108291
|
-
identityFallback
|
|
108621
|
+
identityFallback,
|
|
108622
|
+
access: access7
|
|
108292
108623
|
};
|
|
108293
108624
|
}
|
|
108294
108625
|
return {
|
|
@@ -108299,7 +108630,8 @@ ${body2}`,
|
|
|
108299
108630
|
fidelity,
|
|
108300
108631
|
resourceMaterialization,
|
|
108301
108632
|
accessIdentity,
|
|
108302
|
-
identityFallback
|
|
108633
|
+
identityFallback,
|
|
108634
|
+
access: access7
|
|
108303
108635
|
};
|
|
108304
108636
|
}
|
|
108305
108637
|
async function readPrefetchedLarkDocument(url, prefetched) {
|
|
@@ -108308,7 +108640,7 @@ async function readPrefetchedLarkDocument(url, prefetched) {
|
|
|
108308
108640
|
}, prefetched.identity);
|
|
108309
108641
|
}
|
|
108310
108642
|
var LARK_BIN = "lark-cli", MAX_FETCH_PAGES = 50, MAX_STRUCTURAL_FETCH_ATTEMPTS = 2, LarkCliNotInstalledError, LarkCliError, defaultRunner = (args, options) => new Promise((resolve8, reject) => {
|
|
108311
|
-
const child =
|
|
108643
|
+
const child = spawn6(process.env.CONTEXT_LARK_CLI_BIN?.trim() || LARK_BIN, args, {
|
|
108312
108644
|
...options?.cwd === undefined ? {} : { cwd: options.cwd },
|
|
108313
108645
|
stdio: ["ignore", "pipe", "pipe"]
|
|
108314
108646
|
});
|
|
@@ -108571,6 +108903,7 @@ async function validateBundle(root2, manifest) {
|
|
|
108571
108903
|
assets,
|
|
108572
108904
|
accessIdentity: manifest.access_identity,
|
|
108573
108905
|
identityFallback: false,
|
|
108906
|
+
access: report.access ?? { identity: manifest.access_identity },
|
|
108574
108907
|
...manifest.title === undefined ? {} : { title: manifest.title },
|
|
108575
108908
|
...manifest.revision_id === undefined ? {} : { revisionId: manifest.revision_id },
|
|
108576
108909
|
fidelity: report.fidelity,
|
|
@@ -108788,6 +109121,12 @@ function larkErrorRecovery(error, sourceName) {
|
|
|
108788
109121
|
next: `Inspect the Lark document shape or permissions, then rerun context run capture:lark:${sourceName}`
|
|
108789
109122
|
};
|
|
108790
109123
|
}
|
|
109124
|
+
if (/"code"\s*:\s*3380004\b/u.test(message)) {
|
|
109125
|
+
return {
|
|
109126
|
+
reasonCode: "external.authorization-required",
|
|
109127
|
+
next: `The Lark identity used for capture cannot view this document (code 3380004); signing in again does not help. Ask the document's owner to share it with that identity (for a bot, add its app as a viewer), then rerun context run capture:lark:${sourceName}`
|
|
109128
|
+
};
|
|
109129
|
+
}
|
|
108791
109130
|
if (/auth|login|permission|forbidden|unauthori[sz]ed|scope/iu.test(message)) {
|
|
108792
109131
|
return {
|
|
108793
109132
|
reasonCode: "external.authorization-required",
|
|
@@ -108942,6 +109281,13 @@ async function runCaptureLarkPhaseUnlocked(input) {
|
|
|
108942
109281
|
const previousRevision = (fingerprint === undefined ? undefined : await checkedLarkRevision(input.projectRoot, resolved.sourceName, fingerprint)) ?? previousManifest?.metadata?.source?.revisionId;
|
|
108943
109282
|
const unchangedRevisionId = !refresh && !input.prefetched && !recovery && Object.entries(input.phase.resources ?? {}).every(([key, value]) => value === DEFAULT_RESOURCE_POLICY[key]) && previousManifest?.normalizer_version === LARK_DOCUMENT_NORMALIZER_VERSION && fingerprint !== undefined ? previousRevision : undefined;
|
|
108944
109283
|
await beginFormatOnlyUpdate(input.projectRoot);
|
|
109284
|
+
let unchangedAccess;
|
|
109285
|
+
if (typeof unchangedRevisionId === "string" && previousManifest !== null) {
|
|
109286
|
+
try {
|
|
109287
|
+
unchangedAccess = readDocumentSnapshotCaptureReport({ projectRoot: input.projectRoot, materializedAt, manifest: previousManifest })?.access;
|
|
109288
|
+
} catch {}
|
|
109289
|
+
}
|
|
109290
|
+
const accessEvents = [];
|
|
108945
109291
|
let fetched;
|
|
108946
109292
|
let capturedAt = (input.now ?? new Date).toISOString();
|
|
108947
109293
|
try {
|
|
@@ -108956,21 +109302,31 @@ async function runCaptureLarkPhaseUnlocked(input) {
|
|
|
108956
109302
|
resourcePolicy: input.phase.resources,
|
|
108957
109303
|
requireCompleteBody: true,
|
|
108958
109304
|
...typeof unchangedRevisionId === "string" ? { unchangedRevisionId } : {},
|
|
109305
|
+
...unchangedAccess === undefined ? {} : { unchangedAccess },
|
|
109306
|
+
accessEvents,
|
|
108959
109307
|
...input.prefetched === undefined ? {} : { prefetched: input.prefetched }
|
|
108960
109308
|
}, input.larkRunner);
|
|
108961
109309
|
} catch (error) {
|
|
108962
|
-
|
|
108963
|
-
|
|
109310
|
+
const events = accessEvents.length ? { access_events: [...accessEvents] } : {};
|
|
109311
|
+
if (error instanceof ContextError) {
|
|
109312
|
+
if (!accessEvents.length)
|
|
109313
|
+
throw error;
|
|
109314
|
+
throw new ContextError(error.code, error.message, { ...error.detail, ...events });
|
|
109315
|
+
}
|
|
108964
109316
|
const failure2 = normalizeLarkError(error, resolved.sourceName);
|
|
108965
109317
|
if (failure2.detail?.reason_code === "external.authorization-required" || failure2.detail?.reason_code === "external.tool-failed" && error instanceof LarkCliError && error.exitCode !== 0) {
|
|
108966
|
-
throw new ContextError(failure2.code, failure2.message, { ...failure2.detail, reason_code: DOCUMENT_ACQUISITION_UNAVAILABLE, acquisition_cause: failure2.detail?.reason_code });
|
|
109318
|
+
throw new ContextError(failure2.code, failure2.message, { ...failure2.detail, ...events, reason_code: DOCUMENT_ACQUISITION_UNAVAILABLE, acquisition_cause: failure2.detail?.reason_code });
|
|
108967
109319
|
}
|
|
108968
|
-
|
|
109320
|
+
if (!accessEvents.length)
|
|
109321
|
+
throw failure2;
|
|
109322
|
+
throw new ContextError(failure2.code, failure2.message, { ...failure2.detail, ...events });
|
|
108969
109323
|
}
|
|
109324
|
+
const accessEventDetail = accessEvents.length ? { access_events: [...accessEvents] } : {};
|
|
108970
109325
|
if (fetched.fidelity.evidence_status === "error" || fetched.fidelity.projection_status === "error") {
|
|
108971
109326
|
throw new ContextError(ExitCode.WorkspaceStateError, `lark source ${resolved.sourceName} returned an incomplete body; the existing snapshot was not changed`, {
|
|
108972
109327
|
category: ErrorCategory.PartialFailure,
|
|
108973
109328
|
reason_code: DOCUMENT_ACQUISITION_UNAVAILABLE,
|
|
109329
|
+
...accessEventDetail,
|
|
108974
109330
|
sourceName: resolved.sourceName,
|
|
108975
109331
|
issues: fetched.fidelity.issues,
|
|
108976
109332
|
next: `context run ${input.phase.id} --format json`
|
|
@@ -108993,6 +109349,7 @@ async function runCaptureLarkPhaseUnlocked(input) {
|
|
|
108993
109349
|
},
|
|
108994
109350
|
access_identity: fetched.accessIdentity,
|
|
108995
109351
|
identity_fallback: fetched.identityFallback,
|
|
109352
|
+
access: fetched.access,
|
|
108996
109353
|
snapshot: { manifest: manifestPath, materializedAt, snapshot_hash: previousManifest.snapshot_hash, changed: false },
|
|
108997
109354
|
documents: previousManifest.files.map((file) => ({ path: file.path, title: file.title ?? resolved.sourceName, line_count: file.line_count })),
|
|
108998
109355
|
assets: previousManifest.assets ?? [],
|
|
@@ -109002,17 +109359,21 @@ async function runCaptureLarkPhaseUnlocked(input) {
|
|
|
109002
109359
|
next_action: workspaceRouteReevaluation(input.phase.id)
|
|
109003
109360
|
};
|
|
109004
109361
|
}
|
|
109362
|
+
let degraded = [];
|
|
109005
109363
|
if (previousManifest && previousRevision !== undefined && fetched.revisionId === previousRevision) {
|
|
109006
109364
|
const previous3 = documentSnapshotFidelityState(previousManifest, readDocumentSnapshotCaptureReport({
|
|
109007
109365
|
projectRoot: input.projectRoot,
|
|
109008
109366
|
materializedAt,
|
|
109009
109367
|
manifest: previousManifest
|
|
109010
109368
|
}));
|
|
109011
|
-
|
|
109369
|
+
let lost = fetched.resourceMaterialization.items.filter((item) => previous3.resourceMaterialization?.items.some((old) => old.kind === item.kind && old.locator === item.locator && old.status === "materialized" && (item.status !== "materialized" || item.reason_code === "document.resource.preview" && old.reason_code !== "document.resource.preview")));
|
|
109370
|
+
degraded = lost.filter((item) => item.status === "materialized" || isNonBlockingDocumentResourceFailureReasonCode(item.reason_code));
|
|
109371
|
+
lost = lost.filter((item) => !degraded.includes(item));
|
|
109012
109372
|
if (lost.length)
|
|
109013
109373
|
throw new ContextError(ExitCode.WorkspaceStateError, "Previously captured resources were degraded; the existing snapshot was preserved. Check resource policy and access before retrying the explicit refresh.", {
|
|
109014
109374
|
category: ErrorCategory.PartialFailure,
|
|
109015
109375
|
reason_code: DOCUMENT_ACQUISITION_UNAVAILABLE,
|
|
109376
|
+
...accessEventDetail,
|
|
109016
109377
|
resources: lost.map((item) => ({ locator: item.locator, reason: item.reason })),
|
|
109017
109378
|
next_action: {
|
|
109018
109379
|
command: `context run ${input.phase.id} --input - --format json`,
|
|
@@ -109170,6 +109531,7 @@ async function runCaptureLarkPhaseUnlocked(input) {
|
|
|
109170
109531
|
throw new ContextError(ExitCode.WorkspaceStateError, `lark source ${resolved.sourceName} audit snapshot was preserved, but required resources could not be materialized`, {
|
|
109171
109532
|
category: ErrorCategory.PartialFailure,
|
|
109172
109533
|
code: "lark.capture.resource-materialization-failed",
|
|
109534
|
+
...accessEventDetail,
|
|
109173
109535
|
sourceName: resolved.sourceName,
|
|
109174
109536
|
snapshot: {
|
|
109175
109537
|
manifest: manifestPath,
|
|
@@ -109192,6 +109554,7 @@ async function runCaptureLarkPhaseUnlocked(input) {
|
|
|
109192
109554
|
},
|
|
109193
109555
|
access_identity: fetched.accessIdentity,
|
|
109194
109556
|
identity_fallback: fetched.identityFallback,
|
|
109557
|
+
access: fetched.access,
|
|
109195
109558
|
snapshot: {
|
|
109196
109559
|
manifest: manifestPath,
|
|
109197
109560
|
materializedAt,
|
|
@@ -109213,9 +109576,11 @@ async function runCaptureLarkPhaseUnlocked(input) {
|
|
|
109213
109576
|
diagnostics: [
|
|
109214
109577
|
...cacheDiagnostics,
|
|
109215
109578
|
...recovery === undefined ? [] : [recovery.diagnostic],
|
|
109216
|
-
...fetched.
|
|
109579
|
+
...larkAccessDiagnostics(fetched.access),
|
|
109217
109580
|
...fetched.fidelity.issues.map((issue) => `${issue.severity}: ${issue.code}: ${issue.block_type} × ${issue.count}: ${issue.reason}`),
|
|
109218
|
-
...fetched.resourceMaterialization.items.filter((item) => item.status === "failed" || item.kind === "poll" && item.reason?.includes("absent") === true).map((item) => `${item.status}: lark.capture.resource-${item.status}: ${item.kind}: ${item.reason ?? item.locator}`)
|
|
109581
|
+
...fetched.resourceMaterialization.items.filter((item) => item.status === "failed" || item.kind === "poll" && item.reason?.includes("absent") === true).map((item) => `${item.status}: lark.capture.resource-${item.status}: ${item.kind}: ${item.reason ?? item.locator}`),
|
|
109582
|
+
...fetched.resourceMaterialization.items.filter((item) => item.reason_code === "document.resource.preview").map((item) => `warning: lark.capture.resource-preview: ${item.kind}: ${item.reason ?? item.locator}`),
|
|
109583
|
+
...degraded.map((item) => `warning: lark.capture.resource-degraded: ${item.kind} ${item.locator} was captured before and is now ${item.status === "materialized" ? "a preview" : "a gap"}; its placeholder is not citable evidence`)
|
|
109219
109584
|
],
|
|
109220
109585
|
next_action: workspaceRouteReevaluation(input.phase.id)
|
|
109221
109586
|
};
|
|
@@ -109224,6 +109589,7 @@ async function runCaptureLarkPhase(input) {
|
|
|
109224
109589
|
return withProjectWriteLock(input.projectRoot, "capture-lark", () => runCaptureLarkPhaseUnlocked(input));
|
|
109225
109590
|
}
|
|
109226
109591
|
var init_documentCaptureLark = __esm(() => {
|
|
109592
|
+
init_larkCaptureReport();
|
|
109227
109593
|
init_src3();
|
|
109228
109594
|
init_atomicFileBatch();
|
|
109229
109595
|
init_cliFeedback();
|
|
@@ -109877,8 +110243,6 @@ async function completeCurrentProductionAction(input) {
|
|
|
109877
110243
|
});
|
|
109878
110244
|
if (!stage)
|
|
109879
110245
|
throw invalid3("The production stage expired. Read the current route; do not restore a previous process.");
|
|
109880
|
-
if (input.preview)
|
|
109881
|
-
throw invalid3("Stage files do not use the retired Author preview. Submit the current task files.");
|
|
109882
110246
|
if (!input.submissionPath || input.submissionPath === "-")
|
|
109883
110247
|
throw invalid3("Production requires a stage-local manifest file, not stdin.");
|
|
109884
110248
|
const path3 = relative32(resolve41(input.projectRoot, productionAgentDirectory(stage.id)), resolve41(input.cwd, input.submissionPath));
|
|
@@ -109888,13 +110252,19 @@ async function completeCurrentProductionAction(input) {
|
|
|
109888
110252
|
throw invalid3("The manifest must identify the current production stage. No tasks were saved.");
|
|
109889
110253
|
}
|
|
109890
110254
|
const submission = { projectRoot: input.projectRoot, stage: stage.id, path: path3, manifest, multiAgent: input.multiAgent === true };
|
|
109891
|
-
if ("decision" in value)
|
|
110255
|
+
if ("decision" in value) {
|
|
110256
|
+
if (input.preview)
|
|
110257
|
+
throw invalid3("--preview checks article task files; a report decision has nothing to preview.");
|
|
109892
110258
|
return approveProductionReport({ ...submission, revision: input.revision });
|
|
110259
|
+
}
|
|
109893
110260
|
if (input.revision !== stage.id)
|
|
109894
110261
|
throw invalid3("Use the current stage revision; task input handles protect independent submissions.");
|
|
109895
|
-
if (!stage.planning_complete || "articles" in value)
|
|
110262
|
+
if (!stage.planning_complete || "articles" in value) {
|
|
110263
|
+
if (input.preview)
|
|
110264
|
+
throw invalid3("--preview checks article task files; submit the plan to have it checked.");
|
|
109896
110265
|
return submitProductionPlan(submission);
|
|
109897
|
-
|
|
110266
|
+
}
|
|
110267
|
+
return completeProductionSubmission({ ...submission, preview: input.preview === true });
|
|
109898
110268
|
}));
|
|
109899
110269
|
}
|
|
109900
110270
|
var import_yaml54;
|
|
@@ -116201,7 +116571,7 @@ init_debugTrace();
|
|
|
116201
116571
|
init_src();
|
|
116202
116572
|
init_debugTrace();
|
|
116203
116573
|
import { createHash as createHash39 } from "node:crypto";
|
|
116204
|
-
import { spawn as
|
|
116574
|
+
import { spawn as spawn7 } from "node:child_process";
|
|
116205
116575
|
function digestText2(value, includeTail) {
|
|
116206
116576
|
const filtered = redactIndexerOutputText({
|
|
116207
116577
|
channel: includeTail ? "stderr" : "stdout",
|
|
@@ -116337,7 +116707,7 @@ execution scope cleanup failed`, true)
|
|
|
116337
116707
|
try {
|
|
116338
116708
|
receipt2 = await new Promise((resolve8, reject) => {
|
|
116339
116709
|
let settled = false;
|
|
116340
|
-
const child =
|
|
116710
|
+
const child = spawn7(process.execPath, [this.cliEntryPath, ...args], {
|
|
116341
116711
|
cwd: input.cwd,
|
|
116342
116712
|
env: { ...process.env, ...debugChildEnvironment() },
|
|
116343
116713
|
stdio: ["ignore", "pipe", "pipe"],
|
|
@@ -118310,6 +118680,28 @@ function registerDebugCommands(program2) {
|
|
|
118310
118680
|
});
|
|
118311
118681
|
}
|
|
118312
118682
|
|
|
118683
|
+
// src/commands/nextRoute.ts
|
|
118684
|
+
init_workflowCommandOptions();
|
|
118685
|
+
function nextRouteExecution(program2, command2 = {}) {
|
|
118686
|
+
const root2 = program2.opts();
|
|
118687
|
+
return {
|
|
118688
|
+
managed: root2.workflowManaged === true || command2.managed === true,
|
|
118689
|
+
authorities: mergedWorkflowAuthorities(root2.workflowAuthority, command2.authorities ?? [])
|
|
118690
|
+
};
|
|
118691
|
+
}
|
|
118692
|
+
async function withNextRoute(program2, projectRoot, result, command2 = {}) {
|
|
118693
|
+
const next2 = result?.next_action;
|
|
118694
|
+
if (next2 !== undefined && next2.command !== "context status --format json")
|
|
118695
|
+
return result;
|
|
118696
|
+
try {
|
|
118697
|
+
const { collectProjectStatus: collectProjectStatus2 } = await Promise.resolve().then(() => (init_status(), exports_status));
|
|
118698
|
+
const status = await collectProjectStatus2(projectRoot, nextRouteExecution(program2, command2));
|
|
118699
|
+
return { ...result, workflow: status.workflow };
|
|
118700
|
+
} catch {
|
|
118701
|
+
return result;
|
|
118702
|
+
}
|
|
118703
|
+
}
|
|
118704
|
+
|
|
118313
118705
|
// src/commands/documentRevisionCommands.ts
|
|
118314
118706
|
init_cliFeedback();
|
|
118315
118707
|
init_errors3();
|
|
@@ -118549,22 +118941,6 @@ function requireProjectRoot2() {
|
|
|
118549
118941
|
category: ErrorCategory.WorkspaceNotFound
|
|
118550
118942
|
});
|
|
118551
118943
|
}
|
|
118552
|
-
async function withNextRoute(program2, projectRoot, result) {
|
|
118553
|
-
const next2 = result?.next_action?.command;
|
|
118554
|
-
if (next2 !== "context status --format json")
|
|
118555
|
-
return result;
|
|
118556
|
-
try {
|
|
118557
|
-
const [{ collectProjectStatus: collectProjectStatus2 }, { workflowAuthorities: workflowAuthorities2 }] = await Promise.all([
|
|
118558
|
-
Promise.resolve().then(() => (init_status(), exports_status)),
|
|
118559
|
-
Promise.resolve().then(() => (init_workflowCommandOptions(), exports_workflowCommandOptions))
|
|
118560
|
-
]);
|
|
118561
|
-
const root2 = program2.opts();
|
|
118562
|
-
const status = await collectProjectStatus2(projectRoot, { managed: root2.workflowManaged === true, authorities: workflowAuthorities2(root2.workflowAuthority) });
|
|
118563
|
-
return { ...result, workflow: status.workflow };
|
|
118564
|
-
} catch {
|
|
118565
|
-
return result;
|
|
118566
|
-
}
|
|
118567
|
-
}
|
|
118568
118944
|
function registerDocumentRevisionCommand(program2) {
|
|
118569
118945
|
const task = program2.command("task").description("Explicit current-task recovery");
|
|
118570
118946
|
task.command("retire").description("Preview or apply explicit approved-article retirement and reference cleanup").option("--input <file>", "YAML/JSON reason and targets with optional approved replacement; - for stdin").option("--schema", "show the retirement input schema").option("--apply", "apply the reviewed retirement within existing user authorization").option("--plan-digest <digest>", "exact current retirement preview").option("--format <format>", "output format: json", "json").action(async (options) => {
|
|
@@ -118834,6 +119210,10 @@ function registerDocumentRevisionCommand(program2) {
|
|
|
118834
119210
|
}
|
|
118835
119211
|
|
|
118836
119212
|
// src/commands/versionCommands.ts
|
|
119213
|
+
init_candidateLedger();
|
|
119214
|
+
init_errors3();
|
|
119215
|
+
init_cliFeedback();
|
|
119216
|
+
init_exitCode();
|
|
118837
119217
|
init_workspace();
|
|
118838
119218
|
init_workspaceChangelog();
|
|
118839
119219
|
init_status();
|
|
@@ -118881,6 +119261,20 @@ function registerVersionCommands(program2) {
|
|
|
118881
119261
|
...reference2 === undefined ? {} : { resourceReceiptsReference: reference2 }
|
|
118882
119262
|
};
|
|
118883
119263
|
const resourceReceipts = execution.resourceReceiptsReference === undefined ? undefined : await parseWorkflowResourceReceipts(execution.resourceReceiptsReference, root2);
|
|
119264
|
+
if ((await readCandidateRecords(root2)).some((candidate) => candidate.status === "draft")) {
|
|
119265
|
+
const current3 = (await collectProjectStatus(root2, {
|
|
119266
|
+
...execution,
|
|
119267
|
+
...resourceReceipts === undefined ? {} : { resourceReceipts }
|
|
119268
|
+
})).workflow.current;
|
|
119269
|
+
if (current3?.node !== "record-workspace-version") {
|
|
119270
|
+
throw new ContextError(ExitCode.WorkspaceStateError, `Drafts are still awaiting review; the current step is ${current3?.node ?? "unknown"}, not version recording.`, {
|
|
119271
|
+
category: ErrorCategory.WorkspaceStateInvalid,
|
|
119272
|
+
reason_code: "version-review-pending",
|
|
119273
|
+
next_action: { command: current3?.commands?.[0]?.command ?? workflowStatusCommand(execution) },
|
|
119274
|
+
next: "Finish the current step and Review first; the workflow reaches version recording after approval."
|
|
119275
|
+
});
|
|
119276
|
+
}
|
|
119277
|
+
}
|
|
118884
119278
|
const recorded = await recordWorkspaceVersion(root2, value);
|
|
118885
119279
|
let result;
|
|
118886
119280
|
try {
|
|
@@ -119248,21 +119642,32 @@ async function prepareKnownProductionTasks(input) {
|
|
|
119248
119642
|
if (!request || stage?.report_approved || (stage ? ![stage.id, request.revision].includes(input.revision) : request.revision !== input.revision)) {
|
|
119249
119643
|
throw invalid3("Use known tasks before report approval, with the current preparation revision. Approved stages use ordinary task amendments.");
|
|
119250
119644
|
}
|
|
119251
|
-
if (!stage) {
|
|
119645
|
+
if (!stage || stage.gaps.length) {
|
|
119252
119646
|
await prepareCurrentProductionStage({
|
|
119253
119647
|
projectRoot: input.projectRoot,
|
|
119254
|
-
revision: input.revision,
|
|
119648
|
+
revision: stage?.id ?? input.revision,
|
|
119255
119649
|
sources: [...new Set([...plan.articles.flatMap((article) => article.sources), ...plan.pending_scopes ?? []])]
|
|
119256
119650
|
});
|
|
119257
119651
|
stage = await readProductionStage(input.projectRoot);
|
|
119258
119652
|
}
|
|
119259
119653
|
const text11 = import_yaml57.default.stringify({ ...plan, stage: stage.id });
|
|
119260
|
-
|
|
119261
|
-
|
|
119262
|
-
|
|
119263
|
-
|
|
119264
|
-
|
|
119265
|
-
|
|
119654
|
+
let result;
|
|
119655
|
+
try {
|
|
119656
|
+
result = await submitProductionPlan({
|
|
119657
|
+
projectRoot: input.projectRoot,
|
|
119658
|
+
stage: stage.id,
|
|
119659
|
+
path: fixed2.path,
|
|
119660
|
+
manifest: { path: fixed2.path, text: text11, bytes: Buffer.byteLength(text11), digest: durableContentDigest(text11) }
|
|
119661
|
+
});
|
|
119662
|
+
} catch (error) {
|
|
119663
|
+
if (error instanceof ContextError && error.detail?.reason_code === "production-planning-refresh-required") {
|
|
119664
|
+
error.detail.next_action = {
|
|
119665
|
+
command: `context action prepare-current --revision ${stage.id} --input ${input.path} --format json`,
|
|
119666
|
+
instruction: "Restore or check the listed sources if needed, then rerun this command; it checks them again and submits the same tasks."
|
|
119667
|
+
};
|
|
119668
|
+
}
|
|
119669
|
+
throw error;
|
|
119670
|
+
}
|
|
119266
119671
|
return { ...result, next_action: { command: "context status --format json" } };
|
|
119267
119672
|
}));
|
|
119268
119673
|
}
|
|
@@ -119319,8 +119724,9 @@ function registerProjectActionCommands(program2) {
|
|
|
119319
119724
|
multiAgent: options.multiAgent === true,
|
|
119320
119725
|
...options.source.length ? { sources: options.source } : {}
|
|
119321
119726
|
});
|
|
119727
|
+
const output = "stage_state" in result || options.input ? await withNextRoute(program2, root2.projectRoot, result, { managed: options.managed === true }) : result;
|
|
119322
119728
|
await new Promise((resolve8, reject) => {
|
|
119323
|
-
process.stdout.write(serializeActionCompletion(
|
|
119729
|
+
process.stdout.write(serializeActionCompletion(output, options.format), (error) => {
|
|
119324
119730
|
if (error)
|
|
119325
119731
|
reject(error);
|
|
119326
119732
|
else
|
|
@@ -119328,7 +119734,7 @@ function registerProjectActionCommands(program2) {
|
|
|
119328
119734
|
});
|
|
119329
119735
|
});
|
|
119330
119736
|
});
|
|
119331
|
-
action.command("complete-current").description("Submit minimal semantic output for the exact current workflow revision").requiredOption("--revision <revision>", "workflow revision returned by context status").requiredOption("--input <file>", "YAML/JSON input path, or - for stdin").option("--managed", "continue under explicit current-conversation managed approval").option("--multi-agent", "this caller supports coordinating multiple independent production batch directories; default is one batch").addOption(new Option("--authority <authority>").hideHelp().argParser(collectWorkflowAuthorityOption).default([])).option("--preview", "
|
|
119737
|
+
action.command("complete-current").description("Submit minimal semantic output for the exact current workflow revision").requiredOption("--revision <revision>", "workflow revision returned by context status").requiredOption("--input <file>", "YAML/JSON input path, or - for stdin").option("--managed", "continue under explicit current-conversation managed approval").option("--multi-agent", "this caller supports coordinating multiple independent production batch directories; default is one batch").addOption(new Option("--authority <authority>").hideHelp().argParser(collectWorkflowAuthorityOption).default([])).option("--preview", "check without submitting: an approved revision, every page of a prepared revision batch, or production stage article files").option("--verbose", "include the full completion and next Route inline").option("--format <format>", "output format: json | yaml", "json").action(async (options) => withSubmissionState(async () => {
|
|
119332
119738
|
const format2 = options.format;
|
|
119333
119739
|
if (format2 !== "json" && format2 !== "yaml") {
|
|
119334
119740
|
throw new ContextError(ExitCode.UserError, "--format must be json or yaml", {
|
|
@@ -119499,6 +119905,7 @@ init_repoSources();
|
|
|
119499
119905
|
var import_yaml64 = __toESM(require_dist(), 1);
|
|
119500
119906
|
|
|
119501
119907
|
// src/project/repoSourceRecovery.ts
|
|
119908
|
+
init_gitProgress();
|
|
119502
119909
|
init_cliFeedback();
|
|
119503
119910
|
init_errors3();
|
|
119504
119911
|
init_exitCode();
|
|
@@ -119696,18 +120103,18 @@ async function cloneCheckout(input) {
|
|
|
119696
120103
|
}
|
|
119697
120104
|
await mkdir42(dirname51(target), { recursive: true });
|
|
119698
120105
|
const cloneArgs = ["clone", "--no-checkout", "--depth=1", "--filter=blob:none", input.remote, target];
|
|
120106
|
+
const clone = (args) => runGitWithProgress(args, { env: { ...process.env, GIT_TERMINAL_PROMPT: "0" }, label: "git clone" });
|
|
119699
120107
|
try {
|
|
119700
|
-
await
|
|
119701
|
-
} catch {
|
|
120108
|
+
await clone(cloneArgs);
|
|
120109
|
+
} catch (first) {
|
|
119702
120110
|
await rm29(target, { recursive: true, force: true });
|
|
119703
120111
|
try {
|
|
119704
|
-
|
|
119705
|
-
|
|
119706
|
-
|
|
119707
|
-
});
|
|
120112
|
+
if (first instanceof GitProgressError && first.kind !== "failed")
|
|
120113
|
+
throw first;
|
|
120114
|
+
await clone(["clone", "--no-checkout", "--depth=1", input.remote, target]);
|
|
119708
120115
|
} catch (error) {
|
|
119709
120116
|
await rm29(target, { recursive: true, force: true });
|
|
119710
|
-
const detail = error
|
|
120117
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
119711
120118
|
throw new ContextError(ExitCode.ExternalToolError, `cannot clone registered repository: ${input.remote}`, {
|
|
119712
120119
|
category: ErrorCategory.ExternalToolFailed,
|
|
119713
120120
|
remote: input.remote,
|
|
@@ -119718,9 +120125,11 @@ async function cloneCheckout(input) {
|
|
|
119718
120125
|
}
|
|
119719
120126
|
try {
|
|
119720
120127
|
try {
|
|
119721
|
-
await
|
|
119722
|
-
} catch {
|
|
119723
|
-
|
|
120128
|
+
await runGitWithProgress(["-C", target, "fetch", "--depth=1", "--filter=blob:none", "origin", input.ref], { env: { ...process.env, GIT_TERMINAL_PROMPT: "0" }, label: "git fetch" });
|
|
120129
|
+
} catch (first) {
|
|
120130
|
+
if (first instanceof GitProgressError && first.kind !== "failed")
|
|
120131
|
+
throw first;
|
|
120132
|
+
await runGitWithProgress(["-C", target, "fetch", "--depth=1", "origin", input.ref], { env: { ...process.env, GIT_TERMINAL_PROMPT: "0" }, label: "git fetch" });
|
|
119724
120133
|
}
|
|
119725
120134
|
const sparseDirectories = input.subpaths.length > 0 && (await Promise.all(input.subpaths.map((subpath) => git4(target, ["cat-file", "-t", `${input.ref}:${subpath}`])))).every((type) => type === "tree");
|
|
119726
120135
|
if (sparseDirectories) {
|
|
@@ -121172,7 +121581,7 @@ var import_yaml60 = __toESM(require_dist(), 1);
|
|
|
121172
121581
|
// src/lib/wikiDiscoveryProvider.ts
|
|
121173
121582
|
init_larkResourceCommand();
|
|
121174
121583
|
init_larkResourceScheduler();
|
|
121175
|
-
import { spawn as
|
|
121584
|
+
import { spawn as spawn8 } from "node:child_process";
|
|
121176
121585
|
|
|
121177
121586
|
class WikiDiscoveryError extends Error {
|
|
121178
121587
|
reason;
|
|
@@ -121255,7 +121664,7 @@ function defaultRunner2(signal) {
|
|
|
121255
121664
|
failure2 = new WikiDiscoveryError("request-interrupted", true, "Wiki request was interrupted or exceeded its 30 second deadline");
|
|
121256
121665
|
terminate();
|
|
121257
121666
|
};
|
|
121258
|
-
const child =
|
|
121667
|
+
const child = spawn8(process.env.CONTEXT_LARK_CLI_BIN?.trim() || "lark-cli", args, {
|
|
121259
121668
|
...options?.cwd ? { cwd: options.cwd } : {},
|
|
121260
121669
|
detached: process.platform !== "win32",
|
|
121261
121670
|
stdio: ["ignore", "pipe", "pipe"],
|
|
@@ -121893,6 +122302,35 @@ async function yamlReferences(input) {
|
|
|
121893
122302
|
collectStrings(parsed, strings);
|
|
121894
122303
|
return strings.some((value) => stringReferencesSource(value, input.source));
|
|
121895
122304
|
}
|
|
122305
|
+
var SOURCES_REGISTRY_EXCLUSION2 = Symbol.for("c4a.context.sources-registry-exclusion");
|
|
122306
|
+
function projectReferences(project, source2) {
|
|
122307
|
+
const references = [];
|
|
122308
|
+
project.sources.forEach((declared, index3) => {
|
|
122309
|
+
if (sourceIdentity(declared) === source2.name)
|
|
122310
|
+
references.push(`project.sources[${index3}]`);
|
|
122311
|
+
});
|
|
122312
|
+
project.phases.forEach((phase, index3) => {
|
|
122313
|
+
const direct = "source" in phase && sourceIdentity(phase.source) === source2.name;
|
|
122314
|
+
const resource = phase.reads.some((read) => resourceReferencesSource(read, source2));
|
|
122315
|
+
if (direct || resource)
|
|
122316
|
+
references.push(`project.phases[${index3}] (${phase.id})`);
|
|
122317
|
+
});
|
|
122318
|
+
return references;
|
|
122319
|
+
}
|
|
122320
|
+
async function declaredReferences(projectRoot2, source2) {
|
|
122321
|
+
const global = globalThis;
|
|
122322
|
+
const previous3 = global[SOURCES_REGISTRY_EXCLUSION2];
|
|
122323
|
+
global[SOURCES_REGISTRY_EXCLUSION2] = new Set([source2.name]);
|
|
122324
|
+
let project;
|
|
122325
|
+
try {
|
|
122326
|
+
project = (await loadContextProjectModule(projectRoot2)).project;
|
|
122327
|
+
} catch {
|
|
122328
|
+
project = undefined;
|
|
122329
|
+
} finally {
|
|
122330
|
+
global[SOURCES_REGISTRY_EXCLUSION2] = previous3;
|
|
122331
|
+
}
|
|
122332
|
+
return projectReferences(project ?? (await loadContextProjectModule(projectRoot2)).project, source2);
|
|
122333
|
+
}
|
|
121896
122334
|
async function collectSourceReferences(projectRoot2, source2) {
|
|
121897
122335
|
const references = new Set;
|
|
121898
122336
|
const { currentLedger: currentLedger2, currentSpec: currentSpec2 } = await Promise.resolve().then(() => (init_indexerMainRunStoreRecords(), exports_indexerMainRunStoreRecords));
|
|
@@ -121904,17 +122342,8 @@ async function collectSourceReferences(projectRoot2, source2) {
|
|
|
121904
122342
|
if (values2.some((value) => stringReferencesSource(value, source2)))
|
|
121905
122343
|
references.add(`active Indexer ${entry.indexer_id}`);
|
|
121906
122344
|
}
|
|
121907
|
-
const
|
|
121908
|
-
|
|
121909
|
-
if (sourceIdentity(declared) === source2.name)
|
|
121910
|
-
references.add(`project.sources[${index3}]`);
|
|
121911
|
-
});
|
|
121912
|
-
loaded.project.phases.forEach((phase, index3) => {
|
|
121913
|
-
const direct = "source" in phase && sourceIdentity(phase.source) === source2.name;
|
|
121914
|
-
const resource = phase.reads.some((read) => resourceReferencesSource(read, source2));
|
|
121915
|
-
if (direct || resource)
|
|
121916
|
-
references.add(`project.phases[${index3}] (${phase.id})`);
|
|
121917
|
-
});
|
|
122345
|
+
for (const reference2 of await declaredReferences(projectRoot2, source2))
|
|
122346
|
+
references.add(reference2);
|
|
121918
122347
|
for (const candidate of await readCandidateRecords(projectRoot2)) {
|
|
121919
122348
|
if (candidate.source_refs.some((ref2) => stringReferencesSource(ref2, source2))) {
|
|
121920
122349
|
references.add(`draft candidate ${candidate.candidate_id}`);
|
|
@@ -124919,6 +125348,12 @@ function isDirectCliInvocation(metaUrl, argv1) {
|
|
|
124919
125348
|
}
|
|
124920
125349
|
var isDirectInvocation = typeof process !== "undefined" && isDirectCliInvocation(import.meta.url, process.argv[1]);
|
|
124921
125350
|
if (isDirectInvocation) {
|
|
125351
|
+
for (const stream of [process.stdout, process.stderr]) {
|
|
125352
|
+
stream.on("error", (error) => {
|
|
125353
|
+
if (error.code !== "EPIPE")
|
|
125354
|
+
throw error;
|
|
125355
|
+
});
|
|
125356
|
+
}
|
|
124922
125357
|
cli_main().catch((err) => {
|
|
124923
125358
|
handleCliFailure(err);
|
|
124924
125359
|
});
|