@kabmo-labs/kabmo 0.36.0 → 0.38.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 (292) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +547 -528
  3. package/dist/client/static/js/{CsvGrid-1h3bcak7.js → CsvGrid-90zfbn7f.js} +2 -2
  4. package/dist/client/static/js/{DocxView-ndca8jch.js → DocxView-vwq2rf16.js} +2 -2
  5. package/dist/client/static/js/{DrawioView-kpzd6y0b.js → DrawioView-bvx7eqcz.js} +2 -2
  6. package/dist/client/static/js/{ImageView-79prn3dg.js → ImageView-q6xfmbrq.js} +1 -1
  7. package/dist/client/static/js/{LayoutWrapper-v2wn2sb2.js → LayoutWrapper-qatdaw3n.js} +2 -2
  8. package/dist/client/static/js/{Modal-99j0zz3z.js → Modal-6jx1fvfb.js} +15 -15
  9. package/dist/client/static/js/{PdfView-2rjd87ay.js → PdfView-tkv2d2zs.js} +1 -1
  10. package/dist/client/static/js/{SessionsView-t7f3s71b.js → SessionsView-rbnecykz.js} +1 -1
  11. package/dist/client/static/js/{SheetView-ehb976st.js → SheetView-t08g8kdr.js} +4 -4
  12. package/dist/client/static/js/{SvgPreview-de2bbba6.js → SvgPreview-9vh6mdcp.js} +1 -1
  13. package/dist/client/static/js/{abnfDiagram-O67JEVCF-nx9jzn7m.js → abnfDiagram-O67JEVCF-bxcn33e1.js} +1 -1
  14. package/dist/client/static/js/architecture-7GRP2DOG-r8sz34h3.js +1 -0
  15. package/dist/client/static/js/{architectureDiagram-NJMV4G6O-170v67rr.js → architectureDiagram-NJMV4G6O-40ggw6e8.js} +2 -2
  16. package/dist/client/static/js/{astro-80bs6hvg.js → astro-p3f5p9p2.js} +1 -1
  17. package/dist/client/static/js/{blockDiagram-BEXU5L5S-16q285n1.js → blockDiagram-BEXU5L5S-k41cvjrd.js} +6 -6
  18. package/dist/client/static/js/c-jkdstn33.js +1 -0
  19. package/dist/client/static/js/{c4Diagram-YGBWAQC7-rn3qt45h.js → c4Diagram-YGBWAQC7-rdcmn6ac.js} +2 -2
  20. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-r26wg74e.js → classDiagram-v2-NBCMYWYE-txbmbkxv.js} +5 -5
  21. package/dist/client/static/js/{cose-bilkent-JH36ORCC-82kwe7ha.js → cose-bilkent-JH36ORCC-bxzh3qj1.js} +1 -1
  22. package/dist/client/static/js/cpp-9d3xdpe3.js +1 -0
  23. package/dist/client/static/js/css-r3wja1ze.js +1 -0
  24. package/dist/client/static/js/css-sebxkh5f.js +1 -0
  25. package/dist/client/static/js/cynefin-OW5HDTMX-w2f2vev7.js +1 -0
  26. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-tcxdn6pa.js → cynefinDiagram-VND7K2PF-abx5343b.js} +1 -1
  27. package/dist/client/static/js/{dagre-6A5THRUB-g833ata3.js → dagre-6A5THRUB-baj278kt.js} +2 -2
  28. package/dist/client/static/js/{diagram-22UHCM2B-f1fq8xec.js → diagram-22UHCM2B-vqvhdc5m.js} +7 -7
  29. package/dist/client/static/js/{diagram-3UASUU5V-6j2w016f.js → diagram-3UASUU5V-w328rfx0.js} +2 -2
  30. package/dist/client/static/js/{diagram-ATOU4E4O-6t2qxsk4.js → diagram-ATOU4E4O-zzcmwnm8.js} +2 -2
  31. package/dist/client/static/js/{diagram-CDSNMT55-7abar8s7.js → diagram-CDSNMT55-8yw39mmj.js} +1 -1
  32. package/dist/client/static/js/{diagram-MLGK6HIB-s68rgy16.js → diagram-MLGK6HIB-zgc386pv.js} +1 -1
  33. package/dist/client/static/js/{diagram-MPIPVDR6-azgkm6w8.js → diagram-MPIPVDR6-efmvvscm.js} +1 -1
  34. package/dist/client/static/js/{dockerfile-47e33kqa.js → dockerfile-bp5dre33.js} +1 -1
  35. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-esrjz750.js → ebnfDiagram-ZINNZB2B-p66h0dzq.js} +1 -1
  36. package/dist/client/static/js/{elixir-rpa1g4gy.js → elixir-jwphgp8j.js} +1 -1
  37. package/dist/client/static/js/{elk-276RUBZZ-fhr4b4jj.js → elk-276RUBZZ-g0jjxcqd.js} +1 -1
  38. package/dist/client/static/js/{erDiagram-OPXOYQCR-5r3fmdnz.js → erDiagram-OPXOYQCR-39gat96z.js} +4 -4
  39. package/dist/client/static/js/{erlang-bh5cbm8m.js → erlang-6m6tpt72.js} +1 -1
  40. package/dist/client/static/js/eventmodeling-NTZA5JFV-k5n61zzh.js +1 -0
  41. package/dist/client/static/js/flowDiagram-KWPJA3E3-f6jpcqyq.js +1 -0
  42. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-j4pf6rdn.js → ganttDiagram-FUAMR5RP-nsjv1zt4.js} +2 -2
  43. package/dist/client/static/js/gitGraph-4MIJSDKK-2gf053bx.js +1 -0
  44. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-x5epk0gr.js → gitGraphDiagram-X574FWY7-r4vnkcy3.js} +2 -2
  45. package/dist/client/static/js/graphql-p4cskvad.js +1 -0
  46. package/dist/client/static/js/html-f26r6vv5.js +1 -0
  47. package/dist/client/static/js/{index-c1j0xb0w.js → index-0kxqzafy.js} +1 -1
  48. package/dist/client/static/js/{index-3kgrcaq1.js → index-11bdd235.js} +1 -1
  49. package/dist/client/static/js/{index-b48p8d1j.js → index-1qszrvzk.js} +2 -2
  50. package/dist/client/static/js/{index-3vdmwpbh.js → index-24yyj78e.js} +2 -2
  51. package/dist/client/static/js/{index-63c6t75t.js → index-2drjp9ks.js} +1 -1
  52. package/dist/client/static/js/{index-d2km9egp.js → index-2ndq1ngv.js} +4 -4
  53. package/dist/client/static/js/{index-0j518hqm.js → index-3az1w5f8.js} +2 -2
  54. package/dist/client/static/js/{index-ye450a7z.js → index-50z4ek83.js} +1 -1
  55. package/dist/client/static/js/{index-60ceydzn.js → index-5ebhb94w.js} +1 -1
  56. package/dist/client/static/js/{index-ctgefatv.js → index-5y0bvq4q.js} +34 -34
  57. package/dist/client/static/js/{index-40ve7zzv.js → index-6ax2z70w.js} +1 -1
  58. package/dist/client/static/js/{index-9t82sx0w.js → index-6k3e5dph.js} +2 -2
  59. package/dist/client/static/js/{index-6xzfta4b.js → index-73jwm4d5.js} +1 -1
  60. package/dist/client/static/js/{index-8cy3x2y8.js → index-7fdp9c7m.js} +2 -2
  61. package/dist/client/static/js/{index-zvfvqvn9.js → index-9wd9y6m0.js} +2 -2
  62. package/dist/client/static/js/{index-q5t4sy22.js → index-9wtg6ywn.js} +4 -4
  63. package/dist/client/static/js/{index-nws03exw.js → index-a74k07z2.js} +2 -2
  64. package/dist/client/static/js/{index-982jyfsb.js → index-ashpbfqv.js} +2 -2
  65. package/dist/client/static/js/{index-zp73zexp.js → index-b9b2nwdd.js} +2 -2
  66. package/dist/client/static/js/{index-h1e1abpt.js → index-c15r8jd3.js} +2 -2
  67. package/dist/client/static/js/{index-5rzk1226.js → index-da10qpns.js} +2 -2
  68. package/dist/client/static/js/{index-ky0prc71.js → index-dfgdn3fj.js} +9 -9
  69. package/dist/client/static/js/{index-c09a5s1n.js → index-dkseg29t.js} +9 -9
  70. package/dist/client/static/js/{index-w3n97x4b.js → index-dt7e1328.js} +2 -2
  71. package/dist/client/static/js/{index-sar2ggde.js → index-e1pr3k50.js} +2 -2
  72. package/dist/client/static/js/{index-0b1kwsam.js → index-fghst0kd.js} +32 -32
  73. package/dist/client/static/js/{index-af24nes6.js → index-gbfg0anm.js} +2 -2
  74. package/dist/client/static/js/{index-vtbbfwx0.js → index-gr6jng0x.js} +2 -2
  75. package/dist/client/static/js/{index-44qrckd2.js → index-gwhx66f4.js} +1 -1
  76. package/dist/client/static/js/{index-55pqvh82.js → index-h7pn9qw6.js} +2 -2
  77. package/dist/client/static/js/{index-97t3mv1v.js → index-h8h5c2r8.js} +1 -1
  78. package/dist/client/static/js/{index-v5t761a1.js → index-ha75kff0.js} +2 -2
  79. package/dist/client/static/js/{index-ydvfc9td.js → index-hzx81cjq.js} +4 -4
  80. package/dist/client/static/js/{index-be6gevq8.js → index-k9xsvab3.js} +1 -1
  81. package/dist/client/static/js/{index-v8qd8ypc.js → index-nd4p98mc.js} +2 -2
  82. package/dist/client/static/js/{index-dmgawfhw.js → index-qkscve6n.js} +2 -2
  83. package/dist/client/static/js/{index-w7xbfv44.js → index-qn4pkjfh.js} +2 -2
  84. package/dist/client/static/js/{index-zdtsvnpq.js → index-r83kr4s5.js} +2 -2
  85. package/dist/client/static/js/{index-htt8qxm3.js → index-ra38ggke.js} +1 -1
  86. package/dist/client/static/js/{index-skm6k5w2.js → index-rf0p3v7q.js} +5 -5
  87. package/dist/client/static/js/{index-7r1hw2gd.js → index-rgp69pa8.js} +1 -1
  88. package/dist/client/static/js/{index-8e15fzax.js → index-rqrcw8nj.js} +2 -2
  89. package/dist/client/static/js/{index-63jbb4kf.js → index-sa9cp6km.js} +2 -2
  90. package/dist/client/static/js/{index-75haaj8g.js → index-st202rjv.js} +184 -184
  91. package/dist/client/static/js/{index-mm1rf116.js → index-t5t71dhp.js} +2 -2
  92. package/dist/client/static/js/{index-ktvbsj6w.js → index-tfsaj5d1.js} +2 -2
  93. package/dist/client/static/js/{index-k1xt92h4.js → index-tv61v3t3.js} +1 -1
  94. package/dist/client/static/js/index-tzm90bsz.js +1 -0
  95. package/dist/client/static/js/{index-z6g74h7g.js → index-vb6t44dw.js} +2 -2
  96. package/dist/client/static/js/{index-pyx8n25s.js → index-vnn7m9yp.js} +3 -3
  97. package/dist/client/static/js/{index-5kjpacvd.js → index-vxd4gykh.js} +2 -2
  98. package/dist/client/static/js/{index-r8pckaqe.js → index-xya34x4v.js} +2 -2
  99. package/dist/client/static/js/{index-a293pdg7.js → index-y3hdv561.js} +2 -2
  100. package/dist/client/static/js/{index-9gf8b73w.js → index-z0cpp5bc.js} +2 -2
  101. package/dist/client/static/js/info-A6RAGUB7-3tr0y3s6.js +1 -0
  102. package/dist/client/static/js/{infoDiagram-VRGFBTTK-ktc8nb8g.js → infoDiagram-VRGFBTTK-e39pvm4j.js} +1 -1
  103. package/dist/client/static/js/ini-cg0a5wm3.js +1 -0
  104. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-n3dk6227.js → ishikawaDiagram-OU5B5YK6-rqhszgvp.js} +2 -2
  105. package/dist/client/static/js/java-vcck089n.js +1 -0
  106. package/dist/client/static/js/javascript-nyf39d5r.js +1 -0
  107. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-f0p1h8qn.js → journeyDiagram-ZHPQQLJL-wgy5qrsv.js} +3 -3
  108. package/dist/client/static/js/jsx-ht9zyzwa.js +1 -0
  109. package/dist/client/static/js/{julia-73zjh2w6.js → julia-237yk557.js} +1 -1
  110. package/dist/client/static/js/{kanban-definition-PNTS6WVX-7jdt7dv1.js → kanban-definition-PNTS6WVX-b8bxn0h1.js} +3 -3
  111. package/dist/client/static/js/lua-86fjqj8v.js +1 -0
  112. package/dist/client/static/js/markdown-gwmsh53r.js +1 -0
  113. package/dist/client/static/js/{mermaid.core-e8rzrjt9.js → mermaid.core-vb5ehtre.js} +6 -6
  114. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-7shv6ge0.js → mindmap-definition-NLK3R4M7-t4p38s38.js} +3 -3
  115. package/dist/client/static/js/one-dark-pro-dhybn1ff.js +1 -0
  116. package/dist/client/static/js/one-light-bqg77ay0.js +1 -0
  117. package/dist/client/static/js/packet-AYTQ26CC-xbsyjzrh.js +1 -0
  118. package/dist/client/static/js/{pegDiagram-GJSIUBJH-17ak2zx3.js → pegDiagram-GJSIUBJH-3gp4madx.js} +1 -1
  119. package/dist/client/static/js/{perl-8z46dmze.js → perl-dvz4y1tb.js} +1 -1
  120. package/dist/client/static/js/{php-6qvnp2t6.js → php-n6y7dzhm.js} +1 -1
  121. package/dist/client/static/js/pie-WAS4IAKB-j2tpz0cs.js +1 -0
  122. package/dist/client/static/js/{pieDiagram-5QR66LMP-at4x1g4q.js → pieDiagram-5QR66LMP-0cbm773h.js} +2 -2
  123. package/dist/client/static/js/properties-mzvvbqg5.js +1 -0
  124. package/dist/client/static/js/python-3w64wsyd.js +1 -0
  125. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-apzhwrn4.js → quadrantDiagram-O4NWA36T-jwg7fc9f.js} +1 -1
  126. package/dist/client/static/js/r-32re2zwb.js +1 -0
  127. package/dist/client/static/js/radar-RG4KPBEZ-m3tsyfv0.js +1 -0
  128. package/dist/client/static/js/railroad-74A4TZTK-5p202a4q.js +1 -0
  129. package/dist/client/static/js/railroad-abnf-HS5TGJTU-hj0y9tgn.js +1 -0
  130. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-8c5dct8f.js +1 -0
  131. package/dist/client/static/js/railroad-peg-WCYAUIDC-3tx8z65q.js +1 -0
  132. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-rw8cj5f3.js → railroadDiagram-XR7U4H2S-38xh691s.js} +1 -1
  133. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-qyrse7mb.js → requirementDiagram-PLB6GJNP-gpddawxh.js} +4 -4
  134. package/dist/client/static/js/{ruby-qy8mhstq.js → ruby-7zye3g0e.js} +1 -1
  135. package/dist/client/static/js/{rust-fpshqnk0.js → rust-bx3ecv4n.js} +1 -1
  136. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-254qr59q.js → sankeyDiagram-IPEJSGJF-s6t6bbhk.js} +1 -1
  137. package/dist/client/static/js/{sass-kbwea482.js → sass-m0h9yzfb.js} +1 -1
  138. package/dist/client/static/js/{scss-zphrqp25.js → scss-2pwwfkvn.js} +1 -1
  139. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-y9xjxfc5.js → sequenceDiagram-PO4LG4MO-wkq51pmb.js} +3 -3
  140. package/dist/client/static/js/{sizeCapture-INFHLROL-sc5e60t3.js → sizeCapture-INFHLROL-xtwexf8k.js} +1 -1
  141. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-r134s4xr.js → stateDiagram-v2-GCMORJYK-jnwsqa7y.js} +3 -3
  142. package/dist/client/static/js/{svelte-mwtx07d9.js → svelte-x8f8c8hq.js} +1 -1
  143. package/dist/client/static/js/{swimlanes-2SLR337P-xc7rbawt.js → swimlanes-2SLR337P-mnkkqcbx.js} +1 -1
  144. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-6xmrz03n.js +8 -0
  145. package/dist/client/static/js/{timeline-definition-EJHVYXUP-cgjd8shk.js → timeline-definition-EJHVYXUP-rxq6heqh.js} +2 -2
  146. package/dist/client/static/js/treeView-Q6P3EWNA-mf0rb2yv.js +1 -0
  147. package/dist/client/static/js/treemap-WGGIJYW6-0x5gf06b.js +1 -0
  148. package/dist/client/static/js/typescript-5nmrzgkj.js +1 -0
  149. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-9qsmjhm6.js → usecaseDiagram-POWQR4AR-dz94f57t.js} +13 -13
  150. package/dist/client/static/js/{vennDiagram-UO4OBE2U-4grw9awx.js → vennDiagram-UO4OBE2U-5mmvkhsq.js} +1 -1
  151. package/dist/client/static/js/{vue-j8vb9d7r.js → vue-myjjd0gd.js} +1 -1
  152. package/dist/client/static/js/wardley-WFR3VGLG-x7ej8dms.js +1 -0
  153. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-8gxy0wat.js → wardleyDiagram-VNRHLVJA-dctdntpa.js} +1 -1
  154. package/dist/client/static/js/xml-3dd1pter.js +1 -0
  155. package/dist/client/static/js/{xychartDiagram-PMCCYNJV-5sh7tdrx.js → xychartDiagram-PMCCYNJV-njyfrqkv.js} +2 -2
  156. package/dist/client/static/js/yaml-yssayv8a.js +1 -0
  157. package/package.json +1 -1
  158. package/src/client/components/common/ComposerPicker.tsx +24 -12
  159. package/src/client/components/common/ComposerTextarea.tsx +1 -0
  160. package/src/client/components/layout/session-sidebar/scheduler-modal/ModelFields.tsx +1 -1
  161. package/src/client/components/settings/apply-side-effects.test.ts +5 -4
  162. package/src/client/components/workspace/chat-timeline/chat-input/index.tsx +1 -1
  163. package/src/client/components/workspace/chat-timeline/index.tsx +3 -3
  164. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FormAsk.test.tsx +210 -0
  165. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FormAsk.tsx +342 -0
  166. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/LooseFieldAsk.tsx +44 -0
  167. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/OrphanAsks.test.tsx +44 -1
  168. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/OrphanAsks.tsx +10 -5
  169. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/PluginPendingInteractions.test.ts +1 -0
  170. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/drafts.ts +19 -0
  171. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/form-picks.ts +52 -0
  172. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/index.test.ts +2 -2
  173. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/index.tsx +53 -4
  174. package/src/client/components/workspace/model-dropdown/index.tsx +1 -1
  175. package/src/client/components/workspace/model-dropdown/use-catalog.ts +3 -32
  176. package/src/client/data/settings/omp-schema.json +55 -1
  177. package/src/client/hooks/chat/composer/harness-model-picker.ts +84 -0
  178. package/src/client/hooks/chat/composer/index.ts +26 -6
  179. package/src/client/hooks/chat/timeline/ask-frames.test.ts +80 -7
  180. package/src/client/hooks/chat/timeline/ask-frames.ts +95 -21
  181. package/src/client/hooks/models/use-harnesses.ts +15 -2
  182. package/src/client/hooks/ui/icon-style.ts +7 -4
  183. package/src/client/hooks/ui/style-attributes.test.ts +11 -11
  184. package/src/client/hooks/ui/surface-style.ts +8 -5
  185. package/src/server/lib/assets/shell-attributes.server.ts +12 -9
  186. package/src/server/lib/assets/shell-attributes.test.ts +18 -13
  187. package/src/server/lib/auth/agent-gate.server.ts +64 -0
  188. package/src/server/lib/auth/agent-tree-gate.test.ts +121 -0
  189. package/src/server/lib/auth/guard.test.ts +18 -18
  190. package/src/server/lib/auth/guard.ts +15 -11
  191. package/src/server/lib/auth/handover-guard.test.ts +1 -1
  192. package/src/server/lib/changes/attach.server.ts +57 -0
  193. package/src/server/lib/changes/attach.test.ts +94 -0
  194. package/src/server/lib/changes/blobs.server.ts +52 -0
  195. package/src/server/lib/changes/capture-bash.server.ts +106 -0
  196. package/src/server/lib/changes/capture-fs.server.ts +64 -0
  197. package/src/server/lib/changes/capture-runs.test.ts +136 -0
  198. package/src/server/lib/changes/capture-test-util.ts +46 -0
  199. package/src/server/lib/changes/capture-types.ts +62 -0
  200. package/src/server/lib/changes/capture.server.ts +333 -0
  201. package/src/server/lib/changes/capture.test.ts +245 -0
  202. package/src/server/lib/changes/classify-command.test.ts +172 -0
  203. package/src/server/lib/changes/classify-command.ts +272 -0
  204. package/src/server/lib/changes/classify-git.ts +88 -0
  205. package/src/server/lib/changes/classify-paths.ts +112 -0
  206. package/src/server/lib/changes/classify-tokenize.ts +185 -0
  207. package/src/server/lib/changes/journal.server.ts +183 -0
  208. package/src/server/lib/changes/journal.test.ts +125 -0
  209. package/src/server/lib/changes/merge.test.ts +137 -0
  210. package/src/server/lib/changes/paths.server.ts +37 -0
  211. package/src/server/lib/changes/purge.server.ts +32 -0
  212. package/src/server/lib/changes/reader.server.ts +322 -0
  213. package/src/server/lib/changes/reader.test.ts +137 -0
  214. package/src/server/lib/changes/records.ts +120 -0
  215. package/src/server/lib/changes/scan.server.ts +89 -0
  216. package/src/server/lib/harness/register.server.ts +3 -0
  217. package/src/server/lib/omp/rpc/event-fanout.test.ts +58 -0
  218. package/src/server/lib/omp/rpc/event-fanout.ts +19 -0
  219. package/src/server/lib/omp/rpc/manager.ts +4 -3
  220. package/src/server/lib/omp/rpc/session-registration.ts +5 -0
  221. package/src/server/lib/omp/rpc/session-registry.ts +4 -5
  222. package/src/server/lib/omp/session/delete.server.ts +4 -0
  223. package/src/server/lib/sessions/agent-token.server.test.ts +28 -5
  224. package/src/server/lib/sessions/agent-token.server.ts +42 -6
  225. package/src/server/lib/sessions/relation-access.server.test.ts +96 -0
  226. package/src/server/lib/sessions/relation-access.server.ts +71 -0
  227. package/src/server/routes/sessions/changes.ts +1 -1
  228. package/src/shared/lib/chat/ask-form/fields.ts +1 -0
  229. package/src/shared/lib/chat/ask-form/types.ts +6 -0
  230. package/src/shared/lib/chat/ask-questions.ts +56 -3
  231. package/src/shared/lib/chat/composer/delegation.ts +2 -13
  232. package/src/shared/lib/chat/composer/filter.test.ts +39 -0
  233. package/src/shared/lib/chat/composer/filter.ts +23 -13
  234. package/src/shared/lib/chat/composer/harness-model-items.test.ts +54 -0
  235. package/src/shared/lib/chat/composer/harness-model-items.ts +41 -0
  236. package/src/shared/lib/chat/composer/trigger.test.ts +50 -0
  237. package/src/shared/lib/chat/composer/trigger.ts +29 -1
  238. package/src/shared/lib/chat/timeline/changed-files.test.ts +16 -0
  239. package/src/shared/lib/chat/timeline/changed-files.ts +102 -25
  240. package/src/shared/lib/harness/catalog.ts +21 -0
  241. package/src/{client/components/workspace/model-dropdown/harness-models.test.ts → shared/lib/harness/models.test.ts} +1 -1
  242. package/src/shared/lib/icons/icon-paint-authority.ts +5 -3
  243. package/src/shared/lib/models/option.ts +46 -0
  244. package/src/shared/lib/omp/config/schema.test.ts +20 -0
  245. package/src/shared/lib/theme/icon-style.test.ts +8 -5
  246. package/src/shared/lib/theme/icon-style.ts +15 -7
  247. package/src/shared/lib/theme/surface-style.test.ts +8 -5
  248. package/src/shared/lib/theme/surface-style.ts +17 -7
  249. package/src/shared/lib/workspace/sidebar-style.test.ts +7 -8
  250. package/src/shared/lib/workspace/sidebar-style.ts +7 -8
  251. package/src/shared/types/chat.ts +12 -6
  252. package/src/shared/types/omp/agent.ts +9 -0
  253. package/src/shared/types/session-changes.ts +4 -0
  254. package/dist/client/static/js/architecture-7GRP2DOG-aqft2erp.js +0 -1
  255. package/dist/client/static/js/c-wkgxb1t1.js +0 -1
  256. package/dist/client/static/js/cpp-y0t6mynx.js +0 -1
  257. package/dist/client/static/js/css-r2nhvzff.js +0 -1
  258. package/dist/client/static/js/css-tf1s0nb7.js +0 -1
  259. package/dist/client/static/js/cynefin-OW5HDTMX-v2sz60t6.js +0 -1
  260. package/dist/client/static/js/eventmodeling-NTZA5JFV-8qbefe4m.js +0 -1
  261. package/dist/client/static/js/flowDiagram-KWPJA3E3-krsvgcq7.js +0 -1
  262. package/dist/client/static/js/gitGraph-4MIJSDKK-9bx1a38k.js +0 -1
  263. package/dist/client/static/js/graphql-xnpp5gn9.js +0 -1
  264. package/dist/client/static/js/html-pv88ny12.js +0 -1
  265. package/dist/client/static/js/index-dh1vd0d9.js +0 -1
  266. package/dist/client/static/js/info-A6RAGUB7-j51t7jhh.js +0 -1
  267. package/dist/client/static/js/ini-ygfyhprj.js +0 -1
  268. package/dist/client/static/js/java-gm49vw59.js +0 -1
  269. package/dist/client/static/js/javascript-4kw2j9t3.js +0 -1
  270. package/dist/client/static/js/jsx-ksxw1byz.js +0 -1
  271. package/dist/client/static/js/lua-53gzb9bx.js +0 -1
  272. package/dist/client/static/js/markdown-tk3cd3vs.js +0 -1
  273. package/dist/client/static/js/one-dark-pro-39bt34v9.js +0 -1
  274. package/dist/client/static/js/one-light-xec0sehr.js +0 -1
  275. package/dist/client/static/js/packet-AYTQ26CC-n83gfj2g.js +0 -1
  276. package/dist/client/static/js/pie-WAS4IAKB-5c5pctwz.js +0 -1
  277. package/dist/client/static/js/properties-2tcybqjk.js +0 -1
  278. package/dist/client/static/js/python-qph3dntq.js +0 -1
  279. package/dist/client/static/js/r-gd26x93y.js +0 -1
  280. package/dist/client/static/js/radar-RG4KPBEZ-52e5n99a.js +0 -1
  281. package/dist/client/static/js/railroad-74A4TZTK-44nqxxpy.js +0 -1
  282. package/dist/client/static/js/railroad-abnf-HS5TGJTU-25jxgwg7.js +0 -1
  283. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-64pqpf2y.js +0 -1
  284. package/dist/client/static/js/railroad-peg-WCYAUIDC-0p5sxzpx.js +0 -1
  285. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-kdcdamkj.js +0 -8
  286. package/dist/client/static/js/treeView-Q6P3EWNA-8j14nnd1.js +0 -1
  287. package/dist/client/static/js/treemap-WGGIJYW6-esf993kk.js +0 -1
  288. package/dist/client/static/js/typescript-0s2t05jj.js +0 -1
  289. package/dist/client/static/js/wardley-WFR3VGLG-v4dxm2sb.js +0 -1
  290. package/dist/client/static/js/xml-0py2vkw7.js +0 -1
  291. package/dist/client/static/js/yaml-vghdz0f0.js +0 -1
  292. /package/src/{client/components/workspace/model-dropdown/harness-models.ts → shared/lib/harness/models.ts} +0 -0
@@ -0,0 +1,245 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The capture layer: a tool call's frames become journal records.
8
+ *
9
+ * The cases are the ones the feature exists for — an `edit`, a `write`, a
10
+ * `bash rm`, a `sed -i`, a redirect — plus the two honest failures: an opaque
11
+ * command is a `note`, and a subagent's write is attributed to the child.
12
+ *
13
+ * The fake filesystem is a `Map`, so the before/after pair is deterministic:
14
+ * `flush()` after the start frame proves the snapshot ran before the test
15
+ * changes the file. Every path goes through `at()`, so the fixture is native
16
+ * on Windows too.
17
+ */
18
+
19
+ import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
20
+ import * as fsp from 'node:fs/promises';
21
+ import * as os from 'node:os';
22
+ import * as path from 'node:path';
23
+ import { makeCapture, records, REPO } from '@/server/lib/changes/capture-test-util';
24
+ import { readSessionChangeDiff } from '@/server/lib/changes/reader.server';
25
+
26
+ let dataDir = '';
27
+ let original: string | undefined;
28
+
29
+ beforeAll(async () => {
30
+ original = Bun.env.KABMO_DATA_DIR;
31
+ dataDir = await fsp.mkdtemp(path.join(os.tmpdir(), 'kabmo-changes-capture-'));
32
+ Bun.env.KABMO_DATA_DIR = dataDir;
33
+ });
34
+
35
+ afterAll(async () => {
36
+ if (original === undefined) delete Bun.env.KABMO_DATA_DIR;
37
+ else Bun.env.KABMO_DATA_DIR = original;
38
+ await fsp.rm(dataDir, { recursive: true, force: true });
39
+ });
40
+
41
+ const WINDOW_END = Date.now() + 60_000;
42
+
43
+ /** A path inside the fixture repo, spelled the way the host spells it. */
44
+ function at(relative: string): string {
45
+ return path.join(REPO, relative);
46
+ }
47
+
48
+ describe('tool adapters', () => {
49
+ test('edit records the before and after text', async () => {
50
+ const files = new Map([[at('a.ts'), 'old']]);
51
+ const capture = makeCapture('cap-edit', files);
52
+ capture.onFrame({
53
+ type: 'tool_execution_start',
54
+ toolCallId: 'c1',
55
+ toolName: 'edit',
56
+ args: { path: 'a.ts', old_string: 'old', new_string: 'new' },
57
+ });
58
+ await capture.flush();
59
+ files.set(at('a.ts'), 'new');
60
+ capture.onFrame({ type: 'tool_execution_end', toolCallId: 'c1', toolName: 'edit' });
61
+ await capture.flush();
62
+
63
+ const diff = await readSessionChangeDiff('cap-edit', at('a.ts'), 0, WINDOW_END);
64
+ expect(diff?.status).toBe('modified');
65
+ expect(diff?.oldContent).toBe('old');
66
+ expect(diff?.newContent).toBe('new');
67
+ });
68
+
69
+ test('write of a new file is a create', async () => {
70
+ const files = new Map<string, string>();
71
+ const capture = makeCapture('cap-write', files);
72
+ capture.onFrame({
73
+ type: 'tool_execution_start',
74
+ toolCallId: 'c1',
75
+ toolName: 'write',
76
+ args: { path: 'b.ts', content: 'B' },
77
+ });
78
+ await capture.flush();
79
+ files.set(at('b.ts'), 'B');
80
+ capture.onFrame({ type: 'tool_execution_end', toolCallId: 'c1', toolName: 'write' });
81
+ await capture.flush();
82
+
83
+ const diff = await readSessionChangeDiff('cap-write', at('b.ts'), 0, WINDOW_END);
84
+ expect(diff?.status).toBe('added');
85
+ expect(diff?.newContent).toBe('B');
86
+ });
87
+ });
88
+
89
+ describe('bash capture', () => {
90
+ test('rm is a delete, from the trace argv', async () => {
91
+ const files = new Map([[at('c.ts'), 'C']]);
92
+ const capture = makeCapture('cap-rm', files);
93
+ capture.onFrame({
94
+ type: 'tool_execution_start',
95
+ toolCallId: 'c1',
96
+ toolName: 'bash',
97
+ args: { command: 'rm -f c.ts' },
98
+ });
99
+ await capture.flush();
100
+ files.delete(at('c.ts'));
101
+ capture.onFrame({
102
+ type: 'tool_execution_end',
103
+ toolCallId: 'c1',
104
+ toolName: 'bash',
105
+ result: { details: { trace: { status: 0, units: [{ nodes: [{ k: 'simple', argv: ['rm', '-f', 'c.ts'], st: 0 }] }] } } },
106
+ });
107
+ await capture.flush();
108
+
109
+ const diff = await readSessionChangeDiff('cap-rm', at('c.ts'), 0, WINDOW_END);
110
+ expect(diff?.status).toBe('deleted');
111
+ expect(diff?.oldContent).toBe('C');
112
+ });
113
+
114
+ test('sed -i is an update', async () => {
115
+ const files = new Map([[at('d.ts'), 'a']]);
116
+ const capture = makeCapture('cap-sed', files);
117
+ capture.onFrame({
118
+ type: 'tool_execution_start',
119
+ toolCallId: 'c1',
120
+ toolName: 'bash',
121
+ args: { command: "sed -i 's/a/b/' d.ts" },
122
+ });
123
+ await capture.flush();
124
+ files.set(at('d.ts'), 'b');
125
+ capture.onFrame({
126
+ type: 'tool_execution_end',
127
+ toolCallId: 'c1',
128
+ toolName: 'bash',
129
+ result: { details: { trace: { status: 0, units: [{ nodes: [{ k: 'simple', argv: ['sed', '-i', 's/a/b/', 'd.ts'], st: 0 }] }] } } },
130
+ });
131
+ await capture.flush();
132
+
133
+ const diff = await readSessionChangeDiff('cap-sed', at('d.ts'), 0, WINDOW_END);
134
+ expect(diff?.status).toBe('modified');
135
+ expect(diff?.oldContent).toBe('a');
136
+ expect(diff?.newContent).toBe('b');
137
+ });
138
+
139
+ test('a redirect is a create the trace does not name', async () => {
140
+ const files = new Map<string, string>();
141
+ const capture = makeCapture('cap-redirect', files);
142
+ capture.onFrame({
143
+ type: 'tool_execution_start',
144
+ toolCallId: 'c1',
145
+ toolName: 'bash',
146
+ args: { command: 'echo hi > e.txt' },
147
+ });
148
+ await capture.flush();
149
+ files.set(at('e.txt'), 'hi\n');
150
+ capture.onFrame({
151
+ type: 'tool_execution_end',
152
+ toolCallId: 'c1',
153
+ toolName: 'bash',
154
+ result: { details: { trace: { status: 0, units: [{ nodes: [{ k: 'simple', argv: ['echo', 'hi'], st: 0 }] }] } } },
155
+ });
156
+ await capture.flush();
157
+
158
+ const diff = await readSessionChangeDiff('cap-redirect', at('e.txt'), 0, WINDOW_END);
159
+ expect(diff?.status).toBe('added');
160
+ expect(diff?.newContent).toBe('hi\n');
161
+ });
162
+
163
+ test('an opaque command is a note, not a guess', async () => {
164
+ const files = new Map<string, string>();
165
+ const capture = makeCapture('cap-opaque', files);
166
+ capture.onFrame({
167
+ type: 'tool_execution_start',
168
+ toolCallId: 'c1',
169
+ toolName: 'bash',
170
+ args: { command: 'bun test' },
171
+ });
172
+ await capture.flush();
173
+ capture.onFrame({
174
+ type: 'tool_execution_end',
175
+ toolCallId: 'c1',
176
+ toolName: 'bash',
177
+ result: { details: { trace: { status: 0, units: [{ nodes: [{ k: 'simple', argv: ['bun', 'test'], st: 0 }] }] } } },
178
+ });
179
+ await capture.flush();
180
+
181
+ const lines = await records('cap-opaque');
182
+ expect(lines.some((line) => line.type === 'change')).toBe(false);
183
+ const note = lines.find((line) => line.type === 'note');
184
+ expect(note?.type).toBe('note');
185
+ if (note?.type !== 'note') throw new Error('expected a note');
186
+ expect(note.reason).toBe('opaque-command');
187
+ });
188
+ });
189
+
190
+ describe('scan pass', () => {
191
+ test('an opaque git reset is reconciled from the two snapshots', async () => {
192
+ const files = new Map([[at('g.ts'), 'old']]);
193
+ const scans = [
194
+ { root: REPO, dirty: new Map([[at('g.ts'), 'old']]), truncated: false },
195
+ { root: REPO, dirty: new Map([[at('g.ts'), 'new']]), truncated: false },
196
+ ];
197
+ const capture = makeCapture('cap-scan', files, {
198
+ takeScan: async () => scans.shift() ?? null,
199
+ readHead: async () => null,
200
+ });
201
+ capture.onFrame({
202
+ type: 'tool_execution_start',
203
+ toolCallId: 'c1',
204
+ toolName: 'bash',
205
+ args: { command: 'git reset --hard' },
206
+ });
207
+ await capture.flush();
208
+ files.set(at('g.ts'), 'new');
209
+ capture.onFrame({
210
+ type: 'tool_execution_end',
211
+ toolCallId: 'c1',
212
+ toolName: 'bash',
213
+ result: { details: { trace: { status: 0, units: [{ nodes: [{ k: 'simple', argv: ['git', 'reset', '--hard'], st: 0 }] }] } } },
214
+ });
215
+ await capture.flush();
216
+
217
+ const diff = await readSessionChangeDiff('cap-scan', at('g.ts'), 0, WINDOW_END);
218
+ expect(diff?.status).toBe('modified');
219
+ expect(diff?.oldContent).toBe('old');
220
+ expect(diff?.newContent).toBe('new');
221
+ });
222
+ });
223
+
224
+ describe('subagents', () => {
225
+ test('a child edit is attributed to the child', async () => {
226
+ const files = new Map([[at('f.ts'), 'old']]);
227
+ const capture = makeCapture('cap-sub', files);
228
+ capture.onFrame({
229
+ type: 'subagent_event',
230
+ payload: { type: 'tool_execution_start', toolCallId: 's1', toolName: 'edit', args: { path: 'f.ts' }, agent: 'Child' },
231
+ });
232
+ await capture.flush();
233
+ files.set(at('f.ts'), 'new');
234
+ capture.onFrame({
235
+ type: 'subagent_event',
236
+ payload: { type: 'tool_execution_end', toolCallId: 's1', toolName: 'edit', agent: 'Child' },
237
+ });
238
+ await capture.flush();
239
+
240
+ const change = (await records('cap-sub')).find((line) => line.type === 'change');
241
+ expect(change?.type).toBe('change');
242
+ if (change?.type !== 'change') throw new Error('expected a change');
243
+ expect(change.agent).toBe('Child');
244
+ });
245
+ });
@@ -0,0 +1,172 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The `bash` classifier: the table that decides what a command will touch.
8
+ *
9
+ * The cases are the ones the journal depends on — `rm`, `mv`, `sed -i`, a
10
+ * redirect, a `git` path restore — plus the two failure modes that must be
11
+ * loud: a glob (the shell expands it, so the path is unknown) and an opaque
12
+ * command (a build, a script), which must be marked rather than guessed.
13
+ *
14
+ * Expected paths are built with `at()`/`abs()`, so the suite asserts the same
15
+ * behaviour on a POSIX host and on Windows.
16
+ */
17
+
18
+ import { describe, expect, test } from 'bun:test';
19
+ import path from 'node:path';
20
+ import {
21
+ classifyArgv,
22
+ classifyCommand,
23
+ type CommandPlan,
24
+ } from '@/server/lib/changes/classify-command';
25
+ import { tokenizeCommand } from '@/server/lib/changes/classify-tokenize';
26
+
27
+ const CWD = path.resolve('/repo');
28
+ const HOME = path.resolve('/home/u');
29
+
30
+ /** A path inside the fixture cwd, spelled the way the host spells it. */
31
+ function at(relative: string): string {
32
+ return path.join(CWD, relative);
33
+ }
34
+
35
+ /** An absolute path as the classifier normalizes it. */
36
+ function abs(absolute: string): string {
37
+ return path.normalize(absolute);
38
+ }
39
+
40
+ function plan(script: string): CommandPlan {
41
+ return classifyCommand(script, CWD, HOME);
42
+ }
43
+
44
+ function ops(result: CommandPlan): string[] {
45
+ return result.mutations.map((mutation) => `${mutation.op}:${mutation.path}`);
46
+ }
47
+
48
+ describe('classifyCommand', () => {
49
+ test('rm deletes every operand, flags excluded', () => {
50
+ expect(ops(plan('rm -rf src/a.ts'))).toEqual([`delete:${at('src/a.ts')}`]);
51
+ expect(ops(plan('rm -f /tmp/x'))).toEqual([`delete:${abs('/tmp/x')}`]);
52
+ expect(ops(plan('rm a b'))).toEqual([`delete:${at('a')}`, `delete:${at('b')}`]);
53
+ });
54
+
55
+ test('mv is a rename with its source', () => {
56
+ const result = plan('mv a b');
57
+ expect(result.mutations).toEqual([{ op: 'rename', path: at('b'), from: at('a') }]);
58
+ });
59
+
60
+ test('sed -i updates its file operands; sed without -i is read-only', () => {
61
+ expect(ops(plan("sed -i 's/a/b/' f"))).toEqual([`update:${at('f')}`]);
62
+ expect(ops(plan("sed -i 's/a/b/' f1 f2"))).toEqual([`update:${at('f1')}`, `update:${at('f2')}`]);
63
+ const readOnly = plan("sed 's/a/b/' f");
64
+ expect(readOnly.mutations).toEqual([]);
65
+ expect(readOnly.readOnly).toBe(true);
66
+ });
67
+
68
+ test('perl -i and awk -i inplace update their files', () => {
69
+ expect(ops(plan("perl -i -pe 's/a/b/' f"))).toEqual([`update:${at('f')}`]);
70
+ expect(ops(plan("awk -i inplace '{print}' f"))).toEqual([`update:${at('f')}`]);
71
+ });
72
+
73
+ test('output redirects are mutations the trace does not model', () => {
74
+ expect(ops(plan('echo hi > out.txt'))).toEqual([`update:${at('out.txt')}`]);
75
+ expect(ops(plan('echo hi >> out.txt'))).toEqual([`update:${at('out.txt')}`]);
76
+ expect(ops(plan('ls 2> err.log'))).toEqual([`update:${at('err.log')}`]);
77
+ expect(ops(plan('ls 2>&1'))).toEqual([]);
78
+ expect(plan('ls 2>&1').readOnly).toBe(true);
79
+ });
80
+
81
+ test('cp, tee, truncate, dd, sort -o and curl -o name their destination', () => {
82
+ expect(ops(plan('cp a b'))).toEqual([`update:${at('b')}`]);
83
+ expect(ops(plan('tee out'))).toEqual([`update:${at('out')}`]);
84
+ expect(ops(plan('truncate -s 0 f'))).toEqual([`update:${at('f')}`]);
85
+ expect(ops(plan('dd if=a of=b'))).toEqual([`update:${at('b')}`]);
86
+ expect(ops(plan('sort -o f in'))).toEqual([`update:${at('f')}`]);
87
+ expect(ops(plan('curl -o f https://x'))).toEqual([`update:${at('f')}`]);
88
+ });
89
+
90
+ test('git path restores are updates; a hard reset is opaque', () => {
91
+ expect(ops(plan('git checkout -- a b'))).toEqual([`update:${at('a')}`, `update:${at('b')}`]);
92
+ expect(ops(plan('git restore a'))).toEqual([`update:${at('a')}`]);
93
+ expect(ops(plan('git mv a b'))).toEqual([`rename:${at('b')}`]);
94
+ expect(ops(plan('git rm a'))).toEqual([`delete:${at('a')}`]);
95
+ expect(plan('git reset --hard').opaque).toBe(true);
96
+ expect(plan('git clean -fd').opaque).toBe(true);
97
+ });
98
+
99
+ test('a glob is opaque: the shell expands it, so the path is unknown', () => {
100
+ const result = plan('rm *.ts');
101
+ expect(result.mutations).toEqual([]);
102
+ expect(result.opaque).toBe(true);
103
+ });
104
+
105
+ test('a build or a script is opaque, not read-only', () => {
106
+ expect(plan('bun test').opaque).toBe(true);
107
+ expect(plan('bun test').readOnly).toBe(false);
108
+ expect(plan('node script.js').opaque).toBe(true);
109
+ expect(plan('xargs rm').opaque).toBe(true);
110
+ expect(plan('find . -delete').opaque).toBe(true);
111
+ expect(plan('find . -name x').readOnly).toBe(true);
112
+ });
113
+
114
+ test('a read-only command is read-only', () => {
115
+ expect(plan('rg -n foo src').readOnly).toBe(true);
116
+ expect(plan('ls -la').readOnly).toBe(true);
117
+ expect(plan('git status').readOnly).toBe(true);
118
+ });
119
+
120
+ test('a cd changes what the later relative paths mean', () => {
121
+ expect(ops(plan('cd sub && rm a'))).toEqual([`delete:${at('sub/a')}`]);
122
+ expect(ops(plan('cd sub && cat > b'))).toEqual([`update:${at('sub/b')}`]);
123
+ expect(plan('cd -').opaque).toBe(true);
124
+ });
125
+
126
+ test('an unexpanded variable is opaque, not a literal path', () => {
127
+ const result = plan('cat > $DIR/out.md');
128
+ expect(result.mutations).toEqual([]);
129
+ expect(result.opaque).toBe(true);
130
+ });
131
+
132
+ test('a device file is not a working-tree mutation', () => {
133
+ expect(ops(plan('ls 2>/dev/null'))).toEqual([]);
134
+ expect(plan('ls 2>/dev/null').readOnly).toBe(true);
135
+ expect(plan('ls 2>/dev/null').opaque).toBe(false);
136
+ });
137
+
138
+ test('a heredoc body is data, not commands', () => {
139
+ const result = plan("cat > f <<'EOF'\nrm x\n> y\nEOF");
140
+ expect(ops(result)).toEqual([`update:${at('f')}`]);
141
+ });
142
+
143
+ test('a chain is the union of its commands', () => {
144
+ const result = plan('rm a && echo hi > b');
145
+ expect(ops(result)).toEqual([`delete:${at('a')}`, `update:${at('b')}`]);
146
+ expect(result.readOnly).toBe(false);
147
+ });
148
+ });
149
+
150
+ describe('classifyArgv', () => {
151
+ test('classifies one trace node', () => {
152
+ expect(ops(classifyArgv(['rm', '-rf', 'a'], CWD, HOME))).toEqual([`delete:${at('a')}`]);
153
+ expect(ops(classifyArgv(['sed', '-i', 's/a/b/', 'f'], CWD, HOME))).toEqual([`update:${at('f')}`]);
154
+ });
155
+ });
156
+
157
+ describe('tokenizeCommand', () => {
158
+ test('keeps quoted words whole and separates operators', () => {
159
+ const tokens = tokenizeCommand('a "b c" > d');
160
+ expect(tokens).toEqual([
161
+ { kind: 'word', value: 'a' },
162
+ { kind: 'word', value: 'b c' },
163
+ { kind: 'op', value: '>' },
164
+ { kind: 'word', value: 'd' },
165
+ ]);
166
+ });
167
+
168
+ test('does not treat 2>&1 as a file target', () => {
169
+ const tokens = tokenizeCommand('ls 2>&1');
170
+ expect(tokens.some((token) => token.kind === 'op' && token.value === 'fddup')).toBe(true);
171
+ });
172
+ });
@@ -0,0 +1,272 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * What a `bash` command will do to the working tree, read from its text.
8
+ *
9
+ * omp's shell trace gives exact `argv` and exit status per simple command, but
10
+ * it does NOT model redirections. Measured on 18.20.3: `bun test > /tmp/n1.log
11
+ * 2>&1` produces only `and_or`/`pipeline`/`simple`/`word` nodes, and the
12
+ * `simple` node's argv is `["bun","test"]` — the `>` and its target are absent.
13
+ * So the classifier has two entry points:
14
+ *
15
+ * - {@link classifyCommand} — the whole script, tokenized here, used at
16
+ * `tool_execution_start` to snapshot the targets BEFORE the command runs;
17
+ * - {@link classifyArgv} — one already-parsed `argv` from the trace, used at
18
+ * `tool_execution_end` to confirm what actually ran.
19
+ *
20
+ * A command is `readOnly` when every simple command is a known read-only verb
21
+ * and there is no output redirect. It is `opaque` when at least one command is
22
+ * not understood — a script, a build, `git reset --hard` — which is the signal
23
+ * for the filesystem reconciliation pass rather than a guess.
24
+ *
25
+ * A path containing a glob character is not resolved: the shell expands it, and
26
+ * a guess would journal a file that was never touched. The command is marked
27
+ * opaque instead, so the scan pass answers.
28
+ */
29
+
30
+ import path from 'node:path';
31
+ import { classifyGit } from '@/server/lib/changes/classify-git';
32
+ import {
33
+ dedupe,
34
+ flagValue,
35
+ isSpecialFile,
36
+ nonFlagArgs,
37
+ resolvePath,
38
+ scriptFiles,
39
+ truncateFiles,
40
+ } from '@/server/lib/changes/classify-paths';
41
+ import {
42
+ splitCommands,
43
+ stripHeredocs,
44
+ tokenizeCommand,
45
+ type SimpleCommand,
46
+ } from '@/server/lib/changes/classify-tokenize';
47
+
48
+ export type MutationOp = 'create' | 'update' | 'delete' | 'rename';
49
+
50
+ export interface CommandMutation {
51
+ op: MutationOp;
52
+ /** Absolute path. */
53
+ path: string;
54
+ /** Absolute source path, for a rename. */
55
+ from?: string;
56
+ }
57
+
58
+ export interface CommandPlan {
59
+ mutations: CommandMutation[];
60
+ /** At least one command is not understood; the scan pass must run. */
61
+ opaque: boolean;
62
+ /** Every command is a known read-only verb and there is no output redirect. */
63
+ readOnly: boolean;
64
+ }
65
+
66
+ /** Verbs that never write a file. */
67
+ const READ_ONLY: Record<string, true> = {
68
+ ls: true, cat: true, head: true, tail: true, wc: true, rg: true, grep: true,
69
+ fd: true, stat: true, file: true, which: true, pwd: true,
70
+ echo: true, printf: true, date: true, env: true, printenv: true, whoami: true,
71
+ id: true, uname: true, du: true, df: true, tree: true, jq: true,
72
+ basename: true, dirname: true, realpath: true, readlink: true,
73
+ cut: true, tr: true, nl: true, od: true, strings: true,
74
+ diff: true, cmp: true, comm: true, paste: true, fold: true, seq: true,
75
+ yes: true, true: true, false: true, test: true, '[': true, sleep: true,
76
+ kill: true, ps: true, top: true, lsof: true, cd: true, export: true,
77
+ set: true, unset: true, chmod: true, chown: true, mkdir: true, wait: true,
78
+ jobs: true, bg: true, fg: true, type: true, command: true, hash: true,
79
+ umask: true, ulimit: true,
80
+ };
81
+
82
+ /** Verbs whose effect cannot be read from argv; the scan pass answers. */
83
+ const OPAQUE: Record<string, true> = {
84
+ bun: true, bunx: true, npm: true, npx: true, pnpm: true, yarn: true,
85
+ node: true, deno: true, python: true, python3: true, pip: true, pip3: true,
86
+ sh: true, bash: true, zsh: true, fish: true, make: true, cargo: true,
87
+ rustc: true, go: true, tsc: true, eslint: true, prettier: true,
88
+ playwright: true, vitest: true, jest: true, tar: true, unzip: true,
89
+ zip: true, rsync: true, scp: true, ssh: true, docker: true, kubectl: true,
90
+ helm: true, terraform: true, ansible: true, systemctl: true, launchctl: true,
91
+ brew: true, apt: true, 'apt-get': true, yum: true, dnf: true, pacman: true,
92
+ sudo: true, su: true, eval: true, exec: true, nohup: true, timeout: true,
93
+ parallel: true, 'git-lfs': true, gh: true, glab: true, aws: true,
94
+ gcloud: true, az: true, xargs: true, source: true, '.': true, time: true,
95
+ watch: true,
96
+ };
97
+
98
+ /** Classify one already-parsed `argv` (the shell trace's `simple` node). */
99
+ export function classifyArgv(argv: readonly string[], cwd: string, home: string): CommandPlan {
100
+ return classifySimple({ words: [...argv], redirects: [] }, cwd, home);
101
+ }
102
+
103
+ /** Classify a whole script, including its output redirects and `cd` changes. */
104
+ export function classifyCommand(script: string, cwd: string, home: string): CommandPlan {
105
+ const mutations: CommandMutation[] = [];
106
+ let opaque = false;
107
+ let readOnly = true;
108
+ let currentCwd = cwd;
109
+ for (const command of splitCommands(tokenizeCommand(stripHeredocs(script)))) {
110
+ const verb = command.words[0] ? path.basename(command.words[0]) : '';
111
+ if (verb === 'cd') {
112
+ // A `cd` changes what every later relative path means. `cd -` and a bare
113
+ // `cd` are not tracked, so the command is opaque rather than guessed.
114
+ const target = command.words.slice(1).find((arg) => !arg.startsWith('-'));
115
+ const resolved = target ? resolvePath(currentCwd, home, target) : null;
116
+ if (resolved) currentCwd = resolved;
117
+ else opaque = true;
118
+ continue;
119
+ }
120
+ const result = classifySimple(command, currentCwd, home);
121
+ mutations.push(...result.mutations);
122
+ if (result.opaque) opaque = true;
123
+ if (!result.readOnly) readOnly = false;
124
+ }
125
+ return { mutations: dedupe(mutations), opaque, readOnly };
126
+ }
127
+
128
+ function classifySimple(command: SimpleCommand, cwd: string, home: string): CommandPlan {
129
+ const mutations: CommandMutation[] = [];
130
+ let opaque = false;
131
+ let readOnly = true;
132
+
133
+ const add = (op: MutationOp, raw: string, from?: string): void => {
134
+ // `/dev/null` and friends are redirect sinks, not working-tree mutations.
135
+ if (isSpecialFile(raw)) return;
136
+ const resolved = resolvePath(cwd, home, raw);
137
+ if (!resolved) {
138
+ opaque = true;
139
+ return;
140
+ }
141
+ mutations.push(from ? { op, path: resolved, from } : { op, path: resolved });
142
+ readOnly = false;
143
+ };
144
+
145
+ for (const redirect of command.redirects) {
146
+ add('update', redirect.target);
147
+ }
148
+
149
+ const argv = command.words;
150
+ if (argv.length === 0) return { mutations, opaque, readOnly };
151
+ const verb = path.basename(argv[0]);
152
+ const args = argv.slice(1);
153
+
154
+ if (READ_ONLY[verb] === true) return { mutations, opaque, readOnly };
155
+
156
+ if (verb === 'sed' || verb === 'gsed' || verb === 'perl') {
157
+ const inPlace = args.some((arg) => arg === '-i' || arg.startsWith('-i') || arg === '--in-place' || arg.startsWith('--in-place='));
158
+ if (!inPlace) return { mutations, opaque, readOnly };
159
+ for (const file of scriptFiles(args)) add('update', file);
160
+ return { mutations, opaque, readOnly };
161
+ }
162
+ if (verb === 'awk' || verb === 'gawk') {
163
+ const index = args.findIndex((arg) => arg === '-i' || arg === 'inplace');
164
+ if (index === -1) return { mutations, opaque, readOnly };
165
+ // `-i inplace` is two tokens; the program follows, then the files.
166
+ const programAt = args[index] === '-i' && args[index + 1] === 'inplace' ? index + 2 : index + 1;
167
+ for (const file of args.slice(programAt + 1).filter((arg) => !arg.startsWith('-'))) add('update', file);
168
+ return { mutations, opaque, readOnly };
169
+ }
170
+ if (verb === 'rm' || verb === 'rmdir' || verb === 'unlink') {
171
+ for (const file of nonFlagArgs(args)) add('delete', file);
172
+ return { mutations, opaque, readOnly };
173
+ }
174
+ if (verb === 'mv') {
175
+ const files = nonFlagArgs(args);
176
+ if (files.length < 2) {
177
+ opaque = true;
178
+ return { mutations, opaque, readOnly };
179
+ }
180
+ const dest = files[files.length - 1];
181
+ const sources = files.slice(0, -1);
182
+ for (const source of sources) {
183
+ const from = resolvePath(cwd, home, source);
184
+ const destPath = resolvePath(cwd, home, dest);
185
+ const to = sources.length > 1 && destPath ? path.join(destPath, path.basename(source)) : destPath;
186
+ if (!from || !to) {
187
+ opaque = true;
188
+ continue;
189
+ }
190
+ mutations.push({ op: 'rename', path: to, from });
191
+ readOnly = false;
192
+ }
193
+ return { mutations, opaque, readOnly };
194
+ }
195
+ if (verb === 'cp') {
196
+ const files = nonFlagArgs(args);
197
+ if (files.length < 2) {
198
+ opaque = true;
199
+ return { mutations, opaque, readOnly };
200
+ }
201
+ const dest = files[files.length - 1];
202
+ const sources = files.slice(0, -1);
203
+ for (const source of sources) {
204
+ const destPath = resolvePath(cwd, home, dest);
205
+ const to = sources.length > 1 && destPath ? path.join(destPath, path.basename(source)) : destPath;
206
+ if (!to) {
207
+ opaque = true;
208
+ continue;
209
+ }
210
+ mutations.push({ op: 'update', path: to });
211
+ readOnly = false;
212
+ }
213
+ return { mutations, opaque, readOnly };
214
+ }
215
+ if (verb === 'tee' || verb === 'touch') {
216
+ for (const file of nonFlagArgs(args)) add('update', file);
217
+ return { mutations, opaque, readOnly };
218
+ }
219
+ if (verb === 'truncate') {
220
+ for (const file of truncateFiles(args)) add('update', file);
221
+ return { mutations, opaque, readOnly };
222
+ }
223
+ if (verb === 'install' || verb === 'ln') {
224
+ const files = nonFlagArgs(args);
225
+ const file = files[files.length - 1];
226
+ if (file) add(verb === 'ln' ? 'create' : 'update', file);
227
+ else opaque = true;
228
+ return { mutations, opaque, readOnly };
229
+ }
230
+ if (verb === 'dd') {
231
+ for (const arg of args) {
232
+ if (arg.startsWith('of=')) add('update', arg.slice(3));
233
+ }
234
+ return { mutations, opaque, readOnly };
235
+ }
236
+ if (verb === 'sort') {
237
+ const out = flagValue(args, '-o') ?? flagValue(args, '--output');
238
+ if (out) add('update', out);
239
+ return { mutations, opaque, readOnly };
240
+ }
241
+ if (verb === 'uniq') {
242
+ const files = nonFlagArgs(args);
243
+ if (files.length >= 2) add('update', files[1]);
244
+ return { mutations, opaque, readOnly };
245
+ }
246
+ if (verb === 'curl' || verb === 'wget') {
247
+ const out = flagValue(args, '-o') ?? flagValue(args, '--output') ?? flagValue(args, '-O');
248
+ if (out) add('update', out);
249
+ return { mutations, opaque, readOnly };
250
+ }
251
+ if (verb === 'find') {
252
+ const mutating = args.some((arg) => arg === '-delete' || arg === '-exec' || arg === '-execdir' || arg === '-ok' || arg === '-okdir');
253
+ if (mutating) {
254
+ opaque = true;
255
+ readOnly = false;
256
+ }
257
+ return { mutations, opaque, readOnly };
258
+ }
259
+ if (verb === 'git') {
260
+ return classifyGit(args, cwd, home, mutations, opaque, readOnly);
261
+ }
262
+ if (OPAQUE[verb] === true) {
263
+ opaque = true;
264
+ readOnly = false;
265
+ return { mutations, opaque, readOnly };
266
+ }
267
+
268
+ // An unknown verb is not assumed harmless.
269
+ opaque = true;
270
+ readOnly = false;
271
+ return { mutations, opaque, readOnly };
272
+ }