@sun-asterisk/sungen 3.2.3 → 3.2.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 (184) hide show
  1. package/dist/cli/commands/dashboard.js +2 -2
  2. package/dist/cli/commands/dashboard.js.map +1 -1
  3. package/dist/cli/commands/delivery.d.ts.map +1 -1
  4. package/dist/cli/commands/delivery.js +22 -5
  5. package/dist/cli/commands/delivery.js.map +1 -1
  6. package/dist/cli/commands/feedback.d.ts +11 -0
  7. package/dist/cli/commands/feedback.d.ts.map +1 -1
  8. package/dist/cli/commands/feedback.js +154 -57
  9. package/dist/cli/commands/feedback.js.map +1 -1
  10. package/dist/cli/commands/login.d.ts +19 -0
  11. package/dist/cli/commands/login.d.ts.map +1 -0
  12. package/dist/cli/commands/login.js +76 -0
  13. package/dist/cli/commands/login.js.map +1 -0
  14. package/dist/cli/commands/qa-feedback.d.ts +14 -0
  15. package/dist/cli/commands/qa-feedback.d.ts.map +1 -0
  16. package/dist/cli/commands/qa-feedback.js +83 -0
  17. package/dist/cli/commands/qa-feedback.js.map +1 -0
  18. package/dist/cli/index.js +4 -0
  19. package/dist/cli/index.js.map +1 -1
  20. package/dist/dashboard/snapshot-builder.d.ts +3 -0
  21. package/dist/dashboard/snapshot-builder.d.ts.map +1 -1
  22. package/dist/dashboard/snapshot-builder.js +155 -52
  23. package/dist/dashboard/snapshot-builder.js.map +1 -1
  24. package/dist/dashboard/templates/index.html +23 -23
  25. package/dist/dashboard/types.d.ts +8 -0
  26. package/dist/dashboard/types.d.ts.map +1 -1
  27. package/dist/exporters/api-testcase-formatter.d.ts +55 -0
  28. package/dist/exporters/api-testcase-formatter.d.ts.map +1 -0
  29. package/dist/exporters/api-testcase-formatter.js +304 -0
  30. package/dist/exporters/api-testcase-formatter.js.map +1 -0
  31. package/dist/exporters/csv-exporter.d.ts +13 -1
  32. package/dist/exporters/csv-exporter.d.ts.map +1 -1
  33. package/dist/exporters/csv-exporter.js +35 -6
  34. package/dist/exporters/csv-exporter.js.map +1 -1
  35. package/dist/exporters/feature-parser.d.ts +4 -0
  36. package/dist/exporters/feature-parser.d.ts.map +1 -1
  37. package/dist/exporters/feature-parser.js +7 -2
  38. package/dist/exporters/feature-parser.js.map +1 -1
  39. package/dist/exporters/json-exporter.d.ts.map +1 -1
  40. package/dist/exporters/json-exporter.js +11 -3
  41. package/dist/exporters/json-exporter.js.map +1 -1
  42. package/dist/exporters/playwright-report-parser.d.ts +21 -2
  43. package/dist/exporters/playwright-report-parser.d.ts.map +1 -1
  44. package/dist/exporters/playwright-report-parser.js +52 -12
  45. package/dist/exporters/playwright-report-parser.js.map +1 -1
  46. package/dist/exporters/scenario-merger.d.ts.map +1 -1
  47. package/dist/exporters/scenario-merger.js +50 -2
  48. package/dist/exporters/scenario-merger.js.map +1 -1
  49. package/dist/exporters/spec-parser.js +1 -1
  50. package/dist/exporters/spec-parser.js.map +1 -1
  51. package/dist/exporters/test-data-resolver.d.ts +7 -0
  52. package/dist/exporters/test-data-resolver.d.ts.map +1 -1
  53. package/dist/exporters/test-data-resolver.js +13 -0
  54. package/dist/exporters/test-data-resolver.js.map +1 -1
  55. package/dist/exporters/types.d.ts +13 -0
  56. package/dist/exporters/types.d.ts.map +1 -1
  57. package/dist/exporters/xlsx-exporter.d.ts.map +1 -1
  58. package/dist/exporters/xlsx-exporter.js +131 -42
  59. package/dist/exporters/xlsx-exporter.js.map +1 -1
  60. package/dist/generators/gherkin-parser/index.d.ts +15 -0
  61. package/dist/generators/gherkin-parser/index.d.ts.map +1 -1
  62. package/dist/generators/gherkin-parser/index.js +33 -1
  63. package/dist/generators/gherkin-parser/index.js.map +1 -1
  64. package/dist/generators/test-generator/adapters/appium/templates/steps/actions/check-action.hbs +29 -8
  65. package/dist/generators/test-generator/adapters/appium/templates/steps/actions/scroll-action.hbs +21 -17
  66. package/dist/generators/test-generator/adapters/appium/templates/steps/actions/toggle-action.hbs +3 -0
  67. package/dist/generators/test-generator/adapters/appium/templates/steps/actions/uncheck-action.hbs +26 -6
  68. package/dist/generators/test-generator/adapters/appium/templates/steps/assertions/is-hidden-assertion.hbs +3 -1
  69. package/dist/generators/test-generator/adapters/appium/templates/steps/assertions/visible-assertion.hbs +14 -0
  70. package/dist/generators/test-generator/adapters/appium/templates/steps/gestures/tap-top-action.hbs +3 -0
  71. package/dist/generators/test-generator/adapters/appium/templates/steps/partials/locator.hbs +9 -2
  72. package/dist/generators/test-generator/adapters/appium/templates/test-file.hbs +115 -0
  73. package/dist/generators/test-generator/adapters/playwright/templates/steps/actions/table-action-in-row.hbs +1 -1
  74. package/dist/generators/test-generator/patterns/index.d.ts +12 -0
  75. package/dist/generators/test-generator/patterns/index.d.ts.map +1 -1
  76. package/dist/generators/test-generator/patterns/index.js +21 -1
  77. package/dist/generators/test-generator/patterns/index.js.map +1 -1
  78. package/dist/harness/script-check.d.ts.map +1 -1
  79. package/dist/harness/script-check.js +10 -5
  80. package/dist/harness/script-check.js.map +1 -1
  81. package/dist/orchestrator/ai-skills/writer.d.ts.map +1 -1
  82. package/dist/orchestrator/ai-skills/writer.js +46 -4
  83. package/dist/orchestrator/ai-skills/writer.js.map +1 -1
  84. package/dist/orchestrator/project-initializer.d.ts +14 -0
  85. package/dist/orchestrator/project-initializer.d.ts.map +1 -1
  86. package/dist/orchestrator/project-initializer.js +58 -0
  87. package/dist/orchestrator/project-initializer.js.map +1 -1
  88. package/dist/orchestrator/templates/ai-src/commands/add-flow.md +52 -5
  89. package/dist/orchestrator/templates/ai-src/commands/create-test.md +7 -0
  90. package/dist/orchestrator/templates/ai-src/commands/feedback.md +6 -6
  91. package/dist/orchestrator/templates/ai-src/commands/locale.md +26 -4
  92. package/dist/orchestrator/templates/ai-src/skills/sungen-delivery/SKILL.md +5 -4
  93. package/dist/orchestrator/templates/wdio.conf.ts +39 -3
  94. package/dist/tools/sungen-api/edit-in-editor.d.ts +15 -0
  95. package/dist/tools/sungen-api/edit-in-editor.d.ts.map +1 -0
  96. package/dist/tools/sungen-api/edit-in-editor.js +85 -0
  97. package/dist/tools/sungen-api/edit-in-editor.js.map +1 -0
  98. package/dist/tools/sungen-api/feedback-client.d.ts +24 -0
  99. package/dist/tools/sungen-api/feedback-client.d.ts.map +1 -0
  100. package/dist/tools/sungen-api/feedback-client.js +53 -0
  101. package/dist/tools/sungen-api/feedback-client.js.map +1 -0
  102. package/dist/tools/sungen-api/read-stdin.d.ts +6 -0
  103. package/dist/tools/sungen-api/read-stdin.d.ts.map +1 -0
  104. package/dist/tools/sungen-api/read-stdin.js +19 -0
  105. package/dist/tools/sungen-api/read-stdin.js.map +1 -0
  106. package/dist/tools/sungen-auth/api-base-url.d.ts +14 -0
  107. package/dist/tools/sungen-auth/api-base-url.d.ts.map +1 -0
  108. package/dist/tools/sungen-auth/api-base-url.js +28 -0
  109. package/dist/tools/sungen-auth/api-base-url.js.map +1 -0
  110. package/dist/tools/sungen-auth/credentials-store.d.ts +19 -0
  111. package/dist/tools/sungen-auth/credentials-store.d.ts.map +1 -0
  112. package/dist/tools/sungen-auth/credentials-store.js +94 -0
  113. package/dist/tools/sungen-auth/credentials-store.js.map +1 -0
  114. package/dist/tools/sungen-auth/login-flow.d.ts +33 -0
  115. package/dist/tools/sungen-auth/login-flow.d.ts.map +1 -0
  116. package/dist/tools/sungen-auth/login-flow.js +107 -0
  117. package/dist/tools/sungen-auth/login-flow.js.map +1 -0
  118. package/dist/tools/sungen-auth/loopback-server.d.ts +20 -0
  119. package/dist/tools/sungen-auth/loopback-server.d.ts.map +1 -0
  120. package/dist/tools/sungen-auth/loopback-server.js +132 -0
  121. package/dist/tools/sungen-auth/loopback-server.js.map +1 -0
  122. package/dist/tools/sungen-auth/open-browser.d.ts +10 -0
  123. package/dist/tools/sungen-auth/open-browser.d.ts.map +1 -0
  124. package/dist/tools/sungen-auth/open-browser.js +43 -0
  125. package/dist/tools/sungen-auth/open-browser.js.map +1 -0
  126. package/dist/tools/sungen-auth/pkce.d.ts +13 -0
  127. package/dist/tools/sungen-auth/pkce.d.ts.map +1 -0
  128. package/dist/tools/sungen-auth/pkce.js +27 -0
  129. package/dist/tools/sungen-auth/pkce.js.map +1 -0
  130. package/dist/tools/sungen-auth/sungen-auth-types.d.ts +41 -0
  131. package/dist/tools/sungen-auth/sungen-auth-types.d.ts.map +1 -0
  132. package/dist/tools/sungen-auth/sungen-auth-types.js +7 -0
  133. package/dist/tools/sungen-auth/sungen-auth-types.js.map +1 -0
  134. package/package.json +4 -3
  135. package/src/cli/commands/dashboard.ts +2 -2
  136. package/src/cli/commands/delivery.ts +24 -6
  137. package/src/cli/commands/feedback.ts +123 -51
  138. package/src/cli/commands/login.ts +75 -0
  139. package/src/cli/commands/qa-feedback.ts +77 -0
  140. package/src/cli/index.ts +4 -0
  141. package/src/dashboard/snapshot-builder.ts +146 -46
  142. package/src/dashboard/templates/index.html +23 -23
  143. package/src/dashboard/types.ts +10 -2
  144. package/src/exporters/api-testcase-formatter.ts +325 -0
  145. package/src/exporters/csv-exporter.ts +46 -7
  146. package/src/exporters/feature-parser.ts +7 -2
  147. package/src/exporters/json-exporter.ts +11 -3
  148. package/src/exporters/playwright-report-parser.ts +50 -11
  149. package/src/exporters/scenario-merger.ts +49 -3
  150. package/src/exporters/spec-parser.ts +1 -1
  151. package/src/exporters/test-data-resolver.ts +13 -0
  152. package/src/exporters/types.ts +13 -0
  153. package/src/exporters/xlsx-exporter.ts +155 -49
  154. package/src/generators/gherkin-parser/index.ts +44 -1
  155. package/src/generators/test-generator/adapters/appium/templates/steps/actions/check-action.hbs +29 -8
  156. package/src/generators/test-generator/adapters/appium/templates/steps/actions/scroll-action.hbs +21 -17
  157. package/src/generators/test-generator/adapters/appium/templates/steps/actions/toggle-action.hbs +3 -0
  158. package/src/generators/test-generator/adapters/appium/templates/steps/actions/uncheck-action.hbs +26 -6
  159. package/src/generators/test-generator/adapters/appium/templates/steps/assertions/is-hidden-assertion.hbs +3 -1
  160. package/src/generators/test-generator/adapters/appium/templates/steps/assertions/visible-assertion.hbs +14 -0
  161. package/src/generators/test-generator/adapters/appium/templates/steps/gestures/tap-top-action.hbs +3 -0
  162. package/src/generators/test-generator/adapters/appium/templates/steps/partials/locator.hbs +9 -2
  163. package/src/generators/test-generator/adapters/appium/templates/test-file.hbs +115 -0
  164. package/src/generators/test-generator/adapters/playwright/templates/steps/actions/table-action-in-row.hbs +1 -1
  165. package/src/generators/test-generator/patterns/index.ts +21 -1
  166. package/src/harness/script-check.ts +10 -5
  167. package/src/orchestrator/ai-skills/writer.ts +39 -4
  168. package/src/orchestrator/project-initializer.ts +59 -0
  169. package/src/orchestrator/templates/ai-src/commands/add-flow.md +52 -5
  170. package/src/orchestrator/templates/ai-src/commands/create-test.md +7 -0
  171. package/src/orchestrator/templates/ai-src/commands/feedback.md +6 -6
  172. package/src/orchestrator/templates/ai-src/commands/locale.md +26 -4
  173. package/src/orchestrator/templates/ai-src/skills/sungen-delivery/SKILL.md +5 -4
  174. package/src/orchestrator/templates/wdio.conf.ts +39 -3
  175. package/src/tools/sungen-api/edit-in-editor.ts +48 -0
  176. package/src/tools/sungen-api/feedback-client.ts +62 -0
  177. package/src/tools/sungen-api/read-stdin.ts +15 -0
  178. package/src/tools/sungen-auth/api-base-url.ts +23 -0
  179. package/src/tools/sungen-auth/credentials-store.ts +57 -0
  180. package/src/tools/sungen-auth/login-flow.ts +135 -0
  181. package/src/tools/sungen-auth/loopback-server.ts +113 -0
  182. package/src/tools/sungen-auth/open-browser.ts +42 -0
  183. package/src/tools/sungen-auth/pkce.ts +27 -0
  184. package/src/tools/sungen-auth/sungen-auth-types.ts +45 -0
@@ -4,5 +4,12 @@
4
4
  YAML) is the fallback parent. Note: a child xpath beginning with `//` is ABSOLUTE in Appium even
5
5
  when chained — use accessibility-id / -android uiautomator children for true scoping, or `.//`.
6
6
  The selector argument comes from appium-selector-expr (it carries its OWN quotes, or a per-platform
7
- `driver.isIOS ? … : …` ternary), so it is NOT wrapped in quotes here. --}}
8
- {{~#if parentLocator~}}{{parentLocator}}.{{#if nth}}$$({{> appium-selector-expr}})[{{nth}}]{{else}}$({{> appium-selector-expr}}){{/if}}{{~else~}}{{#if scope}}$('~{{escapeQuotes scope}}').{{#if nth}}$$({{> appium-selector-expr}})[{{nth}}]{{else}}$({{> appium-selector-expr}}){{/if}}{{else}}{{#if nth}}$$({{> appium-selector-expr}})[{{nth}}]{{else}}$({{> appium-selector-expr}}){{/if}}{{/if}}{{~/if~}}
7
+ `driver.isIOS ? … : …` ternary), so it is NOT wrapped in quotes here.
8
+ Simple case (no parent/scope/nth) resolves via `__ensureVisible(...)` Playwright-style implicit
9
+ scroll-into-view, so a below-fold / nav-occluded element is scrolled into the safe band before any
10
+ find/tap/assert (Appium has no auto-scroll). Parent/scope/nth chains keep the plain `$()` — those
11
+ resolve within a container / by index where a blind scroll doesn't apply.
12
+ `plain=true` (passed by is-hidden-assertion) also forces the bare `$()`: an element asserted HIDDEN
13
+ is expected to be absent, so scroll-hunting for it is both pointless and harmful — the 12x down-scroll
14
+ would drag the screen to the bottom and strand later same-scenario steps that sit above. --}}
15
+ {{~#if parentLocator~}}{{parentLocator}}.{{#if nth}}$$({{> appium-selector-expr}})[{{nth}}]{{else}}$({{> appium-selector-expr}}){{/if}}{{~else~}}{{#if scope}}$('~{{escapeQuotes scope}}').{{#if nth}}$$({{> appium-selector-expr}})[{{nth}}]{{else}}$({{> appium-selector-expr}}){{/if}}{{else}}{{#if nth}}$$({{> appium-selector-expr}})[{{nth}}]{{else}}{{#if plain}}$({{> appium-selector-expr}}){{else}}(await __ensureVisible({{> appium-selector-expr}})){{/if}}{{/if}}{{/if}}{{~/if~}}
@@ -5,6 +5,117 @@
5
5
 
6
6
  const testData = TestDataLoader.load('{{screenName}}', '{{featureFileName}}');
7
7
  {{/if}}
8
+
9
+ // Auto scroll-into-view before EVERY element access — the mobile analogue of Playwright's implicit
10
+ // scrollIntoView (Appium/WDIO has none). Fixes two Flutter/native failure modes at once:
11
+ // (A) lazy-render / zero-rect: an item below the fold is NOT usable (absent from the Android a11y
12
+ // tree; present-but-0x0 on iOS), so find/tap/assert fail even though scrolling would reveal it;
13
+ // (B) floating bottom-nav occlusion (Android): a row near the fold is "displayed" but its tap point
14
+ // sits behind the nav bar, so a coordinate tap misses.
15
+ // Already-visible elements return immediately (no scroll, no cost). Returns $(selector) even when
16
+ // never found so the caller's own step surfaces the real failure. The `selector` is re-queried each
17
+ // iteration (post-scroll elements go stale). The readiness gate and gesture differ per OS — each
18
+ // runtime lies differently (see the per-branch notes below).
19
+ //
20
+ // Android gates on isDisplayed() (reliable on UiAutomator2) + rect clearing the 0.82·H nav band,
21
+ // and scrolls with mobile: scrollGesture — NOT UiScrollable, which no-ops on Flutter (no native
22
+ // ScrollView).
23
+ //
24
+ // iOS gates on GEOMETRY, and scrolls with small drags. XCUITest reports a below-fold Flutter
25
+ // element as rect 0x0 + displayed:false while keeping it in the tree, and isDisplayed() also
26
+ // false-negatives on genuinely visible elements (snapshot artifact) — so visibility booleans are
27
+ // unusable as a scroll gate on iOS. An element is "usable" iff its rect is REAL (width/height > 0)
28
+ // with the top edge on screen; the width/height check is essential — a 0x0 rect has y=0, which a
29
+ // naive `y >= 0` gate mistakes for "at the top of the screen" (that exact bug shipped once: it
30
+ // skipped the scroll AND returned a stale 0x0 handle whose click went nowhere). Scrolling uses
31
+ // `mobile: scroll {direction}` — native XCTest paged scroll, the only primitive that worked in a
32
+ // live probe matrix on Flutter: `mobile: scroll {toVisible}` throws (WDA needs a scrollable
33
+ // ancestor with visible children, but Flutter exposes content as SIBLINGS of the ScrollView),
34
+ // `mobile: swipe` flings with momentum past the target, and dragFromToForDuration / W3C pointer
35
+ // drags corrupt the a11y tree (targets vanish from it entirely).
36
+ async function __ensureVisible(selector: string): Promise<WebdriverIO.Element> {
37
+ let winH = 2000;
38
+ try { const s = await driver.getWindowSize(); winH = s.height; } catch { /* keep default */ }
39
+ if (driver.isIOS) {
40
+ // Phase 1 — wait for the element to ENTER the tree WITHOUT gesturing. Right after the
41
+ // relaunch-per-scenario beforeEach nothing is rendered yet, and dragging a still-launching
42
+ // app makes XCUITest block on quiescence per gesture — enough to blow the mocha hook
43
+ // timeout (seen live). A below-fold Flutter element is IN the tree from the start (just
44
+ // 0x0), so in the genuine scroll case this wait returns instantly.
45
+ try { await (await $(selector)).waitForExist({ timeout: 15000 }); } catch { /* virtualized far item or missing → still try scrolling below */ }
46
+ for (let __i = 0; __i < 8; __i++) {
47
+ let existed = false;
48
+ try {
49
+ const el = await $(selector);
50
+ if (await el.isExisting()) {
51
+ existed = true;
52
+ const r = await driver.getElementRect(el.elementId);
53
+ if (r.width > 0 && r.height > 0 && r.y >= 0 && r.y < winH) return el; // real rect, on screen → usable
54
+ }
55
+ } catch { /* not in the tree yet → keep scrolling */ }
56
+ // Render grace — do NOT scroll on the first two passes when the element is in the tree but
57
+ // still 0x0: right after a relaunch Flutter briefly reports even TOP-OF-SCREEN elements as
58
+ // 0x0 while it renders, and a paged scroll fired in that window scrolls them clean off the
59
+ // top, where a down-only loop can never recover them (seen live as a random ~2-cases-per-run
60
+ // flake: "APP PREFERENCES rect 0x0"). A genuinely below-fold element just costs ~1s extra.
61
+ if (existed && __i < 2) { await driver.pause(500); continue; }
62
+ // `mobile: scroll {direction}` = native XCTest paged scroll — the ONLY primitive that moves
63
+ // this Flutter list deterministically (probed live): `mobile: swipe` flings past the target
64
+ // (momentum), and dragFromToForDuration / W3C pointer drags corrupt the a11y tree (targets
65
+ // vanish entirely). The page step is ~0.9 viewport with built-in overlap, so a below-fold
66
+ // element can never be jumped over — it lands near the top of the next page.
67
+ await driver.execute('mobile: scroll', { direction: 'down' })
68
+ .catch(() => driver.execute('mobile: swipe', { direction: 'up' }));
69
+ await driver.pause(400); // settle: let Flutter render the newly-exposed band
70
+ }
71
+ return $(selector);
72
+ }
73
+ const safeBottom = Math.round(winH * 0.82); // above the floating bottom-nav band
74
+ let lastY: number | null = null;
75
+ for (let __i = 0; __i < 12; __i++) {
76
+ let y: number | null = null;
77
+ try {
78
+ const el = await $(selector);
79
+ if (await el.isDisplayed()) {
80
+ const r = await driver.getElementRect(el.elementId);
81
+ if (r.y + r.height <= safeBottom) return el; // rendered AND fully above the floating bottom nav → done
82
+ y = r.y;
83
+ }
84
+ } catch { /* off-screen / not in tree yet → keep scrolling */ }
85
+ // No-progress break: the element is on screen but a prior scroll didn't move it — it's a FIXED
86
+ // element (e.g. a bottom-nav tab, intentionally in the nav band) or we've hit the end of the
87
+ // scrollable. Stop rather than burn the whole budget; the caller acts on it where it is.
88
+ if (y !== null && lastY !== null && Math.abs(y - lastY) < 2) return $(selector);
89
+ lastY = y;
90
+ await driver.execute('mobile: scrollGesture', { left: 60, top: 420, width: 960, height: 1320, direction: 'down', percent: 0.5 });
91
+ await driver.pause(300);
92
+ }
93
+ return $(selector);
94
+ }
95
+
96
+ // Visibility oracle for simple-case `see [X]` assertions. Android: WDIO's toBeDisplayed()
97
+ // (reliable on UiAutomator2). iOS: XCUITest's `visible` attribute false-negatives on real,
98
+ // on-screen elements (snapshot artifact — seen live even on a screen title every prior run
99
+ // passed), so assert GEOMETRY instead: after __ensureVisible has scrolled the target toward
100
+ // view, the element must exist with a real rect (w,h > 0) whose top edge is on screen. On
101
+ // Flutter an off-screen element keeps a 0x0 rect, so this is exactly the "user can see it"
102
+ // boundary. Re-queries fresh + retries briefly to absorb render lag.
103
+ async function __assertVisible(selector: string): Promise<void> {
104
+ const el = await __ensureVisible(selector);
105
+ if (!driver.isIOS) { await expect(el).toBeDisplayed(); return; }
106
+ let winH = 2000;
107
+ try { const s = await driver.getWindowSize(); winH = s.height; } catch { /* keep default */ }
108
+ let r = { x: 0, y: 0, width: 0, height: 0 };
109
+ for (let __i = 0; __i < 3; __i++) {
110
+ try {
111
+ const e2 = await $(selector);
112
+ if (await e2.isExisting()) r = await driver.getElementRect(e2.elementId);
113
+ } catch { /* not in the tree */ }
114
+ if (r.width > 0 && r.height > 0 && r.y >= 0 && r.y < winH) return;
115
+ await driver.pause(500);
116
+ }
117
+ throw new Error(`Expect ${JSON.stringify(selector)} to be displayed — iOS geometry oracle: rect=${JSON.stringify(r)} is not on screen (0x0 = not rendered / scrolled out)`);
118
+ }
8
119
  {{#if singleAuthRole}}
9
120
  import * as fs from 'node:fs';
10
121
  import * as path from 'node:path';
@@ -151,6 +262,10 @@ describe('{{featureName}}', () => {
151
262
  beforeEach(async () => {
152
263
  const __APP_PKG__ = __resolveAppId();
153
264
  try { await driver.terminateApp(__APP_PKG__); } catch { /* app may not be running yet */ }
265
+ // Let the termination fully land before relaunching — activateApp racing a still-dying
266
+ // process can RESUME the old instance (prior scenario's scroll position and all) instead
267
+ // of cold-starting, which strands top-of-screen elements above the viewport.
268
+ await driver.pause(500);
154
269
  await driver.activateApp(__APP_PKG__);
155
270
  // Restore portrait so a prior scenario's `rotate to landscape` can't leak into this one — the
156
271
  // app relaunch above resets in-app state, but device orientation is OS-level and persists.
@@ -1,2 +1,2 @@
1
1
  { const tableRow = {{> locator}}.getByRole('row').filter({ hasText: '{{escapeQuotes filterValue}}' });
2
- await tableRow.getByRole('{{elementRole}}', { name: '{{escapeQuotes elementName}}' }).{{action}}(); }
2
+ await {{{actionLocator}}}.{{action}}(); }
@@ -4,6 +4,23 @@ import { StepPattern, PatternContext } from './types';
4
4
  import { capabilityRegistry } from '../../../capabilities/registry';
5
5
  import { discoverAndRegisterCapabilities } from '../../../capabilities/discover';
6
6
 
7
+ /**
8
+ * Mask the CONTENT of selector refs `[...]` and data placeholders `{{...}}` before verb matching,
9
+ * keeping the delimiters. A step's verb/keywords come from the SENTENCE — never from a selector or
10
+ * variable NAME — but matchers scan `step.text` with substring checks (e.g. `includes('click')`),
11
+ * so a data ref like `{{double_click_guard_account.email}}` would spuriously satisfy the click
12
+ * matcher and pre-empt fill. The content is replaced with an inert placeholder (`~` — carries no
13
+ * verb/keyword/digit substring) rather than emptied, so structural matchers that require a NON-EMPTY
14
+ * ref survive too — e.g. `expect {{a}} is {{b}}` matches `\{\{[^}]+\}\}`, and `in [X] table` /
15
+ * `/\bto\s+\[/` keep their delimiters. The resolver/generator always receives the ORIGINAL step, so
16
+ * value extraction and codegen are unaffected.
17
+ */
18
+ export function maskRefsForMatching(text: string): string {
19
+ return text
20
+ .replace(/\{\{[^}]*\}\}/g, '{{~}}')
21
+ .replace(/\[[^\]]*\]/g, '[~]');
22
+ }
23
+
7
24
  /**
8
25
  * Pattern Registry - manages all step patterns
9
26
  */
@@ -40,8 +57,11 @@ export class PatternRegistry {
40
57
  * Find matching pattern for a step
41
58
  */
42
59
  findPattern(step: ParsedStep): StepPattern | null {
60
+ // Match against text with ref CONTENTS masked, so a verb substring inside a selector/data name
61
+ // (e.g. "click" in `{{double_click_guard_account.email}}`) can't hijack the verb classification.
62
+ const matchStep: ParsedStep = { ...step, text: maskRefsForMatching(step.text) };
43
63
  for (const pattern of this.patterns) {
44
- if (this.matchesPattern(step, pattern.matcher)) {
64
+ if (this.matchesPattern(matchStep, pattern.matcher)) {
45
65
  return pattern;
46
66
  }
47
67
  }
@@ -92,10 +92,11 @@ export function analyzeFaithfulness(specSrc: string, automatedTitles: Set<string
92
92
  }
93
93
 
94
94
  function extractTestTitles(specSrc: string): string[] {
95
- // Count real test cases only: test(...), test.only/.skip/.fixme(...).
96
- // Exclude test.describe / test.beforeAll / hooks (not test cases).
95
+ // Count real test cases only. Web/Playwright specs use test(...) (+ .only/.skip/.fixme);
96
+ // mobile/Appium specs use mocha it(...) (#429 — matching only test() reported EVERY mobile
97
+ // scenario as MISSING). Exclude describe / hooks (not test cases).
97
98
  const titles: string[] = [];
98
- const re = /\btest(?:\.(?:only|skip|fixme))?\(\s*(['"`])([^'"`]+)\1/g;
99
+ const re = /\b(?:test|it)(?:\.(?:only|skip|fixme))?\(\s*(['"`])([^'"`]+)\1/g;
99
100
  let m: RegExpExecArray | null;
100
101
  while ((m = re.exec(specSrc))) titles.push(m[2].trim());
101
102
  return titles;
@@ -183,9 +184,13 @@ export async function runScriptCheck(screenDir: string, screenName: string, kind
183
184
  const qaSourceDir = path.join(process.cwd(), 'qa', kind === 'flow' ? 'flows' : kind === 'api' ? 'api' : 'screens');
184
185
  // api units derive their unit id (api/<area>) from the feature path — like `generate --api`;
185
186
  // screen/flow pass screenName + flowMode explicitly (unchanged → byte-identical regenerate).
187
+ // Regenerate with the SAME framework the committed spec was compiled with — a mobile spec
188
+ // (imports '@wdio/globals') was generated by the appium adapter; regenerating it with the
189
+ // playwright adapter guaranteed a false DRIFT on every mobile screen (#429).
190
+ const framework = specSrc.includes('@wdio/globals') ? 'appium' : 'playwright';
186
191
  const gen = kind === 'api'
187
- ? new CodeGenerator({ framework: 'playwright', runtimeData: true })
188
- : new CodeGenerator({ framework: 'playwright', screenName, runtimeData: true, flowMode: kind === 'flow' });
192
+ ? new CodeGenerator({ framework, runtimeData: true })
193
+ : new CodeGenerator({ framework, screenName, runtimeData: true, flowMode: kind === 'flow' });
189
194
  await gen.generateAllTests(qaSourceDir, tmp, [featurePath]);
190
195
  const fresh = findSpec(tmp, screenName, kind);
191
196
  if (fresh) {
@@ -3,8 +3,9 @@
3
3
  *
4
4
  * managed (skills/commands): ALWAYS overwritten (version-managed, no rollback)
5
5
  * config (CLAUDE.md/AGENTS.md/copilot-instructions): skip-if-exists unless `force`
6
- * orphans: managed files written last run but not this run are DELETED (manifest-derived,
7
- * replaces the hand-curated STALE list decision T2)
6
+ * orphans: managed files written last run but not this run are DELETED — but ONLY within the
7
+ * assistants built THIS run (scoped by namespace), so building one assistant never wipes
8
+ * another's files (manifest-derived; replaces the hand-curated STALE list — decision T2)
8
9
  * detect-and-warn: if a managed file on disk was hand-edited since we wrote it, warn
9
10
  * dry-run: report adds/overwrites/skips/deletes/warnings without touching disk
10
11
  *
@@ -14,6 +15,7 @@ import * as fs from 'fs';
14
15
  import * as path from 'path';
15
16
  import * as crypto from 'crypto';
16
17
  import { BuiltFile } from './build';
18
+ import { AdapterKey } from './adapters';
17
19
 
18
20
  export interface ApplyOptions { force?: boolean; dryRun?: boolean; version: string }
19
21
  export interface ApplyReport {
@@ -26,6 +28,20 @@ const sha = (s: string) => crypto.createHash('sha256').update(s).digest('hex');
26
28
 
27
29
  interface Manifest { version: string; managed: Record<string, string> }
28
30
 
31
+ /**
32
+ * Which assistant a managed/config output path belongs to, by namespace prefix. Scopes orphan
33
+ * cleanup + manifest retention to the assistants built THIS run, so `sungen init --assistant codex`
34
+ * never deletes a previously-installed `.claude/` (and vice versa). Returns null for a path we
35
+ * can't attribute — treated as out-of-scope, so it is never auto-deleted.
36
+ */
37
+ function adapterOf(relPath: string): AdapterKey | null {
38
+ const p = relPath.replace(/\\/g, '/');
39
+ if (p === 'CLAUDE.md' || p.startsWith('.claude/')) return 'claude';
40
+ if (p === 'AGENTS.md' || p.startsWith('.agents/')) return 'codex';
41
+ if (p === '.github/copilot-instructions.md' || p.startsWith('.github/')) return 'copilot';
42
+ return null;
43
+ }
44
+
29
45
  function readManifest(cwd: string): Manifest {
30
46
  const p = path.join(cwd, MANIFEST_REL);
31
47
  if (!fs.existsSync(p)) return { version: '', managed: {} };
@@ -70,9 +86,19 @@ export function applyOutputs(cwd: string, outputs: BuiltFile[], opts: ApplyOptio
70
86
  newManaged[f.outputPath] = sha(f.content);
71
87
  }
72
88
 
73
- // Orphan cleanup: managed files we wrote last time but not now.
89
+ // Assistants this run actually produced output for. Orphan cleanup is scoped to THESE namespaces
90
+ // only — a path belonging to an assistant we did NOT build this run (e.g. `.claude/*` while running
91
+ // `--assistant codex`) is not ours to touch, so init/update is ADDITIVE across assistants instead
92
+ // of wiping the previously-installed one.
93
+ const scoped = new Set<AdapterKey>();
94
+ for (const f of outputs) { const a = adapterOf(f.outputPath); if (a) scoped.add(a); }
95
+ const inScope = (p: string): boolean => { const a = adapterOf(p); return a !== null && scoped.has(a); };
96
+
97
+ // Orphan cleanup: managed files we wrote last time but not now — but ONLY within the assistants
98
+ // built this run. Other assistants' managed files are preserved (this is the cross-assistant fix).
74
99
  for (const oldPath of Object.keys(prev.managed)) {
75
100
  if (newManaged[oldPath]) continue;
101
+ if (!inScope(oldPath)) continue; // belongs to an assistant not built this run → keep it
76
102
  r.deletedOrphans.push(oldPath);
77
103
  if (!opts.dryRun) {
78
104
  const abs = path.join(cwd, oldPath);
@@ -84,9 +110,18 @@ export function applyOutputs(cwd: string, outputs: BuiltFile[], opts: ApplyOptio
84
110
  }
85
111
 
86
112
  if (!opts.dryRun) {
113
+ // Retain manifest entries for assistants NOT built this run so their files stay tracked (and get
114
+ // orphan-cleaned correctly on a later run that DOES target them); merge this run's entries on top.
115
+ const mergedManaged: Record<string, string> = {};
116
+ for (const [p, h] of Object.entries(prev.managed)) {
117
+ if (newManaged[p]) continue; // rewritten this run → newManaged carries the fresh hash
118
+ if (inScope(p)) continue; // orphan within a built assistant → dropped (deleted above)
119
+ mergedManaged[p] = h; // other assistant (or unclassified) → keep tracking
120
+ }
121
+ Object.assign(mergedManaged, newManaged);
87
122
  const mPath = path.join(cwd, MANIFEST_REL);
88
123
  fs.mkdirSync(path.dirname(mPath), { recursive: true });
89
- fs.writeFileSync(mPath, JSON.stringify({ version: opts.version, managed: newManaged }, null, 2));
124
+ fs.writeFileSync(mPath, JSON.stringify({ version: opts.version, managed: mergedManaged }, null, 2));
90
125
  }
91
126
  return r;
92
127
  }
@@ -23,6 +23,37 @@ function sungenVersion(): string {
23
23
  catch { return '0.0.0'; }
24
24
  }
25
25
 
26
+ /**
27
+ * Header written atop a NEW `.codex/config.toml`. Codex loads a PROJECT-scoped config.toml only
28
+ * for TRUSTED projects — without trust the MCP server silently never loads — so the note tells the
29
+ * user how to enable it. (Claude reads `.mcp.json` and Copilot `.vscode/mcp.json` with no such gate.)
30
+ */
31
+ const CODEX_MCP_HEADER = [
32
+ '# Sungen — Codex MCP config (project-scoped, gives run-test the same live browser as Claude/Copilot).',
33
+ '# NOTE: Codex loads a project .codex/config.toml ONLY for TRUSTED projects. If the browser tools',
34
+ '# never appear, trust this project (open it with `codex` and approve, or set trust_level = "trusted"',
35
+ '# for this path in ~/.codex/config.toml). To add Figma too, see https://mcp.figma.com/mcp.',
36
+ '',
37
+ '',
38
+ ].join('\n');
39
+
40
+ /**
41
+ * Append-if-absent merge for Codex's TOML MCP config. Mirrors `mergeMCPConfig`'s "user edits win"
42
+ * contract: preserves the existing file and any user-defined `[mcp_servers.*]`, and only appends the
43
+ * sungen server table when it is missing. Returns `null` when the target server is already present
44
+ * (nothing to write). TOML by hand (no toml dep) — the block is a fixed, simple table.
45
+ */
46
+ export function mergeCodexMcpToml(existing: string, mobileOnly: boolean): string | null {
47
+ const serverKey = mobileOnly ? 'appium-mcp' : 'playwright';
48
+ // Already configured (by the user or a previous run) → preserve, do nothing.
49
+ if (new RegExp(String.raw`^\s*\[mcp_servers\.(?:"?${serverKey}"?)\]`, 'm').test(existing)) return null;
50
+ const block = mobileOnly
51
+ ? '[mcp_servers.appium-mcp]\ncommand = "npx"\nargs = ["-y", "appium-mcp"]\n'
52
+ : '[mcp_servers.playwright]\ncommand = "npx"\nargs = ["@playwright/mcp@latest"]\n';
53
+ if (existing.trim() === '') return CODEX_MCP_HEADER + block;
54
+ return existing + (existing.endsWith('\n') ? '\n' : '\n\n') + block;
55
+ }
56
+
26
57
  export class ProjectInitializer {
27
58
  private baseCwd: string;
28
59
  private cwd: string;
@@ -116,6 +147,12 @@ export class ProjectInitializer {
116
147
  // Create root .mcp.json for Claude Code
117
148
  this.createClaudeMCPConfig();
118
149
 
150
+ // Create .codex/config.toml for Codex CLI — only when Codex is a selected assistant
151
+ // (`sungen init --assistant codex`), since it is Codex-specific config.
152
+ if (this.agents.includes('codex')) {
153
+ this.createCodexMCPConfig();
154
+ }
155
+
119
156
  // Display summary
120
157
  this.displaySummary(normalizedProjectName);
121
158
  }
@@ -309,6 +346,28 @@ export class ProjectInitializer {
309
346
  );
310
347
  }
311
348
 
349
+ /**
350
+ * Create `.codex/config.toml` for Codex CLI — the Codex analog of `.mcp.json` (Claude) and
351
+ * `.vscode/mcp.json` (Copilot), so `sungen run-test` under Codex drives the same live Playwright
352
+ * MCP browser instead of Codex's own (headless) fallback. Mobile-only → appium-mcp. Append-only:
353
+ * preserves an existing file + any user server table (via `mergeCodexMcpToml`).
354
+ */
355
+ private createCodexMCPConfig(): void {
356
+ const filePath = path.join(this.cwd, '.codex', 'config.toml');
357
+ const dir = path.dirname(filePath);
358
+ if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
359
+
360
+ const existed = fs.existsSync(filePath);
361
+ const existing = existed ? fs.readFileSync(filePath, 'utf-8') : '';
362
+ const merged = mergeCodexMcpToml(existing, this.mobileOnly);
363
+ if (merged === null) {
364
+ this.skippedItems.push('.codex/config.toml');
365
+ return;
366
+ }
367
+ fs.writeFileSync(filePath, merged, 'utf-8');
368
+ this.createdItems.push(existed ? '.codex/config.toml (updated)' : '.codex/config.toml');
369
+ }
370
+
312
371
  /**
313
372
  * Add MCP server entries without overwriting user config.
314
373
  * Preserves existing entries with the same key — user edits always win.
@@ -1,9 +1,9 @@
1
1
  ---
2
2
  name: add-flow
3
3
  description: "Add a new Sungen flow — scaffolds directories for E2E cross-screen testing, helps fill spec.md, and can capture visuals via the capture skills"
4
- argument-hint: [flow-name] [--path <start-url>]
4
+ argument-hint: "[flow-name] [--path <start-url>] [--reach <steps>]"
5
5
  order: 10
6
- claude-tools: "Read, Grep, Bash, Glob, Edit, Write, AskUserQuestion, mcp__playwright__browser_navigate, mcp__playwright__browser_take_screenshot, mcp__playwright__browser_snapshot, mcp__figma__get_design_context, mcp__figma__get_variable_defs, mcp__figma__get_screenshot"
6
+ claude-tools: "Read, Grep, Bash, Glob, Edit, Write, AskUserQuestion, mcp__playwright__browser_navigate, mcp__playwright__browser_take_screenshot, mcp__playwright__browser_snapshot, mcp__figma__get_design_context, mcp__figma__get_variable_defs, mcp__figma__get_screenshot, mcp__appium-mcp__select_device, mcp__appium-mcp__appium_session_management, mcp__appium-mcp__generate_locators, mcp__appium-mcp__appium_get_page_source, mcp__appium-mcp__appium_find_element, mcp__appium-mcp__appium_gesture, mcp__appium-mcp__appium_screenshot"
7
7
  copilot-tools: "[vscode, execute, read, agent, edit, search, todo]"
8
8
  codex-trigger: "Run when the user asks to add a NEW cross-screen end-to-end flow. Step 1 (flow variant). Do NOT use for a single screen, creating test cases, or running tests."
9
9
  ---
@@ -13,6 +13,13 @@ codex-trigger: "Run when the user asks to add a NEW cross-screen end-to-end flow
13
13
  {{/cap}}
14
14
  You are adding a new Sungen flow for E2E cross-screen test generation.
15
15
 
16
+ ## Platform detection (do this FIRST)
17
+
18
+ Read `qa/capabilities.yaml` and check the `platform` field.
19
+
20
+ - If `platform: mobile` → follow the **mobile path** in each step below.
21
+ - If `platform: web` or field absent → follow the **web path** (all steps unchanged).
22
+
16
23
  ## Parameters
17
24
 
18
25
  {{#cap parallel-subagents}}
@@ -22,12 +29,13 @@ Parse from `$ARGUMENTS`:
22
29
  {{^cap parallel-subagents}}
23
30
  - **flow** — ${input:flow:flow name (e.g., award-submission, user-onboarding)}
24
31
  {{/cap}}
25
- - **--path \<url\>** — starting page URL path (default: `/login`)
32
+ - **--path \<url\>** — starting page URL path for web (default: `/login`). Not used on mobile.
33
+ - **--reach \<steps\>** — (mobile only) navigation recipe for the flow's first screen: a `>`-separated list of nav steps from app launch, e.g. `"tap [My Page] tab > tap [Settings] row"`. Scaffolded into the `Background:`. Ignored (with a warning) on web projects.
26
34
  - **--description \<text\>** — flow description (optional)
27
35
 
28
36
  {{#cap parallel-subagents}}
29
37
  If **flow** is missing, ask: "What is the flow name? (e.g., `award-submission`, `user-onboarding`)"
30
- If **path** is missing, ask: "What is the starting URL path? (e.g., `/login`)"
38
+ If **path** is missing (web) or **--reach** is missing (mobile), ask for it accordingly — e.g. "What is the starting URL path? (e.g., `/login`)" for web, or "How do you reach the first screen from app launch? (e.g., `tap [My Page] tab > tap [Settings] row`)" for mobile.
31
39
 
32
40
  {{/cap}}
33
41
  ## Steps
@@ -37,6 +45,7 @@ If **path** is missing, ask: "What is the starting URL path? (e.g., `/login`)"
37
45
  {{^cap parallel-subagents}}
38
46
  Run with #tool:terminal:
39
47
  {{/cap}}
48
+ **Web:**
40
49
  ```bash
41
50
  {{#cap parallel-subagents}}
42
51
  sungen add-flow --flow <name> --path <path>
@@ -46,6 +55,18 @@ sungen add-flow --flow ${input:flow} --path ${input:path}
46
55
  {{/cap}}
47
56
  ```
48
57
 
58
+ **Mobile** (`platform: mobile` in `qa/capabilities.yaml`):
59
+ ```bash
60
+ {{#cap parallel-subagents}}
61
+ sungen add-flow --flow <name> [--reach "tap [My Page] tab > tap [Settings] row"]
62
+ # Directories are always qa/flows/<name>/ — there is no qa/mobile/ tree.
63
+ {{/cap}}
64
+ {{^cap parallel-subagents}}
65
+ sungen add-flow --flow ${input:flow} [--reach "tap [My Page] tab > tap [Settings] row"]
66
+ # Directories are always qa/flows/${input:flow}/ — there is no qa/mobile/ tree.
67
+ {{/cap}}
68
+ ```
69
+
49
70
  This creates:
50
71
  ```
51
72
  {{#cap parallel-subagents}}
@@ -76,6 +97,26 @@ Record the screen list — you will need it for:
76
97
 
77
98
  ### 2. Capture visual source
78
99
 
100
+ **Mobile path** (`platform: mobile`):
101
+
102
+ {{#cap parallel-subagents}}
103
+ Use `AskUserQuestion`: *"Capture a live screen via Appium MCP now?"*
104
+ {{/cap}}
105
+ {{^cap parallel-subagents}}
106
+ Ask: *"Capture a live screen via Appium MCP now?"*
107
+ {{/cap}}
108
+ - **Yes, capture now** (Recommended) — invoke the `sungen-capture-mobile` skill (Appium MCP) for the first screen of the flow. It replays the `--reach` nav recipe from the `Background:`, scans the locator tree, and saves a screenshot to `requirements/ui/`. Repeat for each screen in the flow as needed.
109
+ {{#cap parallel-subagents}}
110
+ - **Skip** — user will capture later via `/sungen:run-test` or manually.
111
+ {{/cap}}
112
+ {{^cap parallel-subagents}}
113
+ - **Skip** — user will capture later via `/sungen-run-test` or manually.
114
+ {{/cap}}
115
+
116
+ Do NOT invoke `sungen-capture` (web/Figma) for a mobile project — use `sungen-capture-mobile` only.
117
+
118
+ **Web path:**
119
+
79
120
  {{#cap parallel-subagents}}
80
121
  Use `AskUserQuestion`: *"Pick a visual source for this flow's screens:"*
81
122
  {{/cap}}
@@ -145,5 +186,11 @@ If user picks `/sungen:create-test`, **you MUST use the Skill tool** to invoke i
145
186
  - YAML keys must be **quoted** due to colon: `"login:submit":`
146
187
  - Test data namespaced by phase: `login.email`, `submission.nominee`
147
188
  - `@flow` tag required at feature level
148
- - `Background:` should only contain the starting page navigation
189
+ - `Background:` should only contain the starting navigation — the URL path (web) or the `--reach` nav recipe (mobile)
149
190
  - Each scenario = one phase of the journey
191
+ {{#cap parallel-subagents}}
192
+ - Mobile flows are tagged `@platform:mobile` and run via `/sungen:run-test <flow>` (WebdriverIO, not Playwright)
193
+ {{/cap}}
194
+ {{^cap parallel-subagents}}
195
+ - Mobile flows are tagged `@platform:mobile` and run via `/sungen-run-test <flow>` (WebdriverIO, not Playwright)
196
+ {{/cap}}
@@ -20,6 +20,13 @@ If `spec_figma.md` exists OR the user provides a Figma URL for the PAT flow:
20
20
  **Input**: Screen or flow name (e.g., `/sungen-create-test admin-users`).
21
21
  {{/cap}}
22
22
 
23
+ ## Platform detection (do this FIRST)
24
+
25
+ Read `qa/capabilities.yaml` and check the `platform` field.
26
+
27
+ - If `platform: mobile` → the visual-capture step (Step 3, "Auto-detect visual source") uses the **`sungen-capture-mobile`** skill (Appium MCP live capture) **instead of** the web `sungen-capture` (figma/live). Scenarios use mobile gesture vocabulary from `sungen-mobile-gestures` (tap, swipe, long-press — not click/hover) and `accessibility-id`-first selectors; mobile-specific steps (permission dialogs, clipboard, geolocation) are valid Gherkin, not errors. The `Background:` is a **navigation recipe** (see `add-screen --reach`), not a URL path. Everything else — viewpoints, `sungen-tc-generation`, the harness/audit loop — is platform-agnostic and unchanged.
28
+ - If `platform: web` or field absent → follow the **web path** (all steps below, unchanged) — Figma/live capture via `sungen-capture` as documented in Step 3.
29
+
23
30
  ## Role
24
31
 
25
32
  {{#cap parallel-subagents}}
@@ -10,10 +10,10 @@ codex-trigger: "Run when the user wants to send FEEDBACK about sungen itself."
10
10
  ## Role
11
11
  {{#cap parallel-subagents}}
12
12
 
13
- You capture QA feedback and store it **locally** (no server) via `sungen feedback record`. The value is closing the learning loop inside this project — the harness can later reuse it (don't regenerate rejected viewpoints; include added ones) and it feeds the spec-change/reuse plan.
13
+ You capture QA feedback and store it **locally** (no server) via `sungen qa-feedback record`. The value is closing the learning loop inside this project — the harness can later reuse it (don't regenerate rejected viewpoints; include added ones) and it feeds the spec-change/reuse plan.
14
14
  {{/cap}}
15
15
  {{^cap parallel-subagents}}
16
- Capture QA feedback and store it **locally** (no server) via `sungen feedback record`. Closes the learning loop inside the project; the harness can reuse it later.
16
+ Capture QA feedback and store it **locally** (no server) via `sungen qa-feedback record`. Closes the learning loop inside the project; the harness can reuse it later.
17
17
  {{/cap}}
18
18
 
19
19
  ## Steps
@@ -39,12 +39,12 @@ Capture QA feedback and store it **locally** (no server) via `sungen feedback re
39
39
  {{/cap}}
40
40
  ```bash
41
41
  {{#cap parallel-subagents}}
42
- sungen feedback record --type test-design --screen <name> \
42
+ sungen qa-feedback record --type test-design --screen <name> \
43
43
  --target "VP-DATA-CONSISTENCY" --decision add \
44
44
  --message "<message>" --reason "<why>"
45
45
  {{/cap}}
46
46
  {{^cap parallel-subagents}}
47
- sungen feedback record --type <type> --screen <name> --target "<ref>" --decision <d> --message "<msg>" --reason "<why>"
47
+ sungen qa-feedback record --type <type> --screen <name> --target "<ref>" --decision <d> --message "<msg>" --reason "<why>"
48
48
  {{/cap}}
49
49
  ```
50
50
  {{#cap parallel-subagents}}
@@ -60,8 +60,8 @@ Capture QA feedback and store it **locally** (no server) via `sungen feedback re
60
60
  {{#cap parallel-subagents}}
61
61
  - **Never send anywhere** — this only writes a local file.
62
62
  - Keep `product` feedback separate from `test-design` so it can route to telemetry vs the viewpoint knowledge later.
63
- - View history: `sungen feedback list [--screen <name>] [--type <t>]`.
63
+ - View history: `sungen qa-feedback list [--screen <name>] [--type <t>]`.
64
64
  {{/cap}}
65
65
  {{^cap parallel-subagents}}
66
- - Never send anywhere — local file only. Keep `product` vs `test-design` distinct. View: `sungen feedback list`.
66
+ - Never send anywhere — local file only. Keep `product` vs `test-design` distinct. View: `sungen qa-feedback list`.
67
67
  {{/cap}}
@@ -1,8 +1,8 @@
1
1
  ---
2
- 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."
2
+ description: "Bootstrap i18n for a screen/flow — audit selectors, detect locale switch mechanism via Playwright (web) or device locale (mobile), generate test-data overlay so `sungen:run-test --env <locale>` works."
3
3
  argument-hint: "<name> <locale> [--base-locale <code>] [--offline]"
4
4
  order: 45
5
- claude-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_click, mcp__playwright__browser_storage_state, mcp__playwright__browser_set_storage_state"
5
+ claude-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_click, mcp__playwright__browser_storage_state, mcp__playwright__browser_set_storage_state, mcp__appium-mcp__select_device, mcp__appium-mcp__appium_session_management, mcp__appium-mcp__appium_get_page_source, mcp__appium-mcp__appium_screenshot, mcp__appium-mcp__generate_locators"
6
6
  copilot-tools: "[read, execute, edit, vscode/askQuestions, playwright/*]"
7
7
  codex-trigger: "Run when the user asks to bootstrap i18n/localization for a screen. Runs before run-test --env <locale>."
8
8
  ---
@@ -33,6 +33,27 @@ Reject if name == locale (common typo).
33
33
  Reject if name == locale.
34
34
  {{/cap}}
35
35
 
36
+ ## Platform detection (do this FIRST)
37
+
38
+ Read `qa/capabilities.yaml` and check the `platform` field.
39
+
40
+ - If `platform: mobile` → switch to the **mobile path** (below).
41
+ - If `platform: web` or field absent → follow the **web path** (existing behavior below, unchanged).
42
+
43
+ ### Mobile path
44
+
45
+ When `platform: mobile`, mobile follows the **device locale** — there is no URL prefix, query param, or browser-storage mechanism to detect. Key differences from web (full detail in the `sungen-locale` skill):
46
+
47
+ - **Live capture**: use **Appium MCP** (`select_device` → `appium_session_management(create)` with the device at base locale → `appium_get_page_source` / `appium_screenshot`) — not Playwright browser tools.
48
+ - **Locale-switch mechanism**: `appium:language` / `appium:locale` capabilities + `noReset:false`, resolved automatically at runtime by `wdio.conf.ts`'s `resolveLocaleCaps()`. No fixture files needed.
49
+ - **Phases skipped**: 3.5/3.6 (browser storage diff/verify) and 6d/6f (Pages URL update, locale-config.json) are web-only — skip them. Phase 6 (mobile) writes only selectors `{{var}}`, the base `test-data/<feature>.yaml`, and the overlay `test-data/<feature>.<locale>.yaml`.
50
+ - **Compile**: `sungen generate --screen <name>` (the Appium adapter auto-selects for a mobile project).
51
+ - **Hand-off**: after a locale run, print `SUNGEN_ENV=<locale> npm run test:mobile` (or the `--flow` equivalent). If the device's locale code differs from the overlay's env name, set `SUNGEN_LOCALE=<code>` — `resolveLocaleCaps()` reads it as an override.
52
+ - **Reset after a locale run**: run once with `SUNGEN_LOCALE=en npm run test:mobile` to bring the device/app back to the base language before the next non-locale run.
53
+ - **iOS data-wipe**: `wdio.conf.ts`'s `beforeSession` hook already wipes the app's data container on iOS before any locale run (XCUITest's `noReset:false` alone doesn't clear a persisted in-app language). If an older mobile project's `wdio.conf.ts` predates this hook and iOS keeps the previous language, re-run `sungen init --mobile` to refresh it.
54
+
55
+ Stop here for mobile — do not continue to the web path below. Everything else (the 7-phase strategy, selector/test-data output shape, `{{var}}` overlay pattern) matches web; see the `sungen-locale` skill for the full mobile phase table.
56
+
36
57
  ## Auto-detect context
37
58
 
38
59
  Same as `/sungen:run-test`:
@@ -114,10 +135,11 @@ Offer the user:
114
135
  {{#cap parallel-subagents}}
115
136
  - Do NOT run tests yourself. `/sungen:run-test` is the executor. This command only PREPS files.
116
137
  - Do NOT modify `.feature` files. Localization happens entirely through `selectors/*.yaml` + `test-data/*.yaml`.
117
- - Auth blocker on SAA staging? Use `--offline`. See [[saa-auth-blocker]] memory.
138
+ - Auth blocker on SAA staging (web)? Use `--offline`. See [[saa-auth-blocker]] memory.
139
+ - Mobile device/emulator unreachable? Use `--offline` — same fallback as web.
118
140
  {{/cap}}
119
141
  {{^cap parallel-subagents}}
120
142
  - Do NOT run tests yourself. `/sungen:run-test` is the executor; this command only PREPS files.
121
143
  - Do NOT modify `.feature` files. Localization lives in `selectors/*.yaml` + `test-data/*.yaml` only.
122
- - Auth blocked? Use `--offline`.
144
+ - Auth blocked (web)? Use `--offline`. Mobile device unreachable? Same fallback.
123
145
  {{/cap}}
@@ -78,19 +78,20 @@ The CLI reads the **per-target result file first** (co-located with `.spec.ts`),
78
78
 
79
79
  ---
80
80
 
81
- ## XLSX sheets — Auto / Manual split
81
+ ## XLSX sheets — Overview + Auto / Manual split
82
82
 
83
- The `.xlsx` is split into two sheets so QA manages the sets separately:
83
+ The `.xlsx` leads with an **`Overview`** roll-up sheet, then splits the test cases into detail sheets so QA manages the sets separately:
84
+ - **`Overview`** — first sheet. Same masthead (Sun\* logo, `<SCREEN> TESTCASE` title, No/Version/Issue-Date, ISO band) as the others, then a summary table: one row per following sheet with `# · Sheet name · Passed · Failed · Pending · N/A · Remain · Total`, plus a grand-total row. `Remain = Total − Passed − N/A` (i.e. Failed + Pending), reconciling with each detail sheet's own summary band.
84
85
  - **`Auto`** — automatable test cases (`Auto` + `Not compiled`).
85
86
  - **`Manual`** — `@manual` test cases (always present, header-only when there are none).
86
87
 
87
- Multi-locale (no `SUNGEN_ENV`): one **`<LOCALE> Auto`** sheet per locale + a single shared **`Manual`** sheet (manual TCs are locale-invariant). The **CSV stays one file with every row** — the `Testcase type` column distinguishes Auto vs Manual.
88
+ Multi-locale (no `SUNGEN_ENV`): `Overview` + one **`<LOCALE> Auto`** sheet per locale + a single shared **`Manual`** sheet (manual TCs are locale-invariant). The **CSV stays one file with every row** — the `Testcase type` column distinguishes Auto vs Manual. The Overview lists every detail sheet, so each locale's counts appear on its own row.
88
89
 
89
90
  ---
90
91
 
91
92
  ## API delivery — extra worksheet
92
93
 
93
- For **api-kind units** (`qa/api/<area>/`), the `.xlsx` gains a third worksheet **`API detail`** (appended after Auto/Manual). The main BM-2-901-13 Testcases layout is unchanged. The CSV is unchanged (16-column, no extra sheet).
94
+ For **api-kind units** (`qa/api/<area>/`), the `.xlsx` gains a final worksheet **`API detail`** (appended after Overview/Auto/Manual). The main BM-2-901-13 Testcases layout is unchanged. The CSV is unchanged (16-column, no extra sheet).
94
95
 
95
96
  ### Required sources (API detail sheet only)
96
97