cowork-flow 2.4.0 → 2.4.2

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 (27) hide show
  1. package/CHANGELOG.md +25 -1
  2. package/docs/architecture.en.md +1 -1
  3. package/docs/architecture.md +1 -1
  4. package/package.json +1 -1
  5. package/presets/claude-code/.claude-plugin/plugin.json +1 -1
  6. package/presets/codex/.codex-plugin/plugin.json +1 -1
  7. package/presets/kimi-code/.kimi-plugin/plugin.json +1 -1
  8. package/presets/qoder/.qoder-plugin/plugin.json +1 -1
  9. package/presets/zcode/.zcode-plugin/plugin.json +1 -1
  10. package/template/.cowork-flow/.version +1 -1
  11. package/template/.cowork-flow/scripts/adapters/cli/plan.py +218 -0
  12. package/template/.cowork-flow/scripts/run.py +3 -1
  13. package/template/.cowork-flow/scripts/services/decision_anchor_schema.py +134 -10
  14. package/template/.cowork-flow/scripts/services/fact_view.py +6 -0
  15. package/template/.cowork-flow/scripts/services/plan_binding.py +34 -0
  16. package/template/.cowork-flow/scripts/services/plan_readiness.py +583 -0
  17. package/template/.cowork-flow/scripts/services/plan_scaffold.py +133 -0
  18. package/template/.cowork-flow/scripts/services/plan_schema.py +222 -0
  19. package/template/.cowork-flow/scripts/services/task_context.py +83 -5
  20. package/template/.cowork-flow/scripts/services/task_creation.py +41 -25
  21. package/template/.cowork-flow/spec/contracts/decision-anchor.md +15 -6
  22. package/template/.cowork-flow/spec/contracts/plan-binding.md +85 -5
  23. package/template/.cowork-flow/spec/runtime/contract-registry.json +3 -1
  24. package/template/.cowork-flow/templates/plan-template.md +1 -1
  25. package/template/locales/en-US/.cowork-flow/spec/contracts/decision-anchor.md +15 -6
  26. package/template/locales/en-US/.cowork-flow/templates/plan-template.md +1 -1
  27. package/template/skills/task-planning/SKILL.md +27 -3
@@ -28,6 +28,60 @@ the plan into a second workflow kernel.
28
28
  }
29
29
  ```
30
30
 
31
+ - A newly created strict non-Tiny task also records
32
+ `meta.planReadyRequired: true`. Existing tasks without that marker are not
33
+ retroactively required to have a snapshot; if they are finalized, the
34
+ snapshot is recorded and validated, but a missing snapshot is not a new
35
+ blocker for them.
36
+
37
+ ## Skeleton generation
38
+
39
+ - `./.cowork-flow/run plan new --title <title> --slug <slug>` reads the
40
+ installed localized `.cowork-flow/templates/plan-template.md` and writes a
41
+ plan skeleton to `.cowork-flow/plans/YYYY-MM-DD-<slug>.md`.
42
+ - The title placeholder (`<功能>` / `<Feature>`) is replaced; the rest of the
43
+ template shape is preserved. The file is written as UTF-8 with LF endings.
44
+ - An existing plan is never overwritten unless `--force` is explicit.
45
+ - Generation is optional; a planning agent may still fill the installed
46
+ template directly. `plan finalize` remains the completeness gate.
47
+
48
+ ## Plan finalize
49
+
50
+ - `./.cowork-flow/run plan finalize [task-dir]` is allowed only on a planning
51
+ task. It does not edit the plan or anchor.
52
+ - It requires the bound plan, the configured-language template shape, a
53
+ machine-readable concrete goal line, at least one concrete `AC-NNN` row,
54
+ content in `## 目标` / `## 全局约束` / `## 文件边界` beyond the installed
55
+ template body, complete task briefs (full fields for Normal/High-risk; file
56
+ boundaries, verification command, and completion conditions for Tiny), a
57
+ concrete command inside the task's fenced verification block, a non-empty
58
+ `implement.jsonl`, anchor acceptance rows matching the plan IDs/text, an
59
+ anchor goal matching the plan goal, and the filled anchor spec-check result.
60
+ Template bodies are read from the installed localized template at finalize
61
+ time, so placeholder matching follows template changes instead of a copied
62
+ sentinel list.
63
+ - On success it writes `task.json.meta.planReady`:
64
+
65
+ ```json
66
+ {
67
+ "meta": {
68
+ "planReady": {
69
+ "planDigest": "<sha256>",
70
+ "anchorDigest": "<sha256>",
71
+ "readyAt": "2026-10-23T00:00:00Z",
72
+ "devType": "backend"
73
+ }
74
+ }
75
+ }
76
+ ```
77
+
78
+ - A failed finalize writes nothing. A successful finalize is the handoff point
79
+ for human review: the reviewer sees the complete plan and anchor.
80
+ - A new strict non-Tiny task requires the snapshot at start. Start rejects a
81
+ missing snapshot and rejects any snapshot whose digests no longer match the
82
+ current plan or anchor; editing either file after review requires another
83
+ finalize and another review. Unmarked old tasks remain exempt.
84
+
31
85
  ## Binding during planning
32
86
 
33
87
  - A planning task not bound at creation time can bind a plan later with
@@ -51,9 +105,32 @@ into `in_progress`:
51
105
  - `decision-anchor.md` contains `## Goal`/`## 目标` and
52
106
  `## Acceptance Criteria`/`## 验收标准`.
53
107
  - `implement.jsonl` passes the existing context validation.
54
-
55
- A Tiny task may have no planFile, but must still satisfy the existing anchor and
56
- implement-scope requirements.
108
+ - For a strict non-Tiny task, the plan title contains the configured-language
109
+ marker (`实施计划` / `Implementation Plan`).
110
+ - The plan contains the six configured-language `##` template headings in
111
+ template order: `目标` / `验收标准` / `全局约束` / `文件边界` / `任务` /
112
+ `最终验证`, or their `en-US` equivalents. Extra custom sections are allowed;
113
+ fenced code is ignored; a known template heading from the other language is
114
+ rejected.
115
+ - Any `### 任务` / `### Task` task heading uses the configured-language prefix.
116
+ - `## 最终验证` / `## Final Verification` contains a line starting with
117
+ `规范核对:` / `Spec check:` and carrying an actual `pass` or
118
+ `not_applicable` result. The template placeholder (`<pass / not_applicable +
119
+ 理由>` / `<pass / not_applicable + reason>`) does not satisfy the gate.
120
+ - The strict non-Tiny anchor carries the configured-language `## 验证命令` /
121
+ `## Verification Commands` section with the same filled spec-check result;
122
+ see `decision-anchor.md`.
123
+ - The plan passes `plan finalize`; the anchor acceptance IDs/text match the
124
+ plan, and the stored plan-ready digests still match both files.
125
+
126
+ Creation and `--from-plan` binding stay permissive: a planning task may create
127
+ and bind a plan before its structure is final. The completeness checks run at
128
+ `plan finalize`; the start gate repeats the structural backstop and verifies the
129
+ reviewed snapshot.
130
+
131
+ A Tiny task may have no planFile and is exempt from the plan-shape and anchor
132
+ spec-check gates. A legacy task (no `meta.gateProfile: "strict"`) keeps the
133
+ historical checks; this contract does not retro-fit either profile.
57
134
 
58
135
  ## Implementation recovery
59
136
 
@@ -77,9 +154,12 @@ The recovery output lists paths only and never expands the plan prose.
77
154
 
78
155
  - No parsing of plan step status.
79
156
  - No Markdown AST or DSL.
80
- - No comparing AC text against plan task prose.
157
+ - No semantic validation of plan prose beyond the completeness checks above.
81
158
  - No matching verification commands against evidence records.
82
- - No plan-approval data model.
159
+ - No semantic validation of the spec-check result or reason; the structural
160
+ check only requires an actual `pass` / `not_applicable` token.
161
+ - No approval record beyond the plan-ready digest snapshot; human approval is
162
+ still a process step, not a separate workflow state.
83
163
 
84
164
  These capabilities are considered only after warning noise and real payoff have been
85
165
  validated.
@@ -108,7 +108,9 @@
108
108
  "digest": [
109
109
  "Plan binding records repo-relative task.json.meta.planFile.",
110
110
  "Task start blocks clear missing plan facts for non-Tiny tasks.",
111
- "V1 does not parse plan steps, AC text, or verification evidence."
111
+ "Strict non-Tiny start requires the configured-language plan template shape and a filled spec-check line.",
112
+ "New strict non-Tiny tasks require a plan-ready snapshot from `plan finalize`; edits after finalize invalidate it.",
113
+ "V1 does not parse plan step status or verification evidence; AC text is only compared between plan and anchor."
112
114
  ],
113
115
  "readWhen": [
114
116
  "when changing task creation plan binding",
@@ -71,7 +71,7 @@ Tiny 任务可保留简化 brief,但仍须写明精确文件边界、完成条
71
71
  <command>
72
72
  ```
73
73
 
74
- 当改动文件受 `.cowork-flow/spec/<dev_type>/` 规则覆盖时,在这里加入决定命令或规范门禁核对行(`pass` / `not_applicable` 并附理由);这是强复核提醒,不是硬门禁。
74
+ 当改动文件受 `.cowork-flow/spec/<dev_type>/` 规则覆盖时,在这里加入决定命令或规范门禁核对行(`pass` / `not_applicable` 并附理由)。strict 非 Tiny 任务启动前必须把 `<pass / not_applicable + 理由>` 替换为实际核对结果;保留模板占位符会被 start 门禁阻断。
75
75
 
76
76
  **完成条件**
77
77
  - <2-4 条可检查条件>
@@ -49,7 +49,7 @@ and the left column the `zh-CN` output.
49
49
  | `## Rejected Options` / `## 被拒方案` | optional | required for brainstorming tasks, so a rejected option is not reconsidered during execution |
50
50
  | `## Key Assumptions` / `## 关键假设` | optional | filled in for complex tasks to surface implicit constraints; not read by the runtime parser |
51
51
  | `## Scope Boundary` / `## 范围边界` | optional | prevents scope creep |
52
- | `## Verification Commands` / `## 验证命令` | 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) |
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) |
53
53
 
54
54
  ### Machine-readable line formats (for injection)
55
55
 
@@ -60,11 +60,13 @@ Line-format conventions:
60
60
  - `## Verification Commands`: one command per line (an optional `- ` prefix),
61
61
  truncated to 120 characters, at most 10 lines; the implementing agent runs them
62
62
  itself (self-declared, self-checked) and the reviewer verifies the execution
63
- evidence. When the changed files are covered by `.cowork-flow/spec/<dev_type>/`
64
- rules, the section must also carry the spec/gate check for the task's
65
- `dev_type`: a deciding command, or a `Spec check:` line reviewed clause by
66
- clause (`pass` / `not_applicable` + reason). This is a strong review reminder,
67
- not a `spec-check` hard gate.
63
+ evidence. A strict non-Tiny task must also carry a `Spec check:` line in the
64
+ configured language's section, with the actual `pass` / `not_applicable` result
65
+ and a reason. The template placeholder (`<pass / not_applicable + reason>`) does
66
+ not satisfy the start gate. This line is a hard start gate for strict non-Tiny
67
+ tasks, while its content remains self-declared and is reviewed by the check
68
+ agent. The fact view recognizes the line and does not return it as a shell
69
+ command.
68
70
  - `## Scope Boundary`: only the first non-empty line is taken, truncated to 160
69
71
  characters.
70
72
 
@@ -99,6 +101,13 @@ After merging (5 files): `decision-anchor.md` + `implement.jsonl` + `check.jsonl
99
101
  `## 验收标准`, no duplicate AC ids, no non-AC list rows in that section, and a
100
102
  declared `dev_type` (otherwise `task specs` dev-type dispatch silently comes
101
103
  back shorter).
104
+ - A strict non-Tiny task also requires the configured-language
105
+ `## Verification Commands` / `## 验证命令` section with a filled
106
+ `Spec check:` / `规范核对:` line. A missing section, the other-language
107
+ heading, or the template placeholder blocks start. Tiny tasks and legacy tasks
108
+ are exempt. The bound plan's `## Final Verification` / `## 最终验证` section
109
+ carries the same filled check; plan structure and language are covered by
110
+ `plan-binding.md`.
102
111
  - An acceptance row's checkbox state (`- [ ]` / `- [x]`) and the evidence records
103
112
  (the task directory's `evidence.jsonl`) are the fact source of the completion
104
113
  gate: completion is blocked when an unchecked AC exists (`LIFECYCLE-AC-001`), a
@@ -71,7 +71,7 @@ Tiny plans may keep a shorter brief, but must still name exact file boundaries,
71
71
  <command>
72
72
  ```
73
73
 
74
- When changed files are covered by `.cowork-flow/spec/<dev_type>/` rules, add the deciding command or a spec/gate check line (`pass` / `not_applicable` with reason) here; it is a strong review reminder, not a hard gate.
74
+ When changed files are covered by `.cowork-flow/spec/<dev_type>/` rules, add the deciding command or a spec/gate check line (`pass` / `not_applicable` with reason) here. Before a strict non-Tiny task starts, replace `<pass / not_applicable + reason>` with the actual result; the start gate rejects the template placeholder.
75
75
 
76
76
  **Completion Conditions**
77
77
  - <2-4 checkable conditions>
@@ -30,6 +30,28 @@ If the installed template is missing, stop and report it (run `cwf project sync
30
30
 
31
31
  The template is distributed at install time for the project language configured in `.cowork-flow/config.yaml` (`zh-CN` by default, or `en-US`). Write the plan in that language. Keep the template's machine-readable goal line and `AC-NNN` identifiers unchanged so task creation and workflow gates can parse them. Do not translate paths, commands, code identifiers, or spec file names.
32
32
 
33
+ ### Skeleton Generation
34
+
35
+ Generate the first version from the installed template instead of retyping its structure:
36
+
37
+ ```bash
38
+ ./.cowork-flow/run plan new --title "<plan title>" --slug <ascii-slug>
39
+ ```
40
+
41
+ `plan new` replaces the title placeholder, writes `.cowork-flow/plans/YYYY-MM-DD-<slug>.md`, and refuses to overwrite an existing plan unless `--force` is explicit. Fill the generated skeleton; do not invent a second plan shape. If the installed template is missing, the command stops with a `cwf project sync .` hint.
42
+
43
+ ### Plan Readiness Gate
44
+
45
+ After filling the plan and anchor, finalize them before human review:
46
+
47
+ ```bash
48
+ ./.cowork-flow/run plan finalize <task-dir>
49
+ ```
50
+
51
+ `plan finalize` checks the plan and anchor for template shape, concrete section content, AC rows, complete task briefs, verification commands, matching goal/AC text, the spec-check result, and a non-empty `implement.jsonl`. On success it writes `task.json.meta.planReady` with plan/anchor digests.
52
+
53
+ New strict non-Tiny tasks require this snapshot at start. Present the finalized plan and anchor for human review; start only verifies that the reviewed files have not changed. If either file changes after finalize, run `plan finalize` again and re-review before starting. Tiny and legacy tasks keep their existing exemptions.
54
+
33
55
  ### Plan Style: Task Briefs, Not Design Docs
34
56
 
35
57
  Plans exist to prevent implementation drift. They must guide implementation by pinning task order, file boundaries, key symbols, the core patch shape, test proof, completion conditions, and prohibited drift. They are not architecture essays and must not explain every possible option.
@@ -49,7 +71,7 @@ Fill the template in order: header table and goal first, then acceptance criteri
49
71
  - Every Normal or High-risk task fills every required field in the template's task brief: Purpose, Code Fact Sources, File Boundaries, Key Symbols, Implementation Notes, Test Proof, Verification Command, Completion Conditions, Prohibited Drift, and Deviation Conditions.
50
72
  - For Tiny tasks, keep the brief short but still name exact file boundaries, completion conditions, and verification commands.
51
73
  - For behavior changes, include a failing test before implementation when behavior can be tested.
52
- - For implementation tasks whose changed files are covered by `.cowork-flow/spec/` requirements, name the covered spec files in the plan and add the clause check to the task's `Verification Command` and the plan's `Final Verification`: run the deciding command when one exists, otherwise check clause by clause and record `pass` / `not_applicable` with reason. This is a strong review reminder, not a separate hard gate.
74
+ - For implementation tasks whose changed files are covered by `.cowork-flow/spec/` requirements, name the covered spec files in the plan and add the clause check to the task's `Verification Command` and the plan's `Final Verification`: run the deciding command when one exists, otherwise check clause by clause and record `pass` / `not_applicable` with reason. For strict non-Tiny tasks this is a hard start gate: the bound plan and the task anchor must use the configured-language verification heading and carry a filled spec-check result. The template placeholder `<pass / not_applicable + reason>` blocks start; replace it before starting. The content remains self-declared and is reviewed by the check agent.
53
75
  - Do not add shallow tests just to satisfy process. Avoid tests that only assert existence, mirror implementation details, count mock calls without behavior, or snapshot empty structure.
54
76
  - For complex problems, test depth first: business invariants, cross-layer contracts, state transitions, error boundaries, and real regression paths before narrow unit cases.
55
77
  - Map behavior-changing tests to stable `decision-anchor.md` acceptance IDs when useful; do not create `tdd.jsonl` or write TDD evidence records into `check.jsonl`.
@@ -81,7 +103,8 @@ A plan can be marked approved only when all conditions hold:
81
103
  - Every task in the plan has clear acceptance criteria.
82
104
  - Every task has implementation steps and verification commands.
83
105
  - Task dependencies are explicit, including whether work is serial or parallelizable.
84
- - The plan uses the installed `.cowork-flow/templates/plan-template.md` shape and the configured output language.
106
+ - The plan uses the installed `.cowork-flow/templates/plan-template.md` shape and the configured output language. For strict non-Tiny tasks, the runtime blocks start when the plan or anchor lacks the configured-language verification section or a filled spec-check result.
107
+ - For new strict non-Tiny tasks, the plan and anchor have passed `plan finalize` and the human has reviewed that snapshot. Any later edit requires another finalize and review.
85
108
 
86
109
  `implement.jsonl` is the current task's context index — the files in scope and
87
110
  the spec pointers it needs — not the task list. The plan owns the task list.
@@ -118,5 +141,6 @@ Before handoff:
118
141
  3. Confirm every Normal or High-risk task fills every required brief field in the template.
119
142
  4. Check names, paths, command syntax, and expected outputs.
120
143
  5. Confirm the plan says to stop and report back when code facts conflict with the plan, a plan-external file becomes necessary, or a test fails for an unplanned reason.
121
- 6. Confirm Final Verification carries the applicable `.cowork-flow/spec/<dev_type>/` clause check, or states why no spec file applies.
144
+ 6. Confirm Final Verification carries the applicable `.cowork-flow/spec/<dev_type>/` clause check with an actual `pass` / `not_applicable` result, or states why no spec file applies. For strict non-Tiny tasks the runtime blocks start when this line is missing or still the template placeholder.
122
145
  7. Confirm the plan is written in the configured language and keeps the machine-readable goal line and `AC-NNN` identifiers unchanged.
146
+ 8. Run `plan finalize <task-dir>` and fix every reported blocker before handing the plan to the user for review.