@kabmo-labs/kabmo 0.37.0 → 0.38.1
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 +551 -531
- package/dist/client/static/js/{CsvGrid-xb429wvb.js → CsvGrid-t1n057vw.js} +1 -1
- package/dist/client/static/js/{DocxView-g58e0bs7.js → DocxView-c9g6teks.js} +2 -2
- package/dist/client/static/js/{DrawioView-1j66avvy.js → DrawioView-gd14j54m.js} +1 -1
- package/dist/client/static/js/{ImageView-kraqkypn.js → ImageView-57f1ecdp.js} +1 -1
- package/dist/client/static/js/{LayoutWrapper-85dhbn62.js → LayoutWrapper-x7srbpz1.js} +2 -2
- package/dist/client/static/js/{Modal-f0nfya07.js → Modal-0bn3f77b.js} +15 -15
- package/dist/client/static/js/{PdfView-nddkrky9.js → PdfView-cybz0xbj.js} +1 -1
- package/dist/client/static/js/{SessionsView-a595m6g1.js → SessionsView-gx5q68tp.js} +1 -1
- package/dist/client/static/js/{SheetView-s2p4sk6b.js → SheetView-1kk5y326.js} +1 -1
- package/dist/client/static/js/{SvgPreview-ppdx4yb9.js → SvgPreview-mp4tk37p.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-5cjzxcaq.js → abnfDiagram-O67JEVCF-78qb3can.js} +1 -1
- package/dist/client/static/js/architecture-7GRP2DOG-r8sz34h3.js +1 -0
- package/dist/client/static/js/{architectureDiagram-NJMV4G6O-62mygavm.js → architectureDiagram-NJMV4G6O-n0fr4hb6.js} +2 -2
- package/dist/client/static/js/{astro-80bs6hvg.js → astro-p3f5p9p2.js} +1 -1
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-s5yz9hcd.js → blockDiagram-BEXU5L5S-2xemfrzh.js} +6 -6
- package/dist/client/static/js/c-jkdstn33.js +1 -0
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-rf9xkmrm.js → c4Diagram-YGBWAQC7-zxfdx3eb.js} +2 -2
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-zfm2cj2a.js → classDiagram-v2-NBCMYWYE-z9sasy3k.js} +5 -5
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-fmgpv55e.js → cose-bilkent-JH36ORCC-9byp0czh.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-468r5xc2.js → cynefinDiagram-VND7K2PF-gnm129fx.js} +1 -1
- package/dist/client/static/js/{dagre-6A5THRUB-w370qmgj.js → dagre-6A5THRUB-sc5tfv1w.js} +2 -2
- package/dist/client/static/js/{diagram-22UHCM2B-sfvfjjsy.js → diagram-22UHCM2B-hq11eek7.js} +7 -7
- package/dist/client/static/js/{diagram-3UASUU5V-3r2c8s14.js → diagram-3UASUU5V-7bk532gd.js} +2 -2
- package/dist/client/static/js/{diagram-ATOU4E4O-yathy97a.js → diagram-ATOU4E4O-yt8wxttm.js} +2 -2
- package/dist/client/static/js/{diagram-CDSNMT55-kk437kxq.js → diagram-CDSNMT55-n3978w6p.js} +1 -1
- package/dist/client/static/js/{diagram-MLGK6HIB-qdxfjjhf.js → diagram-MLGK6HIB-004x4gyw.js} +1 -1
- package/dist/client/static/js/{diagram-MPIPVDR6-dfqeqa1d.js → diagram-MPIPVDR6-498nt489.js} +1 -1
- package/dist/client/static/js/{dockerfile-yxrt509r.js → dockerfile-6hbcmkc8.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-s0b0vv4k.js → ebnfDiagram-ZINNZB2B-5fkmymqn.js} +1 -1
- package/dist/client/static/js/{elixir-rpa1g4gy.js → elixir-jwphgp8j.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-mtpw0spa.js → elk-276RUBZZ-6xrfa2kd.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-agjdsm1b.js → erDiagram-OPXOYQCR-byz4zbkn.js} +4 -4
- package/dist/client/static/js/eventmodeling-NTZA5JFV-k5n61zzh.js +1 -0
- package/dist/client/static/js/flowDiagram-KWPJA3E3-s3fbfwrz.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-z6ywqqc1.js → ganttDiagram-FUAMR5RP-4fkw1k01.js} +2 -2
- package/dist/client/static/js/gitGraph-4MIJSDKK-2gf053bx.js +1 -0
- package/dist/client/static/js/{gitGraphDiagram-X574FWY7-bvbmfw6h.js → gitGraphDiagram-X574FWY7-19g84yw8.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-z0frtyje.js → index-0v8b5pzb.js} +4 -4
- package/dist/client/static/js/{index-z7qnffwj.js → index-1j1s91c4.js} +1 -1
- package/dist/client/static/js/{index-jpkj6vqp.js → index-20vhkcb9.js} +1 -1
- package/dist/client/static/js/{index-0j518hqm.js → index-3az1w5f8.js} +2 -2
- package/dist/client/static/js/{index-qznwd6g8.js → index-3wpsr2bc.js} +184 -184
- package/dist/client/static/js/{index-09gx6edj.js → index-3y6krykq.js} +1 -1
- package/dist/client/static/js/{index-we1rpftn.js → index-4jbbdq6n.js} +2 -2
- package/dist/client/static/js/{index-ntxm8pw3.js → index-4qt2e84b.js} +2 -2
- package/dist/client/static/js/{index-49dhv8ry.js → index-57z8mtmx.js} +2 -2
- package/dist/client/static/js/{index-qz8mbxm9.js → index-5gn56236.js} +2 -2
- package/dist/client/static/js/{index-9t82sx0w.js → index-6k3e5dph.js} +2 -2
- package/dist/client/static/js/{index-es3pt29g.js → index-74scnfpk.js} +1 -1
- package/dist/client/static/js/{index-0mvcbbmy.js → index-7kafzae0.js} +9 -9
- package/dist/client/static/js/{index-pd0140dx.js → index-89a2702q.js} +1 -1
- package/dist/client/static/js/{index-059qyaj0.js → index-8j90mdgz.js} +1 -1
- package/dist/client/static/js/{index-zvfvqvn9.js → index-9wd9y6m0.js} +2 -2
- package/dist/client/static/js/{index-a0bdavdr.js → index-ashpbfqv.js} +1 -1
- package/dist/client/static/js/{index-72t6kqjx.js → index-b9b2nwdd.js} +2 -2
- package/dist/client/static/js/{index-8e0s9p45.js → index-baet2nv8.js} +1 -1
- package/dist/client/static/js/{index-j7r414hf.js → index-bhng2dax.js} +2 -2
- package/dist/client/static/js/{index-21b3zyrd.js → index-cj9193d5.js} +2 -2
- package/dist/client/static/js/{index-sezz011q.js → index-dd4q54y0.js} +1 -1
- package/dist/client/static/js/{index-xearvz2z.js → index-e3w46vsc.js} +7 -7
- package/dist/client/static/js/{index-1tyvk778.js → index-e99ec2f0.js} +1 -1
- package/dist/client/static/js/{index-w9zxmev3.js → index-ehnztdd2.js} +1 -1
- package/dist/client/static/js/{index-actppd4z.js → index-epbqzayj.js} +2 -2
- package/dist/client/static/js/{index-k06med7d.js → index-fghst0kd.js} +12 -12
- package/dist/client/static/js/{index-t07b31ny.js → index-fpf1jkwd.js} +3 -3
- package/dist/client/static/js/{index-hbtk0c12.js → index-g252205p.js} +2 -2
- package/dist/client/static/js/{index-vtbbfwx0.js → index-gr6jng0x.js} +2 -2
- package/dist/client/static/js/{index-kzhtmrh0.js → index-gxtgyya0.js} +1 -1
- package/dist/client/static/js/index-j314me09.js +1 -0
- package/dist/client/static/js/{index-5fn0agag.js → index-jbwns6sc.js} +1 -1
- package/dist/client/static/js/{index-cx89yk15.js → index-kdgcbt17.js} +2 -2
- package/dist/client/static/js/{index-m87yykre.js → index-m4bjsyj2.js} +5 -5
- package/dist/client/static/js/{index-15zn3sns.js → index-nd4p98mc.js} +1 -1
- package/dist/client/static/js/{index-nmc30xaz.js → index-pfwd0160.js} +1 -1
- package/dist/client/static/js/{index-w7xbfv44.js → index-qn4pkjfh.js} +2 -2
- package/dist/client/static/js/{index-0sqa91wb.js → index-qntytvt0.js} +2 -2
- package/dist/client/static/js/{index-64mb65wx.js → index-r83kr4s5.js} +2 -2
- package/dist/client/static/js/{index-7sa2e8mn.js → index-rgdhyry3.js} +2 -2
- package/dist/client/static/js/{index-m3j5yx5f.js → index-sjnnv1gd.js} +4 -4
- package/dist/client/static/js/{index-6q80csr0.js → index-t5t71dhp.js} +2 -2
- package/dist/client/static/js/{index-z6g74h7g.js → index-vb6t44dw.js} +2 -2
- package/dist/client/static/js/{index-a293pdg7.js → index-y3hdv561.js} +2 -2
- package/dist/client/static/js/{index-302d35e5.js → index-zj45wj1x.js} +34 -34
- package/dist/client/static/js/{index-83ts8zmk.js → index-zw7qjx65.js} +1 -1
- package/dist/client/static/js/info-A6RAGUB7-3tr0y3s6.js +1 -0
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-58bv28d4.js → infoDiagram-VRGFBTTK-aw6ter0a.js} +1 -1
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-tz6b0caw.js → ishikawaDiagram-OU5B5YK6-62gst5wh.js} +2 -2
- package/dist/client/static/js/javascript-nyf39d5r.js +1 -0
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-ydamm17a.js → journeyDiagram-ZHPQQLJL-6kgv5a4j.js} +3 -3
- package/dist/client/static/js/{julia-v7j460gw.js → julia-237yk557.js} +1 -1
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-7jxfsf17.js → kanban-definition-PNTS6WVX-8p3515b7.js} +3 -3
- package/dist/client/static/js/lua-86fjqj8v.js +1 -0
- package/dist/client/static/js/{mermaid.core-vty0aq6f.js → mermaid.core-b6ga2y8y.js} +6 -6
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-ra4wrts4.js → mindmap-definition-NLK3R4M7-na9e9b4a.js} +2 -2
- package/dist/client/static/js/one-dark-pro-xp6ssk4z.js +1 -0
- package/dist/client/static/js/one-light-xgab7b02.js +1 -0
- package/dist/client/static/js/packet-AYTQ26CC-xbsyjzrh.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-ydjcfea9.js → pegDiagram-GJSIUBJH-d1hk7fnq.js} +1 -1
- package/dist/client/static/js/{perl-gg4jdkcr.js → perl-dvz4y1tb.js} +1 -1
- package/dist/client/static/js/{php-2q8fm6k8.js → php-n6y7dzhm.js} +1 -1
- package/dist/client/static/js/pie-WAS4IAKB-j2tpz0cs.js +1 -0
- package/dist/client/static/js/{pieDiagram-5QR66LMP-wh04y7wp.js → pieDiagram-5QR66LMP-7b9f4x0y.js} +2 -2
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-4mhbag8n.js → quadrantDiagram-O4NWA36T-q4wxgmhg.js} +1 -1
- 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-pagmr4hc.js → railroadDiagram-XR7U4H2S-jngq1qx4.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-jhfhp4eq.js → requirementDiagram-PLB6GJNP-6xph3b72.js} +4 -4
- package/dist/client/static/js/{ruby-vag6a82m.js → ruby-7zye3g0e.js} +1 -1
- package/dist/client/static/js/{rust-yntkm6hw.js → rust-w6hen2h4.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-qrfxzvp3.js → sankeyDiagram-IPEJSGJF-ncfzgdj8.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-fpznwnva.js → sequenceDiagram-PO4LG4MO-sqz0yfg0.js} +3 -3
- package/dist/client/static/js/{sizeCapture-INFHLROL-3hz930jg.js → sizeCapture-INFHLROL-vt8qp04d.js} +1 -1
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-2m99syxm.js → stateDiagram-v2-GCMORJYK-myjtrmfe.js} +3 -3
- package/dist/client/static/js/{svelte-mwtx07d9.js → svelte-x8f8c8hq.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-hmhd360r.js → swimlanes-2SLR337P-z9vx7z4j.js} +1 -1
- package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-a8b7z74e.js → swimlanesDiagram-TC7HE7FX-5vha7thx.js} +1 -1
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-765y3ssa.js → timeline-definition-EJHVYXUP-z815np57.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-rex2j507.js → usecaseDiagram-POWQR4AR-06ntggng.js} +13 -13
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-wd51qq26.js → vennDiagram-UO4OBE2U-nmtaf5rp.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-6jdqn8f7.js → wardleyDiagram-VNRHLVJA-zgsxmak8.js} +1 -1
- package/dist/client/static/js/xml-3dd1pter.js +1 -0
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-kcz8y04e.js → xychartDiagram-PMCCYNJV-8bg9qdra.js} +2 -2
- 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/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/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 +171 -0
- package/src/server/lib/changes/capture-fs.server.ts +64 -0
- package/src/server/lib/changes/capture-races.test.ts +107 -0
- package/src/server/lib/changes/capture-runs.test.ts +136 -0
- package/src/server/lib/changes/capture-scan.test.ts +157 -0
- package/src/server/lib/changes/capture-test-util.ts +46 -0
- package/src/server/lib/changes/capture-types.ts +64 -0
- package/src/server/lib/changes/capture-write.server.ts +50 -0
- package/src/server/lib/changes/capture.server.ts +349 -0
- package/src/server/lib/changes/capture.test.ts +293 -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 +185 -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/omp-fallback.server.ts +48 -0
- package/src/server/lib/changes/omp-fallback.test.ts +75 -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 +350 -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 +139 -0
- package/src/server/lib/changes/sessions.server.ts +65 -0
- package/src/server/lib/changes/sessions.test.ts +52 -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/models/option.ts +46 -0
- package/src/shared/lib/omp/config/schema.test.ts +20 -0
- 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-7ewrw5vc.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-yyyx3px0.js +0 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-cx3ztxfz.js +0 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-267mw6sv.js +0 -1
- package/dist/client/static/js/gitGraph-4MIJSDKK-eg9r85ak.js +0 -1
- package/dist/client/static/js/graphql-skw5krjr.js +0 -1
- package/dist/client/static/js/html-pv88ny12.js +0 -1
- package/dist/client/static/js/index-tcegdd2t.js +0 -1
- package/dist/client/static/js/info-A6RAGUB7-7qhah7fs.js +0 -1
- package/dist/client/static/js/javascript-4kw2j9t3.js +0 -1
- package/dist/client/static/js/lua-ke895s2q.js +0 -1
- package/dist/client/static/js/one-dark-pro-2pywnqrh.js +0 -1
- package/dist/client/static/js/one-light-vfgdt4wf.js +0 -1
- package/dist/client/static/js/packet-AYTQ26CC-ag2g7tbk.js +0 -1
- package/dist/client/static/js/pie-WAS4IAKB-nqcyj3x1.js +0 -1
- package/dist/client/static/js/radar-RG4KPBEZ-60gby7be.js +0 -1
- package/dist/client/static/js/railroad-74A4TZTK-cnkmcjse.js +0 -1
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-qgfdnazd.js +0 -1
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-609h6cpx.js +0 -1
- package/dist/client/static/js/railroad-peg-WCYAUIDC-xqnytjhg.js +0 -1
- package/dist/client/static/js/treeView-Q6P3EWNA-8djqab8k.js +0 -1
- package/dist/client/static/js/treemap-WGGIJYW6-hdztnffk.js +0 -1
- package/dist/client/static/js/typescript-0s2t05jj.js +0 -1
- package/dist/client/static/js/wardley-WFR3VGLG-avby77vv.js +0 -1
- package/dist/client/static/js/xml-81hxjjt4.js +0 -1
- /package/src/{client/components/workspace/model-dropdown/harness-models.ts → shared/lib/harness/models.ts} +0 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The `bash` classifier: the table that decides what a command will touch.
|
|
8
|
+
*
|
|
9
|
+
* The cases are the ones the journal depends on — `rm`, `mv`, `sed -i`, a
|
|
10
|
+
* redirect, a `git` path restore — plus the two failure modes that must be
|
|
11
|
+
* loud: a glob (the shell expands it, so the path is unknown) and an opaque
|
|
12
|
+
* command (a build, a script), which must be marked rather than guessed.
|
|
13
|
+
*
|
|
14
|
+
* Expected paths are built with `at()`/`abs()`, so the suite asserts the same
|
|
15
|
+
* behaviour on a POSIX host and on Windows.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { describe, expect, test } from 'bun:test';
|
|
19
|
+
import path from 'node:path';
|
|
20
|
+
import {
|
|
21
|
+
classifyArgv,
|
|
22
|
+
classifyCommand,
|
|
23
|
+
type CommandPlan,
|
|
24
|
+
} from '@/server/lib/changes/classify-command';
|
|
25
|
+
import { tokenizeCommand } from '@/server/lib/changes/classify-tokenize';
|
|
26
|
+
|
|
27
|
+
const CWD = path.resolve('/repo');
|
|
28
|
+
const HOME = path.resolve('/home/u');
|
|
29
|
+
|
|
30
|
+
/** A path inside the fixture cwd, spelled the way the host spells it. */
|
|
31
|
+
function at(relative: string): string {
|
|
32
|
+
return path.join(CWD, relative);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** An absolute path as the classifier normalizes it. */
|
|
36
|
+
function abs(absolute: string): string {
|
|
37
|
+
return path.normalize(absolute);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function plan(script: string): CommandPlan {
|
|
41
|
+
return classifyCommand(script, CWD, HOME);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function ops(result: CommandPlan): string[] {
|
|
45
|
+
return result.mutations.map((mutation) => `${mutation.op}:${mutation.path}`);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
describe('classifyCommand', () => {
|
|
49
|
+
test('rm deletes every operand, flags excluded', () => {
|
|
50
|
+
expect(ops(plan('rm -rf src/a.ts'))).toEqual([`delete:${at('src/a.ts')}`]);
|
|
51
|
+
expect(ops(plan('rm -f /tmp/x'))).toEqual([`delete:${abs('/tmp/x')}`]);
|
|
52
|
+
expect(ops(plan('rm a b'))).toEqual([`delete:${at('a')}`, `delete:${at('b')}`]);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test('mv is a rename with its source', () => {
|
|
56
|
+
const result = plan('mv a b');
|
|
57
|
+
expect(result.mutations).toEqual([{ op: 'rename', path: at('b'), from: at('a') }]);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test('sed -i updates its file operands; sed without -i is read-only', () => {
|
|
61
|
+
expect(ops(plan("sed -i 's/a/b/' f"))).toEqual([`update:${at('f')}`]);
|
|
62
|
+
expect(ops(plan("sed -i 's/a/b/' f1 f2"))).toEqual([`update:${at('f1')}`, `update:${at('f2')}`]);
|
|
63
|
+
const readOnly = plan("sed 's/a/b/' f");
|
|
64
|
+
expect(readOnly.mutations).toEqual([]);
|
|
65
|
+
expect(readOnly.readOnly).toBe(true);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test('perl -i and awk -i inplace update their files', () => {
|
|
69
|
+
expect(ops(plan("perl -i -pe 's/a/b/' f"))).toEqual([`update:${at('f')}`]);
|
|
70
|
+
expect(ops(plan("awk -i inplace '{print}' f"))).toEqual([`update:${at('f')}`]);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test('output redirects are mutations the trace does not model', () => {
|
|
74
|
+
expect(ops(plan('echo hi > out.txt'))).toEqual([`update:${at('out.txt')}`]);
|
|
75
|
+
expect(ops(plan('echo hi >> out.txt'))).toEqual([`update:${at('out.txt')}`]);
|
|
76
|
+
expect(ops(plan('ls 2> err.log'))).toEqual([`update:${at('err.log')}`]);
|
|
77
|
+
expect(ops(plan('ls 2>&1'))).toEqual([]);
|
|
78
|
+
expect(plan('ls 2>&1').readOnly).toBe(true);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
test('cp, tee, truncate, dd, sort -o and curl -o name their destination', () => {
|
|
82
|
+
expect(ops(plan('cp a b'))).toEqual([`update:${at('b')}`]);
|
|
83
|
+
expect(ops(plan('tee out'))).toEqual([`update:${at('out')}`]);
|
|
84
|
+
expect(ops(plan('truncate -s 0 f'))).toEqual([`update:${at('f')}`]);
|
|
85
|
+
expect(ops(plan('dd if=a of=b'))).toEqual([`update:${at('b')}`]);
|
|
86
|
+
expect(ops(plan('sort -o f in'))).toEqual([`update:${at('f')}`]);
|
|
87
|
+
expect(ops(plan('curl -o f https://x'))).toEqual([`update:${at('f')}`]);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test('git path restores are updates; a hard reset is opaque', () => {
|
|
91
|
+
expect(ops(plan('git checkout -- a b'))).toEqual([`update:${at('a')}`, `update:${at('b')}`]);
|
|
92
|
+
expect(ops(plan('git restore a'))).toEqual([`update:${at('a')}`]);
|
|
93
|
+
expect(ops(plan('git mv a b'))).toEqual([`rename:${at('b')}`]);
|
|
94
|
+
expect(ops(plan('git rm a'))).toEqual([`delete:${at('a')}`]);
|
|
95
|
+
expect(plan('git reset --hard').opaque).toBe(true);
|
|
96
|
+
expect(plan('git clean -fd').opaque).toBe(true);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test('a glob is opaque: the shell expands it, so the path is unknown', () => {
|
|
100
|
+
const result = plan('rm *.ts');
|
|
101
|
+
expect(result.mutations).toEqual([]);
|
|
102
|
+
expect(result.opaque).toBe(true);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test('a build or a script is opaque, not read-only', () => {
|
|
106
|
+
expect(plan('bun test').opaque).toBe(true);
|
|
107
|
+
expect(plan('bun test').readOnly).toBe(false);
|
|
108
|
+
expect(plan('node script.js').opaque).toBe(true);
|
|
109
|
+
expect(plan('xargs rm').opaque).toBe(true);
|
|
110
|
+
expect(plan('find . -delete').opaque).toBe(true);
|
|
111
|
+
expect(plan('find . -name x').readOnly).toBe(true);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test('a read-only command is read-only', () => {
|
|
115
|
+
expect(plan('rg -n foo src').readOnly).toBe(true);
|
|
116
|
+
expect(plan('ls -la').readOnly).toBe(true);
|
|
117
|
+
expect(plan('git status').readOnly).toBe(true);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
test('a cd changes what the later relative paths mean', () => {
|
|
121
|
+
expect(ops(plan('cd sub && rm a'))).toEqual([`delete:${at('sub/a')}`]);
|
|
122
|
+
expect(ops(plan('cd sub && cat > b'))).toEqual([`update:${at('sub/b')}`]);
|
|
123
|
+
expect(plan('cd -').opaque).toBe(true);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
test('an unexpanded variable is opaque, not a literal path', () => {
|
|
127
|
+
const result = plan('cat > $DIR/out.md');
|
|
128
|
+
expect(result.mutations).toEqual([]);
|
|
129
|
+
expect(result.opaque).toBe(true);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
test('a device file is not a working-tree mutation', () => {
|
|
133
|
+
expect(ops(plan('ls 2>/dev/null'))).toEqual([]);
|
|
134
|
+
expect(plan('ls 2>/dev/null').readOnly).toBe(true);
|
|
135
|
+
expect(plan('ls 2>/dev/null').opaque).toBe(false);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
test('a heredoc body is data, not commands', () => {
|
|
139
|
+
const result = plan("cat > f <<'EOF'\nrm x\n> y\nEOF");
|
|
140
|
+
expect(ops(result)).toEqual([`update:${at('f')}`]);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
test('a chain is the union of its commands', () => {
|
|
144
|
+
const result = plan('rm a && echo hi > b');
|
|
145
|
+
expect(ops(result)).toEqual([`delete:${at('a')}`, `update:${at('b')}`]);
|
|
146
|
+
expect(result.readOnly).toBe(false);
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
describe('classifyArgv', () => {
|
|
151
|
+
test('classifies one trace node', () => {
|
|
152
|
+
expect(ops(classifyArgv(['rm', '-rf', 'a'], CWD, HOME))).toEqual([`delete:${at('a')}`]);
|
|
153
|
+
expect(ops(classifyArgv(['sed', '-i', 's/a/b/', 'f'], CWD, HOME))).toEqual([`update:${at('f')}`]);
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
describe('tokenizeCommand', () => {
|
|
158
|
+
test('keeps quoted words whole and separates operators', () => {
|
|
159
|
+
const tokens = tokenizeCommand('a "b c" > d');
|
|
160
|
+
expect(tokens).toEqual([
|
|
161
|
+
{ kind: 'word', value: 'a' },
|
|
162
|
+
{ kind: 'word', value: 'b c' },
|
|
163
|
+
{ kind: 'op', value: '>' },
|
|
164
|
+
{ kind: 'word', value: 'd' },
|
|
165
|
+
]);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
test('does not treat 2>&1 as a file target', () => {
|
|
169
|
+
const tokens = tokenizeCommand('ls 2>&1');
|
|
170
|
+
expect(tokens.some((token) => token.kind === 'op' && token.value === 'fddup')).toBe(true);
|
|
171
|
+
});
|
|
172
|
+
});
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* What a `bash` command will do to the working tree, read from its text.
|
|
8
|
+
*
|
|
9
|
+
* omp's shell trace gives exact `argv` and exit status per simple command, but
|
|
10
|
+
* it does NOT model redirections. Measured on 18.20.3: `bun test > /tmp/n1.log
|
|
11
|
+
* 2>&1` produces only `and_or`/`pipeline`/`simple`/`word` nodes, and the
|
|
12
|
+
* `simple` node's argv is `["bun","test"]` — the `>` and its target are absent.
|
|
13
|
+
* So the classifier has two entry points:
|
|
14
|
+
*
|
|
15
|
+
* - {@link classifyCommand} — the whole script, tokenized here, used at
|
|
16
|
+
* `tool_execution_start` to snapshot the targets BEFORE the command runs;
|
|
17
|
+
* - {@link classifyArgv} — one already-parsed `argv` from the trace, used at
|
|
18
|
+
* `tool_execution_end` to confirm what actually ran.
|
|
19
|
+
*
|
|
20
|
+
* A command is `readOnly` when every simple command is a known read-only verb
|
|
21
|
+
* and there is no output redirect. It is `opaque` when at least one command is
|
|
22
|
+
* not understood — a script, a build, `git reset --hard` — which is the signal
|
|
23
|
+
* for the filesystem reconciliation pass rather than a guess.
|
|
24
|
+
*
|
|
25
|
+
* A path containing a glob character is not resolved: the shell expands it, and
|
|
26
|
+
* a guess would journal a file that was never touched. The command is marked
|
|
27
|
+
* opaque instead, so the scan pass answers.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
import path from 'node:path';
|
|
31
|
+
import { classifyGit } from '@/server/lib/changes/classify-git';
|
|
32
|
+
import {
|
|
33
|
+
dedupe,
|
|
34
|
+
flagValue,
|
|
35
|
+
isSpecialFile,
|
|
36
|
+
nonFlagArgs,
|
|
37
|
+
resolvePath,
|
|
38
|
+
scriptFiles,
|
|
39
|
+
truncateFiles,
|
|
40
|
+
} from '@/server/lib/changes/classify-paths';
|
|
41
|
+
import {
|
|
42
|
+
splitCommands,
|
|
43
|
+
stripHeredocs,
|
|
44
|
+
tokenizeCommand,
|
|
45
|
+
type SimpleCommand,
|
|
46
|
+
} from '@/server/lib/changes/classify-tokenize';
|
|
47
|
+
|
|
48
|
+
export type MutationOp = 'create' | 'update' | 'delete' | 'rename';
|
|
49
|
+
|
|
50
|
+
export interface CommandMutation {
|
|
51
|
+
op: MutationOp;
|
|
52
|
+
/** Absolute path. */
|
|
53
|
+
path: string;
|
|
54
|
+
/** Absolute source path, for a rename. */
|
|
55
|
+
from?: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface CommandPlan {
|
|
59
|
+
mutations: CommandMutation[];
|
|
60
|
+
/** At least one command is not understood; the scan pass must run. */
|
|
61
|
+
opaque: boolean;
|
|
62
|
+
/** Every command is a known read-only verb and there is no output redirect. */
|
|
63
|
+
readOnly: boolean;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Verbs that never write a file. */
|
|
67
|
+
const READ_ONLY: Record<string, true> = {
|
|
68
|
+
ls: true, cat: true, head: true, tail: true, wc: true, rg: true, grep: true,
|
|
69
|
+
fd: true, stat: true, file: true, which: true, pwd: true,
|
|
70
|
+
echo: true, printf: true, date: true, env: true, printenv: true, whoami: true,
|
|
71
|
+
id: true, uname: true, du: true, df: true, tree: true, jq: true,
|
|
72
|
+
basename: true, dirname: true, realpath: true, readlink: true,
|
|
73
|
+
cut: true, tr: true, nl: true, od: true, strings: true,
|
|
74
|
+
diff: true, cmp: true, comm: true, paste: true, fold: true, seq: true,
|
|
75
|
+
yes: true, true: true, false: true, test: true, '[': true, sleep: true,
|
|
76
|
+
kill: true, ps: true, top: true, lsof: true, cd: true, export: true,
|
|
77
|
+
set: true, unset: true, chmod: true, chown: true, mkdir: true, wait: true,
|
|
78
|
+
jobs: true, bg: true, fg: true, type: true, command: true, hash: true,
|
|
79
|
+
umask: true, ulimit: true,
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/** Verbs whose effect cannot be read from argv; the scan pass answers. */
|
|
83
|
+
const OPAQUE: Record<string, true> = {
|
|
84
|
+
bun: true, bunx: true, npm: true, npx: true, pnpm: true, yarn: true,
|
|
85
|
+
node: true, deno: true, python: true, python3: true, pip: true, pip3: true,
|
|
86
|
+
sh: true, bash: true, zsh: true, fish: true, make: true, cargo: true,
|
|
87
|
+
rustc: true, go: true, tsc: true, eslint: true, prettier: true,
|
|
88
|
+
playwright: true, vitest: true, jest: true, tar: true, unzip: true,
|
|
89
|
+
zip: true, rsync: true, scp: true, ssh: true, docker: true, kubectl: true,
|
|
90
|
+
helm: true, terraform: true, ansible: true, systemctl: true, launchctl: true,
|
|
91
|
+
brew: true, apt: true, 'apt-get': true, yum: true, dnf: true, pacman: true,
|
|
92
|
+
sudo: true, su: true, eval: true, exec: true, nohup: true, timeout: true,
|
|
93
|
+
parallel: true, 'git-lfs': true, gh: true, glab: true, aws: true,
|
|
94
|
+
gcloud: true, az: true, xargs: true, source: true, '.': true, time: true,
|
|
95
|
+
watch: true,
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
/** Classify one already-parsed `argv` (the shell trace's `simple` node). */
|
|
99
|
+
export function classifyArgv(argv: readonly string[], cwd: string, home: string): CommandPlan {
|
|
100
|
+
return classifySimple({ words: [...argv], redirects: [] }, cwd, home);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Classify a whole script, including its output redirects and `cd` changes. */
|
|
104
|
+
export function classifyCommand(script: string, cwd: string, home: string): CommandPlan {
|
|
105
|
+
const mutations: CommandMutation[] = [];
|
|
106
|
+
let opaque = false;
|
|
107
|
+
let readOnly = true;
|
|
108
|
+
let currentCwd = cwd;
|
|
109
|
+
for (const command of splitCommands(tokenizeCommand(stripHeredocs(script)))) {
|
|
110
|
+
const verb = command.words[0] ? path.basename(command.words[0]) : '';
|
|
111
|
+
if (verb === 'cd') {
|
|
112
|
+
// A `cd` changes what every later relative path means. `cd -` and a bare
|
|
113
|
+
// `cd` are not tracked, so the command is opaque rather than guessed.
|
|
114
|
+
const target = command.words.slice(1).find((arg) => !arg.startsWith('-'));
|
|
115
|
+
const resolved = target ? resolvePath(currentCwd, home, target) : null;
|
|
116
|
+
if (resolved) currentCwd = resolved;
|
|
117
|
+
else opaque = true;
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
const result = classifySimple(command, currentCwd, home);
|
|
121
|
+
mutations.push(...result.mutations);
|
|
122
|
+
if (result.opaque) opaque = true;
|
|
123
|
+
if (!result.readOnly) readOnly = false;
|
|
124
|
+
}
|
|
125
|
+
return { mutations: dedupe(mutations), opaque, readOnly };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function classifySimple(command: SimpleCommand, cwd: string, home: string): CommandPlan {
|
|
129
|
+
const mutations: CommandMutation[] = [];
|
|
130
|
+
let opaque = false;
|
|
131
|
+
let readOnly = true;
|
|
132
|
+
|
|
133
|
+
const add = (op: MutationOp, raw: string, from?: string): void => {
|
|
134
|
+
// `/dev/null` and friends are redirect sinks, not working-tree mutations.
|
|
135
|
+
if (isSpecialFile(raw)) return;
|
|
136
|
+
const resolved = resolvePath(cwd, home, raw);
|
|
137
|
+
if (!resolved) {
|
|
138
|
+
opaque = true;
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
mutations.push(from ? { op, path: resolved, from } : { op, path: resolved });
|
|
142
|
+
readOnly = false;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
for (const redirect of command.redirects) {
|
|
146
|
+
add('update', redirect.target);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const argv = command.words;
|
|
150
|
+
if (argv.length === 0) return { mutations, opaque, readOnly };
|
|
151
|
+
const verb = path.basename(argv[0]);
|
|
152
|
+
const args = argv.slice(1);
|
|
153
|
+
|
|
154
|
+
if (READ_ONLY[verb] === true) return { mutations, opaque, readOnly };
|
|
155
|
+
|
|
156
|
+
if (verb === 'sed' || verb === 'gsed' || verb === 'perl') {
|
|
157
|
+
const inPlace = args.some((arg) => arg === '-i' || arg.startsWith('-i') || arg === '--in-place' || arg.startsWith('--in-place='));
|
|
158
|
+
if (!inPlace) return { mutations, opaque, readOnly };
|
|
159
|
+
for (const file of scriptFiles(args)) add('update', file);
|
|
160
|
+
return { mutations, opaque, readOnly };
|
|
161
|
+
}
|
|
162
|
+
if (verb === 'awk' || verb === 'gawk') {
|
|
163
|
+
const index = args.findIndex((arg) => arg === '-i' || arg === 'inplace');
|
|
164
|
+
if (index === -1) return { mutations, opaque, readOnly };
|
|
165
|
+
// `-i inplace` is two tokens; the program follows, then the files.
|
|
166
|
+
const programAt = args[index] === '-i' && args[index + 1] === 'inplace' ? index + 2 : index + 1;
|
|
167
|
+
for (const file of args.slice(programAt + 1).filter((arg) => !arg.startsWith('-'))) add('update', file);
|
|
168
|
+
return { mutations, opaque, readOnly };
|
|
169
|
+
}
|
|
170
|
+
if (verb === 'rm' || verb === 'rmdir' || verb === 'unlink') {
|
|
171
|
+
for (const file of nonFlagArgs(args)) add('delete', file);
|
|
172
|
+
return { mutations, opaque, readOnly };
|
|
173
|
+
}
|
|
174
|
+
if (verb === 'mv') {
|
|
175
|
+
const files = nonFlagArgs(args);
|
|
176
|
+
if (files.length < 2) {
|
|
177
|
+
opaque = true;
|
|
178
|
+
return { mutations, opaque, readOnly };
|
|
179
|
+
}
|
|
180
|
+
const dest = files[files.length - 1];
|
|
181
|
+
const sources = files.slice(0, -1);
|
|
182
|
+
for (const source of sources) {
|
|
183
|
+
const from = resolvePath(cwd, home, source);
|
|
184
|
+
const destPath = resolvePath(cwd, home, dest);
|
|
185
|
+
const to = sources.length > 1 && destPath ? path.join(destPath, path.basename(source)) : destPath;
|
|
186
|
+
if (!from || !to) {
|
|
187
|
+
opaque = true;
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
mutations.push({ op: 'rename', path: to, from });
|
|
191
|
+
readOnly = false;
|
|
192
|
+
}
|
|
193
|
+
return { mutations, opaque, readOnly };
|
|
194
|
+
}
|
|
195
|
+
if (verb === 'cp') {
|
|
196
|
+
const files = nonFlagArgs(args);
|
|
197
|
+
if (files.length < 2) {
|
|
198
|
+
opaque = true;
|
|
199
|
+
return { mutations, opaque, readOnly };
|
|
200
|
+
}
|
|
201
|
+
const dest = files[files.length - 1];
|
|
202
|
+
const sources = files.slice(0, -1);
|
|
203
|
+
for (const source of sources) {
|
|
204
|
+
const destPath = resolvePath(cwd, home, dest);
|
|
205
|
+
const to = sources.length > 1 && destPath ? path.join(destPath, path.basename(source)) : destPath;
|
|
206
|
+
if (!to) {
|
|
207
|
+
opaque = true;
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
mutations.push({ op: 'update', path: to });
|
|
211
|
+
readOnly = false;
|
|
212
|
+
}
|
|
213
|
+
return { mutations, opaque, readOnly };
|
|
214
|
+
}
|
|
215
|
+
if (verb === 'tee' || verb === 'touch') {
|
|
216
|
+
for (const file of nonFlagArgs(args)) add('update', file);
|
|
217
|
+
return { mutations, opaque, readOnly };
|
|
218
|
+
}
|
|
219
|
+
if (verb === 'truncate') {
|
|
220
|
+
for (const file of truncateFiles(args)) add('update', file);
|
|
221
|
+
return { mutations, opaque, readOnly };
|
|
222
|
+
}
|
|
223
|
+
if (verb === 'install' || verb === 'ln') {
|
|
224
|
+
const files = nonFlagArgs(args);
|
|
225
|
+
const file = files[files.length - 1];
|
|
226
|
+
if (file) add(verb === 'ln' ? 'create' : 'update', file);
|
|
227
|
+
else opaque = true;
|
|
228
|
+
return { mutations, opaque, readOnly };
|
|
229
|
+
}
|
|
230
|
+
if (verb === 'dd') {
|
|
231
|
+
for (const arg of args) {
|
|
232
|
+
if (arg.startsWith('of=')) add('update', arg.slice(3));
|
|
233
|
+
}
|
|
234
|
+
return { mutations, opaque, readOnly };
|
|
235
|
+
}
|
|
236
|
+
if (verb === 'sort') {
|
|
237
|
+
const out = flagValue(args, '-o') ?? flagValue(args, '--output');
|
|
238
|
+
if (out) add('update', out);
|
|
239
|
+
return { mutations, opaque, readOnly };
|
|
240
|
+
}
|
|
241
|
+
if (verb === 'uniq') {
|
|
242
|
+
const files = nonFlagArgs(args);
|
|
243
|
+
if (files.length >= 2) add('update', files[1]);
|
|
244
|
+
return { mutations, opaque, readOnly };
|
|
245
|
+
}
|
|
246
|
+
if (verb === 'curl' || verb === 'wget') {
|
|
247
|
+
const out = flagValue(args, '-o') ?? flagValue(args, '--output') ?? flagValue(args, '-O');
|
|
248
|
+
if (out) add('update', out);
|
|
249
|
+
return { mutations, opaque, readOnly };
|
|
250
|
+
}
|
|
251
|
+
if (verb === 'find') {
|
|
252
|
+
const mutating = args.some((arg) => arg === '-delete' || arg === '-exec' || arg === '-execdir' || arg === '-ok' || arg === '-okdir');
|
|
253
|
+
if (mutating) {
|
|
254
|
+
opaque = true;
|
|
255
|
+
readOnly = false;
|
|
256
|
+
}
|
|
257
|
+
return { mutations, opaque, readOnly };
|
|
258
|
+
}
|
|
259
|
+
if (verb === 'git') {
|
|
260
|
+
return classifyGit(args, cwd, home, mutations, opaque, readOnly);
|
|
261
|
+
}
|
|
262
|
+
if (OPAQUE[verb] === true) {
|
|
263
|
+
opaque = true;
|
|
264
|
+
readOnly = false;
|
|
265
|
+
return { mutations, opaque, readOnly };
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// An unknown verb is not assumed harmless.
|
|
269
|
+
opaque = true;
|
|
270
|
+
readOnly = false;
|
|
271
|
+
return { mutations, opaque, readOnly };
|
|
272
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The `git` branch of the command classifier.
|
|
8
|
+
*
|
|
9
|
+
* `git` is the one verb whose effect depends on a subcommand, and the split is
|
|
10
|
+
* deliberate: a read-only subcommand (`status`, `diff`, `log`) is not a
|
|
11
|
+
* mutation; a path restore (`checkout --`, `restore`) names its files; and a
|
|
12
|
+
* subcommand that rewrites the tree in ways argv cannot name (`reset --hard`,
|
|
13
|
+
* `clean`, `stash`) is opaque, so the scan pass answers instead of a guess.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import type { CommandMutation, CommandPlan, MutationOp } from '@/server/lib/changes/classify-command';
|
|
17
|
+
import { isSpecialFile, nonFlagArgs, resolvePath } from '@/server/lib/changes/classify-paths';
|
|
18
|
+
|
|
19
|
+
/** `git` subcommands that never write the working tree. */
|
|
20
|
+
const GIT_READ_ONLY: Record<string, true> = {
|
|
21
|
+
status: true, diff: true, log: true, show: true, branch: true,
|
|
22
|
+
'rev-parse': true, 'ls-files': true, remote: true, config: true,
|
|
23
|
+
blame: true, describe: true, tag: true, shortlog: true, reflog: true,
|
|
24
|
+
grep: true, 'ls-tree': true, 'cat-file': true, 'show-ref': true,
|
|
25
|
+
'for-each-ref': true, add: true, commit: true, fetch: true, push: true,
|
|
26
|
+
init: true, clone: true, help: true, version: true, 'count-objects': true,
|
|
27
|
+
fsck: true,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/** `git` subcommands that rewrite the working tree in ways argv cannot name. */
|
|
31
|
+
const GIT_OPAQUE: Record<string, true> = {
|
|
32
|
+
clean: true, reset: true, stash: true, apply: true, am: true,
|
|
33
|
+
rebase: true, merge: true, pull: true, 'cherry-pick': true, revert: true,
|
|
34
|
+
bisect: true, worktree: true, submodule: true, 'filter-branch': true,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export function classifyGit(
|
|
38
|
+
args: readonly string[],
|
|
39
|
+
cwd: string,
|
|
40
|
+
home: string,
|
|
41
|
+
mutations: CommandMutation[],
|
|
42
|
+
opaque: boolean,
|
|
43
|
+
readOnly: boolean,
|
|
44
|
+
): CommandPlan {
|
|
45
|
+
const sub = args[0];
|
|
46
|
+
if (!sub) return { mutations, opaque, readOnly };
|
|
47
|
+
if (GIT_READ_ONLY[sub] === true) return { mutations, opaque, readOnly };
|
|
48
|
+
|
|
49
|
+
const add = (op: MutationOp, raw: string, from?: string): void => {
|
|
50
|
+
if (isSpecialFile(raw)) return;
|
|
51
|
+
const resolved = resolvePath(cwd, home, raw);
|
|
52
|
+
if (!resolved) {
|
|
53
|
+
opaque = true;
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
mutations.push(from ? { op, path: resolved, from } : { op, path: resolved });
|
|
57
|
+
readOnly = false;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
if (sub === 'mv') {
|
|
61
|
+
const files = nonFlagArgs(args.slice(1));
|
|
62
|
+
if (files.length < 2) return { mutations, opaque: true, readOnly: false };
|
|
63
|
+
const from = resolvePath(cwd, home, files[0]);
|
|
64
|
+
const to = resolvePath(cwd, home, files[files.length - 1]);
|
|
65
|
+
if (!from || !to) return { mutations, opaque: true, readOnly: false };
|
|
66
|
+
mutations.push({ op: 'rename', path: to, from });
|
|
67
|
+
return { mutations, opaque, readOnly: false };
|
|
68
|
+
}
|
|
69
|
+
if (sub === 'rm') {
|
|
70
|
+
for (const file of nonFlagArgs(args.slice(1))) add('delete', file);
|
|
71
|
+
return { mutations, opaque, readOnly };
|
|
72
|
+
}
|
|
73
|
+
if (sub === 'checkout' || sub === 'restore') {
|
|
74
|
+
const separator = args.indexOf('--');
|
|
75
|
+
if (separator !== -1) {
|
|
76
|
+
for (const file of args.slice(separator + 1)) add('update', file);
|
|
77
|
+
return { mutations, opaque, readOnly };
|
|
78
|
+
}
|
|
79
|
+
if (sub === 'restore') {
|
|
80
|
+
for (const file of nonFlagArgs(args.slice(1))) add('update', file);
|
|
81
|
+
return { mutations, opaque, readOnly };
|
|
82
|
+
}
|
|
83
|
+
return { mutations, opaque: true, readOnly: false };
|
|
84
|
+
}
|
|
85
|
+
if (GIT_OPAQUE[sub] === true) return { mutations, opaque: true, readOnly: false };
|
|
86
|
+
|
|
87
|
+
return { mutations, opaque: true, readOnly: false };
|
|
88
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Path and operand helpers shared by the command classifier and its `git`
|
|
8
|
+
* branch.
|
|
9
|
+
*
|
|
10
|
+
* `resolvePath` is the security-relevant one: a glob is refused rather than
|
|
11
|
+
* expanded, because the shell expands it and a guess would journal a file that
|
|
12
|
+
* was never touched. The caller marks the command opaque instead.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import path from 'node:path';
|
|
16
|
+
import type { CommandMutation } from '@/server/lib/changes/classify-command';
|
|
17
|
+
|
|
18
|
+
/** Device files a redirect may name; they are not working-tree mutations. */
|
|
19
|
+
const SPECIAL_FILES: Record<string, true> = {
|
|
20
|
+
'/dev/null': true,
|
|
21
|
+
'/dev/stdout': true,
|
|
22
|
+
'/dev/stderr': true,
|
|
23
|
+
'/dev/tty': true,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/** A device file a redirect may name; it is not a working-tree mutation. */
|
|
27
|
+
export function isSpecialFile(raw: string): boolean {
|
|
28
|
+
return SPECIAL_FILES[raw] === true;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Resolve a shell path against the session cwd; `null` for a glob or empty. */
|
|
32
|
+
export function resolvePath(cwd: string, home: string, raw: string): string | null {
|
|
33
|
+
if (!raw) return null;
|
|
34
|
+
// A truncated command (the transcript's `…`) or an unexpanded variable
|
|
35
|
+
// (`$M/$D.md`) names no real path; the command is opaque instead.
|
|
36
|
+
if (raw.includes('…') || raw.includes('$')) return null;
|
|
37
|
+
if (raw.includes('*') || raw.includes('?') || raw.includes('[')) return null;
|
|
38
|
+
let value = raw;
|
|
39
|
+
if (value === '~') value = home;
|
|
40
|
+
else if (value.startsWith('~/')) value = path.join(home, value.slice(2));
|
|
41
|
+
const resolved = path.isAbsolute(value) ? path.normalize(value) : path.resolve(cwd, value);
|
|
42
|
+
return SPECIAL_FILES[resolved] === true ? null : resolved;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Arguments that are not flags; `--` ends flag parsing. */
|
|
46
|
+
export function nonFlagArgs(args: readonly string[]): string[] {
|
|
47
|
+
const out: string[] = [];
|
|
48
|
+
let end = false;
|
|
49
|
+
for (const arg of args) {
|
|
50
|
+
if (!end && arg === '--') {
|
|
51
|
+
end = true;
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
if (!end && arg.startsWith('-') && arg !== '-') continue;
|
|
55
|
+
out.push(arg);
|
|
56
|
+
}
|
|
57
|
+
return out;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function flagValue(args: readonly string[], flag: string): string | undefined {
|
|
61
|
+
const index = args.indexOf(flag);
|
|
62
|
+
if (index === -1) return undefined;
|
|
63
|
+
const value = args[index + 1];
|
|
64
|
+
return value && !value.startsWith('-') ? value : undefined;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** `sed`/`perl` file operands: the script is the first non-flag argument. */
|
|
68
|
+
export function scriptFiles(args: readonly string[]): string[] {
|
|
69
|
+
const files: string[] = [];
|
|
70
|
+
let scriptSeen = false;
|
|
71
|
+
for (let i = 0; i < args.length; i++) {
|
|
72
|
+
const arg = args[i];
|
|
73
|
+
if (arg === '-e' || arg === '--expression' || arg === '-f' || arg === '--file') {
|
|
74
|
+
i++;
|
|
75
|
+
scriptSeen = true;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (arg.startsWith('-')) continue;
|
|
79
|
+
if (!scriptSeen) {
|
|
80
|
+
scriptSeen = true;
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
files.push(arg);
|
|
84
|
+
}
|
|
85
|
+
return files;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function truncateFiles(args: readonly string[]): string[] {
|
|
89
|
+
const files: string[] = [];
|
|
90
|
+
for (let i = 0; i < args.length; i++) {
|
|
91
|
+
const arg = args[i];
|
|
92
|
+
if (arg === '-s' || arg === '--size' || arg === '-r' || arg === '--reference') {
|
|
93
|
+
i++;
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (arg.startsWith('-')) continue;
|
|
97
|
+
files.push(arg);
|
|
98
|
+
}
|
|
99
|
+
return files;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function dedupe(mutations: CommandMutation[]): CommandMutation[] {
|
|
103
|
+
const seen = new Set<string>();
|
|
104
|
+
const out: CommandMutation[] = [];
|
|
105
|
+
for (const mutation of mutations) {
|
|
106
|
+
const key = `${mutation.op}:${mutation.from ?? ''}:${mutation.path}`;
|
|
107
|
+
if (seen.has(key)) continue;
|
|
108
|
+
seen.add(key);
|
|
109
|
+
out.push(mutation);
|
|
110
|
+
}
|
|
111
|
+
return out;
|
|
112
|
+
}
|