@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,290 @@
1
+ import { existsSync, readFileSync, statSync } from 'fs';
2
+ import { zodToJsonSchema } from 'zod-to-json-schema';
3
+ import { PoneyDocument, detectMermaid, fromMermaid, checkDocument, formatCheck } from '@hattoriai/poney-core';
4
+ export { toJSON } from '@hattoriai/poney-core';
5
+ import { ownership } from '@hattoriai/poney-ext-ownership';
6
+ import { security } from '@hattoriai/poney-ext-security';
7
+ import { teamMap } from '@hattoriai/poney-ext-ownership/diagram';
8
+ import { layoutTeamMap } from '@hattoriai/poney-ext-ownership/layout';
9
+ import { registerDiagram } from '@hattoriai/poney-react';
10
+ import { registerExtensionLayout } from '@hattoriai/poney-layout';
11
+ import { execFileSync } from 'child_process';
12
+ import { dirname, join, sep } from 'path';
13
+ import { createRequire } from 'module';
14
+ import { fileURLToPath, pathToFileURL } from 'url';
15
+
16
+ // src/ops.ts
17
+ var WORKING = "working";
18
+ function filesAt(repo, rev) {
19
+ const head = headOf(rev);
20
+ const git = (args) => execFileSync("git", ["-C", repo, ...args], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], maxBuffer: 64 * 1024 * 1024 });
21
+ const cache = /* @__PURE__ */ new Map();
22
+ let list;
23
+ return {
24
+ label: `${repo} at ${head === WORKING ? "the working tree" : head}`,
25
+ read(path) {
26
+ const clean = path.replace(/^\.\//, "");
27
+ if (!cache.has(clean)) {
28
+ try {
29
+ if (head === WORKING) {
30
+ const file = join(repo, clean);
31
+ cache.set(clean, existsSync(file) && statSync(file).isFile() ? readFileSync(file, "utf8") : void 0);
32
+ } else cache.set(clean, git(["show", `${head}:${clean}`]));
33
+ } catch {
34
+ cache.set(clean, void 0);
35
+ }
36
+ }
37
+ return cache.get(clean);
38
+ },
39
+ files() {
40
+ try {
41
+ list ??= git(head === WORKING ? ["ls-files", "--cached", "--others", "--exclude-standard"] : ["ls-tree", "-r", "--name-only", head]).split("\n").filter(Boolean);
42
+ } catch {
43
+ list = [];
44
+ }
45
+ return list;
46
+ }
47
+ };
48
+ }
49
+ function pathHint(path, source) {
50
+ const name = path.split("/").pop() ?? path;
51
+ const like = source.files().filter((f) => f === name || f.endsWith(`/${name}`)).slice(0, 4);
52
+ return like.length ? `Did you mean ${like.map((f) => `"${f}"`).join(" or ")}?` : "Use a path relative to the root of the repository.";
53
+ }
54
+ function diffFromGit(repo, rev) {
55
+ if (rev === WORKING) return execFileSync("git", ["-C", repo, "diff", "--no-color", "--no-ext-diff", "--no-renames", "-U3", "HEAD"], { encoding: "utf8", maxBuffer: 64 * 1024 * 1024 });
56
+ const args = rev.includes("..") ? ["diff", "--no-color", "--no-ext-diff", "--no-renames", "-U3", ...rev.split("..")] : ["show", "--no-color", "--no-ext-diff", "--no-renames", "-U3", "--format=", rev];
57
+ return execFileSync("git", ["-C", repo, ...args], { encoding: "utf8", maxBuffer: 64 * 1024 * 1024 });
58
+ }
59
+ var headOf = (rev) => rev.includes("..") ? rev.split("..")[1] || "HEAD" : rev;
60
+ function parseDiff(text) {
61
+ const files = /* @__PURE__ */ new Map();
62
+ let file;
63
+ let oldN = 0;
64
+ let newN = 0;
65
+ for (const line of text.split("\n")) {
66
+ if (line.startsWith("diff --git ")) {
67
+ file = void 0;
68
+ continue;
69
+ }
70
+ if (line.startsWith("+++ ")) {
71
+ const path = line.slice(4).replace(/^b\//, "");
72
+ file = { added: /* @__PURE__ */ new Map(), removed: /* @__PURE__ */ new Map(), context: /* @__PURE__ */ new Map() };
73
+ if (path !== "/dev/null") files.set(path, file);
74
+ continue;
75
+ }
76
+ if (line.startsWith("--- ")) continue;
77
+ const hunk = /^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(line);
78
+ if (hunk) {
79
+ oldN = Number(hunk[1]);
80
+ newN = Number(hunk[2]);
81
+ continue;
82
+ }
83
+ if (!file) continue;
84
+ if (line.startsWith("+")) file.added.set(newN++, line.slice(1));
85
+ else if (line.startsWith("-")) file.removed.set(oldN++, line.slice(1));
86
+ else if (line.startsWith(" ")) {
87
+ file.context.set(newN, line.slice(1));
88
+ oldN++;
89
+ newN++;
90
+ }
91
+ }
92
+ return files;
93
+ }
94
+ var same = (a, b) => a !== void 0 && a.trimEnd() === b.trimEnd();
95
+ var short = (t) => t.length > 70 ? `${t.slice(0, 67)}\u2026` : t;
96
+ var nearest = (lines, text, near = 0) => [...lines.entries()].filter(([, t]) => same(t, text)).sort((a, b) => Math.abs(a[0] - near) - Math.abs(b[0] - near))[0]?.[0];
97
+ function excerptIssues(block, at, source, code) {
98
+ const content = source.read(block.path);
99
+ if (content === void 0) return [{ path: `${at}.path`, message: `No file "${block.path}" in ${source.label}`, severity: "error", code, hint: pathHint(block.path, source) }];
100
+ const file = content.split("\n");
101
+ const lines = new Map(file.map((t, i) => [i + 1, t]));
102
+ const out = [];
103
+ block.hunks.forEach(
104
+ (h, hi) => h.lines.forEach((l, li) => {
105
+ if (l.kind !== "ctx") return;
106
+ if (l.new !== void 0 && same(lines.get(l.new), l.text)) return;
107
+ const n = nearest(lines, l.text, l.new);
108
+ out.push({
109
+ path: `${at}.hunks.${hi}.lines.${li}`,
110
+ message: `Line ${l.new ?? "?"} of "${block.path}" is not "${short(l.text.trim())}"`,
111
+ severity: "error",
112
+ code,
113
+ hint: n ? `That text is at line ${n}.${l.new && n !== l.new ? ` Every line after it may be off by ${n - l.new} too.` : ""}` : l.new && l.new <= file.length ? `Line ${l.new} is: "${short((lines.get(l.new) ?? "").trim())}".` : `The file has ${file.length} lines.`
114
+ });
115
+ })
116
+ );
117
+ return out.length > 3 ? [...out.slice(0, 3), { ...out[3], message: `${out.length - 3} more lines of "${block.path}" do not match`, hint: 'Copy the excerpt again from the file, with its first line number as "start".' }] : out;
118
+ }
119
+ function verifyExcerpts(doc, source) {
120
+ return doc.walkthroughs.flatMap(
121
+ (w, wi) => w.kind !== "tour" ? [] : w.scenes.flatMap((s, si) => s.code.flatMap((block, ci) => excerptIssues(block, `walkthroughs.${wi}.scenes.${si}.code.${ci}`, source, "code-not-in-file")))
122
+ );
123
+ }
124
+ function verifyCode(doc, diffText, source) {
125
+ const files = parseDiff(diffText);
126
+ const issues = [];
127
+ const error = (path, message, hint) => issues.push({ path, message, severity: "error", code: "code-not-in-diff", ...hint ? { hint } : {} });
128
+ const find = (path) => files.get(path) ?? [...files.entries()].find(([p]) => p.endsWith(`/${path}`) || path.endsWith(`/${p}`))?.[1];
129
+ doc.walkthroughs.forEach(
130
+ (w, wi) => w.kind === "tour" ? void 0 : w.scenes.forEach(
131
+ (s, si) => s.code.forEach((block, ci) => {
132
+ const at = `walkthroughs.${wi}.scenes.${si}.code.${ci}`;
133
+ const f = find(block.path);
134
+ const excerpt2 = block.hunks.every((h) => h.lines.every((l) => l.kind === "ctx"));
135
+ if (excerpt2 && source && (!f || block.hunks.some((h) => h.lines.some((l) => l.new === void 0 || !(same(f.context.get(l.new), l.text) || same(f.added.get(l.new), l.text))))))
136
+ return void issues.push(...excerptIssues(block, at, source, "code-not-in-file"));
137
+ if (!f) return error(`${at}.path`, `"${block.path}" is not in the diff`, `Files in the diff: ${[...files.keys()].slice(0, 8).join(", ")}${files.size > 8 ? ", \u2026" : ""}.`);
138
+ block.hunks.forEach(
139
+ (h, hi) => h.lines.forEach((l, li) => {
140
+ const lp = `${at}.hunks.${hi}.lines.${li}`;
141
+ if (l.kind === "add") {
142
+ if (same(f.added.get(l.new ?? -1), l.text)) return;
143
+ const n = nearest(f.added, l.text, l.new);
144
+ error(lp, `Added line ${l.new ?? "?"} is not "${short(l.text.trim())}"`, n ? `That text is added at line ${n}.` : f.added.has(l.new ?? -1) ? `Line ${l.new} adds: "${short((f.added.get(l.new) ?? "").trim())}".` : "The diff adds no such line. Show only lines the change adds.");
145
+ } else if (l.kind === "del") {
146
+ if (same(f.removed.get(l.old ?? -1), l.text)) return;
147
+ const n = nearest(f.removed, l.text, l.old);
148
+ error(lp, `Removed line ${l.old ?? "?"} is not "${short(l.text.trim())}"`, n ? `That text is removed at old line ${n}.` : "The diff removes no such line.");
149
+ } else {
150
+ if (l.new !== void 0 && (same(f.context.get(l.new), l.text) || same(f.added.get(l.new), l.text))) return;
151
+ if (l.new === void 0 && [...f.context.values()].some((t) => same(t, l.text))) return;
152
+ const n = nearest(f.context, l.text, l.new);
153
+ error(lp, `Context line ${l.new ?? "?"} is not "${short(l.text.trim())}"`, n ? `That text is at line ${n}.` : "Context lines must be unchanged lines the diff shows around a change.");
154
+ }
155
+ })
156
+ );
157
+ })
158
+ )
159
+ );
160
+ return issues;
161
+ }
162
+ function verifySources(doc, source) {
163
+ const issues = [];
164
+ const looksLikePath = (p) => !/\s/.test(p) && /[/.]/.test(p);
165
+ doc.walkthroughs.forEach(
166
+ (w, wi) => w.scenes.forEach(
167
+ (s, si) => s.proof.forEach((p, pi) => {
168
+ if (!p.source || p.missing || !looksLikePath(p.source)) return;
169
+ const at = `walkthroughs.${wi}.scenes.${si}.proof.${pi}`;
170
+ const content = source.read(p.source);
171
+ if (content === void 0) return issues.push({ path: `${at}.source`, message: `No file "${p.source}" in ${source.label}`, severity: "error", code: "proof-not-found", hint: `${pathHint(p.source, source)} Or mark the proof "missing": true.` });
172
+ if (p.test && !content.includes(p.test))
173
+ issues.push({ path: `${at}.test`, message: `"${p.source}" has no test "${p.test}"`, severity: "error", code: "proof-not-found", hint: "Use the test name as it is written in the file." });
174
+ })
175
+ )
176
+ );
177
+ doc.model.entities.forEach(
178
+ (e, ei) => e.sourceRefs.forEach((r, ri) => {
179
+ if (!looksLikePath(r.path)) return;
180
+ const at = `model.entities.${ei}.sourceRefs.${ri}`;
181
+ const content = source.read(r.path);
182
+ if (content === void 0) {
183
+ const dir = r.path.replace(/\/$/, "");
184
+ if (source.files().some((f) => f.startsWith(`${dir}/`))) return;
185
+ return issues.push({ path: `${at}.path`, message: `No file or folder "${r.path}" in ${source.label}`, severity: "error", code: "source-not-found", hint: pathHint(r.path, source) });
186
+ }
187
+ const lines = content.split("\n");
188
+ if (r.line !== void 0 && r.line > lines.length) issues.push({ path: `${at}.line`, message: `"${r.path}" has only ${lines.length} lines`, severity: "error", code: "source-not-found" });
189
+ if (r.symbol && !content.includes(r.symbol.split(/[.#:]/).pop())) issues.push({ path: `${at}.symbol`, message: `"${r.path}" does not mention "${r.symbol}"`, severity: "error", code: "source-not-found", hint: "Use the name as it is written in the file." });
190
+ })
191
+ );
192
+ return issues;
193
+ }
194
+ var here = fileURLToPath(import.meta.url);
195
+ var PACKAGE_ROOT = (() => {
196
+ let dir = dirname(here);
197
+ while (!existsSync(join(dir, "package.json"))) {
198
+ const up = dirname(dir);
199
+ if (up === dir) break;
200
+ dir = up;
201
+ }
202
+ return dir;
203
+ })();
204
+ var packagePath = (...parts) => join(PACKAGE_ROOT, ...parts);
205
+ var fromSource = here.includes(`${sep}src${sep}`);
206
+ function mcpCommand() {
207
+ if (!fromSource) return { command: "node", args: [packagePath("bin", "poney-mcp.mjs")] };
208
+ return { command: "node", args: ["--conditions=poney-source", "--import", tsxLoader(), packagePath("src", "mcp.ts")] };
209
+ }
210
+ function tsxLoader() {
211
+ const manifest = createRequire(import.meta.url).resolve("tsx/package.json");
212
+ const target = JSON.parse(readFileSync(manifest, "utf8")).exports["."];
213
+ const entry = typeof target === "string" ? target : target.import ?? target.default ?? "./dist/loader.mjs";
214
+ return pathToFileURL(join(dirname(manifest), entry)).href;
215
+ }
216
+ var studioDist = () => existsSync(packagePath("studio", "index.html")) ? packagePath("studio") : packagePath("..", "..", "apps", "studio", "dist");
217
+
218
+ // src/ops.ts
219
+ var EXTENSIONS = [ownership, security];
220
+ registerDiagram(teamMap);
221
+ registerExtensionLayout("ownership/team-map", layoutTeamMap);
222
+ var here2 = (p) => packagePath(p.replace(/^\.\.\//, ""));
223
+ var brief = (topic = "change") => `${readFileSync(here2("../brief.md"), "utf8")}
224
+
225
+ ${readFileSync(here2(`../brief-${topic}.md`), "utf8")}`;
226
+ var example = (topic = "change") => readFileSync(here2(topic === "tour" ? "../examples/tour.poney" : "../examples/walkthrough.poney"), "utf8");
227
+ function schema() {
228
+ return zodToJsonSchema(PoneyDocument, { name: "PoneyDocument", target: "jsonSchema7", $refStrategy: "root", definitionPath: "definitions" });
229
+ }
230
+ function readInput(input) {
231
+ try {
232
+ let text = input.text;
233
+ if (input.path) text = readFileSync(input.path, "utf8");
234
+ if (input.document !== void 0 && typeof input.document !== "string") return { value: input.document };
235
+ if (typeof input.document === "string") text = input.document;
236
+ if (text === void 0) return { error: "Give a document, JSON text, or a file path." };
237
+ const kind = detectMermaid(text);
238
+ if (kind) return { value: fromMermaid(text).document, converted: `Converted from a Mermaid ${kind} diagram.` };
239
+ return { value: JSON.parse(text) };
240
+ } catch (e) {
241
+ return { error: e instanceof Error ? e.message : String(e) };
242
+ }
243
+ }
244
+ function check(input, against = {}) {
245
+ const read = readInput(input);
246
+ if (read.error) return { report: `Cannot read the document: ${read.error}` };
247
+ const result = checkDocument(read.value, { extensions: EXTENSIONS });
248
+ const notes = [];
249
+ if (result.ok && result.document && (against.repo || against.diff)) {
250
+ try {
251
+ const doc = result.document;
252
+ const rev = against.rev ?? "HEAD";
253
+ const files = against.repo ? filesAt(against.repo, rev) : void 0;
254
+ const showsChange = doc.walkthroughs.some((w) => w.kind === "change" && w.scenes.some((s) => s.code.length));
255
+ const found = [
256
+ ...showsChange ? verifyCode(doc, against.diff ?? diffFromGit(against.repo, rev), files) : [],
257
+ ...files ? [...verifyExcerpts(doc, files), ...verifySources(doc, files)] : []
258
+ ];
259
+ if (found.length) {
260
+ result.errors.push(...found);
261
+ result.ok = false;
262
+ } else notes.push(`Code, sources and proof match ${files ? files.label : "the diff"}.`);
263
+ } catch (e) {
264
+ notes.push(`Could not read the change: ${e instanceof Error ? e.message.split("\n")[0] : String(e)}`);
265
+ }
266
+ }
267
+ return { result, report: [read.converted, formatCheck(result), ...notes].filter(Boolean).join("\n") };
268
+ }
269
+ function outline(result) {
270
+ const doc = result.document;
271
+ if (!doc) return "";
272
+ return doc.walkthroughs.map((w) => {
273
+ const scenes = [w.overview ? "overview" : void 0, ...w.scenes.map((s) => s.view ? s.id : `${s.id} (code only)`)].filter(Boolean);
274
+ return `Walkthrough "${w.id}": ${w.title}
275
+ Scenes: ${scenes.join(", ")}`;
276
+ }).join("\n");
277
+ }
278
+ function excerpt(repo, path, from, to, rev = "HEAD") {
279
+ const files = filesAt(repo, rev);
280
+ const content = files.read(path);
281
+ if (content === void 0) return { error: `No file "${path}" in ${files.label}.` };
282
+ const lines = content.split("\n");
283
+ if (from < 1 || to < from) return { error: "Give a range like 12-30, first line first." };
284
+ if (from > lines.length) return { error: `"${path}" has ${lines.length} lines.` };
285
+ return { block: { path, start: from, text: lines.slice(from - 1, Math.min(to, lines.length)).join("\n") } };
286
+ }
287
+
288
+ export { EXTENSIONS, brief, check, example, excerpt, mcpCommand, outline, readInput, schema, studioDist };
289
+ //# sourceMappingURL=chunk-TPJZDQG6.js.map
290
+ //# sourceMappingURL=chunk-TPJZDQG6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/verify.ts","../src/paths.ts","../src/ops.ts"],"names":["excerpt","existsSync","join","readFileSync","here"],"mappings":";;;;;;;;;;;;;;;;AAaO,IAAM,OAAA,GAAU,SAAA;AAWhB,SAAS,OAAA,CAAQ,MAAc,GAAA,EAAyB;AAC7D,EAAA,MAAM,IAAA,GAAO,OAAO,GAAG,CAAA;AACvB,EAAA,MAAM,GAAA,GAAM,CAAC,IAAA,KAAmB,YAAA,CAAa,KAAA,EAAO,CAAC,IAAA,EAAM,IAAA,EAAM,GAAG,IAAI,CAAA,EAAG,EAAE,UAAU,MAAA,EAAQ,KAAA,EAAO,CAAC,QAAA,EAAU,MAAA,EAAQ,QAAQ,GAAG,SAAA,EAAW,EAAA,GAAK,IAAA,GAAO,IAAA,EAAM,CAAA;AACjK,EAAA,MAAM,KAAA,uBAAY,GAAA,EAAgC;AAClD,EAAA,IAAI,IAAA;AACJ,EAAA,OAAO;AAAA,IACL,OAAO,CAAA,EAAG,IAAI,OAAO,IAAA,KAAS,OAAA,GAAU,qBAAqB,IAAI,CAAA,CAAA;AAAA,IACjE,KAAK,IAAA,EAAM;AACT,MAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,OAAA,CAAQ,OAAA,EAAS,EAAE,CAAA;AACt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AAA,GAAO,GAAG,IAAA,CAAK,GAAA,CAAI,IAAI,KAAA,CAAM,MAAM,CAAC,CAAA,CAAE,IAAA,CAAK,IAAI,CAAA,EAAE,EAAE;AAC5G","file":"chunk-TPJZDQG6.js","sourcesContent":["/**\n * Proof against the real code. In a change, the code a walkthrough shows must\n * be in the diff, with the line numbers it gives. In a tour, every excerpt\n * must be in the file at those lines. Cited tests and source references must\n * exist. The format cannot know the repository; these checks run when the\n * reader gives one (a git repository and revision, or a diff file).\n */\nimport { execFileSync } from 'node:child_process'\nimport { existsSync, readFileSync, statSync } from 'node:fs'\nimport { join } from 'node:path'\nimport type { CodeBlock, PoneyDocument, ValidationIssue } from '@hattoriai/poney-core'\n\n/** The revision \"working\" means the files on disk, with changes not yet committed. */\nexport const WORKING = 'working'\n\n/** Reads files at one revision of a repository. */\nexport interface FileSource {\n /** e.g. \"~/code/notes at HEAD\". */\n label: string\n read(path: string): string | undefined\n /** Every tracked file, for suggestions. */\n files(): string[]\n}\n\nexport function filesAt(repo: string, rev: string): FileSource {\n const head = headOf(rev)\n const git = (args: string[]) => execFileSync('git', ['-C', repo, ...args], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'], maxBuffer: 64 * 1024 * 1024 })\n const cache = new Map<string, string | undefined>()\n let list: string[] | undefined\n return {\n label: `${repo} at ${head === WORKING ? 'the working tree' : head}`,\n read(path) {\n const clean = path.replace(/^\\.\\//, '')\n if (!cache.has(clean)) {\n try {\n if (head === WORKING) {\n const file = join(repo, clean)\n cache.set(clean, existsSync(file) && statSync(file).isFile() ? readFileSync(file, 'utf8') : undefined)\n } else cache.set(clean, git(['show', `${head}:${clean}`]))\n } catch {\n cache.set(clean, undefined)\n }\n }\n return cache.get(clean)\n },\n files() {\n try {\n list ??= git(head === WORKING ? ['ls-files', '--cached', '--others', '--exclude-standard'] : ['ls-tree', '-r', '--name-only', head]).split('\\n').filter(Boolean)\n } catch {\n list = []\n }\n return list\n },\n }\n}\n\n/** A hint for a path that does not exist: files with the same name. */\nfunction pathHint(path: string, source: FileSource): string {\n const name = path.split('/').pop() ?? path\n const like = source.files().filter((f) => f === name || f.endsWith(`/${name}`)).slice(0, 4)\n return like.length ? `Did you mean ${like.map((f) => `\"${f}\"`).join(' or ')}?` : 'Use a path relative to the root of the repository.'\n}\n\ninterface FileDiff {\n added: Map<number, string>\n removed: Map<number, string>\n context: Map<number, string>\n}\n\n/** The unified diff of a commit, or of a range \"a..b\". */\nexport function diffFromGit(repo: string, rev: string): string {\n if (rev === WORKING) return execFileSync('git', ['-C', repo, 'diff', '--no-color', '--no-ext-diff', '--no-renames', '-U3', 'HEAD'], { encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 })\n const args = rev.includes('..')\n ? ['diff', '--no-color', '--no-ext-diff', '--no-renames', '-U3', ...rev.split('..')]\n : ['show', '--no-color', '--no-ext-diff', '--no-renames', '-U3', '--format=', rev]\n return execFileSync('git', ['-C', repo, ...args], { encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 })\n}\n\n/** The commit whose files the walkthrough describes: the head of a range. */\nexport const headOf = (rev: string) => (rev.includes('..') ? rev.split('..')[1] || 'HEAD' : rev)\n\nexport function parseDiff(text: string): Map<string, FileDiff> {\n const files = new Map<string, FileDiff>()\n let file: FileDiff | undefined\n let oldN = 0\n let newN = 0\n for (const line of text.split('\\n')) {\n if (line.startsWith('diff --git ')) {\n file = undefined\n continue\n }\n if (line.startsWith('+++ ')) {\n const path = line.slice(4).replace(/^b\\//, '')\n file = { added: new Map(), removed: new Map(), context: new Map() }\n if (path !== '/dev/null') files.set(path, file)\n continue\n }\n if (line.startsWith('--- ')) continue\n const hunk = /^@@ -(\\d+)(?:,\\d+)? \\+(\\d+)(?:,\\d+)? @@/.exec(line)\n if (hunk) {\n oldN = Number(hunk[1])\n newN = Number(hunk[2])\n continue\n }\n if (!file) continue\n if (line.startsWith('+')) file.added.set(newN++, line.slice(1))\n else if (line.startsWith('-')) file.removed.set(oldN++, line.slice(1))\n else if (line.startsWith(' ')) {\n file.context.set(newN, line.slice(1))\n oldN++\n newN++\n }\n }\n return files\n}\n\nconst same = (a: string | undefined, b: string) => a !== undefined && a.trimEnd() === b.trimEnd()\nconst short = (t: string) => (t.length > 70 ? `${t.slice(0, 67)}…` : t)\n/** The line with this text nearest to where the walkthrough says it is. */\nconst nearest = (lines: Map<number, string>, text: string, near = 0) =>\n [...lines.entries()].filter(([, t]) => same(t, text)).sort((a, b) => Math.abs(a[0] - near) - Math.abs(b[0] - near))[0]?.[0]\n\n/** The lines of an excerpt must be in the file, at the numbers it gives. */\nfunction excerptIssues(block: CodeBlock, at: string, source: FileSource, code: string): ValidationIssue[] {\n const content = source.read(block.path)\n if (content === undefined) return [{ path: `${at}.path`, message: `No file \"${block.path}\" in ${source.label}`, severity: 'error', code, hint: pathHint(block.path, source) }]\n const file = content.split('\\n')\n const lines = new Map(file.map((t, i) => [i + 1, t]))\n const out: ValidationIssue[] = []\n block.hunks.forEach((h, hi) =>\n h.lines.forEach((l, li) => {\n if (l.kind !== 'ctx') return\n if (l.new !== undefined && same(lines.get(l.new), l.text)) return\n const n = nearest(lines, l.text, l.new)\n out.push({\n path: `${at}.hunks.${hi}.lines.${li}`,\n message: `Line ${l.new ?? '?'} of \"${block.path}\" is not \"${short(l.text.trim())}\"`,\n severity: 'error',\n code,\n hint: n ? `That text is at line ${n}.${l.new && n !== l.new ? ` Every line after it may be off by ${n - l.new} too.` : ''}` : l.new && l.new <= file.length ? `Line ${l.new} is: \"${short((lines.get(l.new) ?? '').trim())}\".` : `The file has ${file.length} lines.`,\n })\n }),\n )\n // One wrong start shifts every line: report the first, with the shift.\n return out.length > 3 ? [...out.slice(0, 3), { ...out[3], message: `${out.length - 3} more lines of \"${block.path}\" do not match`, hint: 'Copy the excerpt again from the file, with its first line number as \"start\".' }] : out\n}\n\n/** In a tour, every excerpt is checked against the file as it is. */\nexport function verifyExcerpts(doc: PoneyDocument, source: FileSource): ValidationIssue[] {\n return doc.walkthroughs.flatMap((w, wi) =>\n w.kind !== 'tour' ? [] : w.scenes.flatMap((s, si) => s.code.flatMap((block, ci) => excerptIssues(block, `walkthroughs.${wi}.scenes.${si}.code.${ci}`, source, 'code-not-in-file'))),\n )\n}\n\n/** Every code line shown must be in the diff, as the line it claims to be. Unchanged lines may also come from the file itself. */\nexport function verifyCode(doc: PoneyDocument, diffText: string, source?: FileSource): ValidationIssue[] {\n const files = parseDiff(diffText)\n const issues: ValidationIssue[] = []\n const error = (path: string, message: string, hint?: string) => issues.push({ path, message, severity: 'error', code: 'code-not-in-diff', ...(hint ? { hint } : {}) })\n const find = (path: string) => files.get(path) ?? [...files.entries()].find(([p]) => p.endsWith(`/${path}`) || path.endsWith(`/${p}`))?.[1]\n doc.walkthroughs.forEach((w, wi) =>\n w.kind === 'tour' ? undefined : w.scenes.forEach((s, si) =>\n s.code.forEach((block, ci) => {\n const at = `walkthroughs.${wi}.scenes.${si}.code.${ci}`\n const f = find(block.path)\n const excerpt = block.hunks.every((h) => h.lines.every((l) => l.kind === 'ctx'))\n if (excerpt && source && (!f || block.hunks.some((h) => h.lines.some((l) => l.new === undefined || !(same(f.context.get(l.new), l.text) || same(f.added.get(l.new), l.text))))))\n return void issues.push(...excerptIssues(block, at, source, 'code-not-in-file'))\n if (!f) return error(`${at}.path`, `\"${block.path}\" is not in the diff`, `Files in the diff: ${[...files.keys()].slice(0, 8).join(', ')}${files.size > 8 ? ', …' : ''}.`)\n block.hunks.forEach((h, hi) =>\n h.lines.forEach((l, li) => {\n const lp = `${at}.hunks.${hi}.lines.${li}`\n if (l.kind === 'add') {\n if (same(f.added.get(l.new ?? -1), l.text)) return\n const n = nearest(f.added, l.text, l.new)\n error(lp, `Added line ${l.new ?? '?'} is not \"${short(l.text.trim())}\"`, n ? `That text is added at line ${n}.` : f.added.has(l.new ?? -1) ? `Line ${l.new} adds: \"${short((f.added.get(l.new!) ?? '').trim())}\".` : 'The diff adds no such line. Show only lines the change adds.')\n } else if (l.kind === 'del') {\n if (same(f.removed.get(l.old ?? -1), l.text)) return\n const n = nearest(f.removed, l.text, l.old)\n error(lp, `Removed line ${l.old ?? '?'} is not \"${short(l.text.trim())}\"`, n ? `That text is removed at old line ${n}.` : 'The diff removes no such line.')\n } else {\n if (l.new !== undefined && (same(f.context.get(l.new), l.text) || same(f.added.get(l.new), l.text))) return\n if (l.new === undefined && [...f.context.values()].some((t) => same(t, l.text))) return\n const n = nearest(f.context, l.text, l.new)\n error(lp, `Context line ${l.new ?? '?'} is not \"${short(l.text.trim())}\"`, n ? `That text is at line ${n}.` : 'Context lines must be unchanged lines the diff shows around a change.')\n }\n }),\n )\n }),\n ),\n )\n return issues\n}\n\n/** Cited test files must exist and contain the named test. Source references on entities must point at real files and symbols. */\nexport function verifySources(doc: PoneyDocument, source: FileSource): ValidationIssue[] {\n const issues: ValidationIssue[] = []\n const looksLikePath = (p: string) => !/\\s/.test(p) && /[/.]/.test(p)\n doc.walkthroughs.forEach((w, wi) =>\n w.scenes.forEach((s, si) =>\n s.proof.forEach((p, pi) => {\n if (!p.source || p.missing || !looksLikePath(p.source)) return\n const at = `walkthroughs.${wi}.scenes.${si}.proof.${pi}`\n const content = source.read(p.source)\n if (content === undefined) return issues.push({ path: `${at}.source`, message: `No file \"${p.source}\" in ${source.label}`, severity: 'error', code: 'proof-not-found', hint: `${pathHint(p.source, source)} Or mark the proof \"missing\": true.` })\n if (p.test && !content.includes(p.test))\n issues.push({ path: `${at}.test`, message: `\"${p.source}\" has no test \"${p.test}\"`, severity: 'error', code: 'proof-not-found', hint: 'Use the test name as it is written in the file.' })\n }),\n ),\n )\n doc.model.entities.forEach((e, ei) =>\n e.sourceRefs.forEach((r, ri) => {\n if (!looksLikePath(r.path)) return\n const at = `model.entities.${ei}.sourceRefs.${ri}`\n const content = source.read(r.path)\n if (content === undefined) {\n // A directory is a fair place to point at, for a module.\n const dir = r.path.replace(/\\/$/, '')\n if (source.files().some((f) => f.startsWith(`${dir}/`))) return\n return issues.push({ path: `${at}.path`, message: `No file or folder \"${r.path}\" in ${source.label}`, severity: 'error', code: 'source-not-found', hint: pathHint(r.path, source) })\n }\n const lines = content.split('\\n')\n if (r.line !== undefined && r.line > lines.length) issues.push({ path: `${at}.line`, message: `\"${r.path}\" has only ${lines.length} lines`, severity: 'error', code: 'source-not-found' })\n if (r.symbol && !content.includes(r.symbol.split(/[.#:]/).pop()!)) issues.push({ path: `${at}.symbol`, message: `\"${r.path}\" does not mention \"${r.symbol}\"`, severity: 'error', code: 'source-not-found', hint: 'Use the name as it is written in the file.' })\n }),\n )\n return issues\n}\n","/**\n * Where this package's files are, the same whether it runs from src/ (in the\n * Poney repository) or from dist/ (installed from npm).\n */\nimport { existsSync, readFileSync } from 'node:fs'\nimport { createRequire } from 'node:module'\nimport { dirname, join, sep } from 'node:path'\nimport { fileURLToPath, pathToFileURL } from 'node:url'\n\nconst here = fileURLToPath(import.meta.url)\n\n/** The package's root folder: the nearest folder up with a package.json. */\nexport const PACKAGE_ROOT = (() => {\n let dir = dirname(here)\n while (!existsSync(join(dir, 'package.json'))) {\n const up = dirname(dir)\n if (up === dir) break\n dir = up\n }\n return dir\n})()\n\nexport const packagePath = (...parts: string[]) => join(PACKAGE_ROOT, ...parts)\n\n/** Running from source, in the repository (not from dist/, installed). */\nexport const fromSource = here.includes(`${sep}src${sep}`)\n\n/**\n * How to start the MCP server. Installed: its bin. In the repository: the\n * source, with the workspace packages' source (\"poney-source\") and tsx,\n * found by absolute path, since an agent may start it in any folder.\n */\nexport function mcpCommand(): { command: string; args: string[] } {\n if (!fromSource) return { command: 'node', args: [packagePath('bin', 'poney-mcp.mjs')] }\n return { command: 'node', args: ['--conditions=poney-source', '--import', tsxLoader(), packagePath('src', 'mcp.ts')] }\n}\n\n/** tsx's loader, as a file URL (its package's \".\" export), so `--import` finds it from any folder. */\nfunction tsxLoader(): string {\n const manifest = createRequire(import.meta.url).resolve('tsx/package.json')\n const target = (JSON.parse(readFileSync(manifest, 'utf8')) as { exports: { '.': string | { import?: string; default?: string } } }).exports['.']\n const entry = typeof target === 'string' ? target : (target.import ?? target.default ?? './dist/loader.mjs')\n return pathToFileURL(join(dirname(manifest), entry)).href\n}\n\n/** The built Studio: inside the package when installed; the Studio app's build in the repository. */\nexport const studioDist = () => (existsSync(packagePath('studio', 'index.html')) ? packagePath('studio') : packagePath('..', '..', 'apps', 'studio', 'dist'))\n","/**\n * The operations behind the CLI and the MCP server: read a document, check\n * it, render a scene, convert Mermaid. Both front ends stay thin.\n */\nimport { readFileSync } from 'node:fs'\nimport { zodToJsonSchema } from 'zod-to-json-schema'\nimport { checkDocument, detectMermaid, formatCheck, fromMermaid, PoneyDocument, toJSON, type CheckResult } from '@hattoriai/poney-core'\nimport { ownership } from '@hattoriai/poney-ext-ownership'\nimport { security } from '@hattoriai/poney-ext-security'\nimport { teamMap } from '@hattoriai/poney-ext-ownership/diagram'\nimport { layoutTeamMap } from '@hattoriai/poney-ext-ownership/layout'\nimport { registerDiagram } from '@hattoriai/poney-react'\nimport { registerExtensionLayout } from '@hattoriai/poney-layout'\nimport { diffFromGit, filesAt, verifyCode, verifyExcerpts, verifySources } from './verify'\nimport { packagePath } from './paths'\n\nexport const EXTENSIONS = [ownership, security]\n\n// The extensions' own diagrams, so headless renders draw their views too.\nregisterDiagram(teamMap)\nregisterExtensionLayout('ownership/team-map', layoutTeamMap)\n\n/** A file of this package, by its path from src/ (the same from dist/). */\nconst here = (p: string) => packagePath(p.replace(/^\\.\\.\\//, ''))\n\n/** What a walkthrough explains: one change, or a codebase as it is. */\nexport type Topic = 'change' | 'tour'\n\n/** The brief that teaches an agent to write a walkthrough: the common guide, then the part for the topic. */\nexport const brief = (topic: Topic = 'change') => `${readFileSync(here('../brief.md'), 'utf8')}\\n\\n${readFileSync(here(`../brief-${topic}.md`), 'utf8')}`\n/** A complete, valid example document for the topic. */\nexport const example = (topic: Topic = 'change') => readFileSync(here(topic === 'tour' ? '../examples/tour.poney' : '../examples/walkthrough.poney'), 'utf8')\n\n/** The JSON Schema of the authoring form: what an agent may write. */\nexport function schema(): object {\n // Cast: the MCP SDK brings its own copy of Zod, and TypeScript cannot compare the two copies.\n return zodToJsonSchema(PoneyDocument as never, { name: 'PoneyDocument', target: 'jsonSchema7', $refStrategy: 'root', definitionPath: 'definitions' })\n}\n\nexport type Input = { document?: unknown; path?: string; text?: string }\n\n/** Reads a document given as an object, as JSON text, or as a file path. Mermaid text is converted. */\nexport function readInput(input: Input): { value?: unknown; error?: string; converted?: string } {\n try {\n let text = input.text\n if (input.path) text = readFileSync(input.path, 'utf8')\n if (input.document !== undefined && typeof input.document !== 'string') return { value: input.document }\n if (typeof input.document === 'string') text = input.document\n if (text === undefined) return { error: 'Give a document, JSON text, or a file path.' }\n const kind = detectMermaid(text)\n if (kind) return { value: fromMermaid(text).document, converted: `Converted from a Mermaid ${kind} diagram.` }\n return { value: JSON.parse(text) }\n } catch (e) {\n return { error: e instanceof Error ? e.message : String(e) }\n }\n}\n\n/** Where to prove the code and tests: a git repository and revision (\"working\" for files on disk), or a diff. */\nexport type Against = { repo?: string; rev?: string; diff?: string }\n\nexport function check(input: Input, against: Against = {}): { result?: CheckResult; report: string } {\n const read = readInput(input)\n if (read.error) return { report: `Cannot read the document: ${read.error}` }\n const result = checkDocument(read.value, { extensions: EXTENSIONS })\n const notes: string[] = []\n if (result.ok && result.document && (against.repo || against.diff)) {\n try {\n const doc = result.document\n const rev = against.rev ?? 'HEAD'\n const files = against.repo ? filesAt(against.repo, rev) : undefined\n const showsChange = doc.walkthroughs.some((w) => w.kind === 'change' && w.scenes.some((s) => s.code.length))\n const found = [\n ...(showsChange ? verifyCode(doc, against.diff ?? diffFromGit(against.repo!, rev), files) : []),\n ...(files ? [...verifyExcerpts(doc, files), ...verifySources(doc, files)] : []),\n ]\n if (found.length) {\n result.errors.push(...found)\n result.ok = false\n } else notes.push(`Code, sources and proof match ${files ? files.label : 'the diff'}.`)\n } catch (e) {\n notes.push(`Could not read the change: ${e instanceof Error ? e.message.split('\\n')[0] : String(e)}`)\n }\n }\n return { result, report: [read.converted, formatCheck(result), ...notes].filter(Boolean).join('\\n') }\n}\n\n/** Short summary of a valid document: what can be rendered. */\nexport function outline(result: CheckResult): string {\n const doc = result.document\n if (!doc) return ''\n return doc.walkthroughs\n .map((w) => {\n const scenes = [w.overview ? 'overview' : undefined, ...w.scenes.map((s) => (s.view ? s.id : `${s.id} (code only)`))].filter(Boolean)\n return `Walkthrough \"${w.id}\": ${w.title}\\n Scenes: ${scenes.join(', ')}`\n })\n .join('\\n')\n}\n\nexport { toJSON }\n\n/**\n * A code excerpt, copied from the file: what a scene's `code` takes. Lines\n * \"from\" to \"to\" (1-based, inclusive) of `path` in `repo` at `rev`.\n */\nexport function excerpt(repo: string, path: string, from: number, to: number, rev = 'HEAD'): { block?: { path: string; start: number; text: string }; error?: string } {\n const files = filesAt(repo, rev)\n const content = files.read(path)\n if (content === undefined) return { error: `No file \"${path}\" in ${files.label}.` }\n const lines = content.split('\\n')\n if (from < 1 || to < from) return { error: 'Give a range like 12-30, first line first.' }\n if (from > lines.length) return { error: `\"${path}\" has ${lines.length} lines.` }\n return { block: { path, start: from, text: lines.slice(from - 1, Math.min(to, lines.length)).join('\\n') } }\n}\n"]}