@tokenroll/llmdoc 3.5.3 → 3.6.0

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.
@@ -3,15 +3,15 @@ import { CliError } from "./errors.js";
3
3
  const DOCUMENT_KINDS = ["architecture", "guide", "reference"];
4
4
  export function parseDocTargetShape(repoRelativePath) {
5
5
  if (!repoRelativePath.startsWith("llmdoc/")) {
6
- throw new CliError("目标必须位于 llmdoc/ 下。");
6
+ throw new CliError("The target must be under llmdoc/.");
7
7
  }
8
8
  if (!repoRelativePath.endsWith(".mdx")) {
9
- throw new CliError("目标必须是 .mdx 文档。");
9
+ throw new CliError("The target must be an .mdx document.");
10
10
  }
11
11
  const llmdocPath = repoRelativePath.slice("llmdoc/".length);
12
12
  const segments = llmdocPath.split("/");
13
13
  if (segments.length !== 1 && segments.length !== 2) {
14
- throw new CliError("V3 文档路径仅允许根 singleton 或 topic/file 两层。");
14
+ throw new CliError("V3 document paths allow only a root singleton or topic/file depth.");
15
15
  }
16
16
  const basename = path.posix.basename(llmdocPath);
17
17
  const topic = segments.length === 2 ? (segments[0] ?? null) : null;
@@ -28,7 +28,7 @@ export function parseDocTargetShape(repoRelativePath) {
28
28
  export function assertDocKindMatchesShape(shape) {
29
29
  // V3 不设入口节点:topic 即纯目录,描述由 CLI 从文档 front matter 聚合。
30
30
  if (shape.basename === "index.mdx") {
31
- throw new CliError("V3 不使用 index.mdx 入口节点;请使用普通命名,topic 描述由 llmdoc tree 聚合。");
31
+ throw new CliError("V3 does not use index.mdx entry nodes. Use a regular name; llmdoc tree derives topic descriptions.");
32
32
  }
33
33
  }
34
34
  export function validateMoveTargetShape(shape) {
@@ -46,5 +46,5 @@ export function assertDocumentKind(input) {
46
46
  if (DOCUMENT_KINDS.includes(input)) {
47
47
  return input;
48
48
  }
49
- throw new CliError(`非法 kind: ${input}。允许值: ${DOCUMENT_KINDS.join(", ")}`);
49
+ throw new CliError(`Invalid kind: ${input}. Allowed values: ${DOCUMENT_KINDS.join(", ")}`);
50
50
  }
package/dist/lib/fs.js CHANGED
@@ -6,7 +6,7 @@ export function findProjectRoot(startDir) {
6
6
  if (found) {
7
7
  return found;
8
8
  }
9
- throw new CliError("未找到 llmdoc/ 目录,请在仓库内运行该命令。", 2);
9
+ throw new CliError("No llmdoc/ directory was found. Run this command inside an llmdoc repository.", 2);
10
10
  }
11
11
  // new 是唯一允许在 llmdoc/ 尚不存在时运行的结构改写命令。
12
12
  // 首次创建严格锁定最近 Git 根;无 Git 但已有 llmdoc/ 时保留原有兼容路径。
@@ -20,7 +20,7 @@ export function findProjectRootForNew(startDir) {
20
20
  if (gitRoot) {
21
21
  return gitRoot;
22
22
  }
23
- throw new CliError("未找到 Git 仓库;请先运行 `git init`,再运行 `llmdoc new`。", 2);
23
+ throw new CliError("No Git repository was found. Run `git init` before `llmdoc new`.", 2);
24
24
  }
25
25
  export function findProjectRootOrNull(startDir) {
26
26
  const start = path.resolve(startDir);
@@ -66,14 +66,14 @@ function isDirectory(candidate) {
66
66
  export function normalizeRepoRelativePath(input) {
67
67
  const normalized = input.replaceAll("\\", "/");
68
68
  if (!normalized || normalized.startsWith("/") || normalized.includes("\0")) {
69
- throw new CliError(`非法路径: ${input}`);
69
+ throw new CliError(`Invalid path: ${input}`);
70
70
  }
71
71
  const parts = normalized.split("/").filter((part) => part !== ".");
72
72
  if (parts.length === 0) {
73
- throw new CliError(`非法路径: ${input}`);
73
+ throw new CliError(`Invalid path: ${input}`);
74
74
  }
75
75
  if (parts.some((part) => part === ".." || part === "")) {
76
- throw new CliError(`路径必须是仓库内规范化相对路径: ${input}`);
76
+ throw new CliError(`Path must be a normalized repository-relative path: ${input}`);
77
77
  }
78
78
  return parts.join("/");
79
79
  }
@@ -84,19 +84,19 @@ export function resolveInsideRoot(rootDir, repoRelativePath, options) {
84
84
  const nearestExistingAncestor = findNearestExistingAncestor(candidate);
85
85
  const ancestorRealPath = fs.realpathSync(nearestExistingAncestor);
86
86
  if (!isWithinRoot(rootRealPath, ancestorRealPath)) {
87
- throw new CliError(`路径越界或经由符号链接逃逸: ${repoRelativePath}`);
87
+ throw new CliError(`Path escapes the repository directly or through a symlink: ${repoRelativePath}`);
88
88
  }
89
89
  if (fs.existsSync(candidate)) {
90
90
  const candidateRealPath = fs.realpathSync(candidate);
91
91
  if (!isWithinRoot(rootRealPath, candidateRealPath)) {
92
- throw new CliError(`路径越界或经由符号链接逃逸: ${repoRelativePath}`);
92
+ throw new CliError(`Path escapes the repository directly or through a symlink: ${repoRelativePath}`);
93
93
  }
94
94
  return candidateRealPath;
95
95
  }
96
96
  if (options?.allowMissing) {
97
97
  return candidate;
98
98
  }
99
- throw new CliError(`路径不存在: ${repoRelativePath}`);
99
+ throw new CliError(`Path does not exist: ${repoRelativePath}`);
100
100
  }
101
101
  export function isWithinRoot(rootRealPath, candidateRealPath) {
102
102
  return candidateRealPath === rootRealPath || candidateRealPath.startsWith(`${rootRealPath}${path.sep}`);
package/dist/lib/git.js CHANGED
@@ -8,7 +8,7 @@ function runGit(rootDir, args) {
8
8
  encoding: "utf8"
9
9
  });
10
10
  if (result.status !== 0) {
11
- throw new CliError((result.stderr || result.stdout || "git 命令失败").trim());
11
+ throw new CliError((result.stderr || result.stdout || "Git command failed").trim());
12
12
  }
13
13
  return result.stdout.trim();
14
14
  }
@@ -48,7 +48,7 @@ export function readGitState(rootDir, baselineRevision) {
48
48
  stagedPaths: [],
49
49
  unstagedPaths: [],
50
50
  untrackedPaths: [],
51
- degradedReason: "当前目录不是 git 仓库,状态面降级为不可用。"
51
+ degradedReason: "The current directory is not a Git repository; state diagnostics are unavailable."
52
52
  };
53
53
  }
54
54
  const headRevision = runGitSafe(rootDir, ["rev-parse", "--verify", "HEAD"]);
@@ -65,10 +65,10 @@ export function readGitState(rootDir, baselineRevision) {
65
65
  : null;
66
66
  let degradedReason = null;
67
67
  if (!headRevision) {
68
- degradedReason = isUnbornHead(rootDir) ? "HEAD 尚无 commit(当前分支尚未创建首次提交)。" : "无法解析 HEAD commit。";
68
+ degradedReason = isUnbornHead(rootDir) ? "HEAD has no commit (the current branch is unborn)." : "Unable to resolve the HEAD commit.";
69
69
  }
70
70
  else if (baselineRevision && !gitCommitExists(rootDir, baselineRevision)) {
71
- degradedReason = `baseline.revision 不存在于当前 git 历史: ${baselineRevision}`;
71
+ degradedReason = `baseline.revision does not exist in current Git history: ${baselineRevision}`;
72
72
  }
73
73
  return {
74
74
  available: true,
@@ -116,10 +116,10 @@ export function readCommitsWithChangedPathsSince(rootDir, revision, headRevision
116
116
  }
117
117
  export function canAdvanceRevisions(gitState) {
118
118
  if (!gitState.available || !gitState.headRevision) {
119
- return { ok: false, reason: gitState.degradedReason ?? "git 状态不可用。" };
119
+ return { ok: false, reason: gitState.degradedReason ?? "Git state is unavailable." };
120
120
  }
121
121
  if (gitState.inProgressOperation) {
122
- return { ok: false, reason: `${gitState.inProgressOperation} 进行中,不推进 revision。` };
122
+ return { ok: false, reason: `${gitState.inProgressOperation} is in progress; revisions cannot advance.` };
123
123
  }
124
124
  return { ok: true };
125
125
  }
@@ -64,27 +64,27 @@ export function validateCodeRefTags(body) {
64
64
  const raw = match[0] ?? "";
65
65
  const attributes = match[1] ?? "";
66
66
  if (!raw.endsWith("/>")) {
67
- issues.push("CodeRef 必须使用自闭合写法 <CodeRef ... />。");
67
+ issues.push("CodeRef must use the self-closing form <CodeRef ... />.");
68
68
  continue;
69
69
  }
70
70
  const attrMatches = [...attributes.matchAll(/([A-Za-z]+)="([^"]*)"/g)];
71
71
  const consumed = attrMatches.map((attr) => attr[0]).join(" ").trim();
72
72
  const normalized = attributes.replace(/\s+/g, " ").trim().replace(/\/$/, "").trim();
73
73
  if (normalized && consumed !== normalized) {
74
- issues.push("CodeRef 仅允许双引号属性 path 和可选 symbol。");
74
+ issues.push("CodeRef allows only the double-quoted path attribute and optional symbol attribute.");
75
75
  continue;
76
76
  }
77
77
  const names = attrMatches.map((attr) => attr[1]);
78
78
  const duplicates = names.filter((name, index) => names.indexOf(name) !== index);
79
79
  if (duplicates.length > 0) {
80
- issues.push(`CodeRef 存在重复属性: ${[...new Set(duplicates)].join(", ")}`);
80
+ issues.push(`CodeRef contains duplicate attributes: ${[...new Set(duplicates)].join(", ")}`);
81
81
  }
82
82
  if (!names.includes("path")) {
83
- issues.push("CodeRef 缺少必填属性 path。");
83
+ issues.push("CodeRef is missing the required path attribute.");
84
84
  }
85
85
  for (const name of names) {
86
86
  if (name !== "path" && name !== "symbol") {
87
- issues.push(`CodeRef 存在未知属性: ${name}`);
87
+ issues.push(`CodeRef contains an unknown attribute: ${name}`);
88
88
  }
89
89
  }
90
90
  }
@@ -13,7 +13,7 @@ export function assertOutputSchema(name, payload) {
13
13
  if (ok) {
14
14
  return;
15
15
  }
16
- throw new CliError(`内部输出契约错误(${name}): ${formatErrors(validator.errors ?? [])}`, 70);
16
+ throw new CliError(`Internal output contract error (${name}): ${formatErrors(validator.errors ?? [])}`, 70);
17
17
  }
18
18
  export function stringifyValidatedOutput(name, payload) {
19
19
  assertOutputSchema(name, payload);
@@ -25,7 +25,7 @@ export function parseAndValidateJsonString(name, input) {
25
25
  payload = JSON.parse(input);
26
26
  }
27
27
  catch (error) {
28
- throw new CliError(`内部输出契约错误(${name}): JSON 解析失败: ${error.message}`, 70);
28
+ throw new CliError(`Internal output contract error (${name}): JSON parse failed: ${error.message}`, 70);
29
29
  }
30
30
  return stringifyValidatedOutput(name, payload);
31
31
  }
@@ -36,7 +36,7 @@ function getValidator(name) {
36
36
  }
37
37
  const defs = schemaDocument.$defs;
38
38
  if (!defs?.[name]) {
39
- throw new CliError(`内部输出契约错误: 未找到 schema ${name}`, 70);
39
+ throw new CliError(`Internal output contract error: schema ${name} was not found`, 70);
40
40
  }
41
41
  const validator = ajv.compile({
42
42
  $schema: "https://json-schema.org/draft/2020-12/schema",
@@ -9,7 +9,7 @@ export function packageRootFromImport(metaUrl) {
9
9
  }
10
10
  const parent = path.dirname(current);
11
11
  if (parent === current) {
12
- throw new Error(`无法从 ${metaUrl} 向上定位 package root。`);
12
+ throw new Error(`Unable to locate the package root above ${metaUrl}.`);
13
13
  }
14
14
  current = parent;
15
15
  }
@@ -6,7 +6,7 @@ export function paginate({ items, estimate, options }) {
6
6
  const budget = options.budget ?? DEFAULT_BUDGET;
7
7
  const offset = decodeCursor(options.cursor);
8
8
  if (offset < 0 || offset > items.length) {
9
- throw new CliError("cursor 非法或已失效。");
9
+ throw new CliError("The cursor is invalid or expired.");
10
10
  }
11
11
  const selected = [];
12
12
  let usedBudget = 0;
@@ -60,6 +60,6 @@ function decodeCursor(cursor) {
60
60
  return payload.offset;
61
61
  }
62
62
  catch {
63
- throw new CliError("cursor 非法或已损坏。");
63
+ throw new CliError("The cursor is invalid or corrupted.");
64
64
  }
65
65
  }
@@ -11,6 +11,7 @@ function readSchema(fileName) {
11
11
  }
12
12
  const docValidator = ajv.compile(readSchema("doc-frontmatter.schema.json"));
13
13
  const metaValidator = ajv.compile(readSchema("meta.schema.json"));
14
+ const configValidator = ajv.compile(readSchema("config.schema.json"));
14
15
  export function validateDocFrontmatter(input) {
15
16
  const ok = docValidator(input);
16
17
  if (ok) {
@@ -33,6 +34,13 @@ export function validateMeta(input) {
33
34
  }
34
35
  return errors;
35
36
  }
37
+ export function validateLlmdocConfig(input) {
38
+ const ok = configValidator(input);
39
+ if (ok) {
40
+ return [];
41
+ }
42
+ return (configValidator.errors ?? []).map(formatAjvError);
43
+ }
36
44
  function formatAjvError(error) {
37
45
  return `${error.instancePath || "/"} ${error.message ?? "invalid"}`;
38
46
  }
package/dist/lib/state.js CHANGED
@@ -2,6 +2,7 @@ import fs from "node:fs";
2
2
  import { canAdvanceRevisions, gitCommitExists, readChangedPathsSince, readGitState } from "./git.js";
3
3
  import { normalizeRepoRelativePath } from "./fs.js";
4
4
  import { matchesCodePathPattern } from "./search.js";
5
+ import { LLMDOC_CONFIG_FILENAME } from "./config.js";
5
6
  export function analyzeDelta(workspace, scope) {
6
7
  const git = readWorkspaceGitState(workspace);
7
8
  const ignorePatterns = loadIgnorePatterns(workspace.rootDir);
@@ -30,8 +31,8 @@ export function analyzeDelta(workspace, scope) {
30
31
  if (revisionInvalid) {
31
32
  invalidRevisionDocuments.push(document);
32
33
  invalidRevisionReasons.push(!validatedRevision
33
- ? `文档 ${document.llmdocPath} 缺少 validatedRevision`
34
- : `文档 ${document.llmdocPath} 的 validatedRevision 不存在于当前 git 历史: ${validatedRevision}`);
34
+ ? `Document ${document.llmdocPath} has no validatedRevision`
35
+ : `Document ${document.llmdocPath} has a validatedRevision that does not exist in current Git history: ${validatedRevision}`);
35
36
  }
36
37
  const changedCommittedPaths = !revisionInvalid && git.headRevision && validatedRevision !== git.headRevision
37
38
  ? getChangedPathsForRevision(workspace.rootDir, validatedRevision, git.headRevision, changedPathsByRevision).filter((filePath) => isSurface(filePath) && documentMatchesPath(document, filePath))
@@ -71,26 +72,24 @@ export function analyzeDelta(workspace, scope) {
71
72
  const unmappedDirtyPaths = dirtyPaths.filter((filePath) => !workspace.documents.some((document) => documentMatchesPath(document, filePath)));
72
73
  const reasons = [];
73
74
  if (!git.available || git.degradedReason) {
74
- reasons.push(git.degradedReason ?? "git 状态不可用");
75
+ reasons.push(git.degradedReason ?? "Git state is unavailable");
75
76
  }
76
77
  if (invalidRevisionReasons.length > 0) {
77
78
  reasons.push(...invalidRevisionReasons);
78
79
  }
79
80
  if (unmappedCommittedPaths.length > 0 || unmappedDirtyPaths.length > 0) {
80
- reasons.push("存在未映射代码路径");
81
+ reasons.push("Unmapped code paths exist");
81
82
  }
82
83
  if (needsReview.length > 0) {
83
- reasons.push("存在 requires 反向一跳需复核文档");
84
+ reasons.push("Documents in the reverse requires closure need review");
84
85
  }
85
86
  if (directImpacts.length > 8) {
86
- reasons.push("受影响文档过多,建议 deep");
87
+ reasons.push("Too many documents are impacted; deep mode is recommended");
87
88
  }
88
89
  if (dirtyDocuments.length > 0) {
89
- reasons.push("存在未提交 dirty 关联代码");
90
+ reasons.push("Mapped implementation code has uncommitted changes");
90
91
  }
91
- const suggestedMode = reasons.some((reason) => ["未映射", "需复核", "过多", "dirty", "不可用", "不存在于当前 git 历史", "validatedRevision", "缺少"].some((keyword) => reason.includes(keyword)))
92
- ? "deep"
93
- : "light";
92
+ const suggestedMode = reasons.length > 0 ? "deep" : "light";
94
93
  return {
95
94
  git,
96
95
  impacts: directImpacts.sort((left, right) => left.document.llmdocPath.localeCompare(right.document.llmdocPath)),
@@ -124,7 +123,7 @@ export function parseScope(values, workspace) {
124
123
  continue;
125
124
  }
126
125
  if (!workspace.documentsByLlmdocPath.has(normalized)) {
127
- throw new Error(`scope 未命中任何 topic 或文档: ${raw}`);
126
+ throw new Error(`Scope did not match any topic or document: ${raw}`);
128
127
  }
129
128
  documentPaths.add(normalized);
130
129
  }
@@ -153,7 +152,7 @@ export function computeGrowthState(workspace) {
153
152
  export function assertRevisionAdvancePreconditions(input) {
154
153
  const { workspace, llmdocPaths, updateAll } = input;
155
154
  if (!workspace.meta) {
156
- throw new Error("缺少 meta.json");
155
+ throw new Error("meta.json is missing");
157
156
  }
158
157
  const git = readWorkspaceGitState(workspace);
159
158
  const advance = canAdvanceRevisions(git);
@@ -171,8 +170,8 @@ export function assertRevisionAdvancePreconditions(input) {
171
170
  });
172
171
  if (blocked.length > 0) {
173
172
  throw new Error(updateAll
174
- ? `全量 fingerprint 时以下文档关联代码存在 dirty 变更,不能伪造 revision: ${blocked.join(", ")}`
175
- : `以下文档关联代码存在 dirty 变更,不能伪造 revision: ${blocked.join(", ")}`);
173
+ ? `A full fingerprint cannot advance while mapped code for these documents is dirty: ${blocked.join(", ")}`
174
+ : `Cannot advance revisions while mapped code for these documents is dirty: ${blocked.join(", ")}`);
176
175
  }
177
176
  return { git, targetPaths };
178
177
  }
@@ -257,7 +256,9 @@ export function loadIgnorePatterns(rootDir) {
257
256
  return patterns;
258
257
  }
259
258
  export function isImplementationSurfacePath(repoRelativePath, ignorePatterns = []) {
260
- if (repoRelativePath.startsWith("llmdoc/") || repoRelativePath.startsWith(".llmdoc-tmp/")) {
259
+ if (repoRelativePath === LLMDOC_CONFIG_FILENAME ||
260
+ repoRelativePath.startsWith("llmdoc/") ||
261
+ repoRelativePath.startsWith(".llmdoc-tmp/")) {
261
262
  return false;
262
263
  }
263
264
  const basename = repoRelativePath.split("/").pop() ?? repoRelativePath;
@@ -48,7 +48,7 @@ export function createViewerRequestHandler(rootDir) {
48
48
  // 仅按扫描产生的 canonical llmdocPath 查表,不接受任意文件系统路径。
49
49
  const document = workspace.documentsByLlmdocPath.get(docPath);
50
50
  if (!document) {
51
- sendJson(response, 404, { error: `未找到文档: ${docPath}` }, headOnly);
51
+ sendJson(response, 404, { error: `Document not found: ${docPath}` }, headOnly);
52
52
  return;
53
53
  }
54
54
  sendJson(response, 200, {
@@ -73,7 +73,7 @@ function sendStaticAsset(response, assetsRoot, asset, headOnly) {
73
73
  // fileName 只可能来自上方常量白名单;请求值不会参与路径解析。
74
74
  const assetPath = path.join(assetsRoot, asset.fileName);
75
75
  if (!fs.existsSync(assetPath)) {
76
- throw new CliError(`viewer 资产缺失: ${asset.fileName}`);
76
+ throw new CliError(`Viewer asset is missing: ${asset.fileName}`);
77
77
  }
78
78
  sendBody(response, 200, fs.readFileSync(assetPath), asset.contentType, headOnly);
79
79
  }
@@ -9,10 +9,11 @@ import { normalizeRepoRelativePath, repoPath, resolveInsideRoot } from "./fs.js"
9
9
  import { gitCommitExists, isShallowRepository } from "./git.js";
10
10
  import { matchesCodePathPattern } from "./search.js";
11
11
  import { validateDocFrontmatter, validateMeta } from "./schema.js";
12
+ import { loadLlmdocConfig } from "./config.js";
12
13
  export function loadWorkspace(rootDir) {
13
14
  const configuredLlmdocDir = path.join(rootDir, "llmdoc");
14
15
  if (!fs.existsSync(configuredLlmdocDir) || !fs.statSync(configuredLlmdocDir).isDirectory()) {
15
- throw new CliError("仓库内不存在 llmdoc/ 目录。", 2);
16
+ throw new CliError("The repository does not contain an llmdoc/ directory.", 2);
16
17
  }
17
18
  resolveInsideRoot(rootDir, "llmdoc");
18
19
  const llmdocDir = configuredLlmdocDir;
@@ -37,6 +38,7 @@ export function loadWorkspace(rootDir) {
37
38
  rootSingletons.sort((left, right) => left.llmdocPath.localeCompare(right.llmdocPath));
38
39
  const metaPath = path.join(llmdocDir, "meta.json");
39
40
  const meta = loadMeta(metaPath, preloadIssues);
41
+ const llmdocConfig = loadLlmdocConfig(rootDir, documentsByLlmdocPath);
40
42
  return {
41
43
  rootDir,
42
44
  llmdocDir,
@@ -46,6 +48,7 @@ export function loadWorkspace(rootDir) {
46
48
  topics,
47
49
  rootSingletons,
48
50
  meta,
51
+ llmdocConfig,
49
52
  preloadIssues
50
53
  };
51
54
  }
@@ -59,7 +62,7 @@ function scanDocuments(rootDir, llmdocDir, preloadIssues) {
59
62
  severity: "error",
60
63
  code: "file.extension.invalid",
61
64
  path: repoRelativePath,
62
- message: "llmdoc/ 下仅允许 .mdx 文档与根级唯一 meta.json。"
65
+ message: "llmdoc/ allows only .mdx documents and one root-level meta.json file."
63
66
  });
64
67
  }
65
68
  return;
@@ -74,7 +77,7 @@ function scanDocuments(rootDir, llmdocDir, preloadIssues) {
74
77
  severity: "error",
75
78
  code: "frontmatter.parse",
76
79
  path: repoRelativePath,
77
- message: `front matter 解析失败: ${error.message}`
80
+ message: `Front matter parse failed: ${error.message}`
78
81
  });
79
82
  return;
80
83
  }
@@ -125,7 +128,7 @@ function loadMeta(metaPath, preloadIssues) {
125
128
  severity: "error",
126
129
  code: "meta.parse",
127
130
  path: "llmdoc/meta.json",
128
- message: `meta.json 解析失败: ${error.message}`
131
+ message: `meta.json parse failed: ${error.message}`
129
132
  });
130
133
  return null;
131
134
  }
@@ -136,7 +139,7 @@ function loadMeta(metaPath, preloadIssues) {
136
139
  severity: "error",
137
140
  code: "meta.invalid",
138
141
  path: "llmdoc/meta.json",
139
- message: `meta.json 非法: ${error}`
142
+ message: `Invalid meta.json: ${error}`
140
143
  });
141
144
  }
142
145
  return null;
@@ -145,13 +148,14 @@ function loadMeta(metaPath, preloadIssues) {
145
148
  }
146
149
  export function validateWorkspace(workspace) {
147
150
  const issues = [...workspace.preloadIssues];
151
+ issues.push(...workspace.llmdocConfig.issues);
148
152
  const seenDocPaths = new Set();
149
153
  if (!workspace.meta) {
150
154
  issues.push({
151
155
  severity: "error",
152
156
  code: "meta.missing",
153
157
  path: "llmdoc/meta.json",
154
- message: "缺少 llmdoc/meta.json。请运行 `npx -y @tokenroll/llmdoc init-state` 建立台账(若仓库尚无提交,请先创建首次 Git 提交)。"
158
+ message: "llmdoc/meta.json is missing. Run `npx -y @tokenroll/llmdoc init-state` to create the ledger (create the initial Git commit first if the repository has no commits)."
155
159
  });
156
160
  }
157
161
  for (const document of workspace.documents) {
@@ -162,7 +166,7 @@ export function validateWorkspace(workspace) {
162
166
  severity: "error",
163
167
  code: "frontmatter.invalid",
164
168
  path: document.repoPath,
165
- message: `front matter 非法: ${error}`
169
+ message: `Invalid front matter: ${error}`
166
170
  });
167
171
  }
168
172
  try {
@@ -183,7 +187,7 @@ export function validateWorkspace(workspace) {
183
187
  severity: "error",
184
188
  code: "hierarchy.nested",
185
189
  path: document.repoPath,
186
- message: "topic 下不允许继续嵌套子目录。"
190
+ message: "A topic cannot contain nested subdirectories."
187
191
  });
188
192
  }
189
193
  const mdxBodyErrors = validateMdxBody(document.body);
@@ -200,7 +204,7 @@ export function validateWorkspace(workspace) {
200
204
  severity: "warning",
201
205
  code: "link.wikilink",
202
206
  path: document.repoPath,
203
- message: "正文包含 [[wikilink]] 语法;llmdoc 不解析它,请改用标准 Markdown 相对链接。"
207
+ message: "The body contains [[wikilink]] syntax, which llmdoc does not parse. Use a standard relative Markdown link."
204
208
  });
205
209
  }
206
210
  for (const relationPath of document.frontmatter.relations?.requires ?? []) {
@@ -218,7 +222,7 @@ export function validateWorkspace(workspace) {
218
222
  severity: "error",
219
223
  code: "relations.requires.missing",
220
224
  path: document.repoPath,
221
- message: `requires 指向不存在的文档: ${relationPath}`
225
+ message: `requires points to a missing document: ${relationPath}`
222
226
  });
223
227
  }
224
228
  }
@@ -237,7 +241,7 @@ export function validateWorkspace(workspace) {
237
241
  severity: "error",
238
242
  code: "relations.related.missing",
239
243
  path: document.repoPath,
240
- message: `related 指向不存在的文档: ${relationPath}`
244
+ message: `related points to a missing document: ${relationPath}`
241
245
  });
242
246
  }
243
247
  }
@@ -249,7 +253,7 @@ export function validateWorkspace(workspace) {
249
253
  severity: "error",
250
254
  code: "link.invalid-path",
251
255
  path: document.repoPath,
252
- message: `正文链接非法: ${linkTarget} (${normalizedLink.message})`
256
+ message: `Invalid body link: ${linkTarget} (${normalizedLink.message})`
253
257
  });
254
258
  }
255
259
  else if (!workspace.documentsByLlmdocPath.has(normalizedLink.value)) {
@@ -257,7 +261,7 @@ export function validateWorkspace(workspace) {
257
261
  severity: "error",
258
262
  code: "link.missing",
259
263
  path: document.repoPath,
260
- message: `正文链接悬空: ${linkTarget}`
264
+ message: `Body link points to a missing document: ${linkTarget}`
261
265
  });
262
266
  }
263
267
  }
@@ -276,7 +280,7 @@ export function validateWorkspace(workspace) {
276
280
  severity: "error",
277
281
  code: "coderef.path.missing",
278
282
  path: document.repoPath,
279
- message: `CodeRef path 不存在: ${codeRef.path}`
283
+ message: `CodeRef path does not exist: ${codeRef.path}`
280
284
  });
281
285
  }
282
286
  }
@@ -295,7 +299,7 @@ export function validateWorkspace(workspace) {
295
299
  severity: "error",
296
300
  code: "code.paths.missing",
297
301
  path: document.repoPath,
298
- message: `code.paths 指向不存在的路径: ${codePath}`
302
+ message: `code.paths points to a missing path: ${codePath}`
299
303
  });
300
304
  }
301
305
  else if (normalized.isGlob &&
@@ -304,7 +308,7 @@ export function validateWorkspace(workspace) {
304
308
  severity: "error",
305
309
  code: "code.paths.unmatched",
306
310
  path: document.repoPath,
307
- message: `code.paths glob 未命中任何现有文件: ${codePath}`
311
+ message: `code.paths glob matches no existing files: ${codePath}`
308
312
  });
309
313
  }
310
314
  }
@@ -313,7 +317,7 @@ export function validateWorkspace(workspace) {
313
317
  severity: "warning",
314
318
  code: "size.line-warning",
315
319
  path: document.repoPath,
316
- message: `文档 ${document.lineCount} 行,超过建议上限 ${DOC_LINE_WARNING_LIMIT} 行。`
320
+ message: `The document has ${document.lineCount} lines, exceeding the recommended limit of ${DOC_LINE_WARNING_LIMIT}.`
317
321
  });
318
322
  }
319
323
  }
@@ -323,7 +327,7 @@ export function validateWorkspace(workspace) {
323
327
  severity: "warning",
324
328
  code: "topic.empty",
325
329
  path: `llmdoc/${topic}`,
326
- message: "topic 目录为空。"
330
+ message: "The topic directory is empty."
327
331
  });
328
332
  }
329
333
  }
@@ -332,13 +336,13 @@ export function validateWorkspace(workspace) {
332
336
  // 否则任何 fetch-depth:1 的 CI 都会误报陈旧。
333
337
  const shallow = isShallowRepository(workspace.rootDir);
334
338
  const revisionSeverity = shallow ? "warning" : "error";
335
- const shallowHint = shallow ? "(shallow clone;完整校验请用 fetch-depth: 0 或 git fetch --unshallow)" : "";
339
+ const shallowHint = shallow ? " (shallow clone; use fetch-depth: 0 or git fetch --unshallow for complete validation)" : "";
336
340
  if (!gitCommitExists(workspace.rootDir, workspace.meta.baseline.revision)) {
337
341
  issues.push({
338
342
  severity: revisionSeverity,
339
343
  code: "meta.baseline.revision.missing",
340
344
  path: "llmdoc/meta.json",
341
- message: `baseline.revision 不存在于当前 git 历史: ${workspace.meta.baseline.revision}${shallowHint}`
345
+ message: `baseline.revision does not exist in current Git history: ${workspace.meta.baseline.revision}${shallowHint}`
342
346
  });
343
347
  }
344
348
  const metaPaths = Object.keys(workspace.meta.documents).sort();
@@ -349,7 +353,7 @@ export function validateWorkspace(workspace) {
349
353
  severity: "error",
350
354
  code: "meta.entry.missing",
351
355
  path: `llmdoc/${docPath}`,
352
- message: "meta.json 缺少对应 documents entry。可用 `llmdoc adopt <path>` 无损登记。"
356
+ message: "meta.json is missing the corresponding documents entry. Use `llmdoc adopt <path>` to register it without rewriting the document."
353
357
  });
354
358
  }
355
359
  }
@@ -359,7 +363,7 @@ export function validateWorkspace(workspace) {
359
363
  severity: "error",
360
364
  code: "meta.entry.orphaned",
361
365
  path: `llmdoc/${metaPath}`,
362
- message: "meta.json 中存在孤儿 documents entry。"
366
+ message: "meta.json contains an orphan documents entry."
363
367
  });
364
368
  }
365
369
  const revision = workspace.meta.documents[metaPath]?.validatedRevision;
@@ -368,7 +372,7 @@ export function validateWorkspace(workspace) {
368
372
  severity: revisionSeverity,
369
373
  code: "meta.document.revision.missing",
370
374
  path: `llmdoc/${metaPath}`,
371
- message: `validatedRevision 不存在于当前 git 历史: ${revision}${shallowHint}`
375
+ message: `validatedRevision does not exist in current Git history: ${revision}${shallowHint}`
372
376
  });
373
377
  }
374
378
  }
@@ -382,13 +386,13 @@ function validateMdxBody(body) {
382
386
  const cleanBody = stripMarkdownLiterals(body);
383
387
  const issues = [];
384
388
  if (/^\s*import\s+/m.test(cleanBody) || /^\s*export\s+/m.test(cleanBody)) {
385
- issues.push("仅允许纯 Markdown 与自闭合 CodeRef,禁止 import/export。");
389
+ issues.push("Only plain Markdown and self-closing CodeRef tags are allowed; import/export is forbidden.");
386
390
  }
387
391
  if (/<(?!CodeRef\b)[A-Za-z][^>]*>/m.test(cleanBody) || /<\/[A-Za-z][^>]*>/m.test(cleanBody)) {
388
- issues.push("仅允许自闭合 <CodeRef ... /> 组件,禁止任意 JSX 标签。");
392
+ issues.push("Only self-closing <CodeRef ... /> components are allowed; arbitrary JSX tags are forbidden.");
389
393
  }
390
394
  if (/\{[^}\n]+\}/m.test(cleanBody)) {
391
- issues.push("禁止在正文中使用 MDX/JS 表达式。");
395
+ issues.push("MDX/JS expressions are forbidden in document bodies.");
392
396
  }
393
397
  issues.push(...validateCodeRefTags(body));
394
398
  return [...new Set(issues)];
@@ -397,10 +401,10 @@ function validateLlmdocRelativePath(input) {
397
401
  try {
398
402
  const normalized = normalizeRepoRelativePath(input);
399
403
  if (!normalized.endsWith(".mdx")) {
400
- return { ok: false, message: `路径必须指向 .mdx 文档: ${input}` };
404
+ return { ok: false, message: `Path must point to an .mdx document: ${input}` };
401
405
  }
402
406
  if (normalized.startsWith("llmdoc/")) {
403
- return { ok: false, message: `路径必须是 llmdoc/ 下相对路径而非仓库根路径: ${input}` };
407
+ return { ok: false, message: `Path must be relative to llmdoc/, not the repository root: ${input}` };
404
408
  }
405
409
  return { ok: true, value: normalized };
406
410
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokenroll/llmdoc",
3
- "version": "3.5.3",
3
+ "version": "3.6.0",
4
4
  "description": "V3 runtime CLI for llmdoc repositories",
5
5
  "homepage": "https://github.com/TokenRollAI/llmdoc",
6
6
  "repository": {