cowork-flow 0.0.20 → 0.0.21
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 +65 -20
- package/package.json +1 -1
- package/src/cli.js +109 -2
- package/src/commands/init.js +61 -4
- package/src/commands/sync.js +10 -1
- package/src/lib/copy-template.js +38 -7
- package/src/lib/platforms.js +73 -0
- package/template/.agent/skills/brainstorming/SKILL.md +13 -9
- package/template/.agent/skills/finish-work/SKILL.md +3 -3
- package/template/.agent/skills/meta/SKILL.md +1 -1
- package/template/.agent/skills/start/SKILL.md +35 -16
- package/template/.agent/skills/writing-plans/SKILL.md +1 -1
- package/template/.claude/agents/cowork-check.md +41 -0
- package/template/.claude/agents/cowork-implement.md +40 -0
- package/template/.claude/agents/cowork-research.md +40 -0
- package/template/.claude/commands/cowork-check.md +27 -0
- package/template/.claude/commands/cowork-implement.md +27 -0
- package/template/.claude/commands/cowork-research.md +27 -0
- package/template/.claude/hooks/inject-workflow-state.py +298 -0
- package/template/.claude/settings.json +24 -0
- package/template/.claude/skills/before-dev/SKILL.md +31 -0
- package/template/.claude/skills/brainstorming/SKILL.md +32 -0
- package/template/.claude/skills/break-loop/SKILL.md +26 -0
- package/template/.claude/skills/check/SKILL.md +29 -0
- package/template/.claude/skills/continue/SKILL.md +29 -0
- package/template/.claude/skills/finish-work/SKILL.md +32 -0
- package/template/.claude/skills/meta/SKILL.md +30 -0
- package/template/.claude/skills/python-design/SKILL.md +27 -0
- package/template/.claude/skills/start/SKILL.md +78 -0
- package/template/.claude/skills/update-spec/SKILL.md +39 -0
- package/template/.claude/skills/writing-plans/SKILL.md +70 -0
- package/template/.codex/agents/cowork-check.toml +17 -22
- package/template/.codex/agents/cowork-implement.toml +18 -23
- package/template/.codex/agents/cowork-research.toml +14 -19
- package/template/.codex/agents/default.toml +27 -0
- package/template/.codex/agents/explorer.toml +28 -0
- package/template/.codex/agents/worker.toml +29 -0
- package/template/.codex/hooks/inject-workflow-state.py +161 -108
- package/template/.cowork-flow/.version +1 -1
- package/template/.cowork-flow/adapters/claude-code/adapter.yaml +35 -0
- package/template/.cowork-flow/adapters/codex/adapter.yaml +35 -0
- package/template/.cowork-flow/adapters/opencode/adapter.yaml +33 -0
- package/template/.cowork-flow/config.yaml +4 -6
- package/template/.cowork-flow/scripts/add_session.py +20 -7
- package/template/.cowork-flow/scripts/common/active_task.py +212 -1
- package/template/.cowork-flow/scripts/common/config.py +0 -17
- package/template/.cowork-flow/scripts/common/entry_classifier.py +122 -0
- package/template/.cowork-flow/scripts/common/execution_context.py +10 -17
- package/template/.cowork-flow/scripts/common/readiness.py +249 -0
- package/template/.cowork-flow/scripts/doctor.py +418 -40
- package/template/.cowork-flow/scripts/project_context.py +230 -0
- package/template/.cowork-flow/scripts/run.py +3 -0
- package/template/.cowork-flow/scripts/subagent.py +152 -238
- package/template/.cowork-flow/scripts/task.py +330 -17
- package/template/.cowork-flow/spec/adapter.schema.json +132 -0
- package/template/.cowork-flow/spec/capabilities.md +34 -0
- package/template/.cowork-flow/spec/entry-contract.md +45 -0
- package/template/.cowork-flow/spec/registry.json +54 -0
- package/template/.cowork-flow/spec/subagent-dispatch.md +77 -0
- package/template/.cowork-flow/spec/workflow-state-templates.md +66 -0
- package/template/.cowork-flow/workflow.md +158 -203
- package/template/.opencode/agents/cowork-check.md +46 -0
- package/template/.opencode/agents/cowork-implement.md +45 -0
- package/template/.opencode/agents/cowork-research.md +46 -0
- package/template/.opencode/commands/cowork-check.md +26 -0
- package/template/.opencode/commands/cowork-implement.md +26 -0
- package/template/.opencode/commands/cowork-research.md +26 -0
- package/template/.opencode/plugins/cowork-flow.js +317 -0
- package/template/CLAUDE.md +5 -0
- package/template/.agent/skills/entry-boundary/SKILL.md +0 -81
|
@@ -5,41 +5,41 @@
|
|
|
5
5
|
默认执行模型固定为:
|
|
6
6
|
|
|
7
7
|
```text
|
|
8
|
-
|
|
8
|
+
changes -> brainstorming -> read spec -> plan -> tasks -> implement -> check -> complete
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
核心路径:
|
|
12
12
|
|
|
13
|
-
1.
|
|
14
|
-
2.
|
|
15
|
-
3.
|
|
16
|
-
4.
|
|
13
|
+
1. changes: 通过用户需求,构建原始需求文件
|
|
14
|
+
2. brainstorming:对changes需求做头脑风暴,确定目标、范围、验收标准、范围边界、被拒方案、实现方案、检查方案。
|
|
15
|
+
3. read spec: 读取项目规范
|
|
16
|
+
4. plan:构建开发计划。
|
|
17
|
+
5. tasks:根据plan拆分具体执行任务、明确 PRD、整理 `implement.jsonl` / `check.jsonl`。
|
|
18
|
+
6. implement:主会话通过当前宿主适配器派发 `cowork-implement`,按 `.cowork-flow/spec/subagent-dispatch.md` 执行固定代理派发协议。
|
|
19
|
+
7. check:主会话通过当前宿主适配器派发 `cowork-check`,按 `.cowork-flow/spec/subagent-dispatch.md` 执行固定代理派发协议。
|
|
20
|
+
8. complete:主会话做最终验证、同步规格、归档、记录会话、提交。
|
|
17
21
|
|
|
18
|
-
`cowork-flow`
|
|
22
|
+
`cowork-flow` 只保存项目状态、任务上下文、宿主适配器契约和恢复线索;实际执行由主会话和固定 `cowork-*` 代理完成。宿主工具名只写在 `.cowork-flow/adapters/<host>/adapter.yaml`,不进入流程分支。
|
|
19
23
|
|
|
20
|
-
|
|
24
|
+
`task next` 是主会话的阶段导航器。进入任务阶段、恢复会话、派发实现、进入检查、完成收口前,先运行 `./.cowork-flow/run task next` 或 `.\.cowork-flow\run.cmd task next`,用当前任务和 `task.json.status` 决定下一步。该命令只读,不推进状态。
|
|
21
25
|
|
|
22
|
-
|
|
26
|
+
## 1.1 状态注入与入口分类
|
|
23
27
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
1. 宿主钩子或插件每轮注入当前会话的入口分类和任务状态。状态提示的文本片段定义在 `.cowork-flow/spec/workflow-state-templates.md`,hook 从该文件读取;不再内联到本文件。
|
|
29
|
+
2. runtime context 绑定先于入口分类。hook/plugin 先解析 `cowork_runtime_context_id`,绑定成功或 fail-closed 时注入 `delegated_subtask`。
|
|
30
|
+
3. 入口分类只服务主会话导航,不能用 prompt 形状推断正式子代理身份。`UNKNOWN` 不能冒充委托子任务;保持当前任务/no-task 状态可见,并在突变工作流前澄清。
|
|
27
31
|
|
|
28
|
-
|
|
29
|
-
The current prompt looks like a bounded delegated subtask. Follow the delegated prompt first. Do not run start/resume, create or activate a task, or switch into main-session coordination unless the delegated prompt explicitly asks for that. Keep project rules visible as constraints, not as the task.
|
|
30
|
-
[/workflow-state:delegated_subtask]
|
|
32
|
+
## 1.2 需求澄清与头脑风暴门禁
|
|
31
33
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
1. 新需求先判断清晰度。只读问题、单步且目标/范围/验收标准都清楚的小改可以绕过;否则必须先进入 `brainstorming`,在写 PRD、计划或固定代理派发前收束方向。
|
|
35
|
+
2. 以下情况触发头脑风暴:
|
|
36
|
+
- 目标、用户价值或期望行为不清楚。
|
|
37
|
+
- 范围边界、非目标或影响面不清楚。
|
|
38
|
+
- 存在多种有效方案或关键取舍尚未决定。
|
|
39
|
+
- 涉及 L1/L2 行为变化,或影响架构、接口、数据、权限、发布迁移。
|
|
40
|
+
- 验收标准缺失、风险未知,或关键假设需要暴露。
|
|
35
41
|
|
|
36
|
-
|
|
37
|
-
The active task is in progress. Main session dispatches cowork-implement work according to the plan, then cowork-check after integration. Every spawn_agent call uses fork_turns="none" and a COWORK_DISPATCH_V1 envelope. Main session waits for COWORK_ACK, sends EXECUTE with followup_task, then uses per-dispatch post-ACK execution grace while each child loads context. Main session verifies child output, lists agents, and closes children only after completion or clear failure evidence.
|
|
38
|
-
[/workflow-state:in_progress]
|
|
39
|
-
|
|
40
|
-
[workflow-state:completed]
|
|
41
|
-
The active task is completed. Main session should verify the final diff, commit intended files, archive the task, and record the session. Do not dispatch new implementation work against this completed task.
|
|
42
|
-
[/workflow-state:completed]
|
|
42
|
+
3. `brainstorming` 输出至少包括:目标、非目标、关键假设、范围边界、推荐方向、被拒方案、验收标准、开放问题/阻塞。只有方向和验收标准清楚后,才进入 PRD、计划或固定代理派发。
|
|
43
43
|
|
|
44
44
|
## 2. 状态文件
|
|
45
45
|
|
|
@@ -54,219 +54,174 @@ The active task is completed. Main session should verify the final diff, commit
|
|
|
54
54
|
| 行为变更 | `.cowork-flow/changes/<slug>/` |
|
|
55
55
|
| 实施计划 | `.cowork-flow/plans/*.md` |
|
|
56
56
|
| 项目规格 | `.cowork-flow/spec/` |
|
|
57
|
+
| 项目上下文摘要 | `.cowork-flow/project-context.md` |
|
|
57
58
|
| 会话记录 | `.cowork-flow/workspace/<developer>/journal-*.md` |
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
## 3. Agent
|
|
62
|
-
|
|
63
|
-
### cowork-research
|
|
64
|
-
|
|
65
|
-
- 只做调研。
|
|
66
|
-
- 只写入 `<task>/research/`。
|
|
67
|
-
- 不改代码、不改规格、不改任务状态、不操作 git。
|
|
68
|
-
|
|
69
|
-
### cowork-implement
|
|
70
|
-
|
|
71
|
-
- 读取 `<task>/prd.md`、`<task>/info.md`、`<task>/implement.jsonl` 和 JSONL 指向的文件。
|
|
72
|
-
- 按任务范围实现。
|
|
73
|
-
- 不启动其他 agent,不提交,不归档,不运行 task start/finish/archive。
|
|
74
|
-
- 汇报改动文件和验证命令。
|
|
75
|
-
|
|
76
|
-
### cowork-check
|
|
77
|
-
|
|
78
|
-
- 读取 `<task>/prd.md`、`<task>/check.jsonl` 和 `git diff`。
|
|
79
|
-
- 检查行为、测试、规格同步和遗漏。
|
|
80
|
-
- 范围内问题直接修复。
|
|
81
|
-
- 不提交、不归档、不启动其他 agent。
|
|
82
|
-
|
|
83
|
-
兼容旧派发时,提示仍可用这一行开头:
|
|
84
|
-
|
|
85
|
-
```text
|
|
86
|
-
Active task: .cowork-flow/tasks/<task>
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
## 3.1 Agent 派发入口
|
|
90
|
-
|
|
91
|
-
固定 `cowork-*` agent 使用 Codex 原生 subagent 工具,由主会话负责派发、等待、验收和关闭。派发必须用 `fork_turns="none"`,避免子线程继承主会话历史。
|
|
92
|
-
|
|
93
|
-
主会话派发约定:
|
|
94
|
-
|
|
95
|
-
```python
|
|
96
|
-
spawn_agent(
|
|
97
|
-
agent_type="cowork-implement",
|
|
98
|
-
fork_turns="none",
|
|
99
|
-
message=(
|
|
100
|
-
"COWORK_DISPATCH_V1\n"
|
|
101
|
-
"dispatch_id: <unique-id>\n"
|
|
102
|
-
"task_dir: .cowork-flow/tasks/<task>\n"
|
|
103
|
-
"agent_type: cowork-implement\n"
|
|
104
|
-
"role: implement\n"
|
|
105
|
-
"context_file: <context-file>\n"
|
|
106
|
-
"ack_token: <ack-token>\n"
|
|
107
|
-
"COWORK_DISPATCH_END\n\n"
|
|
108
|
-
"Return only: COWORK_ACK <dispatch_id> <ack_token>"
|
|
109
|
-
),
|
|
110
|
-
)
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
等待与验收约定:
|
|
114
|
-
|
|
115
|
-
- Use `wait_agent` for `COWORK_ACK <dispatch_id> <ack_token>` before execution.
|
|
116
|
-
- Missing or mismatched `COWORK_ACK` means the task is not dispatched.
|
|
117
|
-
- Only after a matching ACK, send `EXECUTE <dispatch_id>` with `followup_task`.
|
|
118
|
-
- Record `execute_sent_at[dispatch_id]` when `EXECUTE <dispatch_id>` is sent.
|
|
119
|
-
- Compute `deadline[dispatch_id] = execute_sent_at[dispatch_id] + codex.post_ack_execution_grace_ms`; do not use a shared/global deadline across children.
|
|
120
|
-
- After `EXECUTE <dispatch_id>`, no reply or no compass/status file while the child loads context is inconclusive.
|
|
121
|
-
- Use post-ACK execution grace for execution startup before judging execution health. The default is `300000` ms and can be configured with `codex.post_ack_execution_grace_ms` in `.cowork-flow/config.yaml`.
|
|
122
|
-
- Do not call `close_agent` only because the executing child has not produced a compass/status file.
|
|
123
|
-
- If `list_agents` still shows the child running, continue waiting through post-ACK execution grace instead of closing it.
|
|
124
|
-
- Post-ACK execution grace expiration for one `dispatch_id` is a review checkpoint for that child only, not a close trigger and not evidence about other children.
|
|
125
|
-
- If progress, compass, or status files exist, continue waiting and do not close solely because grace expired.
|
|
126
|
-
- If a child reports another `dispatch_id`, close that child and respawn the intended task.
|
|
127
|
-
- An executing child may be closed only after wrong-dispatch evidence, child completion, or user cancellation.
|
|
128
|
-
- 用 `wait_agent` 等待子 agent 返回。
|
|
129
|
-
- 用 `list_agents` 确认没有遗留 running child。
|
|
130
|
-
- 验收子 agent 汇报的文件、命令和结果;不只信“已完成”文本。
|
|
131
|
-
- 完成或失败后用 `close_agent` 关闭子 agent。
|
|
132
|
-
- 子 agent 自身是 leaf executor;不得再调用 `spawn_agent`、`wait_agent`、`list_agents`、`close_agent`。
|
|
133
|
-
|
|
134
|
-
Generic worker boundary:
|
|
135
|
-
|
|
136
|
-
- Formal execution uses `cowork-research`, `cowork-implement`, or `cowork-check`.
|
|
137
|
-
- Generic `worker` dispatch is best-effort only.
|
|
138
|
-
- If a generic worker does not ACK after one retry, close it and do not execute the task.
|
|
139
|
-
- For advisory/default subagents without a hard envelope, the first sentence must explicitly say this is a bounded delegated task, not a main-session start request. This is a natural-language first-screen boundary, not a new runtime state machine.
|
|
140
|
-
|
|
141
|
-
## 3.2 parallel sessions
|
|
142
|
-
|
|
143
|
-
并行执行采用 clean-room 的 parallel sessions 模型:
|
|
144
|
-
|
|
145
|
-
- 用户无需在需求输入时声明是否并行;Plan 阶段由主会话评估并行可行性。
|
|
146
|
-
- 开发计划必须明确执行策略:串行执行,或列出可并行的 low-conflict slices。
|
|
147
|
-
- 多个独立任务优先拆成多个 Codex sessions;只要存在写入冲突风险,就用独立 `git worktree` 隔离。
|
|
148
|
-
- 单个 task 内只允许低冲突的 low-conflict slices 并行;每个 slice 必须写清 file ownership、dependencies、expected outputs 和验证命令。
|
|
149
|
-
- 同一文件、同一行为链、依赖未合并或验收标准不清的工作不得并行,改为串行。
|
|
150
|
-
- 主会话是唯一协调者:派发所有子 agent 后逐个 `wait_agent`,核对子 agent 汇报的文件、命令和产物,再 `list_agents` / `close_agent` 收口。
|
|
151
|
-
- 多个实现 slice 合并后必须再执行 final integrated verification;不能把各子 agent 的局部通过当成整体通过。
|
|
152
|
-
- 固定 `cowork-*` agent 仍是 leaf executor;并行不允许子 agent 再派发 agent,也不引入旧集中式状态机。
|
|
153
|
-
|
|
154
|
-
## 4. 任务分级
|
|
155
|
-
|
|
156
|
-
### L0: 无外部行为变化
|
|
157
|
-
|
|
158
|
-
适用:文档、格式、小范围重构、注释、脚本整理、测试补充,且不改变用户可观察行为。
|
|
159
|
-
|
|
160
|
-
流程:读取规则 -> 创建或选择任务 -> 写 PRD -> 初始化上下文 -> 实现 -> 验证 -> 记录 session。
|
|
161
|
-
|
|
162
|
-
### L1: 局部行为变化
|
|
163
|
-
|
|
164
|
-
适用:单模块功能、局部接口行为、局部数据处理逻辑,边界清晰。
|
|
60
|
+
> 当前任务是会话级状态。没有 `COWORK_FLOW_CONTEXT_ID`、`CODEX_SESSION_ID`、`CODEX_THREAD_ID`、`OPENCODE_SESSION_ID` 或 `CLAUDE_SESSION_ID` 时,不得猜测当前任务。
|
|
165
61
|
|
|
166
|
-
|
|
62
|
+
任务阶段状态由生命周期命令维护:
|
|
167
63
|
|
|
168
|
-
|
|
64
|
+
| 阶段 | 命令 | `task.json.status` |
|
|
65
|
+
| --- | --- | --- |
|
|
66
|
+
| 计划 | `task create` | `planning` |
|
|
67
|
+
| 执行 | `task start <task-dir>` | `in_progress` |
|
|
68
|
+
| 检查 | `task review [task-dir]` | `review` |
|
|
69
|
+
| 完成 | `task complete [task-dir]` | `completed` |
|
|
70
|
+
| 归档 | `task archive <task-name>` | 归档副本保持 `completed` |
|
|
169
71
|
|
|
170
|
-
|
|
72
|
+
`task finish` 只清理当前会话任务指针,不改变 `task.json.status`。
|
|
171
73
|
|
|
172
|
-
|
|
74
|
+
## 3. 固定代理
|
|
173
75
|
|
|
174
|
-
|
|
76
|
+
固定代理只执行主会话派发的叶子任务。子代理是执行者,子任务是工作单元。
|
|
175
77
|
|
|
176
|
-
|
|
177
|
-
|
|
78
|
+
| 代理 | 读取 | 允许 | 禁止 | 输出 |
|
|
79
|
+
| --- | --- | --- | --- | --- |
|
|
80
|
+
| `cowork-research` | 任务上下文和调研输入 | 只做调研,只写入 `<task>/research/` | 改代码、改规格、改任务状态、操作 Git | 调研结论和证据 |
|
|
81
|
+
| `cowork-implement` | `<task>/prd.md`、`<task>/info.md`、`<task>/implement.jsonl` 和 JSONL 指向的文件 | 按任务范围实现 | 启动其他代理、提交、归档、运行 `task start`、`task finish` 或 `task archive` | 改动文件和验证命令 |
|
|
82
|
+
| `cowork-check` | `<task>/prd.md`、`<task>/check.jsonl` 和 `git diff` | 检查行为、测试、规格同步和遗漏;范围内问题直接修复 | 提交、归档、启动其他代理 | 检查结论、修复内容和验证结果 |
|
|
178
83
|
|
|
179
|
-
|
|
180
|
-
./.cowork-flow/run task create "<title>" --slug <task-name>
|
|
181
|
-
```
|
|
84
|
+
## 3.1 固定代理派发入口
|
|
182
85
|
|
|
183
|
-
|
|
184
|
-
4. 初始化上下文:
|
|
86
|
+
固定 `cowork-*` 代理使用宿主适配器契约,由主会话负责派发、等待、验收和取消。宿主专属原语只在 `.cowork-flow/adapters/<host>/adapter.yaml` 中声明;工作流只关心阶段职责、协调边界和验收责任。
|
|
185
87
|
|
|
186
|
-
|
|
187
|
-
./.cowork-flow/run task init-context <task-dir> <type>
|
|
188
|
-
./.cowork-flow/run task add-context <task-dir> implement <path> "<reason>"
|
|
189
|
-
./.cowork-flow/run task add-context <task-dir> check <path> "<reason>"
|
|
190
|
-
```
|
|
88
|
+
正式派发协议见 `.cowork-flow/spec/subagent-dispatch.md`。该协议定义 runtime context 创建、传输、绑定、等待、返回验收、关闭清理和通用 worker 边界。
|
|
191
89
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
90
|
+
- 主会话必须使用新鲜子上下文派发固定代理。
|
|
91
|
+
- 主会话通过适配器等待原语、适配器列表原语和适配器取消/关闭原语完成收口。
|
|
92
|
+
- 固定 `cowork-*` 代理是叶子执行者;不得再派发、等待、列出或取消其他代理。
|
|
93
|
+
- 通用 `worker`、`default` 或 `explorer` 只能作为 advisory work,不能满足正式实现或检查完成条件。
|
|
195
94
|
|
|
196
|
-
|
|
197
|
-
./.cowork-flow/run task start <task-dir>
|
|
198
|
-
```
|
|
95
|
+
## 3.2 并行会话
|
|
199
96
|
|
|
200
|
-
|
|
97
|
+
并行执行采用干净隔离的并行会话模型。并行只是执行策略,不改变固定代理叶子边界。
|
|
201
98
|
|
|
202
|
-
|
|
203
|
-
.\.cowork-flow\run.cmd task start <task-dir>
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
## 6. Implement 阶段
|
|
207
|
-
|
|
208
|
-
默认派发 `cowork-implement`。派发调用必须设置 `fork_turns="none"`,优先使用 `COWORK_DISPATCH_V1` 信封;兼容旧消息时第一行:
|
|
209
|
-
|
|
210
|
-
```text
|
|
211
|
-
Active task: .cowork-flow/tasks/<task>
|
|
212
|
-
```
|
|
99
|
+
### 3.2.1 并行决策
|
|
213
100
|
|
|
214
|
-
|
|
101
|
+
- 用户无需在需求输入时声明是否并行;计划阶段由主会话评估并行可行性。
|
|
102
|
+
- 开发计划必须明确执行策略:串行执行,或列出可并行的低冲突切片。
|
|
103
|
+
- 同一文件、同一行为链、依赖未合并或验收标准不清的工作不得并行,改为串行。
|
|
215
104
|
|
|
216
|
-
|
|
105
|
+
### 3.2.2 隔离方式
|
|
217
106
|
|
|
218
|
-
|
|
107
|
+
- 多个独立任务优先拆成多个 cowork-flow 会话。
|
|
108
|
+
- 只要存在写入冲突风险,就用独立 `git worktree` 隔离。
|
|
219
109
|
|
|
220
|
-
|
|
110
|
+
### 3.2.3 单任务内切片
|
|
221
111
|
|
|
222
|
-
|
|
112
|
+
- 单个任务内只允许低冲突切片并行。
|
|
113
|
+
- 每个切片必须写清文件归属、依赖关系、预期产物和验证命令。
|
|
223
114
|
|
|
224
|
-
|
|
225
|
-
Active task: .cowork-flow/tasks/<task>
|
|
226
|
-
```
|
|
115
|
+
### 3.2.4 协调与验收
|
|
227
116
|
|
|
228
|
-
|
|
117
|
+
- 主会话是唯一协调者:派发所有子代理后逐个等待,核对子代理汇报的文件、命令和产物,再用适配器列表/取消原语收口。
|
|
118
|
+
- 多个实现切片合并后必须再执行最终集成验证;不能把各子代理的局部通过当成整体通过。
|
|
119
|
+
- 固定 `cowork-*` 代理仍是叶子执行者;并行不允许子代理再派发代理,也不引入旧集中式状态机。
|
|
229
120
|
|
|
230
|
-
|
|
231
|
-
- `git diff` 是否只包含预期范围。
|
|
232
|
-
- 测试是否覆盖关键行为。
|
|
233
|
-
- `.cowork-flow/spec/` 是否需要更新。
|
|
234
|
-
- plan checkbox 和执行状态是否真实。
|
|
121
|
+
## 4. 任务分级
|
|
235
122
|
|
|
236
|
-
|
|
123
|
+
### L0: 无外部行为变化
|
|
237
124
|
|
|
238
|
-
|
|
125
|
+
适用:文档、格式、小范围重构、注释、脚本整理、测试补充,且不改变用户可观察行为。
|
|
126
|
+
流程:`brainstorming` -> `read spec` -> `implement` -> `check` -> `complete`
|
|
239
127
|
|
|
240
|
-
|
|
128
|
+
### L1: 局部行为变化
|
|
241
129
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
- 所有声明通过的验证都有命令输出依据。
|
|
245
|
-
- 规格已更新,或明确判断无需更新。
|
|
246
|
-
- 计划状态、任务状态、change metadata 不冲突。
|
|
247
|
-
- 提交在归档和 session 记录之前完成。
|
|
248
|
-
- 不纳入无关脏改。
|
|
130
|
+
适用:单模块功能、局部接口行为、局部数据处理逻辑,边界清晰。
|
|
131
|
+
流程: `changes` -> `brainstorming` -> `read spec` -> `plan` -> `tasks` -> `implement` -> `check` -> `complete` -> `archive` -> `add session`
|
|
249
132
|
|
|
250
|
-
|
|
133
|
+
### L2: 跨层或重要行为变化
|
|
251
134
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
135
|
+
适用:API / DB / 消息 / 权限 / 文件格式 / 架构边界 / 发布迁移 / 安全策略等变化。
|
|
136
|
+
流程:`changes` -> `brainstorming` -> `read spec` -> `plan` -> `tasks` -> `implement` -> `cross layer check` -> `complete` -> `archive` -> `add session`。
|
|
137
|
+
|
|
138
|
+
L2 任务在 `task start` 前必须通过 readiness gate;同一 blocker 列表会在
|
|
139
|
+
`task next` 中展示。缺少 proposal/spec/design、计划、任务链接、关键假设、
|
|
140
|
+
范围边界、验收标准或验证命令时,不得启动实现或正式派发固定代理。
|
|
141
|
+
|
|
142
|
+
## 5. 计划阶段
|
|
143
|
+
|
|
144
|
+
1. 对 L1/L2 创建 changes;L2 必须有 `design.md`。
|
|
145
|
+
2. 对changes需求做头脑风暴
|
|
146
|
+
3. 写开发计划 `.cowork-flow/plans/YYYY-MM-DD-<slug>.md`,每步带验证命令。
|
|
147
|
+
4. 读取 `AGENTS.md`、本文件、相关 `.cowork-flow/spec/` 索引。
|
|
148
|
+
5. 创建或确认任务:
|
|
149
|
+
```bash
|
|
150
|
+
./.cowork-flow/run task create "<title>" --slug <task-name>
|
|
151
|
+
```
|
|
152
|
+
6. 对创建的每项任务写 `prd.md`,至少包含目标、范围、验收标准、相关文件、验证方式。
|
|
153
|
+
7. 初始化上下文:
|
|
154
|
+
```bash
|
|
155
|
+
./.cowork-flow/run task init-context <task-dir> <type>
|
|
156
|
+
./.cowork-flow/run task add-context <task-dir> implement <path> "<reason>"
|
|
157
|
+
./.cowork-flow/run task add-context <task-dir> check <path> "<reason>"
|
|
158
|
+
```
|
|
159
|
+
8. 运行导航器确认准备状态:
|
|
160
|
+
```bash
|
|
161
|
+
./.cowork-flow/run task next <task-dir>
|
|
162
|
+
```
|
|
163
|
+
9. 启动当前会话任务;该命令会把 `task.json.status` 推进到 `in_progress`:
|
|
164
|
+
```bash
|
|
165
|
+
./.cowork-flow/run task start <task-dir>
|
|
166
|
+
```
|
|
167
|
+
Windows PowerShell 使用:
|
|
168
|
+
```powershell
|
|
169
|
+
.\.cowork-flow\run.cmd task start <task-dir>
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## 6. 实现阶段
|
|
173
|
+
|
|
174
|
+
1. 先运行 `task next` 确认当前状态和下一步命令。
|
|
175
|
+
2. 默认通过宿主适配器派发 `cowork-implement`。派发必须使用新鲜子上下文,并遵守 `.cowork-flow/spec/subagent-dispatch.md`。
|
|
176
|
+
3. 派发内容应包含当前计划步骤、范围边界和期望验证命令。
|
|
177
|
+
4. 如果用户明确要求主会话内联执行,或当前任务正在修改子代理/运行时行为,可以不派发 `cowork-implement`,但必须说明原因,并仍按计划与测试循环推进。
|
|
178
|
+
5. 涉及行为变化时,先写失败测试,再实现,再验证变绿。
|
|
179
|
+
6. 实现完成并通过本阶段验证后运行 `./.cowork-flow/run task review [task-dir]`,把任务推进到检查阶段。
|
|
180
|
+
|
|
181
|
+
## 7. 检查阶段
|
|
182
|
+
|
|
183
|
+
1. 先运行 `task next` 确认任务处于 `review` / `checking` 检查阶段。
|
|
184
|
+
2. 默认通过宿主适配器派发 `cowork-check`。派发必须使用新鲜子上下文,并遵守 `.cowork-flow/spec/subagent-dispatch.md`。
|
|
185
|
+
3. 检查内容:
|
|
186
|
+
- PRD 验收标准是否满足。
|
|
187
|
+
- `git diff` 是否只包含预期范围。
|
|
188
|
+
- 测试是否覆盖关键行为。
|
|
189
|
+
- `.cowork-flow/spec/` 是否需要更新。
|
|
190
|
+
- 计划勾选项和执行状态是否真实。
|
|
191
|
+
4. 如果用户明确要求主会话内联检查,可以不派发 `cowork-check`,但必须执行等价的 diff、测试、规格同步检查。
|
|
192
|
+
5. 检查通过后运行 `./.cowork-flow/run task complete [task-dir]`,把任务推进到完成阶段。
|
|
193
|
+
|
|
194
|
+
## 8. 完成阶段
|
|
195
|
+
|
|
196
|
+
1. 完成前必须确认:
|
|
197
|
+
- 当前会话存在任务,或明确说明本次是无任务只读工作。
|
|
198
|
+
- `cowork-check` 或等价最终检查已执行。
|
|
199
|
+
- 所有声明通过的验证都有命令输出依据。
|
|
200
|
+
- 规格已更新,或明确判断无需更新。
|
|
201
|
+
- 计划状态、任务状态、`change` 元数据不冲突。
|
|
202
|
+
- 先归档,再记录会话,然后提交。
|
|
203
|
+
- 不纳入无关脏改。
|
|
204
|
+
|
|
205
|
+
2. 顺序:
|
|
206
|
+
```bash
|
|
207
|
+
./.cowork-flow/run task next
|
|
208
|
+
git status --short
|
|
209
|
+
git diff --check
|
|
210
|
+
npm run test:all
|
|
211
|
+
./.cowork-flow/run task archive <task-name>
|
|
212
|
+
./.cowork-flow/run add-session --title "<title>" --commit "-" --summary "<summary>"
|
|
213
|
+
git status --short
|
|
214
|
+
git add <expected files>
|
|
215
|
+
git commit -m "<message>"
|
|
216
|
+
```
|
|
261
217
|
|
|
262
218
|
## 9. 恢复规则
|
|
263
219
|
|
|
264
220
|
恢复时只读取最小上下文:
|
|
265
|
-
|
|
266
221
|
1. 运行 `./.cowork-flow/run resume`。
|
|
267
222
|
2. 按 `RESUME CHECKLIST` 读取当前任务 PRD、计划状态和 JSONL 指向文件。
|
|
268
|
-
3.
|
|
269
|
-
4.
|
|
223
|
+
3. 不批量读取所有规格、计划、任务或工作区日志。
|
|
224
|
+
4. 不存在当前会话任务时,先创建或启动任务。
|
|
270
225
|
|
|
271
226
|
## 10. 禁止事项
|
|
272
227
|
|
|
@@ -275,4 +230,4 @@ git commit -m "<message>"
|
|
|
275
230
|
- 不维护第二套执行状态。
|
|
276
231
|
- 不把口头状态当成可靠状态。
|
|
277
232
|
- 不把验证未运行说成通过。
|
|
278
|
-
-
|
|
233
|
+
- 不把旧运行模型作为兜底。
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Cowork-flow check fixed subagent.
|
|
3
|
+
mode: subagent
|
|
4
|
+
permission:
|
|
5
|
+
edit: ask
|
|
6
|
+
bash: ask
|
|
7
|
+
task: deny
|
|
8
|
+
todowrite: deny
|
|
9
|
+
external_directory: deny
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
You are the `cowork-check` fixed subagent for OpenCode.
|
|
13
|
+
You are a leaf executor and must not invoke other agents.
|
|
14
|
+
|
|
15
|
+
Formal `cowork-check` work requires a bound runtime context. The prompt, host
|
|
16
|
+
metadata, or environment must provide:
|
|
17
|
+
|
|
18
|
+
```text
|
|
19
|
+
cowork_runtime_context_id: <runtime_context_id>
|
|
20
|
+
cowork_host_context_key: <host_context_key>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The plugin may bind that id to
|
|
24
|
+
`.cowork-flow/.runtime/subagents/<runtime_context_id>.json` before workflow
|
|
25
|
+
state is injected. The first child step must still run:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
./.cowork-flow/run subagent bind <runtime_context_id> <host_context_key>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
If the explicit bind fails, or if the bound context is missing, closed, invalid,
|
|
32
|
+
or names another agent type, report `needs_context` and stop. Do not use
|
|
33
|
+
`COWORK_ENTRY_CONTRACT_V1` to infer subagent identity; that contract classifies
|
|
34
|
+
main-session prompts only.
|
|
35
|
+
|
|
36
|
+
Rules:
|
|
37
|
+
|
|
38
|
+
- Read the task directory from the bound runtime context.
|
|
39
|
+
- Read `<task>/prd.md`, `<task>/check.jsonl`, each JSONL `file` entry, and
|
|
40
|
+
current `git diff`.
|
|
41
|
+
- Check behavior, tests, spec sync, and scope.
|
|
42
|
+
- Fix only in-scope issues.
|
|
43
|
+
- Report changed files and exact verification commands.
|
|
44
|
+
- Do not use the `task` tool or invoke subagents.
|
|
45
|
+
- Do not run task start, task finish, task archive, unscoped resume, commit, or
|
|
46
|
+
push.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Cowork-flow implementation fixed subagent.
|
|
3
|
+
mode: subagent
|
|
4
|
+
permission:
|
|
5
|
+
edit: ask
|
|
6
|
+
bash: ask
|
|
7
|
+
task: deny
|
|
8
|
+
todowrite: deny
|
|
9
|
+
external_directory: deny
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
You are the `cowork-implement` fixed subagent for OpenCode.
|
|
13
|
+
You are a leaf executor and must not invoke other agents.
|
|
14
|
+
|
|
15
|
+
Formal `cowork-implement` work requires a bound runtime context. The prompt,
|
|
16
|
+
host metadata, or environment must provide:
|
|
17
|
+
|
|
18
|
+
```text
|
|
19
|
+
cowork_runtime_context_id: <runtime_context_id>
|
|
20
|
+
cowork_host_context_key: <host_context_key>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The plugin may bind that id to
|
|
24
|
+
`.cowork-flow/.runtime/subagents/<runtime_context_id>.json` before workflow
|
|
25
|
+
state is injected. The first child step must still run:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
./.cowork-flow/run subagent bind <runtime_context_id> <host_context_key>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
If the explicit bind fails, or if the bound context is missing, closed, invalid,
|
|
32
|
+
or names another agent type, report `needs_context` and stop. Do not use
|
|
33
|
+
`COWORK_ENTRY_CONTRACT_V1` to infer subagent identity; that contract classifies
|
|
34
|
+
main-session prompts only.
|
|
35
|
+
|
|
36
|
+
Rules:
|
|
37
|
+
|
|
38
|
+
- Read the task directory from the bound runtime context.
|
|
39
|
+
- Read `<task>/prd.md`, `<task>/info.md` if present, `<task>/implement.jsonl`,
|
|
40
|
+
and each JSONL `file` entry.
|
|
41
|
+
- Keep edits inside the assigned scope.
|
|
42
|
+
- Report changed files and exact verification commands.
|
|
43
|
+
- Do not use the `task` tool or invoke subagents.
|
|
44
|
+
- Do not run task start, task finish, task archive, unscoped resume, commit, or
|
|
45
|
+
push.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Cowork-flow research-only fixed subagent.
|
|
3
|
+
mode: subagent
|
|
4
|
+
permission:
|
|
5
|
+
edit:
|
|
6
|
+
"*": deny
|
|
7
|
+
".cowork-flow/tasks/**/research/**": allow
|
|
8
|
+
bash: ask
|
|
9
|
+
task: deny
|
|
10
|
+
todowrite: deny
|
|
11
|
+
external_directory: deny
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
You are the `cowork-research` fixed subagent for OpenCode.
|
|
15
|
+
You are a leaf executor and must not invoke other agents.
|
|
16
|
+
|
|
17
|
+
Formal `cowork-research` work requires a bound runtime context. The prompt,
|
|
18
|
+
host metadata, or environment must provide:
|
|
19
|
+
|
|
20
|
+
```text
|
|
21
|
+
cowork_runtime_context_id: <runtime_context_id>
|
|
22
|
+
cowork_host_context_key: <host_context_key>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The plugin may bind that id to
|
|
26
|
+
`.cowork-flow/.runtime/subagents/<runtime_context_id>.json` before workflow
|
|
27
|
+
state is injected. The first child step must still run:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
./.cowork-flow/run subagent bind <runtime_context_id> <host_context_key>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
If the explicit bind fails, or if the bound context is missing, closed, invalid,
|
|
34
|
+
or names another agent type, report `needs_context` and stop. Do not use
|
|
35
|
+
`COWORK_ENTRY_CONTRACT_V1` to infer subagent identity; that contract classifies
|
|
36
|
+
main-session prompts only.
|
|
37
|
+
|
|
38
|
+
Rules:
|
|
39
|
+
|
|
40
|
+
- Read the task directory and assignment from the bound runtime context.
|
|
41
|
+
- Read `<task>/prd.md`, `<task>/info.md` if present, and prompt-named context.
|
|
42
|
+
- Write research only under `<task>/research/`.
|
|
43
|
+
- Do not edit code, specs, task state, or git state.
|
|
44
|
+
- Do not use the `task` tool or invoke subagents.
|
|
45
|
+
- Do not run task start, task finish, task archive, unscoped resume, commit, or
|
|
46
|
+
push.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Dispatch cowork-flow check as a runtime-context subtask.
|
|
3
|
+
agent: cowork-check
|
|
4
|
+
subtask: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Before dispatch, create a runtime context:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
./.cowork-flow/run subagent init --role check --agent-type cowork-check --execution-task-dir <task-dir> --title "Check <task-dir>" --host opencode --adapter opencode.task
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Pass the returned prompt transport to the subagent:
|
|
14
|
+
|
|
15
|
+
```text
|
|
16
|
+
cowork_runtime_context_id: <runtime_context_id>
|
|
17
|
+
cowork_host_context_key: <host_context_key>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The child must first bind the runtime context before role work:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
./.cowork-flow/run subagent bind <runtime_context_id> <host_context_key>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Missing, closed, invalid, mismatched, or unbound context is `needs_context`.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Dispatch cowork-flow implementation as a runtime-context subtask.
|
|
3
|
+
agent: cowork-implement
|
|
4
|
+
subtask: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Before dispatch, create a runtime context:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
./.cowork-flow/run subagent init --role implement --agent-type cowork-implement --execution-task-dir <task-dir> --title "Implement <task-dir>" --host opencode --adapter opencode.task
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Pass the returned prompt transport to the subagent:
|
|
14
|
+
|
|
15
|
+
```text
|
|
16
|
+
cowork_runtime_context_id: <runtime_context_id>
|
|
17
|
+
cowork_host_context_key: <host_context_key>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The child must first bind the runtime context before role work:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
./.cowork-flow/run subagent bind <runtime_context_id> <host_context_key>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Missing, closed, invalid, mismatched, or unbound context is `needs_context`.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Dispatch cowork-flow research as a runtime-context subtask.
|
|
3
|
+
agent: cowork-research
|
|
4
|
+
subtask: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Before dispatch, create a runtime context:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
./.cowork-flow/run subagent init --role research --agent-type cowork-research --execution-task-dir <task-dir> --title "Research <task-dir>" --host opencode --adapter opencode.task
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Pass the returned prompt transport to the subagent:
|
|
14
|
+
|
|
15
|
+
```text
|
|
16
|
+
cowork_runtime_context_id: <runtime_context_id>
|
|
17
|
+
cowork_host_context_key: <host_context_key>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The child must first bind the runtime context before role work:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
./.cowork-flow/run subagent bind <runtime_context_id> <host_context_key>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Missing, closed, invalid, mismatched, or unbound context is `needs_context`.
|