@sun-asterisk/sungen 3.2.24 → 3.2.26

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 (345) hide show
  1. package/dist/capabilities/context-router.d.ts.map +1 -1
  2. package/dist/capabilities/context-router.js +15 -7
  3. package/dist/capabilities/context-router.js.map +1 -1
  4. package/dist/cli/commands/audit.d.ts.map +1 -1
  5. package/dist/cli/commands/audit.js +23 -4
  6. package/dist/cli/commands/audit.js.map +1 -1
  7. package/dist/cli/commands/capability.d.ts.map +1 -1
  8. package/dist/cli/commands/capability.js +6 -48
  9. package/dist/cli/commands/capability.js.map +1 -1
  10. package/dist/cli/commands/changed.d.ts +14 -0
  11. package/dist/cli/commands/changed.d.ts.map +1 -0
  12. package/dist/cli/commands/changed.js +128 -0
  13. package/dist/cli/commands/changed.js.map +1 -0
  14. package/dist/cli/commands/delivery.d.ts.map +1 -1
  15. package/dist/cli/commands/delivery.js +25 -1
  16. package/dist/cli/commands/delivery.js.map +1 -1
  17. package/dist/cli/commands/generate.js +1 -1
  18. package/dist/cli/commands/generate.js.map +1 -1
  19. package/dist/cli/commands/results-merge.d.ts +19 -0
  20. package/dist/cli/commands/results-merge.d.ts.map +1 -0
  21. package/dist/cli/commands/results-merge.js +191 -0
  22. package/dist/cli/commands/results-merge.js.map +1 -0
  23. package/dist/cli/commands/update.d.ts.map +1 -1
  24. package/dist/cli/commands/update.js +100 -12
  25. package/dist/cli/commands/update.js.map +1 -1
  26. package/dist/cli/index.js +4 -0
  27. package/dist/cli/index.js.map +1 -1
  28. package/dist/exporters/api-catalog-loader.d.ts.map +1 -1
  29. package/dist/exporters/api-catalog-loader.js +10 -3
  30. package/dist/exporters/api-catalog-loader.js.map +1 -1
  31. package/dist/exporters/api-testcase-formatter.d.ts +9 -0
  32. package/dist/exporters/api-testcase-formatter.d.ts.map +1 -1
  33. package/dist/exporters/api-testcase-formatter.js +55 -3
  34. package/dist/exporters/api-testcase-formatter.js.map +1 -1
  35. package/dist/exporters/csv-exporter.d.ts.map +1 -1
  36. package/dist/exporters/csv-exporter.js +10 -1
  37. package/dist/exporters/csv-exporter.js.map +1 -1
  38. package/dist/exporters/json-exporter.d.ts.map +1 -1
  39. package/dist/exporters/json-exporter.js +6 -1
  40. package/dist/exporters/json-exporter.js.map +1 -1
  41. package/dist/exporters/matrix/build.d.ts.map +1 -1
  42. package/dist/exporters/matrix/build.js +14 -1
  43. package/dist/exporters/matrix/build.js.map +1 -1
  44. package/dist/exporters/matrix/export.js +1 -1
  45. package/dist/exporters/matrix/export.js.map +1 -1
  46. package/dist/exporters/matrix/map-loader.d.ts.map +1 -1
  47. package/dist/exporters/matrix/map-loader.js +5 -0
  48. package/dist/exporters/matrix/map-loader.js.map +1 -1
  49. package/dist/exporters/matrix/render-csv.d.ts.map +1 -1
  50. package/dist/exporters/matrix/render-csv.js +5 -1
  51. package/dist/exporters/matrix/render-csv.js.map +1 -1
  52. package/dist/exporters/matrix/render-xlsx.d.ts.map +1 -1
  53. package/dist/exporters/matrix/render-xlsx.js +4 -1
  54. package/dist/exporters/matrix/render-xlsx.js.map +1 -1
  55. package/dist/exporters/matrix/types.d.ts +18 -0
  56. package/dist/exporters/matrix/types.d.ts.map +1 -1
  57. package/dist/exporters/matrix/types.js.map +1 -1
  58. package/dist/exporters/playwright-report-parser.d.ts +17 -2
  59. package/dist/exporters/playwright-report-parser.d.ts.map +1 -1
  60. package/dist/exporters/playwright-report-parser.js +68 -8
  61. package/dist/exporters/playwright-report-parser.js.map +1 -1
  62. package/dist/exporters/results-merge.d.ts +46 -0
  63. package/dist/exporters/results-merge.d.ts.map +1 -0
  64. package/dist/exporters/results-merge.js +148 -0
  65. package/dist/exporters/results-merge.js.map +1 -0
  66. package/dist/exporters/selector-key-resolver.d.ts +4 -0
  67. package/dist/exporters/selector-key-resolver.d.ts.map +1 -1
  68. package/dist/exporters/selector-key-resolver.js +101 -1
  69. package/dist/exporters/selector-key-resolver.js.map +1 -1
  70. package/dist/exporters/types.d.ts +8 -1
  71. package/dist/exporters/types.d.ts.map +1 -1
  72. package/dist/exporters/xlsx-report-builder.d.ts.map +1 -1
  73. package/dist/exporters/xlsx-report-builder.js +5 -4
  74. package/dist/exporters/xlsx-report-builder.js.map +1 -1
  75. package/dist/generators/gherkin-parser/index.d.ts +2 -0
  76. package/dist/generators/gherkin-parser/index.d.ts.map +1 -1
  77. package/dist/generators/gherkin-parser/index.js +52 -1
  78. package/dist/generators/gherkin-parser/index.js.map +1 -1
  79. package/dist/generators/test-generator/adapters/adapter-interface.d.ts +20 -10
  80. package/dist/generators/test-generator/adapters/adapter-interface.d.ts.map +1 -1
  81. package/dist/generators/test-generator/adapters/appium/appium-adapter.d.ts +2 -11
  82. package/dist/generators/test-generator/adapters/appium/appium-adapter.d.ts.map +1 -1
  83. package/dist/generators/test-generator/adapters/appium/appium-adapter.js.map +1 -1
  84. package/dist/generators/test-generator/adapters/appium/templates/imports.hbs +3 -0
  85. package/dist/generators/test-generator/adapters/appium/templates/steps/actions/date-picker-unsupported.hbs +4 -0
  86. package/dist/generators/test-generator/adapters/appium/templates/steps/actions/lifecycle-missing-app-id.hbs +5 -0
  87. package/dist/generators/test-generator/adapters/appium/templates/steps/assertions/matches-format-assertion.hbs +15 -0
  88. package/dist/generators/test-generator/adapters/appium/templates/steps/assertions/visible-filtered-assertion.hbs +5 -2
  89. package/dist/generators/test-generator/adapters/appium/templates/test-file.hbs +185 -26
  90. package/dist/generators/test-generator/adapters/playwright/playwright-adapter.d.ts +2 -11
  91. package/dist/generators/test-generator/adapters/playwright/playwright-adapter.d.ts.map +1 -1
  92. package/dist/generators/test-generator/adapters/playwright/playwright-adapter.js.map +1 -1
  93. package/dist/generators/test-generator/adapters/playwright/templates/imports.hbs +3 -0
  94. package/dist/generators/test-generator/adapters/playwright/templates/steps/actions/select-action.hbs +17 -1
  95. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/attribute-assertion.hbs +6 -1
  96. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/have-value-assertion.hbs +18 -1
  97. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/hidden-with-filter-assertion.hbs +5 -1
  98. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/matches-format-assertion.hbs +5 -0
  99. package/dist/generators/test-generator/adapters/playwright/templates/steps/assertions/state-with-filter-assertion.hbs +4 -2
  100. package/dist/generators/test-generator/adapters/playwright/templates/steps/navigation/wait-for-element-with-text.hbs +4 -1
  101. package/dist/generators/test-generator/adapters/playwright/templates/steps/partials/recipe-expect-text.hbs +1 -1
  102. package/dist/generators/test-generator/code-generator.d.ts +6 -0
  103. package/dist/generators/test-generator/code-generator.d.ts.map +1 -1
  104. package/dist/generators/test-generator/code-generator.js +80 -7
  105. package/dist/generators/test-generator/code-generator.js.map +1 -1
  106. package/dist/generators/test-generator/diagnostics.d.ts +60 -6
  107. package/dist/generators/test-generator/diagnostics.d.ts.map +1 -1
  108. package/dist/generators/test-generator/diagnostics.js +59 -5
  109. package/dist/generators/test-generator/diagnostics.js.map +1 -1
  110. package/dist/generators/test-generator/patterns/expect-patterns.d.ts +7 -0
  111. package/dist/generators/test-generator/patterns/expect-patterns.d.ts.map +1 -1
  112. package/dist/generators/test-generator/patterns/expect-patterns.js +36 -2
  113. package/dist/generators/test-generator/patterns/expect-patterns.js.map +1 -1
  114. package/dist/generators/test-generator/patterns/index.d.ts +19 -12
  115. package/dist/generators/test-generator/patterns/index.d.ts.map +1 -1
  116. package/dist/generators/test-generator/patterns/index.js +58 -38
  117. package/dist/generators/test-generator/patterns/index.js.map +1 -1
  118. package/dist/generators/test-generator/patterns/types.d.ts +23 -0
  119. package/dist/generators/test-generator/patterns/types.d.ts.map +1 -1
  120. package/dist/generators/test-generator/patterns/unsupported-step-code.d.ts +18 -0
  121. package/dist/generators/test-generator/patterns/unsupported-step-code.d.ts.map +1 -0
  122. package/dist/generators/test-generator/patterns/unsupported-step-code.js +23 -0
  123. package/dist/generators/test-generator/patterns/unsupported-step-code.js.map +1 -0
  124. package/dist/generators/test-generator/recipe-expander.js +9 -1
  125. package/dist/generators/test-generator/recipe-expander.js.map +1 -1
  126. package/dist/generators/test-generator/reset-tier.d.ts +68 -0
  127. package/dist/generators/test-generator/reset-tier.d.ts.map +1 -0
  128. package/dist/generators/test-generator/reset-tier.js +94 -0
  129. package/dist/generators/test-generator/reset-tier.js.map +1 -0
  130. package/dist/generators/test-generator/step-mapper.d.ts +39 -0
  131. package/dist/generators/test-generator/step-mapper.d.ts.map +1 -1
  132. package/dist/generators/test-generator/step-mapper.js +144 -5
  133. package/dist/generators/test-generator/step-mapper.js.map +1 -1
  134. package/dist/generators/test-generator/template-engine.d.ts +2 -10
  135. package/dist/generators/test-generator/template-engine.d.ts.map +1 -1
  136. package/dist/generators/test-generator/template-engine.js +16 -2
  137. package/dist/generators/test-generator/template-engine.js.map +1 -1
  138. package/dist/generators/test-generator/utils/format-pattern.d.ts +35 -0
  139. package/dist/generators/test-generator/utils/format-pattern.d.ts.map +1 -0
  140. package/dist/generators/test-generator/utils/format-pattern.js +82 -0
  141. package/dist/generators/test-generator/utils/format-pattern.js.map +1 -0
  142. package/dist/generators/test-generator/utils/js-literal-scanner.d.ts +42 -0
  143. package/dist/generators/test-generator/utils/js-literal-scanner.d.ts.map +1 -0
  144. package/dist/generators/test-generator/utils/js-literal-scanner.js +142 -0
  145. package/dist/generators/test-generator/utils/js-literal-scanner.js.map +1 -0
  146. package/dist/generators/test-generator/utils/mask-refs-for-matching.d.ts +18 -0
  147. package/dist/generators/test-generator/utils/mask-refs-for-matching.d.ts.map +1 -0
  148. package/dist/generators/test-generator/utils/mask-refs-for-matching.js +25 -0
  149. package/dist/generators/test-generator/utils/mask-refs-for-matching.js.map +1 -0
  150. package/dist/generators/test-generator/utils/runtime-data-transformer.d.ts +9 -1
  151. package/dist/generators/test-generator/utils/runtime-data-transformer.d.ts.map +1 -1
  152. package/dist/generators/test-generator/utils/runtime-data-transformer.js +124 -63
  153. package/dist/generators/test-generator/utils/runtime-data-transformer.js.map +1 -1
  154. package/dist/generators/test-generator/utils/selector-resolver.d.ts.map +1 -1
  155. package/dist/generators/test-generator/utils/selector-resolver.js +20 -1
  156. package/dist/generators/test-generator/utils/selector-resolver.js.map +1 -1
  157. package/dist/generators/test-generator/utils/spec-syntax-check.d.ts +14 -0
  158. package/dist/generators/test-generator/utils/spec-syntax-check.d.ts.map +1 -0
  159. package/dist/generators/test-generator/utils/spec-syntax-check.js +26 -0
  160. package/dist/generators/test-generator/utils/spec-syntax-check.js.map +1 -0
  161. package/dist/harness/annotation-overrides.d.ts +0 -12
  162. package/dist/harness/annotation-overrides.d.ts.map +1 -1
  163. package/dist/harness/annotation-overrides.js +9 -5
  164. package/dist/harness/annotation-overrides.js.map +1 -1
  165. package/dist/harness/audit.d.ts +7 -0
  166. package/dist/harness/audit.d.ts.map +1 -1
  167. package/dist/harness/audit.js +78 -10
  168. package/dist/harness/audit.js.map +1 -1
  169. package/dist/harness/capability-plan.d.ts +2 -1
  170. package/dist/harness/capability-plan.d.ts.map +1 -1
  171. package/dist/harness/capability-plan.js +8 -3
  172. package/dist/harness/capability-plan.js.map +1 -1
  173. package/dist/harness/capability.d.ts +11 -0
  174. package/dist/harness/capability.d.ts.map +1 -1
  175. package/dist/harness/capability.js +8 -0
  176. package/dist/harness/capability.js.map +1 -1
  177. package/dist/harness/catalog/drivers.yaml +5 -0
  178. package/dist/harness/flow-contract.d.ts +18 -1
  179. package/dist/harness/flow-contract.d.ts.map +1 -1
  180. package/dist/harness/flow-contract.js +72 -9
  181. package/dist/harness/flow-contract.js.map +1 -1
  182. package/dist/harness/parse.d.ts.map +1 -1
  183. package/dist/harness/parse.js +5 -1
  184. package/dist/harness/parse.js.map +1 -1
  185. package/dist/harness/quality-gates.d.ts +12 -1
  186. package/dist/harness/quality-gates.d.ts.map +1 -1
  187. package/dist/harness/quality-gates.js +62 -7
  188. package/dist/harness/quality-gates.js.map +1 -1
  189. package/dist/harness/run-manifest.d.ts +58 -0
  190. package/dist/harness/run-manifest.d.ts.map +1 -0
  191. package/dist/harness/run-manifest.js +264 -0
  192. package/dist/harness/run-manifest.js.map +1 -0
  193. package/dist/harness/spec-branches.d.ts +88 -0
  194. package/dist/harness/spec-branches.d.ts.map +1 -0
  195. package/dist/harness/spec-branches.js +280 -0
  196. package/dist/harness/spec-branches.js.map +1 -0
  197. package/dist/harness/spec-coverage.d.ts +1 -1
  198. package/dist/harness/spec-coverage.js +4 -4
  199. package/dist/harness/spec-coverage.js.map +1 -1
  200. package/dist/harness/viewpoint-baseline.d.ts +9 -0
  201. package/dist/harness/viewpoint-baseline.d.ts.map +1 -1
  202. package/dist/harness/viewpoint-baseline.js +33 -3
  203. package/dist/harness/viewpoint-baseline.js.map +1 -1
  204. package/dist/harness/viewpoint-ledger.d.ts +1 -1
  205. package/dist/harness/viewpoint-ledger.d.ts.map +1 -1
  206. package/dist/harness/viewpoint-ledger.js +88 -9
  207. package/dist/harness/viewpoint-ledger.js.map +1 -1
  208. package/dist/index.d.ts +1 -0
  209. package/dist/index.d.ts.map +1 -1
  210. package/dist/index.js +5 -1
  211. package/dist/index.js.map +1 -1
  212. package/dist/orchestrator/lockstep-version.d.ts +22 -0
  213. package/dist/orchestrator/lockstep-version.d.ts.map +1 -0
  214. package/dist/orchestrator/lockstep-version.js +58 -0
  215. package/dist/orchestrator/lockstep-version.js.map +1 -0
  216. package/dist/orchestrator/project-deps-sync.d.ts +39 -0
  217. package/dist/orchestrator/project-deps-sync.d.ts.map +1 -0
  218. package/dist/orchestrator/project-deps-sync.js +175 -0
  219. package/dist/orchestrator/project-deps-sync.js.map +1 -0
  220. package/dist/orchestrator/project-initializer.d.ts.map +1 -1
  221. package/dist/orchestrator/project-initializer.js +5 -2
  222. package/dist/orchestrator/project-initializer.js.map +1 -1
  223. package/dist/orchestrator/templates/ai-src/commands/add-flow.md +16 -0
  224. package/dist/orchestrator/templates/ai-src/commands/create-test.md +9 -0
  225. package/dist/orchestrator/templates/ai-src/commands/delivery.md +9 -2
  226. package/dist/orchestrator/templates/ai-src/commands/run-test.md +109 -0
  227. package/dist/orchestrator/templates/ai-src/config/claude.md +1 -1
  228. package/dist/orchestrator/templates/ai-src/config/copilot.md +1 -1
  229. package/dist/orchestrator/templates/ai-src/skills/sungen-api-design/SKILL.md +49 -0
  230. package/dist/orchestrator/templates/ai-src/skills/sungen-error-mapping/SKILL.md +14 -3
  231. package/dist/orchestrator/templates/ai-src/skills/sungen-gherkin-syntax/SKILL.md +110 -6
  232. package/dist/orchestrator/templates/ai-src/skills/sungen-locale/SKILL.md +1 -1
  233. package/dist/orchestrator/templates/ai-src/skills/sungen-mobile-gestures/SKILL.md +8 -0
  234. package/dist/orchestrator/templates/ai-src/skills/sungen-selector-fix/SKILL.md +1 -1
  235. package/dist/orchestrator/templates/ai-src/skills/sungen-tc-generation/SKILL.md +40 -1
  236. package/dist/orchestrator/templates/ai-src/skills/sungen-tc-review/SKILL.md +15 -0
  237. package/dist/orchestrator/templates/env.appium.example +10 -0
  238. package/dist/orchestrator/templates/specs-api.d.ts +4 -2
  239. package/dist/orchestrator/templates/specs-api.d.ts.map +1 -1
  240. package/dist/orchestrator/templates/specs-api.js +233 -10
  241. package/dist/orchestrator/templates/specs-api.js.map +1 -1
  242. package/dist/orchestrator/templates/specs-api.ts +214 -11
  243. package/dist/orchestrator/templates/specs-regex-escape.d.ts +13 -0
  244. package/dist/orchestrator/templates/specs-regex-escape.d.ts.map +1 -0
  245. package/dist/orchestrator/templates/specs-regex-escape.js +19 -0
  246. package/dist/orchestrator/templates/specs-regex-escape.js.map +1 -0
  247. package/dist/orchestrator/templates/specs-regex-escape.ts +16 -0
  248. package/dist/orchestrator/templates/specs-test-data.ts +53 -6
  249. package/dist/orchestrator/templates/wdio.conf.ts +28 -9
  250. package/package.json +8 -6
  251. package/src/capabilities/context-router.ts +13 -5
  252. package/src/cli/commands/audit.ts +22 -3
  253. package/src/cli/commands/capability.ts +4 -38
  254. package/src/cli/commands/changed.ts +104 -0
  255. package/src/cli/commands/delivery.ts +27 -2
  256. package/src/cli/commands/generate.ts +1 -1
  257. package/src/cli/commands/results-merge.ts +153 -0
  258. package/src/cli/commands/update.ts +72 -13
  259. package/src/cli/index.ts +4 -0
  260. package/src/exporters/api-catalog-loader.ts +10 -2
  261. package/src/exporters/api-testcase-formatter.ts +59 -3
  262. package/src/exporters/csv-exporter.ts +11 -2
  263. package/src/exporters/json-exporter.ts +7 -2
  264. package/src/exporters/matrix/build.ts +13 -1
  265. package/src/exporters/matrix/export.ts +1 -1
  266. package/src/exporters/matrix/map-loader.ts +5 -0
  267. package/src/exporters/matrix/render-csv.ts +5 -1
  268. package/src/exporters/matrix/render-xlsx.ts +4 -1
  269. package/src/exporters/matrix/types.ts +18 -0
  270. package/src/exporters/playwright-report-parser.ts +68 -9
  271. package/src/exporters/results-merge.ts +150 -0
  272. package/src/exporters/selector-key-resolver.ts +81 -1
  273. package/src/exporters/types.ts +8 -1
  274. package/src/exporters/xlsx-report-builder.ts +5 -4
  275. package/src/generators/gherkin-parser/index.ts +55 -1
  276. package/src/generators/test-generator/adapters/adapter-interface.ts +23 -1
  277. package/src/generators/test-generator/adapters/appium/appium-adapter.ts +2 -2
  278. package/src/generators/test-generator/adapters/appium/templates/imports.hbs +3 -0
  279. package/src/generators/test-generator/adapters/appium/templates/steps/actions/date-picker-unsupported.hbs +4 -0
  280. package/src/generators/test-generator/adapters/appium/templates/steps/actions/lifecycle-missing-app-id.hbs +5 -0
  281. package/src/generators/test-generator/adapters/appium/templates/steps/assertions/matches-format-assertion.hbs +15 -0
  282. package/src/generators/test-generator/adapters/appium/templates/steps/assertions/visible-filtered-assertion.hbs +5 -2
  283. package/src/generators/test-generator/adapters/appium/templates/test-file.hbs +185 -26
  284. package/src/generators/test-generator/adapters/playwright/playwright-adapter.ts +2 -2
  285. package/src/generators/test-generator/adapters/playwright/templates/imports.hbs +3 -0
  286. package/src/generators/test-generator/adapters/playwright/templates/steps/actions/select-action.hbs +17 -1
  287. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/attribute-assertion.hbs +6 -1
  288. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/have-value-assertion.hbs +18 -1
  289. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/hidden-with-filter-assertion.hbs +5 -1
  290. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/matches-format-assertion.hbs +5 -0
  291. package/src/generators/test-generator/adapters/playwright/templates/steps/assertions/state-with-filter-assertion.hbs +4 -2
  292. package/src/generators/test-generator/adapters/playwright/templates/steps/navigation/wait-for-element-with-text.hbs +4 -1
  293. package/src/generators/test-generator/adapters/playwright/templates/steps/partials/recipe-expect-text.hbs +1 -1
  294. package/src/generators/test-generator/code-generator.ts +86 -7
  295. package/src/generators/test-generator/diagnostics.ts +60 -6
  296. package/src/generators/test-generator/patterns/expect-patterns.ts +37 -2
  297. package/src/generators/test-generator/patterns/index.ts +58 -33
  298. package/src/generators/test-generator/patterns/types.ts +36 -0
  299. package/src/generators/test-generator/patterns/unsupported-step-code.ts +19 -0
  300. package/src/generators/test-generator/recipe-expander.ts +9 -1
  301. package/src/generators/test-generator/reset-tier.ts +93 -0
  302. package/src/generators/test-generator/step-mapper.ts +149 -6
  303. package/src/generators/test-generator/template-engine.ts +18 -3
  304. package/src/generators/test-generator/utils/format-pattern.ts +79 -0
  305. package/src/generators/test-generator/utils/js-literal-scanner.ts +132 -0
  306. package/src/generators/test-generator/utils/mask-refs-for-matching.ts +21 -0
  307. package/src/generators/test-generator/utils/runtime-data-transformer.ts +126 -76
  308. package/src/generators/test-generator/utils/selector-resolver.ts +22 -1
  309. package/src/generators/test-generator/utils/spec-syntax-check.ts +22 -0
  310. package/src/harness/annotation-overrides.ts +10 -5
  311. package/src/harness/audit.ts +82 -12
  312. package/src/harness/capability-plan.ts +10 -5
  313. package/src/harness/capability.ts +16 -0
  314. package/src/harness/catalog/drivers.yaml +5 -0
  315. package/src/harness/flow-contract.ts +87 -9
  316. package/src/harness/parse.ts +5 -1
  317. package/src/harness/quality-gates.ts +64 -6
  318. package/src/harness/run-manifest.ts +254 -0
  319. package/src/harness/spec-branches.ts +346 -0
  320. package/src/harness/spec-coverage.ts +4 -4
  321. package/src/harness/viewpoint-baseline.ts +41 -6
  322. package/src/harness/viewpoint-ledger.ts +82 -9
  323. package/src/index.ts +1 -0
  324. package/src/orchestrator/lockstep-version.ts +46 -0
  325. package/src/orchestrator/project-deps-sync.ts +175 -0
  326. package/src/orchestrator/project-initializer.ts +5 -2
  327. package/src/orchestrator/templates/ai-src/commands/add-flow.md +16 -0
  328. package/src/orchestrator/templates/ai-src/commands/create-test.md +9 -0
  329. package/src/orchestrator/templates/ai-src/commands/delivery.md +9 -2
  330. package/src/orchestrator/templates/ai-src/commands/run-test.md +109 -0
  331. package/src/orchestrator/templates/ai-src/config/claude.md +1 -1
  332. package/src/orchestrator/templates/ai-src/config/copilot.md +1 -1
  333. package/src/orchestrator/templates/ai-src/skills/sungen-api-design/SKILL.md +49 -0
  334. package/src/orchestrator/templates/ai-src/skills/sungen-error-mapping/SKILL.md +14 -3
  335. package/src/orchestrator/templates/ai-src/skills/sungen-gherkin-syntax/SKILL.md +110 -6
  336. package/src/orchestrator/templates/ai-src/skills/sungen-locale/SKILL.md +1 -1
  337. package/src/orchestrator/templates/ai-src/skills/sungen-mobile-gestures/SKILL.md +8 -0
  338. package/src/orchestrator/templates/ai-src/skills/sungen-selector-fix/SKILL.md +1 -1
  339. package/src/orchestrator/templates/ai-src/skills/sungen-tc-generation/SKILL.md +40 -1
  340. package/src/orchestrator/templates/ai-src/skills/sungen-tc-review/SKILL.md +15 -0
  341. package/src/orchestrator/templates/env.appium.example +10 -0
  342. package/src/orchestrator/templates/specs-api.ts +214 -11
  343. package/src/orchestrator/templates/specs-regex-escape.ts +16 -0
  344. package/src/orchestrator/templates/specs-test-data.ts +53 -6
  345. package/src/orchestrator/templates/wdio.conf.ts +28 -9
@@ -0,0 +1,264 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.buildRunManifest = buildRunManifest;
40
+ exports.readRunManifest = readRunManifest;
41
+ exports.writeRunManifest = writeRunManifest;
42
+ exports.selectChanged = selectChanged;
43
+ /**
44
+ * Run-manifest — which scenarios does a QA edit actually oblige us to re-run?
45
+ *
46
+ * The problem it serves: the JSON reporter writes ONE file per target, named only for the unit +
47
+ * platform + env, so a subset re-run overwrites the full run's results. `sungen results merge`
48
+ * restores the lost half, but only if the caller knew to back the file up first — and only after
49
+ * the caller decided WHICH cases to run. This module answers the second question deterministically
50
+ * so `run-test --change-only` is a computation, not a guess.
51
+ *
52
+ * Sibling of `manifest.ts`, deliberately not an extension of it: that one hashes spec.md sections
53
+ * to decide what to REGENERATE, this one hashes the compiled inputs to decide what to RE-RUN. Same
54
+ * conventions (deterministic hashing, `.sungen/` storage, a plan object), different question.
55
+ *
56
+ * The bias is fixed and one-directional: when an edit cannot be attributed to specific scenarios,
57
+ * EVERY scenario is selected. Over-running costs minutes; under-running reports a scenario green
58
+ * that never re-ran after the change that broke it, which is the failure this whole family of
59
+ * guards exists to prevent.
60
+ *
61
+ * Storage: `.sungen/run-manifest/<slug>.json`.
62
+ */
63
+ const fs = __importStar(require("fs"));
64
+ const path = __importStar(require("path"));
65
+ const crypto_1 = require("crypto");
66
+ const yaml_1 = __importDefault(require("yaml"));
67
+ const unit_paths_1 = require("./unit-paths");
68
+ const read_text_1 = require("./read-text");
69
+ const gherkin_parser_1 = require("../generators/gherkin-parser");
70
+ const sha = (s) => (0, crypto_1.createHash)('sha256').update(s).digest('hex').slice(0, 16);
71
+ /** Mirrors SelectorResolver.generateKey — a `[Ref]` becomes this before the YAML lookup. */
72
+ const refToKey = (label) => label.normalize('NFC').toLowerCase().trim().replace(/\s+/g, ' ');
73
+ const manifestPath = (cwd, unit) => path.join(cwd, '.sungen', 'run-manifest', `${(0, unit_paths_1.reportSlug)(unit)}.json`);
74
+ /** Flatten a YAML mapping to `key → hash(value)`; a non-mapping file yields one whole-file entry. */
75
+ function hashTopLevel(file) {
76
+ if (!fs.existsSync(file))
77
+ return {};
78
+ const text = (0, read_text_1.readTextFile)(file);
79
+ let doc;
80
+ try {
81
+ doc = yaml_1.default.parse(text);
82
+ }
83
+ catch {
84
+ // Unparseable: attribute nothing, and let the caller widen to the whole unit rather than
85
+ // silently treating a broken file as "no change".
86
+ return { __unparseable__: sha(text) };
87
+ }
88
+ // An empty or comment-only file parses to null. That is an EMPTY mapping — nothing to attribute
89
+ // and nothing to widen on — not an unrecognised shape. (A test-data file holding only a comment
90
+ // made the first probe widen to all 18 scenarios.)
91
+ if (doc === null || doc === undefined)
92
+ return {};
93
+ if (typeof doc !== 'object' || Array.isArray(doc))
94
+ return { __whole__: sha(text) };
95
+ const out = {};
96
+ for (const [k, v] of Object.entries(doc)) {
97
+ out[refToKey(k)] = sha(JSON.stringify(v ?? null));
98
+ }
99
+ return out;
100
+ }
101
+ /** Read the unit's compiled inputs and fingerprint them. */
102
+ function buildRunManifest(cwd, unitDir, unit) {
103
+ const parser = new gherkin_parser_1.GherkinParser();
104
+ const scenarios = {};
105
+ const deps = {};
106
+ const bgParts = [];
107
+ for (const file of (0, unit_paths_1.featureFilesFor)(unitDir, unit)) {
108
+ const parsed = parser.parseFeatureFile(file);
109
+ if (parsed.background?.steps?.length) {
110
+ bgParts.push(parsed.background.steps.map((s) => `${s.keyword} ${s.text}`).join('\n'));
111
+ }
112
+ for (const sc of parsed.scenarios) {
113
+ const block = [...(sc.tags || []), ...sc.steps.map((s) => `${s.keyword} ${s.text}`)].join('\n');
114
+ scenarios[sc.name] = sha(block);
115
+ const sel = new Set();
116
+ const dat = new Set();
117
+ for (const st of sc.steps) {
118
+ if (st.selectorRef)
119
+ sel.add(refToKey(st.selectorRef));
120
+ if (st.parentRef)
121
+ sel.add(refToKey(st.parentRef));
122
+ if (st.childRef)
123
+ sel.add(refToKey(st.childRef));
124
+ if (st.dataRef)
125
+ dat.add(refToKey(st.dataRef));
126
+ }
127
+ deps[sc.name] = { selectors: [...sel].sort(), data: [...dat].sort() };
128
+ }
129
+ }
130
+ const selDir = path.join(unitDir, 'selectors');
131
+ const dataDir = path.join(unitDir, 'test-data');
132
+ const collect = (dir) => {
133
+ if (!fs.existsSync(dir))
134
+ return {};
135
+ const merged = {};
136
+ for (const f of fs.readdirSync(dir).filter((n) => /\.ya?ml$/.test(n)).sort()) {
137
+ Object.assign(merged, hashTopLevel(path.join(dir, f)));
138
+ }
139
+ return merged;
140
+ };
141
+ // Project-level config lives beside the units, not inside them.
142
+ const qaDir = path.join(cwd, 'qa');
143
+ const globals = {};
144
+ for (const name of ['app.yaml', 'datasources.yaml', 'capabilities.yaml']) {
145
+ const f = path.join(qaDir, name);
146
+ if (fs.existsSync(f))
147
+ globals[`qa/${name}`] = sha((0, read_text_1.readTextFile)(f));
148
+ }
149
+ return {
150
+ unit,
151
+ recordedAt: new Date().toISOString(),
152
+ scenarios,
153
+ selectorKeys: collect(selDir),
154
+ dataKeys: collect(dataDir),
155
+ deps,
156
+ background: sha(bgParts.join('\n---\n')),
157
+ globals,
158
+ };
159
+ }
160
+ function readRunManifest(cwd, unit) {
161
+ const p = manifestPath(cwd, unit);
162
+ // Absent baseline is the FIRST-RUN case, not an error — selectChanged widens to the whole unit.
163
+ if (!fs.existsSync(p))
164
+ return null;
165
+ try {
166
+ return JSON.parse((0, read_text_1.readTextFile)(p));
167
+ }
168
+ catch {
169
+ return null;
170
+ }
171
+ }
172
+ function writeRunManifest(cwd, unit, m) {
173
+ const p = manifestPath(cwd, unit);
174
+ fs.mkdirSync(path.dirname(p), { recursive: true });
175
+ fs.writeFileSync(p, JSON.stringify(m, null, 2));
176
+ return p;
177
+ }
178
+ /** Keys whose hash differs, was added, or disappeared. */
179
+ function movedKeys(before, after) {
180
+ const moved = new Set();
181
+ for (const k of new Set([...Object.keys(before), ...Object.keys(after)])) {
182
+ if (before[k] !== after[k])
183
+ moved.add(k);
184
+ }
185
+ return moved;
186
+ }
187
+ /**
188
+ * Which scenarios must re-run, given the recorded manifest and the current inputs.
189
+ *
190
+ * A selector key matches a step's `[Ref]` either exactly or as one of the resolver's suffixed
191
+ * forms (`key--button`, `key--3`), because that is how the lookup itself resolves.
192
+ */
193
+ function selectChanged(before, after,
194
+ /**
195
+ * Run-affecting files an outside source (git) reports as changed. Passed in rather than read here
196
+ * so this function stays pure and testable; the CLI gathers the evidence. Non-empty + an
197
+ * otherwise-empty selection means something changed that per-key hashing cannot see (a rename, a
198
+ * new file shape) — unattributable, so it widens like the other unattributable cases.
199
+ */
200
+ externalChanged = []) {
201
+ const titles = Object.keys(after.scenarios);
202
+ const selectAll = (reason) => ({
203
+ unit: after.unit,
204
+ scenarios: titles,
205
+ reasons: Object.fromEntries(titles.map((t) => [t, reason])),
206
+ all: true,
207
+ summary: { total: titles.length, selected: titles.length, firstRun: !before },
208
+ });
209
+ if (!before)
210
+ return selectAll('no previous run recorded');
211
+ const movedGlobals = movedKeys(before.globals || {}, after.globals || {});
212
+ if (movedGlobals.size) {
213
+ return selectAll(`project config changed (${[...movedGlobals].join(', ')}) — it reaches every scenario`);
214
+ }
215
+ if (before.background !== after.background)
216
+ return selectAll('the Background changed — it runs before every scenario');
217
+ if (after.selectorKeys.__unparseable__ || after.dataKeys.__unparseable__) {
218
+ return selectAll('a selectors/test-data file could not be parsed, so the edit cannot be attributed');
219
+ }
220
+ if (after.selectorKeys.__whole__ || after.dataKeys.__whole__) {
221
+ const movedWhole = movedKeys(before.selectorKeys, after.selectorKeys).size
222
+ || movedKeys(before.dataKeys, after.dataKeys).size;
223
+ if (movedWhole)
224
+ return selectAll('a selectors/test-data file is not a key mapping, so the edit cannot be attributed');
225
+ }
226
+ const movedSel = movedKeys(before.selectorKeys, after.selectorKeys);
227
+ const movedDat = movedKeys(before.dataKeys, after.dataKeys);
228
+ const touches = (key, dep) => key === dep || key.startsWith(`${dep}--`);
229
+ const reasons = {};
230
+ for (const title of titles) {
231
+ if (before.scenarios[title] !== after.scenarios[title]) {
232
+ reasons[title] = before.scenarios[title] ? 'its steps or tags changed' : 'new scenario';
233
+ continue;
234
+ }
235
+ const dep = after.deps[title] || { selectors: [], data: [] };
236
+ const sel = [...movedSel].filter((k) => dep.selectors.some((d) => touches(k, d)));
237
+ if (sel.length) {
238
+ reasons[title] = `selector changed: ${sel.slice(0, 3).join(', ')}`;
239
+ continue;
240
+ }
241
+ const dat = [...movedDat].filter((k) => dep.data.some((d) => touches(k, d)));
242
+ if (dat.length) {
243
+ reasons[title] = `test-data changed: ${dat.slice(0, 3).join(', ')}`;
244
+ continue;
245
+ }
246
+ }
247
+ let selected = titles.filter((t) => reasons[t]);
248
+ // Git cross-check. Per-key hashing is blind to structural moves — a renamed selectors file, a new
249
+ // file shape, an encoding change — because the keys simply appear or vanish. When an outside
250
+ // source reports run-affecting files changed and we attributed NOTHING, that is the same
251
+ // unattributable case as an unparseable YAML, so it widens rather than reporting "all current".
252
+ if (!selected.length && externalChanged.length) {
253
+ return selectAll(`git reports ${externalChanged.length} run-affecting file(s) changed (${externalChanged.slice(0, 3).join(', ')}) `
254
+ + 'that per-key hashing could not attribute');
255
+ }
256
+ return {
257
+ unit: after.unit,
258
+ scenarios: selected,
259
+ reasons,
260
+ all: false,
261
+ summary: { total: titles.length, selected: selected.length, firstRun: false },
262
+ };
263
+ }
264
+ //# sourceMappingURL=run-manifest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-manifest.js","sourceRoot":"","sources":["../../src/harness/run-manifest.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+FA,4CAuDC;AAED,0CAKC;AAED,4CAKC;AAiBD,sCAwEC;AA7PD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,uCAAyB;AACzB,2CAA6B;AAC7B,mCAAoC;AACpC,gDAAwB;AACxB,6CAA2D;AAC3D,2CAA2C;AAC3C,iEAA6D;AAE7D,MAAM,GAAG,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,IAAA,mBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAE7F,4FAA4F;AAC5F,MAAM,QAAQ,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CA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I,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7E,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC;YAAC,OAAO,CAAC,KAAK,CAAC,GAAG,sBAAsB,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAAC,SAAS;QAAC,CAAC;IACpG,CAAC;IAED,IAAI,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAEhD,kGAAkG;IAClG,6FAA6F;IAC7F,yFAAyF;IACzF,gGAAgG;IAChG,IAAI,CAAC,QAAQ,CAAC,MAAM,IAAI,eAAe,CAAC,MAAM,EAAE,CAAC;QAC/C,OAAO,SAAS,CACd,eAAe,eAAe,CAAC,MAAM,mCAAmC,eAAe,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;cAChH,0CAA0C,CAC7C,CAAC;IACJ,CAAC;IAED,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,SAAS,EAAE,QAAQ;QACnB,OAAO;QACP,GAAG,EAAE,KAAK;QACV,OAAO,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE;KAC9E,CAAC;AACJ,CAAC"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Mutually-exclusive branches declared in the spec, and whether each one has a scenario (#630).
3
+ *
4
+ * A field report hit the same gap three times in three different flows, in three different
5
+ * shapes: an `### Exception Flow A` heading left entirely blank; a decision table
6
+ * (`DEC-003_EmptyStateCascade`) whose three arms produced ONE covered arm and two
7
+ * scenarios verifying that same arm under different names; and a pseudocode block with two
8
+ * attention-hint branches where only the first got a case.
9
+ *
10
+ * The narrative rule already existed — "AND condition → test each branch failing independently",
11
+ * "business rule → 1 behavioural TC per rule". It was missed anyway, three times. So the
12
+ * reviewers' own conclusion is the design here: what works is an ENFORCED enumeration, the way
13
+ * `Viewpoint items` are enumerated and completeness-checked, not another sentence of guidance.
14
+ *
15
+ * Deliberately conservative. A branch is only claimed when the spec makes the enumeration
16
+ * explicit — a named heading, a table that declares conditions and outcomes, or an if/else
17
+ * cascade — because a false "you missed a branch" costs more trust than it buys coverage.
18
+ */
19
+ import { ScenarioInfo } from './parse';
20
+ export interface SpecBranch {
21
+ /** Stable id for the message: the block name plus the arm. */
22
+ id: string;
23
+ /** The distinctive token the suite is expected to cite. */
24
+ label: string;
25
+ kind: 'exception-flow' | 'alternative-flow' | 'decision-arm' | 'pseudocode-arm';
26
+ /** Where it was found, so the author can go and read it. */
27
+ source: string;
28
+ }
29
+ export declare function specBranches(specText: string): SpecBranch[];
30
+ export declare function unenumeratedBranches(branches: SpecBranch[], featureText: string): SpecBranch[];
31
+ /**
32
+ * Scenarios whose assertions are IDENTICAL — "N cases" in a coverage sheet that verify one arm N
33
+ * times. The field report's decision table produced exactly this: two cases under different
34
+ * names, both asserting the same message, reported as two covered branches.
35
+ *
36
+ * Compares only the assertion side: two scenarios may legitimately share setup and differ in
37
+ * what they prove, but if what they PROVE is identical they are one test.
38
+ */
39
+ export declare function sameOracleClusters(scenarios: ScenarioInfo[]): Array<{
40
+ oracle: string;
41
+ scenarios: string[];
42
+ }>;
43
+ export declare function permissionPairGaps(scenarios: ScenarioInfo[]): Array<{
44
+ scenario: string;
45
+ subject: string[];
46
+ }>;
47
+ export declare function awaitingSeedData(testDataText: string, scenarios: ScenarioInfo[]): Array<{
48
+ key: string;
49
+ scenarios: string[];
50
+ }>;
51
+ /**
52
+ * The fixed risk catalog for a multi-screen journey, reconciled against the flow (#651 F1-7).
53
+ *
54
+ * `SPEC-BRANCH-UNCOVERED` enforces the branches a spec DECLARES. This is the other half, and the
55
+ * one a field report asked for explicitly: the risks a spec is often SILENT about, which a
56
+ * reviewer notices and a generator does not. Their words — *"cả 2 flow đều thiếu 2-3 nhóm trong
57
+ * danh sách này, không phải vì không áp dụng mà vì không có bước bắt buộc rà lại checklist đó
58
+ * trước khi coi flow 'đủ'"*.
59
+ *
60
+ * The same families as the step × risk matrix in `sungen-tc-generation`, so guidance and gate
61
+ * cannot drift apart. A family counts as CONSIDERED when it is mentioned anywhere the author
62
+ * reasons: a declared flow's branch point, outcome or reason; a scenario; or the viewpoint. That
63
+ * makes "we thought about it and it does not apply" a one-line answer — the accounting the flow
64
+ * inventory already asks for — rather than a scenario nobody needs.
65
+ */
66
+ export interface RiskFamily {
67
+ id: string;
68
+ label: string;
69
+ /** What the author writes when they HAVE considered it. */
70
+ re: RegExp;
71
+ /** Why it bites on a multi-screen journey specifically. */
72
+ why: string;
73
+ }
74
+ export declare const MULTI_SCREEN_RISKS: RiskFamily[];
75
+ export declare function unconsideredRisks(contract: FlowContractLike, scenarios: ScenarioInfo[], viewpointText: string): RiskFamily[];
76
+ /** The slice of the contract this needs — kept structural so the module stays import-light. */
77
+ export interface FlowContractLike {
78
+ flows?: Array<{
79
+ id: string;
80
+ branchFrom?: string;
81
+ outcome?: string;
82
+ reason?: string;
83
+ }>;
84
+ minimalGuarantee?: string;
85
+ successGuarantee?: string;
86
+ precondition?: string;
87
+ }
88
+ //# sourceMappingURL=spec-branches.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spec-branches.d.ts","sourceRoot":"","sources":["../../src/harness/spec-branches.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,MAAM,WAAW,UAAU;IACzB,8DAA8D;IAC9D,EAAE,EAAE,MAAM,CAAC;IACX,2DAA2D;IAC3D,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,gBAAgB,GAAG,kBAAk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,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACtF,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}
@@ -0,0 +1,280 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MULTI_SCREEN_RISKS = void 0;
4
+ exports.specBranches = specBranches;
5
+ exports.unenumeratedBranches = unenumeratedBranches;
6
+ exports.sameOracleClusters = sameOracleClusters;
7
+ exports.permissionPairGaps = permissionPairGaps;
8
+ exports.awaitingSeedData = awaitingSeedData;
9
+ exports.unconsideredRisks = unconsideredRisks;
10
+ /**
11
+ * CamelCase identifiers only — an outcome LABEL (`StateNoItems`, `HintPrimary`).
12
+ *
13
+ * SCREAMING_SNAKE was in this pattern and produced two false branches on a real spec:
14
+ * `DEFAULT_FILTER` from `conditions !== DEFAULT_FILTER` and `MESSAGE_READ` from a permission check.
15
+ * Those are OPERANDS inside a condition, not arms of it — a constant names a value, an outcome
16
+ * names a result. Shape alone cannot tell them apart, so the shape that only outcomes use is the
17
+ * one to match (#651 follow-up).
18
+ */
19
+ const IDENTIFIER = /\b([A-Z][a-z0-9]+(?:[A-Z][a-z0-9]+)+)\b/g;
20
+ /**
21
+ * Code references are not branch labels. A table cell citing
22
+ * `src/components/molecules/HomeBoard/AlertPanel.tsx` yielded four "branches" —
23
+ * AlertPanel, TaskPanel, FeaturedList, HomeBoard — none of which is a branch at all.
24
+ * Backticked spans and anything path-shaped go before identifiers are read.
25
+ */
26
+ function withoutCodeRefs(text) {
27
+ return text
28
+ .replace(/`[^`]*`/g, ' ') // inline code spans
29
+ .replace(/\[[^\]]*\]\([^)]*\)/g, ' ') // markdown links
30
+ .replace(/\S*\/\S*/g, ' ') // any path-like token
31
+ .replace(/\b\w+\.(?:tsx?|jsx?|vue|py|rb|go|java|kt|swift|md|ya?ml|json)\b/gi, ' ');
32
+ }
33
+ /** A named decision/rule block: `DEC-003_Foo`, `BR-001_Bar`, `ALG-002`. */
34
+ const NAMED_BLOCK = /\b((?:DEC|BR|ALG|RULE|DISC)-\d+)(?:_([A-Za-z0-9]+))?\b/;
35
+ const HEADING = /^(#{1,6})\s+(.*)$/;
36
+ /**
37
+ * Split a markdown document into `{ heading, lines }` sections, so a table or fence can be
38
+ * attributed to the block that names it.
39
+ */
40
+ function sections(text) {
41
+ const out = [{ heading: '', lines: [] }];
42
+ for (const raw of text.split('\n')) {
43
+ const h = raw.match(HEADING);
44
+ if (h)
45
+ out.push({ heading: h[2].replace(/[*`]/g, '').trim(), lines: [] });
46
+ else
47
+ out[out.length - 1].lines.push(raw);
48
+ }
49
+ return out;
50
+ }
51
+ /** Does this table declare CONDITIONS mapping to OUTCOMES (a decision table)? */
52
+ function isDecisionTable(header, sectionHeading) {
53
+ const cells = header.map((c) => c.toLowerCase());
54
+ // A Given/When/Then table is a list of TEST CASES, not a decision to enumerate — each row is
55
+ // already a case. It matched on `when`+`then` and turned a real spec's test-case table into
56
+ // five phantom branches (#651 follow-up).
57
+ const isGherkinTable = cells.some((c) => /\bgiven\b/.test(c)) && cells.some((c) => /\bwhen\b/.test(c))
58
+ && cells.some((c) => /\bthen\b/.test(c));
59
+ const isTestCaseTable = cells.some((c) => /test[- ]?id|tc[- ]?id|case[- ]?id/.test(c));
60
+ if (isGherkinTable || isTestCaseTable)
61
+ return false;
62
+ const hasCondition = cells.some((c) => /condition|case|when|input|state|flag|criteria|nhánh|điều kiện/.test(c));
63
+ const hasOutcome = cells.some((c) => /outcome|result|then|display|shows?|expected|action|behaviou?r|kết quả/.test(c));
64
+ // A block the spec itself NAMES as a decision counts even if its columns are worded oddly.
65
+ return (hasCondition && hasOutcome) || /\b(?:DEC|decision|cascade|matrix)\b/i.test(sectionHeading);
66
+ }
67
+ function specBranches(specText) {
68
+ const out = [];
69
+ const seen = new Set();
70
+ const push = (b) => {
71
+ const k = `${b.id}|${b.label}`;
72
+ if (seen.has(k))
73
+ return;
74
+ seen.add(k);
75
+ out.push(b);
76
+ };
77
+ for (const sec of sections(specText)) {
78
+ // 1. An `### Exception Flow A` / `### Alternative Flow 2` heading IS one branch. Unambiguous.
79
+ const flowH = sec.heading.match(/^(exception|alternative|alternate)\s+flow\s*([A-Z0-9][\w-]*)?/i);
80
+ if (flowH) {
81
+ const label = sec.heading;
82
+ push({
83
+ id: label, label,
84
+ kind: /^exception/i.test(flowH[1]) ? 'exception-flow' : 'alternative-flow',
85
+ source: `heading "${sec.heading}"`,
86
+ });
87
+ continue;
88
+ }
89
+ const named = sec.heading.match(NAMED_BLOCK);
90
+ const blockName = named ? named[0] : sec.heading;
91
+ // 2. A decision table: each data row is one arm. Matched on the identifier the row names.
92
+ const rows = sec.lines.filter((l) => l.trim().startsWith('|') && !/^\|[\s|:-]+\|?$/.test(l.trim()));
93
+ if (rows.length >= 3) { // header + at least two arms
94
+ const header = rows[0].split('|').map((c) => c.trim()).filter(Boolean);
95
+ if (isDecisionTable(header, sec.heading)) {
96
+ for (const row of rows.slice(1)) {
97
+ const ids = [...withoutCodeRefs(row).matchAll(IDENTIFIER)].map((m) => m[1]);
98
+ // Only an identifier is distinctive enough to look for in a suite; a prose condition
99
+ // would match half the feature file.
100
+ for (const id of ids)
101
+ push({ id: `${blockName}:${id}`, label: id, kind: 'decision-arm', source: `decision table under "${sec.heading}"` });
102
+ }
103
+ }
104
+ }
105
+ // 3. An if/elif/else cascade in a fenced block: each arm that NAMES an outcome identifier.
106
+ let inFence = false;
107
+ let fence = [];
108
+ for (const l of sec.lines) {
109
+ if (l.trim().startsWith('```')) {
110
+ if (inFence) {
111
+ const body = fence.join('\n');
112
+ const arms = (body.match(/\b(?:else\s+if|elif|if|else)\b/g) ?? []).length;
113
+ if (arms >= 2) {
114
+ for (const m of withoutCodeRefs(body).matchAll(IDENTIFIER)) {
115
+ push({ id: `${blockName}:${m[1]}`, label: m[1], kind: 'pseudocode-arm', source: `pseudocode under "${sec.heading}"` });
116
+ }
117
+ }
118
+ fence = [];
119
+ }
120
+ inFence = !inFence;
121
+ continue;
122
+ }
123
+ if (inFence)
124
+ fence.push(l);
125
+ }
126
+ }
127
+ return out;
128
+ }
129
+ /**
130
+ * Branches with no scenario citing them. A citation counts anywhere in the feature text —
131
+ * title, steps or a comment — because an author who deliberately excludes a branch writes the
132
+ * reason as a comment, and that is an accounting, not a gap.
133
+ */
134
+ const GENERIC_WORD = new Set([
135
+ 'flow', 'exception', 'alternative', 'alternate', 'the', 'and', 'with', 'without', 'when', 'then',
136
+ 'user', 'visitor', 'screen', 'page', 'from', 'that', 'this', 'case', 'gate', 'step',
137
+ ]);
138
+ function unenumeratedBranches(branches, featureText) {
139
+ const hay = featureText.toLowerCase();
140
+ return branches.filter((b) => {
141
+ // An IDENTIFIER is precise — require it verbatim. A HEADING is prose the author will
142
+ // rephrase ("Exception Flow A — drawer confirm gate" becomes "closing the drawer without
143
+ // confirming"), so match on its distinctive words instead: demanding the heading verbatim
144
+ // would report a branch that is covered under a better name.
145
+ if (b.kind === 'decision-arm' || b.kind === 'pseudocode-arm')
146
+ return !hay.includes(b.label.toLowerCase());
147
+ const words = [...new Set((b.label.toLowerCase().match(/[a-z][a-z-]{3,}/g) ?? []))]
148
+ .filter((w) => !GENERIC_WORD.has(w));
149
+ if (words.length === 0)
150
+ return !hay.includes(b.label.toLowerCase());
151
+ const hits = words.filter((w) => hay.includes(w)).length;
152
+ return hits < Math.min(2, words.length);
153
+ });
154
+ }
155
+ /**
156
+ * Scenarios whose assertions are IDENTICAL — "N cases" in a coverage sheet that verify one arm N
157
+ * times. The field report's decision table produced exactly this: two cases under different
158
+ * names, both asserting the same message, reported as two covered branches.
159
+ *
160
+ * Compares only the assertion side: two scenarios may legitimately share setup and differ in
161
+ * what they prove, but if what they PROVE is identical they are one test.
162
+ */
163
+ function sameOracleClusters(scenarios) {
164
+ const byOracle = new Map();
165
+ for (const s of scenarios) {
166
+ if (s.manual)
167
+ continue; // a procedure's oracle is prose
168
+ const asserts = [...(s.steps ?? [])]
169
+ .filter((st) => st.bucket === 'then')
170
+ .map((st) => st.text.toLowerCase().replace(/\s+/g, ' ').trim())
171
+ .sort();
172
+ if (asserts.length === 0)
173
+ continue;
174
+ const key = asserts.join(' ; ');
175
+ byOracle.set(key, [...(byOracle.get(key) ?? []), s.name]);
176
+ }
177
+ return [...byOracle.entries()]
178
+ .filter(([, names]) => names.length > 1)
179
+ .map(([oracle, names]) => ({ oracle: oracle.slice(0, 100), scenarios: names }))
180
+ .sort((a, b) => b.scenarios.length - a.scenarios.length);
181
+ }
182
+ /**
183
+ * A "denied → hidden" scenario with no "allowed → shown" counterpart (#630).
184
+ *
185
+ * Two security cases proved that chat content is hidden when `MESSAGE_READ` is denied. If the code
186
+ * hid it unconditionally — ignoring the permission entirely — both still pass. The deny side alone
187
+ * cannot distinguish "the guard works" from "the feature is broken for everyone", so the pair is
188
+ * the test, exactly as `min-1 / min / max / max+1` is the test for a boundary.
189
+ *
190
+ * The mirror of the negative-claim rule the skill already has, on the other side.
191
+ */
192
+ const DENY_SHAPE = /\b(?:denied|deny|denies|forbidden|not authoriz\w*|unauthoriz\w*|no permission|without (?:the )?(?:permission|right|access|flag)|permission (?:is )?off|flag (?:is )?off|revoked|restricted)\b/i;
193
+ const HIDDEN_SHAPE = /\b(?:is hidden|are hidden|not (?:visible|shown|displayed)|blocked|masked|redacted|does not (?:show|render|appear))\b/i;
194
+ const ALLOW_SHAPE = /\b(?:granted|allowed|permitted|authoriz\w*|has (?:the )?(?:permission|right|access)|permission (?:is )?on|flag (?:is )?on|with (?:the )?(?:permission|right|access))\b/i;
195
+ function permissionPairGaps(scenarios) {
196
+ const denies = scenarios.filter((s) => DENY_SHAPE.test(s.haystack) && HIDDEN_SHAPE.test(s.haystack));
197
+ if (denies.length === 0)
198
+ return [];
199
+ const allows = scenarios.filter((s) => ALLOW_SHAPE.test(s.haystack) && !HIDDEN_SHAPE.test(s.stepsText));
200
+ // Words only — the scenario ID is stripped first, because `[a-z][a-z-]{4,}` happily matches
201
+ // `fl-er-` and an id fragment can never appear in the counterpart's title, so demanding it made
202
+ // the pair impossible to find.
203
+ const distinctive = (s) => [...new Set((s.name.replace(/^\S+\s*/, '').toLowerCase().match(/[a-z]{5,}/g) ?? []))]
204
+ .filter((w) => !GENERIC_WORD.has(w) && !/denied|denies|hidden|permission|scenario/.test(w));
205
+ const out = [];
206
+ for (const d of denies) {
207
+ const subject = distinctive(d);
208
+ // The counterpart has to be about the SAME thing — two shared distinctive words, the same
209
+ // bar the ledger's prose matching uses.
210
+ const paired = allows.some((a) => subject.filter((w) => a.haystack.includes(w)).length >= Math.min(2, subject.length));
211
+ if (!paired)
212
+ out.push({ scenario: d.name, subject: subject.slice(0, 4) });
213
+ }
214
+ return out;
215
+ }
216
+ /**
217
+ * Scenarios blocked on test data that is still a placeholder (#630).
218
+ *
219
+ * A deliverable reported "Pending" for a case whose design was finished and whose only blocker was
220
+ * an unseeded ENV-BOUND value — indistinguishable, on the report, from a case with an unresolved
221
+ * design problem. One is a data task, the other is test work; they should not read the same.
222
+ */
223
+ const SEED_PLACEHOLDER = /^(?:TODO[_-]?SEED\w*|TODO|TBD|<[^>]+>|REPLACE[_-]?ME|FILL[_-]?ME|CHANGE[_-]?ME|XXX+)$/i;
224
+ function awaitingSeedData(testDataText, scenarios) {
225
+ // One placeholder key is ONE data task, however many files or lines mention it — a real project
226
+ // reported the same key three times because its overlays each declare it (#651 follow-up).
227
+ const placeholders = [...new Set([...testDataText.matchAll(/^\s*([A-Za-z0-9_.-]+)\s*:\s*["']?([^"'\n#]+?)["']?\s*(?:#.*)?$/gm)]
228
+ .filter((m) => SEED_PLACEHOLDER.test(m[2].trim()))
229
+ .map((m) => m[1]))];
230
+ if (placeholders.length === 0)
231
+ return [];
232
+ return placeholders
233
+ .map((key) => ({
234
+ key,
235
+ scenarios: scenarios.filter((s) => s.stepsText.includes(`{{${key.toLowerCase()}`)
236
+ || new RegExp(`\\{\\{[a-z0-9_.-]*\\.${key.toLowerCase()}\\}\\}`).test(s.stepsText)).map((s) => s.name),
237
+ }))
238
+ .filter((p) => p.scenarios.length > 0);
239
+ }
240
+ exports.MULTI_SCREEN_RISKS = [
241
+ { id: 'double-submit', label: 'double submit / double activation',
242
+ re: /\b(?:double[- ]?(?:submit|click|tap|activation)|twice|two taps?|idempoten\w*|re-?submit|duplicate request)\b/i,
243
+ why: 'a second activation before the first response is the classic way one journey creates two records' },
244
+ { id: 'concurrency', label: 'two tabs / two devices at once',
245
+ re: /\b(?:two tabs?|second tab|another tab|multi[- ]?tab|two devices|second device|concurrent\w*|simultaneous\w*|race)\b/i,
246
+ why: 'a journey that buffers state client-side behaves differently when two of it run at once' },
247
+ { id: 'client-buffer', label: 'client-side buffer kept / lost',
248
+ re: /\b(?:session ?storage|local ?storage|buffer\w*|draft|unsaved|re-?hydrat\w*|restore[sd]?)\b/i,
249
+ why: 'state held between two steps must be proved BOTH ways — it survives a legitimate return, and it is lost when the spec says it is' },
250
+ { id: 'server-error', label: 'a mid-journey server error',
251
+ re: /\b(?:server error|5\d{2}\b|network (?:error|drop|failure)|offline|timeout|unavailable|fails? server-?side|retry)\b/i,
252
+ why: 'the interesting question is what survives the failure, not that an error appeared' },
253
+ { id: 'abandonment', label: 'abandonment / TTL of partial state',
254
+ re: /\b(?:abandon\w*|lapse[sd]?|expir\w*|ttl\b|stale|cleanup|24 ?h|dormant|never (?:completed|finished))\b/i,
255
+ why: 'a journey stopped halfway leaves state somebody owns; a flow test is where that becomes visible' },
256
+ { id: 'direct-access', label: 'direct URL access to a later step',
257
+ re: /\b(?:direct(?:ly)? access|deep[- ]?link|without (?:a |an |the )?(?:context|session|prior)|guard|not skippable|redirect\w*)\b/i,
258
+ why: 'every step after the first is reachable by URL, and only a journey test can check the guard' },
259
+ { id: 'auth-transition', label: 'where the session begins',
260
+ re: /\b(?:authenticat\w*|unauthenticat\w*|signed[- ]in|logged[- ]in|session (?:is )?(?:established|created|begins)|auto[- ]?login)\b/i,
261
+ why: 'the step where an actor stops being anonymous is a boundary no single screen owns' },
262
+ { id: 'escape-hatch', label: 'a documented way out of the journey',
263
+ re: /\b(?:cancel|back to top|exit|leave[sd]? the (?:journey|flow)|opt[- ]?out|skip|dismiss)\b/i,
264
+ why: 'a designed-for exit is an alternate flow with its own outcome, not an error' },
265
+ { id: 'side-effect-order', label: 'ordering of a delayed side effect',
266
+ re: /\b(?:mail|email|notification|webhook|queue|async|delayed|eventual\w*|dispatch\w*|side[- ]effect)\b/i,
267
+ why: 'a journey that triggers an out-of-band effect is where its ordering and its absence both matter' },
268
+ ];
269
+ function unconsideredRisks(contract, scenarios, viewpointText) {
270
+ // Everywhere the author reasons about the journey. A mention in ANY of them is consideration —
271
+ // the check asks "did you think about this?", not "did you write a scenario for it?".
272
+ const corpus = [
273
+ viewpointText,
274
+ ...scenarios.map((s) => s.haystack),
275
+ ...(contract.flows ?? []).flatMap((f) => [f.id, f.branchFrom ?? '', f.outcome ?? '', f.reason ?? '']),
276
+ contract.minimalGuarantee ?? '', contract.successGuarantee ?? '', contract.precondition ?? '',
277
+ ].join('\n').toLowerCase();
278
+ return exports.MULTI_SCREEN_RISKS.filter((r) => !r.re.test(corpus));
279
+ }
280
+ //# sourceMappingURL=spec-branches.js.map