@zmice/zc 0.2.4 → 0.2.6
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.
- package/README.md +89 -9
- package/dist/cli/__tests__/platform.test.js +169 -2
- package/dist/cli/__tests__/platform.test.js.map +1 -1
- package/dist/cli/__tests__/surface.test.js +52 -0
- package/dist/cli/__tests__/surface.test.js.map +1 -1
- package/dist/cli/__tests__/team.test.d.ts +2 -0
- package/dist/cli/__tests__/team.test.d.ts.map +1 -0
- package/dist/cli/__tests__/team.test.js +29 -0
- package/dist/cli/__tests__/team.test.js.map +1 -0
- package/dist/cli/__tests__/upstream.test.js +4 -0
- package/dist/cli/__tests__/upstream.test.js.map +1 -1
- package/dist/cli/platform.d.ts +11 -3
- package/dist/cli/platform.d.ts.map +1 -1
- package/dist/cli/platform.js +186 -49
- package/dist/cli/platform.js.map +1 -1
- package/dist/cli/team.d.ts.map +1 -1
- package/dist/cli/team.js +114 -4
- package/dist/cli/team.js.map +1 -1
- package/dist/cli/upstream.d.ts +1 -0
- package/dist/cli/upstream.d.ts.map +1 -1
- package/dist/cli/upstream.js +84 -5
- package/dist/cli/upstream.js.map +1 -1
- package/dist/node_modules/@zmice/platform-core/dist/index.d.ts +37 -3
- package/dist/node_modules/@zmice/platform-core/dist/index.d.ts.map +1 -1
- package/dist/node_modules/@zmice/platform-core/dist/index.js +68 -0
- package/dist/node_modules/@zmice/platform-core/dist/index.js.map +1 -1
- package/dist/node_modules/@zmice/platform-core/dist/index.test.js +44 -1
- package/dist/node_modules/@zmice/platform-core/dist/index.test.js.map +1 -1
- package/dist/runtime/__tests__/worktree-manager.test.js +63 -1
- package/dist/runtime/__tests__/worktree-manager.test.js.map +1 -1
- package/dist/runtime/worktree-manager.d.ts +26 -1
- package/dist/runtime/worktree-manager.d.ts.map +1 -1
- package/dist/runtime/worktree-manager.js +126 -12
- package/dist/runtime/worktree-manager.js.map +1 -1
- package/dist/team/__tests__/orchestrator.test.js +40 -0
- package/dist/team/__tests__/orchestrator.test.js.map +1 -1
- package/dist/team/__tests__/planner.test.d.ts +2 -0
- package/dist/team/__tests__/planner.test.d.ts.map +1 -0
- package/dist/team/__tests__/planner.test.js +43 -0
- package/dist/team/__tests__/planner.test.js.map +1 -0
- package/dist/team/__tests__/task-queue.test.js +18 -0
- package/dist/team/__tests__/task-queue.test.js.map +1 -1
- package/dist/team/orchestrator.d.ts +2 -1
- package/dist/team/orchestrator.d.ts.map +1 -1
- package/dist/team/orchestrator.js +29 -10
- package/dist/team/orchestrator.js.map +1 -1
- package/dist/team/planner.d.ts +27 -0
- package/dist/team/planner.d.ts.map +1 -0
- package/dist/team/planner.js +120 -0
- package/dist/team/planner.js.map +1 -0
- package/dist/team/task-queue.d.ts +3 -0
- package/dist/team/task-queue.d.ts.map +1 -1
- package/dist/team/task-queue.js +11 -2
- package/dist/team/task-queue.js.map +1 -1
- package/dist/utils/qwen-extension-cli.d.ts.map +1 -1
- package/dist/utils/qwen-extension-cli.js +23 -0
- package/dist/utils/qwen-extension-cli.js.map +1 -1
- package/dist/utils/qwen-extension-cli.test.js +40 -0
- package/dist/utils/qwen-extension-cli.test.js.map +1 -1
- package/package.json +3 -3
- package/vendor/node_modules/@zmice/platform-core/dist/index.d.ts +37 -3
- package/vendor/node_modules/@zmice/platform-core/dist/index.d.ts.map +1 -1
- package/vendor/node_modules/@zmice/platform-core/dist/index.js +68 -0
- package/vendor/node_modules/@zmice/platform-core/dist/index.js.map +1 -1
- package/vendor/node_modules/@zmice/platform-core/dist/index.test.js +44 -1
- package/vendor/node_modules/@zmice/platform-core/dist/index.test.js.map +1 -1
- package/vendor/packages/platform-claude/dist/index.d.ts.map +1 -1
- package/vendor/packages/platform-claude/dist/index.js +12 -70
- package/vendor/packages/platform-claude/dist/index.js.map +1 -1
- package/vendor/packages/platform-codex/dist/generate.d.ts +1 -1
- package/vendor/packages/platform-codex/dist/generate.d.ts.map +1 -1
- package/vendor/packages/platform-codex/dist/generate.js +1 -1
- package/vendor/packages/platform-codex/dist/generate.js.map +1 -1
- package/vendor/packages/platform-codex/dist/index.d.ts +16 -1
- package/vendor/packages/platform-codex/dist/index.d.ts.map +1 -1
- package/vendor/packages/platform-codex/dist/index.js +268 -67
- package/vendor/packages/platform-codex/dist/index.js.map +1 -1
- package/vendor/packages/platform-codex/dist/index.test.js +102 -7
- package/vendor/packages/platform-codex/dist/index.test.js.map +1 -1
- package/vendor/packages/platform-opencode/dist/index.d.ts.map +1 -1
- package/vendor/packages/platform-opencode/dist/index.js +15 -81
- package/vendor/packages/platform-opencode/dist/index.js.map +1 -1
- package/vendor/packages/platform-qwen/dist/index.d.ts.map +1 -1
- package/vendor/packages/platform-qwen/dist/index.js +28 -84
- package/vendor/packages/platform-qwen/dist/index.js.map +1 -1
- package/vendor/packages/toolkit/src/content/agents/architect/body.md +8 -0
- package/vendor/packages/toolkit/src/content/agents/code-reviewer/body.md +10 -0
- package/vendor/packages/toolkit/src/content/agents/product-owner/body.md +8 -0
- package/vendor/packages/toolkit/src/content/commands/plan-review/body.md +3 -1
- package/vendor/packages/toolkit/src/content/commands/start/body.md +51 -2
- package/vendor/packages/toolkit/src/content/commands/start/meta.yaml +2 -2
- package/vendor/packages/toolkit/src/content/skills/branch-finish-and-cleanup/body.md +17 -0
- package/vendor/packages/toolkit/src/content/skills/browser-qa-testing/body.md +77 -520
- package/vendor/packages/toolkit/src/content/skills/ci-cd-and-automation/body.md +56 -387
- package/vendor/packages/toolkit/src/content/skills/code-review-and-quality/body.md +10 -0
- package/vendor/packages/toolkit/src/content/skills/code-simplification/body.md +55 -301
- package/vendor/packages/toolkit/src/content/skills/context-engineering/body.md +10 -0
- package/vendor/packages/toolkit/src/content/skills/continuous-learning/body.md +66 -331
- package/vendor/packages/toolkit/src/content/skills/multi-perspective-review/body.md +30 -1
- package/vendor/packages/toolkit/src/content/skills/parallel-agent-dispatch/body.md +79 -317
- package/vendor/packages/toolkit/src/content/skills/performance-optimization/body.md +60 -330
- package/vendor/packages/toolkit/src/content/skills/planning-and-task-breakdown/body.md +35 -0
- package/vendor/packages/toolkit/src/content/skills/sdd-tdd-workflow/body.md +66 -342
- package/vendor/packages/toolkit/src/content/skills/sprint-retrospective/body.md +66 -303
- package/vendor/packages/toolkit/src/content/skills/team-orchestration/body.md +81 -327
- package/vendor/packages/toolkit/src/content/skills/test-driven-development/body.md +50 -346
- package/vendor/packages/toolkit/src/content/skills/using-agent-skills/body.md +26 -2
- package/vendor/references/upstreams.yaml +5 -0
- package/dist/cli/setup.d.ts +0 -3
- package/dist/cli/setup.d.ts.map +0 -1
- package/dist/cli/setup.js +0 -41
- package/dist/cli/setup.js.map +0 -1
|
@@ -1,372 +1,126 @@
|
|
|
1
1
|
# Team Orchestration
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 角色定位
|
|
4
4
|
|
|
5
|
-
zc
|
|
5
|
+
使用 `zc team` 把多个 AI CLI worker 运行在 tmux pane 和 git worktree 中,适合需要文件系统级隔离、长时间并行或多 CLI 协作的任务。
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
这是重型能力。默认先考虑串行执行或 `parallel-agent-dispatch`;只有用户明确要求多 worker / team 模式,且文件边界清楚时才启动。
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|------|------|
|
|
11
|
-
| **Team** | 一组 worker 的运行实例,对应一个 tmux session 和一组 worktree |
|
|
12
|
-
| **Worker** | 一个运行中的 CLI 进程(Codex 或 Qwen Code),在独立 worktree 中工作 |
|
|
13
|
-
| **TaskQueue** | claim-safe 的任务队列,通过 token 机制防止竞态,支持依赖关系 |
|
|
14
|
-
| **Mailbox** | Worker 间的消息通信系统,支持点对点发送和广播 |
|
|
15
|
-
| **Orchestrator** | 编排控制器,负责启动团队、分派任务、监控 worker 健康、持久化状态 |
|
|
9
|
+
## 何时使用
|
|
16
10
|
|
|
17
|
-
|
|
18
|
-
- `codex` — OpenAI Codex CLI
|
|
19
|
-
- `qwen-code` — Qwen Code CLI
|
|
11
|
+
使用:
|
|
20
12
|
|
|
21
|
-
|
|
13
|
+
- 多个任务可以分配给不同 worker。
|
|
14
|
+
- 需要独立 worktree 避免写入冲突。
|
|
15
|
+
- 需要不同 CLI 处理不同类型任务。
|
|
16
|
+
- 任务较长,值得承担 fan-in 和清理成本。
|
|
22
17
|
|
|
23
|
-
|
|
24
|
-
需要多个 AI agent 并行工作? ─── 否 ──→ 用 zc run 单 worker 执行
|
|
25
|
-
│
|
|
26
|
-
是
|
|
27
|
-
▼
|
|
28
|
-
任务可以分配给不同 worker? ─── 否 ──→ subagent-driven-development(串行委派)
|
|
29
|
-
│
|
|
30
|
-
是
|
|
31
|
-
▼
|
|
32
|
-
需要文件系统级隔离? ─── 否 ──→ parallel-agent-dispatch(上下文级并行)
|
|
33
|
-
│
|
|
34
|
-
是
|
|
35
|
-
▼
|
|
36
|
-
team-orchestration ✓(tmux + worktree 隔离)
|
|
37
|
-
```
|
|
18
|
+
不使用:
|
|
38
19
|
|
|
39
|
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
-
|
|
43
|
-
- 长时间运行的批量任务,需要并行加速
|
|
20
|
+
- 单个简单任务。
|
|
21
|
+
- 任务高度耦合、共享大量上下文。
|
|
22
|
+
- 没有测试或集成验证方式。
|
|
23
|
+
- 只是想“快一点”,但文件所有权不清。
|
|
44
24
|
|
|
45
|
-
|
|
46
|
-
- 单个简单任务 — 直接用 `zc run`
|
|
47
|
-
- 任务之间紧耦合、需要共享上下文 — 用串行子代理
|
|
48
|
-
- 不需要文件系统隔离的轻量并行 — 用 `parallel-agent-dispatch`
|
|
25
|
+
## 快速路径
|
|
49
26
|
|
|
50
|
-
|
|
27
|
+
1. 先用 `zc doctor` 检查环境。
|
|
28
|
+
2. 用 `zc team plan` 做 dry-run,任务必须带 `files=` 边界。
|
|
29
|
+
3. 只有 `canStart=true` 且用户确认后,才运行 `zc team start`。
|
|
30
|
+
4. 用 `zc team status` 和 `zc team log` 监控 worker。
|
|
31
|
+
5. fan-in 前运行 `zc team shutdown <team> --plan` 查看 clean/dirty/ahead/merged 状态。
|
|
32
|
+
6. 明确每个分支去向后再 `zc team shutdown`。
|
|
51
33
|
|
|
52
34
|
```bash
|
|
53
|
-
# 1. 检查环境(git、tmux、Node.js、CLI 是否就绪)
|
|
54
35
|
zc doctor
|
|
55
36
|
|
|
56
|
-
|
|
37
|
+
zc team plan \
|
|
38
|
+
-w 2 \
|
|
39
|
+
-t "API | files=src/api.ts,src/api.test.ts" \
|
|
40
|
+
-t "UI | files=src/ui.ts,src/ui.test.ts"
|
|
41
|
+
|
|
57
42
|
zc team start \
|
|
58
43
|
-w "w1:codex,w2:qwen-code" \
|
|
59
|
-
-t "
|
|
60
|
-
-t "
|
|
44
|
+
-t "API | files=src/api.ts,src/api.test.ts" \
|
|
45
|
+
-t "UI | files=src/ui.ts,src/ui.test.ts"
|
|
61
46
|
|
|
62
|
-
# 3. 查看团队状态
|
|
63
47
|
zc team status <team-name>
|
|
64
|
-
|
|
65
|
-
# 4. 查看 worker 输出日志
|
|
66
48
|
zc team log <team-name>
|
|
67
|
-
zc team
|
|
68
|
-
|
|
69
|
-
# 5. 关闭团队(清理 tmux session + worktree)
|
|
49
|
+
zc team shutdown <team-name> --plan
|
|
70
50
|
zc team shutdown <team-name>
|
|
71
51
|
```
|
|
72
52
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
```bash
|
|
76
|
-
zc team start -n my-team -w "w1:codex,w2:codex" -t "任务A" -t "任务B"
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
指定模型:
|
|
80
|
-
|
|
81
|
-
```bash
|
|
82
|
-
zc team start -w "w1:codex" -t "任务A" -m o3
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
## 工作流详解
|
|
86
|
-
|
|
87
|
-
### 团队启动流程
|
|
88
|
-
|
|
89
|
-
```
|
|
90
|
-
zc team start
|
|
91
|
-
│
|
|
92
|
-
▼
|
|
93
|
-
1. 创建状态目录 (.zc/<team-name>/)
|
|
94
|
-
│
|
|
95
|
-
▼
|
|
96
|
-
2. 初始化子系统
|
|
97
|
-
├── TaskQueue → 加载/创建 tasks.json
|
|
98
|
-
└── Mailbox → 加载/创建 mailbox.json
|
|
99
|
-
│
|
|
100
|
-
▼
|
|
101
|
-
3. 创建 tmux session (zc-<team-name>)
|
|
102
|
-
│
|
|
103
|
-
▼
|
|
104
|
-
4. 创建任务(每个 -t 参数 → 一条 pending 任务)
|
|
105
|
-
│
|
|
106
|
-
▼
|
|
107
|
-
5. 启动 workers
|
|
108
|
-
├── 为每个 worker 创建 git worktree
|
|
109
|
-
├── 在 tmux 中创建 pane
|
|
110
|
-
└── 通过 CLI 适配器 spawn 进程
|
|
111
|
-
│
|
|
112
|
-
▼
|
|
113
|
-
6. 持久化初始状态 → state.json
|
|
114
|
-
│
|
|
115
|
-
▼
|
|
116
|
-
7. 进入 dispatch 循环(每 3 秒一轮)
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
### 任务分派机制
|
|
120
|
-
|
|
121
|
-
Orchestrator 运行一个持续的 dispatch 循环,每轮执行:
|
|
122
|
-
|
|
123
|
-
1. **健康检查** — 检测 busy worker 是否存活;若 worker 死亡,将其任务标记为 `failed`
|
|
124
|
-
2. **匹配分派** — 获取就绪任务(`getReady`:pending 且依赖已完成)和空闲 worker(`getIdleWorkers`),按顺序配对
|
|
125
|
-
3. **Claim-safe 认领** — 使用 UUID token 认领任务,防止竞态条件:
|
|
126
|
-
```
|
|
127
|
-
claim(taskId, workerId) → { task, token }
|
|
128
|
-
transition(taskId, token, "in_progress")
|
|
129
|
-
assignTask(workerId, taskId, description)
|
|
130
|
-
```
|
|
131
|
-
4. **状态持久化** — 每轮结束写入 `state.json`
|
|
132
|
-
|
|
133
|
-
**Claim Token 机制:** 每次认领生成唯一 token,后续的状态转换(完成/失败/释放)必须携带正确的 token,确保同一任务不会被两个 worker 同时操作。
|
|
134
|
-
|
|
135
|
-
### 任务状态流转
|
|
136
|
-
|
|
137
|
-
```
|
|
138
|
-
pending → claimed → in_progress → completed
|
|
139
|
-
→ failed
|
|
140
|
-
↑ │
|
|
141
|
-
└── release(释放回队列) ──┘ (shutdown 时)
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
| 状态 | 含义 |
|
|
145
|
-
|------|------|
|
|
146
|
-
| `pending` | 等待分派 |
|
|
147
|
-
| `claimed` | 已被 worker 认领,等待开始执行 |
|
|
148
|
-
| `in_progress` | 正在执行中 |
|
|
149
|
-
| `completed` | 执行成功 |
|
|
150
|
-
| `failed` | 执行失败(worker 崩溃或主动标记) |
|
|
151
|
-
|
|
152
|
-
任务支持依赖关系:只有所有 `dependencies` 中的任务都已 `completed`,该任务才会进入就绪列表。
|
|
153
|
-
|
|
154
|
-
### Worker 间通信
|
|
155
|
-
|
|
156
|
-
Mailbox 提供两种通信模式:
|
|
157
|
-
|
|
158
|
-
**点对点发送:**
|
|
159
|
-
```bash
|
|
160
|
-
zc msg send <to-worker-id> "需要你在 API 层暴露 /users 端点"
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
**广播(发给所有 worker):**
|
|
164
|
-
```bash
|
|
165
|
-
zc msg broadcast "数据库 schema 已更新,请 pull 最新代码"
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
消息状态流转:`pending → delivered → read`
|
|
53
|
+
## 任务描述规则
|
|
169
54
|
|
|
170
|
-
|
|
55
|
+
每个 `-t` 至少包含:
|
|
171
56
|
|
|
172
|
-
|
|
57
|
+
- 任务名
|
|
58
|
+
- `files=` 文件或目录所有权
|
|
59
|
+
- 验收标准
|
|
60
|
+
- 验证命令
|
|
173
61
|
|
|
174
|
-
|
|
62
|
+
示例:
|
|
175
63
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
- Node.js 版本(≥ 20.0.0)
|
|
179
|
-
- git 是否可用
|
|
180
|
-
- tmux 是否可用
|
|
181
|
-
- Codex CLI / Qwen Code CLI 是否安装
|
|
182
|
-
|
|
183
|
-
```bash
|
|
184
|
-
zc doctor
|
|
64
|
+
```text
|
|
65
|
+
实现用户认证 API | files=src/auth.ts,src/auth.test.ts | verify=pnpm test auth
|
|
185
66
|
```
|
|
186
67
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
启动单个 CLI worker 执行任务,不创建团队:
|
|
68
|
+
没有 `files=` 时,默认不能证明任务可安全并行。
|
|
190
69
|
|
|
191
|
-
|
|
192
|
-
zc run "实现用户登录功能" # 默认使用 codex
|
|
193
|
-
zc run "重构数据层" --cli qwen-code # 使用 qwen-code
|
|
194
|
-
zc run "修复 bug" -m o3 -w ./src # 指定模型和工作目录
|
|
195
|
-
```
|
|
70
|
+
## 启动前推荐格式
|
|
196
71
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
72
|
+
```text
|
|
73
|
+
Recommendation: 使用 zc team because <文件系统隔离收益> outweighs <tmux/worktree/fan-in 成本>。
|
|
74
|
+
- worker:
|
|
75
|
+
- worktree 边界:
|
|
76
|
+
- 不使用 team 的替代方案:
|
|
77
|
+
- fan-in 验证:
|
|
78
|
+
- 清理策略:
|
|
203
79
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
```bash
|
|
207
|
-
zc team start -w "w1:codex,w2:qwen-code" -t "任务1" -t "任务2"
|
|
80
|
+
确认后我再启动;不确认则按串行或 Context Fan-Out 推进。
|
|
208
81
|
```
|
|
209
82
|
|
|
210
|
-
|
|
211
|
-
|------|------|--------|
|
|
212
|
-
| `-w, --workers <spec>` | Worker 规格 `id:cli,...`(必需) | — |
|
|
213
|
-
| `-t, --tasks <task...>` | 任务描述(可重复,至少一个) | — |
|
|
214
|
-
| `-n, --name <name>` | 团队名称 | `team-YYYYMMDD-HHmmss` |
|
|
215
|
-
| `-m, --model <model>` | 模型名称 | — |
|
|
83
|
+
## Worker 协作纪律
|
|
216
84
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
```
|
|
85
|
+
- 每个 worker 只修改自己的 `files=` 范围。
|
|
86
|
+
- 共享接口变更必须通过 mailbox 或主线程广播。
|
|
87
|
+
- worker 完成时报告修改文件、验证结果和待集成事项。
|
|
88
|
+
- 主线程负责最终集成,不把 fan-in 交给任意单个 worker 自行处理。
|
|
222
89
|
|
|
223
|
-
|
|
90
|
+
## Fan-In 与收尾
|
|
224
91
|
|
|
225
|
-
|
|
92
|
+
结束前必须记录:
|
|
226
93
|
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
|
|
94
|
+
```text
|
|
95
|
+
Team acceptance transcript:
|
|
96
|
+
- Team:
|
|
97
|
+
- Workers:
|
|
98
|
+
- Task ownership:
|
|
99
|
+
- Branch/worktree status:
|
|
100
|
+
- Worker results:
|
|
101
|
+
- Integrated diff:
|
|
102
|
+
- Verification:
|
|
103
|
+
- Cleanup:
|
|
230
104
|
```
|
|
231
105
|
|
|
232
|
-
|
|
106
|
+
收尾判断:
|
|
233
107
|
|
|
234
|
-
|
|
108
|
+
- clean 且已合入:可删除 worktree/branch。
|
|
109
|
+
- dirty:先读 diff,决定合入、保留或放弃。
|
|
110
|
+
- ahead 但未合入:明确是否提交、PR 或丢弃。
|
|
111
|
+
- unknown:不要直接删除,先人工确认状态。
|
|
235
112
|
|
|
236
|
-
|
|
237
|
-
zc team shutdown <team-name>
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
终止 tmux session,清理 git worktree。
|
|
241
|
-
|
|
242
|
-
在执行 `shutdown` 前,先完成收尾判定:
|
|
243
|
-
|
|
244
|
-
- 哪些 worker 分支已经可以合入或开 PR
|
|
245
|
-
- 哪些任务失败,需要保留证据后再清理
|
|
246
|
-
- 哪些 worktree 仍要继续使用,不应被误删
|
|
247
|
-
|
|
248
|
-
`shutdown` 是进程和环境层面的终止动作,不应代替 branch / worktree 去向决策。具体判定规则见 `branch-finish-and-cleanup`。
|
|
249
|
-
|
|
250
|
-
### `zc task` — 任务操作
|
|
251
|
-
|
|
252
|
-
```bash
|
|
253
|
-
zc task list # 列出所有任务
|
|
254
|
-
zc task claim <id> # 认领任务
|
|
255
|
-
zc task done <id> # 标记任务完成
|
|
256
|
-
zc task fail <id> -r "编译错误" # 标记任务失败(附原因)
|
|
257
|
-
```
|
|
258
|
-
|
|
259
|
-
### `zc msg` — 消息通信
|
|
260
|
-
|
|
261
|
-
```bash
|
|
262
|
-
zc msg send <to> <body> # 点对点发送
|
|
263
|
-
zc msg broadcast <body> # 广播
|
|
264
|
-
zc msg list # 查看消息
|
|
265
|
-
```
|
|
113
|
+
## 边界与安全
|
|
266
114
|
|
|
267
|
-
|
|
115
|
+
- 不把 `zc team` 当成默认实现方式。
|
|
116
|
+
- 不为了形式统一创建多个 worker。
|
|
117
|
+
- 不在未验证 `canStart=true` 时启动。
|
|
118
|
+
- 不直接清理 dirty worktree。
|
|
119
|
+
- 不混入破坏性 git 操作;需要删除或重置时必须先确认。
|
|
268
120
|
|
|
269
|
-
|
|
270
|
-
zc CLI 入口 (commander)
|
|
271
|
-
│
|
|
272
|
-
├── zc doctor → 环境诊断(platform detection)
|
|
273
|
-
├── zc run → 单 worker 执行
|
|
274
|
-
├── zc toolkit → 工具包查询
|
|
275
|
-
│
|
|
276
|
-
├── zc team → 团队编排
|
|
277
|
-
│ └── Orchestrator(编排控制器)
|
|
278
|
-
│ ├── TaskQueue(claim-safe 任务队列)
|
|
279
|
-
│ │ └── tasks.json(持久化)
|
|
280
|
-
│ ├── Mailbox(消息邮箱)
|
|
281
|
-
│ │ └── mailbox.json(持久化)
|
|
282
|
-
│ └── WorkerManager
|
|
283
|
-
│ ├── SessionManager(tmux session/pane 管理)
|
|
284
|
-
│ └── WorktreeManager(git worktree 生命周期)
|
|
285
|
-
│
|
|
286
|
-
├── zc task → 任务操作(claim/done/fail)
|
|
287
|
-
├── zc msg → 消息通信(send/broadcast)
|
|
288
|
-
│
|
|
289
|
-
└── CLI Adapters(适配层)
|
|
290
|
-
├── CodexAdapter → Codex CLI spawn/detect/healthCheck
|
|
291
|
-
└── QwenCodeAdapter → Qwen Code spawn/detect/healthCheck
|
|
292
|
-
```
|
|
121
|
+
## 相关技能
|
|
293
122
|
|
|
294
|
-
|
|
295
|
-
- `
|
|
296
|
-
- `
|
|
297
|
-
- `
|
|
298
|
-
|
|
299
|
-
## 最佳实践
|
|
300
|
-
|
|
301
|
-
### 任务粒度建议
|
|
302
|
-
|
|
303
|
-
| 粒度 | 建议 | 示例 |
|
|
304
|
-
|------|------|------|
|
|
305
|
-
| 太粗 | 拆分后再分派 | "实现整个后端" → 按模块拆分 |
|
|
306
|
-
| 合适 | 一个任务 = 一个聚焦的功能模块 | "实现用户注册 API + 测试" |
|
|
307
|
-
| 太细 | 合并为一个任务 | "创建 users 表" + "添加 email 字段" → 合并 |
|
|
308
|
-
|
|
309
|
-
**经验法则:** 每个任务应该可以在一个 agent session 中完成(约 30-60 分钟),产出可独立验证的结果。
|
|
310
|
-
|
|
311
|
-
### Worker 数量与 CLI 搭配建议
|
|
312
|
-
|
|
313
|
-
- **2-3 workers** 是常见配置,太多 worker 可能导致资源竞争
|
|
314
|
-
- **混合搭配** — 可以根据任务特点选择不同 CLI:
|
|
315
|
-
```bash
|
|
316
|
-
# Codex 做生成,Qwen Code 做分析
|
|
317
|
-
zc team start -w "gen:codex,review:qwen-code" -t "实现功能" -t "审查代码"
|
|
318
|
-
```
|
|
319
|
-
- **同构配置** — 多个相同 CLI 并行处理同类任务:
|
|
320
|
-
```bash
|
|
321
|
-
zc team start -w "w1:codex,w2:codex,w3:codex" -t "模块A" -t "模块B" -t "模块C"
|
|
322
|
-
```
|
|
323
|
-
|
|
324
|
-
### 故障恢复策略
|
|
325
|
-
|
|
326
|
-
| 故障场景 | 处理方式 |
|
|
327
|
-
|---------|---------|
|
|
328
|
-
| Worker 进程崩溃 | Orchestrator 自动检测,将该任务标记为 `failed`,空闲 worker 可重新认领 |
|
|
329
|
-
| tmux session 丢失 | `zc team shutdown <name>` 清理残留,重新启动团队 |
|
|
330
|
-
| 任务执行失败 | 通过 `zc task fail <id> -r "原因"` 标记,分析原因后调整任务描述重试 |
|
|
331
|
-
| 团队关闭时有运行中任务 | `shutdown()` 会将活跃任务释放回 `pending` 状态 |
|
|
332
|
-
| Worktree 残留 | `zc team shutdown` 自动清理;手动清理用 `git worktree remove` |
|
|
333
|
-
|
|
334
|
-
### 团队收尾协议
|
|
335
|
-
|
|
336
|
-
团队停机前,Orchestrator 之外还要完成一轮 branch closure:
|
|
337
|
-
|
|
338
|
-
1. 汇总每个 worker 的最终状态:`completed`、`failed`、`paused`
|
|
339
|
-
2. 对 `completed` 的 worker,明确是直接合入、开 PR,还是暂时保留分支
|
|
340
|
-
3. 对 `failed` 的 worker,先转移日志、结论和必要证据,再清理 worktree
|
|
341
|
-
4. 对 `paused` 的 worker,登记负责人和恢复条件,避免 worktree 变成无主状态
|
|
342
|
-
5. 最后再执行 `zc team shutdown`
|
|
343
|
-
|
|
344
|
-
这样做的目的,是把“任务队列完成”与“分支真正结束”区分开。团队模式很容易把 worktree 当作任务缓存;这会导致团队已经关闭,但遗留分支无人接手。
|
|
345
|
-
|
|
346
|
-
### 环境注意事项
|
|
347
|
-
|
|
348
|
-
- **Windows 用户:** 建议在 WSL Ubuntu 中运行,以获得完整的 tmux 支持
|
|
349
|
-
- **tmux 必需:** 团队模式依赖 tmux 管理 worker 进程,运行前确保 `zc doctor` 通过
|
|
350
|
-
- **git worktree:** 确保当前目录是 git 仓库,worktree 会创建在项目同级目录
|
|
351
|
-
|
|
352
|
-
## 与其他技能的衔接
|
|
353
|
-
|
|
354
|
-
- **planning-and-task-breakdown** — 上游:将规格拆解为可分派给 worker 的任务列表
|
|
355
|
-
- **parallel-agent-dispatch** — 姊妹技能:上下文级并行(无文件系统隔离),team-orchestration 提供进程级 + 文件系统级隔离
|
|
356
|
-
- **branch-finish-and-cleanup** — worker 停机前后的 branch / worktree 去向判定与清理由该技能提供通用规则
|
|
357
|
-
- **subagent-driven-development** — 姊妹技能:串行版本,适合有依赖的任务链
|
|
358
|
-
- **verification-before-completion** — 所有 worker 完成后,需验证集成结果
|
|
359
|
-
- **git-workflow-and-versioning** — 团队模式深度依赖 git worktree,参见该技能的 worktree 章节
|
|
360
|
-
- **code-review-and-quality** — 多 worker 产出合并后,进行统一的代码审查
|
|
361
|
-
|
|
362
|
-
## Red Flags
|
|
363
|
-
|
|
364
|
-
- 不运行 `zc doctor` 就直接启动团队
|
|
365
|
-
- Worker 数量超过任务数量(资源浪费)
|
|
366
|
-
- 任务粒度过大导致单个 worker 长时间阻塞
|
|
367
|
-
- 忽略 worker 失败信号,不检查失败原因
|
|
368
|
-
- 多个任务修改同一文件但未使用 worktree 隔离
|
|
369
|
-
- 团队关闭后不清理 worktree(浪费磁盘空间)
|
|
370
|
-
- 不利用 Mailbox 通信,让 worker 之间完全孤立地工作
|
|
371
|
-
- 跳过集成验证就声明多 worker 任务全部完成
|
|
372
|
-
- 把 `zc team shutdown` 当成收尾本身,而不先明确各 worker 分支的最终去向
|
|
123
|
+
- `parallel-agent-dispatch`:上下文级并行,成本更低。
|
|
124
|
+
- `subagent-driven-development`:串行子代理委派。
|
|
125
|
+
- `branch-finish-and-cleanup`:分支和 worktree 收尾。
|
|
126
|
+
- `verification-before-completion`:声明完成前的最终证据门禁。
|