返回 CodeWhale
docs-fleet.ts
根目录 / web / lib / i18n / dictionaries / zh / docs-fleet.ts
1 import type { DocsFleetDict } from "../types";
2
3 /** 「运行工作流」页的简体中文词典;与 `en/docs-fleet.ts` 逐段对应。 */
4 export const docsFleet: DocsFleetDict = {
5 metaTitle: "运行工作流 · Codewhale 文档",
6 metaDescription:
7 "在 Fleet 中保存角色和模型,编写可重复的工作流,把它作为可查看、可停止的 Lane 运行,并用持久的智能体批量执行任务。",
8 bodyClassName: "text-ink-soft leading-[1.9] tracking-wide",
9 title: "运行工作流",
10 lede:
11 "大多数多步骤工作,直接提出来就行:在 Operate 模式下,Codewhale 会自己规划步骤,并把彼此独立的步骤并行执行。如果你希望每次都按同一套有序计划来做——分阶段、并行分支、最后汇总——并且每次运行都留有记录,就写一个工作流。",
12 sections: [
13 {
14 id: "fleet",
15 title: "在 Fleet 中保存角色",
16 blocks: [
17 {
18 p: "Fleet 是 Codewhale 可以分派工作的角色列表,以及每个角色使用的模型。在会话中配置一次即可:",
19 },
20 { code: "/fleet setup\n/fleet\n/fleet saved", lang: "Codewhale" },
21 {
22 p: "`/fleet setup` 会带你选定一个角色、它使用的模型(或“沿用会话的模型”),以及保存位置:当前项目,或者对所有仓库都生效的个人配置。写入之前你会看到完整的文件内容。`/fleet` 显示当前所选 Fleet 的成员,`/fleet saved` 用于在已命名的 Fleet 之间切换。",
23 },
24 {
25 p: "Fleet 只决定由谁来做。一个智能体能读、能写、能运行什么,仍然取决于你的工作区信任、[审批设置](/docs/modes)和沙箱。",
26 },
27 ],
28 },
29 {
30 id: "write",
31 title: "编写工作流",
32 blocks: [
33 {
34 p: "工作流是放在仓库 `workflows/` 文件夹中的一个 JavaScript 文件。它只描述步骤,本身不干活。下面这个例子先并行审查两个部分,再汇总结论。把它保存为 `workflows/docs_readiness.workflow.js`:",
35 },
36 {
37 code: `export default workflow({
38 "id": "docs-readiness",
39 "goal": "Review the docs and code for gaps, then summarize the next edit",
40 "nodes": [
41 {
42 "branch": {
43 "id": "parallel-review",
44 "parallel": true,
45 "children": [
46 { "agent": { "id": "code-review", "prompt": "Inspect src/ for undocumented behavior.",
47 "agent_type": "review", "mode": "read_only", "file_scope": ["src"] } },
48 { "agent": { "id": "docs-review", "prompt": "Inspect docs/ for stale or missing steps.",
49 "agent_type": "review", "mode": "read_only", "file_scope": ["docs"] } }
50 ]
51 }
52 },
53 {
54 "reduce": {
55 "id": "summary",
56 "inputs": ["code-review", "docs-review"],
57 "prompt": "Combine the findings into the safest next edit."
58 }
59 }
60 ]
61 });`,
62 lang: "workflows/docs_readiness.workflow.js",
63 },
64 {
65 p: "可用的步骤类型有 `agent`、`branch`、`sequence`、`reduce`、`loop_until`、`cond`、`expand` 和 `teacher_review`。工作流文件本身不能访问文件、shell 或网络,`import`、`fetch`、`eval` 和 `async` 都会被拒绝。真正干活的是它启动的智能体,它们按你平常的权限运行。",
66 },
67 {
68 note: "一次运行最多可启动 1,000 个智能体,同时工作的最多 16 个,其余排队等待。循环必须声明 `max_iterations`。",
69 },
70 ],
71 },
72 {
73 id: "run",
74 title: "运行",
75 blocks: [
76 {
77 code: `codewhale workflow run docs-readiness --runtime inline
78 codewhale workflow run docs-readiness --goal "prepare the 1.2 release" --verify`,
79 lang: "终端",
80 },
81 {
82 p: "Codewhale 会根据名字找到 `workflows/docs_readiness.workflow.js`,检查后启动。`--runtime inline` 在当前终端中运行;默认的 `tmux` 则在一个独立的 tmux 会话中运行,关闭终端后也会继续。`--verify` 会在成功完成后运行验证关卡,`--fleet <name>` 则使用指定的 Fleet 而不是内置角色。",
83 },
84 {
85 p: "如果不想动到当前的工作副本,加上 `--worktree-repo . --branch <name>`:这次运行会拥有自己的 git 工作树和分支。",
86 },
87 {
88 p: "在会话中,`/workflow` 用于启动工作流,`/workflows` 用于列出或取消本会话中的运行。",
89 },
90 ],
91 },
92 {
93 id: "watch",
94 title: "查看和停止运行",
95 blocks: [
96 { p: "每次运行都是一个 Lane。Lane 会保存到磁盘上,所以你可以在任何终端里查看:" },
97 {
98 code: `codewhale lane list
99 codewhale lane status <lane-id>
100 codewhale lane logs <lane-id>
101 codewhale lane attach <lane-id>
102 codewhale lane interrupt <lane-id>`,
103 lang: "终端",
104 },
105 {
106 p: "`lane list`、`lane status` 和 `lane interrupt` 都支持 `--json`,会输出一份机器可读的回执。在会话中,`/lane` 提供同样的操作,结果也完全一致。",
107 },
108 ],
109 },
110 {
111 id: "batch",
112 title: "批量运行任务",
113 blocks: [
114 {
115 p: "如果你手上是一串彼此独立的任务,而不是一套计划,就把它们写成任务文件,作为一次 Fleet 运行来执行。每个任务写明目标、角色和允许写入的路径。完整的 `tasks.json` 示例见[教程](https://github.com/codewhale-hq/CodeWhale/blob/main/docs/FLEET_WORKFLOW_TUTORIAL.md)。",
116 },
117 {
118 code: `codewhale fleet init
119 codewhale fleet run tasks.json --max-workers 4
120 codewhale fleet status
121 codewhale fleet logs <worker-id>
122 codewhale fleet resume <run-id>
123 codewhale fleet stop --all`,
124 lang: "终端",
125 },
126 {
127 p: "`fleet status` 会根据当前工作区的运行记录,统计排队中、运行中、已完成和失败的工作。笔记本休眠或管理进程退出后,`fleet resume` 能接着原来的运行继续,而不会新开一次。如果只想看挂在当前会话上的智能体,用 `/fleet workers`(或 `/subagents`)。",
128 },
129 ],
130 },
131 ],
132 next: [
133 {
134 href: "/docs/subagents",
135 label: "并行运行智能体",
136 note: "不写工作流,也能把一个任务中彼此独立的部分交给子智能体。",
137 },
138 {
139 href: "/docs/review",
140 label: "查看改动",
141 note: "检查一次运行产生的 diff,并在推送前做一次审查。",
142 },
143 {
144 href: "/docs/vocabulary",
145 label: "产品名词",
146 note: "用一句话分别说明 Fleet、Workflow、Lane 和 Runtime。",
147 },
148 ],
149 sourceNote:
150 "来源文档:docs/FLEET.md、docs/FLEET_WORKFLOW_TUTORIAL.md、docs/WORKFLOW_AUTHORING.md · 修改时同步更新 docs-map.ts。",
151 };
152
152 lines TYPESCRIPT