@boyingliu01/xp-gate 0.18.5 → 0.19.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 (254) hide show
  1. package/adapter-common.sh +27 -0
  2. package/adapters/gate-3.sh +0 -0
  3. package/adapters/gate-4.sh +0 -0
  4. package/adapters/gate-7.sh +0 -0
  5. package/adapters/gate-8.sh +0 -0
  6. package/adapters/gate-9.sh +0 -0
  7. package/adapters/powershell.sh +114 -35
  8. package/adapters/typescript.sh +8 -8
  9. package/build-integrity/__tests__/import-resolver.test.ts +22 -0
  10. package/build-integrity/__tests__/orchestrator.test.ts +1 -2
  11. package/build-integrity/gate-10.ts +7 -0
  12. package/gate-12-file-hygiene.sh +230 -0
  13. package/hooks/adapter-common.sh +27 -0
  14. package/hooks/gate-10.sh +105 -0
  15. package/hooks/gate-12-file-hygiene.sh +0 -0
  16. package/hooks/lib/validate-code-walkthrough.cjs +125 -0
  17. package/hooks/pre-commit +130 -33
  18. package/hooks/pre-push +15 -91
  19. package/lib/__tests__/check-version.test.js +67 -46
  20. package/lib/__tests__/doctor.test.js +7 -6
  21. package/lib/__tests__/gate-runner.test.js +267 -0
  22. package/lib/__tests__/init.test.js +32 -0
  23. package/lib/__tests__/npm-package.test.js +13 -0
  24. package/lib/__tests__/phase-transition.test.js +604 -12
  25. package/lib/__tests__/sprint-discovery.test.ts +0 -1
  26. package/lib/__tests__/sprint-status-rework.test.js +100 -1
  27. package/lib/__tests__/update-hooks.test.js +143 -10
  28. package/lib/__tests__/upgrade-exec.test.js +73 -45
  29. package/lib/__tests__/upgrade-skill-sync.test.js +1 -1
  30. package/lib/__tests__/upgrade.test.js +12 -11
  31. package/lib/doctor.js +2 -1
  32. package/lib/gate-runner.js +68 -23
  33. package/lib/init.js +34 -5
  34. package/lib/install-skill.js +1 -0
  35. package/lib/mattpocock-license-verdict.json +1 -1
  36. package/lib/phase-transition.js +203 -23
  37. package/lib/shared-paths.js +2 -0
  38. package/lib/sprint-status.js +15 -4
  39. package/lib/test-alignment.ts +3 -13
  40. package/lib/update-hooks.js +129 -15
  41. package/mock-policy/AGENTS.md +4 -4
  42. package/mock-policy/__tests__/gate-m3.test.ts +0 -5
  43. package/mock-policy/__tests__/scope-scanner.test.ts +8 -2
  44. package/mutation/AGENTS.md +3 -3
  45. package/mutation/__tests__/mutmut-runner.test.ts +443 -2
  46. package/mutation/__tests__/update-baseline.test.ts +0 -2
  47. package/mutation/runners/mutmut-runner.ts +67 -17
  48. package/package.json +9 -3
  49. package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
  50. package/plugins/claude-code/skills/clipboard-vision/SKILL.md +47 -0
  51. package/plugins/claude-code/skills/clipboard-vision/__tests__/clipboard-vision-distribution.test.cjs +65 -0
  52. package/plugins/claude-code/skills/clipboard-vision/__tests__/clipboard-vision-security.test.cjs +185 -0
  53. package/plugins/claude-code/skills/clipboard-vision/__tests__/clipboard-vision.Tests.ps1 +138 -0
  54. package/plugins/claude-code/skills/clipboard-vision/__tests__/clipboard-vision.test.cjs +273 -0
  55. package/plugins/claude-code/skills/clipboard-vision/describe-clipboard.ps1 +115 -0
  56. package/plugins/claude-code/skills/clipboard-vision/describe-clipboard.sh +161 -0
  57. package/plugins/claude-code/skills/clipboard-vision/scripts/clipboard-vision.ps1 +86 -0
  58. package/plugins/claude-code/skills/clipboard-vision/scripts/clipboard-vision.sh +137 -0
  59. package/plugins/claude-code/skills/delphi-review/.delphi-config.json.example +24 -27
  60. package/plugins/claude-code/skills/delphi-review/AGENTS.md +12 -11
  61. package/plugins/claude-code/skills/delphi-review/INSTALL.md +15 -17
  62. package/plugins/claude-code/skills/delphi-review/SKILL.md +30 -29
  63. package/plugins/claude-code/skills/delphi-review/opencode.json.delphi.example +6 -10
  64. package/plugins/claude-code/skills/delphi-review/references/code-walkthrough.md +33 -49
  65. package/plugins/claude-code/skills/delphi-review/references/requirements.md +66 -54
  66. package/plugins/claude-code/skills/delphi-review/references/round-templates.md +7 -7
  67. package/plugins/claude-code/skills/sprint-flow/AGENTS.md +4 -4
  68. package/plugins/claude-code/skills/sprint-flow/SKILL.md +4 -4
  69. package/plugins/claude-code/skills/sprint-flow/references/components/skill-invocations.md +2 -2
  70. package/plugins/claude-code/skills/sprint-flow/references/force-levels.md +37 -35
  71. package/plugins/claude-code/skills/sprint-flow/references/orchestration-rules.md +1 -1
  72. package/plugins/claude-code/skills/sprint-flow/references/phase-1-prep.md +1 -1
  73. package/plugins/claude-code/skills/sprint-flow/references/phase-2-design.md +24 -14
  74. package/plugins/claude-code/skills/sprint-flow/references/phase-4-verify.md +6 -6
  75. package/plugins/claude-code/skills/sprint-flow/references/phase-overview.md +2 -2
  76. package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +3 -3
  77. package/plugins/dsh/README.md +25 -0
  78. package/plugins/dsh/cordis.patch.yml +7 -0
  79. package/plugins/dsh/package.json +70 -0
  80. package/plugins/dsh/scripts/prepack.cjs +82 -0
  81. package/plugins/dsh/skills/admin-template-guidelines/SKILL.md +113 -0
  82. package/plugins/dsh/skills/admin-template-guidelines/references/rule-1.md +91 -0
  83. package/plugins/dsh/skills/admin-template-guidelines/references/rule-2.md +155 -0
  84. package/plugins/dsh/skills/admin-template-guidelines/references/rule-3.md +70 -0
  85. package/plugins/dsh/skills/admin-template-guidelines/references/rule-4.md +154 -0
  86. package/plugins/dsh/skills/admin-template-guidelines/references/rule-5.md +126 -0
  87. package/plugins/dsh/skills/admin-template-guidelines/references/rule-6.md +180 -0
  88. package/plugins/dsh/skills/batch-grill-me/SKILL.md +15 -0
  89. package/plugins/dsh/skills/clipboard-vision/SKILL.md +47 -0
  90. package/plugins/dsh/skills/clipboard-vision/__tests__/clipboard-vision-distribution.test.cjs +65 -0
  91. package/plugins/dsh/skills/clipboard-vision/__tests__/clipboard-vision-security.test.cjs +185 -0
  92. package/plugins/dsh/skills/clipboard-vision/__tests__/clipboard-vision.Tests.ps1 +138 -0
  93. package/plugins/dsh/skills/clipboard-vision/__tests__/clipboard-vision.test.cjs +273 -0
  94. package/plugins/dsh/skills/clipboard-vision/describe-clipboard.ps1 +115 -0
  95. package/plugins/dsh/skills/clipboard-vision/describe-clipboard.sh +161 -0
  96. package/plugins/dsh/skills/clipboard-vision/scripts/clipboard-vision.ps1 +86 -0
  97. package/plugins/dsh/skills/clipboard-vision/scripts/clipboard-vision.sh +137 -0
  98. package/plugins/dsh/skills/delphi-review/.delphi-config.json.example +70 -0
  99. package/plugins/dsh/skills/delphi-review/AGENTS.md +67 -0
  100. package/plugins/dsh/skills/delphi-review/INSTALL.md +150 -0
  101. package/plugins/dsh/skills/delphi-review/SKILL.md +559 -0
  102. package/plugins/dsh/skills/delphi-review/hooks.md +19 -0
  103. package/plugins/dsh/skills/delphi-review/opencode.json.delphi.example +52 -0
  104. package/plugins/dsh/skills/delphi-review/references/code-walkthrough.md +470 -0
  105. package/plugins/dsh/skills/delphi-review/references/orchestrator-dispatch.md +64 -0
  106. package/plugins/dsh/skills/delphi-review/references/requirements.md +402 -0
  107. package/plugins/dsh/skills/delphi-review/references/round-templates.md +134 -0
  108. package/plugins/dsh/skills/delphi-review/scripts/verify-consensus.sh +43 -0
  109. package/plugins/dsh/skills/delphi-review/tools.md +29 -0
  110. package/plugins/dsh/skills/domain-modeling/ADR-FORMAT.md +64 -0
  111. package/plugins/dsh/skills/domain-modeling/CONTEXT-FORMAT.md +60 -0
  112. package/plugins/dsh/skills/domain-modeling/SKILL.md +74 -0
  113. package/plugins/dsh/skills/grill-with-docs/SKILL.md +7 -0
  114. package/plugins/dsh/skills/grilling/SKILL.md +12 -0
  115. package/plugins/dsh/skills/improve-codebase-architecture/SKILL.md +156 -0
  116. package/plugins/dsh/skills/ralph-loop/SKILL.md +198 -0
  117. package/plugins/dsh/skills/ralph-loop/references/components.md +113 -0
  118. package/plugins/dsh/skills/ralph-loop/references/phase-2-build-ralph.md +89 -0
  119. package/plugins/dsh/skills/ralph-loop/references/workflow-details.md +99 -0
  120. package/plugins/dsh/skills/ralph-loop/templates/progress-log.md +36 -0
  121. package/plugins/dsh/skills/sprint-flow/AGENTS.md +103 -0
  122. package/plugins/dsh/skills/sprint-flow/SKILL.md +411 -0
  123. package/plugins/dsh/skills/sprint-flow/__tests__/sprint-flow.test.cjs +457 -0
  124. package/plugins/dsh/skills/sprint-flow/hooks.md +18 -0
  125. package/plugins/dsh/skills/sprint-flow/references/components/memory.md +87 -0
  126. package/plugins/dsh/skills/sprint-flow/references/components/middleware.md +75 -0
  127. package/plugins/dsh/skills/sprint-flow/references/components/skill-invocations.md +105 -0
  128. package/plugins/dsh/skills/sprint-flow/references/components/system-prompt.md +27 -0
  129. package/plugins/dsh/skills/sprint-flow/references/components/tool-descriptions.md +95 -0
  130. package/plugins/dsh/skills/sprint-flow/references/force-levels.md +204 -0
  131. package/plugins/dsh/skills/sprint-flow/references/orchestration-rules.md +236 -0
  132. package/plugins/dsh/skills/sprint-flow/references/phase-1-prep.md +294 -0
  133. package/plugins/dsh/skills/sprint-flow/references/phase-2-design.md +273 -0
  134. package/plugins/dsh/skills/sprint-flow/references/phase-3-build.md +348 -0
  135. package/plugins/dsh/skills/sprint-flow/references/phase-4-verify.md +225 -0
  136. package/plugins/dsh/skills/sprint-flow/references/phase-5-ship.md +222 -0
  137. package/plugins/dsh/skills/sprint-flow/references/phase-6-close.md +266 -0
  138. package/plugins/dsh/skills/sprint-flow/references/phase-overview.md +486 -0
  139. package/plugins/dsh/skills/sprint-flow/scripts/verify-sprint-state.sh +38 -0
  140. package/plugins/dsh/skills/sprint-flow/templates/auto-estimate-learning-log.md +136 -0
  141. package/plugins/dsh/skills/sprint-flow/templates/auto-estimate-output-template.md +110 -0
  142. package/plugins/dsh/skills/sprint-flow/templates/emergent-issues-template.md +120 -0
  143. package/plugins/dsh/skills/sprint-flow/templates/pain-document-template.md +115 -0
  144. package/plugins/dsh/skills/sprint-flow/templates/sprint-progress-template.md +140 -0
  145. package/plugins/dsh/skills/sprint-flow/templates/sprint-summary-template.md +121 -0
  146. package/plugins/dsh/skills/sprint-flow/tools.md +29 -0
  147. package/plugins/dsh/skills/test-driven-development/SKILL.md +371 -0
  148. package/plugins/dsh/skills/test-driven-development/testing-anti-patterns.md +299 -0
  149. package/plugins/dsh/skills/test-specification-alignment/AGENTS.md +56 -0
  150. package/plugins/dsh/skills/test-specification-alignment/SKILL.md +205 -0
  151. package/plugins/dsh/skills/test-specification-alignment/references/alignment-verification-algorithm.md +493 -0
  152. package/plugins/dsh/skills/test-specification-alignment/references/phase2-constraint-enforcement.md +431 -0
  153. package/plugins/dsh/skills/test-specification-alignment/references/specification-format.md +348 -0
  154. package/plugins/dsh/skills/to-issues/SKILL.md +277 -0
  155. package/plugins/dsh/src/command.test.ts +102 -0
  156. package/plugins/dsh/src/command.ts +75 -0
  157. package/plugins/dsh/src/contract.test.ts +62 -0
  158. package/plugins/dsh/src/gate-runner.test.ts +100 -0
  159. package/plugins/dsh/src/gate-runner.ts +58 -0
  160. package/plugins/dsh/src/index.test.ts +97 -0
  161. package/plugins/dsh/src/index.ts +94 -0
  162. package/plugins/dsh/src/skills.test.ts +58 -0
  163. package/plugins/dsh/tsconfig.build.json +13 -0
  164. package/plugins/dsh/tsconfig.json +19 -0
  165. package/plugins/dsh/vitest.config.ts +8 -0
  166. package/plugins/opencode/package.json +1 -1
  167. package/plugins/opencode/scripts/prepack.cjs +1 -0
  168. package/plugins/opencode/skills/clipboard-vision/SKILL.md +47 -0
  169. package/plugins/opencode/skills/clipboard-vision/__tests__/clipboard-vision-distribution.test.cjs +65 -0
  170. package/plugins/opencode/skills/clipboard-vision/__tests__/clipboard-vision-security.test.cjs +185 -0
  171. package/plugins/opencode/skills/clipboard-vision/__tests__/clipboard-vision.Tests.ps1 +138 -0
  172. package/plugins/opencode/skills/clipboard-vision/__tests__/clipboard-vision.test.cjs +273 -0
  173. package/plugins/opencode/skills/clipboard-vision/describe-clipboard.ps1 +115 -0
  174. package/plugins/opencode/skills/clipboard-vision/describe-clipboard.sh +161 -0
  175. package/plugins/opencode/skills/clipboard-vision/scripts/clipboard-vision.ps1 +86 -0
  176. package/plugins/opencode/skills/clipboard-vision/scripts/clipboard-vision.sh +137 -0
  177. package/plugins/opencode/skills/delphi-review/.delphi-config.json.example +24 -27
  178. package/plugins/opencode/skills/delphi-review/AGENTS.md +12 -11
  179. package/plugins/opencode/skills/delphi-review/INSTALL.md +15 -17
  180. package/plugins/opencode/skills/delphi-review/SKILL.md +30 -29
  181. package/plugins/opencode/skills/delphi-review/opencode.json.delphi.example +6 -10
  182. package/plugins/opencode/skills/delphi-review/references/code-walkthrough.md +33 -49
  183. package/plugins/opencode/skills/delphi-review/references/requirements.md +66 -54
  184. package/plugins/opencode/skills/delphi-review/references/round-templates.md +7 -7
  185. package/plugins/opencode/skills/sprint-flow/AGENTS.md +4 -4
  186. package/plugins/opencode/skills/sprint-flow/SKILL.md +4 -4
  187. package/plugins/opencode/skills/sprint-flow/references/components/skill-invocations.md +2 -2
  188. package/plugins/opencode/skills/sprint-flow/references/force-levels.md +37 -35
  189. package/plugins/opencode/skills/sprint-flow/references/orchestration-rules.md +1 -1
  190. package/plugins/opencode/skills/sprint-flow/references/phase-1-prep.md +1 -1
  191. package/plugins/opencode/skills/sprint-flow/references/phase-2-design.md +24 -14
  192. package/plugins/opencode/skills/sprint-flow/references/phase-4-verify.md +6 -6
  193. package/plugins/opencode/skills/sprint-flow/references/phase-overview.md +2 -2
  194. package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +3 -3
  195. package/plugins/qoder/plugin.json +1 -1
  196. package/plugins/qoder/skills/clipboard-vision/SKILL.md +47 -0
  197. package/plugins/qoder/skills/clipboard-vision/__tests__/clipboard-vision-distribution.test.cjs +65 -0
  198. package/plugins/qoder/skills/clipboard-vision/__tests__/clipboard-vision-security.test.cjs +185 -0
  199. package/plugins/qoder/skills/clipboard-vision/__tests__/clipboard-vision.Tests.ps1 +138 -0
  200. package/plugins/qoder/skills/clipboard-vision/__tests__/clipboard-vision.test.cjs +273 -0
  201. package/plugins/qoder/skills/clipboard-vision/clipboard-vision/SKILL.md +47 -0
  202. package/plugins/qoder/skills/clipboard-vision/clipboard-vision/__tests__/clipboard-vision-distribution.test.cjs +65 -0
  203. package/plugins/qoder/skills/clipboard-vision/clipboard-vision/__tests__/clipboard-vision-security.test.cjs +185 -0
  204. package/plugins/qoder/skills/clipboard-vision/clipboard-vision/__tests__/clipboard-vision.Tests.ps1 +138 -0
  205. package/plugins/qoder/skills/clipboard-vision/clipboard-vision/__tests__/clipboard-vision.test.cjs +273 -0
  206. package/plugins/qoder/skills/clipboard-vision/clipboard-vision/scripts/clipboard-vision.ps1 +86 -0
  207. package/plugins/qoder/skills/clipboard-vision/clipboard-vision/scripts/clipboard-vision.sh +137 -0
  208. package/plugins/qoder/skills/clipboard-vision/scripts/clipboard-vision.ps1 +86 -0
  209. package/plugins/qoder/skills/clipboard-vision/scripts/clipboard-vision.sh +137 -0
  210. package/plugins/qoder/skills/delphi-review/.delphi-config.json.example +3 -11
  211. package/plugins/qoder/skills/delphi-review/AGENTS.md +14 -16
  212. package/plugins/qoder/skills/delphi-review/INSTALL.md +12 -12
  213. package/plugins/qoder/skills/delphi-review/SKILL.md +58 -25
  214. package/plugins/qoder/skills/delphi-review/opencode.json.delphi.example +1 -1
  215. package/plugins/qoder/skills/delphi-review/references/code-walkthrough.md +33 -49
  216. package/plugins/qoder/skills/sprint-flow/AGENTS.md +4 -4
  217. package/plugins/qoder/skills/sprint-flow/SKILL.md +2 -2
  218. package/plugins/qoder/skills/sprint-flow/references/force-levels.md +38 -35
  219. package/plugins/qoder/skills/sprint-flow/references/phase-1-prep.md +1 -1
  220. package/plugins/qoder/skills/sprint-flow/references/phase-2-design.md +48 -6
  221. package/plugins/qoder/skills/sprint-flow/references/phase-4-verify.md +5 -6
  222. package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +3 -3
  223. package/principles/AGENTS.md +3 -3
  224. package/scripts/__tests__/sync-package-content.test.js +30 -0
  225. package/scripts/delphi-external-review.cjs +194 -63
  226. package/scripts/sync-package-content.js +9 -2
  227. package/skills/clipboard-vision/SKILL.md +47 -0
  228. package/skills/clipboard-vision/__tests__/clipboard-vision-distribution.test.cjs +65 -0
  229. package/skills/clipboard-vision/__tests__/clipboard-vision-security.test.cjs +185 -0
  230. package/skills/clipboard-vision/__tests__/clipboard-vision.Tests.ps1 +138 -0
  231. package/skills/clipboard-vision/__tests__/clipboard-vision.test.cjs +273 -0
  232. package/skills/clipboard-vision/describe-clipboard.ps1 +115 -0
  233. package/skills/clipboard-vision/describe-clipboard.sh +161 -0
  234. package/skills/clipboard-vision/scripts/clipboard-vision.ps1 +86 -0
  235. package/skills/clipboard-vision/scripts/clipboard-vision.sh +137 -0
  236. package/skills/delphi-review/.delphi-config.json.example +24 -27
  237. package/skills/delphi-review/AGENTS.md +12 -11
  238. package/skills/delphi-review/INSTALL.md +15 -17
  239. package/skills/delphi-review/SKILL.md +30 -29
  240. package/skills/delphi-review/opencode.json.delphi.example +6 -10
  241. package/skills/delphi-review/references/code-walkthrough.md +33 -49
  242. package/skills/delphi-review/references/requirements.md +66 -54
  243. package/skills/delphi-review/references/round-templates.md +7 -7
  244. package/skills/sprint-flow/AGENTS.md +4 -4
  245. package/skills/sprint-flow/SKILL.md +4 -4
  246. package/skills/sprint-flow/references/components/skill-invocations.md +2 -2
  247. package/skills/sprint-flow/references/force-levels.md +37 -35
  248. package/skills/sprint-flow/references/orchestration-rules.md +1 -1
  249. package/skills/sprint-flow/references/phase-1-prep.md +1 -1
  250. package/skills/sprint-flow/references/phase-2-design.md +24 -14
  251. package/skills/sprint-flow/references/phase-4-verify.md +6 -6
  252. package/skills/sprint-flow/references/phase-overview.md +2 -2
  253. package/skills/test-specification-alignment/AGENTS.md +3 -3
  254. package/sprint-gate.sh +291 -0
@@ -0,0 +1,60 @@
1
+ # CONTEXT.md Format
2
+
3
+ ## Structure
4
+
5
+ ```md
6
+ # {Context Name}
7
+
8
+ {One or two sentence description of what this context is and why it exists.}
9
+
10
+ ## Language
11
+
12
+ **Order**:
13
+ {A one or two sentence description of the term}
14
+ _Avoid_: Purchase, transaction
15
+
16
+ **Invoice**:
17
+ A request for payment sent to a customer after delivery.
18
+ _Avoid_: Bill, payment request
19
+
20
+ **Customer**:
21
+ A person or organization that places orders.
22
+ _Avoid_: Client, buyer, account
23
+ ```
24
+
25
+ ## Rules
26
+
27
+ - **Be opinionated.** When multiple words exist for the same concept, pick the best one and list the others under `_Avoid_`.
28
+ - **Keep definitions tight.** One or two sentences max. Define what it IS, not what it does.
29
+ - **Only include terms specific to this project's context.** General programming concepts (timeouts, error types, utility patterns) don't belong even if the project uses them extensively. Before adding a term, ask: is this a concept unique to this context, or a general programming concept? Only the former belongs.
30
+ - **Group terms under subheadings** when natural clusters emerge. If all terms belong to a single cohesive area, a flat list is fine.
31
+
32
+ ## Single vs multi-context repos
33
+
34
+ **Single context (most repos):** One `CONTEXT.md` at the repo root.
35
+
36
+ **Multiple contexts:** A `CONTEXT-MAP.md` at the repo root lists the contexts, where they live, and how they relate to each other:
37
+
38
+ ```md
39
+ # Context Map
40
+
41
+ ## Contexts
42
+
43
+ - [Ordering](./src/ordering/CONTEXT.md) — receives and tracks customer orders
44
+ - [Billing](./src/billing/CONTEXT.md) — generates invoices and processes payments
45
+ - [Fulfillment](./src/fulfillment/CONTEXT.md) — manages warehouse picking and shipping
46
+
47
+ ## Relationships
48
+
49
+ - **Ordering → Fulfillment**: Ordering emits `OrderPlaced` events; Fulfillment consumes them to start picking
50
+ - **Fulfillment → Billing**: Fulfillment emits `ShipmentDispatched` events; Billing consumes them to generate invoices
51
+ - **Ordering ↔ Billing**: Shared types for `CustomerId` and `Money`
52
+ ```
53
+
54
+ The skill infers which structure applies:
55
+
56
+ - If `CONTEXT-MAP.md` exists, read it to find contexts
57
+ - If only a root `CONTEXT.md` exists, single context
58
+ - If neither exists, create a root `CONTEXT.md` lazily when the first term is resolved
59
+
60
+ When multiple contexts exist, infer which one the current topic relates to. If unclear, ask.
@@ -0,0 +1,74 @@
1
+ ---
2
+ name: domain-modeling
3
+ description: Build and sharpen a project's domain model. Use when the user wants to pin down domain terminology or a ubiquitous language, record an architectural decision, or when another skill needs to maintain the domain model.
4
+ ---
5
+
6
+ # Domain Modeling
7
+
8
+ Actively build and sharpen the project's domain model as you design. This is the *active* discipline — challenging terms, inventing edge-case scenarios, and writing the glossary and decisions down the moment they crystallise. (Merely *reading* `CONTEXT.md` for vocabulary is not this skill — that's a one-line habit any skill can do. This skill is for when you're changing the model, not just consuming it.)
9
+
10
+ ## File structure
11
+
12
+ Most repos have a single context:
13
+
14
+ ```
15
+ /
16
+ ├── CONTEXT.md
17
+ ├── docs/
18
+ │ └── adr/
19
+ │ ├── 0001-event-sourced-orders.md
20
+ │ └── 0002-postgres-for-write-model.md
21
+ └── src/
22
+ ```
23
+
24
+ If a `CONTEXT-MAP.md` exists at the root, the repo has multiple contexts. The map points to where each one lives:
25
+
26
+ ```
27
+ /
28
+ ├── CONTEXT-MAP.md
29
+ ├── docs/
30
+ │ └── adr/ ← system-wide decisions
31
+ ├── src/
32
+ │ ├── ordering/
33
+ │ │ ├── CONTEXT.md
34
+ │ │ └── docs/adr/ ← context-specific decisions
35
+ │ └── billing/
36
+ │ ├── CONTEXT.md
37
+ │ └── docs/adr/
38
+ ```
39
+
40
+ Create files lazily — only when you have something to write. If no `CONTEXT.md` exists, create one when the first term is resolved. If no `docs/adr/` exists, create it when the first ADR is needed.
41
+
42
+ ## During the session
43
+
44
+ ### Challenge against the glossary
45
+
46
+ When the user uses a term that conflicts with the existing language in `CONTEXT.md`, call it out immediately. "Your glossary defines 'cancellation' as X, but you seem to mean Y — which is it?"
47
+
48
+ ### Sharpen fuzzy language
49
+
50
+ When the user uses vague or overloaded terms, propose a precise canonical term. "You're saying 'account' — do you mean the Customer or the User? Those are different things."
51
+
52
+ ### Discuss concrete scenarios
53
+
54
+ When domain relationships are being discussed, stress-test them with specific scenarios. Invent scenarios that probe edge cases and force the user to be precise about the boundaries between concepts.
55
+
56
+ ### Cross-reference with code
57
+
58
+ When the user states how something works, check whether the code agrees. If you find a contradiction, surface it: "Your code cancels entire Orders, but you just said partial cancellation is possible — which is right?"
59
+
60
+ ### Update CONTEXT.md inline
61
+
62
+ When a term is resolved, update `CONTEXT.md` right there. Don't batch these up — capture them as they happen. Use the format in [CONTEXT-FORMAT.md](./CONTEXT-FORMAT.md).
63
+
64
+ `CONTEXT.md` should be totally devoid of implementation details. Do not treat `CONTEXT.md` as a spec, a scratch pad, or a repository for implementation decisions. It is a glossary and nothing else.
65
+
66
+ ### Offer ADRs sparingly
67
+
68
+ Only offer to create an ADR when all three are true:
69
+
70
+ 1. **Hard to reverse** — the cost of changing your mind later is meaningful
71
+ 2. **Surprising without context** — a future reader will wonder "why did they do it this way?"
72
+ 3. **The result of a real trade-off** — there were genuine alternatives and you picked one for specific reasons
73
+
74
+ If any of the three is missing, skip the ADR. Use the format in [ADR-FORMAT.md](./ADR-FORMAT.md).
@@ -0,0 +1,7 @@
1
+ ---
2
+ name: grill-with-docs
3
+ description: A relentless interview to sharpen a plan or design, which also creates docs (ADR's and glossary) as we go.
4
+ disable-model-invocation: true
5
+ ---
6
+
7
+ Run a `/grilling` session, using the `/domain-modeling` skill.
@@ -0,0 +1,12 @@
1
+ ---
2
+ name: grilling
3
+ description: Grill the user relentlessly about a plan, decision, or idea. Use when the user wants to stress-test their thinking, or uses any 'grill' trigger phrases.
4
+ ---
5
+
6
+ Interview me relentlessly about every aspect of this until we reach a shared understanding. Walk down each branch of the decision tree, resolving dependencies between decisions one-by-one. For each question, provide your recommended answer.
7
+
8
+ Ask the questions one at a time, waiting for feedback on each question before continuing. Asking multiple questions at once is bewildering.
9
+
10
+ If a *fact* can be found by exploring the environment (filesystem, tools, etc.), look it up rather than asking me. The *decisions*, though, are mine — put each one to me and wait for my answer.
11
+
12
+ Do not act on it until I confirm we have reached a shared understanding.
@@ -0,0 +1,156 @@
1
+ ---
2
+ name: improve-codebase-architecture
3
+ description: Find deepening opportunities in a codebase, informed by domain language in CONTEXT.md and decisions in ADRs. Use when user wants to improve architecture, find refactoring opportunities, consolidate tightly-coupled modules, or make a codebase more AI-navigable. Run periodically (weekly or after surges of development).
4
+ ---
5
+
6
+ # Improve Codebase Architecture
7
+
8
+ 周期性架构健康检查:发现 **shallow module → deep module** 的深度化机会。目标是提升可测试性、AI 可导航性、模块边界清晰度。
9
+
10
+ 与 XP-Gate 质量门禁的分工:
11
+ | 机制 | 时机 | 作用 |
12
+ |------|------|------|
13
+ | **6 道门禁** | 每次 commit | 被动拦截明显问题(函数过长、重复代码等) |
14
+ | **improve-codebase-architecture** | 每周/开发潮后 | 主动深度化改进(seam 识别、模块合并、接口提炼) |
15
+
16
+ ---
17
+
18
+ ## 术语(与 XP-Gate Principles 一致)
19
+
20
+ | 术语 | 定义 |
21
+ |------|------|
22
+ | **Module** | 任何有接口和实现的东西(函数、类、包、slice) |
23
+ | **Interface** | 调用者使用前必须知道的一切:类型、不变量、错误模式、顺序、配置 |
24
+ | **Implementation** | 接口背后的代码 |
25
+ | **Depth** | 接口的杠杆率:大量行为隐藏在简单接口后。**Deep = 高杠杆**。**Shallow = 接口几乎与实现一样复杂** |
26
+ | **Seam** | 接口所在位置;可以在不修改实现的情况下改变行为的地方 |
27
+ | **Adapter** | 在 seam 处满足接口的具体实现 |
28
+ | **Locality** | 深度带来的可维护性收益:变更、bug、知识集中在一处 |
29
+
30
+ ---
31
+
32
+ ## 核心判断工具
33
+
34
+ ### Deletion Test
35
+ 想象删除某个模块:
36
+ - 如果复杂性消失 → 它是 pass-through,不值得保留
37
+ - 如果复杂性在 N 个调用方中重新出现 → **它真正提供了价值**
38
+ - **"Yes, concentrates" = 你想发现的信号**
39
+
40
+ ### The Interface Is the Test Surface
41
+ 接口就是测试的边界。如果测试需要深入实现细节,说明接口太浅。
42
+
43
+ ### One Adapter = Hypothetical Seam. Two Adapters = Real Seam.
44
+ 只有一个实现满足接口 → 可能过度抽象。两个以上 → 真正的可替换边界。
45
+
46
+ ---
47
+
48
+ ## 流程
49
+
50
+ ### 1. 探索
51
+
52
+ 先读项目的 `CONTEXT.md`(领域语言)和 `docs/adr/`(架构决策)。
53
+
54
+ 然后有机地走查代码库(不要遵循死板启发式),注意你在哪里感受到摩擦:
55
+
56
+ - 理解一个概念是否需要在多个小文件间跳来跳去?
57
+ - 模块是否 **shallow** — 接口几乎与实现一样复杂?
58
+ - 纯函数是否仅仅为了可测试性而被提取,但真正的 bug 隐藏在调用方式中?(缺乏 **locality**)
59
+ - 紧密耦合的模块是否在其 seams 之处泄漏?
60
+ - 哪些部分难以通过当前接口进行测试?
61
+
62
+ 对任何怀疑 shallow 的模块执行 **Deletion Test**:删除它会让复杂性集中还是分散?"是的,会集中"就是你要的信号。
63
+
64
+ ### 2. 呈现候选项
65
+
66
+ 以编号列表呈现深度化机会。每项包含:
67
+
68
+ - **Files** — 涉及哪些文件/模块
69
+ - **Problem** — 当前架构为何造成摩擦(使用 CONTEXT.md 中的领域术语)
70
+ - **Solution** — 自然语言描述会怎样改变
71
+ - **Benefits** — 用 locality 和 leverage 解释收益,以及测试会怎样改善
72
+
73
+ **使用 CONTEXT.md 领域术语。如果与 ADR 冲突**,仅在摩擦值得重新讨论 ADR 时才标注:
74
+ > *"Contradicts ADR-0007 — 但值得重新打开,因为…"*
75
+
76
+ 不要列出 ADR 禁止的每个理论重构。
77
+
78
+ **此时不要提出接口设计**。先问用户:"你想探索哪个候选项?"
79
+
80
+ ### 3. 用户选择候选项
81
+
82
+ 仅当用户明确选择某个候选项时,才进入步骤 4。
83
+
84
+ ### 4. Grilling 循环(设计树遍历)
85
+
86
+ 用户选中某个候选项后,进入 grilling 对话:
87
+ - 遍历约束、依赖、深度化模块的形状
88
+ - seam 背后放什么、什么不放在 seam 背后
89
+ - 哪些测试能在深度化后存活/新增
90
+
91
+ **对话中的副作用**(决策固化时立即执行):
92
+ - 命名不在 CONTEXT.md 中的新概念 → **新增到 CONTEXT.md**
93
+ - 模糊术语在对话中变清晰 → **更新 CONTEXT.md**
94
+ - 用户拒绝候选项且有有理由 → **提议记录为 ADR**(避免未来重复建议)
95
+ - 需要探索替代接口 → **按接口设计原则引导**
96
+
97
+ ### 5. 输出(可选)
98
+
99
+ 如果用户在 grilling 后决定执行重构:
100
+ - 生成重构计划(含文件列表、步骤顺序、风险点)
101
+ - 调用 test-driven-development skill 执行重构(保持行为不变)
102
+
103
+ ---
104
+
105
+ ## 与 XP-Gate 集成
106
+
107
+ ### 触发时机
108
+ ```
109
+ Phase 5 (FEEDBACK) 后推荐调用:
110
+ → learn + retro + **improve-codebase-architecture**
111
+ → 发现架构摩擦 → 记录到 retro → 下一 Sprint 纳入 backlog
112
+
113
+ 或作为独立周期性任务:
114
+ → /improve-codebase-architecture → 每周/开发潮后
115
+ ```
116
+
117
+ ### 与 ralph-loop 的关系
118
+ 架构改进本身可以作为一个独立的 REQ 通过 ralph-loop 执行:
119
+ - REQ: "深度化 Order 模块(从 N 个散文件合并为 deep module)"
120
+ - 通过 test-driven-development 保证行为不变
121
+
122
+ ### 与质量门禁的关系
123
+ 架构改进后,质量门禁的 violation 数量应减少:
124
+ - God class → 拆分为 deep modules → SOLID-001 (SRP) 告警消失
125
+ - Deep nesting → 封装为简单接口 → CC-002 告警消失
126
+ - Code duplication → 提取公共 deep module → Gate 2 (Dup Code) 改善
127
+
128
+ ---
129
+
130
+ ## Anti-Patterns
131
+
132
+ | ❌ 错误 | ✅ 正确 |
133
+ |---------|---------|
134
+ | 仅在文件层面重构(拆分大文件) | 在概念边界处重构(deep module 封装行为) |
135
+ | 为了测试而提取纯函数 | 为了 locality 和组织行为边界而重构 |
136
+ | 过度设计接口(只有一个 adapter) | 发现真实 seam(≥2 adapters 或需要可测试性)后再抽象 |
137
+ | 忽视现有 ADR 提出重构 | 尊重 ADR,仅在摩擦值得重新讨论时标注冲突 |
138
+ | 一次性重构整个模块 | 逐个候选项执行,使用 TDD 保证行为不变 |
139
+ | 与 ADR 冲突但不记录决策 | 记录为 ADR,避免未来重复建议 |
140
+
141
+ ---
142
+
143
+ ## 使用示例
144
+
145
+ ```
146
+ /improve-codebase-architecture
147
+
148
+ → Explore: 读取 CONTEXT.md, 走查代码库
149
+ → 发现 3 个浅模块候选项
150
+ → 呈现: #1 Order 模块过浅 / #2 Auth 适配器泄漏 / #3 支付领域缺乏 locality
151
+ → 用户选中 #1
152
+ → Grilling: 讨论 Order 的 seam 应该在哪
153
+ → 更新 CONTEXT.md: 新增 "Order Intake" 术语
154
+ → 提议 ADR: "Order 状态机封装" → 用户同意 → 创建 docs/adr/000X.md
155
+ → 输出: 重构计划 → TDD 执行
156
+ ```
@@ -0,0 +1,198 @@
1
+ ---
2
+ name: ralph-loop
3
+ description: Use when executing Sprint-Flow Phase 2 BUILD, processing one REQ, building the next requirement, iterating with clean context, or requiring full regression per requirement.
4
+ maturity: stable
5
+ ---
6
+
7
+ # Ralph Loop — Default REQ-Level Iterative Build
8
+
9
+ Core principles: **isolated context per REQ**, **TDD-first**, **full regression every iteration**, **token efficiency** (40-67% savings vs parallel).
10
+
11
+ ## Triggers
12
+
13
+ **Keywords**: ralph-loop, process one REQ, Phase 2 BUILD, iterate REQ, isolated REQ build
14
+
15
+ **Use when**: executing Sprint-Flow Phase 2 BUILD; reading specification.yaml to implement REQs one-by-one; needing controlled token budget per REQ; preventing context pollution between REQs; full regression needed per step.
16
+
17
+ **Don't use**: 1-2 simple independent REQs (use parallel); emergency hotfix; `--mode parallel` is explicitly set.
18
+
19
+ ## Architecture Overview
20
+
21
+ Ralph Loop is the **default Phase 2 BUILD mode**. Each REQ gets a fresh subagent context:
22
+
23
+ ```
24
+ Sprint-Flow Phase 2 (default):
25
+ ralph-loop → per-REQ iteration → clean context each time → full regression
26
+
27
+ Sprint-Flow Phase 2 (--mode parallel):
28
+ dispatching-parallel-agents → parallel dispatch → context grows linearly
29
+ ```
30
+
31
+ ## Full Flow
32
+
33
+ ```
34
+ Phase 0: 准备 → 读取 specification.yaml → 构建依赖图 → 拓扑排序
35
+ │
36
+ ▼
37
+ Phase 1: 迭代循环 (max_iterations=15 默认)
38
+ │
39
+ ├── 取下一个 READY REQ(依赖已满足,优先级最高)
40
+ │
41
+ ├── 测试基础设施检查 (test-utils.ts)
42
+ │ ├── 不存在或接口缺失 → dispatch 生成 subagent (retry max 2)
43
+ │ └── 已存在 → 注入 API 摘要到 subagent context
44
+ │
45
+ ├── Dispatch 独立 subagent (unspecified-high + test-driven-development)
46
+ │ Context: 当前 REQ + AC + permanent learnings + contextual learnings
47
+ │ + AGENTS.md + git log -5 + Mock 边界策略
48
+ │
49
+ ├── 三层验证
50
+ │ ├── L1: typecheck + lint → FAIL? → retry
51
+ │ ├── L1b: 测试行占比 ≥ 40% → FAIL? → retry
52
+ │ ├── L2: 全量测试(ALL tests)→ FAIL? → retry
53
+ │ └── L3: coverage ≥ 80% → FAIL? → retry
54
+ │
55
+ ├── PASS → git commit → 标记 done
56
+ │ → 写 learnings (permanent/contextual)
57
+ │ → orchestrator 更新 AGENTS.md
58
+ │ → 继续下一个 READY REQ
59
+ │
60
+ └── FAIL (max 3 retry) → BLOCK → 用户决策 (skip/manual/stop/rollback)
61
+ │
62
+ ▼
63
+ 终止条件: ALL DONE → COMPLETE | max_iterations → PARTIAL | BLOCK → WAIT_USER
64
+ ```
65
+
66
+ ## 输入格式 (specification.yaml)
67
+
68
+ ```yaml
69
+ specification:
70
+ requirements:
71
+ - id: REQ-001
72
+ description: "Create User Model"
73
+ acceptance_criteria:
74
+ - id: AC-001-01
75
+ criteria: "email (unique), password_hash, created_at"
76
+ priority: 1
77
+ status: pending
78
+ - id: REQ-002
79
+ description: "Password encryption"
80
+ depends_on: [REQ-001]
81
+ priority: 2
82
+ status: pending
83
+ ```
84
+
85
+ 每个 REQ 自动作为迭代单元,所有 AC-XXX-XX 作为验收标准。
86
+
87
+ ## 依赖排序
88
+
89
+ 1. 拓扑排序(Kahn's algorithm,基于 `depends_on`)
90
+ 2. 同层按 `priority` 升序
91
+ 3. 循环依赖 → BLOCK + 报告循环链
92
+
93
+ ## 状态机
94
+
95
+ ```
96
+ PENDING → test_infra_check → [infra needed?] → test_infra_dispatch
97
+ │ │
98
+ │ FAIL (max 2) │ pass
99
+ ▼ ▼
100
+ BLOCK/fallback in_progress → done (commit)
101
+ │ │
102
+ │ depend not met │ all done → COMPLETE
103
+ ▼ ▼
104
+ PENDING (waiting) RETRY (n≤3, 注入错误)
105
+ │
106
+ n≥3 → BLOCKED
107
+ ```
108
+
109
+ **崩溃恢复**:检查 checkpoint → 跳过已 done REQs → 从下一个 pending 继续。
110
+
111
+ ## Retry 策略
112
+
113
+ | 轮次 | 注入上下文 | 超时 |
114
+ |------|-----------|------|
115
+ | 1 | 标准上下文 | 300s |
116
+ | 2 | 标准 + 上次失败摘要 | 300s |
117
+ | 3 | 标准 + 前两次失败 + "请使用不同实现方式" | 300s |
118
+
119
+ ## Mock 边界策略
120
+
121
+ | Mock | No Mock |
122
+ |------|---------|
123
+ | 外部 HTTP API、LLM 调用、第三方平台 | 数据库(真实测试库或 sqlite-in-memory)|
124
+ | 时间/随机数/UUID(注入依赖) | HTTP 路由(app.inject())|
125
+ | — | 模板引擎(真实渲染)|
126
+ | — | 纯业务逻辑(真实输入输出)|
127
+
128
+ Mock 密度上限:mock/spy/fn 行数 > 总测试行 30% → 必须加 `// @mock-justified: <理由>`。
129
+
130
+ ## Learnings 分类
131
+
132
+ | 分类 | 内容 | 传递策略 | 升级条件 |
133
+ |------|------|---------|---------|
134
+ | permanent | 架构决策、接口约定 | 始终传入 | ≥2 REQ 引用 / 涉及接口/数据结构 / 用户手动标记 |
135
+ | contextual | 实现细节、一次性 gotchas | 滑动窗口 (最近 3 条) | 满足 permanent 条件自动升级,否则过期 |
136
+
137
+ ## AGENTS.md 更新机制
138
+
139
+ Orchestrator 统一执行,subagent 输出 `agentmd_addition` 字段,orchestrator append。>500 行触发归档到 `.sprint-state/ralph-loop/agents-archive/`。
140
+
141
+ ## Output Format
142
+
143
+ ```json
144
+ {
145
+ "skill_name": "ralph-loop",
146
+ "version": "2.0.0",
147
+ "requirements": { "total": 6, "done": 4, "pending": 1, "blocked": 1, "skipped": 0 },
148
+ "learnings": {
149
+ "permanent": ["Auth middleware must run before validation"],
150
+ "contextual": ["migration files must be in src/migrations/"]
151
+ },
152
+ "status": "running",
153
+ "checkpoint_at": "2026-05-08T10:30:00Z"
154
+ }
155
+ ```
156
+
157
+ **Eval**: `done + pending + blocked + skipped == total`, `iteration <= max_iterations`.
158
+
159
+ ## Scope
160
+
161
+ **In Scope**:
162
+ - Phase 2 BUILD 的 REQ 级迭代构建
163
+ - 从 specification.yaml 读取需求实现
164
+ - TDD + 全量回归测试
165
+ - Learnings 持久化 + 依赖排序 + 崩溃恢复
166
+
167
+ **Out of Scope**:
168
+ - Phase 0-1 (THINK/PLAN) / Phase 3-6 (REVIEW/SHIP/等)
169
+ - 并行模式(`--mode parallel`)
170
+ - 紧急热修复
171
+ - 非 spec 定义的需求
172
+
173
+ ## Token Savings
174
+
175
+ | REQs | Default | Ralph Loop | Savings |
176
+ |------|---------|-----------|---------|
177
+ | 3 | ~15k | ~9k | 40% |
178
+ | 5 | ~50k | ~25k | 50% |
179
+ | 10 | ~150k | ~50k | 67% |
180
+
181
+ ## Anti-Patterns
182
+
183
+ | ❌ Wrong | ✅ Right |
184
+ |----------|---------|
185
+ | 所有需求一个 REQ | 每个 REQ ≤ 1 context window |
186
+ | 验证失败仍 commit | 不提交 |
187
+ | 只跑当前 REQ 的测试 | 全量回归 |
188
+ | 忽略 depends_on | 拓扑排序 |
189
+ | retry 不注入失败原因 | 每次注入上次错误 |
190
+ | subagent 各自写 AGENTS.md | orchestrator 统一更新 |
191
+
192
+ ## References
193
+
194
+ - [Components](references/components.md) — 系统提示/状态记忆/中间件/技能调用/构建步骤分解
195
+ - [Workflow Details](references/workflow-details.md) — 详细执行步骤 + Output Contract 检查清单
196
+ - [Phase 2 Integration](references/phase-2-build-ralph.md) — Sprint-Flow 集成细节
197
+ - [Progress Log Template](templates/progress-log.md)
198
+ - [Design Doc: ralph-loop v3.0](docs/ralph-loop-design.md)
@@ -0,0 +1,113 @@
1
+ # Ralph Loop 组件分解
2
+
3
+ ## 1. System Prompt — 核心原则
4
+
5
+ | # | 原则 | 说明 |
6
+ |---|------|------|
7
+ | 1 | 逐 REQ 迭代 | 一次处理一个 REQ/切片,干净上下文,避免上下文线性膨胀 |
8
+ | 2 | Token 节约 | 比旧并行模式节约 40-67% token |
9
+ | 3 | 全量回归 | 每个 REQ 完成后跑全量测试 |
10
+ | 4 | 进度持久化 | progress.log 持久化 learnings/permanent/contextual |
11
+ | 5 | 可中断续传 | 中断后可从最后完成 REQ 继续 |
12
+
13
+ ## 2. Memory — 状态与记忆结构
14
+
15
+ ### Progress Log Schema (`progress.log` — YAML)
16
+
17
+ ```yaml
18
+ req_progress:
19
+ completed_count: 3
20
+ total_count: 5
21
+ current_req: REQ-XXX-004
22
+ status: running|completed|blocked
23
+ test_infra_status: generated|existing|skipped|fallback
24
+
25
+ learnings:
26
+ permanent:
27
+ - pattern: "描述持久模式"
28
+ evidence: "来源证据"
29
+ contextual:
30
+ - pattern: "描述当前 REQ 有效模式"
31
+ expires_on: "过期条件"
32
+
33
+ cost:
34
+ req_number: 3
35
+ tokens_used: 15000
36
+ cumulative_tokens: 85000
37
+ threshold: 200000
38
+ ```
39
+
40
+ ### Test Infra Status 字段
41
+
42
+ | 值 | 含义 |
43
+ |---|------|
44
+ | `generated` | 本 REQ 首次生成 test-utils.ts |
45
+ | `existing` | test-utils.ts 已存在且接口完整 |
46
+ | `skipped` | 非首次 REQ,跳过 test-infra 检查 |
47
+ | `fallback` | test-infra dispatch 失败,使用 inline 生成 |
48
+
49
+ ### Learnings 分类
50
+
51
+ | 类型 | 生命周期 | 示例 |
52
+ |------|---------|------|
53
+ | `permanent` | 跨所有 REQ | "项目使用 ESLint strict 模式" |
54
+ | `contextual` | 当前 REQ 内 | "REQ 003 使用 Zod 验证 schema" |
55
+
56
+ ## 3. Middleware — 迭代控制逻辑
57
+
58
+ ### 状态机
59
+
60
+ ```
61
+ REQ N → 加载 learnings → 测试基础设施检查 → [infra missing?] → test_infra_dispatch
62
+ │ │ │
63
+ │ │ infra ready │ FAIL (max 2 retry)
64
+ │ ▼ ▼
65
+ │ TDD → 回归测试 ←───────────── BLOCK/fallback
66
+ │ │
67
+ │ PASS → REQ N+1
68
+ │ FAIL → 重试 (max 3) → BLOCK → 用户决策
69
+ │ ALL_REQS_COMPLETE → 结束,返回控制权给 sprint-flow orchestrator
70
+ ```
71
+
72
+ ### 熔断机制
73
+
74
+ | 触发条件 | 动作 |
75
+ |---------|------|
76
+ | TDD 失败 > 3 次 | BLOCK + 用户决策 |
77
+ | Token 使用超阈值 | BLOCK + 用户决策 |
78
+ | 回归测试失败 | 记录到 progress.log,通知 orchestrator |
79
+ | test-infra dispatch 失败 (max 2 retry) | BLOCK 或 fallback inline 生成 |
80
+
81
+ ## 4. Skill Invocations — 技能调用链
82
+
83
+ | 步骤 | Skill | 参数 |
84
+ |------|-------|------|
85
+ | 0 | 测试基础设施检查 | 检查 test-utils.ts 存在性 + 接口契约 |
86
+ | 1 | `test-driven-development` | `--lang` 注入 + TDD 铁律 + Mock 边界 |
87
+ | 2 | `learn` (gstack) | classification: permanent/contextual |
88
+ | 3 | `requesting-code-review` | REQ 完成后评审 |
89
+
90
+ ### test-infra dispatch 节点
91
+
92
+ 当 test-utils.ts 不存在或接口缺失时:
93
+ ```
94
+ task(category="unspecified-high", load_skills=["test-driven-development"],
95
+ prompt="生成测试基础设施:createTestApp() + withTestDb()。TDD 铁律:先写测试再实现。")
96
+ ```
97
+ - retry max 2 次
98
+ - 仍失败 → BLOCK 或 fallback inline 生成(记录 warning)
99
+ - 成功后与业务代码合并为同一 commit
100
+
101
+ ## 5. Tool Descriptions — 构建步骤
102
+
103
+ | 步骤 | 动作 | 说明 |
104
+ |------|------|------|
105
+ | 1 | 加载当前 REQ | 从 specification.yaml 获取下一个 READY REQ |
106
+ | 2 | 加载 learnings | 从 progress.log 加载 permanent + contextual learnings |
107
+ | 3 | 测试基础设施检查 | 检查 test-utils.ts。不存在 → dispatch, retry max 2 |
108
+ | 4 | TDD (RED→GREEN→REFACTOR) | test-driven-development skill |
109
+ | 5 | 全量回归测试 | 运行全部现有测试 |
110
+ | 6 | 测试先行比率检查 (L1b) | 新增测试行数 / 总新增行数 ≥ 40% |
111
+ | 7 | 记录 progress.log | learnings 分类存储 |
112
+ | 8 | 成本检查 | token 使用量是否超阈值 |
113
+ | 9 | 完成/继续 | 所有 REQ 完成 → 结束;否则 → 下一个 |