@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
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Adapter table — one row per assistant. Adding a new assistant = one row here,
3
+ * zero new content files (the whole point of the single-source migration).
4
+ *
5
+ * Output paths preserve the EXACT existing Claude/Copilot conventions (decision 4A) so the
6
+ * golden-regression net stays byte-identical for Claude. Codex is additive (`.agents/skills/`).
7
+ */
8
+
9
+ export type AdapterKey = 'claude' | 'copilot' | 'codex';
10
+
11
+ export interface Adapter {
12
+ key: AdapterKey;
13
+ /** capability tags this adapter owns; cap-fences resolve against this */
14
+ caps: string[];
15
+ /** output path for a `kind: skill` unit, given the skill dir name + relative file */
16
+ skillPath: (skillDir: string, file: string) => string;
17
+ /** output path for a `kind: command` unit; null => commands render as skills */
18
+ commandPath: ((name: string) => string) | null;
19
+ /**
20
+ * When commandPath is null (Codex), a command renders into the skill tree. This computes
21
+ * the skill dir for a command, and a backing skill whose name collides gets a `-guide`
22
+ * suffix (the flat-namespace collision found during spike prep: delivery/dashboard/locale).
23
+ */
24
+ commandAsSkillDir?: (name: string) => string;
25
+ /** Codex needs an explicit trigger prefixed onto the command-skill description */
26
+ commandTriggerPrefix?: boolean;
27
+ }
28
+
29
+ export const ADAPTERS: Record<AdapterKey, Adapter> = {
30
+ claude: {
31
+ key: 'claude',
32
+ caps: ['parallel-subagents'],
33
+ skillPath: (dir, file) => `.claude/skills/${dir}/${file}`,
34
+ commandPath: (name) => `.claude/commands/sungen/${name}.md`,
35
+ },
36
+ copilot: {
37
+ key: 'copilot',
38
+ caps: [],
39
+ skillPath: (dir, file) => `.github/skills/${dir}/${file}`,
40
+ commandPath: (name) => `.github/prompts/sungen-${name}.prompt.md`,
41
+ },
42
+ codex: {
43
+ key: 'codex',
44
+ caps: [],
45
+ skillPath: (dir, file) => `.agents/skills/${dir}/${file}`,
46
+ commandPath: null, // commands become skills
47
+ commandAsSkillDir: (name) => `.agents/skills/sungen-${name}`,
48
+ commandTriggerPrefix: true,
49
+ },
50
+ };
51
+
52
+ export const ALL_ADAPTERS: AdapterKey[] = ['claude', 'copilot', 'codex'];
@@ -0,0 +1,103 @@
1
+ /**
2
+ * buildOutputs — the single entry point init/update call (decision 1A).
3
+ * Produces the full [outputPath, content, class] set for the selected adapters from the
4
+ * canonical source. Pure: never touches disk.
5
+ *
6
+ * class:
7
+ * 'managed' — skill/command files; sungen owns them, always overwritten (version-managed)
8
+ * 'config' — CLAUDE.md / copilot-instructions.md / AGENTS.md; user-customizable,
9
+ * skip-if-exists unless --force (decision 2)
10
+ */
11
+ import * as fs from 'fs';
12
+ import * as path from 'path';
13
+ import { stripCaps } from './cap-stripper';
14
+ import { ADAPTERS, AdapterKey } from './adapters';
15
+ import { parseCommandSource, generateCommand } from './commands';
16
+
17
+ export type FileClass = 'managed' | 'config';
18
+ export interface BuiltFile {
19
+ outputPath: string;
20
+ content: string;
21
+ cls: FileClass;
22
+ }
23
+
24
+ const SRC_SKILLS = path.resolve(__dirname, '..', 'templates', 'ai-src', 'skills');
25
+ const SRC_CMDS = path.resolve(__dirname, '..', 'templates', 'ai-src', 'commands');
26
+ const SRC_AGENTS = path.resolve(__dirname, '..', 'templates', 'ai-src', 'agents');
27
+ const SRC_CONFIG = path.resolve(__dirname, '..', 'templates', 'ai-src', 'config');
28
+
29
+ // Config files per adapter: [source file under ai-src/config, outputPath].
30
+ const CONFIG: Record<AdapterKey, { src: string; out: string }> = {
31
+ claude: { src: 'claude.md', out: 'CLAUDE.md' },
32
+ copilot: { src: 'copilot.md', out: '.github/copilot-instructions.md' },
33
+ codex: { src: 'codex.md', out: 'AGENTS.md' },
34
+ };
35
+
36
+ function commandIds(): Set<string> {
37
+ if (!fs.existsSync(SRC_CMDS)) return new Set();
38
+ return new Set(fs.readdirSync(SRC_CMDS).filter((f) => f.endsWith('.md')).map((f) => f.replace(/\.md$/, '')));
39
+ }
40
+
41
+ /** Build every output file for the given adapters. */
42
+ export function buildOutputs(adapters: AdapterKey[]): BuiltFile[] {
43
+ const out: BuiltFile[] = [];
44
+ const cmdIds = commandIds();
45
+
46
+ for (const key of adapters) {
47
+ const adapter = ADAPTERS[key];
48
+
49
+ // --- Skills ---
50
+ if (fs.existsSync(SRC_SKILLS)) {
51
+ for (const skillDir of fs.readdirSync(SRC_SKILLS)) {
52
+ const dirPath = path.join(SRC_SKILLS, skillDir);
53
+ if (!fs.statSync(dirPath).isDirectory()) continue;
54
+ // Codex flat namespace: a skill whose name collides with a command becomes <dir>-guide.
55
+ // Both the output dir AND the SKILL.md `name:` frontmatter must change, or Codex would
56
+ // discover two skills with the same `name` (breaking $name + description selection).
57
+ const bare = skillDir.replace(/^sungen-/, '');
58
+ const collide = key === 'codex' && cmdIds.has(bare);
59
+ const outDir = collide ? `${skillDir}-guide` : skillDir;
60
+ for (const file of fs.readdirSync(dirPath)) {
61
+ if (!file.endsWith('.md')) continue;
62
+ let raw = fs.readFileSync(path.join(dirPath, file), 'utf8');
63
+ if (collide && file === 'SKILL.md') {
64
+ raw = raw.replace(/^(name:\s*)sungen-[^\n]*/m, `$1sungen-${bare}-guide`);
65
+ }
66
+ out.push({
67
+ outputPath: adapter.skillPath(outDir, file),
68
+ content: stripCaps(raw, adapter.caps, `${skillDir}/${file}`),
69
+ cls: 'managed',
70
+ });
71
+ }
72
+ }
73
+ }
74
+
75
+ // --- Commands ---
76
+ if (fs.existsSync(SRC_CMDS)) {
77
+ for (const f of fs.readdirSync(SRC_CMDS)) {
78
+ if (!f.endsWith('.md')) continue;
79
+ const id = f.replace(/\.md$/, '');
80
+ const src = parseCommandSource(fs.readFileSync(path.join(SRC_CMDS, f), 'utf8'), id);
81
+ const g = generateCommand(src, key);
82
+ out.push({ outputPath: g.outputPath, content: g.content, cls: 'managed' });
83
+ }
84
+ }
85
+
86
+ // --- Agents (Claude-only sub-agents; Copilot runs them inline, Codex has no equivalent) ---
87
+ if (key === 'claude' && fs.existsSync(SRC_AGENTS)) {
88
+ for (const f of fs.readdirSync(SRC_AGENTS)) {
89
+ if (!f.endsWith('.md')) continue;
90
+ const role = f.replace(/\.md$/, '');
91
+ const raw = fs.readFileSync(path.join(SRC_AGENTS, f), 'utf8');
92
+ out.push({ outputPath: `.claude/agents/sungen-${role}.md`, content: stripCaps(raw, adapter.caps, `agents/${f}`), cls: 'managed' });
93
+ }
94
+ }
95
+
96
+ // --- Config (skip-unless-force) ---
97
+ const cfg = CONFIG[key];
98
+ const content = fs.readFileSync(path.join(SRC_CONFIG, cfg.src), 'utf8');
99
+ out.push({ outputPath: cfg.out, content, cls: 'config' });
100
+ }
101
+
102
+ return out;
103
+ }
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Cap-fence stripper for single-source AI skill templates.
3
+ *
4
+ * A single source body may contain capability-fenced blocks that are kept or dropped
5
+ * per target adapter:
6
+ *
7
+ * {{#cap parallel-subagents}} ... kept only if the adapter HAS the cap ... {{/cap}}
8
+ * {{^cap parallel-subagents}} ... kept only if the adapter LACKS the cap ... {{/cap}}
9
+ *
10
+ * Fence lines must be on their own line. Nesting is forbidden. Unknown cap tags and
11
+ * unclosed fences FAIL LOUD (decision 5A) so a typo can never silently delete content.
12
+ *
13
+ * Blank lines left where a block is removed are normalized (no run of 3+ blank lines),
14
+ * so the diff-regression golden net stays quiet (decision 3A).
15
+ */
16
+
17
+ // Central list of valid capability tags. Adding a capability = adding it here.
18
+ // Measured divergence (2026-06-27) shows essentially one axis today.
19
+ export const VALID_CAPS = ['parallel-subagents'] as const;
20
+ export type Cap = (typeof VALID_CAPS)[number];
21
+
22
+ const OPEN_POS = /^\s*\{\{#cap\s+([a-z0-9-]+)\s*\}\}\s*$/;
23
+ const OPEN_NEG = /^\s*\{\{\^cap\s+([a-z0-9-]+)\s*\}\}\s*$/;
24
+ const CLOSE = /^\s*\{\{\/cap\}\}\s*$/;
25
+
26
+ export class CapFenceError extends Error {}
27
+
28
+ /**
29
+ * Render `body` for an adapter that owns `caps`.
30
+ * @param body raw single-source body (frontmatter already removed)
31
+ * @param caps capability tags the target adapter has
32
+ * @param skillName for error messages
33
+ */
34
+ export function stripCaps(body: string, caps: readonly string[], skillName = '<unknown>'): string {
35
+ const has = (tag: string) => caps.includes(tag);
36
+ const out: string[] = [];
37
+ let open: { tag: string; keep: boolean; line: number } | null = null;
38
+
39
+ const lines = body.split('\n');
40
+ for (let i = 0; i < lines.length; i++) {
41
+ const line = lines[i];
42
+ const mPos = line.match(OPEN_POS);
43
+ const mNeg = line.match(OPEN_NEG);
44
+ const mClose = CLOSE.test(line);
45
+
46
+ if (mPos || mNeg) {
47
+ if (open) {
48
+ throw new CapFenceError(
49
+ `${skillName}: nested cap fence at line ${i + 1} (already inside {{#cap ${open.tag}}} from line ${open.line}); nesting is forbidden`,
50
+ );
51
+ }
52
+ const tag = (mPos ? mPos[1] : mNeg![1]);
53
+ if (!VALID_CAPS.includes(tag as Cap)) {
54
+ throw new CapFenceError(
55
+ `${skillName}: unknown cap tag "${tag}" at line ${i + 1} (valid: ${VALID_CAPS.join(', ')})`,
56
+ );
57
+ }
58
+ // positive: keep when adapter HAS cap; negative: keep when adapter LACKS cap
59
+ open = { tag, keep: mPos ? has(tag) : !has(tag), line: i + 1 };
60
+ continue; // fence line itself is never emitted
61
+ }
62
+
63
+ if (mClose) {
64
+ if (!open) {
65
+ throw new CapFenceError(`${skillName}: stray {{/cap}} at line ${i + 1} with no open fence`);
66
+ }
67
+ open = null;
68
+ continue; // fence line itself is never emitted
69
+ }
70
+
71
+ if (open) {
72
+ if (open.keep) out.push(line);
73
+ // dropped block: skip the line
74
+ continue;
75
+ }
76
+ out.push(line);
77
+ }
78
+
79
+ if (open) {
80
+ throw new CapFenceError(`${skillName}: unclosed {{#cap ${open.tag}}} opened at line ${open.line}`);
81
+ }
82
+
83
+ // Normalize: collapse 3+ consecutive blank lines (left by removed blocks) to one.
84
+ return out.join('\n').replace(/\n{3,}/g, '\n\n');
85
+ }
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Command generator. Commands diverge per-adapter in BOTH frontmatter shape and body
3
+ * (measured 2026-06-27: all 10 pairs differ, create-test by 123 lines). Claude output must
4
+ * be byte-identical (gate); Copilot/Codex are re-derived from the canonical source (lenient).
5
+ *
6
+ * Source: templates/ai-src/commands/<name>.md
7
+ * ---
8
+ * name: create-test
9
+ * description: "<canonical Claude description>"
10
+ * argument-hint: "[screen-name]"
11
+ * order: 20
12
+ * claude-tools: "Read, Grep, ..." # verbatim allowed-tools line for Claude
13
+ * codex-trigger: "Run when the user asks to ..." # explicit trigger for Codex (P2 mitigation)
14
+ * copilot-tools: "[vscode, execute, ...]" # optional; default used if absent
15
+ * ---
16
+ * <body with cap-fences>
17
+ */
18
+ import { stripCaps } from './cap-stripper';
19
+ import { GenFile } from './generator';
20
+
21
+ export interface CommandSource {
22
+ id: string; // command identity (from source filename) — drives output paths
23
+ name: string; // frontmatter `name:` value; '' means the original had no name line
24
+ description: string;
25
+ argumentHint: string; // raw, e.g. "[screen-name]"
26
+ order?: number;
27
+ claudeTools: string;
28
+ copilotTools: string;
29
+ codexTrigger: string;
30
+ body: string; // with cap-fences
31
+ }
32
+
33
+ const DEFAULT_COPILOT_TOOLS = '[vscode, execute, read, edit, search, todo]';
34
+
35
+ /** Parse a source command file into a CommandSource. */
36
+ export function parseCommandSource(text: string, id: string): CommandSource {
37
+ const end = text.indexOf('\n---', 3);
38
+ const raw: Record<string, string> = {};
39
+ for (const line of text.slice(3, end).trim().split('\n')) {
40
+ const m = line.match(/^([a-zA-Z_-]+):\s*(.*)$/);
41
+ if (m) raw[m[1]] = m[2];
42
+ }
43
+ // JSON-encoded fields decode losslessly; argument-hint is kept VERBATIM so Claude output
44
+ // reproduces the original quoting (some commands quote it, some don't).
45
+ const dec = (k: string): string => {
46
+ const v = raw[k];
47
+ if (v == null) return '';
48
+ if (v.startsWith('"')) { try { return JSON.parse(v); } catch { /* fall through */ } }
49
+ return v.replace(/^['"]|['"]$/g, '');
50
+ };
51
+ const body = text.slice(end + 4).replace(/^\n+/, '');
52
+ return {
53
+ id,
54
+ name: raw['name'] != null ? dec('name') : '',
55
+ description: dec('description'),
56
+ argumentHint: raw['argument-hint'] || '', // verbatim
57
+ order: raw.order ? Number(raw.order) : undefined,
58
+ claudeTools: dec('claude-tools'),
59
+ copilotTools: raw['copilot-tools'] ? dec('copilot-tools') : DEFAULT_COPILOT_TOOLS,
60
+ codexTrigger: dec('codex-trigger'),
61
+ body,
62
+ };
63
+ }
64
+
65
+ const unquote = (s: string) => s.replace(/^['"]|['"]$/g, '');
66
+
67
+ /** Claude command file — MUST reproduce the exact existing format (byte-identical gate). */
68
+ export function renderClaudeCommand(c: CommandSource): string {
69
+ const fm = [
70
+ '---',
71
+ ...(c.name ? [`name: ${c.name}`] : []), // some commands (locale) omit name
72
+ `description: '${c.description}'`,
73
+ `argument-hint: ${c.argumentHint}`,
74
+ `allowed-tools: ${c.claudeTools}`,
75
+ '---',
76
+ ].join('\n');
77
+ return fm + '\n\n' + stripCaps(c.body, ['parallel-subagents'], `cmd:${c.id}`);
78
+ }
79
+
80
+ /** Copilot prompt file — re-derived (lenient). */
81
+ export function renderCopilotCommand(c: CommandSource): string {
82
+ const fm = [
83
+ '---',
84
+ `name: sungen-${c.id}`,
85
+ `description: '${c.description}'`,
86
+ `argument-hint: '${unquote(c.argumentHint)}'`,
87
+ `agent: 'agent'`,
88
+ `tools: ${c.copilotTools}`,
89
+ '---',
90
+ ].join('\n');
91
+ return fm + '\n\n' + stripCaps(c.body, [], `cmd:${c.id}`);
92
+ }
93
+
94
+ /** Codex command-skill — command folds into a skill with an explicit trigger (decision P2). */
95
+ export function renderCodexCommand(c: CommandSource): string {
96
+ const desc = c.codexTrigger ? `${c.codexTrigger}` : c.description;
97
+ const fm = [
98
+ '---',
99
+ `name: sungen-${c.id}`,
100
+ `description: ${JSON.stringify(desc)}`,
101
+ `kind: command`,
102
+ ...(c.order != null ? [`order: ${c.order}`] : []),
103
+ '---',
104
+ ].join('\n');
105
+ return fm + '\n\n' + stripCaps(c.body, [], `cmd:${c.id}`);
106
+ }
107
+
108
+ export function generateCommand(c: CommandSource, adapter: 'claude' | 'copilot' | 'codex'): GenFile {
109
+ if (adapter === 'claude') return { outputPath: `.claude/commands/sungen/${c.id}.md`, content: renderClaudeCommand(c) };
110
+ if (adapter === 'copilot') return { outputPath: `.github/prompts/sungen-${c.id}.prompt.md`, content: renderCopilotCommand(c) };
111
+ return { outputPath: `.agents/skills/sungen-${c.id}/SKILL.md`, content: renderCodexCommand(c) };
112
+ }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Single-source generator (decision 1A).
3
+ *
4
+ * Produces an in-memory list of [outputPath, content] pairs from canonical source skill
5
+ * files, for the selected adapters. `init` and `update` consume this list and keep their own
6
+ * write semantics — this module never touches disk.
7
+ *
8
+ * Source layout (canonical = Claude content, decision 2):
9
+ * templates/ai-src/skills/<skillDir>/<file>.md (kind: skill, possibly multi-file)
10
+ * templates/ai-src/commands/<name>.md (kind: command) [wired in a later step]
11
+ *
12
+ * Each source file may contain cap-fences ({{#cap}} / {{^cap}}) for per-adapter deltas.
13
+ */
14
+
15
+ import * as fs from 'fs';
16
+ import * as path from 'path';
17
+ import { stripCaps } from './cap-stripper';
18
+ import { ADAPTERS, AdapterKey } from './adapters';
19
+
20
+ export interface GenFile {
21
+ outputPath: string; // repo-relative
22
+ content: string;
23
+ }
24
+
25
+ /** Render all skill units under `srcSkillsDir` for one adapter. */
26
+ export function generateSkills(srcSkillsDir: string, adapterKey: AdapterKey): GenFile[] {
27
+ const adapter = ADAPTERS[adapterKey];
28
+ const out: GenFile[] = [];
29
+ if (!fs.existsSync(srcSkillsDir)) return out;
30
+
31
+ for (const skillDir of fs.readdirSync(srcSkillsDir)) {
32
+ const dirPath = path.join(srcSkillsDir, skillDir);
33
+ if (!fs.statSync(dirPath).isDirectory()) continue;
34
+ for (const file of fs.readdirSync(dirPath)) {
35
+ if (!file.endsWith('.md')) continue;
36
+ const raw = fs.readFileSync(path.join(dirPath, file), 'utf8');
37
+ const content = stripCaps(raw, adapter.caps, `${skillDir}/${file}`);
38
+ out.push({ outputPath: adapter.skillPath(skillDir, file), content });
39
+ }
40
+ }
41
+ return out;
42
+ }
43
+
44
+ /** Render for several adapters at once. */
45
+ export function generate(srcSkillsDir: string, adapters: AdapterKey[]): GenFile[] {
46
+ return adapters.flatMap((a) => generateSkills(srcSkillsDir, a));
47
+ }
@@ -0,0 +1,124 @@
1
+ /**
2
+ * Golden regression net for the single-source generator.
3
+ *
4
+ * Compares generated output for all adapters against committed fixtures under
5
+ * tests/golden/ai-skills/fixtures/. The fixtures were frozen from output that was proven
6
+ * byte-identical to the original per-assistant templates (see git history: the prior
7
+ * ai-instructions-based golden). From now on the fixtures ARE the contract — any change to
8
+ * a source skill/command must be reflected with `--update`, making every output change a
9
+ * reviewable diff.
10
+ *
11
+ * tsx .../golden-skills.test.ts # verify
12
+ * tsx .../golden-skills.test.ts --update # re-freeze fixtures after an intentional change
13
+ *
14
+ * Also runs source lint (decision 6A): required frontmatter + unique-ish command order,
15
+ * and a Codex flat-namespace collision check.
16
+ */
17
+ import * as fs from 'fs';
18
+ import * as path from 'path';
19
+ import { buildOutputs } from './build';
20
+ import { parseCommandSource } from './commands';
21
+
22
+ const FIX = path.resolve(__dirname, '..', '..', '..', 'tests', 'golden', 'ai-skills', 'fixtures');
23
+ const SRC = path.resolve(__dirname, '..', 'templates', 'ai-src', 'skills');
24
+ const SRC_CMD = path.resolve(__dirname, '..', 'templates', 'ai-src', 'commands');
25
+ const UPDATE = process.argv.includes('--update');
26
+
27
+ function lint(): string[] {
28
+ const errs: string[] = [];
29
+ const fmKeys = (t: string): Set<string> => {
30
+ const s = new Set<string>();
31
+ if (!t.startsWith('---')) return s;
32
+ for (const l of t.slice(3, t.indexOf('\n---', 3)).split('\n')) { const m = l.match(/^([a-zA-Z_-]+):/); if (m) s.add(m[1]); }
33
+ return s;
34
+ };
35
+ for (const dir of fs.existsSync(SRC) ? fs.readdirSync(SRC) : []) {
36
+ const dp = path.join(SRC, dir);
37
+ if (!fs.statSync(dp).isDirectory()) continue;
38
+ const f = path.join(dp, 'SKILL.md');
39
+ if (!fs.existsSync(f)) continue;
40
+ const k = fmKeys(fs.readFileSync(f, 'utf8'));
41
+ if (!k.has('name')) errs.push(`${dir}/SKILL.md: missing frontmatter name`);
42
+ if (!k.has('description')) errs.push(`${dir}/SKILL.md: missing frontmatter description`);
43
+ }
44
+ const seen = new Map<string, string>();
45
+ for (const f of fs.existsSync(SRC_CMD) ? fs.readdirSync(SRC_CMD) : []) {
46
+ const c = parseCommandSource(fs.readFileSync(path.join(SRC_CMD, f), 'utf8'), f.replace(/\.md$/, ''));
47
+ if (!c.description) errs.push(`commands/${f}: missing description`);
48
+ if (c.order != null) { const k = String(c.order); if (seen.has(k)) { /* allowed: parallel entrypoints */ } else seen.set(k, f); }
49
+ }
50
+ return errs;
51
+ }
52
+
53
+ function run() {
54
+ // Guardrail: the retired per-assistant folder must never come back. Skills are authored
55
+ // ONCE in ai-src/. If a dev recreates ai-instructions/, fail loud with a pointer.
56
+ const legacyDir = path.resolve(__dirname, '..', 'templates', 'ai-instructions');
57
+ if (fs.existsSync(legacyDir)) {
58
+ console.error('GOLDEN FAILED — templates/ai-instructions/ exists again.');
59
+ console.error(' Author skills/commands in templates/ai-src/ ONLY (see ai-src/README.md).');
60
+ console.error(' The per-assistant duplicates are generated from ai-src by ai-skills/build.ts.');
61
+ process.exit(1);
62
+ }
63
+
64
+ const lintErrs = lint();
65
+ // stripCaps throws on unknown cap tag / unclosed fence, so buildOutputs validates fences.
66
+ const outputs = buildOutputs(['claude', 'copilot', 'codex']);
67
+
68
+ // Codex has ONE flat .agents/skills/ namespace — every discovered SKILL.md `name:` must be
69
+ // unique, or `$name`/description selection is ambiguous (regression guard for the command vs
70
+ // backing-skill collision: dashboard/delivery/locale must be <name> vs <name>-guide).
71
+ const codexNames = new Map<string, string>();
72
+ for (const f of outputs) {
73
+ if (!f.outputPath.startsWith('.agents/skills/') || !f.outputPath.endsWith('/SKILL.md')) continue;
74
+ const m = f.content.match(/^name:\s*(\S+)/m);
75
+ if (!m) continue;
76
+ if (codexNames.has(m[1])) lintErrs.push(`codex duplicate skill name "${m[1]}" (${f.outputPath} & ${codexNames.get(m[1])})`);
77
+ else codexNames.set(m[1], f.outputPath);
78
+ }
79
+
80
+ if (UPDATE) {
81
+ fs.rmSync(FIX, { recursive: true, force: true });
82
+ for (const f of outputs) {
83
+ const abs = path.join(FIX, f.outputPath);
84
+ fs.mkdirSync(path.dirname(abs), { recursive: true });
85
+ fs.writeFileSync(abs, f.content);
86
+ }
87
+ console.log(`✓ froze ${outputs.length} fixtures -> tests/golden/ai-skills/fixtures/`);
88
+ if (lintErrs.length) { console.error('source lint errors:'); lintErrs.forEach((e) => console.error(' ✗ ' + e)); process.exit(1); }
89
+ return;
90
+ }
91
+
92
+ let pass = 0; const mismatches: string[] = []; const missing: string[] = [];
93
+ const expectedPaths = new Set(outputs.map((f) => f.outputPath));
94
+ for (const f of outputs) {
95
+ const abs = path.join(FIX, f.outputPath);
96
+ if (!fs.existsSync(abs)) { missing.push(f.outputPath); continue; }
97
+ if (fs.readFileSync(abs, 'utf8') === f.content) pass++;
98
+ else mismatches.push(f.outputPath);
99
+ }
100
+ // fixtures present but no longer generated => stale
101
+ const stale: string[] = [];
102
+ const walk = (d: string, base = '') => {
103
+ if (!fs.existsSync(d)) return;
104
+ for (const e of fs.readdirSync(d, { withFileTypes: true })) {
105
+ const rel = path.join(base, e.name);
106
+ if (e.isDirectory()) walk(path.join(d, e.name), rel);
107
+ else if (!expectedPaths.has(rel)) stale.push(rel);
108
+ }
109
+ };
110
+ walk(FIX);
111
+
112
+ console.log(`GOLDEN — source lint: ${lintErrs.length === 0 ? 'PASS' : lintErrs.length + ' error(s)'}`);
113
+ lintErrs.forEach((e) => console.log(' ✗ ' + e));
114
+ console.log(`GOLDEN — fixtures: ${pass}/${outputs.length} match | mismatch ${mismatches.length} | missing ${missing.length} | stale ${stale.length}`);
115
+ [...mismatches.map((m) => 'MISMATCH ' + m), ...missing.map((m) => 'MISSING ' + m), ...stale.map((s) => 'STALE ' + s)].forEach((x) => console.log(' ✗ ' + x));
116
+
117
+ if (lintErrs.length || mismatches.length || missing.length || stale.length) {
118
+ console.error('GOLDEN FAILED — run with --update if the change was intentional, then review the diff.');
119
+ process.exit(1);
120
+ }
121
+ console.log('✓ GOLDEN PASS — all adapter output matches frozen fixtures.');
122
+ }
123
+
124
+ run();
@@ -0,0 +1,18 @@
1
+ import { AdapterKey, ALL_ADAPTERS } from './adapters';
2
+
3
+ /**
4
+ * Resolve `--assistant` CLI values to adapter keys.
5
+ * Empty -> ['claude'] (decision T5: never silently install all into a single-assistant repo).
6
+ * 'all' -> every adapter. Unknown values throw.
7
+ */
8
+ export function resolveAssistants(input: string[] | undefined): AdapterKey[] {
9
+ if (!input || input.length === 0) return ['claude'];
10
+ const set = new Set<AdapterKey>();
11
+ for (const raw of input) {
12
+ const v = raw.toLowerCase().trim();
13
+ if (v === 'all') { ALL_ADAPTERS.forEach((a) => set.add(a)); continue; }
14
+ if (v === 'claude' || v === 'copilot' || v === 'codex') { set.add(v); continue; }
15
+ throw new Error(`Unknown --assistant "${raw}" (valid: claude, copilot, codex, all)`);
16
+ }
17
+ return [...set];
18
+ }
@@ -0,0 +1,92 @@
1
+ /**
2
+ * applyOutputs — write a BuiltFile[] to disk with the agreed semantics (decisions 2, T2).
3
+ *
4
+ * managed (skills/commands): ALWAYS overwritten (version-managed, no rollback)
5
+ * config (CLAUDE.md/AGENTS.md/copilot-instructions): skip-if-exists unless `force`
6
+ * orphans: managed files written last run but not this run are DELETED (manifest-derived,
7
+ * replaces the hand-curated STALE list — decision T2)
8
+ * detect-and-warn: if a managed file on disk was hand-edited since we wrote it, warn
9
+ * dry-run: report adds/overwrites/skips/deletes/warnings without touching disk
10
+ *
11
+ * Manifest: <cwd>/.sungen/manifest.json = { version, managed: { <path>: <sha256> } }
12
+ */
13
+ import * as fs from 'fs';
14
+ import * as path from 'path';
15
+ import * as crypto from 'crypto';
16
+ import { BuiltFile } from './build';
17
+
18
+ export interface ApplyOptions { force?: boolean; dryRun?: boolean; version: string }
19
+ export interface ApplyReport {
20
+ created: string[]; overwritten: string[]; skippedConfig: string[];
21
+ deletedOrphans: string[]; handEditWarnings: string[];
22
+ }
23
+
24
+ const MANIFEST_REL = path.join('.sungen', 'manifest.json');
25
+ const sha = (s: string) => crypto.createHash('sha256').update(s).digest('hex');
26
+
27
+ interface Manifest { version: string; managed: Record<string, string> }
28
+
29
+ function readManifest(cwd: string): Manifest {
30
+ const p = path.join(cwd, MANIFEST_REL);
31
+ if (!fs.existsSync(p)) return { version: '', managed: {} };
32
+ try { return JSON.parse(fs.readFileSync(p, 'utf8')); } catch { return { version: '', managed: {} }; }
33
+ }
34
+
35
+ export function applyOutputs(cwd: string, outputs: BuiltFile[], opts: ApplyOptions): ApplyReport {
36
+ const r: ApplyReport = { created: [], overwritten: [], skippedConfig: [], deletedOrphans: [], handEditWarnings: [] };
37
+ const prev = readManifest(cwd);
38
+ const newManaged: Record<string, string> = {};
39
+
40
+ const write = (rel: string, content: string) => {
41
+ if (opts.dryRun) return;
42
+ const abs = path.join(cwd, rel);
43
+ fs.mkdirSync(path.dirname(abs), { recursive: true });
44
+ fs.writeFileSync(abs, content, 'utf8');
45
+ };
46
+
47
+ for (const f of outputs) {
48
+ const abs = path.join(cwd, f.outputPath);
49
+ const exists = fs.existsSync(abs);
50
+
51
+ if (f.cls === 'config') {
52
+ if (exists && !opts.force) { r.skippedConfig.push(f.outputPath); continue; }
53
+ (exists ? r.overwritten : r.created).push(f.outputPath);
54
+ write(f.outputPath, f.content);
55
+ continue;
56
+ }
57
+
58
+ // managed: always overwrite, but warn if hand-edited since our last write
59
+ if (exists) {
60
+ const current = fs.readFileSync(abs, 'utf8');
61
+ const recorded = prev.managed[f.outputPath];
62
+ if (recorded && sha(current) !== recorded && sha(current) !== sha(f.content)) {
63
+ r.handEditWarnings.push(f.outputPath);
64
+ }
65
+ if (current !== f.content) r.overwritten.push(f.outputPath);
66
+ } else {
67
+ r.created.push(f.outputPath);
68
+ }
69
+ write(f.outputPath, f.content);
70
+ newManaged[f.outputPath] = sha(f.content);
71
+ }
72
+
73
+ // Orphan cleanup: managed files we wrote last time but not now.
74
+ for (const oldPath of Object.keys(prev.managed)) {
75
+ if (newManaged[oldPath]) continue;
76
+ r.deletedOrphans.push(oldPath);
77
+ if (!opts.dryRun) {
78
+ const abs = path.join(cwd, oldPath);
79
+ if (fs.existsSync(abs)) fs.rmSync(abs, { force: true });
80
+ // prune now-empty skill dir
81
+ const dir = path.dirname(abs);
82
+ try { if (fs.existsSync(dir) && fs.readdirSync(dir).length === 0) fs.rmdirSync(dir); } catch { /* ignore */ }
83
+ }
84
+ }
85
+
86
+ if (!opts.dryRun) {
87
+ const mPath = path.join(cwd, MANIFEST_REL);
88
+ fs.mkdirSync(path.dirname(mPath), { recursive: true });
89
+ fs.writeFileSync(mPath, JSON.stringify({ version: opts.version, managed: newManaged }, null, 2));
90
+ }
91
+ return r;
92
+ }