@sun-asterisk/sungen 3.2.2-beta.9 → 3.2.3-beta.3

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 (346) hide show
  1. package/dist/capabilities/discover.d.ts.map +1 -1
  2. package/dist/capabilities/discover.js +26 -3
  3. package/dist/capabilities/discover.js.map +1 -1
  4. package/dist/cli/commands/add-flow.d.ts.map +1 -1
  5. package/dist/cli/commands/add-flow.js +2 -0
  6. package/dist/cli/commands/add-flow.js.map +1 -1
  7. package/dist/cli/commands/add.d.ts.map +1 -1
  8. package/dist/cli/commands/add.js +4 -0
  9. package/dist/cli/commands/add.js.map +1 -1
  10. package/dist/cli/commands/capability.d.ts.map +1 -1
  11. package/dist/cli/commands/capability.js +61 -0
  12. package/dist/cli/commands/capability.js.map +1 -1
  13. package/dist/cli/commands/delivery.d.ts.map +1 -1
  14. package/dist/cli/commands/delivery.js +89 -2
  15. package/dist/cli/commands/delivery.js.map +1 -1
  16. package/dist/cli/commands/eval.js +3 -3
  17. package/dist/cli/commands/eval.js.map +1 -1
  18. package/dist/cli/commands/generate.d.ts.map +1 -1
  19. package/dist/cli/commands/generate.js +2 -1
  20. package/dist/cli/commands/generate.js.map +1 -1
  21. package/dist/cli/commands/init.d.ts.map +1 -1
  22. package/dist/cli/commands/init.js +32 -2
  23. package/dist/cli/commands/init.js.map +1 -1
  24. package/dist/cli/commands/journey.d.ts.map +1 -1
  25. package/dist/cli/commands/journey.js +24 -2
  26. package/dist/cli/commands/journey.js.map +1 -1
  27. package/dist/cli/commands/update.d.ts.map +1 -1
  28. package/dist/cli/commands/update.js +10 -3
  29. package/dist/cli/commands/update.js.map +1 -1
  30. package/dist/dashboard/snapshot-builder.d.ts.map +1 -1
  31. package/dist/dashboard/snapshot-builder.js +10 -1
  32. package/dist/dashboard/snapshot-builder.js.map +1 -1
  33. package/dist/exporters/csv-exporter.d.ts.map +1 -1
  34. package/dist/exporters/csv-exporter.js +3 -1
  35. package/dist/exporters/csv-exporter.js.map +1 -1
  36. package/dist/exporters/json-exporter.js +3 -1
  37. package/dist/exporters/json-exporter.js.map +1 -1
  38. package/dist/exporters/mobile-app-id.d.ts +22 -0
  39. package/dist/exporters/mobile-app-id.d.ts.map +1 -0
  40. package/dist/exporters/mobile-app-id.js +37 -0
  41. package/dist/exporters/mobile-app-id.js.map +1 -0
  42. package/dist/exporters/spec-parser.d.ts.map +1 -1
  43. package/dist/exporters/spec-parser.js +6 -2
  44. package/dist/exporters/spec-parser.js.map +1 -1
  45. package/dist/generators/test-generator/adapters/adapter-interface.d.ts +3 -0
  46. package/dist/generators/test-generator/adapters/adapter-interface.d.ts.map +1 -1
  47. package/dist/generators/test-generator/adapters/appium/templates/steps/actions/scroll-action.hbs +7 -4
  48. package/dist/generators/test-generator/adapters/appium/templates/steps/actions/toggle-action.hbs +20 -3
  49. package/dist/generators/test-generator/adapters/appium/templates/steps/assertions/checked-assertion.hbs +4 -1
  50. package/dist/generators/test-generator/adapters/appium/templates/steps/assertions/not-checked-assertion.hbs +4 -1
  51. package/dist/generators/test-generator/adapters/appium/templates/test-file.hbs +3 -0
  52. package/dist/generators/test-generator/code-generator.d.ts.map +1 -1
  53. package/dist/generators/test-generator/code-generator.js +48 -9
  54. package/dist/generators/test-generator/code-generator.js.map +1 -1
  55. package/dist/generators/test-generator/template-engine.d.ts +3 -0
  56. package/dist/generators/test-generator/template-engine.d.ts.map +1 -1
  57. package/dist/generators/test-generator/template-engine.js +11 -1
  58. package/dist/generators/test-generator/template-engine.js.map +1 -1
  59. package/dist/generators/test-generator/utils/selector-resolver.d.ts +11 -1
  60. package/dist/generators/test-generator/utils/selector-resolver.d.ts.map +1 -1
  61. package/dist/generators/test-generator/utils/selector-resolver.js +33 -0
  62. package/dist/generators/test-generator/utils/selector-resolver.js.map +1 -1
  63. package/dist/harness/audit.d.ts.map +1 -1
  64. package/dist/harness/audit.js +8 -1
  65. package/dist/harness/audit.js.map +1 -1
  66. package/dist/harness/catalog/universal-viewpoints.yaml +15 -0
  67. package/dist/harness/eval/skill-lint.d.ts +3 -3
  68. package/dist/harness/eval/skill-lint.d.ts.map +1 -1
  69. package/dist/harness/eval/skill-lint.js +88 -68
  70. package/dist/harness/eval/skill-lint.js.map +1 -1
  71. package/dist/harness/journey.d.ts +37 -1
  72. package/dist/harness/journey.d.ts.map +1 -1
  73. package/dist/harness/journey.js +146 -19
  74. package/dist/harness/journey.js.map +1 -1
  75. package/dist/harness/quality-gates.d.ts +13 -0
  76. package/dist/harness/quality-gates.d.ts.map +1 -1
  77. package/dist/harness/quality-gates.js +23 -0
  78. package/dist/harness/quality-gates.js.map +1 -1
  79. package/dist/harness/sensors.d.ts +1 -1
  80. package/dist/harness/sensors.d.ts.map +1 -1
  81. package/dist/harness/sensors.js +32 -9
  82. package/dist/harness/sensors.js.map +1 -1
  83. package/dist/orchestrator/ai-rules-updater.d.ts +11 -3
  84. package/dist/orchestrator/ai-rules-updater.d.ts.map +1 -1
  85. package/dist/orchestrator/ai-rules-updater.js +44 -180
  86. package/dist/orchestrator/ai-rules-updater.js.map +1 -1
  87. package/dist/orchestrator/ai-skills/adapters.d.ts +28 -0
  88. package/dist/orchestrator/ai-skills/adapters.d.ts.map +1 -0
  89. package/dist/orchestrator/ai-skills/adapters.js +34 -0
  90. package/dist/orchestrator/ai-skills/adapters.js.map +1 -0
  91. package/dist/orchestrator/ai-skills/build.d.ts +10 -0
  92. package/dist/orchestrator/ai-skills/build.d.ts.map +1 -0
  93. package/dist/orchestrator/ai-skills/build.js +128 -0
  94. package/dist/orchestrator/ai-skills/build.js.map +1 -0
  95. package/dist/orchestrator/ai-skills/cap-stripper.d.ts +27 -0
  96. package/dist/orchestrator/ai-skills/cap-stripper.d.ts.map +1 -0
  97. package/dist/orchestrator/ai-skills/cap-stripper.js +78 -0
  98. package/dist/orchestrator/ai-skills/cap-stripper.js.map +1 -0
  99. package/dist/orchestrator/ai-skills/commands.d.ts +22 -0
  100. package/dist/orchestrator/ai-skills/commands.d.ts.map +1 -0
  101. package/dist/orchestrator/ai-skills/commands.js +109 -0
  102. package/dist/orchestrator/ai-skills/commands.js.map +1 -0
  103. package/dist/orchestrator/ai-skills/generator.d.ts +23 -0
  104. package/dist/orchestrator/ai-skills/generator.d.ts.map +1 -0
  105. package/dist/orchestrator/ai-skills/generator.js +79 -0
  106. package/dist/orchestrator/ai-skills/generator.js.map +1 -0
  107. package/dist/orchestrator/ai-skills/golden-skills.test.d.ts +2 -0
  108. package/dist/orchestrator/ai-skills/golden-skills.test.d.ts.map +1 -0
  109. package/dist/orchestrator/ai-skills/golden-skills.test.js +183 -0
  110. package/dist/orchestrator/ai-skills/golden-skills.test.js.map +1 -0
  111. package/dist/orchestrator/ai-skills/resolve-assistants.d.ts +8 -0
  112. package/dist/orchestrator/ai-skills/resolve-assistants.d.ts.map +1 -0
  113. package/dist/orchestrator/ai-skills/resolve-assistants.js +28 -0
  114. package/dist/orchestrator/ai-skills/resolve-assistants.js.map +1 -0
  115. package/dist/orchestrator/ai-skills/writer.d.ts +15 -0
  116. package/dist/orchestrator/ai-skills/writer.d.ts.map +1 -0
  117. package/dist/orchestrator/ai-skills/writer.js +129 -0
  118. package/dist/orchestrator/ai-skills/writer.js.map +1 -0
  119. package/dist/orchestrator/flow-manager.d.ts +11 -0
  120. package/dist/orchestrator/flow-manager.d.ts.map +1 -1
  121. package/dist/orchestrator/flow-manager.js +147 -29
  122. package/dist/orchestrator/flow-manager.js.map +1 -1
  123. package/dist/orchestrator/mobile-runtime-scaffolder.d.ts +59 -0
  124. package/dist/orchestrator/mobile-runtime-scaffolder.d.ts.map +1 -0
  125. package/dist/orchestrator/mobile-runtime-scaffolder.js +298 -0
  126. package/dist/orchestrator/mobile-runtime-scaffolder.js.map +1 -0
  127. package/dist/orchestrator/project-initializer.d.ts +44 -7
  128. package/dist/orchestrator/project-initializer.d.ts.map +1 -1
  129. package/dist/orchestrator/project-initializer.js +147 -79
  130. package/dist/orchestrator/project-initializer.js.map +1 -1
  131. package/dist/orchestrator/screen-manager.d.ts +30 -0
  132. package/dist/orchestrator/screen-manager.d.ts.map +1 -1
  133. package/dist/orchestrator/screen-manager.js +205 -22
  134. package/dist/orchestrator/screen-manager.js.map +1 -1
  135. package/dist/orchestrator/templates/ai-src/README.md +58 -0
  136. package/dist/orchestrator/templates/{ai-instructions/claude-cmd-add-flow.md → ai-src/commands/add-flow.md} +63 -2
  137. package/dist/orchestrator/templates/{ai-instructions/claude-cmd-add-screen.md → ai-src/commands/add-screen.md} +171 -6
  138. package/dist/orchestrator/templates/{ai-instructions/claude-cmd-create-test.md → ai-src/commands/create-test.md} +118 -5
  139. package/{src/orchestrator/templates/ai-instructions/claude-cmd-dashboard.md → dist/orchestrator/templates/ai-src/commands/dashboard.md} +25 -3
  140. package/{src/orchestrator/templates/ai-instructions/claude-cmd-delivery.md → dist/orchestrator/templates/ai-src/commands/delivery.md} +67 -3
  141. package/dist/orchestrator/templates/ai-src/commands/design.md +29 -0
  142. package/{src/orchestrator/templates/ai-instructions/claude-cmd-feedback.md → dist/orchestrator/templates/ai-src/commands/feedback.md} +34 -3
  143. package/dist/orchestrator/templates/{ai-instructions/claude-cmd-locale.md → ai-src/commands/locale.md} +56 -4
  144. package/{src/orchestrator/templates/ai-instructions/claude-cmd-review.md → dist/orchestrator/templates/ai-src/commands/review.md} +57 -2
  145. package/dist/orchestrator/templates/{ai-instructions/claude-cmd-run-test.md → ai-src/commands/run-test.md} +116 -8
  146. package/dist/orchestrator/templates/ai-src/config/codex.md +8 -0
  147. package/{src/orchestrator/templates/ai-instructions/claude-skill-capture-mobile.md → dist/orchestrator/templates/ai-src/skills/sungen-capture-mobile/SKILL.md} +11 -0
  148. package/dist/orchestrator/templates/{ai-instructions/github-skill-sungen-error-mapping.md → ai-src/skills/sungen-error-mapping/SKILL.md} +31 -10
  149. package/{src/orchestrator/templates/ai-instructions/claude-skill-harness-audit.md → dist/orchestrator/templates/ai-src/skills/sungen-harness-audit/SKILL.md} +5 -5
  150. package/{src/orchestrator/templates/ai-instructions/claude-skill-locale.md → dist/orchestrator/templates/ai-src/skills/sungen-locale/SKILL.md} +275 -3
  151. package/{src/orchestrator/templates/ai-instructions/github-skill-sungen-selector-fix.md → dist/orchestrator/templates/ai-src/skills/sungen-selector-fix/SKILL.md} +17 -0
  152. package/{src/orchestrator/templates/ai-instructions/claude-skill-selector-fix-mobile.md → dist/orchestrator/templates/ai-src/skills/sungen-selector-fix-mobile/SKILL.md} +5 -0
  153. package/dist/orchestrator/templates/{ai-instructions/claude-skill-tc-generation.md → ai-src/skills/sungen-tc-generation/SKILL.md} +5 -0
  154. package/dist/orchestrator/templates/playwright.config.ts +7 -4
  155. package/package.json +3 -3
  156. package/src/capabilities/discover.ts +29 -3
  157. package/src/cli/commands/add-flow.ts +2 -0
  158. package/src/cli/commands/add.ts +4 -0
  159. package/src/cli/commands/capability.ts +64 -1
  160. package/src/cli/commands/delivery.ts +89 -2
  161. package/src/cli/commands/eval.ts +3 -3
  162. package/src/cli/commands/generate.ts +2 -1
  163. package/src/cli/commands/init.ts +50 -3
  164. package/src/cli/commands/journey.ts +20 -3
  165. package/src/cli/commands/update.ts +14 -4
  166. package/src/dashboard/snapshot-builder.ts +10 -1
  167. package/src/exporters/csv-exporter.ts +3 -1
  168. package/src/exporters/json-exporter.ts +3 -1
  169. package/src/exporters/mobile-app-id.ts +34 -0
  170. package/src/exporters/spec-parser.ts +6 -2
  171. package/src/generators/test-generator/adapters/adapter-interface.ts +3 -0
  172. package/src/generators/test-generator/adapters/appium/templates/steps/actions/scroll-action.hbs +7 -4
  173. package/src/generators/test-generator/adapters/appium/templates/steps/actions/toggle-action.hbs +20 -3
  174. package/src/generators/test-generator/adapters/appium/templates/steps/assertions/checked-assertion.hbs +4 -1
  175. package/src/generators/test-generator/adapters/appium/templates/steps/assertions/not-checked-assertion.hbs +4 -1
  176. package/src/generators/test-generator/adapters/appium/templates/test-file.hbs +3 -0
  177. package/src/generators/test-generator/code-generator.ts +49 -9
  178. package/src/generators/test-generator/template-engine.ts +14 -1
  179. package/src/generators/test-generator/utils/selector-resolver.ts +51 -1
  180. package/src/harness/audit.ts +9 -2
  181. package/src/harness/catalog/universal-viewpoints.yaml +15 -0
  182. package/src/harness/eval/skill-lint.ts +71 -60
  183. package/src/harness/journey.ts +167 -19
  184. package/src/harness/quality-gates.ts +20 -0
  185. package/src/harness/sensors.ts +25 -8
  186. package/src/orchestrator/ai-rules-updater.ts +35 -197
  187. package/src/orchestrator/ai-skills/adapters.ts +52 -0
  188. package/src/orchestrator/ai-skills/build.ts +103 -0
  189. package/src/orchestrator/ai-skills/cap-stripper.ts +85 -0
  190. package/src/orchestrator/ai-skills/commands.ts +112 -0
  191. package/src/orchestrator/ai-skills/generator.ts +47 -0
  192. package/src/orchestrator/ai-skills/golden-skills.test.ts +124 -0
  193. package/src/orchestrator/ai-skills/resolve-assistants.ts +18 -0
  194. package/src/orchestrator/ai-skills/writer.ts +92 -0
  195. package/src/orchestrator/flow-manager.ts +165 -29
  196. package/src/orchestrator/mobile-runtime-scaffolder.ts +277 -0
  197. package/src/orchestrator/project-initializer.ts +159 -86
  198. package/src/orchestrator/screen-manager.ts +237 -22
  199. package/src/orchestrator/templates/ai-src/README.md +58 -0
  200. package/src/orchestrator/templates/{ai-instructions/claude-cmd-add-flow.md → ai-src/commands/add-flow.md} +63 -2
  201. package/src/orchestrator/templates/{ai-instructions/claude-cmd-add-screen.md → ai-src/commands/add-screen.md} +171 -6
  202. package/src/orchestrator/templates/{ai-instructions/claude-cmd-create-test.md → ai-src/commands/create-test.md} +118 -5
  203. package/{dist/orchestrator/templates/ai-instructions/claude-cmd-dashboard.md → src/orchestrator/templates/ai-src/commands/dashboard.md} +25 -3
  204. package/{dist/orchestrator/templates/ai-instructions/claude-cmd-delivery.md → src/orchestrator/templates/ai-src/commands/delivery.md} +67 -3
  205. package/src/orchestrator/templates/ai-src/commands/design.md +29 -0
  206. package/{dist/orchestrator/templates/ai-instructions/claude-cmd-feedback.md → src/orchestrator/templates/ai-src/commands/feedback.md} +34 -3
  207. package/src/orchestrator/templates/{ai-instructions/claude-cmd-locale.md → ai-src/commands/locale.md} +56 -4
  208. package/{dist/orchestrator/templates/ai-instructions/claude-cmd-review.md → src/orchestrator/templates/ai-src/commands/review.md} +57 -2
  209. package/src/orchestrator/templates/{ai-instructions/claude-cmd-run-test.md → ai-src/commands/run-test.md} +116 -8
  210. package/src/orchestrator/templates/ai-src/config/codex.md +8 -0
  211. package/{dist/orchestrator/templates/ai-instructions/claude-skill-capture-mobile.md → src/orchestrator/templates/ai-src/skills/sungen-capture-mobile/SKILL.md} +11 -0
  212. package/{dist/orchestrator/templates/ai-instructions/claude-skill-error-mapping.md → src/orchestrator/templates/ai-src/skills/sungen-error-mapping/SKILL.md} +31 -10
  213. package/{dist/orchestrator/templates/ai-instructions/claude-skill-harness-audit.md → src/orchestrator/templates/ai-src/skills/sungen-harness-audit/SKILL.md} +5 -5
  214. package/{dist/orchestrator/templates/ai-instructions/claude-skill-locale.md → src/orchestrator/templates/ai-src/skills/sungen-locale/SKILL.md} +275 -3
  215. package/{dist/orchestrator/templates/ai-instructions/github-skill-sungen-selector-fix.md → src/orchestrator/templates/ai-src/skills/sungen-selector-fix/SKILL.md} +17 -0
  216. package/{dist/orchestrator/templates/ai-instructions/claude-skill-selector-fix-mobile.md → src/orchestrator/templates/ai-src/skills/sungen-selector-fix-mobile/SKILL.md} +5 -0
  217. package/src/orchestrator/templates/{ai-instructions/claude-skill-tc-generation.md → ai-src/skills/sungen-tc-generation/SKILL.md} +5 -0
  218. package/src/orchestrator/templates/playwright.config.ts +7 -4
  219. package/dist/orchestrator/templates/ai-instructions/claude-cmd-design.md +0 -12
  220. package/dist/orchestrator/templates/ai-instructions/claude-skill-selector-fix.md +0 -347
  221. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-add-flow.md +0 -86
  222. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-add-screen.md +0 -131
  223. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-create-test.md +0 -94
  224. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-dashboard.md +0 -65
  225. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-delivery.md +0 -83
  226. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-design.md +0 -13
  227. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-feedback.md +0 -24
  228. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-locale.md +0 -70
  229. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-review.md +0 -38
  230. package/dist/orchestrator/templates/ai-instructions/copilot-cmd-run-test.md +0 -158
  231. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-capture-mobile.md +0 -184
  232. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-harness-audit.md +0 -85
  233. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-locale.md +0 -291
  234. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-selector-fix-mobile.md +0 -316
  235. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-selector-keys.md +0 -221
  236. package/dist/orchestrator/templates/ai-instructions/github-skill-sungen-tc-generation.md +0 -617
  237. package/src/orchestrator/templates/ai-instructions/claude-cmd-design.md +0 -12
  238. package/src/orchestrator/templates/ai-instructions/claude-skill-api-design.md +0 -62
  239. package/src/orchestrator/templates/ai-instructions/claude-skill-capture-mode-figma-mcp.md +0 -82
  240. package/src/orchestrator/templates/ai-instructions/claude-skill-capture-mode-figma-pat.md +0 -117
  241. package/src/orchestrator/templates/ai-instructions/claude-skill-capture-mode-live.md +0 -60
  242. package/src/orchestrator/templates/ai-instructions/claude-skill-capture-mode-local.md +0 -38
  243. package/src/orchestrator/templates/ai-instructions/claude-skill-capture.md +0 -35
  244. package/src/orchestrator/templates/ai-instructions/claude-skill-dashboard.md +0 -121
  245. package/src/orchestrator/templates/ai-instructions/claude-skill-delivery.md +0 -141
  246. package/src/orchestrator/templates/ai-instructions/claude-skill-error-mapping.md +0 -176
  247. package/src/orchestrator/templates/ai-instructions/claude-skill-gherkin-syntax.md +0 -446
  248. package/src/orchestrator/templates/ai-instructions/claude-skill-ingest-legacy.md +0 -79
  249. package/src/orchestrator/templates/ai-instructions/claude-skill-mobile-gestures.md +0 -109
  250. package/src/orchestrator/templates/ai-instructions/claude-skill-selector-fix.md +0 -347
  251. package/src/orchestrator/templates/ai-instructions/claude-skill-tc-review.md +0 -320
  252. package/src/orchestrator/templates/ai-instructions/claude-skill-test-design-techniques.md +0 -118
  253. package/src/orchestrator/templates/ai-instructions/claude-skill-viewpoint-group-a-data-entry.md +0 -203
  254. package/src/orchestrator/templates/ai-instructions/claude-skill-viewpoint-group-b-data-ops.md +0 -179
  255. package/src/orchestrator/templates/ai-instructions/claude-skill-viewpoint-group-c-data-explore.md +0 -233
  256. package/src/orchestrator/templates/ai-instructions/claude-skill-viewpoint-group-d-display.md +0 -226
  257. package/src/orchestrator/templates/ai-instructions/claude-skill-viewpoint-group-e-identity.md +0 -177
  258. package/src/orchestrator/templates/ai-instructions/claude-skill-viewpoint.md +0 -118
  259. package/src/orchestrator/templates/ai-instructions/copilot-cmd-add-flow.md +0 -86
  260. package/src/orchestrator/templates/ai-instructions/copilot-cmd-add-screen.md +0 -131
  261. package/src/orchestrator/templates/ai-instructions/copilot-cmd-create-test.md +0 -94
  262. package/src/orchestrator/templates/ai-instructions/copilot-cmd-dashboard.md +0 -65
  263. package/src/orchestrator/templates/ai-instructions/copilot-cmd-delivery.md +0 -83
  264. package/src/orchestrator/templates/ai-instructions/copilot-cmd-design.md +0 -13
  265. package/src/orchestrator/templates/ai-instructions/copilot-cmd-feedback.md +0 -24
  266. package/src/orchestrator/templates/ai-instructions/copilot-cmd-locale.md +0 -70
  267. package/src/orchestrator/templates/ai-instructions/copilot-cmd-review.md +0 -38
  268. package/src/orchestrator/templates/ai-instructions/copilot-cmd-run-test.md +0 -158
  269. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-api-design.md +0 -62
  270. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-capture-mobile.md +0 -184
  271. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-capture-mode-figma-mcp.md +0 -82
  272. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-capture-mode-figma-pat.md +0 -117
  273. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-capture-mode-live.md +0 -60
  274. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-capture-mode-local.md +0 -38
  275. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-capture.md +0 -35
  276. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-dashboard.md +0 -121
  277. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-delivery.md +0 -141
  278. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-error-mapping.md +0 -176
  279. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-gherkin-syntax.md +0 -446
  280. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-harness-audit.md +0 -85
  281. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-ingest-legacy.md +0 -79
  282. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-locale.md +0 -291
  283. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-mobile-gestures.md +0 -109
  284. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-selector-fix-mobile.md +0 -316
  285. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-selector-keys.md +0 -221
  286. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-tc-generation.md +0 -617
  287. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-tc-review.md +0 -320
  288. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-test-design-techniques.md +0 -118
  289. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-viewpoint-group-a-data-entry.md +0 -203
  290. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-viewpoint-group-b-data-ops.md +0 -179
  291. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-viewpoint-group-c-data-explore.md +0 -233
  292. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-viewpoint-group-d-display.md +0 -226
  293. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-viewpoint-group-e-identity.md +0 -177
  294. package/src/orchestrator/templates/ai-instructions/github-skill-sungen-viewpoint.md +0 -118
  295. /package/dist/orchestrator/templates/{ai-instructions/claude-agent-challenge.md → ai-src/agents/challenge.md} +0 -0
  296. /package/dist/orchestrator/templates/{ai-instructions/claude-agent-discovery.md → ai-src/agents/discovery.md} +0 -0
  297. /package/dist/orchestrator/templates/{ai-instructions/claude-agent-generator.md → ai-src/agents/generator.md} +0 -0
  298. /package/dist/orchestrator/templates/{ai-instructions/claude-agent-reviewer.md → ai-src/agents/reviewer.md} +0 -0
  299. /package/dist/orchestrator/templates/{ai-instructions/claude-config.md → ai-src/config/claude.md} +0 -0
  300. /package/dist/orchestrator/templates/{ai-instructions/copilot-config.md → ai-src/config/copilot.md} +0 -0
  301. /package/dist/orchestrator/templates/{ai-instructions/claude-skill-api-design.md → ai-src/skills/sungen-api-design/SKILL.md} +0 -0
  302. /package/dist/orchestrator/templates/{ai-instructions/claude-skill-capture.md → ai-src/skills/sungen-capture/SKILL.md} +0 -0
  303. /package/dist/orchestrator/templates/{ai-instructions/claude-skill-capture-mode-figma-mcp.md → ai-src/skills/sungen-capture/mode-figma-mcp.md} +0 -0
  304. /package/dist/orchestrator/templates/{ai-instructions/claude-skill-capture-mode-figma-pat.md → ai-src/skills/sungen-capture/mode-figma-pat.md} +0 -0
  305. /package/dist/orchestrator/templates/{ai-instructions/claude-skill-capture-mode-live.md → ai-src/skills/sungen-capture/mode-live.md} +0 -0
  306. /package/dist/orchestrator/templates/{ai-instructions/claude-skill-capture-mode-local.md → ai-src/skills/sungen-capture/mode-local.md} +0 -0
  307. /package/dist/orchestrator/templates/{ai-instructions/claude-skill-dashboard.md → ai-src/skills/sungen-dashboard/SKILL.md} +0 -0
  308. /package/dist/orchestrator/templates/{ai-instructions/claude-skill-delivery.md → ai-src/skills/sungen-delivery/SKILL.md} +0 -0
  309. /package/dist/orchestrator/templates/{ai-instructions/claude-skill-gherkin-syntax.md → ai-src/skills/sungen-gherkin-syntax/SKILL.md} +0 -0
  310. /package/dist/orchestrator/templates/{ai-instructions/claude-skill-ingest-legacy.md → ai-src/skills/sungen-ingest-legacy/SKILL.md} +0 -0
  311. /package/dist/orchestrator/templates/{ai-instructions/claude-skill-mobile-gestures.md → ai-src/skills/sungen-mobile-gestures/SKILL.md} +0 -0
  312. /package/dist/orchestrator/templates/{ai-instructions/claude-skill-selector-keys.md → ai-src/skills/sungen-selector-keys/SKILL.md} +0 -0
  313. /package/dist/orchestrator/templates/{ai-instructions/claude-skill-tc-review.md → ai-src/skills/sungen-tc-review/SKILL.md} +0 -0
  314. /package/dist/orchestrator/templates/{ai-instructions/claude-skill-test-design-techniques.md → ai-src/skills/sungen-test-design-techniques/SKILL.md} +0 -0
  315. /package/dist/orchestrator/templates/{ai-instructions/claude-skill-viewpoint.md → ai-src/skills/sungen-viewpoint/SKILL.md} +0 -0
  316. /package/dist/orchestrator/templates/{ai-instructions/claude-skill-viewpoint-group-a-data-entry.md → ai-src/skills/sungen-viewpoint/group-a-data-entry.md} +0 -0
  317. /package/dist/orchestrator/templates/{ai-instructions/claude-skill-viewpoint-group-b-data-ops.md → ai-src/skills/sungen-viewpoint/group-b-data-ops.md} +0 -0
  318. /package/dist/orchestrator/templates/{ai-instructions/claude-skill-viewpoint-group-c-data-explore.md → ai-src/skills/sungen-viewpoint/group-c-data-explore.md} +0 -0
  319. /package/dist/orchestrator/templates/{ai-instructions/claude-skill-viewpoint-group-d-display.md → ai-src/skills/sungen-viewpoint/group-d-display.md} +0 -0
  320. /package/dist/orchestrator/templates/{ai-instructions/claude-skill-viewpoint-group-e-identity.md → ai-src/skills/sungen-viewpoint/group-e-identity.md} +0 -0
  321. /package/src/orchestrator/templates/{ai-instructions/claude-agent-challenge.md → ai-src/agents/challenge.md} +0 -0
  322. /package/src/orchestrator/templates/{ai-instructions/claude-agent-discovery.md → ai-src/agents/discovery.md} +0 -0
  323. /package/src/orchestrator/templates/{ai-instructions/claude-agent-generator.md → ai-src/agents/generator.md} +0 -0
  324. /package/src/orchestrator/templates/{ai-instructions/claude-agent-reviewer.md → ai-src/agents/reviewer.md} +0 -0
  325. /package/src/orchestrator/templates/{ai-instructions/claude-config.md → ai-src/config/claude.md} +0 -0
  326. /package/src/orchestrator/templates/{ai-instructions/copilot-config.md → ai-src/config/copilot.md} +0 -0
  327. /package/{dist/orchestrator/templates/ai-instructions/github-skill-sungen-api-design.md → src/orchestrator/templates/ai-src/skills/sungen-api-design/SKILL.md} +0 -0
  328. /package/{dist/orchestrator/templates/ai-instructions/github-skill-sungen-capture.md → src/orchestrator/templates/ai-src/skills/sungen-capture/SKILL.md} +0 -0
  329. /package/{dist/orchestrator/templates/ai-instructions/github-skill-sungen-capture-mode-figma-mcp.md → src/orchestrator/templates/ai-src/skills/sungen-capture/mode-figma-mcp.md} +0 -0
  330. /package/{dist/orchestrator/templates/ai-instructions/github-skill-sungen-capture-mode-figma-pat.md → src/orchestrator/templates/ai-src/skills/sungen-capture/mode-figma-pat.md} +0 -0
  331. /package/{dist/orchestrator/templates/ai-instructions/github-skill-sungen-capture-mode-live.md → src/orchestrator/templates/ai-src/skills/sungen-capture/mode-live.md} +0 -0
  332. /package/{dist/orchestrator/templates/ai-instructions/github-skill-sungen-capture-mode-local.md → src/orchestrator/templates/ai-src/skills/sungen-capture/mode-local.md} +0 -0
  333. /package/{dist/orchestrator/templates/ai-instructions/github-skill-sungen-dashboard.md → src/orchestrator/templates/ai-src/skills/sungen-dashboard/SKILL.md} +0 -0
  334. /package/{dist/orchestrator/templates/ai-instructions/github-skill-sungen-delivery.md → src/orchestrator/templates/ai-src/skills/sungen-delivery/SKILL.md} +0 -0
  335. /package/{dist/orchestrator/templates/ai-instructions/github-skill-sungen-gherkin-syntax.md → src/orchestrator/templates/ai-src/skills/sungen-gherkin-syntax/SKILL.md} +0 -0
  336. /package/{dist/orchestrator/templates/ai-instructions/github-skill-sungen-ingest-legacy.md → src/orchestrator/templates/ai-src/skills/sungen-ingest-legacy/SKILL.md} +0 -0
  337. /package/{dist/orchestrator/templates/ai-instructions/github-skill-sungen-mobile-gestures.md → src/orchestrator/templates/ai-src/skills/sungen-mobile-gestures/SKILL.md} +0 -0
  338. /package/src/orchestrator/templates/{ai-instructions/claude-skill-selector-keys.md → ai-src/skills/sungen-selector-keys/SKILL.md} +0 -0
  339. /package/{dist/orchestrator/templates/ai-instructions/github-skill-sungen-tc-review.md → src/orchestrator/templates/ai-src/skills/sungen-tc-review/SKILL.md} +0 -0
  340. /package/{dist/orchestrator/templates/ai-instructions/github-skill-sungen-test-design-techniques.md → src/orchestrator/templates/ai-src/skills/sungen-test-design-techniques/SKILL.md} +0 -0
  341. /package/{dist/orchestrator/templates/ai-instructions/github-skill-sungen-viewpoint.md → src/orchestrator/templates/ai-src/skills/sungen-viewpoint/SKILL.md} +0 -0
  342. /package/{dist/orchestrator/templates/ai-instructions/github-skill-sungen-viewpoint-group-a-data-entry.md → src/orchestrator/templates/ai-src/skills/sungen-viewpoint/group-a-data-entry.md} +0 -0
  343. /package/{dist/orchestrator/templates/ai-instructions/github-skill-sungen-viewpoint-group-b-data-ops.md → src/orchestrator/templates/ai-src/skills/sungen-viewpoint/group-b-data-ops.md} +0 -0
  344. /package/{dist/orchestrator/templates/ai-instructions/github-skill-sungen-viewpoint-group-c-data-explore.md → src/orchestrator/templates/ai-src/skills/sungen-viewpoint/group-c-data-explore.md} +0 -0
  345. /package/{dist/orchestrator/templates/ai-instructions/github-skill-sungen-viewpoint-group-d-display.md → src/orchestrator/templates/ai-src/skills/sungen-viewpoint/group-d-display.md} +0 -0
  346. /package/{dist/orchestrator/templates/ai-instructions/github-skill-sungen-viewpoint-group-e-identity.md → src/orchestrator/templates/ai-src/skills/sungen-viewpoint/group-e-identity.md} +0 -0
@@ -6,11 +6,18 @@
6
6
 
7
7
  import * as fs from 'fs';
8
8
  import * as path from 'path';
9
+ import { readCapabilities } from '../harness/capability';
9
10
 
10
11
  export interface FlowOptions {
11
12
  name: string;
12
13
  path?: string;
13
14
  description?: string;
15
+ /**
16
+ * Mobile navigation recipe for the flow's starting screen. A `>`-separated list of nav steps
17
+ * that take the app from launch to the first screen in the flow. Scaffolded into the Background.
18
+ * Ignored (with a warning) for web projects.
19
+ */
20
+ reach?: string;
14
21
  }
15
22
 
16
23
  export class FlowManager {
@@ -25,6 +32,18 @@ export class FlowManager {
25
32
  async addFlow(options: FlowOptions): Promise<void> {
26
33
  this.validateFlowName(options.name);
27
34
 
35
+ // Detect project platform from qa/capabilities.yaml
36
+ const caps = readCapabilities(this.cwd);
37
+ const isMobile = caps.platform === 'mobile';
38
+
39
+ // --reach is mobile-only; warn and drop when the project is web
40
+ if (options.reach && !isMobile) {
41
+ console.warn(
42
+ `Warning: --reach is a mobile navigation recipe and is ignored for web projects. Dropping it.`
43
+ );
44
+ options = { ...options, reach: undefined };
45
+ }
46
+
28
47
  const flowName = this.normalizeFlowName(options.name);
29
48
  const flowDir = path.join(this.flowsDir, flowName);
30
49
 
@@ -59,28 +78,40 @@ export class FlowManager {
59
78
  process.exit(1);
60
79
  }
61
80
 
62
- fs.writeFileSync(featurePath, this.generateFeatureTemplate(options, flowName), 'utf-8');
81
+ fs.writeFileSync(featurePath, this.generateFeatureTemplate(options, flowName, isMobile), 'utf-8');
63
82
 
64
83
  const startPath = options.path || '/login';
65
- fs.writeFileSync(selectorPath, [
66
- `# ${options.name} Flow Selectors`,
67
- `# Namespace keys by screen to avoid duplicates: "login:submit", "awards:submit"`,
68
- ``,
69
- `# --- Login screen ---`,
70
- `login:`,
71
- ` type: 'page'`,
72
- ` value: '${startPath}'`,
73
- ``,
74
- `# "login:email":`,
75
- `# type: 'testid'`,
76
- `# value: 'email-input'`,
77
- ``,
78
- `# "login:submit":`,
79
- `# type: 'role'`,
80
- `# value: 'button'`,
81
- `# name: 'Login'`,
82
- ``,
83
- ].join('\n'), 'utf-8');
84
+ const selectorLines = isMobile
85
+ ? [
86
+ `# ${options.name} Flow Selectors (mobile)`,
87
+ `# Namespace keys by screen: "home:button", "settings:save"`,
88
+ `# Generated at /sungen:run-test via Appium MCP — accessibility-id preferred.`,
89
+ ``,
90
+ `# "home:element":`,
91
+ `# type: 'accessibility-id'`,
92
+ `# value: 'element-id'`,
93
+ ``,
94
+ ]
95
+ : [
96
+ `# ${options.name} Flow Selectors`,
97
+ `# Namespace keys by screen to avoid duplicates: "login:submit", "awards:submit"`,
98
+ ``,
99
+ `# --- Login screen ---`,
100
+ `login:`,
101
+ ` type: 'page'`,
102
+ ` value: '${startPath}'`,
103
+ ``,
104
+ `# "login:email":`,
105
+ `# type: 'testid'`,
106
+ `# value: 'email-input'`,
107
+ ``,
108
+ `# "login:submit":`,
109
+ `# type: 'role'`,
110
+ `# value: 'button'`,
111
+ `# name: 'Login'`,
112
+ ``,
113
+ ];
114
+ fs.writeFileSync(selectorPath, selectorLines.join('\n'), 'utf-8');
84
115
 
85
116
  fs.writeFileSync(testDataPath, [
86
117
  `# ${options.name} Flow Test Data`,
@@ -90,7 +121,7 @@ export class FlowManager {
90
121
  ].join('\n'), 'utf-8');
91
122
 
92
123
  const specPath = path.join(requirementsDir, 'spec.md');
93
- fs.writeFileSync(specPath, this.generateSpecTemplate(options, flowName), 'utf-8');
124
+ fs.writeFileSync(specPath, this.generateSpecTemplate(options, flowName, isMobile), 'utf-8');
94
125
 
95
126
  const viewpointPath = path.join(requirementsDir, 'test-viewpoint.md');
96
127
  fs.writeFileSync(viewpointPath, this.generateViewpointTemplate(options), 'utf-8');
@@ -104,12 +135,21 @@ export class FlowManager {
104
135
  console.log(` ${path.relative(this.cwd, requirementsUiDir)}/`);
105
136
  console.log('');
106
137
 
107
- console.log('Next steps:');
108
- console.log(` 1. Fill requirements/spec.md with flow specification (screens, transitions, business rules)`);
109
- console.log(` Optionally add UI designs to requirements/ui/`);
110
- console.log(` 2. Generate test cases: /sungen:create-test ${flowName}`);
111
- console.log(` 3. Compile: sungen generate --flow ${flowName}`);
112
- console.log(` 4. Run: npx playwright test\n`);
138
+ if (isMobile) {
139
+ console.log('Next steps:');
140
+ console.log(` 1. Fill requirements/spec.md with flow specification (screens, transitions, business rules)`);
141
+ console.log(` Use sungen-capture-mobile to scan each screen via Appium MCP`);
142
+ console.log(` 2. Generate test cases: /sungen:create-test ${flowName}`);
143
+ console.log(` 3. Compile: sungen generate --flow ${flowName} --framework appium`);
144
+ console.log(` 4. Run: npm run test:mobile\n`);
145
+ } else {
146
+ console.log('Next steps:');
147
+ console.log(` 1. Fill requirements/spec.md with flow specification (screens, transitions, business rules)`);
148
+ console.log(` Optionally add UI designs to requirements/ui/`);
149
+ console.log(` 2. Generate test cases: /sungen:create-test ${flowName}`);
150
+ console.log(` 3. Compile: sungen generate --flow ${flowName}`);
151
+ console.log(` 4. Run: npx playwright test\n`);
152
+ }
113
153
  }
114
154
 
115
155
  private validateFlowName(name: string): void {
@@ -131,7 +171,39 @@ export class FlowManager {
131
171
  .replace(/-+/g, '-');
132
172
  }
133
173
 
134
- private generateSpecTemplate(options: FlowOptions, flowName: string): string {
174
+ private generateSpecTemplate(options: FlowOptions, flowName: string, isMobile: boolean): string {
175
+ if (isMobile) {
176
+ return `# ${options.name} Flow Specification
177
+
178
+ ## Overview
179
+ - **Platform:** mobile (Android + iOS)
180
+ - **Auth Required:** no
181
+ - **Starting screen reach:** ${options.reach || '<!-- nav recipe to reach the first screen, e.g. "tap [Tab] > tap [Row]" -->'}
182
+
183
+ ## Screens in Flow
184
+ <!-- List all screens this flow visits, in order -->
185
+
186
+ | # | Screen | Reach | Description |
187
+ |---|--------|-------|-------------|
188
+ | 1 | [Screen Name] | tap [element] | [What user does here] |
189
+
190
+ ## Flow Steps
191
+
192
+ ### Step 1: [Screen Name]
193
+ - **Action:** [What the user taps]
194
+ - **Expected:** [What should happen]
195
+ - **Transition:** Navigates to Step 2
196
+
197
+ ## Business Rules
198
+ <!-- Rules that affect the flow: permissions, conditions, limits -->
199
+ - [Rule 1]
200
+
201
+ ## Notes
202
+ <!-- Edge cases, known issues, environment-specific behavior -->
203
+ - [Note 1]
204
+ `;
205
+ }
206
+
135
207
  const startPath = options.path || '/login';
136
208
  return `# ${options.name} Flow Specification
137
209
 
@@ -215,9 +287,33 @@ export class FlowManager {
215
287
  ].join('\n');
216
288
  }
217
289
 
218
- private generateFeatureTemplate(options: FlowOptions, flowName: string): string {
290
+ private generateFeatureTemplate(options: FlowOptions, flowName: string, isMobile: boolean): string {
219
291
  const description = options.description || `complete the ${options.name} flow`;
220
292
 
293
+ if (isMobile) {
294
+ const background = this.buildMobileBackground(options.reach);
295
+ return `@flow @platform:mobile
296
+ Feature: ${options.name} Flow
297
+
298
+ As a user
299
+ I want to ${description}
300
+ So that I can accomplish my end-to-end goal
301
+
302
+ # Mobile (Appium) flow — selectors use colon namespace: "home:element", "settings:save".
303
+ # See sungen-mobile-gestures for swipe/long-press/scroll steps.
304
+
305
+ ${background}
306
+ @high
307
+ Scenario: Sample step for ${options.name}
308
+ When User tap [Home:element]
309
+ Then User see [Settings] screen
310
+
311
+ Scenario: Sample next step for ${options.name}
312
+ When User tap [Settings:element]
313
+ Then User see [Result:header] header with {{result_text}}
314
+ `;
315
+ }
316
+
221
317
  return `@flow
222
318
  Feature: ${options.name} Flow
223
319
 
@@ -240,4 +336,44 @@ Feature: ${options.name} Flow
240
336
  Then User see "expected result" text
241
337
  `;
242
338
  }
339
+
340
+ /**
341
+ * Build the Background block for a mobile flow — same structure as screen-manager.
342
+ * The `--reach` steps represent how to reach the FIRST screen of the flow from app launch.
343
+ */
344
+ private buildMobileBackground(reach?: string): string {
345
+ const normalizeStep = (raw: string): string =>
346
+ raw
347
+ .trim()
348
+ .replace(/^(given|when|and|then|but)\s+/i, '')
349
+ .replace(/^user\s+/i, '')
350
+ .trim();
351
+
352
+ const steps = (reach || '')
353
+ .split('>')
354
+ .map(normalizeStep)
355
+ .filter(Boolean);
356
+
357
+ if (steps.length === 0) {
358
+ return [
359
+ ' Background:',
360
+ ' # Navigation recipe — how to reach the first screen of this flow from app launch.',
361
+ ' # Prefill with --reach "tap [Tab] > tap [Row]" at add-flow time.',
362
+ ' Given User is on [Home] screen',
363
+ ' # When User tap [<tab or button that leads to the first screen>]',
364
+ '',
365
+ ].join('\n');
366
+ }
367
+
368
+ const navLines = steps.map(
369
+ (body, i) => ` ${i === 0 ? 'When' : 'And'} User ${body}`,
370
+ );
371
+ return [
372
+ ' Background:',
373
+ ' # Navigation recipe — replayed by capture-mobile to land on the first screen.',
374
+ ' Given User is on [Home] screen',
375
+ ...navLines,
376
+ '',
377
+ ].join('\n');
378
+ }
243
379
  }
@@ -0,0 +1,277 @@
1
+ /**
2
+ * Mobile Runtime Scaffolder
3
+ *
4
+ * Emits the Appium/WebdriverIO harness files into a project directory.
5
+ * Called by ProjectInitializer (init --mobile) and, in Phase 02, by `capability add mobile`.
6
+ * Never duplicated — always imported from here.
7
+ */
8
+
9
+ import * as fs from 'fs';
10
+ import * as path from 'path';
11
+ import { spawnSync } from 'child_process';
12
+ import { writeCapabilities } from '../harness/capability';
13
+
14
+ export interface MobileInitOptions {
15
+ enabled: boolean;
16
+ /** Mobile-only project: skip all web (Playwright) scaffolding, deps, and Chromium download. */
17
+ mobileOnly?: boolean;
18
+ appPackage?: string;
19
+ appActivity?: string;
20
+ appApk?: string;
21
+ androidUdid?: string;
22
+ iosBundleId?: string;
23
+ iosDevice?: string;
24
+ iosVersion?: string;
25
+ }
26
+
27
+ export interface ScaffoldResult {
28
+ created: string[];
29
+ skipped: string[];
30
+ }
31
+
32
+ /** Read a template from the orchestrator's bundled templates directory. */
33
+ function readTemplate(filename: string): string {
34
+ const templatePath = path.join(__dirname, 'templates', filename);
35
+ return fs.readFileSync(templatePath, 'utf-8');
36
+ }
37
+
38
+ /**
39
+ * Emit the mobile runtime harness into `cwd`.
40
+ *
41
+ * Files written:
42
+ * wdio.conf.ts — project root (seeded from mobile options)
43
+ * specs/reporters/pw-shape-reporter.ts — Playwright-shaped JSON reporter for WDIO
44
+ * .env.appium — seeded from flags (gitignored)
45
+ * .env.appium.example — committed placeholder guide
46
+ *
47
+ * The caller is responsible for adding `test:mobile` to package.json scripts and
48
+ * writing qa/capabilities.yaml — helpers for both are exported below.
49
+ */
50
+ export function emitMobileRuntime(cwd: string, opts: MobileInitOptions): ScaffoldResult {
51
+ const created: string[] = [];
52
+ const skipped: string[] = [];
53
+
54
+ // wdio.conf.ts (project root) — substitute init-provided app defaults into the template
55
+ const wdioPath = path.join(cwd, 'wdio.conf.ts');
56
+ if (fs.existsSync(wdioPath)) {
57
+ skipped.push('wdio.conf.ts');
58
+ } else {
59
+ const content = readTemplate('wdio.conf.ts')
60
+ .replace('__APP_PACKAGE__', opts.appPackage || 'com.example.app')
61
+ // appActivity is optional — leave empty when not provided so UiAutomator2
62
+ // auto-resolves the launcher activity from appPackage. Only pin when explicitly passed.
63
+ .replace('__APP_ACTIVITY__', opts.appActivity || '')
64
+ .replace('__ANDROID_UDID__', opts.androidUdid || 'emulator-5554')
65
+ .replace('__IOS_BUNDLE_ID__', opts.iosBundleId || 'com.example.app')
66
+ .replace('__IOS_DEVICE__', opts.iosDevice || 'iPhone 16')
67
+ .replace('__IOS_VERSION__', opts.iosVersion || '18.0');
68
+ fs.writeFileSync(wdioPath, content, 'utf-8');
69
+ created.push('wdio.conf.ts');
70
+ }
71
+
72
+ // specs/reporters/pw-shape-reporter.ts
73
+ const reporterPath = path.join(cwd, 'specs', 'reporters', 'pw-shape-reporter.ts');
74
+ if (fs.existsSync(reporterPath)) {
75
+ skipped.push('specs/reporters/pw-shape-reporter.ts');
76
+ } else {
77
+ fs.mkdirSync(path.dirname(reporterPath), { recursive: true });
78
+ fs.writeFileSync(reporterPath, readTemplate('specs-pw-shape-reporter.ts'), 'utf-8');
79
+ created.push('specs/reporters/pw-shape-reporter.ts');
80
+ }
81
+
82
+ // .env.appium — seeded from the flags that were provided; env vars that were not passed
83
+ // are left commented out so the file is a useful guide without imposing bogus values.
84
+ const envPath = path.join(cwd, '.env.appium');
85
+ if (fs.existsSync(envPath)) {
86
+ skipped.push('.env.appium');
87
+ } else {
88
+ const lines: string[] = [
89
+ '# .env.appium — loaded by wdio.conf.ts. Shell exports override these values.',
90
+ '# See .env.appium.example for the full reference.',
91
+ '',
92
+ ];
93
+ if (opts.appPackage) lines.push(`APP_PACKAGE=${opts.appPackage}`);
94
+ if (opts.appActivity) lines.push(`APP_ACTIVITY=${opts.appActivity}`);
95
+ if (opts.appApk) lines.push(`APP_APK=${opts.appApk}`);
96
+ if (opts.androidUdid) lines.push(`ANDROID_UDID=${opts.androidUdid}`);
97
+ if (opts.iosBundleId) lines.push(`IOS_BUNDLE_ID=${opts.iosBundleId}`);
98
+ if (opts.iosDevice) lines.push(`IOS_DEVICE=${opts.iosDevice}`);
99
+ if (opts.iosVersion) lines.push(`IOS_VERSION=${opts.iosVersion}`);
100
+ lines.push('');
101
+ fs.writeFileSync(envPath, lines.join('\n'), 'utf-8');
102
+ created.push('.env.appium');
103
+ }
104
+
105
+ // .env.appium.example — committed placeholder guide (template stored without leading dot
106
+ // so copy-templates' glob picks it up; the output file gets the dot).
107
+ const envExamplePath = path.join(cwd, '.env.appium.example');
108
+ if (fs.existsSync(envExamplePath)) {
109
+ skipped.push('.env.appium.example');
110
+ } else {
111
+ fs.writeFileSync(envExamplePath, readTemplate('env.appium.example'), 'utf-8');
112
+ created.push('.env.appium.example');
113
+ }
114
+
115
+ return { created, skipped };
116
+ }
117
+
118
+ /**
119
+ * Write qa/capabilities.yaml for a mobile project.
120
+ * Uses the canonical writeCapabilities from harness/capability so the format is always consistent.
121
+ */
122
+ export function writeMobileCapabilities(cwd: string): string {
123
+ return writeCapabilities(cwd, { platform: 'mobile', enabled: ['mobile'] });
124
+ }
125
+
126
+ /**
127
+ * Resolve the install spec for `@sungen/driver-mobile`.
128
+ *
129
+ * In a monorepo checkout (dev / dogfood) the driver lives at `packages/driver-mobile` next to core and
130
+ * is NOT published to the registry — so we install it by `file:` path. In a published install (core in
131
+ * node_modules, no sibling package) we fall back to the registry pinned to the core version (lockstep).
132
+ *
133
+ * Why: a bare `@sungen/driver-mobile@<coreVersion>` hits npm E404 whenever the driver is unpublished or
134
+ * the consuming project lives outside the workspace (`test-mobile/`). The local `file:` path makes the
135
+ * dev/dogfood path work without the registry, while the registry fallback preserves lockstep for users.
136
+ */
137
+ function resolveMobileDriverSpec(): string {
138
+ // From this file (src/orchestrator OR dist/orchestrator) the sibling driver package is ../../../driver-mobile.
139
+ const localDriverDir = path.resolve(__dirname, '..', '..', '..', 'driver-mobile');
140
+ if (fs.existsSync(path.join(localDriverDir, 'package.json'))) {
141
+ return `file:${localDriverDir}`;
142
+ }
143
+ let coreVersion = 'latest';
144
+ try {
145
+ coreVersion = require('../../package.json').version || 'latest';
146
+ } catch {
147
+ // noop — fall back to latest
148
+ }
149
+ return `@sungen/driver-mobile@${coreVersion}`;
150
+ }
151
+
152
+ /** Best-effort `npm install -D <specs…> [extraArgs…]` in `cwd`. Returns true on exit code 0. */
153
+ function npmInstallDev(cwd: string, specs: string[], extraArgs: string[] = []): boolean {
154
+ const result = spawnSync('npm', ['install', '-D', ...specs, ...extraArgs], { cwd, stdio: 'inherit', shell: true });
155
+ return result.status === 0;
156
+ }
157
+
158
+ /**
159
+ * Locate the project's locally-installed appium CLI bin. Walks up from `cwd` so it works whether the
160
+ * appium dep is nested under @sungen/driver-mobile or hoisted to a parent node_modules/.bin. Returns
161
+ * null when appium is not installed in the project (then we skip cleanly — no `npx` auto-fetch).
162
+ */
163
+ function appiumBinPath(cwd: string): string | null {
164
+ const binName = process.platform === 'win32' ? 'appium.cmd' : 'appium';
165
+ let dir = path.resolve(cwd);
166
+ for (let i = 0; i < 8; i++) {
167
+ const bin = path.join(dir, 'node_modules', '.bin', binName);
168
+ if (fs.existsSync(bin)) return bin;
169
+ const parent = path.dirname(dir);
170
+ if (parent === dir) break;
171
+ dir = parent;
172
+ }
173
+ return null;
174
+ }
175
+
176
+ /** Appium platform drivers already installed in ~/.appium (per-user). Empty set if it can't tell. */
177
+ function installedAppiumDrivers(appiumBin: string, cwd: string): Set<string> {
178
+ const r = spawnSync(appiumBin, ['driver', 'list', '--installed', '--json'], { cwd, encoding: 'utf-8' });
179
+ if (r.status !== 0 || !r.stdout) return new Set();
180
+ try { return new Set(Object.keys(JSON.parse(r.stdout))); } catch { return new Set(); }
181
+ }
182
+
183
+ /**
184
+ * Auto-install the Appium PLATFORM drivers needed for ANY session — both the appium-mcp live capture
185
+ * (`/sungen:create-test`) and the wdio runner (`/sungen:run-test`). Provisioned by the SAME code path
186
+ * that installs @sungen/driver-mobile (right after its `appium` dep is installed). Best-effort + idempotent.
187
+ *
188
+ * - `uiautomator2` (Android): cross-platform → always.
189
+ * - `xcuitest` (iOS): macOS-only — it builds WebDriverAgent via Xcode at RUN time, usable only on a
190
+ * Mac → installed only on darwin; elsewhere we print the command for when on a Mac.
191
+ *
192
+ * Runs the project-local appium bin directly (NOT `npx`, which would either auto-fetch a latest appium
193
+ * or hard-fail with `--no-install`). If appium isn't installed in the project, skip with a clear hint.
194
+ */
195
+ function installAppiumPlatformDrivers(cwd: string): void {
196
+ const appiumBin = appiumBinPath(cwd);
197
+ if (!appiumBin) {
198
+ console.warn(
199
+ '⚠️ appium is not installed in the project — skipping platform-driver install.\n' +
200
+ ' Install the mobile runtime first (the @sungen/driver-mobile deps via `npm install`), then run:\n' +
201
+ ` npx appium driver install uiautomator2${process.platform === 'darwin' ? ' (+ xcuitest)' : ''}`,
202
+ );
203
+ return;
204
+ }
205
+ const installed = installedAppiumDrivers(appiumBin, cwd);
206
+ const want = ['uiautomator2', ...(process.platform === 'darwin' ? ['xcuitest'] : [])];
207
+ for (const drv of want) {
208
+ if (installed.has(drv)) { console.log(`✓ appium driver "${drv}" already installed.`); continue; }
209
+ console.log(`📦 Installing appium driver "${drv}"...`);
210
+ const r = spawnSync(appiumBin, ['driver', 'install', drv], { cwd, stdio: 'inherit' });
211
+ if (!r || r.status !== 0) {
212
+ console.warn(`⚠️ appium driver "${drv}" not installed (best-effort) — retry: npx appium driver install ${drv}`);
213
+ }
214
+ }
215
+ if (process.platform !== 'darwin') {
216
+ console.log('ℹ️ iOS (xcuitest) is macOS-only (needs Xcode at run time) — skipped on this OS. On a Mac: npx appium driver install xcuitest');
217
+ }
218
+ }
219
+
220
+ /**
221
+ * Best-effort provision of the mobile runtime into a project that has opted into mobile
222
+ * (`sungen init --mobile` / `sungen capability add mobile` — never auto-run; consent-gated).
223
+ *
224
+ * Installs everything the runner needs:
225
+ * 1. `@sungen/driver-mobile` + its WebdriverIO/Appium runtime (declared as that package's `dependencies`).
226
+ * A local `file:` spec (dev/dogfood) uses `npm install --install-links` so npm COPIES the package and
227
+ * installs its transitive deps — a plain file: install only SYMLINKS it and skips the runtime. A
228
+ * published/registry spec installs deps normally.
229
+ * 2. the appium PLATFORM drivers (uiautomator2 / xcuitest, ~/.appium-managed) — NOT npm packages, so
230
+ * installed via the appium CLI here (installAppiumPlatformDrivers), so a session can actually start.
231
+ *
232
+ * Non-fatal: logs a warning on failure so offline/air-gapped init still scaffolds correctly.
233
+ *
234
+ * @returns true if the driver install succeeded (or was already present), false on failure
235
+ */
236
+ export function installMobileDriver(cwd: string): boolean {
237
+ const driverSpec = resolveMobileDriverSpec();
238
+
239
+ // A `file:` spec (unpublished dev/dogfood driver) MUST install with --install-links: a plain file:
240
+ // install only SYMLINKS the package and skips its transitive deps, so the wdio/appium runtime never
241
+ // lands in the project. --install-links makes npm COPY it and install those deps. Registry specs
242
+ // install deps normally, so the flag is omitted there.
243
+ const isFileSpec = driverSpec.startsWith('file:');
244
+
245
+ // Provisioned only when BOTH the driver dep AND its appium runtime are present — a driver that was
246
+ // symlinked earlier (no runtime) must be re-installed (with --install-links) to actually pull appium.
247
+ let hasDriverDep = false;
248
+ try {
249
+ const pkgJsonPath = path.join(cwd, 'package.json');
250
+ if (fs.existsSync(pkgJsonPath)) {
251
+ const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf-8'));
252
+ const allDeps = { ...pkg.dependencies, ...pkg.devDependencies };
253
+ hasDriverDep = !!allDeps['@sungen/driver-mobile'];
254
+ }
255
+ } catch {
256
+ // proceed to install
257
+ }
258
+ const runtimeReady = hasDriverDep && appiumBinPath(cwd) !== null;
259
+
260
+ let driverOk = runtimeReady;
261
+ if (!runtimeReady) {
262
+ console.log(`📦 Installing mobile driver + runtime (${driverSpec})...`);
263
+ driverOk = npmInstallDev(cwd, [driverSpec], isFileSpec ? ['--install-links'] : []);
264
+ if (!driverOk) {
265
+ console.warn(
266
+ `⚠️ Could not install ${driverSpec} — scaffold is complete but the mobile driver is not installed.\n` +
267
+ ` Install manually later: npm install -D ${driverSpec}${isFileSpec ? ' --install-links' : ''}`,
268
+ );
269
+ }
270
+ }
271
+
272
+ // Appium platform driver(s) — REQUIRED for any session (appium-mcp live capture AND the wdio runner).
273
+ // NOT npm packages, so installed via the appium CLI here, by the same code path that installs the driver.
274
+ installAppiumPlatformDrivers(cwd);
275
+
276
+ return driverOk;
277
+ }