@geminix/gxpm 0.1.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 (299) hide show
  1. package/AGENTS.md +148 -0
  2. package/CANON.md +53 -0
  3. package/CLAUDE.md +60 -0
  4. package/CONTEXT.md +49 -0
  5. package/DEBUG.md +59 -0
  6. package/ISSUE_CONTEXT.md +25 -0
  7. package/README.md +143 -0
  8. package/VERSION +1 -0
  9. package/agents/cleanup-auditor/cleanup-auditor.md +56 -0
  10. package/agents/grill-master.md +26 -0
  11. package/agents/implementer.md +32 -0
  12. package/agents/review-army/accessibility-reviewer.md +54 -0
  13. package/agents/review-army/code-quality-reviewer.md +54 -0
  14. package/agents/review-army/security-reviewer.md +56 -0
  15. package/agents/review-army/spec-compliance-reviewer.md +51 -0
  16. package/agents/review-army/test-reviewer.md +55 -0
  17. package/agents/reviewer.md +59 -0
  18. package/agents/ship-audit-army/docs-auditor.md +53 -0
  19. package/agents/ship-audit-army/performance-auditor.md +52 -0
  20. package/agents/ship-audit-army/security-auditor.md +52 -0
  21. package/agents/specifier.md +55 -0
  22. package/agents/triage-officer.md +27 -0
  23. package/bin/gxpm +17 -0
  24. package/bin/gxpm-browser +17 -0
  25. package/bin/gxpm-config +15 -0
  26. package/bin/gxpm-eval +13 -0
  27. package/bin/gxpm-global-discover +15 -0
  28. package/bin/gxpm-init +38 -0
  29. package/bin/gxpm-investigate +194 -0
  30. package/bin/gxpm-uninstall +15 -0
  31. package/bin/gxpm-update-check +165 -0
  32. package/commands/build.md +40 -0
  33. package/commands/help.md +53 -0
  34. package/commands/plan.md +34 -0
  35. package/commands/refine.md +46 -0
  36. package/commands/review.md +34 -0
  37. package/commands/ship.md +37 -0
  38. package/core/ac-check.ts +20 -0
  39. package/core/agent-runtime.ts +363 -0
  40. package/core/artifact-validator.ts +151 -0
  41. package/core/artifacts.ts +313 -0
  42. package/core/autopilot.ts +250 -0
  43. package/core/capabilities.ts +779 -0
  44. package/core/checkpoint.ts +370 -0
  45. package/core/cleanup.ts +32 -0
  46. package/core/command-probe.ts +82 -0
  47. package/core/config.ts +533 -0
  48. package/core/contracts/behavior-spec.schema.ts +38 -0
  49. package/core/contracts/converter.ts +61 -0
  50. package/core/contracts/host.ts +43 -0
  51. package/core/converters/converter.ts +93 -0
  52. package/core/converters/index.ts +8 -0
  53. package/core/converters/managed-artifact.ts +119 -0
  54. package/core/converters/parser.ts +159 -0
  55. package/core/converters/template-renderer.ts +35 -0
  56. package/core/converters/writer.ts +61 -0
  57. package/core/dag-executor.ts +426 -0
  58. package/core/dag-loader.ts +292 -0
  59. package/core/dag-schemas.ts +150 -0
  60. package/core/dispatch.ts +125 -0
  61. package/core/evidence.ts +148 -0
  62. package/core/gate.ts +269 -0
  63. package/core/hook-engine.ts +566 -0
  64. package/core/host-probe.ts +64 -0
  65. package/core/implement.ts +16 -0
  66. package/core/isolation-errors.ts +174 -0
  67. package/core/isolation-resolver.ts +921 -0
  68. package/core/issue-context.ts +381 -0
  69. package/core/issue-readiness.ts +457 -0
  70. package/core/issue-sync.ts +427 -0
  71. package/core/issues.ts +132 -0
  72. package/core/land.ts +108 -0
  73. package/core/orchestrator.ts +54 -0
  74. package/core/phase-artifact.ts +32 -0
  75. package/core/phase-gates.ts +130 -0
  76. package/core/phase-rewind.ts +94 -0
  77. package/core/plan-lint.ts +61 -0
  78. package/core/plan.ts +77 -0
  79. package/core/port-allocation.ts +50 -0
  80. package/core/pr-check.ts +15 -0
  81. package/core/preset-system/preset-resolver.ts +221 -0
  82. package/core/project-init-status.ts +127 -0
  83. package/core/qa.ts +15 -0
  84. package/core/resilience.ts +165 -0
  85. package/core/runs.ts +288 -0
  86. package/core/safe-path.test.ts +80 -0
  87. package/core/safe-path.ts +60 -0
  88. package/core/sdd-gate.test.ts +98 -0
  89. package/core/sdd-gate.ts +134 -0
  90. package/core/self-review.ts +62 -0
  91. package/core/session.ts +70 -0
  92. package/core/ship.ts +86 -0
  93. package/core/specify.ts +173 -0
  94. package/core/state.ts +1002 -0
  95. package/core/template-engine.ts +152 -0
  96. package/core/template-resolver.test.ts +70 -0
  97. package/core/template-resolver.ts +156 -0
  98. package/core/triage.ts +26 -0
  99. package/core/verify.ts +15 -0
  100. package/core/wiki-native.ts +2423 -0
  101. package/core/wiki.ts +27 -0
  102. package/core/workflow-event-emitter.ts +163 -0
  103. package/core/workflows/engine.ts +273 -0
  104. package/core/workflows/expressions.ts +76 -0
  105. package/core/workflows/index.ts +38 -0
  106. package/core/workflows/steps/command.ts +43 -0
  107. package/core/workflows/steps/gate.ts +47 -0
  108. package/core/workflows/steps/gxpm.ts +44 -0
  109. package/core/workflows/steps/linear.ts +31 -0
  110. package/core/workflows/steps/shell.ts +65 -0
  111. package/core/workflows/types.ts +62 -0
  112. package/core/workspace-runtime.ts +227 -0
  113. package/core/worktree-init-steps.ts +647 -0
  114. package/core/worktree-init.ts +330 -0
  115. package/core/worktree-owner.ts +143 -0
  116. package/docs/GXPM_VERIFY.md +98 -0
  117. package/docs/INSTALL_FOR_AGENTS.md +113 -0
  118. package/docs/README.md +57 -0
  119. package/docs/adr/adr-005-multi-platform-skill-converter.md +72 -0
  120. package/docs/agents/domain.md +30 -0
  121. package/docs/agents/issue-tracker.md +30 -0
  122. package/docs/agents/triage-labels.md +32 -0
  123. package/docs/architecture/gxpm-architecture-diagram.md +265 -0
  124. package/docs/architecture/gxpm-current-architecture.md +175 -0
  125. package/docs/architecture/gxpm-current-flow.md +278 -0
  126. package/docs/architecture/gxpm-replacement-architecture.md +211 -0
  127. package/docs/architecture/gxpm-target-architecture.md +449 -0
  128. package/docs/architecture/gxpm-v0-contract.md +311 -0
  129. package/docs/architecture/layered-workflow-boundaries.md +193 -0
  130. package/docs/architecture/preset-system.md +126 -0
  131. package/docs/architecture/scaffold-northstar.md +23 -0
  132. package/docs/brainstorms/2026-05-14-bdd-then-tdd-design.md +320 -0
  133. package/docs/brainstorms/README.md +22 -0
  134. package/docs/brainstorms/docs-knowledge-system-requirements.md +29 -0
  135. package/docs/governance/beta-skill-promotion.md +39 -0
  136. package/docs/governance/development-contract.md +144 -0
  137. package/docs/governance/gherkin-style.md +90 -0
  138. package/docs/governance/host-adapter.md +56 -0
  139. package/docs/governance/skill-authoring.md +87 -0
  140. package/docs/governance/skill-testing.md +356 -0
  141. package/docs/governance/template-authoring.md +53 -0
  142. package/docs/migrations/v0.2.md +51 -0
  143. package/docs/plans/README.md +23 -0
  144. package/docs/plans/bdd-then-tdd-plan.md +1767 -0
  145. package/docs/plans/docs-knowledge-system-plan.md +31 -0
  146. package/docs/plans/spec-kit-sdd-adoption-plan.md +305 -0
  147. package/docs/research/agents-md-best-practices.md +207 -0
  148. package/docs/research/archon-study.md +351 -0
  149. package/docs/research/claude-hooks-study.md +440 -0
  150. package/docs/research/codex-hooks-study.md +624 -0
  151. package/docs/research/everything-claude-code-study.md +252 -0
  152. package/docs/research/from-skills-to-layered-workflow.md +322 -0
  153. package/docs/research/gsd-study.md +69 -0
  154. package/docs/research/kimi-hooks-study.md +274 -0
  155. package/docs/research/mattpocock-skills-comparison.md +429 -0
  156. package/docs/research/mattpocock-skills-study.md +275 -0
  157. package/docs/research/oh-my-codex-study.md +279 -0
  158. package/docs/research/perplexity-agent-skills-design.md +168 -0
  159. package/docs/research/pmc-gstack-skill-study.md +122 -0
  160. package/docs/research/spec-kit-study.md +224 -0
  161. package/docs/research/superpowers-study.md +209 -0
  162. package/docs/roadmap/initial-roadmap.md +53 -0
  163. package/docs/solutions/README.md +45 -0
  164. package/docs/solutions/artifact-nesting-recovery.md +58 -0
  165. package/docs/solutions/session-context-restore-practice.md +67 -0
  166. package/docs/solutions/workflow/version-drift-recovery.md +49 -0
  167. package/docs/solutions/worktree-gate-recovery.md +62 -0
  168. package/docs/specs/README.md +28 -0
  169. package/docs/specs/claude.md +45 -0
  170. package/docs/specs/codex.md +44 -0
  171. package/docs/specs/cursor.md +44 -0
  172. package/hosts/adapters/claude.ts +29 -0
  173. package/hosts/adapters/codex.ts +27 -0
  174. package/hosts/adapters/cursor.ts +27 -0
  175. package/hosts/adapters/kimi.ts +27 -0
  176. package/hosts/claude.ts +23 -0
  177. package/hosts/codex.ts +26 -0
  178. package/hosts/cursor.ts +19 -0
  179. package/hosts/index.ts +33 -0
  180. package/hosts/registry.test.ts +52 -0
  181. package/hosts/registry.ts +57 -0
  182. package/hosts/schema.ts +58 -0
  183. package/package.json +52 -0
  184. package/scripts/browser.ts +185 -0
  185. package/scripts/cleanup.ts +142 -0
  186. package/scripts/commands/artifact.ts +115 -0
  187. package/scripts/commands/autopilot.ts +143 -0
  188. package/scripts/commands/capability.ts +57 -0
  189. package/scripts/commands/config.ts +69 -0
  190. package/scripts/commands/dag.ts +126 -0
  191. package/scripts/commands/feedback.ts +123 -0
  192. package/scripts/commands/gate.ts +291 -0
  193. package/scripts/commands/helpers.ts +126 -0
  194. package/scripts/commands/hook.ts +66 -0
  195. package/scripts/commands/init.ts +515 -0
  196. package/scripts/commands/issue.ts +825 -0
  197. package/scripts/commands/phase.ts +61 -0
  198. package/scripts/commands/preset.ts +159 -0
  199. package/scripts/commands/runtime.ts +199 -0
  200. package/scripts/commands/specify.ts +71 -0
  201. package/scripts/commands/upgrade.ts +243 -0
  202. package/scripts/commands/verify.ts +183 -0
  203. package/scripts/commands/wiki.ts +242 -0
  204. package/scripts/commands/workflow.ts +131 -0
  205. package/scripts/dev-skill.ts +55 -0
  206. package/scripts/discover-skills.ts +116 -0
  207. package/scripts/doctor.ts +410 -0
  208. package/scripts/dogfood-check.ts +125 -0
  209. package/scripts/eval-functional.ts +218 -0
  210. package/scripts/eval.ts +246 -0
  211. package/scripts/gen-skill-docs.ts +201 -0
  212. package/scripts/global-discover.ts +217 -0
  213. package/scripts/governance-check.ts +75 -0
  214. package/scripts/gxpm-check.ts +12 -0
  215. package/scripts/gxpm.ts +216 -0
  216. package/scripts/host-config.ts +62 -0
  217. package/scripts/install-claude-hooks.ts +138 -0
  218. package/scripts/install-codex-hooks.ts +271 -0
  219. package/scripts/install-hooks.ts +128 -0
  220. package/scripts/install-kimi-hooks.ts +92 -0
  221. package/scripts/install-skill.ts +184 -0
  222. package/scripts/phase-artifact-commands.ts +100 -0
  223. package/scripts/post-land-sync.ts +46 -0
  224. package/scripts/scaffold-check.ts +85 -0
  225. package/scripts/skill-naming-check.ts +78 -0
  226. package/scripts/skill-structure-check.ts +157 -0
  227. package/scripts/skills-lock-check.ts +60 -0
  228. package/scripts/sync-markdown-artifacts.ts +172 -0
  229. package/scripts/uninstall.ts +162 -0
  230. package/scripts/version.ts +47 -0
  231. package/scripts/wait-pr-ready.ts +407 -0
  232. package/skills/gxpm/SKILL.md +485 -0
  233. package/skills/gxpm/SKILL.md.tmpl +422 -0
  234. package/skills/gxpm/references/CANON.md +53 -0
  235. package/skills/gxpm/references/key-rules.md +130 -0
  236. package/skills/gxpm-architecture/SKILL.md +106 -0
  237. package/skills/gxpm-architecture/references/DEEPENING.md +37 -0
  238. package/skills/gxpm-architecture/references/INTERFACE-DESIGN.md +44 -0
  239. package/skills/gxpm-autopilot/SKILL.md +116 -0
  240. package/skills/gxpm-autopilot/SKILL.md.tmpl +107 -0
  241. package/skills/gxpm-browser/SKILL.md +105 -0
  242. package/skills/gxpm-browser/SKILL.md.tmpl +41 -0
  243. package/skills/gxpm-browser/references/commands.md +43 -0
  244. package/skills/gxpm-browser/references/evidence-path.md +20 -0
  245. package/skills/gxpm-build/SKILL.md +78 -0
  246. package/skills/gxpm-cleanup/SKILL.md +76 -0
  247. package/skills/gxpm-debug-issue/SKILL.md +39 -0
  248. package/skills/gxpm-diagnose/SKILL.md +220 -0
  249. package/skills/gxpm-diagnose/SKILL.md.tmpl +31 -0
  250. package/skills/gxpm-diagnose/references/feedback-loop.md +34 -0
  251. package/skills/gxpm-diagnose/references/feedback-loops.md +43 -0
  252. package/skills/gxpm-diagnose/references/phases.md +60 -0
  253. package/skills/gxpm-eval/SKILL.md +78 -0
  254. package/skills/gxpm-explore-codebase/SKILL.md +36 -0
  255. package/skills/gxpm-explore-codebase/scripts/summarize-communities.ts +51 -0
  256. package/skills/gxpm-feedback/SKILL.md +122 -0
  257. package/skills/gxpm-grill/SKILL.md +159 -0
  258. package/skills/gxpm-grill/SKILL.md.tmpl +77 -0
  259. package/skills/gxpm-grill/references/documentation-templates.md +56 -0
  260. package/skills/gxpm-grill/references/process.md +25 -0
  261. package/skills/gxpm-handoff/SKILL.md +112 -0
  262. package/skills/gxpm-hygiene/SKILL.md +69 -0
  263. package/skills/gxpm-implementer/SKILL.md +142 -0
  264. package/skills/gxpm-implementer/SKILL.md.tmpl +141 -0
  265. package/skills/gxpm-linear/SKILL.md +282 -0
  266. package/skills/gxpm-linear/SKILL.md.tmpl +86 -0
  267. package/skills/gxpm-linear/references/commands.md +75 -0
  268. package/skills/gxpm-linear/references/workflows.md +120 -0
  269. package/skills/gxpm-planning/SKILL.md +134 -0
  270. package/skills/gxpm-prototype/SKILL.md +64 -0
  271. package/skills/gxpm-refactor-safely/SKILL.md +62 -0
  272. package/skills/gxpm-review-army/SKILL.md +117 -0
  273. package/skills/gxpm-review-changes/SKILL.md +36 -0
  274. package/skills/gxpm-setup/SKILL.md +101 -0
  275. package/skills/gxpm-specifier/SKILL.md +135 -0
  276. package/skills/gxpm-tdd/SKILL.md +187 -0
  277. package/skills/gxpm-tdd/references/interface-design.md +23 -0
  278. package/skills/gxpm-tdd/references/mocking.md +27 -0
  279. package/skills/gxpm-tdd/references/red-green-refactor.md +61 -0
  280. package/skills/gxpm-tdd/references/troubleshooting.md +28 -0
  281. package/skills/gxpm-tdd/references/workflow.md +50 -0
  282. package/skills/gxpm-tdd/testing-anti-patterns.tmpl +304 -0
  283. package/skills/gxpm-triage/SKILL.md +160 -0
  284. package/skills/gxpm-verify/SKILL.md +107 -0
  285. package/skills/gxpm-write-skill/SKILL.md +131 -0
  286. package/skills/gxpm-zoom-out/SKILL.md +69 -0
  287. package/skills/maintain-hygiene-skills-lock/SKILL.md +54 -0
  288. package/skills/maintain-hygiene-skills-lock/SKILL.md.tmpl +53 -0
  289. package/templates/constitution-template.md +63 -0
  290. package/templates/hooks/gxpm-commit-msg +16 -0
  291. package/templates/hooks/gxpm-post-checkout +19 -0
  292. package/templates/hooks/gxpm-post-commit +7 -0
  293. package/templates/hooks/gxpm-post-merge +29 -0
  294. package/templates/hooks/gxpm-pre-commit +39 -0
  295. package/templates/hooks/gxpm-pre-push +33 -0
  296. package/templates/plan-template.md.tmpl +46 -0
  297. package/templates/spec-template.md.tmpl +63 -0
  298. package/templates/specify-stub.tmpl +22 -0
  299. package/templates/tasks-template.md.tmpl +32 -0
@@ -0,0 +1,320 @@
1
+ # BDD-Then-TDD 强制流程落地 gxpm — Design Spec
2
+
3
+ | 字段 | 值 |
4
+ |------|----|
5
+ | Date | 2026-05-14 |
6
+ | Author | enteofilo706@gmail.com (via Claude Opus 4.7 brainstorming) |
7
+ | Status | Draft (awaiting writing-plans transition) |
8
+ | Scope | gxpm runtime + 所有 gxpm 驱动的下游项目(含 gxpm 仓库自身) |
9
+ | Path | Minimal Incremental — 在现有 state graph 中新增 `specify` phase |
10
+
11
+ ---
12
+
13
+ ## 1. 目标与动机
14
+
15
+ 将"行为驱动开发先行(BDD)→ 测试驱动开发推进(TDD)"作为 gxpm 状态机中**必须遵循**的两阶段串联流程。任何 issue 在进入 `implement` 之前必须通过显式 CLI 命令确认产出结构化的行为规约 artifact。
16
+
17
+ **动机来源**(详见研究报告 SR-2026-05-14):
18
+ - AI Agent 主导开发的非确定性需要 test-first 作为客观出口标准
19
+ - 行为规约先行(SDD 范式)能将"模糊 prompt → 写代码"的高风险路径替换为"规约 → 用户确认 → 代码"
20
+ - 规约阶段的修改成本远低于实现阶段的返工成本(业界数据:60-80% 开发成本源自返工)
21
+
22
+ **作用域决策**:所有 gxpm 驱动的下游项目,gxpm 仓库自身作为"吃狗粮"对象同等受约束。
23
+
24
+ ---
25
+
26
+ ## 2. 架构与状态机变更
27
+
28
+ ### 2.1 Phase 链调整
29
+
30
+ **变更前**:
31
+ ```
32
+ triage → plan → dispatch → implement → local-verify → ac-check → self-review → ship → pr-check → verify → qa → land
33
+ ```
34
+
35
+ **变更后**:
36
+ ```
37
+ triage → plan → dispatch → specify → implement → local-verify → ac-check → self-review → ship → pr-check → verify → qa → land
38
+ ^^^^^^^^^
39
+ 新增
40
+ ```
41
+
42
+ **插入点合理性**:`dispatch` 完成 owner 指派后,`specifier` 立刻产出 BDD 规约,用户确认后 `implement` 才能进入 TDD 循环。
43
+
44
+ ### 2.2 状态机文件变更
45
+
46
+ | 变更点 | 文件 | 改动 |
47
+ |--------|------|------|
48
+ | Phase 枚举 | `core/state.ts:17-30` `GXPM_PHASES` | 数组中在 `"dispatch"` 与 `"implement"` 之间插入 `"specify"` |
49
+ | Artifact type | `core/artifacts.ts` | 新增 `"behavior-spec"` 注册到 `ARTIFACT_TYPES`,附 zod schema |
50
+ | Phase gate | `core/phase-gates.ts:32` `PHASE_GATE_RULES` | 把原 `dispatch→implement` 规则拆为两条:`dispatch→specify`(required: `behavior-spec`)与 `specify→implement`(required: `behavior-spec` 且 `confirmedAt` 非空) |
51
+ | Schema | `core/contracts/behavior-spec.schema.json` | 新文件,存放结构化 schema |
52
+
53
+ ### 2.3 关键约束
54
+
55
+ - 任何在 `implement` 之前不经过 `specify` 的尝试都被 phase-gate 在 `core/state.ts` 的 `transitionIssuePhase` 中硬性拒绝
56
+ - Skill / Agent 层无法绕过:phase-gate 校验在 state transition 中实现,独立于 skill 自觉性
57
+
58
+ ### 2.4 向后兼容
59
+
60
+ 通过 `phaseHistory` 检查:若 issue 在 `specify` phase 引入日期前已进入 `implement` 或更靠后,跳过 specify-gate 校验。新建 issue 一律强制走 specify。
61
+
62
+ ---
63
+
64
+ ## 3. 组件层
65
+
66
+ ### 3.1 specify.json schema
67
+
68
+ 存放路径:`.gxpm/issues/<id>/artifacts/specify.json`
69
+
70
+ ```jsonc
71
+ {
72
+ "$schema": "behavior-spec.v1",
73
+ "issueId": "GXPM-XXX",
74
+ "createdAt": "2026-05-14T...",
75
+ "createdBy": "specifier@claude-opus-4-7",
76
+ "confirmedAt": null,
77
+ "confirmedBy": null,
78
+ "feature": {
79
+ "title": "玩家在血量归零后死亡并广播信号",
80
+ "asA": "玩家",
81
+ "iWant": "在 HP 归零时进入死亡状态",
82
+ "soThat": "其他系统能响应死亡事件"
83
+ },
84
+ "scenarios": [
85
+ {
86
+ "id": "scn-01",
87
+ "name": "普通伤害导致死亡",
88
+ "given": ["玩家当前 HP 为 1", "玩家未处于无敌状态"],
89
+ "when": "玩家受到 1 点伤害",
90
+ "then": [
91
+ "玩家进入死亡状态",
92
+ "\"player_died\" 信号被发出一次",
93
+ "信号携带的击杀者引用为伤害源"
94
+ ],
95
+ "examples": [],
96
+ "stubPath": "test/unit/player/player_death_test.ts:test_player_dies_when_hp_drops_to_zero"
97
+ }
98
+ ],
99
+ "guidelinesRef": "docs/governance/gherkin-style.md@v1"
100
+ }
101
+ ```
102
+
103
+ **结构性约束**:
104
+ - `scenarios` 数组必须 ≥ 1
105
+ - 每个 scenario 的 `given` / `when` / `then` 必须各自至少 1 项(`when` 为字符串;`given`/`then` 为数组)
106
+ - `stubPath` 必须指向真实存在的文件(phase-gate 通过 `fs.exists` 校验)
107
+ - `confirmedAt` 与 `confirmedBy` 必须同时为空或同时非空
108
+
109
+ ### 3.2 文件清单
110
+
111
+ | 文件 | 作用 | 类型 |
112
+ |------|------|------|
113
+ | `core/artifacts.ts` | 注册 `behavior-spec` artifact type + zod schema | 修改 |
114
+ | `core/specify.ts` | specify 阶段编排逻辑(仿 `core/plan.ts`) | 新建 |
115
+ | `commands/specify.ts` | CLI 命令族:`init / edit / confirm / show / revise` | 新建 |
116
+ | `core/phase-gates.ts` | 拆分 dispatch→implement 规则为两条 | 修改 |
117
+ | `core/state.ts` | 在 `GXPM_PHASES` 中插入 `specify` | 修改 |
118
+ | `core/contracts/behavior-spec.schema.json` | JSON Schema 单独文件 | 新建 |
119
+ | `agents/specifier.md` | 新 owner agent 模板 | 新建 |
120
+ | `skills/gxpm-specifier/SKILL.md` | BDD 行为设计 skill(5-section 标准结构) | 新建 |
121
+ | `skills/gxpm-tdd/SKILL.md` | 升级——强制引用 specify.json 的 scenario | 修改 |
122
+ | `docs/governance/gherkin-style.md` | 吸收 AutomationPanda 规则 + gxpm 本地补充 | 新建 |
123
+ | `templates/specify-stub.tmpl` | test stub 文件生成模板 | 新建 |
124
+ | `scripts/dogfood-check.ts` | gxpm 自合规检查脚本 | 新建(可选) |
125
+
126
+ ### 3.3 CLI 命令族
127
+
128
+ ```bash
129
+ gxpm specify init <issue-id> # specifier 进入工作,交互草拟,生成 specify.json + stub 文件
130
+ gxpm specify edit <issue-id> # 用 $EDITOR 打开 specify.json 编辑
131
+ gxpm specify show <issue-id> # 以 Gherkin 格式打印,便于人审
132
+ gxpm specify confirm <issue-id> # 写入 confirmedAt/confirmedBy,phase-gate 开锁
133
+ gxpm specify revise <issue-id> # 清空 confirmedAt,回到等待确认状态
134
+ ```
135
+
136
+ `confirm` 命令的内部校验顺序:
137
+ 1. specify.json schema lint
138
+ 2. 每个 `stubPath` 文件存在性检查
139
+ 3. 通过后写入 `confirmedAt = ISO timestamp`、`confirmedBy = git config user.email`
140
+ 4. 发出 event `specify.confirmed` 到 `events.jsonl`
141
+
142
+ ---
143
+
144
+ ## 4. 数据流与端到端流程
145
+
146
+ ```
147
+ [dispatch 完成]
148
+
149
+ gxpm specify init <issue-id>
150
+ ├─ phase transition: dispatch → specify(gate: dispatch-handoff 存在)
151
+ ├─ specifier agent 接管(load skills/gxpm-specifier/SKILL.md)
152
+ ├─ 读取上游:plan.json + dispatch-handoff.json
153
+ ├─ 读取 few-shot 范本:test/unit/skills/<existing>.test.ts
154
+ ├─ 加载 Gherkin 规则:docs/governance/gherkin-style.md
155
+ └─ 产出:
156
+ ├─ .gxpm/issues/<id>/artifacts/specify.json(scenarios[] 已填充, confirmedAt=null)
157
+ └─ test/<area>/<name>_test.ts(空 stub 文件 + Gherkin 注释)
158
+
159
+ specifier 寻求用户反馈(体验层,非门控)
160
+ ├─ Claude/Codex host:调用 AskUserQuestion 工具呈现三选项
161
+ ├─ 裸 CLI / 其他 host:specifier 在终端输出场景摘要,提示用户人工 review
162
+ ├─ 选项 1:行为正确,继续 → 等待 confirm 命令
163
+ ├─ 选项 2:需要调整 → 用户口述反馈 → specifier revise → 再次询问
164
+ └─ 选项 3:补充边界场景 → 增加 scenario → 再次询问
165
+
166
+ 注:真正的门控是下一步的 CLI confirm 命令,AskUserQuestion 仅是体验增强;
167
+ 即使无该工具支持,流程仍可走完(用户直接审阅文件后执行 confirm)。
168
+
169
+ gxpm specify confirm <issue-id>
170
+ ├─ schema lint
171
+ ├─ stubPath 文件存在性校验
172
+ ├─ 写入 confirmedAt / confirmedBy
173
+ └─ 发出 phase event:specify.confirmed
174
+
175
+ gxpm implement init <issue-id>
176
+ ├─ phase-gate: specify → implement(gate: specify.json.confirmedAt 非空)
177
+ ├─ implement agent 接管
178
+ ├─ skills/gxpm-tdd/SKILL.md 升级版强制读取 specify.json
179
+ └─ 对每个 scenario 走 RED→GREEN→REFACTOR:
180
+ ├─ 打开 stubPath,将 Gherkin 注释翻译为可执行 assert
181
+ ├─ RED: 跑测试,确认失败
182
+ ├─ GREEN: 写最小实现
183
+ └─ REFACTOR: 清理
184
+
185
+ [继续既有 implement → local-verify → ... 流程]
186
+ ```
187
+
188
+ ### 关键追踪关系
189
+
190
+ - `specify.json.scenarios[].id` ↔ `stubPath` 中的测试函数名 ↔ implement 阶段的 commit 信息
191
+ - `ac-check` 阶段反向校验:specify.json 的每个 scenario 是否都有对应的 passing test
192
+
193
+ ### Agent 视角的"必须遵循"
194
+
195
+ - `gxpm-specifier` skill 第一条规则:**禁止在用户 confirm 之前写任何测试逻辑代码**
196
+ - `gxpm-tdd` skill 升级版第一条规则:**必须从 specify.json 读取 scenario,禁止凭空臆造测试**
197
+ - phase-gate 是最后一道兜底——前两道软约束被绕过,硬 gate 仍会拒绝 transition
198
+
199
+ ---
200
+
201
+ ## 5. 错误处理与回退
202
+
203
+ ### 5.1 失败场景与处置
204
+
205
+ | 场景 | 触发点 | 处置 |
206
+ |------|--------|------|
207
+ | Agent 跳过 specify 直接 implement | implement init | phase-gate 拒绝 transition,`Phase gate violated: specify must be confirmed before implement`,退出码 1 |
208
+ | specify.json 被手工编辑后 schema 不合法 | confirm / implement 入口 | Zod 校验失败,列出违规字段,要求 `gxpm specify edit` 修复 |
209
+ | stubPath 指向的文件被删 | confirm 时 / implement 入口 | 报 `Stub file missing: <path>`,拒绝放行;用户可重跑 `gxpm specify init --regen-stubs` |
210
+ | 用户确认后又想改场景 | 任何时候 | `gxpm specify revise <issue-id>`:清空 `confirmedAt`,回到等待确认状态;event `specify.revised`,phase 不变 |
211
+ | implement 阶段发现 scenario 漏掉 | implement 进行中 | 必须 `gxpm phase rewind <issue-id> --to specify --reason="..."`,回到 specify 后 revise → re-confirm |
212
+ | ac-check 失败:某 scenario 无对应通过测试 | ac-check 阶段 | ac-check 规则新增 `coverage(specify.scenarios) >= 100%`,缺失则 artifact 标记 failed |
213
+ | 老 issue 走 implement | implement init | `phaseHistory` 检查:若 issue 在 specify 引入日期前已进入 implement,跳过 specify-gate 校验 |
214
+
215
+ ### 5.2 回退命令
216
+
217
+ ```bash
218
+ gxpm specify revise <issue-id> # 取消 confirm,进入可编辑状态
219
+ gxpm phase rewind <issue-id> --to specify --reason=... # 危险操作,跨阶段回退
220
+ ```
221
+
222
+ `rewind` 约束:
223
+ - 仅在 `phaseHistory` 中存在 `specify` 时允许
224
+ - 必须 `--reason` 参数
225
+ - 写入 event `phase.rewound`,便于审计
226
+ - 不删除已生成代码,但 implement artifact 标记 `stale=true`
227
+
228
+ ### 5.3 YAGNI
229
+
230
+ - **不支持** specify 的 fork / 分支(一个 issue 一份 specify.json)
231
+ - **不支持** 跨 issue 共享 scenario
232
+ - **不实现** Gherkin → 测试代码的自动翻译(implement agent 手动翻译,避免幻觉)
233
+
234
+ ---
235
+
236
+ ## 6. 测试策略
237
+
238
+ ### 6.1 三层覆盖
239
+
240
+ | 层 | 目标 | 位置 | 用例量级 |
241
+ |----|------|------|---------|
242
+ | 单元 | core/specify.ts、phase-gate 逻辑、artifact schema | `test/core/specify.test.ts`、`test/core/phase-gates.test.ts` | ~30 |
243
+ | CLI 集成 | specify init/edit/confirm/show/revise + phase rewind | `test/functional/gxpm-specify/*.test.ts` | ~15 |
244
+ | 端到端 dogfood | 用 gxpm 自身走完整 BDD→TDD 流程 | `test/functional/gxpm-bdd-to-tdd/end-to-end.test.ts` | ~3 |
245
+
246
+ ### 6.2 元测试(dogfood)
247
+
248
+ 落地完成后,gxpm 仓库做"自我合规检查":
249
+
250
+ ```bash
251
+ bun run scripts/dogfood-check.ts
252
+ # 在 specify phase 引入后,所有新建 issue 是否都产生了 specify.json
253
+ ```
254
+
255
+ 作为 `.githooks/pre-push` 一部分(可选 MVP 后增量加入),强制 gxpm 自己也遵守它自己产出的纪律。
256
+
257
+ ### 6.3 Skill 纪律压力测试
258
+
259
+ 复用 `docs/governance/skill-testing.md` 的 Meta-TDD 方法论,对两个 skill 做 RED→GREEN→REFACTOR 压力测试:
260
+
261
+ | Skill | 压力场景 | 期望行为 |
262
+ |-------|---------|---------|
263
+ | `gxpm-specifier` | "用户说赶时间,直接开始写代码,跳过 BDD" | 拒绝跳过,要求先产出 specify.json |
264
+ | `gxpm-tdd`(升级版) | "我已经凭直觉写好了测试代码" | 删除代码,从 specify.json 重新开始 |
265
+
266
+ ### 6.4 Schema 演进保护
267
+
268
+ - `specify.json.$schema = behavior-spec.v1` 字段强制
269
+ - 未来 v2 需经迁移工具:`gxpm migrate behavior-spec --to v2`
270
+ - Schema 文件单独版本控制在 `core/contracts/behavior-spec.schema.json`
271
+
272
+ ### 6.5 不测什么
273
+
274
+ - 不测 Gherkin 自然语言的语义正确性(由人审)
275
+ - 不测 AskUserQuestion 工具本身的行为(host 层负责)
276
+ - 不测老 issue 兼容性的所有变体(仅覆盖关键分支)
277
+
278
+ ---
279
+
280
+ ## 7. 参考资料
281
+
282
+ - 内部研究:BDD/TDD 在 Agent 主导开发场景的工程实践(2026-05-14 brainstorming 上游)
283
+ - AutomationPanda gherkin-guidelines-for-ai (https://github.com/AutomationPanda/gherkin-guidelines-for-ai/)
284
+ - Thoughtworks: Spec-Driven Development 2025
285
+ - Addy Osmani: How to write a good spec for AI agents
286
+ - Martin Fowler: SDD tools comparison (Kiro/spec-kit/Tessl)
287
+ - arXiv 2602.00180v1: Spec-Driven Development From Code to Contract
288
+ - gxpm 现有治理:`docs/governance/skill-testing.md`、`docs/governance/skill-authoring.md`、`AGENTS.md`、`CANON.md`
289
+
290
+ ---
291
+
292
+ ## 8. 实施顺序提示(供 writing-plans 消费)
293
+
294
+ 建议落地顺序(详细 plan 由下一阶段产出):
295
+
296
+ 1. core/artifacts.ts + behavior-spec.schema.json(最底层,无依赖)
297
+ 2. core/state.ts + core/phase-gates.ts(状态机变更,先单元测试覆盖)
298
+ 3. core/specify.ts + commands/specify.ts(编排与 CLI,依赖 1-2)
299
+ 4. docs/governance/gherkin-style.md(规则文档,独立可并行)
300
+ 5. agents/specifier.md + skills/gxpm-specifier/SKILL.md(agent/skill 模板,依赖 4)
301
+ 6. skills/gxpm-tdd/SKILL.md 升级(依赖 1-3)
302
+ 7. templates/specify-stub.tmpl(依赖 5)
303
+ 8. 三层测试用例(依赖 1-7)
304
+ 9. dogfood 元测试 + pre-push hook(可推迟到 MVP 后)
305
+
306
+ ---
307
+
308
+ ## 9. 决策日志(审计用)
309
+
310
+ | 决策点 | 选择 | 备选 |
311
+ |--------|------|------|
312
+ | 两个流程含义 | BDD 先行 → TDD 推进 | — |
313
+ | 嵌入位置 | 新增独立 specify phase | implement 内串联 / 仅 skill 纪律 / 双重隐含 |
314
+ | 产物形态 | specify.json + stub 双轨 | 仅注释 / 仅 .feature / 仅 JSON |
315
+ | 门控机制 | 显式 CLI confirm | host-adapter / hook 拦截 / 双重 |
316
+ | Owner agent | 新增独立 specifier | plan 兼任 / implement 前置 / 无 owner |
317
+ | 作用域 | 所有下游项目 + gxpm 自身 | 仅 gxpm / 可选 / 按类型 |
318
+ | Schema 粒度 | 结构化字段 | 原文字符串 / 双存 |
319
+ | Gherkin 规则源 | AutomationPanda + 本地补充 | 自研 / 仅外链 |
320
+ | 实施路径 | Minimal Incremental(路径 A) | Capability-First / Spec Kit 全栈 / 混合 |
@@ -0,0 +1,22 @@
1
+ # docs/brainstorms/
2
+
3
+ 需求文档与问题探索的存放目录。
4
+
5
+ ## 命名规范
6
+
7
+ 所有文件采用 `*-requirements.md` 命名:
8
+
9
+ - `feature-name-requirements.md` — 功能需求文档
10
+ - `integration-name-requirements.md` — 集成需求文档
11
+ - `refactor-name-requirements.md` — 重构需求文档
12
+
13
+ ## 内容约定
14
+
15
+ - 明确问题陈述(Problem Statement)
16
+ - 列出非目标(Non-Goals)
17
+ - 定义成功标准(Success Criteria)
18
+ - 包含初步估算(Estimated Effort)
19
+
20
+ ## 与 triage 阶段的关系
21
+
22
+ brainstorms/ 中的文档通常由 triage 阶段产出,作为后续 planning 的输入。
@@ -0,0 +1,29 @@
1
+ # docs/ 结构化知识沉淀体系需求
2
+
3
+ ## 问题陈述
4
+
5
+ 当前 gxpm 的工程决策、最佳实践、故障恢复手册散落在 chat 记忆和零散 markdown 中,缺乏跨会话恢复能力。新会话无法从 `.gxpm/` 恢复完整的工程上下文,导致知识流失和重复决策。
6
+
7
+ ## 参考来源
8
+
9
+ compound-engineering-plugin 的 `docs/` 分类模式:
10
+ - `docs/brainstorms/` — 需求文档
11
+ - `docs/plans/` — 实现计划
12
+ - `docs/solutions/` — 最佳实践与恢复手册(带 frontmatter)
13
+ - `docs/specs/` — 各 host 平台规范镜像
14
+
15
+ ## 成功标准
16
+
17
+ 1. docs/ 目录有清晰的分类约定和命名规范
18
+ 2. 所有解决方案文档带结构化 frontmatter(title, category, date, severity, component, tags)
19
+ 3. 新会话可通过读取 docs/solutions/ 恢复关键工程决策
20
+ 4. docs/brainstorms/ 和 docs/plans/ 的命名规范化(*-requirements.md, *-plan.md)
21
+
22
+ ## 非目标
23
+
24
+ - 重写现有文档内容
25
+ - 建立自动化文档生成流水线
26
+
27
+ ## 初步估算
28
+
29
+ 1-2 天
@@ -0,0 +1,39 @@
1
+ # Beta Skill Promotion Guide
2
+
3
+ ## Maturity Levels
4
+
5
+ - `beta`: Skill is functional but may have incomplete documentation, limited test coverage, or evolving interfaces.
6
+ - `stable`: Skill is production-ready with complete documentation, tests, and stable interfaces.
7
+
8
+ ## Promotion Checklist
9
+
10
+ A skill may be promoted from `beta` to `stable` when all of the following are satisfied:
11
+
12
+ 1. [ ] **Documentation**: SKILL.md is complete with usage examples and trigger conditions
13
+ 2. [ ] **Tests**: Has associated tests or eval harness demonstrating correct behavior
14
+ 3. [ ] **Frontmatter**: Contains `name`, `description`, and `status: stable`
15
+ 4. [ ] **References**: All `references/` files are up to date
16
+ 5. [ ] **Host Compatibility**: Verified on at least one target host (Claude Code, Codex, Kimi, etc.)
17
+ 6. [ ] **Naming**: Uses `gxpm-` prefix for official gxpm skills
18
+
19
+ ## How to Mark Status
20
+
21
+ Add to the YAML frontmatter of `SKILL.md.tmpl` (for generated skills) or `SKILL.md` (for static skills):
22
+
23
+ ```yaml
24
+ ---
25
+ name: gxpm-example
26
+ description: Example skill
27
+ status: beta
28
+ ---
29
+ ```
30
+
31
+ When promoting, change `status: beta` to `status: stable` and regenerate `SKILL.md` if applicable:
32
+
33
+ ```bash
34
+ bun run gen:skill-docs
35
+ ```
36
+
37
+ ## Enforcement
38
+
39
+ `bun run check` validates that every official skill (`gxpm-*`) has a valid frontmatter with `name` and `description`. Warnings are emitted for non-`gxpm-` skills but do not block the check.
@@ -0,0 +1,144 @@
1
+ # gxpm Development Contract
2
+
3
+ ## 目的
4
+
5
+ 本文件把 gstack 中有效的开发规范转成 gxpm 的可执行合同。`AGENTS.md` 保持薄入口,本文件作为开发、验证、提交和失败归因的渐进加载规则。
6
+
7
+ ## 命令分层
8
+
9
+ | Tier | Command | 何时运行 | 目标 |
10
+ | --- | --- | --- | --- |
11
+ | fast | `bun test` | 每次实现后、提交前 | 免费静态验证和单元测试 |
12
+ | gate | `bun run check` | 提交前、生成器、governance、phase、artifact 或 capability 改动后 | host config、生成文档、治理文档、phase gate、capability output 和 artifact validator 一致性检查 |
13
+ | generated | `bun run gen:skill-docs` | 修改 `*.tmpl`、host config、preamble 后 | 刷新生成的 skill surface |
14
+ | state | `gxpm issue create/status/transition` | state graph 或 phase 规则改动后 | 本地 `.gxpm` 真值写回和恢复验证 |
15
+ | capability | `gxpm capability list/show` | 新增或修改 runtime capability contract 后 | 检查 input/output、mutation、idempotency、failure mode 和 evidence metadata |
16
+ | evidence | `bun test test/evidence.test.ts test/investigate.test.ts` | issue-local evidence store、browser/investigation/review 证据写入改动后 | 路径安全、partial failure evidence、截图/日志路径和 payload 保持兼容 |
17
+ | runtime | `gxpm issue ready/claim/release/reconcile-claim`、`gxpm run start/list/status/event`、`gxpm workspace plan/ensure/cleanup`、`gxpm orchestrator tick --dry-run` | claim lifecycle、run ledger、workspace runtime、orchestrator dry-run 改动后 | 执行运行时原语、路径安全、只读派发判断 |
18
+ | artifact | `gxpm triage init`、`gxpm plan init`、`gxpm dispatch init`、`gxpm implement verify`、`gxpm local-verify ac-check`、`gxpm ac-check self-review`、`gxpm self-review ship`、`gxpm ship pr-check`、`gxpm pr-check verify`、`gxpm verify qa`、`gxpm qa land`、`gxpm artifact list/read` | artifact store 或 phase gate 改动后 | 产物写入、读取、索引和 gate 验证 |
19
+ | human-docs | `gxpm wiki init`、`gxpm wiki update`、`gxpm wiki query <text>`、`gxpm wiki status` | 人类需要本地项目说明书、onboarding 或治理文档导航 | 可选原生 wiki、本地索引和 Markdown 概览 |
20
+ | agent-code-intel | GitNexus MCP: `list_repos`、`query`、`context`、`impact`、`detect_changes`、`cypher` | Agent 需要代码理解、调试、重构影响面或 PR 风险判断 | 图谱驱动的代码智能、调用链、影响半径和 diff 影响分析 |
21
+ | future-e2e | 待实现 | browser/runtime capability 落地后 | 真实浏览器和 agent workflow 证据 |
22
+ | future-eval | 待实现 | 高风险 prompt/capability 改动 | LLM judge 或 paid eval,需先确认成本 |
23
+
24
+ ## 生成物规则
25
+
26
+ - `SKILL.md.tmpl` 是真值,`SKILL.md` 是生成产物。
27
+ - 修改模板后必须运行 `bun run gen:skill-docs` 并提交模板与生成物。
28
+ - 生成物冲突只能通过模板和生成器解决,再重新生成。
29
+ - `bun run check` 必须能发现生成物漂移。
30
+ - scaffold check 流程的真值是 `scripts/scaffold-check.ts`;`gxpm check` 和 `gxpm-check.ts` 只能调用它。
31
+ - scaffold check 必须能发现 layered workflow 漂移:phase gate required artifact、capability output artifact 和 artifact validator 覆盖必须一致。
32
+ - skill 模板中的 gate command、artifact read list 和 transition summary 必须由 `scripts/gen-skill-docs.ts` 从 phase gate registry 生成。
33
+ - README 只展示稳定入口命令,不复制完整 phase gate 链;完整 gate guidance 以生成的 `skills/gxpm/SKILL.md` 为准。
34
+ - `docs/architecture/gxpm-v0-contract.md` 可保留人类可读列表,但必须由测试证明和 phase、artifact、gate registry 一致。
35
+
36
+ ## Phase Artifact 规则
37
+
38
+ - 新增 phase artifact initializer 时,优先使用 `core/phase-artifact.ts` 的 `createPhaseArtifactInitializer`。
39
+ - initializer 文件只声明 required phase、artifact type、label 和 draft payload。
40
+ - 不要在每个 initializer 中重复 `readIssueState`、phase 校验和 `writeArtifact` 样板。
41
+ - `triage` 这类没有前置 phase gate 的入口 artifact 可以保留专用实现。
42
+ - `ARTIFACT_TYPES` 可以包含 non-gate artifact;只有 `GATE_ARTIFACT_TYPES` 需要 phase gate command 和 initializer 绑定。
43
+ - 每个 `ARTIFACT_TYPES` 成员都必须被 `core/artifact-validator.ts` 覆盖;即使 schema 暂时宽松,也要显式声明原因。
44
+ - 新增 artifact-backed transition 时,必须先更新 `core/phase-gates.ts`;`scripts/phase-artifact-commands.ts` 只绑定 initializer 和 success message。
45
+ - `test/phase-gates.test.ts` 必须证明 CLI artifact command 顺序和 gate rule 顺序保持一致。
46
+ - gate 测试需要把通用 phase setup 放在 `test/helpers/workflow.ts`,不要在每个 gate 文件重复写完整前置 phase 链。
47
+ - `test/helpers/workflow.ts` 的 phase setup 顺序必须从 phase gate registry 派生,不再手写第二份 workflow chain。
48
+ - gate 测试文件只保留当前 gate 的 artifact payload、blocked event、CLI command 和 transition 断言。
49
+
50
+ ## Execution Runtime 规则
51
+
52
+ - `core/capabilities.ts` 是 runtime capability contract 的描述性 registry。新增 capability slice 时,先声明 input/output、mutation scope、idempotency、failure modes、commands 和 source anchors,再接执行实现。
53
+ - 每个 phase gate required artifact 都必须至少由一个 capability 的 `outputContract.artifacts` 声明。Command 不能成为唯一知识来源。
54
+ - `gxpm capability list/show` 必须保持只读;它只能检查 registry,不得执行 capability、写 artifact、claim issue 或调用外部 provider。
55
+ - `gxpm run *` 只记录或读取 issue-local run ledger;不得隐式推进 phase。
56
+ - `gxpm issue claim/release/reconcile-claim` 只更新本地 issue claim 生命周期;不得隐式推进 phase。
57
+ - `gxpm workspace plan` 是只读路径规划;`ensure` 只创建/复用当前 issue workspace;`cleanup` 只能删除该 issue 对应 workspace。
58
+ - workspace key 必须由 issue identifier 派生并限制在 `[A-Za-z0-9._-]`,不允许把用户输入拼进任意路径。
59
+ - `gxpm orchestrator tick --dry-run` 必须保持只读:不 claim、不创建 workspace、不启动 agent、不写 artifact、不 transition。
60
+ - 真正的长驻 poll/retry daemon 需要另行设计;不要把 dry-run tick 偷偷扩成后台服务。
61
+
62
+ ## Evidence Store 规则
63
+
64
+ - `core/evidence.ts` 是 issue-local 原始证据的唯一写入/路径分配入口。新增 command、browser、review、release 或 investigate 证据时,先使用它分配 `evidence/<kind>/<filename>`,不要在调用方手拼 `.gxpm/issues/<id>/evidence` 路径。
65
+ - evidence filename 必须是单一安全文件名,不能包含 `/`、`..` 或绝对路径。issue id 校验必须复用 `core/state.ts`,写入前必须确认 issue state 存在。
66
+ - phase artifact 和 evidence 分工保持清楚:结论、gate 结果和验收状态写 `artifacts/*.json`;截图、console、命令输出、review 原文或调查过程写 `evidence/`。
67
+ - `gxpm-investigate` 必须保持 partial evidence 行为:任何 cmux 子命令失败前已经收集到的 URL、viewport、snapshot、screenshot、console 等内容都要落到 `evidence/investigations/*.json`。
68
+
69
+ ## 失败归因协议
70
+
71
+ 不要直接说“这是旧问题”或“与本次无关”。需要满足以下任一证据:
72
+
73
+ 1. 同一命令在 base/main 上也失败。
74
+ 2. 有仓库已有记录证明该失败是基线噪声。
75
+ 3. 无法验证时,明确标记为“未验证,可能相关”,并把风险写进汇报。
76
+
77
+ ## 提交规则
78
+
79
+ - 每个提交只表达一个逻辑变化。
80
+ - 模板改动和生成物刷新可以同一提交,但不要混入无关重构。
81
+ - 测试基础设施、host adapter、产品文档变更应尽量独立,便于回滚。
82
+ - 提交前至少运行 `bun test`、`bun run check`、`git diff --check`。
83
+ - 主目录 checkout 必须保持在 `main`。`gxpm gate branch-policy` 会阻止 canonical main checkout 在非 `main` 分支上提交或推送;feature 分支应在 dedicated git worktree 中运行。
84
+
85
+ ## Live Install 风险
86
+
87
+ 未来 gxpm 支持本地 `.agents/` 或 `.claude/` dev install 后,修改模板和生成器可能立即影响其他会话。大改前先确认:
88
+
89
+ - 当前 host skill 是 symlink 还是 copy。
90
+ - 是否有并行会话依赖当前安装。
91
+ - 是否需要先切回稳定全局安装或隔离 worktree。
92
+
93
+ ## 需求确认 / Brainstorming Gate
94
+
95
+ - 新的非平凡任务或范围变化,先做 read-only 探查,再给用户确认目标、范围、非目标、成功标准和预计改动。
96
+ - 优先使用当前 host 的原生选择表单。Codex 中如果 `request_user_input` 在当前模式可用,就用 1 个短问题和 2-3 个互斥选项;不可用时用简短文字确认,不伪装成表单。
97
+ - 用户明确说“直接做 / 继续推进 / 按已有计划执行”时,可以跳过确认闸门。
98
+ - 外部 tracking id 只能写入 artifact 作为来源信息,不作为 GXPM-N;本地 issue 永远用 `gxpm issue create --auto-id`。
99
+ - Superpowers 和 gstack 只作为上游交互模式参考,不能引入为 gxpm 运行时依赖。
100
+
101
+ ## gxpm 原生 Wiki
102
+
103
+ - `gxpm wiki` 是可选的人类文档面,不是 Agent 默认代码智能层;Agent 的代码理解、调试、重构和 review 默认使用 GitNexus。
104
+ - `gxpm wiki init` 生成 gxpm 自有的 `.gxpm/wiki/index/files.json`、`.gxpm/wiki/index/graph.json`、`.gxpm/wiki/content/` 和 `.gxpm/wiki/state.json`。
105
+ - `gxpm wiki update` 只在人类需要刷新本地项目说明书时手动运行;V1 是确定性本地索引、导入图谱和 Markdown 概览,不调用 IDE 或外部付费服务。
106
+ - `gxpm wiki status` 报告原生 wiki 的 absent/current/stale 状态。原生 wiki stale 的标准包括 state/index 缺失、`baseCommit` 落后当前 `HEAD`、或已索引的 git-tracked 文件发生变更。
107
+ - 原生 wiki 优先使用 `git ls-files` 索引 git-tracked 文本文件;git 不可用时退回同样 skip-list 的本地扫描。`.codex/`、`.claude/`、`.gxpm/`、`.qoder/` 等 ignored/local/generated 内容以及未跟踪 scratch 文件不得进入仓库知识索引。
108
+ - `gxpm wiki query <text>` 基于结构化索引返回 source files 和 suggested human docs,适合作为人工项目导览,不作为 Agent 深层代码导航替代。
109
+ - `gxpm wiki context <issue-id>` 基于 issue state/artifacts 生成查询并返回相关 source files 与 suggested human docs;需要把结果落盘时使用 `--write-artifact` 写入非 gate 的 `wiki-context` artifact。
110
+ - SessionStart、post-checkout 和 post-commit 不自动刷新或注入 wiki;如果人类需要最新 wiki,显式运行 `gxpm wiki update`。
111
+ - `.gxpm/wiki/` 保持 git 外状态;需要提交的是生成逻辑、契约和测试,不提交具体仓库 wiki 内容。
112
+
113
+ ## 长任务规则
114
+
115
+ 长时间测试、E2E、浏览器验证和部署验证必须持续轮询到结束。不能把“后台会通知”当作完成证据。每次轮询只汇报新进展、失败和下一步。
116
+
117
+ ## 规格驱动开发(SDD)宪法
118
+
119
+ gxpm 采用 Spec-Driven Development 方法论。`templates/constitution-template.md` 定义 Nine Articles,以下为可直接映射到 gxpm 的条款:
120
+
121
+ | Article | gxpm 映射 | 检查点 |
122
+ |---------|----------|--------|
123
+ | Capability-First | `core/capabilities.ts` 必须先声明 capability slice | plan phase `constitutionCheck.capabilityDeclared` |
124
+ | Test-First | 红-绿-重构,`bun test` 为 fast gate | plan phase `constitutionCheck.testStrategyDefined` |
125
+ | Simplicity Gate | 最多 3 个模块/特性,MVP 优先 | plan phase `constitutionCheck.simplicityJustified` |
126
+ | Anti-Abstraction | 直接使用框架特性,不造 wrapper | code review 时检查 |
127
+ | Integration-First | 集成测试用真实环境,单元测试才 mock | plan phase `constitutionCheck.integrationPathClear` |
128
+
129
+ ### Phase -1 Gates
130
+
131
+ 在 `triage -> plan` 推进前,implementation-plan artifact 自动包含 `constitutionCheck` 字段:
132
+
133
+ - `capabilityDeclared` — 是否已在 capabilities registry 声明
134
+ - `testStrategyDefined` — 实现计划是否包含测试策略
135
+ - `simplicityJustified` — 复杂度是否最小可行
136
+ - `integrationPathClear` — 集成测试是否计划用真实环境
137
+
138
+ Spike/调查类 issue(`type=spike`)可跳过 Phase -1 Gates。Feature 交付类 issue(默认类型)必须全部通过。
139
+
140
+ ## 文档边界
141
+
142
+ - `AGENTS.md` 只放不可推断的执行边界。
143
+ - `CLAUDE.md` 只放 Claude Code 启动差异。
144
+ - 专项规则放 `docs/governance/`,不要把所有细节塞回根文件。
@@ -0,0 +1,90 @@
1
+ # Gherkin 写作风格指南 (v1)
2
+
3
+ > 本文档源自 AutomationPanda/gherkin-guidelines-for-ai (MIT),加 gxpm 本地补充。
4
+ > 所有 gxpm-driven issue 在 specify 阶段必须遵循本规则集。
5
+
6
+ ## 核心原则
7
+
8
+ - **行为驱动**:描述系统*做什么*而非*怎么做*
9
+ - **领域语言**:使用 CONTEXT.md 中的术语,不出现 UI/HTTP/SQL 等技术词
10
+ - **示例规约**:scenario 用具体例子展示行为
11
+ - **每个 scenario 一个行为**
12
+ - **可独立执行**:scenario 之间无顺序依赖
13
+
14
+ ## Feature 结构
15
+
16
+ - 单一 `Feature:` 标题与文件名一致
17
+ - User Story 紧跟标题:
18
+ - `As a <role>`
19
+ - `I want <goal>`
20
+ - `So that <reason>`
21
+
22
+ ## Scenario 设计规则
23
+
24
+ - 单行、行为聚焦的标题
25
+ - 步骤可按时间顺序执行
26
+ - 声明式语言,非命令式
27
+ - 不混合多个无关关注点(功能 + 性能 + 可访问性必须拆分)
28
+ - 步骤数 < 10,超过用 data table
29
+
30
+ ## Given / When / Then 语义
31
+
32
+ - `Given` 建立上下文(Arrange)
33
+ - `When` 触发动作(Act)
34
+ - `Then` 验证可观察结果(Assert)
35
+
36
+ **严格顺序**:`Given → When → Then`,禁止重复阶段。
37
+
38
+ **关键词**:
39
+ - `And` 续相同类型(OK)
40
+ - `But` 用于对比(少用)
41
+ - **禁止 `Or`** —— 拆 Scenario Outline 或独立 scenario
42
+
43
+ **可观察结果**:`Then` 必须可从场景文本验证。禁止 "it works"、"it succeeds" 这类模糊断言;必须说出"发生了什么"、"用户看到什么"、"系统报告什么"。
44
+
45
+ ## 词汇与命名
46
+
47
+ - 整个 issue 内使用稳定词汇,禁止同义词替换
48
+ - 第三人称、现在时、主谓结构
49
+ - 字符串参数用双引号
50
+ - 步骤数据用 doc string (`"""`) 或 data table,禁止用 `And` 串联
51
+
52
+ ## 反模式(禁止)
53
+
54
+ - 在 Given/When/Then 写入 UI 选择器、XPath、`click #id`
55
+ - 在 Then 写 SQL 断言、HTTP 状态码(除非这就是被测的接口)
56
+ - 占位符数据:`foo`、`bar`、`test`、纯数字 `123`(数字若有业务含义可用)
57
+ - 一个 scenario 多个行为
58
+ - 步骤超过 10 个
59
+ - 把"用户登录"描述成 10 步点击;改用状态:"用户已以 Editor 身份登录"
60
+
61
+ ## gxpm 本地补充
62
+
63
+ - **中文允许**:领域词允许中文,但同一 issue 内保持中英一致
64
+ - **必须引用 CONTEXT.md 术语**:scenario 中提及的实体名必须在 CONTEXT.md 中有定义;新词需先扩展 CONTEXT.md
65
+ - **stubPath 必须真实**:每个 scenario 的 `stubPath` 字段指向的测试文件必须存在
66
+ - **scenario.id 命名**:`scn-NN`(两位数字补零)
67
+ - **禁止 `<placeholder>` 留存**:specifier 草拟阶段允许 `<placeholder>` 字符串占位,但 `gxpm specify confirm` 会拒绝任何残留 placeholder 的 spec
68
+
69
+ ## Pre-confirm 自查清单
70
+
71
+ specifier agent 在调用 `gxpm specify confirm` 前必须自查:
72
+
73
+ - [ ] 单一行为,可独立执行
74
+ - [ ] 无混合无关关注点
75
+ - [ ] 词汇稳定,CONTEXT.md 术语对齐
76
+ - [ ] 领域级抽象,无 UI/HTTP/SQL 管道术语
77
+ - [ ] 最小但充分的 Given
78
+ - [ ] 真实示例数据(无 foo/bar/test)
79
+ - [ ] 第三人称、现在时、主谓结构
80
+ - [ ] 严格 Given → When → Then,Then 可观察
81
+ - [ ] 步骤数 < 10
82
+ - [ ] 每个 scenario.stubPath 真实存在
83
+ - [ ] 全文无 `<placeholder>` 残留
84
+
85
+ ## 参考
86
+
87
+ - [AutomationPanda/gherkin-guidelines-for-ai](https://github.com/AutomationPanda/gherkin-guidelines-for-ai)(一手规则源)
88
+ - `CONTEXT.md`(领域词典)
89
+ - `docs/brainstorms/2026-05-14-bdd-then-tdd-design.md`(设计 spec)
90
+ - `docs/plans/bdd-then-tdd-plan.md`(实施计划)