返回 CodeWhale
docs-map.ts
根目录 / web / lib / docs-map.ts
1 /**
2 * docs-map.ts — canonical documentation registry for codewhale.net.
3 *
4 * Maps every first-class documentation topic area to its repo source file(s)
5 * and website route. This is the single source of truth for the docs hub
6 * sidebar, breadcrumbs, and drift/parity checks.
7 *
8 * EXTENSION PATH FOR NEW LOCALES:
9 * Labels are keyed by locale. Add a new locale column and update the page
10 * components that consume this map. The topic IDs, slugs, and repo sources
11 * are locale-agnostic.
12 */
13
14 export interface DocTopic {
15 /** Stable identifier used in routes and anchors. */
16 id: string;
17 /** URL slug for the docs sub-route (e.g. "install"). */
18 slug: string;
19 /** Label per locale. */
20 label: { en: string; zh: string };
21 /** Short description per locale. */
22 description: { en: string; zh: string };
23 /** Repo source file(s) — the canonical markdown doc in the repo. */
24 repoSource: string | string[];
25 /** Whether this topic has a dedicated website page (vs. linking out). */
26 hasPage: boolean;
27 /** Locale-relative website path when the page lives outside `/docs/<slug>`. */
28 sitePath?: string;
29 /** Category for grouping in the sidebar. */
30 category: "getting-started" | "core-concepts" | "reference" | "extending" | "operations";
31 }
32
33 /** Sidebar and breadcrumb labels for each docs-map category. */
34 export const DOC_CATEGORY_LABELS: Record<DocTopic["category"], { en: string; zh: string }> = {
35 "getting-started": { en: "Get started", zh: "开始使用" },
36 "core-concepts": { en: "Work with Codewhale", zh: "日常使用" },
37 extending: { en: "Extend and automate", zh: "扩展与自动化" },
38 operations: { en: "Get help", zh: "获取帮助" },
39 reference: { en: "Reference", zh: "参考" },
40 };
41
42 export const DOC_TOPICS: DocTopic[] = [
43 {
44 id: "first-time",
45 slug: "first-time",
46 label: { en: "Use Codewhale for the first time", zh: "第一次使用 Codewhale" },
47 description: {
48 en: "Open a terminal, install, pick the folder Codewhale works in, connect a model and finish a first task.",
49 zh: "打开终端、安装、选择 Codewhale 工作的文件夹、连接模型并完成第一个任务。",
50 },
51 repoSource: ["docs/GUIDE.md", "docs/INSTALL.md", "docs/MODES.md", "docs/SANDBOX.md", "docs/KEYBINDINGS.md"],
52 hasPage: true,
53 category: "getting-started",
54 },
55 {
56 id: "install",
57 slug: "install",
58 label: { en: "Install Codewhale", zh: "安装 Codewhale" },
59 description: {
60 en: "The installer, npm, Homebrew tap, Cargo, and release binaries, with the output each step prints.",
61 zh: "安装脚本、npm、Homebrew tap、Cargo 与发布版二进制文件,以及每一步应有的输出。",
62 },
63 repoSource: "docs/INSTALL.md",
64 hasPage: true,
65 sitePath: "install",
66 category: "getting-started",
67 },
68 {
69 id: "guide",
70 slug: "guide",
71 label: { en: "Start your first task", zh: "开始第一个任务" },
72 description: {
73 en: "Install, connect a model, and give Codewhale a task in your project.",
74 zh: "安装、连接模型,然后在你的项目里交给 Codewhale 一项任务。",
75 },
76 repoSource: ["docs/GUIDE.md", "docs/INSTALL.md", "docs/KEYBINDINGS.md"],
77 hasPage: true,
78 category: "getting-started",
79 },
80 {
81 id: "auth",
82 slug: "auth",
83 label: { en: "Connect a provider", zh: "连接模型提供商" },
84 description: {
85 en: "Save a provider key, check which key is used, or run a local model.",
86 zh: "保存提供商密钥、查看当前使用的密钥,或运行本地模型。",
87 },
88 repoSource: ["docs/INSTALL.md", "docs/PROVIDERS.md"],
89 hasPage: true,
90 category: "getting-started",
91 },
92 {
93 id: "account",
94 slug: "account",
95 label: { en: "Sign in to Codewhale", zh: "登录 Codewhale" },
96 description: {
97 en: "Sign in to an existing account from the web, the desktop app, or the terminal, sign out, and find data export and deletion.",
98 zh: "在网页、桌面应用或终端登录已有账户、退出登录,以及找到数据导出和删除的入口。",
99 },
100 repoSource: ["docs/CONFIGURATION.md", "docs/PROVIDERS.md"],
101 hasPage: true,
102 category: "getting-started",
103 },
104 {
105 id: "providers",
106 slug: "providers",
107 label: { en: "Choose a model", zh: "选择模型" },
108 description: {
109 en: "Supported providers, switching models, and running a model yourself.",
110 zh: "支持的提供商、切换模型,以及自己运行模型。",
111 },
112 repoSource: ["docs/PROVIDERS.md", "docs/MODEL_LAB.md"],
113 hasPage: true,
114 sitePath: "models",
115 category: "getting-started",
116 },
117 {
118 id: "configuration",
119 slug: "configuration",
120 label: { en: "Change settings", zh: "修改设置" },
121 description: {
122 en: "Find the config file, change settings from the session or shell, and see what a repository may override.",
123 zh: "找到配置文件,在会话或 shell 中修改设置,并了解仓库可以覆盖哪些设置。",
124 },
125 repoSource: ["docs/CONFIGURATION.md", "docs/LEGACY_PATHS.md"],
126 hasPage: true,
127 category: "getting-started",
128 },
129 {
130 id: "modes",
131 slug: "modes",
132 label: { en: "Set modes and approvals", zh: "设置模式与审批" },
133 description: {
134 en: "Choose Plan, Work or Operate, and choose when Codewhale asks for approval.",
135 zh: "选择 Plan、Work 或 Operate,并选择 Codewhale 何时询问审批。",
136 },
137 repoSource: "docs/MODES.md",
138 hasPage: true,
139 category: "core-concepts",
140 },
141 {
142 id: "review",
143 slug: "review",
144 label: { en: "Review what changed", zh: "查看改动" },
145 description: {
146 en: "See every edit, roll files back to an earlier turn, get a code review, and keep a review receipt.",
147 zh: "查看每一处修改,把文件回滚到之前的回合,做代码审查,并保留审查收据。",
148 },
149 repoSource: ["docs/RECEIPTS.md", "docs/CONFIGURATION.md"],
150 hasPage: true,
151 category: "core-concepts",
152 },
153 {
154 id: "work",
155 slug: "work",
156 label: { en: "Track progress", zh: "跟踪进度" },
157 description: {
158 en: "Follow the goal, To-do list, and sub-agents in the workbar, and hand work to a fresh session.",
159 zh: "在工作栏中跟踪目标、To-do 列表和子 Agent,并把工作交接给新的会话。",
160 },
161 repoSource: "docs/TOOL_SURFACE.md",
162 hasPage: true,
163 category: "core-concepts",
164 },
165 {
166 id: "pet",
167 slug: "pet",
168 label: { en: "Watch each session with the whale view", zh: "用鲸鱼视图查看每个会话" },
169 description: {
170 en: "A whale view per terminal that shows working, waiting for you, done, or failed, with replies and agents one key away.",
171 zh: "每个终端一头鲸鱼,显示工作中、在等你、已完成或失败,回复和智能体只需按一个键即可查看。",
172 },
173 repoSource: "docs/PET_MODE.md",
174 hasPage: true,
175 category: "core-concepts",
176 },
177 {
178 id: "subagents",
179 slug: "subagents",
180 label: { en: "Run agents in parallel", zh: "并行运行 Agent" },
181 description: {
182 en: "Hand independent parts of a task to sub-agents, pick roles, and keep parallel edits in worktrees.",
183 zh: "把任务中独立的部分交给子 Agent,选择角色,并用工作树隔离并行修改。",
184 },
185 repoSource: ["docs/SUBAGENTS.md", "docs/FLEET.md", "docs/MODES.md"],
186 hasPage: true,
187 category: "core-concepts",
188 },
189 {
190 id: "fleet",
191 slug: "fleet",
192 label: { en: "Run a workflow", zh: "运行 Workflow" },
193 description: {
194 en: "Save roles in a Fleet, write a repeatable Workflow, run it as a Lane, and run batches of tasks.",
195 zh: "在 Fleet 中保存角色,编写可重复的 Workflow,把它作为 Lane 运行,并批量执行任务。",
196 },
197 repoSource: ["docs/FLEET.md", "docs/FLEET_WORKFLOW_TUTORIAL.md", "docs/WORKFLOW_AUTHORING.md"],
198 hasPage: true,
199 category: "core-concepts",
200 },
201 {
202 id: "sandbox",
203 slug: "sandbox",
204 label: { en: "Limit what commands can touch", zh: "限制命令的访问范围" },
205 description: {
206 en: "The OS sandbox on macOS, Linux, and Windows, how to turn it on, and how much a command may write.",
207 zh: "macOS、Linux 和 Windows 上的操作系统沙箱、如何开启,以及命令能写到哪里。",
208 },
209 repoSource: ["docs/SANDBOX.md", "docs/AUTHORIZATION_ORDER.md"],
210 hasPage: true,
211 category: "core-concepts",
212 },
213 {
214 id: "trust",
215 slug: "trust",
216 label: { en: "See what leaves your machine", zh: "了解哪些数据会离开本机" },
217 description: {
218 en: "What stays local, what a provider receives, what usage counting sends, and how to turn it off.",
219 zh: "哪些留在本地、提供商会收到什么、用量统计发送什么,以及如何关闭。",
220 },
221 repoSource: ["docs/SANDBOX.md", "docs/AUTHORIZATION_ORDER.md", "docs/TELEMETRY.md", "docs/public-surface-facts.json", "docs/PREVIEW_REQUEST.md"],
222 hasPage: true,
223 category: "core-concepts",
224 },
225 {
226 id: "mcp",
227 slug: "mcp",
228 label: { en: "Connect tools with MCP", zh: "用 MCP 连接工具" },
229 description: {
230 en: "Add a connector: a local (stdio) or remote (HTTP) MCP server. Sign in with OAuth, serve Codewhale over MCP, and try code mode.",
231 zh: "添加连接器:本地(stdio)或远程(HTTP)MCP 服务器。用 OAuth 登录、把 Codewhale 作为 MCP 服务器运行,并试用代码模式。",
232 },
233 repoSource: "docs/MCP.md",
234 hasPage: true,
235 category: "extending",
236 },
237 {
238 id: "hooks",
239 slug: "hooks",
240 label: { en: "Run commands on events", zh: "在事件发生时运行命令" },
241 description: {
242 en: "Add a hook that runs your own script at session start, before a tool call, at turn end, or when Codewhale waits for you.",
243 zh: "添加钩子,在会话开始、工具调用之前、回合结束或 Codewhale 等你回应时运行你自己的脚本。",
244 },
245 repoSource: ["docs/HOOKS.md", "docs/CONFIGURATION.md"],
246 hasPage: true,
247 category: "extending",
248 },
249 {
250 id: "skills",
251 slug: "skills",
252 label: { en: "Add skills", zh: "添加技能" },
253 description: {
254 en: "Install, find, trust, and load reusable instruction packages. A skill can come on its own or inside a plugin.",
255 zh: "安装、查找、信任并加载可复用的指令包。技能可以单独添加,也可以包含在插件中。",
256 },
257 repoSource: ["docs/SKILLS.md", "docs/CLAUDE_PLUGIN_COMPAT.md"],
258 hasPage: true,
259 category: "extending",
260 },
261 {
262 id: "claude-code",
263 slug: "claude-code",
264 label: { en: "Bring your settings from another coding agent", zh: "从其他编码智能体带来你的设置" },
265 description: {
266 en: "Keep compatible instructions and skills, and review settings and MCP imports without running other agents' plugin runtimes.",
267 zh: "保留兼容的指令与技能,审阅设置与 MCP 导入;不会运行其他智能体的插件运行时。",
268 },
269 repoSource: ["docs/CLAUDE_PLUGIN_COMPAT.md", "docs/CONFIGURATION.md"],
270 hasPage: true,
271 category: "getting-started",
272 },
273 {
274 id: "plugins",
275 slug: "plugins",
276 label: { en: "Add plugins", zh: "添加插件" },
277 description: {
278 en: "Choose plugin formats, browse catalog examples, and review, trust and enable plugin bundles. A bundle can carry skills, connectors and hooks.",
279 zh: "选择插件格式,浏览目录示例,并审阅、信任和启用插件包。一个插件包可以携带技能、连接器和钩子。",
280 },
281 repoSource: ["docs/PLUGINS.md", "docs/PLUGIN_BUNDLES.md", "docs/PLUGIN_MARKETPLACE.md", "docs/EXTENSIONS.md"],
282 hasPage: true,
283 sitePath: "plugins",
284 category: "extending",
285 },
286 {
287 id: "runtime-api",
288 slug: "runtime-api",
289 label: { en: "Automate with the Runtime API", zh: "用 Runtime API 自动化" },
290 description: {
291 en: "Run one-shot jobs from scripts, or drive threads, events, and approvals over the local HTTP API.",
292 zh: "在脚本中运行一次性任务,或通过本地 HTTP API 驱动线程、事件和审批。",
293 },
294 repoSource: "docs/RUNTIME_API.md",
295 hasPage: true,
296 category: "extending",
297 },
298 {
299 id: "web",
300 slug: "web",
301 label: { en: "Open the browser client", zh: "打开浏览器客户端" },
302 description: {
303 en: "Work in a local browser tab, or continue a terminal session from the web app with /rc.",
304 zh: "在本机浏览器标签页中工作,或用 /rc 在网页应用中接着使用终端会话。",
305 },
306 repoSource: "docs/WEB.md",
307 hasPage: true,
308 category: "extending",
309 },
310 // Fleet is the canonical customer noun; `/docs/pod` remains a
311 // permanent compatibility redirect in app/[locale]/docs/pod/page.tsx.
312 {
313 id: "memory",
314 slug: "memory",
315 label: { en: "Keep preferences in memory", zh: "用记忆保存偏好" },
316 description: {
317 en: "The local memory store: what it keeps between sessions, where it lives and how to edit it.",
318 zh: "本地记忆存储:跨会话保留什么、存放在哪里,以及如何编辑。",
319 },
320 repoSource: "docs/MEMORY.md",
321 hasPage: false,
322 category: "core-concepts",
323 },
324 {
325 id: "read-media",
326 slug: "read-media",
327 label: { en: "Show the agent an image", zh: "给 Agent 看图片" },
328 description: {
329 en: "How read_media opens screenshots, diagrams and mockups, with its format, size and privacy limits.",
330 zh: "read_media 如何读取截图、图表和设计稿,以及格式、大小和隐私方面的限制。",
331 },
332 repoSource: "docs/READ_MEDIA.md",
333 hasPage: false,
334 category: "core-concepts",
335 },
336 {
337 id: "github-action",
338 slug: "github-action",
339 label: { en: "Review pull requests on GitHub", zh: "在 GitHub 上审查拉取请求" },
340 description: {
341 en: "Run codewhale review from a GitHub workflow with a read-only analysis job and a separate publishing job.",
342 zh: "在 GitHub 工作流中运行 codewhale review:只读的分析作业加上独立的发布作业。",
343 },
344 repoSource: "docs/GITHUB_ACTION.md",
345 hasPage: false,
346 category: "extending",
347 },
348 {
349 id: "cloud-dispatch",
350 slug: "cloud-dispatch",
351 label: { en: "Dispatch to a cloud computer (preview)", zh: "派发到云端电脑(预览)" },
352 description: {
353 en: "Send a task to a computer in your Codewhale account and reopen the same conversation from the terminal or desktop.",
354 zh: "把任务派发到 Codewhale 账户中的电脑,并从终端或桌面重新打开同一个会话。",
355 },
356 repoSource: "docs/CLOUD_DISPATCH.md",
357 hasPage: false,
358 category: "extending",
359 },
360 {
361 id: "troubleshooting",
362 slug: "troubleshooting",
363 label: { en: "Fix a problem", zh: "排查问题" },
364 description: {
365 en: "Diagnose in one command, then fix install, key, network, stuck-turn, session, and MCP problems.",
366 zh: "用一条命令诊断,再解决安装、密钥、网络、回合卡住、会话和 MCP 等问题。",
367 },
368 repoSource: ["docs/INSTALL.md", "docs/OPERATIONS_RUNBOOK.md", "docs/DOCKER.md"],
369 hasPage: true,
370 category: "operations",
371 },
372 {
373 id: "contribution",
374 slug: "contribution",
375 label: { en: "Contribute", zh: "参与贡献" },
376 description: {
377 en: "The contributing guide, agent ethos, contributor credits, and release process.",
378 zh: "贡献指南、Agent 准则、贡献者致谢和发布流程。",
379 },
380 repoSource: [
381 "CONTRIBUTING.md",
382 "docs/AGENT_ETHOS.md",
383 "docs/CONTRIBUTORS.md",
384 "docs/RELEASE_CHECKLIST.md",
385 ],
386 hasPage: false,
387 category: "operations",
388 },
389 {
390 id: "runtime-reference",
391 slug: "runtime-reference",
392 label: { en: "Runtime API reference", zh: "Runtime API 参考" },
393 description: { en: "Read the HTTP routes, request fields and event contracts in the repository.", zh: "查阅仓库中的 HTTP 路由、请求字段和事件约定。" },
394 repoSource: ["docs/RUNTIME_API.md", "docs/RUNTIME_ROUTES.md"],
395 hasPage: true,
396 category: "reference",
397 },
398 {
399 id: "workflow-tutorial",
400 slug: "workflow-tutorial",
401 label: { en: "Fleet and Workflow tutorial", zh: "Fleet 与 Workflow 教程" },
402 description: { en: "Follow the full task-specification tutorial, including validation, launch and recovery.", zh: "按照完整任务规范教程进行验证、启动和恢复。" },
403 repoSource: "docs/FLEET_WORKFLOW_TUTORIAL.md",
404 hasPage: true,
405 category: "extending",
406 },
407 {
408 id: "plugin-authoring",
409 slug: "plugin-authoring",
410 label: { en: "Write your first plugin", zh: "编写第一个插件" },
411 description: { en: "Build, inspect and activate a two-file skill bundle with a visible greeting check.", zh: "创建、检查并启用包含两个文件的技能包,通过问候标记核对结果。" },
412 repoSource: "docs/PLUGIN_AUTHORING.md",
413 hasPage: true,
414 category: "extending",
415 },
416 {
417 id: "vocabulary",
418 slug: "vocabulary",
419 label: { en: "Product terms", zh: "产品名词" },
420 description: {
421 en: "Understand Fleet, Workflow, Lane and Runtime, plus the modes and permission postures.",
422 zh: "了解 Fleet、Workflow、Lane、Runtime,以及模式与权限设置。",
423 },
424 repoSource: ["docs/FLEET.md", "docs/MODES.md", "docs/public-surface-facts.json"],
425 hasPage: true,
426 category: "reference",
427 },
428 {
429 id: "constitution",
430 slug: "constitution",
431 label: { en: "Constitution", zh: "宪章" },
432 description: {
433 en: "The rules the agent follows: built-in rules, your personal constitution, and a repository's own.",
434 zh: "Agent 遵循的规则:内置规则、你的个人宪章,以及仓库自己的宪章。",
435 },
436 repoSource: "docs/CONFIGURATION.md",
437 hasPage: true,
438 category: "reference",
439 },
440 {
441 id: "tools",
442 slug: "tools",
443 label: { en: "Built-in tools", zh: "内置工具" },
444 description: {
445 en: "The small set of tools every session starts with, and how Codewhale finds the rest.",
446 zh: "每个会话默认携带的少量工具,以及 Codewhale 如何按需找到其余工具。",
447 },
448 repoSource: ["docs/TOOL_SURFACE.md", "docs/LSP_PHP_CUSTOM.md"],
449 hasPage: true,
450 category: "reference",
451 },
452 ];
453
454 /** Convenience lookup. */
455 export function getTopic(id: string): DocTopic | undefined {
456 return DOC_TOPICS.find((t) => t.id === id);
457 }
458
459 /** Group topics by category for sidebar rendering. */
460 export function getTopicsByCategory(): Map<DocTopic["category"], DocTopic[]> {
461 const map = new Map<DocTopic["category"], DocTopic[]>();
462 for (const t of DOC_TOPICS) {
463 const group = map.get(t.category) ?? [];
464 group.push(t);
465 map.set(t.category, group);
466 }
467 return map;
468 }
469
470 /** Resolve a topic to its on-site route or canonical repository document. */
471 export function docTopicHref(topic: DocTopic, locale: string): string {
472 if (topic.sitePath) return `/${locale}/${topic.sitePath}`;
473 if (topic.hasPage) return `/${locale}/docs/${topic.slug}`;
474 const source = Array.isArray(topic.repoSource) ? topic.repoSource[0] : topic.repoSource;
475 return `${REPO_DOCS_BASE}/${source}`;
476 }
477
478 /** Whether following a topic leaves codewhale.net for the source document. */
479 export function docTopicIsExternal(topic: DocTopic): boolean {
480 return !topic.hasPage;
481 }
482
483 /** Repo source base URL for generating direct links. */
484 export const REPO_DOCS_BASE = "https://github.com/codewhale-hq/CodeWhale/blob/main";
485
485 lines TYPESCRIPT