cowork-flow 2.3.0 → 2.4.1

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 (63) hide show
  1. package/CHANGELOG.md +31 -1
  2. package/README.en.md +34 -18
  3. package/README.md +8 -5
  4. package/docs/architecture.en.md +95 -0
  5. package/docs/architecture.md +7 -3
  6. package/docs/direction.en.md +71 -0
  7. package/docs/direction.md +6 -1
  8. package/docs/hosts.en.md +299 -0
  9. package/docs/hosts.md +3 -1
  10. package/docs/index.en.md +30 -0
  11. package/docs/index.md +2 -0
  12. package/docs/release.en.md +108 -0
  13. package/docs/release.md +2 -0
  14. package/package.json +2 -2
  15. package/presets/claude-code/.claude-plugin/plugin.json +1 -1
  16. package/presets/claude-code/skills/cowork-flow-bootstrap/SKILL.md +4 -0
  17. package/presets/codex/.codex-plugin/plugin.json +1 -1
  18. package/presets/codex/skills/cowork-flow-bootstrap/SKILL.md +4 -0
  19. package/presets/kimi-code/.kimi-plugin/plugin.json +1 -1
  20. package/presets/kimi-code/skills/cowork-flow-bootstrap/SKILL.md +4 -0
  21. package/presets/opencode/cowork-flow/skills/cowork-flow-bootstrap/SKILL.md +4 -0
  22. package/presets/qoder/.qoder-plugin/plugin.json +1 -1
  23. package/presets/qoder/skills/cowork-flow-bootstrap/SKILL.md +4 -0
  24. package/presets/zcode/.zcode-plugin/plugin.json +1 -1
  25. package/presets/zcode/skills/cowork-flow-bootstrap/SKILL.md +4 -0
  26. package/src/commands/init.js +129 -2
  27. package/src/commands/registry.js +3 -1
  28. package/src/commands/source-refresh.js +5 -1
  29. package/src/commands/sync.js +3 -0
  30. package/src/lib/copy-template.js +23 -5
  31. package/src/lib/host-assets.js +117 -2
  32. package/src/lib/language.js +162 -0
  33. package/template/.cowork-flow/.version +1 -1
  34. package/template/.cowork-flow/config.yaml +8 -0
  35. package/template/.cowork-flow/scripts/adapters/cli/task_create_command.py +5 -3
  36. package/template/.cowork-flow/scripts/adapters/host/host_manifest.py +71 -2
  37. package/template/.cowork-flow/scripts/infra/config.py +85 -0
  38. package/template/.cowork-flow/scripts/services/decision_anchor_schema.py +228 -0
  39. package/template/.cowork-flow/scripts/services/fact_view.py +27 -15
  40. package/template/.cowork-flow/scripts/services/plan_binding.py +34 -0
  41. package/template/.cowork-flow/scripts/services/plan_schema.py +182 -0
  42. package/template/.cowork-flow/scripts/services/task_context.py +84 -12
  43. package/template/.cowork-flow/scripts/services/task_creation.py +89 -30
  44. package/template/.cowork-flow/scripts/services/task_gate_profiles.py +7 -24
  45. package/template/.cowork-flow/spec/contracts/context-injection.md +5 -4
  46. package/template/.cowork-flow/spec/contracts/decision-anchor.md +35 -19
  47. package/template/.cowork-flow/spec/contracts/plan-binding.md +27 -4
  48. package/template/.cowork-flow/spec/index.md +26 -26
  49. package/template/.cowork-flow/spec/references/definition-of-done.md +26 -26
  50. package/template/.cowork-flow/spec/references/index.md +16 -16
  51. package/template/.cowork-flow/spec/references/orchestration-patterns.md +71 -71
  52. package/template/.cowork-flow/spec/references/security-checklist.md +37 -37
  53. package/template/.cowork-flow/spec/references/testing-checklist.md +32 -32
  54. package/template/.cowork-flow/spec/runtime/contract-registry.json +1 -0
  55. package/template/.cowork-flow/spec/runtime/host-assets.json +23 -4
  56. package/template/.cowork-flow/spec/runtime/index.md +10 -12
  57. package/template/.cowork-flow/spec/schemas/host-assets.schema.json +31 -0
  58. package/template/.cowork-flow/spec/schemas/index.md +5 -5
  59. package/template/.cowork-flow/templates/plan-template.md +91 -0
  60. package/template/locales/en-US/.cowork-flow/spec/contracts/decision-anchor.md +169 -0
  61. package/template/locales/en-US/.cowork-flow/templates/plan-template.md +91 -0
  62. package/template/skills/runtime-health/scripts/doctor.py +110 -0
  63. package/template/skills/task-planning/SKILL.md +21 -94
@@ -289,7 +289,8 @@ Verify: npm run test:fast; python3 -m pytest tests/ -q
289
289
  - **Gates**: static preview text, identical on all hosts; the delegated
290
290
  variant replaces the self-declaration sentence with "scope is inherited
291
291
  from the parent task (read-only reference)".
292
- - **Verify**: `## 验证命令` lines from decision-anchor (first 10, 120 chars
292
+ - **Verify**: `## Verification Commands`/`## 验证命令` lines from
293
+ decision-anchor (first 10, 120 chars
293
294
  each) — the agent's own declared self-checks; omitted when none.
294
295
  - **Per-edit warning**: PostToolUse on an edit tool injects at most one
295
296
  line when the edited file is outside the task's declared scope —
@@ -326,9 +327,9 @@ Verify: npm run test:fast; python3 -m pytest tests/ -q
326
327
  budget/limits come from `.cowork-flow/spec/runtime/scope-rules.json`, the
327
328
  single source consumed at runtime; a missing or malformed file degrades to
328
329
  embedded defaults that are byte-identical with the shipped file (locked by
329
- `tests/test_scope_rules.py`). The file is template-managed
330
- (`syncPolicy.safeFiles`): `cwf project sync` refreshes it, so local edits to
331
- it do not survive a sync.
330
+ `tests/test_scope_rules.py`). The file is framework-managed: `cwf project
331
+ sync` refreshes it as part of the synced `spec/runtime/` tree, so local edits
332
+ to it do not survive a sync.
332
333
  - Absent for `no_task` / `planning` / `completed` states. Block content is
333
334
  byte-identical across host lines for the whole fixture matrix
334
335
  (`test/fixtures/stage-contract-matrix.json` drives the equality test:
@@ -8,8 +8,9 @@ the alternatives", which compresses the number of task artifacts.
8
8
 
9
9
  ## Schema
10
10
 
11
- These section names are literal: the runtime parser matches them exactly, so a
12
- translated heading would simply stop being read.
11
+ These section names are machine-readable. The runtime parser accepts both the
12
+ Chinese and English heading sets, and new anchors use the language configured in
13
+ `.cowork-flow/config.yaml` (`zh-CN` is the default).
13
14
 
14
15
  ```markdown
15
16
  # Decision Anchor
@@ -38,14 +39,17 @@ translated heading would simply stop being read.
38
39
 
39
40
  ## Section requirements
40
41
 
42
+ Both heading columns below are accepted; the left column is the `zh-CN` output
43
+ and the right column the `en-US` output.
44
+
41
45
  | Section | Required | Why |
42
46
  |------|------|------|
43
- | `## 目标` | required | no goal, no acceptance baseline |
44
- | `## 验收标准` | required | `task_start` is blocked without acceptance criteria |
45
- | `## 被拒方案` | optional | required for brainstorming tasks, so a rejected option is not reconsidered during execution |
46
- | `## 关键假设` | optional | filled in for complex tasks to surface implicit constraints; not read by the runtime parser |
47
- | `## 范围边界` | optional | prevents scope creep |
48
- | `## 验证命令` | optional | filled in for complex tasks, as the basis for automated verification; when the changed files are covered by `.cowork-flow/spec/backend/` or `frontend/` rules, it must also carry the spec/gate check for the task's `dev_type` (deciding command, or clause-by-clause `pass` / `not_applicable` with reason) |
47
+ | `## 目标` / `## Goal` | required | no goal, no acceptance baseline |
48
+ | `## 验收标准` / `## Acceptance Criteria` | required | `task_start` is blocked without acceptance criteria |
49
+ | `## 被拒方案` / `## Rejected Options` | optional | required for brainstorming tasks, so a rejected option is not reconsidered during execution |
50
+ | `## 关键假设` / `## Key Assumptions` | optional | filled in for complex tasks to surface implicit constraints; not read by the runtime parser |
51
+ | `## 范围边界` / `## Scope Boundary` | optional | prevents scope creep |
52
+ | `## 验证命令` / `## Verification Commands` | required for strict non-Tiny; optional for legacy/Tiny | filled in for complex tasks, as the basis for automated verification; a strict non-Tiny task also needs the configured-language section and a filled spec/gate check for the task's `dev_type` (deciding command, or clause-by-clause `pass` / `not_applicable` with reason) |
49
53
 
50
54
  ### Machine-readable line formats (for injection)
51
55
 
@@ -55,11 +59,13 @@ fact view (`services/fact_view.parse_decision_anchor`). Line-format conventions:
55
59
  - `## 验证命令`: one command per line (an optional `- ` prefix), truncated to 120
56
60
  characters, at most 10 lines; the implementing agent runs them itself
57
61
  (self-declared, self-checked) and the reviewer verifies the execution evidence.
58
- When the changed files are covered by `.cowork-flow/spec/<dev_type>/` rules, the
59
- section must also carry the spec/gate check for the task's `dev_type`: a deciding
60
- command, or a `规范核对:` line reviewed clause by clause (`pass` /
61
- `not_applicable` + reason). This is a strong review reminder, not a `spec-check`
62
- hard gate.
62
+ A strict non-Tiny task must also carry a `规范核对:` line in the configured
63
+ language's section, with the actual `pass` / `not_applicable` result and a
64
+ reason. The template placeholder (`<pass / not_applicable + 理由>`) does not
65
+ satisfy the start gate. This line is a hard start gate for strict non-Tiny
66
+ tasks, while its content remains self-declared and is reviewed by the check
67
+ agent. The fact view recognizes the line and does not return it as a shell
68
+ command.
63
69
  - `## 范围边界`: only the first non-empty line is taken, truncated to 160
64
70
  characters.
65
71
 
@@ -84,15 +90,24 @@ After merging (5 files): `decision-anchor.md` + `implement.jsonl` + `check.jsonl
84
90
  ## Lifecycle check coupling
85
91
 
86
92
  - The preflight for `task next <dir> --run` checks that `decision-anchor.md` is
87
- non-empty and requires the `## 目标` and `## 验收标准` sections to be present.
93
+ non-empty and requires the `## 目标` / `## Goal` and `## 验收标准` /
94
+ `## Acceptance Criteria` sections to be present.
88
95
  - **Gate profile `meta.gateProfile`**: a newly created task is written as
89
96
  `"strict"`; an unmarked task is treated as `"legacy"` — existing tasks are not
90
97
  retro-fitted with the stricter gate, and the profile is queryable through the
91
98
  fact view. On top of the section check, a strict task additionally requires: at
92
- least one parseable `- [ ] AC-xxx: ...` row in `## 验收标准`, no duplicate AC ids,
93
- no non-AC list rows in that section, and a declared `dev_type` (otherwise
94
- `task specs` dev-type dispatch silently comes back shorter).
95
- - A `## 验收标准` row's checkbox state (`- [ ]` / `- [x]`) and the evidence records
99
+ least one parseable `- [ ] AC-xxx: ...` row in `## 验收标准` /
100
+ `## Acceptance Criteria`, no duplicate AC ids, no non-AC list rows in that
101
+ section, and a declared `dev_type` (otherwise `task specs` dev-type dispatch
102
+ silently comes back shorter).
103
+ - A strict non-Tiny task also requires the configured-language
104
+ `## 验证命令` / `## Verification Commands` section with a filled
105
+ `规范核对:` / `Spec check:` line. A missing section, the other-language
106
+ heading, or the template placeholder blocks start. Tiny tasks and legacy tasks
107
+ are exempt. The bound plan's `## 最终验证` / `## Final Verification` section
108
+ carries the same filled check; plan structure and language are covered by
109
+ `plan-binding.md`.
110
+ - An acceptance row's checkbox state (`- [ ]` / `- [x]`) and the evidence records
96
111
  (the task directory's `evidence.jsonl`) are the fact source of the completion
97
112
  gate: completion is blocked when an unchecked AC exists (`LIFECYCLE-AC-001`), a
98
113
  declared AC has no evidence (`LIFECYCLE-AC-002`), a strict task cannot read any
@@ -149,4 +164,5 @@ source; if a task directory has only `prd.md` and no `decision-anchor.md`,
149
164
  `decision-anchor.md is missing or empty`.
150
165
 
151
166
  An existing legacy task needs a human to convert the `prd.md` content into
152
- `decision-anchor.md`, fill in `## 目标` and `## 验收标准`, and only then start.
167
+ `decision-anchor.md`, fill in `## 目标` / `## Goal` and `## 验收标准` /
168
+ `## Acceptance Criteria`, and only then start.
@@ -48,11 +48,32 @@ into `in_progress`:
48
48
  - `task.json.meta.planFile` exists.
49
49
  - `planFile` is a repo-relative `.cowork-flow/plans/` path.
50
50
  - The plan file exists and is non-empty.
51
- - `decision-anchor.md` contains `## 目标` and `## 验收标准`.
51
+ - `decision-anchor.md` contains `## Goal`/`## 目标` and
52
+ `## Acceptance Criteria`/`## 验收标准`.
52
53
  - `implement.jsonl` passes the existing context validation.
53
-
54
- A Tiny task may have no planFile, but must still satisfy the existing anchor and
55
- implement-scope requirements.
54
+ - For a strict non-Tiny task, the plan title contains the configured-language
55
+ marker (`实施计划` / `Implementation Plan`).
56
+ - The plan contains the six configured-language `##` template headings in
57
+ template order: `目标` / `验收标准` / `全局约束` / `文件边界` / `任务` /
58
+ `最终验证`, or their `en-US` equivalents. Extra custom sections are allowed;
59
+ fenced code is ignored; a known template heading from the other language is
60
+ rejected.
61
+ - Any `### 任务` / `### Task` task heading uses the configured-language prefix.
62
+ - `## 最终验证` / `## Final Verification` contains a line starting with
63
+ `规范核对:` / `Spec check:` and carrying an actual `pass` or
64
+ `not_applicable` result. The template placeholder (`<pass / not_applicable +
65
+ 理由>` / `<pass / not_applicable + reason>`) does not satisfy the gate.
66
+ - The strict non-Tiny anchor carries the configured-language `## 验证命令` /
67
+ `## Verification Commands` section with the same filled spec-check result;
68
+ see `decision-anchor.md`.
69
+
70
+ Creation and `--from-plan` binding stay permissive: a planning task may create
71
+ and bind a plan before its structure is final. These checks run only at the
72
+ planning → `in_progress` start gate.
73
+
74
+ A Tiny task may have no planFile and is exempt from the plan-shape and anchor
75
+ spec-check gates. A legacy task (no `meta.gateProfile: "strict"`) keeps the
76
+ historical checks; this contract does not retro-fit either profile.
56
77
 
57
78
  ## Implementation recovery
58
79
 
@@ -78,6 +99,8 @@ The recovery output lists paths only and never expands the plan prose.
78
99
  - No Markdown AST or DSL.
79
100
  - No comparing AC text against plan task prose.
80
101
  - No matching verification commands against evidence records.
102
+ - No semantic validation of the spec-check result or reason; the structural
103
+ check only requires an actual `pass` / `not_applicable` token.
81
104
  - No plan-approval data model.
82
105
 
83
106
  These capabilities are considered only after warning noise and real payoff have been
@@ -1,35 +1,35 @@
1
1
  # Cowork Flow Spec Index
2
2
 
3
- 本目录只存放项目规范、运行时合同和运行时配置 schema。按职责分层:
3
+ This directory holds project specs, runtime contracts, and runtime configuration schemas. Layers by responsibility:
4
4
 
5
- | 目录 | 作用 |
5
+ | Directory | Purpose |
6
6
  | --- | --- |
7
- | `contracts/` | 人读的 workflow、宿主适配器和子代理协议合同。 |
8
- | `runtime/` | runtime 读取的机器配置,包括 contract registry 和 host asset manifest。 |
9
- | `schemas/` | runtime 配置和宿主合同的 JSON Schema。 |
10
- | `backend/` | 后端实现规范;由 review skill 按需读取并逐条审查。 |
11
- | `frontend/` | 前端实现规范;由 review skill 按需读取并逐条审查。 |
12
- | `guides/` | brainstorming/task-planning 阶段的编码前思考、跨层设计和复用判断指引。 |
13
- | `references/` | 按需参考材料(DoD、测试清单、安全清单、协作模式);不自动加载。加载条件见 contract-registry.json 的 references 数组。 |
14
-
15
- 流程内核只负责任务状态、文件范围、runtime context、归档一致性等可机器判断的事实。
16
- 动作、阶段指导和专属运行时由各 Skill 的 `manifest.json` 声明;不维护集中式
17
- Skill registry。
18
- `backend/`、`frontend/` 中的自然语言规范不注册为 runtime gate;
19
- `task-review` skill 根据当前 diff 和任务范围读取并逐条审查。
20
- `guides/` 属于前置澄清与计划参考;选用后的结论应进入 `decision-anchor.md` 或任务计划。
7
+ | `contracts/` | Human-readable contracts for the workflow, host adapters, and subagent protocol. |
8
+ | `runtime/` | Machine configuration read by the runtime, including the contract registry and host asset manifest. |
9
+ | `schemas/` | JSON Schemas for runtime configuration and host contracts. |
10
+ | `backend/` | Backend implementation specs; the review skill reads them on demand and checks each clause. |
11
+ | `frontend/` | Frontend implementation specs; the review skill reads them on demand and checks each clause. |
12
+ | `guides/` | Pre-implementation thinking, cross-layer design, and reuse guidance for brainstorming/task-planning. |
13
+ | `references/` | On-demand reference material (DoD, testing checklist, security checklist, orchestration patterns); never auto-loaded. Load conditions are in the `references` array of contract-registry.json. |
14
+
15
+ Sync ownership: `contracts/`, `runtime/`, `schemas/`, and this file are framework-maintained and follow `cwf project sync`; `backend/`, `frontend/`, `guides/`, and `references/` are project-maintained, and `sync` never overwrites or deletes files there.
16
+
17
+ The workflow kernel only owns machine-checkable facts: task state, file scope, runtime context, and archive consistency.
18
+ Actions, stage guidance, and dedicated runtimes are declared by each Skill's `manifest.json`; there is no centralized Skill registry.
19
+ Natural-language specs under `backend/` and `frontend/` are not registered as runtime gates; the `task-review` skill reads them according to the current diff and task scope and checks each clause.
20
+ `guides/` is pre-implementation clarification and planning reference; selected conclusions belong in `decision-anchor.md` or the task plan.
21
21
 
22
22
  ## references/
23
23
 
24
- > 按需参考材料。**不在主会话中自动加载**——仅当 skill 入口或 agent 判断需要时读取。
24
+ > On-demand reference material. **Never auto-loaded in the main session** — read only when a skill entry or agent judges it necessary.
25
25
 
26
- reference 文件之作用是:
27
- 1. 为 skill 入口提供补充上下文(main skill 是入口,reference 是补充)
28
- 2. 减少每次会话需加载的内容(spec/backend/ 等窄域规范只有实际需要时才加载)
29
- 3. 在 planning、check 或 review 阶段提供快速对照清单
26
+ Reference files:
27
+ 1. Provide supplemental context for skill entries (the main skill is the entry point; references supplement it).
28
+ 2. Reduce what each session must load (narrow-domain specs such as `spec/backend/` are read only when needed).
29
+ 3. Provide quick checklists during planning, check, or review.
30
30
 
31
- 加载规则:
32
- - contract-registry 中 loadWhen 之一被匹配时读取
33
- - skill 正文中显式引用 reference ID 时读取
34
- - 用户在主会话请求特定检查时
35
- - **不**自动加载——这是与 contracts/ 系列的区别
31
+ Loading rules:
32
+ - Read when one of the `loadWhen` conditions in contract-registry matches.
33
+ - Read when a skill body explicitly references a reference ID.
34
+ - Read when the user requests a specific check in the main session.
35
+ - **Never auto-loaded** — that is the difference from `contracts/`.
@@ -1,44 +1,44 @@
1
1
  # Definition of Done
2
2
 
3
- > 项目级完成门槛。每项变更在被视为"完成"前必须满足。与 per-task AC 互补但不替代。
3
+ > Project-level completion gates. Every change must satisfy these before it is considered "done". They complement per-task ACs; they do not replace them.
4
4
 
5
- ## 通用门槛(所有任务)
5
+ ## General gates (all tasks)
6
6
 
7
- | # | 检查项 | 验证 |
7
+ | # | Check | Verification |
8
8
  |---|---|---|
9
- | G1 | 代码实现符合 decision-anchor acceptance criteria | AC 全部为 verified |
10
- | G2 | 行为变更有对应测试或明确验证命令;高风险任务覆盖失败、边界或回归路径 | `./.cowork-flow/run task next <dir> --validate` 与任务验证命令通过 |
11
- | G3 | check phase 完成,无 unresolved blocker | `task-review` 结论为 pass,completion lifecycle blocker 为 0 |
12
- | G4 | 无新引入 lint/type/build 警告 | lint / build 命令通过 |
13
- | G5 | Git status snapshot 仅含任务相关变更,包括 staged、unstaged、untracked | git status --porcelain=v1 -uall |
9
+ | G1 | Implementation satisfies the decision-anchor acceptance criteria | All ACs are verified |
10
+ | G2 | Behavior changes have corresponding tests or an explicit verification command; high-risk tasks cover failure, boundary, or regression paths | `./.cowork-flow/run task next <dir> --validate` and the task verification commands pass |
11
+ | G3 | Check phase is complete with no unresolved blocker | `task-review` verdict is pass, and the completion lifecycle blocker count is 0 |
12
+ | G4 | No newly introduced lint/type/build warnings | lint / build commands pass |
13
+ | G5 | Git status snapshot contains only task-related changes, including staged, unstaged, and untracked | git status --porcelain=v1 -uall |
14
14
 
15
- ## L0 专属(docs/format/comments only)
15
+ ## L0 only (docs/format/comments only)
16
16
 
17
- | # | 检查项 |
17
+ | # | Check |
18
18
  |---|---|
19
- | L0-1 | 确认变更不涉及行为(docs/format/comments only)|
20
- | L0-2 | git diff --check 无空白错误 |
19
+ | L0-1 | Change is confirmed non-behavioral (docs/format/comments only) |
20
+ | L0-2 | `git diff --check` reports no whitespace errors |
21
21
 
22
- ## L1 专属(单模块行为变更)
22
+ ## L1 only (single-module behavior change)
23
23
 
24
- | # | 检查项 |
24
+ | # | Check |
25
25
  |---|---|
26
- | L1-1 | brainstorming 记录存在 |
27
- | L1-2 | 修改未扩散到无关模块(git diff 范围与 task.scope 一致)|
26
+ | L1-1 | Brainstorming record exists |
27
+ | L1-2 | Changes do not spread into unrelated modules (git diff range matches task.scope) |
28
28
 
29
- ## L2 专属(跨层 / 架构 / 迁移)
29
+ ## L2 only (cross-layer / architecture / migration)
30
30
 
31
- | # | 检查项 |
31
+ | # | Check |
32
32
  |---|---|
33
- | L2-1 | proposal.md / spec.md / design.md 齐全 |
34
- | L2-2 | 结构化决策审查已按 Skill 指导完成或明确记录不适用 |
35
- | L2-3 | readiness gate 全部通过(`task next <dir> --run` 无 blocker)|
36
- | L2-4 | spec-sync Skill 已确认规格同步或明确记录无需更新 |
33
+ | L2-1 | proposal.md / spec.md / design.md are complete |
34
+ | L2-2 | Structured decision review completed per Skill guidance, or explicitly recorded as not applicable |
35
+ | L2-3 | All readiness gates pass (no blocker from `task next <dir> --run`) |
36
+ | L2-4 | spec-sync Skill confirms spec synchronization, or explicitly records that no update is needed |
37
37
 
38
- ## DoD 与 per-task AC 的区别
38
+ ## DoD vs per-task AC
39
39
 
40
40
  | DoD | AC |
41
41
  |---|---|
42
- | 项目级不变量——本次任务不例外 | decision-anchor 特有的完成条件 |
43
- | 来源:spec/references/definition-of-done | 来源:<task>/decision-anchor.md |
44
- | 两者都满足 = 任务真正完成 |
42
+ | Project-level invariant — this task is no exception | Completion conditions specific to the decision-anchor |
43
+ | Source: spec/references/definition-of-done | Source: <task>/decision-anchor.md |
44
+ | Satisfying both = the task is truly complete |
@@ -1,20 +1,20 @@
1
- # References — 按需加载参考材料
1
+ # References — On-Demand Reference Material
2
2
 
3
- > **不自动加载。** 仅当 skill 入口显式引用 reference ID 时、或 agent 判断需要时读取。
3
+ > **Never auto-loaded.** Read only when a skill entry explicitly references a reference ID, or when an agent judges it necessary.
4
4
 
5
- 本目录存放窄适用范围的快速参考卡,作为 skill 入口的补充。相较 `spec/contracts/`(契约)和 `spec/backend|frontend/`(域规范),reference 文件之作用是:
6
- 1. 在 check / finish 阶段提供快速对照清单(而非完整规范)
7
- 2. 在分析潜在 prompt injection 时提供防御规则集
8
- 3. 声明性总结 cowork-flow 已实现的协作模式
5
+ This directory holds narrow-scope quick-reference cards that supplement skill entries. Compared with `spec/contracts/` (contracts) and `spec/backend|frontend/` (domain specs), reference files:
6
+ 1. Provide quick checklists during check / finish (not full specs).
7
+ 2. Provide defensive rule sets for analyzing potential prompt injection.
8
+ 3. Declare the collaboration patterns cowork-flow already implements.
9
9
 
10
- 加载规则:
11
- - contract-registry.json 的 `references[*].loadWhen` 之一被匹配时
12
- - skill 正文中显式引用 reference ID 时
13
- - 用户在主会话请求特定检查时(如"security checklist")
14
- - **不**自动加载——这是与 contracts/ 系列的区别
10
+ Loading rules:
11
+ - Read when one of `contract-registry.json`'s `references[*].loadWhen` conditions matches.
12
+ - Read when a skill body explicitly references a reference ID.
13
+ - Read when the user requests a specific check in the main session (for example, "security checklist").
14
+ - **Never auto-loaded** — that is the difference from `contracts/`.
15
15
 
16
- 当前参考:
17
- - [definition-of-done.md](definition-of-done.md) — DoD:项目级完成门槛(L0/L1/L2 三档)
18
- - [testing-checklist.md](testing-checklist.md) — 测试结构/深度/反模式快速参考
19
- - [security-checklist.md](security-checklist.md) — OWASP Top 10 映射 + 快速检查
20
- - [orchestration-patterns.md](orchestration-patterns.md) — 已实现的协作模式声明性目录
16
+ Current references:
17
+ - [definition-of-done.md](definition-of-done.md) — DoD: project-level completion gates (L0/L1/L2).
18
+ - [testing-checklist.md](testing-checklist.md) — quick reference for test structure, depth, and anti-patterns.
19
+ - [security-checklist.md](security-checklist.md) — OWASP Top 10 mapping plus a quick check.
20
+ - [orchestration-patterns.md](orchestration-patterns.md) — declarative catalog of the collaboration patterns already implemented.
@@ -1,141 +1,141 @@
1
1
  # Orchestration Patterns
2
2
 
3
- > 已实现的协作模式声明性目录。
4
- > 本文件是 spec/contracts/ 系列的人可读摘要——权威定义以 spec/contracts/ 为准。
3
+ > Declarative catalog of the collaboration patterns already implemented.
4
+ > This file is a human-readable summary of the `spec/contracts/` series — the contracts are authoritative.
5
5
 
6
- ## 核心原则
6
+ ## Core principle
7
7
 
8
- **主会话是唯一的协调者。固定子代理是叶子执行者。用户是流程的最终决策者。**
8
+ **The main session is the only coordinator. Fixed subagents are leaf executors. The user is the final decision-maker.**
9
9
 
10
10
  ---
11
11
 
12
- ## 模式 1:叶子执行器(已实现)
12
+ ## Pattern 1: Leaf executors (implemented)
13
13
 
14
14
  ```
15
- 主会话 -> cowork-implement(实现)-> 返回 -> 主会话验证
16
- 主会话 -> cowork-check(验证) -> 返回 -> 主会话确认
17
- 主会话 -> cowork-research(调研) -> 返回 -> 主会话综合
15
+ main session -> cowork-implement (implement) -> return -> main session verifies
16
+ main session -> cowork-check (verify) -> return -> main session confirms
17
+ main session -> cowork-research (research) -> return -> main session synthesizes
18
18
  ```
19
19
 
20
- **使用场景**: 计划声明了并行低冲突切片(文件所有权干净、各有独立验证);需要上下文隔离的调研(cowork-research);完成前必须的独立复核(cowork-check)。
20
+ **When to use**: the plan declares parallel low-conflict slices (clean file ownership, independent verification); research that needs context isolation (cowork-research); the independent review required before completion (cowork-check).
21
21
 
22
- **约束**:
23
- - R-AG-001: 子代理不能派发其他子代理
24
- - R-AG-002: 子代理不修改 spec 文件
25
- - R-AG-003: 子代理不操作 Git
26
- - R-AG-004: 子代理不提交/归档
22
+ **Constraints**:
23
+ - R-AG-001: subagents must not dispatch other subagents
24
+ - R-AG-002: subagents must not modify spec files
25
+ - R-AG-003: subagents must not operate Git
26
+ - R-AG-004: subagents must not commit/archive
27
27
 
28
- **验证**: dispatch 前用 `subagent init --role` 创建 runtime context;child 第一个动作必须是 `subagent bind`;parent 检查 `status: bound`。
28
+ **Verification**: create the runtime context with `subagent init --role` before dispatch; the child's first action must be `subagent bind`; the parent checks `status: bound`.
29
29
 
30
30
  ---
31
31
 
32
- ## 模式 2:并行扇出 + 合并(已实现,主会话管理)
32
+ ## Pattern 2: Parallel fan-out + merge (implemented, main-session managed)
33
33
 
34
34
  ```
35
- 主会话 ─┬─> cowork-implement (task-slice-a) ─┐
36
- ├─> cowork-implement (task-slice-b) ─┤─> 所有返回 ─> 集成验证 ─> 主会话综合
37
- └─> cowork-research (background) ─┘
35
+ main session ─┬─> cowork-implement (task-slice-a) ─┐
36
+ ├─> cowork-implement (task-slice-b) ─┤─> all return ─> integrated verification ─> main session synthesizes
37
+ └─> cowork-research (background) ─┘
38
38
  ```
39
39
 
40
- **使用场景**: 多个低耦合的实现切片可以并行。
40
+ **When to use**: multiple low-coupling implementation slices can run in parallel.
41
41
 
42
- **验证清单**:
43
- 1. 子任务之间无写冲突(不同文件或通过 git worktree 隔离)
44
- 2. 每个子代理产出不同类型的发现
45
- 3. 合并步骤在主 agent 的上下文窗口内可完成
46
- 4. 用户等待时长足够使 parallel wall-clock 收益明显
47
- 5. 收束为单次 cowork-check 复核与单次提交(回执指纹覆盖合并后的变更集)
48
- 6. 同一工作树不能并行两个任务(文件范围门禁读取工作树全量变更);跨任务并行使用独立 worktree/clone 并经看板依赖边协调
42
+ **Verification checklist**:
43
+ 1. No write conflicts between subtasks (different files or isolated through git worktree)
44
+ 2. Each subagent produces a different type of finding
45
+ 3. The merge step fits within the main agent's context window
46
+ 4. The user's wait is long enough for parallel wall-clock gains to matter
47
+ 5. Converge on a single cowork-check review and a single commit (the receipt fingerprint covers the merged change set)
48
+ 6. Two tasks cannot run in parallel in one worktree (the file-scope gate reads the whole working tree); cross-task parallelism uses separate worktrees/clones and coordinates through board dependency edges
49
49
 
50
- 任一答案为否 → 回退为模式 1 顺序执行。
50
+ If any answer is no, fall back to Pattern 1 sequential execution.
51
51
 
52
52
  ---
53
53
 
54
- ## 模式 3:顺序 skill 链(已实现,用户驱动)
54
+ ## Pattern 3: Sequential skill chain (implemented, user-driven)
55
55
 
56
56
  ```
57
- 用户执行: task next --run --title ... -> brainstorming -> task-planning -> task next <dir> --run -> implement -> check -> task next <dir> --run --intent review
57
+ User runs: task next --run --title ... -> brainstorming -> task-planning -> task next <dir> --run -> implement -> check -> task next <dir> --run --intent review
58
58
  ```
59
59
 
60
- **使用场景**: 阶段之间有依赖关系,用户在阶段间判断有价值。
60
+ **When to use**: stages depend on each other, and user judgment between stages is valuable.
61
61
 
62
- **为什么不做生命周期编排 agent**:
63
- - 编排 agent 会在 hand-off 间总结→丢失细微差异
64
- - 用户在阶段间的检查点能早期发现方向错误
65
- - 人工检查的成本 < 走错方向的返工成本
62
+ **Why there is no lifecycle-orchestration agent**:
63
+ - An orchestration agent summarizes between hand-offs, losing nuance
64
+ - User checkpoints between stages catch wrong directions early
65
+ - The cost of a human check is lower than the rework cost of going the wrong way
66
66
 
67
67
  ---
68
68
 
69
- ## 模式 4:Party Mode V2 Board(已实现,咨询性质)
69
+ ## Pattern 4: Party Mode V2 Board (implemented, advisory)
70
70
 
71
71
  ```
72
- 主会话 ─> 启动 Discussion(party-v2 runtime board)
73
- ─> 子代理通过 board 交流(不直接对话)
74
- ─> 主持人监控漂移,不参与决策
75
- ─> 产出建议,不改变任务状态
72
+ main session ─> start Discussion (party-v2 runtime board)
73
+ ─> subagents communicate through the board (never directly)
74
+ ─> moderator monitors drift and does not decide
75
+ ─> produces advice and does not change task state
76
76
  ```
77
77
 
78
- **约束**:
79
- - Board 不能推进任务状态
80
- - 不能替代 Implement/Check formal gates
81
- - 主持人不能转述、总结、合成子代理意见
78
+ **Constraints**:
79
+ - The board cannot advance task state
80
+ - It cannot replace the Implement/Check formal gates
81
+ - The moderator must not relay, summarize, or synthesize subagent opinions
82
82
 
83
83
  ---
84
84
 
85
- ## 反模式 A:路由人格(禁止)
85
+ ## Anti-pattern A: Router persona (forbidden)
86
86
 
87
87
  ```
88
- /workflow -> 代理人格("需要什么角色?") -> 子人格 -> 代理人格(重述) -> 用户
88
+ /workflow -> agent persona ("what role do you need?") -> sub-persona -> agent persona (restates) -> user
89
89
  ```
90
90
 
91
- **为什么不行**: 纯路由层没有领域价值; 两次重述→信息丢失+~2x token; AGENTS.md 的 workflow-state 路由已覆盖
91
+ **Why not**: a pure routing layer has no domain value; double restatement loses information and costs ~2x tokens; the `<workflow-state>` routing in AGENTS.md already covers this
92
92
 
93
- **替代方案**: 用 `<workflow-state>` 块直接路由,不通过人格。
93
+ **Alternative**: route directly with the `<workflow-state>` block; do not use personas.
94
94
 
95
95
  ---
96
96
 
97
- ## 反模式 B:人格调用人格(禁止)
97
+ ## Anti-pattern B: Persona calling persona (forbidden)
98
98
 
99
99
  ```
100
- cowork-check("看到安全相关代码") -> cowork-security-audit
100
+ cowork-check("sees security-related code") -> cowork-security-audit
101
101
  ```
102
102
 
103
- **为什么不行**: 人格设计为产出单一视角; 链式调用破坏此设计; 调用人格传递的摘要丢失上下文; 失败模式相乘
103
+ **Why not**: personas are designed to produce a single perspective; chaining breaks that design; summaries passed between personas lose context; failure modes multiply
104
104
 
105
- **替代方案**: 当前人格在报告中推荐后续审计;用户或主会话运行第二轮。
105
+ **Alternative**: the current persona recommends a follow-up audit in its report; the user or main session runs the second round.
106
106
 
107
107
  ---
108
108
 
109
- ## 反模式 C:Deep nesting(禁止)
109
+ ## Anti-pattern C: Deep nesting (forbidden)
110
110
 
111
111
  ```
112
112
  /ship -> quality-coordinator -> code-reviewer -> security-auditor
113
113
  ```
114
114
 
115
- **为什么不行**: 每一层增加延迟和 token 但无决策价值; 深层人格的上下文多次总结后失真
115
+ **Why not**: each layer adds latency and tokens without decision value; deep persona context degrades after repeated summarization
116
116
 
117
- **替代方案**: cowork-flow 当前深度 = 1(主会话 → 叶子子代理)。不引入中间层。
117
+ **Alternative**: cowork-flow's current depth = 1 (main session -> leaf subagent). Do not introduce intermediate layers.
118
118
 
119
119
  ---
120
120
 
121
- ## 决策流
121
+ ## Decision flow
122
122
 
123
123
  ```
124
- 任务是一个视角对一个 artifact?
125
- ├── 是 → 直接调用。停止。
126
- └── 否 → task 可并列?
127
- ├── 否 → 顺序 skill 链(用户驱动)
128
- └── 是 → 并行扇-out(主会话协调)
129
- 验证清单:
130
- - 子任务无写冲突
131
- - 每 persona 产出不同类型
132
- - 合并步骤 fit in main context
133
- 任一不满足 → 回退顺序
124
+ Is the task one perspective on one artifact?
125
+ ├── Yes -> call it directly. Stop.
126
+ └── No -> can the tasks run in parallel?
127
+ ├── No -> sequential skill chain (user-driven)
128
+ └── Yes -> parallel fan-out (main-session coordinated)
129
+ Verification checklist:
130
+ - subtasks have no write conflicts
131
+ - each persona produces a different type
132
+ - the merge step fits in the main context
133
+ Any failure -> fall back to sequential
134
134
  ```
135
135
 
136
- ## 参见
136
+ ## See also
137
137
 
138
- - `spec/contracts/subagent-dispatch.md` — formal dispatch 协议权威定义
139
- - `spec/contracts/party-mode-v2-board.md` — Party Mode V2 权威定义
140
- - `spec/backend/`、`spec/frontend/`、`spec/guides/` — 用户定义规范,由 review skill 按需逐条审查
141
- - `skills/cowork-flow/SKILL.md` — workflow state 路由
138
+ - `spec/contracts/subagent-dispatch.md` — authoritative formal dispatch protocol
139
+ - `spec/contracts/party-mode-v2-board.md` — authoritative Party Mode V2 definition
140
+ - `spec/backend/`, `spec/frontend/`, `spec/guides/` — user-defined specs, read clause by clause by the review skill
141
+ - `skills/cowork-flow/SKILL.md` — workflow state routing