@kabmo-labs/kabmo 0.40.0 → 0.41.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 +360 -359
- package/dist/client/static/js/{CsvGrid-j9nvnhq1.js → CsvGrid-60njj97j.js} +2 -2
- package/dist/client/static/js/{DocxView-87gnpm81.js → DocxView-rsv0j46a.js} +1 -1
- package/dist/client/static/js/{DrawioView-a351t8f8.js → DrawioView-n2g5df3a.js} +1 -1
- package/dist/client/static/js/{ImageView-c139r891.js → ImageView-t330jx6y.js} +1 -1
- package/dist/client/static/js/LayoutWrapper-qp6nsw65.js +2 -0
- package/dist/client/static/js/{Modal-0weqfqvk.js → Modal-sbya4ahp.js} +9 -9
- package/dist/client/static/js/{PdfView-n6bwcvc8.js → PdfView-1r7a0qkp.js} +1 -1
- package/dist/client/static/js/SessionsView-yqs5m8tj.js +1 -0
- package/dist/client/static/js/{SheetView-k8ymr87w.js → SheetView-bt5pp042.js} +8 -8
- package/dist/client/static/js/{SvgPreview-5pcp444e.js → SvgPreview-vfmqgmrx.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-psav75bx.js → abnfDiagram-O67JEVCF-8k5hk1yx.js} +1 -1
- package/dist/client/static/js/architecture-7GRP2DOG-1wqga929.js +1 -0
- package/dist/client/static/js/{architectureDiagram-NJMV4G6O-9bk6ykn7.js → architectureDiagram-NJMV4G6O-7jcb7fgy.js} +2 -2
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-17xsf182.js → blockDiagram-BEXU5L5S-04sbtdth.js} +1 -1
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-jn9j4n04.js → c4Diagram-YGBWAQC7-vwac9za0.js} +1 -1
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-663z1g1r.js → classDiagram-v2-NBCMYWYE-18cc0bsb.js} +1 -1
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-vp4yvx8x.js → cose-bilkent-JH36ORCC-dk683zvp.js} +1 -1
- package/dist/client/static/js/css-2re5mbea.js +1 -0
- package/dist/client/static/js/cynefin-OW5HDTMX-j2dpdgkh.js +1 -0
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-dagkrjbh.js → cynefinDiagram-VND7K2PF-m2sx8d8s.js} +1 -1
- package/dist/client/static/js/{dagre-6A5THRUB-8qgwpb5a.js → dagre-6A5THRUB-qf3pr59p.js} +2 -2
- package/dist/client/static/js/{diagram-22UHCM2B-671xtp0d.js → diagram-22UHCM2B-twnz23mt.js} +1 -1
- package/dist/client/static/js/{diagram-3UASUU5V-8nn5fha8.js → diagram-3UASUU5V-417bas6t.js} +1 -1
- package/dist/client/static/js/{diagram-ATOU4E4O-dnar0ktg.js → diagram-ATOU4E4O-n63cpdnx.js} +1 -1
- package/dist/client/static/js/{diagram-CDSNMT55-bt0fhk7n.js → diagram-CDSNMT55-v86p14dd.js} +1 -1
- package/dist/client/static/js/{diagram-MLGK6HIB-tp6dwxdb.js → diagram-MLGK6HIB-7a0h1hs3.js} +1 -1
- package/dist/client/static/js/{diagram-MPIPVDR6-qgx8c8ee.js → diagram-MPIPVDR6-w75bftmd.js} +1 -1
- package/dist/client/static/js/{dockerfile-hk0s4qaw.js → dockerfile-g5qbaeq3.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-nmf9r33z.js → ebnfDiagram-ZINNZB2B-vdzm3tsv.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-dheh5ngz.js → elk-276RUBZZ-2fsbb484.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-8837mk18.js → erDiagram-OPXOYQCR-vnkztq7d.js} +1 -1
- package/dist/client/static/js/{erlang-w9gmf866.js → erlang-jqqa3ehb.js} +1 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-xjvjawd3.js +1 -0
- package/dist/client/static/js/flowDiagram-KWPJA3E3-j21f2bfg.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-g68mvnje.js → ganttDiagram-FUAMR5RP-pbvcch52.js} +1 -1
- package/dist/client/static/js/gitGraph-4MIJSDKK-r0zbk95f.js +1 -0
- package/dist/client/static/js/{gitGraphDiagram-X574FWY7-ymk81cdj.js → gitGraphDiagram-X574FWY7-dkvktvzr.js} +1 -1
- package/dist/client/static/js/graphql-npbd9fdx.js +1 -0
- package/dist/client/static/js/{index-jy91r3ap.js → index-0c6vpk89.js} +2 -2
- package/dist/client/static/js/{index-js81yrmy.js → index-0xaz2eyv.js} +2 -2
- package/dist/client/static/js/{index-qnt118mp.js → index-1sw00wm0.js} +1 -1
- package/dist/client/static/js/{index-rvjc19x7.js → index-2z9wrb46.js} +1 -1
- package/dist/client/static/js/{index-ag78jnva.js → index-3rymer2w.js} +1 -1
- package/dist/client/static/js/{index-69xe17c1.js → index-4jk8ngjg.js} +2 -2
- package/dist/client/static/js/{index-q1bqg4f6.js → index-55hq7tnj.js} +1 -1
- package/dist/client/static/js/{index-547h1b8j.js → index-6fx2t6y7.js} +6 -6
- package/dist/client/static/js/{index-bgpcf3mr.js → index-7fwppdkn.js} +1 -1
- package/dist/client/static/js/{index-p2812ygk.js → index-7w3gqw2b.js} +1 -1
- package/dist/client/static/js/{index-2kg3r5jw.js → index-9dnkfpx4.js} +2 -2
- package/dist/client/static/js/{index-8ggxxp8c.js → index-9fnzcg2x.js} +1 -1
- package/dist/client/static/js/{index-y5hxhr7q.js → index-a4ed3mks.js} +1 -1
- package/dist/client/static/js/{index-g10nr8m6.js → index-ae91g8ka.js} +5 -5
- package/dist/client/static/js/{index-d1vearmk.js → index-ajjq0b8y.js} +2 -2
- package/dist/client/static/js/{index-ek7hqfp0.js → index-amawahyh.js} +2 -2
- package/dist/client/static/js/{index-wv36ddd5.js → index-b6cyn4hr.js} +19 -19
- package/dist/client/static/js/{index-aznkfx1z.js → index-c6kx7s6a.js} +1 -1
- package/dist/client/static/js/{index-9wjnbb3q.js → index-cytks03p.js} +2 -2
- package/dist/client/static/js/{index-b612vske.js → index-djv15k5s.js} +2 -2
- package/dist/client/static/js/{index-8888hgj8.js → index-ds6a2cx7.js} +4 -4
- package/dist/client/static/js/{index-qw5aqk2d.js → index-e6qjfcz9.js} +1 -1
- package/dist/client/static/js/{index-173x4bh0.js → index-e7yf273s.js} +2 -2
- package/dist/client/static/js/{index-y82bk3hr.js → index-efn233xp.js} +4 -4
- package/dist/client/static/js/index-esx3zwnt.js +1 -0
- package/dist/client/static/js/{index-4j1g7m8g.js → index-f8pq132s.js} +1 -1
- package/dist/client/static/js/{index-qntpsp98.js → index-fbbp5cwj.js} +1 -1
- package/dist/client/static/js/{index-bdz08fe2.js → index-g1cggqgx.js} +7 -7
- package/dist/client/static/js/{index-bj3wn9je.js → index-ghsdzs4m.js} +1 -1
- package/dist/client/static/js/{index-j4ks5s41.js → index-gs7ytgdw.js} +171 -171
- package/dist/client/static/js/{index-gx2xefdg.js → index-hz177dr2.js} +2 -2
- package/dist/client/static/js/{index-wy05jt00.js → index-j5ram1ve.js} +1 -1
- package/dist/client/static/js/{index-6wtx7a9x.js → index-ne131hmw.js} +1 -1
- package/dist/client/static/js/{index-vwc8pdy3.js → index-ngk9h0v9.js} +1 -1
- package/dist/client/static/js/{index-ek4gwrm8.js → index-ntcqyqd5.js} +2 -2
- package/dist/client/static/js/{index-4j5jwb54.js → index-pbsm2vw7.js} +2 -2
- package/dist/client/static/js/{index-wsqgp9jw.js → index-pfbyfab5.js} +1 -1
- package/dist/client/static/js/{index-vv9ytx0t.js → index-pn91shfp.js} +2 -2
- package/dist/client/static/js/{index-w130cs7d.js → index-qjsy6p86.js} +1 -1
- package/dist/client/static/js/{index-dj7y2df7.js → index-rdqn92tc.js} +1 -1
- package/dist/client/static/js/{index-c003wb3r.js → index-re1xz433.js} +1 -1
- package/dist/client/static/js/{index-mxpgfj6p.js → index-rebnv57p.js} +1 -1
- package/dist/client/static/js/{index-cccrappc.js → index-tgper3yy.js} +2 -2
- package/dist/client/static/js/{index-pp6mss9b.js → index-x2kb1kx5.js} +1 -1
- package/dist/client/static/js/{index-018ehs1n.js → index-xfa5hswh.js} +1 -1
- package/dist/client/static/js/{index-r1fe56cn.js → index-yq9vnd1y.js} +2 -2
- package/dist/client/static/js/{index-harsfp4x.js → index-zfykeg7x.js} +3 -3
- package/dist/client/static/js/{index-ys4t1am4.js → index-zye9309h.js} +2 -2
- package/dist/client/static/js/info-A6RAGUB7-a8xap43w.js +1 -0
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-11trzn8c.js → infoDiagram-VRGFBTTK-mh6yks62.js} +1 -1
- package/dist/client/static/js/ini-df5bw23e.js +1 -0
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-8xnnymb5.js → ishikawaDiagram-OU5B5YK6-hnfqppnv.js} +1 -1
- package/dist/client/static/js/java-8j33rj1p.js +1 -0
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-wd47j0hy.js → journeyDiagram-ZHPQQLJL-s4nv1f3q.js} +2 -2
- package/dist/client/static/js/jsx-f6p72qpc.js +1 -0
- package/dist/client/static/js/{julia-c2q0vwpd.js → julia-yre4bxb9.js} +1 -1
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-s5rgcp44.js → kanban-definition-PNTS6WVX-t8kbfefp.js} +7 -7
- package/dist/client/static/js/lua-bahx6qze.js +1 -0
- package/dist/client/static/js/markdown-9dhg1fax.js +1 -0
- package/dist/client/static/js/{mermaid.core-9fxp8nt2.js → mermaid.core-0784021p.js} +6 -6
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-4fyewtst.js → mindmap-definition-NLK3R4M7-swkkze8c.js} +8 -8
- package/dist/client/static/js/one-dark-pro-h5tmw145.js +1 -0
- package/dist/client/static/js/one-light-x7vj1pxr.js +1 -0
- package/dist/client/static/js/packet-AYTQ26CC-b5bvg6v1.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-s2xe2e2k.js → pegDiagram-GJSIUBJH-jqayzh7z.js} +1 -1
- package/dist/client/static/js/{perl-6pa0tn3b.js → perl-weeskn1v.js} +1 -1
- package/dist/client/static/js/{php-1zy994pz.js → php-vf3045p9.js} +1 -1
- package/dist/client/static/js/pie-WAS4IAKB-77ee73zg.js +1 -0
- package/dist/client/static/js/{pieDiagram-5QR66LMP-1szpjbzy.js → pieDiagram-5QR66LMP-w03a65ky.js} +1 -1
- package/dist/client/static/js/properties-49mfnee4.js +1 -0
- package/dist/client/static/js/python-qb69wp1s.js +1 -0
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-mv3ee2qa.js → quadrantDiagram-O4NWA36T-2j7sfa9s.js} +1 -1
- package/dist/client/static/js/r-s3mf2tch.js +1 -0
- package/dist/client/static/js/radar-RG4KPBEZ-cp79xtvb.js +1 -0
- package/dist/client/static/js/railroad-74A4TZTK-dcpgqhcb.js +1 -0
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-qasqv686.js +1 -0
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-e46908rd.js +1 -0
- package/dist/client/static/js/railroad-peg-WCYAUIDC-7009t6bk.js +1 -0
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-hgdqjpm9.js → railroadDiagram-XR7U4H2S-jtkkgy34.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-yrfjp9wx.js → requirementDiagram-PLB6GJNP-t85ckjdb.js} +1 -1
- package/dist/client/static/js/{ruby-arvs7kz4.js → ruby-1a2ryzy6.js} +1 -1
- package/dist/client/static/js/{rust-3ahjk339.js → rust-736r0f0v.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-k7k871xa.js → sankeyDiagram-IPEJSGJF-5pfkw8ne.js} +1 -1
- package/dist/client/static/js/{sass-cmkf7nwd.js → sass-tq4vw7hd.js} +1 -1
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-gd80m0as.js → sequenceDiagram-PO4LG4MO-55vs9zv5.js} +3 -3
- package/dist/client/static/js/{sizeCapture-INFHLROL-jv6p4834.js → sizeCapture-INFHLROL-pzqqd7f4.js} +1 -1
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-tvphxq2h.js → stateDiagram-v2-GCMORJYK-6nhrph8n.js} +2 -2
- package/dist/client/static/js/{swimlanes-2SLR337P-3dt7nxj2.js → swimlanes-2SLR337P-6tcnxfbv.js} +1 -1
- package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-7xrkrkpa.js +8 -0
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-40vvf856.js → timeline-definition-EJHVYXUP-1dz46nt5.js} +2 -2
- package/dist/client/static/js/treeView-Q6P3EWNA-tpn62q8j.js +1 -0
- package/dist/client/static/js/treemap-WGGIJYW6-w910f1g4.js +1 -0
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-g1j5x0xh.js → usecaseDiagram-POWQR4AR-b3jfveq6.js} +1 -1
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-5b8789qk.js → vennDiagram-UO4OBE2U-dnc3jqvp.js} +3 -3
- package/dist/client/static/js/wardley-WFR3VGLG-pt9tq808.js +1 -0
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-c7x3za3w.js → wardleyDiagram-VNRHLVJA-466m8400.js} +1 -1
- package/dist/client/static/js/xml-wr1dxav5.js +1 -0
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-h0fy45tg.js → xychartDiagram-PMCCYNJV-kryrpqp1.js} +2 -2
- package/dist/client/static/js/yaml-0y9fdskg.js +1 -0
- package/package.json +1 -1
- package/src/client/components/layout/desktop-layout/LeftColumn.tsx +7 -0
- package/src/client/components/layout/session-sidebar/SessionsView.tsx +2 -1
- package/src/client/components/layout/session-sidebar/about-modal/index.test.tsx +1 -1
- package/src/client/components/mobile/SessionSidebar.tsx +4 -0
- package/src/client/components/workspace/chat-timeline/MessageList.test.ts +19 -19
- package/src/client/hooks/commands/use-command-runtime.ts +15 -0
- package/src/client/hooks/ui/updates/check-request.ts +41 -0
- package/src/client/hooks/ui/updates/index.ts +13 -5
- package/src/client/lib/native/run-command.test.ts +95 -0
- package/src/client/lib/native/run-command.ts +52 -0
- package/src/client/lib/router/open-session.test.ts +26 -1
- package/src/client/lib/router/open-session.ts +21 -0
- package/src/client/main.tsx +9 -0
- package/src/server/lib/changes/capture-shell.test.ts +253 -0
- package/src/server/lib/changes/capture-targets.test.ts +83 -0
- package/src/server/lib/changes/capture-targets.ts +51 -0
- package/src/server/lib/changes/capture-write.server.ts +2 -2
- package/src/server/lib/changes/capture.server.ts +14 -29
- package/src/server/lib/changes/capture.test.ts +69 -149
- package/src/server/lib/changes/patch-paths.ts +37 -0
- package/src/shared/lib/commands/catalog.test.ts +36 -0
- package/src/shared/lib/commands/catalog.ts +16 -0
- package/src/shared/lib/updates/popup-state.ts +11 -0
- package/dist/client/static/js/LayoutWrapper-08axzr3a.js +0 -2
- package/dist/client/static/js/SessionsView-awef8ehj.js +0 -1
- package/dist/client/static/js/architecture-7GRP2DOG-6rbq97t9.js +0 -1
- package/dist/client/static/js/css-zj4qzw6r.js +0 -1
- package/dist/client/static/js/cynefin-OW5HDTMX-zafxcz2k.js +0 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-cq3dvz7e.js +0 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-spzh2jxq.js +0 -1
- package/dist/client/static/js/gitGraph-4MIJSDKK-epgk26pj.js +0 -1
- package/dist/client/static/js/graphql-dewsj5g1.js +0 -1
- package/dist/client/static/js/index-dhrp656p.js +0 -1
- package/dist/client/static/js/info-A6RAGUB7-0an46pag.js +0 -1
- package/dist/client/static/js/ini-09e0scxh.js +0 -1
- package/dist/client/static/js/java-vnaesxzs.js +0 -1
- package/dist/client/static/js/jsx-xz71aed4.js +0 -1
- package/dist/client/static/js/lua-e4wenyzt.js +0 -1
- package/dist/client/static/js/markdown-yv3p1p7m.js +0 -1
- package/dist/client/static/js/one-dark-pro-ahch85zb.js +0 -1
- package/dist/client/static/js/one-light-9706jgqt.js +0 -1
- package/dist/client/static/js/packet-AYTQ26CC-5e397pav.js +0 -1
- package/dist/client/static/js/pie-WAS4IAKB-0zzmzg64.js +0 -1
- package/dist/client/static/js/properties-0ag74bdj.js +0 -1
- package/dist/client/static/js/python-zsn5tdbj.js +0 -1
- package/dist/client/static/js/r-mwtqhnw3.js +0 -1
- package/dist/client/static/js/radar-RG4KPBEZ-mtar9742.js +0 -1
- package/dist/client/static/js/railroad-74A4TZTK-d6a6j9fq.js +0 -1
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-1257kd8x.js +0 -1
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-v8b6qmas.js +0 -1
- package/dist/client/static/js/railroad-peg-WCYAUIDC-jxpbx410.js +0 -1
- package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-aqnh1hhp.js +0 -8
- package/dist/client/static/js/treeView-Q6P3EWNA-q3qr7ew7.js +0 -1
- package/dist/client/static/js/treemap-WGGIJYW6-zgbdydeq.js +0 -1
- package/dist/client/static/js/wardley-WFR3VGLG-b230aajh.js +0 -1
- package/dist/client/static/js/xml-23y6pgvx.js +0 -1
- package/dist/client/static/js/yaml-vrayja34.js +0 -1
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
import { afterAll, afterEach, beforeAll, describe, expect, test } from 'bun:test';
|
|
16
16
|
import { Window } from 'happy-dom';
|
|
17
17
|
|
|
18
|
-
import { openSessionInUrl } from '@/client/lib/router/open-session';
|
|
18
|
+
import { openEmptyWorkspace, openSessionInUrl } from '@/client/lib/router/open-session';
|
|
19
19
|
import { installOpenSessionDispatcher } from '@/client/lib/native/open-session';
|
|
20
20
|
import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
|
|
21
21
|
|
|
@@ -65,6 +65,31 @@ describe('openSessionInUrl', () => {
|
|
|
65
65
|
});
|
|
66
66
|
});
|
|
67
67
|
|
|
68
|
+
describe('openEmptyWorkspace', () => {
|
|
69
|
+
test('clears every routing parameter', () => {
|
|
70
|
+
go('?folderId=3&sessionId=old&subagent=9');
|
|
71
|
+
expect(openEmptyWorkspace()).toBe(true);
|
|
72
|
+
expect(window.location.search).toBe('');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test('tells the router the URL moved', () => {
|
|
76
|
+
go('?sessionId=old');
|
|
77
|
+
let events = 0;
|
|
78
|
+
const listener = () => { events += 1; };
|
|
79
|
+
window.addEventListener('popstate', listener);
|
|
80
|
+
openEmptyWorkspace();
|
|
81
|
+
window.removeEventListener('popstate', listener);
|
|
82
|
+
expect(events).toBe(1);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test('keeps the path and the hash', () => {
|
|
86
|
+
window.history.replaceState(null, '', '/workspace?sessionId=old#timeline');
|
|
87
|
+
openEmptyWorkspace();
|
|
88
|
+
expect(window.location.pathname).toBe('/workspace');
|
|
89
|
+
expect(window.location.hash).toBe('#timeline');
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
68
93
|
describe('window.__kabmoOpenSession', () => {
|
|
69
94
|
test('the installed dispatcher is the same navigation', () => {
|
|
70
95
|
installOpenSessionDispatcher();
|
|
@@ -32,3 +32,24 @@ export function openSessionInUrl(sessionId: string): boolean {
|
|
|
32
32
|
window.dispatchEvent(new Event('popstate'));
|
|
33
33
|
return true;
|
|
34
34
|
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Clear the routing state, which is the sidebar's own "New Session".
|
|
38
|
+
*
|
|
39
|
+
* The sidebar's primary action opens the EMPTY WORKSPACE — the landing, with no
|
|
40
|
+
* query at all — rather than minting a pending chat (see `SessionsView`). A
|
|
41
|
+
* native menu row and the command palette need the same move without a component
|
|
42
|
+
* to call `setSearchParams` from, so it lives here beside the session opener and
|
|
43
|
+
* writes through the same store.
|
|
44
|
+
*/
|
|
45
|
+
export function openEmptyWorkspace(options: { replace?: boolean } = {}): boolean {
|
|
46
|
+
if (typeof window === 'undefined') return false;
|
|
47
|
+
const url = new URL(window.location.href);
|
|
48
|
+
url.search = '';
|
|
49
|
+
// The sidebar's own button replaces the history entry (a New Session press is
|
|
50
|
+
// not a place to go Back to); the option keeps the two callers identical.
|
|
51
|
+
if (options.replace) window.history.replaceState(null, '', url);
|
|
52
|
+
else window.history.pushState(null, '', url);
|
|
53
|
+
window.dispatchEvent(new Event('popstate'));
|
|
54
|
+
return true;
|
|
55
|
+
}
|
package/src/client/main.tsx
CHANGED
|
@@ -21,6 +21,7 @@ import { readNotificationGrant } from '@/client/lib/notifications/os';
|
|
|
21
21
|
import { installOpenSessionDispatcher } from '@/client/lib/native/open-session';
|
|
22
22
|
import { installFileLaunchHandler } from '@/client/lib/launch/file-handlers';
|
|
23
23
|
import { installOpenPaths } from '@/client/lib/native/open-paths';
|
|
24
|
+
import { installCommandRunner } from '@/client/lib/native/run-command';
|
|
24
25
|
import { installDeviceFiles } from '@/client/lib/launch/device-files';
|
|
25
26
|
|
|
26
27
|
import '@/client/tailwind.css';
|
|
@@ -144,6 +145,14 @@ installOpenSessionDispatcher();
|
|
|
144
145
|
// drained by the same tick that registers the opener.
|
|
145
146
|
installOpenPaths();
|
|
146
147
|
|
|
148
|
+
// A native menu row can only report a click; the command it names lives in the
|
|
149
|
+
// page's catalog. The shell calls `window.__kabmoRunCommand(id)` and this is the
|
|
150
|
+
// transport — installed before the first render for the same reason as the other
|
|
151
|
+
// native hooks: a row pressed during hydration must find the runner, not
|
|
152
|
+
// `undefined`. The row carries NO key equivalent, so the page's own dispatcher
|
|
153
|
+
// keeps every chord (and the user's overrides) intact.
|
|
154
|
+
installCommandRunner();
|
|
155
|
+
|
|
147
156
|
// A document the PHONE handed over — picked in the Files app, or "Open with →
|
|
148
157
|
// Kabmo" from Gmail — arrives as BYTES, not a path: the console may be on
|
|
149
158
|
// another machine, so it could never read the file itself. The shell announces
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The capture layer, at the shell: a `bash` call's frames become records.
|
|
8
|
+
*
|
|
9
|
+
* `capture.test.ts` covers the tool adapters (an `edit`, a `write`, an
|
|
10
|
+
* `apply_patch`); this file covers the three lower-authority layers — the trace
|
|
11
|
+
* that names a command's argv, the scan that reconciles an opaque one, and the
|
|
12
|
+
* subagent whose write is attributed to the child.
|
|
13
|
+
*
|
|
14
|
+
* The fake filesystem is a `Map`, so the before/after pair is deterministic:
|
|
15
|
+
* `flush()` after the start frame proves the snapshot ran before the test
|
|
16
|
+
* changes the file. Every path goes through `at()`, so the fixture is native
|
|
17
|
+
* on Windows too.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
|
|
21
|
+
import * as fsp from 'node:fs/promises';
|
|
22
|
+
import * as os from 'node:os';
|
|
23
|
+
import * as path from 'node:path';
|
|
24
|
+
import { makeCapture, records, REPO } from '@/server/lib/changes/capture-test-util';
|
|
25
|
+
import { ChangeJournal } from '@/server/lib/changes/journal.server';
|
|
26
|
+
import { readSessionChangeDiff } from '@/server/lib/changes/reader.server';
|
|
27
|
+
|
|
28
|
+
let dataDir = '';
|
|
29
|
+
let agentDir = '';
|
|
30
|
+
let original: string | undefined;
|
|
31
|
+
let originalAgent: string | undefined;
|
|
32
|
+
|
|
33
|
+
beforeAll(async () => {
|
|
34
|
+
original = Bun.env.KABMO_DATA_DIR;
|
|
35
|
+
originalAgent = Bun.env.PI_CODING_AGENT_DIR;
|
|
36
|
+
dataDir = await fsp.mkdtemp(path.join(os.tmpdir(), 'kabmo-changes-shell-'));
|
|
37
|
+
agentDir = await fsp.mkdtemp(path.join(os.tmpdir(), 'kabmo-changes-shell-agent-'));
|
|
38
|
+
Bun.env.KABMO_DATA_DIR = dataDir;
|
|
39
|
+
Bun.env.PI_CODING_AGENT_DIR = agentDir;
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
afterAll(async () => {
|
|
43
|
+
if (original === undefined) delete Bun.env.KABMO_DATA_DIR;
|
|
44
|
+
else Bun.env.KABMO_DATA_DIR = original;
|
|
45
|
+
if (originalAgent === undefined) delete Bun.env.PI_CODING_AGENT_DIR;
|
|
46
|
+
else Bun.env.PI_CODING_AGENT_DIR = originalAgent;
|
|
47
|
+
await fsp.rm(dataDir, { recursive: true, force: true });
|
|
48
|
+
await fsp.rm(agentDir, { recursive: true, force: true });
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const WINDOW_END = Date.now() + 60_000;
|
|
52
|
+
|
|
53
|
+
/** A path inside the fixture repo, spelled the way the host spells it. */
|
|
54
|
+
function at(relative: string): string {
|
|
55
|
+
return path.join(REPO, relative);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
describe('bash capture', () => {
|
|
59
|
+
test('rm is a delete, from the trace argv', async () => {
|
|
60
|
+
const files = new Map([[at('c.ts'), 'C']]);
|
|
61
|
+
const capture = makeCapture('cap-rm', files);
|
|
62
|
+
capture.onFrame({
|
|
63
|
+
type: 'tool_execution_start',
|
|
64
|
+
toolCallId: 'c1',
|
|
65
|
+
toolName: 'bash',
|
|
66
|
+
args: { command: 'rm -f c.ts' },
|
|
67
|
+
});
|
|
68
|
+
await capture.flush();
|
|
69
|
+
files.delete(at('c.ts'));
|
|
70
|
+
capture.onFrame({
|
|
71
|
+
type: 'tool_execution_end',
|
|
72
|
+
toolCallId: 'c1',
|
|
73
|
+
toolName: 'bash',
|
|
74
|
+
result: { details: { trace: { status: 0, units: [{ nodes: [{ k: 'simple', argv: ['rm', '-f', 'c.ts'], st: 0 }] }] } } },
|
|
75
|
+
});
|
|
76
|
+
await capture.flush();
|
|
77
|
+
|
|
78
|
+
const diff = await readSessionChangeDiff('cap-rm', at('c.ts'), 0, WINDOW_END);
|
|
79
|
+
expect(diff?.status).toBe('deleted');
|
|
80
|
+
expect(diff?.oldContent).toBe('C');
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('sed -i is an update', async () => {
|
|
84
|
+
const files = new Map([[at('d.ts'), 'a']]);
|
|
85
|
+
const capture = makeCapture('cap-sed', files);
|
|
86
|
+
capture.onFrame({
|
|
87
|
+
type: 'tool_execution_start',
|
|
88
|
+
toolCallId: 'c1',
|
|
89
|
+
toolName: 'bash',
|
|
90
|
+
args: { command: "sed -i 's/a/b/' d.ts" },
|
|
91
|
+
});
|
|
92
|
+
await capture.flush();
|
|
93
|
+
files.set(at('d.ts'), 'b');
|
|
94
|
+
capture.onFrame({
|
|
95
|
+
type: 'tool_execution_end',
|
|
96
|
+
toolCallId: 'c1',
|
|
97
|
+
toolName: 'bash',
|
|
98
|
+
result: { details: { trace: { status: 0, units: [{ nodes: [{ k: 'simple', argv: ['sed', '-i', 's/a/b/', 'd.ts'], st: 0 }] }] } } },
|
|
99
|
+
});
|
|
100
|
+
await capture.flush();
|
|
101
|
+
|
|
102
|
+
const diff = await readSessionChangeDiff('cap-sed', at('d.ts'), 0, WINDOW_END);
|
|
103
|
+
expect(diff?.status).toBe('modified');
|
|
104
|
+
expect(diff?.oldContent).toBe('a');
|
|
105
|
+
expect(diff?.newContent).toBe('b');
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
test('a redirect is a create the trace does not name', async () => {
|
|
109
|
+
const files = new Map<string, string>();
|
|
110
|
+
const capture = makeCapture('cap-redirect', files);
|
|
111
|
+
capture.onFrame({
|
|
112
|
+
type: 'tool_execution_start',
|
|
113
|
+
toolCallId: 'c1',
|
|
114
|
+
toolName: 'bash',
|
|
115
|
+
args: { command: 'echo hi > e.txt' },
|
|
116
|
+
});
|
|
117
|
+
await capture.flush();
|
|
118
|
+
files.set(at('e.txt'), 'hi\n');
|
|
119
|
+
capture.onFrame({
|
|
120
|
+
type: 'tool_execution_end',
|
|
121
|
+
toolCallId: 'c1',
|
|
122
|
+
toolName: 'bash',
|
|
123
|
+
result: { details: { trace: { status: 0, units: [{ nodes: [{ k: 'simple', argv: ['echo', 'hi'], st: 0 }] }] } } },
|
|
124
|
+
});
|
|
125
|
+
await capture.flush();
|
|
126
|
+
|
|
127
|
+
const diff = await readSessionChangeDiff('cap-redirect', at('e.txt'), 0, WINDOW_END);
|
|
128
|
+
expect(diff?.status).toBe('added');
|
|
129
|
+
expect(diff?.newContent).toBe('hi\n');
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
test('an opaque command is a note, not a guess', async () => {
|
|
133
|
+
const files = new Map<string, string>();
|
|
134
|
+
const capture = makeCapture('cap-opaque', files);
|
|
135
|
+
capture.onFrame({
|
|
136
|
+
type: 'tool_execution_start',
|
|
137
|
+
toolCallId: 'c1',
|
|
138
|
+
toolName: 'bash',
|
|
139
|
+
args: { command: 'bun test' },
|
|
140
|
+
});
|
|
141
|
+
await capture.flush();
|
|
142
|
+
capture.onFrame({
|
|
143
|
+
type: 'tool_execution_end',
|
|
144
|
+
toolCallId: 'c1',
|
|
145
|
+
toolName: 'bash',
|
|
146
|
+
result: { details: { trace: { status: 0, units: [{ nodes: [{ k: 'simple', argv: ['bun', 'test'], st: 0 }] }] } } },
|
|
147
|
+
});
|
|
148
|
+
await capture.flush();
|
|
149
|
+
|
|
150
|
+
const lines = await records('cap-opaque');
|
|
151
|
+
expect(lines.some((line) => line.type === 'change')).toBe(false);
|
|
152
|
+
const note = lines.find((line) => line.type === 'note');
|
|
153
|
+
expect(note?.type).toBe('note');
|
|
154
|
+
if (note?.type !== 'note') throw new Error('expected a note');
|
|
155
|
+
expect(note.reason).toBe('opaque-command');
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
describe('scan pass', () => {
|
|
160
|
+
test('an opaque git reset is reconciled from the two snapshots', async () => {
|
|
161
|
+
const files = new Map([[at('g.ts'), 'old']]);
|
|
162
|
+
const scans = [
|
|
163
|
+
{ root: REPO, dirty: new Map([[at('g.ts'), 'old']]), truncated: false },
|
|
164
|
+
{ root: REPO, dirty: new Map([[at('g.ts'), 'new']]), truncated: false },
|
|
165
|
+
];
|
|
166
|
+
const capture = makeCapture('cap-scan', files, {
|
|
167
|
+
takeScan: async () => scans.shift() ?? null,
|
|
168
|
+
readHead: async () => null,
|
|
169
|
+
});
|
|
170
|
+
capture.onFrame({
|
|
171
|
+
type: 'tool_execution_start',
|
|
172
|
+
toolCallId: 'c1',
|
|
173
|
+
toolName: 'bash',
|
|
174
|
+
args: { command: 'git reset --hard' },
|
|
175
|
+
});
|
|
176
|
+
await capture.flush();
|
|
177
|
+
files.set(at('g.ts'), 'new');
|
|
178
|
+
capture.onFrame({
|
|
179
|
+
type: 'tool_execution_end',
|
|
180
|
+
toolCallId: 'c1',
|
|
181
|
+
toolName: 'bash',
|
|
182
|
+
result: { details: { trace: { status: 0, units: [{ nodes: [{ k: 'simple', argv: ['git', 'reset', '--hard'], st: 0 }] }] } } },
|
|
183
|
+
});
|
|
184
|
+
await capture.flush();
|
|
185
|
+
|
|
186
|
+
const diff = await readSessionChangeDiff('cap-scan', at('g.ts'), 0, WINDOW_END);
|
|
187
|
+
expect(diff?.status).toBe('modified');
|
|
188
|
+
expect(diff?.oldContent).toBe('old');
|
|
189
|
+
expect(diff?.newContent).toBe('new');
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
describe('cross-session scan', () => {
|
|
194
|
+
test('a scan skips a path another session in the same cwd recorded', async () => {
|
|
195
|
+
const other = new ChangeJournal('cap-other', REPO);
|
|
196
|
+
await other.recordChange({
|
|
197
|
+
at: Date.now(), agent: 'Main', tool: 'edit', op: 'update', path: at('file4.txt'),
|
|
198
|
+
displayPath: 'file4.txt', before: 'a', after: 'b', source: 'tool',
|
|
199
|
+
});
|
|
200
|
+
await other.flush();
|
|
201
|
+
|
|
202
|
+
const files = new Map<string, string>();
|
|
203
|
+
const scans = [
|
|
204
|
+
{ root: REPO, dirty: new Map<string, string | null>(), truncated: false },
|
|
205
|
+
{ root: REPO, dirty: new Map([[at('file4.txt'), 'python']]), truncated: false },
|
|
206
|
+
];
|
|
207
|
+
const capture = makeCapture('cap-cross', files, {
|
|
208
|
+
takeScan: async () => scans.shift() ?? null,
|
|
209
|
+
readHead: async () => null,
|
|
210
|
+
});
|
|
211
|
+
capture.onFrame({
|
|
212
|
+
type: 'tool_execution_start',
|
|
213
|
+
toolCallId: 'c1',
|
|
214
|
+
toolName: 'bash',
|
|
215
|
+
args: { command: "python3 - <<'PY'\nopen('file4.txt','w').write('python')\nPY" },
|
|
216
|
+
});
|
|
217
|
+
await capture.flush();
|
|
218
|
+
files.set(at('file4.txt'), 'python');
|
|
219
|
+
capture.onFrame({
|
|
220
|
+
type: 'tool_execution_end',
|
|
221
|
+
toolCallId: 'c1',
|
|
222
|
+
toolName: 'bash',
|
|
223
|
+
result: { details: { trace: { status: 0, units: [{ nodes: [{ k: 'simple', argv: ['python3', '-'], st: 0 }] }] } } },
|
|
224
|
+
});
|
|
225
|
+
await capture.flush();
|
|
226
|
+
|
|
227
|
+
const lines = await records('cap-cross');
|
|
228
|
+
expect(lines.some((line) => line.type === 'change' && line.path === at('file4.txt'))).toBe(false);
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
describe('subagents', () => {
|
|
233
|
+
test('a child edit is attributed to the child', async () => {
|
|
234
|
+
const files = new Map([[at('f.ts'), 'old']]);
|
|
235
|
+
const capture = makeCapture('cap-sub', files);
|
|
236
|
+
capture.onFrame({
|
|
237
|
+
type: 'subagent_event',
|
|
238
|
+
payload: { type: 'tool_execution_start', toolCallId: 's1', toolName: 'edit', args: { path: 'f.ts' }, agent: 'Child' },
|
|
239
|
+
});
|
|
240
|
+
await capture.flush();
|
|
241
|
+
files.set(at('f.ts'), 'new');
|
|
242
|
+
capture.onFrame({
|
|
243
|
+
type: 'subagent_event',
|
|
244
|
+
payload: { type: 'tool_execution_end', toolCallId: 's1', toolName: 'edit', agent: 'Child' },
|
|
245
|
+
});
|
|
246
|
+
await capture.flush();
|
|
247
|
+
|
|
248
|
+
const change = (await records('cap-sub')).find((line) => line.type === 'change');
|
|
249
|
+
expect(change?.type).toBe('change');
|
|
250
|
+
if (change?.type !== 'change') throw new Error('expected a change');
|
|
251
|
+
expect(change.agent).toBe('Child');
|
|
252
|
+
});
|
|
253
|
+
});
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The paths a tool call can touch, read from its args before it runs.
|
|
8
|
+
*
|
|
9
|
+
* Every case is a spelling a real agent sends: omp's `path`, ACP's `filePath`,
|
|
10
|
+
* Claude's `file_path`, an `apply_patch` that names them only in the patch text,
|
|
11
|
+
* and a `bash` call whose plan carries the mutations (plus the source side of a
|
|
12
|
+
* move, which is what makes a `mv` snapshot the file that disappears).
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { describe, expect, test } from 'bun:test';
|
|
16
|
+
import path from 'node:path';
|
|
17
|
+
import { captureTargets } from '@/server/lib/changes/capture-targets';
|
|
18
|
+
import type { PendingCall } from '@/server/lib/changes/capture-types';
|
|
19
|
+
|
|
20
|
+
const CWD = path.resolve('/work');
|
|
21
|
+
|
|
22
|
+
function pending(tool: string, args: Record<string, unknown>): PendingCall {
|
|
23
|
+
return {
|
|
24
|
+
toolCallId: 'c1',
|
|
25
|
+
tool,
|
|
26
|
+
agent: 'Main',
|
|
27
|
+
startedAt: 0,
|
|
28
|
+
args,
|
|
29
|
+
before: new Map(),
|
|
30
|
+
ready: Promise.resolve(),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
describe('captureTargets', () => {
|
|
35
|
+
test('a file tool resolves its relative path against the session cwd', () => {
|
|
36
|
+
expect(captureTargets(pending('edit', { path: 'src/a.ts' }), CWD)).toEqual([path.join(CWD, 'src/a.ts')]);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test('every arg spelling an agent uses is a target', () => {
|
|
40
|
+
const args = { path: 'a.ts', file_path: 'b.ts', filePath: 'c.ts', moveTo: 'd.ts', destination: 'e.ts' };
|
|
41
|
+
expect(captureTargets(pending('edit', args), CWD)).toEqual(['a', 'b', 'c', 'd', 'e'].map((name) => path.join(CWD, `${name}.ts`)));
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test('an absolute path is normalized, not re-rooted', () => {
|
|
45
|
+
const absolute = path.resolve('/other/x.ts');
|
|
46
|
+
expect(captureTargets(pending('write', { path: absolute }), CWD)).toEqual([absolute]);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('an apply_patch names its paths inside the patch text', () => {
|
|
50
|
+
const patch = [
|
|
51
|
+
'*** Begin Patch',
|
|
52
|
+
'*** Update File: src/one.ts',
|
|
53
|
+
'*** Move to: src/two.ts',
|
|
54
|
+
'*** Add File: src/three.ts',
|
|
55
|
+
'*** End Patch',
|
|
56
|
+
].join('\n');
|
|
57
|
+
expect(captureTargets(pending('apply_patch', { patch }), CWD)).toEqual(
|
|
58
|
+
['src/one.ts', 'src/two.ts', 'src/three.ts'].map((relative) => path.join(CWD, relative)),
|
|
59
|
+
);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test('a bash call takes its plan mutations, including the side a move leaves', () => {
|
|
63
|
+
const plan = {
|
|
64
|
+
scan: false,
|
|
65
|
+
opaque: false,
|
|
66
|
+
readOnly: false,
|
|
67
|
+
mutations: [
|
|
68
|
+
{ path: path.join(CWD, 'from.ts'), from: path.join(CWD, 'old.ts'), op: 'update' as const },
|
|
69
|
+
{ path: path.join(CWD, 'new.ts'), op: 'create' as const },
|
|
70
|
+
],
|
|
71
|
+
};
|
|
72
|
+
const call = { ...pending('bash', { command: 'mv old.ts from.ts' }), plan };
|
|
73
|
+
expect(captureTargets(call, CWD)).toEqual([path.join(CWD, 'from.ts'), path.join(CWD, 'old.ts'), path.join(CWD, 'new.ts')]);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test('a URL is not a path', () => {
|
|
77
|
+
expect(captureTargets(pending('read', { path: 'https://example.test/a.ts' }), CWD)).toEqual([]);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test('a tool with no path arg has no target', () => {
|
|
81
|
+
expect(captureTargets(pending('read', {}), CWD)).toEqual([]);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The paths one tool call can touch, read from its `args`.
|
|
8
|
+
*
|
|
9
|
+
* A file tool names its path outright — `filePath` is the ACP/opencode
|
|
10
|
+
* spelling, `path`/`file_path` the omp and Claude ones, and a tool whose args
|
|
11
|
+
* use none of them is a note. `apply_patch` names its paths only inside the
|
|
12
|
+
* patch text, so the headers are read. A `bash` call instead takes the paths its
|
|
13
|
+
* classification found, plus the source side of a move, which is what makes the
|
|
14
|
+
* before-snapshot cover a redirect or an `mv` the trace does not model.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import path from 'node:path';
|
|
18
|
+
import type { PendingCall } from '@/server/lib/changes/capture-types';
|
|
19
|
+
import { patchPaths } from '@/server/lib/changes/patch-paths';
|
|
20
|
+
|
|
21
|
+
/** Every absolute path the call could read or write, before it runs. */
|
|
22
|
+
export function captureTargets(pending: PendingCall, cwd: string): string[] {
|
|
23
|
+
if (pending.tool === 'bash') {
|
|
24
|
+
const paths: string[] = [];
|
|
25
|
+
for (const mutation of pending.plan?.mutations ?? []) {
|
|
26
|
+
paths.push(mutation.path);
|
|
27
|
+
if (mutation.from) paths.push(mutation.from);
|
|
28
|
+
}
|
|
29
|
+
return paths;
|
|
30
|
+
}
|
|
31
|
+
const args = pending.args;
|
|
32
|
+
const raw: unknown[] = [args.path, args.file_path, args.filePath, args.moveTo, args.destination];
|
|
33
|
+
if (Array.isArray(args.paths)) raw.push(...args.paths);
|
|
34
|
+
if (Array.isArray(args.files)) raw.push(...args.files);
|
|
35
|
+
const patch = typeof args.patch === 'string'
|
|
36
|
+
? args.patch
|
|
37
|
+
: typeof args.patchText === 'string'
|
|
38
|
+
? args.patchText
|
|
39
|
+
: typeof args.input === 'string'
|
|
40
|
+
? args.input
|
|
41
|
+
: '';
|
|
42
|
+
if (patch) raw.push(...patchPaths(patch));
|
|
43
|
+
const paths: string[] = [];
|
|
44
|
+
for (const value of raw) {
|
|
45
|
+
// A URL is not a path; a bare `://` inside a Windows path is not either,
|
|
46
|
+
// which is why this looks for the scheme separator rather than `:`.
|
|
47
|
+
if (typeof value !== 'string' || !value || value.includes('://')) continue;
|
|
48
|
+
paths.push(path.isAbsolute(value) ? path.normalize(value) : path.resolve(cwd, value));
|
|
49
|
+
}
|
|
50
|
+
return paths;
|
|
51
|
+
}
|
|
@@ -21,8 +21,8 @@ import { readOmpBefore } from '@/server/lib/changes/omp-fallback.server';
|
|
|
21
21
|
/** The before side of an `edit` whose write landed before the snapshot. */
|
|
22
22
|
export function reconstructEdit(pending: PendingCall, after: string | null | undefined): string | null {
|
|
23
23
|
if (after === null || after === undefined) return null;
|
|
24
|
-
const oldString = pending.args.old_string;
|
|
25
|
-
const newString = pending.args.new_string;
|
|
24
|
+
const oldString = pending.args.old_string ?? pending.args.oldString;
|
|
25
|
+
const newString = pending.args.new_string ?? pending.args.newString;
|
|
26
26
|
if (typeof oldString !== 'string' || typeof newString !== 'string' || !newString) return null;
|
|
27
27
|
if (!after.includes(newString)) return null;
|
|
28
28
|
return after.replace(newString, oldString);
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
* from the frame in place right after the raw listeners return.
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
|
-
import path from 'node:path';
|
|
32
31
|
import { isRecord } from '@/shared/lib/util/guards';
|
|
33
32
|
import type { AgentEvent } from '@/server/lib/omp/rpc/constants';
|
|
34
33
|
import { classifyCommand } from '@/server/lib/changes/classify-command';
|
|
@@ -48,7 +47,8 @@ import type {
|
|
|
48
47
|
ShellTrace,
|
|
49
48
|
} from '@/server/lib/changes/capture-types';
|
|
50
49
|
import { readHeadContent, takeScan, type GitScan } from '@/server/lib/changes/scan.server';
|
|
51
|
-
import { isBuildPath, isExcludedTempPath } from '@/server/lib/changes/temp-path';
|
|
50
|
+
import { isBuildPath, isExcludedTempPath, isInside } from '@/server/lib/changes/temp-path';
|
|
51
|
+
import { captureTargets } from '@/server/lib/changes/capture-targets';
|
|
52
52
|
import { reconstructEdit, resolveRacedWrite } from '@/server/lib/changes/capture-write.server';
|
|
53
53
|
import { MAX_BLOB_BYTES } from '@/server/lib/changes/blobs.server';
|
|
54
54
|
|
|
@@ -166,15 +166,20 @@ export class ChangeCapture {
|
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
async #snapshotBefore(pending: PendingCall): Promise<void> {
|
|
169
|
-
|
|
170
|
-
|
|
169
|
+
// ACP agents name their shell tool `exec_command`, `shell`, or even the
|
|
170
|
+
// command itself; the `command` argument is the one stable signal.
|
|
171
|
+
const command = typeof pending.args.command === 'string' ? pending.args.command : '';
|
|
172
|
+
if (pending.tool === 'bash' || command) {
|
|
171
173
|
pending.command = command;
|
|
172
|
-
pending.
|
|
174
|
+
const commandCwd = typeof pending.args.cwd === 'string' && isInside(pending.args.cwd, this.deps.cwd)
|
|
175
|
+
? pending.args.cwd
|
|
176
|
+
: this.deps.cwd;
|
|
177
|
+
pending.plan = classifyCommand(command, commandCwd, this.deps.home);
|
|
173
178
|
if (pending.plan.scan) {
|
|
174
179
|
pending.scan = await this.#takeScan(this.deps.cwd);
|
|
175
180
|
}
|
|
176
181
|
}
|
|
177
|
-
for (const absolute of
|
|
182
|
+
for (const absolute of captureTargets(pending, this.deps.cwd)) {
|
|
178
183
|
if (pending.before.has(absolute)) continue;
|
|
179
184
|
const info = await this.#statFile(absolute);
|
|
180
185
|
const text = await this.#readCapped(absolute);
|
|
@@ -182,27 +187,6 @@ export class ChangeCapture {
|
|
|
182
187
|
}
|
|
183
188
|
}
|
|
184
189
|
|
|
185
|
-
#targets(pending: PendingCall): string[] {
|
|
186
|
-
if (pending.tool === 'bash') {
|
|
187
|
-
const paths: string[] = [];
|
|
188
|
-
for (const mutation of pending.plan?.mutations ?? []) {
|
|
189
|
-
paths.push(mutation.path);
|
|
190
|
-
if (mutation.from) paths.push(mutation.from);
|
|
191
|
-
}
|
|
192
|
-
return paths;
|
|
193
|
-
}
|
|
194
|
-
const args = pending.args;
|
|
195
|
-
const raw: unknown[] = [args.path, args.file_path, args.moveTo, args.destination];
|
|
196
|
-
if (Array.isArray(args.paths)) raw.push(...args.paths);
|
|
197
|
-
if (Array.isArray(args.files)) raw.push(...args.files);
|
|
198
|
-
const paths: string[] = [];
|
|
199
|
-
for (const value of raw) {
|
|
200
|
-
if (typeof value !== 'string' || !value || value.includes('://')) continue;
|
|
201
|
-
paths.push(path.isAbsolute(value) ? path.normalize(value) : path.resolve(this.deps.cwd, value));
|
|
202
|
-
}
|
|
203
|
-
return paths;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
190
|
async #end(event: AgentEvent): Promise<void> {
|
|
207
191
|
const toolCallId = typeof event.toolCallId === 'string' ? event.toolCallId : '';
|
|
208
192
|
if (!toolCallId) return;
|
|
@@ -214,12 +198,13 @@ export class ChangeCapture {
|
|
|
214
198
|
// resumes later.
|
|
215
199
|
const trace = extractTrace(event);
|
|
216
200
|
await pending.ready;
|
|
217
|
-
|
|
201
|
+
const isShell = pending.tool === 'bash' || typeof pending.args.command === 'string';
|
|
202
|
+
if (isShell) await this.#endBash(pending, trace);
|
|
218
203
|
else await this.#endFileTool(pending);
|
|
219
204
|
}
|
|
220
205
|
|
|
221
206
|
async #endFileTool(pending: PendingCall): Promise<void> {
|
|
222
|
-
const targets =
|
|
207
|
+
const targets = captureTargets(pending, this.deps.cwd);
|
|
223
208
|
if (targets.length === 0) {
|
|
224
209
|
// A read-only tool (`read`, `glob`, `grep`) has no adapter and no
|
|
225
210
|
// mutation; only a tool whose NAME promises a write is worth a note.
|