@sun-asterisk/sungen 2.6.11 → 2.6.14

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 (128) hide show
  1. package/dist/cli/commands/delivery.d.ts.map +1 -1
  2. package/dist/cli/commands/delivery.js +215 -65
  3. package/dist/cli/commands/delivery.js.map +1 -1
  4. package/dist/cli/index.js +1 -1
  5. package/dist/dashboard/snapshot-builder.d.ts.map +1 -1
  6. package/dist/dashboard/snapshot-builder.js +173 -32
  7. package/dist/dashboard/snapshot-builder.js.map +1 -1
  8. package/dist/dashboard/templates/index.html +84 -84
  9. package/dist/dashboard/types.d.ts +35 -0
  10. package/dist/dashboard/types.d.ts.map +1 -1
  11. package/dist/exporters/csv-exporter.d.ts +24 -3
  12. package/dist/exporters/csv-exporter.d.ts.map +1 -1
  13. package/dist/exporters/csv-exporter.js +28 -7
  14. package/dist/exporters/csv-exporter.js.map +1 -1
  15. package/dist/exporters/json-exporter.d.ts +15 -0
  16. package/dist/exporters/json-exporter.d.ts.map +1 -1
  17. package/dist/exporters/json-exporter.js +7 -2
  18. package/dist/exporters/json-exporter.js.map +1 -1
  19. package/dist/exporters/playwright-report-parser.d.ts +7 -0
  20. package/dist/exporters/playwright-report-parser.d.ts.map +1 -1
  21. package/dist/exporters/playwright-report-parser.js +20 -0
  22. package/dist/exporters/playwright-report-parser.js.map +1 -1
  23. package/dist/exporters/selector-key-resolver.d.ts +55 -0
  24. package/dist/exporters/selector-key-resolver.d.ts.map +1 -0
  25. package/dist/exporters/selector-key-resolver.js +208 -0
  26. package/dist/exporters/selector-key-resolver.js.map +1 -0
  27. package/dist/exporters/test-data-resolver.d.ts +15 -2
  28. package/dist/exporters/test-data-resolver.d.ts.map +1 -1
  29. package/dist/exporters/test-data-resolver.js +61 -8
  30. package/dist/exporters/test-data-resolver.js.map +1 -1
  31. package/dist/exporters/types.d.ts +1 -0
  32. package/dist/exporters/types.d.ts.map +1 -1
  33. package/dist/exporters/xlsx-exporter.d.ts +28 -3
  34. package/dist/exporters/xlsx-exporter.d.ts.map +1 -1
  35. package/dist/exporters/xlsx-exporter.js +34 -6
  36. package/dist/exporters/xlsx-exporter.js.map +1 -1
  37. package/dist/generators/test-generator/code-generator.d.ts.map +1 -1
  38. package/dist/generators/test-generator/code-generator.js +13 -0
  39. package/dist/generators/test-generator/code-generator.js.map +1 -1
  40. package/dist/generators/test-generator/utils/selector-resolver.d.ts +9 -0
  41. package/dist/generators/test-generator/utils/selector-resolver.d.ts.map +1 -1
  42. package/dist/generators/test-generator/utils/selector-resolver.js +18 -2
  43. package/dist/generators/test-generator/utils/selector-resolver.js.map +1 -1
  44. package/dist/orchestrator/ai-rules-updater.d.ts.map +1 -1
  45. package/dist/orchestrator/ai-rules-updater.js +4 -0
  46. package/dist/orchestrator/ai-rules-updater.js.map +1 -1
  47. package/dist/orchestrator/project-initializer.d.ts.map +1 -1
  48. package/dist/orchestrator/project-initializer.js +1 -2
  49. package/dist/orchestrator/project-initializer.js.map +1 -1
  50. package/dist/orchestrator/templates/ai-instructions/claude-cmd-add-screen.md +48 -14
  51. package/dist/orchestrator/templates/ai-instructions/claude-cmd-dashboard.md +4 -1
  52. package/dist/orchestrator/templates/ai-instructions/claude-cmd-delivery.md +22 -11
  53. package/dist/orchestrator/templates/ai-instructions/claude-cmd-locale.md +71 -0
  54. package/dist/orchestrator/templates/ai-instructions/claude-cmd-review.md +23 -8
  55. package/dist/orchestrator/templates/ai-instructions/claude-cmd-run-test.md +45 -6
  56. package/dist/orchestrator/templates/ai-instructions/claude-config.md +6 -1
  57. package/dist/orchestrator/templates/ai-instructions/claude-skill-locale.md +316 -0
  58. package/dist/orchestrator/templates/ai-instructions/claude-skill-selector-fix.md +1 -0
  59. package/dist/orchestrator/templates/ai-instructions/claude-skill-selector-keys.md +38 -0
  60. package/dist/orchestrator/templates/ai-instructions/claude-skill-tc-generation.md +2 -0
  61. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-add-screen.md +50 -13
  62. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-dashboard.md +4 -1
  63. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-delivery.md +20 -9
  64. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-locale.md +70 -0
  65. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-review.md +23 -8
  66. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-run-test.md +44 -6
  67. package/dist/orchestrator/templates/ai-instructions/copilot-config.md +6 -1
  68. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-locale.md +291 -0
  69. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-selector-fix.md +1 -0
  70. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-selector-keys.md +38 -0
  71. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-tc-generation.md +2 -0
  72. package/dist/orchestrator/templates/playwright.config.ts +25 -8
  73. package/dist/orchestrator/templates/specs-base.ts +9 -0
  74. package/dist/orchestrator/templates/specs-locale-fixture.ts +105 -0
  75. package/package.json +1 -1
  76. package/src/cli/commands/delivery.ts +256 -65
  77. package/src/cli/index.ts +1 -1
  78. package/src/dashboard/snapshot-builder.ts +207 -32
  79. package/src/dashboard/templates/index.html +84 -84
  80. package/src/dashboard/types.ts +40 -3
  81. package/src/exporters/csv-exporter.ts +36 -7
  82. package/src/exporters/json-exporter.ts +22 -2
  83. package/src/exporters/playwright-report-parser.ts +20 -0
  84. package/src/exporters/selector-key-resolver.ts +190 -0
  85. package/src/exporters/test-data-resolver.ts +65 -7
  86. package/src/exporters/types.ts +1 -0
  87. package/src/exporters/xlsx-exporter.ts +61 -7
  88. package/src/generators/test-generator/code-generator.ts +14 -0
  89. package/src/generators/test-generator/utils/selector-resolver.ts +19 -2
  90. package/src/orchestrator/ai-rules-updater.ts +4 -0
  91. package/src/orchestrator/project-initializer.ts +1 -2
  92. package/src/orchestrator/templates/ai-instructions/claude-cmd-add-screen.md +48 -14
  93. package/src/orchestrator/templates/ai-instructions/claude-cmd-dashboard.md +4 -1
  94. package/src/orchestrator/templates/ai-instructions/claude-cmd-delivery.md +22 -11
  95. package/src/orchestrator/templates/ai-instructions/claude-cmd-locale.md +71 -0
  96. package/src/orchestrator/templates/ai-instructions/claude-cmd-review.md +23 -8
  97. package/src/orchestrator/templates/ai-instructions/claude-cmd-run-test.md +45 -6
  98. package/src/orchestrator/templates/ai-instructions/claude-config.md +6 -1
  99. package/src/orchestrator/templates/ai-instructions/claude-skill-locale.md +316 -0
  100. package/src/orchestrator/templates/ai-instructions/claude-skill-selector-fix.md +1 -0
  101. package/src/orchestrator/templates/ai-instructions/claude-skill-selector-keys.md +38 -0
  102. package/src/orchestrator/templates/ai-instructions/claude-skill-tc-generation.md +2 -0
  103. package/src/orchestrator/templates/ai-instructions/copilot-cmd-add-screen.md +50 -13
  104. package/src/orchestrator/templates/ai-instructions/copilot-cmd-dashboard.md +4 -1
  105. package/src/orchestrator/templates/ai-instructions/copilot-cmd-delivery.md +20 -9
  106. package/src/orchestrator/templates/ai-instructions/copilot-cmd-locale.md +70 -0
  107. package/src/orchestrator/templates/ai-instructions/copilot-cmd-review.md +23 -8
  108. package/src/orchestrator/templates/ai-instructions/copilot-cmd-run-test.md +44 -6
  109. package/src/orchestrator/templates/ai-instructions/copilot-config.md +6 -1
  110. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-locale.md +291 -0
  111. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-selector-fix.md +1 -0
  112. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-selector-keys.md +38 -0
  113. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-tc-generation.md +2 -0
  114. package/src/orchestrator/templates/playwright.config.ts +25 -8
  115. package/src/orchestrator/templates/specs-base.ts +9 -0
  116. package/src/orchestrator/templates/specs-locale-fixture.ts +105 -0
  117. package/dist/orchestrator/templates/playwright.config.d.ts +0 -10
  118. package/dist/orchestrator/templates/playwright.config.d.ts.map +0 -1
  119. package/dist/orchestrator/templates/playwright.config.js +0 -104
  120. package/dist/orchestrator/templates/playwright.config.js.map +0 -1
  121. package/dist/orchestrator/templates/specs-base.d.ts +0 -14
  122. package/dist/orchestrator/templates/specs-base.d.ts.map +0 -1
  123. package/dist/orchestrator/templates/specs-base.js +0 -77
  124. package/dist/orchestrator/templates/specs-base.js.map +0 -1
  125. package/dist/orchestrator/templates/specs-test-data.d.ts +0 -16
  126. package/dist/orchestrator/templates/specs-test-data.d.ts.map +0 -1
  127. package/dist/orchestrator/templates/specs-test-data.js +0 -151
  128. package/dist/orchestrator/templates/specs-test-data.js.map +0 -1
@@ -115,6 +115,44 @@ gửi lời cảm ơn--3:
115
115
  name: 'Gửi lời cảm ơn'
116
116
  ```
117
117
 
118
+ ## i18n: Template Variables in Selectors
119
+
120
+ For multilingual sites without `data-testid`, use `{{variable}}` in `name` or `value` fields to reference locale-dependent text from `test-data.yaml`.
121
+
122
+ ```yaml
123
+ # selectors — one file for all locales
124
+ submit:
125
+ type: role
126
+ value: button
127
+ name: "{{lbl_submit}}"
128
+
129
+ search:
130
+ type: placeholder
131
+ value: "{{lbl_search}}"
132
+
133
+ logo:
134
+ type: testid
135
+ value: app-logo # testid is locale-independent — no variable needed
136
+ ```
137
+
138
+ ```yaml
139
+ # test-data/login.yaml (base — English)
140
+ lbl_submit: "Sign in"
141
+ lbl_search: "Search..."
142
+
143
+ # test-data/login.vi.yaml (Vietnamese)
144
+ lbl_submit: "Đăng nhập"
145
+ lbl_search: "Tìm kiếm..."
146
+ ```
147
+
148
+ Run: `SUNGEN_ENV=vi npx playwright test`
149
+
150
+ **Rules:**
151
+ 1. Prefix i18n keys with `lbl_`, `msg_`, `txt_` to separate from test data
152
+ 2. Prefer `data-testid` — only use `{{variable}}` when no stable selector exists
153
+ 3. Feature file stays identical across locales
154
+ 4. Requires runtime data mode (default, not `--inline-data`)
155
+
118
156
  ## Lookup Priority
119
157
 
120
158
  Resolver searches in this order:
@@ -352,6 +352,8 @@ Feature: <Screen> Screen
352
352
 
353
353
  **Environment-specific data**: create `<screen>.<env>.yaml` alongside the base file with only the keys that change. Users run `SUNGEN_ENV=staging npx playwright test` to merge overrides.
354
354
 
355
+ **i18n / multilingual**: use the same `SUNGEN_ENV` overlay for locale variants — e.g., `login.vi.yaml`, `login.staging-ja.yaml`. Include `lbl_*` / `msg_*` keys for selector `{{variable}}` references (see `sungen-selector-keys` § i18n). One feature file + one selector file works across all locales.
356
+
355
357
  ## Flow Test Generation
356
358
 
357
359
  When generating tests for a **flow** (`qa/flows/<name>/`), adapt the strategy:
@@ -1,41 +1,59 @@
1
1
  ---
2
2
  name: sungen-add-screen
3
- description: 'Add a new Sungen screen — scaffolds directories, helps fill spec.md, and can auto-capture a live-page screenshot via Playwright MCP'
4
- argument-hint: '[screen-name] [url-path] [--figma <url>]'
3
+ description: 'Add a new Sungen screen or a sub-feature to an existing one — scaffolds directories, helps fill spec.md, and can auto-capture a live-page screenshot via Playwright MCP'
4
+ argument-hint: '[screen-name] [url-path] [--feature <name>] [--figma <url>]'
5
5
  agent: 'agent'
6
6
  tools: [vscode, execute, read, agent, edit, search, web, browser, todo, 'playwright/*']
7
7
  ---
8
8
 
9
9
  **Input**: Screen name and URL path (e.g., `/sungen-add-screen login /login`).
10
10
  Optionally include a Figma URL: `/sungen-add-screen login /login --figma https://www.figma.com/design/...`.
11
+ To add a sub-feature file to an existing screen: `/sungen-add-screen awards --feature modal`.
11
12
 
12
- You are adding a new Sungen screen for test generation.
13
+ You are adding a new Sungen screen for test generation, or extending an existing screen with an additional `.feature` file (sub-feature).
13
14
 
14
15
  ## Parameters
15
16
 
16
17
  - **screen** — ${input:screen:screen name (e.g., login, dashboard)}
17
- - **path** — ${input:path:URL path (e.g., /login, /dashboard)} — optional when --figma is provided
18
- - **--figma \<url\>**Figma share URL (optional)
19
- - **--refresh**bypass Figma cache and re-fetch (optional, use with --figma)
20
- - **--scale \<n\>** PNG export scale factor, default 2 (optional)
21
- - **--hi-res** — export at 4× scale, shorthand for --scale 4 (optional)
18
+ - **path** — ${input:path:URL path (e.g., /login, /dashboard)} — optional when --figma is provided or when adding a sub-feature
19
+ - **`--feature <name>`**sub-feature name to add to an existing screen (e.g., `modal`, `filter`, `create-flow`). Creates `<screen>-<feature>.feature` + matching `selectors/<screen>-<feature>.yaml` + `test-data/<screen>-<feature>.yaml` without touching the screen's other files. Use this when one screen has multiple `.feature` files.
20
+ - **`--figma <url>`** — Figma share URL (optional)
21
+ - **`--refresh`**bypass Figma cache and re-fetch (optional, use with --figma)
22
+ - **`--scale <n>`** PNG export scale factor, default 2 (optional)
23
+ - **`--hi-res`** — export at 4× scale, shorthand for --scale 4 (optional)
24
+
25
+ **Mode detection** — before invoking the CLI, check whether `qa/screens/<screen>/` already exists:
26
+ - Screen does NOT exist → fresh screen creation (need `--path` unless `--figma` provided)
27
+ - Screen exists AND `--feature <name>` provided → sub-feature mode (skip spec.md, only generate the 3 new files)
28
+ - Screen exists AND no `--feature` → ask the user whether they meant to add a sub-feature (offer `--feature <suggested-name>`) or refresh visuals only (with `--figma`)
22
29
 
23
30
  ## Steps
24
31
 
25
- ### 1. Scaffold the screen
32
+ ### 1. Scaffold the screen (or sub-feature)
26
33
 
27
- **Standard path (no --figma):**
34
+ **Standard path (no --figma, no --feature):**
28
35
 
29
36
  Run with #tool:terminal:
30
37
  ```bash
31
38
  sungen add --screen ${input:screen} --path ${input:path}
32
39
  ```
33
40
 
41
+ **Sub-feature mode (`--feature <name>` provided):**
42
+
43
+ Run with #tool:terminal:
44
+ ```bash
45
+ sungen add --screen ${input:screen} --feature <name> [--path ${input:path}]
46
+ # Generates qa/screens/${input:screen}/{features,selectors,test-data}/${input:screen}-<name>.{feature,yaml,yaml}
47
+ # Existing screen files (spec.md, awards.feature, …) are untouched.
48
+ # --path is optional — defaults to /${input:screen} when omitted.
49
+ ```
50
+
34
51
  **Figma branch (when --figma \<url\> is provided):**
35
52
 
36
53
  Run with #tool:terminal:
37
54
  ```bash
38
- sungen add --screen ${input:screen} --figma <figma-url> [--path ${input:path}] [--refresh] [--scale <n>]
55
+ sungen add --screen ${input:screen} --figma <figma-url> [--path ${input:path}] [--feature <name>] [--refresh] [--scale <n>]
56
+ # --feature can be combined with --figma when the new sub-feature has its own Figma frame.
39
57
  ```
40
58
 
41
59
  This CLI command automatically:
@@ -82,13 +100,32 @@ Each capture skill writes outputs into `qa/screens/${input:screen}/requirements/
82
100
 
83
101
  ### 3. Fill spec.md
84
102
 
85
- Ask: *"Fill `spec.md` now? (You can reference the captured visuals)"* offer **1) Yes, fill now (Recommended)** / **2) Skip, fill later**.
103
+ **Skip this step when `--feature` was used** — the screen's existing `spec.md` is reused for all sub-features; only suggest the user append a new section for the sub-feature if useful (e.g. `## Modal Confirm Withdrawal`).
104
+
105
+ For fresh screen creation, ask: *"Fill `spec.md` now? (You can reference the captured visuals)"* — offer **1) Yes, fill now (Recommended)** / **2) Skip, fill later**.
86
106
 
87
107
  If yes → open `qa/screens/${input:screen}/requirements/spec.md` and help the user fill sections, fields, validation rules, business rules, and states. Reference the captured visuals from Step 2 to suggest field names, form elements, and UI states. Especially prompt for the optional **Figma URL** and **Live URL** fields in Overview — those unlock auto-capture without re-asking next run.
88
108
 
89
109
  ### 4. Next steps
90
110
 
91
- Tell the user what was created and offer next steps:
111
+ Tell the user what was created. When `--feature` was used, list the 3 new files explicitly (`features/${input:screen}-<name>.feature`, `selectors/${input:screen}-<name>.yaml`, `test-data/${input:screen}-<name>.yaml`) and remind that `/sungen-create-test` currently operates at the screen level — it will see both the parent feature and the new sub-feature and ask which one to update.
112
+
113
+ Then offer next steps:
92
114
 
93
115
  - **`/sungen-create-test ${input:screen}`** — Create test cases from requirements/designs (Recommended)
94
116
  - **Done for now** — I'll come back later
117
+
118
+ ## CLI Reference
119
+
120
+ ```
121
+ sungen add --screen <name>
122
+ [-p, --path <path>] URL route (e.g., /awards). Required for capture; defaults to /<screen> when omitted.
123
+ [-f, --feature <name>] Add a sub-feature .feature file to an existing screen.
124
+ Output filename = <screen>-<feature>.{feature,yaml,yaml}.
125
+ [-c, --capture] Auto-capture a live screenshot to requirements/ui/ (needs --path).
126
+ [-d, --description <text>] Screen description (used in spec.md stub).
127
+ [--figma <url>] Figma share URL — generates spec_figma.md + ui/*.png.
128
+ [--refresh] Bypass Figma cache (use with --figma).
129
+ [--scale <n>] PNG export scale (default 2).
130
+ [--hi-res] Shorthand for --scale 4.
131
+ ```
@@ -19,8 +19,11 @@ Parse **screens** from `$ARGUMENTS`:
19
19
 
20
20
  ### 1. Invoke the CLI
21
21
 
22
+ Prefer the local `./bin/sungen.js` when it exists (sungen monorepo dev). Fall back to `npx sungen` for downstream projects.
23
+
22
24
  ```bash
23
- npx sungen dashboard <screens>
25
+ # Local-first dispatcher — works in both monorepo and consumer projects:
26
+ [ -x ./bin/sungen.js ] && ./bin/sungen.js dashboard <screens> || npx sungen dashboard <screens>
24
27
  ```
25
28
 
26
29
  - No args → all screens + flows.
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: sungen-delivery
3
3
  description: 'Export Gherkin scenarios + Playwright results to CSV test case file for QA delivery.'
4
- argument-hint: "[name...] (omit for all screens and flows)"
4
+ argument-hint: "[name...] [--env <locale>] (omit names for all targets; --env for locale-specific export)"
5
5
  tools: [read, execute, edit, vscode/askQuestions]
6
6
  ---
7
7
 
@@ -11,9 +11,11 @@ You are a **QA Test Delivery Engineer**. Your job is to invoke the deterministic
11
11
 
12
12
  ## Parameters
13
13
 
14
- Parse **names** from `$ARGUMENTS`:
15
- - If empty → CLI will process **all** screens in `qa/screens/` and flows in `qa/flows/`
16
- - If provided pass them through to the CLI (auto-detects screen vs flow per name)
14
+ Parse from `$ARGUMENTS`:
15
+ - **names** zero or more screen/flow names. Empty → CLI processes all targets in `qa/screens/` + `qa/flows/`.
16
+ - **`--env <locale>`** optional. Sets `SUNGEN_ENV=<locale>` for the run so the CLI merges `<name>.<locale>.yaml` over the base test-data and writes `<name>-testcases.<locale>.csv` / `.xlsx`. Accept `--locale <locale>` as an alias.
17
+
18
+ If `--env` is passed but no value follows, ask the user which locale to use.
17
19
 
18
20
  ## Steps
19
21
 
@@ -22,18 +24,22 @@ Parse **names** from `$ARGUMENTS`:
22
24
  Run via Bash (single command, no extra parsing):
23
25
 
24
26
  ```bash
25
- npx sungen delivery <names>
27
+ # No env — local-first dispatcher:
28
+ [ -x ./bin/sungen.js ] && ./bin/sungen.js delivery <names> || npx sungen delivery <names>
29
+
30
+ # Locale-specific:
31
+ [ -x ./bin/sungen.js ] && SUNGEN_ENV=<locale> ./bin/sungen.js delivery <names> || SUNGEN_ENV=<locale> npx sungen delivery <names>
26
32
  ```
27
33
 
28
- - If no args → just run `npx sungen delivery` (exports all screens + flows)
29
- - If args → pass them as positional arguments (auto-detects screen vs flow)
34
+ - If no name args → omit `<names>` (CLI processes all targets).
35
+ - If `--env <locale>` was provided prepend `SUNGEN_ENV=<locale>` to the command. Do NOT pass `--env` to the CLI itself it's not a CLI flag, only a slash-command convenience.
30
36
 
31
37
  The CLI handles:
32
38
  - Scope detection (all screens + flows vs specific names)
33
39
  - Auto-detect: `qa/flows/<name>/` → flow, `qa/screens/<name>/` → screen
34
40
  - Pre-flight source checks with colorful output
35
- - Parsing `.feature`, `.spec.ts`, `test-data.yaml`, `test-results/results.json`
36
- - Generating CSV at `qa/deliverables/<name>-testcases.csv`
41
+ - Parsing `.feature`, `.spec.ts`, `test-data.yaml` (+ `<name>.<env>.yaml` overlay when `SUNGEN_ENV` is set), and per-target `<name>-test-result[.<env>].json`
42
+ - Generating CSV/XLSX at `qa/deliverables/<name>-testcases[.<env>].csv` / `.xlsx`
37
43
  - Printing summary table
38
44
 
39
45
  ### 2. Handle pre-flight failures (if CLI exits non-zero)
@@ -69,4 +75,9 @@ Forward the CLI's summary table to the user verbatim. Then use `AskUserQuestion`
69
75
  sungen delivery [names...]
70
76
  [--skip-preflight] Skip pre-flight checks (not recommended)
71
77
  [--continue-on-missing] Skip targets with blocking misses
78
+
79
+ # Locale-aware export (env var, not a CLI flag):
80
+ SUNGEN_ENV=<locale> sungen delivery [names...]
81
+ → reads <name>.<locale>.yaml overlay, picks <name>-test-result.<locale>.json,
82
+ writes <name>-testcases.<locale>.csv / .xlsx
72
83
  ```
@@ -0,0 +1,70 @@
1
+ ---
2
+ name: sungen-locale
3
+ description: 'Bootstrap i18n for a screen/flow — audit selectors, detect locale switch mechanism via Playwright, generate test-data overlay so `sungen:run-test --env <locale>` works.'
4
+ argument-hint: "<name> <locale> [--base-locale <code>] [--offline]"
5
+ tools: [read, execute, edit, vscode/askQuestions, playwright/*]
6
+ ---
7
+
8
+ ## Role
9
+
10
+ You are a **Senior QA Localization Engineer**. Use the `sungen-locale` skill — it contains the full phased strategy. Your job in this command is parameter parsing, context detection, and final hand-off.
11
+
12
+ ## Parameters
13
+
14
+ Parse from `$ARGUMENTS`:
15
+ - **name** — screen or flow name (e.g. `home`, `awards`). If missing, ask the user.
16
+ - **locale** — target locale code (e.g. `en`, `ja`, `en-US`, `staging-ja`). If missing, ask. This becomes the suffix in `test-data/<feature>.<locale>.yaml` and `SUNGEN_ENV=<locale>` at run time.
17
+ - **`--base-locale <code>`** — optional. Locale of the existing `test-data/<feature>.yaml`. Default `vi`. Reporting only — files are never renamed.
18
+ - **`--offline`** — force OFFLINE mode (skip Playwright capture). Useful when you know the live page can't be reached.
19
+
20
+ Reject if name == locale.
21
+
22
+ ## Auto-detect context
23
+
24
+ Same as `/sungen:run-test`:
25
+ - `qa/flows/<name>/` exists → flow mode (base path: `qa/flows/<name>/`)
26
+ - Else `qa/screens/<name>/` exists → screen mode (base path: `qa/screens/<name>/`)
27
+ - Neither → tell user and stop
28
+
29
+ ## Steps
30
+
31
+ The `sungen-locale` skill defines 7 phases. Execute them in order:
32
+
33
+ 1. **Phase 1 — Selector audit** (always, no MCP)
34
+ 2. **Phase 2 — Capture base locale** (Live mode only)
35
+ 3. **Phase 3 — Switch locale + detect mechanism** (Live mode only)
36
+ 4. **Phase 4 — Diff base ↔ target** (Live mode only)
37
+ 5. **Phase 5 — Confirm proposal** (always)
38
+ 6. **Phase 6 — Apply files** (always, after confirmation)
39
+ 7. **Phase 7 — Hand off** (always)
40
+
41
+ **Mode selection** happens at the start of Phase 2:
42
+
43
+ - If `--offline` flag → OFFLINE mode (skip Phases 2-4).
44
+ - Else try `browser_navigate(baseURL)` — succeeds + page renders content → LIVE mode.
45
+ - If navigate fails / page redirects to login / shows blocker → fall back to OFFLINE mode automatically. Announce the fallback clearly.
46
+
47
+ ## Enumerate features
48
+
49
+ Multi-feature screens (e.g. `home` has `home.feature` + `home-modal.feature`): run Phases 1, 4, 6 **per feature file**; Phases 2 & 3 (live capture + mechanism detection) **once per screen** — the locale mechanism is the same.
50
+
51
+ ```bash
52
+ ls qa/screens/<name>/features/*.feature
53
+ # or
54
+ ls qa/flows/<name>/features/*.feature
55
+ ```
56
+
57
+ ## After Phase 7
58
+
59
+ Offer the user:
60
+
61
+ - **`/sungen:run-test <name> --env <locale>`** — Run tests against the new locale (Recommended)
62
+ - **`/sungen:locale <name> <other-locale>`** — Bootstrap another locale
63
+ - **Open the overlay file** for review/edit
64
+ - **Done**
65
+
66
+ ## Notes
67
+
68
+ - Do NOT run tests yourself. `/sungen:run-test` is the executor; this command only PREPS files.
69
+ - Do NOT modify `.feature` files. Localization lives in `selectors/*.yaml` + `test-data/*.yaml` only.
70
+ - Auth blocked? Use `--offline`.
@@ -20,13 +20,28 @@ You are a **Senior QA Reviewer**. You evaluate Gherkin test cases using the `sun
20
20
 
21
21
  ## Steps
22
22
 
23
- 1. Read `<base>/<name>/features/<name>.feature` and `<base>/<name>/test-data/<name>.yaml`. If missing → `/sungen-create-test` first.
24
- 2. Follow the `sungen-tc-review` skillscore 3 dimensions: Syntax (30pts), Coverage (40pts), Viewpoint (30pts). **For flows**, also apply the "Flow Review Additions" section. Use `sungen-viewpoint` for pattern checklists.
25
- 3. **Unverified Selectors check** — if `<base>/<name>/selectors/<name>.yaml` exists, count lines matching `@needs-live-verify`. Include in the review report as a non-scoring metric. Does NOT affect the 60% threshold.
26
- 4. Output review report per `sungen-tc-review` format. **>= 60%**: PASS. **< 60%**: FAIL with recommendations.
27
- 5. If FAIL and user confirms update test cases following `sungen-gherkin-syntax` and `sungen-tc-generation` skills, then re-review.
28
- 6. After PASS (or user decides to proceed), offer next steps:
29
-
30
- - **`/sungen-run-test ${input:name}`** — Generate selectors, compile, and run tests (Recommended)
23
+ 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.
24
+ 2. **Review every feature file**for each `<basename>.feature` discovered in step 1:
25
+ - Read `<basename>.feature` and the matching `test-data/<basename>.yaml`.
26
+ - Apply the `sungen-tc-review` skill — score 3 dimensions: Syntax (30pts), Coverage (40pts), Viewpoint (30pts). **For flows**, also apply the "Flow Review Additions" section. Use `sungen-viewpoint` for pattern checklists.
27
+ - 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 60% threshold.
28
+ 3. **Aggregated output** present scores in a per-feature table, then a screen-level rollup:
29
+
30
+ ```
31
+ Feature Syntax Coverage Viewpoint Total Verdict
32
+ ──────────────────────────────────────────────────────────────────
33
+ home.feature 28/30 36/40 27/30 91% PASS
34
+ home-modal.feature 26/30 24/40 22/30 72% PASS
35
+ ──────────────────────────────────────────────────────────────────
36
+ Screen rollup (mean) 27/30 30/40 24.5/30 81.5% PASS
37
+ ```
38
+
39
+ - **>= 60% per file**: PASS that file.
40
+ - **< 60% per file**: FAIL that file with recommendations.
41
+ - Show the full per-file report (recommendations, top issues) **only for files that fail**, or when the user asks for the deep report.
42
+ 4. If any file is FAIL and user confirms → update that file's test cases following `sungen-gherkin-syntax` and `sungen-tc-generation` skills, then re-review **only the failing files** (skip already-passing ones to save time).
43
+ 5. After all files PASS (or user decides to proceed), offer next steps:
44
+
45
+ - **`/sungen-run-test ${input:name}`** — Generate selectors, compile, and run tests for **every feature** in this screen (Recommended)
31
46
  - **`/sungen-create-test ${input:name}`** — Add more test cases before running
32
47
  - **Done for now** — I'll come back later
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: sungen-run-test
3
3
  description: 'Generate selectors + auth state via Playwright MCP, compile, and run Playwright tests — auto-fixes selectors on failure'
4
- argument-hint: '[name]'
4
+ argument-hint: "[name] [--env <locale>]"
5
5
  tools: [read, execute, edit, vscode/askQuestions, playwright/*]
6
6
  ---
7
7
 
@@ -11,7 +11,24 @@ You are a **Senior Developer**. Use `sungen-selector-fix`, `sungen-selector-keys
11
11
 
12
12
  ## Parameters
13
13
 
14
- Parse **name** from `$ARGUMENTS`. If missing, ask the user.
14
+ Parse from `$ARGUMENTS`:
15
+ - **name** — screen or flow name. If missing, ask the user.
16
+ - **`--env <locale>`** — optional. Sets `SUNGEN_ENV=<locale>` for the test run so the runtime test-data resolver merges `<name>.<locale>.yaml` over the base, and `playwright.config.ts` writes results to `<name>-test-result.<locale>.json`. Accept `--locale <locale>` as an alias.
17
+
18
+ If `--env` is passed but no value follows, ask the user which locale to use.
19
+
20
+ **`--env <locale>` pre-flight**: when `--env` is passed AND the matching overlay file doesn't exist yet (`test-data/<feature>.<locale>.yaml` missing), tests will silently fall back to base locale — the run will execute but won't actually exercise the locale. Before Phase 0.5, check:
21
+
22
+ ```bash
23
+ ls qa/<screens|flows>/<name>/test-data/*.<locale>.yaml 2>/dev/null | wc -l
24
+ ```
25
+
26
+ Count 0 → offer the user:
27
+ - **Run `/sungen-locale <name> <locale>` first** (Recommended) — bootstrap the overlay
28
+ - **Continue anyway** — tests will likely fail on a real locale page
29
+ - **Cancel**
30
+
31
+ Skip when `--env` matches the base locale.
15
32
 
16
33
  **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>/`).
17
34
 
@@ -52,7 +69,11 @@ Parse **name** from `$ARGUMENTS`. If missing, ask the user.
52
69
  name: "Submit"
53
70
  ```
54
71
  3. **Phase 0.5 — Auth Persistence**: if the feature has `@auth:<role>` tags and `specs/.auth/<role>.json` is missing/expired, run Phase 0.5 from `sungen-selector-fix` — user logs in manually in MCP browser → `browser_storage_state` → `specs/.auth/<role>.json`. Offer `sungen makeauth <role>` as CLI fallback only if `browser_storage_state` isn't available in this MCP version.
55
- 4. Compile: **Screen**: `sungen generate --screen <name>`. **Flow**: `sungen generate --flow <name>`. Default: runtime data loading from YAML. Use `--inline-data` only if user requests compile-time hardcoded values.
72
+ 4. Compile via local-first dispatcher so the sungen monorepo's unpublished selector-resolver features (i18n `{{var}}` interpolation, namespaced selector lookup) are picked up:
73
+ - **Screen**: `[ -x ./bin/sungen.js ] && ./bin/sungen.js generate --screen <name> || npx sungen generate --screen <name>`
74
+ - **Flow**: `[ -x ./bin/sungen.js ] && ./bin/sungen.js generate --flow <name> || npx sungen generate --flow <name>`
75
+
76
+ Default: runtime data loading from YAML. Use `--inline-data` only if user requests compile-time hardcoded values.
56
77
 
57
78
  ## Run & Fix (phased — per `sungen-selector-fix` skill)
58
79
 
@@ -63,13 +84,30 @@ Parse **name** from `$ARGUMENTS`. If missing, ask the user.
63
84
 
64
85
  ## Playwright command guidelines
65
86
 
66
- **Per-screen/flow JSON results** — each run must write its JSON report to a dedicated path co-located with the `.spec.ts`, so `sungen delivery` can read the correct results:
87
+ **Multi-feature screens** — `sungen generate --screen <name>` produces one `<basename>.spec.ts` per `.feature` file (e.g. `home.spec.ts` + `home-modal.spec.ts`). You must **invoke playwright once per spec file** so each gets its own JSON result that `sungen delivery` can pick up. Do NOT run a single command with the directory as the test argument — that bundles everything into one results file that delivery can't disambiguate.
88
+
89
+ **Per-spec JSON results** — each invocation writes its JSON report to a path matching the spec basename. When `--env <locale>` was parsed from `$ARGUMENTS`, prepend `SUNGEN_ENV=<locale>` — `playwright.config.ts` auto-inserts `.<locale>` before `.json` in the output path:
67
90
 
68
91
  ```bash
69
- # ✅ Screen
92
+ # ✅ Screen with 1 feature
70
93
  PLAYWRIGHT_JSON_OUTPUT_NAME=specs/generated/<name>/<name>-test-result.json \
71
94
  npx playwright test specs/generated/<name>/<name>.spec.ts
72
95
 
96
+ # ✅ Screen with multiple features — loop in shell:
97
+ for spec in specs/generated/<name>/*.spec.ts; do
98
+ base=$(basename "$spec" .spec.ts)
99
+ PLAYWRIGHT_JSON_OUTPUT_NAME="specs/generated/<name>/${base}-test-result.json" \
100
+ npx playwright test "$spec"
101
+ done
102
+
103
+ # ✅ Locale 'vi' — same loop, just prepend SUNGEN_ENV=vi
104
+ for spec in specs/generated/<name>/*.spec.ts; do
105
+ base=$(basename "$spec" .spec.ts)
106
+ SUNGEN_ENV=vi \
107
+ PLAYWRIGHT_JSON_OUTPUT_NAME="specs/generated/<name>/${base}-test-result.json" \
108
+ npx playwright test "$spec"
109
+ done
110
+
73
111
  # ✅ Flow
74
112
  PLAYWRIGHT_JSON_OUTPUT_NAME=specs/generated/flows/<name>/<name>-test-result.json \
75
113
  npx playwright test specs/generated/flows/<name>/<name>.spec.ts
@@ -88,7 +126,7 @@ npx playwright test specs/generated/<name>/<name>.spec.ts
88
126
 
89
127
  If you want to filter scenarios, use `-g "<pattern>"` instead of a reporter override.
90
128
 
91
- `sungen delivery` reads the per-screen file first, falls back to the global `test-results/results.json` if missing.
129
+ `sungen delivery` reads per-feature `<basename>-test-result[.env].json` files (one per feature in the screen) and writes one CSV/XLSX per feature (e.g. `home-testcases.csv` + `home-modal-testcases.csv`). When `--env <locale>` was used here, run delivery with the same locale (`/sungen-delivery <name> --env <locale>`) so it picks the matching `*-test-result.<locale>.json` files and produces `*-testcases.<locale>.csv` / `.xlsx`.
92
130
 
93
131
  ## Next steps
94
132
 
@@ -20,8 +20,9 @@ You generate 3 files for sungen — a Gherkin compiler that produces Playwright
20
20
  | `sungen-capture-local` | Load existing UI assets (screenshots, mockups, Figma exports) from `requirements/ui/` |
21
21
  | `sungen-capture-live` | Capture a live running page via Playwright MCP (snapshot + screenshot) |
22
22
  | `sungen-figma-source` | Figma URL → spec_figma.md + ui/*.png + provisional selectors |
23
+ | `sungen-locale` | Bootstrap i18n — audit selectors, detect locale switch mechanism, generate test-data overlay |
23
24
 
24
- ## Workflow (6 AI commands)
25
+ ## Workflow (7 AI commands)
25
26
 
26
27
  | Command | What it does |
27
28
  |---|---|
@@ -31,9 +32,11 @@ You generate 3 files for sungen — a Gherkin compiler that produces Playwright
31
32
  | `/sungen-review <name>` | Score syntax, coverage, viewpoint quality (auto-detects screen or flow) |
32
33
  | `/sungen-run-test <name>` | Generate `selectors.yaml`, compile, run, auto-fix (auto-detects screen or flow) |
33
34
  | `/sungen-delivery [name...]` | Export test cases → CSV for QA delivery (all screens if no arg) |
35
+ | `/sungen-locale <name> <locale>` | Bootstrap i18n for a screen — audit selectors, detect locale switch, generate overlay (run before `/sungen-run-test --env <locale>`) |
34
36
 
35
37
  **Screen path:** add-screen → create-test → review → run-test → delivery.
36
38
  **Flow path:** add-flow → create-test → review → run-test → delivery.
39
+ **i18n path:** (after run-test passes for base locale) → locale → run-test --env <locale> → delivery --env <locale>.
37
40
 
38
41
  `create-test`, `review`, and `run-test` auto-detect context: if `qa/flows/<name>/` exists → flow mode, else `qa/screens/<name>/` → screen mode.
39
42
 
@@ -82,6 +85,8 @@ qa/deliverables/<name>-testcases.xlsx # Styled workbook for client hand-off
82
85
 
83
86
  **Environment overrides**: `SUNGEN_ENV=staging npx playwright test` merges `<screen>.staging.yaml` on top of `<screen>.yaml`. Create `<screen>.<env>.yaml` for environment-specific values (different credentials, URLs, test users).
84
87
 
88
+ **i18n support**: for multilingual sites, use `{{variable}}` in selector `name`/`value` fields to reference locale-dependent text from test-data. Create locale overlay files (e.g., `<screen>.vi.yaml`, `<screen>.staging-ja.yaml`) and run with `SUNGEN_ENV=vi`. One feature file + one selector file works across all locales. See `sungen-selector-keys` skill for details.
89
+
85
90
  ## CLI Commands
86
91
 
87
92
  ```bash