cowork-flow 0.0.37 → 0.0.39

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 (111) hide show
  1. package/README.md +27 -14
  2. package/package.json +1 -1
  3. package/src/commands/init.js +39 -28
  4. package/src/commands/sync.js +2 -2
  5. package/src/lib/asset-plan.js +127 -0
  6. package/src/lib/copy-template.js +101 -141
  7. package/src/lib/host-assets.js +231 -0
  8. package/src/lib/plan-applier.js +329 -0
  9. package/src/lib/platforms.js +15 -76
  10. package/src/lib/skill-registry.js +503 -0
  11. package/template/.claude/agents/cowork-check.md +10 -1
  12. package/template/.claude/agents/cowork-implement.md +11 -2
  13. package/template/.claude/hooks/inject-workflow-state.py +51 -254
  14. package/template/.codex/agents/cowork-check.toml +12 -3
  15. package/template/.codex/agents/cowork-implement.toml +11 -2
  16. package/template/.codex/agents/default.toml +3 -2
  17. package/template/.codex/agents/explorer.toml +3 -2
  18. package/template/.codex/agents/worker.toml +2 -1
  19. package/template/.codex/hooks/inject-workflow-state.py +46 -265
  20. package/template/.cowork-flow/.version +1 -1
  21. package/template/.cowork-flow/scripts/application/__init__.py +1 -0
  22. package/template/.cowork-flow/scripts/application/batch_execution.py +743 -0
  23. package/template/.cowork-flow/scripts/application/runtime_context_service.py +365 -0
  24. package/template/.cowork-flow/scripts/application/task_archive.py +220 -0
  25. package/template/.cowork-flow/scripts/application/task_context.py +765 -0
  26. package/template/.cowork-flow/scripts/application/task_creation.py +201 -0
  27. package/template/.cowork-flow/scripts/application/task_lifecycle.py +532 -0
  28. package/template/.cowork-flow/scripts/application/task_tree.py +179 -0
  29. package/template/.cowork-flow/scripts/commands/doctor.py +78 -57
  30. package/template/.cowork-flow/scripts/commands/party_mode_v2.py +671 -425
  31. package/template/.cowork-flow/scripts/commands/subagent.py +38 -26
  32. package/template/.cowork-flow/scripts/commands/task.py +535 -1953
  33. package/template/.cowork-flow/scripts/commands/task_archive_commands.py +195 -0
  34. package/template/.cowork-flow/scripts/commands/task_context_commands.py +240 -0
  35. package/template/.cowork-flow/scripts/commands/task_create_command.py +164 -0
  36. package/template/.cowork-flow/scripts/commands/task_navigation.py +407 -0
  37. package/template/.cowork-flow/scripts/commands/task_parser.py +364 -0
  38. package/template/.cowork-flow/scripts/commands/task_support.py +76 -0
  39. package/template/.cowork-flow/scripts/commands/task_tree_commands.py +160 -0
  40. package/template/.cowork-flow/scripts/common/core/execution_context.py +161 -85
  41. package/template/.cowork-flow/scripts/common/core/host_manifest.py +393 -0
  42. package/template/.cowork-flow/scripts/common/core/skill_registry.py +568 -0
  43. package/template/.cowork-flow/scripts/common/gates/coding_standards.py +58 -7
  44. package/template/.cowork-flow/scripts/common/gates/gates.py +323 -46
  45. package/template/.cowork-flow/scripts/common/gates/models.py +196 -0
  46. package/template/.cowork-flow/scripts/common/gates/registry.py +79 -0
  47. package/template/.cowork-flow/scripts/common/gates/tdd_evidence.py +13 -13
  48. package/template/.cowork-flow/scripts/common/gates/validate_coding_standards.py +104 -62
  49. package/template/.cowork-flow/scripts/common/gates/validate_implementation.py +39 -22
  50. package/template/.cowork-flow/scripts/common/gates/validate_rules.py +223 -40
  51. package/template/.cowork-flow/scripts/common/git/git_context.py +216 -182
  52. package/template/.cowork-flow/scripts/common/host/__init__.py +1 -0
  53. package/template/.cowork-flow/scripts/common/host/workflow_state_hook.py +303 -0
  54. package/template/.cowork-flow/scripts/common/storage/__init__.py +1 -0
  55. package/template/.cowork-flow/scripts/common/storage/operation_log.py +72 -0
  56. package/template/.cowork-flow/scripts/common/storage/state_store.py +279 -0
  57. package/template/.cowork-flow/scripts/common/storage/unit_of_work.py +214 -0
  58. package/template/.cowork-flow/scripts/common/task/active_task.py +93 -135
  59. package/template/.cowork-flow/scripts/common/task/batch_mode.py +33 -120
  60. package/template/.cowork-flow/scripts/common/task/decision_review.py +85 -0
  61. package/template/.cowork-flow/scripts/common/task/readiness.py +9 -15
  62. package/template/.cowork-flow/scripts/common/task/task_repository.py +156 -0
  63. package/template/.cowork-flow/scripts/run.py +24 -0
  64. package/template/.cowork-flow/spec/contracts/decision-anchor.md +8 -2
  65. package/template/.cowork-flow/spec/contracts/subagent-dispatch.md +2 -4
  66. package/template/.cowork-flow/spec/contracts/workflow-state-templates.md +1 -1
  67. package/template/.cowork-flow/spec/protocols/decision-review.md +28 -0
  68. package/template/.cowork-flow/spec/protocols/review.md +34 -0
  69. package/template/.cowork-flow/spec/protocols/spec-maintenance.md +16 -0
  70. package/template/.cowork-flow/spec/protocols/tdd.md +30 -0
  71. package/template/.cowork-flow/spec/references/definition-of-done.md +4 -4
  72. package/template/.cowork-flow/spec/references/orchestration-patterns.md +1 -1
  73. package/template/.cowork-flow/spec/runtime/contract-registry.json +25 -0
  74. package/template/.cowork-flow/spec/runtime/host-assets.json +214 -0
  75. package/template/.cowork-flow/spec/runtime/index.md +8 -0
  76. package/template/.cowork-flow/spec/runtime/rules.json +61 -10
  77. package/template/.cowork-flow/spec/runtime/skill-registry.json +397 -0
  78. package/template/.cowork-flow/spec/schemas/host-assets.schema.json +173 -0
  79. package/template/.cowork-flow/spec/schemas/rules.schema.json +10 -1
  80. package/template/.cowork-flow/spec/schemas/skill-registry.schema.json +202 -0
  81. package/template/.cowork-flow/workflow.md +18 -13
  82. package/template/.opencode/agents/cowork-check.md +11 -0
  83. package/template/.opencode/agents/cowork-implement.md +16 -1
  84. package/template/.zcode/.zcode-plugin/plugin.json +1 -1
  85. package/template/.zcode/hooks/inject-context.js +3 -85
  86. package/template/.zcode/hooks/inject-context.selfcheck.mjs +6 -6
  87. package/template/.zcode/scaffold/.cowork-flow/spec/contracts/decision-anchor.md +8 -2
  88. package/template/.zcode/scaffold/.cowork-flow/spec/contracts/subagent-dispatch.md +2 -4
  89. package/template/.zcode/scaffold/.cowork-flow/spec/runtime/rules.json +61 -10
  90. package/template/.zcode/scaffold/.cowork-flow/spec/schemas/rules.schema.json +10 -1
  91. package/template/.zcode/scaffold/.cowork-flow/workflow.md +18 -13
  92. package/template/.zcode/scaffold/AGENTS.md +18 -8
  93. package/template/AGENTS.md +1 -1
  94. package/template/skills/batch-mode/SKILL.md +140 -76
  95. package/template/skills/brainstorming/SKILL.md +2 -2
  96. package/template/skills/cowork-flow/SKILL.md +42 -0
  97. package/template/skills/party-mode/SHARED-BOUNDARIES.md +1 -1
  98. package/template/skills/party-mode/SKILL.md +48 -119
  99. package/template/.cowork-flow/scripts/common/gates/spec_validator.py +0 -53
  100. package/template/.cowork-flow/scripts/common/gates/validate_jsonl.py +0 -32
  101. package/template/skills/before-dev/SKILL.md +0 -41
  102. package/template/skills/check/SKILL.md +0 -53
  103. package/template/skills/check/simplification-guide.md +0 -47
  104. package/template/skills/continue/SKILL.md +0 -29
  105. package/template/skills/doubt-review/SKILL.md +0 -118
  106. package/template/skills/finish-work/SKILL.md +0 -32
  107. package/template/skills/party-mode-v2/SKILL.md +0 -75
  108. package/template/skills/start/SKILL.md +0 -78
  109. package/template/skills/tdd/SKILL.md +0 -74
  110. package/template/skills/update-spec/SKILL.md +0 -39
  111. package/template/skills/using-cowork-flow/SKILL.md +0 -80
@@ -11,7 +11,11 @@
11
11
  "fix_hint": "创建 .cowork-flow/changes/<slug>/proposal.md 并填写目标、用户价值、范围边界",
12
12
  "source_file": ".cowork-flow/workflow.md",
13
13
  "source_excerpt": "定义 L1(增量)、L2(结构性)和 L3(重大)三级工作",
14
- "enforcement": "validate_rules"
14
+ "enforcement": "validate_rules",
15
+ "validator": "runtime.l2_required_file",
16
+ "parameters": {
17
+ "filename": "proposal.md"
18
+ }
15
19
  },
16
20
  {
17
21
  "id": "R-WF-002",
@@ -23,7 +27,11 @@
23
27
  "fix_hint": "创建 .cowork-flow/changes/<slug>/spec.md 并填写功能规格",
24
28
  "source_file": ".cowork-flow/workflow.md",
25
29
  "source_excerpt": "L2(结构性)",
26
- "enforcement": "validate_rules"
30
+ "enforcement": "validate_rules",
31
+ "validator": "runtime.l2_required_file",
32
+ "parameters": {
33
+ "filename": "spec.md"
34
+ }
27
35
  },
28
36
  {
29
37
  "id": "R-WF-003",
@@ -35,7 +43,11 @@
35
43
  "fix_hint": "创建 .cowork-flow/changes/<slug>/design.md 并填写技术设计",
36
44
  "source_file": ".cowork-flow/workflow.md",
37
45
  "source_excerpt": "L2(结构性)",
38
- "enforcement": "validate_rules"
46
+ "enforcement": "validate_rules",
47
+ "validator": "runtime.l2_required_file",
48
+ "parameters": {
49
+ "filename": "design.md"
50
+ }
39
51
  },
40
52
  {
41
53
  "id": "R-WF-004",
@@ -47,7 +59,9 @@
47
59
  "fix_hint": "在 change.yaml 中添加 plan 字段指向 .cowork-flow/plans/ 下的计划文件",
48
60
  "source_file": ".cowork-flow/workflow.md",
49
61
  "source_excerpt": "L2(结构性)",
50
- "enforcement": "validate_rules"
62
+ "enforcement": "validate_rules",
63
+ "validator": "runtime.l2_plan_link",
64
+ "parameters": {}
51
65
  },
52
66
  {
53
67
  "id": "R-WF-005",
@@ -59,7 +73,25 @@
59
73
  "fix_hint": "在 change.yaml 中添加 tasks 字段指向相关任务目录",
60
74
  "source_file": ".cowork-flow/workflow.md",
61
75
  "source_excerpt": "L2(结构性)",
62
- "enforcement": "validate_rules"
76
+ "enforcement": "validate_rules",
77
+ "validator": "runtime.l2_task_link",
78
+ "parameters": {}
79
+ },
80
+ {
81
+ "id": "R-WF-006",
82
+ "type": "phase_gate",
83
+ "severity": "block",
84
+ "scope": "task_start",
85
+ "condition": "L2 任务必须有有效的 decision-review.jsonl",
86
+ "message": "L2 decision review evidence is missing or invalid",
87
+ "fix_hint": "按 .cowork-flow/spec/protocols/decision-review.md 写入已接受的结构化记录",
88
+ "source_file": ".cowork-flow/spec/protocols/decision-review.md",
89
+ "source_excerpt": "L2 task start requires accepted structured decision evidence",
90
+ "enforcement": "validate_rules",
91
+ "validator": "runtime.l2_decision_review",
92
+ "parameters": {
93
+ "filename": "decision-review.jsonl"
94
+ }
63
95
  },
64
96
  {
65
97
  "id": "R-WF-007",
@@ -71,7 +103,13 @@
71
103
  "fix_hint": "运行 ./.cowork-flow/run task review [task-dir] 进入检查阶段,然后运行验证命令",
72
104
  "source_file": ".cowork-flow/workflow.md",
73
105
  "source_excerpt": "先验证再完成",
74
- "enforcement": "validate_rules"
106
+ "enforcement": "validate_rules",
107
+ "validator": "runtime.task_status",
108
+ "parameters": {
109
+ "allowed_statuses": [
110
+ "review"
111
+ ]
112
+ }
75
113
  },
76
114
  {
77
115
  "id": "R-WF-008",
@@ -83,7 +121,14 @@
83
121
  "fix_hint": "创建 <task-dir>/decision-anchor.md,至少包含 ## 目标和 ## 验收标准",
84
122
  "source_file": ".cowork-flow/spec/contracts/decision-anchor.md",
85
123
  "source_excerpt": "每个任务必须有决策锚点",
86
- "enforcement": "validate_rules"
124
+ "enforcement": "validate_rules",
125
+ "validator": "runtime.decision_anchor",
126
+ "parameters": {
127
+ "required_sections": [
128
+ "目标",
129
+ "验收标准"
130
+ ]
131
+ }
87
132
  },
88
133
  {
89
134
  "id": "R-AG-002",
@@ -95,7 +140,9 @@
95
140
  "fix_hint": "规格文件只能由主会话修改,子代理应专注于实现任务",
96
141
  "source_file": ".cowork-flow/spec/contracts/subagent-dispatch.md",
97
142
  "source_excerpt": "cowork-* 固定代理是叶子执行者",
98
- "enforcement": "validate_implementation"
143
+ "enforcement": "validate_implementation",
144
+ "validator": "implementation.spec_files",
145
+ "parameters": {}
99
146
  },
100
147
  {
101
148
  "id": "R-AG-005",
@@ -107,7 +154,9 @@
107
154
  "fix_hint": "通过 ./.cowork-flow/run task add-context <dir> implement <path> <reason> 登记所有需要修改的文件",
108
155
  "source_file": ".cowork-flow/spec/contracts/decision-anchor.md",
109
156
  "source_excerpt": "implement.jsonl 是任务的权威文件白名单",
110
- "enforcement": "validate_implementation"
157
+ "enforcement": "validate_implementation",
158
+ "validator": "implementation.allowed_files",
159
+ "parameters": {}
111
160
  },
112
161
  {
113
162
  "id": "R-AG-006",
@@ -119,7 +168,9 @@
119
168
  "fix_hint": "保持代码简单直接,只有在确认需要复用时才进行抽象",
120
169
  "source_file": "AGENTS.md",
121
170
  "source_excerpt": "不为一次性代码做抽象",
122
- "enforcement": "validate_implementation"
171
+ "enforcement": "validate_implementation",
172
+ "validator": "implementation.premature_abstraction",
173
+ "parameters": {}
123
174
  }
124
175
  ]
125
176
  }
@@ -15,7 +15,7 @@
15
15
  "description": "Array of rules",
16
16
  "items": {
17
17
  "type": "object",
18
- "required": ["id", "type", "severity", "scope", "condition", "message", "fix_hint", "source_file", "enforcement"],
18
+ "required": ["id", "type", "severity", "scope", "condition", "message", "fix_hint", "source_file", "enforcement", "validator", "parameters"],
19
19
  "anyOf": [
20
20
  {"required": ["source_anchor"]},
21
21
  {"required": ["source_excerpt"]}
@@ -69,6 +69,15 @@
69
69
  "type": "string",
70
70
  "enum": ["validate_rules", "validate_implementation"],
71
71
  "description": "Runtime surface responsible for enforcing this rule. Must have a corresponding validator module."
72
+ },
73
+ "validator": {
74
+ "type": "string",
75
+ "pattern": "^[a-z][a-z0-9_]*(\\.[a-z][a-z0-9_]*)+$",
76
+ "description": "Registered validator capability key. Multiple rules may reuse the same capability."
77
+ },
78
+ "parameters": {
79
+ "type": "object",
80
+ "description": "Validator-specific configuration validated by the registered capability."
72
81
  }
73
82
  },
74
83
  "additionalProperties": false
@@ -14,7 +14,7 @@ changes -> brainstorming -> read spec -> plan -> tasks -> implement -> check ->
14
14
  2. brainstorming:对changes需求做头脑风暴,确定目标、范围、验收标准、范围边界、被拒方案、实现方案、检查方案。
15
15
  3. read spec: 读取项目规范
16
16
  4. plan:构建开发计划。
17
- 5. tasks:根据plan拆分具体执行任务、明确 PRD、整理 `implement.jsonl` / `check.jsonl`。
17
+ 5. tasks:根据plan拆分具体执行任务、明确 `decision-anchor.md`、整理 `implement.jsonl` / `check.jsonl`。
18
18
  6. implement:主会话通过当前宿主适配器派发 `cowork-implement`,按 `.cowork-flow/spec/contracts/subagent-dispatch.md` 执行固定代理派发协议。
19
19
  7. check:主会话通过当前宿主适配器派发 `cowork-check`,按 `.cowork-flow/spec/contracts/subagent-dispatch.md` 执行固定代理派发协议。
20
20
  8. complete:主会话做最终验证、同步规格、归档、记录会话、提交。
@@ -31,7 +31,7 @@ changes -> brainstorming -> read spec -> plan -> tasks -> implement -> check ->
31
31
 
32
32
  ## 1.2 需求澄清与头脑风暴门禁
33
33
 
34
- 1. 新需求先判断清晰度。只读问题、单步且目标/范围/验收标准都清楚的小改可以绕过;否则必须先进入 `brainstorming`,在写 PRD、计划或固定代理派发前收束方向。
34
+ 1. 新需求先判断清晰度。只读问题、单步且目标/范围/验收标准都清楚的小改可以绕过;否则必须先进入 `brainstorming`,在写决策锚点、计划或固定代理派发前收束方向。
35
35
  2. 以下情况触发头脑风暴:
36
36
  - 目标、用户价值或期望行为不清楚。
37
37
  - 范围边界、非目标或影响面不清楚。
@@ -39,7 +39,7 @@ changes -> brainstorming -> read spec -> plan -> tasks -> implement -> check ->
39
39
  - 涉及 L1/L2 行为变化,或影响架构、接口、数据、权限、发布迁移。
40
40
  - 验收标准缺失、风险未知,或关键假设需要暴露。
41
41
 
42
- 3. `brainstorming` 输出至少包括:目标、非目标、关键假设、范围边界、推荐方向、被拒方案、验收标准、开放问题/阻塞。只有方向和验收标准清楚后,才进入 PRD、计划或固定代理派发。
42
+ 3. `brainstorming` 输出至少包括:目标、非目标、关键假设、范围边界、推荐方向、被拒方案、验收标准、开放问题/阻塞。只有方向和验收标准清楚后,才进入决策锚点、计划或固定代理派发。
43
43
 
44
44
  ## 2. 状态文件
45
45
 
@@ -70,6 +70,15 @@ changes -> brainstorming -> read spec -> plan -> tasks -> implement -> check ->
70
70
 
71
71
  `task finish` 只清理当前会话任务指针,不改变 `task.json.status`。
72
72
 
73
+ ## 2.1 运行时权威边界与旧资产清理
74
+
75
+ 1. `scripts/commands/` 只负责参数解析和输出;任务、上下文、归档和 runtime context 业务流程由 `scripts/application/` 编排。
76
+ 2. JSON 状态写入统一经过 `scripts/common/storage/`,显式使用 UTF-8、修订检查和可恢复 Unit of Work。
77
+ 3. 宿主资产、平台识别、同步保护和 obsolete cleanup 清单以 `spec/runtime/host-assets.json` 为权威来源;禁止在命令层维护第二套平台集合。
78
+ 4. init/sync 必须先构建和验证 Asset Plan,再通过 staging、备份和 rollback 提交;`.cowork-flow/.version` 最后更新。
79
+ 5. 旧 task/session/runtime-context 只允许在带保护测试的读取边界保留;旧受管资产只允许由 sync 的 obsolete cleanup 删除。新写入必须使用当前 schema、当前目录和共享 Hook 核心。
80
+ 6. 未完成事务、损坏状态或未知 schema 不能静默继续写入;无法安全恢复时 fail-closed 并保留诊断现场。
81
+
73
82
  ## 3. 固定代理
74
83
 
75
84
  固定代理只执行主会话派发的叶子任务。子代理是执行者,子任务是工作单元。
@@ -91,17 +100,13 @@ changes -> brainstorming -> read spec -> plan -> tasks -> implement -> check ->
91
100
  - 固定 `cowork-*` 代理是叶子执行者;不得再派发、等待、列出或取消其他代理。
92
101
  - 通用 `worker`、`default` 或 `explorer` 只能作为 advisory work,不能满足正式实现或检查完成条件。
93
102
 
94
- ## 3.2 手动 Party Mode
95
-
96
- Party Mode 是用户手动触发的 advisory roundtable。主会话可通过当前宿主适配器创建 fresh child contexts,收集真实讨论子代理的证据、分歧、风险和可测验收信号,再由主会话综合结论。
97
-
98
- Party Mode 不能推进任务状态,不能满足正式实现或检查完成条件,也不能替代 `cowork-implement` 或 `cowork-check`。轮次上限、继续/停止条件、输出 schema 和可配置默认值由 party-mode skill 定义;正式子代理协议仍以 `.cowork-flow/spec/contracts/subagent-dispatch.md` 为准。
103
+ ## 3.2 Party Mode
99
104
 
100
- ## 3.2.1 手动 Party Mode V2
105
+ Party Mode 是用户手动触发的 runtime board advisory workflow。主会话通过 `party-mode` 入口启动 `party-v2` runtime;Python runtime 控制看板、当前轮视图、schema 校验、轮次上限、纠偏事件和最终报告。
101
106
 
102
- Party Mode V2 是用户手动触发的 runtime board advisory workflow。Python runtime 控制看板、当前轮视图、schema 校验、轮次上限、纠偏事件和最终报告;子代理通过 board API 交流,主持人只监控 runtime status、执行宿主适配器动作和记录偏题纠正。
107
+ Party Mode 子代理通过 board API 交流,主持人只监控 runtime status、执行宿主适配器动作和记录偏题纠正。Party Mode 不能推进任务状态,不能满足正式实现或检查完成条件,也不能替代 `cowork-implement` 或 `cowork-check`。
103
108
 
104
- Party Mode V2 仍不能推进任务状态,不能满足正式实现或检查完成条件,也不能替代 `cowork-implement` 或 `cowork-check`。V2 runtime 只输出 host-neutral next actions,宿主专属原语仍只在 `.cowork-flow/adapters/<host>/adapter.yaml` 和宿主资产中声明。
109
+ Party Mode runtime 只输出 host-neutral next actions,宿主专属原语仍只在 `.cowork-flow/adapters/<host>/adapter.yaml` 和宿主资产中声明。正式子代理协议仍以 `.cowork-flow/spec/contracts/subagent-dispatch.md` 为准。
105
110
 
106
111
  ## 3.3 并行会话
107
112
 
@@ -195,7 +200,7 @@ L2 任务在 `task start` 前必须通过 readiness gate;同一 blocker 列表
195
200
  1. 先运行 `task next` 确认任务处于 `review` 检查阶段。
196
201
  2. 默认通过宿主适配器派发 `cowork-check`。派发必须使用新鲜子上下文,并遵守 `.cowork-flow/spec/contracts/subagent-dispatch.md`。
197
202
  3. 检查内容:
198
- - PRD 验收标准是否满足。
203
+ - decision-anchor 验收标准是否满足。
199
204
  - `git diff` 是否只包含预期范围。
200
205
  - 测试是否覆盖关键行为。
201
206
  - `.cowork-flow/spec/` 是否需要更新。
@@ -233,7 +238,7 @@ L2 任务在 `task start` 前必须通过 readiness gate;同一 blocker 列表
233
238
 
234
239
  恢复时只读取最小上下文:
235
240
  1. 运行 `./.cowork-flow/run resume`。
236
- 2. 按 `RESUME CHECKLIST` 读取当前任务 PRD、计划状态和 JSONL 指向文件。
241
+ 2. 按 `RESUME CHECKLIST` 读取当前任务 decision-anchor、计划状态和 JSONL 指向文件。
237
242
  3. 不批量读取所有规格、计划、任务或工作区日志。
238
243
  4. 不存在当前会话任务时,先创建或启动任务。
239
244
 
@@ -16,24 +16,34 @@
16
16
 
17
17
  ## 0.1 编码前强制门禁
18
18
 
19
- **编辑文件、变更代码、派发子代理之前,MUST 调用 `before-dev` skill。**
19
+ **编辑文件、变更代码、派发子代理之前,先确定当前工作流状态,再决定放行、阻断还是路由。**
20
20
 
21
- 该 skill 读取 `<workflow-state>` 决定放行或阻断:
21
+ 按以下顺序判定当前状态:
22
+
23
+ 1. **系统提示已包含 `<workflow-state>` 块(hook 注入)**: 直接按该块
24
+ `Status:` 行路由。
25
+ 2. **否则运行一次导航器**:
26
+ ```bash
27
+ ./.cowork-flow/run task next [task-dir-or-name]
28
+ ```
29
+ 按返回的 `task.json.status` 路由,缺失活动任务时先创建再启动。
30
+
31
+ 状态路由:
22
32
 
23
33
  - `no_task` → **阻断**。拒绝写代码;引导 brainstorming → plan → task create → task start
24
- - `delegated_subtask` → 按子代理规则执行
25
- - `planning` → **阻断**。PRD 和 implement.jsonl 就绪前不允许实现
26
- - `in_progress` / `review` → 放行
27
- - `completed` → **阻断**。创建新任务
34
+ - `delegated_subtask` → 按子代理规则执行,派发方核验绑定
35
+ - `planning` → **阻断**。decision-anchor.md 和 implement.jsonl 就绪前不允许实现或派发 cowork-implement
36
+ - `in_progress` / `review` → 放行;按当前阶段推进
37
+ - `completed` → **阻断**。创建新任务或归档会话
28
38
 
29
39
  豁免:
30
40
 
31
41
  - 只读问答
32
42
  - 纯查询命令(`git status`、`task next`、`task current`)
33
43
  - 用户明确说"跳过流程"
34
- - `before-dev` 本身
44
+ - `task next` / `task validate` 本身
35
45
 
36
- 不确定是否需要写代码时,先调用 `before-dev`。
46
+ 不确定是否需要写代码时,先运行 `task next`。
37
47
 
38
48
  ## 1. 先思考
39
49
 
@@ -32,7 +32,7 @@
32
32
 
33
33
  - `no_task` → **阻断**。拒绝写代码;引导 brainstorming → plan → task create → task start。
34
34
  - `delegated_subtask` → 按子代理规则执行,派发方核验绑定。
35
- - `planning` → **阻断**。PRD 和 implement.jsonl 就绪前不允许实现或派发 cowork-implement。
35
+ - `planning` → **阻断**。decision-anchor.md 和 implement.jsonl 就绪前不允许实现或派发 cowork-implement。
36
36
  - `in_progress` / `review` → 放行;按当前阶段推进。
37
37
  - `completed` → **阻断**。创建新任务或归档会话。
38
38
 
@@ -1,117 +1,181 @@
1
1
  ---
2
2
  name: batch-mode
3
- description: Use when user approves a full plan and wants autonomous execution through all tasks without manual stepping. Each task still passes all gates independently.
3
+ description: 用户批准完整计划并要求按任务图连续执行时使用;每个任务仍独立经过 Gate、实现、检查、完成和提交。
4
4
  ---
5
5
 
6
6
  # Batch Mode
7
7
 
8
- ## Overview
8
+ ## 核心契约
9
9
 
10
- User approves the plan once (`implement.jsonl`), then the agent autonomously completes all tasks. **This does not bypass verification gates** -- each task still:
11
- - Passes the TDD evidence gate
12
- - Passes the check phase gates
13
- - Gets an independent commit
14
- - Pauses back to the user on failure or high-risk steps
10
+ Batch Scheduler 是持久化状态机,不在 CLI 内模拟实现或检查完成。
15
11
 
16
- Only the **manual progression between tasks** is removed.
12
+ - 任务顺序只来自 change/task graph 的叶子任务拓扑序。
13
+ - `implement.jsonl`、`check.jsonl` 和 `tdd.jsonl` 只作为当前任务上下文与 Gate 证据,
14
+ 不能作为 Batch 任务列表。
15
+ - 每次只发布一个 host-neutral `next_action`。
16
+ - Host 执行真实动作后,必须回写结果;状态机验证仓库状态后才推进。
17
+ - 任何 Gate、绑定、实现、检查、测试、完成或提交失败都会暂停。
18
+ - 已完成的任务、阶段和提交不会在恢复时重复执行。
17
19
 
18
- ## When to Use
20
+ ## 启动条件
19
21
 
20
- - Plan is approved (`implement.jsonl` is complete and the user said "approved" + "auto" at the end of writing-plans)
21
- - Current before-dev status is in_progress or review
22
- - Tasks are low-coupling (different files/modules, no write conflicts)
23
- - L0/L1 tasks dominate (L2 tasks recommended for step-by-step confirmation)
22
+ 仅在以下条件全部满足时启动:
24
23
 
25
- **Not applicable when**:
26
- - Tasks are L2 (step-by-task review recommended)
27
- - Tasks have dependencies or write conflicts
28
- - This is a first-time exploratory implementation (implementation path is uncertain)
29
- - The user has not explicitly requested batch mode
24
+ 1. 用户明确批准计划并要求自动连续执行。
25
+ 2. parent task 与所有叶子任务已建立有效 task graph。
26
+ 3. 当前会话是 main/coordinator,不是 worker 或 delegated subagent。
27
+ 4. Host 能执行 task、subagent 和 Git 动作。
30
28
 
31
- ## Startup Conditions
29
+ 启动命令:
32
30
 
31
+ ```bash
32
+ ./.cowork-flow/run task start <parent-task> --auto --approved
33
33
  ```
34
- User: "approved" + "auto"
35
- -> agent checks:
36
- 1. before-dev status = in_progress / review
37
- 2. implement.jsonl exists, non-empty, every line is valid JSON
38
- 3. user explicitly approved
34
+
35
+ 命令返回完整 Batch 状态,其中 `next_action` 是唯一允许执行的下一步。
36
+
37
+ ## Host Action 循环
38
+
39
+ 每次按以下顺序处理:
40
+
41
+ 1. 读取 `next_action`,核对 `action_id`、`type`、`task` 和 `task_dir`。
42
+ 2. 只执行该动作,不提前执行后续阶段。
43
+ 3. 将结果写入 UTF-8 JSON 文件。
44
+ 4. 回写结果:
45
+
46
+ ```bash
47
+ ./.cowork-flow/run task batch-record-result <batch-id> --file <result.json>
48
+ ```
49
+
50
+ 5. 读取新状态;若为 `awaiting_host`,继续新的 `next_action`;若为 `paused`,
51
+ 停止后续任务。
52
+
53
+ ## Action 类型
54
+
55
+ ### `start_task`
56
+
57
+ 运行真实任务启动命令并通过 readiness/spec/TDD Gate:
58
+
59
+ ```bash
60
+ ./.cowork-flow/run task start <task_dir>
61
+ ```
62
+
63
+ 成功结果必须包含:
64
+
65
+ ```json
66
+ {
67
+ "action_id": "<action-id>",
68
+ "type": "start_task",
69
+ "outcome": "success",
70
+ "task_status": "in_progress"
71
+ }
39
72
  ```
40
73
 
41
- ## Batch Loop
74
+ 状态机同时读取 `task.json`,仅相信真实的 `in_progress` 状态。
42
75
 
76
+ ### `init_implement_context` / `init_check_context`
77
+
78
+ 按 action 中的 `role`、`agent_type`、`task_dir` 和 `title` 运行:
79
+
80
+ ```bash
81
+ ./.cowork-flow/run subagent init \
82
+ --role <role> \
83
+ --agent-type <agent_type> \
84
+ --execution-task-dir <task_dir> \
85
+ --title "<title>"
43
86
  ```
44
- for task in implement.jsonl:
45
- 1. task start <task> (full readiness gate, includes L2 doubt-review)
46
- 2. dispatch cowork-implement
47
- 3. dispatch cowork-check
48
- 4. if check passes: git commit + task review + task complete
49
- 5. if check fails: cowork-implement fix (up to 3 retries)
50
- 6. on triggering any of 5 safety valves -> pause and report
87
+
88
+ Host 必须使用返回的 `cowork_runtime_context_id` 与
89
+ `cowork_host_context_key` 派发对应 worker,并让 worker 首步执行
90
+ `subagent bind`。
91
+
92
+ 初始化结果必须回写:
93
+
94
+ ```json
95
+ {
96
+ "action_id": "<action-id>",
97
+ "type": "init_implement_context",
98
+ "outcome": "success",
99
+ "runtime_context_id": "<runtime-context-id>",
100
+ "host_context_key": "<host-context-key>"
101
+ }
51
102
  ```
52
103
 
53
- ## 5 Safety Valves (Pause Conditions)
104
+ 检查阶段将 `type` 改为 `init_check_context`。
105
+
106
+ ### `await_implement_result` / `await_check_result`
107
+
108
+ 等待对应 worker 完成,验证输出属于当前任务且 runtime context 已绑定到预期 Host。
54
109
 
55
- Any single condition below triggers a **pause**; do not proceed to the next task:
110
+ 成功结果必须包含 action 中相同的 `runtime_context_id` 和
111
+ `host_context_key`。状态机验证 `status=bound` 后关闭 runtime context;
112
+ 如果关闭成功但 Batch checkpoint 尚未落盘,重复回写仍可恢复。
56
113
 
57
- 1. **TDD gate failure**: any task's tdd.jsonl evidence is invalid or missing
58
- 2. **Check gate failure**: any task's check.jsonl has an unresolved blocker (after 3 retries)
59
- 3. **Test/build breakage**: `git diff` introduces conflicts inconsistent with R-AG-005
60
- 4. **3 retries still failing**: the same task's implement + check loop has not passed after 3 rounds
61
- 5. **L2 doubt-review blocker**: an L2 decision has substantive unresolved doubt findings not reconciled
114
+ ### `review_task`
62
115
 
63
- When paused, output:
116
+ 运行:
64
117
 
118
+ ```bash
119
+ ./.cowork-flow/run task review <task_dir>
65
120
  ```
66
- ## Batch Mode Paused
67
121
 
68
- Task: <task-name>
69
- Reason: <specific cause>
70
- Current state: <task status + last command output>
122
+ 成功结果的 `task_status` 必须为 `review`,状态机还会读取真实 `task.json`。
123
+
124
+ ### `complete_task`
125
+
126
+ 运行:
127
+
128
+ ```bash
129
+ ./.cowork-flow/run task complete <task_dir>
130
+ ```
131
+
132
+ 成功结果的 `task_status` 必须为 `completed`,状态机还会读取真实 `task.json`。
133
+
134
+ ### `commit_task`
135
+
136
+ 只提交当前任务已验证的改动,并回写真实 commit id:
71
137
 
72
- Options:
73
- 1. Skip this task -> mark as skipped, proceed to next
74
- 2. Manual takeover -> exit batch, user resumes manually
75
- 3. Abort -> exit batch, all already-committed tasks remain intact
138
+ ```json
139
+ {
140
+ "action_id": "<action-id>",
141
+ "type": "commit_task",
142
+ "outcome": "success",
143
+ "commit_id": "<git-commit-id>"
144
+ }
76
145
  ```
77
146
 
78
- ## Post-Batch Verification
147
+ 状态机使用 Git 验证该对象确实是 commit;空值、占位字符串或不存在的 commit
148
+ 都会暂停。
79
149
 
80
- After all tasks complete (or after skips/aborts), run once:
150
+ ## 失败与恢复
81
151
 
82
- 1. **Full test suite**: `python -m pytest` / `npm test` / project-defined verification command
83
- 2. **git log audit**: confirm each task has an independent commit with a message reflecting the task
84
- 3. **Spec sync check**: confirm no remaining spec synchronization needs
85
- 4. **Final report**:
152
+ Host 不可用或任一动作失败时,回写非 success 结果:
86
153
 
154
+ ```json
155
+ {
156
+ "action_id": "<action-id>",
157
+ "type": "<action-type>",
158
+ "outcome": "failure",
159
+ "detail": "<specific cause>"
160
+ }
87
161
  ```
88
- ## Batch Mode Report
89
162
 
90
- - Tasks completed: N
91
- - Tasks skipped: M (reasons: ...)
92
- - Total commits: K
93
- - Issues found: ...
163
+ 状态会变为 `paused`,失败任务与所有后续任务不会被标记 completed。
94
164
 
95
- ### Per-Task Summary
165
+ 修复原因后运行:
96
166
 
97
- | task | commits | duration | issues |
98
- |------|---------|----------|--------|
99
- | ... | ... | ... | ... |
167
+ ```bash
168
+ ./.cowork-flow/run task batch-resume <batch-id>
100
169
  ```
101
170
 
102
- ## Relationship With Existing Systems
171
+ 恢复会生成新的 `action_id`,但保留已完成任务、阶段、runtime 证据和 commit。
172
+ 不要跳过失败任务,不要手工修改 Batch 状态文件。
103
173
 
104
- - writing-plans -> generates implement.jsonl (input)
105
- - task start -> unchanged (each task has its own readiness gate)
106
- - cowork-implement -> unchanged (dispatch one task per call)
107
- - cowork-check -> unchanged (check one task per call)
108
- - doubt-review -> auto-triggered for L2 tasks
109
- - Party Mode -> does not participate in batch mode (advisory in nature)
174
+ ## 完成验证
110
175
 
111
- ## Relationship With Before-Dev Gate
176
+ Batch 状态变为 `completed` 后:
112
177
 
113
- Batch mode can only start when before-dev status is in_progress.
114
- Before entering batch mode, the main session confirms:
115
- - before-dev status = in_progress / review
116
- - implement.jsonl exists and is non-empty
117
- - the user explicitly said "approved" at the end of writing-plans
178
+ 1. 运行项目完整测试与构建命令。
179
+ 2. 核对 `completed_tasks`、`task_phases` 与 `commits` 一一对应。
180
+ 3. 核对每个叶子任务都有独立 commit。
181
+ 4. 运行 spec sync、doctor 和发布前检查。
@@ -5,7 +5,7 @@ description: Use when requirements are unclear, a requested change has multiple
5
5
 
6
6
  # Brainstorming
7
7
 
8
- Use this skill as the active clarification gate for new requirements. Turn an idea into a clear change request before PRD, planning, fixed-agent dispatch, or code changes begin.
8
+ Use this skill as the active clarification gate for new requirements. Turn an idea into a clear change request before decision-anchor, planning, fixed-agent dispatch, or code changes begin.
9
9
 
10
10
  ## Flow
11
11
 
@@ -13,7 +13,7 @@ Use this skill as the active clarification gate for new requirements. Turn an id
13
13
  2. State the goal, non-goals, assumptions, scope boundary, success criteria, and the smallest useful scope.
14
14
  3. Ask one high-value question only when the answer cannot be inferred safely; otherwise proceed with explicit assumptions.
15
15
  4. Present 2-3 viable approaches when trade-offs matter, with a concrete recommended direction.
16
- 5. Do not write PRD, planning, or fixed-agent dispatch input until the direction and acceptance criteria are clear.
16
+ 5. Do not write decision-anchor, planning, or fixed-agent dispatch input until the direction and acceptance criteria are clear.
17
17
  6. For L1/L2 work, create or update the change/task artifacts required by `.cowork-flow/workflow.md` after the clarification output is stable.
18
18
  7. Hand off to `writing-plans` when the requested behavior and acceptance criteria are clear.
19
19
 
@@ -0,0 +1,42 @@
1
+ ---
2
+ name: cowork-flow
3
+ description: Route cowork-flow work through one authoritative workflow entry. Use for starting, resuming, implementing, reviewing, debugging, discussing, or finishing repository work when workflow state and the next allowed operation must be resolved.
4
+ ---
5
+
6
+ # Cowork Flow
7
+
8
+ Use this Skill as the only public workflow router. Do not reproduce lifecycle
9
+ rules from other Skills.
10
+
11
+ ## Resolve State
12
+
13
+ 1. Use the injected `<workflow-state>` when present.
14
+ 2. If state is absent, run `./.cowork-flow/run task next --json` exactly once.
15
+ 3. Treat `status`, `allowedOperations`, `requiredArtifacts`,
16
+ `recommendedSkill`, `internalProtocols`, and `blockers` as authoritative.
17
+ 4. Stop repository mutations when blockers exclude the requested operation.
18
+
19
+ ## Classify Intent
20
+
21
+ Classify the request into exactly one intent:
22
+
23
+ - `question`: answer or explain without changing repository state.
24
+ - `clarify`: refine goals, boundaries, or acceptance criteria.
25
+ - `plan`: create or revise an executable plan.
26
+ - `implement`: change code or task artifacts.
27
+ - `review`: verify implementation or complete review gates.
28
+ - `debug`: diagnose a failure or repeated unsuccessful attempt.
29
+ - `discuss`: compare options without advancing task state.
30
+ - `batch`: request automated execution of a task graph.
31
+
32
+ For `question`, answer directly when `answer_questions` is allowed. Do not load
33
+ implementation or review protocols.
34
+
35
+ ## Route
36
+
37
+ Use the active public Registry entry whose status and intent match the request.
38
+ Select at most one public Skill. If there is no match, follow the allowed
39
+ operation directly or report the blocker; never guess a second workflow entry.
40
+
41
+ Load only the protocols listed in `internalProtocols`. These protocols refine
42
+ execution but are not public alternatives and cannot override Runtime Gates.
@@ -1,6 +1,6 @@
1
1
  # Shared Boundaries
2
2
 
3
- These boundaries apply to both Party Mode and Party Mode V2.
3
+ These boundaries apply to Party Mode runtime-board discussions.
4
4
 
5
5
  - This skill is advisory only.
6
6
  - It cannot mutate task status, start/review/complete/archive tasks, add sessions, commit, push, or satisfy formal workflow gates.