@opencode/core 0.0.0-dev-20574 → 0.0.0-dev-20578
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/account/sql.js +1 -1
- package/dist/agent.js +79 -79
- package/dist/aisdk-native.js +89 -89
- package/dist/aisdk.js +94 -94
- package/dist/app.js +7 -7
- package/dist/bus.js +73 -73
- package/dist/chunks/{file-retention-3fdy5e26.js → plugin-04d3ggy7.js} +18 -18
- package/dist/chunks/{file-retention-3xnccdbj.js → plugin-06fncbhs.js} +14 -14
- package/dist/chunks/{file-retention-rpg9c19m.js → plugin-06x8he3q.js} +4 -4
- package/dist/chunks/{file-retention-dzz4avzz.js → plugin-09djgkn9.js} +20 -20
- package/dist/chunks/{file-retention-2qmevabq.js → plugin-0a04tq27.js} +1 -1
- package/dist/chunks/{file-retention-mj0s41ck.js → plugin-0d0dy0b8.js} +16 -16
- package/dist/chunks/{file-retention-dp7d2fdn.js → plugin-0grfgy22.js} +23 -23
- package/dist/chunks/{file-retention-0j77ygfz.js → plugin-0j77ygfz.js} +2 -2
- package/dist/chunks/{file-retention-fcrkznn8.js → plugin-0jwsre1p.js} +5 -5
- package/dist/chunks/{file-retention-0paq2nw3.js → plugin-0paq2nw3.js} +1 -1
- package/dist/chunks/{file-retention-0vbcp93d.js → plugin-0vbcp93d.js} +2 -2
- package/dist/chunks/{file-retention-1dazxqgg.js → plugin-1dazxqgg.js} +2 -2
- package/dist/chunks/{file-retention-1dvck2a7.js → plugin-1dvck2a7.js} +2 -2
- package/dist/chunks/{file-retention-375t9ctr.js → plugin-1eznydrh.js} +12 -12
- package/dist/chunks/{file-retention-vqr6g7p3.js → plugin-1hxtq9m9.js} +29 -29
- package/dist/chunks/{file-retention-kbrxqvty.js → plugin-1m06e57m.js} +10 -10
- package/dist/chunks/{file-retention-ywae51ae.js → plugin-1x0vprbs.js} +15 -15
- package/dist/chunks/{file-retention-1ygqh575.js → plugin-1ygqh575.js} +2 -2
- package/dist/chunks/{file-retention-3n34rj9j.js → plugin-24creq0d.js} +7 -7
- package/dist/chunks/{file-retention-fwdg1fxj.js → plugin-28z24pfh.js} +23 -23
- package/dist/chunks/{file-retention-2a5m3afh.js → plugin-2a5m3afh.js} +1 -1
- package/dist/chunks/{file-retention-2ccvkpx1.js → plugin-2ccvkpx1.js} +2 -2
- package/dist/chunks/{file-retention-qd6mjxjn.js → plugin-2dcw1sfe.js} +7 -7
- package/dist/chunks/{file-retention-gzxe17p4.js → plugin-2ex9tkzb.js} +36 -36
- package/dist/chunks/{file-retention-g186129t.js → plugin-2m5wdzz9.js} +4 -4
- package/dist/chunks/{file-retention-2cmv4prx.js → plugin-2p0jthwz.js} +15 -15
- package/dist/chunks/{file-retention-2wj8n25z.js → plugin-2p5y98w0.js} +6 -6
- package/dist/chunks/{file-retention-6sr3ve8g.js → plugin-2pnhn36q.js} +4 -4
- package/dist/chunks/{file-retention-kkszqkca.js → plugin-30hx8gy4.js} +11 -11
- package/dist/chunks/{file-retention-8nqvxmhp.js → plugin-34bd8zqa.js} +15 -15
- package/dist/chunks/{file-retention-fyjp43ss.js → plugin-35ng7dkh.js} +5 -5
- package/dist/chunks/{file-retention-sqsf5w9p.js → plugin-371g5ft3.js} +22 -22
- package/dist/chunks/{file-retention-rnyw8s47.js → plugin-39sy8z68.js} +9 -9
- package/dist/chunks/{file-retention-n3sbkf7y.js → plugin-3ary6tpn.js} +6 -6
- package/dist/chunks/{file-retention-7nd1w80t.js → plugin-3d32k6hr.js} +14 -14
- package/dist/chunks/{file-retention-3fc6dm20.js → plugin-3fc6dm20.js} +1 -1
- package/dist/chunks/{file-retention-1hs5gw21.js → plugin-3g98wrjp.js} +15 -15
- package/dist/chunks/{file-retention-3hepkmqq.js → plugin-3hepkmqq.js} +1 -1
- package/dist/chunks/{file-retention-tr8p7823.js → plugin-3n0emgyf.js} +26 -26
- package/dist/chunks/{file-retention-srdsxf88.js → plugin-3r80836k.js} +29 -29
- package/dist/chunks/{file-retention-32mfgrc2.js → plugin-3rt7qeq2.js} +46 -46
- package/dist/chunks/{file-retention-3smtnn6g.js → plugin-3smtnn6g.js} +1 -1
- package/dist/chunks/{file-retention-3tvqynh2.js → plugin-3tvqynh2.js} +1 -1
- package/dist/chunks/{file-retention-rjbgsrgy.js → plugin-3x5wnmsa.js} +3 -3
- package/dist/chunks/{file-retention-3zsf4n22.js → plugin-3zsf4n22.js} +1 -1
- package/dist/chunks/{file-retention-2196dttv.js → plugin-41japfwg.js} +19 -19
- package/dist/chunks/{file-retention-a7yy2md1.js → plugin-43r5tmwz.js} +174 -174
- package/dist/chunks/{file-retention-rxwegcwa.js → plugin-4bcaa4pk.js} +24 -24
- package/dist/chunks/{file-retention-vsv6kgcp.js → plugin-4fsvs0r5.js} +13 -13
- package/dist/chunks/{file-retention-yg48zpvb.js → plugin-4hmze3tg.js} +9 -9
- package/dist/chunks/{file-retention-d4zdj4k1.js → plugin-4r3ynae4.js} +47 -47
- package/dist/chunks/{file-retention-dm0afct9.js → plugin-51nd9ekg.js} +33 -33
- package/dist/chunks/{file-retention-54ma36ye.js → plugin-54ma36ye.js} +1 -1
- package/dist/chunks/{file-retention-y2f4f8ve.js → plugin-5anybvrp.js} +9 -9
- package/dist/chunks/{file-retention-5daktx2q.js → plugin-5daktx2q.js} +1 -1
- package/dist/chunks/{file-retention-5dkn69vz.js → plugin-5dkn69vz.js} +1 -1
- package/dist/chunks/{file-retention-m0wjs088.js → plugin-5egfvsg2.js} +25 -25
- package/dist/chunks/{file-retention-268p1yhm.js → plugin-5g4drkc8.js} +11 -11
- package/dist/chunks/{file-retention-zrpzfdax.js → plugin-5h261f6e.js} +43 -43
- package/dist/chunks/{file-retention-pvmde4fp.js → plugin-5kyzh40n.js} +5 -5
- package/dist/chunks/{file-retention-gr0k9txt.js → plugin-5p2w852e.js} +6 -6
- package/dist/chunks/{file-retention-m3jsamem.js → plugin-5q82qb79.js} +22 -22
- package/dist/chunks/{file-retention-5t3nmthw.js → plugin-5t3nmthw.js} +2 -2
- package/dist/chunks/{file-retention-p37cw4rj.js → plugin-5yzzbxa7.js} +8 -8
- package/dist/chunks/{file-retention-7dd7hteq.js → plugin-61rwkfw7.js} +13 -13
- package/dist/chunks/{file-retention-nnzbwe1c.js → plugin-62kmmg0k.js} +3 -3
- package/dist/chunks/{file-retention-669tq793.js → plugin-669tq793.js} +1 -1
- package/dist/chunks/{file-retention-87ec1t8q.js → plugin-68vrpgj2.js} +29 -29
- package/dist/chunks/{file-retention-awyx35h1.js → plugin-69hdsgk8.js} +32 -32
- package/dist/chunks/{file-retention-54rek375.js → plugin-69mqpp93.js} +20 -20
- package/dist/chunks/{file-retention-tn2h520a.js → plugin-6arwdhpr.js} +30 -30
- package/dist/chunks/{file-retention-v0es1rhs.js → plugin-6g7e4dd5.js} +7 -7
- package/dist/chunks/{file-retention-6xb47vfp.js → plugin-6xb47vfp.js} +1 -1
- package/dist/chunks/{file-retention-6zjj7zaj.js → plugin-6zy4stt8.js} +7 -7
- package/dist/chunks/{file-retention-71az546q.js → plugin-71az546q.js} +2 -2
- package/dist/chunks/{file-retention-yeg9yvqq.js → plugin-76g71pff.js} +48 -48
- package/dist/chunks/{file-retention-7bmhse3q.js → plugin-7bmhse3q.js} +1 -1
- package/dist/chunks/{file-retention-0e92md3a.js → plugin-7qgmcsxr.js} +23 -23
- package/dist/chunks/{file-retention-gy0h6dkp.js → plugin-7raxn3d9.js} +13 -13
- package/dist/chunks/{file-retention-eq1mg9hk.js → plugin-7t4975xj.js} +5 -5
- package/dist/chunks/{file-retention-tbe4vfsv.js → plugin-7y3n75t2.js} +8 -8
- package/dist/chunks/{file-retention-915xkp7h.js → plugin-81vaem42.js} +11 -11
- package/dist/chunks/{file-retention-xkepe22y.js → plugin-84fx5zbw.js} +15 -15
- package/dist/chunks/{file-retention-84txncab.js → plugin-84txncab.js} +1 -1
- package/dist/chunks/{file-retention-v8b0935d.js → plugin-8c8v92hd.js} +15 -15
- package/dist/chunks/{file-retention-f4ea6fbw.js → plugin-8cqakzrt.js} +16 -16
- package/dist/chunks/{file-retention-8d7r5vzw.js → plugin-8d7r5vzw.js} +1 -1
- package/dist/chunks/{file-retention-2r2pg6z6.js → plugin-8dsxej7q.js} +5 -5
- package/dist/chunks/{file-retention-mvns82mh.js → plugin-8etvpd78.js} +1 -1
- package/dist/chunks/{file-retention-3397p42w.js → plugin-8mq6ch7h.js} +16 -16
- package/dist/chunks/{file-retention-enqpvmpb.js → plugin-8q4vwcbd.js} +33 -33
- package/dist/chunks/{file-retention-c27esgm9.js → plugin-8s4zq5p9.js} +8 -8
- package/dist/chunks/{file-retention-py3kkmfq.js → plugin-8sze2n9a.js} +6 -6
- package/dist/chunks/{file-retention-7prahzjg.js → plugin-90wqxygs.js} +11 -11
- package/dist/chunks/{file-retention-zp1mrdgp.js → plugin-947pvy6h.js} +3 -3
- package/dist/chunks/{file-retention-3wga580s.js → plugin-9c1yxwsv.js} +13 -13
- package/dist/chunks/{file-retention-9e5bzkjp.js → plugin-9e5bzkjp.js} +3 -3
- package/dist/chunks/{file-retention-m2wjhmzf.js → plugin-9jww82ap.js} +87 -87
- package/dist/chunks/{file-retention-96xkdgy7.js → plugin-9przwesc.js} +35 -35
- package/dist/chunks/{file-retention-2n1dscnb.js → plugin-9s85hpde.js} +3 -3
- package/dist/chunks/{file-retention-f7vbsmz3.js → plugin-9szwjyee.js} +8 -8
- package/dist/chunks/{file-retention-1ncsypj2.js → plugin-9tnt1thx.js} +15 -15
- package/dist/chunks/{file-retention-v7z2bvyd.js → plugin-a3c7ahw6.js} +4 -4
- package/dist/chunks/{file-retention-aaet6srn.js → plugin-aaet6srn.js} +2 -2
- package/dist/chunks/{file-retention-7t7jzkqc.js → plugin-acqz3eas.js} +21 -21
- package/dist/chunks/{file-retention-7gmg37r4.js → plugin-afc78eap.js} +8 -8
- package/dist/chunks/{file-retention-sxsav6rz.js → plugin-agw9xp4d.js} +18 -18
- package/dist/chunks/{file-retention-krk958qj.js → plugin-ak7e9zsb.js} +38 -38
- package/dist/chunks/{file-retention-ea4zmnh0.js → plugin-aphb00ew.js} +2 -2
- package/dist/chunks/{file-retention-5n3c8dqy.js → plugin-aqs4ydsz.js} +26 -26
- package/dist/chunks/{file-retention-w3x9v1nk.js → plugin-aryyw1nk.js} +8 -8
- package/dist/chunks/{file-retention-q58edvkc.js → plugin-ay3mx084.js} +11 -11
- package/dist/chunks/{file-retention-fm2qvscf.js → plugin-b27vhd2z.js} +4 -4
- package/dist/chunks/{file-retention-b6gygkdw.js → plugin-b6gygkdw.js} +2 -2
- package/dist/chunks/{file-retention-8sngbae2.js → plugin-b7fettsd.js} +4 -4
- package/dist/chunks/{file-retention-gdzm1g2q.js → plugin-bxq680aw.js} +39 -39
- package/dist/chunks/plugin-by5v678g.js +18 -0
- package/dist/chunks/{file-retention-0vjy9swk.js → plugin-c1gr2zd3.js} +3 -3
- package/dist/chunks/{file-retention-r2qmqz0p.js → plugin-c1vsqjm1.js} +38 -38
- package/dist/chunks/{file-retention-5mra6jzn.js → plugin-c7jwjaks.js} +22 -22
- package/dist/chunks/{file-retention-cdy3mprf.js → plugin-cepe0qf7.js} +44 -44
- package/dist/chunks/{file-retention-kzgjq6s9.js → plugin-cfz5gkc0.js} +8 -8
- package/dist/chunks/{file-retention-cpneeje0.js → plugin-cpneeje0.js} +2 -2
- package/dist/chunks/{file-retention-wp6kzx6e.js → plugin-cwwytgmc.js} +4 -4
- package/dist/chunks/{file-retention-wzxmb50y.js → plugin-d10hb995.js} +25 -25
- package/dist/chunks/{file-retention-7gvnq27t.js → plugin-da0rp3w3.js} +7 -7
- package/dist/chunks/{file-retention-50gqarwy.js → plugin-djz46489.js} +13 -13
- package/dist/chunks/{file-retention-qp9vg2jq.js → plugin-drnf6xwf.js} +2 -2
- package/dist/chunks/{file-retention-mfzhreb2.js → plugin-ds421k4t.js} +11 -11
- package/dist/chunks/{file-retention-41f99y6m.js → plugin-dx92dk9v.js} +11 -11
- package/dist/chunks/{file-retention-p686mhj9.js → plugin-dyrgthp5.js} +22 -22
- package/dist/chunks/{file-retention-x953gtjm.js → plugin-e4g6rnfs.js} +7 -7
- package/dist/chunks/{file-retention-ztrfc8bt.js → plugin-e5nrtag5.js} +28 -28
- package/dist/chunks/{file-retention-mewprhs7.js → plugin-e6tayz2r.js} +49 -49
- package/dist/chunks/{file-retention-4cq6ekdq.js → plugin-e9txt9vy.js} +5 -5
- package/dist/chunks/{file-retention-2k71kv7p.js → plugin-eahhehpg.js} +4 -4
- package/dist/chunks/{file-retention-ef5x83kb.js → plugin-ef5x83kb.js} +1 -1
- package/dist/chunks/{file-retention-1szktn86.js → plugin-ef7p9trg.js} +9 -9
- package/dist/chunks/{file-retention-eq1pz5kg.js → plugin-eq1pz5kg.js} +1 -1
- package/dist/chunks/{file-retention-etq0c3wd.js → plugin-etq0c3wd.js} +1 -1
- package/dist/chunks/{file-retention-fxtr5mc8.js → plugin-ext61gvm.js} +15 -15
- package/dist/chunks/{file-retention-c1cwwd8w.js → plugin-f8147smy.js} +5 -5
- package/dist/chunks/{file-retention-x9ehtewq.js → plugin-fdf2r7px.js} +25 -25
- package/dist/chunks/{file-retention-mvjs53cw.js → plugin-fnwaevmq.js} +36 -36
- package/dist/chunks/{file-retention-2wz3v08k.js → plugin-fq3v9e4w.js} +22 -22
- package/dist/chunks/{file-retention-1wqgvv8c.js → plugin-fwdyap71.js} +8 -8
- package/dist/chunks/{file-retention-319s4164.js → plugin-fz79dkc7.js} +8 -8
- package/dist/chunks/plugin-g93t3hq1.js +26 -0
- package/dist/chunks/{file-retention-ezg6p8me.js → plugin-gahzhxn8.js} +23 -23
- package/dist/chunks/{file-retention-gd4qta3r.js → plugin-gd4qta3r.js} +1 -1
- package/dist/chunks/{file-retention-ajjrsc3c.js → plugin-gfwqja43.js} +5 -5
- package/dist/chunks/{file-retention-h2b79v29.js → plugin-h2b79v29.js} +2 -2
- package/dist/chunks/{file-retention-9b9xphtx.js → plugin-h4cyradc.js} +12 -12
- package/dist/chunks/{file-retention-h5w29vws.js → plugin-h5w29vws.js} +1 -1
- package/dist/chunks/{file-retention-h6vf3j39.js → plugin-h6vf3j39.js} +1 -1
- package/dist/chunks/{file-retention-p78wsmvm.js → plugin-h8ft0m90.js} +14 -14
- package/dist/chunks/plugin-h92akkf0.js +253 -0
- package/dist/chunks/{file-retention-1mxdpm3z.js → plugin-hahjxtze.js} +10 -10
- package/dist/chunks/{file-retention-7ryscgg3.js → plugin-hcd320rf.js} +3 -3
- package/dist/chunks/plugin-hqe3s9vz.js +507 -0
- package/dist/chunks/{file-retention-4wsngk0e.js → plugin-hz0mzm96.js} +57 -57
- package/dist/chunks/{file-retention-z8fkwh97.js → plugin-j2zjmsnh.js} +6 -6
- package/dist/chunks/{file-retention-j56e64zr.js → plugin-j56e64zr.js} +1 -1
- package/dist/chunks/{file-retention-kc9s2bvd.js → plugin-j730n9rv.js} +22 -22
- package/dist/chunks/{file-retention-f3fpyva3.js → plugin-jav2p7n3.js} +3 -3
- package/dist/chunks/{file-retention-veyd67p8.js → plugin-jgj04qff.js} +11 -11
- package/dist/chunks/{file-retention-x5n5s6zj.js → plugin-js9gsb9m.js} +16 -16
- package/dist/chunks/{file-retention-g8h4s9py.js → plugin-k0r5d45h.js} +5 -5
- package/dist/chunks/{file-retention-y65z2yc1.js → plugin-k618byr3.js} +17 -17
- package/dist/chunks/{file-retention-k70p9jzb.js → plugin-k70p9jzb.js} +2 -2
- package/dist/chunks/{file-retention-697fm79x.js → plugin-kb6vbnxp.js} +4 -4
- package/dist/chunks/{file-retention-e053pdg9.js → plugin-kem2dng2.js} +33 -33
- package/dist/chunks/{file-retention-t80nve53.js → plugin-khhk3gee.js} +9 -9
- package/dist/chunks/{file-retention-vazhwx36.js → plugin-kjdm35cs.js} +5 -5
- package/dist/chunks/{file-retention-wv99ph99.js → plugin-kk5na4ms.js} +3 -3
- package/dist/chunks/{file-retention-z9jgckgc.js → plugin-kqzb879x.js} +25 -25
- package/dist/chunks/{file-retention-ma0f636y.js → plugin-ksr3qje0.js} +14 -9
- package/dist/chunks/{file-retention-a1095nc3.js → plugin-ktyrkyt5.js} +13 -13
- package/dist/chunks/{file-retention-m3fdjcah.js → plugin-m3fdjcah.js} +1 -1
- package/dist/chunks/{file-retention-y45w4r2r.js → plugin-m4wv7hmr.js} +16 -16
- package/dist/chunks/{file-retention-m9w0rfyh.js → plugin-m9w0rfyh.js} +1 -1
- package/dist/chunks/{file-retention-9gvqmzxk.js → plugin-mccvx0ph.js} +10 -10
- package/dist/chunks/{file-retention-qqrjxc2w.js → plugin-mdvte9fh.js} +12 -12
- package/dist/chunks/{file-retention-krg3ta3s.js → plugin-mk89bcdm.js} +10 -10
- package/dist/chunks/{file-retention-fk670htj.js → plugin-mmq86yx8.js} +24 -24
- package/dist/chunks/{file-retention-5epte933.js → plugin-my4zabxr.js} +2 -2
- package/dist/chunks/{file-retention-57errdhv.js → plugin-n11bbmz5.js} +4 -4
- package/dist/chunks/{file-retention-n9k80d2m.js → plugin-nj1j17x6.js} +8 -8
- package/dist/chunks/{file-retention-qwrqq5be.js → plugin-nnjbqqpn.js} +10 -10
- package/dist/chunks/{file-retention-vw1pxqrh.js → plugin-nqa2gsff.js} +11 -11
- package/dist/chunks/{file-retention-dpkg50ah.js → plugin-nxm207yx.js} +4 -4
- package/dist/chunks/{file-retention-zfaa1m6t.js → plugin-nxnchq8r.js} +14 -14
- package/dist/chunks/{file-retention-pm9geeax.js → plugin-nzh5psd4.js} +9 -9
- package/dist/chunks/{file-retention-ypbz4tzh.js → plugin-pcfe7wwq.js} +5 -5
- package/dist/chunks/{file-retention-stsn5t8w.js → plugin-pfpr1sg6.js} +13 -13
- package/dist/chunks/{file-retention-wgka6yms.js → plugin-pfybfzrt.js} +19 -19
- package/dist/chunks/{file-retention-pjvnvgmy.js → plugin-pjvnvgmy.js} +1 -1
- package/dist/chunks/{file-retention-pknna89w.js → plugin-pknna89w.js} +1 -1
- package/dist/chunks/{file-retention-y15vpdnr.js → plugin-pnkbpv6t.js} +9 -9
- package/dist/chunks/{file-retention-rat4bpn3.js → plugin-q41hpyd6.js} +29 -29
- package/dist/chunks/{file-retention-pd3frt8f.js → plugin-q5fbr5p5.js} +5 -5
- package/dist/chunks/{file-retention-33166y9b.js → plugin-q9nhy42k.js} +31 -31
- package/dist/chunks/{file-retention-2nxxjbx2.js → plugin-qce0q5sw.js} +8 -8
- package/dist/chunks/{file-retention-fhz5gfgy.js → plugin-qdbakdjh.js} +5 -5
- package/dist/chunks/{file-retention-t785n9z2.js → plugin-qj2xshqj.js} +30 -30
- package/dist/chunks/{file-retention-zy3hk2a4.js → plugin-qj750ez4.js} +4 -4
- package/dist/chunks/{file-retention-pvb1tgyf.js → plugin-qkn17avs.js} +9 -9
- package/dist/chunks/{file-retention-qnc92qwc.js → plugin-qnc92qwc.js} +1 -1
- package/dist/chunks/{file-retention-zmr78fwr.js → plugin-qne3fa44.js} +5 -5
- package/dist/chunks/{file-retention-b1jpbdrv.js → plugin-qq2xhrb8.js} +41 -41
- package/dist/chunks/{file-retention-2m8jawch.js → plugin-qr25pfvb.js} +4 -4
- package/dist/chunks/{file-retention-qsdy395h.js → plugin-qsdy395h.js} +1 -1
- package/dist/chunks/{file-retention-xyafkbt0.js → plugin-qxjc9qry.js} +3 -3
- package/dist/chunks/{file-retention-qygbw77c.js → plugin-qygbw77c.js} +2 -2
- package/dist/chunks/{file-retention-ax0xj8rw.js → plugin-r9f8m4wv.js} +14 -14
- package/dist/chunks/{file-retention-rdw6cm16.js → plugin-rdw6cm16.js} +1 -1
- package/dist/chunks/{file-retention-mw1bpke0.js → plugin-rk6z8b2s.js} +33 -33
- package/dist/chunks/{file-retention-5ykye0sw.js → plugin-s607qcgc.js} +24 -24
- package/dist/chunks/{file-retention-ngzfrjhk.js → plugin-sqhwqkv8.js} +18 -18
- package/dist/chunks/{file-retention-848ay80d.js → plugin-sr4k8heh.js} +7 -7
- package/dist/chunks/{file-retention-13wr99d4.js → plugin-svf1j9mj.js} +16 -16
- package/dist/chunks/{file-retention-hg0myvjy.js → plugin-sw2ky0ak.js} +22 -22
- package/dist/chunks/{file-retention-sd5f6jdk.js → plugin-sxzvkvgj.js} +6 -6
- package/dist/chunks/{file-retention-hzwpgbhq.js → plugin-t01ewf6t.js} +11 -11
- package/dist/chunks/{file-retention-a1dpt3w1.js → plugin-t03g005h.js} +8 -8
- package/dist/chunks/{file-retention-t550f9t1.js → plugin-t550f9t1.js} +1 -1
- package/dist/chunks/{file-retention-qq827dyh.js → plugin-t5n9kkmz.js} +6 -6
- package/dist/chunks/{file-retention-tazgh4e4.js → plugin-tazgh4e4.js} +1 -1
- package/dist/chunks/{file-retention-9hb60gjr.js → plugin-tc91rda6.js} +9 -9
- package/dist/chunks/{file-retention-tcezcvh9.js → plugin-tcezcvh9.js} +1 -1
- package/dist/chunks/{file-retention-tdstcens.js → plugin-tdstcens.js} +1 -1
- package/dist/chunks/{file-retention-ymkva6fh.js → plugin-tefzd8kx.js} +28 -28
- package/dist/chunks/{file-retention-v5xqqhk9.js → plugin-ty9x2hpf.js} +19 -19
- package/dist/chunks/{file-retention-6z3bvhcz.js → plugin-v9b8r7m3.js} +12 -12
- package/dist/chunks/{file-retention-kzxyyqqs.js → plugin-v9gryrmc.js} +76 -76
- package/dist/chunks/{file-retention-veqvce7d.js → plugin-veqvce7d.js} +1 -1
- package/dist/chunks/{file-retention-e3dcjyq4.js → plugin-vvr3dw31.js} +10 -10
- package/dist/chunks/{file-retention-xpj445q7.js → plugin-vx4r8km3.js} +28 -28
- package/dist/chunks/{file-retention-9jgrbctr.js → plugin-vynkv33f.js} +13 -13
- package/dist/chunks/{file-retention-vzcthcp8.js → plugin-vzcthcp8.js} +1 -1
- package/dist/chunks/{file-retention-vzs5sf6e.js → plugin-vzs5sf6e.js} +1 -1
- package/dist/chunks/{file-retention-yrd2sane.js → plugin-w05x0cfw.js} +6 -6
- package/dist/chunks/{file-retention-dy8qh9xy.js → plugin-w1ad28wa.js} +5 -5
- package/dist/chunks/{file-retention-w3wsvvr9.js → plugin-w3wsvvr9.js} +1 -1
- package/dist/chunks/{file-retention-t0v7bfqb.js → plugin-w7m571bh.js} +32 -32
- package/dist/chunks/{file-retention-ttgz6xng.js → plugin-w808e159.js} +18 -18
- package/dist/chunks/{file-retention-wd87259q.js → plugin-wd87259q.js} +1 -1
- package/dist/chunks/{file-retention-5ae5pymj.js → plugin-wp1hpspq.js} +6 -6
- package/dist/chunks/{file-retention-addxnjmp.js → plugin-x661k3y3.js} +4 -4
- package/dist/chunks/{file-retention-k11a9bb6.js → plugin-x88jpnpr.js} +21 -21
- package/dist/chunks/{file-retention-xfkkasph.js → plugin-xfkkasph.js} +1 -1
- package/dist/chunks/{file-retention-dmqcgk4z.js → plugin-xkntkrq7.js} +5 -5
- package/dist/chunks/{file-retention-95833ddw.js → plugin-xkt82cda.js} +21 -21
- package/dist/chunks/{file-retention-zmphxn8h.js → plugin-xqsx1vwf.js} +31 -31
- package/dist/chunks/{file-retention-27yxxq2c.js → plugin-xt0fd68y.js} +13 -13
- package/dist/chunks/{file-retention-xeng5h15.js → plugin-xw9z83sh.js} +55 -55
- package/dist/chunks/{file-retention-y1fvbwt7.js → plugin-y1fvbwt7.js} +1 -1
- package/dist/chunks/{file-retention-jnx78pdv.js → plugin-y630p9sc.js} +23 -23
- package/dist/chunks/{file-retention-rxgdtc18.js → plugin-y7nnagj6.js} +30 -30
- package/dist/chunks/{file-retention-amxv2bkz.js → plugin-ydkmjtsm.js} +11 -11
- package/dist/chunks/{file-retention-1k9vww9s.js → plugin-ydrgdh5s.js} +21 -21
- package/dist/chunks/{file-retention-xesmd8aj.js → plugin-yfh8cgan.js} +9 -9
- package/dist/chunks/{file-retention-hjqkwgk2.js → plugin-ygkw9vpb.js} +14 -14
- package/dist/chunks/{file-retention-1acjjqhc.js → plugin-yp2x3t23.js} +4 -4
- package/dist/chunks/{file-retention-prq7hedt.js → plugin-yr715y08.js} +9 -9
- package/dist/chunks/{file-retention-xf1w3e7t.js → plugin-yrh23yf8.js} +15 -15
- package/dist/chunks/{file-retention-a9j2r79z.js → plugin-yrqbh8b0.js} +20 -20
- package/dist/chunks/{file-retention-2v1t43t7.js → plugin-yt1qgzdm.js} +10 -10
- package/dist/chunks/{file-retention-z0bkrqjs.js → plugin-z0bkrqjs.js} +1 -1
- package/dist/chunks/{file-retention-mek16e5d.js → plugin-z4ev155g.js} +11 -11
- package/dist/chunks/{file-retention-qh5zdhhs.js → plugin-z5rqpkns.js} +35 -35
- package/dist/chunks/{file-retention-732xvhct.js → plugin-zdpsxmh8.js} +38 -38
- package/dist/chunks/{file-retention-6efb5sa0.js → plugin-zg6rd06s.js} +11 -11
- package/dist/chunks/{file-retention-z2yservp.js → plugin-znfvst1a.js} +3 -3
- package/dist/chunks/{file-retention-zr2ceqn5.js → plugin-zr2ceqn5.js} +1 -1
- package/dist/chunks/{file-retention-zxq2ej10.js → plugin-zxq2ej10.js} +1 -1
- package/dist/chunks/{file-retention-vgmzs5ge.js → plugin-zz5k72w4.js} +20 -20
- package/dist/codemode/catalog.js +1 -1
- package/dist/codemode/instructions.js +5 -5
- package/dist/codemode/tool.js +3 -3
- package/dist/codemode/web.js +1 -1
- package/dist/command.js +83 -83
- package/dist/config/discovery.js +82 -82
- package/dist/config/markdown.js +1 -1
- package/dist/config/normalize.js +99 -99
- package/dist/config/plugin/agent.js +116 -116
- package/dist/config/plugin/command.js +205 -205
- package/dist/config/plugin/compaction.js +154 -154
- package/dist/config/plugin/compatibility.js +132 -132
- package/dist/config/plugin/entry-observer.js +1 -1
- package/dist/config/plugin/formatter.js +117 -117
- package/dist/config/plugin/image.js +116 -116
- package/dist/config/plugin/instruction.js +90 -90
- package/dist/config/plugin/location-watcher.js +118 -118
- package/dist/config/plugin/mcp.js +123 -123
- package/dist/config/plugin/policy.js +117 -117
- package/dist/config/plugin/provider.js +116 -116
- package/dist/config/plugin/reference.js +118 -118
- package/dist/config/plugin/shell.js +118 -118
- package/dist/config/plugin/skill-file.js +102 -102
- package/dist/config/plugin/skill.js +137 -137
- package/dist/config/plugin/snapshot.js +116 -116
- package/dist/config/plugin/source.js +117 -117
- package/dist/config/plugin/tool-output.js +117 -117
- package/dist/config/plugin/websearch.js +117 -117
- package/dist/config/plugin/worktree.js +118 -118
- package/dist/config/variable.js +3 -3
- package/dist/config/watch.js +1 -1
- package/dist/config.js +121 -121
- package/dist/credential/sql.js +2 -2
- package/dist/credential.js +83 -83
- package/dist/database/database.js +66 -66
- package/dist/database/drizzle/effect-sqlite/driver.js +14 -14
- package/dist/database/drizzle/effect-sqlite/index.js +14 -14
- package/dist/database/drizzle/effect-sqlite/session.js +11 -11
- package/dist/database/drizzle/index.js +15 -15
- package/dist/database/drizzle/internal/drizzle-utils.js +1 -1
- package/dist/database/drizzle/sqlite-core/effect/count.js +1 -1
- package/dist/database/drizzle/sqlite-core/effect/db.js +9 -9
- package/dist/database/drizzle/sqlite-core/effect/delete.js +2 -2
- package/dist/database/drizzle/sqlite-core/effect/index.js +10 -10
- package/dist/database/drizzle/sqlite-core/effect/insert.js +2 -2
- package/dist/database/drizzle/sqlite-core/effect/query.js +1 -1
- package/dist/database/drizzle/sqlite-core/effect/raw.js +1 -1
- package/dist/database/drizzle/sqlite-core/effect/select.js +2 -2
- package/dist/database/drizzle/sqlite-core/effect/session.js +10 -10
- package/dist/database/drizzle/sqlite-core/effect/update.js +2 -2
- package/dist/database/drizzle.js +16 -16
- package/dist/database/migration/20260127222353_familiar_lady_ursula.js +1 -1
- package/dist/database/migration/20260211171708_add_project_commands.js +1 -1
- package/dist/database/migration/20260213144116_wakeful_the_professor.js +1 -1
- package/dist/database/migration/20260225215848_workspace.js +1 -1
- package/dist/database/migration/20260227213759_add_session_workspace_id.js +1 -1
- package/dist/database/migration/20260228203230_blue_harpoon.js +1 -1
- package/dist/database/migration/20260303231226_add_workspace_fields.js +1 -1
- package/dist/database/migration/20260309230000_move_org_to_state.js +1 -1
- package/dist/database/migration/20260312043431_session_message_cursor.js +1 -1
- package/dist/database/migration/20260323234822_events.js +1 -1
- package/dist/database/migration/20260410174513_workspace-name.js +1 -1
- package/dist/database/migration/20260413175956_chief_energizer.js +1 -1
- package/dist/database/migration/20260423070820_add_icon_url_override.js +1 -1
- package/dist/database/migration/20260427172553_slow_nightmare.js +1 -1
- package/dist/database/migration/20260428004200_add_session_path.js +1 -1
- package/dist/database/migration/20260501142318_next_venus.js +1 -1
- package/dist/database/migration/20260504145000_add_sync_owner.js +1 -1
- package/dist/database/migration/20260507164347_add_workspace_time.js +1 -1
- package/dist/database/migration/20260510033149_session_usage.js +1 -1
- package/dist/database/migration/20260511000411_data_migration_state.js +1 -1
- package/dist/database/migration/20260511173437_session-metadata.js +1 -1
- package/dist/database/migration/20260601010001_normalize_storage_paths.js +1 -1
- package/dist/database/migration/20260601202201_amazing_prowler.js +1 -1
- package/dist/database/migration/20260602002951_lowly_union_jack.js +1 -1
- package/dist/database/migration/20260602182828_add_project_directories.js +1 -1
- package/dist/database/migration/20260603001617_session_message_projection_indexes.js +1 -1
- package/dist/database/migration/20260603040000_session_message_projection_order.js +1 -1
- package/dist/database/migration/20260603141458_session_input_inbox.js +1 -1
- package/dist/database/migration/20260603160727_jittery_ezekiel_stane.js +1 -1
- package/dist/database/migration/20260604172448_event_sourced_session_input.js +1 -1
- package/dist/database/migration/20260605003541_add_session_context_snapshot.js +1 -1
- package/dist/database/migration/20260605042240_add_context_epoch_agent.js +1 -1
- package/dist/database/migration/20260611035744_credential.js +1 -1
- package/dist/database/migration/20260611192811_lush_chimera.js +1 -1
- package/dist/database/migration/20260612174303_project_dir_strategy.js +1 -1
- package/dist/database/migration/20260622142730_simplify_session_context_epoch.js +1 -1
- package/dist/database/migration/20260622170816_reset_v2_session_state.js +1 -1
- package/dist/database/migration/20260622202450_simplify_session_input.js +1 -1
- package/dist/database/migration/20260804233008_loose_psylocke.js +1 -1
- package/dist/database/migration/20260805200742_import_legacy_credentials.js +1 -1
- package/dist/database/migration/20260808023530_workspace_domain.js +1 -1
- package/dist/database/migration/20260811161259_execution_claim_attempts.js +1 -1
- package/dist/database/migration/20260812181746_session_inbox.js +1 -1
- package/dist/database/migration/20260812213948_worktree.js +1 -1
- package/dist/database/migration/20260819222447_session_viewed_state.js +1 -1
- package/dist/database/migration/20260823191254_nullable_workspace_binding.js +1 -1
- package/dist/database/migration/20260910120000_clear_v1_session_permission.js +1 -1
- package/dist/database/migration/20260923013825_project_time_active.js +1 -1
- package/dist/database/migration.gen.js +49 -49
- package/dist/database/migration.js +51 -51
- package/dist/database/path.js +2 -2
- package/dist/database/schema.gen.js +1 -1
- package/dist/database/schema.sql.js +1 -1
- package/dist/database/sqlite.bun.js +1 -1
- package/dist/database/sqlite.js +1 -1
- package/dist/database/sqlite.node.js +1 -1
- package/dist/database/sqlite.workerd.js +1 -1
- package/dist/database/v1-migration.bun.js +76 -76
- package/dist/database/v1-migration.js +1 -1
- package/dist/effect/app-node-builder.js +363 -363
- package/dist/effect/app-node-platform.js +2 -2
- package/dist/effect/keyed-mutex.js +3 -3
- package/dist/effect/websocket-constructor.js +1 -1
- package/dist/environment/driver.js +1 -1
- package/dist/environment/environment.js +93 -93
- package/dist/environment/exec-defaults.js +2 -2
- package/dist/environment/files.js +1 -1
- package/dist/environment/index.js +95 -95
- package/dist/environment/local.js +2 -2
- package/dist/environment/memory.js +2 -2
- package/dist/environment/unavailable.js +1 -1
- package/dist/event/sql.js +1 -1
- package/dist/event-logger.js +72 -72
- package/dist/file-access.js +104 -104
- package/dist/file-mutation.js +94 -94
- package/dist/file-retention.js +1 -1
- package/dist/filesystem/fff.bun.js +2 -2
- package/dist/filesystem/fff.js +1 -1
- package/dist/filesystem/fff.node.js +2 -2
- package/dist/filesystem/fff.workerd.js +2 -2
- package/dist/filesystem/location-watcher-policy.js +2 -2
- package/dist/filesystem/location-watcher.js +220 -220
- package/dist/filesystem/protected.js +1 -1
- package/dist/filesystem/search.js +103 -103
- package/dist/filesystem/watcher-binding.js +1 -1
- package/dist/filesystem/watcher.js +15 -15
- package/dist/filesystem.js +100 -100
- package/dist/form.js +74 -74
- package/dist/formatter/builtins.js +2 -2
- package/dist/formatter.js +87 -87
- package/dist/generate.js +103 -103
- package/dist/git.js +10 -10
- package/dist/github-copilot/chat/convert-to-openai-compatible-chat-messages.js +1 -1
- package/dist/github-copilot/chat/get-response-metadata.js +1 -1
- package/dist/github-copilot/chat/map-openai-compatible-finish-reason.js +1 -1
- package/dist/github-copilot/chat/openai-compatible-chat-language-model.js +7 -7
- package/dist/github-copilot/chat/openai-compatible-chat-options.js +1 -1
- package/dist/github-copilot/chat/openai-compatible-prepare-tools.js +1 -1
- package/dist/github-copilot/copilot-provider.js +17 -17
- package/dist/github-copilot/models.js +99 -99
- package/dist/github-copilot/openai-compatible-error.js +1 -1
- package/dist/github-copilot/responses/convert-to-openai-responses-input.js +1 -1
- package/dist/github-copilot/responses/map-openai-responses-finish-reason.js +1 -1
- package/dist/github-copilot/responses/openai-error.js +1 -1
- package/dist/github-copilot/responses/openai-responses-language-model.js +10 -10
- package/dist/github-copilot/responses/openai-responses-prepare-tools.js +6 -6
- package/dist/github-copilot/responses/tool/code-interpreter.js +1 -1
- package/dist/github-copilot/responses/tool/file-search.js +1 -1
- package/dist/github-copilot/responses/tool/image-generation.js +1 -1
- package/dist/github-copilot/responses/tool/web-search-preview.js +1 -1
- package/dist/github-copilot/responses/tool/web-search.js +1 -1
- package/dist/image/photon.js +2 -2
- package/dist/image.js +6 -6
- package/dist/instance/service.js +5 -5
- package/dist/instance.js +354 -354
- package/dist/instruction-discovery.js +85 -85
- package/dist/instructions/builtins.js +87 -87
- package/dist/instructions/index.js +1 -1
- package/dist/integration/connection.js +3 -3
- package/dist/integration.js +83 -83
- package/dist/job.js +78 -78
- package/dist/kv/sql.js +2 -2
- package/dist/kv.js +71 -71
- package/dist/location-activity.js +132 -132
- package/dist/location-lifecycle.js +107 -107
- package/dist/location-service-map.js +86 -86
- package/dist/location-services.js +351 -351
- package/dist/location.js +87 -87
- package/dist/managed-policy.js +5 -5
- package/dist/mcp/client.js +91 -91
- package/dist/mcp/index.js +109 -109
- package/dist/mcp/instructions.js +125 -125
- package/dist/mcp/oauth.js +92 -87
- package/dist/mcp/stdio.js +90 -90
- package/dist/mime.js +1 -1
- package/dist/modal/models.js +99 -99
- package/dist/model-resolver.js +98 -98
- package/dist/model.js +96 -96
- package/dist/models-dev.js +107 -107
- package/dist/oauth/page.js +1 -1
- package/dist/permission/saved.js +80 -80
- package/dist/permission/sql.js +5 -5
- package/dist/permission.js +107 -107
- package/dist/persistent-pty/binary.bun.js +1 -1
- package/dist/persistent-pty/daemon.js +1 -1
- package/dist/persistent-pty/index.js +90 -90
- package/dist/persistent-pty/pty-binding.js +1 -1
- package/dist/persistent-pty.js +75 -75
- package/dist/plugin/agent.js +100 -100
- package/dist/plugin/command.js +100 -100
- package/dist/plugin/hooks.js +5 -5
- package/dist/plugin/host.js +211 -211
- package/dist/plugin/identity.js +3 -3
- package/dist/plugin/instance.js +5 -5
- package/dist/plugin/internal.js +326 -326
- package/dist/plugin/mcp-codemode-defaults.js +3 -3
- package/dist/plugin/models-dev.js +96 -96
- package/dist/plugin/module.js +7 -7
- package/dist/plugin/optimize.js +4 -4
- package/dist/plugin/plan.js +102 -102
- package/dist/plugin/promise.js +1 -1
- package/dist/plugin/provider/amazon-bedrock.js +90 -90
- package/dist/plugin/provider/azure.js +117 -117
- package/dist/plugin/provider/cerebras.js +1 -1
- package/dist/plugin/provider/chatgpt.js +93 -93
- package/dist/plugin/provider/cloudflare-ai-gateway.js +113 -113
- package/dist/plugin/provider/cloudflare-workers-ai.js +114 -114
- package/dist/plugin/provider/cohere.js +2 -2
- package/dist/plugin/provider/configured.js +112 -112
- package/dist/plugin/provider/digitalocean.js +93 -93
- package/dist/plugin/provider/dynamic.js +2 -2
- package/dist/plugin/provider/factory.js +1 -1
- package/dist/plugin/provider/gateway.js +2 -2
- package/dist/plugin/provider/github-copilot.js +95 -95
- package/dist/plugin/provider/gitlab.js +93 -93
- package/dist/plugin/provider/google-vertex.js +90 -90
- package/dist/plugin/provider/kilo.js +1 -1
- package/dist/plugin/provider/llmgateway.js +78 -78
- package/dist/plugin/provider/lmstudio.js +115 -115
- package/dist/plugin/provider/modal.js +92 -92
- package/dist/plugin/provider/nvidia.js +1 -1
- package/dist/plugin/provider/ollama.js +115 -115
- package/dist/plugin/provider/openai.js +95 -95
- package/dist/plugin/provider/opencode.js +96 -96
- package/dist/plugin/provider/openrouter.js +91 -91
- package/dist/plugin/provider/perplexity.js +2 -2
- package/dist/plugin/provider/poe.js +79 -79
- package/dist/plugin/provider/prompt-cache-key.js +90 -90
- package/dist/plugin/provider/sap-ai-core.js +91 -91
- package/dist/plugin/provider/sdk-factory.js +1 -1
- package/dist/plugin/provider/snowflake-cortex.js +115 -115
- package/dist/plugin/provider/vercel.js +90 -90
- package/dist/plugin/provider/vllm.js +115 -115
- package/dist/plugin/provider/xai.js +91 -91
- package/dist/plugin/provider/zenmux.js +1 -1
- package/dist/plugin/provider.js +155 -155
- package/dist/plugin/sdk.js +74 -74
- package/dist/plugin/service.js +3 -3
- package/dist/plugin/skill.js +132 -132
- package/dist/plugin/source-directory.js +1 -1
- package/dist/plugin/supervisor.js +343 -343
- package/dist/plugin/tool-input-repair.js +4 -4
- package/dist/plugin/update.js +6 -6
- package/dist/plugin/vcs/git.js +86 -86
- package/dist/plugin/vcs/hg.js +86 -86
- package/dist/plugin/verbosity.js +91 -91
- package/dist/plugin/warming.js +114 -114
- package/dist/plugin/websearch/exa.js +5 -5
- package/dist/plugin/websearch/firecrawl.js +6 -6
- package/dist/plugin/websearch/index.js +9 -9
- package/dist/plugin/websearch/mcp.js +2 -2
- package/dist/plugin/websearch/parallel.js +8 -8
- package/dist/plugin/websearch/tavily.js +4 -4
- package/dist/plugin/websearch/tinyfish.js +8 -8
- package/dist/plugin.js +222 -222
- package/dist/project/schema.js +6 -6
- package/dist/project/sql.js +4 -4
- package/dist/project.js +88 -88
- package/dist/provider.js +95 -95
- package/dist/pty/protocol.js +1 -1
- package/dist/pty/ticket.js +1 -1
- package/dist/pty.js +95 -95
- package/dist/reference/instructions.js +87 -87
- package/dist/reference.js +91 -91
- package/dist/repository-cache.js +79 -79
- package/dist/repository.js +1 -1
- package/dist/ripgrep/binary.js +2 -2
- package/dist/ripgrep.js +95 -95
- package/dist/rpc.js +86 -86
- package/dist/schema.js +1 -1
- package/dist/session/affinity.js +1 -1
- package/dist/session/command.js +74 -74
- package/dist/session/compaction.js +129 -129
- package/dist/session/context.js +151 -151
- package/dist/session/diff.js +88 -88
- package/dist/session/environment.js +5 -5
- package/dist/session/error.js +5 -5
- package/dist/session/event.js +1 -1
- package/dist/session/execution/restart.js +215 -215
- package/dist/session/execution.js +127 -127
- package/dist/session/generate.js +152 -152
- package/dist/session/history.js +13 -13
- package/dist/session/inbox.js +90 -90
- package/dist/session/info.js +3 -3
- package/dist/session/instruction-entry.js +77 -77
- package/dist/session/instruction-state.js +8 -8
- package/dist/session/instructions.js +93 -93
- package/dist/session/message-updater.js +4 -4
- package/dist/session/message.js +1 -1
- package/dist/session/model-request.js +118 -118
- package/dist/session/model-transport.js +9 -9
- package/dist/session/move.js +129 -129
- package/dist/session/projector.js +86 -86
- package/dist/session/prompt.js +105 -105
- package/dist/session/provider-context.js +1 -1
- package/dist/session/revert.js +90 -90
- package/dist/session/run-coordinator.js +3 -3
- package/dist/session/runner/index.js +3 -3
- package/dist/session/runner/llm.js +222 -222
- package/dist/session/runner/max-steps.js +1 -1
- package/dist/session/runner/model.js +98 -98
- package/dist/session/runner/publish-llm-event.js +113 -113
- package/dist/session/runner/retry.js +2 -2
- package/dist/session/runner/step.js +125 -125
- package/dist/session/runner/to-llm-message.js +2 -2
- package/dist/session/schema.js +3 -3
- package/dist/session/session.js +162 -162
- package/dist/session/shell.js +130 -130
- package/dist/session/skill.js +103 -103
- package/dist/session/sql.js +5 -5
- package/dist/session/stats.js +73 -73
- package/dist/session/store.js +87 -87
- package/dist/session/subagent-completion.js +1 -1
- package/dist/session/subagent-job.js +203 -203
- package/dist/session/system-prompt.js +1 -1
- package/dist/session/title.js +151 -151
- package/dist/session/to-session-error.js +111 -111
- package/dist/session/transfer.js +209 -209
- package/dist/session/usage.js +1 -1
- package/dist/session.js +207 -207
- package/dist/shell/parse.js +6 -6
- package/dist/shell/result.js +1 -1
- package/dist/shell/scan.js +1238 -682
- package/dist/shell/select.js +11 -11
- package/dist/shell.js +132 -132
- package/dist/skill/discovery.js +2 -2
- package/dist/skill/instructions.js +105 -105
- package/dist/skill.js +114 -114
- package/dist/snapshot.js +93 -93
- package/dist/state.js +1 -1
- package/dist/tool/html-markdown.js +1 -1
- package/dist/tool/http-body.js +1 -1
- package/dist/tool/mcp.js +126 -126
- package/dist/tool/plugin/edit.js +114 -114
- package/dist/tool/plugin/file-diff.js +1 -1
- package/dist/tool/plugin/glob.js +120 -120
- package/dist/tool/plugin/grep.js +124 -124
- package/dist/tool/plugin/mcp-resource.js +117 -117
- package/dist/tool/plugin/opencode.js +3 -3
- package/dist/tool/plugin/patch.js +120 -120
- package/dist/tool/plugin/question.js +101 -101
- package/dist/tool/plugin/read.js +125 -125
- package/dist/tool/plugin/shell.js +210 -210
- package/dist/tool/plugin/skill.js +113 -113
- package/dist/tool/plugin/subagent.js +210 -210
- package/dist/tool/plugin/webfetch.js +110 -110
- package/dist/tool/plugin/websearch.js +114 -114
- package/dist/tool/plugin/write.js +122 -122
- package/dist/tool/read-filesystem.js +96 -96
- package/dist/tool/runtime.js +1 -1
- package/dist/tool-output.js +7 -7
- package/dist/tool.js +14 -14
- package/dist/types/mcp/oauth.d.ts +1 -10
- package/dist/types/shell/scan.d.ts +2 -1
- package/dist/util/error-summary.js +1 -1
- package/dist/util/error.js +1 -1
- package/dist/util/git-executable.js +2 -2
- package/dist/util/iife.js +1 -1
- package/dist/util/lazy.js +1 -1
- package/dist/util/slug.js +1 -1
- package/dist/util/token.js +1 -1
- package/dist/util/which.js +1 -1
- package/dist/util/wildcard.js +1 -1
- package/dist/v1/config/agent.js +5 -5
- package/dist/v1/config/command.js +3 -3
- package/dist/v1/config/error.js +2 -2
- package/dist/v1/config/mcp.js +4 -4
- package/dist/v1/config/migrate.js +92 -92
- package/dist/v1/config/permission.js +3 -3
- package/dist/v1/config/plugin.js +3 -3
- package/dist/v1/config/provider-options.js +1 -1
- package/dist/v1/config/provider.js +4 -4
- package/dist/variant.js +93 -93
- package/dist/vcs/patch.js +1 -1
- package/dist/vcs.js +89 -89
- package/dist/websearch.js +82 -82
- package/dist/wellknown/plugin.js +74 -74
- package/dist/wellknown.js +81 -81
- package/dist/workspace/driver.js +7 -7
- package/dist/workspace/sql.js +1 -1
- package/dist/workspace.js +80 -80
- package/dist/worktree/directory.js +2 -2
- package/dist/worktree/git.js +10 -10
- package/dist/worktree/sql.js +5 -5
- package/dist/worktree/strategies.js +89 -89
- package/dist/worktree.js +96 -96
- package/package.json +8 -8
- package/dist/chunks/file-retention-esnfnt1j.js +0 -507
- package/dist/chunks/file-retention-pf31ssb9.js +0 -18
- package/dist/chunks/file-retention-t8fqbehz.js +0 -253
- package/dist/chunks/file-retention-yyn9wyjq.js +0 -26
- /package/dist/chunks/{file-retention-0qkdqm5v.js → plugin-0qkdqm5v.js} +0 -0
- /package/dist/chunks/{file-retention-0zkw76rk.js → plugin-0zkw76rk.js} +0 -0
- /package/dist/chunks/{file-retention-17cy0kzp.js → plugin-17cy0kzp.js} +0 -0
- /package/dist/chunks/{file-retention-1cnp2v09.js → plugin-1cnp2v09.js} +0 -0
- /package/dist/chunks/{file-retention-1kg9ymc8.js → plugin-1kg9ymc8.js} +0 -0
- /package/dist/chunks/{file-retention-24dcb14g.js → plugin-24dcb14g.js} +0 -0
- /package/dist/chunks/{file-retention-2710q6r3.js → plugin-2710q6r3.js} +0 -0
- /package/dist/chunks/{file-retention-2axfhc9x.js → plugin-2axfhc9x.js} +0 -0
- /package/dist/chunks/{file-retention-2c3vjs8z.js → plugin-2c3vjs8z.js} +0 -0
- /package/dist/chunks/{file-retention-34c7v6d4.js → plugin-34c7v6d4.js} +0 -0
- /package/dist/chunks/{file-retention-359p4xyc.js → plugin-359p4xyc.js} +0 -0
- /package/dist/chunks/{file-retention-3asan66x.js → plugin-3asan66x.js} +0 -0
- /package/dist/chunks/{file-retention-3t0ybcrp.js → plugin-3t0ybcrp.js} +0 -0
- /package/dist/chunks/{file-retention-3v8g72cx.js → plugin-3v8g72cx.js} +0 -0
- /package/dist/chunks/{file-retention-3w5fmr99.js → plugin-3w5fmr99.js} +0 -0
- /package/dist/chunks/{file-retention-3wcehsnq.js → plugin-3wcehsnq.js} +0 -0
- /package/dist/chunks/{file-retention-43n2bw4t.js → plugin-43n2bw4t.js} +0 -0
- /package/dist/chunks/{file-retention-4knz6hnm.js → plugin-4knz6hnm.js} +0 -0
- /package/dist/chunks/{file-retention-4vcrnpx2.js → plugin-4vcrnpx2.js} +0 -0
- /package/dist/chunks/{file-retention-4y7fprxs.js → plugin-4y7fprxs.js} +0 -0
- /package/dist/chunks/{file-retention-53557ph1.js → plugin-53557ph1.js} +0 -0
- /package/dist/chunks/{file-retention-550bvhaj.js → plugin-550bvhaj.js} +0 -0
- /package/dist/chunks/{file-retention-6prwharc.js → plugin-6prwharc.js} +0 -0
- /package/dist/chunks/{file-retention-7akdwqpd.js → plugin-7akdwqpd.js} +0 -0
- /package/dist/chunks/{file-retention-7m9af43g.js → plugin-7m9af43g.js} +0 -0
- /package/dist/chunks/{file-retention-822emrt2.js → plugin-822emrt2.js} +0 -0
- /package/dist/chunks/{file-retention-88xbtdfr.js → plugin-88xbtdfr.js} +0 -0
- /package/dist/chunks/{file-retention-8n3pysct.js → plugin-8n3pysct.js} +0 -0
- /package/dist/chunks/{file-retention-8wj87zfr.js → plugin-8wj87zfr.js} +0 -0
- /package/dist/chunks/{file-retention-9a4afbnw.js → plugin-9a4afbnw.js} +0 -0
- /package/dist/chunks/{file-retention-9rqn6x4v.js → plugin-9rqn6x4v.js} +0 -0
- /package/dist/chunks/{file-retention-a6k6eb26.js → plugin-a6k6eb26.js} +0 -0
- /package/dist/chunks/{file-retention-af5trqkr.js → plugin-af5trqkr.js} +0 -0
- /package/dist/chunks/{file-retention-afrmfg78.js → plugin-afrmfg78.js} +0 -0
- /package/dist/chunks/{file-retention-aqzs7mqg.js → plugin-aqzs7mqg.js} +0 -0
- /package/dist/chunks/{file-retention-atq7p7m5.js → plugin-atq7p7m5.js} +0 -0
- /package/dist/chunks/{file-retention-bkyjaxrp.js → plugin-bkyjaxrp.js} +0 -0
- /package/dist/chunks/{file-retention-bmr6ed5q.js → plugin-bmr6ed5q.js} +0 -0
- /package/dist/chunks/{file-retention-cf4snx6d.js → plugin-cf4snx6d.js} +0 -0
- /package/dist/chunks/{file-retention-cvy3z8tj.js → plugin-cvy3z8tj.js} +0 -0
- /package/dist/chunks/{file-retention-d9fn303g.js → plugin-d9fn303g.js} +0 -0
- /package/dist/chunks/{file-retention-d9jj8t3e.js → plugin-d9jj8t3e.js} +0 -0
- /package/dist/chunks/{file-retention-dajrwvna.js → plugin-dajrwvna.js} +0 -0
- /package/dist/chunks/{file-retention-dap0rakb.js → plugin-dap0rakb.js} +0 -0
- /package/dist/chunks/{file-retention-df08tz66.js → plugin-df08tz66.js} +0 -0
- /package/dist/chunks/{file-retention-dy18nga0.js → plugin-dy18nga0.js} +0 -0
- /package/dist/chunks/{file-retention-e3qxr5gk.js → plugin-e3qxr5gk.js} +0 -0
- /package/dist/chunks/{file-retention-e5kj55wp.js → plugin-e5kj55wp.js} +0 -0
- /package/dist/chunks/{file-retention-e73j6tqm.js → plugin-e73j6tqm.js} +0 -0
- /package/dist/chunks/{file-retention-ec1grn59.js → plugin-ec1grn59.js} +0 -0
- /package/dist/chunks/{file-retention-eh3zwz77.js → plugin-eh3zwz77.js} +0 -0
- /package/dist/chunks/{file-retention-emrn6kk6.js → plugin-emrn6kk6.js} +0 -0
- /package/dist/chunks/{file-retention-f0mxakyp.js → plugin-f0mxakyp.js} +0 -0
- /package/dist/chunks/{file-retention-f6n9ztr4.js → plugin-f6n9ztr4.js} +0 -0
- /package/dist/chunks/{file-retention-faypxj3z.js → plugin-faypxj3z.js} +0 -0
- /package/dist/chunks/{file-retention-fd410y7t.js → plugin-fd410y7t.js} +0 -0
- /package/dist/chunks/{file-retention-fxgpk5d8.js → plugin-fxgpk5d8.js} +0 -0
- /package/dist/chunks/{file-retention-g4wezp1m.js → plugin-g4wezp1m.js} +0 -0
- /package/dist/chunks/{file-retention-g86h250q.js → plugin-g86h250q.js} +0 -0
- /package/dist/chunks/{file-retention-gebd4c9n.js → plugin-gebd4c9n.js} +0 -0
- /package/dist/chunks/{file-retention-gftt206x.js → plugin-gftt206x.js} +0 -0
- /package/dist/chunks/{file-retention-hjbc5kem.js → plugin-hjbc5kem.js} +0 -0
- /package/dist/chunks/{file-retention-hk9envan.js → plugin-hk9envan.js} +0 -0
- /package/dist/chunks/{file-retention-j2ntwpah.js → plugin-j2ntwpah.js} +0 -0
- /package/dist/chunks/{file-retention-j5zkgpj8.js → plugin-j5zkgpj8.js} +0 -0
- /package/dist/chunks/{file-retention-jjkms2e6.js → plugin-jjkms2e6.js} +0 -0
- /package/dist/chunks/{file-retention-jr7sbwjy.js → plugin-jr7sbwjy.js} +0 -0
- /package/dist/chunks/{file-retention-jwfs4k6c.js → plugin-jwfs4k6c.js} +0 -0
- /package/dist/chunks/{file-retention-jzg6c2d5.js → plugin-jzg6c2d5.js} +0 -0
- /package/dist/chunks/{file-retention-mp448xyj.js → plugin-mp448xyj.js} +0 -0
- /package/dist/chunks/{file-retention-msx8hqn2.js → plugin-msx8hqn2.js} +0 -0
- /package/dist/chunks/{file-retention-n05xt0ee.js → plugin-n05xt0ee.js} +0 -0
- /package/dist/chunks/{file-retention-n3j8tn72.js → plugin-n3j8tn72.js} +0 -0
- /package/dist/chunks/{file-retention-njntx4h6.js → plugin-njntx4h6.js} +0 -0
- /package/dist/chunks/{file-retention-q3sfg36h.js → plugin-q3sfg36h.js} +0 -0
- /package/dist/chunks/{file-retention-q74kybfr.js → plugin-q74kybfr.js} +0 -0
- /package/dist/chunks/{file-retention-qaymkmh1.js → plugin-qaymkmh1.js} +0 -0
- /package/dist/chunks/{file-retention-qb87gjwd.js → plugin-qb87gjwd.js} +0 -0
- /package/dist/chunks/{file-retention-qfa1cgps.js → plugin-qfa1cgps.js} +0 -0
- /package/dist/chunks/{file-retention-qg3g05ea.js → plugin-qg3g05ea.js} +0 -0
- /package/dist/chunks/{file-retention-qrg20bc0.js → plugin-qrg20bc0.js} +0 -0
- /package/dist/chunks/{file-retention-rcb2kzg1.js → plugin-rcb2kzg1.js} +0 -0
- /package/dist/chunks/{file-retention-sdp7kfr6.js → plugin-sdp7kfr6.js} +0 -0
- /package/dist/chunks/{file-retention-ssg3fenm.js → plugin-ssg3fenm.js} +0 -0
- /package/dist/chunks/{file-retention-w803qqfp.js → plugin-w803qqfp.js} +0 -0
- /package/dist/chunks/{file-retention-wc3fc9cn.js → plugin-wc3fc9cn.js} +0 -0
- /package/dist/chunks/{file-retention-wer8tq1h.js → plugin-wer8tq1h.js} +0 -0
- /package/dist/chunks/{file-retention-wtztk69x.js → plugin-wtztk69x.js} +0 -0
- /package/dist/chunks/{file-retention-x0ckcb58.js → plugin-x0ckcb58.js} +0 -0
- /package/dist/chunks/{file-retention-x61499pn.js → plugin-x61499pn.js} +0 -0
- /package/dist/chunks/{file-retention-y44na4kk.js → plugin-y44na4kk.js} +0 -0
- /package/dist/chunks/{file-retention-y8cydn3q.js → plugin-y8cydn3q.js} +0 -0
- /package/dist/chunks/{file-retention-y8f7s663.js → plugin-y8f7s663.js} +0 -0
- /package/dist/chunks/{file-retention-ygaqb7jw.js → plugin-ygaqb7jw.js} +0 -0
- /package/dist/chunks/{file-retention-ym463w8f.js → plugin-ym463w8f.js} +0 -0
- /package/dist/chunks/{file-retention-z5v4ffb3.js → plugin-z5v4ffb3.js} +0 -0
- /package/dist/chunks/{file-retention-z9919s4g.js → plugin-z9919s4g.js} +0 -0
package/dist/shell/scan.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__export
|
|
3
|
-
} from "../chunks/
|
|
3
|
+
} from "../chunks/plugin-9rqn6x4v.js";
|
|
4
4
|
|
|
5
5
|
// src/shell/scan.ts
|
|
6
6
|
var exports_scan = {};
|
|
@@ -10,716 +10,1271 @@ __export(exports_scan, {
|
|
|
10
10
|
scanPowerShell: () => scanPowerShell
|
|
11
11
|
});
|
|
12
12
|
var BASH_REDIRECTS = ["&>>", "&>", "<<<", "<<-", "<<", "<>", "<&", ">&", ">|", ">>", ">", "<"];
|
|
13
|
-
var
|
|
13
|
+
var BASH_LIST_OPERATORS = ["&&", "||", "|&"];
|
|
14
|
+
var BASH_CASE_OPERATORS = [";;&", ";;", ";&", ";|", ...BASH_LIST_OPERATORS];
|
|
15
|
+
var BASH_BINDING_BUILTINS = new Set([
|
|
16
|
+
"declare",
|
|
17
|
+
"typeset",
|
|
18
|
+
"local",
|
|
19
|
+
"export",
|
|
20
|
+
"readonly",
|
|
21
|
+
"private",
|
|
22
|
+
"unset",
|
|
23
|
+
"read",
|
|
24
|
+
"getln",
|
|
25
|
+
"vared",
|
|
26
|
+
"getopts",
|
|
27
|
+
"mapfile",
|
|
28
|
+
"readarray",
|
|
29
|
+
"compgen",
|
|
30
|
+
"zparseopts",
|
|
31
|
+
"zregexparse",
|
|
32
|
+
"zformat",
|
|
33
|
+
"zstyle",
|
|
34
|
+
"zstat",
|
|
35
|
+
"stat"
|
|
36
|
+
]);
|
|
37
|
+
var BASH_ARITHMETIC_COMPARISONS = new Set(["-eq", "-ne", "-lt", "-le", "-gt", "-ge"]);
|
|
38
|
+
var BASH_EXPANSION_RE = /\$(?:\\.|\\\n)*[({]|`/;
|
|
39
|
+
var BASH_ESCAPE_RE = /\\(?:x[\da-fA-F]{1,2}|[0-7]{1,3}|u[\da-fA-F]{1,4}|U[\da-fA-F]{1,8})/;
|
|
40
|
+
var BASH_ASSIGNMENT_DECLARATIONS = new Set(["declare", "typeset", "export", "readonly", "local"]);
|
|
41
|
+
var BASH_DECLARATIONS = new Set([...BASH_ASSIGNMENT_DECLARATIONS, "unset", "unsetenv"]);
|
|
42
|
+
var BASH_PRECOMMANDS = new Set(["builtin", "command", "time", "coproc", "!"]);
|
|
43
|
+
var ZSH_PRECOMMANDS = new Set(["noglob", "nocorrect", "exec", "-"]);
|
|
44
|
+
var ZSH_ARITHMETIC_BUILTINS = new Set([
|
|
45
|
+
"integer",
|
|
46
|
+
"float",
|
|
47
|
+
"exit",
|
|
48
|
+
"return",
|
|
49
|
+
"shift",
|
|
50
|
+
"break",
|
|
51
|
+
"continue",
|
|
52
|
+
"bye",
|
|
53
|
+
"logout"
|
|
54
|
+
]);
|
|
55
|
+
var BASH_NON_FUNCTION_KEYWORDS = new Set([
|
|
56
|
+
"if",
|
|
57
|
+
"for",
|
|
58
|
+
"select",
|
|
59
|
+
"case",
|
|
60
|
+
"then",
|
|
61
|
+
"elif",
|
|
62
|
+
"else",
|
|
63
|
+
"fi",
|
|
64
|
+
"do",
|
|
65
|
+
"done",
|
|
66
|
+
"in",
|
|
67
|
+
"esac"
|
|
68
|
+
]);
|
|
69
|
+
var BASH_UNIT_STARTS = "\\$'\"`<>";
|
|
14
70
|
var MAX_INPUT_LENGTH = 64 * 1024;
|
|
15
71
|
var MAX_SUBSTITUTION_DEPTH = 32;
|
|
16
|
-
|
|
17
|
-
|
|
72
|
+
var TOKEN_RE = /[A-Za-z_][A-Za-z0-9_]*(?=(?:\\\n)*(?:[ \t\n;|&()<>]|$))/y;
|
|
73
|
+
var BRACE_CLOSE_AHEAD_RE = /(?:\\\n)*(?:[ \t\n;&|()<>]|$)/y;
|
|
74
|
+
var SPACE_CONTINUATION_AHEAD_RE = /(?:\\\n)*[ \t\n]/y;
|
|
75
|
+
var NEGATION_AHEAD_RE = /(?:\\\n)*[ \t\n(]/y;
|
|
76
|
+
var COPROC_AHEAD_RE = /coproc(?:[ \t]|\\\n)+(?:--(?:[ \t]|\\\n)+)?(?:[A-Za-z_][A-Za-z0-9_]*(?:[ \t]|\\\n)+)?(?=(?:!(?:[ \t]|\\\n)*)*(?:[{(]|\[\[(?:\\\n)*[ \t\n]|(?:if|while|until|for|select|case|repeat)\b))/y;
|
|
77
|
+
var TIME_AHEAD_RE = /time(?:[ \t]|\\\n)+(?:-p(?:[ \t]|\\\n)+)?(?:--(?:[ \t]|\\\n)+)?(?=(?:!(?:[ \t]|\\\n)*)*(?:[{(]|\[\[(?:\\\n)*[ \t\n]|(?:if|while|until|for|select|case|repeat)\b))/y;
|
|
78
|
+
var FUNCTION_HEAD_RE = /(function[ \t](?:[ \t]|\\\n)*)?([A-Za-z_][\w.:+@%-]*)?(?:[ \t]|\\\n)*(\([ \t]*\))?((?:[ \t\n]|\\\n|#[^\n]*\n)*)/y;
|
|
79
|
+
var FUNCTION_BODY_RE = /[{(]|\[\[(?=(?:\\\n)*[ \t\n])|(?:if|while|until|for|select|case|repeat)(?=(?:\\\n)*(?:[ \t\n(]|$))/y;
|
|
80
|
+
var DO_AHEAD_RE = /(?:[ \t\n;]|\\\n|#[^\n]*(?:\n|$))*(?:do(?=(?:\\\n)*(?:[ \t\n;{(]|$))|\{(?=(?:\\\n)*[ \t\n]))/y;
|
|
81
|
+
var NOFORK_OPEN_RE = /\$\{(?:\\\n)*(?:[ \t\n]|\|)/y;
|
|
82
|
+
var ZSH_SAFE_FLAGS_RE = /\$\{\((?:[@AaBbCcDEfFikLMmNnOopqStUuVvWwXZz0-]|q[-+]?|[js]([^({[<\\])(?:(?!\1)[^)])*\1)*\)/y;
|
|
83
|
+
var ZSH_GLOB_MODIFIER_RE = /(?:[\^=~#+]|\\\n)*~/y;
|
|
84
|
+
var ZSH_SUBSCRIPT_RE = /\$(?:[\^=+~#]|\\\n)*(?:[A-Za-z_](?:[A-Za-z0-9_]|\\\n)*|[@*#?$!0-9-])(?:\\\n)*\[/y;
|
|
85
|
+
var LINE_CONTINUATION_RE = /(?:\\\n)*/y;
|
|
86
|
+
var PARAMETER_PREFIX_RE = /(?:\\\n)*(?:\([^)]*\))?(?:[!#^=+~]|\\\n)*/y;
|
|
87
|
+
var PARAMETER_NAME_RE = /(?:[A-Za-z_](?:[A-Za-z0-9_]|\\\n)*|\d(?:\d|\\\n)*|[@*#?$!-])(?:\\\n)*/y;
|
|
88
|
+
var PARAMETER_PROMPT_RE = /@(?:\\\n)*[EP](?:\\\n)*\}/y;
|
|
89
|
+
var BASH_ANSI_ESCAPES = {
|
|
90
|
+
a: "\x07",
|
|
91
|
+
b: "\b",
|
|
92
|
+
e: "\x1B",
|
|
93
|
+
E: "\x1B",
|
|
94
|
+
f: "\f",
|
|
95
|
+
n: `
|
|
96
|
+
`,
|
|
97
|
+
r: "\r",
|
|
98
|
+
t: "\t",
|
|
99
|
+
v: "\v",
|
|
100
|
+
"\\": "\\",
|
|
101
|
+
"'": "'",
|
|
102
|
+
'"': '"',
|
|
103
|
+
"?": "?"
|
|
104
|
+
};
|
|
105
|
+
function scan(input, dialect = "posix") {
|
|
106
|
+
if (input.length > MAX_INPUT_LENGTH)
|
|
107
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
108
|
+
const context = { remaining: MAX_INPUT_LENGTH * MAX_SUBSTITUTION_DEPTH, dialect };
|
|
109
|
+
const result = scanBash(input, 0, 0, context);
|
|
110
|
+
if (result.kind === "opaque")
|
|
111
|
+
return result;
|
|
112
|
+
if (context.boundDollar && context.boundOpen && context.variableSink)
|
|
113
|
+
return { kind: "opaque", reason: "dynamic-execution" };
|
|
114
|
+
return { kind: "scanned", commands: result.commands };
|
|
18
115
|
}
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
if (
|
|
116
|
+
function bashStatement(state) {
|
|
117
|
+
const structure = state.structures.at(-1);
|
|
118
|
+
if (structure)
|
|
119
|
+
structure.count++;
|
|
120
|
+
}
|
|
121
|
+
function bashInHeader(state) {
|
|
122
|
+
const phase = state.structures.at(-1)?.phase;
|
|
123
|
+
return phase === "header" || phase === "pattern" || phase === "do";
|
|
124
|
+
}
|
|
125
|
+
function atCommandStart(state) {
|
|
126
|
+
return !state.words.length && !state.hasRedirect && !state.compoundEnd && !bashInHeader(state);
|
|
127
|
+
}
|
|
128
|
+
function pending(state) {
|
|
129
|
+
return state.wordStarted || state.words.length > 0 || state.hasRedirect || state.compoundEnd;
|
|
130
|
+
}
|
|
131
|
+
function endBashList(state) {
|
|
132
|
+
if (pending(state))
|
|
133
|
+
finishBashCommand(state);
|
|
134
|
+
return !state.dangling;
|
|
135
|
+
}
|
|
136
|
+
function closeBashList(state, end) {
|
|
137
|
+
if (!endBashList(state))
|
|
22
138
|
return { kind: "opaque", reason: "invalid-structure" };
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
139
|
+
if (state.invalid)
|
|
140
|
+
return { kind: "opaque", reason: state.invalid };
|
|
141
|
+
if (state.structures.length)
|
|
142
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
143
|
+
return { kind: "scanned", commands: state.commands, end };
|
|
144
|
+
}
|
|
145
|
+
function finishBashWord(state) {
|
|
146
|
+
if (!state.wordStarted)
|
|
147
|
+
return;
|
|
148
|
+
if (/PS4/.test(state.word))
|
|
149
|
+
state.context.variableSink = true;
|
|
150
|
+
const evaluation = bashWordEvaluation(state);
|
|
151
|
+
if (state.context.dialect !== "bash" && (/(?:READ)?NULLCMD/.test(state.word) || (state.assignmentWord || evaluation === "binding") && /^(?:-[A-Za-z]*v)?(?:(?:dis_)?(?:functions|[gs]?aliases)|options|commands)(?:\+?=|\[|$)/.test(state.word)))
|
|
152
|
+
state.invalid ??= "dynamic-execution";
|
|
153
|
+
if (evaluation && bashEvaluatesExpansion(state, evaluation, state.context))
|
|
154
|
+
state.invalid ??= "dynamic-execution";
|
|
155
|
+
if (state.outer)
|
|
156
|
+
state.outer.output += ` ${state.literal} ${state.output}`;
|
|
157
|
+
const structure = state.structures.at(-1);
|
|
158
|
+
const repeatHeader = structure?.kind === "repeat" && structure.phase === "header";
|
|
159
|
+
if (!state.redirectTarget && repeatHeader)
|
|
160
|
+
structure.phase = "do";
|
|
161
|
+
if (!state.redirectTarget && !repeatHeader) {
|
|
162
|
+
if (!state.assignmentWord && state.commandWordIndex < 0)
|
|
163
|
+
state.commandWordIndex = state.words.length;
|
|
164
|
+
state.commandStart ??= state.wordStart;
|
|
165
|
+
state.words.push(state.word);
|
|
166
|
+
state.rawWords.push(state.input.slice(state.wordStart, state.wordEnd));
|
|
167
|
+
state.commandEnd = state.wordEnd;
|
|
168
|
+
}
|
|
169
|
+
state.redirectTarget = false;
|
|
170
|
+
state.hereString = false;
|
|
171
|
+
state.word = "";
|
|
172
|
+
state.literal = "";
|
|
173
|
+
state.output = "";
|
|
174
|
+
state.wordStarted = false;
|
|
175
|
+
state.assignmentWord = false;
|
|
176
|
+
state.assignmentHeadUnsafe = false;
|
|
177
|
+
}
|
|
178
|
+
function bashWordEvaluation(state) {
|
|
179
|
+
if (state.redirectTarget)
|
|
180
|
+
return state.hereString ? "deferred" : undefined;
|
|
181
|
+
const structure = state.structures.at(-1);
|
|
182
|
+
if (structure?.kind === "repeat" && structure.phase === "header")
|
|
183
|
+
return "arithmetic";
|
|
184
|
+
if (structure?.kind === "for" && structure.phase === "header" && structure.sawIn)
|
|
185
|
+
return "deferred";
|
|
186
|
+
if (state.commandWordIndex < 0)
|
|
187
|
+
return state.assignmentWord ? "deferred" : undefined;
|
|
188
|
+
const name = bashBuiltinIndex(state);
|
|
189
|
+
const command = state.words[name];
|
|
190
|
+
if (command === undefined)
|
|
191
|
+
return;
|
|
192
|
+
if (command === "let" || state.context.dialect !== "bash" && ZSH_ARITHMETIC_BUILTINS.has(command))
|
|
193
|
+
return "arithmetic";
|
|
194
|
+
if (command === "set")
|
|
195
|
+
return state.words.slice(name + 1).some((word) => /^[-+][A-Za-z0-9]*A/.test(word)) ? "binding" : "deferred";
|
|
196
|
+
if (BASH_BINDING_BUILTINS.has(command)) {
|
|
197
|
+
const options = state.words.slice(name + 1);
|
|
198
|
+
if (options.some((word) => word.startsWith("-") && /[EFin]/.test(word)))
|
|
199
|
+
return "arithmetic";
|
|
200
|
+
if (state.assignmentWord && BASH_ASSIGNMENT_DECLARATIONS.has(command) && options.every((word) => !word.startsWith("-")) && (command === "export" || command === "readonly" || state.context.dialect === "zsh" || !/\+?=(?:\(|[$`])/.test(state.word)))
|
|
201
|
+
return "deferred";
|
|
202
|
+
return "binding";
|
|
203
|
+
}
|
|
204
|
+
if (command === "printf" || command === "print") {
|
|
205
|
+
const options = [...state.words.slice(name + 1), state.word];
|
|
206
|
+
const flag = command === "print" ? /^-[A-Za-z]*v/ : /^-v/;
|
|
207
|
+
return options.some((word) => flag.test(word)) ? "binding" : undefined;
|
|
208
|
+
}
|
|
209
|
+
if (command === "wait")
|
|
210
|
+
return /^-[nf]*p/.test(state.word) || /^-[nf]*p$/.test(state.words.at(-1) ?? "") ? "binding" : undefined;
|
|
211
|
+
if (command === "test" || command === "[") {
|
|
212
|
+
if (state.words.at(-1) === "-v")
|
|
213
|
+
return "binding";
|
|
214
|
+
if (state.context.dialect !== "bash" && state.words.at(-1) === "-t")
|
|
215
|
+
return "arithmetic";
|
|
216
|
+
}
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
function bashBuiltinIndex(state) {
|
|
220
|
+
let name = state.commandWordIndex;
|
|
221
|
+
while (BASH_PRECOMMANDS.has(state.words[name] ?? "") || state.context.dialect !== "bash" && ZSH_PRECOMMANDS.has(state.words[name] ?? "")) {
|
|
222
|
+
const precommand = state.words[name++];
|
|
223
|
+
while (precommand !== "-" && state.words[name]?.startsWith("-")) {
|
|
224
|
+
if (precommand === "exec" && /^-[cl]*a$/.test(state.words[name]))
|
|
225
|
+
name++;
|
|
226
|
+
name++;
|
|
71
227
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
228
|
+
}
|
|
229
|
+
return name;
|
|
230
|
+
}
|
|
231
|
+
function finishBashCommand(state, boundary = false) {
|
|
232
|
+
finishBashWord(state);
|
|
233
|
+
if (state.redirectTarget)
|
|
234
|
+
state.invalid ??= "invalid-redirect";
|
|
235
|
+
state.redirectTarget = false;
|
|
236
|
+
if (state.compoundEnd && state.words.length > 0)
|
|
237
|
+
state.invalid ??= "invalid-structure";
|
|
238
|
+
const name = state.commandWordIndex;
|
|
239
|
+
const inHeader = bashInHeader(state);
|
|
240
|
+
if (name >= 0 && !state.words[name])
|
|
241
|
+
state.invalid ??= "invalid-structure";
|
|
242
|
+
if (name >= 0 && !inHeader) {
|
|
243
|
+
const resource = state.input.slice(state.commandStart, state.resourceEnd ?? state.wordEnd).replace(/^[ \t\n]+|[ \t\n]+$/g, "");
|
|
244
|
+
const command = {
|
|
245
|
+
resource,
|
|
246
|
+
words: state.words.slice(name),
|
|
247
|
+
rawWords: state.rawWords.slice(name),
|
|
248
|
+
...name === 0 && BASH_DECLARATIONS.has(state.rawWords[0]) && resource.startsWith(state.rawWords[0]) ? { declaration: true } : {},
|
|
249
|
+
...state.redirectWordCount !== undefined && state.redirectWordCount < state.words.length ? { redirectWordCount: state.redirectWordCount - name } : {}
|
|
250
|
+
};
|
|
251
|
+
state.commands.push(command);
|
|
252
|
+
const builtin = bashBuiltinIndex(state);
|
|
253
|
+
const builtinName = state.words[builtin];
|
|
254
|
+
const builtinArgs = state.words.slice(builtin + 1);
|
|
255
|
+
if (builtinName === "eval")
|
|
256
|
+
state.context.variableSink = true;
|
|
257
|
+
if (builtinName === "set" && builtinArgs.some((word) => /^-[A-Za-z0-9]*k/.test(word) || word === "keyword"))
|
|
258
|
+
state.invalid ??= "dynamic-execution";
|
|
259
|
+
if (builtinName === "alias" && builtinArgs.some((word) => word.includes("=")))
|
|
260
|
+
state.invalid ??= "dynamic-execution";
|
|
261
|
+
if (state.context.dialect !== "bash" && (builtinName === "emulate" || (builtinName === "setopt" || builtinName === "unsetopt" || builtinName === "set" && builtinArgs.some((word) => /^[-+][A-Za-z0-9]*o/.test(word))) && builtinArgs.some((word) => /^-[A-Za-z0-9]*m/.test(word) || /^(?:no)?(?:globsubst|kshglob|promptsubst|promptvars|aliases)$/.test(word.replace(/^[-+][A-Za-z0-9]*?o/i, "").toLowerCase().replace(/[_-]/g, "")))))
|
|
262
|
+
state.invalid ??= "dynamic-execution";
|
|
263
|
+
if (state.context.dialect !== "zsh" && builtinName === "compgen" && builtinArgs.some((word) => word.startsWith("-") && /[CF]/.test(word)))
|
|
264
|
+
state.invalid ??= "dynamic-execution";
|
|
265
|
+
if (BASH_BINDING_BUILTINS.has(builtinName ?? "")) {
|
|
266
|
+
for (const heredoc of state.heredocs)
|
|
267
|
+
heredoc.binding ??= true;
|
|
268
|
+
}
|
|
269
|
+
if (state.resourceEnd === undefined) {
|
|
270
|
+
for (const heredoc of state.heredocs) {
|
|
271
|
+
if (heredoc.command)
|
|
272
|
+
continue;
|
|
273
|
+
heredoc.command = command;
|
|
274
|
+
heredoc.start = state.commandStart;
|
|
107
275
|
}
|
|
108
|
-
} else if (!header() && !compoundEnd && (hasRedirect || boundary || separated)) {
|
|
109
|
-
const assignmentOnly = assignmentWords.length > 0 && assignmentWords.every(Boolean);
|
|
110
|
-
if (!assignmentOnly && !hasRedirect)
|
|
111
|
-
invalidStructure = true;
|
|
112
276
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
277
|
+
}
|
|
278
|
+
if (boundary && !state.words.length && !state.hasRedirect && !state.compoundEnd && !inHeader)
|
|
279
|
+
state.invalid ??= "invalid-structure";
|
|
280
|
+
if (state.words.length > (state.ampersandRedirectWords ?? Infinity))
|
|
281
|
+
state.invalid ??= "invalid-redirect";
|
|
282
|
+
state.commands.push(...state.nestedCommands.splice(0));
|
|
283
|
+
if (!inHeader && (state.words.length > 0 || state.hasRedirect))
|
|
284
|
+
bashStatement(state);
|
|
285
|
+
state.words.length = 0;
|
|
286
|
+
state.rawWords.length = 0;
|
|
287
|
+
state.commandWordIndex = -1;
|
|
288
|
+
state.commandStart = undefined;
|
|
289
|
+
state.hasRedirect = false;
|
|
290
|
+
state.resourceEnd = undefined;
|
|
291
|
+
state.redirectWordCount = undefined;
|
|
292
|
+
state.ampersandRedirectWords = undefined;
|
|
293
|
+
state.compoundEnd = false;
|
|
294
|
+
state.dangling = false;
|
|
295
|
+
}
|
|
296
|
+
function scanBash(input, start, depth, context, close, heredocs, outer) {
|
|
297
|
+
if (depth > MAX_SUBSTITUTION_DEPTH || context.remaining < 0)
|
|
298
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
299
|
+
const state = {
|
|
300
|
+
input,
|
|
301
|
+
context,
|
|
302
|
+
commands: [],
|
|
303
|
+
nestedCommands: [],
|
|
304
|
+
words: [],
|
|
305
|
+
rawWords: [],
|
|
306
|
+
heredocs: heredocs ?? [],
|
|
307
|
+
structures: [],
|
|
308
|
+
word: "",
|
|
309
|
+
literal: "",
|
|
310
|
+
output: "",
|
|
311
|
+
wordStarted: false,
|
|
312
|
+
wordStart: start,
|
|
313
|
+
wordEnd: start,
|
|
314
|
+
commandStart: undefined,
|
|
315
|
+
commandEnd: start,
|
|
316
|
+
resourceEnd: undefined,
|
|
317
|
+
redirectWordCount: undefined,
|
|
318
|
+
ampersandRedirectWords: undefined,
|
|
319
|
+
commandWordIndex: -1,
|
|
320
|
+
assignmentWord: false,
|
|
321
|
+
assignmentHeadUnsafe: false,
|
|
322
|
+
invalid: undefined,
|
|
323
|
+
redirectTarget: false,
|
|
324
|
+
hereString: false,
|
|
325
|
+
hasRedirect: false,
|
|
326
|
+
compoundEnd: false,
|
|
327
|
+
dangling: false,
|
|
328
|
+
outer
|
|
124
329
|
};
|
|
125
|
-
for (let index =
|
|
330
|
+
for (let index = start;index < input.length; index++) {
|
|
331
|
+
if (--context.remaining < 0)
|
|
332
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
126
333
|
const char = input[index];
|
|
127
|
-
if (
|
|
128
|
-
|
|
129
|
-
|
|
334
|
+
if (char === "\\" && input[index + 1] === `
|
|
335
|
+
`) {
|
|
336
|
+
index++;
|
|
337
|
+
continue;
|
|
338
|
+
}
|
|
339
|
+
if (!state.wordStarted) {
|
|
340
|
+
state.wordStart = index;
|
|
130
341
|
if (char === " " || char === "\t")
|
|
131
342
|
continue;
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
if (
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
if (structure?.phase === "pattern" && (char === "(" || char === "|"))
|
|
142
|
-
continue;
|
|
143
|
-
if (structure?.phase === "pattern" && char === ")") {
|
|
144
|
-
finishCommand();
|
|
145
|
-
structure.phase = "body";
|
|
146
|
-
structure.count = 0;
|
|
147
|
-
segment = index + 1;
|
|
148
|
-
continue;
|
|
149
|
-
}
|
|
150
|
-
if (structure?.kind === "for" && structure.phase === "header" && char === "(" && input[index + 1] !== "(") {
|
|
151
|
-
const values = bashExpansion(input, index, depth, "array");
|
|
152
|
-
if (!values)
|
|
153
|
-
return { kind: "opaque", reason: "compound-command" };
|
|
154
|
-
finishCommand();
|
|
155
|
-
const failure = addSubstitutions(values);
|
|
156
|
-
if (failure)
|
|
157
|
-
return failure;
|
|
158
|
-
commands.push(...nestedCommands.splice(0));
|
|
159
|
-
structure.phase = "do";
|
|
160
|
-
if (!/^(?:[ \t\n;]|\\\n|#[^\n]*(?:\n|$))*do(?=[ \t\n;]|$)/.test(input.slice(values.end + 1)))
|
|
161
|
-
structures.pop();
|
|
162
|
-
index = values.end;
|
|
163
|
-
segment = index + 1;
|
|
343
|
+
if (char === "}" && state.words.length === 0 && !state.redirectTarget && (close === "}" || close === "nofork") && state.structures.length === 0 && (heredocs !== undefined || state.heredocs.length === 0) && (close === "nofork" || (BRACE_CLOSE_AHEAD_RE.lastIndex = index + 1, BRACE_CLOSE_AHEAD_RE.test(input))))
|
|
344
|
+
return closeBashList(state, index);
|
|
345
|
+
if (char === "}")
|
|
346
|
+
return { kind: "opaque", reason: state.structures.length ? "compound-command" : "invalid-structure" };
|
|
347
|
+
const step = scanBashCommandStart(state, index, depth, context);
|
|
348
|
+
if (typeof step === "object")
|
|
349
|
+
return step;
|
|
350
|
+
if (step !== undefined) {
|
|
351
|
+
index = step;
|
|
164
352
|
continue;
|
|
165
353
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
} else {
|
|
203
|
-
if (token === "fi" && (structure.kind !== "if" || structure.phase !== "body" || !structure.count) || token === "done" && (!["for", "while", "until"].includes(structure.kind) || structure.phase !== "body" || !structure.count) || token === "esac" && (structure.kind !== "case" || structure.phase === "header"))
|
|
204
|
-
return { kind: "opaque", reason: "compound-command" };
|
|
205
|
-
structures.pop();
|
|
206
|
-
statement();
|
|
207
|
-
compoundEnd = true;
|
|
208
|
-
dangling = false;
|
|
209
|
-
}
|
|
210
|
-
structure.count = 0;
|
|
211
|
-
index += token.length - 1;
|
|
212
|
-
segment = index + 1;
|
|
213
|
-
inList = false;
|
|
214
|
-
continue;
|
|
215
|
-
}
|
|
216
|
-
if (!header() && (char === "!" && /[ \t\n]/.test(input[index + 1] ?? "") || token === "coproc" && /^coproc[ \t]+(?:[A-Za-z_][A-Za-z0-9_]*[ \t]+)?(?:[{(]|(?:if|while|until|for|case)\b)/.test(input.slice(index)) || token === "time" && /^time[ \t]+(?:-p[ \t]+)?(?:[{(]|(?:if|while|until|for|case)\b)/.test(input.slice(index)))) {
|
|
217
|
-
index += token ? token.length - 1 : 0;
|
|
218
|
-
if (token === "time")
|
|
219
|
-
index += /^[ \t]+-p\b/.exec(input.slice(index + 1))?.[0].length ?? 0;
|
|
220
|
-
if (token === "coproc")
|
|
221
|
-
index += /^[ \t]+[A-Za-z_][A-Za-z0-9_]*[ \t]+(?=[{(]|(?:if|while|until|for|case)\b)/.exec(input.slice(index + 1))?.[0].length ?? 0;
|
|
222
|
-
segment = index + 1;
|
|
223
|
-
continue;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
if ((!words.length && !hasRedirect && !header() || structure?.kind === "for" && structure.phase === "header") && input.startsWith("((", index)) {
|
|
227
|
-
const expression = bashExpansion(input, index, depth, "arithmetic");
|
|
228
|
-
if (!expression)
|
|
229
|
-
return { kind: "opaque", reason: "invalid-structure" };
|
|
230
|
-
const failure = addSubstitutions(expression);
|
|
231
|
-
if (failure)
|
|
232
|
-
return failure;
|
|
233
|
-
commands.push(...nestedCommands.splice(0));
|
|
234
|
-
statement();
|
|
235
|
-
compoundEnd = !header();
|
|
236
|
-
dangling = false;
|
|
237
|
-
index = expression.end;
|
|
238
|
-
segment = index + 1;
|
|
239
|
-
continue;
|
|
240
|
-
}
|
|
241
|
-
if (!words.length && !hasRedirect && !header() && (char === "(" || char === "{" && /[ \t\n]/.test(input[index + 1] ?? ""))) {
|
|
242
|
-
const group = bashDelimited(input, index, depth);
|
|
243
|
-
if (!group || !group.source.trim())
|
|
244
|
-
return { kind: "opaque", reason: "invalid-structure" };
|
|
245
|
-
const result = scanBash(group.source, depth + 1, budget);
|
|
246
|
-
if (result.kind === "opaque")
|
|
247
|
-
return result;
|
|
248
|
-
commands.push(...result.commands);
|
|
249
|
-
statement();
|
|
250
|
-
compoundEnd = true;
|
|
251
|
-
dangling = false;
|
|
252
|
-
index = group.end;
|
|
253
|
-
segment = index + 1;
|
|
254
|
-
continue;
|
|
255
|
-
}
|
|
256
|
-
if (!words.length && !hasRedirect && input.startsWith("[[", index)) {
|
|
257
|
-
const expression = bashExpansion(input, index, depth, "test");
|
|
258
|
-
if (!expression)
|
|
354
|
+
}
|
|
355
|
+
if (char === "\\" && index + 1 >= input.length)
|
|
356
|
+
return { kind: "opaque", reason: "unterminated-escape" };
|
|
357
|
+
if (!state.assignmentWord && (`'"\\`.includes(char) || char === "$" && (input[index + 1] === "'" || input[index + 1] === '"')))
|
|
358
|
+
state.assignmentHeadUnsafe = true;
|
|
359
|
+
const inCasePattern = state.structures.at(-1)?.phase === "pattern";
|
|
360
|
+
const array = state.assignmentWord && /[^=]=$/.test(state.word) && (state.commandWordIndex < 0 || BASH_ASSIGNMENT_DECLARATIONS.has(state.rawWords[state.commandWordIndex]));
|
|
361
|
+
if (char === "=" && (!state.wordStarted || array) && input[index + 1] === "(") {
|
|
362
|
+
const end = scanBashNested(input, index + 2, depth, context, state.nestedCommands, ")");
|
|
363
|
+
if (typeof end === "object")
|
|
364
|
+
return end;
|
|
365
|
+
state.wordStarted = true;
|
|
366
|
+
state.word += input.slice(index, end + 1);
|
|
367
|
+
index = end;
|
|
368
|
+
state.wordEnd = index + 1;
|
|
369
|
+
continue;
|
|
370
|
+
}
|
|
371
|
+
const unit = BASH_UNIT_STARTS.includes(char) ? scanBashUnit(input, index, depth, context, state.nestedCommands, "word", !state.assignmentWord && state.commandWordIndex >= 0 && !BASH_DECLARATIONS.has(state.rawWords[0]), state) : undefined;
|
|
372
|
+
if (typeof unit === "object")
|
|
373
|
+
return unit;
|
|
374
|
+
if (unit !== undefined) {
|
|
375
|
+
state.wordStarted = true;
|
|
376
|
+
index = unit;
|
|
377
|
+
state.wordEnd = index + 1;
|
|
378
|
+
continue;
|
|
379
|
+
}
|
|
380
|
+
if (char === "[" && !inCasePattern && !state.assignmentWord && !state.assignmentHeadUnsafe && state.commandWordIndex < 0 && /^[A-Za-z_][A-Za-z0-9_]*$/.test(state.word)) {
|
|
381
|
+
const subscript = [];
|
|
382
|
+
const end = scanBashSubscript(input, index + 1, depth, context, subscript, BASH_SPANS.assignmentSubscript);
|
|
383
|
+
if (typeof end === "object")
|
|
384
|
+
return end;
|
|
385
|
+
const assign = bashOperator(input, end + 1, ["+=", "="]);
|
|
386
|
+
if (typeof assign === "object")
|
|
387
|
+
return assign;
|
|
388
|
+
if (assign) {
|
|
389
|
+
if (context.dialect === "posix" && /[$`]/.test(input.slice(index + 1, end)))
|
|
259
390
|
return { kind: "opaque", reason: "invalid-structure" };
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
compoundEnd = true;
|
|
266
|
-
dangling = false;
|
|
267
|
-
index = expression.end;
|
|
268
|
-
segment = index + 1;
|
|
391
|
+
state.nestedCommands.push(...subscript);
|
|
392
|
+
state.assignmentWord = true;
|
|
393
|
+
state.word += input.slice(index, end + 1);
|
|
394
|
+
index = end;
|
|
395
|
+
state.wordEnd = index + 1;
|
|
269
396
|
continue;
|
|
270
397
|
}
|
|
271
398
|
}
|
|
272
|
-
if (
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
if (
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
wordStarted = true;
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
const next = input[index + 1];
|
|
287
|
-
if ('$`"\\\n'.includes(next)) {
|
|
288
|
-
index++;
|
|
289
|
-
if (next !== `
|
|
290
|
-
`)
|
|
291
|
-
word += next;
|
|
292
|
-
} else
|
|
293
|
-
word += char;
|
|
294
|
-
} else if (char === "$" && "({[".includes(input[index + 1] ?? "\x00") || char === "`") {
|
|
295
|
-
const substitution = bashExpansion(input, index, depth, undefined, true);
|
|
296
|
-
if (!substitution || depth >= MAX_SUBSTITUTION_DEPTH)
|
|
297
|
-
return { kind: "opaque", reason: "command-substitution" };
|
|
298
|
-
const failure = addSubstitutions(substitution);
|
|
299
|
-
if (failure)
|
|
300
|
-
return failure;
|
|
301
|
-
word += input.slice(index, substitution.end + 1);
|
|
302
|
-
index = substitution.end;
|
|
303
|
-
} else
|
|
304
|
-
word += char;
|
|
305
|
-
wordEnd = index + 1;
|
|
306
|
-
continue;
|
|
307
|
-
}
|
|
308
|
-
if (char === "$" && input[index + 1] === "'") {
|
|
309
|
-
const literal = bashAnsiQuote(input, index + 1);
|
|
310
|
-
if (!literal)
|
|
311
|
-
return { kind: "opaque", reason: "unterminated-quote" };
|
|
312
|
-
wordStarted = true;
|
|
313
|
-
if (!assignmentWord)
|
|
314
|
-
assignmentHeadUnsafe = true;
|
|
315
|
-
word += literal.value;
|
|
316
|
-
index = literal.end;
|
|
317
|
-
wordEnd = index + 1;
|
|
318
|
-
continue;
|
|
319
|
-
}
|
|
320
|
-
if (char === "$" && input[index + 1] === '"') {
|
|
321
|
-
quote = "double";
|
|
322
|
-
wordStarted = true;
|
|
323
|
-
if (!assignmentWord)
|
|
324
|
-
assignmentHeadUnsafe = true;
|
|
325
|
-
wordEnd = ++index + 1;
|
|
326
|
-
continue;
|
|
327
|
-
}
|
|
328
|
-
if (char === "'") {
|
|
329
|
-
quote = "single";
|
|
330
|
-
wordStarted = true;
|
|
331
|
-
wordEnd = index + 1;
|
|
332
|
-
if (!assignmentWord)
|
|
333
|
-
assignmentHeadUnsafe = true;
|
|
334
|
-
continue;
|
|
335
|
-
}
|
|
336
|
-
if (char === '"') {
|
|
337
|
-
quote = "double";
|
|
338
|
-
wordStarted = true;
|
|
339
|
-
wordEnd = index + 1;
|
|
340
|
-
if (!assignmentWord)
|
|
341
|
-
assignmentHeadUnsafe = true;
|
|
342
|
-
continue;
|
|
343
|
-
}
|
|
344
|
-
if (char === "\\") {
|
|
345
|
-
if (index + 1 >= input.length)
|
|
346
|
-
return { kind: "opaque", reason: "unterminated-escape" };
|
|
347
|
-
if (input[index + 1] === `
|
|
348
|
-
`)
|
|
349
|
-
index++;
|
|
350
|
-
else {
|
|
351
|
-
wordStarted = true;
|
|
352
|
-
if (!assignmentWord)
|
|
353
|
-
assignmentHeadUnsafe = true;
|
|
354
|
-
word += input[++index];
|
|
355
|
-
wordEnd = index + 1;
|
|
356
|
-
}
|
|
357
|
-
continue;
|
|
358
|
-
}
|
|
359
|
-
if (char === "$" && "({[".includes(input[index + 1] ?? "\x00") || char === "`" || char === "[" && /^[A-Za-z_][A-Za-z0-9_]*$/.test(word) && /^\[[\s\S]*?\]\+?=/.test(input.slice(index)) || char === "(" && (assignmentWord || /[?*+@!]$/.test(word))) {
|
|
360
|
-
const substitution = char === "(" ? bashExpansion(input, index, depth, assignmentWord ? "array" : "pattern") : char === "[" ? bashExpansion(input, index, depth, "subscript") : bashExpansion(input, index, depth);
|
|
361
|
-
if (!substitution || depth >= MAX_SUBSTITUTION_DEPTH)
|
|
362
|
-
return { kind: "opaque", reason: "command-substitution" };
|
|
363
|
-
const failure = addSubstitutions(substitution);
|
|
364
|
-
if (failure)
|
|
365
|
-
return failure;
|
|
366
|
-
wordStarted = true;
|
|
367
|
-
word += input.slice(index, substitution.end + 1);
|
|
368
|
-
index = substitution.end;
|
|
369
|
-
wordEnd = index + 1;
|
|
370
|
-
continue;
|
|
371
|
-
}
|
|
372
|
-
if ((char === "<" || char === ">" || char === "=" && !wordStarted) && input[index + 1] === "(") {
|
|
373
|
-
const substitution = bashDelimited(input, index + 1, depth);
|
|
374
|
-
if (!substitution || depth >= MAX_SUBSTITUTION_DEPTH)
|
|
375
|
-
return { kind: "opaque", reason: "command-substitution" };
|
|
376
|
-
const failure = addSubstitutions(substitution);
|
|
377
|
-
if (failure)
|
|
378
|
-
return failure;
|
|
379
|
-
wordStarted = true;
|
|
380
|
-
word += input.slice(index, substitution.end + 1);
|
|
381
|
-
index = substitution.end;
|
|
382
|
-
wordEnd = index + 1;
|
|
399
|
+
if (char === "(" && (array || (inCasePattern || context.dialect === "bash") && /[?*+@!]$/.test(state.word))) {
|
|
400
|
+
const mode = array ? "array" : "pattern";
|
|
401
|
+
const end = scanBashArrayOrPattern(input, index, depth + 1, context, state.nestedCommands, mode);
|
|
402
|
+
if (typeof end === "object")
|
|
403
|
+
return end;
|
|
404
|
+
if (bashCrossesHeredoc(state, index, end))
|
|
405
|
+
return { kind: "opaque", reason: "heredoc" };
|
|
406
|
+
if (array && end + 1 < input.length && !`
|
|
407
|
+
;&|<>)`.includes(input[end + 1]))
|
|
408
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
409
|
+
state.wordStarted = true;
|
|
410
|
+
state.word += input.slice(index, end + 1);
|
|
411
|
+
index = end;
|
|
412
|
+
state.wordEnd = index + 1;
|
|
383
413
|
continue;
|
|
384
414
|
}
|
|
385
|
-
if (char === "#" && !wordStarted) {
|
|
415
|
+
if (char === "#" && !state.wordStarted) {
|
|
386
416
|
const newline = input.indexOf(`
|
|
387
417
|
`, index);
|
|
388
|
-
if (words.length > 0 || hasRedirect) {
|
|
389
|
-
finishCommand();
|
|
390
|
-
dangling = false;
|
|
391
|
-
inList = false;
|
|
392
|
-
}
|
|
393
418
|
if (newline === -1)
|
|
394
419
|
break;
|
|
395
420
|
index = newline - 1;
|
|
396
|
-
segment = newline;
|
|
397
421
|
continue;
|
|
398
422
|
}
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
if (
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
if (wordEnd < index)
|
|
406
|
-
commandEnd = wordEnd;
|
|
407
|
-
word = "";
|
|
408
|
-
wordStarted = false;
|
|
409
|
-
} else
|
|
410
|
-
finishWord();
|
|
411
|
-
if (redirectWordCount === undefined && assignmentWords.some((assignment) => !assignment)) {
|
|
412
|
-
redirectWordCount = words.length;
|
|
413
|
-
if (inList)
|
|
414
|
-
resourceEnd = commandEnd;
|
|
415
|
-
}
|
|
416
|
-
if (redirect === "<<" || redirect === "<<-") {
|
|
417
|
-
const delimiter = bashHeredocDelimiter(input, index);
|
|
418
|
-
if (!delimiter)
|
|
419
|
-
return { kind: "opaque", reason: "invalid-redirect" };
|
|
420
|
-
heredocs.push(delimiter);
|
|
421
|
-
wordEnd = delimiter.end + 1;
|
|
422
|
-
index = delimiter.end;
|
|
423
|
-
redirectTarget = false;
|
|
424
|
-
continue;
|
|
425
|
-
}
|
|
426
|
-
redirectTarget = true;
|
|
427
|
-
index += redirect.length - 1;
|
|
423
|
+
if (`<>&|;
|
|
424
|
+
`.includes(char)) {
|
|
425
|
+
const step = scanBashOperatorOrSeparator(state, index, depth, context);
|
|
426
|
+
if (typeof step === "object")
|
|
427
|
+
return step;
|
|
428
|
+
index = step;
|
|
428
429
|
continue;
|
|
429
430
|
}
|
|
430
|
-
if (
|
|
431
|
-
|
|
431
|
+
if (inCasePattern && char === ")") {
|
|
432
|
+
finishBashWord(state);
|
|
432
433
|
index--;
|
|
433
434
|
continue;
|
|
434
435
|
}
|
|
435
|
-
if ("
|
|
436
|
-
|
|
436
|
+
if (char === ")") {
|
|
437
|
+
if (close !== ")" || state.structures.length > 0 || heredocs === undefined && state.heredocs.length > 0)
|
|
438
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
439
|
+
return closeBashList(state, index);
|
|
440
|
+
}
|
|
441
|
+
if (char === "(")
|
|
442
|
+
return { kind: "opaque", reason: state.wordStarted ? "dynamic-execution" : "compound-command" };
|
|
437
443
|
if (/\s/.test(char) && !`
|
|
438
444
|
`.includes(char))
|
|
439
445
|
return { kind: "opaque", reason: "invalid-structure" };
|
|
440
446
|
if (char === " " || char === "\t") {
|
|
441
|
-
|
|
447
|
+
finishBashWord(state);
|
|
442
448
|
continue;
|
|
443
449
|
}
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
450
|
+
state.wordStarted = true;
|
|
451
|
+
if (char === "=" && !state.assignmentWord && !state.assignmentHeadUnsafe && /^[A-Za-z_][A-Za-z0-9_]*\+?$/.test(state.word))
|
|
452
|
+
state.assignmentWord = true;
|
|
453
|
+
bashAppend(state, char);
|
|
454
|
+
state.wordEnd = index + 1;
|
|
455
|
+
}
|
|
456
|
+
if (close)
|
|
457
|
+
return { kind: "opaque", reason: close === ")" ? "command-substitution" : "invalid-structure" };
|
|
458
|
+
if (state.heredocs.length)
|
|
459
|
+
return { kind: "opaque", reason: "heredoc" };
|
|
460
|
+
return closeBashList(state, input.length);
|
|
461
|
+
}
|
|
462
|
+
function scanBashOperatorOrSeparator(state, index, depth, context) {
|
|
463
|
+
const input = state.input;
|
|
464
|
+
const char = input[index];
|
|
465
|
+
const redirect = "<>&".includes(char) ? bashOperator(input, index, BASH_REDIRECTS) : undefined;
|
|
466
|
+
if (typeof redirect === "object")
|
|
467
|
+
return redirect;
|
|
468
|
+
const caseHead = state.structures.at(-1);
|
|
469
|
+
if (redirect && caseHead?.kind === "case" && caseHead.phase !== "body")
|
|
470
|
+
return { kind: "opaque", reason: "invalid-redirect" };
|
|
471
|
+
if (redirect) {
|
|
472
|
+
state.hasRedirect = true;
|
|
473
|
+
state.commandStart ??= state.wordStart;
|
|
474
|
+
if (state.redirectTarget)
|
|
475
|
+
state.invalid ??= "invalid-redirect";
|
|
476
|
+
const fdPrefix = state.wordStarted && !state.assignmentHeadUnsafe && /^(?:\d+|\{[A-Za-z_][A-Za-z0-9_]*\})$/.test(state.word);
|
|
477
|
+
if (fdPrefix) {
|
|
478
|
+
if (state.wordEnd < index)
|
|
479
|
+
state.commandEnd = state.wordEnd;
|
|
480
|
+
state.word = "";
|
|
481
|
+
state.literal = "";
|
|
482
|
+
state.output = "";
|
|
483
|
+
state.wordStarted = false;
|
|
484
|
+
}
|
|
485
|
+
if (!fdPrefix)
|
|
486
|
+
finishBashWord(state);
|
|
487
|
+
if (redirect.startsWith("&") && context.dialect === "posix")
|
|
488
|
+
state.ampersandRedirectWords ??= state.words.length;
|
|
489
|
+
if (state.redirectWordCount === undefined && state.commandWordIndex >= 0) {
|
|
490
|
+
state.redirectWordCount = state.words.length;
|
|
491
|
+
if (state.dangling)
|
|
492
|
+
state.resourceEnd = state.commandEnd;
|
|
493
|
+
}
|
|
494
|
+
if (redirect === "<<" || redirect === "<<-") {
|
|
495
|
+
const delimiter = bashHeredocDelimiter(input, index + redirect.length, redirect === "<<-");
|
|
496
|
+
if (!delimiter)
|
|
497
|
+
return { kind: "opaque", reason: "invalid-redirect" };
|
|
498
|
+
state.heredocs.push(delimiter);
|
|
499
|
+
state.wordEnd = delimiter.end + 1;
|
|
500
|
+
state.redirectTarget = false;
|
|
501
|
+
return delimiter.end;
|
|
502
|
+
}
|
|
503
|
+
state.redirectTarget = true;
|
|
504
|
+
state.hereString = redirect === "<<<";
|
|
505
|
+
return index + redirect.length - 1;
|
|
506
|
+
}
|
|
507
|
+
if (state.structures.at(-1)?.phase === "pattern" && char === "|") {
|
|
508
|
+
finishBashWord(state);
|
|
509
|
+
return index - 1;
|
|
510
|
+
}
|
|
511
|
+
const structure = state.structures.at(-1);
|
|
512
|
+
const caseBody = structure?.kind === "case" && structure.phase === "body";
|
|
513
|
+
const operator = bashOperator(input, index, caseBody ? BASH_CASE_OPERATORS : BASH_LIST_OPERATORS);
|
|
514
|
+
if (typeof operator === "object")
|
|
515
|
+
return operator;
|
|
516
|
+
const separator = operator ?? char;
|
|
517
|
+
if (caseBody && separator.startsWith(";") && separator.length > 1) {
|
|
518
|
+
if (!endBashList(state))
|
|
519
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
520
|
+
structure.phase = "pattern";
|
|
521
|
+
structure.patternStarted = false;
|
|
522
|
+
return index + separator.length - 1;
|
|
523
|
+
}
|
|
524
|
+
if (structure?.kind === "case" && (structure.phase === "header" || structure.phase === "pattern")) {
|
|
525
|
+
if (separator !== `
|
|
526
|
+
`)
|
|
527
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
528
|
+
if (structure.phase === "pattern" && (state.wordStarted || state.words.length > 0))
|
|
529
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
530
|
+
finishBashWord(state);
|
|
531
|
+
return readBashHeredocs(state, index, depth, context);
|
|
532
|
+
}
|
|
533
|
+
if ((structure?.kind === "for" || structure?.kind === "repeat") && (structure.phase === "header" || structure.phase === "do")) {
|
|
534
|
+
if (separator !== ";" && separator !== `
|
|
535
|
+
`)
|
|
536
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
537
|
+
if (structure.phase === "header" && !structure.sawIn && !state.wordStarted && state.words.length === 0)
|
|
538
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
539
|
+
}
|
|
540
|
+
if (separator === `
|
|
541
|
+
` && !pending(state))
|
|
542
|
+
return readBashHeredocs(state, index, depth, context);
|
|
543
|
+
finishBashCommand(state, true);
|
|
544
|
+
if (structure?.kind === "for" && structure.phase === "header")
|
|
545
|
+
structure.phase = "do";
|
|
546
|
+
state.dangling = separator !== "&" && separator !== ";" && separator !== `
|
|
547
|
+
`;
|
|
548
|
+
if (separator === `
|
|
549
|
+
` && state.heredocs.length)
|
|
550
|
+
return index - 1;
|
|
551
|
+
return index + separator.length - 1;
|
|
552
|
+
}
|
|
553
|
+
function bashCommandKey(command) {
|
|
554
|
+
return JSON.stringify([command.resource, command.words]);
|
|
555
|
+
}
|
|
556
|
+
function readBashHeredocs(state, index, depth, context) {
|
|
557
|
+
let end = index;
|
|
558
|
+
for (const heredoc of state.heredocs.splice(0)) {
|
|
559
|
+
const body = bashHeredoc(state.input, end + 1, heredoc);
|
|
560
|
+
if (!body)
|
|
561
|
+
return { kind: "opaque", reason: "heredoc" };
|
|
562
|
+
if (heredoc.command)
|
|
563
|
+
heredoc.command.resource = state.input.slice(heredoc.start, body.end).trim();
|
|
564
|
+
const text = heredoc.quoted ? { word: body.source, literal: body.source, output: "" } : bashText();
|
|
565
|
+
if (!heredoc.quoted) {
|
|
566
|
+
const expansion = scanBashSpan(body.source, 0, depth, context, state.commands, BASH_SPANS.heredoc, true, text);
|
|
567
|
+
if (typeof expansion === "object")
|
|
568
|
+
return expansion;
|
|
569
|
+
}
|
|
570
|
+
if (heredoc.binding)
|
|
571
|
+
bashEvaluatesExpansion(text, "deferred", context);
|
|
572
|
+
end = body.end;
|
|
573
|
+
}
|
|
574
|
+
return end;
|
|
575
|
+
}
|
|
576
|
+
function bashCrossesHeredoc(state, start, end) {
|
|
577
|
+
return state.heredocs.length > 0 && state.input.slice(start, end).includes(`
|
|
578
|
+
`);
|
|
579
|
+
}
|
|
580
|
+
function scanBashCommandStart(state, index, depth, context) {
|
|
581
|
+
const input = state.input;
|
|
582
|
+
const char = input[index];
|
|
583
|
+
const structure = state.structures.at(-1);
|
|
584
|
+
if (structure?.phase === "pattern" && !structure.patternStarted && !state.words.length && char === "(") {
|
|
585
|
+
structure.patternStarted = true;
|
|
586
|
+
return index;
|
|
587
|
+
}
|
|
588
|
+
if (structure?.phase === "pattern" && char === "|") {
|
|
589
|
+
if (!state.words.length)
|
|
590
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
591
|
+
finishBashWord(state);
|
|
592
|
+
structure.patternStarted = true;
|
|
593
|
+
return index;
|
|
594
|
+
}
|
|
595
|
+
if (structure?.phase === "pattern" && char === ")") {
|
|
596
|
+
if (!state.words.length)
|
|
597
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
598
|
+
finishBashCommand(state);
|
|
599
|
+
structure.phase = "body";
|
|
600
|
+
structure.count = 0;
|
|
601
|
+
return index;
|
|
602
|
+
}
|
|
603
|
+
if (structure?.kind === "for" && structure.phase === "header" && char === "(" && input[index + 1] !== "(") {
|
|
604
|
+
const end = scanBashArrayOrPattern(input, index, depth + 1, context, state.nestedCommands, "array");
|
|
605
|
+
if (typeof end === "object")
|
|
606
|
+
return end;
|
|
607
|
+
if (bashCrossesHeredoc(state, index, end))
|
|
608
|
+
return { kind: "opaque", reason: "heredoc" };
|
|
609
|
+
finishBashCommand(state);
|
|
610
|
+
structure.phase = "do";
|
|
611
|
+
structure.parenthesized = true;
|
|
612
|
+
DO_AHEAD_RE.lastIndex = end + 1;
|
|
613
|
+
if (!DO_AHEAD_RE.test(input))
|
|
614
|
+
state.structures.pop();
|
|
615
|
+
return end;
|
|
616
|
+
}
|
|
617
|
+
if (structure?.kind === "repeat" && structure.phase === "do" && char !== `
|
|
618
|
+
` && char !== "#" && char !== ";") {
|
|
619
|
+
TOKEN_RE.lastIndex = index;
|
|
620
|
+
if (TOKEN_RE.exec(input)?.[0] !== "do")
|
|
621
|
+
state.structures.pop();
|
|
622
|
+
}
|
|
623
|
+
const keywordStep = scanBashKeyword(state, index, depth, context);
|
|
624
|
+
if (keywordStep !== undefined)
|
|
625
|
+
return keywordStep;
|
|
626
|
+
if (structure?.kind === "for" && structure.phase === "do" && char !== `
|
|
627
|
+
` && char !== "#" && char !== ";") {
|
|
628
|
+
SPACE_CONTINUATION_AHEAD_RE.lastIndex = index + 1;
|
|
629
|
+
if (char !== "{" || !SPACE_CONTINUATION_AHEAD_RE.test(input))
|
|
630
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
631
|
+
state.structures.pop();
|
|
632
|
+
}
|
|
633
|
+
const atStart = atCommandStart(state);
|
|
634
|
+
const functionHead = atStart && char === "(" ? bashFunctionHeadLength(input, index) : 0;
|
|
635
|
+
if (functionHead)
|
|
636
|
+
return index + functionHead - 1;
|
|
637
|
+
if (atStart && char === "!") {
|
|
638
|
+
NEGATION_AHEAD_RE.lastIndex = index + 1;
|
|
639
|
+
if (NEGATION_AHEAD_RE.test(input))
|
|
640
|
+
return index;
|
|
641
|
+
}
|
|
642
|
+
const forHeader = structure?.kind === "for" && structure.phase === "header";
|
|
643
|
+
const compoundOpen = (atStart || forHeader) && "([".includes(char) ? bashOperator(input, index, ["((", "[["]) : undefined;
|
|
644
|
+
if (typeof compoundOpen === "object")
|
|
645
|
+
return compoundOpen;
|
|
646
|
+
if (compoundOpen === "((") {
|
|
647
|
+
if (forHeader && state.words.length > 0)
|
|
648
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
649
|
+
const span = forHeader ? BASH_SPANS.forArithmetic : BASH_SPANS.arithmetic;
|
|
650
|
+
const end = scanBashArithmetic(input, index + 2, depth, context, state.commands, span);
|
|
651
|
+
if (typeof end === "number") {
|
|
652
|
+
if (bashCrossesHeredoc(state, index, end))
|
|
653
|
+
return { kind: "opaque", reason: "heredoc" };
|
|
654
|
+
if (!forHeader && context.dialect === "posix") {
|
|
655
|
+
const subshells = scanBash(input, index + 1, depth + 1, context, ")");
|
|
656
|
+
if (subshells.kind === "opaque")
|
|
657
|
+
return subshells;
|
|
658
|
+
if (subshells.end !== end)
|
|
659
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
660
|
+
const seen = new Set(state.commands.map(bashCommandKey));
|
|
661
|
+
state.commands.push(...subshells.commands.filter((command) => !seen.has(bashCommandKey(command))));
|
|
481
662
|
}
|
|
482
|
-
|
|
483
|
-
if (structure?.kind === "for" && structure.phase === "header")
|
|
663
|
+
if (forHeader) {
|
|
484
664
|
structure.phase = "do";
|
|
485
|
-
|
|
486
|
-
`;
|
|
487
|
-
inList = dangling;
|
|
488
|
-
if (separator === `
|
|
489
|
-
` && heredocs.length) {
|
|
490
|
-
index--;
|
|
491
|
-
continue;
|
|
665
|
+
structure.sawIn = true;
|
|
492
666
|
}
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
667
|
+
if (!forHeader) {
|
|
668
|
+
bashStatement(state);
|
|
669
|
+
state.compoundEnd = true;
|
|
670
|
+
}
|
|
671
|
+
return end;
|
|
496
672
|
}
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
wordEnd = index + 1;
|
|
673
|
+
if (end)
|
|
674
|
+
return end;
|
|
675
|
+
if (forHeader)
|
|
676
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
502
677
|
}
|
|
503
|
-
if (
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
678
|
+
if (atStart && (char === "(" || char === "{" && (SPACE_CONTINUATION_AHEAD_RE.lastIndex = index + 1, SPACE_CONTINUATION_AHEAD_RE.test(input)))) {
|
|
679
|
+
const group = scanBash(input, index + 1, depth + 1, context, char === "{" ? "}" : ")", state.heredocs);
|
|
680
|
+
if (group.kind === "opaque")
|
|
681
|
+
return group;
|
|
682
|
+
if (!input.slice(index + 1, group.end).trim())
|
|
683
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
684
|
+
state.commands.push(...group.commands);
|
|
685
|
+
bashStatement(state);
|
|
686
|
+
state.compoundEnd = true;
|
|
687
|
+
return group.end;
|
|
510
688
|
}
|
|
511
|
-
if (
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
689
|
+
if (atStart && compoundOpen === "[[" && (SPACE_CONTINUATION_AHEAD_RE.lastIndex = index + 2, SPACE_CONTINUATION_AHEAD_RE.test(input))) {
|
|
690
|
+
const end = scanBashConditional(input, index + 2, depth, context, state.commands);
|
|
691
|
+
if (typeof end === "object")
|
|
692
|
+
return end;
|
|
693
|
+
if (bashCrossesHeredoc(state, index, end))
|
|
694
|
+
return { kind: "opaque", reason: "heredoc" };
|
|
695
|
+
bashStatement(state);
|
|
696
|
+
state.compoundEnd = true;
|
|
697
|
+
return end;
|
|
698
|
+
}
|
|
699
|
+
return;
|
|
700
|
+
}
|
|
701
|
+
function scanBashKeyword(state, index, depth, context) {
|
|
702
|
+
const input = state.input;
|
|
703
|
+
const char = input[index];
|
|
704
|
+
if (!(char >= "A" && char <= "Z" || char >= "a" && char <= "z" || char === "_"))
|
|
705
|
+
return;
|
|
706
|
+
const structure = state.structures.at(-1);
|
|
707
|
+
TOKEN_RE.lastIndex = index;
|
|
708
|
+
const token = TOKEN_RE.exec(input)?.[0];
|
|
709
|
+
const end = index + (token?.length ?? 0) - 1;
|
|
710
|
+
if (structure?.kind === "case" && structure.phase === "header" && token === "in") {
|
|
711
|
+
if (state.words.length !== 1 || state.hasRedirect)
|
|
712
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
713
|
+
finishBashCommand(state);
|
|
714
|
+
structure.phase = "pattern";
|
|
715
|
+
structure.patternStarted = false;
|
|
716
|
+
return end;
|
|
717
|
+
}
|
|
718
|
+
if (structure?.kind === "for" && (structure.phase === "header" || structure.phase === "do") && !structure.sawIn && !structure.parenthesized && token === "in" && (structure.phase === "do" || state.words.length >= 1)) {
|
|
719
|
+
structure.sawIn = true;
|
|
720
|
+
structure.phase = "header";
|
|
721
|
+
return end;
|
|
722
|
+
}
|
|
723
|
+
if (structure?.phase === "pattern" && !structure.patternStarted && !state.words.length && token === "esac") {
|
|
724
|
+
state.structures.pop();
|
|
725
|
+
bashStatement(state);
|
|
726
|
+
state.compoundEnd = true;
|
|
727
|
+
return end;
|
|
728
|
+
}
|
|
729
|
+
if (structure?.kind === "for" && structure.phase === "header" && !structure.sawIn && state.words.length === 1 && !state.hasRedirect && token === "do") {
|
|
730
|
+
finishBashCommand(state);
|
|
731
|
+
structure.phase = "do";
|
|
732
|
+
}
|
|
733
|
+
const inHeader = bashInHeader(state);
|
|
734
|
+
if (token && ["then", "elif", "else", "fi", "do", "done", "esac"].includes(token) && !state.words.length && !state.redirectTarget && (!inHeader || token === "do" && structure?.phase === "do")) {
|
|
735
|
+
if (state.hasRedirect && context.dialect !== "zsh" || !endBashList(state) || !structure)
|
|
736
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
737
|
+
if (token === "then") {
|
|
738
|
+
if (structure.kind !== "if" || structure.phase !== "condition" || !structure.count)
|
|
739
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
740
|
+
structure.phase = "body";
|
|
741
|
+
structure.count = 0;
|
|
742
|
+
return end;
|
|
743
|
+
}
|
|
744
|
+
if (token === "elif" || token === "else") {
|
|
745
|
+
if (structure.kind !== "if" || structure.phase !== "body" || !structure.count || structure.sawElse)
|
|
746
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
747
|
+
structure.phase = token === "elif" ? "condition" : "body";
|
|
748
|
+
structure.sawElse = token === "else";
|
|
749
|
+
structure.count = 0;
|
|
750
|
+
return end;
|
|
751
|
+
}
|
|
752
|
+
if (token === "do") {
|
|
753
|
+
if (!["for", "while", "until", "repeat"].includes(structure.kind) || !["condition", "do"].includes(structure.phase) || structure.kind !== "for" && structure.kind !== "repeat" && !structure.count)
|
|
754
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
755
|
+
structure.phase = "body";
|
|
756
|
+
structure.count = 0;
|
|
757
|
+
return end;
|
|
758
|
+
}
|
|
759
|
+
if (token === "fi" && (structure.kind !== "if" || structure.phase !== "body" || !structure.count) || token === "done" && (!["for", "while", "until", "repeat"].includes(structure.kind) || structure.phase !== "body" || !structure.count) || token === "esac" && (structure.kind !== "case" || structure.phase === "header"))
|
|
760
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
761
|
+
state.structures.pop();
|
|
762
|
+
bashStatement(state);
|
|
763
|
+
state.compoundEnd = true;
|
|
764
|
+
return end;
|
|
765
|
+
}
|
|
766
|
+
if (!atCommandStart(state))
|
|
767
|
+
return;
|
|
768
|
+
const definitionLength = bashFunctionHeadLength(input, index);
|
|
769
|
+
if (definitionLength > 0)
|
|
770
|
+
return index + definitionLength - 1;
|
|
771
|
+
if (token === "if" || token === "while" || token === "until" || token === "for" || token === "select" || token === "case" || token === "repeat" && context.dialect !== "bash") {
|
|
772
|
+
if (depth + state.structures.length >= MAX_SUBSTITUTION_DEPTH)
|
|
773
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
774
|
+
state.structures.push({
|
|
775
|
+
kind: token === "select" ? "for" : token,
|
|
776
|
+
phase: ["for", "select", "case", "repeat"].includes(token) ? "header" : "condition",
|
|
777
|
+
count: 0
|
|
778
|
+
});
|
|
779
|
+
state.dangling = false;
|
|
780
|
+
return end;
|
|
781
|
+
}
|
|
782
|
+
if (token === "coproc") {
|
|
783
|
+
COPROC_AHEAD_RE.lastIndex = index;
|
|
784
|
+
const coprocMatch = COPROC_AHEAD_RE.exec(input)?.[0];
|
|
785
|
+
if (coprocMatch)
|
|
786
|
+
return index + coprocMatch.length - 1;
|
|
787
|
+
}
|
|
788
|
+
if (token === "time") {
|
|
789
|
+
TIME_AHEAD_RE.lastIndex = index;
|
|
790
|
+
const timeMatch = TIME_AHEAD_RE.exec(input)?.[0];
|
|
791
|
+
if (timeMatch)
|
|
792
|
+
return index + timeMatch.length - 1;
|
|
793
|
+
}
|
|
794
|
+
return;
|
|
520
795
|
}
|
|
521
|
-
function
|
|
522
|
-
|
|
796
|
+
function bashFunctionHeadLength(input, start) {
|
|
797
|
+
FUNCTION_HEAD_RE.lastIndex = start;
|
|
798
|
+
const head = FUNCTION_HEAD_RE.exec(input);
|
|
799
|
+
if (!head || (head[1] ? !head[2] : !head[3] || BASH_NON_FUNCTION_KEYWORDS.has(head[2] ?? "")))
|
|
800
|
+
return 0;
|
|
801
|
+
FUNCTION_BODY_RE.lastIndex = start + head[0].length;
|
|
802
|
+
return FUNCTION_BODY_RE.test(input) ? head[0].length - head[4].length : 0;
|
|
523
803
|
}
|
|
524
|
-
|
|
804
|
+
var BASH_SPANS = {
|
|
805
|
+
double: { close: '"', reject: "", mode: "quoted" },
|
|
806
|
+
heredoc: { reject: "", mode: "quoted" },
|
|
807
|
+
arithmetic: { open: "(", close: ")", reject: ";#}", mode: "arithmetic" },
|
|
808
|
+
forArithmetic: { open: "(", close: ")", reject: "#}", mode: "arithmetic" },
|
|
809
|
+
bracketArithmetic: { close: "]", reject: `;|&<>()[
|
|
810
|
+
'"\\#`, mode: "arithmetic" },
|
|
811
|
+
subscript: { open: "[", close: "]", reject: '"}', mode: "arithmetic" },
|
|
812
|
+
quotedSubscript: { open: "[", close: "]", reject: '"', mode: "quoted" },
|
|
813
|
+
assignmentSubscript: { open: "[", close: "]", reject: `
|
|
814
|
+
\r\v\f;&|<>()`, mode: "arithmetic" },
|
|
815
|
+
arithmeticQuote: { close: "'", reject: '()[];"}', mode: "quoted" },
|
|
816
|
+
arithmeticDouble: { close: '"', reject: "()[];}", mode: "quoted" },
|
|
817
|
+
parameterQuote: { close: "'", reject: '"}[]', mode: "quoted" }
|
|
818
|
+
};
|
|
819
|
+
function scanBashUnit(input, index, depth, context, commands, mode, allowBracket, text) {
|
|
820
|
+
const char = input[index];
|
|
821
|
+
const next = input[index + 1] ?? "\x00";
|
|
822
|
+
if (char === "\\") {
|
|
823
|
+
if (mode === "quoted" && !'$`"\\\n'.includes(next))
|
|
824
|
+
return;
|
|
825
|
+
if (text && next !== `
|
|
826
|
+
`)
|
|
827
|
+
bashAppend(text, input.slice(index + 1, index + 2));
|
|
828
|
+
return index + 1;
|
|
829
|
+
}
|
|
830
|
+
if (char === "$" && context.dialect !== "bash" && zshEvaluates(input, index))
|
|
831
|
+
return { kind: "opaque", reason: "dynamic-execution" };
|
|
832
|
+
if (char === "$" && context.dialect !== "bash" && (mode === "word" || mode === "quoted") && (ZSH_SUBSCRIPT_RE.lastIndex = index, ZSH_SUBSCRIPT_RE.test(input))) {
|
|
833
|
+
const bracket = ZSH_SUBSCRIPT_RE.lastIndex;
|
|
834
|
+
const subscript = bashText();
|
|
835
|
+
const span = mode === "quoted" ? BASH_SPANS.quotedSubscript : BASH_SPANS.subscript;
|
|
836
|
+
const end = scanBashSpan(input, bracket, depth, context, commands, span, false, subscript);
|
|
837
|
+
if (typeof end === "object")
|
|
838
|
+
return end;
|
|
839
|
+
if (bashEvaluatesExpansion(subscript, "arithmetic", context))
|
|
840
|
+
return { kind: "opaque", reason: "dynamic-execution" };
|
|
841
|
+
if (text)
|
|
842
|
+
text.word += `${input.slice(index, bracket)}${subscript.word}]`;
|
|
843
|
+
return end;
|
|
844
|
+
}
|
|
845
|
+
const opener = char === "$" ? bashOperator(input, index, ["$$", "$((", "$(", "${", "$[", "$'", '$"']) : mode === "word" && (char === "<" || char === ">") ? bashOperator(input, index, [`${char}(`]) : undefined;
|
|
846
|
+
if (typeof opener === "object")
|
|
847
|
+
return opener;
|
|
848
|
+
if (opener === "$$") {
|
|
849
|
+
LINE_CONTINUATION_RE.lastIndex = index + 2;
|
|
850
|
+
const quoteStart = LINE_CONTINUATION_RE.exec(input) ? LINE_CONTINUATION_RE.lastIndex : index + 2;
|
|
851
|
+
if (input[quoteStart] === "'") {
|
|
852
|
+
const nextQuote = input.indexOf("'", quoteStart + 1);
|
|
853
|
+
if (nextQuote < 0)
|
|
854
|
+
return { kind: "opaque", reason: "unterminated-quote" };
|
|
855
|
+
if (input.slice(quoteStart + 1, nextQuote).includes("\\") && input.includes("'", nextQuote + 1))
|
|
856
|
+
return { kind: "opaque", reason: "unterminated-quote" };
|
|
857
|
+
}
|
|
858
|
+
if (text)
|
|
859
|
+
text.word += "$$";
|
|
860
|
+
return index + 1;
|
|
861
|
+
}
|
|
862
|
+
if (mode === "word" && opener === "$'") {
|
|
863
|
+
const quote = bashAnsiQuote(input, index + 1);
|
|
864
|
+
if (!quote)
|
|
865
|
+
return { kind: "opaque", reason: "unterminated-quote" };
|
|
866
|
+
const firstQuote = input.indexOf("'", index + 2);
|
|
867
|
+
if (quote.end !== firstQuote && (context.dialect !== "bash" && index >= 2 && input[index - 2] === "$" || context.dialect === "posix" && (input.indexOf("'", firstQuote + 1) < quote.end || /[#"\n]|\\'/.test(input.slice(firstQuote + 1)))))
|
|
868
|
+
return { kind: "opaque", reason: "unterminated-quote" };
|
|
869
|
+
if (text)
|
|
870
|
+
bashAppend(text, quote.value);
|
|
871
|
+
return quote.end;
|
|
872
|
+
}
|
|
873
|
+
if (mode === "arithmetic" && opener === "$'") {
|
|
874
|
+
const quote = bashAnsiQuote(input, index + 1);
|
|
875
|
+
if (!quote || quote.end !== input.indexOf("'", index + 2) || /[()[\];"}]/.test(quote.value))
|
|
876
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
877
|
+
if (text)
|
|
878
|
+
bashAppend(text, quote.value);
|
|
879
|
+
return scanBashSpan(input, index + 2, depth, context, commands, BASH_SPANS.arithmeticQuote, allowBracket, text);
|
|
880
|
+
}
|
|
881
|
+
if (mode === "word" && char === "'") {
|
|
882
|
+
const end = input.indexOf("'", index + 1);
|
|
883
|
+
if (end < 0)
|
|
884
|
+
return { kind: "opaque", reason: "unterminated-quote" };
|
|
885
|
+
if (text)
|
|
886
|
+
bashAppend(text, input.slice(index + 1, end));
|
|
887
|
+
return end;
|
|
888
|
+
}
|
|
889
|
+
if (mode === "arithmetic" && char === "'")
|
|
890
|
+
return scanBashSpan(input, index + 1, depth, context, commands, BASH_SPANS.arithmeticQuote, allowBracket, text);
|
|
891
|
+
if (mode === "word" && opener === '$"')
|
|
892
|
+
return scanBashSpan(input, index + 2, depth, context, commands, BASH_SPANS.double, allowBracket, text);
|
|
893
|
+
if (mode !== "quoted" && char === '"') {
|
|
894
|
+
const span = mode === "arithmetic" ? BASH_SPANS.arithmeticDouble : BASH_SPANS.double;
|
|
895
|
+
return scanBashSpan(input, index + 1, depth, context, commands, span, allowBracket, text);
|
|
896
|
+
}
|
|
897
|
+
const end = opener === "<(" || opener === ">(" ? scanBashNested(input, index + 2, depth, context, commands, ")") : opener && opener !== "$'" && opener !== '$"' || char === "`" ? scanBashDollarOrBacktick(input, index, depth, context, commands, mode !== "word", allowBracket, text) : undefined;
|
|
898
|
+
if (end === undefined && char === "$" && /[A-Za-z_0-9@*#?$!-]/.test(next)) {
|
|
899
|
+
if (text)
|
|
900
|
+
text.word += "$";
|
|
901
|
+
return index;
|
|
902
|
+
}
|
|
903
|
+
if (text && typeof end === "number")
|
|
904
|
+
text.word += input.slice(index, end + 1);
|
|
905
|
+
return end;
|
|
906
|
+
}
|
|
907
|
+
function zshEvaluates(input, index) {
|
|
908
|
+
let at = index + 1;
|
|
909
|
+
if (input.startsWith("{\\\n", at))
|
|
910
|
+
return true;
|
|
911
|
+
if (input[at] === "{" && input[at + 1] === "(") {
|
|
912
|
+
ZSH_SAFE_FLAGS_RE.lastIndex = index;
|
|
913
|
+
if (!ZSH_SAFE_FLAGS_RE.test(input))
|
|
914
|
+
return true;
|
|
915
|
+
at = ZSH_SAFE_FLAGS_RE.lastIndex;
|
|
916
|
+
}
|
|
917
|
+
if (input[at] === "{")
|
|
918
|
+
at++;
|
|
919
|
+
ZSH_GLOB_MODIFIER_RE.lastIndex = at;
|
|
920
|
+
return ZSH_GLOB_MODIFIER_RE.test(input);
|
|
921
|
+
}
|
|
922
|
+
function bashAppend(text, value) {
|
|
923
|
+
text.word += value;
|
|
924
|
+
text.literal += value;
|
|
925
|
+
}
|
|
926
|
+
function bashEvaluatesExpansion(text, evaluation, context) {
|
|
927
|
+
const combined = `${text.literal} ${text.output}`;
|
|
928
|
+
const hasExpansion = BASH_EXPANSION_RE.test(combined);
|
|
929
|
+
const hasEscape = BASH_ESCAPE_RE.test(text.literal);
|
|
930
|
+
if (hasExpansion || hasEscape || /[$`]/.test(text.literal))
|
|
931
|
+
context.boundDollar = true;
|
|
932
|
+
if (hasExpansion || hasEscape || /[({`]/.test(text.literal))
|
|
933
|
+
context.boundOpen = true;
|
|
934
|
+
if (evaluation === "deferred")
|
|
935
|
+
return false;
|
|
936
|
+
if (evaluation === "arithmetic" ? /[A-Za-z_]|(?:\$(?![?#!-]|\$(?!\[)))/.test(text.word) : text.word.includes("$") || combined.includes("["))
|
|
937
|
+
context.variableSink = true;
|
|
938
|
+
if (evaluation === "arithmetic")
|
|
939
|
+
return hasExpansion;
|
|
940
|
+
return combined.includes("[") && hasExpansion;
|
|
941
|
+
}
|
|
942
|
+
function bashText() {
|
|
943
|
+
return { word: "", literal: "", output: "" };
|
|
944
|
+
}
|
|
945
|
+
function scanBashSubscript(input, start, depth, context, commands, span = BASH_SPANS.subscript) {
|
|
946
|
+
const text = bashText();
|
|
947
|
+
const end = scanBashSpan(input, start, depth, context, commands, span, false, text);
|
|
948
|
+
if (typeof end === "number" && bashEvaluatesExpansion(text, "arithmetic", context))
|
|
949
|
+
return { kind: "opaque", reason: "dynamic-execution" };
|
|
950
|
+
return end;
|
|
951
|
+
}
|
|
952
|
+
function scanBashSpan(input, start, depth, context, commands, span, allowBracket, text) {
|
|
953
|
+
let nesting = 0;
|
|
954
|
+
for (let index = start;index < input.length; index++) {
|
|
955
|
+
if (--context.remaining < 0)
|
|
956
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
957
|
+
const char = input[index];
|
|
958
|
+
if (char === span.close && !nesting)
|
|
959
|
+
return index;
|
|
960
|
+
if (span.reject.includes(char) && !(char === "#" && /[\d$]/.test(input[index - 1] ?? "")))
|
|
961
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
962
|
+
if (char === span.open && ++nesting + depth > MAX_SUBSTITUTION_DEPTH)
|
|
963
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
964
|
+
if (char === span.close)
|
|
965
|
+
nesting--;
|
|
966
|
+
const unit = char === span.open || char === span.close ? undefined : scanBashUnit(input, index, depth, context, commands, span.mode, allowBracket, text);
|
|
967
|
+
if (typeof unit === "object")
|
|
968
|
+
return unit;
|
|
969
|
+
if (unit !== undefined)
|
|
970
|
+
index = unit;
|
|
971
|
+
else if (char === "\\" && (input[index + 1] === span.open || input[index + 1] === span.close)) {
|
|
972
|
+
if (text)
|
|
973
|
+
bashAppend(text, input.slice(index, index + 2));
|
|
974
|
+
index++;
|
|
975
|
+
} else if (text)
|
|
976
|
+
bashAppend(text, char);
|
|
977
|
+
}
|
|
978
|
+
return span.close ? { kind: "opaque", reason: "unterminated-quote" } : input.length;
|
|
979
|
+
}
|
|
980
|
+
function scanBashNested(input, start, depth, context, commands, close, text) {
|
|
981
|
+
const nested = scanBash(input, start, depth + 1, context, close, undefined, text);
|
|
982
|
+
if (nested.kind === "opaque")
|
|
983
|
+
return nested;
|
|
984
|
+
commands.push(...nested.commands);
|
|
985
|
+
return nested.end;
|
|
986
|
+
}
|
|
987
|
+
function bashOperator(input, index, operators) {
|
|
988
|
+
let text = "";
|
|
989
|
+
for (let cursor = index;text.length < 3 && cursor < input.length; cursor++) {
|
|
990
|
+
if (input.startsWith("\\\n", cursor))
|
|
991
|
+
cursor++;
|
|
992
|
+
else
|
|
993
|
+
text += input[cursor];
|
|
994
|
+
}
|
|
995
|
+
const operator = operators.find((candidate) => text.startsWith(candidate));
|
|
996
|
+
if (operator && !input.startsWith(operator, index))
|
|
997
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
998
|
+
return operator;
|
|
999
|
+
}
|
|
1000
|
+
function scanBashDollarOrBacktick(input, start, depth, context, commands, quoted, allowBracket, text) {
|
|
525
1001
|
if (depth >= MAX_SUBSTITUTION_DEPTH)
|
|
1002
|
+
return { kind: "opaque", reason: "command-substitution" };
|
|
1003
|
+
if (input[start] === "`")
|
|
1004
|
+
return scanBashBacktick(input, start, depth + 1, context, commands, quoted, text);
|
|
1005
|
+
if (input.startsWith("$((", start)) {
|
|
1006
|
+
const end = scanBashArithmetic(input, start + 3, depth + 1, context, commands, BASH_SPANS.arithmetic);
|
|
1007
|
+
if (end !== undefined)
|
|
1008
|
+
return end;
|
|
1009
|
+
}
|
|
1010
|
+
if (input.startsWith("$(", start))
|
|
1011
|
+
return scanBashNested(input, start + 2, depth, context, commands, ")", text);
|
|
1012
|
+
NOFORK_OPEN_RE.lastIndex = start;
|
|
1013
|
+
const nofork = NOFORK_OPEN_RE.exec(input);
|
|
1014
|
+
if (nofork)
|
|
1015
|
+
return scanBashNested(input, start + nofork[0].length, depth, context, commands, "nofork", text);
|
|
1016
|
+
if (input.startsWith("${", start)) {
|
|
1017
|
+
const parameter = bashText();
|
|
1018
|
+
const end = scanBashParameter(input, start + 2, depth + 1, context, commands, quoted, parameter);
|
|
1019
|
+
if (/^(?:\\\n)*!/.test(input.slice(start + 2))) {
|
|
1020
|
+
context.variableSink = true;
|
|
1021
|
+
if (bashEvaluatesExpansion(parameter, "binding", context))
|
|
1022
|
+
return { kind: "opaque", reason: "dynamic-execution" };
|
|
1023
|
+
}
|
|
1024
|
+
if (text) {
|
|
1025
|
+
text.literal += parameter.literal;
|
|
1026
|
+
text.output += parameter.output;
|
|
1027
|
+
}
|
|
1028
|
+
return end;
|
|
1029
|
+
}
|
|
1030
|
+
if (!allowBracket && context.dialect === "posix")
|
|
1031
|
+
return { kind: "opaque", reason: "command-substitution" };
|
|
1032
|
+
const expression = bashText();
|
|
1033
|
+
const end = scanBashSpan(input, start + 2, depth + 1, context, commands, BASH_SPANS.bracketArithmetic, true, expression);
|
|
1034
|
+
if (typeof end === "number" && bashEvaluatesExpansion(expression, "arithmetic", context))
|
|
1035
|
+
return { kind: "opaque", reason: "dynamic-execution" };
|
|
1036
|
+
return end;
|
|
1037
|
+
}
|
|
1038
|
+
function scanBashArithmetic(input, start, depth, context, commands, span) {
|
|
1039
|
+
const arithmetic = [];
|
|
1040
|
+
const text = bashText();
|
|
1041
|
+
const end = scanBashSpan(input, start, depth, context, arithmetic, span, true, text);
|
|
1042
|
+
if (typeof end === "object")
|
|
1043
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1044
|
+
const close = bashOperator(input, end, ["))"]);
|
|
1045
|
+
if (typeof close === "object")
|
|
1046
|
+
return close;
|
|
1047
|
+
if (!close)
|
|
526
1048
|
return;
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
1049
|
+
if (bashEvaluatesExpansion(text, "arithmetic", context))
|
|
1050
|
+
return { kind: "opaque", reason: "dynamic-execution" };
|
|
1051
|
+
commands.push(...arithmetic);
|
|
1052
|
+
return end + 1;
|
|
1053
|
+
}
|
|
1054
|
+
function scanBashBacktick(input, start, depth, context, commands, quoted, text) {
|
|
1055
|
+
let source = "";
|
|
531
1056
|
for (let index = start + 1;index < input.length; index++) {
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
if (
|
|
537
|
-
|
|
538
|
-
|
|
1057
|
+
if (--context.remaining < 0)
|
|
1058
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1059
|
+
if (input[index] === "`") {
|
|
1060
|
+
const inner = scanBash(source, 0, depth, context, undefined, undefined, text);
|
|
1061
|
+
if (inner.kind === "opaque")
|
|
1062
|
+
return { kind: "opaque", reason: "command-substitution" };
|
|
1063
|
+
commands.push(...inner.commands);
|
|
1064
|
+
return index;
|
|
1065
|
+
}
|
|
1066
|
+
const next = input[index + 1] ?? "\x00";
|
|
1067
|
+
if (input[index] === "\\" && ("$`\\\n".includes(next) || quoted && next === '"')) {
|
|
539
1068
|
index++;
|
|
1069
|
+
if (next !== `
|
|
1070
|
+
`)
|
|
1071
|
+
source += next;
|
|
540
1072
|
continue;
|
|
541
1073
|
}
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
1074
|
+
source += input[index];
|
|
1075
|
+
}
|
|
1076
|
+
return { kind: "opaque", reason: "command-substitution" };
|
|
1077
|
+
}
|
|
1078
|
+
function scanBashParameter(input, start, depth, context, commands, quoted, text) {
|
|
1079
|
+
PARAMETER_PREFIX_RE.lastIndex = start;
|
|
1080
|
+
const nameStart = PARAMETER_PREFIX_RE.exec(input) ? PARAMETER_PREFIX_RE.lastIndex : start;
|
|
1081
|
+
PARAMETER_NAME_RE.lastIndex = nameStart;
|
|
1082
|
+
let colon = PARAMETER_NAME_RE.test(input) ? PARAMETER_NAME_RE.lastIndex : -1;
|
|
1083
|
+
const name = colon > nameStart ? input.slice(nameStart, colon).replace(/\\\n/g, "") : "";
|
|
1084
|
+
if (context.dialect !== "bash" && (/^(?:READ)?NULLCMD$/.test(name) || /^(?:(?:dis_)?(?:functions|[gs]?aliases)|options|commands)$/.test(name) && "[=:".includes(input[colon] ?? "")))
|
|
1085
|
+
return { kind: "opaque", reason: "dynamic-execution" };
|
|
1086
|
+
if (name === "PS4")
|
|
1087
|
+
context.variableSink = true;
|
|
1088
|
+
let evaluation;
|
|
1089
|
+
let wordOffset = 0;
|
|
1090
|
+
let literalOffset = 0;
|
|
1091
|
+
for (let index = start;index < input.length; index++) {
|
|
1092
|
+
if (--context.remaining < 0)
|
|
1093
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1094
|
+
const char = input[index];
|
|
1095
|
+
if (char === "}") {
|
|
1096
|
+
if (evaluation && bashEvaluatesExpansion({ word: text.word.slice(wordOffset), literal: text.literal.slice(literalOffset), output: text.output }, evaluation, context))
|
|
1097
|
+
return { kind: "opaque", reason: "dynamic-execution" };
|
|
1098
|
+
return index;
|
|
1099
|
+
}
|
|
1100
|
+
if (index === colon && !evaluation) {
|
|
1101
|
+
if (char === ":" && !"-=?+".includes(input[index + 1] ?? ""))
|
|
1102
|
+
evaluation = "arithmetic";
|
|
1103
|
+
if (char === "=" || char === ":" && input[index + 1] === "=")
|
|
1104
|
+
evaluation = "deferred";
|
|
1105
|
+
if (evaluation) {
|
|
1106
|
+
wordOffset = text.word.length;
|
|
1107
|
+
literalOffset = text.literal.length;
|
|
550
1108
|
}
|
|
551
|
-
const nested = char === '"' || input.startsWith('$"', index) ? bashExpansion(input, index + (char === "$" ? 1 : 0), depth + 1, "double") : bashExpansion(input, index, depth + 1);
|
|
552
|
-
if (!nested)
|
|
553
|
-
return;
|
|
554
|
-
index = nested.end;
|
|
555
|
-
continue;
|
|
556
1109
|
}
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
1110
|
+
if (char === "@") {
|
|
1111
|
+
PARAMETER_PROMPT_RE.lastIndex = index;
|
|
1112
|
+
if (PARAMETER_PROMPT_RE.test(input))
|
|
1113
|
+
return { kind: "opaque", reason: "dynamic-execution" };
|
|
1114
|
+
}
|
|
1115
|
+
if (!quoted && context.dialect !== "bash" && char === "(" && index > start)
|
|
1116
|
+
return { kind: "opaque", reason: "dynamic-execution" };
|
|
1117
|
+
if (quoted && char === "'" && input[index - 1] === "$") {
|
|
1118
|
+
const ansi = bashAnsiQuote(input, index);
|
|
1119
|
+
if (!ansi)
|
|
1120
|
+
return { kind: "opaque", reason: "unterminated-quote" };
|
|
1121
|
+
text.literal += ansi.value;
|
|
1122
|
+
}
|
|
1123
|
+
const subscript = index === colon && char === "[";
|
|
1124
|
+
const unit = subscript ? scanBashSubscript(input, index + 1, depth, context, commands) : quoted && char === "'" ? scanBashSpan(input, index + 1, depth, context, commands, BASH_SPANS.parameterQuote, false, text) : quoted && char === '"' ? scanBashSpan(input, index + 1, depth, context, commands, BASH_SPANS.double, false, text) : scanBashUnit(input, index, depth, context, commands, quoted ? "quoted" : "word", false, text);
|
|
1125
|
+
if (typeof unit === "object")
|
|
1126
|
+
return unit;
|
|
1127
|
+
if (quoted && unit !== undefined && input.startsWith("$(", index) && input.slice(index, unit + 1).includes("}"))
|
|
1128
|
+
return { kind: "opaque", reason: "command-substitution" };
|
|
1129
|
+
if (subscript || index === nameStart && input.startsWith("${", index) && unit !== undefined) {
|
|
1130
|
+
LINE_CONTINUATION_RE.lastIndex = Number(unit) + 1;
|
|
1131
|
+
colon = LINE_CONTINUATION_RE.exec(input) ? LINE_CONTINUATION_RE.lastIndex : Number(unit) + 1;
|
|
1132
|
+
}
|
|
1133
|
+
if (unit !== undefined)
|
|
1134
|
+
index = unit;
|
|
1135
|
+
else
|
|
1136
|
+
bashAppend(text, char);
|
|
1137
|
+
}
|
|
1138
|
+
return { kind: "opaque", reason: "command-substitution" };
|
|
1139
|
+
}
|
|
1140
|
+
function scanBashConditional(input, start, depth, context, commands) {
|
|
1141
|
+
const words = [];
|
|
1142
|
+
let text = bashText();
|
|
1143
|
+
let wordStarted = false;
|
|
1144
|
+
let hasWord = false;
|
|
1145
|
+
let parenDepth = 0;
|
|
1146
|
+
let patternParenDepth = 0;
|
|
1147
|
+
const flushWord = () => {
|
|
1148
|
+
if (!hasWord)
|
|
1149
|
+
return;
|
|
1150
|
+
words.push(text);
|
|
1151
|
+
text = bashText();
|
|
1152
|
+
hasWord = false;
|
|
1153
|
+
};
|
|
1154
|
+
for (let index = start;index < input.length; index++) {
|
|
1155
|
+
if (--context.remaining < 0)
|
|
1156
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1157
|
+
const char = input[index];
|
|
1158
|
+
if (char === "\\" && input[index + 1] === `
|
|
1159
|
+
`) {
|
|
1160
|
+
index++;
|
|
561
1161
|
continue;
|
|
562
1162
|
}
|
|
563
|
-
if (
|
|
1163
|
+
if (!wordStarted)
|
|
1164
|
+
flushWord();
|
|
1165
|
+
const close = !wordStarted && char === "]" ? bashOperator(input, index, ["]]"]) : undefined;
|
|
1166
|
+
if (typeof close === "object")
|
|
1167
|
+
return close;
|
|
1168
|
+
if (close) {
|
|
1169
|
+
BRACE_CLOSE_AHEAD_RE.lastIndex = index + 2;
|
|
1170
|
+
if (BRACE_CLOSE_AHEAD_RE.test(input)) {
|
|
1171
|
+
if (parenDepth !== 0)
|
|
1172
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1173
|
+
const evaluated = words.some((word, at) => words[at - 1]?.word === "-v" && bashEvaluatesExpansion(word, "binding", context) || (context.dialect !== "bash" && words[at - 1]?.word === "-t" || BASH_ARITHMETIC_COMPARISONS.has(words[at - 1]?.word ?? "") || BASH_ARITHMETIC_COMPARISONS.has(words[at + 1]?.word ?? "")) && bashEvaluatesExpansion(word, "arithmetic", context));
|
|
1174
|
+
if (evaluated)
|
|
1175
|
+
return { kind: "opaque", reason: "dynamic-execution" };
|
|
1176
|
+
return index + 1;
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
if (!wordStarted && char === "#") {
|
|
564
1180
|
const newline = input.indexOf(`
|
|
565
1181
|
`, index);
|
|
566
1182
|
if (newline < 0)
|
|
567
|
-
return;
|
|
568
|
-
index = newline
|
|
569
|
-
continue;
|
|
570
|
-
}
|
|
571
|
-
if (input.startsWith("<<<", index)) {
|
|
572
|
-
index += 2;
|
|
1183
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1184
|
+
index = newline;
|
|
573
1185
|
continue;
|
|
574
1186
|
}
|
|
575
|
-
if (
|
|
576
|
-
|
|
577
|
-
if (!
|
|
578
|
-
|
|
579
|
-
heredocs.push(delimiter);
|
|
580
|
-
index = delimiter.end;
|
|
1187
|
+
if (char === " " || char === "\t" || char === `
|
|
1188
|
+
`) {
|
|
1189
|
+
if (!patternParenDepth)
|
|
1190
|
+
wordStarted = false;
|
|
581
1191
|
continue;
|
|
582
1192
|
}
|
|
583
|
-
if (char ===
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
1193
|
+
if (char === ";")
|
|
1194
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1195
|
+
if (char === "(" || char === ")") {
|
|
1196
|
+
if (char === ")" && parenDepth === 0)
|
|
1197
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1198
|
+
const inPattern = patternParenDepth > 0 || char === "(" && ["=", "==", "!=", "=~"].includes(words.at(-1)?.word ?? "");
|
|
1199
|
+
parenDepth += char === "(" ? 1 : -1;
|
|
1200
|
+
if (inPattern) {
|
|
1201
|
+
patternParenDepth += char === "(" ? 1 : -1;
|
|
1202
|
+
wordStarted = true;
|
|
1203
|
+
hasWord = true;
|
|
1204
|
+
bashAppend(text, char);
|
|
1205
|
+
continue;
|
|
590
1206
|
}
|
|
591
|
-
|
|
1207
|
+
flushWord();
|
|
1208
|
+
words.push({ word: char, literal: "", output: "" });
|
|
1209
|
+
wordStarted = false;
|
|
592
1210
|
continue;
|
|
593
1211
|
}
|
|
594
|
-
const
|
|
595
|
-
if (
|
|
596
|
-
|
|
597
|
-
if (
|
|
598
|
-
|
|
599
|
-
if (
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
index += token.length - 1;
|
|
604
|
-
continue;
|
|
605
|
-
}
|
|
606
|
-
if (cases.length && char === ";" && /[;&]/.test(input[index + 1] ?? ""))
|
|
607
|
-
cases[cases.length - 1] = "pattern";
|
|
608
|
-
if (cases.at(-1) === "pattern" && char === "(")
|
|
609
|
-
continue;
|
|
610
|
-
if (cases.at(-1) === "pattern" && char === ")") {
|
|
611
|
-
cases[cases.length - 1] = "body";
|
|
612
|
-
commandStart = true;
|
|
1212
|
+
const unit = scanBashUnit(input, index, depth, context, commands, "word", true, text);
|
|
1213
|
+
if (typeof unit === "object")
|
|
1214
|
+
return unit;
|
|
1215
|
+
if (unit !== undefined)
|
|
1216
|
+
index = unit;
|
|
1217
|
+
if (unit === undefined && !patternParenDepth && "&|<>".includes(char)) {
|
|
1218
|
+
flushWord();
|
|
1219
|
+
words.push({ word: char, literal: "", output: "" });
|
|
1220
|
+
wordStarted = false;
|
|
613
1221
|
continue;
|
|
614
1222
|
}
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
index = nested.end;
|
|
620
|
-
commandStart = false;
|
|
621
|
-
continue;
|
|
622
|
-
}
|
|
623
|
-
if (char === "(" || char === "{" && boundary && /[ \t\n]/.test(input[index + 1] ?? "")) {
|
|
624
|
-
const nested = bashDelimited(input, index, depth + 1);
|
|
625
|
-
if (!nested)
|
|
626
|
-
return;
|
|
627
|
-
index = nested.end;
|
|
628
|
-
commandStart = false;
|
|
629
|
-
continue;
|
|
630
|
-
}
|
|
631
|
-
if (char === close && (close === ")" || boundary))
|
|
632
|
-
return { source: input.slice(start + 1, index), end: index };
|
|
633
|
-
if (/[\n;&|]/.test(char))
|
|
634
|
-
commandStart = true;
|
|
635
|
-
else if (!/[ \t]/.test(char))
|
|
636
|
-
commandStart = false;
|
|
1223
|
+
wordStarted = true;
|
|
1224
|
+
hasWord = true;
|
|
1225
|
+
if (unit === undefined)
|
|
1226
|
+
bashAppend(text, char);
|
|
637
1227
|
}
|
|
1228
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
638
1229
|
}
|
|
639
|
-
function
|
|
640
|
-
if (depth
|
|
641
|
-
return;
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
if (input[index] === "\\" && "$`\\\n".includes(input[index + 1] ?? "\x00")) {
|
|
648
|
-
if (input[++index] !== `
|
|
649
|
-
`)
|
|
650
|
-
source += input[index];
|
|
651
|
-
continue;
|
|
652
|
-
}
|
|
653
|
-
source += input[index];
|
|
654
|
-
}
|
|
655
|
-
return;
|
|
656
|
-
}
|
|
657
|
-
if (!mode && input.startsWith("$(", start) && !input.startsWith("$((", start))
|
|
658
|
-
return bashDelimited(input, start + 1, depth);
|
|
659
|
-
if (!mode && /^\$\{[ \t\n|]/.test(input.slice(start))) {
|
|
660
|
-
const nested = bashDelimited(input, start + 1, depth);
|
|
661
|
-
if (!nested)
|
|
662
|
-
return;
|
|
663
|
-
return { ...nested, source: nested.source.startsWith("|") ? nested.source.slice(1) : nested.source };
|
|
664
|
-
}
|
|
665
|
-
const kind = mode ?? (input[start + 1] === "{" ? "parameter" : input[start + 1] === "[" ? "subscript" : "arithmetic");
|
|
666
|
-
const arithmetic = ["arithmetic", "arithmetic-group", "subscript"].includes(kind);
|
|
667
|
-
const offset = mode ? kind === "heredoc" ? 0 : kind === "arithmetic" || kind === "test" ? 2 : 1 : kind === "arithmetic" ? 3 : 2;
|
|
668
|
-
const close = kind === "heredoc" ? undefined : kind === "double" ? '"' : kind === "parameter" ? "}" : kind === "subscript" ? "]" : kind === "test" ? "]]" : kind === "arithmetic" ? "))" : ")";
|
|
669
|
-
const substitutions = [];
|
|
670
|
-
for (let index = start + offset;index < input.length; index++) {
|
|
1230
|
+
function scanBashArrayOrPattern(input, start, depth, context, commands, mode) {
|
|
1231
|
+
if (depth > MAX_SUBSTITUTION_DEPTH)
|
|
1232
|
+
return { kind: "opaque", reason: "command-substitution" };
|
|
1233
|
+
const text = mode === "array" ? bashText() : undefined;
|
|
1234
|
+
let wordStarted = false;
|
|
1235
|
+
for (let index = start + 1;index < input.length; index++) {
|
|
1236
|
+
if (--context.remaining < 0)
|
|
1237
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
671
1238
|
const char = input[index];
|
|
672
|
-
if (
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
if (kind !== "heredoc" && kind !== "double" || '$`\\\n"'.includes(input[index + 1] ?? "\x00"))
|
|
676
|
-
index++;
|
|
1239
|
+
if (char === "\\" && input[index + 1] === `
|
|
1240
|
+
`) {
|
|
1241
|
+
index++;
|
|
677
1242
|
continue;
|
|
678
1243
|
}
|
|
679
|
-
if ((char === "
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
continue;
|
|
1244
|
+
if (text && (char === ")" || char === " " || char === "\t" || char === `
|
|
1245
|
+
`)) {
|
|
1246
|
+
bashEvaluatesExpansion(text, "deferred", context);
|
|
1247
|
+
text.literal = "";
|
|
1248
|
+
text.output = "";
|
|
685
1249
|
}
|
|
686
|
-
if (char ===
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
if (char === "`" || char === "$" && "({[".includes(input[index + 1] ?? "\x00")) {
|
|
695
|
-
const nested = bashExpansion(input, index, depth + 1, undefined, kind === "double" || quoted);
|
|
696
|
-
if (!nested)
|
|
697
|
-
return;
|
|
698
|
-
substitutions.push(...nested.substitutions ?? [nested.source]);
|
|
699
|
-
index = nested.end;
|
|
700
|
-
continue;
|
|
701
|
-
}
|
|
702
|
-
if ((kind === "array" && "<>=".includes(char) || kind === "test" && "<>".includes(char)) && input[index + 1] === "(") {
|
|
703
|
-
const nested = bashDelimited(input, index + 1, depth + 1);
|
|
704
|
-
if (!nested)
|
|
705
|
-
return;
|
|
706
|
-
substitutions.push(nested.source);
|
|
707
|
-
index = nested.end;
|
|
1250
|
+
if (char === ")")
|
|
1251
|
+
return index;
|
|
1252
|
+
if (mode === "array" && !wordStarted && char === "#") {
|
|
1253
|
+
const newline = input.indexOf(`
|
|
1254
|
+
`, index);
|
|
1255
|
+
if (newline < 0)
|
|
1256
|
+
return { kind: "opaque", reason: "command-substitution" };
|
|
1257
|
+
index = newline;
|
|
708
1258
|
continue;
|
|
709
1259
|
}
|
|
710
|
-
if (
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
return;
|
|
714
|
-
substitutions.push(...nested.substitutions);
|
|
715
|
-
index = nested.end;
|
|
1260
|
+
if (char === " " || char === "\t" || mode === "array" && char === `
|
|
1261
|
+
`) {
|
|
1262
|
+
wordStarted = false;
|
|
716
1263
|
continue;
|
|
717
1264
|
}
|
|
718
|
-
if (
|
|
719
|
-
|
|
1265
|
+
if (char === `
|
|
1266
|
+
` || char === ";" || char === "&" || mode === "array" && "|(".includes(char))
|
|
1267
|
+
return { kind: "opaque", reason: "command-substitution" };
|
|
1268
|
+
wordStarted = true;
|
|
1269
|
+
const unit = mode === "array" && char === "=" && input[index + 1] === "(" ? scanBashNested(input, index + 2, depth, context, commands, ")") : char === "(" ? scanBashArrayOrPattern(input, index, depth + 1, context, commands, mode) : char === "[" ? scanBashSubscript(input, index + 1, depth, context, commands) : scanBashUnit(input, index, depth, context, commands, "word", false, text);
|
|
1270
|
+
if (typeof unit === "object")
|
|
1271
|
+
return unit;
|
|
1272
|
+
if (unit !== undefined)
|
|
1273
|
+
index = unit;
|
|
1274
|
+
else if (text)
|
|
1275
|
+
text.literal += char;
|
|
720
1276
|
}
|
|
721
|
-
|
|
722
|
-
return { source: input.slice(start), end: input.length - 1, substitutions };
|
|
1277
|
+
return { kind: "opaque", reason: "command-substitution" };
|
|
723
1278
|
}
|
|
724
1279
|
function bashAnsiQuote(input, start) {
|
|
725
1280
|
let value = "";
|
|
@@ -731,58 +1286,45 @@ function bashAnsiQuote(input, start) {
|
|
|
731
1286
|
continue;
|
|
732
1287
|
}
|
|
733
1288
|
const escaped = input[++index];
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
f: "\f",
|
|
740
|
-
n: `
|
|
741
|
-
`,
|
|
742
|
-
r: "\r",
|
|
743
|
-
t: "\t",
|
|
744
|
-
v: "\v",
|
|
745
|
-
"\\": "\\",
|
|
746
|
-
"'": "'",
|
|
747
|
-
'"': '"',
|
|
748
|
-
"?": "?"
|
|
749
|
-
};
|
|
750
|
-
if (escaped in simple)
|
|
751
|
-
value += simple[escaped];
|
|
752
|
-
else if (escaped === "c" && index + 1 < input.length)
|
|
753
|
-
value += String.fromCharCode(input[++index].toUpperCase().charCodeAt(0) & 31);
|
|
754
|
-
else {
|
|
755
|
-
const digits = escaped === "x" ? /^[\da-fA-F]{1,2}/.exec(input.slice(index + 1))?.[0] : escaped === "u" ? /^[\da-fA-F]{1,4}/.exec(input.slice(index + 1))?.[0] : escaped === "U" ? /^[\da-fA-F]{1,8}/.exec(input.slice(index + 1))?.[0] : /[0-7]/.test(escaped ?? "") ? /^[0-7]{1,3}/.exec(input.slice(index))?.[0] : undefined;
|
|
756
|
-
if (!digits)
|
|
757
|
-
value += `\\${escaped}`;
|
|
758
|
-
else {
|
|
759
|
-
const octal = /[0-7]/.test(escaped);
|
|
760
|
-
const point = parseInt(digits, octal ? 8 : 16);
|
|
761
|
-
value += point <= 1114111 ? String.fromCodePoint(point) : "";
|
|
762
|
-
index += digits.length - (octal ? 1 : 0);
|
|
763
|
-
}
|
|
1289
|
+
if (escaped === undefined)
|
|
1290
|
+
return;
|
|
1291
|
+
if (escaped in BASH_ANSI_ESCAPES) {
|
|
1292
|
+
value += BASH_ANSI_ESCAPES[escaped];
|
|
1293
|
+
continue;
|
|
764
1294
|
}
|
|
1295
|
+
const digits = escaped === "x" ? /^[\da-fA-F]{1,2}/.exec(input.slice(index + 1, index + 3))?.[0] : /[0-7]/.test(escaped) ? /^[0-7]{1,3}/.exec(input.slice(index, index + 3))?.[0] : undefined;
|
|
1296
|
+
if (!digits)
|
|
1297
|
+
return;
|
|
1298
|
+
const octal = /[0-7]/.test(escaped);
|
|
1299
|
+
const point = parseInt(digits, octal ? 8 : 16);
|
|
1300
|
+
if (point === 0)
|
|
1301
|
+
return;
|
|
1302
|
+
value += String.fromCodePoint(point);
|
|
1303
|
+
index += digits.length - (octal ? 1 : 0);
|
|
765
1304
|
}
|
|
766
1305
|
}
|
|
767
|
-
function bashHeredocDelimiter(input, start) {
|
|
768
|
-
const tabs = input[start + 2] === "-";
|
|
1306
|
+
function bashHeredocDelimiter(input, start, tabs) {
|
|
769
1307
|
let delimiter = "";
|
|
1308
|
+
let dashDelimiter;
|
|
770
1309
|
let quoted = false;
|
|
771
1310
|
let quote;
|
|
772
1311
|
let end = start;
|
|
773
1312
|
let started = false;
|
|
774
|
-
for (let index = start
|
|
1313
|
+
for (let index = start;index < input.length; index++) {
|
|
775
1314
|
const char = input[index];
|
|
776
1315
|
if (!started && /[ \t]/.test(char))
|
|
777
1316
|
continue;
|
|
778
1317
|
if (!started && char === "#")
|
|
779
1318
|
return;
|
|
780
1319
|
if (!quote && /[ \t\n;&|()<>]/.test(char))
|
|
781
|
-
return started ? { delimiter, quoted, tabs, end } : undefined;
|
|
1320
|
+
return started ? { delimiter, dashDelimiter, quoted, tabs, end } : undefined;
|
|
1321
|
+
if (!quote && char === "$" && input.startsWith("\\\n", index + 1))
|
|
1322
|
+
return;
|
|
782
1323
|
if (!quote && input.startsWith("$'", index)) {
|
|
783
1324
|
const literal = bashAnsiQuote(input, index + 1);
|
|
784
|
-
if (!literal)
|
|
1325
|
+
if (!literal || literal.end !== input.indexOf("'", index + 2))
|
|
785
1326
|
return;
|
|
1327
|
+
dashDelimiter = `${dashDelimiter ?? delimiter}$${input.slice(index + 2, literal.end)}`;
|
|
786
1328
|
delimiter += literal.value;
|
|
787
1329
|
quoted = true;
|
|
788
1330
|
started = true;
|
|
@@ -790,13 +1332,8 @@ function bashHeredocDelimiter(input, start) {
|
|
|
790
1332
|
end = index;
|
|
791
1333
|
continue;
|
|
792
1334
|
}
|
|
793
|
-
if (!quote && input.startsWith('$"', index))
|
|
794
|
-
|
|
795
|
-
quoted = true;
|
|
796
|
-
started = true;
|
|
797
|
-
end = ++index;
|
|
798
|
-
continue;
|
|
799
|
-
}
|
|
1335
|
+
if (!quote && input.startsWith('$"', index))
|
|
1336
|
+
return;
|
|
800
1337
|
if (char === quote) {
|
|
801
1338
|
quote = undefined;
|
|
802
1339
|
end = index;
|
|
@@ -814,7 +1351,10 @@ function bashHeredocDelimiter(input, start) {
|
|
|
814
1351
|
if (!quote || '$`"\\'.includes(next)) {
|
|
815
1352
|
quoted = true;
|
|
816
1353
|
started = true;
|
|
817
|
-
|
|
1354
|
+
const escaped = input[++index];
|
|
1355
|
+
if (dashDelimiter !== undefined)
|
|
1356
|
+
dashDelimiter += escaped;
|
|
1357
|
+
delimiter += escaped;
|
|
818
1358
|
end = index;
|
|
819
1359
|
continue;
|
|
820
1360
|
}
|
|
@@ -826,31 +1366,47 @@ function bashHeredocDelimiter(input, start) {
|
|
|
826
1366
|
end = index;
|
|
827
1367
|
continue;
|
|
828
1368
|
}
|
|
1369
|
+
if (dashDelimiter !== undefined)
|
|
1370
|
+
dashDelimiter += char;
|
|
829
1371
|
delimiter += char;
|
|
830
1372
|
started = true;
|
|
831
1373
|
end = index;
|
|
832
1374
|
}
|
|
833
1375
|
if (started && !quote)
|
|
834
|
-
return { delimiter, quoted, tabs, end };
|
|
1376
|
+
return { delimiter, dashDelimiter, quoted, tabs, end };
|
|
835
1377
|
}
|
|
836
1378
|
function bashHeredoc(input, start, delimiter) {
|
|
837
1379
|
const bodyStart = start;
|
|
838
1380
|
let lineStart = start;
|
|
839
1381
|
let line = "";
|
|
1382
|
+
let backslashes = 0;
|
|
840
1383
|
for (let index = start;index <= input.length; index++) {
|
|
841
1384
|
if (index < input.length && input[index] !== `
|
|
842
1385
|
`)
|
|
843
1386
|
continue;
|
|
844
|
-
const text = input.slice(start, index);
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
1387
|
+
const text = delimiter.tabs && start === lineStart ? input.slice(start, index).replace(/^\t+/, "") : input.slice(start, index);
|
|
1388
|
+
let run = 0;
|
|
1389
|
+
while (text[text.length - 1 - run] === "\\")
|
|
1390
|
+
run++;
|
|
1391
|
+
backslashes = run === text.length ? backslashes + run : run;
|
|
1392
|
+
const continued = !delimiter.quoted && backslashes % 2 === 1 && index < input.length;
|
|
1393
|
+
const maxLength = Math.max(delimiter.delimiter.length, delimiter.dashDelimiter?.length ?? 0);
|
|
1394
|
+
if (line.length <= maxLength)
|
|
1395
|
+
line += continued ? text.slice(0, -1) : text;
|
|
1396
|
+
if (continued) {
|
|
1397
|
+
backslashes--;
|
|
848
1398
|
start = index + 1;
|
|
849
1399
|
continue;
|
|
850
1400
|
}
|
|
851
|
-
if (line === delimiter.
|
|
1401
|
+
if (delimiter.dashDelimiter !== undefined && line === delimiter.dashDelimiter)
|
|
1402
|
+
return;
|
|
1403
|
+
if (line === delimiter.delimiter) {
|
|
1404
|
+
if (start > lineStart && input.slice(index + 1).includes(delimiter.delimiter))
|
|
1405
|
+
return;
|
|
852
1406
|
return { source: input.slice(bodyStart, lineStart), end: index };
|
|
1407
|
+
}
|
|
853
1408
|
line = "";
|
|
1409
|
+
backslashes = 0;
|
|
854
1410
|
start = index + 1;
|
|
855
1411
|
lineStart = start;
|
|
856
1412
|
}
|