@kabmo-labs/kabmo 0.46.1 → 0.48.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 (339) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +506 -502
  3. package/dist/client/static/js/Body-3tspyjtk.js +3 -0
  4. package/dist/client/static/js/{CsvGrid-qdkmv8bj.js → CsvGrid-3pwsfmxp.js} +2 -2
  5. package/dist/client/static/js/{DocxView-k84ns803.js → DocxView-xcg9jktb.js} +3 -3
  6. package/dist/client/static/js/{DrawioView-r1n717f7.js → DrawioView-2q19tgkx.js} +2 -2
  7. package/dist/client/static/js/HtmlPreview-92cadvbr.js +1 -0
  8. package/dist/client/static/js/ImageView-pr4h38hb.js +1 -0
  9. package/dist/client/static/js/LayoutWrapper-n4tzhjes.js +2 -0
  10. package/dist/client/static/js/MergeDiffView-0t15nh9f.js +1 -0
  11. package/dist/client/static/js/{Modal-xe6h99jn.js → Modal-77hgx4dw.js} +20 -20
  12. package/dist/client/static/js/{PdfView-ffg4mccg.js → PdfView-gzxhvxe8.js} +1 -1
  13. package/dist/client/static/js/{SessionsView-cdcbsee9.js → SessionsView-2tdqrvk0.js} +1 -1
  14. package/dist/client/static/js/{SheetView-89sscpz6.js → SheetView-w5w2m2de.js} +22 -22
  15. package/dist/client/static/js/{SvgPreview-68c0ccbv.js → SvgPreview-mtk6de6h.js} +1 -1
  16. package/dist/client/static/js/{abnfDiagram-O67JEVCF-h3a5s259.js → abnfDiagram-O67JEVCF-tha4j2fn.js} +1 -1
  17. package/dist/client/static/js/architecture-7GRP2DOG-zs15nydj.js +1 -0
  18. package/dist/client/static/js/{architectureDiagram-NJMV4G6O-983p0jgn.js → architectureDiagram-NJMV4G6O-heep78p6.js} +6 -6
  19. package/dist/client/static/js/{astro-hyj5wege.js → astro-r4dp34pw.js} +1 -1
  20. package/dist/client/static/js/bash-8d3wrx5c.js +1 -0
  21. package/dist/client/static/js/{blockDiagram-BEXU5L5S-16pse5mh.js → blockDiagram-BEXU5L5S-6mzgfqh8.js} +5 -5
  22. package/dist/client/static/js/c-rn3z0csz.js +1 -0
  23. package/dist/client/static/js/{c4Diagram-YGBWAQC7-mvnb00zt.js → c4Diagram-YGBWAQC7-sfkcw7g9.js} +4 -4
  24. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-kmpd91xb.js → classDiagram-v2-NBCMYWYE-v530ny5e.js} +6 -6
  25. package/dist/client/static/js/{cose-bilkent-JH36ORCC-3ek5r5se.js → cose-bilkent-JH36ORCC-ybv1ttbx.js} +1 -1
  26. package/dist/client/static/js/cpp-99ws9nak.js +1 -0
  27. package/dist/client/static/js/css-narcr42w.js +1 -0
  28. package/dist/client/static/js/cynefin-OW5HDTMX-p3y1b4ap.js +1 -0
  29. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-jkbh84zn.js → cynefinDiagram-VND7K2PF-k8f3z0mm.js} +2 -2
  30. package/dist/client/static/js/{dagre-6A5THRUB-4fdc0sgn.js → dagre-6A5THRUB-gk0gp124.js} +2 -2
  31. package/dist/client/static/js/{diagram-22UHCM2B-hbk61nq9.js → diagram-22UHCM2B-2zh2957c.js} +15 -15
  32. package/dist/client/static/js/{diagram-3UASUU5V-hfpbr9qh.js → diagram-3UASUU5V-bzstt5e2.js} +2 -2
  33. package/dist/client/static/js/{diagram-ATOU4E4O-fn0nt71a.js → diagram-ATOU4E4O-16adx4g0.js} +3 -3
  34. package/dist/client/static/js/{diagram-CDSNMT55-ssswxjeb.js → diagram-CDSNMT55-1ja98ens.js} +5 -5
  35. package/dist/client/static/js/{diagram-MLGK6HIB-whnzxv6f.js → diagram-MLGK6HIB-f9nnyjbq.js} +2 -2
  36. package/dist/client/static/js/{diagram-MPIPVDR6-hk1chzxk.js → diagram-MPIPVDR6-3qgadfjz.js} +2 -2
  37. package/dist/client/static/js/{dockerfile-zmsj8r4g.js → dockerfile-04tc68pq.js} +1 -1
  38. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-q1vkg5mr.js → ebnfDiagram-ZINNZB2B-022cz603.js} +1 -1
  39. package/dist/client/static/js/{elixir-80wq7gak.js → elixir-61gbjv6c.js} +1 -1
  40. package/dist/client/static/js/{elk-276RUBZZ-kt98vg8j.js → elk-276RUBZZ-2anf1c36.js} +1 -1
  41. package/dist/client/static/js/{erDiagram-OPXOYQCR-ey3avsn9.js → erDiagram-OPXOYQCR-ndd27fz1.js} +7 -7
  42. package/dist/client/static/js/{erlang-814e8qy5.js → erlang-bh5cbm8m.js} +1 -1
  43. package/dist/client/static/js/eventmodeling-NTZA5JFV-sx2cwkz3.js +1 -0
  44. package/dist/client/static/js/flowDiagram-KWPJA3E3-dsc17mty.js +1 -0
  45. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-a9k1at43.js → ganttDiagram-FUAMR5RP-9gm6hkgn.js} +4 -4
  46. package/dist/client/static/js/gitGraph-4MIJSDKK-yqhbscsd.js +1 -0
  47. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-gnekjfym.js → gitGraphDiagram-X574FWY7-78bxa67c.js} +8 -8
  48. package/dist/client/static/js/graphql-tr0jcndy.js +1 -0
  49. package/dist/client/static/js/html-n8fdvrdk.js +1 -0
  50. package/dist/client/static/js/index-0e51wknc.js +10 -0
  51. package/dist/client/static/js/{index-z25ss7xj.js → index-13g17wa3.js} +1 -1
  52. package/dist/client/static/js/index-1hb8fvw9.js +1 -0
  53. package/dist/client/static/js/{index-1c2jvnyh.js → index-2bsnywea.js} +2 -2
  54. package/dist/client/static/js/{index-g7s0wsag.js → index-2n1fgpjv.js} +2 -2
  55. package/dist/client/static/js/{index-3x7h2eqj.js → index-30a8py59.js} +2 -2
  56. package/dist/client/static/js/{index-qf3y3ahx.js → index-34aq5bz5.js} +2 -2
  57. package/dist/client/static/js/index-3en15m75.js +2 -0
  58. package/dist/client/static/js/{index-nw5mvcaj.js → index-417fbrqk.js} +2 -2
  59. package/dist/client/static/js/{index-z4530r3c.js → index-45p59fxq.js} +2 -2
  60. package/dist/client/static/js/index-4n7t26ap.js +2 -0
  61. package/dist/client/static/js/{index-kty4ncsr.js → index-55pqvh82.js} +2 -2
  62. package/dist/client/static/js/index-5mpv57fn.js +12 -0
  63. package/dist/client/static/js/{index-x9r7zfp4.js → index-7pz6n3pg.js} +2 -2
  64. package/dist/client/static/js/{index-1ax52p0q.js → index-7whstwc7.js} +2 -2
  65. package/dist/client/static/js/index-869vdnz8.js +2 -0
  66. package/dist/client/static/js/{index-fzngzhww.js → index-8tvrzce0.js} +2 -2
  67. package/dist/client/static/js/index-9a78xmkk.js +462 -0
  68. package/dist/client/static/js/{index-33qxg79j.js → index-a58rkn3f.js} +5 -5
  69. package/dist/client/static/js/{index-60v30k5h.js → index-aa3hmn6j.js} +64 -64
  70. package/dist/client/static/js/{index-wrcdc9vz.js → index-aabp7nt6.js} +1 -1
  71. package/dist/client/static/js/{index-64sqfr4a.js → index-abrrqhne.js} +2 -2
  72. package/dist/client/static/js/{index-9vv7wr1n.js → index-ac2q5903.js} +2 -2
  73. package/dist/client/static/js/index-axtm1aq8.js +2 -0
  74. package/dist/client/static/js/index-b2cs4c51.js +4 -0
  75. package/dist/client/static/js/{index-8g7q8mz4.js → index-c250nzm1.js} +3 -3
  76. package/dist/client/static/js/{index-abs635a1.js → index-dxnkwf39.js} +48 -48
  77. package/dist/client/static/js/{index-kbhrvep8.js → index-e6ny4gd9.js} +6 -6
  78. package/dist/client/static/js/index-ebf50mrs.js +9 -0
  79. package/dist/client/static/js/{index-trvqvb1v.js → index-ep6bqcmg.js} +2 -2
  80. package/dist/client/static/js/{index-qfxn7yh5.js → index-fb2s080r.js} +2 -2
  81. package/dist/client/static/js/index-fryp0kgf.js +2 -0
  82. package/dist/client/static/js/{index-2ks0m8ss.js → index-g3rg6vsd.js} +2 -2
  83. package/dist/client/static/js/{index-sa1675y0.js → index-g8rpydkr.js} +2 -2
  84. package/dist/client/static/js/{index-bsr7wmj2.js → index-gkmn4y1v.js} +1 -1
  85. package/dist/client/static/js/{index-xq5f3nxa.js → index-gpmcth0x.js} +2 -2
  86. package/dist/client/static/js/{index-e9cxje00.js → index-hcmhdpp4.js} +10 -10
  87. package/dist/client/static/js/{index-kb14dhrx.js → index-he4k2j91.js} +2 -2
  88. package/dist/client/static/js/{index-wbws16ag.js → index-hq28918s.js} +2 -2
  89. package/dist/client/static/js/{index-84fyq5a6.js → index-hwzxdwwg.js} +1 -1
  90. package/dist/client/static/js/{index-2a6qp9y6.js → index-jnkc9p53.js} +1 -1
  91. package/dist/client/static/js/{index-pavvxrsz.js → index-k39be93q.js} +1 -1
  92. package/dist/client/static/js/{index-c9e417cs.js → index-kaxvwh07.js} +2 -2
  93. package/dist/client/static/js/{index-ykm7a3cp.js → index-kjr68pcj.js} +2 -2
  94. package/dist/client/static/js/{index-b5dfvget.js → index-m0fatq7c.js} +4 -4
  95. package/dist/client/static/js/{index-atq9q1s7.js → index-m39gbcxn.js} +1 -1
  96. package/dist/client/static/js/{index-hnb66d3s.js → index-mqzgf7rw.js} +2 -2
  97. package/dist/client/static/js/{index-5wz0y88c.js → index-pzsp1src.js} +2 -2
  98. package/dist/client/static/js/{index-yf93db65.js → index-qe0vfv6s.js} +1 -1
  99. package/dist/client/static/js/{index-q9ytjey8.js → index-qek9mt5w.js} +1 -1
  100. package/dist/client/static/js/{index-d23eacf2.js → index-qxzj780x.js} +2 -2
  101. package/dist/client/static/js/index-rgxg0azs.css +1 -0
  102. package/dist/client/static/js/{index-m4k054wz.js → index-rq4dk4tp.js} +4 -4
  103. package/dist/client/static/js/{index-fj5rsp5v.js → index-seekt5k3.js} +2 -2
  104. package/dist/client/static/js/{index-561gkvve.js → index-sng4prpr.js} +2 -2
  105. package/dist/client/static/js/{index-vjmg7kn5.js → index-t4s10406.js} +2 -2
  106. package/dist/client/static/js/{index-b2e5pwx7.js → index-tzz5gp8a.js} +5 -5
  107. package/dist/client/static/js/index-vnv9z0a1.js +1 -0
  108. package/dist/client/static/js/{index-19x11s5w.js → index-x7rajphe.js} +2 -2
  109. package/dist/client/static/js/{index-dxvtjn6a.js → index-xny7vsfz.js} +2 -2
  110. package/dist/client/static/js/index-xr4hjv01.js +2 -0
  111. package/dist/client/static/js/{index-65afr75v.js → index-ya9yqj5w.js} +2 -2
  112. package/dist/client/static/js/{index-z0fkfphe.js → index-zcgqacvx.js} +2 -2
  113. package/dist/client/static/js/info-A6RAGUB7-0sd3zzgg.js +1 -0
  114. package/dist/client/static/js/{infoDiagram-VRGFBTTK-r1p25738.js → infoDiagram-VRGFBTTK-bxk0g0pe.js} +2 -2
  115. package/dist/client/static/js/ini-tnaw7zjy.js +1 -0
  116. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-afgrqdrt.js → ishikawaDiagram-OU5B5YK6-d1kdkhth.js} +3 -3
  117. package/dist/client/static/js/java-m4dpc2vw.js +1 -0
  118. package/dist/client/static/js/javascript-8y26t991.js +1 -0
  119. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-hepa4wk7.js → journeyDiagram-ZHPQQLJL-cahg3zjq.js} +4 -4
  120. package/dist/client/static/js/json-azm7bdqd.js +1 -0
  121. package/dist/client/static/js/jsx-p9j1k773.js +1 -0
  122. package/dist/client/static/js/{julia-yv2j8qd0.js → julia-2n5k898q.js} +1 -1
  123. package/dist/client/static/js/{kanban-definition-PNTS6WVX-jysft8ya.js → kanban-definition-PNTS6WVX-nq7t83en.js} +6 -6
  124. package/dist/client/static/js/lua-hbm9rhz9.js +1 -0
  125. package/dist/client/static/js/markdown-tk3cd3vs.js +1 -0
  126. package/dist/client/static/js/{mermaid.core-0m90b0s8.js → mermaid.core-6nw0853j.js} +8 -8
  127. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-x2rrzpvr.js → mindmap-definition-NLK3R4M7-cm7ykxf2.js} +3 -3
  128. package/dist/client/static/js/one-dark-pro-2cdc2nk7.js +1 -0
  129. package/dist/client/static/js/one-light-bt6z4jf0.js +1 -0
  130. package/dist/client/static/js/packet-AYTQ26CC-13w2v5bb.js +1 -0
  131. package/dist/client/static/js/{pegDiagram-GJSIUBJH-z7vb7f1z.js → pegDiagram-GJSIUBJH-xwxz8nsq.js} +1 -1
  132. package/dist/client/static/js/{perl-917pjq5a.js → perl-66vb5pz7.js} +1 -1
  133. package/dist/client/static/js/{php-hwz75qzt.js → php-4e9we8am.js} +1 -1
  134. package/dist/client/static/js/pie-WAS4IAKB-swtnysgn.js +1 -0
  135. package/dist/client/static/js/{pieDiagram-5QR66LMP-jqv6v4e6.js → pieDiagram-5QR66LMP-n910k9th.js} +3 -3
  136. package/dist/client/static/js/properties-6911ckw7.js +1 -0
  137. package/dist/client/static/js/python-44cvj250.js +1 -0
  138. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-w2h8yxrv.js → quadrantDiagram-O4NWA36T-dxkwxbqb.js} +6 -6
  139. package/dist/client/static/js/r-t3sepzm4.js +1 -0
  140. package/dist/client/static/js/radar-RG4KPBEZ-vtvxkx55.js +1 -0
  141. package/dist/client/static/js/railroad-74A4TZTK-5sp2d63r.js +1 -0
  142. package/dist/client/static/js/railroad-abnf-HS5TGJTU-kg706fan.js +1 -0
  143. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-4ra1gzx5.js +1 -0
  144. package/dist/client/static/js/railroad-peg-WCYAUIDC-hms3zpjm.js +1 -0
  145. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-nd09yac3.js → railroadDiagram-XR7U4H2S-xb1smt7r.js} +1 -1
  146. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-t61zxh5v.js → requirementDiagram-PLB6GJNP-6kb21b9f.js} +6 -6
  147. package/dist/client/static/js/{ruby-er7ayhte.js → ruby-v7nmcvyr.js} +1 -1
  148. package/dist/client/static/js/{rust-avnkhh0p.js → rust-5ersd7be.js} +1 -1
  149. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-2f7h2cmw.js → sankeyDiagram-IPEJSGJF-74z0fskw.js} +4 -4
  150. package/dist/client/static/js/{sass-n47tt136.js → sass-h3nvy4c8.js} +1 -1
  151. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-kfb5d7zd.js → sequenceDiagram-PO4LG4MO-apn6kezn.js} +17 -17
  152. package/dist/client/static/js/{sizeCapture-INFHLROL-amfg19se.js → sizeCapture-INFHLROL-2drzcjb8.js} +1 -1
  153. package/dist/client/static/js/sql-zdkawqx3.js +1 -0
  154. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-k5hx7btx.js → stateDiagram-v2-GCMORJYK-ma09vhby.js} +3 -3
  155. package/dist/client/static/js/{svelte-2pmz35vx.js → svelte-dhspkgss.js} +1 -1
  156. package/dist/client/static/js/{swimlanes-2SLR337P-wv3rp8kk.js → swimlanes-2SLR337P-f6y9xqnx.js} +1 -1
  157. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-3dwas56m.js +8 -0
  158. package/dist/client/static/js/{timeline-definition-EJHVYXUP-0re95wtn.js → timeline-definition-EJHVYXUP-zmcmvq00.js} +5 -5
  159. package/dist/client/static/js/treeView-Q6P3EWNA-7t5k6rs2.js +1 -0
  160. package/dist/client/static/js/treemap-WGGIJYW6-w56ry3bg.js +1 -0
  161. package/dist/client/static/js/tsx-b7eabr17.js +1 -0
  162. package/dist/client/static/js/typescript-nnkvhwfy.js +1 -0
  163. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-yrje14qp.js → usecaseDiagram-POWQR4AR-wfaa019a.js} +24 -24
  164. package/dist/client/static/js/{vennDiagram-UO4OBE2U-jxkmrfy5.js → vennDiagram-UO4OBE2U-46wf2pgd.js} +8 -8
  165. package/dist/client/static/js/{vue-d5gpjfgn.js → vue-ffngx2b3.js} +1 -1
  166. package/dist/client/static/js/wardley-WFR3VGLG-rtjb9kgv.js +1 -0
  167. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-d3v2m9b1.js → wardleyDiagram-VNRHLVJA-10ph3bzq.js} +4 -4
  168. package/dist/client/static/js/xml-xy1tw6b2.js +1 -0
  169. package/dist/client/static/js/{xychartDiagram-PMCCYNJV-9a1s1rjt.js → xychartDiagram-PMCCYNJV-2ba825z9.js} +5 -5
  170. package/dist/client/static/js/yaml-0fexqg2d.js +1 -0
  171. package/marketplace/marketplace.json +34 -7
  172. package/marketplace/plugins/kanban/README.md +143 -0
  173. package/marketplace/plugins/kanban/icon.svg +5 -0
  174. package/marketplace/plugins/kanban/package.json +30 -0
  175. package/marketplace/plugins/kanban/src/app.tsx +34 -0
  176. package/marketplace/plugins/kanban/src/mcp-tools.ts +296 -0
  177. package/marketplace/plugins/kanban/src/mcp.test.ts +199 -0
  178. package/marketplace/plugins/kanban/src/mcp.ts +148 -0
  179. package/marketplace/plugins/kanban/src/panel/CardSheet.tsx +319 -0
  180. package/marketplace/plugins/kanban/src/panel/CardTile.tsx +97 -0
  181. package/marketplace/plugins/kanban/src/panel/StageColumn.tsx +116 -0
  182. package/marketplace/plugins/kanban/src/panel/StageSheet.tsx +249 -0
  183. package/marketplace/plugins/kanban/src/panel/catalogs.ts +114 -0
  184. package/marketplace/plugins/kanban/src/panel/index.tsx +327 -0
  185. package/marketplace/plugins/kanban/src/panel/panel.test.ts +219 -0
  186. package/marketplace/plugins/kanban/src/panel/start-work.ts +132 -0
  187. package/marketplace/plugins/kanban/src/panel/use-board.ts +148 -0
  188. package/marketplace/plugins/kanban/src/panel/use-card-detail.ts +70 -0
  189. package/marketplace/plugins/kanban/src/panel/use-writes.ts +123 -0
  190. package/marketplace/plugins/kanban/src/protocol.ts +180 -0
  191. package/marketplace/plugins/kanban/src/server.test.ts +113 -0
  192. package/marketplace/plugins/kanban/src/server.ts +227 -0
  193. package/marketplace/plugins/kanban/src/store/board.test.ts +311 -0
  194. package/marketplace/plugins/kanban/src/store/board.ts +147 -0
  195. package/marketplace/plugins/kanban/src/store/cards.ts +228 -0
  196. package/marketplace/plugins/kanban/src/store/fs.ts +159 -0
  197. package/marketplace/plugins/kanban/src/store/ops.ts +245 -0
  198. package/marketplace/plugins/kanban/src/store/resolve.test.ts +82 -0
  199. package/marketplace/plugins/kanban/src/store/resolve.ts +135 -0
  200. package/marketplace/plugins/kanban/tsconfig.json +26 -0
  201. package/package.json +2 -2
  202. package/src/client/components/common/file-icon/index.tsx +1 -1
  203. package/src/client/components/layout/desktop-layout/LeftColumn.tsx +12 -3
  204. package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +34 -7
  205. package/src/client/components/layout/desktop-layout/index.tsx +17 -22
  206. package/src/client/components/mobile/mobile-right-sidebar/EditorSurface.tsx +2 -0
  207. package/src/client/components/mobile/mobile-right-sidebar/FullEditor.tsx +11 -3
  208. package/src/client/components/settings/categories/appearance-settings/EditorThemeSection.test.tsx +21 -0
  209. package/src/client/components/settings/categories/appearance-settings/EditorThemeSection.tsx +8 -4
  210. package/src/client/components/settings/categories/appearance-settings/ThemeCard.tsx +8 -2
  211. package/src/client/components/settings/categories/appearance-settings/ThemeGrid.tsx +15 -4
  212. package/src/client/components/settings/categories/usage-settings/LimitsSection.tsx +10 -3
  213. package/src/client/components/settings/categories/usage-settings/ProviderDetail.tsx +27 -4
  214. package/src/client/components/settings/categories/usage-settings/TokenHarborCard.tsx +160 -0
  215. package/src/client/components/settings/categories/usage-settings/TokenPortalCard.tsx +104 -0
  216. package/src/client/components/settings/categories/usage-settings/format.ts +35 -0
  217. package/src/client/components/settings/categories/usage-settings/limits-section.test.tsx +16 -0
  218. package/src/client/components/settings/categories/usage-settings/providers.ts +26 -4
  219. package/src/client/components/settings/categories/usage-settings/token-harbor-card.test.tsx +114 -0
  220. package/src/client/components/settings/categories/usage-settings/token-harbor-hint.test.ts +68 -0
  221. package/src/client/components/settings/categories/usage-settings/token-portal-card.test.tsx +81 -0
  222. package/src/client/components/settings/categories/usage-settings/usage-and-picker.test.ts +66 -0
  223. package/src/client/components/workspace/chat-timeline/chat-input/AccessDropdown.test.ts +21 -0
  224. package/src/client/components/workspace/chat-timeline/chat-input/AccessDropdown.tsx +7 -1
  225. package/src/client/components/workspace/chat-timeline/chat-input/ThinkingLevelDropdown.tsx +3 -1
  226. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.tsx +1 -1
  227. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/DiffView.test.ts +13 -0
  228. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/DiffView.tsx +41 -18
  229. package/src/client/components/workspace/editor/BodyLazy.tsx +40 -0
  230. package/src/client/components/workspace/editor/FilePane.tsx +4 -2
  231. package/src/client/components/workspace/editor/Tabs.tsx +7 -1
  232. package/src/client/components/workspace/editor/Toolbar.tsx +7 -1
  233. package/src/client/components/workspace/editor/chrome-rows.test.tsx +126 -0
  234. package/src/client/components/workspace/editor/index.tsx +2 -2
  235. package/src/client/components/workspace/editor/viewers/HtmlPreview.test.tsx +94 -0
  236. package/src/client/components/workspace/editor/viewers/HtmlPreview.tsx +71 -0
  237. package/src/client/components/workspace/editor/viewers/bytes.ts +1 -1
  238. package/src/client/components/workspace/editor/viewers/dispatch.tsx +18 -2
  239. package/src/client/components/workspace/editor/viewers/viewers.test.ts +14 -1
  240. package/src/client/components/workspace/panel-header/index.test.tsx +2 -1
  241. package/src/client/components/workspace/panel-header/index.tsx +6 -4
  242. package/src/client/data/settings/omp-schema.json +33 -10
  243. package/src/client/hooks/editor/resolve-viewer.ts +1 -1
  244. package/src/client/hooks/editor/use-editor-drop.ts +14 -0
  245. package/src/client/hooks/editor/use-editor-tab-state.ts +5 -4
  246. package/src/client/hooks/ui/media-query.ts +27 -0
  247. package/src/client/hooks/workspace/file-tabs.ts +10 -0
  248. package/src/client/hooks/workspace/right-panel-presence.test.ts +152 -0
  249. package/src/client/hooks/workspace/right-panel-presence.ts +119 -0
  250. package/src/client/lib/router/search-params.test.ts +83 -0
  251. package/src/client/lib/router/search-params.ts +14 -3
  252. package/src/server/lib/mcp/session-mcp.test.ts +64 -1
  253. package/src/server/lib/mcp/session-overlay.server.ts +7 -4
  254. package/src/server/lib/omp/rpc/constants.test.ts +31 -0
  255. package/src/server/lib/omp/rpc/constants.ts +19 -0
  256. package/src/server/lib/omp/rpc/session-new.ts +78 -0
  257. package/src/server/lib/omp/rpc/session-registry.ts +22 -49
  258. package/src/server/lib/omp/rpc/spawn-mcp.ts +8 -1
  259. package/src/server/lib/omp/session/blobs.server.ts +2 -1
  260. package/src/server/lib/plugins/e2e.test.ts +71 -2
  261. package/src/server/lib/plugins/loader.server.ts +20 -1
  262. package/src/server/lib/plugins/module-import.server.ts +45 -0
  263. package/src/server/lib/usage/provider-key.ts +18 -0
  264. package/src/server/lib/usage/providers.server.ts +27 -3
  265. package/src/server/lib/usage/report.server.ts +24 -0
  266. package/src/server/lib/usage/token-harbor.test.ts +191 -0
  267. package/src/server/lib/usage/token-harbor.ts +207 -0
  268. package/src/server/lib/usage/token-portal.test.ts +140 -0
  269. package/src/server/lib/usage/token-portal.ts +179 -0
  270. package/src/server/lib/usage/vendor-http.test.ts +52 -0
  271. package/src/server/lib/usage/vendor-http.ts +9 -2
  272. package/src/server/routes/agent/new-prompt.test.ts +81 -0
  273. package/src/server/routes/agent/new.ts +78 -4
  274. package/src/server/routes/fs/raw.test.ts +12 -0
  275. package/src/server/routes/fs/raw.ts +2 -6
  276. package/src/server/routes/wiki/asset.ts +1 -1
  277. package/src/shared/lib/fs/document-kind.test.ts +39 -2
  278. package/src/shared/lib/fs/document-kind.ts +49 -1
  279. package/src/shared/lib/fs/file-kind.test.ts +30 -3
  280. package/src/shared/lib/fs/file-kind.ts +7 -104
  281. package/src/shared/lib/fs/mime.ts +159 -0
  282. package/src/shared/lib/omp/config/schema-releases.test.ts +22 -0
  283. package/src/shared/lib/workspace/sidebar-width.test.ts +34 -0
  284. package/src/shared/lib/workspace/sidebar-width.ts +33 -0
  285. package/src/shared/lib/workspace/workspace-panel-widths.test.ts +124 -0
  286. package/src/shared/lib/workspace/workspace-panel-widths.ts +115 -18
  287. package/src/shared/types/settings/usage.ts +89 -2
  288. package/dist/client/static/js/ImageView-jkrdrq8v.js +0 -1
  289. package/dist/client/static/js/LayoutWrapper-sh634350.js +0 -2
  290. package/dist/client/static/js/architecture-7GRP2DOG-pvb4d65d.js +0 -1
  291. package/dist/client/static/js/bash-8d8z8zrg.js +0 -1
  292. package/dist/client/static/js/c-acmn1zc9.js +0 -1
  293. package/dist/client/static/js/cpp-620mvjkk.js +0 -1
  294. package/dist/client/static/js/css-bt76kxbq.js +0 -1
  295. package/dist/client/static/js/cynefin-OW5HDTMX-gmx4vean.js +0 -1
  296. package/dist/client/static/js/eventmodeling-NTZA5JFV-vrnheyh7.js +0 -1
  297. package/dist/client/static/js/flowDiagram-KWPJA3E3-7gvtpn3d.js +0 -1
  298. package/dist/client/static/js/gitGraph-4MIJSDKK-n6wnc8st.js +0 -1
  299. package/dist/client/static/js/graphql-j1a6zp7m.js +0 -1
  300. package/dist/client/static/js/html-m0megrvb.js +0 -1
  301. package/dist/client/static/js/index-4cag7w6k.js +0 -479
  302. package/dist/client/static/js/index-5ka2tyf9.js +0 -3
  303. package/dist/client/static/js/index-83rkg916.js +0 -2
  304. package/dist/client/static/js/index-amsa0tfs.js +0 -2
  305. package/dist/client/static/js/index-dn7hg4em.js +0 -2
  306. package/dist/client/static/js/index-dpy3ewrn.css +0 -1
  307. package/dist/client/static/js/index-dt6q3rws.js +0 -12
  308. package/dist/client/static/js/index-hgzntg2j.js +0 -2
  309. package/dist/client/static/js/index-vkqb4dnt.js +0 -1
  310. package/dist/client/static/js/index-xwjbq003.js +0 -2
  311. package/dist/client/static/js/info-A6RAGUB7-1xtdxjz2.js +0 -1
  312. package/dist/client/static/js/ini-5f4zqtqr.js +0 -1
  313. package/dist/client/static/js/java-jj41mty3.js +0 -1
  314. package/dist/client/static/js/javascript-n9w9p97f.js +0 -1
  315. package/dist/client/static/js/json-rnh2h17x.js +0 -1
  316. package/dist/client/static/js/jsx-4gecrt29.js +0 -1
  317. package/dist/client/static/js/lua-zszaw2f7.js +0 -1
  318. package/dist/client/static/js/markdown-nm6gw4v4.js +0 -1
  319. package/dist/client/static/js/one-dark-pro-09d8p5vy.js +0 -1
  320. package/dist/client/static/js/one-light-g3ednt6p.js +0 -1
  321. package/dist/client/static/js/packet-AYTQ26CC-zm1r82x5.js +0 -1
  322. package/dist/client/static/js/pie-WAS4IAKB-sqa7321j.js +0 -1
  323. package/dist/client/static/js/properties-rkptax7r.js +0 -1
  324. package/dist/client/static/js/python-qf1se1mj.js +0 -1
  325. package/dist/client/static/js/r-ms0cygq2.js +0 -1
  326. package/dist/client/static/js/radar-RG4KPBEZ-z3z82syp.js +0 -1
  327. package/dist/client/static/js/railroad-74A4TZTK-z6swcqq2.js +0 -1
  328. package/dist/client/static/js/railroad-abnf-HS5TGJTU-33km6py4.js +0 -1
  329. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-1zbf1xmq.js +0 -1
  330. package/dist/client/static/js/railroad-peg-WCYAUIDC-wte1xzzy.js +0 -1
  331. package/dist/client/static/js/sql-hd42h8wx.js +0 -1
  332. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-6y8zdbm4.js +0 -8
  333. package/dist/client/static/js/treeView-Q6P3EWNA-pvgx6n22.js +0 -1
  334. package/dist/client/static/js/treemap-WGGIJYW6-3n9zm628.js +0 -1
  335. package/dist/client/static/js/tsx-gx7td06z.js +0 -1
  336. package/dist/client/static/js/typescript-1a808spn.js +0 -1
  337. package/dist/client/static/js/wardley-WFR3VGLG-7m07ewc4.js +0 -1
  338. package/dist/client/static/js/xml-3117mxd9.js +0 -1
  339. package/dist/client/static/js/yaml-dmvh8vyt.js +0 -1
@@ -0,0 +1,227 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The plugin's server half: the RPC surface the panel calls, the invalidation
8
+ * topic, and the watcher that notices an AGENT's write.
9
+ *
10
+ * The watcher is the half that makes decision 3 visible. An agent moves a card
11
+ * through the MCP child, which is a different process; the panel only learns
12
+ * about it because `cards/` changed and this half publishes a new revision. So
13
+ * the topic carries `{ revision, at }` rather than the board — a 500-card board
14
+ * on every file event would be the socket doing a database's job.
15
+ *
16
+ * Nothing here resolves a model or spawns a session. `resolveAgent` reports the
17
+ * chain and the PANEL calls `/api/agent/new` with it, because that route already
18
+ * owns the fallbacks (project default, persisted pick, approval mode) and a
19
+ * second copy of that rule is how the board and the composer would drift.
20
+ */
21
+
22
+ import fs from 'fs';
23
+ import path from 'path';
24
+ import { fileURLToPath } from 'node:url';
25
+
26
+ import type { KabmoPluginApi } from '@kabmo-labs/kabmo-sdk';
27
+
28
+ import type { BoardSignal, ResolvedAgent } from './protocol';
29
+ import { KanbanError, boardDir, cardsDir } from './store/fs';
30
+ import {
31
+ addCard,
32
+ cardDetail,
33
+ claimCard,
34
+ createBoard,
35
+ linkSession,
36
+ moveCard,
37
+ readBoardState,
38
+ removeCard,
39
+ saveDefaults,
40
+ saveStages,
41
+ updateCard,
42
+ } from './store/ops';
43
+ import { readBoard } from './store/board';
44
+ import { resolveAgent } from './store/resolve';
45
+ import { runMcpServer } from './mcp';
46
+
47
+ /** The debounce a burst of file events collapses into. */
48
+ const WATCH_DEBOUNCE_MS = 150;
49
+
50
+ /**
51
+ * The MCP bootstrap lives HERE, not in the app bundle.
52
+ *
53
+ * `dist/server.js` is the one file built for Bun and spawned as a process, so it
54
+ * is the only place a stdio server can live. `import.meta.main` is what keeps the
55
+ * two uses apart: Kabmo IMPORTS this module as a factory, and an MCP client RUNS
56
+ * it with `--mcp` — without the guard, importing the plugin would start a server
57
+ * on Kabmo's own stdin.
58
+ */
59
+ if (import.meta.main && Bun.argv.includes('--mcp')) {
60
+ // The HOST's data dir, not the board dir: `boardDir()` appends `kanban`, and
61
+ // handing it a board dir would nest a second one.
62
+ const dir = Bun.env.KANBAN_DATA_DIR;
63
+ if (!dir) {
64
+ // Loud, because an empty board is worse than a refusal: a client pointed at
65
+ // the wrong directory would read cards that are not there and act on them.
66
+ process.stderr.write('kanban: KANBAN_DATA_DIR is required when running as an MCP server.\n');
67
+ process.exit(2);
68
+ }
69
+ await runMcpServer(dir);
70
+ }
71
+
72
+ export default function plugin(api: KabmoPluginApi): void {
73
+ const dataDir = api.paths.dataDir;
74
+ let revision = 0;
75
+ api.realtime.seed({ revision: 0, at: new Date().toISOString() } satisfies BoardSignal);
76
+
77
+ const publish = () => {
78
+ revision += 1;
79
+ api.realtime.publish({ revision, at: new Date().toISOString() } satisfies BoardSignal);
80
+ };
81
+
82
+ /** Run an operation, publish, and answer the fresh revision with it. */
83
+ const mutate = async <T>(work: () => Promise<T>): Promise<T & { revision: number }> => {
84
+ const value = await work();
85
+ publish();
86
+ return { ...value, revision: revision + 1 };
87
+ };
88
+
89
+ // `openBoard` answers absence as a VALUE (`exists: false`), because the panel
90
+ // needs to offer Create — and the route re-wraps a thrown refusal as
91
+ // `handler_error`, so a code the client matched on would never arrive.
92
+ api.rpc.register('openBoard', { handler: () => readBoardState(dataDir) });
93
+ api.rpc.register('initBoard', { handler: async () => ({ exists: true, ...(await createBoard(dataDir)) }) });
94
+ api.rpc.register('readCard', {
95
+ handler: async (input) => {
96
+ const { id } = input as { id: string };
97
+ const { card, board } = await cardDetail(dataDir, id);
98
+ const stage = board.stages.find((entry) => entry.id === card.status);
99
+ return { card, board, stage: stage ?? null, agent: resolveAgent(card, stage, board) };
100
+ },
101
+ });
102
+ api.rpc.register('createCard', {
103
+ handler: (input) => mutate(async () => ({ card: await addCard(dataDir, input as never) })),
104
+ });
105
+ api.rpc.register('updateCard', {
106
+ handler: (input) => {
107
+ const { id, patch, baseUpdatedAt } = input as { id: string; patch: never; baseUpdatedAt?: string };
108
+ return mutate(async () => ({ card: await updateCard(dataDir, id, patch, baseUpdatedAt) }));
109
+ },
110
+ });
111
+ api.rpc.register('moveCard', {
112
+ handler: (input) => {
113
+ const { id, status, baseUpdatedAt } = input as { id: string; status: string; baseUpdatedAt?: string };
114
+ return mutate(async () => moveCard(dataDir, id, status, baseUpdatedAt));
115
+ },
116
+ });
117
+ api.rpc.register('deleteCard', {
118
+ handler: (input) => {
119
+ const { id } = input as { id: string };
120
+ return mutate(async () => {
121
+ await removeCard(dataDir, id);
122
+ return {};
123
+ });
124
+ },
125
+ });
126
+ api.rpc.register('linkSession', {
127
+ handler: (input) => {
128
+ const { id, sessionId } = input as { id: string; sessionId: string | null };
129
+ return mutate(async () => ({ card: await linkSession(dataDir, id, sessionId) }));
130
+ },
131
+ });
132
+ api.rpc.register('claimCard', {
133
+ handler: (input) => {
134
+ const { id, sessionId } = input as { id: string; sessionId?: string };
135
+ return mutate(async () => ({ card: await claimCard(dataDir, id, sessionId) }));
136
+ },
137
+ });
138
+ api.rpc.register('saveStages', {
139
+ handler: (input) => {
140
+ const { stages } = input as { stages: never };
141
+ return mutate(async () => ({ board: (await saveStages(dataDir, stages)).board }));
142
+ },
143
+ });
144
+ api.rpc.register('saveDefaults', {
145
+ handler: (input) => {
146
+ const { defaults } = input as { defaults: never };
147
+ return mutate(async () => ({ board: (await saveDefaults(dataDir, defaults)).board }));
148
+ },
149
+ });
150
+ /** The chain, reported so the sheet can name where every field came from. */
151
+ api.rpc.register('resolveAgent', {
152
+ handler: async (input) => {
153
+ const { id } = input as { id: string };
154
+ const { card, board } = await cardDetail(dataDir, id);
155
+ const stage = board.stages.find((entry) => entry.id === card.status);
156
+ return { agent: resolveAgent(card, stage, board) satisfies ResolvedAgent };
157
+ },
158
+ });
159
+ /** The board's defaults and stages, for a sheet that has no card selected. */
160
+ api.rpc.register('readStages', { handler: () => readBoard(dataDir) });
161
+ api.rpc.register('watchTick', {
162
+ // Exposed for the panel's manual Refresh: the same publish a file event does.
163
+ handler: () => {
164
+ publish();
165
+ return { revision };
166
+ },
167
+ });
168
+ /**
169
+ * Watch the board directory.
170
+ *
171
+ * `fs.watch` on the directory (not each file) so a card CREATED by an agent is
172
+ * noticed too. The watcher is best-effort: a platform that cannot watch leaves
173
+ * the panel's Refresh button as the way to catch up, which is stated rather
174
+ * than hidden.
175
+ */
176
+ let watcher: fs.FSWatcher | null = null;
177
+ let timer: ReturnType<typeof setTimeout> | undefined;
178
+ const schedule = () => {
179
+ clearTimeout(timer);
180
+ timer = setTimeout(() => {
181
+ timer = undefined;
182
+ publish();
183
+ }, WATCH_DEBOUNCE_MS);
184
+ };
185
+ try {
186
+ fs.mkdirSync(cardsDir(dataDir), { recursive: true });
187
+ watcher = fs.watch(cardsDir(dataDir), { persistent: false }, schedule);
188
+ } catch (cause) {
189
+ api.log.warn('the board is not being watched; Refresh still re-reads', {
190
+ message: cause instanceof Error ? cause.message : String(cause),
191
+ });
192
+ }
193
+
194
+ api.onDispose(() => {
195
+ clearTimeout(timer);
196
+ watcher?.close();
197
+ watcher = null;
198
+ });
199
+
200
+ /**
201
+ * The agent's tool surface, declared once and delivered by the host.
202
+ *
203
+ * `env` is what makes this work with no `cwd` on a plugin MCP server: the child
204
+ * is TOLD where Kabmo keeps its state instead of guessing from the agent's
205
+ * directory.
206
+ * `fileURLToPath`, not `.pathname`, because the latter yields `/C:/…` on
207
+ * Windows. `--mcp` is the guard `server.ts` checks with `import.meta.main`, so
208
+ * this file is both the plugin and the MCP server.
209
+ */
210
+ api.mcp.register({
211
+ id: 'board',
212
+ transport: 'stdio',
213
+ command: Bun.which('bun') ?? 'bun',
214
+ args: [fileURLToPath(import.meta.url), '--mcp'],
215
+ env: { KANBAN_DATA_DIR: dataDir },
216
+ });
217
+
218
+ api.log.info('kanban server half loaded', { board: boardDir(dataDir) });
219
+ }
220
+
221
+ /** Re-exported so the RPC route can answer a refusal as a value, not a throw. */
222
+ export { KanbanError };
223
+
224
+ /** The card file path, for the panel's "Show file" action. */
225
+ export function cardPath(dataDir: string, id: string): string {
226
+ return path.join(cardsDir(dataDir), `${id}.json`);
227
+ }
@@ -0,0 +1,311 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The store's rules, one per failure that is silent when broken.
8
+ *
9
+ * The board is files another process writes, so the cases that matter are the
10
+ * ones a happy-path test never sees: a card an agent half-wrote, a stage that no
11
+ * longer exists, a card whose folder was deleted, a stale `baseUpdatedAt`, two
12
+ * writers racing the same card, and the promise that a removed plugin does not
13
+ * take the user's board with it.
14
+ */
15
+
16
+ import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
17
+ import fs from 'fs';
18
+ import os from 'os';
19
+ import path from 'path';
20
+
21
+ import {
22
+ MAX_IMAGES,
23
+ MAX_PROMPT_CHARS,
24
+ type Card,
25
+ type Stage,
26
+ } from '../protocol';
27
+ import { KanbanError, boardFile, cardFile, cardsDir } from './fs';
28
+ import { defaultBoard, initBoard, readBoard } from './board';
29
+ import { listCards, mutateCard, readCard, summarize, validateCard } from './cards';
30
+ import {
31
+ addCard,
32
+ claimCard,
33
+ createBoard,
34
+ linkSession,
35
+ moveCard,
36
+ nextCard,
37
+ removeCard,
38
+ saveStages,
39
+ snapshot,
40
+ updateCard,
41
+ } from './ops';
42
+
43
+ let dataDir = '';
44
+
45
+ beforeEach(() => {
46
+ dataDir = fs.mkdtempSync(path.join(os.tmpdir(), 'kanban-store-'));
47
+ });
48
+
49
+ afterEach(() => {
50
+ fs.rmSync(dataDir, { recursive: true, force: true });
51
+ });
52
+
53
+ function refusal(run: () => unknown): KanbanError {
54
+ try {
55
+ const value = run();
56
+ if (value instanceof Promise) {
57
+ // A synchronous helper cannot await; the async callers below catch their
58
+ // own refusals instead.
59
+ throw new Error('expected a synchronous refusal');
60
+ }
61
+ } catch (cause) {
62
+ if (cause instanceof KanbanError) return cause;
63
+ throw cause;
64
+ }
65
+ throw new Error('expected a refusal, got a value');
66
+ }
67
+
68
+ async function asyncRefusal(run: () => Promise<unknown>): Promise<KanbanError> {
69
+ try {
70
+ await run();
71
+ } catch (cause) {
72
+ if (cause instanceof KanbanError) return cause;
73
+ throw cause;
74
+ }
75
+ throw new Error('expected a refusal, got a value');
76
+ }
77
+
78
+ describe('board file', () => {
79
+ test('a fresh board carries the six stages and no overrides', async () => {
80
+ const board = await initBoard(dataDir);
81
+ expect(board.stages.map((stage) => stage.id)).toEqual([
82
+ 'backlog', 'open', 'in_progress', 'review', 'test', 'done',
83
+ ]);
84
+ // Only the two working stages run a session; the rest are planning lanes.
85
+ expect(board.stages.filter((stage) => stage.session).map((stage) => stage.id)).toEqual(['in_progress', 'review']);
86
+ expect(board.defaults).toEqual({});
87
+ });
88
+
89
+ test('init writes a README that names the ABSOLUTE board path', async () => {
90
+ // An agent cannot guess `~/.kabmo`, so the file it reads has to say it.
91
+ await initBoard(dataDir);
92
+ const readme = fs.readFileSync(path.join(dataDir, 'kanban', 'README.md'), 'utf8');
93
+ expect(readme).toContain(path.join(dataDir, 'kanban'));
94
+ expect(readme).toContain('kanban_*');
95
+ });
96
+
97
+ test('a missing board is a no_board refusal, never an empty board', async () => {
98
+ expect((await asyncRefusal(() => snapshot(dataDir))).code).toBe('no_board');
99
+ });
100
+
101
+ test('an unreadable board.json is an io refusal naming the file', async () => {
102
+ fs.mkdirSync(path.join(dataDir, 'kanban'), { recursive: true });
103
+ fs.writeFileSync(boardFile(dataDir), '{ not json');
104
+ const error = await asyncRefusal(() => readBoard(dataDir));
105
+ expect(error.code).toBe('io');
106
+ expect(error.message).toContain('board.json');
107
+ });
108
+
109
+ test('a board whose stages all failed to parse falls back to the defaults', async () => {
110
+ fs.mkdirSync(path.join(dataDir, 'kanban'), { recursive: true });
111
+ fs.writeFileSync(boardFile(dataDir), JSON.stringify({ stages: [{ id: 'Bad Id!' }] }));
112
+ expect((await readBoard(dataDir)).stages.map((stage) => stage.id)).toContain('in_progress');
113
+ });
114
+
115
+ test('creating twice is idempotent', async () => {
116
+ await createBoard(dataDir);
117
+ const second = await createBoard(dataDir);
118
+ expect(second.board.stages.length).toBe(6);
119
+ });
120
+ });
121
+
122
+ describe('cards', () => {
123
+ test('create stamps an id, a workspace and a stage', async () => {
124
+ await initBoard(dataDir);
125
+ const card = await addCard(dataDir, { title: 'Fix it', workspace: '/w', task: { prompt: 'do it' } });
126
+ expect(card.id).toMatch(/^k-[0-9a-f]{6}$/);
127
+ expect(card.workspace).toBe('/w');
128
+ expect(card.status).toBe('open');
129
+ expect(fs.existsSync(cardFile(dataDir, card.id))).toBe(true);
130
+ });
131
+
132
+ test('a card with no workspace is the global bucket, not the server cwd', async () => {
133
+ await initBoard(dataDir);
134
+ const card = await addCard(dataDir, { title: 'Global thing' });
135
+ expect(card.workspace).toBeNull();
136
+ });
137
+
138
+ test('an unknown stage is refused by name', async () => {
139
+ await initBoard(dataDir);
140
+ expect((await asyncRefusal(() => addCard(dataDir, { title: 'x', status: 'nope' }))).message).toContain('nope');
141
+ });
142
+
143
+ test('an update preserves fields the caller did not touch, including unknown ones', async () => {
144
+ await initBoard(dataDir);
145
+ const card = await addCard(dataDir, { title: 'Keep me', task: { prompt: 'p' } });
146
+ // A newer writer's field must survive an older panel's edit.
147
+ const raw = JSON.parse(fs.readFileSync(cardFile(dataDir, card.id), 'utf8')) as Record<string, unknown>;
148
+ fs.writeFileSync(cardFile(dataDir, card.id), JSON.stringify({ ...raw, futureField: { nested: true } }));
149
+
150
+ const updated = await updateCard(dataDir, card.id, { title: 'Renamed' });
151
+ expect(updated.title).toBe('Renamed');
152
+ expect(updated.task.prompt).toBe('p');
153
+ const after = JSON.parse(fs.readFileSync(cardFile(dataDir, card.id), 'utf8')) as Record<string, unknown>;
154
+ expect(after.futureField).toEqual({ nested: true });
155
+ });
156
+
157
+ test('a stale baseUpdatedAt is refused instead of overwriting an agent edit', async () => {
158
+ await initBoard(dataDir);
159
+ const card = await addCard(dataDir, { title: 'Race' });
160
+ const first = await updateCard(dataDir, card.id, { title: 'First' });
161
+ // A stamp from before the last write is stale; the caller must re-read.
162
+ const error = await asyncRefusal(() =>
163
+ updateCard(dataDir, card.id, { title: 'Second' }, card.updatedAt),
164
+ );
165
+ expect(error.code).toBe('stale');
166
+ // And two writes inside one millisecond still differ, or the token is inert.
167
+ const second = await updateCard(dataDir, card.id, { title: 'Second' }, first.updatedAt);
168
+ expect(second.updatedAt > first.updatedAt).toBe(true);
169
+ });
170
+
171
+ test('a bad id is refused before any file is touched', async () => {
172
+ await initBoard(dataDir);
173
+ expect((await asyncRefusal(() => readCard(dataDir, '../../etc/passwd'))).code).toBe('invalid');
174
+ });
175
+
176
+ test('a card file an agent broke is reported with its path, not skipped', async () => {
177
+ await initBoard(dataDir);
178
+ await addCard(dataDir, { title: 'Good' });
179
+ fs.writeFileSync(path.join(cardsDir(dataDir), 'k-abcdef.json'), '{ broken');
180
+ const { cards, errors } = await listCards(dataDir);
181
+ expect(cards).toHaveLength(1);
182
+ expect(errors[0]?.path).toBe('cards/k-abcdef.json');
183
+ });
184
+
185
+ test('summaries carry no prompt and no images', async () => {
186
+ await initBoard(dataDir);
187
+ const card = await addCard(dataDir, {
188
+ title: 'Slim',
189
+ task: { prompt: 'a long task', images: [{ name: 'a.png', mimeType: 'image/png', dataBase64: 'AAAA' }] },
190
+ });
191
+ const summary = summarize(card);
192
+ expect(summary).not.toHaveProperty('task');
193
+ expect(summary.hasPrompt).toBe(true);
194
+ expect(summary.imageCount).toBe(1);
195
+ });
196
+
197
+ test('the prompt and image ceilings are refused, not truncated', async () => {
198
+ const card = {
199
+ schema: 2, id: 'k-abcdef', title: 't', status: 'open', priority: 2, workspace: null,
200
+ task: { prompt: 'x'.repeat(MAX_PROMPT_CHARS + 1), images: [] },
201
+ sessionId: null, createdAt: '', updatedAt: '', movedAt: null,
202
+ } satisfies Card;
203
+ expect(refusal(() => validateCard(card)).message).toContain(String(MAX_PROMPT_CHARS));
204
+
205
+ const images = Array.from({ length: MAX_IMAGES + 1 }, () => ({ name: 'a', mimeType: 'image/png', dataBase64: 'A' }));
206
+ expect(refusal(() => validateCard({ ...card, task: { prompt: '', images } })).message).toContain('images');
207
+ });
208
+
209
+ test('priority outside 0..4 is refused', async () => {
210
+ await initBoard(dataDir);
211
+ expect((await asyncRefusal(() => addCard(dataDir, { title: 'x', priority: 9 }))).code).toBe('invalid');
212
+ });
213
+
214
+ test('delete removes the file and a second delete says not found', async () => {
215
+ await initBoard(dataDir);
216
+ const card = await addCard(dataDir, { title: 'Gone' });
217
+ await removeCard(dataDir, card.id);
218
+ expect(fs.existsSync(cardFile(dataDir, card.id))).toBe(false);
219
+ expect((await asyncRefusal(() => removeCard(dataDir, card.id))).code).toBe('not_found');
220
+ });
221
+
222
+ test('an atomic write leaves no temp file behind', async () => {
223
+ await initBoard(dataDir);
224
+ const card = await addCard(dataDir, { title: 'Clean' });
225
+ await mutateCard(dataDir, card.id, (current) => ({ ...current, title: 'Clean 2' }));
226
+ expect(fs.readdirSync(cardsDir(dataDir)).filter((name) => name.endsWith('.tmp'))).toEqual([]);
227
+ });
228
+ });
229
+
230
+ describe('stages', () => {
231
+ test('a move into a session stage without a link asks for Start work', async () => {
232
+ await initBoard(dataDir);
233
+ const card = await addCard(dataDir, { title: 'Work' });
234
+ const moved = await moveCard(dataDir, card.id, 'in_progress');
235
+ expect(moved.card.status).toBe('in_progress');
236
+ expect(moved.next).toBe('start_work_required');
237
+ });
238
+
239
+ test('a move into a planning stage asks for nothing', async () => {
240
+ await initBoard(dataDir);
241
+ const card = await addCard(dataDir, { title: 'Plan' });
242
+ expect((await moveCard(dataDir, card.id, 'backlog')).next).toBeUndefined();
243
+ });
244
+
245
+ test('a linked card needs no Start work', async () => {
246
+ await initBoard(dataDir);
247
+ const card = await addCard(dataDir, { title: 'Linked' });
248
+ await linkSession(dataDir, card.id, 'sess-1');
249
+ expect((await moveCard(dataDir, card.id, 'in_progress')).next).toBeUndefined();
250
+ });
251
+
252
+ test('claim records the session and lands in the working stage in one write', async () => {
253
+ await initBoard(dataDir);
254
+ const card = await addCard(dataDir, { title: 'Claim me' });
255
+ const claimed = await claimCard(dataDir, card.id, 'sess-9');
256
+ expect(claimed.status).toBe('in_progress');
257
+ expect(claimed.sessionId).toBe('sess-9');
258
+ expect(claimed.movedAt).not.toBeNull();
259
+ });
260
+
261
+ test('a duplicate stage id is refused', async () => {
262
+ await initBoard(dataDir);
263
+ const stages: Stage[] = [...defaultBoard('').stages, { id: 'open', label: 'Again', hidden: false, session: false }];
264
+ expect((await asyncRefusal(() => saveStages(dataDir, stages))).message).toContain('twice');
265
+ });
266
+
267
+ test('a stage id that could not be a filename is refused', async () => {
268
+ await initBoard(dataDir);
269
+ const stages: Stage[] = [{ id: '../escape', label: 'X', hidden: false, session: false }];
270
+ expect((await asyncRefusal(() => saveStages(dataDir, stages))).code).toBe('invalid');
271
+ });
272
+ });
273
+
274
+ describe('next card', () => {
275
+ test('the highest priority card that is not done wins', async () => {
276
+ await initBoard(dataDir);
277
+ await addCard(dataDir, { title: 'Low', priority: 4 });
278
+ const urgent = await addCard(dataDir, { title: 'Urgent', priority: 0 });
279
+ await addCard(dataDir, { title: 'Medium', priority: 2 });
280
+ expect((await nextCard(dataDir))?.id).toBe(urgent.id);
281
+ });
282
+
283
+ test('a done card is never offered', async () => {
284
+ await initBoard(dataDir);
285
+ const card = await addCard(dataDir, { title: 'Finished', priority: 0 });
286
+ await moveCard(dataDir, card.id, 'done');
287
+ await addCard(dataDir, { title: 'Next', priority: 3 });
288
+ expect((await nextCard(dataDir))?.title).toBe('Next');
289
+ });
290
+
291
+ test('a workspace filter only offers that workspace, and null is not a wildcard', async () => {
292
+ await initBoard(dataDir);
293
+ await addCard(dataDir, { title: 'A', workspace: '/a', priority: 0 });
294
+ const b = await addCard(dataDir, { title: 'B', workspace: '/b', priority: 1 });
295
+ expect((await nextCard(dataDir, '/b'))?.id).toBe(b.id);
296
+ await addCard(dataDir, { title: 'Global', priority: 0 });
297
+ expect((await nextCard(dataDir, null))?.title).toBe('Global');
298
+ });
299
+ });
300
+
301
+ describe('removal', () => {
302
+ test('deleting the plugin directory leaves the board alone', async () => {
303
+ // The board lives in the DATA dir, so "remove the plugin" cannot reach it.
304
+ // This is the property that made files win over plugin storage rows.
305
+ await initBoard(dataDir);
306
+ const card = await addCard(dataDir, { title: 'Mine' });
307
+ expect(fs.readFileSync(boardFile(dataDir), 'utf8')).toContain('schema');
308
+ expect(fs.existsSync(cardFile(dataDir, card.id))).toBe(true);
309
+ expect(fs.existsSync(path.join(dataDir, 'kanban', 'src'))).toBe(false);
310
+ });
311
+ });
@@ -0,0 +1,147 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Reading and writing the board: one `board.json` and one file per card.
8
+ *
9
+ * A card file is the unit of change — one card edited is one file written, and a
10
+ * reader never has to parse a list that carries every card's prompt. `listCards`
11
+ * therefore returns SUMMARIES: the panel does not need a prompt to draw a card,
12
+ * and a 500-card board over a socket should not carry 500 prompts.
13
+ *
14
+ * `readCard` keeps the raw record beside the typed view so a write can spread it
15
+ * back: a field a newer writer added survives an older panel's edit, which is
16
+ * what keeps two halves of the plugin (and an agent with a text editor) from
17
+ * silently deleting each other's data.
18
+ */
19
+
20
+ import fs from 'fs';
21
+ import path from 'path';
22
+
23
+ import { DEFAULT_STAGES, STAGE_ID, type Board, type Card, type Stage } from '../protocol';
24
+ import { KanbanError, boardDir, boardFile, messageOf, readJson, withWriteLock, writeJsonAtomic } from './fs';
25
+
26
+ /** A fresh board: the six stages and NO overrides, so every field falls back to the host. */
27
+ export function defaultBoard(now: string): Board {
28
+ return {
29
+ schema: 2,
30
+ // Deliberately empty: naming `omp-rpc` here would freeze a copy of the
31
+ // host's default in a file, and the board would then disagree with the
32
+ // composer the day the host changed its mind.
33
+ defaults: {},
34
+ stages: DEFAULT_STAGES.map((stage) => ({ ...stage })),
35
+ updatedAt: now,
36
+ };
37
+ }
38
+
39
+ /** A JSON object, or `{}` for anything else — the shape every reader folds over. */
40
+ function asRecord(value: unknown): Record<string, unknown> {
41
+ return value && typeof value === 'object' && !Array.isArray(value) ? (value as Record<string, unknown>) : {};
42
+ }
43
+
44
+ function asString(value: unknown): string {
45
+ return typeof value === 'string' ? value : '';
46
+ }
47
+
48
+ function asStringArray(value: unknown): string[] {
49
+ return Array.isArray(value) ? value.filter((entry): entry is string => typeof entry === 'string') : [];
50
+ }
51
+
52
+ /** One stage off disk, refused when its id could not be a filename. */
53
+ function parseStage(raw: unknown): Stage | null {
54
+ const record = asRecord(raw);
55
+ const id = asString(record.id);
56
+ if (!STAGE_ID.test(id)) return null;
57
+ return {
58
+ id,
59
+ label: asString(record.label) || id,
60
+ hidden: record.hidden === true,
61
+ session: record.session === true,
62
+ ...(record.agent !== undefined ? { agent: asRecord(record.agent) as Stage['agent'] } : {}),
63
+ };
64
+ }
65
+
66
+ /**
67
+ * `board.json` as the rest of the plugin uses it, or a `no_board` refusal.
68
+ *
69
+ * An unreadable file is NOT an empty board: reporting "no cards" over a file
70
+ * that failed to parse is how a board silently looks wiped.
71
+ */
72
+ export async function readBoard(dataDir: string): Promise<Board> {
73
+ const file = boardFile(dataDir);
74
+ let parsed: unknown;
75
+ try {
76
+ parsed = await readJson(file);
77
+ } catch (cause) {
78
+ throw new KanbanError('io', `Could not read ${file}: ${messageOf(cause)}`);
79
+ }
80
+ if (parsed === null) throw new KanbanError('no_board', 'No board in this data directory yet.');
81
+ const record = asRecord(parsed);
82
+ const stages = (Array.isArray(record.stages) ? record.stages : [])
83
+ .map(parseStage)
84
+ .filter((stage): stage is Stage => stage !== null);
85
+ return {
86
+ schema: 2,
87
+ defaults: asRecord(record.defaults) as Board['defaults'],
88
+ stages: stages.length > 0 ? stages : defaultBoard(new Date().toISOString()).stages,
89
+ updatedAt: asString(record.updatedAt) || new Date().toISOString(),
90
+ };
91
+ }
92
+
93
+ /** Create the board directory, `board.json` and the agent-facing README. */
94
+ export async function initBoard(dataDir: string): Promise<Board> {
95
+ const board = defaultBoard(new Date().toISOString());
96
+ await withWriteLock(dataDir, async () => {
97
+ await writeJsonAtomic(boardFile(dataDir), board);
98
+ await fs.promises.writeFile(path.join(boardDir(dataDir), 'README.md'), boardReadme(dataDir), 'utf8');
99
+ });
100
+ return board;
101
+ }
102
+
103
+ /** Write the board back (stages, defaults). Callers hold the lock. */
104
+ export async function writeBoard(dataDir: string, board: Board): Promise<void> {
105
+ await writeJsonAtomic(boardFile(dataDir), { ...board, updatedAt: new Date().toISOString() });
106
+ }
107
+
108
+ /** The README an agent reads: it names the absolute path, which is not guessable. */
109
+ function boardReadme(dataDir: string): string {
110
+ const root = boardDir(dataDir);
111
+ return `# Kanban
112
+
113
+ This directory is a task board. One card is one JSON file; the board's stages and
114
+ defaults live in \`board.json\`.
115
+
116
+ - Cards: \`${root}/cards/<id>.json\`
117
+ - Stages: \`${root}/board.json\` → \`stages[]\`
118
+ - Absolute path: \`${root}\`
119
+
120
+ ## Editing a card
121
+
122
+ Read the file, change ONLY the fields you mean to change, write it back. Preserve
123
+ every field you do not understand — a newer writer may have added one.
124
+
125
+ - \`status\` must be a stage id from \`board.json\`.
126
+ - Bump \`updatedAt\` (ISO 8601) and set \`movedAt\` when you change \`status\`.
127
+ - Never write a partial file: write a sibling temp file and rename it over the
128
+ target. Never edit \`board.json\` to move a card.
129
+
130
+ Prefer the \`kanban_*\` MCP tools when they are available: they take the write
131
+ lock and validate the stage for you.
132
+ `;
133
+ }
134
+
135
+ /** The parsers the card module reuses, so both files read one set of rules. */
136
+ export { asRecord, asString, asStringArray };
137
+
138
+ /** Stages by id, for the callers that resolve a card's stage. */
139
+ export function stageOf(board: Board, id: string): Stage | undefined {
140
+ return board.stages.find((stage) => stage.id === id);
141
+ }
142
+
143
+ /** The stage a card belongs to for display: its own, or undefined when orphaned. */
144
+ export function cardStage(board: Board, card: Card): Stage | undefined {
145
+ return stageOf(board, card.status);
146
+ }
147
+