@epoint-testtech/ep-stage-skill 0.0.4-alpha.1 → 0.0.6

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 (213) hide show
  1. package/SKILL.md +27 -27
  2. package/codex-skill/ep-stage/glue-create-project/SKILL.md +223 -206
  3. package/codex-skill/ep-stage/glue-generate-testcase/SKILL.md +275 -274
  4. package/codex-skill/ep-stage/glue-generate-testcase/examples/observable-testcase.json +40 -40
  5. package/codex-skill/ep-stage/glue-generate-testcase/references/testcase-schema.md +95 -112
  6. package/codex-skill/ep-stage/glue-generate-testcase/references/testcase-tpl.md +72 -72
  7. package/codex-skill/ep-stage/glue-run-test/SKILL.md +295 -289
  8. package/codex-skill/ep-stage/glue-run-test/references/ai-runtime-loop.md +30 -0
  9. package/codex-skill/ep-stage/glue-run-test/references/crud-pipeline.md +132 -145
  10. package/codex-skill/ep-stage/glue-run-test/references/gap-review-protocol.md +44 -43
  11. package/codex-skill/ep-stage/glue-run-test/references/harness-principles.md +46 -46
  12. package/codex-skill/ep-stage/glue-run-test/references/playwright-cli-odav.md +166 -0
  13. package/codex-skill/ep-stage/glue-run-test/scripts/extract-page-elements-eval.mjs +233 -0
  14. package/codex-skill/ep-stage/glue-run-test/scripts/generate-crud-spec.mjs +149 -149
  15. package/codex-skill/ep-stage/page-element-scan/SKILL.md +91 -0
  16. package/codex-skill/ep-stage/page-element-scan/evals/evals.json +37 -0
  17. package/codex-skill/ep-stage/page-element-scan/evals/fixtures/sample-list-page.html +85 -0
  18. package/codex-skill/ep-stage/page-element-scan/references/pagination-controls.md +153 -0
  19. package/codex-skill/ep-stage/page-element-scan/scripts/extract-page-elements-eval.mjs +233 -0
  20. package/codex-skill/ep-stage/page-element-scan/scripts/extract-page-elements.mjs +298 -0
  21. package/codex-skill/ep-stage/page-element-scan/scripts/scan-page.mjs +749 -0
  22. package/codex-skill/ep-stage/recording-to-glue/SKILL.md +28 -28
  23. package/codex-skill/ep-stage/scripts/validate-skill.mjs +98 -95
  24. package/dist/src/cli/generate-testcase.d.ts +17 -51
  25. package/dist/src/cli/generate-testcase.d.ts.map +1 -1
  26. package/dist/src/cli/generate-testcase.js +74 -181
  27. package/dist/src/cli/index.d.ts +3 -2
  28. package/dist/src/cli/index.d.ts.map +1 -1
  29. package/dist/src/cli/index.js +51 -17
  30. package/dist/src/cli/run.d.ts +136 -29
  31. package/dist/src/cli/run.d.ts.map +1 -1
  32. package/dist/src/cli/run.js +507 -65
  33. package/dist/src/cli/spec.d.ts +17 -13
  34. package/dist/src/cli/spec.d.ts.map +1 -1
  35. package/dist/src/cli/spec.js +59 -33
  36. package/dist/src/contracts/crud-business-module.d.ts +6 -0
  37. package/dist/src/contracts/crud-business-module.d.ts.map +1 -1
  38. package/dist/src/contracts/glue-contract-v1.d.ts +98 -0
  39. package/dist/src/contracts/glue-contract-v1.d.ts.map +1 -0
  40. package/dist/src/contracts/glue-contract-v1.js +9 -0
  41. package/dist/src/contracts/observable-chain.d.ts +4 -0
  42. package/dist/src/contracts/observable-chain.d.ts.map +1 -1
  43. package/dist/src/extractors/code-list-json5.d.ts +192 -0
  44. package/dist/src/extractors/code-list-json5.d.ts.map +1 -0
  45. package/dist/src/extractors/code-list-json5.js +91 -0
  46. package/dist/src/extractors/html-page.d.ts +9 -0
  47. package/dist/src/extractors/html-page.d.ts.map +1 -1
  48. package/dist/src/extractors/html-page.js +26 -2
  49. package/dist/src/extractors/prd-extractor.d.ts +70 -0
  50. package/dist/src/extractors/prd-extractor.d.ts.map +1 -0
  51. package/dist/src/extractors/prd-extractor.js +248 -0
  52. package/dist/src/generators/agent-inferred-workflow-script.js +66 -66
  53. package/dist/src/generators/stage-skeleton-script.d.ts +87 -20
  54. package/dist/src/generators/stage-skeleton-script.d.ts.map +1 -1
  55. package/dist/src/generators/stage-skeleton-script.js +647 -238
  56. package/dist/src/index.d.ts +2 -2
  57. package/dist/src/index.d.ts.map +1 -1
  58. package/dist/src/index.js +1 -1
  59. package/dist/src/normalizers/crud-contract.d.ts +3 -0
  60. package/dist/src/normalizers/crud-contract.d.ts.map +1 -1
  61. package/dist/src/normalizers/crud-contract.js +3 -0
  62. package/dist/src/runtime/ai-runtime-trace.d.ts +88 -0
  63. package/dist/src/runtime/ai-runtime-trace.d.ts.map +1 -0
  64. package/dist/src/runtime/ai-runtime-trace.js +119 -0
  65. package/dist/src/testcase/button-interaction-inference.d.ts +37 -0
  66. package/dist/src/testcase/button-interaction-inference.d.ts.map +1 -0
  67. package/dist/src/testcase/button-interaction-inference.js +385 -0
  68. package/dist/src/testcase/contract-testcase-assembler.d.ts +44 -0
  69. package/dist/src/testcase/contract-testcase-assembler.d.ts.map +1 -0
  70. package/dist/src/testcase/contract-testcase-assembler.js +806 -0
  71. package/dist/src/testcase/prd-button-mapper.d.ts +72 -0
  72. package/dist/src/testcase/prd-button-mapper.d.ts.map +1 -0
  73. package/dist/src/testcase/prd-button-mapper.js +148 -0
  74. package/dist/src/testcase/runtime-context.d.ts +9 -0
  75. package/dist/src/testcase/runtime-context.d.ts.map +1 -0
  76. package/dist/src/testcase/runtime-context.js +1 -0
  77. package/dist/src/testcase/test-access.d.ts +38 -0
  78. package/dist/src/testcase/test-access.d.ts.map +1 -0
  79. package/dist/src/testcase/test-access.js +106 -0
  80. package/dist/src/testcase/testcase-execution-fields.d.ts +10 -0
  81. package/dist/src/testcase/testcase-execution-fields.d.ts.map +1 -0
  82. package/dist/src/testcase/testcase-execution-fields.js +1 -0
  83. package/dist/src/testcase/testcase-generator.d.ts.map +1 -1
  84. package/dist/src/testcase/testcase-generator.js +6 -0
  85. package/dist/src/testcase/testcase-markdown.d.ts +11 -0
  86. package/dist/src/testcase/testcase-markdown.d.ts.map +1 -0
  87. package/dist/src/testcase/testcase-markdown.js +181 -0
  88. package/dist/src/testcase/testcase-skeleton.d.ts +4 -0
  89. package/dist/src/testcase/testcase-skeleton.d.ts.map +1 -1
  90. package/dist/src/testcase/testcase-spec-assembly.d.ts +4 -0
  91. package/dist/src/testcase/testcase-spec-assembly.d.ts.map +1 -1
  92. package/dist/src/testcase/testcase-v1-draft.d.ts +58 -0
  93. package/dist/src/testcase/testcase-v1-draft.d.ts.map +1 -0
  94. package/dist/src/testcase/testcase-v1-draft.js +13 -0
  95. package/dist/src/validation/contract.d.ts +14 -0
  96. package/dist/src/validation/contract.d.ts.map +1 -0
  97. package/dist/src/validation/contract.js +132 -0
  98. package/dist/src/validation/credentials.d.ts +7 -2
  99. package/dist/src/validation/credentials.d.ts.map +1 -1
  100. package/dist/src/validation/credentials.js +15 -4
  101. package/dist/src/validation/index.d.ts +1 -0
  102. package/dist/src/validation/index.d.ts.map +1 -1
  103. package/dist/src/validation/index.js +1 -0
  104. package/dist/src/validation/testcase.d.ts +9 -7
  105. package/dist/src/validation/testcase.d.ts.map +1 -1
  106. package/dist/src/validation/testcase.js +181 -34
  107. package/docs/README.md +124 -134
  108. package/docs/mvp-usage-guide.md +298 -298
  109. package/examples/schemeresource-observable-docs/schemeresource.context.md +20 -20
  110. package/examples/schemeresource.module-hints.json +38 -38
  111. package/examples/schemeresource.observable.code_list.md +37 -37
  112. package/examples/zwplace-observable-docs/zwplace.context.md +16 -16
  113. package/examples/zwplace-placecategory-validation.json +29 -29
  114. package/examples/zwplace.module-hints.json +69 -69
  115. package/examples/zwplace.observable.code_list.md +37 -37
  116. package/package.json +2 -2
  117. package/codex-skill/ep-stage/.omc/state/sessions/d636ad35-5fc9-4d5e-85b0-2bcad7d86ee5/pre-tool-advisory-throttle.json +0 -10
  118. package/dist/test/cli/extract-contract.test.d.ts +0 -2
  119. package/dist/test/cli/extract-contract.test.d.ts.map +0 -1
  120. package/dist/test/cli/extract-contract.test.js +0 -32
  121. package/dist/test/cli/generate-testcase-inference.test.d.ts +0 -2
  122. package/dist/test/cli/generate-testcase-inference.test.d.ts.map +0 -1
  123. package/dist/test/cli/generate-testcase-inference.test.js +0 -63
  124. package/dist/test/cli/generate-testcase-paths.test.d.ts +0 -2
  125. package/dist/test/cli/generate-testcase-paths.test.d.ts.map +0 -1
  126. package/dist/test/cli/generate-testcase-paths.test.js +0 -165
  127. package/dist/test/cli/generate-testcase-requirements.test.d.ts +0 -2
  128. package/dist/test/cli/generate-testcase-requirements.test.d.ts.map +0 -1
  129. package/dist/test/cli/generate-testcase-requirements.test.js +0 -229
  130. package/dist/test/cli/generate-testcase.test.d.ts +0 -2
  131. package/dist/test/cli/generate-testcase.test.d.ts.map +0 -1
  132. package/dist/test/cli/generate-testcase.test.js +0 -130
  133. package/dist/test/cli/index.test.d.ts +0 -2
  134. package/dist/test/cli/index.test.d.ts.map +0 -1
  135. package/dist/test/cli/index.test.js +0 -113
  136. package/dist/test/cli/probe.test.d.ts +0 -2
  137. package/dist/test/cli/probe.test.d.ts.map +0 -1
  138. package/dist/test/cli/probe.test.js +0 -31
  139. package/dist/test/cli/run.test.d.ts +0 -2
  140. package/dist/test/cli/run.test.d.ts.map +0 -1
  141. package/dist/test/cli/run.test.js +0 -149
  142. package/dist/test/cli/spec-boundary.test.d.ts +0 -2
  143. package/dist/test/cli/spec-boundary.test.d.ts.map +0 -1
  144. package/dist/test/cli/spec-boundary.test.js +0 -198
  145. package/dist/test/cli/spec.test.d.ts +0 -2
  146. package/dist/test/cli/spec.test.d.ts.map +0 -1
  147. package/dist/test/cli/spec.test.js +0 -196
  148. package/dist/test/code-list.test.d.ts +0 -2
  149. package/dist/test/code-list.test.d.ts.map +0 -1
  150. package/dist/test/code-list.test.js +0 -39
  151. package/dist/test/crud-contract.test.d.ts +0 -2
  152. package/dist/test/crud-contract.test.d.ts.map +0 -1
  153. package/dist/test/crud-contract.test.js +0 -799
  154. package/dist/test/gap-inference.test.d.ts +0 -2
  155. package/dist/test/gap-inference.test.d.ts.map +0 -1
  156. package/dist/test/gap-inference.test.js +0 -597
  157. package/dist/test/generalization.test.d.ts +0 -2
  158. package/dist/test/generalization.test.d.ts.map +0 -1
  159. package/dist/test/generalization.test.js +0 -73
  160. package/dist/test/inference/module-hints-inference.test.d.ts +0 -2
  161. package/dist/test/inference/module-hints-inference.test.d.ts.map +0 -1
  162. package/dist/test/inference/module-hints-inference.test.js +0 -25
  163. package/dist/test/inference/source-analysis.test.d.ts +0 -2
  164. package/dist/test/inference/source-analysis.test.d.ts.map +0 -1
  165. package/dist/test/inference/source-analysis.test.js +0 -23
  166. package/dist/test/material-inventory.test.d.ts +0 -2
  167. package/dist/test/material-inventory.test.d.ts.map +0 -1
  168. package/dist/test/material-inventory.test.js +0 -154
  169. package/dist/test/observable-chain.test.d.ts +0 -2
  170. package/dist/test/observable-chain.test.d.ts.map +0 -1
  171. package/dist/test/observable-chain.test.js +0 -123
  172. package/dist/test/observable-pipeline.test.d.ts +0 -2
  173. package/dist/test/observable-pipeline.test.d.ts.map +0 -1
  174. package/dist/test/observable-pipeline.test.js +0 -470
  175. package/dist/test/page-structure.test.d.ts +0 -2
  176. package/dist/test/page-structure.test.d.ts.map +0 -1
  177. package/dist/test/page-structure.test.js +0 -45
  178. package/dist/test/scenario-inference.test.d.ts +0 -2
  179. package/dist/test/scenario-inference.test.d.ts.map +0 -1
  180. package/dist/test/scenario-inference.test.js +0 -73
  181. package/dist/test/stage-context.test.d.ts +0 -2
  182. package/dist/test/stage-context.test.d.ts.map +0 -1
  183. package/dist/test/stage-context.test.js +0 -395
  184. package/dist/test/testcase-generator.test.d.ts +0 -2
  185. package/dist/test/testcase-generator.test.d.ts.map +0 -1
  186. package/dist/test/testcase-generator.test.js +0 -276
  187. package/dist/test/testcase-skeleton.test.d.ts +0 -2
  188. package/dist/test/testcase-skeleton.test.d.ts.map +0 -1
  189. package/dist/test/testcase-skeleton.test.js +0 -185
  190. package/dist/test/testcase-spec-assembly.test.d.ts +0 -2
  191. package/dist/test/testcase-spec-assembly.test.d.ts.map +0 -1
  192. package/dist/test/testcase-spec-assembly.test.js +0 -105
  193. package/dist/test/util/credentials.test.d.ts +0 -2
  194. package/dist/test/util/credentials.test.d.ts.map +0 -1
  195. package/dist/test/util/credentials.test.js +0 -64
  196. package/dist/test/util/i18n-testcase.test.d.ts +0 -2
  197. package/dist/test/util/i18n-testcase.test.d.ts.map +0 -1
  198. package/dist/test/util/i18n-testcase.test.js +0 -119
  199. package/dist/test/util/softlink.test.d.ts +0 -2
  200. package/dist/test/util/softlink.test.d.ts.map +0 -1
  201. package/dist/test/util/softlink.test.js +0 -82
  202. package/dist/test/validation/credentials.test.d.ts +0 -2
  203. package/dist/test/validation/credentials.test.d.ts.map +0 -1
  204. package/dist/test/validation/credentials.test.js +0 -72
  205. package/dist/test/validation/projects-index.test.d.ts +0 -2
  206. package/dist/test/validation/projects-index.test.d.ts.map +0 -1
  207. package/dist/test/validation/projects-index.test.js +0 -48
  208. package/dist/test/validation/testcase.test.d.ts +0 -2
  209. package/dist/test/validation/testcase.test.d.ts.map +0 -1
  210. package/dist/test/validation/testcase.test.js +0 -129
  211. package/dist/vitest.config.d.ts +0 -3
  212. package/dist/vitest.config.d.ts.map +0 -1
  213. package/dist/vitest.config.js +0 -7
@@ -1,274 +1,275 @@
1
- ---
2
- name: glue-generate-testcase
3
- description: 使用时机:当用户对某需求要「生成用例 / 准备测试场景 / 钻探上游需求生成胶水冒烟用例」或显式触发 `/glue-generate-testcase <code_list.md路径>` 时使用。本 skill 包装 `@epoint-testtech/ep-stage-skill` CLI 的 `testcase` 子命令,并负责自然语言映射、缺数据引导、Step 5 凭据交互确认。
4
- version: 2026-06-26+58fd337
5
- argument-hint: "<code_list.md绝对/相对路径>"
6
- ---
7
-
8
- # ep-stage: glue-generate-testcase
9
-
10
- 本 skill 引导 Agent **包装** `@epoint-testtech/ep-stage-skill` CLI 的 `testcase` 子命令,不重新实现钻探与用例生成。CLI 内部完成物料解析 + contract 提取(内嵌)+ coverage 分析 + testcase v2 装配 + credentials.template 生成 + code_list.md 软链。skill 负责:`code_list.md` 路径解析、反查项目脚手架、缺数据引导、Step 5 平台对话确认凭据、审阅引导。用户视角全中文,不暴露 CLI 名称。
11
-
12
- > 钻探前置:v2 顶层(schemaVersion + scenario + menuPath + requiredSystems + requiredRoles + coveredActions + uncoveredCandidates)由 CLI 一次写入。scenario 3 档决策(REQ-SCENE-01):①CLI `--scenario` ②ModuleHints 推断 ③默认 `crud`;scenario 作为**产物**(非输入)写入顶层。
13
-
14
- ## 1. 自然语言映射
15
-
16
- ```text
17
- /glue-generate-testcase /abs/path/.../014-测试需求10-20260622/code_list.md # 绝对路径
18
- /glue-generate-testcase ../knowledge-project/.../014-测试需求10-20260622/code_list.md # 相对路径
19
- /glue-generate-testcase # 无参数 → 问 code_list.md 路径
20
- /glue-generate-testcase /abs/path/.../014-测试需求10-20260622/code_list.md --debug # 调试模式 → 跑本地 ep-stage-skill dist
21
- ```
22
-
23
- > **`--debug` flag**:正常调用走远程 `npx @epoint-testtech/ep-stage-skill@latest`。开发期想测试未发布的本地代码时传 `--debug`,skill 在 Step 4 改用 `node <repo>/packages/ep-stage-skill/dist/src/cli/index.js`。前提:cwd 在 ep-stage monorepo 内(向上能找到 `pnpm-workspace.yaml`);找不到时直接 exit 1 报错,不静默 fallback 到 npx。
24
-
25
- `--hints` 仅保留为 CLI 开发调试覆盖参数,skill 正常路径不得要求用户提供。
26
-
27
- skill 把 `code_list.md` 入参 `path.resolve` 绝对化,用其父目录 basename 取「需求名」作为 `<projectDir>/src/tests/<需求名>` 子目录。**projectDir 不接受参数**,全部从 `~/.ep-stage/projects.index.json5` 反查最新 `mode: 'glue'` 条目(多条 AskUserQuestion 让用户挑);索引缺失走引导场景 A。
28
-
29
- ## 2. Agent 执行剧本(8 步任务清单协议)
30
-
31
- **任务清单协议(REQ-UX-01)**:load 后**立即**打印初始任务清单(Step 0);每完成一步输出单行 `✅ 第 N 步 — <中文名> 已完成,进入第 N+1 步 — <下一中文名>...`;Step 8 输出全勾选终态清单 + 摘要。
32
-
33
- ### Step 0 — 打印任务清单
34
-
35
- ```markdown
36
- 📋 **生成胶水测试用例任务清单**
37
-
38
- - [ ] 第 1 步 — 解析 code_list 路径
39
- - [ ] 第 2 步 — 反查项目脚手架
40
- - [ ] 第 3 步 — 校验 code_list.md 输入
41
- - [ ] 第 4 步 — 调用钻探与用例生成 CLI
42
- - [ ] 第 5 步 — 与研发人员交互确认推断结果
43
- - [ ] 第 6 步 — 校验产物完整性 + AI 渲染表格化 testcase.md
44
- - [ ] 第 7 步 — 写入需求条目到项目索引
45
- - [ ] 第 8 步 — 输出审阅引导摘要
46
- ```
47
-
48
- ### Step 1 — 解析 code_list 路径
49
-
50
- 从用户消息 / args 抽取 `code_list.md` 路径,绝对化后得到 `codeListPath`,再用其父目录 basename 作为需求名。中文复述识别结果:"已识别:code_list.md = `<abs>`,需求名 = `<basename>`"。入参缺失 → free text 询问"请给我 code_list.md 的绝对或相对路径"。
51
-
52
- ### Step 2 反查项目脚手架(缺引导 A)
53
-
54
- `~/.ep-stage/projects.index.json5`:文件不存在 / glue 条目 **引导场景 A**:中文提示"未发现胶水测试脚手架。请先跑 `/glue-create-project <项目名>` 创建脚手架后再回来",退出不调 CLI。多条匹配 → AskUserQuestion 挑 projectDir。单条 → 直接拼 `--tests-dir` 根。
55
-
56
- ### Step 3 校验 code_list.md 输入(缺引导 D)
57
-
58
- 校验 `codeListPath` 是否存在,且 `code_list.md` 内至少给出:
59
- - `knowledgeRoot: /abs/path`,或
60
- - `> 整理目录:\`/abs/path\``
61
-
62
- 其余物料路径默认视为相对该根目录的路径;若某项缺失或不存在,再进入交互补齐。`codeListPath` 本身缺失 → **引导场景 D**,AskUserQuestion 三选一:
63
-
64
- 1. **提供 code_list.md 路径**:让用户给绝对路径,skill 改用该路径继续。
65
- 2. **读 PRD 草稿生成 code_list.md**:在需求目录找 PRD / spec.yaml,AI 推断 `knowledgeRoot` / `menu` / 文件清单写一份 code_list.md 草稿,提示"已生成草稿,请人审后再跑",退出。
66
- 3. **取消**:直接退出,不调 CLI。
67
-
68
- ### Step 4 — 调用钻探与用例生成 CLI
69
-
70
- 固定流程(不 which、不扫 monorepo、不 cd、**不喂 stdin**)。
71
-
72
- **正常模式**(用户 args `--debug`):
73
-
74
- ```bash
75
- npx -y @epoint-testtech/ep-stage-skill@latest testcase \
76
- --code-list <codeListPath> \
77
- --tests-dir <projectDir>/src/tests/<需求名> \
78
- --requirement-dir <codeListPath 的父目录> \
79
- --project-dir <projectDir> \
80
- [--scenario <值>]
81
- ```
82
-
83
- **调试模式**(用户 args 含 `--debug`,要求 cwd 在 ep-stage monorepo 内;详见 §1 `--debug` flag 说明):
84
-
85
- ```bash
86
- D="$PWD"; REPO=""
87
- while [ "$D" != "/" ]; do
88
- if [ -f "$D/pnpm-workspace.yaml" ] && [ -f "$D/packages/ep-stage-skill/dist/src/cli/index.js" ]; then
89
- REPO="$D"; break
90
- fi
91
- D="$(dirname "$D")"
92
- done
93
- [ -z "$REPO" ] && { echo "❌ --debug 但找不到本地 monorepo(需 cwd 在 ep-stage 仓库内向上能找到 pnpm-workspace.yaml + packages/ep-stage-skill/dist/src/cli/index.js)"; exit 1; }
94
- echo " 调试模式:本地 $REPO/packages/ep-stage-skill/dist/src/cli/index.js"
95
- node "$REPO/packages/ep-stage-skill/dist/src/cli/index.js" testcase \
96
- --code-list <codeListPath> \
97
- --tests-dir <projectDir>/src/tests/<需求名> \
98
- --requirement-dir <codeListPath 的父目录> \
99
- --project-dir <projectDir> \
100
- [--scenario <值>]
101
- ```
102
-
103
- CLI 内部:先按 scenario 3 档决策(①`--scenario` ②ModuleHints ③默认 `crud`),按 scenario 选 extractor → 物料解析 + contract 提取 + coverage 分析 → 装配 testcase v2(最终 scenario 写入 `testcase.json5` 顶层)→ 写 testcase.json5 / testcase.md(i18n 中文)/ credentials.template.json5 / `.ep-stage/contract.json` / `.ep-stage/inference-trace.json` 软链上游 code_list.md。CLI 非 0 退出 → 复述 stderr,不发完成提示,不进 Step 5。
104
-
105
- ### Step 5 — 与研发人员交互确认推断结果(REQ-UX-02)
106
-
107
- Step 4 成功后,skill 读 testcase.json5 顶层 `requiredSystems[]` / `requiredRoles[]`,再读 `~/.ep-stage/projects.index.json5` `systems[]` 算 `cachedSystemsHit`(url 命中的列表)。用**平台对话能力**(Claude Code 用 `AskUserQuestion` / Codex 用对应交互机制)跟用户对话:
108
-
109
- > 推断出 **N 个系统** + **M 个角色**(如 建设单位 / 施工单位 / 监理单位)。请选择:
110
- > 1. **现在交互输入**(推荐:≤3 角色场景)— 我逐个角色问 URL / 用户名 / 密码 / systemName,**直接写 `credentials.json5`**
111
- > 2. **仅生成 template,自己后续填** — 退出后请拷贝 `credentials.template.json5` `credentials.json5` 并填值
112
- > 3. **跳过,使用全局 systems[] 缓存复用** — 自动从 `cachedSystemsHit` 命中缓存生成 `credentials.json5`(缺失角色 fallback 引导 C,留给 glue-run-test)
113
-
114
- 三分支处理:
115
-
116
- - **选 1**:skill 顺序问每条角色的 URL/username/password/systemName(free text),直接写 `<需求名>/credentials.json5`(gitignore,非 template),**回写**全局 `~/.ep-stage/projects.index.json5` 的 `systems[].credentialsCache`(按 url 归并,跨需求复用)。
117
- - **选 2**:保留 template;提示"请编辑 `credentials.json5` 后再跑 `/glue-run-test`",进入 Step 6。
118
- - **选 3**:从 `systems[].credentialsCache` 拼出 credentials.json5,缺失角色用 template 占位符保留。
119
-
120
- ### Step 6 校验产物完整性 + AI 渲染审阅视图 testcase.md
121
-
122
- **Step 6.1校验产物完整性**
123
-
124
- 按 §3 验证清单 `ls` / `Read` 校验 CLI 产物存在(除 `testcase.md` 外其他全部,缺任意一项视为整体失败,按 §4 报告):
125
-
126
- - `testcase.json5`、`credentials.template.json5`(或 `credentials.json5`)、`code_list.md` 软链、`.ep-stage/contract.json`、`.ep-stage/inference-trace.json`
127
-
128
- > 注意:CLI 当前会先产一份 bullet 格式的 `testcase.md`(来自 `renderTestcaseMarkdown`);本 Step 6.2 会**覆盖**它为表格化审阅视图。先校验该 CLI 产物存在即可,不审格式。
129
-
130
- **Step 6.2AI 基于 tpl 渲染表格化 testcase.md(核心人审视图)**
131
-
132
- 1. **读三个数据源(全部 `Read`,绝不修改其内容)**:
133
- - `<testsDir>/testcase.json5`:事实源 — cases 数量 / `caseId` / `title` / `reviewStatus` / `requiredRole` / 顶层 `schemaVersion` / `scenario` / `moduleId` / `moduleName` / `menuPath` / `requiredRoles` 必须**逐字取自此**。
134
- - `<testsDir>/.ep-stage/contract.json`:业务槽位 步骤/断言/前置条件中的具体标签(菜单 / 列表页 / 按钮文字 / 查询字段 / 删除策略)必须**逐字取自此**对应路径(`contract.pages.list.title` / `contract.flows.create.entryButton.label` 等)。
135
- - `<testsDir>/credentials.json5`(如不存在则用 `credentials.template.json5`):登录地址 / 账号;密码**不写入** testcase.md。
136
-
137
- 2. **读 tpl**:`packages/ep-stage-skill/codex-skill/ep-stage/glue-generate-testcase/references/testcase-tpl.md`(本 skill 的同级 `references/testcase-tpl.md`,按 frontmatter + 环境信息 section + 5 列 CRUD 表格 + 审阅引导组装;模板内 `<!-- ... -->` 注释含详细填充规则,AI 必须读完后再渲染)。
138
-
139
- 3. **按 tpl 填充,写盘到 `<testsDir>/testcase.md`(覆盖 CLI 那份 bullet 版本)**:
140
- - frontmatter 4 字段(schemaVersion / scenario / moduleId / contractVersion)逐字取数据源
141
- - 「环境信息」section:登录地址/账号从 credentials;菜单/列表页/查询字段/操作角色/未解析槽位从 testcase.json5 + contract.json
142
- - 「CRUD 冒烟用例」表格:cases[] **一条 = 一行**(数量必须严格等于 `testcase.json5.cases.length`,不得增删),按 caseId 后缀(.create / .read / .update / .delete)走 tpl 内注释列出的步骤/断言/前置条件填充规则;非 CRUD 用例按 cases[].businessIntent / assertionExpectation 直译,缺时填「待人工补充」、不发挥
143
- - 表格中**不展示 evidence 列**(人审不需要技术性溯源)
144
- - 「审阅引导」section:原样复制 tpl 末尾的 3 条引导(替换其中引用的具体路径)
145
-
146
- 4. **AI 忠实性自检(写盘前必做)**:
147
- - testcase.md 表格行数 - 1 (表头) == testcase.json5 cases.length
148
- - 每行 `用例 ID` 列 == testcase.json5 cases[i].caseId
149
- - 每行 `标题` 列 == testcase.json5 cases[i].title
150
- - 步骤/断言/前置条件中所有「{contract.xxx}」型槽位标签真实存在于 contract.json(grep 验证)
151
- - **任一项不通过**:不写盘,按 §4 报告「忠实性自检失败」+ 具体差异 + 停 Step 6.2,不进 Step 7
152
-
153
- 5. **重跑覆盖语义**:每次跑 skill 都重新执行 Step 6.2,testcase.md 完全覆盖前一次产物;人审意见**只写进 testcase.json5**(JSON5 `// 注释`),**不写 testcase.md**。
154
-
155
- **Step 6.3 — 复核环境信息可执行性(可选)**
156
-
157
- Step 5 已交互写入 credentials.json5:环境信息 section 的「登录地址」应是真实 URL(非占位 `<请填登录页 URL>`)。占位状态下完成提示中提醒用户补 credentials.json5 后再跑 `/glue-run-test`。
158
-
159
- ### Step 7 写入需求条目到项目索引
160
-
161
- CLI testcase 子命令在传入 `--project-dir` 时,自动往 `~/.ep-stage/projects.index.json5` 对应 `projects[].requirements[]` 追加本需求条目(含 `name / requirementDir / testsDir / lastRunStatus: "never"`,同名需求去重更新);未传 `--project-dir` 则跳过(不维护 index)。skill Step 4 命令总带 `--project-dir`,故正常流程 CLI 必追加。skill 校验:条目存在;`name` 与 Step 1 一致;`testsDir` 指向 `<projectDir>/src/tests/<需求名>`。
162
-
163
- ### Step 8 输出审阅引导摘要
164
-
165
- 打印全勾选终态清单 + §5 完成提示(含审阅引导链:审 testcase.md → 编辑 testcase.json5 → 填 credentials.json5 → 跑 `/glue-run-test`)。
166
-
167
- ## 3. 验证清单
168
-
169
- | 路径 | 说明 |
170
- |--------------------------------------------------------------|--------------------------------------------------------|
171
- | `<projectDir>/src/tests/<需求名>/testcase.json5` | v2 schema(含 scenario / menuPath / requiredSystems 等),**事实源** |
172
- | `<projectDir>/src/tests/<需求名>/testcase.md` | **AI 基于 `references/testcase-tpl.md` 渲染的审阅视图**(5 列表格 + 环境信息 + 审阅引导,重跑覆盖;CLI 先产 bullet 版,Step 6.2 覆盖之) |
173
- | `<projectDir>/src/tests/<需求名>/credentials.template.json5` | 行数 = `requiredRoles.length` |
174
- | `<projectDir>/src/tests/<需求名>/code_list.md` | 软链 / hardlink / copy 到上游 |
175
- | `<projectDir>/src/tests/<需求名>/.ep-stage/contract.json` | 内部产物,机器专用,禁手编 |
176
- | `<projectDir>/src/tests/<需求名>/.ep-stage/inference-trace.json` | 推理追踪总账,只供排查和审阅,不作为 spec 主输入 |
177
- | `~/.ep-stage/projects.index.json5` | 已追加 `projects[].requirements[]` |
178
-
179
- > 常态不生成 `source-spec.json` 或 `module-hints.inferred.json5`;二者只作为显式调试导出,非正常产物。
180
-
181
- ## 4. 错误处理
182
-
183
- | 触发时机 | Agent 中文呈现 + 建议 |
184
- |-----------------------------------------|----------------------------------------------------------------------|
185
- | 引导 A(缺脚手架) | 中文提示+退出,引导先跑 `/glue-create-project` |
186
- | 引导 D(缺 code_list.md) | AskUserQuestion 三选一:建软链 / 读 PRD 草稿 / 取消 |
187
- | CLI exit ≠ 0 | 复述 stderr 中文转述,不发完成提示,不进 Step 5 |
188
- | testcase.json5 缺 `schemaVersion: "v2"` | 报"产物 schema 校验失败,请重跑 `/glue-generate-testcase <code_list.md路径>`" |
189
- | Step 5 选 1 用户中途取消 | 保留 template,提示"凭据未写入,请稍后拷贝 template 自填" |
190
- | Step 6.2 忠实性自检失败 | 不写 testcase.md,复述差异(行数不匹配 / caseId 错位 / 槽位标签 contract 中不存在),引导审阅 testcase.json5 与 contract.json 后重跑 |
191
-
192
- ## 5. 完成提示
193
-
194
- Step 8 全部通过后,按以下中文格式呈现(不要用 success/done/generated):
195
-
196
- > ✅ 用例生成完成
197
- >
198
- > 需求:`<需求名>`
199
- > 项目:`<projectDir>`
200
- > 产物目录:`<projectDir>/src/tests/<需求名>/`(testcase.json5 v2 + testcase.md + credentials.template.json5 + credentials.json5(如选 1/3)+ code_list.md 软链 + .ep-stage/contract.json + .ep-stage/inference-trace.json)
201
- > 项目索引:`~/.ep-stage/projects.index.json5` 已追加需求条目
202
- >
203
- > 下一步审阅引导链:
204
- > 1. 打开 `testcase.md` 审阅推断结果与未确认项
205
- > 2. 如需调整,编辑 `testcase.json5`(JSON5 支持 `// 注释`,审阅意见可直接写注释)
206
- > 3. 检查 / 填好 `credentials.json5`(如未在 Step 5 选 1/3 写入)
207
- > 4. 跑 `/glue-run-test <需求目录路径>` 组装并执行 spec
208
-
209
- ## 6. 引导场景
210
-
211
- - **A(缺脚手架)**:Step 2 反查 projects.index.json5 无 glue 条目 → 提示先跑 `/glue-create-project` 退出。
212
- - **D(缺 code_list.md)**:Step 3 缺失 → AskUserQuestion 三选一(建软链 / 读 PRD 草稿 / 取消)。
213
- - **B / C**:由下游 `glue-run-test` 处理。
214
-
215
- ## 7. 输入字段约定
216
-
217
- ```markdown
218
- <!-- code_list.md 字段约定(REQ-FILE-02 / REQ-MENU-01) -->
219
- knowledgeRoot: /abs/path/to/knowledge-project/xxx <!-- 推荐:结构化根目录 -->
220
-
221
- > 整理目录:`/abs/path/to/knowledge-project/xxx` <!-- 兼容旧格式;其余相对路径默认相对该目录 -->
222
- > 菜单:一级菜单>二级菜单 <!-- 人工读写首选:中文键「菜单」,与「整理目录」同风格;可选,缺时引导补,最终写入 testcase.json5.menuPath -->
223
- menu: 一级菜单>二级菜单 <!-- 英文键兼容:裸行 menu / menuPath 仍可解析(blockquote「>」形式仅认「菜单」)。CLI 内部字段名仍为 menu -->
224
-
225
- `_docs/.../spec.yaml`
226
- `src/main/webapp/.../*.html`
227
- `src/main/java/.../*Action.java`
228
-
229
- <!-- module-hints 是 CLI 基于上游物料推理的过程产物(落入 .ep-stage/inference-trace.json),
230
- 不是 code_list 该列的输入物料;旧 examples/zwplace.module-hints.json 仅作历史 fixture(REQ-INFER-010)。 -->
231
- ```
232
-
233
- ## 8. 内嵌数据契约范例
234
-
235
- `<需求名>/testcase.json5` v2 顶层骨架(详见 references/testcase-schema.md):
236
-
237
- ```json5
238
- {
239
- schemaVersion: "v2",
240
- scenario: "crud", // 产物:CLI 3 档决策后写入
241
- moduleId: "zwplace", moduleName: "场所窗口信息管理",
242
- menuPath: "场所窗口信息管理>场所窗口信息列表",
243
- requiredSystems: [{ url: "http://...", systemName: "主业务系统" }],
244
- requiredRoles: [{ role: "admin", hint: "默认操作员" }],
245
- coveredActions: [{ actionId: "zwplace.create", kind: "create", evidence: ["html=...", "java=..."] }],
246
- uncoveredCandidates: [{ actionId: "zwplace.sync", status: "planned", requiredRole: "admin", businessIntent: "...", assertionExpectation: "...", evidence: ["..."] }],
247
- cases: [{ caseId: "zwplace.create", title: "新增", scenario: "crud.single-page", reviewStatus: "confirmed", requiredRole: "admin", evidence: ["..."], steps: [], assertions: [], unresolved: [] }],
248
- reasoningSummary: { conclusion: "...", evidenceChain: [], alternatives: [], confidence: "high", risks: [], needsHumanReview: false }
249
- }
250
- ```
251
-
252
- `<需求名>/credentials.template.json5`(行数 = `requiredRoles.length`) + `~/.ep-stage/projects.index.json5` 需求条目(CLI 追加到 `projects[].requirements[]`):
253
-
254
- ```json5
255
- // credentials.template.json5
256
- [ { url: "<请填登录页 URL>", username: "<请填>", password: "<请填>", role: "admin", systemName: "主业务系统" } ]
257
-
258
- // projects.index.json5 → projects[].requirements[<i>]
259
- { name: "014-测试需求10-20260622", requirementDir: "/abs/.../014-测试需求10-20260622", testsDir: "<projectDir>/src/tests/014-测试需求10-20260622", lastRunStatus: "never" }
260
- ```
261
-
262
- ## 9. 按需加载
263
-
264
- - 用例 schema 详解:`references/testcase-schema.md`(v2)
265
- - **testcase.md 渲染模板:`references/testcase-tpl.md`(Step 6.2 必读)**
266
- - 既有工作流参考:`references/workflow.md`
267
-
268
- ## 10. 关键约束
269
-
270
- - 顶层 `reviewStatus` 字段**永远不引入**(REQ-DATA-04);审阅意见请直接在 `testcase.json5` 加 JSON5 `// 注释`。
271
- - `cases[].reviewStatus = needs_review` 的用例不得进入 spec 组装(spec 组装阶段按 case 粒度阻断)。
272
- - 嵌套 CRUD 一期仅作为候选用例进入 testcase,不写入正式 CRUD 契约。
273
- - testcase.md 每次重跑完全覆盖,不保留人工编辑(事实源是 testcase.json5)。**testcase.md 由 skill Step 6.2 基于 `references/testcase-tpl.md` AI 渲染**(CLI 当前先产一份 bullet 版作为兜底,Step 6.2 覆盖之);步骤/断言/前置条件中的具体槽位标签必须逐字取自 contract.json,AI 只组织自然语言句式,不得新增/捏造槽位。
274
- - 对话中展示可审阅推理摘要和证据链,不展示原始隐式思维链。
1
+ ---
2
+ name: glue-generate-testcase
3
+ description: 使用时机:当用户对某需求要「生成用例 / 准备测试场景 / 钻探上游需求生成胶水冒烟用例」或显式触发 `/glue-generate-testcase <code_list.json5路径>` 时使用。本 skill 包装 `@epoint-testtech/ep-stage-skill` CLI 的 `testcase` 子命令,并负责自然语言映射、缺数据引导、Step 5 凭据交互确认。
4
+ version: 2026-08-12+925f4c4
5
+ argument-hint: "<code_list.json5绝对/相对路径>"
6
+ ---
7
+
8
+ # ep-stage: glue-generate-testcase
9
+
10
+ 本 skill 引导 Agent **包装** `@epoint-testtech/ep-stage-skill` CLI 的 `testcase` 子命令,不重新实现钻探与用例生成。CLI 内部完成物料解析 + contract 提取(内嵌)+ coverage 分析 + testcase 装配 + credentials.template 生成。skill 负责:`code_list.json5` 路径解析、反查项目脚手架、缺数据引导、Step 5 平台对话确认凭据、审阅引导。用户视角全中文,不暴露 CLI 名称。
11
+
12
+ > **契约可观测性 gate**:每个非平凡字段必须能追溯到上游证据、可重复推导规则、运行配置来源或人工确认问题;无法给出来源的字段必须进入 `unresolvedSlots`,禁止写入 `contract.json5`。"无来源不入契约"。
13
+
14
+ > 钻探前置:testcase.json5 顶层(schemaVersion:'ep-stage-testcase/v1-draft' + testcaseId + contractRef + scenario + moduleId + moduleName + runtimeContext? + testAccess? + cases + uncoveredCandidates)由 CLI 一次写入。scenario 由 CLI 按 `code_list.json5` 推导(assembler),014 默认 `crud_export`;scenario 作为**产物**(非输入)写入顶层。`menuPath` 不是新链路必填字段。`runtimeContext` 用于落定工程与 spec 路径;`testAccess` 只保存 `credentialRef/requiredRoles`,明文账号密码与运行访问数据统一写入 `credentials.json5`。`directUrl` 是待测页面直达地址,不属于上游出码事实;缺失时必须在本 skill 交互补齐,并通过 CLI 参数写入 `contract.json5.base.navigation.directUrl`。**module-hints 已废弃**(交接文档 §4.1),不作为输入。
15
+
16
+ ## 1. 自然语言映射
17
+
18
+ ```text
19
+ /glue-generate-testcase /abs/path/.../014-测试需求10-20260622/_docs/code_list.json5 # 绝对路径
20
+ /glue-generate-testcase ../knowledge-project/.../014-测试需求10-20260622/_docs/code_list.json5 # 相对路径
21
+ /glue-generate-testcase # 无参数 → 问 code_list.json5 路径
22
+ /glue-generate-testcase /abs/path/.../014-测试需求10-20260622/_docs/code_list.json5 --debug # 调试模式 → 跑本地 ep-stage-skill dist
23
+ ```
24
+
25
+ > **`--debug` flag**:正常调用走远程 `npx @epoint-testtech/ep-stage-skill@latest`。开发期想测试未发布的本地代码时传 `--debug`,skill 在 Step 4 改用 `node <repo>/packages/ep-stage-skill/dist/src/cli/index.js`。前提:cwd 在 ep-stage monorepo 内(向上能找到 `pnpm-workspace.yaml`);找不到时直接 exit 1 报错,不静默 fallback 到 npx。
26
+
27
+ `--scenario` 不作为正常路径输入(scenario CLI `code_list.json5` 推导,014 默认 `crud_export`);`--hints` / module-hints 已废弃,不作为输入。
28
+
29
+ skill 把 `code_list.json5` 入参 `path.resolve` 绝对化,用其父目录的父目录 basename 取「需求名」作为 `<projectDir>/src/tests/<需求名>` 子目录(`_docs/code_list.json5` 上一级即需求目录)。**projectDir 不接受参数**,全部从 `~/.ep-stage/projects.index.json5` 反查最新 `mode: 'glue'` 条目(多条 AskUserQuestion 让用户挑);索引缺失走引导场景 A。
30
+
31
+ ## 2. Agent 执行剧本(8 步任务清单协议)
32
+
33
+ **任务清单协议(REQ-UX-01)**:load 后**最先**单行展示技能版本(取本 SKILL.md frontmatter 的 `version` 字段),格式 `技能版本:glue-generate-testcase <version>`;随后**立即**打印初始任务清单(Step 0);每完成一步输出单行 `第 N 步 <中文名> 已完成,进入第 N+1 步 — <下一中文名>...`;Step 8 输出全勾选终态清单 + 摘要。
34
+
35
+ ### Step 0 — 打印任务清单
36
+
37
+ ```markdown
38
+ **生成胶水测试用例任务清单**
39
+
40
+ - [ ] 第 1 步 — 解析 code_list.json5 路径
41
+ - [ ] 第 2 步 — 反查项目脚手架
42
+ - [ ] 第 3 步 — 校验 code_list.json5 输入
43
+ - [ ] 第 4 步 — 补齐待测页面 directUrl 并调用钻探与用例生成 CLI
44
+ - [ ] 第 5 步 — 与研发人员交互确认推断结果
45
+ - [ ] 第 6 步 — 校验产物完整性 + 审阅 testcase.md 单表
46
+ - [ ] 第 7 步 — 写入需求条目到项目索引
47
+ - [ ] 第 8 步 — 输出审阅引导摘要
48
+ ```
49
+
50
+ ### Step 1 解析 code_list 路径
51
+
52
+ 从用户消息 / args 抽取 `code_list.json5` 路径,绝对化后得到 `codeListPath`,再用其父目录的父目录 basename 作为需求名(`_docs/code_list.json5` 上一级即需求目录)。中文复述识别结果:"已识别:code_list.json5 = `<abs>`,需求名 = `<basename>`"。入参缺失 free text 询问"请给我 code_list.json5 的绝对或相对路径(位于需求目录 `_docs/` 下)"。
53
+
54
+ ### Step 2 反查项目脚手架(缺引导 A
55
+
56
+ `~/.ep-stage/projects.index.json5`:文件不存在 / glue 条目 **引导场景 A**:中文提示"未发现胶水测试脚手架。请先跑 `/glue-create-project <项目名>` 创建脚手架后再回来",退出不调 CLI。多条匹配 AskUserQuestion 挑 projectDir。单条 → 直接拼 `--tests-dir` 根。
57
+
58
+ ### Step 3 — 校验 code_list.json5 输入(缺 → 引导 D)
59
+
60
+ 校验 `codeListPath` 是否存在,且 `code_list.json5` 内至少给出:
61
+ - `knowledgeRoot: /abs/path`,或
62
+ - `> 整理目录:\`/abs/path\``
63
+
64
+ 其余物料路径默认视为相对该根目录的路径;若某项缺失或不存在,再进入交互补齐。`codeListPath` 本身缺失 **引导场景 D**,AskUserQuestion 三选一:
65
+
66
+ 1. **提供 code_list.json5 路径**:让用户给绝对路径(位于需求目录 `_docs/` 下),skill 改用该路径继续。
67
+ 2. **读 PRD 草稿生成 code_list.json5**:在需求目录找 PRD / spec.yaml,AI 推断 `knowledgeRoot` / `menu` / 文件清单写一份 `code_list.json5` 草稿到 `_docs/` 下,提示"已生成草稿,请人审后再跑",退出。
68
+ 3. **取消**:直接退出,不调 CLI
69
+
70
+ ### Step 4 补齐待测页面 directUrl 并调用钻探与用例生成 CLI
71
+
72
+ 固定流程(不 which、不扫 monorepo、不 cd、**不喂 stdin**)。调用 CLI 前先确定待测页面 `directUrl`:
73
+
74
+ - 若 `code_list.json5` 已有待测页面节点的 `pages[role=list].directUrl`,直接使用。
75
+ - 若缺失,必须用平台对话询问用户:"请提供待测页面直达链接(directUrl)。说明:直达链接通常来自浏览器地址栏中 view-source: 后面的页面地址;例如 view-source:http://192.168.203.46:8100/epoint-web/perpage/zwplace/gxhzwplacelist.html,实际填写 http://192.168.203.46:8100/epoint-web/perpage/zwplace/gxhzwplacelist.html。"
76
+ - 仍缺失则停止,不调 CLI。禁止让下游 `glue-run-test` 自行猜入口。
77
+
78
+ **正常模式**(用户 args `--debug`):
79
+
80
+ ```bash
81
+ npx -y @epoint-testtech/ep-stage-skill@latest testcase \
82
+ --code-list <codeListPath> \
83
+ --tests-dir <projectDir>/src/tests/<需求名> \
84
+ --requirement-dir <codeListPath 的父目录> \
85
+ --project-dir <projectDir> \
86
+ --direct-url <待测列表页 directUrl>
87
+ ```
88
+
89
+ (scenario 由 CLI 按 `code_list.json5` 推导,014 默认 `crud_export`,正常路径不传 `--scenario`)
90
+
91
+ **调试模式**(用户 args 含 `--debug`,要求 cwd 在 ep-stage monorepo 内;详见 §1 `--debug` flag 说明):
92
+
93
+ ```bash
94
+ D="$PWD"; REPO=""
95
+ while [ "$D" != "/" ]; do
96
+ if [ -f "$D/pnpm-workspace.yaml" ] && [ -f "$D/packages/ep-stage-skill/dist/src/cli/index.js" ]; then
97
+ REPO="$D"; break
98
+ fi
99
+ D="$(dirname "$D")"
100
+ done
101
+ [ -z "$REPO" ] && { echo "错误:--debug 但找不到本地 monorepo(需 cwd 在 ep-stage 仓库内向上能找到 pnpm-workspace.yaml + packages/ep-stage-skill/dist/src/cli/index.js)"; exit 1; }
102
+ echo "调试模式:本地 $REPO/packages/ep-stage-skill/dist/src/cli/index.js"
103
+ node "$REPO/packages/ep-stage-skill/dist/src/cli/index.js" testcase \
104
+ --code-list <codeListPath> \
105
+ --tests-dir <projectDir>/src/tests/<需求名> \
106
+ --requirement-dir <codeListPath 的父目录> \
107
+ --project-dir <projectDir> \
108
+ --direct-url <待测列表页 directUrl>
109
+ ```
110
+
111
+ (scenario CLI `code_list.json5` 推导,014 默认 `crud_export`,正常路径不传 `--scenario`)
112
+
113
+ CLI 内部:按 `code_list.json5` 解析物料 → assembler 推导 scenario(014 默认 `crud_export`)→ 装配 contract + testcase(scenario 作为产物写入 `testcase.json5` 顶层,`directUrl` 写入 `contract.json5.base.navigation.directUrl`,`testcase.json5.testAccess` 只写 `credentialRef/requiredRoles`)→ schema 门禁 → 写 testcase.json5 / testcase.md(统一单表审阅视图)/ credentials.template.json5 / `.ep-stage/contract.json5` / `.ep-stage/inference-trace.json`。testcase.md 只渲染一张用例表,列为:用例 ID / 生成策略 / 用例标题 / 查询主键 / 前置条件 / 执行步骤 / 执行断言。glue 与 ai 通过“生成策略”列区分,不拆成两个表。CLI 非 0 退出 → 复述 stderr,不发完成提示,不进 Step 5。
114
+
115
+ ### Step 5 — 与研发人员交互确认推断结果(REQ-UX-02)
116
+
117
+ Step 4 成功后,skill CLI 产出的 `credentials.template.json5`(行数 = `code_list.roles.length`,每条对应一个角色)+ `uncoveredCandidates[].requiredRole`,再读 `~/.ep-stage/projects.index.json5` `systems[]` 算 `cachedSystemsHit`(url 命中的列表)。用**平台对话能力**(Claude Code 用 `AskUserQuestion` / Codex 用对应交互机制)跟用户对话:
118
+
119
+ > 推断出 **N 个角色**(如 建设单位 / 施工单位 / 监理单位)。请选择:
120
+ > 1. **现在交互输入**(推荐:≤3 角色场景)— 我逐个角色问直达链接(directUrl)/ 登录地址(loginUrl)/ 系统名称(systemName)/ 角色(role)/ 账号(username)/ 密码(password),汇总摘要请你确认后写 `credentials.json5`
121
+ > 2. **仅生成 template,自己后续填** — 退出后请拷贝 `credentials.template.json5` → `credentials.json5` 并填值
122
+ > 3. **跳过,使用全局 systems[] 缓存复用** 自动从 `cachedSystemsHit` 命中缓存生成 `credentials.json5`(缺失角色 fallback 引导 C,留给 glue-run-test)
123
+
124
+ 三分支处理:
125
+
126
+ - **选 1**:skill 顺序问每条角色的直达链接(directUrl)/ 登录地址(loginUrl)/ 系统名称(systemName)/ 角色(role)/ 账号(username)/ 密码(password)(free text)。直达链接问题必须说明其来源是 `view-source:` 后面的页面地址。收集后先展示摘要给用户确认;确认后写 `<需求名>/credentials.json5`(gitignore,非 template),`<需求名>/testcase.json5.testAccess` 只保留 `credentialRef: 'credentials.json5'` 和 `requiredRoles`,**回写**全局 `~/.ep-stage/projects.index.json5` 的 `systems[].credentialsCache`(按 loginUrl 归并,跨需求复用)。
127
+ - **选 2**:保留 template;提示"请编辑 `credentials.json5` 后再跑 `/glue-run-test`",进入 Step 6。
128
+ - **选 3**:从 `systems[].credentialsCache` 拼出 credentials.json5,缺失角色用 template 占位符保留;`<需求名>/testcase.json5.testAccess` 只保留 `credentialRef: 'credentials.json5'` `requiredRoles`,不写明文账号密码。
129
+
130
+ ### Step 6 — 校验产物完整性 + 审阅 testcase.md 单表
131
+
132
+ **Step 6.1 校验产物完整性**
133
+
134
+ §3 验证清单 `ls` / `Read` 校验 CLI 产物存在(除 `testcase.md` 外其他全部,缺任意一项视为整体失败,按 §4 报告):
135
+
136
+ - `testcase.json5`、`credentials.template.json5`(或 `credentials.json5`)、`.ep-stage/contract.json5`、`.ep-stage/inference-trace.json`
137
+
138
+ Step 6 只需要确认 CLI 已基于 `testcase.json5` 事实源写出 `testcase.md`。该文件固定是一张审阅表,列为:用例 ID / 生成策略 / 用例标题 / 查询主键 / 前置条件 / 执行步骤 / 执行断言。glue 与 ai 统一在同一张表中,通过“生成策略”列区分。每次重跑都会整体覆盖 `testcase.md`;人审意见只写进 `testcase.json5`(JSON5 `// 注释`),不写 `testcase.md`。
139
+
140
+ ### Step 7 写入需求条目到项目索引
141
+
142
+ CLI testcase 子命令在传入 `--project-dir` 时,自动往 `~/.ep-stage/projects.index.json5` 对应 `projects[].requirements[]` 追加本需求条目(含 `name / requirementDir / testsDir / lastRunStatus: "never"`,同名需求去重更新);未传 `--project-dir` 则跳过(不维护 index)。skill Step 4 命令总带 `--project-dir`,故正常流程 CLI 必追加。skill 校验:条目存在;`name` 与 Step 1 一致;`testsDir` 指向 `<projectDir>/src/tests/<需求名>`。
143
+
144
+ ### Step 8 输出审阅引导摘要
145
+
146
+ 打印全勾选终态清单 + §5 完成提示(含审阅引导链:审 testcase.md 编辑 testcase.json5 → 填 credentials.json5 → 跑 `/glue-run-test`)。
147
+
148
+ ## 3. 验证清单
149
+
150
+ | 路径 | 说明 |
151
+ |--------------------------------------------------------------|--------------------------------------------------------|
152
+ | `<projectDir>/src/tests/<需求名>/testcase.json5` | testcase schema v1-draft(schemaVersion / scenario / moduleId / moduleName / menuPath / runtimeContext? / testAccess? / contractRef / cases / uncoveredCandidates),**事实源** |
153
+ | `<projectDir>/src/tests/<需求名>/testcase.md` | 基于 `testcase.json5` 渲染的单表审阅视图(列:用例 ID / 生成策略 / 用例标题 / 查询主键 / 前置条件 / 执行步骤 / 执行断言;重跑覆盖) |
154
+ | `<projectDir>/src/tests/<需求名>/credentials.template.json5` | 行数 = `code_list.roles.length`(每条对应一个角色) |
155
+ | `<projectDir>/src/tests/<需求名>/.ep-stage/contract.json5` | 内部产物,机器专用,禁手编 |
156
+ | `<projectDir>/src/tests/<需求名>/.ep-stage/inference-trace.json` | 推理追踪总账,只供排查和审阅,不作为 spec 主输入 |
157
+ | `~/.ep-stage/projects.index.json5` | 已追加 `projects[].requirements[]` |
158
+
159
+ > 常态不生成 `source-spec.json` `module-hints.inferred.json5`;二者只作为显式调试导出,非正常产物。
160
+
161
+ ## 4. 错误处理
162
+
163
+ | 触发时机 | Agent 中文呈现 + 建议 |
164
+ |-----------------------------------------|----------------------------------------------------------------------|
165
+ | 引导 A(缺脚手架) | 中文提示+退出,引导先跑 `/glue-create-project` |
166
+ | 引导 D(缺 code_list.json5) | AskUserQuestion 三选一:提供路径 / 读 PRD 草稿 / 取消 |
167
+ | CLI exit ≠ 0 | 复述 stderr 中文转述,不发完成提示,不进 Step 5 |
168
+ | testcase.json5 缺 `schemaVersion` | 报"产物 schema 校验失败,请重跑 `/glue-generate-testcase <code_list.json5路径>`" |
169
+ | Step 5 选 1 用户中途取消 | 保留 template,提示"凭据未写入,请稍后拷贝 template 自填" |
170
+ | testcase.md 单表缺失或结构异常 | 复述缺失项或列结构异常,提示检查 testcase.json5 与 CLI 输出后重跑 |
171
+
172
+ ## 5. 完成提示
173
+
174
+ Step 8 全部通过后,按以下中文格式呈现(不要用 success/done/generated):
175
+
176
+ > 用例已生成。
177
+ >
178
+ > 测试项目:`<projectDir>`
179
+ > 用例文件:`<projectDir>/src/tests/<需求名>/testcase.json5`
180
+ > 用例摘要:共 N 条,胶水组装 X 条,AI 推理 Y 条
181
+ > 重点审核:AI 推理用例、blocked 候选、登录角色信息
182
+ >
183
+ > 需要调整的话,直接告诉我改哪条用例,我来更新 testcase.json5。
184
+ >
185
+ > 下一步指令:
186
+ > `/glue-run-test <projectDir>/src/tests/<需求名>/testcase.json5`
187
+
188
+ ## 6. 引导场景
189
+
190
+ - **A(缺脚手架)**:Step 2 反查 projects.index.json5 glue 条目 提示先跑 `/glue-create-project` 退出。
191
+ - **D(缺 code_list.json5)**:Step 3 缺失 → AskUserQuestion 三选一(提供路径 / 读 PRD 草稿 / 取消)。
192
+ - **B / C**:由下游 `glue-run-test` 处理。
193
+
194
+ ## 7. 输入字段约定
195
+
196
+ ```markdown
197
+ <!-- code_list.json5 字段约定(REQ-FILE-02 / REQ-MENU-01) -->
198
+ knowledgeRoot: /abs/path/to/knowledge-project/xxx <!-- 推荐:结构化根目录 -->
199
+
200
+ > 整理目录:`/abs/path/to/knowledge-project/xxx` <!-- 兼容旧格式;其余相对路径默认相对该目录 -->
201
+ > 菜单:一级菜单>二级菜单 <!-- 人工读写首选:中文键「菜单」,与「整理目录」同风格;可选,缺时引导补,最终写入 testcase.json5.menuPath -->
202
+ menu: 一级菜单>二级菜单 <!-- 英文键兼容:裸行 menu / menuPath 仍可解析(blockquote「>」形式仅认「菜单」)。CLI 内部字段名仍为 menu -->
203
+
204
+ `_docs/.../spec.yaml`
205
+ `src/main/webapp/.../*.html`
206
+ `src/main/java/.../*Action.java`
207
+
208
+ <!-- module-hints 是 CLI 基于上游物料推理的过程产物(落入 .ep-stage/inference-trace.json),
209
+ 不是 code_list 该列的输入物料;旧 examples/zwplace.module-hints.json 仅作历史 fixture(REQ-INFER-010)。 -->
210
+ ```
211
+
212
+ ## 8. 内嵌数据契约范例
213
+
214
+ `<需求名>/testcase.json5` 顶层骨架(v1-draft,详见 references/testcase-schema.md):
215
+
216
+ ```json5
217
+ {
218
+ schemaVersion: "ep-stage-testcase/v1-draft",
219
+ testcaseId: "zwplace-testcase",
220
+ contractRef: ".ep-stage/contract.json5", // 指向同需求目录 .ep-stage/contract.json5
221
+ scenario: "crud_export", // 产物:CLI 按 code_list.json5 推导,014 默认 crud_export
222
+ moduleId: "zwplace", moduleName: "场所窗口信息管理",
223
+ menuPath: "场所窗口信息管理>场所窗口信息列表",
224
+ runtimeContext: {
225
+ testProjectDir: "/abs/path/to/glue-project",
226
+ caseDir: "/abs/path/to/glue-project/src/tests/014-测试需求10-20260622",
227
+ specPath: "/abs/path/to/glue-project/src/tests/014-测试需求10-20260622/crud.spec.ts"
228
+ },
229
+ testAccess: {
230
+ credentialRef: "credentials.json5",
231
+ requiredRoles: ["业务管理员"]
232
+ },
233
+ cases: [
234
+ { caseId: "zwplace-placename-create", title: "场所名称-新增", generationStrategy: "glue", coverageStatus: "covered", reviewStatus: "confirmed", queryKey: "场所名称", precondition: "使用具备权限的测试角色登录系统并进入目标列表页", steps: "按查询主键完成新增、查询、编辑、删除或导出流程", assertion: "按查询主键、列表结果或导出行为验证执行结果" }
235
+ // cases[] 桶只承载 generationStrategy='glue';正式执行字段同步写入 queryKey/precondition/steps/assertion
236
+ ],
237
+ uncoveredCandidates: [
238
+ { caseId: "businessState.transitions", label: "状态流转", generationStrategy: "ai", coverageStatus: "gap", requiredRole: "业务管理员", businessIntent: "覆盖在用不可删除等业务规则边界", assertionExpectation: "在用状态场所执行删除时应被业务规则阻断", queryKey: "不适用", precondition: "使用角色:业务管理员", steps: "按 AI Runtime Task 观察页面并执行:覆盖在用不可删除等业务规则边界", assertion: "在用状态场所执行删除时应被业务规则阻断" }
239
+ // uncoveredCandidates[] 桶只承载 generationStrategy='ai';缺入口/缺权限/缺运行数据用 coverageStatus='blocked' 表达,同时保留正式执行字段
240
+ ]
241
+ }
242
+ ```
243
+
244
+ `<需求名>/credentials.template.json5`(按 code_list.json5 的业务角色事实生成模板) + `~/.ep-stage/projects.index.json5` 需求条目(CLI 追加到 `projects[].requirements[]`):
245
+
246
+ ```json5
247
+ // credentials.template.json5
248
+ [
249
+ {
250
+ directUrl: "<请填待测页面直达链接,取 view-source: 后面的页面地址>",
251
+ loginUrl: "<请填登录地址>",
252
+ systemName: "<请填系统名称>",
253
+ role: "业务管理员",
254
+ username: "<请填账号>",
255
+ password: "<请填密码>",
256
+ },
257
+ ]
258
+
259
+ // projects.index.json5 projects[].requirements[<i>]
260
+ { name: "014-测试需求10-20260622", requirementDir: "/abs/.../014-测试需求10-20260622", testsDir: "<projectDir>/src/tests/014-测试需求10-20260622", lastRunStatus: "never" }
261
+ ```
262
+
263
+ ## 9. 按需加载
264
+
265
+ - 用例 schema 详解:`references/testcase-schema.md`(v1-draft)
266
+ - **testcase.md 渲染规则:统一单表,列为用例 ID / 生成策略 / 用例标题 / 查询主键 / 前置条件 / 执行步骤 / 执行断言**
267
+ - 既有工作流参考:`references/workflow.md`
268
+
269
+ ## 10. 关键约束
270
+
271
+ - 顶层 `reviewStatus` 字段**永远不引入**(REQ-DATA-04);审阅意见请直接在 `testcase.json5` JSON5 `// 注释`。
272
+ - `cases[].reviewStatus = needs_review` 的用例不得进入 spec 组装(spec 组装阶段按 case 粒度阻断)。
273
+ - 嵌套 CRUD 一期仅作为候选用例进入 testcase,不写入正式 CRUD 契约。
274
+ - testcase.md 每次重跑完全覆盖,不保留人工编辑;事实源始终是 testcase.json5。审阅视图固定为统一单表,glue 与 ai 只通过“生成策略”列区分,不再拆成两个表。
275
+ - 对话中展示可审阅推理摘要和证据链,不展示原始隐式思维链。