@antheo/morph 0.0.0-stage → 0.3.0

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 (464) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +266 -2
  3. package/SKILL.md +61 -0
  4. package/dist/ai/cli-provider.d.ts +80 -0
  5. package/dist/ai/cli-provider.js +250 -0
  6. package/dist/ai/gate.d.ts +39 -0
  7. package/dist/ai/gate.js +124 -0
  8. package/dist/ai/provider.d.ts +36 -0
  9. package/dist/ai/provider.js +168 -0
  10. package/dist/ai/repair.d.ts +90 -0
  11. package/dist/ai/repair.js +172 -0
  12. package/dist/analyzer/deps.d.ts +30 -0
  13. package/dist/analyzer/deps.js +265 -0
  14. package/dist/analyzer/manifest.d.ts +5 -0
  15. package/dist/analyzer/manifest.js +119 -0
  16. package/dist/analyzer/parse.d.ts +21 -0
  17. package/dist/analyzer/parse.js +29 -0
  18. package/dist/batch-worker.d.ts +16 -0
  19. package/dist/batch-worker.js +10 -0
  20. package/dist/batch.d.ts +26 -0
  21. package/dist/batch.js +227 -0
  22. package/dist/bridge/index.d.ts +26 -0
  23. package/dist/bridge/index.js +138 -0
  24. package/dist/bridge/props.d.ts +56 -0
  25. package/dist/bridge/props.js +191 -0
  26. package/dist/bridge/wrappers.d.ts +24 -0
  27. package/dist/bridge/wrappers.js +276 -0
  28. package/dist/cli/format.d.ts +7 -0
  29. package/dist/cli/format.js +30 -0
  30. package/dist/cli.d.ts +2 -0
  31. package/dist/cli.js +492 -0
  32. package/dist/fonts/carry.d.ts +34 -0
  33. package/dist/fonts/carry.js +113 -0
  34. package/dist/fonts/fallback.d.ts +11 -0
  35. package/dist/fonts/fallback.js +21 -0
  36. package/dist/fonts/google.d.ts +65 -0
  37. package/dist/fonts/google.js +343 -0
  38. package/dist/fonts/index.d.ts +27 -0
  39. package/dist/fonts/index.js +48 -0
  40. package/dist/fonts/local.d.ts +46 -0
  41. package/dist/fonts/local.js +150 -0
  42. package/dist/fonts/sfnt.d.ts +19 -0
  43. package/dist/fonts/sfnt.js +174 -0
  44. package/dist/fonts/shim.d.ts +14 -0
  45. package/dist/fonts/shim.js +96 -0
  46. package/dist/gate.d.ts +105 -0
  47. package/dist/gate.js +157 -0
  48. package/dist/index.d.ts +55 -0
  49. package/dist/index.js +74 -0
  50. package/dist/ir/annotate.d.ts +16 -0
  51. package/dist/ir/annotate.js +145 -0
  52. package/dist/ir/as-child.d.ts +18 -0
  53. package/dist/ir/as-child.js +239 -0
  54. package/dist/ir/compounds.d.ts +27 -0
  55. package/dist/ir/compounds.js +183 -0
  56. package/dist/ir/contexts.d.ts +26 -0
  57. package/dist/ir/contexts.js +185 -0
  58. package/dist/ir/dom.d.ts +11 -0
  59. package/dist/ir/dom.js +60 -0
  60. package/dist/ir/effect-returns.d.ts +10 -0
  61. package/dist/ir/effect-returns.js +25 -0
  62. package/dist/ir/extract-ui-types.d.ts +33 -0
  63. package/dist/ir/extract-ui-types.js +224 -0
  64. package/dist/ir/extract-ui.d.ts +34 -0
  65. package/dist/ir/extract-ui.js +567 -0
  66. package/dist/ir/falsy.d.ts +13 -0
  67. package/dist/ir/falsy.js +66 -0
  68. package/dist/ir/forward-refs.d.ts +11 -0
  69. package/dist/ir/forward-refs.js +155 -0
  70. package/dist/ir/fragment-source.d.ts +4 -0
  71. package/dist/ir/fragment-source.js +13 -0
  72. package/dist/ir/fragments.d.ts +32 -0
  73. package/dist/ir/fragments.js +192 -0
  74. package/dist/ir/helper-snippets.d.ts +30 -0
  75. package/dist/ir/helper-snippets.js +550 -0
  76. package/dist/ir/latest-refs.d.ts +11 -0
  77. package/dist/ir/latest-refs.js +187 -0
  78. package/dist/ir/live-args.d.ts +26 -0
  79. package/dist/ir/live-args.js +335 -0
  80. package/dist/ir/lower.d.ts +83 -0
  81. package/dist/ir/lower.js +6016 -0
  82. package/dist/ir/markup-values.d.ts +16 -0
  83. package/dist/ir/markup-values.js +188 -0
  84. package/dist/ir/model.d.ts +605 -0
  85. package/dist/ir/model.js +1 -0
  86. package/dist/ir/oracle.d.ts +91 -0
  87. package/dist/ir/oracle.js +610 -0
  88. package/dist/ir/radix.d.ts +122 -0
  89. package/dist/ir/radix.js +344 -0
  90. package/dist/ir/rename.d.ts +15 -0
  91. package/dist/ir/rename.js +151 -0
  92. package/dist/ir/render-props.d.ts +31 -0
  93. package/dist/ir/render-props.js +67 -0
  94. package/dist/ir/rewrite.d.ts +44 -0
  95. package/dist/ir/rewrite.js +381 -0
  96. package/dist/ir/running-index.d.ts +11 -0
  97. package/dist/ir/running-index.js +217 -0
  98. package/dist/ir/snapshots.d.ts +12 -0
  99. package/dist/ir/snapshots.js +140 -0
  100. package/dist/ir/style.d.ts +19 -0
  101. package/dist/ir/style.js +76 -0
  102. package/dist/ir/types.d.ts +42 -0
  103. package/dist/ir/types.js +271 -0
  104. package/dist/ir/walk.d.ts +11 -0
  105. package/dist/ir/walk.js +18 -0
  106. package/dist/mcp/server.d.ts +81 -0
  107. package/dist/mcp/server.js +518 -0
  108. package/dist/pipeline.d.ts +26 -0
  109. package/dist/pipeline.js +750 -0
  110. package/dist/registry/add.d.ts +91 -0
  111. package/dist/registry/add.js +273 -0
  112. package/dist/registry/fetch.d.ts +40 -0
  113. package/dist/registry/fetch.js +186 -0
  114. package/dist/registry/ip.d.ts +18 -0
  115. package/dist/registry/ip.js +153 -0
  116. package/dist/registry/item.d.ts +39 -0
  117. package/dist/registry/item.js +131 -0
  118. package/dist/registry/load.d.ts +35 -0
  119. package/dist/registry/load.js +106 -0
  120. package/dist/registry/paths.d.ts +8 -0
  121. package/dist/registry/paths.js +43 -0
  122. package/dist/registry/publish.d.ts +119 -0
  123. package/dist/registry/publish.js +439 -0
  124. package/dist/targets/angular/bank/bank.d.ts +39 -0
  125. package/dist/targets/angular/bank/bank.js +61 -0
  126. package/dist/targets/angular/bank/helpers.d.ts +64 -0
  127. package/dist/targets/angular/bank/helpers.js +246 -0
  128. package/dist/targets/angular/bank/kept.d.ts +98 -0
  129. package/dist/targets/angular/bank/kept.js +791 -0
  130. package/dist/targets/angular/bank/plan-helpers.d.ts +17 -0
  131. package/dist/targets/angular/bank/plan-helpers.js +286 -0
  132. package/dist/targets/angular/bank/plan.d.ts +22 -0
  133. package/dist/targets/angular/bank/plan.js +152 -0
  134. package/dist/targets/angular/bank/receivers.d.ts +66 -0
  135. package/dist/targets/angular/bank/receivers.js +293 -0
  136. package/dist/targets/angular/bank/runtime.d.ts +14 -0
  137. package/dist/targets/angular/bank/runtime.js +152 -0
  138. package/dist/targets/angular/controlled.d.ts +7 -0
  139. package/dist/targets/angular/controlled.js +37 -0
  140. package/dist/targets/angular/dynamic-tags.d.ts +34 -0
  141. package/dist/targets/angular/dynamic-tags.js +192 -0
  142. package/dist/targets/angular/emit.d.ts +41 -0
  143. package/dist/targets/angular/emit.js +5970 -0
  144. package/dist/targets/angular/exports.d.ts +48 -0
  145. package/dist/targets/angular/exports.js +243 -0
  146. package/dist/targets/angular/helpers.d.ts +15 -0
  147. package/dist/targets/angular/helpers.js +33 -0
  148. package/dist/targets/angular/host-boundary.d.ts +5 -0
  149. package/dist/targets/angular/host-boundary.js +166 -0
  150. package/dist/targets/angular/host-form.d.ts +150 -0
  151. package/dist/targets/angular/host-form.js +727 -0
  152. package/dist/targets/angular/markup-values.d.ts +58 -0
  153. package/dist/targets/angular/markup-values.js +661 -0
  154. package/dist/targets/angular/motion-directive.d.ts +12 -0
  155. package/dist/targets/angular/motion-directive.js +257 -0
  156. package/dist/targets/angular/motion-hooks.d.ts +73 -0
  157. package/dist/targets/angular/motion-hooks.js +293 -0
  158. package/dist/targets/angular/motion-layout.d.ts +14 -0
  159. package/dist/targets/angular/motion-layout.js +74 -0
  160. package/dist/targets/angular/motion-templates.d.ts +10 -0
  161. package/dist/targets/angular/motion-templates.js +65 -0
  162. package/dist/targets/angular/motion.d.ts +57 -0
  163. package/dist/targets/angular/motion.js +202 -0
  164. package/dist/targets/angular/narrowing.d.ts +24 -0
  165. package/dist/targets/angular/narrowing.js +205 -0
  166. package/dist/targets/angular/ngc.d.ts +23 -0
  167. package/dist/targets/angular/ngc.js +134 -0
  168. package/dist/targets/angular/passed-handle.d.ts +39 -0
  169. package/dist/targets/angular/passed-handle.js +154 -0
  170. package/dist/targets/angular/projected.d.ts +9 -0
  171. package/dist/targets/angular/projected.js +63 -0
  172. package/dist/targets/angular/radix/cores/alert-dialog.d.ts +13 -0
  173. package/dist/targets/angular/radix/cores/alert-dialog.js +388 -0
  174. package/dist/targets/angular/radix/cores/index.d.ts +17 -0
  175. package/dist/targets/angular/radix/cores/index.js +50 -0
  176. package/dist/targets/angular/radix/cores/slider.d.ts +8 -0
  177. package/dist/targets/angular/radix/cores/slider.js +202 -0
  178. package/dist/targets/angular/radix/index.d.ts +21 -0
  179. package/dist/targets/angular/radix/index.js +35 -0
  180. package/dist/targets/angular/radix/packages.d.ts +3 -0
  181. package/dist/targets/angular/radix/packages.js +558 -0
  182. package/dist/targets/angular/radix/part.d.ts +236 -0
  183. package/dist/targets/angular/radix/part.js +71 -0
  184. package/dist/targets/angular/radix/prepare.d.ts +66 -0
  185. package/dist/targets/angular/radix/prepare.js +548 -0
  186. package/dist/targets/angular/radix/template.d.ts +43 -0
  187. package/dist/targets/angular/radix/template.js +172 -0
  188. package/dist/targets/angular/refs.d.ts +68 -0
  189. package/dist/targets/angular/refs.js +443 -0
  190. package/dist/targets/angular/slots.d.ts +22 -0
  191. package/dist/targets/angular/slots.js +60 -0
  192. package/dist/targets/angular/source-types.d.ts +10 -0
  193. package/dist/targets/angular/source-types.js +45 -0
  194. package/dist/targets/angular/spread-forward.d.ts +24 -0
  195. package/dist/targets/angular/spread-forward.js +72 -0
  196. package/dist/targets/angular/spread.d.ts +32 -0
  197. package/dist/targets/angular/spread.js +182 -0
  198. package/dist/targets/angular/svg-hosts.d.ts +25 -0
  199. package/dist/targets/angular/svg-hosts.js +107 -0
  200. package/dist/targets/angular/template-expr.d.ts +36 -0
  201. package/dist/targets/angular/template-expr.js +287 -0
  202. package/dist/targets/angular/types.d.ts +9 -0
  203. package/dist/targets/angular/types.js +63 -0
  204. package/dist/targets/angular/walk.d.ts +11 -0
  205. package/dist/targets/angular/walk.js +26 -0
  206. package/dist/targets/react-native/emit.d.ts +14 -0
  207. package/dist/targets/react-native/emit.js +585 -0
  208. package/dist/targets/react-native/fidelity.d.ts +5 -0
  209. package/dist/targets/react-native/fidelity.js +43 -0
  210. package/dist/targets/react-native/motion.d.ts +10 -0
  211. package/dist/targets/react-native/motion.js +290 -0
  212. package/dist/targets/react-native/skia.d.ts +30 -0
  213. package/dist/targets/react-native/skia.js +358 -0
  214. package/dist/targets/shared/context.d.ts +47 -0
  215. package/dist/targets/shared/context.js +195 -0
  216. package/dist/targets/shared/foreign.d.ts +10 -0
  217. package/dist/targets/shared/foreign.js +72 -0
  218. package/dist/targets/shared/fragments.d.ts +21 -0
  219. package/dist/targets/shared/fragments.js +309 -0
  220. package/dist/targets/shared/handles.d.ts +65 -0
  221. package/dist/targets/shared/handles.js +299 -0
  222. package/dist/targets/shared/inline.d.ts +53 -0
  223. package/dist/targets/shared/inline.js +524 -0
  224. package/dist/targets/shared/layout.d.ts +70 -0
  225. package/dist/targets/shared/layout.js +224 -0
  226. package/dist/targets/shared/markup.d.ts +26 -0
  227. package/dist/targets/shared/markup.js +65 -0
  228. package/dist/targets/shared/module.d.ts +84 -0
  229. package/dist/targets/shared/module.js +468 -0
  230. package/dist/targets/shared/motion-hooks.d.ts +37 -0
  231. package/dist/targets/shared/motion-hooks.js +87 -0
  232. package/dist/targets/shared/motion-layout.d.ts +70 -0
  233. package/dist/targets/shared/motion-layout.js +392 -0
  234. package/dist/targets/shared/portal.d.ts +10 -0
  235. package/dist/targets/shared/portal.js +23 -0
  236. package/dist/targets/shared/prop-writes.d.ts +11 -0
  237. package/dist/targets/shared/prop-writes.js +32 -0
  238. package/dist/targets/shared/prune.d.ts +54 -0
  239. package/dist/targets/shared/prune.js +405 -0
  240. package/dist/targets/shared/react-libs.d.ts +25 -0
  241. package/dist/targets/shared/react-libs.js +142 -0
  242. package/dist/targets/shared/react-types.d.ts +16 -0
  243. package/dist/targets/shared/react-types.js +374 -0
  244. package/dist/targets/shared/react-values.d.ts +20 -0
  245. package/dist/targets/shared/react-values.js +145 -0
  246. package/dist/targets/shared/ref-callback.d.ts +16 -0
  247. package/dist/targets/shared/ref-callback.js +114 -0
  248. package/dist/targets/shared/script.d.ts +65 -0
  249. package/dist/targets/shared/script.js +406 -0
  250. package/dist/targets/shared/unused.d.ts +12 -0
  251. package/dist/targets/shared/unused.js +146 -0
  252. package/dist/targets/svelte/dom-spread.d.ts +27 -0
  253. package/dist/targets/svelte/dom-spread.js +146 -0
  254. package/dist/targets/svelte/emit.d.ts +15 -0
  255. package/dist/targets/svelte/emit.js +3784 -0
  256. package/dist/targets/svelte/handle-branches.d.ts +22 -0
  257. package/dist/targets/svelte/handle-branches.js +146 -0
  258. package/dist/targets/svelte/html-keys.d.ts +9 -0
  259. package/dist/targets/svelte/html-keys.js +40 -0
  260. package/dist/targets/svelte/markup-data/data.d.ts +51 -0
  261. package/dist/targets/svelte/markup-data/data.js +305 -0
  262. package/dist/targets/svelte/markup-data/helper.d.ts +12 -0
  263. package/dist/targets/svelte/markup-data/helper.js +81 -0
  264. package/dist/targets/svelte/markup-data/module-data.d.ts +21 -0
  265. package/dist/targets/svelte/markup-data/module-data.js +473 -0
  266. package/dist/targets/svelte/markup-data/sites.d.ts +52 -0
  267. package/dist/targets/svelte/markup-data/sites.js +303 -0
  268. package/dist/targets/svelte/motion-layout.d.ts +13 -0
  269. package/dist/targets/svelte/motion-layout.js +70 -0
  270. package/dist/targets/svelte/motion-table.d.ts +14 -0
  271. package/dist/targets/svelte/motion-table.js +308 -0
  272. package/dist/targets/svelte/motion.d.ts +46 -0
  273. package/dist/targets/svelte/motion.js +405 -0
  274. package/dist/targets/svelte/presence.d.ts +71 -0
  275. package/dist/targets/svelte/presence.js +318 -0
  276. package/dist/targets/svelte/radix/accordion.d.ts +9 -0
  277. package/dist/targets/svelte/radix/accordion.js +24 -0
  278. package/dist/targets/svelte/radix/aspect-ratio.d.ts +6 -0
  279. package/dist/targets/svelte/radix/aspect-ratio.js +8 -0
  280. package/dist/targets/svelte/radix/avatar.d.ts +6 -0
  281. package/dist/targets/svelte/radix/avatar.js +10 -0
  282. package/dist/targets/svelte/radix/checkbox.d.ts +10 -0
  283. package/dist/targets/svelte/radix/checkbox.js +24 -0
  284. package/dist/targets/svelte/radix/collapsible.d.ts +7 -0
  285. package/dist/targets/svelte/radix/collapsible.js +16 -0
  286. package/dist/targets/svelte/radix/context-menu.d.ts +8 -0
  287. package/dist/targets/svelte/radix/context-menu.js +49 -0
  288. package/dist/targets/svelte/radix/cores/alert-dialog.d.ts +17 -0
  289. package/dist/targets/svelte/radix/cores/alert-dialog.js +449 -0
  290. package/dist/targets/svelte/radix/cores/collapsible.d.ts +12 -0
  291. package/dist/targets/svelte/radix/cores/collapsible.js +214 -0
  292. package/dist/targets/svelte/radix/cores/core.d.ts +32 -0
  293. package/dist/targets/svelte/radix/cores/core.js +80 -0
  294. package/dist/targets/svelte/radix/cores/direction.d.ts +10 -0
  295. package/dist/targets/svelte/radix/cores/direction.js +64 -0
  296. package/dist/targets/svelte/radix/cores/index.d.ts +19 -0
  297. package/dist/targets/svelte/radix/cores/index.js +85 -0
  298. package/dist/targets/svelte/radix/cores/modal-layer.d.ts +11 -0
  299. package/dist/targets/svelte/radix/cores/modal-layer.js +244 -0
  300. package/dist/targets/svelte/radix/cores/presence.d.ts +12 -0
  301. package/dist/targets/svelte/radix/cores/presence.js +129 -0
  302. package/dist/targets/svelte/radix/cores/slider-logic.d.ts +10 -0
  303. package/dist/targets/svelte/radix/cores/slider-logic.js +287 -0
  304. package/dist/targets/svelte/radix/cores/slider.d.ts +13 -0
  305. package/dist/targets/svelte/radix/cores/slider.js +267 -0
  306. package/dist/targets/svelte/radix/dialog.d.ts +8 -0
  307. package/dist/targets/svelte/radix/dialog.js +20 -0
  308. package/dist/targets/svelte/radix/dropdown-menu.d.ts +9 -0
  309. package/dist/targets/svelte/radix/dropdown-menu.js +38 -0
  310. package/dist/targets/svelte/radix/emit.d.ts +12 -0
  311. package/dist/targets/svelte/radix/emit.js +1339 -0
  312. package/dist/targets/svelte/radix/hover-card.d.ts +7 -0
  313. package/dist/targets/svelte/radix/hover-card.js +22 -0
  314. package/dist/targets/svelte/radix/index.d.ts +12 -0
  315. package/dist/targets/svelte/radix/index.js +28 -0
  316. package/dist/targets/svelte/radix/label.d.ts +3 -0
  317. package/dist/targets/svelte/radix/label.js +5 -0
  318. package/dist/targets/svelte/radix/menubar.d.ts +7 -0
  319. package/dist/targets/svelte/radix/menubar.js +34 -0
  320. package/dist/targets/svelte/radix/navigation-menu.d.ts +8 -0
  321. package/dist/targets/svelte/radix/navigation-menu.js +25 -0
  322. package/dist/targets/svelte/radix/packages.d.ts +34 -0
  323. package/dist/targets/svelte/radix/packages.js +100 -0
  324. package/dist/targets/svelte/radix/part.d.ts +161 -0
  325. package/dist/targets/svelte/radix/part.js +85 -0
  326. package/dist/targets/svelte/radix/popover.d.ts +7 -0
  327. package/dist/targets/svelte/radix/popover.js +15 -0
  328. package/dist/targets/svelte/radix/progress.d.ts +11 -0
  329. package/dist/targets/svelte/radix/progress.js +27 -0
  330. package/dist/targets/svelte/radix/radio-group.d.ts +9 -0
  331. package/dist/targets/svelte/radix/radio-group.js +26 -0
  332. package/dist/targets/svelte/radix/scroll-area.d.ts +7 -0
  333. package/dist/targets/svelte/radix/scroll-area.js +19 -0
  334. package/dist/targets/svelte/radix/select.d.ts +13 -0
  335. package/dist/targets/svelte/radix/select.js +81 -0
  336. package/dist/targets/svelte/radix/separator.d.ts +3 -0
  337. package/dist/targets/svelte/radix/separator.js +5 -0
  338. package/dist/targets/svelte/radix/slider.d.ts +6 -0
  339. package/dist/targets/svelte/radix/slider.js +8 -0
  340. package/dist/targets/svelte/radix/switch.d.ts +6 -0
  341. package/dist/targets/svelte/radix/switch.js +10 -0
  342. package/dist/targets/svelte/radix/tabs.d.ts +8 -0
  343. package/dist/targets/svelte/radix/tabs.js +15 -0
  344. package/dist/targets/svelte/radix/toggle-group.d.ts +9 -0
  345. package/dist/targets/svelte/radix/toggle-group.js +17 -0
  346. package/dist/targets/svelte/radix/toggle.d.ts +6 -0
  347. package/dist/targets/svelte/radix/toggle.js +9 -0
  348. package/dist/targets/svelte/radix/tooltip.d.ts +6 -0
  349. package/dist/targets/svelte/radix/tooltip.js +24 -0
  350. package/dist/targets/svelte/strip.d.ts +2 -0
  351. package/dist/targets/svelte/strip.js +5 -0
  352. package/dist/targets/vue/emit.d.ts +15 -0
  353. package/dist/targets/vue/emit.js +4092 -0
  354. package/dist/targets/vue/events.d.ts +11 -0
  355. package/dist/targets/vue/events.js +13 -0
  356. package/dist/targets/vue/module-builders.d.ts +28 -0
  357. package/dist/targets/vue/module-builders.js +258 -0
  358. package/dist/targets/vue/motion-layout.d.ts +19 -0
  359. package/dist/targets/vue/motion-layout.js +79 -0
  360. package/dist/targets/vue/motion.d.ts +12 -0
  361. package/dist/targets/vue/motion.js +46 -0
  362. package/dist/targets/vue/radix/accordion.d.ts +3 -0
  363. package/dist/targets/vue/radix/accordion.js +12 -0
  364. package/dist/targets/vue/radix/alert-dialog.d.ts +6 -0
  365. package/dist/targets/vue/radix/alert-dialog.js +18 -0
  366. package/dist/targets/vue/radix/aspect-ratio.d.ts +6 -0
  367. package/dist/targets/vue/radix/aspect-ratio.js +8 -0
  368. package/dist/targets/vue/radix/avatar.d.ts +3 -0
  369. package/dist/targets/vue/radix/avatar.js +7 -0
  370. package/dist/targets/vue/radix/checkbox.d.ts +3 -0
  371. package/dist/targets/vue/radix/checkbox.js +9 -0
  372. package/dist/targets/vue/radix/collapsible.d.ts +7 -0
  373. package/dist/targets/vue/radix/collapsible.js +11 -0
  374. package/dist/targets/vue/radix/context-menu.d.ts +3 -0
  375. package/dist/targets/vue/radix/context-menu.js +30 -0
  376. package/dist/targets/vue/radix/dialog.d.ts +3 -0
  377. package/dist/targets/vue/radix/dialog.js +12 -0
  378. package/dist/targets/vue/radix/direction.d.ts +7 -0
  379. package/dist/targets/vue/radix/direction.js +9 -0
  380. package/dist/targets/vue/radix/dropdown-menu.d.ts +3 -0
  381. package/dist/targets/vue/radix/dropdown-menu.js +29 -0
  382. package/dist/targets/vue/radix/hover-card.d.ts +3 -0
  383. package/dist/targets/vue/radix/hover-card.js +11 -0
  384. package/dist/targets/vue/radix/index.d.ts +65 -0
  385. package/dist/targets/vue/radix/index.js +225 -0
  386. package/dist/targets/vue/radix/label.d.ts +3 -0
  387. package/dist/targets/vue/radix/label.js +5 -0
  388. package/dist/targets/vue/radix/menubar.d.ts +6 -0
  389. package/dist/targets/vue/radix/menubar.js +29 -0
  390. package/dist/targets/vue/radix/navigation-menu.d.ts +6 -0
  391. package/dist/targets/vue/radix/navigation-menu.js +21 -0
  392. package/dist/targets/vue/radix/part.d.ts +41 -0
  393. package/dist/targets/vue/radix/part.js +46 -0
  394. package/dist/targets/vue/radix/popover.d.ts +3 -0
  395. package/dist/targets/vue/radix/popover.js +11 -0
  396. package/dist/targets/vue/radix/progress.d.ts +3 -0
  397. package/dist/targets/vue/radix/progress.js +6 -0
  398. package/dist/targets/vue/radix/radio-group.d.ts +3 -0
  399. package/dist/targets/vue/radix/radio-group.js +10 -0
  400. package/dist/targets/vue/radix/scroll-area.d.ts +3 -0
  401. package/dist/targets/vue/radix/scroll-area.js +11 -0
  402. package/dist/targets/vue/radix/select.d.ts +3 -0
  403. package/dist/targets/vue/radix/select.js +29 -0
  404. package/dist/targets/vue/radix/separator.d.ts +3 -0
  405. package/dist/targets/vue/radix/separator.js +5 -0
  406. package/dist/targets/vue/radix/slider.d.ts +3 -0
  407. package/dist/targets/vue/radix/slider.js +13 -0
  408. package/dist/targets/vue/radix/switch.d.ts +3 -0
  409. package/dist/targets/vue/radix/switch.js +9 -0
  410. package/dist/targets/vue/radix/tabs.d.ts +3 -0
  411. package/dist/targets/vue/radix/tabs.js +12 -0
  412. package/dist/targets/vue/radix/toggle-group.d.ts +3 -0
  413. package/dist/targets/vue/radix/toggle-group.js +10 -0
  414. package/dist/targets/vue/radix/toggle.d.ts +3 -0
  415. package/dist/targets/vue/radix/toggle.js +8 -0
  416. package/dist/targets/vue/radix/tooltip.d.ts +3 -0
  417. package/dist/targets/vue/radix/tooltip.js +14 -0
  418. package/dist/targets/vue/render-fn/h.d.ts +52 -0
  419. package/dist/targets/vue/render-fn/h.js +442 -0
  420. package/dist/targets/vue/render-fn.d.ts +21 -0
  421. package/dist/targets/vue/render-fn.js +357 -0
  422. package/dist/targets/vue/slot.d.ts +9 -0
  423. package/dist/targets/vue/slot.js +57 -0
  424. package/dist/typecheck/host.d.ts +45 -0
  425. package/dist/typecheck/host.js +309 -0
  426. package/dist/typecheck/index.d.ts +16 -0
  427. package/dist/typecheck/index.js +17 -0
  428. package/dist/typecheck/lucide.d.ts +8 -0
  429. package/dist/typecheck/lucide.js +45 -0
  430. package/dist/typecheck/sourcemap.d.ts +9 -0
  431. package/dist/typecheck/sourcemap.js +54 -0
  432. package/dist/typecheck/svelte.d.ts +9 -0
  433. package/dist/typecheck/svelte.js +116 -0
  434. package/dist/typecheck/vue.d.ts +8 -0
  435. package/dist/typecheck/vue.js +78 -0
  436. package/dist/types.d.ts +446 -0
  437. package/dist/types.js +11 -0
  438. package/dist/utils/cleanup.d.ts +32 -0
  439. package/dist/utils/cleanup.js +119 -0
  440. package/dist/utils/errors.d.ts +7 -0
  441. package/dist/utils/errors.js +15 -0
  442. package/dist/utils/fs-safe.d.ts +14 -0
  443. package/dist/utils/fs-safe.js +64 -0
  444. package/dist/validate.d.ts +16 -0
  445. package/dist/validate.js +204 -0
  446. package/dist/verify/auto-steps.d.ts +107 -0
  447. package/dist/verify/auto-steps.js +471 -0
  448. package/dist/verify/bundle.d.ts +68 -0
  449. package/dist/verify/bundle.js +548 -0
  450. package/dist/verify/diff.d.ts +31 -0
  451. package/dist/verify/diff.js +133 -0
  452. package/dist/verify/leaks.d.ts +25 -0
  453. package/dist/verify/leaks.js +261 -0
  454. package/dist/verify/link-worker.d.ts +1 -0
  455. package/dist/verify/link-worker.js +27 -0
  456. package/dist/verify/runner.d.ts +57 -0
  457. package/dist/verify/runner.js +867 -0
  458. package/dist/verify/sandbox.d.ts +40 -0
  459. package/dist/verify/sandbox.js +496 -0
  460. package/dist/verify/steps.d.ts +42 -0
  461. package/dist/verify/steps.js +475 -0
  462. package/dist/verify/verdict.d.ts +15 -0
  463. package/dist/verify/verdict.js +19 -0
  464. package/package.json +118 -4
@@ -0,0 +1,250 @@
1
+ import { spawn, spawnSync } from 'node:child_process';
2
+ import { existsSync, readFileSync, statSync } from 'node:fs';
3
+ import { delimiter, dirname, join, win32 } from 'node:path';
4
+ import { MorphError } from '../utils/errors.js';
5
+ import { cleanup, makeTempDir } from '../utils/cleanup.js';
6
+ /**
7
+ * Local official CLI providers (v0.3 Milestone A): assisted mode asks the user's own installed, unmodified vendor CLI
8
+ * (Claude Code, Codex, Gemini CLI) for one text answer, as a separate program, for personal local use. morph never
9
+ * reads, locates, copies or logs any login, token or credential file of these CLIs and passes no flag that changes how
10
+ * they sign in (no `--bare` on claude: the docs say bare mode does not use the subscription login). The child inherits
11
+ * the environment like every child process; nothing is added to it.
12
+ *
13
+ * Facts used (notes v03/web-facts.md, read 4 Dec 2026), and what was NOT CONFIRMED there:
14
+ * - claude: `-p` prints one answer and exits; piped stdin is read in -p mode (capped at 10 MB by Claude Code); with
15
+ * both stdin and a prompt argument, the argument is the instruction. Whether `-p` with no argument takes the whole
16
+ * prompt from stdin is NOT CONFIRMED, so a fixed instruction (never file content) is passed as the -p argument.
17
+ * `--tools ""` disables built-in tools, `--disallowedTools "mcp__*"` MCP tools; failures inside the run (no login)
18
+ * are printed on stdout with a non-zero exit.
19
+ * - codex: `codex exec -` reads the whole prompt from stdin and prints only the final message on stdout; `--sandbox
20
+ * read-only`; exec needs a Git repo unless `--skip-git-repo-check`; `--ephemeral` writes no session files. Its exit
21
+ * codes are NOT CONFIRMED (any non-zero is reported as a failure with its number).
22
+ * - gemini: `-p` text "Appended to stdin input if provided. Forces non-interactive mode"; exit codes 0, 1, 42 (input
23
+ * error), 53 (turn limit exceeded). Unpaid and Google One users were moved to Antigravity CLI (`agy`) on 18 June 2026.
24
+ * A flag that a future CLI version drops makes the CLI exit non-zero: reported as an error naming the CLI and its exit
25
+ * code, never as an empty or partial answer.
26
+ */
27
+ export const CLI_PROVIDERS = ['claude-cli', 'codex-cli', 'gemini-cli'];
28
+ /** The fixed instruction given as an argument where the CLI needs one; the prompt itself only ever goes on stdin. */
29
+ const STDIN_INSTRUCTION = 'Follow the instructions given on standard input. Reply with text only.';
30
+ const SPECS = {
31
+ 'claude-cli': {
32
+ bin: 'claude',
33
+ label: 'Claude Code',
34
+ install: 'https://code.claude.com/docs/en/setup (Windows PowerShell: irm https://claude.ai/install.ps1 | iex; macOS, Linux, WSL: curl -fsSL https://claude.ai/install.sh | bash; or npm install -g @anthropic-ai/claude-code@latest)',
35
+ args: (model) => ['-p', STDIN_INSTRUCTION, '--output-format', 'text', '--tools', '', '--disallowedTools', 'mcp__*', '--no-session-persistence', ...(model ? ['--model', model] : [])],
36
+ exitMeaning: {},
37
+ },
38
+ 'codex-cli': {
39
+ bin: 'codex',
40
+ label: 'Codex CLI',
41
+ install: 'npm install -g @openai/codex (or see https://github.com/openai/codex)',
42
+ args: (model) => ['exec', '--sandbox', 'read-only', '--skip-git-repo-check', '--ephemeral', '--color', 'never', ...(model ? ['--model', model] : []), '-'],
43
+ exitMeaning: {},
44
+ },
45
+ 'gemini-cli': {
46
+ bin: 'gemini',
47
+ label: 'Gemini CLI',
48
+ install: 'npm install -g @google/gemini-cli (note: unpaid and Google One accounts were moved to Antigravity CLI on 18 June 2026; Gemini CLI now targets Gemini Code Assist Standard and Enterprise)',
49
+ args: (model) => ['-p', STDIN_INSTRUCTION, '--output-format', 'text', ...(model ? ['--model', model] : [])],
50
+ exitMeaning: { 42: ' (input error)', 53: ' (turn limit exceeded)' },
51
+ },
52
+ };
53
+ export function isCliProvider(name) {
54
+ return CLI_PROVIDERS.includes(name);
55
+ }
56
+ /** A model id passed as an argument: never one that could read as a flag. */
57
+ const MODEL_ID = /^[A-Za-z0-9][A-Za-z0-9._:/@~-]{0,127}$/;
58
+ /** The largest prompt sent on stdin (Claude Code itself refuses piped stdin over 10 MB). */
59
+ export const MAX_CLI_PROMPT_BYTES = 4 * 1024 * 1024;
60
+ /** The most stdout kept: more than that stops the run. */
61
+ export const MAX_CLI_STDOUT_BYTES = 4 * 1024 * 1024;
62
+ const MAX_STDERR_BYTES = 64 * 1024;
63
+ const DEFAULT_CLI_TIMEOUT_MS = 600_000;
64
+ const isFile = (p) => existsSync(p) && statSync(p).isFile();
65
+ /**
66
+ * Finds `bin` on PATH without a shell. On Windows each folder is tried with each PATHEXT extension in order, as cmd
67
+ * does. An .exe or .com is started directly. A .cmd or .bat cannot be started without a shell, which morph never uses:
68
+ * an npm shim (`"%dp0%\node_modules\...\cli.js" %*`) is run as Node with its script; any other script shim is an error
69
+ * that says so. Returns null when nothing is found.
70
+ */
71
+ export function resolveExecutable(bin, env) {
72
+ const windows = env.platform === 'win32';
73
+ const folders = env.path.split(windows ? ';' : delimiter).map((d) => d.trim().replace(/^"(.*)"$/, '$1')).filter(Boolean);
74
+ const exts = windows ? env.pathExt.split(';').map((e) => e.trim().toLowerCase()).filter((e) => e.startsWith('.')) : [''];
75
+ for (const folder of folders) {
76
+ for (const ext of exts) {
77
+ const candidate = join(folder, `${bin}${ext}`);
78
+ if (!isFile(candidate))
79
+ continue;
80
+ if (!windows || ext === '.exe' || ext === '.com')
81
+ return { file: candidate, args: [], found: candidate };
82
+ if (ext === '.cmd' || ext === '.bat')
83
+ return fromShim(candidate, env);
84
+ // another PATHEXT kind (.js, .vbs, .ps1 ...) needs its own host program: not started
85
+ throw shimError(candidate);
86
+ }
87
+ }
88
+ return null;
89
+ }
90
+ function shimError(found) {
91
+ return new MorphError('ai-cli-shim', `${found} is a script that Windows can only start through a shell, and morph never starts programs through a shell. Install the CLI's native executable (an .exe on PATH), or install it with npm so that its .cmd shim points at a JavaScript file morph can run with Node.`);
92
+ }
93
+ /** An npm cmd-shim: run its JavaScript target with Node (the shim's own node.exe when it has one), never cmd.exe. */
94
+ function fromShim(found, env) {
95
+ let text;
96
+ try {
97
+ text = readFileSync(found, 'utf8');
98
+ }
99
+ catch (error) {
100
+ throw new MorphError('ai-cli-shim', `${found} could not be read to find the program it starts: ${error instanceof Error ? error.message : String(error)}`);
101
+ }
102
+ const m = /"%~?dp0%?\\([^"%\r\n]+\.(?:c|m)?js)"/i.exec(text);
103
+ const parts = (m?.[1] ?? '').split(/[\\/]/).filter(Boolean);
104
+ if (!parts.length || parts.includes('..'))
105
+ throw shimError(found);
106
+ const folder = dirname(found);
107
+ const script = join(folder, ...parts);
108
+ if (!isFile(script))
109
+ throw shimError(found);
110
+ const localNode = join(folder, 'node.exe');
111
+ return { file: isFile(localNode) ? localNode : env.nodePath, args: [script], found };
112
+ }
113
+ /** Ends the child and every process it started (Windows: taskkill /T; elsewhere: its process group). */
114
+ function killTree(child) {
115
+ if (child.pid === undefined || child.exitCode !== null || child.signalCode !== null)
116
+ return;
117
+ if (process.platform === 'win32') {
118
+ const taskkill = win32.join(process.env['SystemRoot'] ?? 'C:\\Windows', 'System32', 'taskkill.exe');
119
+ const r = spawnSync(taskkill, ['/pid', String(child.pid), '/T', '/F'], { shell: false, windowsHide: true, stdio: 'ignore', timeout: 10_000 });
120
+ if (r.status !== 0)
121
+ child.kill('SIGKILL');
122
+ return;
123
+ }
124
+ try {
125
+ process.kill(-child.pid, 'SIGKILL');
126
+ }
127
+ catch {
128
+ // no such group (ESRCH): kill the child itself in case it was not a group leader
129
+ child.kill('SIGKILL');
130
+ }
131
+ }
132
+ /** Keeps the last `max` bytes of a growing text. */
133
+ function tail(text, max) {
134
+ return text.length > max ? text.slice(text.length - max) : text;
135
+ }
136
+ /**
137
+ * One answer from a local official CLI: the prompt on stdin only, an argument array, `shell: false`, a fresh empty
138
+ * working folder (so no project's hooks or MCP config there run), a bounded run that ends the whole process tree, a
139
+ * cap on what is kept. Errors name the CLI; what it printed is redacted and cut short before it is shown.
140
+ */
141
+ export async function completeCli(opts, system, user) {
142
+ const spec = SPECS[opts.provider];
143
+ if (opts.model !== undefined && !MODEL_ID.test(opts.model))
144
+ throw new MorphError('ai-no-model', `"${opts.model}" is not a model id ${spec.label} can be given (letters, digits and . _ : / @ ~ -, not starting with -).`);
145
+ const prompt = `${system}\n\n${user}\n`;
146
+ if (Buffer.byteLength(prompt, 'utf8') > MAX_CLI_PROMPT_BYTES)
147
+ throw new MorphError('input-too-large', `The prompt is over ${MAX_CLI_PROMPT_BYTES / 1024 / 1024} MB; ${spec.label} is not asked.`);
148
+ let file;
149
+ let args;
150
+ if (opts.executable) {
151
+ file = opts.executable.file;
152
+ args = [...(opts.executable.args ?? []), ...spec.args(opts.model)];
153
+ }
154
+ else {
155
+ const found = resolveExecutable(spec.bin, { platform: process.platform, path: process.env['PATH'] ?? process.env['Path'] ?? '', pathExt: process.env['PATHEXT'] ?? '.COM;.EXE;.BAT;.CMD', nodePath: process.execPath });
156
+ if (!found)
157
+ throw new MorphError('ai-cli-missing', `${spec.label} ("${spec.bin}") was not found on PATH. Install it: ${spec.install}. Then sign in by running "${spec.bin}" once yourself; morph never reads or handles its login.`);
158
+ file = found.file;
159
+ args = [...found.args, ...spec.args(opts.model)];
160
+ }
161
+ const work = makeTempDir();
162
+ try {
163
+ return await runChild(spec, file, args, work.dir, prompt, opts);
164
+ }
165
+ finally {
166
+ await work.dispose();
167
+ }
168
+ }
169
+ function runChild(spec, file, args, cwd, prompt, opts) {
170
+ return new Promise((resolvePromise, reject) => {
171
+ let child;
172
+ try {
173
+ child = spawn(file, args, { shell: false, cwd, stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true, detached: process.platform !== 'win32' });
174
+ }
175
+ catch (error) {
176
+ reject(new MorphError('ai-cli-missing', `${spec.label} could not be started (${opts.redact(error instanceof Error ? error.message : String(error))}). Install it: ${spec.install}.`));
177
+ return;
178
+ }
179
+ const release = cleanup.add(`${spec.bin} child`, () => killTree(child), () => killTree(child));
180
+ let stdout = '';
181
+ let stdoutBytes = 0;
182
+ let stderr = '';
183
+ let settled = false;
184
+ let stop = null;
185
+ const finish = (error, value) => {
186
+ if (settled)
187
+ return;
188
+ settled = true;
189
+ clearTimeout(timer);
190
+ void release().catch(() => undefined);
191
+ if (error)
192
+ reject(error);
193
+ else
194
+ resolvePromise(value);
195
+ };
196
+ const timeoutMs = opts.timeoutMs ?? DEFAULT_CLI_TIMEOUT_MS;
197
+ const timer = setTimeout(() => {
198
+ stop = new MorphError('ai-cli-timeout', `${spec.label} did not answer within ${Math.round(timeoutMs / 1000)} s; it was stopped.`);
199
+ killTree(child);
200
+ }, timeoutMs);
201
+ child.stdout?.setEncoding('utf8');
202
+ child.stderr?.setEncoding('utf8');
203
+ child.stdout?.on('data', (chunk) => {
204
+ stdoutBytes += Buffer.byteLength(chunk, 'utf8');
205
+ if (stdoutBytes > MAX_CLI_STDOUT_BYTES) {
206
+ if (!stop)
207
+ stop = new MorphError('ai-cli-output', `${spec.label} printed more than ${MAX_CLI_STDOUT_BYTES / 1024 / 1024} MB; it was stopped.`);
208
+ killTree(child);
209
+ return;
210
+ }
211
+ stdout += chunk;
212
+ });
213
+ child.stderr?.on('data', (chunk) => {
214
+ stderr = tail(stderr + chunk, MAX_STDERR_BYTES);
215
+ });
216
+ // a child that exits before reading all of stdin closes the pipe: its exit code says what happened
217
+ child.stdin?.on('error', (error) => {
218
+ if (!stop && !/EPIPE|EOF/.test(error.message))
219
+ stop = new MorphError('ai-cli-exit', `${spec.label}: the prompt could not be written to its input: ${opts.redact(error.message)}`);
220
+ });
221
+ child.on('error', (error) => {
222
+ if (error.code === 'ENOENT')
223
+ finish(new MorphError('ai-cli-missing', `${spec.label} ("${spec.bin}") could not be started: the program was not found. Install it: ${spec.install}.`), '');
224
+ else
225
+ finish(new MorphError('ai-cli-exit', `${spec.label} could not be started: ${opts.redact(error.message)}`), '');
226
+ });
227
+ child.on('close', (code, signal) => {
228
+ if (stop)
229
+ return finish(stop, '');
230
+ if (code !== 0) {
231
+ const said = (stderr.trim() || stdout.trim()).split(/\r?\n/).slice(-4).join(' ');
232
+ const meaning = code === null ? ` (stopped by ${signal ?? 'a signal'})` : (spec.exitMeaning[code] ?? '');
233
+ return finish(new MorphError('ai-cli-exit', `${spec.label} exited with code ${code ?? 'none'}${meaning}${said ? `: ${opts.redact(said).slice(0, 400)}` : ''}. If it is not signed in, run "${spec.bin}" once yourself to sign in.`), '');
234
+ }
235
+ if (!stdout.trim())
236
+ return finish(new MorphError('ai-response', `${spec.label} printed no answer.`), '');
237
+ finish(null, stdout);
238
+ });
239
+ child.stdin?.end(prompt, 'utf8');
240
+ });
241
+ }
242
+ /** The executable name and install hint of a CLI provider (for docs and messages). */
243
+ export function cliInfo(name) {
244
+ const { bin, label, install } = SPECS[name];
245
+ return { bin, label, install };
246
+ }
247
+ /** The arguments morph passes to a CLI provider (tests check that no prompt text is ever among them). */
248
+ export function cliArgs(name, model) {
249
+ return SPECS[name].args(model);
250
+ }
@@ -0,0 +1,39 @@
1
+ import type { Diagnostic, EmittedFile, InteractionState, Target, VerifyResult, VerifyStep, WebTarget } from '../types.js';
2
+ /** The match every state and every step must reach against the React original. */
3
+ export declare const ASSIST_MATCH = 0.99;
4
+ /**
5
+ * The gates a model-written result must pass, in the order they run: the target's real compiler, the strict type check
6
+ * (vue-tsc / svelte-check's; Angular's compiler is already strict, so for Angular both are one run of ngtsc with
7
+ * strictTemplates), the browser harness against the React original (every state and every step at 99% or more, no
8
+ * page error, no DOM fact that differs after a step) and the unmount check (it leaves nothing running that React
9
+ * does not).
10
+ */
11
+ export type AssistGate = 'compiler' | 'typecheck' | 'browser' | 'unmount';
12
+ export declare const ASSIST_GATES: readonly AssistGate[];
13
+ /** What stopped an attempt: a gate, or the step before them (`reply`: no code in the reply; `provider`: the call failed). */
14
+ export type AssistStop = AssistGate | 'reply' | 'provider';
15
+ export interface GateFailure {
16
+ gate: AssistStop;
17
+ reason: string;
18
+ /** every problem the gate found, located (`path:line: message`), at most 20; `reason` names the first */
19
+ details?: string[];
20
+ }
21
+ /** The compiler marks code it could not convert; a result that still holds such a mark is not a conversion. */
22
+ export declare const NOT_CONVERTED: RegExp;
23
+ /** The code in a reply: the longest fenced block, or null when there is none. */
24
+ export declare function extractCode(reply: string): string | null;
25
+ /**
26
+ * The gates that run without a browser: the compiler marks, the target's real compiler, the strict type check.
27
+ * Returns the first failure, or null when all of them pass.
28
+ */
29
+ export declare function staticGates(files: EmittedFile[], target: WebTarget, projectRoot: string): Promise<GateFailure | null>;
30
+ /**
31
+ * Judges one verify run (made with `unmount: true` and the candidate's files for `target`) against the bar: every state
32
+ * asked for and every step compared and at 99% or more, no DOM fact different after a step, no error on the target's
33
+ * page, no error of the run itself, and the unmount check clean against React's. `compilerDiagnostics` are the
34
+ * compile's own, which verify repeats about the compiler's output (the candidate replaced it): they are not the run's.
35
+ * Returns the first failure, or null when the candidate passes.
36
+ */
37
+ export declare function browserVerdict(result: VerifyResult, target: WebTarget, states: readonly InteractionState[], steps: readonly VerifyStep[], compilerDiagnostics: readonly Diagnostic[]): GateFailure | null;
38
+ /** The web targets the browser gate can run for; React Native has no browser harness, so it can never pass every gate. */
39
+ export declare function gateable(target: Target): target is WebTarget;
@@ -0,0 +1,124 @@
1
+ import { validateAngular, validateFiles } from '../validate.js';
2
+ import { typecheckWeb } from '../typecheck/index.js';
3
+ import { useProjectLib } from '../typecheck/host.js';
4
+ /** The match every state and every step must reach against the React original. */
5
+ export const ASSIST_MATCH = 0.99;
6
+ export const ASSIST_GATES = ['compiler', 'typecheck', 'browser', 'unmount'];
7
+ /** At most this many located problems are kept in `GateFailure.details`. */
8
+ const MAX_DETAILS = 20;
9
+ function located(p) {
10
+ return `${p.path ?? p.file ?? ''}${p.line ? `:${p.line}` : ''}: ${firstLine(p.message)}`;
11
+ }
12
+ /** The compiler marks code it could not convert; a result that still holds such a mark is not a conversion. */
13
+ export const NOT_CONVERTED = /antheo-morph: (not converted|elements in script code are not converted)/;
14
+ /** The code in a reply: the longest fenced block, or null when there is none. */
15
+ export function extractCode(reply) {
16
+ const fenced = [...reply.matchAll(/```[a-zA-Z]*\r?\n([\s\S]*?)```/g)].map((m) => m[1] ?? '');
17
+ if (!fenced.length)
18
+ return null;
19
+ return fenced.sort((a, b) => b.length - a.length)[0] ?? null;
20
+ }
21
+ const firstLine = (text) => text.split('\n')[0] ?? text;
22
+ /**
23
+ * The gates that run without a browser: the compiler marks, the target's real compiler, the strict type check.
24
+ * Returns the first failure, or null when all of them pass.
25
+ */
26
+ export async function staticGates(files, target, projectRoot) {
27
+ const marked = files.find((f) => NOT_CONVERTED.test(f.contents));
28
+ if (marked)
29
+ return { gate: 'compiler', reason: `${marked.path} still holds code the compiler marked as not converted.` };
30
+ if (target === 'angular') {
31
+ const problems = await validateAngular(files, projectRoot);
32
+ if (problems.length)
33
+ return { gate: 'compiler', reason: `the Angular compiler in strict mode rejected it: ${firstLine(problems[0]?.message ?? '')}`, details: problems.slice(0, MAX_DETAILS).map(located) };
34
+ return null;
35
+ }
36
+ const isData = (f) => f.path.endsWith('.json');
37
+ const problems = validateFiles(files.filter((f) => !isData(f)), target);
38
+ if (problems.length)
39
+ return { gate: 'compiler', reason: `the ${target} compiler rejected it: ${firstLine(problems[0]?.message ?? '')}`, details: problems.slice(0, MAX_DETAILS).map(located) };
40
+ for (const f of files.filter(isData)) {
41
+ try {
42
+ JSON.parse(f.contents);
43
+ }
44
+ catch {
45
+ return { gate: 'compiler', reason: `${f.path} is not valid JSON.` };
46
+ }
47
+ }
48
+ useProjectLib(projectRoot);
49
+ const typed = await typecheckWeb(files, target, projectRoot);
50
+ if (typed.length) {
51
+ const p = typed[0];
52
+ return { gate: 'typecheck', reason: `the strict type check found ${typed.length} error${typed.length === 1 ? '' : 's'}, first: ${p?.path}${p?.line ? `:${p.line}` : ''}: ${firstLine(p?.message ?? '')}`, details: typed.slice(0, MAX_DETAILS).map(located) };
53
+ }
54
+ return null;
55
+ }
56
+ const diagnosticKey = (d) => `${d.code}\u0000${d.target ?? ''}\u0000${d.message}`;
57
+ /**
58
+ * Judges one verify run (made with `unmount: true` and the candidate's files for `target`) against the bar: every state
59
+ * asked for and every step compared and at 99% or more, no DOM fact different after a step, no error on the target's
60
+ * page, no error of the run itself, and the unmount check clean against React's. `compilerDiagnostics` are the
61
+ * compile's own, which verify repeats about the compiler's output (the candidate replaced it): they are not the run's.
62
+ * Returns the first failure, or null when the candidate passes.
63
+ */
64
+ export function browserVerdict(result, target, states, steps, compilerDiagnostics) {
65
+ const own = new Set(compilerDiagnostics.map(diagnosticKey));
66
+ const errors = result.diagnostics.filter((d) => d.severity === 'error' && !own.has(diagnosticKey(d)) && (d.target === undefined || d.target === target));
67
+ // what the unmount check says is the unmount gate's, judged after the renders
68
+ const UNMOUNT = new Set(['unmount-failed', 'unmount-leak']);
69
+ const runErrors = errors.filter((d) => !UNMOUNT.has(d.code));
70
+ if (runErrors.length)
71
+ return { gate: 'browser', reason: `${runErrors[0]?.code}: ${firstLine(runErrors[0]?.message ?? '')}` };
72
+ const pageErrors = result.pageErrors.filter((e) => e.startsWith(`${target}:`));
73
+ if (pageErrors.length)
74
+ return { gate: 'browser', reason: `the ${target} page threw: ${firstLine(pageErrors[0] ?? '')}` };
75
+ for (const state of states) {
76
+ const c = result.comparisons.find((x) => x.target === target && x.state === state);
77
+ if (!c)
78
+ return { gate: 'browser', reason: `the ${state} state was not compared.` };
79
+ if (c.match < ASSIST_MATCH)
80
+ return { gate: 'browser', reason: `${state}: ${(c.match * 100).toFixed(2)}% of pixels match React's (needs 99%).` };
81
+ }
82
+ for (const [index, step] of steps.entries()) {
83
+ const c = result.steps?.find((x) => x.target === target && x.index === index);
84
+ if (!c)
85
+ return { gate: 'browser', reason: `step "${step.name}" was not compared.` };
86
+ if (c.failure)
87
+ return { gate: 'browser', reason: `step "${step.name}": ${c.failure}` };
88
+ if (c.match < ASSIST_MATCH)
89
+ return { gate: 'browser', reason: `step "${step.name}": ${(c.match * 100).toFixed(2)}% match React's (needs 99%).` };
90
+ if (c.state.length) {
91
+ const s = c.state[0];
92
+ return { gate: 'browser', reason: `step "${step.name}": ${s?.fact} is ${s?.actual ?? 'missing'}, React's is ${s?.react ?? 'missing'}.` };
93
+ }
94
+ }
95
+ if (result.minMatch < ASSIST_MATCH)
96
+ return { gate: 'browser', reason: `the lowest match is ${(result.minMatch * 100).toFixed(2)}% (needs 99%).` };
97
+ const unmountFailed = errors.find((d) => d.code === 'unmount-failed');
98
+ if (unmountFailed)
99
+ return { gate: 'unmount', reason: firstLine(unmountFailed.message) };
100
+ const unmountLeak = errors.find((d) => d.code === 'unmount-leak');
101
+ const leaks = result.leaks?.find((l) => l.framework === target);
102
+ if (!leaks)
103
+ return { gate: 'unmount', reason: `${target} was not measured after unmount.` };
104
+ if (!leaks.beyondReact)
105
+ return { gate: 'unmount', reason: 'React could not be measured after unmount, so there is nothing to compare with.' };
106
+ if (!leaks.clean) {
107
+ const b = leaks.beyondReact;
108
+ const left = [
109
+ b.raf ? `${b.raf} animation frame loop${b.raf === 1 ? '' : 's'}` : '',
110
+ b.intervals ? `${b.intervals} interval${b.intervals === 1 ? '' : 's'}` : '',
111
+ b.timeouts ? `${b.timeouts} timeout${b.timeouts === 1 ? '' : 's'}` : '',
112
+ ...b.listeners.map((l) => `${l.count} ${l.target} ${l.type} listener${l.count === 1 ? '' : 's'}`),
113
+ ...b.observers.map((o) => `${o.count} ${o.kind}${o.count === 1 ? '' : 's'}`),
114
+ ].filter(Boolean);
115
+ return { gate: 'unmount', reason: `after unmount it leaves running what React does not: ${left.join(', ') || 'something'}.` };
116
+ }
117
+ if (unmountLeak)
118
+ return { gate: 'unmount', reason: firstLine(unmountLeak.message) };
119
+ return null;
120
+ }
121
+ /** The web targets the browser gate can run for; React Native has no browser harness, so it can never pass every gate. */
122
+ export function gateable(target) {
123
+ return target === 'vue' || target === 'svelte' || target === 'angular';
124
+ }
@@ -0,0 +1,36 @@
1
+ import { type CliExecutable, type CliProviderName } from './cli-provider.js';
2
+ export type { CliExecutable, CliProviderName } from './cli-provider.js';
3
+ /** Providers reached over HTTPS with an API key (ollama: a local server, no key). */
4
+ export declare const HTTP_PROVIDERS: readonly ["anthropic", "openai", "ollama", "gemini", "openrouter"];
5
+ export type HttpProviderName = (typeof HTTP_PROVIDERS)[number];
6
+ /** every provider: the HTTPS ones, then the user's own installed official CLIs (personal local use) */
7
+ export declare const PROVIDERS: readonly ["anthropic", "openai", "ollama", "gemini", "openrouter", "claude-cli", "codex-cli", "gemini-cli"];
8
+ export type ProviderName = HttpProviderName | CliProviderName;
9
+ /** A provider name from user input, or a MorphError naming the ones that exist (a typo never falls through to another). */
10
+ export declare function providerName(value: string): ProviderName;
11
+ export interface ProviderOptions {
12
+ provider: ProviderName;
13
+ /**
14
+ * default: claude-opus-5-5 for anthropic, gemini-4-hydrogen for gemini, the CLI's own default for a CLI provider;
15
+ * required for openai, ollama and openrouter
16
+ */
17
+ model?: string;
18
+ /**
19
+ * default: ANTHROPIC_API_KEY / OPENAI_API_KEY / GEMINI_API_KEY / OPENROUTER_API_KEY from the environment; ollama and
20
+ * the CLI providers need none (a CLI uses its own sign-in, which morph never reads)
21
+ */
22
+ apiKey?: string;
23
+ /** default: the provider's public endpoint (ollama: http://127.0.0.1:11434) */
24
+ baseUrl?: string;
25
+ /** for tests: a stand-in for fetch */
26
+ fetchImpl?: typeof fetch;
27
+ /** for tests only (programmatic, never a flag): the program run in place of a CLI provider's vendor CLI */
28
+ executable?: CliExecutable;
29
+ timeoutMs?: number;
30
+ }
31
+ /** every API key in the environment that a provider reads, redacted from anything morph prints. */
32
+ export declare function envSecrets(): (string | undefined)[];
33
+ /** Replaces every secret (and anything shaped like an API key or bearer token) in a message. */
34
+ export declare function redact(text: string, secrets?: (string | undefined)[]): string;
35
+ /** One completion over raw fetch (no LLM SDK); errors never carry the key. */
36
+ export declare function complete(opts: ProviderOptions, system: string, user: string): Promise<string>;
@@ -0,0 +1,168 @@
1
+ import { MorphError } from '../utils/errors.js';
2
+ // the CLI providers (v0.3 Milestone A)
3
+ import { CLI_PROVIDERS, completeCli, isCliProvider } from './cli-provider.js';
4
+ /** Providers reached over HTTPS with an API key (ollama: a local server, no key). */
5
+ export const HTTP_PROVIDERS = ['anthropic', 'openai', 'ollama', 'gemini', 'openrouter'];
6
+ /** every provider: the HTTPS ones, then the user's own installed official CLIs (personal local use) */
7
+ export const PROVIDERS = [...HTTP_PROVIDERS, ...CLI_PROVIDERS];
8
+ /** A provider name from user input, or a MorphError naming the ones that exist (a typo never falls through to another). */
9
+ export function providerName(value) {
10
+ const found = PROVIDERS.find((p) => p === value);
11
+ if (!found)
12
+ throw new MorphError('ai-provider', `Unknown provider "${value}" (expected ${PROVIDERS.join(', ')}).`);
13
+ return found;
14
+ }
15
+ const ENV_KEYS = { anthropic: 'ANTHROPIC_API_KEY', openai: 'OPENAI_API_KEY', ollama: null, gemini: 'GEMINI_API_KEY', openrouter: 'OPENROUTER_API_KEY' };
16
+ /** every API key in the environment that a provider reads, redacted from anything morph prints. */
17
+ export function envSecrets() {
18
+ return Object.values(ENV_KEYS).map((name) => (name ? process.env[name] : undefined));
19
+ }
20
+ /** Replaces every secret (and anything shaped like an API key or bearer token) in a message. */
21
+ export function redact(text, secrets = []) {
22
+ let out = text;
23
+ for (const s of secrets)
24
+ if (s && s.length >= 6)
25
+ out = out.split(s).join('[redacted]');
26
+ return out
27
+ .replace(/sk-ant-[A-Za-z0-9_-]{8,}/g, '[redacted]')
28
+ .replace(/sk-[A-Za-z0-9_-]{16,}/g, '[redacted]')
29
+ // Google API keys (Gemini) and their header
30
+ .replace(/AIza[A-Za-z0-9_-]{20,}/g, '[redacted]')
31
+ .replace(/(Bearer|x-api-key[":\s]+|x-goog-api-key[":\s]+)\s*[A-Za-z0-9._-]{12,}/gi, '$1 [redacted]');
32
+ }
33
+ // keyed by the HTTPS provider (the CLI providers have no key)
34
+ function keyFor(provider, opts) {
35
+ const env = ENV_KEYS[provider];
36
+ return opts.apiKey ?? (env ? process.env[env] : undefined);
37
+ }
38
+ /** a model id that goes into a URL path (gemini): letters, digits and . _ - only. */
39
+ const URL_MODEL = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
40
+ /** One completion over raw fetch (no LLM SDK); errors never carry the key. */
41
+ export async function complete(opts, system, user) {
42
+ // API callers can pass any string at runtime: check before choosing an endpoint
43
+ const provider = providerName(opts.provider);
44
+ // the user's own installed official CLI, run as a separate program (src/ai/cli-provider.ts)
45
+ if (isCliProvider(provider)) {
46
+ const secrets = [opts.apiKey, ...envSecrets()];
47
+ return completeCli({ provider, ...(opts.model ? { model: opts.model } : {}), ...(opts.timeoutMs ? { timeoutMs: opts.timeoutMs } : {}), ...(opts.executable ? { executable: opts.executable } : {}), redact: (t) => redact(t, secrets) }, system, user);
48
+ }
49
+ const doFetch = opts.fetchImpl ?? fetch;
50
+ const key = keyFor(provider, opts);
51
+ if (provider !== 'ollama' && !key)
52
+ throw new MorphError('ai-no-key', `No API key for ${provider}: set ${ENV_KEYS[provider] ?? 'apiKey'}.`);
53
+ if (provider !== 'anthropic' && provider !== 'gemini' && !opts.model)
54
+ throw new MorphError('ai-no-model', `--model is required for ${provider}.`);
55
+ const signal = AbortSignal.timeout(opts.timeoutMs ?? 120_000);
56
+ let url;
57
+ let init;
58
+ if (opts.provider === 'anthropic') {
59
+ url = `${opts.baseUrl ?? 'https://api.anthropic.com'}/v1/messages`;
60
+ init = {
61
+ method: 'POST',
62
+ signal,
63
+ headers: { 'content-type': 'application/json', 'x-api-key': key ?? '', 'anthropic-version': '2023-06-01', 'anthropic-beta': 'server-side-fallback-2026-07-01' },
64
+ // a policy decline is re-run on a fallback model inside the same call
65
+ body: JSON.stringify({ model: opts.model ?? 'claude-opus-5-5', max_tokens: 16000, system, messages: [{ role: 'user', content: user }], fallbacks: 'default' }),
66
+ };
67
+ }
68
+ else if (provider === 'gemini') {
69
+ // Gemini API generateContent; the key goes in the x-goog-api-key header, never in the URL
70
+ const model = opts.model ?? 'gemini-4-hydrogen';
71
+ if (!URL_MODEL.test(model))
72
+ throw new MorphError('ai-no-model', `"${model}" is not a Gemini model id (letters, digits, . _ -).`);
73
+ url = `${opts.baseUrl ?? 'https://generativelanguage.googleapis.com'}/v1beta/models/${encodeURIComponent(model)}:generateContent`;
74
+ init = {
75
+ method: 'POST',
76
+ signal,
77
+ headers: { 'content-type': 'application/json', 'x-goog-api-key': key ?? '' },
78
+ body: JSON.stringify({ system_instruction: { parts: [{ text: system }] }, contents: [{ role: 'user', parts: [{ text: user }] }], generationConfig: { maxOutputTokens: 16000 } }),
79
+ };
80
+ }
81
+ else if (provider === 'openrouter') {
82
+ // OpenRouter chat completions; Bearer key in the header
83
+ url = `${opts.baseUrl ?? 'https://openrouter.ai'}/api/v1/chat/completions`;
84
+ init = {
85
+ method: 'POST',
86
+ signal,
87
+ headers: { 'content-type': 'application/json', authorization: `Bearer ${key ?? ''}`, 'X-OpenRouter-Title': 'antheo-morph' },
88
+ body: JSON.stringify({ model: opts.model, max_tokens: 16000, messages: [{ role: 'system', content: system }, { role: 'user', content: user }] }),
89
+ };
90
+ }
91
+ else if (opts.provider === 'openai') {
92
+ url = `${opts.baseUrl ?? 'https://api.openai.com'}/v1/chat/completions`;
93
+ init = { method: 'POST', signal, headers: { 'content-type': 'application/json', authorization: `Bearer ${key ?? ''}` }, body: JSON.stringify({ model: opts.model, messages: [{ role: 'system', content: system }, { role: 'user', content: user }] }) };
94
+ }
95
+ else {
96
+ url = `${opts.baseUrl ?? 'http://127.0.0.1:11434'}/api/chat`;
97
+ init = { method: 'POST', signal, headers: { 'content-type': 'application/json' }, body: JSON.stringify({ model: opts.model, stream: false, messages: [{ role: 'system', content: system }, { role: 'user', content: user }] }) };
98
+ }
99
+ let res;
100
+ try {
101
+ res = await doFetch(url, init);
102
+ }
103
+ catch (error) {
104
+ throw new MorphError('ai-network', redact(`${opts.provider} request failed: ${error instanceof Error ? error.message : String(error)}`, [key, ...envSecrets()]));
105
+ }
106
+ const text = await res.text();
107
+ if (!res.ok)
108
+ throw new MorphError('ai-http', redact(`${opts.provider} returned ${res.status}: ${text.slice(0, 300)}`, [key, ...envSecrets()]));
109
+ let body;
110
+ try {
111
+ body = JSON.parse(text);
112
+ }
113
+ catch {
114
+ throw new MorphError('ai-response', `${opts.provider} returned a response that is not JSON.`);
115
+ }
116
+ if (opts.provider === 'anthropic') {
117
+ const msg = body;
118
+ if (msg.stop_reason === 'refusal')
119
+ throw new MorphError('ai-refusal', 'The model declined the request.');
120
+ return (msg.content ?? []).filter((b) => b.type === 'text').map((b) => b.text ?? '').join('');
121
+ }
122
+ if (provider === 'gemini')
123
+ return geminiText(body);
124
+ if (provider === 'openrouter')
125
+ return openRouterText(body, key);
126
+ if (opts.provider === 'openai')
127
+ return body.choices?.[0]?.message?.content ?? '';
128
+ return body.message?.content ?? '';
129
+ }
130
+ /**
131
+ * the text of a Gemini generateContent reply. A blocked prompt (`promptFeedback.blockReason`) or a candidate that
132
+ * stopped without text (`finishReason` SAFETY, RECITATION ...) is a MorphError naming the reason, never an empty answer.
133
+ * Parts marked `thought: true` are left out (NOT CONFIRMED as the exact rule in the docs read: a reply holding only
134
+ * such parts fails clearly instead of being used).
135
+ */
136
+ function geminiText(body) {
137
+ const b = body;
138
+ if (b.promptFeedback?.blockReason)
139
+ throw new MorphError('ai-refusal', `gemini blocked the prompt (${b.promptFeedback.blockReason}).`);
140
+ const candidate = b.candidates?.[0];
141
+ if (!candidate)
142
+ throw new MorphError('ai-response', 'gemini returned no candidate.');
143
+ const parts = candidate.content?.parts ?? [];
144
+ const text = parts.filter((p) => p.thought !== true && typeof p.text === 'string').map((p) => p.text ?? '').join('');
145
+ if (!text) {
146
+ const why = candidate.finishReason && candidate.finishReason !== 'STOP' ? ` (finishReason ${candidate.finishReason})` : parts.length ? ' (only thought parts)' : '';
147
+ const refused = candidate.finishReason === 'SAFETY' || candidate.finishReason === 'PROHIBITED_CONTENT' || candidate.finishReason === 'BLOCKLIST';
148
+ throw new MorphError(refused ? 'ai-refusal' : 'ai-response', `gemini returned no text${why}.`);
149
+ }
150
+ return text;
151
+ }
152
+ /**
153
+ * the text of an OpenRouter chat completion. A 200 can still carry an `error` object, and a choice can end with
154
+ * `finish_reason: "error"`: both are MorphErrors (redacted), never an empty answer.
155
+ */
156
+ function openRouterText(body, key) {
157
+ const b = body;
158
+ if (b.error)
159
+ throw new MorphError('ai-http', redact(`openrouter returned an error${b.error.code ? ` ${b.error.code}` : ''}: ${String(b.error.message ?? '').slice(0, 300)}`, [key, ...envSecrets()]));
160
+ const choice = b.choices?.[0];
161
+ if (!choice)
162
+ throw new MorphError('ai-response', 'openrouter returned no choice.');
163
+ if (choice.finish_reason === 'error')
164
+ throw new MorphError('ai-response', 'openrouter: the model stopped with an error.');
165
+ if (choice.finish_reason === 'content_filter' && !choice.message?.content)
166
+ throw new MorphError('ai-refusal', 'openrouter: the reply was filtered.');
167
+ return choice.message?.content ?? '';
168
+ }