| 1 | /** |
| 2 | * docs-tasks.ts — the task-based index of codewhale.net documentation. |
| 3 | * |
| 4 | * `docs-map.ts` answers "what topics exist"; this registry answers "I am |
| 5 | * trying to do X — where do I go". Every task points at a first-party route |
| 6 | * (locale-relative, so `/${locale}${href}` always exists) and names the |
| 7 | * topic it belongs to, so the hub can search tasks and topics together and |
| 8 | * `docs-tasks.test.ts` can prove every target resolves. |
| 9 | * |
| 10 | * TRUTH CONTRACT: a task may only describe behaviour the target page (and |
| 11 | * its repository source document) actually documents. Keep the verbs |
| 12 | * concrete and keep the list short enough to read in one screen. |
| 13 | * |
| 14 | * Labels are `{ en, zh }` pairs like docs-map.ts; other locales fall back to |
| 15 | * English through `pickText`. |
| 16 | */ |
| 17 | import type { LocalizedText } from "./content/vocabulary"; |
| 18 | import { DOC_TOPICS, type DocTopic } from "./docs-map"; |
| 19 | import { normalizeQuery } from "./search-utils"; |
| 20 | |
| 21 | export interface DocTask { |
| 22 | id: string; |
| 23 | label: LocalizedText; |
| 24 | description: LocalizedText; |
| 25 | /** Locale-relative route, e.g. "/install" or "/docs/modes". */ |
| 26 | href: string; |
| 27 | /** Owning docs-map topic id, for grouping and source attribution. */ |
| 28 | topicId: DocTopic["id"]; |
| 29 | /** Extra search words, both languages, lowercase not required. */ |
| 30 | keywords: LocalizedText; |
| 31 | } |
| 32 | |
| 33 | export const DOC_TASKS: DocTask[] = [ |
| 34 | { |
| 35 | id: "install", |
| 36 | label: { en: "Install Codewhale", zh: "安装 Codewhale" }, |
| 37 | description: { |
| 38 | en: "One command on macOS or Linux; npm, Cargo, release binaries, and the Homebrew tap on Linux also work.", |
| 39 | zh: "在 macOS 或 Linux 上只需一条命令;也可以用 npm、Cargo、发布版二进制文件,或在 Linux 上用 Homebrew tap 安装。", |
| 40 | }, |
| 41 | href: "/install", |
| 42 | topicId: "install", |
| 43 | keywords: { en: "download setup brew npm cargo docker termux binary windows", zh: "下载 安装 二进制 镜像" }, |
| 44 | }, |
| 45 | { |
| 46 | id: "first-task", |
| 47 | label: { en: "Start your first task", zh: "开始第一个任务" }, |
| 48 | description: { |
| 49 | en: "Open Codewhale in a project, look around in Plan, then let it edit in Work.", |
| 50 | zh: "在项目中打开 Codewhale,先在 Plan 里了解项目,再让它在 Work 里动手修改。", |
| 51 | }, |
| 52 | href: "/docs/guide", |
| 53 | topicId: "guide", |
| 54 | keywords: { en: "getting started quickstart tutorial first run", zh: "入门 快速开始 教程 首次运行" }, |
| 55 | }, |
| 56 | { |
| 57 | id: "connect-provider", |
| 58 | label: { en: "Connect a provider", zh: "连接模型提供商" }, |
| 59 | description: { |
| 60 | en: "Save a key for DeepSeek, Anthropic, OpenAI, Google or another provider, or run a model yourself with no key.", |
| 61 | zh: "为 DeepSeek、Anthropic、OpenAI、Google 等提供商保存密钥,或者不用密钥自己运行模型。", |
| 62 | }, |
| 63 | href: "/docs/auth", |
| 64 | topicId: "auth", |
| 65 | keywords: { en: "api key byok auth set login account ollama vllm sglang local", zh: "密钥 登录 账户 本地模型" }, |
| 66 | }, |
| 67 | { |
| 68 | id: "sign-in", |
| 69 | label: { en: "Sign in to Codewhale", zh: "登录 Codewhale" }, |
| 70 | description: { |
| 71 | en: "Sign in to an existing account from the web, the desktop app, or the terminal, and sign out again.", |
| 72 | zh: "在网页、桌面应用或终端登录已有账户,并在需要时退出登录。", |
| 73 | }, |
| 74 | href: "/docs/account", |
| 75 | topicId: "account", |
| 76 | keywords: { en: "login logout sign out account export delete data privacy api key", zh: "登录 退出 账户 导出 删除 数据 隐私" }, |
| 77 | }, |
| 78 | { |
| 79 | id: "choose-model", |
| 80 | label: { en: "Choose or switch models", zh: "选择或切换模型" }, |
| 81 | description: { |
| 82 | en: "Supported providers, switching mid-session, and local runners.", |
| 83 | zh: "支持的提供商、在会话中切换模型,以及本地运行器。", |
| 84 | }, |
| 85 | href: "/models", |
| 86 | topicId: "providers", |
| 87 | keywords: { en: "model switch provider openai-compatible", zh: "模型 切换 提供商" }, |
| 88 | }, |
| 89 | { |
| 90 | id: "set-approvals", |
| 91 | label: { en: "Decide what runs without asking", zh: "决定哪些操作无需询问" }, |
| 92 | description: { |
| 93 | en: "Plan, Work, or Operate; Ask, Auto-Review, or Full Access; and how to answer a prompt.", |
| 94 | zh: "Plan、Work 或 Operate;Ask、Auto-Review 或 Full Access;以及如何回应审批提示。", |
| 95 | }, |
| 96 | href: "/docs/modes", |
| 97 | topicId: "modes", |
| 98 | keywords: { en: "mode tab shift+tab ask auto-review full access permission", zh: "模式 审批 权限" }, |
| 99 | }, |
| 100 | { |
| 101 | id: "review-changes", |
| 102 | label: { en: "Review what changed", zh: "查看改动" }, |
| 103 | description: { |
| 104 | en: "See every edit, roll files back to an earlier turn, and get a code review before you push.", |
| 105 | zh: "查看每一处修改,把文件回滚到之前的回合,并在推送前做代码审查。", |
| 106 | }, |
| 107 | href: "/docs/review", |
| 108 | topicId: "review", |
| 109 | keywords: { en: "diff undo restore rollback snapshot code review", zh: "差异 撤销 回滚 快照 审查" }, |
| 110 | }, |
| 111 | { |
| 112 | "id": "preview-request", |
| 113 | "label": { |
| 114 | "en": "Inspect the outbound request", |
| 115 | "zh": "检查出站请求" |
| 116 | }, |
| 117 | "description": { |
| 118 | "en": "Read a redacted request manifest without sending or changing session state.", |
| 119 | "zh": "读取脱敏请求清单,不发送请求也不修改会话状态。" |
| 120 | }, |
| 121 | "href": "/docs/trust", |
| 122 | "topicId": "trust", |
| 123 | "keywords": { |
| 124 | "en": "preview-request preview_request dryrun prompt payload manifest offline", |
| 125 | "zh": "请求 提示 预览 清单 离线" |
| 126 | } |
| 127 | }, |
| 128 | { |
| 129 | "id": "language-server", |
| 130 | "label": { |
| 131 | "en": "Read language-server diagnostics", |
| 132 | "zh": "读取语言服务器诊断" |
| 133 | }, |
| 134 | "description": { |
| 135 | "en": "Return LSP errors after edits and configure custom servers by file extension.", |
| 136 | "zh": "修改后返回 LSP 错误,并按文件扩展名配置自定义服务器。" |
| 137 | }, |
| 138 | "href": "/docs/tools", |
| 139 | "topicId": "tools", |
| 140 | "keywords": { |
| 141 | "en": "lsp diagnostics type errors language server php custom", |
| 142 | "zh": "语言服务器 诊断 类型 错误" |
| 143 | } |
| 144 | }, |
| 145 | { |
| 146 | "id": "execution-policy", |
| 147 | "label": { |
| 148 | "en": "Inspect execution policy rules", |
| 149 | "zh": "检查执行策略规则" |
| 150 | }, |
| 151 | "description": { |
| 152 | "en": "Read rule sources, matchers and scope; understand allow, ask and deny precedence.", |
| 153 | "zh": "查看规则来源、匹配器与作用域,了解 allow、ask 和 deny 的优先级。" |
| 154 | }, |
| 155 | "href": "/docs/sandbox", |
| 156 | "topicId": "sandbox", |
| 157 | "keywords": { |
| 158 | "en": "exec-policy execpolicy permissions rules prefix deny ask allow", |
| 159 | "zh": "执行策略 权限 规则 拒绝 审批" |
| 160 | } |
| 161 | }, |
| 162 | { |
| 163 | "id": "manage-skills", |
| 164 | "label": { |
| 165 | "en": "Manage reusable skills", |
| 166 | "zh": "管理可复用技能" |
| 167 | }, |
| 168 | "description": { |
| 169 | "en": "Find SKILL.md folders, import into owned roots and control invocation.", |
| 170 | "zh": "查找 SKILL.md 文件夹、导入自有目录并控制调用。" |
| 171 | }, |
| 172 | "href": "/docs/skills", |
| 173 | "topicId": "skills", |
| 174 | "keywords": { |
| 175 | "en": "skills trust skill.md invocation install claude agents", |
| 176 | "zh": "技能 信任 安装 调用" |
| 177 | } |
| 178 | }, |
| 179 | { |
| 180 | "id": "move-from-claude-code", |
| 181 | "label": { |
| 182 | "en": "Bring your settings from another coding agent", |
| 183 | "zh": "从其他编码智能体带来你的设置" |
| 184 | }, |
| 185 | "description": { |
| 186 | "en": "Keep compatible instructions and skills, and review a settings import plan.", |
| 187 | "zh": "保留兼容指令与技能,并审阅设置导入方案。" |
| 188 | }, |
| 189 | "href": "/docs/claude-code", |
| 190 | "topicId": "claude-code", |
| 191 | "keywords": { |
| 192 | "en": "import-claude plugin settings migration move import instructions skills", |
| 193 | "zh": "迁移 导入 插件 设置 指令 技能" |
| 194 | } |
| 195 | }, |
| 196 | { |
| 197 | id: "receipts", |
| 198 | label: { en: "See what a session did", zh: "查看会话做了什么" }, |
| 199 | description: { |
| 200 | en: "Read a session receipt of commands, file changes, tools and approval decisions.", |
| 201 | zh: "阅读会话收据,查看命令、文件修改、工具与审批决策。", |
| 202 | }, |
| 203 | href: "/docs/review", |
| 204 | topicId: "review", |
| 205 | keywords: { en: "receipt receipts audit tool approval command file export", zh: "收据 推送 导出" }, |
| 206 | }, |
| 207 | { |
| 208 | id: "watch-sessions", |
| 209 | label: { en: "Watch each session at a glance", zh: "一眼查看每个会话" }, |
| 210 | description: { |
| 211 | en: "Run /whale in each terminal to see which session is working, waiting for you, done, or failed.", |
| 212 | zh: "在每个终端运行 /whale,看清哪个会话在工作、在等你、已完成或失败。", |
| 213 | }, |
| 214 | href: "/docs/pet", |
| 215 | topicId: "pet", |
| 216 | keywords: { en: "pet whale status glance terminals sessions inspect f5", zh: "鲸鱼 状态 终端 会话 查看" }, |
| 217 | }, |
| 218 | { |
| 219 | id: "run-workflow", |
| 220 | label: { en: "Run a workflow", zh: "运行 Workflow" }, |
| 221 | description: { |
| 222 | en: "Write a repeatable Workflow, run it as a Lane, and watch or stop it from any terminal.", |
| 223 | zh: "编写可重复的 Workflow,把它作为 Lane 运行,并在任何终端查看或停止它。", |
| 224 | }, |
| 225 | href: "/docs/fleet", |
| 226 | topicId: "fleet", |
| 227 | keywords: { en: "fleet workflow lane operate durable tasks.json", zh: "编排 持久 工作流" }, |
| 228 | }, |
| 229 | { |
| 230 | id: "parallel-agents", |
| 231 | label: { en: "Run agents in parallel", zh: "并行运行 Agent" }, |
| 232 | description: { |
| 233 | en: "Roles, separate worktrees for parallel edits, and how to watch sub-agents.", |
| 234 | zh: "角色、为并行修改准备的独立工作树,以及如何查看子 Agent。", |
| 235 | }, |
| 236 | href: "/docs/subagents", |
| 237 | topicId: "subagents", |
| 238 | keywords: { en: "agent explore reviewer implement worktree concurrency subagents", zh: "子代理 并行 角色 工作树" }, |
| 239 | }, |
| 240 | { |
| 241 | id: "mcp-server", |
| 242 | label: { en: "Connect tools with MCP", zh: "用 MCP 连接工具" }, |
| 243 | description: { |
| 244 | en: "Add a local or remote MCP server, sign in with OAuth, or serve Codewhale over MCP.", |
| 245 | zh: "添加本地或远程 MCP 服务器、用 OAuth 登录,或把 Codewhale 作为 MCP 服务器提供。", |
| 246 | }, |
| 247 | href: "/docs/mcp", |
| 248 | topicId: "mcp", |
| 249 | keywords: { en: "model context protocol tools stdio http oauth", zh: "工具 协议 服务器" }, |
| 250 | }, |
| 251 | { |
| 252 | id: "code-mode", |
| 253 | label: { en: "Try code mode", zh: "试用代码模式" }, |
| 254 | description: { |
| 255 | en: "Let the model compose several tool calls — MCP and plugin tools included — in one short program, under the same approvals as direct calls. Experimental, on by default.", |
| 256 | zh: "让模型在一段简短的程序中组合多个工具调用(包括 MCP 和插件工具),审批流程与直接调用相同。实验性功能,默认开启。", |
| 257 | }, |
| 258 | href: "/docs/mcp", |
| 259 | topicId: "mcp", |
| 260 | keywords: { en: "code_mode execute_tools javascript experimental", zh: "代码模式 实验" }, |
| 261 | }, |
| 262 | { |
| 263 | id: "hooks", |
| 264 | label: { en: "Run commands on events", zh: "在事件发生时运行命令" }, |
| 265 | description: { |
| 266 | en: "Block a risky command, add context, or get notified when Codewhale waits for you.", |
| 267 | zh: "拦下危险命令、补充上下文,或在 Codewhale 等你回应时收到提醒。", |
| 268 | }, |
| 269 | href: "/docs/hooks", |
| 270 | topicId: "hooks", |
| 271 | keywords: { en: "hook lifecycle tool_call_before session_start event", zh: "钩子 生命周期 事件" }, |
| 272 | }, |
| 273 | { |
| 274 | id: "sandbox", |
| 275 | label: { en: "Limit what commands can touch", zh: "限制命令的访问范围" }, |
| 276 | description: { |
| 277 | en: "See which OS sandbox your platform has and turn on bubblewrap on Linux.", |
| 278 | zh: "了解你的平台有哪种操作系统沙箱,并在 Linux 上开启 bubblewrap。", |
| 279 | }, |
| 280 | href: "/docs/sandbox", |
| 281 | topicId: "sandbox", |
| 282 | keywords: { en: "sandbox seatbelt bwrap bubblewrap workspace-write", zh: "沙箱 隔离" }, |
| 283 | }, |
| 284 | { |
| 285 | id: "automate", |
| 286 | label: { en: "Automate with the Runtime API", zh: "用 Runtime API 自动化" }, |
| 287 | description: { |
| 288 | en: "Run one-shot jobs in CI, or drive threads and approvals over the local HTTP API.", |
| 289 | zh: "在 CI 中运行一次性任务,或通过本地 HTTP API 驱动线程和审批。", |
| 290 | }, |
| 291 | href: "/docs/runtime-api", |
| 292 | topicId: "runtime-api", |
| 293 | keywords: { en: "http api exec ci acp integration sse", zh: "接口 集成 脚本" }, |
| 294 | }, |
| 295 | { |
| 296 | id: "browser-client", |
| 297 | label: { en: "Open the browser client", zh: "打开浏览器客户端" }, |
| 298 | description: { |
| 299 | en: "Work in a local browser tab, or continue a session from the web app with /rc.", |
| 300 | zh: "在本机浏览器标签页中工作,或用 /rc 在网页应用中继续会话。", |
| 301 | }, |
| 302 | href: "/docs/web", |
| 303 | topicId: "web", |
| 304 | keywords: { en: "web ui localhost loopback remote control rc", zh: "网页 客户端 本机 远程" }, |
| 305 | }, |
| 306 | { |
| 307 | id: "troubleshoot", |
| 308 | label: { en: "Fix a problem", zh: "排查问题" }, |
| 309 | description: { |
| 310 | en: "Diagnose in one command, then fix install, key, network, and stuck-turn problems.", |
| 311 | zh: "用一条命令诊断,再解决安装、密钥、网络和回合卡住等问题。", |
| 312 | }, |
| 313 | href: "/docs/troubleshooting", |
| 314 | topicId: "troubleshooting", |
| 315 | keywords: { en: "error crash doctor diagnose recover resume docker", zh: "错误 崩溃 诊断 恢复" }, |
| 316 | }, |
| 317 | { |
| 318 | id: "trust", |
| 319 | label: { en: "See what leaves your machine", zh: "了解哪些数据会离开本机" }, |
| 320 | description: { |
| 321 | en: "What a provider receives, what usage counting sends, and how to turn it off.", |
| 322 | zh: "提供商会收到什么、用量统计发送什么,以及如何关闭。", |
| 323 | }, |
| 324 | href: "/docs/trust", |
| 325 | topicId: "trust", |
| 326 | keywords: { en: "privacy security telemetry data vulnerability report", zh: "隐私 安全 遥测 数据 漏洞" }, |
| 327 | }, |
| 328 | { |
| 329 | id: "runtime-reference", |
| 330 | label: { en: "Look up an API route or event", zh: "查找 API 路由或事件" }, |
| 331 | description: { en: "Search the HTTP routes, request fields and event contracts in the repository's main branch.", zh: "搜索仓库 main 分支中的 HTTP 路由、请求字段和事件约定。" }, |
| 332 | href: "/docs/runtime-reference", |
| 333 | topicId: "runtime-reference", |
| 334 | keywords: { en: "reference endpoint schema request response fields SSE event replay", zh: "参考 端点 结构 请求 响应 字段 事件 回放" }, |
| 335 | }, |
| 336 | { |
| 337 | id: "write-plugin", |
| 338 | label: { en: "Write and verify a small plugin", zh: "编写并核对一个小插件" }, |
| 339 | description: { en: "Create a two-file skill bundle and check its explicit greeting marker after review and activation.", zh: "创建包含两个文件的技能包,审阅并启用后,核对明确的问候标记。" }, |
| 340 | href: "/docs/plugin-authoring", |
| 341 | topicId: "plugin-authoring", |
| 342 | keywords: { en: "author plugin.json SKILL.md trust hash hello greeting bundle", zh: "编写 插件 技能 信任 哈希 问候 包" }, |
| 343 | }, |
| 344 | { |
| 345 | id: "fleet-task-spec", |
| 346 | label: { en: "Validate a Fleet task specification", zh: "验证 Fleet 任务规范" }, |
| 347 | description: { en: "Follow the full task file tutorial and validate its structure and configured route before launching workers.", zh: "按照完整任务文件教程,在启动 worker 前验证结构与已配置路由。" }, |
| 348 | href: "/docs/workflow-tutorial", |
| 349 | topicId: "workflow-tutorial", |
| 350 | keywords: { en: "fleet tasks.json check validate durable workers resume restart", zh: "任务 检查 验证 持久 恢复 重启" }, |
| 351 | }, |
| 352 | |
| 353 | ]; |
| 354 | |
| 355 | /** The owning topic for a task, or undefined if the registry drifted. */ |
| 356 | export function taskTopic(task: DocTask): DocTopic | undefined { |
| 357 | return DOC_TOPICS.find((t) => t.id === task.topicId); |
| 358 | } |
| 359 | |
| 360 | /** Lowercase haystack across both languages, the route, and the topic. */ |
| 361 | export function docTaskHaystack(task: DocTask): string { |
| 362 | return normalizeQuery( |
| 363 | [ |
| 364 | task.id, |
| 365 | task.label.en, |
| 366 | task.label.zh, |
| 367 | task.description.en, |
| 368 | task.description.zh, |
| 369 | task.keywords.en, |
| 370 | task.keywords.zh, |
| 371 | task.href, |
| 372 | task.topicId, |
| 373 | ].join(" "), |
| 374 | ); |
| 375 | } |
| 376 |