Commit 9508a5527200ff4b80767adc047757615541060a

Authored by zichun
1 parent 85429095

feat(lite): merge test-gate + module-report + milestone-tag into one milestone skill

skills/coding/milestone-tag/SKILL.md deleted
1   ----
2   -name: milestone-tag
3   -description: 完成报告生成后,把当前分支(module-* 后端 / frontend-phase 前端)本地合并进默认分支并打里程碑 tag(milestone/<id>),把 tag 名回写 docs/08(§ 二 模块行 / § 三 整体里程碑)+ 报告 § ⑫,然后自动回调 coding-start 推进下一阶段。全程无人工介入。
4   -user-invocable: false
5   -allowed-tools: Read Edit Skill Bash(git *)
6   ----
7   -
8   -**所有输出必须使用中文。**
9   -
10   -# milestone-tag
11   -
12   -## 前置条件
13   -
14   -- `module-report` 已生成报告并 commit 到当前分支
15   -- `test-gate` 绿色,test-gate.md 已 commit 到当前分支
16   -- 当前分支 = `module-<module_id>` 或 `frontend-phase`(由 `module-start` 步骤 3 / `frontend-start` 步骤 4 切入)
17   -
18   -## 执行步骤
19   -
20   -### 步骤 1:验证当前分支并推断 phase
21   -
22   -`git branch --show-current`:
23   -
24   -- 匹配 `module-*` → `phase=backend`,`phase_id=` 去掉 `module-` 前缀,`tag=milestone/<phase_id>`
25   -- 等于 `frontend-phase` → `phase=frontend`,`phase_id=frontend-phase`,`tag=milestone/frontend-phase`
26   -- 其它 → 停下报错(不自动建分支——分支职责在上游 `module-start` / `frontend-start`)
27   -
28   -### 步骤 2:验证 worktree 干净
29   -
30   -`git status --porcelain` 输出非空 → 停下打印 dirty 文件清单:
31   -
32   -```
33   -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
34   - [milestone-tag] ⚠️ worktree 不干净,无法集成 + 打里程碑
35   -
36   - <git status 输出>
37   -
38   - 集成前所有 evidence 必须已 commit。检查点:
39   - - test-gate 步骤 3 是否已 commit test-gate.md?
40   - - module-report 步骤 5 是否已 commit 报告 + cross-module log?
41   -
42   - 修复:git add <files> && git commit -m "...",然后重跑 /erp-workflow:coding-start。
43   -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
44   -```
45   -
46   -### 步骤 3:探测本地默认分支
47   -
48   -无远程,用 `git rev-parse --verify` 依次探测本地 `main` / `master`,取第一个存在的作为 `default_branch`。两者都不存在 → 停下报错。
49   -
50   -### 步骤 4:本地集成(合并模块分支进默认分支)
51   -
52   -替代原来的"远程 push + 人工 MR merge"——本地完成集成:
53   -
54   -```bash
55   -git checkout <default_branch>
56   -git merge --no-ff <current_branch> -m "merge(<phase_id>): integrate <current_branch>"
57   -```
58   -
59   -合并冲突 → 停下打印冲突文件清单,引导人工解决后重跑 `/erp-workflow:coding-start`(不自动 `--abort`、不强制覆盖)。
60   -
61   -### 步骤 5:回写 docs/08 里程碑字段并 commit
62   -
63   -在 `default_branch` 上 `Edit docs/08-模块任务管理.md`:
64   -
65   -- **phase=backend**:在 § 二 中找到当前模块的 ` - 里程碑: —` 改为 ` - 里程碑: milestone/<phase_id>`
66   -- **phase=frontend**:在 § 三 中找到 `- 整体里程碑: —` 改为 `- 整体里程碑: milestone/frontend-phase`
67   -
68   -```bash
69   -git add docs/08-模块任务管理.md
70   -git commit -m "chore(<phase_id>): record milestone/<phase_id> in docs/08"
71   -```
72   -
73   -### 步骤 6:在默认分支 HEAD 打 annotated 里程碑 tag
74   -
75   -```bash
76   -git tag -a milestone/<phase_id> -m "milestone(<phase_id>): <phase> 阶段完成"
77   -```
78   -
79   -tag 已存在(重跑场景)→ 跳过,不重复打。
80   -
81   -### 步骤 7:追加里程碑 tag 到完成报告 § ⑫ 并 commit
82   -
83   -`Edit docs/superpowers/module-reports/<date>-<phase_id>.md` 的 § ⑫,把 `{{milestone_tag}}` 替换为 `milestone/<phase_id>`(已替换则跳过)。
84   -
85   -```bash
86   -git add docs/superpowers/module-reports/<date>-<phase_id>.md
87   -git commit -m "docs(<phase_id>): record milestone/<phase_id> in completion report"
88   -```
89   -
90   -### 步骤 8:自动回调 coding-start 推进下一阶段
91   -
92   -本阶段已集成 + 打 tag,**不停下等人工**。立即用 Skill 工具调用 `coding-start`:
93   -
94   -- coding-start 重新做后端 / 前端完成性检查(按 `里程碑:` 字段 + `git tag -l`),未完则推进下一模块 / 前端阶段,全部完成则打印"所有阶段已完成"。
95   -
96   -## 参考
97   -
98   -- 上游:`module-report`
99   -- 下游:`coding-start`(自治回调,由其路由下一阶段)
skills/coding/milestone/SKILL.md 0 → 100644
  1 +---
  2 +name: milestone
  3 +description: 单元(后端模块 / 前端阶段)全部 approve 后的收尾闸门:子会话跑测试 → 写精简完成报告 → 本地 merge 进默认分支 + 打 milestone/<id> tag + 回写 docs/08 → 自动回调 coding-start。phase 由当前分支推断。
  4 +user-invocable: false
  5 +allowed-tools: Read Write Edit Skill Agent Bash(git *)
  6 +---
  7 +
  8 +**所有输出必须使用中文。**
  9 +
  10 +# milestone
  11 +
  12 +单元(后端模块 / 前端阶段)所有功能完成、所有 approve 齐全后的唯一收尾闸门。把原来三个 skill 的职责合并为四个阶段依次执行:
  13 +
  14 +1. **推断 phase**(分支名 → backend / frontend)
  15 +2. **测试闸门**(子会话跑测试,绿才能继续)
  16 +3. **精简完成报告**(6 节,commit 到当前分支)
  17 +4. **本地集成 + tag + 回写 docs/08 + 自动回调**
  18 +
  19 +## 阶段 0:推断 phase 与关键变量
  20 +
  21 +执行 `git branch --show-current`:
  22 +
  23 +- 匹配 `module-<id>` → `phase=backend`,`phase_id=<id>`(去掉 `module-` 前缀),`tag=milestone/<id>`,`test_command=./scripts/test.sh`
  24 +- 等于 `frontend-phase` → `phase=frontend`,`phase_id=frontend-phase`,`tag=milestone/frontend-phase`;`test_command` 从 `docs/04-技术规范.md § 零 frontend.test_command` / `frontend.e2e_command` 拼接(缺失则 `pnpm test:ci && pnpm e2e:ci`)
  25 +- 其它任何分支 → **硬停**,打印以下诊断并终止(分支切换职责在上游 `phase-driver`,不在此处):
  26 +
  27 + ```
  28 + [milestone] ⛔ 当前分支 <branch> 不满足执行条件。
  29 + milestone 只能在 module-<id> 或 frontend-phase 分支上运行。
  30 + 请检查 phase-driver 是否正确切换了分支。
  31 + ```
  32 +
  33 +记录变量:`branch`(原始分支名),`phase`,`phase_id`,`tag`,`test_command`。
  34 +
  35 +## 阶段 1:测试闸门(子会话硬门)
  36 +
  37 +> **护栏(绝对规则):绝不在主会话直接执行测试命令。必须通过 Agent 子会话(general-purpose)运行,主会话只接收结构化 JSON 结论。**
  38 +
  39 +1. 派发 Agent 子会话,传入 `test_command`,要求子会话仅返回以下结构化 JSON(不输出任何描述文字):
  40 +
  41 + ```json
  42 + {
  43 + "command": "<实际执行的命令>",
  44 + "exit_code": <int>,
  45 + "passed": <int>,
  46 + "failed": <int>,
  47 + "stdout_excerpt": "<最后 30 行,含 FAIL 摘要>"
  48 + }
  49 + ```
  50 +
  51 +2. 接收 JSON 后保存为本地变量(`test_json`),不写独立文件——测试证据将折叠进阶段 2 的报告 `## ② 测试证据` 节。
  52 +
  53 +3. **`exit_code = 0`(绿色)** → 进入阶段 2。
  54 +
  55 +4. **`exit_code ≠ 0`(红色)** → 打印以下横幅并**停止**,不进入任何下游阶段,不自动重试,不自动修复:
  56 +
  57 + ```
  58 + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  59 + [milestone] ⚠️ 测试未通过 (phase=<phase>)
  60 + 命令: <test_command>
  61 + 退出码: <exit_code>
  62 + 失败: <failed>
  63 + 摘要: <stdout_excerpt>
  64 +
  65 + 按失败类型选恢复路径:
  66 + ① 测试脆弱(偶发 flakey)→ 重跑 /erp-workflow:coding-start
  67 + (phase-driver 幂等:所有单元已 approve 会跳过功能循环,直接重跑本闸门)
  68 + ② 真有回归
  69 + 后端:rm docs/superpowers/reviews/*-<REQ-id>.md
  70 + → 重跑 /erp-workflow:coding-start(phase-driver 视该 REQ 未完成,重走功能循环)
  71 + 前端:rm docs/superpowers/reviews/*-FE-<NN>.md
  72 + → 重跑 /erp-workflow:coding-start(phase-driver 视该 FE 未完成,重走功能循环)
  73 + ③ 环境 / 依赖问题(DB 连不上 / 外部 API 失败 / 证书失效 / Playwright 浏览器未装)
  74 + → Skill(interrupt-check) 追加 Blocker → 修复环境
  75 + → 参考 .env.local / docs/04 § 零 环境配置 → 重跑
  76 + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  77 + ```
  78 +
  79 +## 阶段 2:精简完成报告
  80 +
  81 +> **核心约束:只收集 git 摘要,绝不把 diff 正文读入主会话上下文。**
  82 +
  83 +### 2.1 收集输入
  84 +
  85 +**后端(phase=backend):**
  86 +
  87 +- §③ 文件变更:
  88 + ```bash
  89 + git diff --stat <branch_start>..HEAD
  90 + git diff --name-status <branch_start>..HEAD
  91 + git log --oneline <branch_start>..HEAD
  92 + ```
  93 + `<branch_start>` = 本模块分支从默认分支分叉的 commit(`git merge-base <branch> <default_branch>`)
  94 +- §④ Migration:`git diff --name-only --diff-filter=A <branch_start>..HEAD -- 'sql/migrations/V*.sql'` 列新增 migration 文件名;若有,逐个 Read 第一行作简短说明。
  95 +- §⑤ 偏离:Read `docs/superpowers/reviews/<日期>-<phase_id>-*.md`(如存在),提取偏离与取舍说明。
  96 +- §① 覆盖单元:扫 `docs/superpowers/reviews/` 下属于本模块的 `<日期>-<REQ-id>.md`,列出 REQ ID 与标题。
  97 +
  98 +**前端(phase=frontend):**
  99 +
  100 +- §③ 文件变更:同上,区间为 `frontend-phase` 分支起点 → HEAD
  101 +- §① 覆盖单元:扫 `docs/superpowers/reviews/<日期>-FE-*.md`,按 FE-NN 顺序列出
  102 +- §④ Migration:填 `N/A(前端阶段)`
  103 +- §⑤ 偏离:除常规偏离外,额外审查"实际渲染 DOM 与各 FE 关联原型主结构的差异",逐 FE 列出(关联原型清单见每个 FE 的 spec)
  104 +
  105 +### 2.2 渲染并 commit 报告
  106 +
  107 +按 `${CLAUDE_SKILL_DIR}/templates/milestone-report-template.md` 渲染 6 节。`{{milestone_tag}}` 先填占位符 `{{milestone_tag}}`(阶段 3 步骤 6 回写)。
  108 +
  109 +写入 `docs/superpowers/module-reports/<YYYY-MM-DD>-<phase_id>.md`。
  110 +
  111 +```bash
  112 +git add docs/superpowers/module-reports/<YYYY-MM-DD>-<phase_id>.md
  113 +git commit -m "docs(<phase_id>): add completion report"
  114 +```
  115 +
  116 +**此 commit 是必需的**——阶段 3 的 worktree-clean 前置检查依赖于此。
  117 +
  118 +## 阶段 3:本地集成 + tag + 回写 docs/08
  119 +
  120 +### 3.1 验证 worktree 干净
  121 +
  122 +```bash
  123 +git status --porcelain
  124 +```
  125 +
  126 +输出非空 → **停止**,打印 dirty 文件清单:
  127 +
  128 +```
  129 +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  130 + [milestone] ⚠️ worktree 不干净,无法集成 + 打里程碑
  131 +
  132 + <git status 输出>
  133 +
  134 + 集成前所有 evidence 必须已 commit。检查点:
  135 + - 阶段 2 是否已 commit 完成报告?
  136 + (阶段 1 测试证据已折叠进报告,无单独文件需 commit)
  137 +
  138 + 修复:git add <files> && git commit -m "...",然后重跑 /erp-workflow:coding-start。
  139 +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  140 +```
  141 +
  142 +### 3.2 探测本地默认分支
  143 +
  144 +用 `git rev-parse --verify` 依次探测本地 `main`、`master`,取第一个存在的作为 `default_branch`。两者都不存在 → 停止报错(不自动创建分支)。
  145 +
  146 +### 3.3 本地 merge
  147 +
  148 +```bash
  149 +git checkout <default_branch>
  150 +git merge --no-ff <branch> -m "merge(<phase_id>): integrate <branch>"
  151 +```
  152 +
  153 +合并冲突 → 停止,打印冲突文件清单,引导人工解决后重跑 `/erp-workflow:coding-start`(不自动 `--abort`,不强制覆盖)。
  154 +
  155 +### 3.4 回写 docs/08 里程碑字段
  156 +
  157 +在 `default_branch` 上 `Edit docs/08-模块任务管理.md`:
  158 +
  159 +- **phase=backend**:在 § 二 找到当前模块行 ` - 里程碑: —` → ` - 里程碑: milestone/<phase_id>`
  160 +- **phase=frontend**:在 § 三 找到 `- 整体里程碑: —` → `- 整体里程碑: milestone/frontend-phase`
  161 +
  162 +```bash
  163 +git add docs/08-模块任务管理.md
  164 +git commit -m "chore(<phase_id>): record milestone/<phase_id> in docs/08"
  165 +```
  166 +
  167 +### 3.5 打 annotated tag
  168 +
  169 +```bash
  170 +git tag -a milestone/<phase_id> -m "milestone(<phase_id>): <phase> 阶段完成"
  171 +```
  172 +
  173 +tag 已存在(重跑场景)→ 跳过,不重复打。
  174 +
  175 +### 3.6 追加 tag 到报告 §⑥ 并 commit
  176 +
  177 +`Edit docs/superpowers/module-reports/<YYYY-MM-DD>-<phase_id>.md`,把 `{{milestone_tag}}` 替换为 `milestone/<phase_id>`(已替换则跳过)。
  178 +
  179 +```bash
  180 +git add docs/superpowers/module-reports/<YYYY-MM-DD>-<phase_id>.md
  181 +git commit -m "docs(<phase_id>): record milestone/<phase_id> in completion report"
  182 +```
  183 +
  184 +## 阶段 4:自动回调
  185 +
  186 +本阶段已集成 + 打 tag,**不停下等人工**。立即调用:
  187 +
  188 +```
  189 +Skill(coding-start)
  190 +```
  191 +
  192 +coding-start 重新检查后端 / 前端完成性(按 `里程碑:` 字段 + `git tag -l`),未完则推进下一模块 / 前端阶段;全部完成则打印"所有阶段已完成"。
  193 +
  194 +## 护栏
  195 +
  196 +- **绝不**在主会话直接执行 `./scripts/test.sh` / `pnpm test` / `pnpm e2e`——必须通过 Agent 子会话
  197 +- 本闸门是里程碑 tag 前唯一的硬测试门——红色时**绝不**跳过直接进入集成 / 打 tag
  198 +- worktree 不干净时不执行 merge(停下,不修复)
  199 +- 合并冲突时不自动解决(停下,指引人工)
  200 +
  201 +## 参考
  202 +
  203 +- `${CLAUDE_SKILL_DIR}/templates/milestone-report-template.md`(6 节精简报告)
  204 +- 上游:`phase-driver`(后端所有 REQ / 前端所有 FE 全部 approve 后派发到此)
  205 +- 下游:`coding-start`(自治回调,由其路由下一阶段)
... ...
skills/coding/milestone/templates/milestone-report-template.md 0 → 100644
  1 +# 完成报告 — {{phase_id}}({{phase}})
  2 +
  3 +> 生成: {{date}} | 分支: {{branch}} | 里程碑: {{milestone_tag}}
  4 +
  5 +## ① 单元信息
  6 +- 类型: {{phase}} | ID: {{phase_id}} | 名称: {{name}}
  7 +- 覆盖单元(REQ / FE): {{covered_list}}
  8 +
  9 +## ② 测试证据
  10 +- 命令: {{test_command}} | 退出码: {{exit_code}} | 通过/失败: {{passed}}/{{failed}}
  11 +- 摘要: {{stdout_excerpt}}
  12 +
  13 +## ③ 文件变更
  14 +{{git_diff_stat}}
  15 +
  16 +## ④ 数据库 / Migration(前端填 N/A)
  17 +{{migrations_summary}}
  18 +
  19 +## ⑤ 偏离与取舍
  20 +{{deviations}} <!-- 无则写"无偏离";前端额外列 DOM 与关联原型主结构差异 -->
  21 +
  22 +## ⑥ 里程碑
  23 +- tag: {{milestone_tag}}
  24 +- 下一步: {{next_unit}}
... ...
skills/coding/module-report/SKILL.md deleted
1   ----
2   -name: module-report
3   -description: 本地测试闸门通过后,生成标准化 12 节完成报告(后端模块 OR 前端阶段)并 commit 到当前分支(供里程碑标记)。
4   -user-invocable: false
5   -allowed-tools: Read Write Glob Grep Skill Bash(git diff *) Bash(git log *) Bash(git add *) Bash(git commit *) Bash(git branch *)
6   ----
7   -
8   -**所有输出必须使用中文。**
9   -
10   -# module-report
11   -
12   -`test-gate` 绿色后渲染 12 节完成报告,commit 到当前分支供里程碑标记。**只读摘要,不读 diff 正文进上下文**。
13   -
14   -按当前分支自动推断 `phase`:
15   -
16   -- `module-<id>` → `phase=backend`,`phase_id=<id>`
17   -- `frontend-phase` → `phase=frontend`,`phase_id=frontend-phase`
18   -- 其它分支 → 硬停
19   -
20   -## 执行步骤
21   -
22   -### 步骤 0:推断 phase 与上下文
23   -
24   -从 `git branch --show-current` 取分支名,按上述规则推出 `phase` 与 `phase_id`。
25   -
26   -1. 验证上游 `test-gate` 已绿(读 `docs/superpowers/module-reports/<phase_id>-test-gate.md`);红色则停。
27   -
28   -2. 收集输入(核心约束:取 git 摘要而非 diff 正文):
29   -
30   - **后端阶段 (phase=backend)**:
31   - - § ③ 文件变更:`git diff --stat` / `--name-status` / `git log --oneline`(区间:module 分支起点 → HEAD)
32   - - § ② / § ⑨:Read `docs/superpowers/{specs,plans,reviews}/<日期>-<本模块的 REQ>.md`
33   - - § ⑤:Read `docs/superpowers/module-reports/<phase_id>-test-gate.md`
34   - - § ⑥ Migration:`git diff --name-only --diff-filter=A -- 'sql/migrations/V*.sql'` 列新增 migration,每个 Read 第一行作说明
35   - - § ⑦ 跨模块改动:Read `docs/superpowers/module-reports/<phase_id>-cross-module.md`(如存在)
36   - - § ④ 读写的表:用 grep 定位涉 SQL 的文件后按需读片段,**不全量读 docs/03**
37   -
38   - **前端阶段 (phase=frontend)**:
39   - - § ① 模块信息:`module_id` 填 `frontend-phase`,`module_name` 填 `前端阶段(整体)`
40   - - § ② 改为"FE 完成清单":扫 `docs/superpowers/{specs,plans,reviews}/<日期>-FE-*.md`,按 FE-NN 顺序列出
41   - - § ③ 文件变更:`git diff --stat` 区间 `frontend-phase` 分支起点 → HEAD
42   - - § ④ 数据库使用表:填 `N/A(前端阶段)`
43   - - § ⑤:Read `docs/superpowers/module-reports/frontend-phase-test-gate.md`
44   - - § ⑥ Migration:填 `N/A(前端阶段)`
45   - - § ⑦:填 `N/A(前端阶段不涉及跨模块代码改动;token 漂移见 § ⑧)`
46   - - § ⑧ 偏离清单:除常规偏离外,额外审查"实际渲染 DOM 与各 FE 关联原型主结构的差异",逐 FE 列出(关联原型清单见每个 FE 的 spec)
47   - - § ⑪ 下一模块预览:填"上线/部署后续步骤"
48   -
49   -3. 按 `${CLAUDE_SKILL_DIR}/templates/module-report-template.md` 渲染 12 节。
50   -
51   -4. **硬验证**:
52   - - § ⑦(仅 backend):跨模块日志中任何 `TBD(CC 补)` 或敷衍填充 → 调用 `Skill(cross-module-log)` 一次性批量补齐,补完回本步骤重验(**整模块周期内唯一补 TBD 的时机**)
53   - - § ⑧:必须列举所有偏离之处;若无,写"无偏离"
54   -
55   -5. 写入 `docs/superpowers/module-reports/<YYYY-MM-DD>-<phase_id>.md`,连同跨模块日志(如存在)一起 commit 到当前分支:
56   - ```bash
57   - git add docs/superpowers/module-reports/<YYYY-MM-DD>-<phase_id>.md
58   - [ -f docs/superpowers/module-reports/<phase_id>-cross-module.md ] && \
59   - git add docs/superpowers/module-reports/<phase_id>-cross-module.md
60   - git commit -m "docs(<phase_id>): add completion report + cross-module log"
61   - ```
62   - commit 是必需的——`milestone-tag` 的 worktree-clean 前置条件依赖此步。
63   -
64   -6. 调用 `Skill(milestone-tag)` 本地集成并打里程碑 tag。
65   -
66   -## 参考
67   -
68   -- `${CLAUDE_SKILL_DIR}/templates/module-report-template.md`(12 节,后端 + 前端共用)
69   -- 上游:`test-gate`(绿色时派发)
70   -- 下游:`milestone-tag`(phase 由当前分支推断)
skills/coding/module-report/templates/module-report-template.md deleted
1   ----
2   -module_id: {{module_id}}
3   -date: {{date}}
4   -git_range: {{git_range}}
5   ----
6   -
7   -# 模块完成报告 — {{module_id}} {{module_name}}
8   -
9   -## ① 模块信息
10   -- 模块 ID: {{module_id}}
11   -- 模块名: {{module_name}}
12   -- 开发区间: {{git_range}}
13   -
14   -## ② REQ 完成清单
15   -{{#each reqs}}
16   -- [{{status}}] {{req_id}} — {{title}}
17   - - spec: docs/superpowers/specs/{{date}}-{{req_id}}.md
18   - - plan: docs/superpowers/plans/{{date}}-{{req_id}}.md
19   - - review: docs/superpowers/reviews/{{date}}-{{req_id}}.md
20   -{{/each}}
21   -
22   -## ③ 文件变更表
23   -| 文件 | 操作 | 说明 |
24   -|---|---|---|
25   -{{#each file_changes}}
26   -| {{path}} | {{action}} | {{note}} |
27   -{{/each}}
28   -
29   -## ④ 数据库使用表
30   -- 读: {{tables_read}}
31   -- 写: {{tables_written}}
32   -
33   -## ⑤ 测试结果
34   -- `scripts/test.sh` 最终:{{test_conclusion}}
35   -- 通过: {{passed}} / 失败: {{failed}} / 跳过: {{skipped}}
36   -- 覆盖率: {{coverage}}
37   -
38   -## ⑥ 本模块新增 Migration
39   -
40   -{{#each migrations}}
41   -- `sql/migrations/{{filename}}` — {{desc}}
42   -{{/each}}
43   -
44   -<!-- 若本模块无 schema 改动,整节内容写 "—" -->
45   -
46   -
47   -## ⑦ 跨模块改动清单(软规则 S2)
48   -
49   -{{cross_module_contents}}
50   -
51   -## ⑧ 偏离 spec 清单
52   -{{#each deviations}}
53   -- {{req_id}}: {{deviation}} (原因: {{reason}})
54   -{{/each}}
55   -
56   -## ⑨ AI reviewer 报告汇总
57   -{{#each reviews}}
58   -- {{req_id}}: round {{round}} — {{verdict}}(link: docs/superpowers/reviews/{{date}}-{{req_id}}.md)
59   -{{/each}}
60   -
61   -## ⑩ 已知问题
62   -{{known_issues}}
63   -
64   -## ⑪ 下一模块预览
65   -{{next_module}}
66   -
67   -## ⑫ 里程碑 tag
68   -{{milestone_tag}}
skills/coding/test-gate/SKILL.md deleted
1   ----
2   -name: test-gate
3   -description: 打里程碑 tag 前的硬闸门。后端阶段子会话跑 scripts/test.sh,前端阶段跑前端测试命令;绿则进入 module-report,红则停下并按失败类型引导用户。
4   -user-invocable: false
5   -allowed-tools: Read Write Skill Agent Bash(git add *) Bash(git commit *) Bash(git branch *)
6   ----
7   -
8   -**所有输出必须使用中文。**
9   -
10   -# test-gate
11   -
12   -模块(后端阶段)或整个前端阶段所有功能完成后的硬闸门。按当前分支自动推断 `phase`:
13   -
14   -- `module-*` 分支 → `phase=backend`:子会话跑 `./scripts/test.sh`(含本模块新增 + 已合并模块回归)
15   -- `frontend-phase` 分支 → `phase=frontend`:子会话跑前端测试命令(vitest + playwright)
16   -
17   -按模板渲染证据并 commit 到当前分支。绿色继续,红色停下。
18   -
19   -## 执行步骤
20   -
21   -### 步骤 0:推断 phase 与目标命令
22   -
23   -`git branch --show-current`:
24   -
25   -- `module-<id>` → `phase=backend`,`phase_id=<id>`,`command=./scripts/test.sh`
26   -- `frontend-phase` → `phase=frontend`,`phase_id=frontend-phase`;命令从 `docs/04-技术规范.md § 零 frontend.test_command` / `frontend.e2e_command` 拼接(缺失则 `pnpm test:ci && pnpm e2e:ci`)
27   -- 其它分支 → 硬停打印 `test-gate 仅在 module-* 或 frontend-phase 分支可调用,当前 <branch>`
28   -
29   -1. 派发 Agent 子会话(general-purpose)运行上述 `command`,子会话只返回结构化 JSON(不输出描述文字):
30   - ```json
31   - {
32   - "command": "<command>",
33   - "exit_code": <int>,
34   - "passed": <int>,
35   - "failed": <int>,
36   - "stdout_excerpt": "<最后 30 行,含 FAIL 摘要>"
37   - }
38   - ```
39   -2. 按 `${CLAUDE_SKILL_DIR}/templates/test-gate-result-template.md` 渲染证据,写入 `docs/superpowers/module-reports/<phase_id>-test-gate.md`(后端:`<module_id>-test-gate.md`;前端:`frontend-phase-test-gate.md`)。
40   -3. Commit evidence 到当前分支(保证证据随里程碑 merge 进默认分支可审计):
41   - ```bash
42   - git add docs/superpowers/module-reports/<phase_id>-test-gate.md
43   - git commit -m "chore(<phase_id>): add local test-gate evidence"
44   - ```
45   -4. **`exit_code = 0`** → 调用 `Skill(module-report)`。
46   -5. **失败** → 打印以下横幅并停止,不调用下游 skill;不自动重试、不自动修复(失败分类需人工判断):
47   -
48   - ```
49   - ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
50   - [test-gate] ⚠️ 未通过 (phase=<phase>)
51   - 失败清单: <子会话 JSON 的 failed 摘要>
52   - 详细证据: docs/superpowers/module-reports/<phase_id>-test-gate.md
53   -
54   - 按失败类型选恢复路径:
55   - ① 测试脆弱(偶发 flakey)→ 重跑 /erp-workflow:coding-start
56   - (module-start / frontend-start 幂等:reviews 已全 approve 会跳过功能循环,直接重跑本闸门)
57   - ② 真有回归
58   - 后端:rm docs/superpowers/reviews/*-<REQ-id>.md
59   - → 重跑 /erp-workflow:coding-start(module-start 视该 REQ 未完成,重走功能循环)
60   - 前端:rm docs/superpowers/reviews/*-FE-<NN>.md
61   - → 重跑 /erp-workflow:coding-start(frontend-start 视该 FE 未完成,重走功能循环)
62   - ③ 环境/依赖问题(DB 连不上 / 外部 API 失败 / 证书失效 / Playwright 浏览器未装)
63   - → Skill(interrupt-check) 追加 Blocker 到任一 plan 文件 → 修复环境 → 重跑
64   - ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
65   - ```
66   -
67   -## 护栏
68   -
69   -- **绝不**在主会话直接执行 `./scripts/test.sh` / `pnpm test` / `pnpm e2e`,必须通过子会话
70   -- 本闸门是里程碑 tag 前唯一的硬测试门:红色时**绝不**跳过直接进入 `module-report` / `milestone-tag`
71   -
72   -## 参考
73   -
74   -- `${CLAUDE_SKILL_DIR}/templates/test-gate-result-template.md`
75   -- 上游:`module-start`(后端阶段 REQ 全 approve 后派发到此);`frontend-start`(前端阶段 FE 全 approve 后派发到此)
76   -- 下游:`module-report`(绿色时;后端 + 前端共用,phase 由当前分支推断)
skills/coding/test-gate/templates/test-gate-result-template.md deleted
1   -## Local test gate — {{module_id}}
2   -
3   -执行时间: {{timestamp}}
4   -
5   -### scripts/test.sh (subagent)
6   -- 子会话: {{subagent_id}}
7   -- 命令: {{command}}
8   -- 退出码: {{exit_code}}
9   -- 通过: {{passed}} / 失败: {{failed}}
10   -- 关键 stdout (≤30 行):
11   -
12   -```
13   -{{stdout_excerpt}}
14   -```
15   -
16   -结论: {{conclusion}} (green / red)