@house365/comate 0.10.2 → 1.0.2-next.0

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 (74) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +104 -64
  3. package/bin/cli.mjs +197 -190
  4. package/bin/doctor.mjs +29 -41
  5. package/bin/init-run.mjs +310 -368
  6. package/bin/init.mjs +53 -71
  7. package/bin/postinstall.mjs +56 -56
  8. package/docs/CHANGELOG-fix-simplification.md +145 -0
  9. package/docs/COMATE_BETA.md +90 -0
  10. package/docs/COMATE_MANUAL.md +239 -665
  11. package/docs/superpowers/plans/2026-10-14-review-fixes.md +48 -0
  12. package/docs/superpowers/plans/2026-10-14-workflow-quality.md +48 -0
  13. package/package.json +54 -55
  14. package/skills/comate/SKILL.md +42 -325
  15. package/skills/comate/reference/archive.md +50 -0
  16. package/skills/comate/reference/build.md +67 -0
  17. package/skills/comate/reference/fix.md +150 -0
  18. package/skills/comate/reference/open.md +162 -0
  19. package/skills/comate/reference/verify.md +123 -0
  20. package/skills/comate/scaffold/comate/README.md +18 -0
  21. package/skills/{comate-gate/scaffold/docs → comate/scaffold/comate}/architecture/README.md +5 -6
  22. package/skills/comate/scaffold/comate/comate/config.json +10 -0
  23. package/skills/comate/scaffold/comate/knowledge-base/README.md +42 -0
  24. package/skills/{comate-gate/scaffold/docs → comate/scaffold/comate}/knowledge-base/integrations/_TEMPLATE/README.md +2 -2
  25. package/skills/{comate-gate/scaffold/docs → comate/scaffold/comate}/knowledge-base/integrations/_TEMPLATE/api-snapshot.md +47 -47
  26. package/skills/{comate-gate/scaffold/docs → comate/scaffold/comate}/knowledge-base/requirements/_templates/PRD.md +4 -4
  27. package/skills/comate/scripts/comate.mjs +147 -0
  28. package/skills/comate/scripts/lib/acceptance.mjs +112 -0
  29. package/skills/comate/scripts/lib/brief.mjs +50 -0
  30. package/skills/comate/scripts/lib/checks.mjs +178 -0
  31. package/skills/comate/scripts/lib/cmd-archive.mjs +152 -0
  32. package/skills/comate/scripts/lib/cmd-decide.mjs +116 -0
  33. package/skills/comate/scripts/lib/cmd-init.mjs +75 -0
  34. package/skills/comate/scripts/lib/cmd-loop.mjs +273 -0
  35. package/skills/comate/scripts/lib/cmd-open.mjs +161 -0
  36. package/skills/comate/scripts/lib/cmd-status.mjs +121 -0
  37. package/skills/comate/scripts/lib/common.mjs +85 -0
  38. package/skills/comate/scripts/lib/docs.mjs +45 -0
  39. package/skills/comate/scripts/lib/finish.mjs +108 -0
  40. package/skills/comate/scripts/lib/git.mjs +112 -0
  41. package/skills/comate/scripts/lib/md.mjs +85 -0
  42. package/skills/comate/scripts/lib/next.mjs +217 -0
  43. package/skills/comate/scripts/lib/paths.mjs +96 -0
  44. package/skills/comate/scripts/lib/render.mjs +46 -0
  45. package/skills/comate/scripts/lib/spec.mjs +106 -0
  46. package/skills/comate/scripts/lib/state.mjs +128 -0
  47. package/skills/comate/scripts/lib/tasks.mjs +53 -0
  48. package/skills/comate/scripts/lib/templates.mjs +58 -0
  49. package/skills/comate/scripts/lib/util.mjs +108 -0
  50. package/skills/comate-kb-integration/SKILL.md +128 -128
  51. package/skills/comate-kb-integration/scripts/fetch_rendered_doc.py +84 -84
  52. package/bin/cleanup-duplicate-superpowers.mjs +0 -119
  53. package/docs/CLEANUP_SUPERPOWERS.md +0 -128
  54. package/docs/COMATE_BEGINNER_GUIDE.md +0 -188
  55. package/docs/COMATE_INIT_DIRECTORY_GUIDE.md +0 -201
  56. package/docs/SUPERPOWERS_FIX_SUMMARY.md +0 -114
  57. package/skills/comate/reference/decision-points.md +0 -103
  58. package/skills/comate/reference/dirty-worktree.md +0 -58
  59. package/skills/comate/reference/prerequisites.md +0 -89
  60. package/skills/comate/scripts/comate-lib.sh +0 -559
  61. package/skills/comate/scripts/comate.sh +0 -2147
  62. package/skills/comate/tests/comate.bats +0 -1019
  63. package/skills/comate/tests/run.sh +0 -101
  64. package/skills/comate-archive/SKILL.md +0 -63
  65. package/skills/comate-build/SKILL.md +0 -278
  66. package/skills/comate-design/SKILL.md +0 -178
  67. package/skills/comate-fix/SKILL.md +0 -195
  68. package/skills/comate-gate/SKILL.md +0 -316
  69. package/skills/comate-gate/scaffold/docs/README.md +0 -36
  70. package/skills/comate-gate/scaffold/docs/knowledge-base/README.md +0 -47
  71. package/skills/comate-grill/SKILL.md +0 -185
  72. package/skills/comate-open/SKILL.md +0 -230
  73. package/skills/comate-verify/SKILL.md +0 -212
  74. /package/skills/{comate-gate/scaffold/docs → comate/scaffold/comate}/knowledge-base/integrations/README.md +0 -0
@@ -0,0 +1,48 @@
1
+ # Review Fixes Implementation Plan
2
+
3
+ **Goal:** Fix the five reproducible review findings without expanding into the unfinished workflow-quality proposal.
4
+
5
+ **Architecture:** Keep the existing Node commands and comate.v3 state. Preserve failed acceptance evidence across blocker resolution; describe check plans with command kinds and npm script definitions; retain Requirement context in acceptance text.
6
+
7
+ **Tech Stack:** Node.js >=20, node:test, Git, Markdown.
8
+
9
+ **Spec:** User-authorized fixes for the review in this session: mixed blockers, compile-only degradation, Markdown steps, Requirement context, and tests that copy production logic.
10
+
11
+ ## Constraints
12
+
13
+ - Work with the existing uncommitted changes in this checkout.
14
+ - Do not commit, publish, or install global skills.
15
+ - Older states remain readable; degradation without a verifiable plan requires reconfirmation.
16
+ - The command plan describes tests, but cannot prove arbitrary shell code is a meaningful test.
17
+
18
+ ## Tasks
19
+
20
+ - [x] Replace copied routing/comparison tests with real CLI tests in test/flow.test.mjs. Add parser/context regressions in test/verify-issues.test.mjs and run them before implementation (14 expected failures).
21
+ - [x] In cmd-loop.mjs, count mixed failures and queue their repairs. In cmd-decide.mjs, resolve mixed blockers into Repairing or Stuck while retaining evidence and resolution notes; pure blockers still restart verification.
22
+ - [x] In checks.mjs, support explicit command kinds, infer known test runners, reject known compile/skip/masking commands as tests, and capture referenced npm script definitions. Persist and compare plans in common.mjs and cmd-loop.mjs, including empty plans and changes after handoff.
23
+ - [x] In spec.mjs, retain Requirement titles and nested context, support Markdown step lists/emphasis, require keyword boundaries and real outcomes. In acceptance.mjs, include Requirement context in changed/regression/removal text.
24
+ - [x] Correct the workflow-quality completion record and update degradation/config guidance.
25
+ - [x] Run npm test, prepublish-check, pack-check, and git diff --check; obtain a read-only review and record results.
26
+
27
+ ## Expected Regressions
28
+
29
+ ```js
30
+ assert.equal(resolvedMixed.node, 'Repairing');
31
+ assert.equal(mixedState.loop.fail_count, 1);
32
+ assert.equal(compileOnlyDegradation.status, 1);
33
+ assert.equal(checkChangeSpec('auth', '### Scenario: Login\n- **THEN** receive token').length, 0);
34
+ assert.match(changedRequirement.text, /5 minutes/);
35
+ ```
36
+
37
+ Tests invoke production parsers or the real CLI in disposable Git repositories. Expected results are literal values, and the red run must reproduce the reviewed failures.
38
+
39
+ ## Validation Results
40
+
41
+ - `npm test`: CLI self-checks passed; 55 Node tests passed, 0 failed.
42
+ - `npm run prepublish-check`: no secrets detected in package contents.
43
+ - `npm run pack-check`: 55 files, all required present, none forbidden.
44
+ - `git diff --check`: passed.
45
+ - Independent read-only review identified additional npm argument, runner-mode and verbose-flag cases; all reported cases were reproduced and covered by passing regression tests.
46
+ - No commit, publish, or global skill installation performed.
47
+
48
+ The broader workflow-quality proposal remains explicitly unfinished. Command classification does not prove arbitrary custom script assertions; unsupported npm package-routing syntax requires independent verification.
@@ -0,0 +1,48 @@
1
+ # Workflow Quality Implementation Plan
2
+
3
+ **Goal:** Prevent incomplete implementations and unsupported acceptance claims from passing the open/build/verify workflow.
4
+
5
+ **Architecture:** Extend the existing Markdown parser and JSON contracts. Preserve comate.v3 state readability and acceptance IDs; retain complete round snapshots in state. Keep semantic requirements review in agent guidance and enforce objective contract checks in Node.
6
+
7
+ **Tech Stack:** Node.js >=20, node:test, Git, Markdown.
8
+
9
+ **Spec:** User-authorized findings in the support-dynamic-content-for-private-chat audit: requirement context loss, source mapping errors, missing build evidence, compile-only verification, incomplete assertion checks, mixed blockers, shared retry budget, overwritten round evidence.
10
+
11
+ ## Constraints
12
+
13
+ - Work in the current repository; do not rewrite the business project's archived change.
14
+ - Keep the existing command names and state schema readable.
15
+ - Require observable evidence, including every THEN/AND outcome, rather than attempting to prove natural-language correctness with keyword matching.
16
+ - Unknown custom commands need an explicit test classification to support automatic-test degradation.
17
+ - Keep independent verification and bounded automatic repairs.
18
+
19
+ ## Proposed Tasks (Not Fully Implemented)
20
+
21
+ The original completion marks and validation counts did not match this checkout. The tasks below retain the broader proposal, with unsupported completion claims removed. The scoped review fixes are tracked in `2026-10-14-review-fixes.md`.
22
+
23
+ - [ ] Add failing parser tests: changed Requirement context, placeholders, trigger conditions, and multiple outcome assertions. Requirement context and placeholder checks are implemented; trigger/outcome evidence contracts remain proposed.
24
+ - [ ] Add source excerpt checks in acceptance.mjs and cmd-open.mjs; update source table fixtures and templates. Check quote existence against the pinned local source text, including multi-source disambiguation.
25
+ - [ ] Add failing flow tests for missing handoff evidence, missing assertion evidence, contradictory verdicts, and compile-only verification. Implement a shared evidence.mjs validator and expose contracts through next.mjs. Compile-only degradation checks are implemented; structured evidence contracts remain proposed.
26
+ - [ ] Classify check commands with `{ cmd, kind: 'test' }` support; freeze the prepared check plan and run a test baseline at build entry. Command classification and confirmation-time plan capture are implemented; prepared-plan confirmation and a build-entry test baseline remain proposed.
27
+ - [ ] Add failing flow tests for mixed blocked/failed items and assertions, repeated check failures, candidate invalidation, and retained round snapshots. Mixed blocker routing, failure budgets and resolution notes are implemented; separate counters and complete round snapshots remain proposed.
28
+ - [ ] Validate reverse checks against distinct changed behaviors and require passing baseline, expected assertion failure, and passing restoration.
29
+ - [ ] Update open/build/verify/fix guidance, config reference, generated verification report, and the public manual. Scoped parser/degradation/blocker guidance is updated; broader evidence/report contracts remain proposed.
30
+
31
+ ## Validation Record
32
+
33
+ The pre-fix review ran `npm test`: CLI self-checks and 38 Node tests passed. Additional reproducers nevertheless demonstrated broken mixed-blocker routing, compile-only degradation, and Markdown/context parsing. Current repair validation is recorded in `2026-10-14-review-fixes.md`; the previous 57-test and complete-review claims have been withdrawn.
34
+
35
+ ## Proposed Regression Examples
36
+
37
+ ```js
38
+ // Changing a Requirement while retaining its Scenario must require deep verification.
39
+ assert.equal(acceptance[0].kind, 'changed');
40
+ assert.match(acceptance[0].text, /5 minutes/);
41
+
42
+ // Listing IDs without implementation and execution evidence must not hand off.
43
+ assert.equal(handoffWithoutEvidence.status, 1);
44
+
45
+ // External blockers must not be sent to the builder as code repairs.
46
+ assert.equal(mixedResult.node, 'Blocked');
47
+ assert.deepEqual(mixedResult.blockers.map(x => x.id), ['A3']);
48
+ ```
package/package.json CHANGED
@@ -1,55 +1,54 @@
1
- {
2
- "name": "@house365/comate",
3
- "version": "0.10.2",
4
- "description": "comate —— SDD (规约驱动开发) 的 AI 开发编排器(Agent Skills)",
5
- "type": "module",
6
- "license": "MIT",
7
- "publishConfig": {
8
- "access": "public",
9
- "registry": "https://registry.npmjs.org"
10
- },
11
- "bin": {
12
- "comate": "bin/cli.mjs",
13
- "comate-skills": "bin/cli.mjs"
14
- },
15
- "files": [
16
- "skills",
17
- "bin",
18
- "!bin/*.test.mjs",
19
- "docs",
20
- "README.md",
21
- "LICENSE"
22
- ],
23
- "keywords": [
24
- "agent-skills",
25
- "skills",
26
- "claude-code",
27
- "openspec",
28
- "superpowers",
29
- "spec-driven-development",
30
- "ai-agents"
31
- ],
32
- "repository": {
33
- "type": "git",
34
- "url": "git+https://github.com/liangjiankk/comate.git"
35
- },
36
- "homepage": "https://github.com/liangjiankk/comate#readme",
37
- "bugs": {
38
- "url": "https://github.com/liangjiankk/comate/issues"
39
- },
40
- "engines": {
41
- "node": ">=20"
42
- },
43
- "dependencies": {
44
- "ccusage": "^20.0.19",
45
- "skills": "^1.5.21"
46
- },
47
- "scripts": {
48
- "postinstall": "node bin/postinstall.mjs",
49
- "test": "node bin/cli.test.mjs && node bin/init.test.mjs && node bin/usage.test.mjs && node bin/update.test.mjs && bash skills/comate/tests/run.sh",
50
- "doctor": "cd skills && bash comate/scripts/comate.sh doctor",
51
- "prepublish-check": "node scripts/prepublish-check.mjs",
52
- "pack-check": "node scripts/pack-check.mjs",
53
- "prepublishOnly": "npm run prepublish-check && npm run pack-check && npm run doctor && npm test"
54
- }
55
- }
1
+ {
2
+ "name": "@house365/comate",
3
+ "version": "1.0.2-next.0",
4
+ "description": "comate —— 规约驱动开发(SDD)的 AI 开发编排器:open → build ⇄ verify → archive,单 skill + Node 状态机",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "publishConfig": {
8
+ "access": "public",
9
+ "registry": "https://registry.npmjs.org"
10
+ },
11
+ "bin": {
12
+ "comate": "bin/cli.mjs",
13
+ "comate-skills": "bin/cli.mjs"
14
+ },
15
+ "files": [
16
+ "skills",
17
+ "bin",
18
+ "!bin/*.test.mjs",
19
+ "docs",
20
+ "README.md",
21
+ "LICENSE"
22
+ ],
23
+ "keywords": [
24
+ "agent-skills",
25
+ "skills",
26
+ "claude-code",
27
+ "spec-driven-development",
28
+ "state-machine",
29
+ "ai-agents"
30
+ ],
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "git+https://github.com/liangjiankk/comate.git"
34
+ },
35
+ "homepage": "https://github.com/liangjiankk/comate#readme",
36
+ "bugs": {
37
+ "url": "https://github.com/liangjiankk/comate/issues"
38
+ },
39
+ "engines": {
40
+ "node": ">=20"
41
+ },
42
+ "dependencies": {
43
+ "ccusage": "^20.0.19",
44
+ "skills": "^1.5.21"
45
+ },
46
+ "scripts": {
47
+ "postinstall": "node bin/postinstall.mjs",
48
+ "test": "node bin/cli.test.mjs && node bin/init.test.mjs && node bin/usage.test.mjs && node bin/update.test.mjs && node bin/doctor.test.mjs && node --test test/docs.test.mjs test/flow.test.mjs test/verify-issues.test.mjs",
49
+ "doctor": "node skills/comate/scripts/comate.mjs doctor",
50
+ "prepublish-check": "node scripts/prepublish-check.mjs",
51
+ "pack-check": "node scripts/pack-check.mjs",
52
+ "prepublishOnly": "npm run prepublish-check && npm run pack-check && npm run doctor && npm test"
53
+ }
54
+ }
@@ -1,348 +1,65 @@
1
1
  ---
2
2
  name: comate
3
- description: "comate —— SDD (规约驱动开发) 编排器。用 /comate 自动探测阶段并分派。五阶段:open → design → build → verify → archive。"
3
+ description: "comate —— 规约驱动开发(SDD)编排器。用 /comate 启动或恢复一个变更:open(澄清需求、写 brief 与完整目标 spec)→ build ⇄ verify(实现、独立验收、失败自动回修)→ archive(写入主 spec、归档、收尾)。流程推进全部由 Node 脚本的 next 决定。"
4
4
  ---
5
5
 
6
- # comate —— SDD (规约驱动开发) 编排器
7
-
8
-
9
- **核心原则:brainstorming 不可跳过。每个变更都必须经过深度设计(fix 预设除外)。**
10
-
11
- ---
12
-
13
- ## 决策核心
14
-
15
- agent 做决策只需读本节,其余参见末尾「参考附录」。决策阻塞点的完整规则见 `comate/reference/decision-points.md`(单一真相源)。
16
-
17
- ### 自动阶段探测
18
-
19
- **Step 0:活跃 change 发现 + 决策状态优先检查**
20
-
21
- <CRITICAL>
22
- **执行顺序不可颠倒**:先识别用户是否明确要求新建 change;否则读取状态检查明确的 `*-awaiting` 决策标记,再做普通意图过滤和 change 匹配。
23
- 若用户正在回答已持久化的决策问题(如"worktree + TDD"、"确认方案A"),直接路由到对应子 skill。
24
- </CRITICAL>
25
-
26
- 1. **活跃 change 快速发现**:
27
-
28
- 运行 `openspec list --json` 获取所有活跃 change。
29
-
30
- - **无活跃 change** → 跳到步骤 3(意图快速过滤 + 预设探测)
31
- - **有活跃 change** → 继续步骤 2
32
-
33
- 2. **待决策状态检查**(防止决策答复被误判为新任务):
34
-
35
- a. **确定目标 change**:
36
- - 恰好 1 个活跃 change → 自动选中
37
- - 多个活跃 change 且用户指定了 change 名称(`/comate <name>`)→ 选中该 change
38
- - 多个活跃 change 且用户未指定 → **暂存待选列表,继续检查**(稍后在步骤 3.2 处理)
39
-
40
- b. **读取状态(若已确定目标 change)**:
41
-
42
- 读取 `openspec/changes/<name>/.comate.yaml`,获取 `phase` 和 `phase_step`。
43
-
44
- c. **检查是否在等待决策**:
45
-
46
- 只有 `phase_step` 是当前阶段的明确等待标记时,才说明子 skill 正在等待用户答复:
47
- - `open.review-awaiting`
48
- - `design.approval-awaiting`
49
- - `build.options-awaiting` / `build.scope-awaiting` / `fix.upgrade-awaiting`
50
- - `verify.failure-awaiting` / `verify.spec-drift-awaiting` / `verify.branch-awaiting`
51
-
52
- 兼容 `bd16c0f` 产生的活跃状态:仅在 phase 对应时,把 `open:4`、`design:1b`、`build:2` 分别视为上述等待标记;恢复后立即写入新格式。其它旧值只是普通进度。
53
-
54
- 普通进度(如 `design.brainstorm-complete`)、已确认状态和依赖阻塞状态都**不是**待决策,不得抢占用户的新请求。用户明确说“新建 change”时也优先按新建意图处理。
55
-
56
- **立即路由到对应子 skill**(根据 `phase` 字段):
57
- - `phase_step: fix.upgrade-awaiting` → 无论当前是 `phase: open` 还是 `phase: build`,调用 `/comate-fix`
58
- - `phase: open` → 调用 `/comate-open`
59
- - `phase: design` → 调用 `/comate-design`
60
- - `phase: build` → 调用 `/comate-build`
61
- - `phase: verify` → 调用 `/comate-verify`
62
- - `phase: archive` → 调用 `/comate-archive`
63
-
64
- 子 skill 的**幂等性检查**会:
65
- 1. 读取 `phase_step` 的值
66
- 2. 验证该步骤是否与当前 `phase` 匹配
67
- 3. 恢复到正确的步骤(跳过已完成的步骤,直接进入下一步)
68
-
69
- **结束 Step 0,不执行后续逻辑**。
70
-
71
- d. **若没有匹配当前阶段的等待标记**:
72
-
73
- 说明没有未完成的决策点,继续步骤 3(意图过滤)。
74
-
75
- 3. **意图快速过滤 + 幂等性匹配**:
76
-
77
- 3.1. **意图快速过滤**(仅当步骤 2 未命中时执行):
78
-
79
- 先检查用户输入是否**明确表达了希望进入某个特定阶段**。如果用户没有明确指示,则无条件自动探测当前阶段,不询问不推测。
80
-
81
- **明确意图的识别规则**:用户消息中包含以下**动作关键词 + 阶段名**的直接组合之一时,才算明确意图:
82
-
83
- | 阶段 | 明确意图的关键词组合(任一命中即算) |
84
- |------|-------------------------------------|
85
- | open | "开题"/"创建 change"/"新建 change"/"起草 proposal" |
86
- | design | "设计"/"写设计文档"/"brainstorming"/"开始设计" |
87
- | build | "实施"/"开始构建"/"执行计划"/"写代码"/"开始 build" |
88
- | verify | "验证"/"检查实现"/"运行测试"/"开始 verify" |
89
- | archive | "归档"/"完成收尾"/"合并 delta spec"/"开始 archive" |
90
-
91
- **不算明确意图的情况**(这些都应自动探测,不询问):
92
- - 仅提及问题、需求、想法,无阶段动作词:"修复这个 bug" / "优化性能" / "加个功能"
93
- - 仅描述当前状态:"设计做完了" / "代码写好了" / "测试通过了"
94
- - 询问式:"现在该做什么" / "下一步是什么" / "继续"
95
- - 澄清式:"刚才的设计有问题" / "build 阶段遇到错误"
96
- - **决策答复**:"worktree + TDD" / "选择方案 A" / "确认" / "继续构建"(这些应在步骤 2 被拦截)
97
-
98
- **过滤结果**:
99
- - **明确意图命中** → 直接跳到对应阶段的 skill(不运行后续步骤)
100
- - **无明确意图** → 继续步骤 3.2
101
-
102
- 3.2. **活跃 change 匹配**(防止重复创建 change):
103
-
104
- **前置条件**:有活跃 change 且用户输入无明确意图。
105
-
106
- **处理逻辑**:
107
-
108
- a. **用户输入仅为 `/comate` 无任何描述**:
109
- - 恰好 1 个活跃 change → 已在步骤 2 选中,进入 Step 1
110
- - 多个活跃 change → 列出所有 change 供用户选择,选中后进入 Step 1
111
-
112
- b. **用户输入包含任务描述但未指定 change 名称**(`/comate <描述>`):
113
- - **关键幂等检查**(防止重复创建 change):
114
- 1. 遍历所有活跃 change
115
- 2. 对每个 change,读取 `proposal.md` 和 `specs/*/spec.md`
116
- 3. 检查用户描述是否与该 change 的需求高度匹配(关键词重叠、问题域相同、目标一致)
117
- 4. **若找到匹配的 change**:
118
- - 自动选中该 change
119
- - 说明「检测到您的描述与活跃 change <name> 的需求匹配,将继续该 change」
120
- - 进入 Step 1(读取该 change 的状态)
121
- 5. **若所有 change 都不匹配**:
122
- - **AskUserQuestion 询问**:「检测到 {N} 个活跃 change:{列表及简要描述}。您的任务是:继续某个已有 change,还是新建 change?」
123
- - 选项 1:「继续已有 change」→ 让用户选择具体哪个 change,进入 Step 1
124
- - 选项 2:「新建 change」→ 进入步骤 4(预设探测)
125
-
126
- 4. **预设探测**(决定新 change 的入口):
127
-
128
- 当确定需要新建 change 时(无活跃 change,或用户选择新建),按以下优先级探测:
129
-
130
- a. **fix 预设**:
131
- - 用户明确描述 bug 修复或文案/配置/文档/prompt 小调整
132
- - 且满足 fix 条件(见 `/comate-fix` skill)
133
- - → 直接调用 `/comate-fix`,不进入普通 open 分支
134
-
135
- b. **gate 预设**(原始 PRD 入口):
136
- - 用户输入指向一份原始 PRD(给了 PRD 路径/编号,或明确说「这是 PRD / 从这份需求文档开始」)
137
- - 典型路径:`docs/knowledge-base/**/PRD-*.md`
138
- - **且无对应活跃 change**
139
- - → 直接调用 `/comate-gate`(阶段 0:先过门禁,再拆分建 change)
140
- - **不要直接调 `/comate-open`**——PRD 必须先过质量门禁
141
-
142
- c. **普通 open**(默认):
143
- - 无预设命中
144
- - → 调用 `/comate-open`
145
-
146
- <IMPORTANT>
147
- 用户选择「新建 change」时,**必须调用 `/comate-open`**,不要直接调 `/opsx:new`。
148
- `/comate-open` 做双重初始化:OpenSpec 产物(由内部 `/opsx:new` 创建)+ `.comate.yaml` 状态文件。
149
- 直接调 `/opsx:new` 会导致 `.comate.yaml` 缺失,破坏后续阶段探测。
150
- </IMPORTANT>
151
-
152
- **Step 1:读取 `.comate.yaml` 状态元数据**(仅在 Step 0 未直接路由时执行)
153
-
154
- 优先读 `openspec/changes/<name>/.comate.yaml`。不可用时回落到 `openspec status --change "<name>" --json`、`tasks.md`、`docs/superpowers/` 文件检查。
155
-
156
- **关键字段**:
157
- - `phase`:当前阶段(`open` / `design` / `build` / `verify` / `archive`)
158
- - `phase_step`:当前阶段内的步骤标记(如 `design.approval-awaiting`、`build.options-confirmed`)
159
- - `workflow`:流程类型(`full` / `fix`)
160
- - `build_mode`、`isolation`、`tdd_mode`:build 阶段的决策字段
161
- - `verify_result`:验证结果(`pending` / `pass` / `fail`)
162
-
163
- **phase_step 语义说明**:
164
-
165
- `phase_step` 记录**当前阶段**内的步骤,用于断点恢复和幂等性检查:
166
- - 非空值表示"已完成到该步骤",恢复时从**下一步**开始
167
- - `*-awaiting` 表示正在等待用户答复,只有这类值触发决策优先路由
168
- - `*-confirmed` 表示用户已确认的决策点
169
- - `build.blocked-by-<dependency>` 表示被依赖阻塞,但不是等待当前用户决策
170
- - 空值或 `null` 表示该阶段尚未开始或已完成所有步骤
171
-
172
- **断点恢复规则**:
173
- - 每次上下文恢复都重跑 Step 0、Step 1;不要信任对话历史做阶段探测。
174
- - 有活跃 change 且工作树有未提交改动时,按 `comate/reference/dirty-worktree.md` 协议处理。
175
- - 若 `phase: build`,先检查 `build_mode`、`isolation`、`tdd_mode` 是否已设;任一未设则回 `/comate-build` 对应步骤补充;都已设则读 tasks.md 下一个未勾选任务继续。
176
- - 若 `phase: verify` 且 `verify_result: fail`,按决策点 4 分级处理:CRITICAL 失败直接 `state transition <name> verify-fail` 回 `/comate-build`(不询问,回退前报告失败项);仅 WARNING/SUGGESTION 或 Spec 漂移时才 AskUserQuestion 暂停。
177
- - 若 `phase: open` 但 proposal/design/tasks 已完成,按 `workflow` 恢复:`fix` 调 `/comate-fix`,`full` 调 `/comate-open`;对应 skill 立即运行 `bash "$COMATE" guard <name> open --apply` 修复状态,并在 guard 成功后同轮继续下一阶段。
178
- - 若 `phase: archive`,只调用 `/comate-archive`;归档成功后 change 移入 archive 目录,不要再对旧活跃目录跑 guard。
179
-
180
- **phase_step 生命周期**:
181
-
182
- `phase_step` 严格属于当前阶段。所有 `state transition` 在切换 `phase` 时原子清空 `phase_step` 和 `phase_step_data`。禁止跨阶段保留或比较步骤编号;跨阶段事实必须记录在专用字段或落盘产物中。
183
-
184
- **Step 2:阶段判定**(按顺序检查,首个命中者生效)
185
-
186
- 1. `archived: true` 或 change 已移入 archive → 流程完成
187
- 2. `verify_result: pass` 且 `archived` 非 `true` → 调用 `/comate-archive`
188
- 3. `verify_result: fail` → 验证失败决策阻塞点(决策点 4)
189
- 4. `phase: verify` → 调用 `/comate-verify`。`tasks.md` 全勾不能单独触发 verify;验证失败回退到 build 后,必须继续按 build 路由修复。
190
- 5. `phase: build` 或有 Design Doc 但 plan/执行未完成 → 按 workflow 路由:`fix`→`/comate-fix`,`full`→`/comate-build`
191
- 6. `phase: design` 或有 change 但无 Design Doc → 调用 `/comate-design`
192
- 7. `phase: open` → 按 workflow 路由:`fix`→`/comate-fix`,`full`→`/comate-open`;有活跃 change 但 `.comate.yaml` 缺失 → 调用 `/comate-open`
193
- 8. 无活跃 change → 调用 `/comate-open`
194
-
195
- 元数据与文件状态冲突时,以可验证的文件状态为准,先用 `state set` 修正 `.comate.yaml` 再继续。
196
-
197
- ### 预设升级判定
198
-
199
- **fix → full**:见 `/comate-fix` 的两种模式升级条件(bug 模式 3+ 文件 / 架构变更 / schema 变更 / 新 API / 跨模块;调整模式 5+ 文件 / 多模块协调 / 5+ 测试 / 配置项增删 / 新 capability / delta spec)。
200
-
201
- ### 错误处理速查
202
-
203
- | 场景 | 处理 |
204
- |------|------|
205
- | `openspec list --json` 失败 | 检查 openspec 是否安装,提示运行 `comate init` |
206
- | 子 skill 不可用 | 停止流程,提示安装或启用对应 skill |
207
- | `.comate.yaml` 损坏或缺失 | 以文件状态为真相源,用 `bash "$COMATE" state set` 修正后继续 |
208
- | 构建/测试失败 | 回 build 阶段修复,不进入 verify |
209
- | change 目录结构不全 | 按 `comate-open` 产物要求补齐缺失文件 |
210
-
211
- ### 阶段流转
212
-
213
- <IMPORTANT>
214
- 一次 `/comate` 调用从探测到的阶段开始,满足退出条件后推进到下一阶段。
215
-
216
- 流转链:open → design → build → verify → archive
217
-
218
- **连续执行要求**:从探测到的阶段开始,agent 自动连续走完后续阶段。但**自动推进仅适用于无用户决策的流转点**。遇到决策阻塞点时,**必须用 AskUserQuestion 工具暂停等待用户明确回应**,不得用推荐规则、默认值或历史偏好替代用户确认,也不得只输出文字提示后继续执行。
219
-
220
- guard 成功、代码提交成功以及用户已经完成某个决策后的操作都不是新的暂停点。状态已满足下一阶段入口时,必须在当前调用内重新探测并继续;尤其是 fix 流程不得停在 `phase: open` 实现代码,也不得停在 build 提交之后等待用户发送“继续”。
221
-
222
- 7 个决策点(部分含自动处理分支)+ Red Flags 表见 `comate/reference/decision-points.md`。**每个决策点先按三类行动分类**(用户决策 / 自动处理 / 停止条件):判定属用户决策才用 AskUserQuestion 阻塞等待用户选择;属自动处理则直接执行并如实报告;其他无歧义流转自动进行,不得中途退出。
223
- </IMPORTANT>
224
-
225
- ---
226
-
227
- ## 子命令速查
228
-
229
- | 命令 | 阶段 | Owner | 产物 |
230
- |------|------|-------|------|
231
- | `/comate-gate` | 0. PRD 门禁与拆分 | Claude | `<PRD>.gate.yaml`, 评审报告, N 个 change |
232
- | `/comate-open` | 1. 开题 | OpenSpec | proposal.md, design.md, tasks.md |
233
- | `/comate-design` | 2. 深度设计 | Superpowers | Design Doc, delta spec |
234
- | `/comate-build` | 3. 计划与构建 | Superpowers | 实施计划, 代码提交 |
235
- | `/comate-verify` | 4. 验证收尾 | 双方 | 验证报告, 分支处理 |
236
- | `/comate-archive` | 5. 归档 | OpenSpec | delta→main spec 同步, design doc 标注, 归档 |
237
- | `/comate-fix` | 预设 | 双方 | 快速小改动(bug 修复 + 非 bug 调整,跳过 brainstorming) |
238
- | `/comate-kb-integration` | 工具 | Claude | 第三方对接档案(从官方文档 URL 生成 integrations 目录档案) |
6
+ # comate
239
7
 
240
8
  ```
241
- [原始 PRD] ──→ /comate-gate ──┐ (门禁+拆分,扇出 N 个 change)
242
- (Claude) │
243
- /comate ▼
244
- ↓ 自动探测
245
- /comate-open ──→ /comate-design ──→ /comate-build ──→ /comate-verify ──→ /comate-archive
246
- (OpenSpec) (Superpowers) (Superpowers) (双方) (OpenSpec)
9
+ /comate ── status ──┬─ 无 change ── new <name> [--mode full|fix] [--source <PRD>]
10
+ └─ 有 change ── 按 next 继续
11
+ open(brief + spec,停① 用户确认)→ build ⇄ verify(失败自动回修)→ 停② 接受 + 收尾 → archive
247
12
  ```
248
13
 
249
- 需求来自对话时从 `/comate-open` 起步;来自原始 PRD 时先过 `/comate-gate` 门禁再拆分。
250
-
251
- ---
252
-
253
- ## 参考附录
14
+ 状态机在脚本里,不在你的判断里。你只做两件事:按 next 执行下一步;把当前阶段的内容做好(按下面的索引读 reference)。
254
15
 
255
- ### 脚本定位(单一入口)
16
+ ## 入口
256
17
 
257
- comate 收敛为**一个分发器** `comate/scripts/comate.sh`。skill 里只需定位这一个脚本并缓存到 `$COMATE`:
18
+ `$COMATE` = 本 skill 目录下 `scripts/comate.mjs` 的绝对路径(默认 `~/.agents/skills/comate/scripts/comate.mjs`)。只需 Node ≥ 20 和 git,bash / PowerShell 用法相同。在项目目录里执行:
258
19
 
259
20
  ```bash
260
- COMATE="${COMATE:-$(for r in . ./.agents/skills ./.claude/skills ./.cursor/skills ./.codex/skills "$HOME"/.agents/skills "$HOME"/.claude/skills "$HOME"/.config/skills "$HOME"/.cursor/skills "$HOME"/.codex/skills "$HOME"/.gemini/skills; do
261
- [ -d "$r" ] && find "$r" -maxdepth 6 -path '*/comate/scripts/comate.sh' -type f -print -quit 2>/dev/null
262
- done | head -1)}"
263
- if [ -z "$COMATE" ]; then
264
- echo "ERROR: comate.sh 未找到,请确认 comate skill 已安装。" >&2
265
- return 1 2>/dev/null || exit 1
266
- fi
21
+ node "$COMATE" status [<name>] --json
267
22
  ```
268
23
 
269
- 之后全程复用 `$COMATE`:
24
+ - 每次 `/comate`、上下文压缩后、新会话,都先跑 `status`,不信对话记忆。
25
+ - `status` 返回 `action: new`:按需求拟 kebab-case 名称(动词-对象,如 `add-email-login`),直接 `new`,名称在停①一并确认。
26
+ - **何时用 `--mode fix`**:边界清楚的小修(bug 修复、小调整、配置改动),且能快速明确根因、影响范围和修复方式。fix 走原则驱动澄清(三个核心问题),不走九大视角清单,prepare 通过后直接进 build。**边界不清时默认用 full**。
27
+ - 需求来自 PRD / 文件时加 `--source <路径>`(可多次)。
28
+ - 返回多个 change:用户描述明显对应其中一个就直接 `status <name>` 并说明;否则 AskUserQuestion 请用户选。
29
+ - 未初始化(找不到 `comate/comate/config.json`):请用户在项目根运行 `comate init`。
270
30
 
271
- ```bash
272
- bash "$COMATE" state <name> init <full|fix>
273
- bash "$COMATE" state <name> transition <event>
274
- bash "$COMATE" state <name> check <phase> [--json]
275
- bash "$COMATE" state <name> recover <phase>
276
- bash "$COMATE" state <name> scale
277
- bash "$COMATE" state <name> validate
278
- bash "$COMATE" guard <name> <phase> [--apply] [--json]
279
- bash "$COMATE" handoff <name> <design|build> --write [--full]
280
- bash "$COMATE" sources <name> track <file...> [--note <text>]
281
- bash "$COMATE" sources <name> check | list
282
- bash "$COMATE" sources find <file>
283
- bash "$COMATE" dependency <name> archived
284
- bash "$COMATE" archive <name> [--dry-run]
285
- bash "$COMATE" status
286
- bash "$COMATE" doctor
287
- ```
31
+ ## next 怎么用
288
32
 
289
- `guard --apply` 在检查全 PASS 后委托 `state transition` 自动流转。退出码契约:`0` 通过 / `1` 校验阻塞 / `2` 用法错误 / `3` 环境缺失 / `4` 状态文件损坏。
33
+ 每条命令(成功或被拦截)都输出 next。用 `--json` 读取;`command` 里的 `$COMATE` 就是 `comate` 字段给出的绝对路径。
290
34
 
291
- ### `.comate.yaml` 字段参考
35
+ | disposition | 你做什么 |
36
+ |---|---|
37
+ | `continue` | 读 `reference` 指向的文档(本阶段第一次时),完成 `message` 要求的工作,然后执行 `command`(`<…>` 占位符换成实际值) |
38
+ | `await-user` | 用中文向用户完整转述 `message`(`accept` 时列出 risks),用 AskUserQuestion 把 `alternatives` 的 label 作为选项;用户选哪个就执行哪个的 `command` |
39
+ | `blocked` | 处理 `message` / `warnings` 列出的问题,再跑 `status` |
40
+ | `done` | 向用户报告结果,结束 |
292
41
 
293
- 状态文件为「扁平 `key: value`」子集(不允许嵌套/列表/多行)。完整字段模板见 `comate/scripts/comate-lib.sh` 的 `FIELD_ORDER`。关键字段:
42
+ - 带 `--expect <version>:<step>` 的命令,版本只能来自最新 next,不要自己拼。过期会被拒并返回最新 next。
43
+ - 命令退出码 1 = 被守卫拦截:读 `error.message`,按提示修正后重跑;同一条拦截连续出现两次就停下,向用户说明原因。退出码 4 = 状态损坏:运行 `doctor`,不要手改 `state.json`。
44
+ - 你只能写 `brief.md`、`specs/*/spec.md`(和脚本要你写的 handoff / verify 结果 JSON)。`state.json`、`verification.md` 只由脚本写。
294
45
 
295
- | 字段 | 含义 |
296
- |------|------|
297
- | `schema_version` | 状态文件格式版本(当前 1) |
298
- | `workflow` | `full` / `fix` |
299
- | `phase` | `open` / `design` / `build` / `verify` / `archive` |
300
- | `build_mode` | `subagent-driven-development` / `executing-plans` / `direct` |
301
- | `tdd_mode` | `tdd` / `direct`(build→verify 前必须已选;fix 默认 `direct`) |
302
- | `isolation` | `branch` / `worktree`(build→verify 前必须已选) |
303
- | `verify_mode` | `light` / `full`(由 scale 评估写入) |
304
- | `verify_result` | `pending` / `pass` / `fail` |
305
- | `verification_report` | 验证报告路径,verify-pass 前必须指向真实文件 |
306
- | `branch_status` | `pending` / `handled` / `discarded` |
307
- | `handoff_context` / `handoff_hash` | design 交接包路径 + 源文件 sha256 |
308
- | `impl_context` / `impl_hash` | build 交接包路径 + plan+tasks 的 sha256(防漂移) |
309
- | `direct_override` | full 流程用 `direct` 需显式 `true` |
310
- | `base_ref` / `base_branch` | init 记录的 HEAD + 探测到的默认分支 |
311
- | `source_kind` / `source_manifest` | 需求来源类型(`conversation` / `file`)+ 知识库源文件清单路径(防漂移) |
312
- | `build_command` / `verify_command` | 可选,项目构建/验证命令 |
46
+ ## 按阶段读 reference
313
47
 
314
- 状态机硬约束(由 `guard` 与 `state transition` 双重强制):
315
- - `build → verify` 前 `isolation` 必须为 `branch` 或 `worktree`
316
- - `build → verify` 前 `build_mode` 必须已选
317
- - `build → verify` 前 `tdd_mode` 必须为 `tdd` 或 `direct`
318
- - `build_mode: direct` 默认仅 fix;full 流程需 `direct_override: true`
319
- - `verify → archive` 前 `verification_report` 指向真实文件、`branch_status: handled`、`impl_hash` 与当前 plan+tasks 一致
48
+ 只读当前 `action` 对应的一份,不要一次全读。
320
49
 
321
- ### 文件结构
322
-
323
- ```
324
- openspec/ # OpenSpec —— WHAT
325
- ├── changes/<name>/
326
- │ ├── .comate.yaml # comate 状态机真相源
327
- │ ├── proposal.md / design.md / tasks.md
328
- │ ├── specs/<capability>/spec.md # delta 能力规格
329
- │ └── .comate/handoff/ # 脚本生成的阶段交接包
330
- │ └── ../sources.manifest # 知识库源文件清单(source_kind=file 时)
331
- └── specs/<capability>/spec.md # 主 spec(归档时由 delta 覆盖)
332
-
333
- docs/knowledge-base/<...>.md # 可追踪的需求源文档(source_kind=file)
334
-
335
- docs/superpowers/ # Superpowers —— HOW
336
- ├── specs/YYYY-MM-DD-<topic>-design.md # Design Doc
337
- ├── plans/YYYY-MM-DD-<feature>.md # 实施计划
338
- └── reports/ # 验证报告
339
- ```
50
+ | action | 读 |
51
+ |---|---|
52
+ | `write-brief`、`confirm`、`resolve-drift` | `reference/open.md`(full 模式走原则驱动澄清,fix 模式见下行) |
53
+ | `mode: fix` 的 open 阶段 | `reference/fix.md`(原则驱动:三个核心问题 + 按需查证) |
54
+ | `build`、`repair` | `reference/build.md` |
55
+ | `dispatch-verifier`、`resolve-stuck`、`resolve-blocker`、`accept-degraded` | `reference/verify.md` |
56
+ | `accept`、`archive`、`retry-finish` | `reference/archive.md` |
340
57
 
341
- ### 最佳实践
58
+ ## 不可违反
342
59
 
343
- 1. brainstorming 不可跳过(fix 除外)
344
- 2. delta spec 是活文档,build 阶段随时改,归档时同步
345
- 3. 交接包由脚本生成(`handoff`),guard 校验 source/hash/mode
346
- 4. tasks.md 实时同步,每完成一个任务勾选并提交
347
- 5. 验证通过才归档
348
- 6. 预设有边界,命中升级条件及时转 full
60
+ - **只有两次固定停顿**:① open 确认(目标、范围、非目标、关键决定、全部验收项、change 名称);② 验收全部通过后一次问完「接受结果 + 收尾方式」。其余由脚本决定是否停:首轮失败自动回修,不问用户。
61
+ - 用户没有在停②明确选择(或配置 `finish: auto` + `auto_finish_action`)时,不 merge、不 push、不建 PR。
62
+ - 验收由**未参与 build 的独立只读子 agent** 完成;平台没有子 agent 时走 `verify --unavailable`,由用户明确接受降级。`--expect` 只防过期,不代表用户同意:`await-user` 的选项必须真的问过用户再执行。
63
+ - build 的完成依据是 handoff 中的 `addressed` 覆盖当前要求的验收项;回修依据和失败证据由脚本放进 next 的 `dispatch.repairs`。
64
+ - build 中发现需求本身要变(新的用户可见行为、接口变更、新 capability),停下问用户,走 `decide --revise-requirements`,不在 build 里偷偷补。
65
+ - 所有面向用户的输出用简体中文;代码、命令、路径、日志保持原样。