@hattoriai/poney 0.0.0-stage → 0.1.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 (359) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +23 -2
  3. package/bin/poney-mcp.mjs +3 -0
  4. package/bin/poney.mjs +3 -0
  5. package/brief-change.md +23 -0
  6. package/brief-tour.md +43 -0
  7. package/brief.md +133 -0
  8. package/dist/chunk-BCOS4LFB.js +1184 -0
  9. package/dist/chunk-BCOS4LFB.js.map +1 -0
  10. package/dist/chunk-TPJZDQG6.js +290 -0
  11. package/dist/chunk-TPJZDQG6.js.map +1 -0
  12. package/dist/chunk-YLKV6LIU.js +621 -0
  13. package/dist/chunk-YLKV6LIU.js.map +1 -0
  14. package/dist/cli.d.ts +2 -0
  15. package/dist/cli.js +181 -0
  16. package/dist/cli.js.map +1 -0
  17. package/dist/hub-FERXNPJS.js +4 -0
  18. package/dist/hub-FERXNPJS.js.map +1 -0
  19. package/dist/live/types.d.ts +165 -0
  20. package/dist/live/types.js +3 -0
  21. package/dist/live/types.js.map +1 -0
  22. package/dist/mcp.d.ts +2 -0
  23. package/dist/mcp.js +288 -0
  24. package/dist/mcp.js.map +1 -0
  25. package/dist/ops.d.ts +1575 -0
  26. package/dist/ops.js +3 -0
  27. package/dist/ops.js.map +1 -0
  28. package/dist/plugins/index.d.ts +94 -0
  29. package/dist/plugins/index.js +3 -0
  30. package/dist/plugins/index.js.map +1 -0
  31. package/dist/run-25PP2HWH.js +3 -0
  32. package/dist/run-25PP2HWH.js.map +1 -0
  33. package/dist/types-N-oiuMYy.d.ts +77 -0
  34. package/examples/tour.poney +195 -0
  35. package/examples/walkthrough.poney +644 -0
  36. package/package.json +76 -4
  37. package/studio/assets/abap-BdImnpbu.js +1 -0
  38. package/studio/assets/actionscript-3-B3316cI-.js +1 -0
  39. package/studio/assets/ada-BIOnG6TC.js +1 -0
  40. package/studio/assets/ahk-BrbAagtO.js +1 -0
  41. package/studio/assets/ahk2-8Zs4aa1G.js +1 -0
  42. package/studio/assets/andromeeda-C4gqWexZ.js +1 -0
  43. package/studio/assets/angular-html-D_SYSyRt.js +1 -0
  44. package/studio/assets/angular-ts-DGq0tZX5.js +1 -0
  45. package/studio/assets/apache-Pmp26Uib.js +1 -0
  46. package/studio/assets/apex-DhZFqWV2.js +1 -0
  47. package/studio/assets/apl-ChzvTHjC.js +1 -0
  48. package/studio/assets/applescript-Co6uUVPk.js +1 -0
  49. package/studio/assets/ara-BRHolxvo.js +1 -0
  50. package/studio/assets/asciidoc-CSVQ5wI8.js +1 -0
  51. package/studio/assets/asm-D_Q5rh1f.js +1 -0
  52. package/studio/assets/astro-DTjqU0_L.js +1 -0
  53. package/studio/assets/aurora-x-D-2ljcwZ.js +1 -0
  54. package/studio/assets/awk-DMzUqQB5.js +1 -0
  55. package/studio/assets/ayu-dark-DYE7WIF3.js +1 -0
  56. package/studio/assets/ayu-light-BA47KaF1.js +1 -0
  57. package/studio/assets/ayu-mirage-32ctXXKs.js +1 -0
  58. package/studio/assets/ballerina-BFfxhgS-.js +1 -0
  59. package/studio/assets/bat-CickPsom.js +1 -0
  60. package/studio/assets/beancount-BgSHGh8x.js +1 -0
  61. package/studio/assets/berry-uYugtg8r.js +1 -0
  62. package/studio/assets/bibtex-CHM0blh-.js +1 -0
  63. package/studio/assets/bicep-Bmn6On1c.js +1 -0
  64. package/studio/assets/bird2-Bx8U0n9b.js +1 -0
  65. package/studio/assets/blade-k33SngOZ.js +1 -0
  66. package/studio/assets/bsl-DlhNcFeZ.js +1 -0
  67. package/studio/assets/c-BIGW1oBm.js +1 -0
  68. package/studio/assets/c3-Dp5svz6Z.js +1 -0
  69. package/studio/assets/cadence-Bv_4Rxtq.js +1 -0
  70. package/studio/assets/cairo-KRGpt6FW.js +1 -0
  71. package/studio/assets/catppuccin-frappe-CZL1YF0i.js +1 -0
  72. package/studio/assets/catppuccin-latte-DH-8KZSZ.js +1 -0
  73. package/studio/assets/catppuccin-macchiato-B7yYVSCf.js +1 -0
  74. package/studio/assets/catppuccin-mocha-Ct7hS0mc.js +1 -0
  75. package/studio/assets/chapel-DTp_pixX.js +1 -0
  76. package/studio/assets/clarity-Dn5IMItf.js +1 -0
  77. package/studio/assets/clojure-P80f7IUj.js +1 -0
  78. package/studio/assets/cmake-D1j8_8rp.js +1 -0
  79. package/studio/assets/cobol-BBKr1ja6.js +1 -0
  80. package/studio/assets/codeowners-Bp6g37R7.js +1 -0
  81. package/studio/assets/codeql-DsOJ9woJ.js +1 -0
  82. package/studio/assets/coffee-Ch7k5sss.js +1 -0
  83. package/studio/assets/common-lisp-Cg-RD9OK.js +1 -0
  84. package/studio/assets/coq-BqXF5kFF.js +1 -0
  85. package/studio/assets/cpp-BMRokrvK.js +1 -0
  86. package/studio/assets/crystal-LUwhHfY5.js +1 -0
  87. package/studio/assets/csharp-B_TYUkTI.js +1 -0
  88. package/studio/assets/css-Z72CF80r.js +1 -0
  89. package/studio/assets/csv-fuZLfV_i.js +1 -0
  90. package/studio/assets/cue-D82EKSYY.js +1 -0
  91. package/studio/assets/cypher-COkxafJQ.js +1 -0
  92. package/studio/assets/d-85-TOEBH.js +1 -0
  93. package/studio/assets/dark-plus-C3mMm8J8.js +1 -0
  94. package/studio/assets/dart-CtKP3W-j.js +1 -0
  95. package/studio/assets/dax-CEL-wOlO.js +1 -0
  96. package/studio/assets/desktop-BmXAJ9_W.js +1 -0
  97. package/studio/assets/diff-D97Zzqfu.js +1 -0
  98. package/studio/assets/dist-_ey1iXf6.js +153 -0
  99. package/studio/assets/docker-BcOcwvcX.js +1 -0
  100. package/studio/assets/dotenv-De0Btta0.js +1 -0
  101. package/studio/assets/dracula-BzJJZx-M.js +1 -0
  102. package/studio/assets/dracula-soft-BXkSAIEj.js +1 -0
  103. package/studio/assets/dream-maker-BtqSS_iP.js +1 -0
  104. package/studio/assets/edge-CJaD-t2L.js +1 -0
  105. package/studio/assets/elixir-DkJLSxtU.js +1 -0
  106. package/studio/assets/elk.bundled-Bw5WzyyE.js +26 -0
  107. package/studio/assets/elm-DbKCFpqz.js +1 -0
  108. package/studio/assets/emacs-lisp-DaIrSCgJ.js +1 -0
  109. package/studio/assets/erb-CSMaCouu.js +1 -0
  110. package/studio/assets/erlang-DsQrWhSR.js +1 -0
  111. package/studio/assets/everforest-dark-BgDCqdQA.js +1 -0
  112. package/studio/assets/everforest-light-C8M2exoo.js +1 -0
  113. package/studio/assets/fennel-BYunw83y.js +1 -0
  114. package/studio/assets/fish-BvzEVeQv.js +1 -0
  115. package/studio/assets/fluent-C4IJs8-o.js +1 -0
  116. package/studio/assets/fortran-fixed-form-CkoXwp7k.js +1 -0
  117. package/studio/assets/fortran-free-form-BxgE0vQu.js +1 -0
  118. package/studio/assets/fsharp-CXgrBDvD.js +1 -0
  119. package/studio/assets/gdresource-TyuKm33G.js +1 -0
  120. package/studio/assets/gdscript-DqcFQ5yU.js +1 -0
  121. package/studio/assets/gdshader-DkwncUOv.js +1 -0
  122. package/studio/assets/genie-D0YGMca9.js +1 -0
  123. package/studio/assets/gherkin-DyxjwDmM.js +1 -0
  124. package/studio/assets/git-commit-F4YmCXRG.js +1 -0
  125. package/studio/assets/git-rebase-r7XF79zn.js +1 -0
  126. package/studio/assets/github-dark-DHJKELXO.js +1 -0
  127. package/studio/assets/github-dark-default-Cuk6v7N8.js +1 -0
  128. package/studio/assets/github-dark-dimmed-DH5Ifo-i.js +1 -0
  129. package/studio/assets/github-dark-high-contrast-E3gJ1_iC.js +1 -0
  130. package/studio/assets/github-light-DAi9KRSo.js +1 -0
  131. package/studio/assets/github-light-default-D7oLnXFd.js +1 -0
  132. package/studio/assets/github-light-high-contrast-BfjtVDDH.js +1 -0
  133. package/studio/assets/gleam-BspZqrRM.js +1 -0
  134. package/studio/assets/glimmer-js-Drrc9bTt.js +1 -0
  135. package/studio/assets/glimmer-ts-zeybXsvi.js +1 -0
  136. package/studio/assets/glsl-DplSGwfg.js +1 -0
  137. package/studio/assets/gn-8iBmfbXw.js +1 -0
  138. package/studio/assets/gnuplot-DdkO51Og.js +1 -0
  139. package/studio/assets/go-C27-OAKa.js +1 -0
  140. package/studio/assets/graphql-ChdNCCLP.js +1 -0
  141. package/studio/assets/groovy-gcz8RCvz.js +1 -0
  142. package/studio/assets/gruvbox-dark-hard-CFHQjOhq.js +1 -0
  143. package/studio/assets/gruvbox-dark-medium-GsRaNv29.js +1 -0
  144. package/studio/assets/gruvbox-dark-soft-CVdnzihN.js +1 -0
  145. package/studio/assets/gruvbox-light-hard-CH1njM8p.js +1 -0
  146. package/studio/assets/gruvbox-light-medium-DRw_LuNl.js +1 -0
  147. package/studio/assets/gruvbox-light-soft-hJgmCMqR.js +1 -0
  148. package/studio/assets/hack-Ck6-gGSS.js +1 -0
  149. package/studio/assets/haml-GN_XdMnF.js +1 -0
  150. package/studio/assets/handlebars-DPT5vKgj.js +1 -0
  151. package/studio/assets/hanken-grotesk-latin-ext-wght-normal-Dg-wlmqe.woff2 +0 -0
  152. package/studio/assets/hanken-grotesk-latin-wght-normal-CaVRRdDk.woff2 +0 -0
  153. package/studio/assets/hanken-grotesk-vietnamese-wght-normal-CHiFlh_0.woff2 +0 -0
  154. package/studio/assets/haskell-Df6bDoY_.js +1 -0
  155. package/studio/assets/haxe-CfZj7gIn.js +1 -0
  156. package/studio/assets/hcl-BWvSN4gD.js +1 -0
  157. package/studio/assets/hjson-D5-asLiD.js +1 -0
  158. package/studio/assets/hlsl-D3lLCCz7.js +1 -0
  159. package/studio/assets/horizon-BUw7H-hv.js +1 -0
  160. package/studio/assets/horizon-bright-CUuTKBJd.js +1 -0
  161. package/studio/assets/houston-DnULxvSX.js +1 -0
  162. package/studio/assets/html-BlS82ilI.js +1 -0
  163. package/studio/assets/html-derivative-DZhk3IEZ.js +1 -0
  164. package/studio/assets/http-jrhK8wxY.js +1 -0
  165. package/studio/assets/hurl-irOxFIW8.js +1 -0
  166. package/studio/assets/hxml-2-FPmUDs.js +1 -0
  167. package/studio/assets/hy-DFXneXwc.js +1 -0
  168. package/studio/assets/imba-DGztddWO.js +1 -0
  169. package/studio/assets/index-B-C2JUUu.css +1 -0
  170. package/studio/assets/index-DOjop_HJ.js +889 -0
  171. package/studio/assets/ini-BEwlwnbL.js +1 -0
  172. package/studio/assets/java-CylS5w8V.js +1 -0
  173. package/studio/assets/javascript-wDzz0qaB.js +1 -0
  174. package/studio/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
  175. package/studio/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
  176. package/studio/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
  177. package/studio/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
  178. package/studio/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
  179. package/studio/assets/jinja-DFQZVq3b.js +1 -0
  180. package/studio/assets/jison-wvAkD_A8.js +1 -0
  181. package/studio/assets/json-Cp-IABpG.js +1 -0
  182. package/studio/assets/json5-C9tS-k6U.js +1 -0
  183. package/studio/assets/jsonc-Des-eS-w.js +1 -0
  184. package/studio/assets/jsonl-DcaNXYhu.js +1 -0
  185. package/studio/assets/jsonnet-DFQXde-d.js +1 -0
  186. package/studio/assets/jssm-C2t-YnRu.js +1 -0
  187. package/studio/assets/jsx-g9-lgVsj.js +1 -0
  188. package/studio/assets/julia-Cu79e8SL.js +1 -0
  189. package/studio/assets/just-CMxyWJJc.js +1 -0
  190. package/studio/assets/kanagawa-dragon-BuwD2xS4.js +1 -0
  191. package/studio/assets/kanagawa-lotus-C3DzagqV.js +1 -0
  192. package/studio/assets/kanagawa-wave-DFGoQZhC.js +1 -0
  193. package/studio/assets/kdl-DV7GczEv.js +1 -0
  194. package/studio/assets/kotlin-BdnUsdx6.js +1 -0
  195. package/studio/assets/kusto-wEQ09or8.js +1 -0
  196. package/studio/assets/laserwave-DUszq2jm.js +1 -0
  197. package/studio/assets/latex-DJVikpzR.js +1 -0
  198. package/studio/assets/lean-BZvkOJ9d.js +1 -0
  199. package/studio/assets/less-B1dDrJ26.js +1 -0
  200. package/studio/assets/light-plus-B7mTdjB0.js +1 -0
  201. package/studio/assets/liquid-B-duXHXw.js +1 -0
  202. package/studio/assets/llvm-BZoOZj88.js +1 -0
  203. package/studio/assets/log-2UxHyX5q.js +1 -0
  204. package/studio/assets/logo-BtOb2qkB.js +1 -0
  205. package/studio/assets/lua-BaeVxFsk.js +1 -0
  206. package/studio/assets/luau-nOZpfvQi.js +1 -0
  207. package/studio/assets/make-CHLpvVh8.js +1 -0
  208. package/studio/assets/markdown-Cvjx9yec.js +1 -0
  209. package/studio/assets/marko-BYgDmDgU.js +1 -0
  210. package/studio/assets/material-theme-D5KoaKCx.js +1 -0
  211. package/studio/assets/material-theme-darker-BfHTSMKl.js +1 -0
  212. package/studio/assets/material-theme-lighter-B0m2ddpp.js +1 -0
  213. package/studio/assets/material-theme-ocean-CyktbL80.js +1 -0
  214. package/studio/assets/material-theme-palenight-Csfq5Kiy.js +1 -0
  215. package/studio/assets/matlab-D7o27uSR.js +1 -0
  216. package/studio/assets/mdc-DF4WjDMn.js +1 -0
  217. package/studio/assets/mdx-Cmh6b_Ma.js +1 -0
  218. package/studio/assets/mermaid-CQcHuHx7.js +1 -0
  219. package/studio/assets/min-dark-CafNBF8u.js +1 -0
  220. package/studio/assets/min-light-CTRr51gU.js +1 -0
  221. package/studio/assets/mipsasm-CKIfxQSi.js +1 -0
  222. package/studio/assets/mojo-DJz3ZmWd.js +1 -0
  223. package/studio/assets/monokai-CR4piiQ-.js +1 -0
  224. package/studio/assets/moonbit-Bag4Rp_g.js +1 -0
  225. package/studio/assets/move-el3G9tDJ.js +1 -0
  226. package/studio/assets/narrat-DRg8JJMk.js +1 -0
  227. package/studio/assets/nextflow-BCxp2Aob.js +1 -0
  228. package/studio/assets/nextflow-groovy-CedDknKX.js +1 -0
  229. package/studio/assets/nginx-BpAMiNFr.js +1 -0
  230. package/studio/assets/night-owl-C39BiMTA.js +1 -0
  231. package/studio/assets/night-owl-light-CMTm3GFP.js +1 -0
  232. package/studio/assets/nim-nV83PyhX.js +1 -0
  233. package/studio/assets/nix-CwoSXNpI.js +1 -0
  234. package/studio/assets/nord-Ddv68eIx.js +1 -0
  235. package/studio/assets/nsis-BlV79W_Q.js +1 -0
  236. package/studio/assets/nushell-BXD5iret.js +1 -0
  237. package/studio/assets/objective-c-DXmwc3jG.js +1 -0
  238. package/studio/assets/objective-cpp-CLxacb5B.js +1 -0
  239. package/studio/assets/ocaml-C0hk2d4L.js +1 -0
  240. package/studio/assets/odin-BBf5iR-q.js +1 -0
  241. package/studio/assets/one-dark-pro-CxGP3dtY.js +1 -0
  242. package/studio/assets/one-light-C3Wv6jpd.js +1 -0
  243. package/studio/assets/openscad-C4EeE6gA.js +1 -0
  244. package/studio/assets/org-6a7ccXN_.js +1 -0
  245. package/studio/assets/pascal-D93ZcfNL.js +1 -0
  246. package/studio/assets/perl-5klg-GXX.js +1 -0
  247. package/studio/assets/php-DoruYMF0.js +1 -0
  248. package/studio/assets/pkl-u5AG7uiY.js +1 -0
  249. package/studio/assets/plastic-3e1v2bzS.js +1 -0
  250. package/studio/assets/plsql-ChMvpjG-.js +1 -0
  251. package/studio/assets/po-BTJTHyun.js +1 -0
  252. package/studio/assets/poimandres-CS3Unz2-.js +1 -0
  253. package/studio/assets/polar-C0HS_06l.js +1 -0
  254. package/studio/assets/postcss-CXtECtnM.js +1 -0
  255. package/studio/assets/powerquery-CEu0bR-o.js +1 -0
  256. package/studio/assets/powershell-Dd0kTxKP.js +1 -0
  257. package/studio/assets/prisma-Vru482bI.js +1 -0
  258. package/studio/assets/prolog-CbFg5uaA.js +1 -0
  259. package/studio/assets/proto-C7zT0LnQ.js +1 -0
  260. package/studio/assets/pug-BtYPkAgq.js +1 -0
  261. package/studio/assets/puppet-BMWR74SV.js +1 -0
  262. package/studio/assets/purescript-CklMAg4u.js +1 -0
  263. package/studio/assets/python-B6aJPvgy.js +1 -0
  264. package/studio/assets/qml-3beO22l8.js +1 -0
  265. package/studio/assets/qmldir-C8lEn-DE.js +1 -0
  266. package/studio/assets/qss-IeuSbFQv.js +1 -0
  267. package/studio/assets/r-Cf5RLm7j.js +1 -0
  268. package/studio/assets/racket-BqYA7rlc.js +1 -0
  269. package/studio/assets/raku-DXvB9xmW.js +1 -0
  270. package/studio/assets/razor-CyjPwjZj.js +1 -0
  271. package/studio/assets/rbs-CpoqiR4B.js +1 -0
  272. package/studio/assets/red-DMbB5_pp.js +1 -0
  273. package/studio/assets/reg-C-SQnVFl.js +1 -0
  274. package/studio/assets/regexp-CDVJQ6XC.js +1 -0
  275. package/studio/assets/rel-C3B-1QV4.js +1 -0
  276. package/studio/assets/riscv-BM1_JUlF.js +1 -0
  277. package/studio/assets/ron-D8l8udqQ.js +1 -0
  278. package/studio/assets/rose-pine-5qJOZa0Y.js +1 -0
  279. package/studio/assets/rose-pine-dawn-zx0QlTCp.js +1 -0
  280. package/studio/assets/rose-pine-moon-C9pEdX9L.js +1 -0
  281. package/studio/assets/rosmsg-BJDFO7_C.js +1 -0
  282. package/studio/assets/rst-CVOjT0e7.js +1 -0
  283. package/studio/assets/ruby-C8rp0wew.js +1 -0
  284. package/studio/assets/rust-DPvrY3IQ.js +1 -0
  285. package/studio/assets/sas-BGn39htG.js +1 -0
  286. package/studio/assets/sass-Cj5Yp3dK.js +1 -0
  287. package/studio/assets/scala-CqE71os6.js +1 -0
  288. package/studio/assets/scheme-C98Dy4si.js +1 -0
  289. package/studio/assets/scss-Cw6XMfVs.js +1 -0
  290. package/studio/assets/sdbl-DVxCFoDh.js +1 -0
  291. package/studio/assets/shaderlab-Dg9Lc6iA.js +1 -0
  292. package/studio/assets/shellscript-Yzrsuije.js +1 -0
  293. package/studio/assets/shellsession-BADoaaVG.js +1 -0
  294. package/studio/assets/slack-dark-BthQWCQV.js +1 -0
  295. package/studio/assets/slack-ochin-DqwNpetd.js +1 -0
  296. package/studio/assets/smalltalk-BOQMe2GC.js +1 -0
  297. package/studio/assets/smithy-cds9vsN8.js +1 -0
  298. package/studio/assets/snazzy-light-Bw305WKR.js +1 -0
  299. package/studio/assets/solarized-dark-UcubFVte.js +1 -0
  300. package/studio/assets/solarized-light-DCG28T6R.js +1 -0
  301. package/studio/assets/solidity-DijEV5ha.js +1 -0
  302. package/studio/assets/soy-zscZBeg6.js +1 -0
  303. package/studio/assets/sparql-rVzFXLq3.js +1 -0
  304. package/studio/assets/splunk-BtCnVYZw.js +1 -0
  305. package/studio/assets/sql-DkvoVjww.js +1 -0
  306. package/studio/assets/src-Br__iChL.js +88 -0
  307. package/studio/assets/ssh-config-_ykCGR6B.js +1 -0
  308. package/studio/assets/stata-DACIj5bg.js +1 -0
  309. package/studio/assets/stylus-BEDo0Tqx.js +1 -0
  310. package/studio/assets/surrealql-Cjom0U5J.js +1 -0
  311. package/studio/assets/svelte-D84K1R2Q.js +1 -0
  312. package/studio/assets/swift-C2oV4EkX.js +1 -0
  313. package/studio/assets/synthwave-84-CbfX1IO0.js +1 -0
  314. package/studio/assets/system-verilog-0hqHdDBg.js +1 -0
  315. package/studio/assets/systemd-4A_iFExJ.js +1 -0
  316. package/studio/assets/talonscript-CkByrt1z.js +1 -0
  317. package/studio/assets/tasl-QIJgUcNo.js +1 -0
  318. package/studio/assets/tcl-dwOrl1Do.js +1 -0
  319. package/studio/assets/templ-Vpw5XpSW.js +1 -0
  320. package/studio/assets/terraform-BETggiCN.js +1 -0
  321. package/studio/assets/tex-D96PA37w.js +1 -0
  322. package/studio/assets/tokyo-night-hegEt444.js +1 -0
  323. package/studio/assets/toml-vGWfd6FD.js +1 -0
  324. package/studio/assets/ts-tags-Ls60c9xG.js +1 -0
  325. package/studio/assets/tsv-B_m7g4N7.js +1 -0
  326. package/studio/assets/tsx-COt5Ahok.js +1 -0
  327. package/studio/assets/turtle-BsS91CYL.js +1 -0
  328. package/studio/assets/twig-D9-LOF2p.js +1 -0
  329. package/studio/assets/typescript-BPQ3VLAy.js +1 -0
  330. package/studio/assets/typespec-ClX509-Q.js +1 -0
  331. package/studio/assets/typst-DamkJZ1Q.js +1 -0
  332. package/studio/assets/v-BGw2Nkan.js +1 -0
  333. package/studio/assets/vala-CsfeWuGM.js +1 -0
  334. package/studio/assets/vb-Cu-pLBUe.js +1 -0
  335. package/studio/assets/verilog-nZwndyjY.js +1 -0
  336. package/studio/assets/vesper-DRje8inN.js +1 -0
  337. package/studio/assets/vhdl-CeAyd5Ju.js +1 -0
  338. package/studio/assets/viml-CJc9bBzg.js +1 -0
  339. package/studio/assets/vitesse-black-Bkuqu6BP.js +1 -0
  340. package/studio/assets/vitesse-dark-D0r3Knsf.js +1 -0
  341. package/studio/assets/vitesse-light-CVO1_9PV.js +1 -0
  342. package/studio/assets/vue-DSqPwMUe.js +1 -0
  343. package/studio/assets/vue-html-AaS7Mt5G.js +1 -0
  344. package/studio/assets/vue-vine-C0RcJ6UU.js +1 -0
  345. package/studio/assets/vyper-CDx5xZoG.js +1 -0
  346. package/studio/assets/wasm-Cey7Y6ql.js +1 -0
  347. package/studio/assets/wasm-MzD3tlZU.js +1 -0
  348. package/studio/assets/wenyan-BV7otONQ.js +1 -0
  349. package/studio/assets/wgsl-Dx-B1_4e.js +1 -0
  350. package/studio/assets/wikitext-BhOHFoWU.js +1 -0
  351. package/studio/assets/wit-5i3qLPDT.js +1 -0
  352. package/studio/assets/wolfram-lXgVvXCa.js +1 -0
  353. package/studio/assets/xml-sdJ4AIDG.js +1 -0
  354. package/studio/assets/xsl-CtQFsRM5.js +1 -0
  355. package/studio/assets/yaml-Buea-lGh.js +1 -0
  356. package/studio/assets/zenscript-DVFEvuxE.js +1 -0
  357. package/studio/assets/zig-VOosw3JB.js +1 -0
  358. package/studio/favicon.svg +7 -0
  359. package/studio/index.html +15 -0
@@ -0,0 +1,621 @@
1
+ import { join, isAbsolute, basename, normalize, dirname, relative } from 'path';
2
+ import { parseDocument } from '@hattoriai/poney-core';
3
+ import { existsSync, readFileSync, readdirSync } from 'fs';
4
+ import { homedir } from 'os';
5
+ import { pathToFileURL } from 'url';
6
+ import { execFileSync } from 'child_process';
7
+
8
+ // src/plugins/run.ts
9
+
10
+ // src/plugins/merge.ts
11
+ function mergeImport(document, result, project) {
12
+ const doc = structuredClone(document ?? { poneyVersion: "0.1.0", project: project ?? { id: "imported", name: "Imported", description: "" }, model: {}, views: [], walkthroughs: [] });
13
+ doc.model ??= {};
14
+ doc.views ??= [];
15
+ const report = { added: { entities: 0, relationships: 0, dataTypes: 0, dataRelations: 0, views: 0 }, kept: 0, skipped: 0 };
16
+ const add = (key, items, ok = () => true) => {
17
+ const list = doc.model[key] ??= [];
18
+ const ids = new Set(list.map((x) => x.id));
19
+ for (const item of items) {
20
+ if (ids.has(item.id)) report.kept++;
21
+ else if (!ok(item, ids)) report.skipped++;
22
+ else {
23
+ list.push(item);
24
+ ids.add(item.id);
25
+ report.added[key]++;
26
+ }
27
+ }
28
+ };
29
+ add("entities", result.entities);
30
+ const entities = new Set(doc.model.entities.map((e) => e.id));
31
+ add("relationships", result.relationships, (r) => entities.has(r.source) && entities.has(r.target));
32
+ add("dataTypes", result.dataTypes.map((d) => d.storedIn && !entities.has(d.storedIn) ? { ...d, storedIn: void 0 } : d));
33
+ const tables = new Set(doc.model.dataTypes.map((d) => d.id));
34
+ add("dataRelations", result.dataRelations, (r) => tables.has(r.from) && tables.has(r.to));
35
+ const views = new Set(doc.views.map((v) => v.id));
36
+ for (const v of result.views) {
37
+ if (views.has(v.id)) report.kept++;
38
+ else {
39
+ doc.views.push(v);
40
+ report.added.views++;
41
+ }
42
+ }
43
+ return { document: doc, report };
44
+ }
45
+ function describeMerge(r) {
46
+ const parts = Object.entries(r.added).filter(([, n]) => n).map(([k, n]) => `${n} ${LABEL[k][n === 1 ? 0 : 1]}`);
47
+ return `Added ${parts.length ? parts.join(", ") : "nothing"}.${r.kept ? ` Kept ${r.kept} the document already had.` : ""}${r.skipped ? ` Left out ${r.skipped} relationships whose ends are not in the document.` : ""}`;
48
+ }
49
+ var LABEL = { entities: ["part", "parts"], relationships: ["relationship", "relationships"], dataTypes: ["table", "tables"], dataRelations: ["table relation", "table relations"], views: ["view", "views"] };
50
+
51
+ // src/plugins/types.ts
52
+ var definePlugin = (plugin) => plugin;
53
+ var slug = (s) => s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "x";
54
+ var SKIP = /* @__PURE__ */ new Set(["node_modules", ".git", "dist", "build", "coverage", "vendor", "tmp", "_build", "deps", ".next"]);
55
+ function listFiles(dir, match) {
56
+ try {
57
+ const out = execFileSync("git", ["-C", dir, "ls-files", "--cached", "--others", "--exclude-standard"], { encoding: "utf8", maxBuffer: 64 * 1024 * 1024, stdio: ["ignore", "pipe", "ignore"] });
58
+ return out.split("\n").filter((p) => p && match(p));
59
+ } catch {
60
+ const out = [];
61
+ const walk = (d) => {
62
+ for (const e of readdirSync(d, { withFileTypes: true })) {
63
+ if (e.name.startsWith(".") && e.name !== ".") continue;
64
+ const path = join(d, e.name);
65
+ if (e.isDirectory()) {
66
+ if (!SKIP.has(e.name)) walk(path);
67
+ } else if (match(relative(dir, path))) out.push(relative(dir, path));
68
+ }
69
+ };
70
+ walk(dir);
71
+ return out;
72
+ }
73
+ }
74
+
75
+ // src/plugins/importers/schema.ts
76
+ var VIEW_LIMIT = 40;
77
+ var CANDIDATES = ["db/schema.rb", "db/structure.sql", "prisma/schema.prisma", "schema.prisma", "db/schema.sql", "schema.sql", "sql/schema.sql"];
78
+ var schemaImporter = {
79
+ id: "schema",
80
+ name: "Database schema",
81
+ description: "Tables, columns and foreign keys from db/schema.rb, a SQL schema or schema.prisma.",
82
+ detect(dir) {
83
+ const found = CANDIDATES.filter((p) => existsSync(join(dir, p)));
84
+ if (found.length) return found;
85
+ return listFiles(dir, (p) => /(^|\/)(schema|structure)\.(sql|rb|prisma)$/.test(p) && !p.includes("node_modules/")).slice(0, 5);
86
+ },
87
+ async run(dir, options = {}) {
88
+ const path = options.path ?? this.detect(dir)[0];
89
+ if (!path) return { entities: [], relationships: [], dataTypes: [], dataRelations: [], views: [], notes: ["No schema file found: db/schema.rb, a .sql schema, or schema.prisma."] };
90
+ const text = readFileSync(join(dir, path), "utf8");
91
+ const tables = path.endsWith(".rb") ? parseRailsSchema(text) : path.endsWith(".prisma") ? parsePrisma(text) : parseSql(text);
92
+ return toImport(tables, path, options.store);
93
+ }
94
+ };
95
+ function toImport(tables, path, store) {
96
+ const id = (table) => slug(table);
97
+ const known = new Set(tables.map((t) => t.name));
98
+ const dataTypes = tables.map((t) => ({
99
+ id: id(t.name),
100
+ kind: "table",
101
+ name: t.name,
102
+ summary: `The ${t.name} table.`,
103
+ fields: t.columns.map((c) => ({
104
+ name: c.name,
105
+ type: c.type,
106
+ primaryKey: !!c.primaryKey,
107
+ nullable: !!c.nullable,
108
+ unique: !!c.unique,
109
+ ...c.references && known.has(c.references.table) ? { references: { dataType: id(c.references.table), field: c.references.column } } : {}
110
+ })),
111
+ ...store ? { storedIn: store } : {},
112
+ sourceRefs: [{ path }],
113
+ ext: {}
114
+ }));
115
+ const dataRelations = tables.flatMap(
116
+ (t) => t.columns.filter((c) => c.references && known.has(c.references.table)).map((c) => ({
117
+ id: `${id(t.name)}-${slug(c.name)}`,
118
+ from: id(t.name),
119
+ to: id(c.references.table),
120
+ fromCardinality: "many",
121
+ toCardinality: c.nullable ? "zero-or-one" : "one",
122
+ label: `${c.name}`,
123
+ via: c.name,
124
+ logical: false
125
+ }))
126
+ );
127
+ const notes = [`Read ${tables.length} tables and ${dataRelations.length} foreign keys from ${path}.`];
128
+ const views = tables.length && tables.length <= VIEW_LIMIT ? [{ id: "database-schema", type: "erd", title: "Database schema", description: `Every table in ${path}, and the foreign keys between them.`, category: "data", dataTypes: dataTypes.map((d) => d.id) }] : [];
129
+ if (tables.length > VIEW_LIMIT) notes.push(`No ERD view: ${tables.length} tables is too many for one picture. Make views of the tables that matter.`);
130
+ return { entities: [], relationships: [], dataTypes, dataRelations, views, notes };
131
+ }
132
+ var RAILS_TYPE = { bigint: "bigint", integer: "integer", string: "string", text: "text", boolean: "boolean", datetime: "datetime", date: "date", decimal: "decimal", float: "float", jsonb: "jsonb", json: "json", uuid: "uuid", binary: "binary", timestamp: "timestamp", time: "time", inet: "inet", citext: "citext", enum: "enum" };
133
+ function parseRailsSchema(text) {
134
+ const tables = [];
135
+ const byName = /* @__PURE__ */ new Map();
136
+ const lines = text.split("\n");
137
+ let current;
138
+ for (const raw of lines) {
139
+ const line = raw.trim();
140
+ const create = /^create_table\s+"([^"]+)"(.*)\bdo\s*\|t\|/.exec(line);
141
+ if (create) {
142
+ const opts = create[2];
143
+ current = { name: create[1], columns: [] };
144
+ if (!/\bid:\s*false\b/.test(opts)) {
145
+ const type = /\bid:\s*:(\w+)/.exec(opts)?.[1] ?? /\bid:\s*"(\w+)"/.exec(opts)?.[1] ?? "bigint";
146
+ current.columns.push({ name: "id", type, primaryKey: true });
147
+ }
148
+ tables.push(current);
149
+ byName.set(current.name, current);
150
+ continue;
151
+ }
152
+ if (!current) {
153
+ const fk = /^add_foreign_key\s+"([^"]+)",\s*"([^"]+)"(.*)$/.exec(line);
154
+ if (fk) {
155
+ const table = byName.get(fk[1]);
156
+ const column = /\bcolumn:\s*"([^"]+)"/.exec(fk[3])?.[1] ?? `${singular(fk[2])}_id`;
157
+ const primary = /\bprimary_key:\s*"([^"]+)"/.exec(fk[3])?.[1] ?? "id";
158
+ const col2 = table?.columns.find((c) => c.name === column);
159
+ if (col2) col2.references = { table: fk[2], column: primary };
160
+ }
161
+ continue;
162
+ }
163
+ if (line === "end") {
164
+ current = void 0;
165
+ continue;
166
+ }
167
+ const col = /^t\.(\w+)\s+"([^"]+)"(.*)$/.exec(line);
168
+ if (col && col[1] !== "index") {
169
+ current.columns.push({ name: col[2], type: RAILS_TYPE[col[1]] ?? col[1], nullable: !/\bnull:\s*false\b/.test(col[3]) });
170
+ continue;
171
+ }
172
+ const index = /^t\.index\s+\["([^"]+)"\](.*)$/.exec(line);
173
+ if (index && /\bunique:\s*true\b/.test(index[2])) {
174
+ const c = current.columns.find((x) => x.name === index[1]);
175
+ if (c) c.unique = true;
176
+ }
177
+ }
178
+ return tables;
179
+ }
180
+ function singular(word) {
181
+ if (/ies$/.test(word)) return word.replace(/ies$/, "y");
182
+ if (/(ss|sh|ch|x|z)es$/.test(word)) return word.replace(/es$/, "");
183
+ if (/s$/.test(word) && !/ss$/.test(word)) return word.replace(/s$/, "");
184
+ return word;
185
+ }
186
+ var bare = (name) => name.trim().split(".").pop().replace(/^["`[]|["`\]]$/g, "");
187
+ function splitTop(s) {
188
+ const out = [];
189
+ let depth = 0;
190
+ let cur = "";
191
+ for (const ch of s) {
192
+ if (ch === "(") depth++;
193
+ if (ch === ")") depth--;
194
+ if (ch === "," && depth === 0) {
195
+ out.push(cur);
196
+ cur = "";
197
+ } else cur += ch;
198
+ }
199
+ if (cur.trim()) out.push(cur);
200
+ return out.map((x) => x.trim()).filter(Boolean);
201
+ }
202
+ function inside(s, start) {
203
+ let depth = 0;
204
+ for (let i = start; i < s.length; i++) {
205
+ if (s[i] === "(") depth++;
206
+ else if (s[i] === ")" && --depth === 0) return { body: s.slice(start + 1, i), end: i };
207
+ }
208
+ return { body: s.slice(start + 1), end: s.length };
209
+ }
210
+ var names = (list) => list.split(",").map(bare);
211
+ function parseSql(text) {
212
+ const sql = text.replace(/--[^\n]*/g, "").replace(/\/\*[\s\S]*?\*\//g, "");
213
+ const tables = /* @__PURE__ */ new Map();
214
+ const create = /create\s+(?:unlogged\s+|temporary\s+|temp\s+)?table\s+(?:if\s+not\s+exists\s+)?([\w."`[\]]+)\s*\(/gi;
215
+ for (let m = create.exec(sql); m; m = create.exec(sql)) {
216
+ const { body, end } = inside(sql, m.index + m[0].length - 1);
217
+ create.lastIndex = end;
218
+ const table = { name: bare(m[1]), columns: [] };
219
+ for (const part of splitTop(body)) {
220
+ const constraint = part.replace(/^constraint\s+[\w"`]+\s+/i, "");
221
+ const pk = /^primary\s+key\s*\(([^)]+)\)/i.exec(constraint);
222
+ const fk = /^foreign\s+key\s*\(([^)]+)\)\s*references\s+([\w."`[\]]+)\s*\(([^)]+)\)/i.exec(constraint);
223
+ const uq = /^unique\s*\(([^)]+)\)/i.exec(constraint);
224
+ if (pk) names(pk[1]).forEach((n) => mark(table, n, { primaryKey: true }));
225
+ else if (fk) names(fk[1]).forEach((n, i) => mark(table, n, { references: { table: bare(fk[2]), column: names(fk[3])[i] ?? "id" } }));
226
+ else if (uq) {
227
+ const cols = names(uq[1]);
228
+ if (cols.length === 1) mark(table, cols[0], { unique: true });
229
+ } else if (!/^(check|exclude|index|key)\b/i.test(constraint)) {
230
+ const col = /^([\w"`[\]]+)\s+([\s\S]*)$/.exec(part);
231
+ if (!col || /^like\b/i.test(part)) continue;
232
+ const at = col[2].search(/\s(not\s+null|null|primary\s+key|references|default|unique|check|constraint|generated|collate)\b/i);
233
+ const type = (at < 0 ? col[2] : col[2].slice(0, at)).trim();
234
+ const rest = at < 0 ? "" : col[2].slice(at);
235
+ const ref = /references\s+([\w."`[\]]+)\s*(?:\(([^)]+)\))?/i.exec(rest);
236
+ table.columns.push({
237
+ name: bare(col[1]),
238
+ type: type.toLowerCase(),
239
+ primaryKey: /primary\s+key/i.test(rest),
240
+ nullable: !/not\s+null|primary\s+key/i.test(rest),
241
+ unique: /\bunique\b/i.test(rest),
242
+ ...ref ? { references: { table: bare(ref[1]), column: ref[2] ? bare(ref[2]) : "id" } } : {}
243
+ });
244
+ }
245
+ }
246
+ tables.set(table.name, table);
247
+ }
248
+ const alter = /alter\s+table\s+(?:only\s+)?([\w."`[\]]+)\s+add\s+constraint\s+[\w"`]+\s+(primary\s+key|unique|foreign\s+key)\s*\(([^)]+)\)(?:\s*references\s+([\w."`[\]]+)\s*\(([^)]+)\))?/gi;
249
+ for (let m = alter.exec(sql); m; m = alter.exec(sql)) {
250
+ const table = tables.get(bare(m[1]));
251
+ if (!table) continue;
252
+ const cols = names(m[3]);
253
+ const kind = m[2].toLowerCase().replace(/\s+/g, " ");
254
+ if (kind === "primary key") cols.forEach((n) => mark(table, n, { primaryKey: true }));
255
+ else if (kind === "unique" && cols.length === 1) mark(table, cols[0], { unique: true });
256
+ else if (kind === "foreign key" && m[4]) cols.forEach((n, i) => mark(table, n, { references: { table: bare(m[4]), column: names(m[5])[i] ?? "id" } }));
257
+ }
258
+ return [...tables.values()];
259
+ }
260
+ function mark(table, column, patch) {
261
+ const c = table.columns.find((x) => x.name === column);
262
+ if (!c) return;
263
+ Object.assign(c, patch);
264
+ if (patch.primaryKey) c.nullable = false;
265
+ }
266
+ function parsePrisma(text) {
267
+ const models = [...text.matchAll(/^model\s+(\w+)\s*\{([\s\S]*?)^\}/gm)];
268
+ const modelNames = new Set(models.map((m) => m[1]));
269
+ const tables = [];
270
+ for (const [, name, body] of models) {
271
+ const table = { name, columns: [] };
272
+ const relations = [];
273
+ for (const raw of body.split("\n")) {
274
+ const line = raw.replace(/\/\/.*$/, "").trim();
275
+ if (!line || line.startsWith("@@")) {
276
+ const id = /^@@id\(\[([^\]]+)\]/.exec(line);
277
+ if (id) id[1].split(",").forEach((n) => mark(table, n.trim(), { primaryKey: true }));
278
+ const uq = /^@@unique\(\[([^\]]+)\]/.exec(line);
279
+ if (uq && !uq[1].includes(",")) mark(table, uq[1].trim(), { unique: true });
280
+ continue;
281
+ }
282
+ const m = /^(\w+)\s+(\w+)(\[\])?(\?)?(.*)$/.exec(line);
283
+ if (!m) continue;
284
+ const [, field, type, list, optional, attrs] = m;
285
+ if (modelNames.has(type)) {
286
+ const rel = /@relation\([^)]*fields:\s*\[([^\]]+)\][^)]*references:\s*\[([^\]]+)\]/.exec(attrs);
287
+ if (rel && !list) relations.push({ fields: rel[1].split(",").map((s) => s.trim()), table: type, references: rel[2].split(",").map((s) => s.trim()) });
288
+ continue;
289
+ }
290
+ table.columns.push({ name: field, type: `${type}${list ? "[]" : ""}`, primaryKey: /@id\b/.test(attrs), nullable: !!optional, unique: /@unique\b/.test(attrs) });
291
+ }
292
+ relations.forEach((r) => r.fields.forEach((f, i) => mark(table, f, { references: { table: r.table, column: r.references[i] ?? "id" } })));
293
+ tables.push(table);
294
+ }
295
+ return tables;
296
+ }
297
+ var SOURCE = /\.(ts|tsx|mts|cts|js|jsx|mjs|cjs)$/;
298
+ var TEST = /(\.(test|spec|stories)\.[cm]?[jt]sx?$)|(^|\/)(__tests__|__mocks__|test|tests|e2e)\//;
299
+ var IMPORT = /(?:import|export)\s[^'"`;]*?from\s*['"]([^'"]+)['"]|import\s*['"]([^'"]+)['"]|(?:require|import)\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
300
+ var EXTENSIONS = ["", ".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs", "/index.ts", "/index.tsx", "/index.js", "/index.jsx", "/index.mjs"];
301
+ var SOURCE_ROOTS = ["src", "lib", "app", "source"];
302
+ var OPEN_LIMIT = 14;
303
+ var jsModulesImporter = {
304
+ id: "js-modules",
305
+ name: "JavaScript and TypeScript modules",
306
+ description: "Modules (top folders of each package) and who imports whom, from import and require statements.",
307
+ detect(dir) {
308
+ if (!existsSync(join(dir, "package.json"))) return [];
309
+ return listFiles(dir, (p) => SOURCE.test(p) && !TEST.test(p)).length ? ["package.json"] : [];
310
+ },
311
+ async run(dir) {
312
+ const files = listFiles(dir, (p) => SOURCE.test(p) && !TEST.test(p) && !p.endsWith(".d.ts"));
313
+ const fileSet = new Set(files);
314
+ const packages = findPackages(dir, listFiles(dir, (p) => p === "package.json" || p.endsWith("/package.json")));
315
+ const packageOf = (file) => packages.filter((p) => p.dir === "" || file.startsWith(`${p.dir}/`)).sort((a, b) => b.dir.length - a.dir.length)[0];
316
+ const workspace = packages.length > 1;
317
+ const moduleOf = (file) => {
318
+ const pkg = packageOf(file);
319
+ const rest = (pkg.dir ? file.slice(pkg.dir.length + 1) : file).split("/");
320
+ const root = rest.length > 1 && SOURCE_ROOTS.includes(rest[0]) ? 1 : 0;
321
+ const folder = rest.length - 1 > root ? rest[root] : "(top)";
322
+ const path = [pkg.dir, ...rest.slice(0, root), folder === "(top)" ? "" : folder].filter(Boolean).join("/");
323
+ return { pkg, folder, path, key: `${pkg.dir}|${folder}` };
324
+ };
325
+ const resolve = (from, spec) => {
326
+ const pkg = packageOf(from);
327
+ let base;
328
+ if (spec.startsWith(".")) base = normalize(join(dirname(from), spec));
329
+ else {
330
+ const alias = pkg.paths.find((p) => spec === p.prefix || spec.startsWith(p.prefix));
331
+ if (alias) base = normalize(join(alias.target, spec.slice(alias.prefix.length)));
332
+ else {
333
+ const target = packages.find((p) => p.name && (spec === p.name || spec.startsWith(`${p.name}/`)));
334
+ if (!target) return void 0;
335
+ const sub = spec.slice(target.name.length).replace(/^\//, "");
336
+ base = sub ? join(target.dir, sub) : join(target.dir, "src/index");
337
+ if (!sub && !EXTENSIONS.some((e) => fileSet.has(`${base}${e}`))) base = join(target.dir, "index");
338
+ }
339
+ }
340
+ const candidates = [base, base.replace(/\.(m|c)?js$/, "")];
341
+ for (const c of candidates) for (const e of EXTENSIONS) if (fileSet.has(`${c}${e}`)) return `${c}${e}`;
342
+ return void 0;
343
+ };
344
+ const modules = /* @__PURE__ */ new Map();
345
+ const edges = /* @__PURE__ */ new Map();
346
+ let unresolved = 0;
347
+ for (const file of files) {
348
+ const from = moduleOf(file);
349
+ modules.set(from.key, { ...from, files: (modules.get(from.key)?.files ?? 0) + 1 });
350
+ const text = readFileSync(join(dir, file), "utf8");
351
+ for (const m of text.matchAll(IMPORT)) {
352
+ const spec = m[1] ?? m[2] ?? m[3];
353
+ const target = resolve(file, spec);
354
+ if (!target) {
355
+ if (spec.startsWith(".")) unresolved++;
356
+ continue;
357
+ }
358
+ const to = moduleOf(target);
359
+ if (to.key === from.key) continue;
360
+ const key = `${from.key}\u2192${to.key}`;
361
+ edges.set(key, (edges.get(key) ?? 0) + 1);
362
+ }
363
+ }
364
+ const pkgId = (p) => `pkg-${slug(p.name || p.dir || "root")}`;
365
+ const modId = (m) => workspace ? `${pkgId(m.pkg).slice(4)}-${slug(m.folder)}` : slug(m.folder);
366
+ const usedPackages = workspace ? [...new Set([...modules.values()].map((m) => m.pkg))] : [];
367
+ const entities = [
368
+ ...usedPackages.map((p) => ({ id: pkgId(p), kind: "library", name: p.name || p.dir || "root", summary: `The package in ${p.dir || "the root folder"}.`, tags: [], sourceRefs: [{ path: p.dir || "." }], metadata: {}, ext: {} })),
369
+ ...[...modules.values()].map((m) => ({
370
+ id: modId(m),
371
+ kind: "module",
372
+ name: m.folder,
373
+ summary: `${m.files} file${m.files === 1 ? "" : "s"} in ${m.path || "the root folder"}.`,
374
+ ...workspace ? { parent: pkgId(m.pkg) } : {},
375
+ tags: [],
376
+ sourceRefs: [{ path: m.path || "." }],
377
+ metadata: { files: m.files },
378
+ ext: {}
379
+ }))
380
+ ];
381
+ const relationships = [...edges.entries()].map(([key, count]) => {
382
+ const [a, b] = key.split("\u2192").map((k) => modules.get(k));
383
+ return { id: `${modId(a)}-imports-${modId(b)}`, kind: "depends-on", source: modId(a), target: modId(b), label: "Imports", data: [], metadata: { imports: count }, ext: {} };
384
+ });
385
+ const ids = entities.map((e) => e.id);
386
+ const closed = workspace && modules.size > OPEN_LIMIT;
387
+ const views = entities.length ? [
388
+ {
389
+ id: "modules",
390
+ type: "architecture",
391
+ title: "Modules",
392
+ description: workspace ? "Each package and its modules, and who imports whom. Open a package to see its modules." : "The modules of the code, and who imports whom.",
393
+ category: "structure",
394
+ entities: ids,
395
+ ...closed ? { collapsed: usedPackages.map(pkgId) } : {}
396
+ }
397
+ ] : [];
398
+ const notes = [`Read ${files.length} source files in ${workspace ? `${usedPackages.length} packages` : "one package"}: ${modules.size} modules, ${relationships.length} import links. Tests and npm dependencies are left out.`];
399
+ if (unresolved) notes.push(`${unresolved} relative imports did not resolve to a file (generated code, or files git ignores).`);
400
+ return { entities, relationships, dataTypes: [], dataRelations: [], views, notes };
401
+ }
402
+ };
403
+ function findPackages(dir, manifests) {
404
+ const out = [];
405
+ for (const m of manifests) {
406
+ const pkgDir = m === "package.json" ? "" : m.slice(0, -"/package.json".length);
407
+ let name = "";
408
+ try {
409
+ name = JSON.parse(readFileSync(join(dir, m), "utf8")).name ?? "";
410
+ } catch {
411
+ continue;
412
+ }
413
+ out.push({ dir: pkgDir, name, paths: tsPaths(dir, pkgDir) });
414
+ }
415
+ if (!out.some((p) => p.dir === "")) out.push({ dir: "", name: "", paths: tsPaths(dir, "") });
416
+ return out;
417
+ }
418
+ function tsPaths(dir, pkgDir) {
419
+ const file = join(dir, pkgDir, "tsconfig.json");
420
+ if (!existsSync(file)) return [];
421
+ try {
422
+ const text = readFileSync(file, "utf8").replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:"])\/\/.*$/gm, "$1").replace(/,(\s*[}\]])/g, "$1");
423
+ const options = JSON.parse(text).compilerOptions ?? {};
424
+ return Object.entries(options.paths ?? {}).filter(([k, v]) => k.endsWith("*") && v[0]?.endsWith("*")).map(([k, v]) => ({ prefix: k.slice(0, -1), target: normalize(join(pkgDir, options.baseUrl ?? ".", v[0].slice(0, -1))) }));
425
+ } catch {
426
+ return [];
427
+ }
428
+ }
429
+ function relativeTo(dir, path) {
430
+ const p = isAbsolute(path) ? relative(dir, path) : path;
431
+ return p.replace(/\\/g, "/").replace(/^\.\//, "");
432
+ }
433
+ var covers = (ref, file) => {
434
+ const r = ref.replace(/^\.\/?/, "").replace(/\/$/, "");
435
+ return r === "" || file === r || file.startsWith(`${r}/`);
436
+ };
437
+ function perEntity(doc, files, sum) {
438
+ const out = /* @__PURE__ */ new Map();
439
+ const paths = [...files.keys()];
440
+ for (const e of doc.model.entities) {
441
+ const refs = e.sourceRefs.map((s) => s.path);
442
+ if (!refs.length) continue;
443
+ const mine = paths.filter((f) => refs.some((r) => covers(r, f)));
444
+ if (mine.length) out.set(e.id, sum(mine.map((f) => files.get(f))));
445
+ }
446
+ return out;
447
+ }
448
+
449
+ // src/plugins/overlays/coverage.ts
450
+ var REPORTS = ["coverage/lcov.info", "lcov.info", "coverage/coverage-final.json", "coverage/.resultset.json", "cover/excoveralls.json", "excoveralls.json"];
451
+ var LOW = 50;
452
+ var coverageOverlay = {
453
+ id: "coverage",
454
+ name: "Test coverage",
455
+ description: "The share of lines the tests run, per part, from the last coverage report (lcov, Istanbul, SimpleCov, ExCoveralls).",
456
+ detect: (dir) => REPORTS.filter((p) => existsSync(join(dir, p))),
457
+ async read(dir, doc) {
458
+ const report = this.detect(dir)[0];
459
+ const at = (/* @__PURE__ */ new Date()).toISOString();
460
+ if (!report) return { title: "Test coverage", at, marks: [], notes: ["No coverage report found. Run the tests with coverage first (for example coverage/lcov.info)."] };
461
+ const files = readReport(dir, report);
462
+ const parts = perEntity(doc, files, (items) => items.reduce((a, b) => ({ covered: a.covered + b.covered, total: a.total + b.total })));
463
+ const marks = [];
464
+ for (const [id, l] of parts) {
465
+ if (!l.total) continue;
466
+ const pct = Math.round(100 * l.covered / l.total);
467
+ marks.push({ target: `entity:${id}`, badge: { text: `${pct}% tested`, tone: pct >= 80 ? "malachite" : pct >= LOW ? "ochre" : "poney" }, ...pct < LOW ? { effect: "attention" } : {} });
468
+ }
469
+ const notes = [`Read ${files.size} files from ${report}. ${marks.length} parts have source paths with coverage.`];
470
+ return { title: "Test coverage", at, marks, notes };
471
+ }
472
+ };
473
+ function readReport(dir, report) {
474
+ const text = readFileSync(join(dir, report), "utf8");
475
+ const out = /* @__PURE__ */ new Map();
476
+ const add = (path, covered, total) => {
477
+ const p = relativeTo(dir, path);
478
+ const cur = out.get(p) ?? { covered: 0, total: 0 };
479
+ out.set(p, { covered: cur.covered + covered, total: cur.total + total });
480
+ };
481
+ if (report.endsWith(".info")) {
482
+ let file = "";
483
+ for (const line of text.split("\n")) {
484
+ if (line.startsWith("SF:")) file = line.slice(3).trim();
485
+ else if (line.startsWith("LH:")) add(file, Number(line.slice(3)), 0);
486
+ else if (line.startsWith("LF:")) add(file, 0, Number(line.slice(3)));
487
+ }
488
+ return out;
489
+ }
490
+ const json = JSON.parse(text);
491
+ if (report.endsWith("coverage-final.json")) {
492
+ for (const [path, f] of Object.entries(json)) {
493
+ const hits = Object.values(f.s ?? {});
494
+ add(path, hits.filter((n) => n > 0).length, hits.length);
495
+ }
496
+ } else if (report.endsWith(".resultset.json")) {
497
+ for (const run of Object.values(json))
498
+ for (const [path, f] of Object.entries(run.coverage ?? {})) countLines(Array.isArray(f) ? f : f.lines ?? [], (c, t) => add(path, c, t));
499
+ } else {
500
+ for (const f of json.source_files ?? []) countLines(f.coverage, (c, t) => add(f.name, c, t));
501
+ }
502
+ return out;
503
+ }
504
+ function countLines(lines, done) {
505
+ const relevant = lines.filter((n) => n !== null);
506
+ done(relevant.filter((n) => n > 0).length, relevant.length);
507
+ }
508
+ var DAYS = 90;
509
+ var TOP = 3;
510
+ var MIN = 5;
511
+ var churnOverlay = {
512
+ id: "churn",
513
+ name: "Recent changes",
514
+ description: `How many commits touched each part in the last ${DAYS} days, from git.`,
515
+ detect: (dir) => existsSync(join(dir, ".git")) ? [".git"] : [],
516
+ async read(dir, doc) {
517
+ const at = (/* @__PURE__ */ new Date()).toISOString();
518
+ let log = "";
519
+ try {
520
+ log = execFileSync("git", ["-C", dir, "log", `--since=${DAYS} days ago`, "--name-only", "--format=%x00%H"], { encoding: "utf8", maxBuffer: 256 * 1024 * 1024, stdio: ["ignore", "pipe", "ignore"] });
521
+ } catch {
522
+ return { title: "Recent changes", at, marks: [], notes: ["This folder is not a git repository."] };
523
+ }
524
+ const commits = log.split("\0").filter(Boolean).map((c) => c.split("\n").slice(1).filter(Boolean));
525
+ const counts = /* @__PURE__ */ new Map();
526
+ for (const e of doc.model.entities) {
527
+ const refs = e.sourceRefs.map((s) => s.path);
528
+ if (!refs.length) continue;
529
+ const n = commits.filter((files) => files.some((f) => refs.some((r) => covers(r, f)))).length;
530
+ if (n) counts.set(e.id, n);
531
+ }
532
+ const hot = new Set(
533
+ [...counts.entries()].filter(([, n]) => n >= MIN).sort((a, b) => b[1] - a[1]).slice(0, TOP).map(([id]) => id)
534
+ );
535
+ const marks = [...counts.entries()].map(([id, n]) => ({ target: `entity:${id}`, badge: { text: `${n} change${n === 1 ? "" : "s"} in ${DAYS} d` }, ...hot.has(id) ? { effect: "attention" } : {} }));
536
+ return { title: "Recent changes", at, marks, notes: [`Read ${commits.length} commits from the last ${DAYS} days.`] };
537
+ }
538
+ };
539
+
540
+ // src/plugins/registry.ts
541
+ var BUILT_IN = definePlugin({ name: "poney", importers: [schemaImporter, jsModulesImporter], overlays: [coverageOverlay, churnOverlay] });
542
+ var pluginsFile = () => process.env.PONEY_PLUGINS ?? join(homedir(), ".poney", "plugins.json");
543
+ var loaded;
544
+ function plugins() {
545
+ return loaded ??= load();
546
+ }
547
+ var resetPlugins = () => loaded = void 0;
548
+ async function load() {
549
+ const all = [BUILT_IN];
550
+ const problems = [];
551
+ const file = pluginsFile();
552
+ if (existsSync(file)) {
553
+ let list = [];
554
+ try {
555
+ list = JSON.parse(readFileSync(file, "utf8")).plugins ?? [];
556
+ } catch (e) {
557
+ problems.push(`${file} is not valid JSON: ${e instanceof Error ? e.message : String(e)}`);
558
+ }
559
+ for (const spec of Array.isArray(list) ? list : []) {
560
+ if (typeof spec !== "string") continue;
561
+ try {
562
+ const mod = await (isAbsolute(spec) ? import(pathToFileURL(spec).href) : import(spec));
563
+ const plugin = mod.default;
564
+ if (!plugin || typeof plugin.name !== "string") throw new Error("its default export is not a plugin (use definePlugin)");
565
+ all.push(plugin);
566
+ } catch (e) {
567
+ problems.push(`The plugin "${spec}" did not load: ${e instanceof Error ? e.message : String(e)}`);
568
+ }
569
+ }
570
+ }
571
+ const byId = (items) => [...new Map(items.map((x) => [x.id, x])).values()];
572
+ return {
573
+ plugins: all,
574
+ importers: byId(all.flatMap((p) => p.importers ?? [])),
575
+ overlays: byId(all.flatMap((p) => p.overlays ?? [])),
576
+ problems
577
+ };
578
+ }
579
+
580
+ // src/plugins/run.ts
581
+ async function available(dir) {
582
+ const p = await plugins();
583
+ const describe = (x) => {
584
+ let files = [];
585
+ try {
586
+ files = x.detect(dir);
587
+ } catch {
588
+ }
589
+ return { id: x.id, name: x.name, description: x.description, files };
590
+ };
591
+ return { importers: p.importers.map(describe), overlays: p.overlays.map(describe), problems: p.problems };
592
+ }
593
+ async function runImport(id, dir, options = {}) {
594
+ const { importers } = await plugins();
595
+ const importer = importers.find((i) => i.id === id);
596
+ if (!importer) throw new Error(`No importer "${id}". Importers: ${importers.map((i) => i.id).join(", ")}.`);
597
+ const result = await importer.run(dir, options);
598
+ const name = basename(dir);
599
+ const { document, report } = mergeImport(options.into, result, { id: slug(name), name, description: `The code in ${name}.` });
600
+ return { document, summary: [describeMerge(report), ...result.notes].join("\n") };
601
+ }
602
+ async function runOverlay(id, dir, document) {
603
+ const { overlays } = await plugins();
604
+ const overlay = overlays.find((o) => o.id === id);
605
+ if (!overlay) throw new Error(`No overlay "${id}". Overlays: ${overlays.map((o) => o.id).join(", ")}.`);
606
+ let doc;
607
+ try {
608
+ doc = parseDocument(document);
609
+ } catch {
610
+ throw new Error("The open document is not valid; an overlay needs a valid document.");
611
+ }
612
+ return overlay.read(dir, doc);
613
+ }
614
+ function describeOverlay(r) {
615
+ const lines = r.marks.map((m) => `- ${m.target}: ${m.badge?.text ?? ""}${m.effect ? ` (${m.effect})` : ""}`);
616
+ return [`${r.title}, read ${r.at}.`, ...r.notes, ...lines].join("\n");
617
+ }
618
+
619
+ export { BUILT_IN, available, definePlugin, describeMerge, describeOverlay, mergeImport, plugins, pluginsFile, resetPlugins, runImport, runOverlay, slug };
620
+ //# sourceMappingURL=chunk-YLKV6LIU.js.map
621
+ //# sourceMappingURL=chunk-YLKV6LIU.js.map