@sun-asterisk/sungen 2.4.3 → 2.4.5

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 (24) hide show
  1. package/dist/cli/commands/add.d.ts.map +1 -1
  2. package/dist/cli/commands/add.js +8 -2
  3. package/dist/cli/commands/add.js.map +1 -1
  4. package/dist/cli/index.js +1 -1
  5. package/dist/orchestrator/screen-manager.d.ts +1 -0
  6. package/dist/orchestrator/screen-manager.d.ts.map +1 -1
  7. package/dist/orchestrator/screen-manager.js +2 -2
  8. package/dist/orchestrator/screen-manager.js.map +1 -1
  9. package/dist/orchestrator/templates/ai-instructions/claude-cmd-add-screen.md +19 -8
  10. package/dist/orchestrator/templates/ai-instructions/claude-cmd-run-test.md +11 -10
  11. package/dist/orchestrator/templates/ai-instructions/claude-skill-selector-fix.md +87 -4
  12. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-add-screen.md +19 -8
  13. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-run-test.md +10 -9
  14. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-selector-fix.md +87 -4
  15. package/package.json +1 -1
  16. package/src/cli/commands/add.ts +9 -2
  17. package/src/cli/index.ts +1 -1
  18. package/src/orchestrator/screen-manager.ts +3 -2
  19. package/src/orchestrator/templates/ai-instructions/claude-cmd-add-screen.md +19 -8
  20. package/src/orchestrator/templates/ai-instructions/claude-cmd-run-test.md +11 -10
  21. package/src/orchestrator/templates/ai-instructions/claude-skill-selector-fix.md +87 -4
  22. package/src/orchestrator/templates/ai-instructions/copilot-cmd-add-screen.md +19 -8
  23. package/src/orchestrator/templates/ai-instructions/copilot-cmd-run-test.md +10 -9
  24. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-selector-fix.md +87 -4
@@ -1 +1 @@
1
- {"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/add.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAwBzD"}
1
+ {"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/add.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA+BzD"}
@@ -4,18 +4,24 @@ exports.registerAddCommand = registerAddCommand;
4
4
  function registerAddCommand(program) {
5
5
  program
6
6
  .command('add')
7
- .description('Add screen or feature definition with scaffolded files. Auto-captures screenshots when --path is provided.')
7
+ .description('Add screen or feature definition with scaffolded files. Use --capture to auto-capture a live-page screenshot.')
8
8
  .requiredOption('--screen <name>', 'Screen name')
9
- .option('-p, --path <path>', 'Screen route path (e.g. /awards). Also triggers auto-screenshot capture.')
9
+ .option('-p, --path <path>', 'Screen route path (e.g. /awards)')
10
+ .option('-c, --capture', 'Auto-capture a live-page screenshot to requirements/ui/ (requires --path)')
10
11
  .option('-f, --feature <name>', 'Add additional feature file to existing screen')
11
12
  .option('-d, --description <text>', 'Screen description')
12
13
  .action(async (options) => {
13
14
  try {
15
+ if (options.capture && !options.path) {
16
+ console.error('Error: --capture requires --path to be set');
17
+ process.exit(1);
18
+ }
14
19
  const { ScreenManager } = require('../../orchestrator/screen-manager');
15
20
  const manager = new ScreenManager();
16
21
  await manager.addScreen({
17
22
  name: options.screen,
18
23
  path: options.path,
24
+ capture: options.capture,
19
25
  feature: options.feature,
20
26
  description: options.description,
21
27
  });
@@ -1 +1 @@
1
- {"version":3,"file":"add.js","sourceRoot":"","sources":["../../../src/cli/commands/add.ts"],"names":[],"mappings":";;AAEA,gDAwBC;AAxBD,SAAgB,kBAAkB,CAAC,OAAgB;IACjD,OAAO;SACJ,OAAO,CAAC,KAAK,CAAC;SACd,WAAW,CAAC,4GAA4G,CAAC;SACzH,cAAc,CAAC,iBAAiB,EAAE,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AAC;SACxD,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QACxB,IAAI,CAAC;YACH,IAAI,OAAO,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;gBACrC,OAAO,CAAC,KAAK,CAAC,4CAA4C,CAAC,CAAC;gBAC5D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC;YAED,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;YACvE,MAAM,OAAO,GAAG,IAAI,aAAa,EAAE,CAAC;YAEpC,MAAM,OAAO,CAAC,SAAS,CAAC;gBACtB,IAAI,EAAE,OAAO,CAAC,MAAM;gBACpB,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,WAAW,EAAE,OAAO,CAAC,WAAW;aACjC,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;YACxE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
package/dist/cli/index.js CHANGED
@@ -16,7 +16,7 @@ async function main() {
16
16
  program
17
17
  .name('sungen')
18
18
  .description('Deterministic E2E Test Compiler — Gherkin + Selectors → Playwright')
19
- .version('2.4.3');
19
+ .version('2.4.5');
20
20
  // Global options
21
21
  program
22
22
  .option('-v, --verbose', 'Enable verbose logging');
@@ -5,6 +5,7 @@
5
5
  export interface ScreenOptions {
6
6
  name: string;
7
7
  path?: string;
8
+ capture?: boolean;
8
9
  feature?: string;
9
10
  description?: string;
10
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"screen-manager.d.ts","sourceRoot":"","sources":["../../src/orchestrator/screen-manager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,UAAU,CAAS;;IAO3B;;OAEG;IACG,SAAS,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAyLtD;;OAEG;YACW,iBAAiB;IAqC/B;;OAEG;IACH,OAAO,CAAC,UAAU;IASlB,OAAO,CAAC,kBAAkB;IAW1B,OAAO,CAAC,mBAAmB;IAQ3B,OAAO,CAAC,uBAAuB;IAO/B,OAAO,CAAC,oBAAoB;IAsD5B,OAAO,CAAC,uBAAuB;CAmBhC"}
1
+ {"version":3,"file":"screen-manager.d.ts","sourceRoot":"","sources":["../../src/orchestrator/screen-manager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,UAAU,CAAS;;IAO3B;;OAEG;IACG,SAAS,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAyLtD;;OAEG;YACW,iBAAiB;IAqC/B;;OAEG;IACH,OAAO,CAAC,UAAU;IASlB,OAAO,CAAC,kBAAkB;IAW1B,OAAO,CAAC,mBAAmB;IAQ3B,OAAO,CAAC,uBAAuB;IAO/B,OAAO,CAAC,oBAAoB;IAsD5B,OAAO,CAAC,uBAAuB;CAmBhC"}
@@ -198,9 +198,9 @@ class ScreenManager {
198
198
  '',
199
199
  ].join('\n'), 'utf-8');
200
200
  }
201
- // Auto-screenshot: capture page if --path is provided
201
+ // Auto-screenshot: capture page only when --capture is set (requires --path)
202
202
  // Use filename (not screenName) so each feature gets its own screenshots
203
- if (options.path) {
203
+ if (options.capture && options.path) {
204
204
  await this.captureScreenshot(options.path, requirementsUiDir, filename);
205
205
  }
206
206
  // Display success
@@ -1 +1 @@
1
- {"version":3,"file":"screen-manager.js","sourceRoot":"","sources":["../../src/orchestrator/screen-manager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AACzB,2CAA6B;AAC7B,2CAA4C;AAS5C,MAAa,aAAa;IAIxB;QACE,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;QACzB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;IACzD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,SAAS,CAAC,OAAsB;QACpC,uBAAuB;QACvB,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAEtC,sCAAsC;QACtC,MAAM,UAAU,GAAG,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC1D,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QAEzD,oEAAoE;QACpE,IAAI,QAAgB,CAAC;QACrB,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACpB,QAAQ,GAAG,GAAG,UAAU,IAAI,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CA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;QACtE,MAAM,UAAU,GAAG,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC1D,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,IAAI,IAAI,UAAU,EAAE,CAAC;QACrD,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,qBAAqB,OAAO,CAAC,IAAI,SAAS,CAAC;QAEtF,OAAO,YAAY,OAAO,CAAC,IAAI;;;cAGrB,WAAW;;UAEf,WAAW;;;kCAGa,OAAO,CAAC,IAAI;wBACtB,UAAU;;;CAGjC,CAAC;IACA,CAAC;CACF;AA5VD,sCA4VC"}
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  name: add-screen
3
- description: 'Add a new Sungen screen — scaffolds directories and delegates to create-test for test case creation'
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
4
  argument-hint: [screen-name] [url-path]
5
- allowed-tools: Read, Grep, Bash, Glob, AskUserQuestion
5
+ allowed-tools: Read, Grep, Bash, Glob, Edit, Write, AskUserQuestion, mcp__playwright__browser_navigate, mcp__playwright__browser_take_screenshot, mcp__playwright__browser_snapshot
6
6
  ---
7
7
 
8
8
  You are adding a new Sungen screen for test generation.
@@ -25,20 +25,31 @@ Run:
25
25
  sungen add --screen <screen> --path <path>
26
26
  ```
27
27
 
28
- ### 2. Fill requirements (recommended)
28
+ ### 2. Prepare requirements
29
29
 
30
- Ask the user: "Would you like to fill in `requirements/spec.md` now? This helps generate higher quality test cases."
30
+ Use `AskUserQuestion` to let the user choose how to prepare requirements this is the foundation for high-quality test generation:
31
31
 
32
- - If yes → open `qa/screens/<screen>/requirements/spec.md` and help the user fill sections, fields, validation rules, business rules, and states.
33
- - If they have UI designs (screenshots, Figma exports, mockups) suggest copying them to `requirements/ui/`.
34
- - If no proceed to step 3.
32
+ - **Fill `spec.md` + capture live-page screenshot** (Recommended) best test quality
33
+ - **Fill `spec.md` only** app not live yet, or no need for visuals
34
+ - **Capture live-page screenshot only** spec will come later
35
+ - **Skip requirements prep** — proceed to `/sungen:create-test` immediately
36
+
37
+ **If "Fill `spec.md`" is chosen**: open `qa/screens/<screen>/requirements/spec.md` and help the user fill sections, fields, validation rules, business rules, and states.
38
+
39
+ **If "Capture live-page screenshot" is chosen**:
40
+ 1. Read `baseURL` from `playwright.config.ts` (fall back to `APP_BASE_URL` env, then ask the user).
41
+ 2. `browser_navigate` to `<baseURL><path>`.
42
+ 3. If redirected to login → ask the user to log in manually in the MCP browser, wait for confirmation, then re-navigate. (No auth persistence needed here — that's handled by Phase 0.5 in `sungen-selector-fix` when tests run.)
43
+ 4. `browser_take_screenshot` with `filename: "qa/screens/<screen>/requirements/ui/<screen>.png"`.
44
+ 5. If the screen has multiple important states (empty, loaded, error, modal open), offer additional captures named `<screen>-<state>.png`.
45
+
46
+ If the user has additional UI designs (Figma exports, mockups), suggest copying them to `requirements/ui/`.
35
47
 
36
48
  ### 3. Next steps
37
49
 
38
50
  Tell the user what was created, then use `AskUserQuestion` to offer next steps:
39
51
 
40
52
  - **`/sungen:create-test <screen>`** — Create test cases from requirements/designs (Recommended)
41
- - **Fill `requirements/spec.md`** — Write screen specs first for better test quality
42
53
  - **Done for now** — I'll come back later
43
54
 
44
55
  If user picks `/sungen:create-test`, **you MUST use the Skill tool** to invoke it. Do NOT generate test cases yourself — the skill auto-loads `sungen-gherkin-syntax` and `sungen-tc-generation`.
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  name: run-test
3
- description: 'Compile and run Playwright tests — auto-fixes selectors on failure'
3
+ description: 'Generate selectors + auth state via Playwright MCP, compile, and run Playwright tests — auto-fixes selectors on failure'
4
4
  argument-hint: [screen-name]
5
- allowed-tools: Read, Grep, Bash, Glob, Edit, AskUserQuestion
5
+ allowed-tools: Read, Grep, Bash, Glob, Edit, Write, AskUserQuestion, mcp__playwright__browser_navigate, mcp__playwright__browser_snapshot, mcp__playwright__browser_take_screenshot, mcp__playwright__browser_wait_for, mcp__playwright__browser_evaluate, mcp__playwright__browser_run_code, mcp__playwright__browser_storage_state, mcp__playwright__browser_set_storage_state
6
6
  ---
7
7
 
8
8
  ## Role
@@ -13,18 +13,19 @@ You are a **Senior Developer**. Use `sungen-selector-fix`, `sungen-selector-keys
13
13
 
14
14
  Parse **screen** from `$ARGUMENTS`. If missing, ask the user.
15
15
 
16
- ## Compile
16
+ ## Pre-run (phased — per `sungen-selector-fix` skill)
17
17
 
18
- 1. Verify `qa/screens/<screen>/` has `.feature` + `test-data.yaml`
19
- 2. Ensure `selectors.yaml` has page selector. If missing, ask user for URL path
20
- 3. `sungen generate --screen <screen>`
18
+ 1. Verify `qa/screens/<screen>/` has `.feature` + `test-data.yaml`.
19
+ 2. **Phase 0 — Selector Pre-gen**: if `selectors.yaml` is missing/empty or doesn't cover the feature file's `[Reference]`s, run Phase 0 from `sungen-selector-fix` — confirm with user, `browser_navigate` one `browser_snapshot` → merge YAML entries.
20
+ 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.
21
+ 4. Compile: `sungen generate --screen <screen>`.
21
22
 
22
23
  ## Run & Fix (phased — per `sungen-selector-fix` skill)
23
24
 
24
- 4. **Phase 1 — Smoke Check**: Run first 5 `@critical`/`@high` scenarios only. If failures → diagnose, fix fundamentals (page selector, auth, base @steps), re-run. Max 2 attempts. If still broken → ask user.
25
- 5. **Phase 2 — Priority Wave**: Run all `@critical` + `@high` scenarios. Fix only failures from this wave. Max 2 attempts. Shared selectors fixed here cascade to later phases.
26
- 6. **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.
27
- 7. **Phase 4 — Regression**: One final full run. Report results. No more fix loops.
25
+ 5. **Phase 1 — Smoke Check**: Run first 5 `@critical`/`@high` scenarios only. If failures → diagnose, fix fundamentals (page selector, auth, base @steps), re-run. Max 2 attempts. If still broken → ask user.
26
+ 6. **Phase 2 — Priority Wave**: Run all `@critical` + `@high` scenarios. Fix only failures from this wave. Max 2 attempts. Shared selectors fixed here cascade to later phases.
27
+ 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.
28
+ 8. **Phase 4 — Regression**: One final full run. Report results. No more fix loops.
28
29
 
29
30
  ## Next steps
30
31
 
@@ -8,7 +8,88 @@ user-invocable: false
8
8
 
9
9
  Run tests in priority waves — catch fundamental issues early, fix critical paths first, let shared fixes cascade to lower-priority tests.
10
10
 
11
- **Never run all tests blindly.** Always start with a smoke check.
11
+ **Never run all tests blindly.** Always start with selector pre-generation, then a smoke check.
12
+
13
+ ---
14
+
15
+ ## Phase 0: Pre-run Selector Generation (Playwright MCP)
16
+
17
+ **Before any `sungen generate` or test run**, populate `selectors.yaml` from the live page so tests don't fail on missing keys in Phase 1.
18
+
19
+ ### When to run Phase 0
20
+
21
+ - `selectors.yaml` missing, empty, or contains only the page selector
22
+ - The `.feature` file has `[Reference]` keys without corresponding YAML entries and the referenced element can't be auto-inferred (see `sungen-selector-keys` § Auto-Infer)
23
+ - User explicitly re-scans after UI changes
24
+
25
+ If existing selectors already cover the feature file, **skip Phase 0** and go straight to compile + Phase 1.
26
+
27
+ ### Steps
28
+
29
+ 1. **Confirm with the user** via `AskUserQuestion`: *"Generate selectors from the live page via Playwright MCP now?"* — offer **Yes, scan live page** / **Skip (use existing selectors.yaml)** / **Cancel**.
30
+ 2. **Collect references**: parse the `.feature` file for every `[Reference]` element + its type (e.g. `[Submit] button`, `[Email] field`). Deduplicate.
31
+ 3. **Ensure page selector**: if missing, ask user for URL path and write it first.
32
+ 4. **Navigate**:
33
+ - Read `baseURL` from `playwright.config.ts`.
34
+ - `browser_navigate` to the page URL.
35
+ - If redirected to login → run **Phase 0.5: Auth Persistence** first (see below), then re-navigate to the target page.
36
+ 5. **Snapshot**: take **ONE** `browser_snapshot`. All Phase 0 selectors come from this single snapshot.
37
+ 6. **Generate YAML entries**:
38
+ - Keys: follow `sungen-selector-keys` (lowercase, Unicode preserved, `--type` / `--N` suffixes).
39
+ - Selector priority: follow the table in **Diagnosis & Fix § Step 3** (`testid` > `role`+name > `placeholder` > `label` > `locator` > `text`).
40
+ - Copy names **character-for-character** from the snapshot. Never infer from the Gherkin label.
41
+ - If an element is auto-inferable per `sungen-selector-keys` § Auto-Infer, **omit it** from YAML — keep the file minimal.
42
+ 7. **Merge, don't overwrite**: preserve the page selector and any user-authored entries in `selectors.yaml`. Only add missing keys.
43
+ 8. **Show summary + confirm**: list the keys that will be added, ask the user to approve, then write the file.
44
+ 9. **Compile**: `sungen generate --screen <screen>` — then proceed to Phase 1.
45
+
46
+ ### Common Phase 0 pitfalls
47
+
48
+ - Writing keys inferred from the Gherkin label instead of the snapshot name → Phase 1 will fail with "no element found".
49
+ - Skipping Phase 0.5 when an auth redirect happened → snapshot captures the login page, all selectors wrong.
50
+ - Using `browser_evaluate` alone to scrape cookies → misses httpOnly session cookies. Always use `browser_storage_state` (or the `browser_run_code` fallback).
51
+ - Overwriting user-authored selectors → always merge.
52
+
53
+ ---
54
+
55
+ ## Phase 0.5: Auth Persistence (MCP alternative to `sungen makeauth`)
56
+
57
+ Capture an authenticated session from the MCP browser into `specs/.auth/<role>.json` — the same path `sungen makeauth` writes to, which compiled tests already reference via `test.use({ storageState })` based on `@auth:<role>` tags. No `playwright.config.ts` edits needed. Run once per auth lifetime, not on every selector fix.
58
+
59
+ ### When to run Phase 0.5
60
+
61
+ - Phase 0 navigation hit a login redirect and `specs/.auth/<role>.json` is missing or expired
62
+ - A scenario tagged `@auth:<role>` is about to run and its auth file is absent
63
+ - User asks to refresh auth
64
+
65
+ Skip if `specs/.auth/<role>.json` already exists and a probe navigation reaches an authenticated page without redirecting to login.
66
+
67
+ ### Steps
68
+
69
+ 1. **Resolve the role**:
70
+ - Look at the `.feature` file for `@auth:<role>` tags (feature-level or scenario-level). Pick the role for the scenario being run. If no tag exists, default to `user`.
71
+ - Target file: `specs/.auth/<role>.json`. Create `specs/.auth/` if missing.
72
+ - If the file already exists → use `AskUserQuestion` to confirm overwrite (mirrors the `(y/N)` prompt in `sungen makeauth`).
73
+ 2. **Navigate to login**:
74
+ - Read `baseURL` from `playwright.config.ts` (fall back to `APP_BASE_URL` env, then `http://localhost:3000` — same resolution order as `sungen makeauth`).
75
+ - `browser_navigate` to `<baseURL>/login`. If the app uses a different login path, ask the user.
76
+ - If the URL doesn't stay on `/login` after load → user is already signed in. Skip step 3.
77
+ 3. **Ask the user to log in manually** in the MCP browser (username, password, MFA, SSO — whatever the app needs). Never type credentials via `browser_type` or script the login. Wait for the user to confirm in chat that they're signed in.
78
+ 4. **Verify login** — check the current URL or take a `browser_snapshot`; confirm the page is no longer on `/login`.
79
+ 5. **Export storage state** (preferred → fallback):
80
+ - **Preferred** — `browser_storage_state` with `filename: "specs/.auth/<role>.json"` (native Playwright MCP tool; captures cookies including httpOnly + localStorage + sessionStorage via the Playwright context — same output format as `context.storageState({ path })` used by `sungen makeauth`).
81
+ - **Fallback** — if `browser_storage_state` isn't available in this MCP version, use `browser_run_code` to execute `await context.storageState({ path: 'specs/.auth/<role>.json' })`.
82
+ - **Do NOT** use `browser_evaluate` for auth export — it misses httpOnly cookies and session auth will fail silently.
83
+ 6. **Gitignore** — ensure `specs/.auth/` (or `specs/.auth/*.json`) is in `.gitignore`. Add it if missing.
84
+ 7. **Return to Phase 0 step 4** — re-`browser_navigate` to the target page; the session is now active.
85
+
86
+ ### Phase 0.5 pitfalls
87
+
88
+ - Writing to a path other than `specs/.auth/<role>.json` → compiled tests won't find the file. Always match `sungen makeauth`'s convention.
89
+ - Committing `specs/.auth/*.json` → leaks a live session. Always gitignore.
90
+ - Scripting the login with `browser_type` → bypasses MFA/CAPTCHA and risks account lockout. Always manual.
91
+ - Running Phase 0.5 on every `run-test` invocation → unnecessary; reuse the file until tests start redirecting to login.
92
+ - Mismatch between `<role>` in the auth file and `@auth:<role>` tag → compiled tests reference a nonexistent file.
12
93
 
13
94
  ---
14
95
 
@@ -94,10 +175,10 @@ Only when `test-results/` screenshots are insufficient:
94
175
 
95
176
  1. Read `baseURL` from `playwright.config.ts`
96
177
  2. `browser_navigate` to target page
97
- 3. If redirected to login → ask user to log in manually via MCP browser
178
+ 3. If redirected to login → run **Phase 0.5: Auth Persistence**, then re-navigate
98
179
  4. Take **ONE** `browser_snapshot` — fix all broken selectors from this single snapshot
99
180
 
100
- **Never use `sungen makeauth`.** Never use `browser_evaluate` to inject cookies.
181
+ Never use `browser_evaluate` to inject or read cookies (misses httpOnly). For auth, use Phase 0.5 or `sungen makeauth`.
101
182
 
102
183
  ### Step 3: Fix Broken Selectors
103
184
 
@@ -181,9 +262,11 @@ user detail:
181
262
 
182
263
  | Phase | What runs | Max fix attempts | On failure after max |
183
264
  |---|---|---|---|
265
+ | 0. Pre-gen | Playwright MCP snapshot → write selectors.yaml | 1 snapshot | Ask user — skip or retry navigation |
266
+ | 0.5. Auth | Manual login in MCP browser → `browser_storage_state` → `specs/.auth/<role>.json` | 1 login | Ask user — retry login or fall back to `sungen makeauth` |
184
267
  | 1. Smoke | First 5 @critical/@high | 2 | Ask user — fundamentals broken |
185
268
  | 2. Priority | All @critical + @high | 2 | Report failures, continue to Phase 3 |
186
269
  | 3. Full | All tests | 1 | Report @low/@normal failures, continue |
187
270
  | 4. Regression | All tests | 0 | Report final results |
188
271
 
189
- **Total worst case: 5 fix attempts** (2+2+1), not unbounded loops.
272
+ **Total worst case: 5 fix attempts** (2+2+1), not unbounded loops. Phases 0 and 0.5 don't count toward fix budget.
@@ -1,9 +1,9 @@
1
1
  ---
2
2
  name: sungen-add-screen
3
- description: 'Add a new Sungen screen — scaffolds directories and delegates to /sungen-create-test for test case creation'
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
4
  argument-hint: '[screen-name] [url-path]'
5
5
  agent: 'agent'
6
- tools: [vscode, execute, read, agent, edit, search, web, browser, todo]
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`).
@@ -24,18 +24,29 @@ Run with #tool:terminal:
24
24
  sungen add --screen ${input:screen} --path ${input:path}
25
25
  ```
26
26
 
27
- ### 2. Fill requirements (recommended)
27
+ ### 2. Prepare requirements
28
28
 
29
- Ask the user: "Would you like to fill in `requirements/spec.md` now? This helps generate higher quality test cases."
29
+ Ask the user to choose how to prepare requirements this is the foundation for high-quality test generation:
30
30
 
31
- - If yes → open `qa/screens/${input:screen}/requirements/spec.md` and help the user fill sections, fields, validation rules, business rules, and states.
32
- - If they have UI designs (screenshots, Figma exports, mockups) suggest copying them to `requirements/ui/`.
33
- - If no proceed to step 3.
31
+ - **Fill `spec.md` + capture live-page screenshot** (Recommended) best test quality
32
+ - **Fill `spec.md` only** app not live yet, or no need for visuals
33
+ - **Capture live-page screenshot only** spec will come later
34
+ - **Skip requirements prep** — proceed to `/sungen-create-test` immediately
35
+
36
+ **If "Fill `spec.md`" is chosen**: open `qa/screens/${input:screen}/requirements/spec.md` and help the user fill sections, fields, validation rules, business rules, and states.
37
+
38
+ **If "Capture live-page screenshot" is chosen**:
39
+ 1. Read `baseURL` from `playwright.config.ts` (fall back to `APP_BASE_URL` env, then ask the user).
40
+ 2. `browser_navigate` to `<baseURL>${input:path}`.
41
+ 3. If redirected to login → ask the user to log in manually in the MCP browser, wait for confirmation, then re-navigate. (No auth persistence needed here — that's handled by Phase 0.5 in `sungen-selector-fix` when tests run.)
42
+ 4. `browser_take_screenshot` with `filename: "qa/screens/${input:screen}/requirements/ui/${input:screen}.png"`.
43
+ 5. If the screen has multiple important states (empty, loaded, error, modal open), offer additional captures named `${input:screen}-<state>.png`.
44
+
45
+ If the user has additional UI designs (Figma exports, mockups), suggest copying them to `requirements/ui/`.
34
46
 
35
47
  ### 3. Next steps
36
48
 
37
49
  Tell the user what was created and offer next steps:
38
50
 
39
51
  - **`/sungen-create-test ${input:screen}`** — Create test cases from requirements/designs (Recommended)
40
- - **Fill `requirements/spec.md`** — Write screen specs first for better test quality
41
52
  - **Done for now** — I'll come back later
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: sungen-run-test
3
- description: 'Compile and run Playwright tests — auto-fixes selectors on failure. Uses sungen-selector-fix, sungen-selector-keys, and sungen-error-mapping skills.'
3
+ description: 'Generate selectors + auth state via Playwright MCP, compile, and run Playwright tests — auto-fixes selectors on failure. Uses sungen-selector-fix, sungen-selector-keys, and sungen-error-mapping skills.'
4
4
  argument-hint: '[screen-name]'
5
5
  agent: 'agent'
6
6
  tools: [vscode, execute, read, agent, edit, search, web, browser, todo, 'playwright/*']
@@ -16,18 +16,19 @@ You are a **Senior Developer**. Use `sungen-selector-fix`, `sungen-selector-keys
16
16
 
17
17
  - **screen** — ${input:screen:screen name (e.g., login, dashboard)}
18
18
 
19
- ## Compile
19
+ ## Pre-run (phased — per `sungen-selector-fix` skill)
20
20
 
21
- 1. Verify `qa/screens/${input:screen}/` has `.feature` + `test-data.yaml`
22
- 2. Ensure `selectors.yaml` has page selector. If missing, ask user for URL path
23
- 3. `sungen generate --screen ${input:screen}`
21
+ 1. Verify `qa/screens/${input:screen}/` has `.feature` + `test-data.yaml`.
22
+ 2. **Phase 0 — Selector Pre-gen**: if `selectors.yaml` is missing/empty or doesn't cover the feature file's `[Reference]`s, run Phase 0 from `sungen-selector-fix` — confirm with user, `browser_navigate` one `browser_snapshot` → merge YAML entries.
23
+ 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.
24
+ 4. Compile: `sungen generate --screen ${input:screen}`.
24
25
 
25
26
  ## Run & Fix (phased — per `sungen-selector-fix` skill)
26
27
 
27
- 4. **Phase 1 — Smoke Check**: Run first 5 `@critical`/`@high` scenarios only. If failures → diagnose, fix fundamentals (page selector, auth, base @steps), re-run. Max 2 attempts. If still broken → ask user.
28
- 5. **Phase 2 — Priority Wave**: Run all `@critical` + `@high` scenarios. Fix only failures from this wave. Max 2 attempts. Shared selectors fixed here cascade to later phases.
29
- 6. **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.
30
- 7. **Phase 4 — Regression**: One final full run. Report results. No more fix loops.
28
+ 5. **Phase 1 — Smoke Check**: Run first 5 `@critical`/`@high` scenarios only. If failures → diagnose, fix fundamentals (page selector, auth, base @steps), re-run. Max 2 attempts. If still broken → ask user.
29
+ 6. **Phase 2 — Priority Wave**: Run all `@critical` + `@high` scenarios. Fix only failures from this wave. Max 2 attempts. Shared selectors fixed here cascade to later phases.
30
+ 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.
31
+ 8. **Phase 4 — Regression**: One final full run. Report results. No more fix loops.
31
32
 
32
33
  ## Next steps
33
34
 
@@ -8,7 +8,88 @@ user-invocable: false
8
8
 
9
9
  Run tests in priority waves — catch fundamental issues early, fix critical paths first, let shared fixes cascade to lower-priority tests.
10
10
 
11
- **Never run all tests blindly.** Always start with a smoke check.
11
+ **Never run all tests blindly.** Always start with selector pre-generation, then a smoke check.
12
+
13
+ ---
14
+
15
+ ## Phase 0: Pre-run Selector Generation (Playwright MCP)
16
+
17
+ **Before any `sungen generate` or test run**, populate `selectors.yaml` from the live page so tests don't fail on missing keys in Phase 1.
18
+
19
+ ### When to run Phase 0
20
+
21
+ - `selectors.yaml` missing, empty, or contains only the page selector
22
+ - The `.feature` file has `[Reference]` keys without corresponding YAML entries and the referenced element can't be auto-inferred (see `sungen-selector-keys` § Auto-Infer)
23
+ - User explicitly re-scans after UI changes
24
+
25
+ If existing selectors already cover the feature file, **skip Phase 0** and go straight to compile + Phase 1.
26
+
27
+ ### Steps
28
+
29
+ 1. **Confirm with the user**: *"Generate selectors from the live page via Playwright MCP now?"* — offer **Yes, scan live page** / **Skip (use existing selectors.yaml)** / **Cancel**.
30
+ 2. **Collect references**: parse the `.feature` file for every `[Reference]` element + its type (e.g. `[Submit] button`, `[Email] field`). Deduplicate.
31
+ 3. **Ensure page selector**: if missing, ask user for URL path and write it first.
32
+ 4. **Navigate**:
33
+ - Read `baseURL` from `playwright.config.ts`.
34
+ - `browser_navigate` to the page URL.
35
+ - If redirected to login → **ask the user to log in manually in the MCP browser**, wait for confirmation, then continue. Never use `sungen makeauth`. Never inject cookies via `browser_evaluate`.
36
+ 5. **Snapshot**: take **ONE** `browser_snapshot`. All Phase 0 selectors come from this single snapshot.
37
+ 6. **Generate YAML entries**:
38
+ - Keys: follow `sungen-selector-keys` (lowercase, Unicode preserved, `--type` / `--N` suffixes).
39
+ - Selector priority: follow the table in **Diagnosis & Fix § Step 3** (`testid` > `role`+name > `placeholder` > `label` > `locator` > `text`).
40
+ - Copy names **character-for-character** from the snapshot. Never infer from the Gherkin label.
41
+ - If an element is auto-inferable per `sungen-selector-keys` § Auto-Infer, **omit it** from YAML — keep the file minimal.
42
+ 7. **Merge, don't overwrite**: preserve the page selector and any user-authored entries in `selectors.yaml`. Only add missing keys.
43
+ 8. **Show summary + confirm**: list the keys that will be added, ask the user to approve, then write the file.
44
+ 9. **Compile**: `sungen generate --screen <screen>` — then proceed to Phase 1.
45
+
46
+ ### Common Phase 0 pitfalls
47
+
48
+ - Writing keys inferred from the Gherkin label instead of the snapshot name → Phase 1 will fail with "no element found".
49
+ - Skipping Phase 0.5 when an auth redirect happened → snapshot captures the login page, all selectors wrong.
50
+ - Using `browser_evaluate` alone to scrape cookies → misses httpOnly session cookies. Always use `browser_storage_state` (or the `browser_run_code` fallback).
51
+ - Overwriting user-authored selectors → always merge.
52
+
53
+ ---
54
+
55
+ ## Phase 0.5: Auth Persistence (MCP alternative to `sungen makeauth`)
56
+
57
+ Capture an authenticated session from the MCP browser into `specs/.auth/<role>.json` — the same path `sungen makeauth` writes to, which compiled tests already reference via `test.use({ storageState })` based on `@auth:<role>` tags. No `playwright.config.ts` edits needed. Run once per auth lifetime, not on every selector fix.
58
+
59
+ ### When to run Phase 0.5
60
+
61
+ - Phase 0 navigation hit a login redirect and `specs/.auth/<role>.json` is missing or expired
62
+ - A scenario tagged `@auth:<role>` is about to run and its auth file is absent
63
+ - User asks to refresh auth
64
+
65
+ Skip if `specs/.auth/<role>.json` already exists and a probe navigation reaches an authenticated page without redirecting to login.
66
+
67
+ ### Steps
68
+
69
+ 1. **Resolve the role**:
70
+ - Look at the `.feature` file for `@auth:<role>` tags (feature-level or scenario-level). Pick the role for the scenario being run. If no tag exists, default to `user`.
71
+ - Target file: `specs/.auth/<role>.json`. Create `specs/.auth/` if missing.
72
+ - If the file already exists → confirm overwrite with the user (mirrors the `(y/N)` prompt in `sungen makeauth`).
73
+ 2. **Navigate to login**:
74
+ - Read `baseURL` from `playwright.config.ts` (fall back to `APP_BASE_URL` env, then `http://localhost:3000` — same resolution order as `sungen makeauth`).
75
+ - `browser_navigate` to `<baseURL>/login`. If the app uses a different login path, ask the user.
76
+ - If the URL doesn't stay on `/login` after load → user is already signed in. Skip step 3.
77
+ 3. **Ask the user to log in manually** in the MCP browser (username, password, MFA, SSO — whatever the app needs). Never type credentials via `browser_type` or script the login. Wait for the user to confirm in chat that they're signed in.
78
+ 4. **Verify login** — check the current URL or take a `browser_snapshot`; confirm the page is no longer on `/login`.
79
+ 5. **Export storage state** (preferred → fallback):
80
+ - **Preferred** — `browser_storage_state` with `filename: "specs/.auth/<role>.json"` (native Playwright MCP tool; captures cookies including httpOnly + localStorage + sessionStorage via the Playwright context — same output format as `context.storageState({ path })` used by `sungen makeauth`).
81
+ - **Fallback** — if `browser_storage_state` isn't available in this MCP version, use `browser_run_code` to execute `await context.storageState({ path: 'specs/.auth/<role>.json' })`.
82
+ - **Do NOT** use `browser_evaluate` for auth export — it misses httpOnly cookies and session auth will fail silently.
83
+ 6. **Gitignore** — ensure `specs/.auth/` (or `specs/.auth/*.json`) is in `.gitignore`. Add it if missing.
84
+ 7. **Return to Phase 0 step 4** — re-`browser_navigate` to the target page; the session is now active.
85
+
86
+ ### Phase 0.5 pitfalls
87
+
88
+ - Writing to a path other than `specs/.auth/<role>.json` → compiled tests won't find the file. Always match `sungen makeauth`'s convention.
89
+ - Committing `specs/.auth/*.json` → leaks a live session. Always gitignore.
90
+ - Scripting the login with `browser_type` → bypasses MFA/CAPTCHA and risks account lockout. Always manual.
91
+ - Running Phase 0.5 on every `run-test` invocation → unnecessary; reuse the file until tests start redirecting to login.
92
+ - Mismatch between `<role>` in the auth file and `@auth:<role>` tag → compiled tests reference a nonexistent file.
12
93
 
13
94
  ---
14
95
 
@@ -94,10 +175,10 @@ Only when `test-results/` screenshots are insufficient:
94
175
 
95
176
  1. Read `baseURL` from `playwright.config.ts`
96
177
  2. `browser_navigate` to target page
97
- 3. If redirected to login → ask user to log in manually via MCP browser
178
+ 3. If redirected to login → run **Phase 0.5: Auth Persistence**, then re-navigate
98
179
  4. Take **ONE** `browser_snapshot` — fix all broken selectors from this single snapshot
99
180
 
100
- **Never use `sungen makeauth`.** Never use `browser_evaluate` to inject cookies.
181
+ Never use `browser_evaluate` to inject or read cookies (misses httpOnly). For auth, use Phase 0.5 or `sungen makeauth`.
101
182
 
102
183
  ### Step 3: Fix Broken Selectors
103
184
 
@@ -181,9 +262,11 @@ user detail:
181
262
 
182
263
  | Phase | What runs | Max fix attempts | On failure after max |
183
264
  |---|---|---|---|
265
+ | 0. Pre-gen | Playwright MCP snapshot → write selectors.yaml | 1 snapshot | Ask user — skip or retry navigation |
266
+ | 0.5. Auth | Manual login in MCP browser → `browser_storage_state` → `specs/.auth/<role>.json` | 1 login | Ask user — retry login or fall back to `sungen makeauth` |
184
267
  | 1. Smoke | First 5 @critical/@high | 2 | Ask user — fundamentals broken |
185
268
  | 2. Priority | All @critical + @high | 2 | Report failures, continue to Phase 3 |
186
269
  | 3. Full | All tests | 1 | Report @low/@normal failures, continue |
187
270
  | 4. Regression | All tests | 0 | Report final results |
188
271
 
189
- **Total worst case: 5 fix attempts** (2+2+1), not unbounded loops.
272
+ **Total worst case: 5 fix attempts** (2+2+1), not unbounded loops. Phases 0 and 0.5 don't count toward fix budget.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sun-asterisk/sungen",
3
- "version": "2.4.3",
3
+ "version": "2.4.5",
4
4
  "description": "Deterministic E2E Test Compiler - Gherkin + Selectors → Playwright tests",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -3,19 +3,26 @@ import { Command } from 'commander';
3
3
  export function registerAddCommand(program: Command): void {
4
4
  program
5
5
  .command('add')
6
- .description('Add screen or feature definition with scaffolded files. Auto-captures screenshots when --path is provided.')
6
+ .description('Add screen or feature definition with scaffolded files. Use --capture to auto-capture a live-page screenshot.')
7
7
  .requiredOption('--screen <name>', 'Screen name')
8
- .option('-p, --path <path>', 'Screen route path (e.g. /awards). Also triggers auto-screenshot capture.')
8
+ .option('-p, --path <path>', 'Screen route path (e.g. /awards)')
9
+ .option('-c, --capture', 'Auto-capture a live-page screenshot to requirements/ui/ (requires --path)')
9
10
  .option('-f, --feature <name>', 'Add additional feature file to existing screen')
10
11
  .option('-d, --description <text>', 'Screen description')
11
12
  .action(async (options) => {
12
13
  try {
14
+ if (options.capture && !options.path) {
15
+ console.error('Error: --capture requires --path to be set');
16
+ process.exit(1);
17
+ }
18
+
13
19
  const { ScreenManager } = require('../../orchestrator/screen-manager');
14
20
  const manager = new ScreenManager();
15
21
 
16
22
  await manager.addScreen({
17
23
  name: options.screen,
18
24
  path: options.path,
25
+ capture: options.capture,
19
26
  feature: options.feature,
20
27
  description: options.description,
21
28
  });
package/src/cli/index.ts CHANGED
@@ -17,7 +17,7 @@ async function main() {
17
17
  program
18
18
  .name('sungen')
19
19
  .description('Deterministic E2E Test Compiler — Gherkin + Selectors → Playwright')
20
- .version('2.4.3');
20
+ .version('2.4.5');
21
21
 
22
22
  // Global options
23
23
  program
@@ -10,6 +10,7 @@ import { chromium } from '@playwright/test';
10
10
  export interface ScreenOptions {
11
11
  name: string;
12
12
  path?: string;
13
+ capture?: boolean;
13
14
  feature?: string;
14
15
  description?: string;
15
16
  }
@@ -185,9 +186,9 @@ export class ScreenManager {
185
186
  ].join('\n'), 'utf-8');
186
187
  }
187
188
 
188
- // Auto-screenshot: capture page if --path is provided
189
+ // Auto-screenshot: capture page only when --capture is set (requires --path)
189
190
  // Use filename (not screenName) so each feature gets its own screenshots
190
- if (options.path) {
191
+ if (options.capture && options.path) {
191
192
  await this.captureScreenshot(options.path, requirementsUiDir, filename);
192
193
  }
193
194
 
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  name: add-screen
3
- description: 'Add a new Sungen screen — scaffolds directories and delegates to create-test for test case creation'
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
4
  argument-hint: [screen-name] [url-path]
5
- allowed-tools: Read, Grep, Bash, Glob, AskUserQuestion
5
+ allowed-tools: Read, Grep, Bash, Glob, Edit, Write, AskUserQuestion, mcp__playwright__browser_navigate, mcp__playwright__browser_take_screenshot, mcp__playwright__browser_snapshot
6
6
  ---
7
7
 
8
8
  You are adding a new Sungen screen for test generation.
@@ -25,20 +25,31 @@ Run:
25
25
  sungen add --screen <screen> --path <path>
26
26
  ```
27
27
 
28
- ### 2. Fill requirements (recommended)
28
+ ### 2. Prepare requirements
29
29
 
30
- Ask the user: "Would you like to fill in `requirements/spec.md` now? This helps generate higher quality test cases."
30
+ Use `AskUserQuestion` to let the user choose how to prepare requirements this is the foundation for high-quality test generation:
31
31
 
32
- - If yes → open `qa/screens/<screen>/requirements/spec.md` and help the user fill sections, fields, validation rules, business rules, and states.
33
- - If they have UI designs (screenshots, Figma exports, mockups) suggest copying them to `requirements/ui/`.
34
- - If no proceed to step 3.
32
+ - **Fill `spec.md` + capture live-page screenshot** (Recommended) best test quality
33
+ - **Fill `spec.md` only** app not live yet, or no need for visuals
34
+ - **Capture live-page screenshot only** spec will come later
35
+ - **Skip requirements prep** — proceed to `/sungen:create-test` immediately
36
+
37
+ **If "Fill `spec.md`" is chosen**: open `qa/screens/<screen>/requirements/spec.md` and help the user fill sections, fields, validation rules, business rules, and states.
38
+
39
+ **If "Capture live-page screenshot" is chosen**:
40
+ 1. Read `baseURL` from `playwright.config.ts` (fall back to `APP_BASE_URL` env, then ask the user).
41
+ 2. `browser_navigate` to `<baseURL><path>`.
42
+ 3. If redirected to login → ask the user to log in manually in the MCP browser, wait for confirmation, then re-navigate. (No auth persistence needed here — that's handled by Phase 0.5 in `sungen-selector-fix` when tests run.)
43
+ 4. `browser_take_screenshot` with `filename: "qa/screens/<screen>/requirements/ui/<screen>.png"`.
44
+ 5. If the screen has multiple important states (empty, loaded, error, modal open), offer additional captures named `<screen>-<state>.png`.
45
+
46
+ If the user has additional UI designs (Figma exports, mockups), suggest copying them to `requirements/ui/`.
35
47
 
36
48
  ### 3. Next steps
37
49
 
38
50
  Tell the user what was created, then use `AskUserQuestion` to offer next steps:
39
51
 
40
52
  - **`/sungen:create-test <screen>`** — Create test cases from requirements/designs (Recommended)
41
- - **Fill `requirements/spec.md`** — Write screen specs first for better test quality
42
53
  - **Done for now** — I'll come back later
43
54
 
44
55
  If user picks `/sungen:create-test`, **you MUST use the Skill tool** to invoke it. Do NOT generate test cases yourself — the skill auto-loads `sungen-gherkin-syntax` and `sungen-tc-generation`.
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  name: run-test
3
- description: 'Compile and run Playwright tests — auto-fixes selectors on failure'
3
+ description: 'Generate selectors + auth state via Playwright MCP, compile, and run Playwright tests — auto-fixes selectors on failure'
4
4
  argument-hint: [screen-name]
5
- allowed-tools: Read, Grep, Bash, Glob, Edit, AskUserQuestion
5
+ allowed-tools: Read, Grep, Bash, Glob, Edit, Write, AskUserQuestion, mcp__playwright__browser_navigate, mcp__playwright__browser_snapshot, mcp__playwright__browser_take_screenshot, mcp__playwright__browser_wait_for, mcp__playwright__browser_evaluate, mcp__playwright__browser_run_code, mcp__playwright__browser_storage_state, mcp__playwright__browser_set_storage_state
6
6
  ---
7
7
 
8
8
  ## Role
@@ -13,18 +13,19 @@ You are a **Senior Developer**. Use `sungen-selector-fix`, `sungen-selector-keys
13
13
 
14
14
  Parse **screen** from `$ARGUMENTS`. If missing, ask the user.
15
15
 
16
- ## Compile
16
+ ## Pre-run (phased — per `sungen-selector-fix` skill)
17
17
 
18
- 1. Verify `qa/screens/<screen>/` has `.feature` + `test-data.yaml`
19
- 2. Ensure `selectors.yaml` has page selector. If missing, ask user for URL path
20
- 3. `sungen generate --screen <screen>`
18
+ 1. Verify `qa/screens/<screen>/` has `.feature` + `test-data.yaml`.
19
+ 2. **Phase 0 — Selector Pre-gen**: if `selectors.yaml` is missing/empty or doesn't cover the feature file's `[Reference]`s, run Phase 0 from `sungen-selector-fix` — confirm with user, `browser_navigate` one `browser_snapshot` → merge YAML entries.
20
+ 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.
21
+ 4. Compile: `sungen generate --screen <screen>`.
21
22
 
22
23
  ## Run & Fix (phased — per `sungen-selector-fix` skill)
23
24
 
24
- 4. **Phase 1 — Smoke Check**: Run first 5 `@critical`/`@high` scenarios only. If failures → diagnose, fix fundamentals (page selector, auth, base @steps), re-run. Max 2 attempts. If still broken → ask user.
25
- 5. **Phase 2 — Priority Wave**: Run all `@critical` + `@high` scenarios. Fix only failures from this wave. Max 2 attempts. Shared selectors fixed here cascade to later phases.
26
- 6. **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.
27
- 7. **Phase 4 — Regression**: One final full run. Report results. No more fix loops.
25
+ 5. **Phase 1 — Smoke Check**: Run first 5 `@critical`/`@high` scenarios only. If failures → diagnose, fix fundamentals (page selector, auth, base @steps), re-run. Max 2 attempts. If still broken → ask user.
26
+ 6. **Phase 2 — Priority Wave**: Run all `@critical` + `@high` scenarios. Fix only failures from this wave. Max 2 attempts. Shared selectors fixed here cascade to later phases.
27
+ 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.
28
+ 8. **Phase 4 — Regression**: One final full run. Report results. No more fix loops.
28
29
 
29
30
  ## Next steps
30
31
 
@@ -8,7 +8,88 @@ user-invocable: false
8
8
 
9
9
  Run tests in priority waves — catch fundamental issues early, fix critical paths first, let shared fixes cascade to lower-priority tests.
10
10
 
11
- **Never run all tests blindly.** Always start with a smoke check.
11
+ **Never run all tests blindly.** Always start with selector pre-generation, then a smoke check.
12
+
13
+ ---
14
+
15
+ ## Phase 0: Pre-run Selector Generation (Playwright MCP)
16
+
17
+ **Before any `sungen generate` or test run**, populate `selectors.yaml` from the live page so tests don't fail on missing keys in Phase 1.
18
+
19
+ ### When to run Phase 0
20
+
21
+ - `selectors.yaml` missing, empty, or contains only the page selector
22
+ - The `.feature` file has `[Reference]` keys without corresponding YAML entries and the referenced element can't be auto-inferred (see `sungen-selector-keys` § Auto-Infer)
23
+ - User explicitly re-scans after UI changes
24
+
25
+ If existing selectors already cover the feature file, **skip Phase 0** and go straight to compile + Phase 1.
26
+
27
+ ### Steps
28
+
29
+ 1. **Confirm with the user** via `AskUserQuestion`: *"Generate selectors from the live page via Playwright MCP now?"* — offer **Yes, scan live page** / **Skip (use existing selectors.yaml)** / **Cancel**.
30
+ 2. **Collect references**: parse the `.feature` file for every `[Reference]` element + its type (e.g. `[Submit] button`, `[Email] field`). Deduplicate.
31
+ 3. **Ensure page selector**: if missing, ask user for URL path and write it first.
32
+ 4. **Navigate**:
33
+ - Read `baseURL` from `playwright.config.ts`.
34
+ - `browser_navigate` to the page URL.
35
+ - If redirected to login → run **Phase 0.5: Auth Persistence** first (see below), then re-navigate to the target page.
36
+ 5. **Snapshot**: take **ONE** `browser_snapshot`. All Phase 0 selectors come from this single snapshot.
37
+ 6. **Generate YAML entries**:
38
+ - Keys: follow `sungen-selector-keys` (lowercase, Unicode preserved, `--type` / `--N` suffixes).
39
+ - Selector priority: follow the table in **Diagnosis & Fix § Step 3** (`testid` > `role`+name > `placeholder` > `label` > `locator` > `text`).
40
+ - Copy names **character-for-character** from the snapshot. Never infer from the Gherkin label.
41
+ - If an element is auto-inferable per `sungen-selector-keys` § Auto-Infer, **omit it** from YAML — keep the file minimal.
42
+ 7. **Merge, don't overwrite**: preserve the page selector and any user-authored entries in `selectors.yaml`. Only add missing keys.
43
+ 8. **Show summary + confirm**: list the keys that will be added, ask the user to approve, then write the file.
44
+ 9. **Compile**: `sungen generate --screen <screen>` — then proceed to Phase 1.
45
+
46
+ ### Common Phase 0 pitfalls
47
+
48
+ - Writing keys inferred from the Gherkin label instead of the snapshot name → Phase 1 will fail with "no element found".
49
+ - Skipping Phase 0.5 when an auth redirect happened → snapshot captures the login page, all selectors wrong.
50
+ - Using `browser_evaluate` alone to scrape cookies → misses httpOnly session cookies. Always use `browser_storage_state` (or the `browser_run_code` fallback).
51
+ - Overwriting user-authored selectors → always merge.
52
+
53
+ ---
54
+
55
+ ## Phase 0.5: Auth Persistence (MCP alternative to `sungen makeauth`)
56
+
57
+ Capture an authenticated session from the MCP browser into `specs/.auth/<role>.json` — the same path `sungen makeauth` writes to, which compiled tests already reference via `test.use({ storageState })` based on `@auth:<role>` tags. No `playwright.config.ts` edits needed. Run once per auth lifetime, not on every selector fix.
58
+
59
+ ### When to run Phase 0.5
60
+
61
+ - Phase 0 navigation hit a login redirect and `specs/.auth/<role>.json` is missing or expired
62
+ - A scenario tagged `@auth:<role>` is about to run and its auth file is absent
63
+ - User asks to refresh auth
64
+
65
+ Skip if `specs/.auth/<role>.json` already exists and a probe navigation reaches an authenticated page without redirecting to login.
66
+
67
+ ### Steps
68
+
69
+ 1. **Resolve the role**:
70
+ - Look at the `.feature` file for `@auth:<role>` tags (feature-level or scenario-level). Pick the role for the scenario being run. If no tag exists, default to `user`.
71
+ - Target file: `specs/.auth/<role>.json`. Create `specs/.auth/` if missing.
72
+ - If the file already exists → use `AskUserQuestion` to confirm overwrite (mirrors the `(y/N)` prompt in `sungen makeauth`).
73
+ 2. **Navigate to login**:
74
+ - Read `baseURL` from `playwright.config.ts` (fall back to `APP_BASE_URL` env, then `http://localhost:3000` — same resolution order as `sungen makeauth`).
75
+ - `browser_navigate` to `<baseURL>/login`. If the app uses a different login path, ask the user.
76
+ - If the URL doesn't stay on `/login` after load → user is already signed in. Skip step 3.
77
+ 3. **Ask the user to log in manually** in the MCP browser (username, password, MFA, SSO — whatever the app needs). Never type credentials via `browser_type` or script the login. Wait for the user to confirm in chat that they're signed in.
78
+ 4. **Verify login** — check the current URL or take a `browser_snapshot`; confirm the page is no longer on `/login`.
79
+ 5. **Export storage state** (preferred → fallback):
80
+ - **Preferred** — `browser_storage_state` with `filename: "specs/.auth/<role>.json"` (native Playwright MCP tool; captures cookies including httpOnly + localStorage + sessionStorage via the Playwright context — same output format as `context.storageState({ path })` used by `sungen makeauth`).
81
+ - **Fallback** — if `browser_storage_state` isn't available in this MCP version, use `browser_run_code` to execute `await context.storageState({ path: 'specs/.auth/<role>.json' })`.
82
+ - **Do NOT** use `browser_evaluate` for auth export — it misses httpOnly cookies and session auth will fail silently.
83
+ 6. **Gitignore** — ensure `specs/.auth/` (or `specs/.auth/*.json`) is in `.gitignore`. Add it if missing.
84
+ 7. **Return to Phase 0 step 4** — re-`browser_navigate` to the target page; the session is now active.
85
+
86
+ ### Phase 0.5 pitfalls
87
+
88
+ - Writing to a path other than `specs/.auth/<role>.json` → compiled tests won't find the file. Always match `sungen makeauth`'s convention.
89
+ - Committing `specs/.auth/*.json` → leaks a live session. Always gitignore.
90
+ - Scripting the login with `browser_type` → bypasses MFA/CAPTCHA and risks account lockout. Always manual.
91
+ - Running Phase 0.5 on every `run-test` invocation → unnecessary; reuse the file until tests start redirecting to login.
92
+ - Mismatch between `<role>` in the auth file and `@auth:<role>` tag → compiled tests reference a nonexistent file.
12
93
 
13
94
  ---
14
95
 
@@ -94,10 +175,10 @@ Only when `test-results/` screenshots are insufficient:
94
175
 
95
176
  1. Read `baseURL` from `playwright.config.ts`
96
177
  2. `browser_navigate` to target page
97
- 3. If redirected to login → ask user to log in manually via MCP browser
178
+ 3. If redirected to login → run **Phase 0.5: Auth Persistence**, then re-navigate
98
179
  4. Take **ONE** `browser_snapshot` — fix all broken selectors from this single snapshot
99
180
 
100
- **Never use `sungen makeauth`.** Never use `browser_evaluate` to inject cookies.
181
+ Never use `browser_evaluate` to inject or read cookies (misses httpOnly). For auth, use Phase 0.5 or `sungen makeauth`.
101
182
 
102
183
  ### Step 3: Fix Broken Selectors
103
184
 
@@ -181,9 +262,11 @@ user detail:
181
262
 
182
263
  | Phase | What runs | Max fix attempts | On failure after max |
183
264
  |---|---|---|---|
265
+ | 0. Pre-gen | Playwright MCP snapshot → write selectors.yaml | 1 snapshot | Ask user — skip or retry navigation |
266
+ | 0.5. Auth | Manual login in MCP browser → `browser_storage_state` → `specs/.auth/<role>.json` | 1 login | Ask user — retry login or fall back to `sungen makeauth` |
184
267
  | 1. Smoke | First 5 @critical/@high | 2 | Ask user — fundamentals broken |
185
268
  | 2. Priority | All @critical + @high | 2 | Report failures, continue to Phase 3 |
186
269
  | 3. Full | All tests | 1 | Report @low/@normal failures, continue |
187
270
  | 4. Regression | All tests | 0 | Report final results |
188
271
 
189
- **Total worst case: 5 fix attempts** (2+2+1), not unbounded loops.
272
+ **Total worst case: 5 fix attempts** (2+2+1), not unbounded loops. Phases 0 and 0.5 don't count toward fix budget.
@@ -1,9 +1,9 @@
1
1
  ---
2
2
  name: sungen-add-screen
3
- description: 'Add a new Sungen screen — scaffolds directories and delegates to /sungen-create-test for test case creation'
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
4
  argument-hint: '[screen-name] [url-path]'
5
5
  agent: 'agent'
6
- tools: [vscode, execute, read, agent, edit, search, web, browser, todo]
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`).
@@ -24,18 +24,29 @@ Run with #tool:terminal:
24
24
  sungen add --screen ${input:screen} --path ${input:path}
25
25
  ```
26
26
 
27
- ### 2. Fill requirements (recommended)
27
+ ### 2. Prepare requirements
28
28
 
29
- Ask the user: "Would you like to fill in `requirements/spec.md` now? This helps generate higher quality test cases."
29
+ Ask the user to choose how to prepare requirements this is the foundation for high-quality test generation:
30
30
 
31
- - If yes → open `qa/screens/${input:screen}/requirements/spec.md` and help the user fill sections, fields, validation rules, business rules, and states.
32
- - If they have UI designs (screenshots, Figma exports, mockups) suggest copying them to `requirements/ui/`.
33
- - If no proceed to step 3.
31
+ - **Fill `spec.md` + capture live-page screenshot** (Recommended) best test quality
32
+ - **Fill `spec.md` only** app not live yet, or no need for visuals
33
+ - **Capture live-page screenshot only** spec will come later
34
+ - **Skip requirements prep** — proceed to `/sungen-create-test` immediately
35
+
36
+ **If "Fill `spec.md`" is chosen**: open `qa/screens/${input:screen}/requirements/spec.md` and help the user fill sections, fields, validation rules, business rules, and states.
37
+
38
+ **If "Capture live-page screenshot" is chosen**:
39
+ 1. Read `baseURL` from `playwright.config.ts` (fall back to `APP_BASE_URL` env, then ask the user).
40
+ 2. `browser_navigate` to `<baseURL>${input:path}`.
41
+ 3. If redirected to login → ask the user to log in manually in the MCP browser, wait for confirmation, then re-navigate. (No auth persistence needed here — that's handled by Phase 0.5 in `sungen-selector-fix` when tests run.)
42
+ 4. `browser_take_screenshot` with `filename: "qa/screens/${input:screen}/requirements/ui/${input:screen}.png"`.
43
+ 5. If the screen has multiple important states (empty, loaded, error, modal open), offer additional captures named `${input:screen}-<state>.png`.
44
+
45
+ If the user has additional UI designs (Figma exports, mockups), suggest copying them to `requirements/ui/`.
34
46
 
35
47
  ### 3. Next steps
36
48
 
37
49
  Tell the user what was created and offer next steps:
38
50
 
39
51
  - **`/sungen-create-test ${input:screen}`** — Create test cases from requirements/designs (Recommended)
40
- - **Fill `requirements/spec.md`** — Write screen specs first for better test quality
41
52
  - **Done for now** — I'll come back later
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: sungen-run-test
3
- description: 'Compile and run Playwright tests — auto-fixes selectors on failure. Uses sungen-selector-fix, sungen-selector-keys, and sungen-error-mapping skills.'
3
+ description: 'Generate selectors + auth state via Playwright MCP, compile, and run Playwright tests — auto-fixes selectors on failure. Uses sungen-selector-fix, sungen-selector-keys, and sungen-error-mapping skills.'
4
4
  argument-hint: '[screen-name]'
5
5
  agent: 'agent'
6
6
  tools: [vscode, execute, read, agent, edit, search, web, browser, todo, 'playwright/*']
@@ -16,18 +16,19 @@ You are a **Senior Developer**. Use `sungen-selector-fix`, `sungen-selector-keys
16
16
 
17
17
  - **screen** — ${input:screen:screen name (e.g., login, dashboard)}
18
18
 
19
- ## Compile
19
+ ## Pre-run (phased — per `sungen-selector-fix` skill)
20
20
 
21
- 1. Verify `qa/screens/${input:screen}/` has `.feature` + `test-data.yaml`
22
- 2. Ensure `selectors.yaml` has page selector. If missing, ask user for URL path
23
- 3. `sungen generate --screen ${input:screen}`
21
+ 1. Verify `qa/screens/${input:screen}/` has `.feature` + `test-data.yaml`.
22
+ 2. **Phase 0 — Selector Pre-gen**: if `selectors.yaml` is missing/empty or doesn't cover the feature file's `[Reference]`s, run Phase 0 from `sungen-selector-fix` — confirm with user, `browser_navigate` one `browser_snapshot` → merge YAML entries.
23
+ 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.
24
+ 4. Compile: `sungen generate --screen ${input:screen}`.
24
25
 
25
26
  ## Run & Fix (phased — per `sungen-selector-fix` skill)
26
27
 
27
- 4. **Phase 1 — Smoke Check**: Run first 5 `@critical`/`@high` scenarios only. If failures → diagnose, fix fundamentals (page selector, auth, base @steps), re-run. Max 2 attempts. If still broken → ask user.
28
- 5. **Phase 2 — Priority Wave**: Run all `@critical` + `@high` scenarios. Fix only failures from this wave. Max 2 attempts. Shared selectors fixed here cascade to later phases.
29
- 6. **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.
30
- 7. **Phase 4 — Regression**: One final full run. Report results. No more fix loops.
28
+ 5. **Phase 1 — Smoke Check**: Run first 5 `@critical`/`@high` scenarios only. If failures → diagnose, fix fundamentals (page selector, auth, base @steps), re-run. Max 2 attempts. If still broken → ask user.
29
+ 6. **Phase 2 — Priority Wave**: Run all `@critical` + `@high` scenarios. Fix only failures from this wave. Max 2 attempts. Shared selectors fixed here cascade to later phases.
30
+ 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.
31
+ 8. **Phase 4 — Regression**: One final full run. Report results. No more fix loops.
31
32
 
32
33
  ## Next steps
33
34
 
@@ -8,7 +8,88 @@ user-invocable: false
8
8
 
9
9
  Run tests in priority waves — catch fundamental issues early, fix critical paths first, let shared fixes cascade to lower-priority tests.
10
10
 
11
- **Never run all tests blindly.** Always start with a smoke check.
11
+ **Never run all tests blindly.** Always start with selector pre-generation, then a smoke check.
12
+
13
+ ---
14
+
15
+ ## Phase 0: Pre-run Selector Generation (Playwright MCP)
16
+
17
+ **Before any `sungen generate` or test run**, populate `selectors.yaml` from the live page so tests don't fail on missing keys in Phase 1.
18
+
19
+ ### When to run Phase 0
20
+
21
+ - `selectors.yaml` missing, empty, or contains only the page selector
22
+ - The `.feature` file has `[Reference]` keys without corresponding YAML entries and the referenced element can't be auto-inferred (see `sungen-selector-keys` § Auto-Infer)
23
+ - User explicitly re-scans after UI changes
24
+
25
+ If existing selectors already cover the feature file, **skip Phase 0** and go straight to compile + Phase 1.
26
+
27
+ ### Steps
28
+
29
+ 1. **Confirm with the user**: *"Generate selectors from the live page via Playwright MCP now?"* — offer **Yes, scan live page** / **Skip (use existing selectors.yaml)** / **Cancel**.
30
+ 2. **Collect references**: parse the `.feature` file for every `[Reference]` element + its type (e.g. `[Submit] button`, `[Email] field`). Deduplicate.
31
+ 3. **Ensure page selector**: if missing, ask user for URL path and write it first.
32
+ 4. **Navigate**:
33
+ - Read `baseURL` from `playwright.config.ts`.
34
+ - `browser_navigate` to the page URL.
35
+ - If redirected to login → **ask the user to log in manually in the MCP browser**, wait for confirmation, then continue. Never use `sungen makeauth`. Never inject cookies via `browser_evaluate`.
36
+ 5. **Snapshot**: take **ONE** `browser_snapshot`. All Phase 0 selectors come from this single snapshot.
37
+ 6. **Generate YAML entries**:
38
+ - Keys: follow `sungen-selector-keys` (lowercase, Unicode preserved, `--type` / `--N` suffixes).
39
+ - Selector priority: follow the table in **Diagnosis & Fix § Step 3** (`testid` > `role`+name > `placeholder` > `label` > `locator` > `text`).
40
+ - Copy names **character-for-character** from the snapshot. Never infer from the Gherkin label.
41
+ - If an element is auto-inferable per `sungen-selector-keys` § Auto-Infer, **omit it** from YAML — keep the file minimal.
42
+ 7. **Merge, don't overwrite**: preserve the page selector and any user-authored entries in `selectors.yaml`. Only add missing keys.
43
+ 8. **Show summary + confirm**: list the keys that will be added, ask the user to approve, then write the file.
44
+ 9. **Compile**: `sungen generate --screen <screen>` — then proceed to Phase 1.
45
+
46
+ ### Common Phase 0 pitfalls
47
+
48
+ - Writing keys inferred from the Gherkin label instead of the snapshot name → Phase 1 will fail with "no element found".
49
+ - Skipping Phase 0.5 when an auth redirect happened → snapshot captures the login page, all selectors wrong.
50
+ - Using `browser_evaluate` alone to scrape cookies → misses httpOnly session cookies. Always use `browser_storage_state` (or the `browser_run_code` fallback).
51
+ - Overwriting user-authored selectors → always merge.
52
+
53
+ ---
54
+
55
+ ## Phase 0.5: Auth Persistence (MCP alternative to `sungen makeauth`)
56
+
57
+ Capture an authenticated session from the MCP browser into `specs/.auth/<role>.json` — the same path `sungen makeauth` writes to, which compiled tests already reference via `test.use({ storageState })` based on `@auth:<role>` tags. No `playwright.config.ts` edits needed. Run once per auth lifetime, not on every selector fix.
58
+
59
+ ### When to run Phase 0.5
60
+
61
+ - Phase 0 navigation hit a login redirect and `specs/.auth/<role>.json` is missing or expired
62
+ - A scenario tagged `@auth:<role>` is about to run and its auth file is absent
63
+ - User asks to refresh auth
64
+
65
+ Skip if `specs/.auth/<role>.json` already exists and a probe navigation reaches an authenticated page without redirecting to login.
66
+
67
+ ### Steps
68
+
69
+ 1. **Resolve the role**:
70
+ - Look at the `.feature` file for `@auth:<role>` tags (feature-level or scenario-level). Pick the role for the scenario being run. If no tag exists, default to `user`.
71
+ - Target file: `specs/.auth/<role>.json`. Create `specs/.auth/` if missing.
72
+ - If the file already exists → confirm overwrite with the user (mirrors the `(y/N)` prompt in `sungen makeauth`).
73
+ 2. **Navigate to login**:
74
+ - Read `baseURL` from `playwright.config.ts` (fall back to `APP_BASE_URL` env, then `http://localhost:3000` — same resolution order as `sungen makeauth`).
75
+ - `browser_navigate` to `<baseURL>/login`. If the app uses a different login path, ask the user.
76
+ - If the URL doesn't stay on `/login` after load → user is already signed in. Skip step 3.
77
+ 3. **Ask the user to log in manually** in the MCP browser (username, password, MFA, SSO — whatever the app needs). Never type credentials via `browser_type` or script the login. Wait for the user to confirm in chat that they're signed in.
78
+ 4. **Verify login** — check the current URL or take a `browser_snapshot`; confirm the page is no longer on `/login`.
79
+ 5. **Export storage state** (preferred → fallback):
80
+ - **Preferred** — `browser_storage_state` with `filename: "specs/.auth/<role>.json"` (native Playwright MCP tool; captures cookies including httpOnly + localStorage + sessionStorage via the Playwright context — same output format as `context.storageState({ path })` used by `sungen makeauth`).
81
+ - **Fallback** — if `browser_storage_state` isn't available in this MCP version, use `browser_run_code` to execute `await context.storageState({ path: 'specs/.auth/<role>.json' })`.
82
+ - **Do NOT** use `browser_evaluate` for auth export — it misses httpOnly cookies and session auth will fail silently.
83
+ 6. **Gitignore** — ensure `specs/.auth/` (or `specs/.auth/*.json`) is in `.gitignore`. Add it if missing.
84
+ 7. **Return to Phase 0 step 4** — re-`browser_navigate` to the target page; the session is now active.
85
+
86
+ ### Phase 0.5 pitfalls
87
+
88
+ - Writing to a path other than `specs/.auth/<role>.json` → compiled tests won't find the file. Always match `sungen makeauth`'s convention.
89
+ - Committing `specs/.auth/*.json` → leaks a live session. Always gitignore.
90
+ - Scripting the login with `browser_type` → bypasses MFA/CAPTCHA and risks account lockout. Always manual.
91
+ - Running Phase 0.5 on every `run-test` invocation → unnecessary; reuse the file until tests start redirecting to login.
92
+ - Mismatch between `<role>` in the auth file and `@auth:<role>` tag → compiled tests reference a nonexistent file.
12
93
 
13
94
  ---
14
95
 
@@ -94,10 +175,10 @@ Only when `test-results/` screenshots are insufficient:
94
175
 
95
176
  1. Read `baseURL` from `playwright.config.ts`
96
177
  2. `browser_navigate` to target page
97
- 3. If redirected to login → ask user to log in manually via MCP browser
178
+ 3. If redirected to login → run **Phase 0.5: Auth Persistence**, then re-navigate
98
179
  4. Take **ONE** `browser_snapshot` — fix all broken selectors from this single snapshot
99
180
 
100
- **Never use `sungen makeauth`.** Never use `browser_evaluate` to inject cookies.
181
+ Never use `browser_evaluate` to inject or read cookies (misses httpOnly). For auth, use Phase 0.5 or `sungen makeauth`.
101
182
 
102
183
  ### Step 3: Fix Broken Selectors
103
184
 
@@ -181,9 +262,11 @@ user detail:
181
262
 
182
263
  | Phase | What runs | Max fix attempts | On failure after max |
183
264
  |---|---|---|---|
265
+ | 0. Pre-gen | Playwright MCP snapshot → write selectors.yaml | 1 snapshot | Ask user — skip or retry navigation |
266
+ | 0.5. Auth | Manual login in MCP browser → `browser_storage_state` → `specs/.auth/<role>.json` | 1 login | Ask user — retry login or fall back to `sungen makeauth` |
184
267
  | 1. Smoke | First 5 @critical/@high | 2 | Ask user — fundamentals broken |
185
268
  | 2. Priority | All @critical + @high | 2 | Report failures, continue to Phase 3 |
186
269
  | 3. Full | All tests | 1 | Report @low/@normal failures, continue |
187
270
  | 4. Regression | All tests | 0 | Report final results |
188
271
 
189
- **Total worst case: 5 fix attempts** (2+2+1), not unbounded loops.
272
+ **Total worst case: 5 fix attempts** (2+2+1), not unbounded loops. Phases 0 and 0.5 don't count toward fix budget.