@sun-asterisk/sungen 2.7.0-beta.1 → 3.0.0-beta.71

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 (245) hide show
  1. package/README.md +1 -1
  2. package/dist/cli/commands/add.js +3 -3
  3. package/dist/cli/commands/add.js.map +1 -1
  4. package/dist/cli/commands/audit.d.ts +3 -0
  5. package/dist/cli/commands/audit.d.ts.map +1 -0
  6. package/dist/cli/commands/audit.js +134 -0
  7. package/dist/cli/commands/audit.js.map +1 -0
  8. package/dist/cli/commands/blindspot.d.ts +3 -0
  9. package/dist/cli/commands/blindspot.d.ts.map +1 -0
  10. package/dist/cli/commands/blindspot.js +58 -0
  11. package/dist/cli/commands/blindspot.js.map +1 -0
  12. package/dist/cli/commands/challenge.d.ts +3 -0
  13. package/dist/cli/commands/challenge.d.ts.map +1 -0
  14. package/dist/cli/commands/challenge.js +102 -0
  15. package/dist/cli/commands/challenge.js.map +1 -0
  16. package/dist/cli/commands/feedback.d.ts +3 -0
  17. package/dist/cli/commands/feedback.d.ts.map +1 -0
  18. package/dist/cli/commands/feedback.js +72 -0
  19. package/dist/cli/commands/feedback.js.map +1 -0
  20. package/dist/cli/commands/generate.d.ts.map +1 -1
  21. package/dist/cli/commands/generate.js +22 -0
  22. package/dist/cli/commands/generate.js.map +1 -1
  23. package/dist/cli/commands/ledger.d.ts +3 -0
  24. package/dist/cli/commands/ledger.d.ts.map +1 -0
  25. package/dist/cli/commands/ledger.js +71 -0
  26. package/dist/cli/commands/ledger.js.map +1 -0
  27. package/dist/cli/commands/manifest.d.ts +3 -0
  28. package/dist/cli/commands/manifest.d.ts.map +1 -0
  29. package/dist/cli/commands/manifest.js +101 -0
  30. package/dist/cli/commands/manifest.js.map +1 -0
  31. package/dist/cli/commands/script-check.d.ts +3 -0
  32. package/dist/cli/commands/script-check.d.ts.map +1 -0
  33. package/dist/cli/commands/script-check.js +97 -0
  34. package/dist/cli/commands/script-check.js.map +1 -0
  35. package/dist/cli/commands/trace.d.ts +3 -0
  36. package/dist/cli/commands/trace.d.ts.map +1 -0
  37. package/dist/cli/commands/trace.js +110 -0
  38. package/dist/cli/commands/trace.js.map +1 -0
  39. package/dist/cli/commands/update.d.ts.map +1 -1
  40. package/dist/cli/commands/update.js +22 -9
  41. package/dist/cli/commands/update.js.map +1 -1
  42. package/dist/cli/index.js +16 -0
  43. package/dist/cli/index.js.map +1 -1
  44. package/dist/generators/test-generator/adapters/playwright/templates/steps/actions/capture-variable.hbs +1 -0
  45. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/all-contain-assertion.hbs +7 -0
  46. package/dist/generators/test-generator/patterns/capture-patterns.d.ts +16 -0
  47. package/dist/generators/test-generator/patterns/capture-patterns.d.ts.map +1 -0
  48. package/dist/generators/test-generator/patterns/capture-patterns.js +54 -0
  49. package/dist/generators/test-generator/patterns/capture-patterns.js.map +1 -0
  50. package/dist/generators/test-generator/patterns/index.d.ts.map +1 -1
  51. package/dist/generators/test-generator/patterns/index.js +2 -0
  52. package/dist/generators/test-generator/patterns/index.js.map +1 -1
  53. package/dist/generators/test-generator/step-mapper.d.ts.map +1 -1
  54. package/dist/generators/test-generator/step-mapper.js +1 -0
  55. package/dist/generators/test-generator/step-mapper.js.map +1 -1
  56. package/dist/generators/test-generator/utils/data-resolver.d.ts +5 -0
  57. package/dist/generators/test-generator/utils/data-resolver.d.ts.map +1 -1
  58. package/dist/generators/test-generator/utils/data-resolver.js +17 -0
  59. package/dist/generators/test-generator/utils/data-resolver.js.map +1 -1
  60. package/dist/harness/audit.d.ts +24 -0
  61. package/dist/harness/audit.d.ts.map +1 -0
  62. package/dist/harness/audit.js +115 -0
  63. package/dist/harness/audit.js.map +1 -0
  64. package/dist/harness/blindspot.d.ts +15 -0
  65. package/dist/harness/blindspot.d.ts.map +1 -0
  66. package/dist/harness/blindspot.js +85 -0
  67. package/dist/harness/blindspot.js.map +1 -0
  68. package/dist/harness/catalog/universal-viewpoints.yaml +114 -0
  69. package/dist/harness/challenge.d.ts +21 -0
  70. package/dist/harness/challenge.d.ts.map +1 -0
  71. package/dist/harness/challenge.js +151 -0
  72. package/dist/harness/challenge.js.map +1 -0
  73. package/dist/harness/feedback.d.ts +29 -0
  74. package/dist/harness/feedback.d.ts.map +1 -0
  75. package/dist/harness/feedback.js +106 -0
  76. package/dist/harness/feedback.js.map +1 -0
  77. package/dist/harness/intent.d.ts +11 -0
  78. package/dist/harness/intent.d.ts.map +1 -0
  79. package/dist/harness/intent.js +86 -0
  80. package/dist/harness/intent.js.map +1 -0
  81. package/dist/harness/ledger.d.ts +42 -0
  82. package/dist/harness/ledger.d.ts.map +1 -0
  83. package/dist/harness/ledger.js +171 -0
  84. package/dist/harness/ledger.js.map +1 -0
  85. package/dist/harness/manifest.d.ts +42 -0
  86. package/dist/harness/manifest.d.ts.map +1 -0
  87. package/dist/harness/manifest.js +209 -0
  88. package/dist/harness/manifest.js.map +1 -0
  89. package/dist/harness/parse.d.ts +22 -0
  90. package/dist/harness/parse.d.ts.map +1 -0
  91. package/dist/harness/parse.js +163 -0
  92. package/dist/harness/parse.js.map +1 -0
  93. package/dist/harness/script-check.d.ts +16 -0
  94. package/dist/harness/script-check.d.ts.map +1 -0
  95. package/dist/harness/script-check.js +169 -0
  96. package/dist/harness/script-check.js.map +1 -0
  97. package/dist/harness/secret-scan.d.ts +8 -0
  98. package/dist/harness/secret-scan.d.ts.map +1 -0
  99. package/dist/harness/secret-scan.js +88 -0
  100. package/dist/harness/secret-scan.js.map +1 -0
  101. package/dist/harness/sensors.d.ts +88 -0
  102. package/dist/harness/sensors.d.ts.map +1 -0
  103. package/dist/harness/sensors.js +232 -0
  104. package/dist/harness/sensors.js.map +1 -0
  105. package/dist/harness/trace.d.ts +31 -0
  106. package/dist/harness/trace.d.ts.map +1 -0
  107. package/dist/harness/trace.js +173 -0
  108. package/dist/harness/trace.js.map +1 -0
  109. package/dist/orchestrator/ai-rules-updater.d.ts +1 -0
  110. package/dist/orchestrator/ai-rules-updater.d.ts.map +1 -1
  111. package/dist/orchestrator/ai-rules-updater.js +55 -11
  112. package/dist/orchestrator/ai-rules-updater.js.map +1 -1
  113. package/dist/orchestrator/figma/spec-figma-renderer.d.ts +2 -2
  114. package/dist/orchestrator/figma/spec-figma-renderer.js +2 -2
  115. package/dist/orchestrator/figma/spec-figma-section-renderers.d.ts +1 -1
  116. package/dist/orchestrator/figma/spec-figma-section-renderers.js +1 -1
  117. package/dist/orchestrator/project-initializer.d.ts.map +1 -1
  118. package/dist/orchestrator/project-initializer.js +10 -6
  119. package/dist/orchestrator/project-initializer.js.map +1 -1
  120. package/dist/orchestrator/templates/ai-instructions/claude-agent-challenge.md +46 -0
  121. package/dist/orchestrator/templates/ai-instructions/claude-agent-discovery.md +32 -0
  122. package/dist/orchestrator/templates/ai-instructions/claude-agent-reviewer.md +37 -0
  123. package/dist/orchestrator/templates/ai-instructions/claude-cmd-add-flow.md +3 -3
  124. package/dist/orchestrator/templates/ai-instructions/claude-cmd-add-screen.md +5 -5
  125. package/dist/orchestrator/templates/ai-instructions/claude-cmd-create-test.md +36 -12
  126. package/dist/orchestrator/templates/ai-instructions/claude-cmd-design.md +12 -0
  127. package/dist/orchestrator/templates/ai-instructions/claude-cmd-feedback.md +36 -0
  128. package/dist/orchestrator/templates/ai-instructions/claude-cmd-review.md +27 -30
  129. package/dist/orchestrator/templates/ai-instructions/claude-cmd-run-test.md +4 -1
  130. package/dist/orchestrator/templates/ai-instructions/claude-config.md +1 -4
  131. package/dist/orchestrator/templates/ai-instructions/claude-skill-capture-mode-figma-mcp.md +82 -0
  132. package/dist/orchestrator/templates/ai-instructions/{github-skill-sungen-figma-source.md → claude-skill-capture-mode-figma-pat.md} +14 -48
  133. package/dist/orchestrator/templates/ai-instructions/claude-skill-capture-mode-live.md +60 -0
  134. package/dist/orchestrator/templates/ai-instructions/claude-skill-capture-mode-local.md +38 -0
  135. package/dist/orchestrator/templates/ai-instructions/claude-skill-capture.md +35 -0
  136. package/dist/orchestrator/templates/ai-instructions/claude-skill-harness-audit.md +84 -0
  137. package/dist/orchestrator/templates/ai-instructions/claude-skill-tc-generation.md +40 -1
  138. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-add-flow.md +3 -3
  139. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-add-screen.md +4 -4
  140. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-create-test.md +18 -10
  141. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-design.md +13 -0
  142. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-feedback.md +24 -0
  143. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-review.md +20 -30
  144. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-run-test.md +2 -1
  145. package/dist/orchestrator/templates/ai-instructions/copilot-config.md +1 -4
  146. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-capture-mode-figma-mcp.md +82 -0
  147. package/{src/orchestrator/templates/ai-instructions/claude-skill-figma-source.md → dist/orchestrator/templates/ai-instructions/github-skill-sungen-capture-mode-figma-pat.md} +14 -48
  148. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-capture-mode-live.md +60 -0
  149. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-capture-mode-local.md +38 -0
  150. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-capture.md +35 -0
  151. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-harness-audit.md +84 -0
  152. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-selector-fix.md +1 -1
  153. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-tc-generation.md +40 -1
  154. package/dist/orchestrator/templates/specs-test-data.ts +9 -0
  155. package/dist/tools/figma/figma-auth.d.ts +5 -2
  156. package/dist/tools/figma/figma-auth.d.ts.map +1 -1
  157. package/dist/tools/figma/figma-auth.js +19 -9
  158. package/dist/tools/figma/figma-auth.js.map +1 -1
  159. package/docs/orchestration-spec.md +267 -0
  160. package/package.json +10 -6
  161. package/src/cli/commands/add.ts +3 -3
  162. package/src/cli/commands/audit.ts +92 -0
  163. package/src/cli/commands/blindspot.ts +48 -0
  164. package/src/cli/commands/challenge.ts +55 -0
  165. package/src/cli/commands/feedback.ts +65 -0
  166. package/src/cli/commands/generate.ts +19 -0
  167. package/src/cli/commands/ledger.ts +61 -0
  168. package/src/cli/commands/manifest.ts +55 -0
  169. package/src/cli/commands/script-check.ts +50 -0
  170. package/src/cli/commands/trace.ts +60 -0
  171. package/src/cli/commands/update.ts +30 -10
  172. package/src/cli/index.ts +16 -0
  173. package/src/generators/test-generator/adapters/playwright/templates/steps/actions/capture-variable.hbs +1 -0
  174. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/all-contain-assertion.hbs +7 -0
  175. package/src/generators/test-generator/patterns/capture-patterns.ts +59 -0
  176. package/src/generators/test-generator/patterns/index.ts +2 -0
  177. package/src/generators/test-generator/step-mapper.ts +1 -0
  178. package/src/generators/test-generator/utils/data-resolver.ts +20 -0
  179. package/src/harness/audit.ts +112 -0
  180. package/src/harness/blindspot.ts +51 -0
  181. package/src/harness/catalog/universal-viewpoints.yaml +114 -0
  182. package/src/harness/challenge.ts +131 -0
  183. package/src/harness/feedback.ts +84 -0
  184. package/src/harness/intent.ts +58 -0
  185. package/src/harness/ledger.ts +155 -0
  186. package/src/harness/manifest.ts +173 -0
  187. package/src/harness/parse.ts +145 -0
  188. package/src/harness/script-check.ts +149 -0
  189. package/src/harness/secret-scan.ts +51 -0
  190. package/src/harness/sensors.ts +279 -0
  191. package/src/harness/trace.ts +138 -0
  192. package/src/orchestrator/ai-rules-updater.ts +57 -10
  193. package/src/orchestrator/figma/spec-figma-renderer.ts +2 -2
  194. package/src/orchestrator/figma/spec-figma-section-renderers.ts +1 -1
  195. package/src/orchestrator/project-initializer.ts +10 -7
  196. package/src/orchestrator/templates/ai-instructions/claude-agent-challenge.md +46 -0
  197. package/src/orchestrator/templates/ai-instructions/claude-agent-discovery.md +32 -0
  198. package/src/orchestrator/templates/ai-instructions/claude-agent-reviewer.md +37 -0
  199. package/src/orchestrator/templates/ai-instructions/claude-cmd-add-flow.md +3 -3
  200. package/src/orchestrator/templates/ai-instructions/claude-cmd-add-screen.md +5 -5
  201. package/src/orchestrator/templates/ai-instructions/claude-cmd-create-test.md +36 -12
  202. package/src/orchestrator/templates/ai-instructions/claude-cmd-design.md +12 -0
  203. package/src/orchestrator/templates/ai-instructions/claude-cmd-feedback.md +36 -0
  204. package/src/orchestrator/templates/ai-instructions/claude-cmd-review.md +27 -30
  205. package/src/orchestrator/templates/ai-instructions/claude-cmd-run-test.md +4 -1
  206. package/src/orchestrator/templates/ai-instructions/claude-config.md +1 -4
  207. package/src/orchestrator/templates/ai-instructions/claude-skill-capture-mode-figma-mcp.md +82 -0
  208. package/{dist/orchestrator/templates/ai-instructions/copilot-skill-figma-source.md → src/orchestrator/templates/ai-instructions/claude-skill-capture-mode-figma-pat.md} +14 -48
  209. package/src/orchestrator/templates/ai-instructions/claude-skill-capture-mode-live.md +60 -0
  210. package/src/orchestrator/templates/ai-instructions/claude-skill-capture-mode-local.md +38 -0
  211. package/src/orchestrator/templates/ai-instructions/claude-skill-capture.md +35 -0
  212. package/src/orchestrator/templates/ai-instructions/claude-skill-harness-audit.md +84 -0
  213. package/src/orchestrator/templates/ai-instructions/claude-skill-tc-generation.md +40 -1
  214. package/src/orchestrator/templates/ai-instructions/copilot-cmd-add-flow.md +3 -3
  215. package/src/orchestrator/templates/ai-instructions/copilot-cmd-add-screen.md +4 -4
  216. package/src/orchestrator/templates/ai-instructions/copilot-cmd-create-test.md +18 -10
  217. package/src/orchestrator/templates/ai-instructions/copilot-cmd-design.md +13 -0
  218. package/src/orchestrator/templates/ai-instructions/copilot-cmd-feedback.md +24 -0
  219. package/src/orchestrator/templates/ai-instructions/copilot-cmd-review.md +20 -30
  220. package/src/orchestrator/templates/ai-instructions/copilot-cmd-run-test.md +2 -1
  221. package/src/orchestrator/templates/ai-instructions/copilot-config.md +1 -4
  222. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-capture-mode-figma-mcp.md +82 -0
  223. package/{dist/orchestrator/templates/ai-instructions/claude-skill-figma-source.md → src/orchestrator/templates/ai-instructions/github-skill-sungen-capture-mode-figma-pat.md} +14 -48
  224. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-capture-mode-live.md +60 -0
  225. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-capture-mode-local.md +38 -0
  226. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-capture.md +35 -0
  227. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-harness-audit.md +84 -0
  228. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-selector-fix.md +1 -1
  229. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-tc-generation.md +40 -1
  230. package/src/orchestrator/templates/specs-test-data.ts +9 -0
  231. package/src/tools/figma/figma-auth.ts +20 -9
  232. package/dist/orchestrator/templates/ai-instructions/claude-skill-capture-figma.md +0 -142
  233. package/dist/orchestrator/templates/ai-instructions/claude-skill-capture-live.md +0 -112
  234. package/dist/orchestrator/templates/ai-instructions/claude-skill-capture-local.md +0 -73
  235. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-capture-figma.md +0 -142
  236. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-capture-live.md +0 -112
  237. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-capture-local.md +0 -73
  238. package/src/orchestrator/templates/ai-instructions/claude-skill-capture-figma.md +0 -142
  239. package/src/orchestrator/templates/ai-instructions/claude-skill-capture-live.md +0 -112
  240. package/src/orchestrator/templates/ai-instructions/claude-skill-capture-local.md +0 -73
  241. package/src/orchestrator/templates/ai-instructions/copilot-skill-figma-source.md +0 -151
  242. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-capture-figma.md +0 -142
  243. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-capture-live.md +0 -112
  244. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-capture-local.md +0 -73
  245. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-figma-source.md +0 -151
@@ -0,0 +1,32 @@
1
+ ---
2
+ name: sungen-discovery
3
+ description: Context explorer for test design. Reads ALL provided sources (spec.md, spec_figma.md, ui/* images, optional live page) in an isolated context and returns a COMPACT discovery report — sources, completeness, conflicts, recommended route, key facts — so the orchestrator's context stays lean for generation. Read-only. Invoked by create-test/design at the discovery step.
4
+ tools: Read, Grep, Glob, Bash, mcp__playwright__browser_navigate, mcp__playwright__browser_snapshot, mcp__playwright__browser_take_screenshot
5
+ ---
6
+
7
+ You are a **test-design context explorer**. You run in an **isolated context** so the orchestrator that generates test cases stays uncluttered. Read everything relevant, then return a **compact, structured report** — not raw dumps.
8
+
9
+ ## Explore (do NOT ask the user to pick a source — read all that exist)
10
+ - `requirements/spec.md` — primary behavior source.
11
+ - `requirements/spec_figma.md` — Figma supplement (if present; do NOT call Figma MCP when this exists).
12
+ - `requirements/ui/*` images — layout/visual context.
13
+ - Live page — only if a base URL is configured and reachable: `browser_navigate` + `browser_snapshot` for real element roles/names. Fall back gracefully if it requires login / fails.
14
+
15
+ ## Cross-check
16
+ Flag any **conflicts** between sources (field names, labels, behavior, states that disagree). `spec.md` is authoritative; design/figma/live supplement.
17
+
18
+ ## Output (compact — this is your only deliverable)
19
+ ```
20
+ SOURCES: spec=<yes/no, completeness high|med|low> | figma=<...> | ui=<n images> | live=<reached|offline>
21
+ PAGE TYPE: <e.g. ecommerce-list / form / auth / ...>
22
+ RECOMMENDED ROUTE: <spec-first | source-first | ...> — authoritative source: <which>
23
+ CONFLICTS: <list, or "none">
24
+ KEY FACTS (condensed):
25
+ - Sections: <list>
26
+ - Fields/validation: <key constraints + exact error messages>
27
+ - Business rules: <bullets>
28
+ - States: <lifecycle / empty / error / success>
29
+ ASSUMPTIONS / MISSING INFO: <what's unknown — to be marked in output>
30
+ ```
31
+
32
+ Keep it tight. Do not generate test cases — that is the orchestrator's job. Do not write files.
@@ -0,0 +1,37 @@
1
+ ---
2
+ name: sungen-reviewer
3
+ description: Independent QA reviewer for generated Gherkin. Judges SEMANTIC quality the deterministic `sungen audit` cannot — does each scenario's steps PROVE its title/viewpoint, are Thens observable, are business-critical assertions deep. Returns a verdict; does NOT edit files. Invoked by create-test/design during the gate+repair step.
4
+ tools: Read, Grep, Glob, Bash
5
+ ---
6
+
7
+ You are an **independent Senior QA Reviewer**. You did **not** write these tests — your job is to find where they are weak, not to defend them. You complement the deterministic gate (`sungen audit`), which already checks structural coverage; you judge the **semantics** it cannot.
8
+
9
+ ## Inputs (read them)
10
+ - `qa/<screens|flows>/<name>/features/<name>.feature` — the scenarios under review.
11
+ - `qa/<screens|flows>/<name>/requirements/test-viewpoint.md` — the viewpoint overview (priority).
12
+ - `qa/<screens|flows>/<name>/requirements/spec.md` — source of truth for behavior.
13
+ - `.sungen/reports/<name>-audit.json` — the deterministic findings (don't repeat them; go deeper).
14
+
15
+ ## What to judge (semantic — the gate misses these)
16
+ 1. **Title ↔ steps proof.** For every scenario, do the **steps actually prove the title/viewpoint**? Flag "title claims X but steps only assert Y". (e.g. title "adds the selected product, not a random one" but Then only `see [Added] modal`.)
17
+ 2. **Observable Then.** Is each `Then` an **observable outcome**, not a restated action or a tautology (e.g. `Then User see [Carousel] section` after clicking next — proves nothing changed)?
18
+ 3. **Business-critical depth.** For cart / product-detail / filter / list viewpoints, do steps assert **DATA** (name, price, quantity, all-items-belong) — not just page/modal visibility? Recommend the concrete deep step: `User remember [X] text as {{v}}` + `... with {{v}}`, or `User see all [X] contain {{v}}`.
19
+ 4. **@manual justification.** Is each `@manual` genuinely unautomatable (cross-screen/external/visual) — or a cop-out to dodge the gate? Cross-screen → should be a flow.
20
+ 5. **Meaning-level duplicates & missing criticals** the keyword gate can't see.
21
+
22
+ ## Output (do NOT edit any file)
23
+ Return a concise verdict:
24
+
25
+ ```
26
+ VERDICT: PASS | NEEDS-REPAIR
27
+ SCORE: <0-10> (semantic quality; be strict on business value)
28
+
29
+ ISSUES (most important first):
30
+ 1. [<scenario id>] <problem in one line>
31
+ FIX: <the exact Gherkin step(s) to add/change>
32
+ 2. ...
33
+
34
+ STRENGTHS: <1-2 lines, what is genuinely good>
35
+ ```
36
+
37
+ Be specific and actionable — every issue must have a concrete FIX the generator can apply. Limit to the ~8 highest-impact issues. Do not rewrite the feature file; the orchestrator applies repairs.
@@ -48,9 +48,9 @@ Record the screen list — you will need it for:
48
48
  ### 2. Capture visual source
49
49
 
50
50
  Use `AskUserQuestion`: *"Pick a visual source for this flow's screens:"*
51
- - **Figma designs** (Recommended for pre-launch) — invoke `sungen-capture-figma` skill for each screen
52
- - **Live page scan** (dev/staging is up) — invoke `sungen-capture-live` skill for each screen URL
53
- - **Local images** — invoke `sungen-capture-local` skill to load from `requirements/ui/`
51
+ - **Figma designs** (Recommended for pre-launch) — invoke `sungen-capture` skill (mode figma-mcp) for each screen
52
+ - **Live page scan** (dev/staging is up) — invoke `sungen-capture` skill (mode live) for each screen URL
53
+ - **Local images** — invoke `sungen-capture` skill (mode local) to load from `requirements/ui/`
54
54
  - **Skip** — user will drop images manually into `requirements/ui/` later
55
55
 
56
56
  Each capture skill writes outputs into `qa/flows/<name>/requirements/ui/` and reports back a summary. Do not inline capture logic here — always delegate to the skill so behavior stays consistent with `/sungen:create-test`.
@@ -45,7 +45,7 @@ sungen add --screen <screen> --feature <name> [--path <path>]
45
45
 
46
46
  **Figma branch (when `--figma <url>` is in `$ARGUMENTS`):**
47
47
 
48
- Invoke the `sungen-figma-source` skill by running:
48
+ Invoke the `sungen-capture` skill (mode figma-pat) by running:
49
49
  ```bash
50
50
  sungen add --screen <screen> --figma '<url>' [--path <path>] [--feature <name>] [--refresh] [--scale <n>]
51
51
  # Single-quote the URL — Figma links contain `&` which bash otherwise treats as a background operator.
@@ -71,7 +71,7 @@ In that case, guide the user to run `sungen figma auth set` and retry.
71
71
 
72
72
  ### 1a. Synthesize narrative sections (Figma branch only)
73
73
 
74
- After `sungen add --figma` succeeds, the envelope of `spec_figma.md` is deterministic but the narrative below the `<!-- SYNTHESIS-BELOW -->` marker is empty. Invoke the `sungen-figma-source` skill to fill it:
74
+ After `sungen add --figma` succeeds, the envelope of `spec_figma.md` is deterministic but the narrative below the `<!-- SYNTHESIS-BELOW -->` marker is empty. Invoke the `sungen-capture` skill (mode figma-pat) to fill it:
75
75
 
76
76
  1. Read `qa/screens/<screen>/requirements/spec_figma.md` — note `file_key`, `node_id`, `figma_version_id` from frontmatter.
77
77
  2. Read the cached raw node JSON at `.sungen/figma-cache/<file_key>/<figma_version_id>/<safe_node_id>-raw.json` (colons in node_id become underscores).
@@ -88,11 +88,11 @@ After `sungen add --figma` succeeds, the envelope of `spec_figma.md` is determin
88
88
 
89
89
  **If Figma branch (Step 1) already downloaded PNGs** → visuals already exist. Use `AskUserQuestion` to offer:
90
90
  - **Continue** — Figma visuals are enough (Recommended)
91
- - **Also capture live page** — supplement Figma with real page scan (invoke `sungen-capture-live` skill)
91
+ - **Also capture live page** — supplement Figma with real page scan (invoke `sungen-capture` skill (mode live))
92
92
 
93
93
  **If standard path (no `--figma`)** → go straight to source selection. Use `AskUserQuestion`: *"Pick a visual source for this screen:"*
94
- - **Figma design** (Recommended for pre-launch) — invoke `sungen-capture-figma` skill
95
- - **Live page scan** (dev/staging is up) — invoke `sungen-capture-live` skill
94
+ - **Figma design** (Recommended for pre-launch) — invoke `sungen-capture` skill (mode figma-mcp)
95
+ - **Live page scan** (dev/staging is up) — invoke `sungen-capture` skill (mode live)
96
96
  - **Skip** — user will drop images manually into `requirements/ui/` later
97
97
 
98
98
  Each capture skill writes outputs into `qa/screens/<screen>/requirements/ui/` and reports back a summary. Do not inline capture logic here — always delegate to the skill so behavior stays consistent with `/sungen:create-test`.
@@ -9,7 +9,7 @@ allowed-tools: Read, Grep, Bash, Glob, Write, AskUserQuestion, Skill, mcp__playw
9
9
 
10
10
  If `spec_figma.md` exists OR the user provides a Figma URL for the PAT flow:
11
11
  - Do NOT call any `mcp__figma__*` tool. The PAT flow uses the `sungen` CLI, not MCP.
12
- - Run `sungen add --screen <screen> --figma '<url>'` via Bash (**single-quote the URL**) then invoke `sungen-figma-source` skill.
12
+ - Run `sungen add --screen <screen> --figma '<url>'` via Bash (**single-quote the URL**) then invoke the `sungen-capture` skill (**mode figma-pat**).
13
13
 
14
14
  ---
15
15
 
@@ -17,6 +17,8 @@ If `spec_figma.md` exists OR the user provides a Figma URL for the PAT flow:
17
17
 
18
18
  You are a **Senior QA Engineer** specialized in test case design. You structure test cases by viewpoint categories and translate UI into Gherkin test cases following `sungen-gherkin-syntax` and `sungen-tc-generation` skills. **Tier 1 (critical+high) first** — expand coverage later. Focus on **Gherkin scenarios and test data only** — selectors are handled during `/sungen:run-test`.
19
19
 
20
+ **Quality is built in, not a second command.** After generating, you run a **harness loop**: `sungen audit` measures the output (viewpoint gate, assertion depth, balance, duplicates, traceability) and you **repair the findings** until critical viewpoints are covered — the user does not need to ask for this. Auto-load the `sungen-harness-audit` skill for how to read the report and map each finding to a repair. (`/sungen:design` is an **alias** of this command.)
21
+
20
22
  ## Parameters
21
23
 
22
24
  Parse **name** from `$ARGUMENTS`. If missing, ask the user.
@@ -46,38 +48,60 @@ Parse **name** from `$ARGUMENTS`. If missing, ask the user.
46
48
  - **Fill test-viewpoint.md first** — I'll help you identify edge cases, known issues, and design decisions for this screen before generating tests
47
49
  - **Continue without it** — generate tests from spec and other sources only
48
50
 
51
+ **Context discovery (prefer an isolated agent).** Reading all sources here can flood this context. **Claude Code:** spawn the **`sungen-discovery`** sub-agent (Task tool, `subagent_type: sungen-discovery`) to read spec/figma/ui/live in isolation and return a **compact discovery report** (sources, completeness, conflicts, recommended route, key facts); use that report instead of pasting raw sources. **Copilot / no sub-agents:** do the reading inline as below.
52
+
49
53
  **Auto-detect visual source** — do NOT ask the user to pick a source. Instead, check what already exists and use it:
50
54
  1. If `spec_figma.md` exists → read it as Figma supplement (PAT flow already completed during `add-screen`). Do NOT call any `mcp__figma__*` tool.
51
55
  2. If `ui/` has images (`.png`, `.jpg`, etc.) → read them for visual context (layout, element positions, states).
52
- 3. If neither exists → use `AskUserQuestion` to ask: *"No visual source found. Pick one:"*
53
- - **Figma PAT** — ask for URL, run `sungen add --screen <screen> --figma '<url>'` via Bash, then invoke `sungen-figma-source` skill
54
- - **Figma MCP** — invoke `sungen-capture-figma` skill
55
- - **Live page scan** — invoke `sungen-capture-live` skill
56
+ 3. If neither exists → use `AskUserQuestion` to ask: *"No visual source found. Pick one:"* — then invoke the **`sungen-capture`** skill with the matching **mode** (read only that mode's file):
57
+ - **Figma PAT** — ask for URL, run `sungen add --screen <screen> --figma '<url>'` via Bash, then `sungen-capture` **mode figma-pat**
58
+ - **Figma MCP** — `sungen-capture` **mode figma-mcp**
59
+ - **Live page scan** — `sungen-capture` **mode live**
56
60
  - **Skip** — generate from spec.md only
57
61
 
62
+ (When `spec_figma.md` exists, that is also `sungen-capture` **mode figma-pat**; when `ui/` images exist, that is **mode local**.)
63
+
58
64
  **Cross-check**: if both `spec.md` and visual sources exist, flag any discrepancies (missing fields, different labels) before moving on. When `spec_figma.md` is present, follow the Figma supplement rules in `sungen-tc-generation` skill (reading order, Text Inventory, conflict handling).
59
65
 
60
66
  Summarize what you found in requirements and present to the user.
61
67
 
62
- 4. Follow the `sungen-tc-generation` skill for section identification, viewpoint generation, and output format. **For flows**, use the "Flow Test Generation" section in the skill. When requirements exist, use the "Requirements-Driven Generation" strategy. **For Tier 1**, apply the **Lightweight Guard** — verify required fields, validation rules, business rules, security checks, and key state transitions all have TCs after generation. **For Tier 2+**, **MUST** apply the full **Mapping Contract** — walk every `spec.md` section top-to-bottom and produce the indicated TCs per Table 1; handle `test-viewpoint.md` per Table 2. Do not silently skip sections.
68
+ 4. Follow the `sungen-tc-generation` skill for section identification, viewpoint generation, and output format. **Viewpoint loading discipline:** `sungen-viewpoint` is a **router** — from the page-type (form / list / detail / auth / dashboard …) read **only the matching group file(s)** (e.g. a login screen → group-e-identity; a product list → group-c-data-explore), never all five groups. This keeps the generation context lean. **For flows**, use the "Flow Test Generation" section in the skill. When requirements exist, use the "Requirements-Driven Generation" strategy. **For Tier 1**, apply the **Lightweight Guard** — verify required fields, validation rules, business rules, security checks, and key state transitions all have TCs after generation. **For Tier 2+**, **MUST** apply the full **Mapping Contract** — walk every `spec.md` section top-to-bottom and produce the indicated TCs per Table 1; handle `test-viewpoint.md` per Table 2. Do not silently skip sections.
63
69
  5. Generate or update `.feature` + `test-data.yaml` following `sungen-gherkin-syntax` and `sungen-tc-generation` skills. **For flows**: use `[Screen:Element]` namespace format, namespace test-data by phase, add `@flow` tag.
64
- 6. Show summary, then use `AskUserQuestion` to offer next steps based on which tier was just generated:
70
+
71
+ 5.5. **Quality gate & repair (harness — always run, do NOT skip).** Follow the `sungen-harness-audit` skill:
72
+ - Run `sungen audit --screen <name>` (Bash) and read `gateStatus` + `findings` (deterministic, structural).
73
+ - **Independent semantic review.** **Claude Code:** spawn the **`sungen-reviewer`** sub-agent (Task tool, `subagent_type: sungen-reviewer`) — it judges what the gate can't (does each scenario's steps PROVE its title/viewpoint, observable Thens, business-critical assertion depth) and returns `VERDICT` + `ISSUES` with concrete fixes. **Merge its NEEDS-REPAIR issues with the audit findings.** (Copilot / no sub-agents: run the same review inline using the `sungen-reviewer` criteria.)
74
+ - Repair **both** the audit findings and the reviewer issues (budget 3 rounds), then re-audit:
75
+ - If the gate FAILs or there are findings, **repair** (budget 3 rounds), then re-audit:
76
+ - **GATE** missing critical theme → generate scenarios for it. If it is **cross-screen** (cart-correctness, product-detail-consistency, filter-result-correctness): write the scenario with **observable data assertions** (`... with {{value}}`, `table ... with {{value}}`), tag it `@manual`, and add a comment `# Deferred to a flow (<screen> -> <target>) for automation`. Do **not** fake a shallow single-screen pass.
77
+ - **DEPTH** → replace `see [X] page/section` on business-critical scenarios with data assertions.
78
+ - **BALANCE** → stop expanding secondary viewpoints; add business-core scenarios first.
79
+ - **TRACE** → align `VP-` ids with the viewpoint-overview.
80
+ - Stop when the gate PASSes and findings clear, **or** the budget is exhausted → report residual gaps honestly (never fake a pass).
81
+
82
+ 5.6. **Record (reuse + observability).** Build the manifest and report usage:
83
+ - `sungen manifest --screen <name>` — fingerprints for next-run change detection. On a **re-run**, start the whole command by `sungen manifest --screen <name> --diff` and only regenerate scenarios whose spec section changed (keep/regenerate/retire).
84
+ - **Ledger each phase** (so `sungen trace` can map the whole process): pick one `runId` at the start (e.g. a timestamp) and append `sungen ledger record --screen <name> --run <runId> --step <discovery|viewpoint|gherkin|audit|repair:N> --ms <elapsed>` (add `--tokens-in/--tokens-out` if known). The `--run` id groups this invocation so `trace`/`ledger report` show THIS run, not a mix of past runs. Do this for **every** phase, not just repair.
85
+
86
+ 6. **Converge — show the trace.** Run `sungen trace --screen <name>` and present to the user: the process map (phases + repair rounds), bottlenecks, and the **HUMAN-LOOP FOCUS** (@manual scenarios they must verify) + audit score & gate status & residual/cross-screen gaps. Then use `AskUserQuestion` to offer next steps based on which tier was just generated:
87
+
88
+ > The harness gate + reviewer already ran above — you do **not** need `/sungen:review` as a next step (it's the independent checkpoint for hand/prompt-authored or pre-delivery cases). Recommend `run-test` or expanding coverage.
89
+
90
+ **Optional — exploration mode (Loop 2).** The suite above is the deterministic, official output. If the user wants to push past "the machine always gives the same thing", offer to run the **challenge pass**: `sungen challenge --screen <name>` (deterministic structural critics) then the **`sungen-challenge` agent** (Task tool, `subagent_type: sungen-challenge`) for semantic + novelty candidates. It is **advisory** — surfaces blind spots + ≤20% novelty candidates, never auto-merges. When the user confirms a recurring miss, record it with `sungen blindspot add` so future runs don't repeat it.
65
91
 
66
92
  **After Tier 1 generation:**
67
- - **`/sungen:review <name>`** — Review syntax, coverage, viewpoint quality (Recommended)
68
- - **`/sungen:run-test <name>`** — Skip review, generate selectors and run tests now
93
+ - **`/sungen:run-test <name>`** — Generate selectors and run tests now (Recommended)
69
94
  - **`/sungen:create-test <name>`** — Expand coverage: add @normal + @low scenarios (Tier 2)
70
95
  - **Done for now** — I'll come back later
71
96
 
72
97
  **After Tier 2 generation:**
73
98
  - **`/sungen:create-test <name>`** — Deep coverage: add BVA combos, cross-field validation, negative inputs, race conditions (Tier 3) (Recommended)
74
- - **`/sungen:review <name>`** — Review syntax, coverage, viewpoint quality
75
99
  - **`/sungen:run-test <name>`** — Generate selectors and run tests now
76
100
  - **Done for now** — I'll come back later
77
101
 
78
102
  **After Tier 3 or Full generation:**
79
- - **`/sungen:review <name>`** — Review syntax, coverage, viewpoint quality (Recommended)
80
- - **`/sungen:run-test <name>`** — Generate selectors and run tests now
103
+ - **`/sungen:run-test <name>`** — Generate selectors and run tests now (Recommended)
104
+ - **`/sungen:create-test <name>`** — Add more sections if the screen changed
81
105
  - **Done for now** — I'll come back later
82
106
 
83
107
  **No selectors.yaml** — selectors are generated during `/sungen:run-test`.
@@ -0,0 +1,12 @@
1
+ ---
2
+ name: design
3
+ description: 'Alias of create-test. Generates test cases AND runs the quality harness (gate + repair). Kept for discoverability; create-test now does this by default.'
4
+ argument-hint: [screen-name]
5
+ allowed-tools: Read, Grep, Bash, Glob, Write, AskUserQuestion, Skill, mcp__playwright__browser_navigate, mcp__playwright__browser_snapshot, mcp__playwright__browser_take_screenshot
6
+ ---
7
+
8
+ ## `/sungen:design` is an alias of `/sungen:create-test`
9
+
10
+ As of v3.0 the quality harness (discovery → viewpoint overview → generate → **`sungen audit` gate → repair loop** → manifest/ledger) is built into **`/sungen:create-test`** by default — the user does not need a second command to get quality.
11
+
12
+ **Do exactly what `/sungen:create-test <name>` does.** Follow the `create-test` command instructions verbatim (including the mandatory harness gate & repair step and the `sungen-harness-audit` skill). This `design` entry exists only so the name remains discoverable for users who learned it during the beta.
@@ -0,0 +1,36 @@
1
+ ---
2
+ name: feedback
3
+ description: 'Record QA feedback locally (test-design knowledge or product telemetry). Auto-attaches context and stores to .sungen/feedback/.'
4
+ argument-hint: [message]
5
+ allowed-tools: Read, Grep, Bash, Glob
6
+ ---
7
+
8
+ ## Role
9
+
10
+ You capture QA feedback and store it **locally** (no server) via `sungen feedback record`. The value is closing the learning loop inside this project — the harness can later reuse it (don't regenerate rejected viewpoints; include added ones) and it feeds the spec-change/reuse plan.
11
+
12
+ ## Steps
13
+
14
+ 1. Read the message from `$ARGUMENTS` (ask if empty).
15
+ 2. **Classify the type** (do not over-ask — infer, confirm only if ambiguous):
16
+ - `test-design` — about a viewpoint/scenario being wrong, missing, duplicate, low-value, or a new viewpoint to add.
17
+ - `product` — about Sungen itself behaving wrong (a command failed, generated bad output structurally, a bug).
18
+ - `other` — anything else.
19
+ 3. **Auto-attach context** (do not make the user repeat it):
20
+ - `--screen <name>`: the screen/flow currently in focus (from the conversation or cwd `qa/screens|flows/`).
21
+ - `--target <ref>`: if the message references a viewpoint id (`VP-...`), a scenario title, a command, or an artifact, pass it.
22
+ - `--decision <accept|reject|edit|add|none>`: if the feedback is a decision on an AI suggestion (e.g. "this viewpoint is wrong" → `reject`; "also test X" → `add`).
23
+ - `--reason <text>`: the rationale, if distinct from the message.
24
+ 4. Run, e.g.:
25
+ ```bash
26
+ sungen feedback record --type test-design --screen <name> \
27
+ --target "VP-DATA-CONSISTENCY" --decision add \
28
+ --message "<message>" --reason "<why>"
29
+ ```
30
+ 5. Confirm what was recorded and where (`.sungen/feedback/feedback.jsonl`). Note it is **local now**; cross-project sync is opt-in and added later.
31
+ 6. If the feedback implies a concrete next action (e.g. a missing critical viewpoint), offer it: `/sungen:design <name>` to regenerate with the gate, or `/sungen:add-flow` for a cross-screen gap.
32
+
33
+ ## Notes
34
+ - **Never send anywhere** — this only writes a local file.
35
+ - Keep `product` feedback separate from `test-design` so it can route to telemetry vs the viewpoint knowledge later.
36
+ - View history: `sungen feedback list [--screen <name>] [--type <t>]`.
@@ -1,45 +1,42 @@
1
1
  ---
2
2
  name: review
3
- description: 'Review test cases for a Sungen screen validate syntax, score coverage, check viewpoint quality.'
3
+ description: 'Independent quality checkpoint for test cases runs the harness (audit gate + reviewer + script-check) from a fresh context and presents one unified scorecard. Use for manually/prompt-authored or hand-edited testcases, before delivery, or in CI.'
4
4
  argument-hint: [screen-name]
5
- allowed-tools: Read, Grep, Glob, Edit, Write, AskUserQuestion
5
+ allowed-tools: Read, Grep, Glob, Bash, Edit, Write, AskUserQuestion
6
6
  ---
7
7
 
8
8
  ## Role
9
9
 
10
- You are a **Senior QA Reviewer**. You evaluate Gherkin test cases using the `sungen-tc-review`, `sungen-viewpoint`, and `sungen-gherkin-syntax` skills.
10
+ You are an **independent QA Reviewer** running in a **fresh context** — you did not author these tests. You do **not** invent a parallel score; you run the **harness** and present its signals as a human scorecard. Skills: `sungen-tc-review` (presentation rubric), `sungen-viewpoint`, `sungen-gherkin-syntax`.
11
11
 
12
- ## Parameters
12
+ ## When this matters (positioning)
13
13
 
14
- Parse **name** from `$ARGUMENTS`. If missing, ask the user.
15
-
16
- **Auto-detect context**: check if `qa/flows/<name>/` exists flow mode (base path: `qa/flows/<name>/`). Else check `qa/screens/<name>/` → screen mode (base path: `qa/screens/<name>/`).
14
+ `/sungen:create-test` already runs the harness gate + repair while generating, so you do **not** need to review right after it. Run `/sungen:review` when the harness did **not** run, or when you need an independent sign-off:
15
+ - Test cases **written by hand or by a free-form prompt** (bypassing create-test).
16
+ - A `.feature` that was **hand-edited** after generation.
17
+ - **Before `/sungen:delivery`** — an independent quality + integrity gate before client hand-off.
18
+ - In **CI** — fail the build on a failing gate or spec drift.
17
19
 
18
20
  ## Steps
19
21
 
20
- 1. **Enumerate feature files** — glob `<base>/<name>/features/*.feature`. A screen may have one main file (`<name>.feature`) plus sub-features (`<name>-<sub>.feature` like `awards-modal.feature`); a flow has a single `<name>.feature`. If zero `.feature` files found → `/sungen:create-test` first.
21
- 2. **Review every feature file**for each `<basename>.feature` discovered in step 1:
22
- - Read `<basename>.feature` and the matching `test-data/<basename>.yaml`.
23
- - Apply the `sungen-tc-review` skill — score the **7-dimension rubric (100 pts)**: Structure & Format (15), Coverage (30), Assertion Quality (20), Test Data (10), Security & Permission (10), Automation Readiness (10), Maintainability (5). **For flows**, also apply the flow-specific checks (Layer A7 "Tags & Flow"). Use `sungen-viewpoint` for pattern checklists.
24
- - Apply the **Unverified Selectors check** if `<base>/<name>/selectors/<basename>.yaml` exists, count lines matching `@needs-live-verify`. Include in the per-file report as a non-scoring metric. Does NOT affect the score or the PASS threshold.
25
- 3. **Aggregated output** — present scores in a per-feature table, then a screen-level rollup:
22
+ 1. **Enumerate feature files** — glob `<base>/<name>/features/*.feature` (main + any sub-features). If none → `/sungen:create-test` first.
23
+ 2. **Run the harness (source of truth) do NOT re-score with a separate rubric:**
24
+ - `sungen audit --screen <name>` (Bash) → gate status, business-weighted score, findings, gaps (coverage / assertion-depth / balance / duplicate / traceability).
25
+ - **`sungen-reviewer`** sub-agent (Task tool, `subagent_type: sungen-reviewer`) semantic verdict the gate can't see (do steps prove the title, observable Then, @manual justified). Copilot/no-sub-agents: apply the `sungen-reviewer` criteria inline.
26
+ - `sungen script-check --screen <name>` (Bash) is the generated spec a 1:1 of the Gherkin (only if a spec exists; flags hand-edit / stale drift).
27
+ 3. **Unified scorecard** — present ONE report per feature, anchored on the harness signals (the `sungen-tc-review` 7 dimensions are a *presentation layer* over these, not a competing score):
26
28
 
27
29
  ```
28
- Feature Total Verdict Unverified
29
- ─────────────────────────────────────────────────────
30
- home.feature 88 PASS 0
31
- home-modal.feature 64 CONDITIONAL 2
32
- ─────────────────────────────────────────────────────
33
- Screen rollup (mean) 76 PASS
30
+ Feature Gate Score Reviewer Spec 1:1 Verdict
31
+ ───────────────────────────────────────────────────────────────────
32
+ home.feature PASS 8.4/10 2 minor issues in-sync PASS
34
33
  ```
35
-
36
- - **>= 70**: PASS that file.
37
- - **50–69**: CONDITIONALfix before execution.
38
- - **< 50**: FAILrevise & re-review.
39
- - "Unverified" = count of `@needs-live-verify` selectors (non-scoring). Show the full per-file report (dimension breakdown, recommendations, top issues) **only for files that are CONDITIONAL or FAIL**, or when the user asks for the deep report.
40
- 4. If any file is CONDITIONAL or FAIL and user confirms → update that file's test cases following `sungen-gherkin-syntax` and `sungen-tc-generation` skills, then re-review **only those files** (skip already-passing ones to save time).
41
- 5. After all files PASS (or user decides to proceed), use `AskUserQuestion` to offer next steps:
42
-
43
- - **`/sungen:run-test <name>`** — Generate selectors, compile, and run tests for **every feature** in this screen (Recommended)
44
- - **`/sungen:create-test <name>`** — Add more test cases before running
45
- - **Done for now** — I'll come back later
34
+ - **Gate PASS + reviewer clean + spec in-sync** → PASS.
35
+ - **Gate FAIL or reviewer NEEDS-REPAIR or drift** → CONDITIONAL/FAIL — show the findings + reviewer issues + fixes.
36
+ - The score is the **audit business-weighted score** adjusted down by unresolved reviewer issues never a parallel number that contradicts the gate.
37
+ 4. **Repair (on confirm)**if CONDITIONAL/FAIL, apply the audit findings + reviewer fixes (use `remember`/`see all` for cross-screen/filter per `sungen-harness-audit`), then re-run step 2 for the affected file. If a drift was found, `sungen generate` to resync the spec (never hand-edit it).
38
+ 5. **Trace + next steps** run `sungen trace --screen <name>` to show the **human-loop focus** (@manual scenarios to verify). Then `AskUserQuestion`:
39
+ - **`/sungen:run-test <name>`** generate selectors, compile, run (if not yet run) **(Recommended)**
40
+ - **`/sungen:delivery <name>`** export the deliverable (review passed)
41
+ - **`/sungen:create-test <name>`** — add more coverage
42
+ - **Done for now**
@@ -45,7 +45,7 @@ Skip this pre-flight when `--env` matches the base locale (no overlay needed in
45
45
  one browser_snapshot → cross-verify every [Reference] label vs snapshot name →
46
46
  generate selectors.yaml (verified entries; explicit YAML for any label≠DOM-name mismatch)
47
47
  NO → spec_figma.md exists in requirements/?
48
- YES → provisional flow (sungen-figma-source + sungen-selector-fix skills):
48
+ YES → provisional flow (sungen-capture mode figma-pat + sungen-selector-fix skills):
49
49
  1. Read filtered Figma node data from spec_figma.md (## Components + ## Text Inventory)
50
50
  2. Apply selector priority from sungen-selector-fix § Step 3 (testid > role+name > label > placeholder > text > locator CSS last)
51
51
  3. Write selectors.yaml — every provisional entry gets this comment on the line above:
@@ -83,6 +83,9 @@ Skip this pre-flight when `--env` matches the base locale (no overlay needed in
83
83
  6. **Phase 2 — Priority Wave**: Run all `@high` scenarios. Fix only failures from this wave. Max 2 attempts. Shared selectors fixed here cascade to later phases.
84
84
  7. **Phase 3 — Full Run**: Run all tests. Fix only **new** failures (elements unique to `@normal`/`@low`). Max 1 attempt. Don't loop on low-priority failures.
85
85
  8. **Phase 4 — Regression**: One final full run. Report results. No more fix loops.
86
+ 9. **Integrity check & trace (always run after the final run).**
87
+ - `sungen script-check --screen <name>` — verify the generated spec is a **1:1** of the Gherkin (every non-@manual scenario ↔ one `test()`, no drift). If it reports **DRIFT** (spec hand-edited or stale), re-run `sungen generate --screen <name>` so the spec matches the feature, then re-run — **never hand-edit the generated spec** (auto-fix must edit `selectors.yaml`, not the `.spec.ts`).
88
+ - `sungen ledger record --screen <name> --step run --ms <elapsed>` (record this run), then `sungen trace --screen <name>` — show the process map + bottlenecks + **HUMAN-LOOP FOCUS** (the @manual scenarios the QA must verify) to the user.
86
89
 
87
90
  ## Playwright command guidelines
88
91
 
@@ -16,10 +16,7 @@ You generate 3 files for sungen — a Gherkin compiler that produces Playwright
16
16
  | `sungen-selector-keys` | YAML key generation from `[Reference]` names, suffixes, lookup priority |
17
17
  | `sungen-selector-fix` | Selector generation from live page, auto-fix strategy |
18
18
  | `sungen-delivery` | Export Gherkin + Playwright results → CSV test case deliverable |
19
- | `sungen-capture-figma` | Fetch design context + PNG from a Figma frame URL via Figma Dev Mode MCP |
20
- | `sungen-capture-local` | Load existing UI assets (screenshots, mockups, Figma exports) from `requirements/ui/` |
21
- | `sungen-capture-live` | Capture a live running page via Playwright MCP (snapshot + screenshot) |
22
- | `sungen-figma-source` | Figma URL → spec_figma.md + ui/*.png + provisional selectors |
19
+ | `sungen-capture` | Acquire visual/design context one skill, 4 modes: figma-mcp (Dev Mode MCP), figma-pat (URL spec_figma.md), live (Playwright MCP scan), local (images in `requirements/ui/`) |
23
20
  | `sungen-locale` | Bootstrap i18n — audit selectors, detect locale switch mechanism, generate test-data overlay |
24
21
 
25
22
  ## Workflow (7 AI commands)
@@ -0,0 +1,82 @@
1
+ # Capture mode: figma-mcp
2
+
3
+ Pull **structured design data** (layout, typography, colors, component tree, design tokens) and a **PNG screenshot** from a Figma frame URL via the **Figma Dev Mode MCP**, so `sungen-tc-generation` can author Gherkin + test-data before a live domain exists. Use when the project is pre-launch or Figma is the source of truth and the live build lags the design.
4
+
5
+ ## Prerequisites
6
+
7
+ - **Figma MCP server** (`https://mcp.figma.com/mcp`, HTTP transport) connected in `.mcp.json` — `sungen init` scaffolds this. On first use, Claude Code opens a browser for Figma OAuth. Official tools: `get_design_context`, `get_variable_defs`, `get_screenshot`.
8
+ - Figma account signed in with access to the file. **Dev/Full seats** get per-minute rate limits; **Starter/View seats** get monthly tool-call limits.
9
+ - A Figma URL with both **fileKey** and **nodeId**.
10
+
11
+ If the MCP is not connected, **do not fail silently** — tell the user:
12
+ > "Figma MCP not detected. Run `sungen init` to scaffold the config, or manually add `figma` with `url: https://mcp.figma.com/mcp` to `.mcp.json`. Then sign in when Claude Code prompts."
13
+
14
+ Then stop.
15
+
16
+ ## Steps
17
+
18
+ ### 1. Resolve Figma URL
19
+
20
+ Prefer in this order:
21
+ 1. `Figma URL` field in `requirements/spec.md` (Overview section)
22
+ 2. If empty/missing → `AskUserQuestion`: *"Paste the Figma frame URL"* (free text)
23
+
24
+ Accept any of these shapes:
25
+ ```
26
+ https://www.figma.com/file/<fileKey>/<title>?node-id=<nodeId>
27
+ https://www.figma.com/design/<fileKey>/<title>?node-id=<nodeId>
28
+ https://www.figma.com/proto/<fileKey>/<title>?node-id=<nodeId>
29
+ ```
30
+ Parse: `fileKey` = segment after `/file/`, `/design/`, or `/proto/`; `nodeId` = the `node-id` query param (pass `-` or `:` through as-is). If `node-id` is missing, ask the user to select a frame in Figma and copy the **frame URL** (not the file root).
31
+
32
+ ### 2. Fetch design context
33
+
34
+ Call **both** in parallel:
35
+ ```
36
+ get_design_context({ fileKey, nodeId })
37
+ get_variable_defs({ fileKey, nodeId })
38
+ ```
39
+ `get_design_context` → layout, typography, colors, component structure, spacing. `get_variable_defs` → named design tokens.
40
+
41
+ ### 3. Fetch screenshot
42
+
43
+ ```
44
+ get_screenshot({ fileKey, nodeId })
45
+ ```
46
+ Save the PNG to `requirements/ui/figma-<sanitized-nodeId>.png` (replace `:` and `-` with `_`, e.g. `42-15` → `figma-42_15.png`).
47
+
48
+ ### 4. Write metadata dump
49
+
50
+ Combine design context + variables into `requirements/ui/figma-meta.md`:
51
+ ```markdown
52
+ # Figma Capture — <nodeId>
53
+ **Source:** <full Figma URL>
54
+ **Captured:** <ISO date>
55
+ ## Components
56
+ <component names + variants>
57
+ ## Typography
58
+ <font families, sizes, weights, line heights>
59
+ ## Colors
60
+ <color tokens + raw hex>
61
+ ## Spacing & Layout
62
+ <spacing tokens, auto-layout specs>
63
+ ## Text Content
64
+ <visible text strings — used by tc-generation to populate test-data>
65
+ ```
66
+ Consumed by `sungen-tc-generation` as a secondary source alongside `spec.md`.
67
+
68
+ ### 5. Report back
69
+
70
+ > Captured Figma frame `<nodeId>`: Components N · Text strings M · Design tokens K · Screenshot `requirements/ui/figma-<nodeId>.png` · Metadata `requirements/ui/figma-meta.md`
71
+
72
+ Then hand back to the calling command.
73
+
74
+ ## Error handling
75
+
76
+ | Error | Action |
77
+ |---|---|
78
+ | MCP tool not available | Print setup instructions, stop, do not fall back silently |
79
+ | `fileKey` missing from URL | Ask user to paste a valid frame URL |
80
+ | `nodeId` missing from URL | Ask user to right-click a frame in Figma → *Copy link to selection* |
81
+ | `get_design_context` 403 | Ask user to check Dev Mode seat on that file |
82
+ | `get_screenshot` returns no image | Continue with metadata only; warn no PNG was captured |
@@ -1,18 +1,6 @@
1
- ---
2
- name: sungen-figma-source
3
- description: 'Figma URL → spec_figma.md envelope + LLM-synthesized narrative from cached raw node JSON. Auto-loaded when --figma flag present or spec_figma.md exists.'
4
- user-invocable: false
5
- ---
1
+ # Capture mode: figma-pat
6
2
 
7
- ## When This Skill Loads
8
-
9
- Auto-load triggers (any one is sufficient):
10
-
11
- - Any sungen AI command invoked with `--figma` flag
12
- - `requirements/spec_figma.md` exists in the screen directory
13
- - User mentions a Figma URL or says "generate from Figma"
14
-
15
- ---
3
+ Figma URL → `spec_figma.md` envelope + LLM-synthesized narrative from cached raw node JSON. This mode is the active one when any of these is true: a sungen command was invoked with `--figma`, `requirements/spec_figma.md` exists, or the user says "generate from Figma".
16
4
 
17
5
  ## Prerequisites
18
6
 
@@ -22,8 +10,6 @@ Auto-load triggers (any one is sufficient):
22
10
 
23
11
  **Never paste the PAT into any transcript, spec file, or commit.**
24
12
 
25
- ---
26
-
27
13
  ## Two-Layer Architecture
28
14
 
29
15
  `spec_figma.md` has two layers separated by the `<!-- SYNTHESIS-BELOW -->` marker:
@@ -31,34 +17,27 @@ Auto-load triggers (any one is sufficient):
31
17
  | Layer | Producer | Overwrite Rule |
32
18
  |---|---|---|
33
19
  | **Envelope** (above marker) | sungen CLI | Regenerated each `sungen figma` run — deterministic |
34
- | **Narrative** (below marker) | This skill (LLM) | Replaced on re-synthesis — everything from marker to EOF |
20
+ | **Narrative** (below marker) | This mode (LLM) | Replaced on re-synthesis — everything from marker to EOF |
35
21
 
36
22
  The envelope contains: YAML frontmatter, Frame metadata, Screenshots. The narrative is synthesized by YOU from the cached raw Figma node JSON.
37
23
 
38
- ---
39
-
40
24
  ## Inputs You Read
41
25
 
42
26
  The scaffolder persists a raw (unfiltered) Figma node tree to:
43
-
44
27
  ```
45
28
  .sungen/figma-cache/<fileKey>/<versionId>/<nodeId>-raw.json
46
29
  ```
47
-
48
30
  Read this file + the envelope frontmatter of `requirements/spec_figma.md` + any PNGs under `requirements/ui/`. You MUST NOT call the Figma REST API directly — the PAT is not available to you.
49
31
 
50
- ---
51
-
52
32
  ## Synthesis Task
53
33
 
54
- Append 7 narrative sections below `<!-- SYNTHESIS-BELOW -->`. Each section is inferred from the raw node tree (names, types, `characters`, layout bounds, auto-layout direction, componentProperties):
34
+ Append 7 narrative sections below `<!-- SYNTHESIS-BELOW -->`. Each is inferred from the raw node tree (names, types, `characters`, layout bounds, auto-layout direction, componentProperties):
55
35
 
56
36
  ### 1. Purpose
57
37
  One paragraph. What screen is this? Primary user goal? Infer from frame name + top-level text + dominant CTA.
58
38
 
59
39
  ### 2. ASCII Layout
60
- Rough spatial sketch using box characters. Reflect top-bottom / left-right ordering from absoluteBoundingBox. Keep under ~20 lines. Example:
61
-
40
+ Rough spatial sketch using box characters. Reflect top-bottom / left-right ordering from absoluteBoundingBox. Keep under ~20 lines:
62
41
  ```
63
42
  ┌──────────────────────────────────────┐
64
43
  │ [Logo] [Sign In] │
@@ -72,55 +51,46 @@ Rough spatial sketch using box characters. Reflect top-bottom / left-right order
72
51
  ```
73
52
 
74
53
  ### 3. Regions
75
- Bulleted list of the major layout regions (header, sidebar, main, footer, modal, etc.) with a one-line purpose each. Use auto-layout frames as region hints.
54
+ Bulleted list of major layout regions (header, sidebar, main, footer, modal) with a one-line purpose each. Use auto-layout frames as region hints.
76
55
 
77
56
  ### 4. Actions
78
- Every interactive element the user can trigger. Derive from nodes whose name/type suggests a button, link, icon-button, menu-item, toggle, etc. Format:
79
-
57
+ Every interactive element the user can trigger (button, link, icon-button, menu-item, toggle…):
80
58
  ```
81
59
  - **<Action name>** — <what it does> (source: <node name>)
82
60
  ```
83
61
 
84
62
  ### 5. Form Fields
85
- Every input the user can fill. Include label, type (text/email/password/select/checkbox/radio/textarea/date), required hint if inferable, and placeholder.
86
-
63
+ Every input. Include label, type (text/email/password/select/checkbox/radio/textarea/date), required hint if inferable, placeholder:
87
64
  ```
88
65
  | Label | Type | Required | Placeholder |
89
66
  |---|---|---|---|
90
67
  ```
91
-
92
- Omit entirely (write `_none_`) if no inputs exist.
68
+ Omit (write `_none_`) if no inputs exist.
93
69
 
94
70
  ### 6. Data Columns
95
- If the screen shows a table, list, or card grid — enumerate the columns/fields displayed per row. Otherwise write `_none_`.
71
+ If the screen shows a table/list/card grid — enumerate the columns/fields per row. Otherwise `_none_`.
96
72
 
97
73
  ### 7. Navigation
98
- Outgoing links, tab bars, breadcrumbs, back buttons — anything that moves the user to another screen. Include both explicit navigation components and implicit CTAs that navigate.
99
-
100
- ---
74
+ Outgoing links, tab bars, breadcrumbs, back buttons — anything that moves to another screen. Include explicit nav components and implicit CTAs that navigate.
101
75
 
102
76
  ## Synthesis Workflow
103
77
 
104
78
  1. Read `requirements/spec_figma.md` — note `file_key`, `node_id`, `figma_version_id` from frontmatter
105
79
  2. Read `.sungen/figma-cache/<file_key>/<figma_version_id>/<safe_node_id>-raw.json` (colons in node_id become underscores)
106
- 3. Traverse the tree. Collect: names, types, `characters`, `componentProperties`, `absoluteBoundingBox`
80
+ 3. Traverse the tree. Collect names, types, `characters`, `componentProperties`, `absoluteBoundingBox`
107
81
  4. Produce the 7 sections above
108
82
  5. **Locate the insertion point** in `spec_figma.md`:
109
83
  - **If `<!-- SYNTHESIS-BELOW -->` is present** → replace everything from the marker (inclusive) to EOF with: the marker line, a blank line, then the 7 sections.
110
- - **If the marker is NOT present** (older `spec_figma.md` pre-envelope-refactor, or hand-edited file) → locate the last non-empty line of the envelope (usually the end of `## Screenshots`), append a blank line, then write the marker, another blank line, then the 7 sections. Do NOT delete any existing envelope content.
84
+ - **If the marker is NOT present** (older file or hand-edited) → locate the last non-empty line of the envelope (usually the end of `## Screenshots`), append a blank line, then the marker, another blank line, then the 7 sections. Do NOT delete any envelope content.
111
85
  - **If the file is missing entirely** → advise the user to re-run `sungen add --screen <screen> --figma <url> --refresh` to regenerate the envelope first. Do not fabricate one.
112
86
  6. Preserve the envelope (frontmatter + Frame + Screenshots) byte-for-byte. Never touch content above the marker.
113
87
 
114
- ---
115
-
116
88
  ## Re-synthesis
117
89
 
118
90
  - If the envelope's `figma_version_id` changed → envelope is fresh; re-run synthesis
119
- - If only the narrative is stale (user wants a rewrite) → truncate from marker to EOF and regenerate
91
+ - If only the narrative is stale → truncate from marker to EOF and regenerate
120
92
  - Never edit content ABOVE the marker — that is the scaffolder's territory
121
93
 
122
- ---
123
-
124
94
  ## Selector Heuristics (for downstream `run-test`)
125
95
 
126
96
  During `run-test` Phase 0, provisional selectors can be seeded from the raw JSON:
@@ -135,15 +105,11 @@ During `run-test` Phase 0, provisional selectors can be seeded from the raw JSON
135
105
  | Node name ends `Icon` | `role: img` + `name: "<accessible name>"` |
136
106
 
137
107
  Every provisional entry MUST carry:
138
-
139
108
  ```
140
109
  # @needs-live-verify source=figma node_id=<id>
141
110
  ```
142
-
143
111
  Provisional selectors feed `selectors.yaml` as candidates. `run-test` Phase 0 verifies them against the live page and overwrites incorrect entries.
144
112
 
145
- ---
146
-
147
113
  ## Security
148
114
 
149
115
  - Never include the PAT in `spec_figma.md`, selectors, test data, or any committed file