peaks-cli 1.2.9 → 1.3.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 (53) hide show
  1. package/README.md +62 -46
  2. package/bin/peaks.js +0 -0
  3. package/dist/src/cli/commands/hooks-commands.js +24 -9
  4. package/dist/src/cli/commands/progress-commands.js +26 -2
  5. package/dist/src/cli/commands/request-commands.js +5 -0
  6. package/dist/src/cli/commands/slice-commands.d.ts +3 -0
  7. package/dist/src/cli/commands/slice-commands.js +42 -0
  8. package/dist/src/cli/commands/workflow-commands.js +3 -3
  9. package/dist/src/cli/commands/workspace-commands.d.ts +63 -0
  10. package/dist/src/cli/commands/workspace-commands.js +347 -5
  11. package/dist/src/cli/program.js +4 -0
  12. package/dist/src/services/artifacts/artifact-prerequisites.d.ts +17 -1
  13. package/dist/src/services/artifacts/artifact-prerequisites.js +38 -5
  14. package/dist/src/services/artifacts/request-artifact-service.d.ts +22 -0
  15. package/dist/src/services/artifacts/request-artifact-service.js +172 -54
  16. package/dist/src/services/doctor/doctor-service.d.ts +7 -0
  17. package/dist/src/services/doctor/doctor-service.js +20 -2
  18. package/dist/src/services/progress/progress-service.d.ts +26 -0
  19. package/dist/src/services/progress/progress-service.js +25 -0
  20. package/dist/src/services/sc/sc-service.d.ts +52 -1
  21. package/dist/src/services/sc/sc-service.js +324 -17
  22. package/dist/src/services/scan/acceptance-coverage-service.js +6 -2
  23. package/dist/src/services/session/session-manager.d.ts +7 -5
  24. package/dist/src/services/session/session-manager.js +60 -16
  25. package/dist/src/services/skills/hooks-settings-service.d.ts +25 -3
  26. package/dist/src/services/skills/hooks-settings-service.js +57 -13
  27. package/dist/src/services/skills/skill-presence-service.js +102 -68
  28. package/dist/src/services/skills/skill-runbook-service.js +2 -1
  29. package/dist/src/services/skills/skill-statusline-service.js +13 -7
  30. package/dist/src/services/slice/slice-check-service.d.ts +2 -0
  31. package/dist/src/services/slice/slice-check-service.js +248 -0
  32. package/dist/src/services/slice/slice-check-types.d.ts +61 -0
  33. package/dist/src/services/slice/slice-check-types.js +18 -0
  34. package/dist/src/services/workflow/pipeline-verify-service.d.ts +5 -2
  35. package/dist/src/services/workflow/pipeline-verify-service.js +35 -35
  36. package/dist/src/services/workspace/migrate-service.d.ts +2 -0
  37. package/dist/src/services/workspace/migrate-service.js +484 -0
  38. package/dist/src/services/workspace/migrate-types.d.ts +84 -0
  39. package/dist/src/services/workspace/migrate-types.js +21 -0
  40. package/dist/src/services/workspace/reconcile-service.d.ts +119 -0
  41. package/dist/src/services/workspace/reconcile-service.js +464 -0
  42. package/dist/src/services/workspace/reconcile-types.d.ts +93 -0
  43. package/dist/src/services/workspace/reconcile-types.js +13 -0
  44. package/dist/src/services/workspace/workspace-service.d.ts +11 -0
  45. package/dist/src/services/workspace/workspace-service.js +87 -7
  46. package/dist/src/shared/change-id.d.ts +59 -0
  47. package/dist/src/shared/change-id.js +194 -16
  48. package/dist/src/shared/version.d.ts +1 -1
  49. package/dist/src/shared/version.js +1 -1
  50. package/package.json +13 -2
  51. package/skills/peaks-solo/SKILL.md +28 -4
  52. package/skills/peaks-solo/references/micro-cycle.md +155 -0
  53. package/skills/peaks-solo/references/runbook.md +2 -0
@@ -0,0 +1,155 @@
1
+ # RD micro-cycle (TDD 小步快测)
2
+
3
+ > 参考 TDD 模式的红绿循环。设计目标:把 1 行 bug fix 的反馈循环从
4
+ > ~30s(全 suite + verify-pipeline)压到 ~100ms(单测 + 心算)。
5
+
6
+ ## 什么时候用 micro-cycle
7
+
8
+ - 在 **RD 实现** 阶段,**slice 内部** 做小修复 / refactor / lint fix / 微调时
9
+ - 节奏:5-10 秒一个 micro-cycle
10
+
11
+ ## 什么时候**不**用 micro-cycle
12
+
13
+ - slice 边界(一个 RD 任务结束 / 用户说 ship / 一个 logical change 整体完成)→ 走 `peaks slice check`
14
+ - 新增 slice / 跨模块 refactor / 依赖升级 → 直接走 peaks-rd 主流程
15
+ - `--type docs` / `--type chore` → 没有 acceptance 表面,micro-cycle 不适用
16
+
17
+ ## The cycle (硬约束顺序)
18
+
19
+ ### 1. RED — 写/改一个 unit test 反映 bug
20
+
21
+ ```bash
22
+ vim tests/unit/<file>.test.ts # 加 1 个 test 反映 bug
23
+ ```
24
+
25
+ 约束:**先写测试,再写实现**。LLM 写完实现再补 test 属于反向 TDD,等同于 skip micro-cycle。
26
+
27
+ ### 2. 跑这一个 test(确认 red)
28
+
29
+ ```bash
30
+ npx vitest run tests/unit/<file>.test.ts \
31
+ -t "<new test name>" \
32
+ --no-coverage
33
+ ```
34
+
35
+ 预期:test FAIL。**如果已经 pass → 你的测试没反映 bug,回去重写**。
36
+
37
+ ### 3. GREEN — 修实现
38
+
39
+ ```bash
40
+ vim src/<file>.ts
41
+ ```
42
+
43
+ 约束:**minimal change**,不要顺手"改进"无关代码。
44
+
45
+ ### 4. 跑这一个 test(确认 green)
46
+
47
+ ```bash
48
+ npx vitest run tests/unit/<file>.test.ts \
49
+ -t "<new test name>" \
50
+ --no-coverage
51
+ ```
52
+
53
+ 预期:test PASS。**如果还 FAIL → 你的实现不对,回去修**。
54
+
55
+ ### 5. 局部回扫 — 跑同 file 的所有 test
56
+
57
+ ```bash
58
+ npx vitest run tests/unit/<file>.test.ts --no-coverage
59
+ ```
60
+
61
+ 目的:防"改一处坏一处"。比全 suite 快 10-50×。
62
+
63
+ ### 6. 写一个 commit message(先不 commit)
64
+
65
+ ```bash
66
+ git add -p
67
+ # commit message: [micro-cycle] <slice-id>: <one-line summary>
68
+ ```
69
+
70
+ ## micro-cycle 内**禁止**触发
71
+
72
+ | 命令 | 理由 |
73
+ |---|---|
74
+ | `npx vitest run`(无 filter)| 30s+,micro-cycle 内禁止 |
75
+ | `npx tsc --noEmit` | 边界点才跑 |
76
+ | `peaks workflow verify-pipeline` | 边界点才跑 |
77
+ | 3-way fan-out(code-review / security-review / perf-baseline)| 边界点 + RD-internal 才跑 |
78
+ | `peaks request transition <rid> --state qa-handoff` | micro-cycle 内**不切 slice 状态** |
79
+
80
+ **违反任何一条 = workflow violation**(slice 边界才能跑全套)。
81
+
82
+ ## 边界 check(slice 结束)
83
+
84
+ 当一个 slice 内的所有 micro-cycle 都 green 且用户/agent 准备进入 peaks-qa 时,**必须**跑:
85
+
86
+ ```bash
87
+ peaks slice check [--rid <rid>] [--project <path>] [--json]
88
+ ```
89
+
90
+ 这个命令编排:
91
+ 1. `npx tsc --noEmit`(typecheck)
92
+ 2. `npx vitest run`(全 suite)
93
+ 3. 3-way fan-out(code-review + security-review + perf-baseline)
94
+ 4. `peaks workflow verify-pipeline --rid <rid> --project <path>`
95
+
96
+ 4 个 check 全绿 + verify-pipeline pass → 才进 `peaks request transition --state qa-handoff`,让 peaks-qa 接管。
97
+
98
+ ## Micro-cycle → 边界 check → QA 的串联
99
+
100
+ ```
101
+ peaks-rd 启动一个 slice
102
+
103
+ bug 1 → micro-cycle (红绿, ~10s)
104
+ bug 2 → micro-cycle
105
+ bug 3 → micro-cycle
106
+ ...
107
+ ↓ 全部 green
108
+ peaks slice check # 4 项检查全绿
109
+
110
+ peaks request transition --state qa-handoff
111
+
112
+ peaks-qa 接管 (full gate machinery)
113
+
114
+ verdict=pass → SC + TXT → handoff
115
+ verdict=return-to-rd → RD 修 (new slice 内部走 micro-cycle)
116
+ ```
117
+
118
+ ## Anti-patterns(明确禁止)
119
+
120
+ - ❌ 写实现先于测试(反向 TDD)
121
+ - ❌ micro-cycle 内跑全 suite(`vitest run`)
122
+ - ❌ micro-cycle 内调 `peaks workflow verify-pipeline`
123
+ - ❌ 1 个 micro-cycle 改 < 1 行代码(合并到下一个相关变更)
124
+ - ❌ skip 边界 check 直接 ship
125
+ - ❌ 在 micro-cycle 内修改 reviewed artifacts(code-review / security-review / perf-baseline)— 等边界再 regenerate
126
+ - ❌ micro-cycle 跨 PR/branch(一次 PR 内的所有 micro-cycles 才合在一起 review)
127
+
128
+ ## 跟其他 skill 的边界
129
+
130
+ | 阶段 | 谁负责 | 节奏 |
131
+ |---|---|---|
132
+ | RD slice 内部 | peaks-solo (main loop) | micro-cycle(5-10s 一个) |
133
+ | RD slice 边界 | peaks-solo 调用 `peaks slice check` | 一次 |
134
+ | QA test execution | peaks-qa (sub-agent or inline) | slice 级 |
135
+ | 3-way fan-out (CR + sec + perf) | peaks-rd (sub-agent) | slice 级(RD 内部一次 + 边界 check 一次) |
136
+ | TXT handoff | peaks-txt | slice 级 |
137
+ | SC commit-boundaries | peaks-sc | slice 级 |
138
+
139
+ ## 为什么这套比当前 peaks-solo 的设计合理
140
+
141
+ - **快**:micro-cycle ~100ms(vs 30s 全 suite),改 10 个 bug 从 5 分钟降到 30 秒
142
+ - **稳**:边界 check 不省,4 项检查(tsc + vitest + 3-way + verify-pipeline)一次全跑
143
+ - **清晰**:LLM 看到一个 explicit "禁止" 列表 + 强制 sequence,比"建议"更不容易越界
144
+ - **可观测**:micro-cycle 走单测 → 边界跑 verify-pipeline,每步都有 JSON envelope 验证
145
+
146
+ ## 跟 peaks-solo SKILL.md 的对账
147
+
148
+ - `peaks slice check` = 边界命令
149
+ - micro-cycle = slice 内部
150
+ - 3-way fan-out = peaks-rd 内部 + `peaks slice check` 末尾
151
+ - `peaks workflow verify-pipeline` = 边界 check
152
+ - `peaks request transition` = 边界切状态
153
+ - peaks-qa 接管 = 边界 + `verdict != pass` 时的下一轮
154
+
155
+ 完整流程见 SKILL.md。
@@ -18,6 +18,7 @@ peaks doctor --json
18
18
  peaks project dashboard --project <repo> --json
19
19
  peaks skill runbook peaks-solo --json
20
20
  peaks workspace init --project <repo> --json
21
+ peaks workspace reconcile --project <repo> --json
21
22
  peaks scan archetype --project <repo> --json
22
23
  # → copy archetype, frontendOnly, signals into .peaks/<session-id>/rd/project-scan.md (Peaks-Cli Gate A)
23
24
  # → copy libraries[] into .peaks/<session-id>/rd/project-scan.md under `## Library versions`
@@ -131,6 +132,7 @@ peaks sc boundary --slice-id <rid> --artifact <artifact> --code <file> --json
131
132
  # 9. Peaks-Cli OpenSpec archive (exit gate; only after QA pass, when openspec/ exists)
132
133
  peaks openspec validate <cid> --project <repo> --json
133
134
  peaks openspec archive <cid> --project <repo> --apply --json
135
+ peaks workspace reconcile --project <repo> --apply --older-than 7
134
136
 
135
137
  # 10. Peaks-Cli TXT handoff — invoke peaks-txt which embeds memory markers and extracts
136
138
  # peaks-txt writes the handoff capsule to .peaks/<id>/txt/handoff.md. Inside the