@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.
@@ -58,7 +58,7 @@ async function loadState() {
58
58
  const response = await fetch("/api/state", { headers: { accept: "application/json" } });
59
59
  if (!response.ok) throw new Error(`HTTP ${response.status}`);
60
60
  const nextState = await response.json();
61
- if (!Array.isArray(nextState.nodes) || !Array.isArray(nextState.edges)) throw new Error("服务返回了无效状态");
61
+ if (!Array.isArray(nextState.nodes) || !Array.isArray(nextState.edges)) throw new Error("The server returned invalid state");
62
62
  state = nextState;
63
63
  topicColors = createTopicColors(state.nodes);
64
64
  if (selectedDocument && !state.nodes.some((node) => node.path === selectedDocument)) selectedDocument = null;
@@ -83,15 +83,15 @@ function renderHeader() {
83
83
  const baseline = state.baseline;
84
84
  const shortRevision = baseline.revision?.slice(0, 7);
85
85
  if (!baseline.revision) {
86
- setChip(elements.statBaseline, "baseline 缺失", "bad");
86
+ setChip(elements.statBaseline, "baseline missing", "bad");
87
87
  } else if (baseline.degradedReason || baseline.relevantBehindHead === null) {
88
- setChip(elements.statBaseline, `baseline ${shortRevision} · 状态未知`, "warn");
88
+ setChip(elements.statBaseline, `baseline ${shortRevision} · status unknown`, "warn");
89
89
  } else if (baseline.relevantBehindHead > 0) {
90
- setChip(elements.statBaseline, `baseline ${shortRevision} · ${baseline.relevantBehindHead} 个源码提交待复核`, "warn");
90
+ setChip(elements.statBaseline, `baseline ${shortRevision} · ${baseline.relevantBehindHead} source commit(s) need review`, "warn");
91
91
  } else if (baseline.metadataOnlyBehind) {
92
- setChip(elements.statBaseline, `baseline ${shortRevision} · metadata-only,知识干净`, "ok");
92
+ setChip(elements.statBaseline, `baseline ${shortRevision} · metadata-only, knowledge clean`, "ok");
93
93
  } else {
94
- setChip(elements.statBaseline, `baseline ${shortRevision} · 最新`, "ok");
94
+ setChip(elements.statBaseline, `baseline ${shortRevision} · current`, "ok");
95
95
  }
96
96
 
97
97
  const validation = state.validate;
@@ -103,9 +103,9 @@ function renderHeader() {
103
103
 
104
104
  const stale = state.nodes.filter((node) => node.status !== "fresh").length;
105
105
  const unmapped = state.delta.unmappedCommittedPaths.length + state.delta.unmappedDirtyPaths.length;
106
- if (stale) setChip(elements.statDelta, `${stale} 份待同步 · 建议 ${state.delta.suggestedMode}`, "warn");
107
- else if (unmapped) setChip(elements.statDelta, `${unmapped} 个未映射变化 · 建议 ${state.delta.suggestedMode}`, "warn");
108
- else setChip(elements.statDelta, "知识面新鲜", "ok");
106
+ if (stale) setChip(elements.statDelta, `${stale} document(s) pending · ${state.delta.suggestedMode} recommended`, "warn");
107
+ else if (unmapped) setChip(elements.statDelta, `${unmapped} unmapped change(s) · ${state.delta.suggestedMode} recommended`, "warn");
108
+ else setChip(elements.statDelta, "knowledge is current", "ok");
109
109
  }
110
110
 
111
111
  function setChip(chip, text, stateClass) {
@@ -154,7 +154,7 @@ function renderSidebar() {
154
154
  fragment.append(item);
155
155
  }
156
156
  }
157
- if (!fragment.childNodes.length) fragment.append(element("div", "empty-list", "没有匹配的文档"));
157
+ if (!fragment.childNodes.length) fragment.append(element("div", "empty-list", "No matching documents"));
158
158
  elements.documentList.replaceChildren(fragment);
159
159
  }
160
160
 
@@ -195,7 +195,7 @@ async function selectDocument(path) {
195
195
  }
196
196
 
197
197
  function showError(message) {
198
- elements.error.textContent = `Viewer 加载失败:${message}`;
198
+ elements.error.textContent = `Viewer load failed: ${message}`;
199
199
  elements.error.hidden = false;
200
200
  }
201
201
 
@@ -9,7 +9,7 @@ const DROP_TAGS = new Set(["EMBED", "FORM", "IFRAME", "INPUT", "LINK", "META", "
9
9
  export function createDetailRenderer({ panel, container, onSelectDocument, getState }) {
10
10
  let activeRequest = null;
11
11
 
12
- function showPlaceholder(message = "选择一个 topic 或文档查看详情") {
12
+ function showPlaceholder(message = "Select a topic or document to view details") {
13
13
  activeRequest?.abort();
14
14
  const placeholder = element("div", "placeholder", message);
15
15
  container.replaceChildren(placeholder);
@@ -31,7 +31,7 @@ export function createDetailRenderer({ panel, container, onSelectDocument, getSt
31
31
  const description = element(
32
32
  "div",
33
33
  "desc",
34
- `${documents.length} docs · ~${tokenCount} tokens · 状态最差 ${worstStatus(documents)}`
34
+ `${documents.length} docs · ~${tokenCount} tokens · worst status ${worstStatus(documents)}`
35
35
  );
36
36
  const cards = documents.map((node) => {
37
37
  const card = element("button", "topic-doc-card");
@@ -52,7 +52,7 @@ export function createDetailRenderer({ panel, container, onSelectDocument, getSt
52
52
  activeRequest?.abort();
53
53
  activeRequest = new AbortController();
54
54
  const request = activeRequest;
55
- container.replaceChildren(element("div", "placeholder", "正在加载文档…"));
55
+ container.replaceChildren(element("div", "placeholder", "Loading document…"));
56
56
  openPanel();
57
57
 
58
58
  try {
@@ -64,7 +64,7 @@ export function createDetailRenderer({ panel, container, onSelectDocument, getSt
64
64
  } catch (error) {
65
65
  if (error instanceof DOMException && error.name === "AbortError") return;
66
66
  const message = error instanceof Error ? error.message : String(error);
67
- container.replaceChildren(element("div", "placeholder", `加载失败:${message}`));
67
+ container.replaceChildren(element("div", "placeholder", `Load failed: ${message}`));
68
68
  }
69
69
  }
70
70
 
@@ -332,11 +332,11 @@ export function createGraphController(options) {
332
332
 
333
333
  function setGraphChrome(mode) {
334
334
  hint.textContent = mode === "topics"
335
- ? "Topic 拓扑 · 边粗细表示跨域引用数 · 点击下钻"
336
- : "文档全图 · 点击查看详情 · 拖动画布 / 滚轮缩放";
335
+ ? "Topic topology · edge width shows cross-domain references · click to drill down"
336
+ : "Document graph · click for details · drag to pan / scroll to zoom";
337
337
  legend.replaceChildren();
338
338
  const edgeItems = mode === "topics"
339
- ? [["", "跨域引用"]]
339
+ ? [["", "Cross-domain references"]]
340
340
  : [["", "requires"], ["related", "related"], ["link", "link"]];
341
341
  for (const [className, label] of edgeItems) {
342
342
  const item = document.createElement("span");
@@ -12,46 +12,46 @@
12
12
  <body>
13
13
  <header class="app-header">
14
14
  <h1>llmdoc <span class="repo" id="repo"></span></h1>
15
- <div class="health-strip" aria-label="知识面状态">
15
+ <div class="health-strip" aria-label="Knowledge status">
16
16
  <span class="chip" id="stat-docs"></span>
17
17
  <span class="chip" id="stat-baseline"></span>
18
18
  <span class="chip" id="stat-validate"></span>
19
19
  <span class="chip" id="stat-delta"></span>
20
20
  </div>
21
- <button class="chip button" id="refresh" type="button" aria-label="刷新知识面">↻ 刷新</button>
22
- <div class="toggle" role="group" aria-label="图谱显示模式">
23
- <button id="mode-topics" type="button">Topics 拓扑</button>
24
- <button id="mode-docs" type="button">Documents 全图</button>
21
+ <button class="chip button" id="refresh" type="button" aria-label="Refresh knowledge">↻ Refresh</button>
22
+ <div class="toggle" role="group" aria-label="Graph display mode">
23
+ <button id="mode-topics" type="button">Topic topology</button>
24
+ <button id="mode-docs" type="button">All documents</button>
25
25
  </div>
26
26
  </header>
27
27
 
28
28
  <div id="load-error" class="load-error" role="alert" hidden></div>
29
29
 
30
30
  <main>
31
- <nav id="sidebar" aria-label="llmdoc 文档列表">
31
+ <nav id="sidebar" aria-label="llmdoc document list">
32
32
  <label class="search-box">
33
- <span class="sr-only">过滤文档</span>
34
- <input id="search" type="search" placeholder="过滤路径、标题或描述" autocomplete="off" />
33
+ <span class="sr-only">Filter documents</span>
34
+ <input id="search" type="search" placeholder="Filter by path, title, or description" autocomplete="off" />
35
35
  <kbd>/</kbd>
36
36
  </label>
37
37
  <div id="doc-list"></div>
38
38
  </nav>
39
39
 
40
- <section id="graph-wrap" aria-label="知识关系图">
41
- <svg id="graph" role="application" tabindex="0" aria-label="知识关系图;可拖动画布、滚轮缩放,按 0 重置视图"></svg>
40
+ <section id="graph-wrap" aria-label="Knowledge relationship graph">
41
+ <svg id="graph" role="application" tabindex="0" aria-label="Knowledge graph; drag to pan, scroll to zoom, press 0 to reset"></svg>
42
42
  <div id="graph-hint" aria-live="polite"></div>
43
- <div id="graph-toolbar" role="group" aria-label="图谱缩放控制">
44
- <button id="zoom-out" type="button" title="缩小">−</button>
45
- <button id="zoom-reset" type="button" title="重置视图">适应</button>
46
- <button id="zoom-in" type="button" title="放大">+</button>
43
+ <div id="graph-toolbar" role="group" aria-label="Graph zoom controls">
44
+ <button id="zoom-out" type="button" title="Zoom out">−</button>
45
+ <button id="zoom-reset" type="button" title="Reset view">Fit</button>
46
+ <button id="zoom-in" type="button" title="Zoom in">+</button>
47
47
  </div>
48
- <div id="legend" aria-label="图例"></div>
49
- <div id="graph-empty" hidden>没有可显示的文档</div>
48
+ <div id="legend" aria-label="Legend"></div>
49
+ <div id="graph-empty" hidden>No documents to display</div>
50
50
  </section>
51
51
 
52
- <aside id="detail" aria-label="文档详情">
53
- <button id="detail-close" type="button" aria-label="关闭详情">×</button>
54
- <div class="inner"><div class="placeholder">选择一个 topic 或文档查看详情</div></div>
52
+ <aside id="detail" aria-label="Document details">
53
+ <button id="detail-close" type="button" aria-label="Close details">×</button>
54
+ <div class="inner"><div class="placeholder">Select a topic or document to view details</div></div>
55
55
  </aside>
56
56
  </main>
57
57
  </body>
package/dist/cli.js CHANGED
@@ -43,38 +43,38 @@ export async function runCli(argv, cwd = process.cwd(), stdin = "") {
43
43
  }
44
44
  program
45
45
  .name("llmdoc")
46
- .description("面向 LLM 的项目知识库 CLI:渐进检索 llmdoc/ 文档,维护 revision 台账")
47
- .version(readPackageVersion(), "--version", "输出 CLI 版本")
48
- .helpOption("-h, --help", "显示帮助")
49
- .helpCommand("help [command]", "显示指定命令的帮助")
50
- .showHelpAfterError("(用 --help 查看用法)");
46
+ .description("Project knowledge CLI for LLMs: progressively retrieve llmdoc/ documents and maintain the revision ledger")
47
+ .version(readPackageVersion(), "--version", "output the CLI version")
48
+ .helpOption("-h, --help", "display help")
49
+ .helpCommand("help [command]", "display help for a command")
50
+ .showHelpAfterError("(use --help to view usage)");
51
51
  program
52
- .option("--json", "以 JSON 输出(经 schema 校验)")
53
- .option("--cursor <cursor>", "上次输出截断处的游标,从该处继续")
54
- .option("--budget <tokens>", "输出 token 预算,超出即截断并返回 cursor", parseInteger)
55
- .option("--limit <n>", "最多返回条数", parseInteger);
52
+ .option("--json", "emit schema-validated JSON")
53
+ .option("--cursor <cursor>", "continue from a cursor returned by a truncated response")
54
+ .option("--budget <tokens>", "truncate output at this token budget and return a cursor", parseInteger)
55
+ .option("--limit <n>", "maximum number of items to return", parseInteger);
56
56
  program.addHelpText("after", [
57
57
  "",
58
- "按用途速查:",
59
- " 检索(只读) tree → index / search / context → show",
60
- " 状态诊断 status · delta · validate",
61
- " 结构改写 new · adopt · mv · fingerprint · init-state · commit",
62
- " 维护诊断 prune · upgrade",
63
- " 集成 hook · serve",
58
+ "Quick reference by purpose:",
59
+ " Retrieval (read-only) tree → index / search / context → show",
60
+ " State diagnostics status · delta · validate",
61
+ " Structural mutation new · adopt · mv · fingerprint · init-state · commit",
62
+ " Maintenance prune · upgrade",
63
+ " Integration hook · serve",
64
64
  "",
65
- "常用示例:",
66
- " llmdoc tree --docs 全局地图,展开到文档级",
67
- " llmdoc search \"重试策略\" --limit 5 词法检索文档",
68
- " llmdoc context --files src/api/retry.ts 按源码反查应读文档",
69
- " llmdoc show api-client/retry-policy.mdx 读取正文",
70
- " llmdoc commit -m \"docs: ...\" 校验并提交 llmdoc 写集",
65
+ "Common examples:",
66
+ " llmdoc tree --docs expand the global map to documents",
67
+ " llmdoc search \"retry policy\" --limit 5 search documents lexically",
68
+ " llmdoc context --files src/api/retry.ts map source files to documents to read",
69
+ " llmdoc show api-client/retry-policy.mdx read selected bodies",
70
+ " llmdoc commit -m \"docs: ...\" validate and commit the llmdoc write set",
71
71
  "",
72
- "所有检索命令支持 --json / --budget / --limit;输出被截断时带 --cursor 继续。"
72
+ "All retrieval commands support --json / --budget / --limit; use --cursor to continue truncated output."
73
73
  ].join("\n"));
74
74
  program
75
75
  .command("tree")
76
- .description("输出 llmdoc 全局地图(默认停在 topic 层)")
77
- .option("--docs", "展开到文档级")
76
+ .description("output the global llmdoc map (topics by default)")
77
+ .option("--docs", "expand to document level")
78
78
  .action((commandOptions) => {
79
79
  const rootDir = findProjectRoot(cwd);
80
80
  const result = runTree({ ...globalOptions, ...commandOptions, cwd: rootDir });
@@ -82,35 +82,35 @@ export async function runCli(argv, cwd = process.cwd(), stdin = "") {
82
82
  });
83
83
  program
84
84
  .command("index")
85
- .description("列出文档元数据索引(不读正文即可判断相关性)")
86
- .option("--topic <topic>", "只列指定 topic 下的文档")
87
- .option("--kind <kind>", "只列指定类型: architecture | guide | reference")
85
+ .description("list document metadata without reading bodies")
86
+ .option("--topic <topic>", "list documents only under this topic")
87
+ .option("--kind <kind>", "filter by kind: architecture | guide | reference")
88
88
  .action((commandOptions) => {
89
89
  const rootDir = findProjectRoot(cwd);
90
90
  output.push(writeOutput("index", runIndex({ ...globalOptions, ...commandOptions, cwd: rootDir }), globalOptions.json));
91
91
  });
92
92
  program
93
93
  .command("show")
94
- .description("读取一个或多个文档正文")
95
- .argument("<path...>", "llmdoc/ 下的相对路径,如 api-client/retry-policy.mdx")
94
+ .description("read one or more document bodies")
95
+ .argument("<path...>", "paths relative to llmdoc/, such as api-client/retry-policy.mdx")
96
96
  .action((paths) => {
97
97
  const rootDir = findProjectRoot(cwd);
98
98
  output.push(writeOutput("show", runShow({ ...globalOptions, cwd: rootDir, paths }), globalOptions.json));
99
99
  });
100
100
  program
101
101
  .command("search")
102
- .description("按词法检索 llmdoc 文档(自动中文分词,必要时使用 CJK bigram 降级)")
103
- .argument("<query>", "检索词")
104
- .option("--topic <topic>", "限定 topic")
105
- .option("--kind <kind>", "限定类型: architecture | guide | reference")
102
+ .description("search llmdoc documents lexically (Chinese segmentation with CJK bigram fallback)")
103
+ .argument("<query>", "search query")
104
+ .option("--topic <topic>", "limit to a topic")
105
+ .option("--kind <kind>", "filter by kind: architecture | guide | reference")
106
106
  .action((query, commandOptions) => {
107
107
  const rootDir = findProjectRoot(cwd);
108
108
  output.push(writeOutput("search", runSearch({ ...globalOptions, ...commandOptions, cwd: rootDir, query }), globalOptions.json));
109
109
  });
110
110
  program
111
111
  .command("context")
112
- .description("按源码文件反查应读文档(含 requires 前置闭包)")
113
- .requiredOption("--files <files...>", "源码文件路径,可多个")
112
+ .description("map source files to documents to read, including the requires closure")
113
+ .requiredOption("--files <files...>", "one or more source file paths")
114
114
  .action((commandOptions) => {
115
115
  const rootDir = findProjectRoot(cwd);
116
116
  output.push(writeOutput("context", runContext({
@@ -121,7 +121,7 @@ export async function runCli(argv, cwd = process.cwd(), stdin = "") {
121
121
  });
122
122
  program
123
123
  .command("validate")
124
- .description("校验 llmdoc 结构与引用")
124
+ .description("validate llmdoc structure and references")
125
125
  .action((commandOptions) => {
126
126
  const rootDir = findProjectRoot(cwd);
127
127
  const result = runValidate({ ...globalOptions, ...commandOptions, cwd: rootDir });
@@ -130,24 +130,24 @@ export async function runCli(argv, cwd = process.cwd(), stdin = "") {
130
130
  });
131
131
  program
132
132
  .command("status")
133
- .description("查看 baseline、dirty 与增长状态")
133
+ .description("inspect baseline, dirty, and growth state")
134
134
  .action((commandOptions) => {
135
135
  const rootDir = findProjectRoot(cwd);
136
136
  output.push(writeOutput("status", runStatus({ ...globalOptions, ...commandOptions, cwd: rootDir }), globalOptions.json));
137
137
  });
138
138
  program
139
139
  .command("delta")
140
- .description("查看代码变化对应的文档影响面(决定 update 走 light 还是 deep)")
141
- .option("--scope <scope...>", "限定参与比对的代码路径")
140
+ .description("inspect document impacts from code changes and choose light or deep update mode")
141
+ .option("--scope <scope...>", "limit comparison to selected topics or documents")
142
142
  .action((commandOptions) => {
143
143
  const rootDir = findProjectRoot(cwd);
144
144
  output.push(writeOutput("delta", runDelta({ ...globalOptions, ...commandOptions, cwd: rootDir }), globalOptions.json));
145
145
  });
146
146
  program
147
147
  .command("fingerprint")
148
- .description("把文档 validatedRevision 刷新到当前 HEAD")
149
- .option("--update <path...>", "只刷新指定文档")
150
- .option("--all", "刷新全部文档并推进 baseline")
148
+ .description("refresh document validatedRevision values to the current HEAD")
149
+ .option("--update <path...>", "refresh only selected documents")
150
+ .option("--all", "refresh every document and advance the baseline")
151
151
  .action((commandOptions) => {
152
152
  const rootDir = findProjectRoot(cwd);
153
153
  output.push(writeOutput("fingerprint", runFingerprint({
@@ -159,8 +159,8 @@ export async function runCli(argv, cwd = process.cwd(), stdin = "") {
159
159
  });
160
160
  program
161
161
  .command("init-state")
162
- .description("首次生成 llmdoc/meta.json 台账骨架(validatedRevision 全部为 null)")
163
- .addHelpText("after", "\n前置: Git HEAD 必须已有真实 commit。生成后先 validate,再用 commit --all 完成 bootstrap。")
162
+ .description("create the initial llmdoc/meta.json ledger with null validatedRevision values")
163
+ .addHelpText("after", "\nPrerequisite: Git HEAD must reference a real commit. Then run validate and finish bootstrap with commit --all.")
164
164
  .action(async () => {
165
165
  const { runInitState } = await import("./commands/init-state.js");
166
166
  const rootDir = findProjectRoot(cwd);
@@ -168,11 +168,11 @@ export async function runCli(argv, cwd = process.cwd(), stdin = "") {
168
168
  });
169
169
  program
170
170
  .command("commit")
171
- .description("一体化收尾:validate 门控 → 可选提交正文 → 刷新 changed/verified revision → meta 小 commit")
171
+ .description("finalize atomically: validate, optionally commit prose, refresh revisions, and commit metadata")
172
172
  .option("-m, --message <message>", "docs commit message")
173
- .option("--all", "fingerprint 全部文档并推进 baseline")
174
- .option("--verified <paths...>", "正文复核后无需改写,刷新指定文档的 validatedRevision")
175
- .option("--no-verify", "透传 git commit --no-verify(husky 等重钩子仓库)")
173
+ .option("--all", "fingerprint every document and advance the baseline")
174
+ .option("--verified <paths...>", "refresh validatedRevision for reviewed documents whose bodies did not change")
175
+ .option("--no-verify", "pass --no-verify through to git commit")
176
176
  .action(async (commandOptions) => {
177
177
  const { runCommit } = await import("./commands/commit.js");
178
178
  const rootDir = findProjectRoot(cwd);
@@ -187,11 +187,11 @@ export async function runCli(argv, cwd = process.cwd(), stdin = "") {
187
187
  });
188
188
  program
189
189
  .command("new")
190
- .description("在 llmdoc/ 下生成文档脚手架")
191
- .argument("<path>", "目标相对路径,如 api-client/retry-policy.mdx")
192
- .requiredOption("--kind <kind>", "文档类型: architecture | guide | reference")
193
- .option("--description <description>", "front matter 一句话描述")
194
- .addHelpText("after", "\n首次创建时会自动建立 llmdoc/;完成初始文档后运行 init-state → validate → commit --all。")
190
+ .description("scaffold a document under llmdoc/")
191
+ .argument("<path>", "target path, such as api-client/retry-policy.mdx")
192
+ .requiredOption("--kind <kind>", "document kind: architecture | guide | reference")
193
+ .option("--description <description>", "one-line front matter description")
194
+ .addHelpText("after", "\nThe first document creates llmdoc/ automatically. Finish bootstrap with init-state → validate → commit --all.")
195
195
  .action((targetPath, commandOptions) => {
196
196
  output.push(writeOutput("new", runNew({
197
197
  ...globalOptions,
@@ -203,8 +203,8 @@ export async function runCli(argv, cwd = process.cwd(), stdin = "") {
203
203
  });
204
204
  program
205
205
  .command("adopt")
206
- .description("无损登记已存在的 .mdx 到 meta.json(validatedRevision: null,不改正文,幂等)")
207
- .argument("<path...>", "已存在的 llmdoc/ 下相对路径,可多个")
206
+ .description("register existing .mdx documents in meta.json without rewriting them")
207
+ .argument("<path...>", "one or more existing paths under llmdoc/")
208
208
  .action(async (paths) => {
209
209
  const { runAdopt } = await import("./commands/adopt.js");
210
210
  const rootDir = findProjectRoot(cwd);
@@ -212,55 +212,55 @@ export async function runCli(argv, cwd = process.cwd(), stdin = "") {
212
212
  });
213
213
  program
214
214
  .command("mv")
215
- .description("移动/重命名文档或整个 topic,并重写内部引用")
216
- .argument("<from>", "源路径")
217
- .argument("<to>", "目标路径")
215
+ .description("move or rename a document or topic and rewrite internal references")
216
+ .argument("<from>", "source path")
217
+ .argument("<to>", "target path")
218
218
  .action((from, to) => {
219
219
  const rootDir = findProjectRoot(cwd);
220
220
  output.push(writeOutput("mv", runMove({ ...globalOptions, cwd: rootDir, from, to }), globalOptions.json));
221
221
  });
222
222
  program
223
223
  .command("prune")
224
- .description("输出只读收敛报告(增长趋势、重复候选、小文档合并候选)")
225
- .option("--report", "输出只读收敛报告")
224
+ .description("output a read-only convergence report")
225
+ .option("--report", "output the read-only report")
226
226
  .action((commandOptions) => {
227
227
  const rootDir = findProjectRoot(cwd);
228
228
  output.push(writeOutput("prune", runPrune({ ...globalOptions, cwd: rootDir, report: commandOptions.report }), globalOptions.json));
229
229
  });
230
230
  program
231
231
  .command("upgrade")
232
- .description("盘点 legacy/V2 到 V3 的迁移需求")
232
+ .description("inventory legacy/V2 to V3 migration needs")
233
233
  .action(async (commandOptions) => {
234
234
  const { runUpgrade } = await import("./commands/upgrade.js");
235
235
  const rootDir = findProjectRootOrNull(cwd) ?? cwd;
236
236
  output.push(writeOutput("upgrade", await runUpgrade({ ...globalOptions, ...commandOptions, cwd: rootDir }), globalOptions.json));
237
237
  });
238
- const hookCommand = program.command("hook").description("供编辑器/Agent hooks 调用的只读信号(异常时 fail-open)");
238
+ const hookCommand = program.command("hook").description("read-only, fail-open signals for editor and Agent hooks");
239
239
  hookCommand
240
240
  .command("session-start")
241
- .description("输出 SessionStart 短状态信号")
241
+ .description("output SessionStart state and apply optional llmdoc.config.json startup config")
242
242
  .action(() => {
243
243
  const rootDir = findProjectRootOrNull(cwd) ?? cwd;
244
244
  output.push(runHook({ cwd: rootDir, mode: "session-start", stdin }));
245
245
  });
246
246
  hookCommand
247
247
  .command("stop")
248
- .description("输出 Stop hook JSON 提醒")
248
+ .description("output the Stop hook JSON reminder")
249
249
  .action(() => {
250
250
  const rootDir = findProjectRootOrNull(cwd) ?? cwd;
251
251
  output.push(parseAndValidateJsonString("hook", runHook({ cwd: rootDir, mode: "stop", stdin })));
252
252
  });
253
253
  hookCommand
254
254
  .command("compact")
255
- .description("输出 PreCompact hook JSON 指令")
255
+ .description("output the PreCompact hook JSON instruction")
256
256
  .action(() => {
257
257
  const rootDir = findProjectRootOrNull(cwd) ?? cwd;
258
258
  output.push(parseAndValidateJsonString("hook", runHook({ cwd: rootDir, mode: "compact", stdin })));
259
259
  });
260
260
  program
261
261
  .command("serve")
262
- .description("启动本地 Web Viewer(HTTP 服务,浏览文档结构与关联,Ctrl-C 退出)")
263
- .option("--port <port>", "监听端口", parseInteger)
262
+ .description("start the local Web Viewer; press Ctrl-C to stop")
263
+ .option("--port <port>", "listening port", parseInteger)
264
264
  .action(async (commandOptions) => {
265
265
  const { runServe } = await import("./commands/serve.js");
266
266
  const rootDir = findProjectRoot(cwd);
@@ -295,7 +295,7 @@ function writeOutput(schemaName, value, expectJson = false) {
295
295
  function parseInteger(input) {
296
296
  const value = Number.parseInt(input, 10);
297
297
  if (Number.isNaN(value) || value <= 0) {
298
- throw new CliError(`非法整数: ${input}`);
298
+ throw new CliError(`Invalid integer: ${input}`);
299
299
  }
300
300
  return value;
301
301
  }
@@ -10,21 +10,21 @@ export function runAdopt(options) {
10
10
  const rootDir = findProjectRoot(options.cwd);
11
11
  const workspace = loadWorkspace(rootDir);
12
12
  if (!workspace.meta) {
13
- throw new CliError("缺少 llmdoc/meta.json,先运行 llmdoc init-state。");
13
+ throw new CliError("llmdoc/meta.json is missing; run llmdoc init-state first.");
14
14
  }
15
15
  const llmdocPaths = options.paths.map((input) => {
16
16
  const repoRelativePath = normalizeRepoRelativePath(input.startsWith("llmdoc/") ? input : `llmdoc/${input}`);
17
17
  if (!repoRelativePath.startsWith("llmdoc/") || !repoRelativePath.endsWith(".mdx")) {
18
- throw new CliError(`adopt 只能登记 llmdoc/ 下的 .mdx 文档: ${input}`);
18
+ throw new CliError(`adopt can register only .mdx documents under llmdoc/: ${input}`);
19
19
  }
20
20
  const shape = parseDocTargetShape(repoRelativePath);
21
21
  assertDocKindMatchesShape(shape);
22
22
  const absolutePath = resolveInsideRoot(rootDir, repoRelativePath, { allowMissing: true });
23
23
  if (!fs.existsSync(absolutePath)) {
24
- throw new CliError(`目标不存在,adopt 只登记已有文档(新建请用 llmdoc new): ${repoRelativePath}`);
24
+ throw new CliError(`Target does not exist; adopt registers existing documents only (use llmdoc new to create one): ${repoRelativePath}`);
25
25
  }
26
26
  if (!workspace.documentsByLlmdocPath.has(shape.llmdocPath)) {
27
- throw new CliError(`文档未被 workspace 识别(front matter 可能不合法): ${repoRelativePath}`);
27
+ throw new CliError(`The workspace did not recognize the document (its front matter may be invalid): ${repoRelativePath}`);
28
28
  }
29
29
  return shape.llmdocPath;
30
30
  });
@@ -32,7 +32,7 @@ export function runAdopt(options) {
32
32
  const targetRepoPaths = new Set(llmdocPaths.map((llmdocPath) => `llmdoc/${llmdocPath}`));
33
33
  const blockingIssues = validateWorkspace(workspace).filter((issue) => issue.severity === "error" && issue.path !== undefined && targetRepoPaths.has(issue.path) && issue.code !== "meta.entry.missing");
34
34
  if (blockingIssues.length > 0) {
35
- throw new CliError(`目标文档未通过校验,拒绝登记:\n${blockingIssues.map((issue) => ` ${issue.code} (${issue.path}) ${issue.message}`).join("\n")}`);
35
+ throw new CliError(`Target documents failed validation; refusing to register them:\n${blockingIssues.map((issue) => ` ${issue.code} (${issue.path}) ${issue.message}`).join("\n")}`);
36
36
  }
37
37
  const adopted = [];
38
38
  const alreadyRegistered = [];
@@ -59,7 +59,7 @@ export function runAdopt(options) {
59
59
  lines.push(`already registered (no-op): ${alreadyRegistered.join(", ")}`);
60
60
  }
61
61
  if (adopted.length > 0) {
62
- lines.push("validatedRevision 登记为 null;经 validate 后用 fingerprint/commit 写入有效 revision。");
62
+ lines.push("validatedRevision was registered as null; after validation, use fingerprint/commit to write a valid revision.");
63
63
  }
64
64
  return lines.join("\n");
65
65
  }
@@ -10,22 +10,22 @@ export function runCommit(options) {
10
10
  const preflightWorkspace = loadWorkspace(rootDir);
11
11
  const verifiedPaths = uniquePaths((options.verified ?? []).map((value) => (value.startsWith("llmdoc/") ? value.slice("llmdoc/".length) : value)));
12
12
  if (options.all && verifiedPaths.length > 0) {
13
- throw new CliError("commit 不能同时使用 --all 与 --verified。");
13
+ throw new CliError("commit cannot use --all and --verified together.");
14
14
  }
15
15
  for (const docPath of verifiedPaths) {
16
16
  if (!preflightWorkspace.documentsByLlmdocPath.has(docPath)) {
17
- throw new CliError(`文档不存在: ${docPath}`);
17
+ throw new CliError(`Document does not exist: ${docPath}`);
18
18
  }
19
19
  }
20
20
  const issues = validateWorkspace(preflightWorkspace);
21
21
  const errors = issues.filter((issue) => issue.severity === "error");
22
22
  if (errors.length > 0) {
23
- throw new CliError(`validate 未通过,拒绝提交:\n${errors.map((issue) => ` ${issue.code} (${issue.path})`).join("\n")}`);
23
+ throw new CliError(`Validation failed; refusing to commit:\n${errors.map((issue) => ` ${issue.code} (${issue.path})`).join("\n")}`);
24
24
  }
25
25
  const porcelain = runGit(rootDir, ["status", "--porcelain", "--", "llmdoc"]);
26
26
  const hasLlmdocChanges = Boolean(porcelain.trim());
27
27
  if (!hasLlmdocChanges && !options.all && verifiedPaths.length === 0) {
28
- return options.json ? { status: "no_change", commits: [], updated: [] } : "no_change: llmdoc/ 无待提交变更";
28
+ return options.json ? { status: "no_change", commits: [], updated: [] } : "no_change: llmdoc/ has no changes to commit";
29
29
  }
30
30
  const changedDocPaths = porcelain
31
31
  .split(/\r?\n/)
@@ -48,7 +48,7 @@ export function runCommit(options) {
48
48
  });
49
49
  }
50
50
  catch (error) {
51
- throw new CliError(`fingerprint 预检未通过,未创建任何 commit: ${error.message}`, 70);
51
+ throw new CliError(`Fingerprint preflight failed; no commit was created: ${error.message}`, 70);
52
52
  }
53
53
  if (changedDocPaths.length === 0) {
54
54
  return commitMetaOnly({
@@ -150,7 +150,7 @@ function uniquePaths(paths) {
150
150
  function runGit(rootDir, args) {
151
151
  const result = spawnSync("git", ["-c", "core.quotePath=false", ...args], { cwd: rootDir, encoding: "utf8" });
152
152
  if (result.status !== 0) {
153
- throw new CliError((result.stderr || result.stdout || `git ${args[0]} 失败`).trim());
153
+ throw new CliError((result.stderr || result.stdout || `git ${args[0]} failed`).trim());
154
154
  }
155
155
  return result.stdout;
156
156
  }
@@ -7,7 +7,7 @@ import { normalizeRepoRelativePath, resolveInsideRoot } from "../lib/fs.js";
7
7
  import { estimateTokens } from "../lib/markdown.js";
8
8
  export function runContext(options) {
9
9
  if (options.files.length === 0) {
10
- throw new CliError("context 需要至少一个 --files 输入。");
10
+ throw new CliError("context requires at least one --files input.");
11
11
  }
12
12
  const workspace = loadWorkspace(options.cwd);
13
13
  const normalizedFiles = options.files.map((file) => {
@@ -5,14 +5,14 @@ export function runFingerprint(options) {
5
5
  const workspace = loadWorkspace(options.cwd);
6
6
  const targetPaths = options.update?.map((value) => (value.startsWith("llmdoc/") ? value.slice("llmdoc/".length) : value)) ?? [];
7
7
  if (options.all && targetPaths.length > 0) {
8
- throw new CliError("fingerprint 不能同时使用 --all 与 --update。");
8
+ throw new CliError("fingerprint cannot use --all and --update together.");
9
9
  }
10
10
  if (!options.all && targetPaths.length === 0) {
11
- throw new CliError("fingerprint 需要 --all 或 --update <path...>。");
11
+ throw new CliError("fingerprint requires --all or --update <path...>.");
12
12
  }
13
13
  for (const docPath of targetPaths) {
14
14
  if (!workspace.documentsByLlmdocPath.has(docPath)) {
15
- throw new CliError(`文档不存在: ${docPath}`);
15
+ throw new CliError(`Document does not exist: ${docPath}`);
16
16
  }
17
17
  }
18
18
  try {