@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.
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +547 -528
- package/dist/client/static/js/{CsvGrid-1h3bcak7.js → CsvGrid-90zfbn7f.js} +2 -2
- package/dist/client/static/js/{DocxView-ndca8jch.js → DocxView-vwq2rf16.js} +2 -2
- package/dist/client/static/js/{DrawioView-kpzd6y0b.js → DrawioView-bvx7eqcz.js} +2 -2
- package/dist/client/static/js/{ImageView-79prn3dg.js → ImageView-q6xfmbrq.js} +1 -1
- package/dist/client/static/js/{LayoutWrapper-v2wn2sb2.js → LayoutWrapper-qatdaw3n.js} +2 -2
- package/dist/client/static/js/{Modal-99j0zz3z.js → Modal-6jx1fvfb.js} +15 -15
- package/dist/client/static/js/{PdfView-2rjd87ay.js → PdfView-tkv2d2zs.js} +1 -1
- package/dist/client/static/js/{SessionsView-t7f3s71b.js → SessionsView-rbnecykz.js} +1 -1
- package/dist/client/static/js/{SheetView-ehb976st.js → SheetView-t08g8kdr.js} +4 -4
- package/dist/client/static/js/{SvgPreview-de2bbba6.js → SvgPreview-9vh6mdcp.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-nx9jzn7m.js → abnfDiagram-O67JEVCF-bxcn33e1.js} +1 -1
- package/dist/client/static/js/architecture-7GRP2DOG-r8sz34h3.js +1 -0
- package/dist/client/static/js/{architectureDiagram-NJMV4G6O-170v67rr.js → architectureDiagram-NJMV4G6O-40ggw6e8.js} +2 -2
- package/dist/client/static/js/{astro-80bs6hvg.js → astro-p3f5p9p2.js} +1 -1
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-16q285n1.js → blockDiagram-BEXU5L5S-k41cvjrd.js} +6 -6
- package/dist/client/static/js/c-jkdstn33.js +1 -0
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-rn3qt45h.js → c4Diagram-YGBWAQC7-rdcmn6ac.js} +2 -2
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-r26wg74e.js → classDiagram-v2-NBCMYWYE-txbmbkxv.js} +5 -5
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-82kwe7ha.js → cose-bilkent-JH36ORCC-bxzh3qj1.js} +1 -1
- package/dist/client/static/js/cpp-9d3xdpe3.js +1 -0
- package/dist/client/static/js/css-r3wja1ze.js +1 -0
- package/dist/client/static/js/css-sebxkh5f.js +1 -0
- package/dist/client/static/js/cynefin-OW5HDTMX-w2f2vev7.js +1 -0
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-tcxdn6pa.js → cynefinDiagram-VND7K2PF-abx5343b.js} +1 -1
- package/dist/client/static/js/{dagre-6A5THRUB-g833ata3.js → dagre-6A5THRUB-baj278kt.js} +2 -2
- package/dist/client/static/js/{diagram-22UHCM2B-f1fq8xec.js → diagram-22UHCM2B-vqvhdc5m.js} +7 -7
- package/dist/client/static/js/{diagram-3UASUU5V-6j2w016f.js → diagram-3UASUU5V-w328rfx0.js} +2 -2
- package/dist/client/static/js/{diagram-ATOU4E4O-6t2qxsk4.js → diagram-ATOU4E4O-zzcmwnm8.js} +2 -2
- package/dist/client/static/js/{diagram-CDSNMT55-7abar8s7.js → diagram-CDSNMT55-8yw39mmj.js} +1 -1
- package/dist/client/static/js/{diagram-MLGK6HIB-s68rgy16.js → diagram-MLGK6HIB-zgc386pv.js} +1 -1
- package/dist/client/static/js/{diagram-MPIPVDR6-azgkm6w8.js → diagram-MPIPVDR6-efmvvscm.js} +1 -1
- package/dist/client/static/js/{dockerfile-47e33kqa.js → dockerfile-bp5dre33.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-esrjz750.js → ebnfDiagram-ZINNZB2B-p66h0dzq.js} +1 -1
- package/dist/client/static/js/{elixir-rpa1g4gy.js → elixir-jwphgp8j.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-fhr4b4jj.js → elk-276RUBZZ-g0jjxcqd.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-5r3fmdnz.js → erDiagram-OPXOYQCR-39gat96z.js} +4 -4
- package/dist/client/static/js/{erlang-bh5cbm8m.js → erlang-6m6tpt72.js} +1 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-k5n61zzh.js +1 -0
- package/dist/client/static/js/flowDiagram-KWPJA3E3-f6jpcqyq.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-j4pf6rdn.js → ganttDiagram-FUAMR5RP-nsjv1zt4.js} +2 -2
- package/dist/client/static/js/gitGraph-4MIJSDKK-2gf053bx.js +1 -0
- package/dist/client/static/js/{gitGraphDiagram-X574FWY7-x5epk0gr.js → gitGraphDiagram-X574FWY7-r4vnkcy3.js} +2 -2
- package/dist/client/static/js/graphql-p4cskvad.js +1 -0
- package/dist/client/static/js/html-f26r6vv5.js +1 -0
- package/dist/client/static/js/{index-c1j0xb0w.js → index-0kxqzafy.js} +1 -1
- package/dist/client/static/js/{index-3kgrcaq1.js → index-11bdd235.js} +1 -1
- package/dist/client/static/js/{index-b48p8d1j.js → index-1qszrvzk.js} +2 -2
- package/dist/client/static/js/{index-3vdmwpbh.js → index-24yyj78e.js} +2 -2
- package/dist/client/static/js/{index-63c6t75t.js → index-2drjp9ks.js} +1 -1
- package/dist/client/static/js/{index-d2km9egp.js → index-2ndq1ngv.js} +4 -4
- package/dist/client/static/js/{index-0j518hqm.js → index-3az1w5f8.js} +2 -2
- package/dist/client/static/js/{index-ye450a7z.js → index-50z4ek83.js} +1 -1
- package/dist/client/static/js/{index-60ceydzn.js → index-5ebhb94w.js} +1 -1
- package/dist/client/static/js/{index-ctgefatv.js → index-5y0bvq4q.js} +34 -34
- package/dist/client/static/js/{index-40ve7zzv.js → index-6ax2z70w.js} +1 -1
- package/dist/client/static/js/{index-9t82sx0w.js → index-6k3e5dph.js} +2 -2
- package/dist/client/static/js/{index-6xzfta4b.js → index-73jwm4d5.js} +1 -1
- package/dist/client/static/js/{index-8cy3x2y8.js → index-7fdp9c7m.js} +2 -2
- package/dist/client/static/js/{index-zvfvqvn9.js → index-9wd9y6m0.js} +2 -2
- package/dist/client/static/js/{index-q5t4sy22.js → index-9wtg6ywn.js} +4 -4
- package/dist/client/static/js/{index-nws03exw.js → index-a74k07z2.js} +2 -2
- package/dist/client/static/js/{index-982jyfsb.js → index-ashpbfqv.js} +2 -2
- package/dist/client/static/js/{index-zp73zexp.js → index-b9b2nwdd.js} +2 -2
- package/dist/client/static/js/{index-h1e1abpt.js → index-c15r8jd3.js} +2 -2
- package/dist/client/static/js/{index-5rzk1226.js → index-da10qpns.js} +2 -2
- package/dist/client/static/js/{index-ky0prc71.js → index-dfgdn3fj.js} +9 -9
- package/dist/client/static/js/{index-c09a5s1n.js → index-dkseg29t.js} +9 -9
- package/dist/client/static/js/{index-w3n97x4b.js → index-dt7e1328.js} +2 -2
- package/dist/client/static/js/{index-sar2ggde.js → index-e1pr3k50.js} +2 -2
- package/dist/client/static/js/{index-0b1kwsam.js → index-fghst0kd.js} +32 -32
- package/dist/client/static/js/{index-af24nes6.js → index-gbfg0anm.js} +2 -2
- package/dist/client/static/js/{index-vtbbfwx0.js → index-gr6jng0x.js} +2 -2
- package/dist/client/static/js/{index-44qrckd2.js → index-gwhx66f4.js} +1 -1
- package/dist/client/static/js/{index-55pqvh82.js → index-h7pn9qw6.js} +2 -2
- package/dist/client/static/js/{index-97t3mv1v.js → index-h8h5c2r8.js} +1 -1
- package/dist/client/static/js/{index-v5t761a1.js → index-ha75kff0.js} +2 -2
- package/dist/client/static/js/{index-ydvfc9td.js → index-hzx81cjq.js} +4 -4
- package/dist/client/static/js/{index-be6gevq8.js → index-k9xsvab3.js} +1 -1
- package/dist/client/static/js/{index-v8qd8ypc.js → index-nd4p98mc.js} +2 -2
- package/dist/client/static/js/{index-dmgawfhw.js → index-qkscve6n.js} +2 -2
- package/dist/client/static/js/{index-w7xbfv44.js → index-qn4pkjfh.js} +2 -2
- package/dist/client/static/js/{index-zdtsvnpq.js → index-r83kr4s5.js} +2 -2
- package/dist/client/static/js/{index-htt8qxm3.js → index-ra38ggke.js} +1 -1
- package/dist/client/static/js/{index-skm6k5w2.js → index-rf0p3v7q.js} +5 -5
- package/dist/client/static/js/{index-7r1hw2gd.js → index-rgp69pa8.js} +1 -1
- package/dist/client/static/js/{index-8e15fzax.js → index-rqrcw8nj.js} +2 -2
- package/dist/client/static/js/{index-63jbb4kf.js → index-sa9cp6km.js} +2 -2
- package/dist/client/static/js/{index-75haaj8g.js → index-st202rjv.js} +184 -184
- package/dist/client/static/js/{index-mm1rf116.js → index-t5t71dhp.js} +2 -2
- package/dist/client/static/js/{index-ktvbsj6w.js → index-tfsaj5d1.js} +2 -2
- package/dist/client/static/js/{index-k1xt92h4.js → index-tv61v3t3.js} +1 -1
- package/dist/client/static/js/index-tzm90bsz.js +1 -0
- package/dist/client/static/js/{index-z6g74h7g.js → index-vb6t44dw.js} +2 -2
- package/dist/client/static/js/{index-pyx8n25s.js → index-vnn7m9yp.js} +3 -3
- package/dist/client/static/js/{index-5kjpacvd.js → index-vxd4gykh.js} +2 -2
- package/dist/client/static/js/{index-r8pckaqe.js → index-xya34x4v.js} +2 -2
- package/dist/client/static/js/{index-a293pdg7.js → index-y3hdv561.js} +2 -2
- package/dist/client/static/js/{index-9gf8b73w.js → index-z0cpp5bc.js} +2 -2
- package/dist/client/static/js/info-A6RAGUB7-3tr0y3s6.js +1 -0
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-ktc8nb8g.js → infoDiagram-VRGFBTTK-e39pvm4j.js} +1 -1
- package/dist/client/static/js/ini-cg0a5wm3.js +1 -0
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-n3dk6227.js → ishikawaDiagram-OU5B5YK6-rqhszgvp.js} +2 -2
- package/dist/client/static/js/java-vcck089n.js +1 -0
- package/dist/client/static/js/javascript-nyf39d5r.js +1 -0
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-f0p1h8qn.js → journeyDiagram-ZHPQQLJL-wgy5qrsv.js} +3 -3
- package/dist/client/static/js/jsx-ht9zyzwa.js +1 -0
- package/dist/client/static/js/{julia-73zjh2w6.js → julia-237yk557.js} +1 -1
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-7jdt7dv1.js → kanban-definition-PNTS6WVX-b8bxn0h1.js} +3 -3
- package/dist/client/static/js/lua-86fjqj8v.js +1 -0
- package/dist/client/static/js/markdown-gwmsh53r.js +1 -0
- package/dist/client/static/js/{mermaid.core-e8rzrjt9.js → mermaid.core-vb5ehtre.js} +6 -6
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-7shv6ge0.js → mindmap-definition-NLK3R4M7-t4p38s38.js} +3 -3
- package/dist/client/static/js/one-dark-pro-dhybn1ff.js +1 -0
- package/dist/client/static/js/one-light-bqg77ay0.js +1 -0
- package/dist/client/static/js/packet-AYTQ26CC-xbsyjzrh.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-17ak2zx3.js → pegDiagram-GJSIUBJH-3gp4madx.js} +1 -1
- package/dist/client/static/js/{perl-8z46dmze.js → perl-dvz4y1tb.js} +1 -1
- package/dist/client/static/js/{php-6qvnp2t6.js → php-n6y7dzhm.js} +1 -1
- package/dist/client/static/js/pie-WAS4IAKB-j2tpz0cs.js +1 -0
- package/dist/client/static/js/{pieDiagram-5QR66LMP-at4x1g4q.js → pieDiagram-5QR66LMP-0cbm773h.js} +2 -2
- package/dist/client/static/js/properties-mzvvbqg5.js +1 -0
- package/dist/client/static/js/python-3w64wsyd.js +1 -0
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-apzhwrn4.js → quadrantDiagram-O4NWA36T-jwg7fc9f.js} +1 -1
- package/dist/client/static/js/r-32re2zwb.js +1 -0
- package/dist/client/static/js/radar-RG4KPBEZ-m3tsyfv0.js +1 -0
- package/dist/client/static/js/railroad-74A4TZTK-5p202a4q.js +1 -0
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-hj0y9tgn.js +1 -0
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-8c5dct8f.js +1 -0
- package/dist/client/static/js/railroad-peg-WCYAUIDC-3tx8z65q.js +1 -0
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-rw8cj5f3.js → railroadDiagram-XR7U4H2S-38xh691s.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-qyrse7mb.js → requirementDiagram-PLB6GJNP-gpddawxh.js} +4 -4
- package/dist/client/static/js/{ruby-qy8mhstq.js → ruby-7zye3g0e.js} +1 -1
- package/dist/client/static/js/{rust-fpshqnk0.js → rust-bx3ecv4n.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-254qr59q.js → sankeyDiagram-IPEJSGJF-s6t6bbhk.js} +1 -1
- package/dist/client/static/js/{sass-kbwea482.js → sass-m0h9yzfb.js} +1 -1
- package/dist/client/static/js/{scss-zphrqp25.js → scss-2pwwfkvn.js} +1 -1
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-y9xjxfc5.js → sequenceDiagram-PO4LG4MO-wkq51pmb.js} +3 -3
- package/dist/client/static/js/{sizeCapture-INFHLROL-sc5e60t3.js → sizeCapture-INFHLROL-xtwexf8k.js} +1 -1
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-r134s4xr.js → stateDiagram-v2-GCMORJYK-jnwsqa7y.js} +3 -3
- package/dist/client/static/js/{svelte-mwtx07d9.js → svelte-x8f8c8hq.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-xc7rbawt.js → swimlanes-2SLR337P-mnkkqcbx.js} +1 -1
- package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-6xmrz03n.js +8 -0
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-cgjd8shk.js → timeline-definition-EJHVYXUP-rxq6heqh.js} +2 -2
- package/dist/client/static/js/treeView-Q6P3EWNA-mf0rb2yv.js +1 -0
- package/dist/client/static/js/treemap-WGGIJYW6-0x5gf06b.js +1 -0
- package/dist/client/static/js/typescript-5nmrzgkj.js +1 -0
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-9qsmjhm6.js → usecaseDiagram-POWQR4AR-dz94f57t.js} +13 -13
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-4grw9awx.js → vennDiagram-UO4OBE2U-5mmvkhsq.js} +1 -1
- package/dist/client/static/js/{vue-j8vb9d7r.js → vue-myjjd0gd.js} +1 -1
- package/dist/client/static/js/wardley-WFR3VGLG-x7ej8dms.js +1 -0
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-8gxy0wat.js → wardleyDiagram-VNRHLVJA-dctdntpa.js} +1 -1
- package/dist/client/static/js/xml-3dd1pter.js +1 -0
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-5sh7tdrx.js → xychartDiagram-PMCCYNJV-njyfrqkv.js} +2 -2
- package/dist/client/static/js/yaml-yssayv8a.js +1 -0
- package/package.json +1 -1
- package/src/client/components/common/ComposerPicker.tsx +24 -12
- package/src/client/components/common/ComposerTextarea.tsx +1 -0
- package/src/client/components/layout/session-sidebar/scheduler-modal/ModelFields.tsx +1 -1
- package/src/client/components/settings/apply-side-effects.test.ts +5 -4
- package/src/client/components/workspace/chat-timeline/chat-input/index.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/index.tsx +3 -3
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FormAsk.test.tsx +210 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FormAsk.tsx +342 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/LooseFieldAsk.tsx +44 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/OrphanAsks.test.tsx +44 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/OrphanAsks.tsx +10 -5
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/PluginPendingInteractions.test.ts +1 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/drafts.ts +19 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/form-picks.ts +52 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/index.test.ts +2 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/index.tsx +53 -4
- package/src/client/components/workspace/model-dropdown/index.tsx +1 -1
- package/src/client/components/workspace/model-dropdown/use-catalog.ts +3 -32
- package/src/client/data/settings/omp-schema.json +55 -1
- package/src/client/hooks/chat/composer/harness-model-picker.ts +84 -0
- package/src/client/hooks/chat/composer/index.ts +26 -6
- package/src/client/hooks/chat/timeline/ask-frames.test.ts +80 -7
- package/src/client/hooks/chat/timeline/ask-frames.ts +95 -21
- package/src/client/hooks/models/use-harnesses.ts +15 -2
- package/src/client/hooks/ui/icon-style.ts +7 -4
- package/src/client/hooks/ui/style-attributes.test.ts +11 -11
- package/src/client/hooks/ui/surface-style.ts +8 -5
- package/src/server/lib/assets/shell-attributes.server.ts +12 -9
- package/src/server/lib/assets/shell-attributes.test.ts +18 -13
- package/src/server/lib/auth/agent-gate.server.ts +64 -0
- package/src/server/lib/auth/agent-tree-gate.test.ts +121 -0
- package/src/server/lib/auth/guard.test.ts +18 -18
- package/src/server/lib/auth/guard.ts +15 -11
- package/src/server/lib/auth/handover-guard.test.ts +1 -1
- package/src/server/lib/changes/attach.server.ts +57 -0
- package/src/server/lib/changes/attach.test.ts +94 -0
- package/src/server/lib/changes/blobs.server.ts +52 -0
- package/src/server/lib/changes/capture-bash.server.ts +106 -0
- package/src/server/lib/changes/capture-fs.server.ts +64 -0
- package/src/server/lib/changes/capture-runs.test.ts +136 -0
- package/src/server/lib/changes/capture-test-util.ts +46 -0
- package/src/server/lib/changes/capture-types.ts +62 -0
- package/src/server/lib/changes/capture.server.ts +333 -0
- package/src/server/lib/changes/capture.test.ts +245 -0
- package/src/server/lib/changes/classify-command.test.ts +172 -0
- package/src/server/lib/changes/classify-command.ts +272 -0
- package/src/server/lib/changes/classify-git.ts +88 -0
- package/src/server/lib/changes/classify-paths.ts +112 -0
- package/src/server/lib/changes/classify-tokenize.ts +185 -0
- package/src/server/lib/changes/journal.server.ts +183 -0
- package/src/server/lib/changes/journal.test.ts +125 -0
- package/src/server/lib/changes/merge.test.ts +137 -0
- package/src/server/lib/changes/paths.server.ts +37 -0
- package/src/server/lib/changes/purge.server.ts +32 -0
- package/src/server/lib/changes/reader.server.ts +322 -0
- package/src/server/lib/changes/reader.test.ts +137 -0
- package/src/server/lib/changes/records.ts +120 -0
- package/src/server/lib/changes/scan.server.ts +89 -0
- package/src/server/lib/harness/register.server.ts +3 -0
- package/src/server/lib/omp/rpc/event-fanout.test.ts +58 -0
- package/src/server/lib/omp/rpc/event-fanout.ts +19 -0
- package/src/server/lib/omp/rpc/manager.ts +4 -3
- package/src/server/lib/omp/rpc/session-registration.ts +5 -0
- package/src/server/lib/omp/rpc/session-registry.ts +4 -5
- package/src/server/lib/omp/session/delete.server.ts +4 -0
- package/src/server/lib/sessions/agent-token.server.test.ts +28 -5
- package/src/server/lib/sessions/agent-token.server.ts +42 -6
- package/src/server/lib/sessions/relation-access.server.test.ts +96 -0
- package/src/server/lib/sessions/relation-access.server.ts +71 -0
- package/src/server/routes/sessions/changes.ts +1 -1
- package/src/shared/lib/chat/ask-form/fields.ts +1 -0
- package/src/shared/lib/chat/ask-form/types.ts +6 -0
- package/src/shared/lib/chat/ask-questions.ts +56 -3
- package/src/shared/lib/chat/composer/delegation.ts +2 -13
- package/src/shared/lib/chat/composer/filter.test.ts +39 -0
- package/src/shared/lib/chat/composer/filter.ts +23 -13
- package/src/shared/lib/chat/composer/harness-model-items.test.ts +54 -0
- package/src/shared/lib/chat/composer/harness-model-items.ts +41 -0
- package/src/shared/lib/chat/composer/trigger.test.ts +50 -0
- package/src/shared/lib/chat/composer/trigger.ts +29 -1
- package/src/shared/lib/chat/timeline/changed-files.test.ts +16 -0
- package/src/shared/lib/chat/timeline/changed-files.ts +102 -25
- package/src/shared/lib/harness/catalog.ts +21 -0
- package/src/{client/components/workspace/model-dropdown/harness-models.test.ts → shared/lib/harness/models.test.ts} +1 -1
- package/src/shared/lib/icons/icon-paint-authority.ts +5 -3
- package/src/shared/lib/models/option.ts +46 -0
- package/src/shared/lib/omp/config/schema.test.ts +20 -0
- package/src/shared/lib/theme/icon-style.test.ts +8 -5
- package/src/shared/lib/theme/icon-style.ts +15 -7
- package/src/shared/lib/theme/surface-style.test.ts +8 -5
- package/src/shared/lib/theme/surface-style.ts +17 -7
- package/src/shared/lib/workspace/sidebar-style.test.ts +7 -8
- package/src/shared/lib/workspace/sidebar-style.ts +7 -8
- package/src/shared/types/chat.ts +12 -6
- package/src/shared/types/omp/agent.ts +9 -0
- package/src/shared/types/session-changes.ts +4 -0
- package/dist/client/static/js/architecture-7GRP2DOG-aqft2erp.js +0 -1
- package/dist/client/static/js/c-wkgxb1t1.js +0 -1
- package/dist/client/static/js/cpp-y0t6mynx.js +0 -1
- package/dist/client/static/js/css-r2nhvzff.js +0 -1
- package/dist/client/static/js/css-tf1s0nb7.js +0 -1
- package/dist/client/static/js/cynefin-OW5HDTMX-v2sz60t6.js +0 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-8qbefe4m.js +0 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-krsvgcq7.js +0 -1
- package/dist/client/static/js/gitGraph-4MIJSDKK-9bx1a38k.js +0 -1
- package/dist/client/static/js/graphql-xnpp5gn9.js +0 -1
- package/dist/client/static/js/html-pv88ny12.js +0 -1
- package/dist/client/static/js/index-dh1vd0d9.js +0 -1
- package/dist/client/static/js/info-A6RAGUB7-j51t7jhh.js +0 -1
- package/dist/client/static/js/ini-ygfyhprj.js +0 -1
- package/dist/client/static/js/java-gm49vw59.js +0 -1
- package/dist/client/static/js/javascript-4kw2j9t3.js +0 -1
- package/dist/client/static/js/jsx-ksxw1byz.js +0 -1
- package/dist/client/static/js/lua-53gzb9bx.js +0 -1
- package/dist/client/static/js/markdown-tk3cd3vs.js +0 -1
- package/dist/client/static/js/one-dark-pro-39bt34v9.js +0 -1
- package/dist/client/static/js/one-light-xec0sehr.js +0 -1
- package/dist/client/static/js/packet-AYTQ26CC-n83gfj2g.js +0 -1
- package/dist/client/static/js/pie-WAS4IAKB-5c5pctwz.js +0 -1
- package/dist/client/static/js/properties-2tcybqjk.js +0 -1
- package/dist/client/static/js/python-qph3dntq.js +0 -1
- package/dist/client/static/js/r-gd26x93y.js +0 -1
- package/dist/client/static/js/radar-RG4KPBEZ-52e5n99a.js +0 -1
- package/dist/client/static/js/railroad-74A4TZTK-44nqxxpy.js +0 -1
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-25jxgwg7.js +0 -1
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-64pqpf2y.js +0 -1
- package/dist/client/static/js/railroad-peg-WCYAUIDC-0p5sxzpx.js +0 -1
- package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-kdcdamkj.js +0 -8
- package/dist/client/static/js/treeView-Q6P3EWNA-8j14nnd1.js +0 -1
- package/dist/client/static/js/treemap-WGGIJYW6-esf993kk.js +0 -1
- package/dist/client/static/js/typescript-0s2t05jj.js +0 -1
- package/dist/client/static/js/wardley-WFR3VGLG-v4dxm2sb.js +0 -1
- package/dist/client/static/js/xml-0py2vkw7.js +0 -1
- package/dist/client/static/js/yaml-vghdz0f0.js +0 -1
- /package/src/{client/components/workspace/model-dropdown/harness-models.ts → shared/lib/harness/models.ts} +0 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A session that spans the feature: it ran before the Kabmo journal existed and
|
|
8
|
+
* continued after it.
|
|
9
|
+
*
|
|
10
|
+
* The Kabmo journal starts mid-session, so the omp records older than its first
|
|
11
|
+
* line are merged in. A diff whose two sides straddle the boundary must read
|
|
12
|
+
* the omp blob for the `before` and the Kabmo blob for the `after` — the two
|
|
13
|
+
* stores are separate directories.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
|
|
17
|
+
import * as fsp from 'node:fs/promises';
|
|
18
|
+
import * as os from 'node:os';
|
|
19
|
+
import * as path from 'node:path';
|
|
20
|
+
import { ChangeJournal } from '@/server/lib/changes/journal.server';
|
|
21
|
+
import {
|
|
22
|
+
readSessionChangeDiff,
|
|
23
|
+
readSessionChangeList,
|
|
24
|
+
} from '@/server/lib/changes/reader.server';
|
|
25
|
+
import { clearSessionFileCaches } from '@/server/lib/omp/session/files';
|
|
26
|
+
|
|
27
|
+
const SESSION = 'merge-1';
|
|
28
|
+
const CWD = '/repo';
|
|
29
|
+
let dataDir = '';
|
|
30
|
+
let agentDir = '';
|
|
31
|
+
let ompJournalDir = '';
|
|
32
|
+
let originalData: string | undefined;
|
|
33
|
+
let originalAgent: string | undefined;
|
|
34
|
+
|
|
35
|
+
async function ompBlob(key: string, text: string): Promise<void> {
|
|
36
|
+
await fsp.mkdir(path.join(ompJournalDir, 'blobs'), { recursive: true });
|
|
37
|
+
await fsp.writeFile(path.join(ompJournalDir, 'blobs', key), Bun.gzipSync(Buffer.from(text, 'utf8')));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function ompChange(record: Record<string, unknown>): Promise<void> {
|
|
41
|
+
await fsp.appendFile(path.join(ompJournalDir, 'changes.jsonl'), `${JSON.stringify(record)}\n`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
beforeAll(async () => {
|
|
45
|
+
originalData = Bun.env.KABMO_DATA_DIR;
|
|
46
|
+
originalAgent = Bun.env.PI_CODING_AGENT_DIR;
|
|
47
|
+
dataDir = await fsp.mkdtemp(path.join(os.tmpdir(), 'kabmo-merge-data-'));
|
|
48
|
+
agentDir = await fsp.mkdtemp(path.join(os.tmpdir(), 'kabmo-merge-agent-'));
|
|
49
|
+
Bun.env.KABMO_DATA_DIR = dataDir;
|
|
50
|
+
Bun.env.PI_CODING_AGENT_DIR = agentDir;
|
|
51
|
+
clearSessionFileCaches();
|
|
52
|
+
|
|
53
|
+
const projectDir = path.join(agentDir, 'sessions', '-repo');
|
|
54
|
+
await fsp.mkdir(projectDir, { recursive: true });
|
|
55
|
+
const sessionFile = path.join(projectDir, `2026-01-01T00-00-00-000Z_${SESSION}.jsonl`);
|
|
56
|
+
await fsp.writeFile(
|
|
57
|
+
sessionFile,
|
|
58
|
+
`${JSON.stringify({ type: 'session', version: 3, id: SESSION, timestamp: '2026-01-01T00:00:00.000Z', cwd: CWD })}\n`,
|
|
59
|
+
);
|
|
60
|
+
ompJournalDir = sessionFile.slice(0, -'.jsonl'.length);
|
|
61
|
+
await fsp.mkdir(ompJournalDir, { recursive: true });
|
|
62
|
+
|
|
63
|
+
// The pre-feature half: an omp create and an omp update.
|
|
64
|
+
await ompBlob('omp-a', 'A');
|
|
65
|
+
await ompBlob('omp-b1', 'B1');
|
|
66
|
+
await ompBlob('omp-b2', 'B2');
|
|
67
|
+
await ompChange({ type: 'change', at: 100, agent: 'Main', tool: 'edit', path: '/repo/a.ts', before: null, after: 'omp-a' });
|
|
68
|
+
await ompChange({ type: 'change', at: 110, agent: 'Main', tool: 'edit', path: '/repo/b.ts', before: 'omp-b1', after: 'omp-b2' });
|
|
69
|
+
// After the first Kabmo line: must NOT be merged.
|
|
70
|
+
await ompChange({ type: 'change', at: 300, agent: 'Main', tool: 'edit', path: '/repo/d.ts', before: null, after: 'omp-a' });
|
|
71
|
+
// A pre-feature creation whose file is gone: the omp heuristic drops it.
|
|
72
|
+
await ompChange({ type: 'change', at: 120, agent: 'Main', tool: 'edit', path: '/repo/e.ts', before: null, after: 'omp-a' });
|
|
73
|
+
|
|
74
|
+
// The post-feature half: a Kabmo update of a.ts and b.ts, plus a new c.ts.
|
|
75
|
+
const journal = new ChangeJournal(SESSION, CWD);
|
|
76
|
+
await journal.recordChange({
|
|
77
|
+
at: 200, agent: 'Main', tool: 'bash', op: 'update', path: '/repo/a.ts',
|
|
78
|
+
displayPath: 'a.ts', before: 'A', after: 'A2', source: 'trace', command: 'sed -i s/A/A2/ a.ts',
|
|
79
|
+
});
|
|
80
|
+
await journal.recordChange({
|
|
81
|
+
at: 210, agent: 'Main', tool: 'bash', op: 'update', path: '/repo/b.ts',
|
|
82
|
+
displayPath: 'b.ts', before: 'B2', after: 'B3', source: 'trace', command: 'sed -i s/B2/B3/ b.ts',
|
|
83
|
+
});
|
|
84
|
+
await journal.recordChange({
|
|
85
|
+
at: 220, agent: 'Main', tool: 'write', op: 'create', path: '/repo/c.ts',
|
|
86
|
+
displayPath: 'c.ts', before: null, after: 'C', source: 'tool',
|
|
87
|
+
});
|
|
88
|
+
await journal.flush();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
afterAll(async () => {
|
|
92
|
+
if (originalData === undefined) delete Bun.env.KABMO_DATA_DIR;
|
|
93
|
+
else Bun.env.KABMO_DATA_DIR = originalData;
|
|
94
|
+
if (originalAgent === undefined) delete Bun.env.PI_CODING_AGENT_DIR;
|
|
95
|
+
else Bun.env.PI_CODING_AGENT_DIR = originalAgent;
|
|
96
|
+
clearSessionFileCaches();
|
|
97
|
+
await fsp.rm(dataDir, { recursive: true, force: true });
|
|
98
|
+
await fsp.rm(agentDir, { recursive: true, force: true });
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
describe('a session that spans the feature', () => {
|
|
102
|
+
test('merges the omp records older than the first Kabmo line', async () => {
|
|
103
|
+
const records = await readSessionChangeList(SESSION);
|
|
104
|
+
expect(records.map((record) => record.path)).toEqual([
|
|
105
|
+
'/repo/a.ts',
|
|
106
|
+
'/repo/b.ts',
|
|
107
|
+
'/repo/a.ts',
|
|
108
|
+
'/repo/b.ts',
|
|
109
|
+
'/repo/c.ts',
|
|
110
|
+
]);
|
|
111
|
+
// The omp record after the boundary is not merged.
|
|
112
|
+
expect(records.some((record) => record.path === '/repo/d.ts')).toBe(false);
|
|
113
|
+
// A pre-feature creation whose file is gone is dropped by the omp heuristic.
|
|
114
|
+
expect(records.some((record) => record.path === '/repo/e.ts')).toBe(false);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
test('a diff straddling the boundary reads each side from its own store', async () => {
|
|
118
|
+
const diff = await readSessionChangeDiff(SESSION, '/repo/b.ts', 0, 1000);
|
|
119
|
+
expect(diff?.status).toBe('modified');
|
|
120
|
+
expect(diff?.oldContent).toBe('B1');
|
|
121
|
+
expect(diff?.newContent).toBe('B3');
|
|
122
|
+
expect(diff?.unavailable).toBe(false);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
test('a create before the boundary and an update after it is one added file', async () => {
|
|
126
|
+
const diff = await readSessionChangeDiff(SESSION, '/repo/a.ts', 0, 1000);
|
|
127
|
+
expect(diff?.status).toBe('added');
|
|
128
|
+
expect(diff?.oldContent).toBe('');
|
|
129
|
+
expect(diff?.newContent).toBe('A2');
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
test('a Kabmo-only path reads the Kabmo store', async () => {
|
|
133
|
+
const diff = await readSessionChangeDiff(SESSION, '/repo/c.ts', 0, 1000);
|
|
134
|
+
expect(diff?.status).toBe('added');
|
|
135
|
+
expect(diff?.newContent).toBe('C');
|
|
136
|
+
});
|
|
137
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Where a session's Kabmo change journal lives.
|
|
8
|
+
*
|
|
9
|
+
* `~/.kabmo/changes/<sessionId>/` — beside the database, the same root `btw/`
|
|
10
|
+
* uses, so a delete of the data directory takes the journals with it. The
|
|
11
|
+
* session id is a single path segment by construction (omp UUIDs, mock
|
|
12
|
+
* integers); the guard is here because the reader is reached from a route
|
|
13
|
+
* parameter, and `path.join` normalizes a `..` into a different directory.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import path from 'node:path';
|
|
17
|
+
import { getDataDir } from '@/server/lib/lifecycle/paths';
|
|
18
|
+
import { isSinglePathSegment } from '@/server/lib/fs/path-segment';
|
|
19
|
+
|
|
20
|
+
export function changesRoot(): string {
|
|
21
|
+
return path.join(getDataDir(), 'changes');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function sessionChangesDir(sessionId: string): string {
|
|
25
|
+
if (!isSinglePathSegment(sessionId)) {
|
|
26
|
+
throw new Error(`Invalid session id for a change journal: ${JSON.stringify(sessionId)}`);
|
|
27
|
+
}
|
|
28
|
+
return path.join(changesRoot(), sessionId);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function journalPath(sessionId: string): string {
|
|
32
|
+
return path.join(sessionChangesDir(sessionId), 'changes.jsonl');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function blobsDir(sessionId: string): string {
|
|
36
|
+
return path.join(sessionChangesDir(sessionId), 'blobs');
|
|
37
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Remove a session's Kabmo change journal.
|
|
8
|
+
*
|
|
9
|
+
* The journal is derived data, but it holds file contents: leaving it behind
|
|
10
|
+
* after a delete would keep a copy of every file the run touched, under an id
|
|
11
|
+
* the sidebar no longer lists. The directory is the unit — `changes.jsonl`,
|
|
12
|
+
* its rotated siblings and `blobs/` all live under it.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { rm } from 'node:fs/promises';
|
|
16
|
+
import { sessionChangesDir } from '@/server/lib/changes/paths.server';
|
|
17
|
+
|
|
18
|
+
/** True when a journal directory existed and was removed. */
|
|
19
|
+
export async function purgeChangeJournal(sessionId: string): Promise<boolean> {
|
|
20
|
+
let dir: string;
|
|
21
|
+
try {
|
|
22
|
+
dir = sessionChangesDir(sessionId);
|
|
23
|
+
} catch {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
await rm(dir, { recursive: true, force: true });
|
|
28
|
+
return true;
|
|
29
|
+
} catch {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Read a session's Kabmo change journal, with omp's journal as the fallback and
|
|
8
|
+
* the pre-feature half merged in.
|
|
9
|
+
*
|
|
10
|
+
* The Kabmo journal is the answer when it has any `change` record: it sees the
|
|
11
|
+
* `bash` mutations omp never records, and a delete is a record rather than a
|
|
12
|
+
* creation whose file happens to be gone. A session that predates the feature
|
|
13
|
+
* has no Kabmo journal, so the omp reader answers — read directly, not
|
|
14
|
+
* imported, because an import would duplicate the blobs and the lines.
|
|
15
|
+
*
|
|
16
|
+
* A session that SPANS the feature is the third case: it ran before the journal
|
|
17
|
+
* existed and continued after it. The Kabmo journal then starts mid-session, so
|
|
18
|
+
* the omp records older than its first line are merged in. Newer omp records
|
|
19
|
+
* are not: from the first Kabmo line on, the Kabmo journal is the authority,
|
|
20
|
+
* and merging both would double every edit the two writers both saw.
|
|
21
|
+
*
|
|
22
|
+
* Each merged record carries the store its blob keys belong to, so a diff whose
|
|
23
|
+
* two sides straddle the boundary reads the right blob directory.
|
|
24
|
+
*
|
|
25
|
+
* The parse is cached by the size+mtime of every journal file, the same rule
|
|
26
|
+
* the omp reader follows. A torn final line is skipped, not fatal.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
import { readdir, stat } from 'node:fs/promises';
|
|
30
|
+
import path from 'node:path';
|
|
31
|
+
import { blobsDir, sessionChangesDir } from '@/server/lib/changes/paths.server';
|
|
32
|
+
import { readBlob } from '@/server/lib/changes/blobs.server';
|
|
33
|
+
import { parseJournalLine, type JournalChangeRecord } from '@/server/lib/changes/records';
|
|
34
|
+
import {
|
|
35
|
+
readSessionChangeIndex as readOmpIndex,
|
|
36
|
+
readSessionChangeList as readOmpList,
|
|
37
|
+
} from '@/server/lib/omp/session/changes';
|
|
38
|
+
import { findSessionFileById } from '@/server/lib/omp/session/locator';
|
|
39
|
+
import { siblingDirForSession } from '@/server/lib/omp/subagent/history/paths';
|
|
40
|
+
import { unifiedDiff } from '@/shared/lib/fs/unified-diff';
|
|
41
|
+
import { patchSides } from '@/shared/lib/fs/patch-sides';
|
|
42
|
+
import type {
|
|
43
|
+
SessionChangeCounts,
|
|
44
|
+
SessionChangeDiff,
|
|
45
|
+
SessionChangeRecord,
|
|
46
|
+
} from '@/shared/types/session-changes';
|
|
47
|
+
|
|
48
|
+
interface CacheEntry {
|
|
49
|
+
signature: string;
|
|
50
|
+
records: JournalChangeRecord[];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
interface CacheHost {
|
|
54
|
+
entries: Map<string, CacheEntry>;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
declare global {
|
|
58
|
+
// eslint-disable-next-line no-var
|
|
59
|
+
var __kabmoChangeJournalCache: CacheHost | undefined;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function cache(): CacheHost {
|
|
63
|
+
if (!globalThis.__kabmoChangeJournalCache) globalThis.__kabmoChangeJournalCache = { entries: new Map() };
|
|
64
|
+
return globalThis.__kabmoChangeJournalCache;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Journal files oldest first: rotated `changes.<epoch>.jsonl`, then the current one. */
|
|
68
|
+
function journalFiles(names: string[]): string[] {
|
|
69
|
+
return names
|
|
70
|
+
.filter((name) => name === 'changes.jsonl' || /^changes\.\d+\.jsonl$/.test(name))
|
|
71
|
+
.sort();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async function signatureFor(dir: string, files: string[]): Promise<string> {
|
|
75
|
+
const parts: string[] = [];
|
|
76
|
+
for (const name of files) {
|
|
77
|
+
const info = await stat(path.join(dir, name)).catch(() => null);
|
|
78
|
+
parts.push(`${name}:${info?.size ?? 0}:${info?.mtimeMs ?? 0}`);
|
|
79
|
+
}
|
|
80
|
+
return parts.join('|');
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async function readJournalRecords(sessionId: string): Promise<JournalChangeRecord[]> {
|
|
84
|
+
let dir: string;
|
|
85
|
+
try {
|
|
86
|
+
dir = sessionChangesDir(sessionId);
|
|
87
|
+
} catch {
|
|
88
|
+
return [];
|
|
89
|
+
}
|
|
90
|
+
let names: string[];
|
|
91
|
+
try {
|
|
92
|
+
names = await readdir(dir);
|
|
93
|
+
} catch {
|
|
94
|
+
return [];
|
|
95
|
+
}
|
|
96
|
+
const files = journalFiles(names);
|
|
97
|
+
if (files.length === 0) return [];
|
|
98
|
+
|
|
99
|
+
const signature = await signatureFor(dir, files);
|
|
100
|
+
const cached = cache().entries.get(sessionId);
|
|
101
|
+
if (cached && cached.signature === signature) return cached.records;
|
|
102
|
+
|
|
103
|
+
const records: JournalChangeRecord[] = [];
|
|
104
|
+
for (const name of files) {
|
|
105
|
+
const text = await Bun.file(path.join(dir, name)).text().catch(() => '');
|
|
106
|
+
for (const line of text.split('\n')) {
|
|
107
|
+
const record = parseJournalLine(line);
|
|
108
|
+
if (record?.type === 'change') records.push(record);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
records.sort((a, b) => a.at - b.at);
|
|
112
|
+
cache().entries.set(sessionId, { signature, records });
|
|
113
|
+
return records;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** One record plus the blob store its `before`/`after` keys belong to. */
|
|
117
|
+
interface MergedRecord {
|
|
118
|
+
at: number;
|
|
119
|
+
runId?: string;
|
|
120
|
+
runAt?: number;
|
|
121
|
+
agent: string;
|
|
122
|
+
parent?: string;
|
|
123
|
+
tool: string;
|
|
124
|
+
path: string;
|
|
125
|
+
displayPath: string;
|
|
126
|
+
before: string | null | undefined;
|
|
127
|
+
after: string | null | undefined;
|
|
128
|
+
store: 'kabmo' | 'omp';
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** The omp journal's blob directory, or `null` when the session has no file. */
|
|
132
|
+
async function ompBlobDir(sessionId: string): Promise<string | null> {
|
|
133
|
+
const sessionFile = await findSessionFileById(sessionId);
|
|
134
|
+
if (!sessionFile) return null;
|
|
135
|
+
return path.join(siblingDirForSession(sessionFile), 'blobs');
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* The session's records, oldest first.
|
|
140
|
+
*
|
|
141
|
+
* `list` selects the omp reader's list variant (which drops a creation whose
|
|
142
|
+
* file is gone) for the no-Kabmo fallback. Once a Kabmo journal exists, the omp
|
|
143
|
+
* half is read RAW: the Kabmo `delete` record is the other half of a
|
|
144
|
+
* create-then-delete, and the client's net logic drops the pair.
|
|
145
|
+
*/
|
|
146
|
+
async function readMergedRecords(sessionId: string, list: boolean): Promise<MergedRecord[]> {
|
|
147
|
+
const kabmo = await readJournalRecords(sessionId);
|
|
148
|
+
if (kabmo.length === 0) {
|
|
149
|
+
const omp = list ? await readOmpList(sessionId) : await readOmpIndex(sessionId);
|
|
150
|
+
return omp.map((record) => ({ ...record, store: 'omp' as const }));
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const firstKabmoAt = kabmo[0].at;
|
|
154
|
+
const omp = await readOmpIndex(sessionId);
|
|
155
|
+
const merged: MergedRecord[] = [];
|
|
156
|
+
for (const record of omp) {
|
|
157
|
+
if (record.at >= firstKabmoAt) continue;
|
|
158
|
+
merged.push({ ...record, store: 'omp' });
|
|
159
|
+
}
|
|
160
|
+
for (const record of kabmo) {
|
|
161
|
+
merged.push({
|
|
162
|
+
at: record.at,
|
|
163
|
+
...(record.runId ? { runId: record.runId } : {}),
|
|
164
|
+
...(record.runAt !== undefined ? { runAt: record.runAt } : {}),
|
|
165
|
+
agent: record.agent,
|
|
166
|
+
...(record.parent ? { parent: record.parent } : {}),
|
|
167
|
+
tool: record.tool,
|
|
168
|
+
path: record.path,
|
|
169
|
+
displayPath: record.displayPath,
|
|
170
|
+
before: record.before,
|
|
171
|
+
after: record.after,
|
|
172
|
+
store: 'kabmo',
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
merged.sort((a, b) => a.at - b.at);
|
|
176
|
+
return merged;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function toSessionChangeRecord(record: MergedRecord): SessionChangeRecord {
|
|
180
|
+
return {
|
|
181
|
+
at: record.at,
|
|
182
|
+
...(record.runId ? { runId: record.runId } : {}),
|
|
183
|
+
...(record.runAt !== undefined ? { runAt: record.runAt } : {}),
|
|
184
|
+
agent: record.agent,
|
|
185
|
+
...(record.parent ? { parent: record.parent } : {}),
|
|
186
|
+
tool: record.tool,
|
|
187
|
+
path: record.path,
|
|
188
|
+
displayPath: record.displayPath,
|
|
189
|
+
before: record.before,
|
|
190
|
+
after: record.after,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** True when the path is still on disk; a stat error other than ENOENT counts
|
|
195
|
+
* as present, so a permission problem never hides a real change. */
|
|
196
|
+
async function pathExists(absolute: string): Promise<boolean> {
|
|
197
|
+
try {
|
|
198
|
+
await stat(absolute);
|
|
199
|
+
return true;
|
|
200
|
+
} catch (error) {
|
|
201
|
+
return (error as NodeJS.ErrnoException).code !== 'ENOENT';
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** Resolve a blob key from the store that wrote it. */
|
|
206
|
+
async function resolveMergedBlob(
|
|
207
|
+
sessionId: string,
|
|
208
|
+
store: MergedRecord['store'],
|
|
209
|
+
key: string | null | undefined,
|
|
210
|
+
): Promise<string | null | undefined> {
|
|
211
|
+
if (key === null) return null;
|
|
212
|
+
if (key === undefined) return undefined;
|
|
213
|
+
if (store === 'kabmo') return readBlob(blobsDir(sessionId), key);
|
|
214
|
+
const dir = await ompBlobDir(sessionId);
|
|
215
|
+
return dir ? readBlob(dir, key) : undefined;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** Every change record of one session, oldest first, with display paths. */
|
|
219
|
+
export async function readSessionChangeIndex(sessionId: string): Promise<SessionChangeRecord[]> {
|
|
220
|
+
const records = await readMergedRecords(sessionId, false);
|
|
221
|
+
return records.map(toSessionChangeRecord);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* The index the chat's per-run list reads.
|
|
226
|
+
*
|
|
227
|
+
* A session with no Kabmo journal falls back to the omp list, which still needs
|
|
228
|
+
* its "creation whose file is gone" heuristic. Once a Kabmo journal exists, the
|
|
229
|
+
* merged list is raw and the client's net logic drops a create-then-delete.
|
|
230
|
+
*/
|
|
231
|
+
export async function readSessionChangeList(sessionId: string): Promise<SessionChangeRecord[]> {
|
|
232
|
+
const records = await readMergedRecords(sessionId, true);
|
|
233
|
+
// The omp half keeps its own heuristic for a path the Kabmo journal never
|
|
234
|
+
// mentions: a creation whose file is gone was created and deleted before the
|
|
235
|
+
// feature, and its net change is zero. A path the Kabmo journal DOES mention
|
|
236
|
+
// is left to the client's net logic, which sees the Kabmo delete record.
|
|
237
|
+
const kabmoPaths = new Set(records.filter((record) => record.store === 'kabmo').map((record) => record.path));
|
|
238
|
+
const gone = new Set<string>();
|
|
239
|
+
await Promise.all(
|
|
240
|
+
records
|
|
241
|
+
.filter((record) => record.store === 'omp' && record.before === null && !kabmoPaths.has(record.path))
|
|
242
|
+
.map(async (record) => {
|
|
243
|
+
if (!(await pathExists(record.path))) gone.add(record.path);
|
|
244
|
+
}),
|
|
245
|
+
);
|
|
246
|
+
return records.filter((record) => !gone.has(record.path)).map(toSessionChangeRecord);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/** The net change of `absolutePath` inside `[from, to]`. */
|
|
250
|
+
export async function readSessionChangeDiff(
|
|
251
|
+
sessionId: string,
|
|
252
|
+
absolutePath: string,
|
|
253
|
+
from: number,
|
|
254
|
+
to: number,
|
|
255
|
+
): Promise<SessionChangeDiff | null> {
|
|
256
|
+
const records = await readMergedRecords(sessionId, false);
|
|
257
|
+
const inRange = records
|
|
258
|
+
.filter((record) => record.path === absolutePath && record.at >= from && record.at <= to)
|
|
259
|
+
.sort((a, b) => a.at - b.at);
|
|
260
|
+
if (inRange.length === 0) return null;
|
|
261
|
+
|
|
262
|
+
const first = inRange[0];
|
|
263
|
+
const last = inRange[inRange.length - 1];
|
|
264
|
+
const status = first.before === null ? 'added' : last.after === null ? 'deleted' : 'modified';
|
|
265
|
+
const [before, after] = await Promise.all([
|
|
266
|
+
resolveMergedBlob(sessionId, first.store, first.before),
|
|
267
|
+
resolveMergedBlob(sessionId, last.store, last.after),
|
|
268
|
+
]);
|
|
269
|
+
if (before === undefined || after === undefined) {
|
|
270
|
+
return {
|
|
271
|
+
path: absolutePath,
|
|
272
|
+
displayPath: last.displayPath,
|
|
273
|
+
status,
|
|
274
|
+
oldContent: '',
|
|
275
|
+
newContent: '',
|
|
276
|
+
diff: '',
|
|
277
|
+
unavailable: true,
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
const oldContent = before ?? '';
|
|
281
|
+
const newContent = after ?? '';
|
|
282
|
+
return {
|
|
283
|
+
path: absolutePath,
|
|
284
|
+
displayPath: last.displayPath,
|
|
285
|
+
status,
|
|
286
|
+
oldContent,
|
|
287
|
+
newContent,
|
|
288
|
+
diff: unifiedDiff(last.displayPath, oldContent, newContent),
|
|
289
|
+
unavailable: false,
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/** Net `+`/`−` line counts for every path changed inside `[from, to]`. */
|
|
294
|
+
export async function readSessionChangeStats(
|
|
295
|
+
sessionId: string,
|
|
296
|
+
from: number,
|
|
297
|
+
to: number,
|
|
298
|
+
): Promise<Record<string, SessionChangeCounts>> {
|
|
299
|
+
const records = await readMergedRecords(sessionId, false);
|
|
300
|
+
const spans = new Map<string, { first: MergedRecord; last: MergedRecord }>();
|
|
301
|
+
for (const record of records) {
|
|
302
|
+
if (record.at < from || record.at > to) continue;
|
|
303
|
+
const span = spans.get(record.path);
|
|
304
|
+
if (span) span.last = record;
|
|
305
|
+
else spans.set(record.path, { first: record, last: record });
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
const stats: Record<string, SessionChangeCounts> = {};
|
|
309
|
+
await Promise.all(
|
|
310
|
+
[...spans].map(async ([absolutePath, { first, last }]) => {
|
|
311
|
+
const [before, after] = await Promise.all([
|
|
312
|
+
resolveMergedBlob(sessionId, first.store, first.before),
|
|
313
|
+
resolveMergedBlob(sessionId, last.store, last.after),
|
|
314
|
+
]);
|
|
315
|
+
if (before === undefined || after === undefined) return;
|
|
316
|
+
const sides = patchSides(unifiedDiff(absolutePath, before ?? '', after ?? ''));
|
|
317
|
+
if (sides.additions === 0 && sides.deletions === 0) return;
|
|
318
|
+
stats[absolutePath] = { added: sides.additions, removed: sides.deletions };
|
|
319
|
+
}),
|
|
320
|
+
);
|
|
321
|
+
return stats;
|
|
322
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The journal reader: the net change of a run, the `+`/`−` counts, and the
|
|
8
|
+
* fallback to omp's journal for a session that predates the feature.
|
|
9
|
+
*
|
|
10
|
+
* The net rule is the one the diff tab shows — the first record's `before` to
|
|
11
|
+
* the last record's `after` — so a create-then-update reads as one added file,
|
|
12
|
+
* not two writes.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
|
|
16
|
+
import * as fsp from 'node:fs/promises';
|
|
17
|
+
import * as os from 'node:os';
|
|
18
|
+
import * as path from 'node:path';
|
|
19
|
+
import { ChangeJournal } from '@/server/lib/changes/journal.server';
|
|
20
|
+
import { journalPath } from '@/server/lib/changes/paths.server';
|
|
21
|
+
import {
|
|
22
|
+
readSessionChangeDiff,
|
|
23
|
+
readSessionChangeIndex,
|
|
24
|
+
readSessionChangeList,
|
|
25
|
+
readSessionChangeStats,
|
|
26
|
+
} from '@/server/lib/changes/reader.server';
|
|
27
|
+
import { clearSessionFileCaches } from '@/server/lib/omp/session/files';
|
|
28
|
+
|
|
29
|
+
const SESSION = 'sess-read';
|
|
30
|
+
let dataDir = '';
|
|
31
|
+
let agentDir = '';
|
|
32
|
+
let originalData: string | undefined;
|
|
33
|
+
let originalAgent: string | undefined;
|
|
34
|
+
|
|
35
|
+
beforeAll(async () => {
|
|
36
|
+
originalData = Bun.env.KABMO_DATA_DIR;
|
|
37
|
+
originalAgent = Bun.env.PI_CODING_AGENT_DIR;
|
|
38
|
+
dataDir = await fsp.mkdtemp(path.join(os.tmpdir(), 'kabmo-changes-read-'));
|
|
39
|
+
agentDir = await fsp.mkdtemp(path.join(os.tmpdir(), 'kabmo-changes-agent-'));
|
|
40
|
+
Bun.env.KABMO_DATA_DIR = dataDir;
|
|
41
|
+
Bun.env.PI_CODING_AGENT_DIR = agentDir;
|
|
42
|
+
clearSessionFileCaches();
|
|
43
|
+
|
|
44
|
+
const journal = new ChangeJournal(SESSION, '/repo');
|
|
45
|
+
await journal.recordChange({
|
|
46
|
+
at: 100, runId: 'r-1', runAt: 90, agent: 'Main', tool: 'edit', op: 'create', path: '/repo/a.ts',
|
|
47
|
+
displayPath: 'a.ts', before: null, after: 'A', source: 'tool',
|
|
48
|
+
});
|
|
49
|
+
await journal.recordChange({
|
|
50
|
+
at: 200, agent: 'Main', tool: 'edit', op: 'update', path: '/repo/a.ts',
|
|
51
|
+
displayPath: 'a.ts', before: 'A', after: 'B', source: 'tool',
|
|
52
|
+
});
|
|
53
|
+
await journal.recordChange({
|
|
54
|
+
at: 300, agent: 'Main', tool: 'bash', op: 'delete', path: '/repo/b.ts',
|
|
55
|
+
displayPath: 'b.ts', before: 'X', after: null, source: 'trace', command: 'rm b.ts', exit: 0,
|
|
56
|
+
});
|
|
57
|
+
await journal.flush();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
afterAll(async () => {
|
|
61
|
+
if (originalData === undefined) delete Bun.env.KABMO_DATA_DIR;
|
|
62
|
+
else Bun.env.KABMO_DATA_DIR = originalData;
|
|
63
|
+
if (originalAgent === undefined) delete Bun.env.PI_CODING_AGENT_DIR;
|
|
64
|
+
else Bun.env.PI_CODING_AGENT_DIR = originalAgent;
|
|
65
|
+
clearSessionFileCaches();
|
|
66
|
+
await fsp.rm(dataDir, { recursive: true, force: true });
|
|
67
|
+
await fsp.rm(agentDir, { recursive: true, force: true });
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
describe('readSessionChangeIndex', () => {
|
|
71
|
+
test('returns every record, oldest first, with display paths', async () => {
|
|
72
|
+
const records = await readSessionChangeIndex(SESSION);
|
|
73
|
+
expect(records.map((record) => record.displayPath)).toEqual(['a.ts', 'a.ts', 'b.ts']);
|
|
74
|
+
expect(records[2]?.tool).toBe('bash');
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
describe('run fields', () => {
|
|
79
|
+
test('maps the run id and its start time', async () => {
|
|
80
|
+
const records = await readSessionChangeIndex(SESSION);
|
|
81
|
+
expect(records[0]?.runId).toBe('r-1');
|
|
82
|
+
expect(records[0]?.runAt).toBe(90);
|
|
83
|
+
expect(records[1]?.runId).toBeUndefined();
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
describe('readSessionChangeList', () => {
|
|
88
|
+
test('keeps a delete record instead of inferring it from the filesystem', async () => {
|
|
89
|
+
const records = await readSessionChangeList(SESSION);
|
|
90
|
+
expect(records.length).toBe(3);
|
|
91
|
+
expect(records.some((record) => record.path === '/repo/b.ts')).toBe(true);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
describe('readSessionChangeDiff', () => {
|
|
96
|
+
test('is the first before to the last after', async () => {
|
|
97
|
+
const diff = await readSessionChangeDiff(SESSION, '/repo/a.ts', 0, 1000);
|
|
98
|
+
expect(diff?.status).toBe('added');
|
|
99
|
+
expect(diff?.oldContent).toBe('');
|
|
100
|
+
expect(diff?.newContent).toBe('B');
|
|
101
|
+
expect(diff?.unavailable).toBe(false);
|
|
102
|
+
expect(diff?.diff).toContain('+B');
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test('a deleted path has an empty after side', async () => {
|
|
106
|
+
const diff = await readSessionChangeDiff(SESSION, '/repo/b.ts', 0, 1000);
|
|
107
|
+
expect(diff?.status).toBe('deleted');
|
|
108
|
+
expect(diff?.oldContent).toBe('X');
|
|
109
|
+
expect(diff?.newContent).toBe('');
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
test('a path outside the window has no diff', async () => {
|
|
113
|
+
expect(await readSessionChangeDiff(SESSION, '/repo/a.ts', 500, 1000)).toBeNull();
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
describe('readSessionChangeStats', () => {
|
|
118
|
+
test('counts the net pair, not each write', async () => {
|
|
119
|
+
const stats = await readSessionChangeStats(SESSION, 0, 1000);
|
|
120
|
+
expect(stats['/repo/a.ts']).toEqual({ added: 1, removed: 0 });
|
|
121
|
+
expect(stats['/repo/b.ts']).toEqual({ added: 0, removed: 1 });
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
describe('fallback', () => {
|
|
126
|
+
test('a session with no Kabmo journal answers the omp reader (empty here)', async () => {
|
|
127
|
+
expect(await readSessionChangeIndex('no-such-session')).toEqual([]);
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
describe('torn line', () => {
|
|
132
|
+
test('a partial final line does not hide the earlier records', async () => {
|
|
133
|
+
await fsp.appendFile(journalPath(SESSION), '{"v":1,"type":"change"');
|
|
134
|
+
const records = await readSessionChangeIndex(SESSION);
|
|
135
|
+
expect(records.length).toBe(3);
|
|
136
|
+
});
|
|
137
|
+
});
|