cowork-flow 0.0.19 → 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.
Files changed (69) hide show
  1. package/README.md +65 -20
  2. package/package.json +1 -1
  3. package/src/cli.js +109 -2
  4. package/src/commands/init.js +61 -4
  5. package/src/commands/sync.js +10 -1
  6. package/src/lib/copy-template.js +38 -7
  7. package/src/lib/platforms.js +73 -0
  8. package/template/.agent/skills/brainstorming/SKILL.md +13 -9
  9. package/template/.agent/skills/finish-work/SKILL.md +3 -3
  10. package/template/.agent/skills/meta/SKILL.md +1 -1
  11. package/template/.agent/skills/start/SKILL.md +38 -14
  12. package/template/.agent/skills/writing-plans/SKILL.md +1 -1
  13. package/template/.claude/agents/cowork-check.md +41 -0
  14. package/template/.claude/agents/cowork-implement.md +40 -0
  15. package/template/.claude/agents/cowork-research.md +40 -0
  16. package/template/.claude/commands/cowork-check.md +27 -0
  17. package/template/.claude/commands/cowork-implement.md +27 -0
  18. package/template/.claude/commands/cowork-research.md +27 -0
  19. package/template/.claude/hooks/inject-workflow-state.py +298 -0
  20. package/template/.claude/settings.json +24 -0
  21. package/template/.claude/skills/before-dev/SKILL.md +31 -0
  22. package/template/.claude/skills/brainstorming/SKILL.md +32 -0
  23. package/template/.claude/skills/break-loop/SKILL.md +26 -0
  24. package/template/.claude/skills/check/SKILL.md +29 -0
  25. package/template/.claude/skills/continue/SKILL.md +29 -0
  26. package/template/.claude/skills/finish-work/SKILL.md +32 -0
  27. package/template/.claude/skills/meta/SKILL.md +30 -0
  28. package/template/.claude/skills/python-design/SKILL.md +27 -0
  29. package/template/.claude/skills/start/SKILL.md +78 -0
  30. package/template/.claude/skills/update-spec/SKILL.md +39 -0
  31. package/template/.claude/skills/writing-plans/SKILL.md +70 -0
  32. package/template/.codex/agents/cowork-check.toml +17 -22
  33. package/template/.codex/agents/cowork-implement.toml +18 -23
  34. package/template/.codex/agents/cowork-research.toml +14 -19
  35. package/template/.codex/agents/default.toml +27 -0
  36. package/template/.codex/agents/explorer.toml +28 -0
  37. package/template/.codex/agents/worker.toml +29 -0
  38. package/template/.codex/hooks/inject-workflow-state.py +172 -90
  39. package/template/.cowork-flow/.version +1 -1
  40. package/template/.cowork-flow/adapters/claude-code/adapter.yaml +35 -0
  41. package/template/.cowork-flow/adapters/codex/adapter.yaml +35 -0
  42. package/template/.cowork-flow/adapters/opencode/adapter.yaml +33 -0
  43. package/template/.cowork-flow/config.yaml +4 -1
  44. package/template/.cowork-flow/scripts/add_session.py +20 -7
  45. package/template/.cowork-flow/scripts/common/active_task.py +212 -1
  46. package/template/.cowork-flow/scripts/common/entry_classifier.py +122 -0
  47. package/template/.cowork-flow/scripts/common/execution_context.py +10 -17
  48. package/template/.cowork-flow/scripts/common/readiness.py +249 -0
  49. package/template/.cowork-flow/scripts/doctor.py +417 -29
  50. package/template/.cowork-flow/scripts/project_context.py +230 -0
  51. package/template/.cowork-flow/scripts/run.py +3 -0
  52. package/template/.cowork-flow/scripts/subagent.py +152 -238
  53. package/template/.cowork-flow/scripts/task.py +330 -17
  54. package/template/.cowork-flow/spec/adapter.schema.json +132 -0
  55. package/template/.cowork-flow/spec/capabilities.md +34 -0
  56. package/template/.cowork-flow/spec/entry-contract.md +45 -0
  57. package/template/.cowork-flow/spec/registry.json +54 -0
  58. package/template/.cowork-flow/spec/subagent-dispatch.md +77 -0
  59. package/template/.cowork-flow/spec/workflow-state-templates.md +66 -0
  60. package/template/.cowork-flow/workflow.md +154 -190
  61. package/template/.opencode/agents/cowork-check.md +46 -0
  62. package/template/.opencode/agents/cowork-implement.md +45 -0
  63. package/template/.opencode/agents/cowork-research.md +46 -0
  64. package/template/.opencode/commands/cowork-check.md +26 -0
  65. package/template/.opencode/commands/cowork-implement.md +26 -0
  66. package/template/.opencode/commands/cowork-research.md +26 -0
  67. package/template/.opencode/plugins/cowork-flow.js +317 -0
  68. package/template/CLAUDE.md +5 -0
  69. package/template/.agent/skills/entry-boundary/SKILL.md +0 -81
@@ -5,41 +5,41 @@
5
5
  默认执行模型固定为:
6
6
 
7
7
  ```text
8
- Plan -> Implement -> Check -> Finish
8
+ changes -> brainstorming -> read spec -> plan -> tasks -> implement -> check -> complete
9
9
  ```
10
10
 
11
11
  核心路径:
12
12
 
13
- 1. Plan: 建立任务、明确 PRD、整理 `implement.jsonl` / `check.jsonl`。
14
- 2. Implement: 主会话用 `spawn_agent` 派发 `cowork-implement`,`fork_turns="none"`,先发 `COWORK_DISPATCH_V1` 信封并等待 `COWORK_ACK`。
15
- 3. Check: 主会话用 `spawn_agent` 派发 `cowork-check`,`fork_turns="none"`,先发 `COWORK_DISPATCH_V1` 信封并等待 `COWORK_ACK`。
16
- 4. Finish: 主会话做最终验证、同步规格、提交、归档、记录 session。
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` 只保存项目状态、任务上下文和恢复线索;实际执行由主会话和固定 `cowork-*` agent 完成。
22
+ `cowork-flow` 只保存项目状态、任务上下文、宿主适配器契约和恢复线索;实际执行由主会话和固定 `cowork-*` 代理完成。宿主工具名只写在 `.cowork-flow/adapters/<host>/adapter.yaml`,不进入流程分支。
19
23
 
20
- ## 1.1 Hook 注入状态
24
+ `task next` 是主会话的阶段导航器。进入任务阶段、恢复会话、派发实现、进入检查、完成收口前,先运行 `./.cowork-flow/run task next` 或 `.\.cowork-flow\run.cmd task next`,用当前任务和 `task.json.status` 决定下一步。该命令只读,不推进状态。
21
25
 
22
- `.codex/hooks/inject-workflow-state.py` 每轮读取当前 session task,并把下面的 `[workflow-state:*]` 片段注入 Codex 上下文。`workflow.md` 是状态提示的唯一来源;修改流程时必须同步这些片段。
26
+ ## 1.1 状态注入与入口分类
23
27
 
24
- [workflow-state:no_task]
25
- No active task for this session. For read-only Q&A, answer directly. For implementation, refactor, behavior change, or multi-step work, create or start a task first, then continue through Plan -> Implement -> Check -> Finish.
26
- [/workflow-state:no_task]
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
- [workflow-state:delegated_subtask]
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
- [workflow-state:planning]
33
- The active task is in planning. Finish prd.md, curate implement.jsonl and check.jsonl with spec/research files, then run task start before dispatching cowork-implement.
34
- [/workflow-state:planning]
34
+ 1. 新需求先判断清晰度。只读问题、单步且目标/范围/验收标准都清楚的小改可以绕过;否则必须先进入 `brainstorming`,在写 PRD、计划或固定代理派发前收束方向。
35
+ 2. 以下情况触发头脑风暴:
36
+ - 目标、用户价值或期望行为不清楚。
37
+ - 范围边界、非目标或影响面不清楚。
38
+ - 存在多种有效方案或关键取舍尚未决定。
39
+ - 涉及 L1/L2 行为变化,或影响架构、接口、数据、权限、发布迁移。
40
+ - 验收标准缺失、风险未知,或关键假设需要暴露。
35
41
 
36
- [workflow-state:in_progress]
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, verifies child output, lists agents, and closes children.
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,210 +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
- 当前任务是 session-scoped。没有 `COWORK_FLOW_CONTEXT_ID`、`CODEX_SESSION_ID` 或 `CODEX_THREAD_ID` 时,不得猜测当前任务。
60
+ > 当前任务是会话级状态。没有 `COWORK_FLOW_CONTEXT_ID`、`CODEX_SESSION_ID`、`CODEX_THREAD_ID`、`OPENCODE_SESSION_ID` 或 `CLAUDE_SESSION_ID` 时,不得猜测当前任务。
60
61
 
61
- ## 3. Agent
62
+ 任务阶段状态由生命周期命令维护:
62
63
 
63
- ### cowork-research
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` |
64
71
 
65
- - 只做调研。
66
- - 只写入 `<task>/research/`。
67
- - 不改代码、不改规格、不改任务状态、不操作 git。
72
+ `task finish` 只清理当前会话任务指针,不改变 `task.json.status`。
68
73
 
69
- ### cowork-implement
74
+ ## 3. 固定代理
70
75
 
71
- - 读取 `<task>/prd.md`、`<task>/info.md`、`<task>/implement.jsonl` 和 JSONL 指向的文件。
72
- - 按任务范围实现。
73
- - 不启动其他 agent,不提交,不归档,不运行 task start/finish/archive。
74
- - 汇报改动文件和验证命令。
76
+ 固定代理只执行主会话派发的叶子任务。子代理是执行者,子任务是工作单元。
75
77
 
76
- ### cowork-check
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` | 检查行为、测试、规格同步和遗漏;范围内问题直接修复 | 提交、归档、启动其他代理 | 检查结论、修复内容和验证结果 |
77
83
 
78
- - 读取 `<task>/prd.md`、`<task>/check.jsonl` 和 `git diff`。
79
- - 检查行为、测试、规格同步和遗漏。
80
- - 范围内问题直接修复。
81
- - 不提交、不归档、不启动其他 agent。
84
+ ## 3.1 固定代理派发入口
82
85
 
83
- 兼容旧派发时,提示仍可用这一行开头:
86
+ 固定 `cowork-*` 代理使用宿主适配器契约,由主会话负责派发、等待、验收和取消。宿主专属原语只在 `.cowork-flow/adapters/<host>/adapter.yaml` 中声明;工作流只关心阶段职责、协调边界和验收责任。
84
87
 
85
- ```text
86
- Active task: .cowork-flow/tasks/<task>
87
- ```
88
+ 正式派发协议见 `.cowork-flow/spec/subagent-dispatch.md`。该协议定义 runtime context 创建、传输、绑定、等待、返回验收、关闭清理和通用 worker 边界。
88
89
 
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
- ```
90
+ - 主会话必须使用新鲜子上下文派发固定代理。
91
+ - 主会话通过适配器等待原语、适配器列表原语和适配器取消/关闭原语完成收口。
92
+ - 固定 `cowork-*` 代理是叶子执行者;不得再派发、等待、列出或取消其他代理。
93
+ - 通用 `worker`、`default` 或 `explorer` 只能作为 advisory work,不能满足正式实现或检查完成条件。
112
94
 
113
- 等待与验收约定:
95
+ ## 3.2 并行会话
114
96
 
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
- - If a child reports another `dispatch_id`, close that child and respawn the intended task.
119
- - 用 `wait_agent` 等待子 agent 返回。
120
- - 用 `list_agents` 确认没有遗留 running child。
121
- - 验收子 agent 汇报的文件、命令和结果;不只信“已完成”文本。
122
- - 完成或失败后用 `close_agent` 关闭子 agent。
123
- - 子 agent 自身是 leaf executor;不得再调用 `spawn_agent`、`wait_agent`、`list_agents`、`close_agent`。
97
+ 并行执行采用干净隔离的并行会话模型。并行只是执行策略,不改变固定代理叶子边界。
124
98
 
125
- Generic worker boundary:
99
+ ### 3.2.1 并行决策
126
100
 
127
- - Formal execution uses `cowork-research`, `cowork-implement`, or `cowork-check`.
128
- - Generic `worker` dispatch is best-effort only.
129
- - If a generic worker does not ACK after one retry, close it and do not execute the task.
130
- - 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.
101
+ - 用户无需在需求输入时声明是否并行;计划阶段由主会话评估并行可行性。
102
+ - 开发计划必须明确执行策略:串行执行,或列出可并行的低冲突切片。
103
+ - 同一文件、同一行为链、依赖未合并或验收标准不清的工作不得并行,改为串行。
131
104
 
132
- ## 3.2 parallel sessions
105
+ ### 3.2.2 隔离方式
133
106
 
134
- 并行执行采用 clean-room 的 parallel sessions 模型:
107
+ - 多个独立任务优先拆成多个 cowork-flow 会话。
108
+ - 只要存在写入冲突风险,就用独立 `git worktree` 隔离。
135
109
 
136
- - 用户无需在需求输入时声明是否并行;Plan 阶段由主会话评估并行可行性。
137
- - 开发计划必须明确执行策略:串行执行,或列出可并行的 low-conflict slices。
138
- - 多个独立任务优先拆成多个 Codex sessions;只要存在写入冲突风险,就用独立 `git worktree` 隔离。
139
- - 单个 task 内只允许低冲突的 low-conflict slices 并行;每个 slice 必须写清 file ownership、dependencies、expected outputs 和验证命令。
140
- - 同一文件、同一行为链、依赖未合并或验收标准不清的工作不得并行,改为串行。
141
- - 主会话是唯一协调者:派发所有子 agent 后逐个 `wait_agent`,核对子 agent 汇报的文件、命令和产物,再 `list_agents` / `close_agent` 收口。
142
- - 多个实现 slice 合并后必须再执行 final integrated verification;不能把各子 agent 的局部通过当成整体通过。
143
- - 固定 `cowork-*` agent 仍是 leaf executor;并行不允许子 agent 再派发 agent,也不引入旧集中式状态机。
110
+ ### 3.2.3 单任务内切片
111
+
112
+ - 单个任务内只允许低冲突切片并行。
113
+ - 每个切片必须写清文件归属、依赖关系、预期产物和验证命令。
114
+
115
+ ### 3.2.4 协调与验收
116
+
117
+ - 主会话是唯一协调者:派发所有子代理后逐个等待,核对子代理汇报的文件、命令和产物,再用适配器列表/取消原语收口。
118
+ - 多个实现切片合并后必须再执行最终集成验证;不能把各子代理的局部通过当成整体通过。
119
+ - 固定 `cowork-*` 代理仍是叶子执行者;并行不允许子代理再派发代理,也不引入旧集中式状态机。
144
120
 
145
121
  ## 4. 任务分级
146
122
 
147
123
  ### L0: 无外部行为变化
148
124
 
149
125
  适用:文档、格式、小范围重构、注释、脚本整理、测试补充,且不改变用户可观察行为。
150
-
151
- 流程:读取规则 -> 创建或选择任务 -> 写 PRD -> 初始化上下文 -> 实现 -> 验证 -> 记录 session。
126
+ 流程:`brainstorming` -> `read spec` -> `implement` -> `check` -> `complete`
152
127
 
153
128
  ### L1: 局部行为变化
154
129
 
155
130
  适用:单模块功能、局部接口行为、局部数据处理逻辑,边界清晰。
156
-
157
- 流程:change -> brainstorming -> spec -> plan -> task context -> Implement -> Check -> Finish。
131
+ 流程: `changes` -> `brainstorming` -> `read spec` -> `plan` -> `tasks` -> `implement` -> `check` -> `complete` -> `archive` -> `add session`
158
132
 
159
133
  ### L2: 跨层或重要行为变化
160
134
 
161
135
  适用:API / DB / 消息 / 权限 / 文件格式 / 架构边界 / 发布迁移 / 安全策略等变化。
162
-
163
- 流程:change -> brainstorming -> design.md -> spec -> plan -> task context -> Implement -> Check -> Finish -> cross-layer review。
164
-
165
- ## 5. Plan 阶段
166
-
167
- 1. 读取 `AGENTS.md`、本文件、相关 `.cowork-flow/spec/` 索引。
168
- 2. 创建或确认任务:
169
-
170
- ```bash
171
- ./.cowork-flow/run task create "<title>" --slug <task-name>
172
- ```
173
-
174
- 3. 写 `prd.md`,至少包含目标、范围、验收标准、相关文件、验证方式。
175
- 4. 初始化上下文:
176
-
177
- ```bash
178
- ./.cowork-flow/run task init-context <task-dir> <type>
179
- ./.cowork-flow/run task add-context <task-dir> implement <path> "<reason>"
180
- ./.cowork-flow/run task add-context <task-dir> check <path> "<reason>"
181
- ```
182
-
183
- 5. 对 L1/L2 创建 change;L2 必须有 `design.md`。
184
- 6. 写 `.cowork-flow/plans/YYYY-MM-DD-<slug>.md`,每步带验证命令。
185
- 7. 启动当前会话任务:
186
-
187
- ```bash
188
- ./.cowork-flow/run task start <task-dir>
189
- ```
190
-
191
- Windows PowerShell 使用:
192
-
193
- ```powershell
194
- .\.cowork-flow\run.cmd task start <task-dir>
195
- ```
196
-
197
- ## 6. Implement 阶段
198
-
199
- 默认派发 `cowork-implement`。派发调用必须设置 `fork_turns="none"`,优先使用 `COWORK_DISPATCH_V1` 信封;兼容旧消息时第一行:
200
-
201
- ```text
202
- Active task: .cowork-flow/tasks/<task>
203
- ```
204
-
205
- 派发内容应包含当前计划步骤、范围边界和期望验证命令。
206
-
207
- 如果用户明确要求主会话 inline 执行,或当前任务正在修改 subagent/runtime 行为,可以不派发 `cowork-implement`,但必须说明原因,并仍按计划与测试循环推进。
208
-
209
- 涉及行为变化时,先写失败测试,再实现,再验证变绿。
210
-
211
- ## 7. Check 阶段
212
-
213
- 默认派发 `cowork-check`。派发调用必须设置 `fork_turns="none"`,优先使用 `COWORK_DISPATCH_V1` 信封;兼容旧消息时第一行:
214
-
215
- ```text
216
- Active task: .cowork-flow/tasks/<task>
217
- ```
218
-
219
- 检查内容:
220
-
221
- - PRD 验收标准是否满足。
222
- - `git diff` 是否只包含预期范围。
223
- - 测试是否覆盖关键行为。
224
- - `.cowork-flow/spec/` 是否需要更新。
225
- - plan checkbox 和执行状态是否真实。
226
-
227
- 如果用户明确要求主会话 inline 检查,可以不派发 `cowork-check`,但必须执行等价的 diff、测试、规格同步检查。
228
-
229
- ## 8. Finish 阶段
230
-
231
- 完成前必须确认:
232
-
233
- - 当前 session 存在任务,或明确说明本次是无任务只读工作。
234
- - `cowork-check` 或等价最终检查已执行。
235
- - 所有声明通过的验证都有命令输出依据。
236
- - 规格已更新,或明确判断无需更新。
237
- - 计划状态、任务状态、change metadata 不冲突。
238
- - 提交在归档和 session 记录之前完成。
239
- - 不纳入无关脏改。
240
-
241
- 推荐顺序:
242
-
243
- ```bash
244
- git status --short
245
- git diff --check
246
- npm run test:all
247
- git add <expected files>
248
- git commit -m "<message>"
249
- ./.cowork-flow/run task archive <task-name>
250
- ./.cowork-flow/run add-session --title "<title>" --commit "<commit>" --summary "<summary>"
251
- ```
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
+ ```
252
217
 
253
218
  ## 9. 恢复规则
254
219
 
255
220
  恢复时只读取最小上下文:
256
-
257
221
  1. 运行 `./.cowork-flow/run resume`。
258
222
  2. 按 `RESUME CHECKLIST` 读取当前任务 PRD、计划状态和 JSONL 指向文件。
259
- 3. 不批量读取所有 spec、所有 plans、所有 tasks 或 workspace journal。
260
- 4. 不存在当前 session task 时,先创建或启动任务。
223
+ 3. 不批量读取所有规格、计划、任务或工作区日志。
224
+ 4. 不存在当前会话任务时,先创建或启动任务。
261
225
 
262
226
  ## 10. 禁止事项
263
227
 
@@ -266,4 +230,4 @@ git commit -m "<message>"
266
230
  - 不维护第二套执行状态。
267
231
  - 不把口头状态当成可靠状态。
268
232
  - 不把验证未运行说成通过。
269
- - 不把旧运行模型作为 fallback。
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`.