@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,275 @@
1
+ # mattpocock-skills 工程实践研究报告
2
+
3
+ > 研究日期:2026-05-02
4
+ > 来源:mattpocock/skills(本地路径 `/Users/x/Desktop/Project/github/mattpocock-skills`)
5
+ > 研究目的:提取对 gxpm 有参考价值的工程实践,建立快速适配索引
6
+ > 关联文档:`docs/research/mattpocock-skills-comparison.md`(已有对标分析)
7
+
8
+ ---
9
+
10
+ ## 一、项目定位
11
+
12
+ **mattpocock-skills** 是一个**纯 Markdown + Shell 的技能仓库**,无 package.json,不依赖 Node.js 运行时。所有技能都是面向 Claude Code 的 prompt 指令集合,通过 `.claude-plugin/plugin.json` 声明可被 Claude CLI 发现。
13
+
14
+ 核心定位:面向软件交付生命周期的**工作流技能集合**,按 issue tracker 驱动的工程流程组织(需求对齐 → 计划产出 → 任务拆解 → 问题流转 → 开发实施 → 故障排查)。
15
+
16
+ ---
17
+
18
+ ## 二、架构与目录结构
19
+
20
+ ```
21
+ mattpocock-skills/
22
+ ├── README.md # 技能总览 + 使用哲学
23
+ ├── CONTEXT.md # 领域词汇表(issue tracker, triage role 等)
24
+ ├── CLAUDE.md # 仓库内部治理规则
25
+ ├── docs/adr/ # 架构决策记录(仅 1 条 ADR)
26
+ ├── .claude-plugin/
27
+ │ └── plugin.json # 暴露给 Claude CLI 的技能清单(12 个技能)
28
+ ├── scripts/
29
+ │ ├── list-skills.sh # 枚举所有 SKILL.md
30
+ │ └── link-skills.sh # 将技能软链到 ~/.claude/skills
31
+ ├── skills/
32
+ │ ├── engineering/ # 9 个日常工程技能
33
+ │ ├── productivity/ # 3 个通用工作流技能
34
+ │ ├── misc/ # 4 个低频工具
35
+ │ ├── personal/ # 2 个个人专用(不在 README/plugin 中曝光)
36
+ │ └── deprecated/ # 4 个已弃用技能
37
+ └── .out-of-scope/ # 反需求知识库(3 个拒绝项记录)
38
+ ```
39
+
40
+ **关键治理规则(`CLAUDE.md`)**:
41
+ - `engineering/`、`productivity/`、`misc/` 中的技能必须在根级 `README.md` 和 `plugin.json` 中登记
42
+ - `personal/` 和 `deprecated/` **严禁**出现在 README/plugin 中
43
+ - 每个 bucket 目录有自己的 `README.md`,列出该 bucket 内所有技能的一行描述
44
+
45
+ ---
46
+
47
+ ## 三、核心功能模块
48
+
49
+ 项目按**软件交付生命周期**组织技能,职责边界极其清晰:
50
+
51
+ | 阶段 | 技能 | 职责 |
52
+ |------|------|------|
53
+ | **初始化** | `setup-matt-pocock-skills` | 种子配置:issue tracker 类型、triage label 映射、domain doc 布局 |
54
+ | **需求对齐** | `grill-me` / `grill-with-docs` | 通过"拷问式访谈"消解需求歧义;`grill-with-docs` 额外维护 `CONTEXT.md` 和 ADR |
55
+ | **计划产出** | `to-prd` | 将对话上下文合成为 PRD,发布到 issue tracker |
56
+ | **任务拆解** | `to-issues` | 将 PRD/计划拆分为 tracer-bullet 垂直切片(Vertical Slices) |
57
+ | **问题流转** | `triage` | 状态机驱动的 issue 分类:5 个 state role + 2 个 category role |
58
+ | **开发实施** | `tdd` | 红-绿-重构循环,强制"一个测试 → 一个实现"的垂直切片 |
59
+ | **故障排查** | `diagnose` | 6 阶段诊断法:构建反馈循环 → 复现 → 假设 → 探测 → 修复 → 事后分析 |
60
+ | **架构治理** | `improve-codebase-architecture` | 基于 `CONTEXT.md` + ADR 持续发现"深度模块"重构机会 |
61
+ | **代码理解** | `zoom-out` | 轻量提示:要求 Agent 使用领域词汇给出高层模块地图 |
62
+
63
+ **设计哲学**:每个技能只做一件事,技能之间通过**文档真值(`CONTEXT.md`、ADR、配置)**间接协作,而非直接调用。
64
+
65
+ ---
66
+
67
+ ## 四、技术栈
68
+
69
+ - **纯 Markdown**:所有 skill 逻辑用 Markdown 表达
70
+ - **YAML frontmatter**:skill 元数据(name、description、disable-model-invocation)
71
+ - **Shell 脚本**:辅助工具(list-skills.sh、link-skills.sh)
72
+ - **无 package.json**:零 Node.js 依赖
73
+ - **无 CI/CD**:无自动化测试基础设施
74
+
75
+ ---
76
+
77
+ ## 五、Skill 结构定义
78
+
79
+ ### 5.1 文件结构规范
80
+
81
+ ```
82
+ skill-name/
83
+ ├── SKILL.md # 主指令(必需)
84
+ ├── REFERENCE.md # 详细参考(可选,当 SKILL.md 超过 100 行时拆分)
85
+ ├── EXAMPLES.md # 用例示例(可选)
86
+ ├── AGENT-BRIEF.md # 专用模板(如 triage)
87
+ ├── OUT-OF-SCOPE.md # 知识库规范(如 triage)
88
+ ├── CONTEXT-FORMAT.md # 上下文格式规范(如 grill-with-docs)
89
+ └── scripts/ # 确定性工具脚本(可选)
90
+ └── helper.sh
91
+ ```
92
+
93
+ ### 5.2 Frontmatter 规范
94
+
95
+ ```yaml
96
+ ---
97
+ name: skill-name
98
+ description: Brief description of capability. Use when [specific triggers].
99
+ disable-model-invocation: true # 可选,仅作为提示,不调用模型
100
+ ---
101
+ ```
102
+
103
+ ### 5.3 Description 字段契约
104
+
105
+ - **硬限制**:≤ 1024 字符
106
+ - **视角**:第三人称
107
+ - **格式**:第一句讲能力,第二句以 `"Use when..."` 给出触发条件
108
+ - **重要性**:`description` 是 Agent 选择加载哪个 skill 的**唯一信息源**
109
+
110
+ ### 5.4 内容组织原则
111
+
112
+ | 原则 | 说明 |
113
+ |------|------|
114
+ | **Progressive Disclosure** | SKILL.md 保持精简(目标 <100 行),高级内容拆分到 REFERENCE.md |
115
+ | **确定性脚本外置** | 验证、格式化等确定性操作写为脚本,节省 token 并提升可靠性 |
116
+ | **具体示例优先** | 禁止空泛描述,必须包含 Good/Bad 对比示例 |
117
+ | **无时效信息** | 禁止包含版本号、时间等易过期内容 |
118
+
119
+ ### 5.5 对比 gxpm 现状
120
+
121
+ gxpm 的 skill 结构(`skills/gxpm-*/SKILL.md`)已经高度遵循此模式,且增加了 `.tmpl` 源文件 + `gen:skill-docs` 生成管道,这是 mattpocock-skills 所没有的**工程化增强**。
122
+
123
+ ---
124
+
125
+ ## 六、Skill 的测试与验证机制
126
+
127
+ ### 6.1 现状:无自动化测试基础设施
128
+
129
+ mattpocock-skills **没有**测试目录、没有 CI 配置、没有自动化验证管道。Skill 的质量保障依赖:
130
+
131
+ 1. **Review Checklist**(`write-a-skill/SKILL.md` 末尾):
132
+ - Description 包含触发条件("Use when...")
133
+ - SKILL.md < 100 行
134
+ - 无时效敏感信息
135
+ - 术语一致
136
+ - 包含具体示例
137
+ - 引用仅一层深度
138
+
139
+ 2. **Deprecated 目录作为迭代证据**:弃用技能不删除,移入 `deprecated/`,保留历史决策痕迹。
140
+
141
+ 3. **使用反馈驱动**:通过 newsletter 和实际工程使用发现问题。
142
+
143
+ ### 6.2 诊断技能的"反馈循环"哲学
144
+
145
+ 虽然 skill 本身无测试,但 `diagnose` skill 将**"构建快速反馈循环"**提升为调试的第一性原理:
146
+
147
+ > "If you have a fast, deterministic, agent-runnable pass/fail signal for the bug, you will find the cause... If you don't have one, no amount of staring at code will save you."
148
+
149
+ `tdd` skill 同样将测试视为**行为契约**而非实现验证。
150
+
151
+ ---
152
+
153
+ ## 七、配置系统与扩展点
154
+
155
+ ### 7.1 核心设计:Per-Repo 配置种子
156
+
157
+ `setup-matt-pocock-skills` 是一个**prompt-driven 的配置生成器**(非确定性脚本),产出以下真值文件:
158
+
159
+ ```
160
+ docs/agents/
161
+ ├── issue-tracker.md # GitHub / GitLab / Local / Other
162
+ ├── triage-labels.md # 5 个 canonical role → 实际 label 字符串映射
163
+ └── domain.md # 单上下文 vs 多上下文布局规则
164
+ ```
165
+
166
+ 并在 `AGENTS.md` 或 `CLAUDE.md` 中注入 `## Agent skills` 块。
167
+
168
+ ### 7.2 硬依赖 vs 软依赖分离(ADR-0001)
169
+
170
+ | 类型 | 技能 | 策略 |
171
+ |------|------|------|
172
+ | **Hard dependency** | `to-issues`, `to-prd`, `triage` | 必须显式提示:*"run `/setup-matt-pocock-skills` if not"*。没有配置则输出错误。 |
173
+ | **Soft dependency** | `diagnose`, `tdd`, `improve-codebase-architecture`, `zoom-out` | 模糊引用"domain glossary"和"ADRs"。无配置时优雅降级,输出只是不够精准。 |
174
+
175
+ **设计意图**:避免在不需要的地方 cargo-cult 配置指针,保持软依赖技能的 token 轻量。
176
+
177
+ ### 7.3 Issue Tracker 抽象
178
+
179
+ 支持四级后端:
180
+ - **GitHub**(`gh` CLI)
181
+ - **GitLab**(`glab` CLI)
182
+ - **Local markdown**(`.scratch/<feature>/`)
183
+ - **Other**(自由文本,由用户自行描述工作流)
184
+
185
+ ### 7.4 领域文档布局
186
+
187
+ - **Single-context**:根级 `CONTEXT.md` + `docs/adr/`
188
+ - **Multi-context**:根级 `CONTEXT-MAP.md` 指向多个子上下文(如 monorepo)
189
+
190
+ ### 7.5 反需求知识库:`.out-of-scope/`
191
+
192
+ - 一概念一文件(kebab-case 命名)
193
+ - 格式:决策、理由、先例请求列表
194
+ - 在 `triage` 阶段自动匹配,避免重复讨论已拒绝的特性
195
+ - 仅用于 enhancement 的 `wontfix`,不用于 bug
196
+
197
+ ### 7.6 Agent Brief 模板
198
+
199
+ 当 issue 进入 `ready-for-agent` 时,`triage` 要求发布结构化评论:
200
+ - **Durability over precision**:只描述接口/行为/类型,不引用文件路径或行号
201
+ - **Behavioral, not procedural**:描述"系统应该做什么",而非"如何修改"
202
+ - **Explicit scope boundaries**:明确列出 Out of scope
203
+
204
+ ---
205
+
206
+ ## 八、对 gxpm 的借鉴价值
207
+
208
+ ### 8.1 可直接复用的模式 ✅
209
+
210
+ | 模式 | 来源文件 | gxpm 应用建议 |
211
+ |------|----------|---------------|
212
+ | **硬/软依赖分离** | `docs/adr/0001-explicit-setup-pointer-only-for-hard-dependencies.md` | `gxpm-init` 应明确区分哪些技能/phase 必须预配置,哪些可优雅降级 |
213
+ | **Agent Brief 契约** | `skills/engineering/triage/AGENT-BRIEF.md` | `dispatch` phase 产出的 artifact 可直接采用:行为描述 + 关键接口 + 验收标准 + 范围边界,禁止文件路径/行号 |
214
+ | **`.out-of-scope/` 反需求库** | `skills/engineering/triage/OUT-OF-SCOPE.md` | gxpm 已有 `.gxpm/out-of-scope/`(目前为空),可采纳"一概念一文件 + 先例请求列表 + triage 自动匹配"的完整规范 |
215
+ | **垂直切片(Tracer Bullet)** | `skills/engineering/to-issues/SKILL.md` | `gxpm-planning` skill 拆解 issue 时已使用 vertical slice,可进一步引入 HITL vs AFK 分类和显式依赖图 |
216
+ | **诊断反馈循环优先** | `skills/engineering/diagnose/SKILL.md` | `gxpm-diagnose` skill 可将 Phase 1(构建反馈循环)作为核心框架 |
217
+ | **Disable-model-invocation 轻量技能** | `skills/engineering/zoom-out/SKILL.md` | 对于纯提示类技能(如 `gxpm-grill` 的某些模式),可加 `disable-model-invocation: true` |
218
+ | **Issue tracker CLI 抽象** | `skills/engineering/setup-matt-pocock-skills/issue-tracker-*.md` | gxpm 的 Linear/GitHub 集成不应硬编码 CLI,而应通过配置抽象,支持"本地 markdown"作为 fallback |
219
+
220
+ ### 8.2 应避免的陷阱 ❌
221
+
222
+ | 陷阱 | mattpocock-skills 现状 | gxpm 应如何超越 |
223
+ |------|------------------------|-----------------|
224
+ | **无自动化验证** | Skill 质量仅靠人工 review checklist 保障 | gxpm 应为 skill 建立**自动化 lint/检查**(如 `bun run check`)、甚至 eval 测试 |
225
+ | **无类型安全** | 纯 Markdown frontmatter,无 schema 校验 | gxpm 使用 TypeScript 运行时,skill 元数据应通过 Zod 等 schema 校验 |
226
+ | **版本与迁移缺失** | 弃用技能仅移入 `deprecated/` 目录,无迁移指南 | 应建立 skill 版本契约和 deprecation 策略(如 `DEPRECATED.md` + 自动迁移提示) |
227
+ | **配置重复提示** | 每个硬依赖技能都重复同样的 setup 提示语 | 可通过 host hook 或 capability runtime 在 session 启动时统一注入配置状态 |
228
+ | **无状态机持久化** | triage 状态依赖 issue tracker label,无本地状态图 | gxpm 的核心优势正是**统一 state graph**(`.gxpm/issues/<id>/`),应继续强化 |
229
+ | **Plugin.json 静态注册** | `.claude-plugin/plugin.json` 是静态清单 | gxpm 的 skill 注册应支持动态发现(`discover-skills`),与 host adapter 解耦 |
230
+
231
+ ---
232
+
233
+ ## 九、关键差异提醒
234
+
235
+ mattpocock-skills 是**Claude Code 的纯 prompt skill 集合**,没有自己的运行时、状态图或 capability 系统。gxpm 是**独立产品**,具备:
236
+ - TypeScript 运行时 + state graph
237
+ - `.gxpm/` 本地真值目录
238
+ - Capability runtime + browser evidence
239
+ - Review/ship governance
240
+
241
+ 因此,gxpm 不应模仿其"无测试、无类型"的轻量模式,而应**吸收其 workflow 设计、文档治理和 skill 结构规范**,同时在工程化、自动化验证和状态持久化上建立更高标准。
242
+
243
+ ---
244
+
245
+ ## 十、关键文件映射
246
+
247
+ | mattpocock-skills 文件/模式 | gxpm 对应位置/建议 |
248
+ |----------------------------|---------------------|
249
+ | `CONTEXT.md` | 已存在,继续作为领域词汇单一真相源 |
250
+ | `docs/adr/0001-explicit-setup-pointer-only-for-hard-dependencies.md` | `docs/architecture/` 下记录 gxpm 的硬/软依赖决策 |
251
+ | `skills/engineering/triage/AGENT-BRIEF.md` | `core/dispatch.ts` + artifact 模板 |
252
+ | `skills/engineering/triage/OUT-OF-SCOPE.md` | `.gxpm/out-of-scope/` 规范化 |
253
+ | `skills/engineering/to-issues/SKILL.md` | `skills/gxpm-planning/SKILL.md` |
254
+ | `skills/engineering/diagnose/SKILL.md` | `skills/gxpm-diagnose/SKILL.md` |
255
+ | `skills/engineering/tdd/SKILL.md` | `skills/gxpm-tdd/SKILL.md` |
256
+ | `skills/engineering/write-a-skill/SKILL.md` | `docs/governance/skill-authoring.md` |
257
+ | `.out-of-scope/` | `.gxpm/out-of-scope/` 待填充 |
258
+ | `deprecated/` | 未来 skill 淘汰机制参考 |
259
+
260
+ ---
261
+
262
+ ## 十一、适配建议
263
+
264
+ 1. **硬/软依赖分离**:在 `gxpm-init` 和 `AGENTS.md` 中明确标记哪些能力是 hard dependency(必须 setup 后才能使用,如 issue tracker 配置),哪些是 soft dependency(无配置时优雅降级,如 `gxpm-diagnose`)。
265
+ 2. **Agent Brief 模板**:`dispatch` phase 产出的 artifact 采用 Agent Brief 格式——只描述接口/行为/类型,不引用文件路径或行号,明确 scope boundaries。
266
+ 3. **`.out-of-scope/` 规范化**:将 `.gxpm/out-of-scope/` 从空目录升级为"一概念一文件"的反需求知识库,在 `gxpm-triage` 中自动匹配,避免重复讨论已拒绝的特性。
267
+ 4. **Skill 自动化验证**:为 gxpm skills 建立自动化 lint(description 长度、frontmatter 完整性、术语一致性)和 eval 测试框架,超越 mattpocock-skills 的人工 review checklist。
268
+ 5. **Issue Tracker 抽象**:当前 gxpm 硬绑定 Linear,应参考 mattpocock-skills 的抽象层设计,支持本地 markdown fallback(`.gxpm/issues/<id>/` 本身就是本地真值,可作为独立后端)。
269
+ 6. **垂直切片强化**:`gxpm-planning` skill 在拆解 issue 时,引入 tracer-bullet 垂直切片 + HITL vs AFK 分类 + 显式依赖图。
270
+
271
+ ---
272
+
273
+ ## 十二、一句话总结
274
+
275
+ > mattpocock-skills 是 gxpm 在**工作流设计、领域文档治理、skill 契约规范**方面的优秀上游参考。gxpm 已大量吸收其术语和结构(`CONTEXT.md`、triage role、vertical slice),下一步应重点补齐其短板:**skill 自动化验证、类型安全 schema、状态机持久化、以及硬/软依赖的 runtime 级管理**。
@@ -0,0 +1,279 @@
1
+ # oh-my-codex 工程实践研究报告
2
+
3
+ > 研究日期:2026-05-02
4
+ > 来源:Yeachan-Heo/oh-my-codex(本地路径 `/Users/x/Desktop/Project/github/oh-my-codex`)
5
+ > 研究目的:提取对 gxpm 有参考价值的工程实践,建立快速适配索引
6
+
7
+ ---
8
+
9
+ ## 一、项目定位
10
+
11
+ **oh-my-codex(OMX)** 是一个基于 OpenAI Codex CLI 的**工作流编排层**,不自建执行引擎,而是通过 hooks、skills、state 管理和 tmux 运行时来增强 Codex 的默认体验。
12
+
13
+ 核心定位:"better task routing + better workflow + better runtime"。OMX 在 Codex CLI 之上构建了一个完整的代理项目管理工作流,包含需求澄清、计划生成、团队并行执行、持久化完成循环等阶段。
14
+
15
+ ---
16
+
17
+ ## 二、架构与目录结构
18
+
19
+ ```
20
+ oh-my-codex/
21
+ ├── src/
22
+ │ ├── cli/ # CLI 命令入口(omx.ts → index.ts)
23
+ │ ├── config/ # 配置解析:Codex hooks、模型路由、MCP registry
24
+ │ ├── hooks/ # 生命周期钩子:keyword-detector、session、agents-overlay
25
+ │ ├── modes/ # 工作流模式基类:startMode/updateMode/cancelMode
26
+ │ ├── state/ # 状态机:workflow-transition、skill-active、reconcile
27
+ │ ├── runtime/ # 执行循环:run-loop、run-outcome、terminal-lifecycle
28
+ │ ├── team/ # 团队并行运行时:orchestrator、tmux-session、worktree、state
29
+ │ ├── ralph/ # 持久化完成循环:persistence、contract
30
+ │ ├── pipeline/ # 流水线阶段
31
+ │ ├── mcp/ # MCP 服务器实现(state-server、trace-server)
32
+ │ ├── agents/ # 原生代理配置生成
33
+ │ ├── hud/ # Heads-up display 状态
34
+ │ └── utils/ # 路径解析、AGENTS.md 工具
35
+ ├── skills/ # SKILL.md 技能定义(ralph、team、autopilot、deep-interview 等)
36
+ ├── prompts/ # 角色提示词(analyst、architect、executor 等 30+ 角色)
37
+ ├── templates/ # 模型指令模板
38
+ ├── plugins/ # Codex 官方插件打包(含 marketplace.json)
39
+ ├── crates/ # Rust 子 crate(runtime-core、explore、mux、sparkshell)
40
+ └── docs/ # 详尽文档(contracts、reference、release-notes、状态模型)
41
+ ```
42
+
43
+ **关键架构决策**:
44
+ - **双层状态存储**:`.omx/state/<mode>-state.json`(权威)+ `skill-active-state.json`(兼容/可见层)
45
+ - **Session 作用域优先**:session-scoped state > current session > root scope fallback
46
+ - **混合语言运行时**:TS 负责编排与 CLI,Rust 负责高性能探索和 runtime 桥接
47
+ - **Codex 插件 + 原生 Hooks 双轨**:既有 `.codex/hooks.json` 原生 hook,也有 OMX plugin hooks
48
+
49
+ ---
50
+
51
+ ## 三、核心功能模块
52
+
53
+ | 模块 | 职责 | gxpm 映射参考 |
54
+ |------|------|---------------|
55
+ | **cli/omx.ts** | CLI 入口,处理 `main(argv)` | `bin/gxpm` 系列脚本 |
56
+ | **config/** | 解析 `.omx-config.json`、Codex `config.toml`、模型路由 | `core/config.ts` |
57
+ | **hooks/** | `UserPromptSubmit` 关键词检测、`SessionStart` 上下文注入、`Stop` 续行判断 | `.githooks/` 和 host adapter |
58
+ | **modes/base.ts** | 统一模式生命周期:start → update → cancel | gxpm phase gate |
59
+ | **state/** | 工作流过渡决策、协调同步 | gxpm issue state graph |
60
+ | **runtime/** | 通用执行循环、结果分类 | gxpm implement/execute loop |
61
+ | **team/** | tmux 多窗格并行工作器、任务分解、worktree 隔离 | gxpm(未来)并行执行层 |
62
+ | **ralph/** | 持久化完成循环:进度台账、PRD 迁移、视觉校验门 | gxpm implement → verify → land |
63
+ | **mcp/** | 暴露 `omx_state.*` 工具给 Codex/MCP 客户端 | gxpm capability runtime |
64
+ | **agents/** | 原生 Codex Agent TOML 生成(30+ 角色定义) | gxpm skills/hosts |
65
+
66
+ ---
67
+
68
+ ## 四、技术栈
69
+
70
+ - **Node.js 20+ + TypeScript**:主运行时与编排
71
+ - **Rust**:辅助运行时(`omx-explore`、`omx-mux`、`omx-runtime-core`、`omx-sparkshell`)
72
+ - **Cargo**:构建 Native 代理/探索 harness
73
+ - **tmux**:macOS/Linux 团队并行执行的基础设施
74
+ - **MCP (Model Context Protocol)**:状态读写、wiki、trace 等服务器能力
75
+
76
+ ---
77
+
78
+ ## 五、Codex CLI 工作流设计
79
+
80
+ ### 5.1 Native Hook 映射矩阵
81
+
82
+ | Codex Hook | OMX 处理 | 状态 |
83
+ |-----------|---------|------|
84
+ | `SessionStart` | 刷新 session bookkeeping、注入 wiki 上下文、恢复开发者上下文 | native |
85
+ | `UserPromptSubmit` | 关键词检测(`$ralph`/`$team`/`$ralplan`)、状态种子、triage 路由 | native |
86
+ | `PreToolUse` (Bash) | `rm -rf` 警告、内联 `git commit` 拦截、文档刷新警告 | native-partial |
87
+ | `PostToolUse` (Bash) | 命令失败/权限错误指引、MCP 传输死亡检测 | native-partial |
88
+ | `Stop` | Ralph/Team/Autopilot 续行判断、auto-nudge、生命周期元数据 | native-partial |
89
+
90
+ **关键设计**:`.codex/hooks.json` 是**共享所有权文件** —— OMX 只刷新自己管理的 wrapper 条目,保留用户自定义 hook。`omx uninstall` 也只移除 OMX 管理的部分。
91
+
92
+ ### 5.2 标准工作流(Canonical Workflow)
93
+
94
+ ```
95
+ $deep-interview → $ralplan → ($team | $ralph)
96
+ ```
97
+
98
+ - **deep-interview**:澄清需求、边界、非目标
99
+ - **ralplan**:生成并审批实现计划
100
+ - **team**:tmux 并行执行(适合大任务)
101
+ - **ralph**:持久化单所有者完成循环(适合需要保证完成的场景)
102
+
103
+ ### 5.3 关键词检测与状态种子
104
+
105
+ `src/hooks/keyword-detector.ts` 是工作流路由的核心:
106
+ - 检测 `$skill` 关键词并排序
107
+ - 记录 `skill-active-state.json`
108
+ - 对 `$ralph` 只做**状态种子**,不启动 CLI 进程
109
+ - 多关键词支持:`$ralplan $team $ralph` 会延迟执行技能,保留 planning 为当前主模式
110
+
111
+ ### 5.4 插件 Hooks 扩展点
112
+
113
+ - 用户可在 `.omx/hooks/*.mjs` 编写插件
114
+ - 暴露事件:`session-start`、`keyword-detector`、`pre-tool-use`、`post-tool-use`、`stop`、`session-end`、`turn-complete`、`session-idle`
115
+ - SDK 提供:`sdk.state.read/write`(插件命名空间隔离)、`sdk.tmux.sendKeys`、`sdk.log.info/warn/error`
116
+
117
+ ---
118
+
119
+ ## 六、配置系统与扩展点
120
+
121
+ ### 6.1 三层配置来源
122
+
123
+ 1. **Shell 环境变量**(最高优先级):`OMX_DEFAULT_FRONTIER_MODEL`、`OMX_DEFAULT_STANDARD_MODEL`
124
+ 2. **`.omx-config.json`**:用户级(`~/.codex/`)或项目级(`./.codex/`)
125
+ 3. **Codex `config.toml`**:读取 root model、provider、model_providers
126
+
127
+ ### 6.2 模型路由解析链
128
+
129
+ ```
130
+ mode-specific > models.default > OMX_DEFAULT_FRONTIER_MODEL > config.toml model > built-in default (gpt-5.5)
131
+ ```
132
+
133
+ - 团队低复杂度 worker:`team_low_complexity` 别名支持三种 key 风格(snake/kebab/camel)
134
+ - **显式规则**:禁止从模型名称子串推断 reasoning effort
135
+
136
+ ### 6.3 扩展点
137
+
138
+ | 扩展点 | 机制 | 位置 |
139
+ |--------|------|------|
140
+ | **Skills** | SKILL.md + frontmatter | `skills/`(项目级)或 `~/.codex/skills/`(用户级) |
141
+ | **Prompts** | Markdown 角色定义 | `prompts/` |
142
+ | **Native Agents** | TOML 生成 | `.codex/agents/` |
143
+ | **Plugin Hooks** | ES Module 导出 `onHookEvent` | `.omx/hooks/*.mjs` |
144
+ | **MCP Servers** | 通过 `.mcp.json` / `config.toml` 注册 | `config/mcp-registry.ts` |
145
+ | **Wiki** | Markdown-first、搜索优先 | `.omx/wiki/` |
146
+
147
+ ### 6.4 AGENTS.md 合并策略
148
+
149
+ - `omx setup --merge-agents` 在现有 `AGENTS.md` 中插入 OMX 生成区块
150
+ - 使用 `<!-- OMX:AGENTS:START -->` / `<!-- OMX:AGENTS:END -->` 标记
151
+ - 非交互式 setup 默认跳过已有 `AGENTS.md`(避免覆盖用户定制)
152
+
153
+ ---
154
+
155
+ ## 七、Agent 执行循环与状态管理
156
+
157
+ ### 7.1 状态模型(Explicit Terminal Stop Model)
158
+
159
+ 生命周期结果:`finished` / `blocked` / `failed` / `userinterlude` / `askuserQuestion`
160
+
161
+ **读取优先级**:
162
+ 1. `lifecycle_outcome`(规范生命周期元数据)
163
+ 2. 遗留 `run_outcome`
164
+ 3. 从 `current_phase` 推断
165
+
166
+ ### 7.2 工作流过渡规则(Workflow Transition)
167
+
168
+ `src/state/workflow-transition.ts` 实现了严格的状态机:
169
+
170
+ | 源模式 | 目标模式 | 结果 |
171
+ |--------|---------|------|
172
+ | deep-interview | ralplan | auto-complete 源模式 |
173
+ | ralplan | team / ralph / autopilot | auto-complete 源模式 |
174
+ | team | ralph | overlap(共存) |
175
+ | ralph | team | overlap(共存) |
176
+ | execution → planning | — | **deny**(禁止回滚) |
177
+
178
+ **关键不变量**:
179
+ - 执行类模式回滚到规划类模式永远不允许自动完成
180
+ - 未在白名单中的过渡默认拒绝
181
+ - native-hook 输出是展示层,不是独立决策引擎
182
+
183
+ ### 7.3 通用执行循环(Run Loop)
184
+
185
+ `src/runtime/run-loop.ts` 提供 `runUntilTerminal(step, options)`:
186
+ - 每次迭代返回 `{ outcome, state }`
187
+ - 结果分类:`progress` / `continue`(非终端) vs `finish` / `blocked_on_user` / `failed` / `cancelled`(终端)
188
+ - 支持 `maxIterations` 和 `onIteration` 回调
189
+ - 标准化别名映射:`done` → `finish`, `error` → `failed`, `abort` → `cancelled`
190
+
191
+ ### 7.4 Team 并行运行时
192
+
193
+ **阶段管道**:`team-plan` → `team-prd` → `team-exec` → `team-verify` → `team-fix`(循环)→ `complete`/`failed`
194
+
195
+ **基础设施**:
196
+ - **tmux**:leader 窗格 + worker 窗格分割
197
+ - **worktree**:每个 worker 可运行在独立 git worktree(`--worktree`)
198
+ - **Mailbox**:`.omx/state/team/<team>/mailbox/leader-fixed.json` 进行 leader-worker 通信
199
+ - **Dispatch Request**:任务分派状态机(pending → notified → delivered → integrated)
200
+ - **Worker CLI 多态**:支持 Codex 或 Claude CLI 作为 worker(`OMX_TEAM_WORKER_CLI`)
201
+
202
+ ### 7.5 Ralph 持久化循环
203
+
204
+ - **Context Snapshot**:`.omx/context/{task-slug}-{timestamp}.md` 强制 grounding
205
+ - **Progress Ledger**:`.omx/state/ralph-progress.json` 记录迭代、视觉反馈
206
+ - **PRD 模式**:`--prd` 先初始化产品需求文档
207
+ - **完成门控**:
208
+ 1. 零 pending TODO
209
+ 2. 新鲜测试/构建通过
210
+ 3. Architect 验证(STANDARD tier 起)
211
+ 4. AI-slop-cleaner 清理
212
+ 5. 回归重验证
213
+
214
+ ---
215
+
216
+ ## 八、对 gxpm 的借鉴价值
217
+
218
+ ### 8.1 可直接复用的模式 ✅
219
+
220
+ | # | 模式 | 具体借鉴方式 |
221
+ |---|------|-------------|
222
+ | 1 | **显式终端停止模型** | gxpm phase gate 可引入 `lifecycle_outcome` 规范层,替代单一 `phase` 推断 |
223
+ | 2 | **工作流过渡白名单** | gxpm issue 的 phase 推进可引入 `evaluateWorkflowTransition`,防止非法回滚 |
224
+ | 3 | **Session 作用域状态隔离** | gxpm 的 `.gxpm/issues/<id>/` 可进一步引入 `session-scoped state` 优先于 `root scope` |
225
+ | 4 | **共享所有权配置** | `.codex/hooks.json` 的共享所有权设计可直接用于 gxpm 的 `.githooks/` |
226
+ | 5 | **AGENTS.md 合并标记** | `<!-- OMX:AGENTS:START/END -->` 的区块合并策略比全文件覆盖更安全 |
227
+ | 6 | **模型路由解析链** | gxpm host adapter 可引入 `mode-specific > default > env > built-in` 的模型选择链 |
228
+ | 7 | **Context Snapshot 强制门控** | Ralph 的 context snapshot 可移植到 gxpm 的 `dispatch→implement` 阶段 |
229
+ | 8 | **Run Loop 抽象** | `runUntilTerminal(step)` 的通用循环可封装为 gxpm capability runtime 的基础执行原语 |
230
+ | 9 | **MCP 状态服务器** | `omx_state.*` MCP 工具将状态读写暴露给 agent,gxpm 可将 artifact 读写封装为 MCP tools |
231
+ | 10 | **Skill frontmatter 元数据** | `--- name: ralph description: ... ---` 的标准化 SKILL.md 头部可被 gxpm skills 采用 |
232
+
233
+ ### 8.2 应避免的陷阱 ❌
234
+
235
+ | # | 陷阱 | 原因 | gxpm 应对建议 |
236
+ |---|------|------|---------------|
237
+ | 1 | **过度依赖 tmux** | 强绑定 tmux,Windows/WSL 体验降级、测试复杂 | 优先考虑原生 subagent/MCP 并行,tmux 仅作为可选后端 |
238
+ | 2 | **双层状态同步风险** | `mode-state.json` + `skill-active-state.json` 多次导致 "ghost state" | 坚持**单一真相源**(`.gxpm/issues/<id>/`),若需兼容层则引入显式协调 helper |
239
+ | 3 | **Hooks fallback 矩阵过复杂** | native/native-partial/runtime-fallback/not-supported-yet 四级,调试困难 | 优先走**原生 host adapter 扩展点**,减少 fallback 层 |
240
+ | 4 | **Rust/TS 混合构建复杂度** | 需要 Cargo + Node 双构建链,测试和发布流程重 | gxpm 当前纯 TS/Bun 是优势,Rust 引入需有明确性能诉求 |
241
+ | 5 | **进程级 worker 过重** | 每个 worker 是完整 Codex/Claude CLI 进程,启动慢、资源消耗大 | 使用**轻量级 task delegation** 而非完整进程复制 |
242
+ | 6 | **Setup 副作用过多** | `omx setup` 修改多处位置,回滚复杂 | `gxpm-init` 应更模块化,支持 dry-run 和 scope 选择 |
243
+ | 7 | **Prompt 路由的隐性状态** | `keyword-detector` + `triage-heuristic` 在 prompt submit 时注入路由上下文 | gxpm 应让**issue id 显式驱动路由**,避免隐式分类干扰 |
244
+
245
+ ---
246
+
247
+ ## 九、关键文件映射
248
+
249
+ | OMX 文件路径 | 内容 | gxpm 对应 |
250
+ |-------------|------|-----------|
251
+ | `docs/STATE_MODEL.md` | 状态权威、过渡规则、审计字段 | `docs/architecture/gxpm-v0-contract.md` |
252
+ | `docs/codex-native-hooks.md` | 原生 hook 映射矩阵 | `docs/governance/host-adapter.md` |
253
+ | `docs/hooks-extension.md` | 插件扩展点、SDK 接口 | `hosts/codex.ts` 扩展设计 |
254
+ | `src/state/workflow-transition.ts` | 工作流过渡决策引擎 | `core/gate.ts` |
255
+ | `src/modes/base.ts` | 统一模式生命周期 | `core/dispatch.ts` |
256
+ | `src/runtime/run-loop.ts` | 通用终端执行循环 | capability runtime 执行原语 |
257
+ | `src/team/orchestrator.ts` | Team 阶段管道 | 未来并行执行层参考 |
258
+ | `src/team/runtime.ts` | Team tmux 运行时、worktree、mailbox | `core/worktree.ts`(如存在) |
259
+ | `src/config/models.ts` | 模型路由解析链 | `hosts/` 模型选择逻辑 |
260
+ | `src/hooks/keyword-detector.ts` | 关键词检测与状态种子 | `core/command-probe.ts` |
261
+ | `skills/ralph/SKILL.md` | 持久化完成循环的完整契约 | `skills/gxpm/` 系列 |
262
+ | `skills/team/SKILL.md` | 团队并行执行的完整契约 | 未来并行执行层参考 |
263
+
264
+ ---
265
+
266
+ ## 十、适配建议
267
+
268
+ 1. **生命周期模型规范化**:在 gxpm 的 phase gate 中引入 `lifecycle_outcome` 规范层(`finished`/`blocked`/`failed`/`cancelled`),替代单一的 `phase` 字符串推断,增强跨会话恢复能力。
269
+ 2. **工作流过渡规则**:引入 `evaluateWorkflowTransition` 白名单机制,明确允许和禁止的 phase 转换(如 `qa→implement` 禁止自动完成)。
270
+ 3. **AGENTS.md 合并策略**:`gxpm-init` 采用标记式合并(`<!-- GXPM:AGENTS:START/END -->`),避免覆盖用户已有定制。
271
+ 4. **模型路由链**:host adapter 引入 `mode-specific > default > env > built-in` 的模型选择链,支持 per-skill/per-phase 模型降级。
272
+ 5. **MCP 状态暴露**:将 `.gxpm/issues/<id>/` 的 artifact 读写封装为 MCP tools(如 `gxpm_state.read`、`gxpm_state.write`),实现 agent 自托管状态。
273
+ 6. **Context Snapshot**:在 `dispatch→implement` 阶段要求 agent 完成上下文快照(`.gxpm/issues/<id>/context-snapshot.md`),强制 grounding。
274
+
275
+ ---
276
+
277
+ ## 十一、一句话总结
278
+
279
+ > oh-my-codex 在**工作流过渡规则、显式生命周期模型、配置分层解析、共享所有权 hook、AGENTS.md 合并策略**方面提供了非常成熟的参考实现,建议 gxpm 在 capability runtime 和 phase gate 设计中重点吸收;同时,OMX 作为 Codex wrapper 的某些复杂兼容层(双层状态、tmux 进程级并行)在 gxpm 的独立产品定位下可以简化或避免。