@opencode/core 2.2.2 → 2.2.3
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 +91 -91
- package/dist/aisdk-native.js +101 -101
- package/dist/aisdk.js +107 -107
- package/dist/app.js +9 -9
- package/dist/bus.js +83 -83
- package/dist/chunks/usage-limits-034tev2y.js +43 -0
- package/dist/chunks/usage-limits-03mq5jdz.js +377 -0
- package/dist/chunks/usage-limits-04p08dea.js +283 -0
- package/dist/chunks/usage-limits-0885wsjc.js +65 -0
- package/dist/chunks/usage-limits-0d2428b6.js +215 -0
- package/dist/chunks/usage-limits-0ek446ey.js +95 -0
- package/dist/chunks/usage-limits-0m8chefa.js +173 -0
- package/dist/chunks/usage-limits-0weke1bx.js +664 -0
- package/dist/chunks/usage-limits-0xzgxfq0.js +84 -0
- package/dist/chunks/usage-limits-0z6v00n2.js +74 -0
- package/dist/chunks/usage-limits-114c099t.js +348 -0
- package/dist/chunks/usage-limits-161gdnzb.js +149 -0
- package/dist/chunks/usage-limits-1aqsckx4.js +19 -0
- package/dist/chunks/usage-limits-1ep2p91f.js +18 -0
- package/dist/chunks/usage-limits-1j0ttc0k.js +325 -0
- package/dist/chunks/usage-limits-1w61pkx2.js +103 -0
- package/dist/chunks/usage-limits-1x2knyw4.js +42 -0
- package/dist/chunks/usage-limits-20pht57w.js +40 -0
- package/dist/chunks/usage-limits-23yt1abd.js +123 -0
- package/dist/chunks/usage-limits-25h84942.js +17 -0
- package/dist/chunks/usage-limits-2862kdgf.js +489 -0
- package/dist/chunks/usage-limits-29g8zhjy.js +41 -0
- package/dist/chunks/usage-limits-2bsm227b.js +54 -0
- package/dist/chunks/usage-limits-2bswbpgz.js +37 -0
- package/dist/chunks/usage-limits-2p60zmnr.js +90 -0
- package/dist/chunks/usage-limits-2q0ftwq8.js +416 -0
- package/dist/chunks/usage-limits-2qxqxxnw.js +247 -0
- package/dist/chunks/usage-limits-2ssyd3bd.js +177 -0
- package/dist/chunks/usage-limits-2y95b060.js +34 -0
- package/dist/chunks/usage-limits-388adpjt.js +197 -0
- package/dist/chunks/usage-limits-3a9e2hp9.js +142 -0
- package/dist/chunks/usage-limits-3cn1nqds.js +89 -0
- package/dist/chunks/usage-limits-3hepkmqq.js +13 -0
- package/dist/chunks/usage-limits-3nnc7tm4.js +247 -0
- package/dist/chunks/usage-limits-3nnrz6f6.js +13 -0
- package/dist/chunks/usage-limits-40y6dtc2.js +175 -0
- package/dist/chunks/usage-limits-44pmzq9c.js +41 -0
- package/dist/chunks/usage-limits-474t0jp4.js +79 -0
- package/dist/chunks/usage-limits-49xxf483.js +121 -0
- package/dist/chunks/usage-limits-4d2dtj2f.js +31 -0
- package/dist/chunks/usage-limits-4dx1dgte.js +16 -0
- package/dist/chunks/usage-limits-4h9sjm86.js +224 -0
- package/dist/chunks/usage-limits-4peydfvx.js +207 -0
- package/dist/chunks/usage-limits-4pyp9zr9.js +63 -0
- package/dist/chunks/usage-limits-4qk9sjk2.js +9 -0
- package/dist/chunks/usage-limits-4v008n1t.js +13 -0
- package/dist/chunks/usage-limits-500yw4m2.js +182 -0
- package/dist/chunks/usage-limits-58h557c0.js +36 -0
- package/dist/chunks/usage-limits-5a543fyv.js +378 -0
- package/dist/chunks/usage-limits-5bcsk9b3.js +257 -0
- package/dist/chunks/usage-limits-5cwm0vrb.js +75 -0
- package/dist/chunks/usage-limits-5ekpk5gk.js +133 -0
- package/dist/chunks/usage-limits-5k9ccchm.js +238 -0
- package/dist/chunks/usage-limits-5m9w47nd.js +21 -0
- package/dist/chunks/usage-limits-5n0rnk8e.js +31 -0
- package/dist/chunks/usage-limits-5vty935g.js +37 -0
- package/dist/chunks/usage-limits-60a1dn3c.js +71 -0
- package/dist/chunks/usage-limits-60mrzfj0.js +49 -0
- package/dist/chunks/usage-limits-668rppz5.js +97 -0
- package/dist/chunks/usage-limits-67zhfnr5.js +75 -0
- package/dist/chunks/usage-limits-68ps1td5.js +748 -0
- package/dist/chunks/usage-limits-693ajvae.js +443 -0
- package/dist/chunks/usage-limits-694dpcrp.js +55 -0
- package/dist/chunks/usage-limits-6dtxpht2.js +201 -0
- package/dist/chunks/usage-limits-6er5y2fs.js +163 -0
- package/dist/chunks/usage-limits-6esdw8yj.js +34 -0
- package/dist/chunks/usage-limits-6h8vcvjm.js +53 -0
- package/dist/chunks/usage-limits-6wg1qg5c.js +96 -0
- package/dist/chunks/usage-limits-6ztqv1pd.js +183 -0
- package/dist/chunks/usage-limits-76mdcqjq.js +792 -0
- package/dist/chunks/usage-limits-774q7b2v.js +388 -0
- package/dist/chunks/usage-limits-775hqbnd.js +34 -0
- package/dist/chunks/usage-limits-7a3ts1e5.js +81 -0
- package/dist/chunks/usage-limits-7ass9zk5.js +52 -0
- package/dist/chunks/usage-limits-7bmhse3q.js +118 -0
- package/dist/chunks/usage-limits-7dz1b5qc.js +180 -0
- package/dist/chunks/usage-limits-7fhwv4x0.js +38 -0
- package/dist/chunks/usage-limits-7gp52k32.js +342 -0
- package/dist/chunks/usage-limits-7hxch2qy.js +35 -0
- package/dist/chunks/usage-limits-7kr66rt3.js +2158 -0
- package/dist/chunks/usage-limits-7w2ypzdf.js +62 -0
- package/dist/chunks/usage-limits-7y2j04q1.js +97 -0
- package/dist/chunks/usage-limits-80vrve0e.js +107 -0
- package/dist/chunks/usage-limits-84ce92z0.js +140 -0
- package/dist/chunks/usage-limits-89287pr7.js +78 -0
- package/dist/chunks/usage-limits-8g0jpqzw.js +68 -0
- package/dist/chunks/usage-limits-8hdxb4rm.js +71 -0
- package/dist/chunks/usage-limits-8j99vdm2.js +407 -0
- package/dist/chunks/usage-limits-8n2zw19c.js +123 -0
- package/dist/chunks/usage-limits-8r6p5f50.js +258 -0
- package/dist/chunks/usage-limits-8rsvvp9m.js +166 -0
- package/dist/chunks/usage-limits-8s96kadw.js +173 -0
- package/dist/chunks/usage-limits-8srhw74s.js +44 -0
- package/dist/chunks/usage-limits-8v3021e0.js +710 -0
- package/dist/chunks/usage-limits-8wtp7s3z.js +14 -0
- package/dist/chunks/usage-limits-8ww20s18.js +126 -0
- package/dist/chunks/usage-limits-8zqj3j1k.js +213 -0
- package/dist/chunks/usage-limits-902cdbxm.js +351 -0
- package/dist/chunks/usage-limits-90zstvax.js +129 -0
- package/dist/chunks/usage-limits-941ns1g4.js +125 -0
- package/dist/chunks/usage-limits-94v1enck.js +90 -0
- package/dist/chunks/usage-limits-95sp4hdf.js +26 -0
- package/dist/chunks/usage-limits-99yjq7qb.js +171 -0
- package/dist/chunks/usage-limits-9cgtp5bz.js +336 -0
- package/dist/chunks/usage-limits-9daenajy.js +162 -0
- package/dist/chunks/usage-limits-9eh6sf6d.js +185 -0
- package/dist/chunks/usage-limits-9jq890y0.js +187 -0
- package/dist/chunks/usage-limits-9nkjg9qd.js +20 -0
- package/dist/chunks/usage-limits-9xe88z92.js +201 -0
- package/dist/chunks/usage-limits-9xnvtjrj.js +868 -0
- package/dist/chunks/usage-limits-a3r2a0ar.js +539 -0
- package/dist/chunks/usage-limits-a3v55ybv.js +120 -0
- package/dist/chunks/usage-limits-ar4q0bdv.js +444 -0
- package/dist/chunks/usage-limits-avg4aq00.js +279 -0
- package/dist/chunks/usage-limits-ax5y7az6.js +116 -0
- package/dist/chunks/usage-limits-ayjs7tqn.js +17 -0
- package/dist/chunks/usage-limits-b0gnbynm.js +31 -0
- package/dist/chunks/usage-limits-b41wgt7r.js +278 -0
- package/dist/chunks/usage-limits-b4zj633n.js +465 -0
- package/dist/chunks/usage-limits-b6vsg801.js +406 -0
- package/dist/chunks/usage-limits-b7a7zv4d.js +94 -0
- package/dist/chunks/usage-limits-b8mknwc7.js +98 -0
- package/dist/chunks/usage-limits-b9a8fgmc.js +224 -0
- package/dist/chunks/usage-limits-b9qn7d7q.js +37 -0
- package/dist/chunks/usage-limits-bda3esj3.js +200 -0
- package/dist/chunks/usage-limits-bmphwkmb.js +118 -0
- package/dist/chunks/usage-limits-bpj7e5pf.js +139 -0
- package/dist/chunks/usage-limits-bstexjd6.js +175 -0
- package/dist/chunks/usage-limits-bx8w4fye.js +587 -0
- package/dist/chunks/usage-limits-bypbe432.js +86 -0
- package/dist/chunks/usage-limits-bzp09gqc.js +43 -0
- package/dist/chunks/usage-limits-c26bh0y8.js +379 -0
- package/dist/chunks/usage-limits-c4cws4p8.js +52 -0
- package/dist/chunks/usage-limits-ccjxwn3d.js +22 -0
- package/dist/chunks/usage-limits-cta89apb.js +311 -0
- package/dist/chunks/usage-limits-cwrgdav8.js +83 -0
- package/dist/chunks/usage-limits-cwz64wqk.js +186 -0
- package/dist/chunks/usage-limits-cx6jnjd2.js +42 -0
- package/dist/chunks/usage-limits-cy8gb27n.js +400 -0
- package/dist/chunks/usage-limits-d1vch9mx.js +1332 -0
- package/dist/chunks/usage-limits-d4ftrgr2.js +313 -0
- package/dist/chunks/usage-limits-d4v9tmah.js +25 -0
- package/dist/chunks/usage-limits-d8nyttsp.js +7 -0
- package/dist/chunks/usage-limits-da6a8czh.js +33 -0
- package/dist/chunks/usage-limits-dm1b1mmt.js +200 -0
- package/dist/chunks/usage-limits-dmwpx947.js +123 -0
- package/dist/chunks/usage-limits-dpqc1c18.js +82 -0
- package/dist/chunks/usage-limits-dt77769w.js +53 -0
- package/dist/chunks/usage-limits-e2btc9sx.js +227 -0
- package/dist/chunks/usage-limits-e2rhb6tw.js +102 -0
- package/dist/chunks/usage-limits-e3hd0enn.js +38 -0
- package/dist/chunks/usage-limits-e5r74ts4.js +35 -0
- package/dist/chunks/usage-limits-e834z07m.js +50 -0
- package/dist/chunks/usage-limits-e8pm465n.js +41 -0
- package/dist/chunks/usage-limits-eayabys9.js +63 -0
- package/dist/chunks/usage-limits-egzae5dw.js +226 -0
- package/dist/chunks/usage-limits-ejsdfd4v.js +134 -0
- package/dist/chunks/usage-limits-en6c2g1y.js +46 -0
- package/dist/chunks/usage-limits-eqw4pqj1.js +48 -0
- package/dist/chunks/usage-limits-evr76v84.js +94 -0
- package/dist/chunks/usage-limits-ewezx4md.js +261 -0
- package/dist/chunks/usage-limits-ezna1kdx.js +18 -0
- package/dist/chunks/usage-limits-f2kytvwy.js +42 -0
- package/dist/chunks/usage-limits-f5d5a401.js +58 -0
- package/dist/chunks/usage-limits-f6p21kdy.js +157 -0
- package/dist/chunks/usage-limits-feqecrca.js +362 -0
- package/dist/chunks/usage-limits-fffv3p7h.js +143 -0
- package/dist/chunks/usage-limits-fg9p65nk.js +37 -0
- package/dist/chunks/usage-limits-fjz66g9m.js +83 -0
- package/dist/chunks/usage-limits-g8wef12p.js +184 -0
- package/dist/chunks/usage-limits-g9czakeh.js +122 -0
- package/dist/chunks/usage-limits-gbjdnr5j.js +72 -0
- package/dist/chunks/usage-limits-gdaxappr.js +272 -0
- package/dist/chunks/usage-limits-gqnkkt2t.js +201 -0
- package/dist/chunks/usage-limits-h075eahz.js +43 -0
- package/dist/chunks/usage-limits-h5zbxgdz.js +147 -0
- package/dist/chunks/usage-limits-h7zpsm02.js +99 -0
- package/dist/chunks/usage-limits-hh7kjqtw.js +66 -0
- package/dist/chunks/usage-limits-hkq0605p.js +214 -0
- package/dist/chunks/usage-limits-hnsyj4wy.js +126 -0
- package/dist/chunks/usage-limits-hpg1pkwy.js +20 -0
- package/dist/chunks/usage-limits-htq0fyv1.js +110 -0
- package/dist/chunks/usage-limits-hv71va99.js +26 -0
- package/dist/chunks/usage-limits-hyc87431.js +241 -0
- package/dist/chunks/usage-limits-j38jzfz7.js +36 -0
- package/dist/chunks/usage-limits-j40zgs96.js +40 -0
- package/dist/chunks/usage-limits-j79p8763.js +128 -0
- package/dist/chunks/usage-limits-j9nxzz3g.js +107 -0
- package/dist/chunks/usage-limits-jaq18jgp.js +16 -0
- package/dist/chunks/usage-limits-jcxymc27.js +141 -0
- package/dist/chunks/usage-limits-jj2gwtr5.js +115 -0
- package/dist/chunks/usage-limits-jnc77vb7.js +537 -0
- package/dist/chunks/usage-limits-jq3a00x6.js +544 -0
- package/dist/chunks/usage-limits-jtnps1zs.js +154 -0
- package/dist/chunks/usage-limits-jwv04pkk.js +42 -0
- package/dist/chunks/usage-limits-k0dvq0p8.js +62 -0
- package/dist/chunks/usage-limits-k0sc0549.js +355 -0
- package/dist/chunks/usage-limits-k20abjym.js +97 -0
- package/dist/chunks/usage-limits-k2m4hrdy.js +579 -0
- package/dist/chunks/usage-limits-k382atqt.js +167 -0
- package/dist/chunks/usage-limits-k3cx6fhe.js +82 -0
- package/dist/chunks/usage-limits-k4n5rdea.js +90 -0
- package/dist/chunks/usage-limits-k93tcc60.js +235 -0
- package/dist/chunks/usage-limits-kb2zgvc1.js +148 -0
- package/dist/chunks/usage-limits-kg6t11tp.js +75 -0
- package/dist/chunks/usage-limits-kh70vamz.js +544 -0
- package/dist/chunks/usage-limits-kt3bjfbg.js +26 -0
- package/dist/chunks/usage-limits-ktf6v6ad.js +348 -0
- package/dist/chunks/usage-limits-kzj6t2v8.js +72 -0
- package/dist/chunks/usage-limits-m027q5yz.js +135 -0
- package/dist/chunks/usage-limits-m0db3c0y.js +73 -0
- package/dist/chunks/usage-limits-m1714858.js +39 -0
- package/dist/chunks/usage-limits-m219wbpy.js +72 -0
- package/dist/chunks/usage-limits-m6e4v83y.js +56 -0
- package/dist/chunks/usage-limits-m8tca5a1.js +137 -0
- package/dist/chunks/usage-limits-m979knme.js +49 -0
- package/dist/chunks/usage-limits-m9w0rfyh.js +123 -0
- package/dist/chunks/usage-limits-mam087a8.js +51 -0
- package/dist/chunks/usage-limits-marjhpxb.js +368 -0
- package/dist/chunks/usage-limits-mb7mbhnz.js +133 -0
- package/dist/chunks/usage-limits-mbr47c0q.js +291 -0
- package/dist/chunks/usage-limits-mkvajvdj.js +38 -0
- package/dist/chunks/usage-limits-mqt5h58n.js +108 -0
- package/dist/chunks/usage-limits-mrpnjyvf.js +450 -0
- package/dist/chunks/usage-limits-msd2a3qm.js +164 -0
- package/dist/chunks/usage-limits-mvt4g508.js +49 -0
- package/dist/chunks/usage-limits-mw5z1gck.js +111 -0
- package/dist/chunks/usage-limits-mz94qrfz.js +75 -0
- package/dist/chunks/usage-limits-n9y0vfz9.js +128 -0
- package/dist/chunks/usage-limits-nah043kf.js +42 -0
- package/dist/chunks/usage-limits-ndw3w55s.js +35 -0
- package/dist/chunks/usage-limits-nmbybfz1.js +63 -0
- package/dist/chunks/usage-limits-nmwft8kx.js +80 -0
- package/dist/chunks/usage-limits-npn7q6je.js +377 -0
- package/dist/chunks/usage-limits-nyxvvj5y.js +49 -0
- package/dist/chunks/usage-limits-p015t6z3.js +38 -0
- package/dist/chunks/usage-limits-p2n9dgry.js +319 -0
- package/dist/chunks/usage-limits-p7vhpwh8.js +16 -0
- package/dist/chunks/usage-limits-pav9knxy.js +184 -0
- package/dist/chunks/usage-limits-pc7ssjbc.js +96 -0
- package/dist/chunks/usage-limits-pcx93rbs.js +668 -0
- package/dist/chunks/usage-limits-pf1y59er.js +101 -0
- package/dist/chunks/usage-limits-pknna89w.js +18 -0
- package/dist/chunks/usage-limits-q1nnka74.js +31 -0
- package/dist/chunks/usage-limits-q9sn4ddb.js +611 -0
- package/dist/chunks/usage-limits-qbh9qxse.js +331 -0
- package/dist/chunks/usage-limits-qft8hb75.js +21 -0
- package/dist/chunks/usage-limits-qj1k32xn.js +258 -0
- package/dist/chunks/usage-limits-qkt7tgv5.js +107 -0
- package/dist/chunks/usage-limits-qp5navez.js +343 -0
- package/dist/chunks/usage-limits-qp7r0hxv.js +120 -0
- package/dist/chunks/usage-limits-qqaph24h.js +262 -0
- package/dist/chunks/usage-limits-qqvy8y24.js +45 -0
- package/dist/chunks/usage-limits-qsrr0pb2.js +226 -0
- package/dist/chunks/usage-limits-qv7a899h.js +113 -0
- package/dist/chunks/usage-limits-qzk2n153.js +31 -0
- package/dist/chunks/usage-limits-r0vy810z.js +282 -0
- package/dist/chunks/usage-limits-r542h3bh.js +54 -0
- package/dist/chunks/usage-limits-rb9dy4dg.js +116 -0
- package/dist/chunks/usage-limits-rca9n2n2.js +80 -0
- package/dist/chunks/usage-limits-rf9654yx.js +221 -0
- package/dist/chunks/usage-limits-rhzn93nm.js +106 -0
- package/dist/chunks/usage-limits-rp2cm5ts.js +94 -0
- package/dist/chunks/usage-limits-rt5dr6hb.js +14 -0
- package/dist/chunks/usage-limits-s4y30yy0.js +182 -0
- package/dist/chunks/usage-limits-s731tgr5.js +552 -0
- package/dist/chunks/usage-limits-sa3fpqfw.js +46 -0
- package/dist/chunks/usage-limits-sbya78hr.js +67 -0
- package/dist/chunks/usage-limits-sc35yb2g.js +148 -0
- package/dist/chunks/usage-limits-sqjzf8x2.js +41 -0
- package/dist/chunks/usage-limits-svcy3p9a.js +38 -0
- package/dist/chunks/usage-limits-szwm4crx.js +34 -0
- package/dist/chunks/usage-limits-tczq8hjw.js +25 -0
- package/dist/chunks/usage-limits-tg7s7b5t.js +39 -0
- package/dist/chunks/usage-limits-tnn0wdmp.js +48 -0
- package/dist/chunks/usage-limits-tr8x705m.js +22 -0
- package/dist/chunks/usage-limits-twssxy5n.js +170 -0
- package/dist/chunks/usage-limits-ty5qxp0p.js +66 -0
- package/dist/chunks/usage-limits-v2r1d0zg.js +86 -0
- package/dist/chunks/usage-limits-v5hpj9dd.js +32 -0
- package/dist/chunks/usage-limits-vb80j1wh.js +262 -0
- package/dist/chunks/usage-limits-vbttd8dk.js +126 -0
- package/dist/chunks/usage-limits-vek77fn1.js +410 -0
- package/dist/chunks/usage-limits-vfbg1mpw.js +357 -0
- package/dist/chunks/usage-limits-vgpm2vyx.js +184 -0
- package/dist/chunks/usage-limits-vjf35v1f.js +110 -0
- package/dist/chunks/usage-limits-vrcsa8qx.js +155 -0
- package/dist/chunks/usage-limits-vsqvcqta.js +59 -0
- package/dist/chunks/usage-limits-vt2d6wap.js +67 -0
- package/dist/chunks/usage-limits-w2eysc6j.js +64 -0
- package/dist/chunks/usage-limits-w35wzz9x.js +31 -0
- package/dist/chunks/usage-limits-w370kc95.js +50 -0
- package/dist/chunks/usage-limits-w3wsvvr9.js +80 -0
- package/dist/chunks/usage-limits-w6xtvkbn.js +198 -0
- package/dist/chunks/usage-limits-w8qtt4th.js +63 -0
- package/dist/chunks/usage-limits-wakvkjy4.js +79 -0
- package/dist/chunks/usage-limits-wd87259q.js +102 -0
- package/dist/chunks/usage-limits-wegkxhrn.js +37 -0
- package/dist/chunks/usage-limits-whck4r0n.js +72 -0
- package/dist/chunks/usage-limits-wnhgecwx.js +93 -0
- package/dist/chunks/usage-limits-wr3re1en.js +22 -0
- package/dist/chunks/usage-limits-xa14bxe7.js +88 -0
- package/dist/chunks/usage-limits-xcp7yafh.js +672 -0
- package/dist/chunks/usage-limits-xgtstc0b.js +347 -0
- package/dist/chunks/usage-limits-xmtg6xg5.js +181 -0
- package/dist/chunks/usage-limits-xpgtv4k5.js +156 -0
- package/dist/chunks/usage-limits-y1s46rby.js +70 -0
- package/dist/chunks/usage-limits-y3seyarw.js +597 -0
- package/dist/chunks/usage-limits-y5an59n2.js +284 -0
- package/dist/chunks/usage-limits-y5r9v80f.js +31 -0
- package/dist/chunks/usage-limits-y61545pt.js +111 -0
- package/dist/chunks/usage-limits-yara3q77.js +132 -0
- package/dist/chunks/usage-limits-yax7g9mp.js +96 -0
- package/dist/chunks/usage-limits-yb20nhc3.js +229 -0
- package/dist/chunks/usage-limits-yb21bz95.js +44 -0
- package/dist/chunks/usage-limits-yepgas63.js +81 -0
- package/dist/chunks/usage-limits-ymyp89gh.js +201 -0
- package/dist/chunks/usage-limits-ypj1acmt.js +28 -0
- package/dist/chunks/usage-limits-yqveydy6.js +18 -0
- package/dist/chunks/usage-limits-yr705xyq.js +17 -0
- package/dist/chunks/usage-limits-yy0ph7eq.js +61 -0
- package/dist/chunks/usage-limits-z1n4r95z.js +591 -0
- package/dist/chunks/usage-limits-z2xe5rth.js +93 -0
- package/dist/chunks/usage-limits-z7t8qjxt.js +236 -0
- package/dist/chunks/usage-limits-zmnc4hw2.js +51 -0
- package/dist/chunks/usage-limits-zpv6qa87.js +40 -0
- package/dist/chunks/usage-limits-zvgw15wn.js +921 -0
- package/dist/chunks/usage-limits-zzr7ewsq.js +104 -0
- package/dist/chunks/usage-limits-zzyrkxde.js +73 -0
- package/dist/codemode/catalog.js +1 -1
- package/dist/codemode/execution.js +8 -0
- package/dist/codemode/fetch.js +153 -0
- package/dist/codemode/instructions.js +7 -7
- package/dist/codemode/tool.js +156 -5
- package/dist/command.js +93 -93
- package/dist/config/discovery.js +96 -96
- package/dist/config/integration.js +13 -9
- package/dist/config/managed.js +8 -0
- package/dist/config/markdown.js +1 -1
- package/dist/config/normalize.js +111 -111
- package/dist/config/plugin/agent.js +131 -127
- package/dist/config/plugin/command.js +229 -225
- package/dist/config/plugin/compaction.js +170 -166
- package/dist/config/plugin/compatibility.js +149 -146
- package/dist/config/plugin/entry-observer.js +1 -1
- package/dist/config/plugin/formatter.js +130 -126
- package/dist/config/plugin/image.js +129 -125
- package/dist/config/plugin/instruction.js +129 -125
- package/dist/config/plugin/location-watcher.js +129 -125
- package/dist/config/plugin/mcp.js +138 -134
- package/dist/config/plugin/policy.js +129 -127
- package/dist/config/plugin/provider.js +131 -128
- package/dist/config/plugin/reference.js +131 -127
- package/dist/config/plugin/shell.js +129 -125
- package/dist/config/plugin/skill-file.js +145 -142
- package/dist/config/plugin/skill-scan.js +1 -1
- package/dist/config/plugin/skill.js +152 -149
- package/dist/config/plugin/snapshot.js +129 -125
- package/dist/config/plugin/source.js +132 -128
- package/dist/config/plugin/tool-output.js +130 -126
- package/dist/config/plugin/websearch.js +128 -124
- package/dist/config/plugin/worktree.js +131 -127
- package/dist/config/variable.js +1 -1
- package/dist/config/watch.js +1 -1
- package/dist/config.js +132 -128
- package/dist/console-access.js +1 -1
- package/dist/credential/sql.js +2 -2
- package/dist/credential.js +89 -89
- package/dist/database/database.js +78 -78
- 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/20261007190000_azure_cli_external_credential.js +1 -1
- package/dist/database/migration/20261010180456_project_time_archived.js +1 -1
- package/dist/database/migration/20261024002554_session_allowance.js +1 -1
- package/dist/database/migration/20261024175301_drop_session_allowance.js +1 -1
- package/dist/database/migration/20261025123711_blob.js +1 -1
- package/dist/database/migration/20261025154125_drop_session_pending.js +1 -1
- package/dist/database/migration/20261026223005_schedule.js +1 -1
- package/dist/database/migration/20261029002625_session_part.js +1 -1
- package/dist/database/migration/20261029073502_session_time_busy.js +1 -1
- package/dist/database/migration/20261029165540_schedule_checks.js +1 -1
- package/dist/database/migration.gen.js +59 -59
- package/dist/database/migration.js +61 -61
- 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 +107 -107
- package/dist/database/v1-migration.js +1 -1
- package/dist/effect/app-node-builder.js +424 -390
- 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 +105 -105
- package/dist/environment/exec-defaults.js +2 -2
- package/dist/environment/files.js +1 -1
- package/dist/environment/index.js +105 -105
- package/dist/environment/local.js +2 -2
- package/dist/environment/memory.js +2 -2
- package/dist/environment/unavailable.js +3 -3
- package/dist/event/sql.js +1 -1
- package/dist/event-logger.js +84 -84
- package/dist/file-access.js +155 -152
- package/dist/file-mutation.js +102 -102
- 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/file-watch.js +90 -90
- package/dist/filesystem/location-watcher-policy.js +6 -6
- package/dist/filesystem/location-watcher.js +240 -236
- package/dist/filesystem/protected.js +3 -3
- package/dist/filesystem/search.js +111 -111
- package/dist/filesystem/watcher-binding.js +3 -3
- package/dist/filesystem/watcher.js +11 -11
- package/dist/filesystem.js +116 -116
- package/dist/form.js +88 -88
- package/dist/formatter/builtins.js +4 -4
- package/dist/formatter.js +99 -99
- package/dist/generate.js +121 -121
- package/dist/git.js +11 -11
- 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 +105 -105
- 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/notice.js +1 -1
- package/dist/image/photon-normalize.js +1 -1
- package/dist/image/photon-worker.js +1 -1
- package/dist/image/photon.js +4 -4
- package/dist/image.js +6 -6
- package/dist/instance/service.js +5 -5
- package/dist/instance.js +415 -381
- package/dist/instruction-discovery.js +94 -94
- package/dist/instructions/builtins.js +99 -99
- package/dist/instructions/index.js +7 -5
- package/dist/integration/connection.js +3 -3
- package/dist/integration.js +97 -97
- package/dist/job.js +88 -88
- package/dist/kv/sql.js +2 -2
- package/dist/kv.js +83 -83
- package/dist/location-activity.js +173 -170
- package/dist/location-lifecycle.js +149 -146
- package/dist/location-service-map.js +98 -98
- package/dist/location-services.js +412 -378
- package/dist/location.js +101 -101
- package/dist/managed-policy.js +11 -3
- package/dist/mcp/client.js +103 -103
- package/dist/mcp/index.js +121 -121
- package/dist/mcp/instructions.js +176 -168
- package/dist/mcp/oauth.js +88 -88
- package/dist/mcp/socket-client.js +1 -1
- package/dist/mcp/stdio.js +102 -102
- package/dist/mime.js +1 -1
- package/dist/modal/models.js +105 -105
- package/dist/model-resolver.js +109 -109
- package/dist/model-retry.js +1 -1
- package/dist/model.js +110 -110
- package/dist/models-dev/v1.js +1 -1
- package/dist/models-dev.js +118 -118
- package/dist/oauth/page.js +1 -1
- package/dist/permission/saved.js +90 -90
- package/dist/permission/sql.js +5 -5
- package/dist/permission.js +152 -149
- package/dist/persistent-pty/binary.bun.js +1 -1
- package/dist/persistent-pty/daemon.js +1 -1
- package/dist/persistent-pty/index.js +100 -100
- package/dist/persistent-pty/pty-binding.js +1 -1
- package/dist/persistent-pty.js +85 -85
- package/dist/plugin/agent.js +86 -86
- package/dist/plugin/command.js +114 -114
- package/dist/plugin/goal.js +3 -3
- package/dist/plugin/hooks.js +7 -7
- package/dist/plugin/host.js +235 -231
- package/dist/plugin/identity.js +5 -5
- package/dist/plugin/instance.js +5 -5
- package/dist/plugin/internal.js +391 -357
- package/dist/plugin/mcp-codemode-defaults.js +3 -3
- package/dist/plugin/models-dev.js +109 -109
- package/dist/plugin/module.js +128 -127
- package/dist/plugin/optimize.js +4 -4
- package/dist/plugin/plan.js +145 -142
- package/dist/plugin/promise.js +1 -1
- package/dist/plugin/provider/amazon-bedrock.js +103 -103
- package/dist/plugin/provider/azure.js +129 -125
- package/dist/plugin/provider/cerebras.js +1 -1
- package/dist/plugin/provider/chatgpt.js +129 -125
- package/dist/plugin/provider/claude-agent/aisdk.js +121 -0
- package/dist/plugin/provider/claude-agent/claude/agent-sdk.js +2 -0
- package/dist/plugin/provider/claude-agent/claude/agent-sdk.workerd.js +2 -0
- package/dist/plugin/provider/claude-agent/claude/fork.js +9 -0
- package/dist/plugin/provider/claude-agent/claude/io.js +11 -0
- package/dist/plugin/provider/claude-agent/claude/probe.js +15 -0
- package/dist/plugin/provider/claude-agent/claude/query-options.js +15 -0
- package/dist/plugin/provider/claude-agent/claude/sdk.js +8 -0
- package/dist/plugin/provider/claude-agent/claude/session.js +11 -0
- package/dist/plugin/provider/claude-agent/claude/sessions.js +27 -0
- package/dist/plugin/provider/claude-agent/claude/status.js +14 -0
- package/dist/plugin/provider/claude-agent/index.js +151 -0
- package/dist/plugin/provider/claude-agent/instructions.js +116 -0
- package/dist/plugin/provider/claude-agent/integration.js +119 -0
- package/dist/plugin/provider/claude-agent/language-model/claude-agent-error.js +8 -0
- package/dist/plugin/provider/claude-agent/language-model/claude-agent-language-model.js +14 -0
- package/dist/plugin/provider/claude-agent/language-model/convert-claude-stream.js +11 -0
- package/dist/plugin/provider/claude-agent/language-model/convert-to-claude-message.js +8 -0
- package/dist/plugin/provider/claude-agent/language-model/request-kind.js +12 -0
- package/dist/plugin/provider/claude-agent/language-model/system-prompt.js +14 -0
- package/dist/plugin/provider/claude-agent/language-model/usage.js +8 -0
- package/dist/plugin/provider/claude-agent/provider.js +120 -0
- package/dist/plugin/provider/claude-agent/session.js +116 -0
- package/dist/plugin/provider/claude-agent/sync/catch-up.js +10 -0
- package/dist/plugin/provider/claude-agent/sync/checkpoints.js +9 -0
- package/dist/plugin/provider/claude-agent/sync/decide.js +11 -0
- package/dist/plugin/provider/claude-agent/sync/fingerprint.js +8 -0
- package/dist/plugin/provider/claude-agent/sync/record.js +8 -0
- package/dist/plugin/provider/claude-agent/tools/hooks.js +8 -0
- package/dist/plugin/provider/claude-agent/tools/names.js +14 -0
- package/dist/plugin/provider/claude-agent/tools/pending.js +8 -0
- package/dist/plugin/provider/claude-agent/tools/result.js +12 -0
- package/dist/plugin/provider/claude-agent/tools/server.js +9 -0
- package/dist/plugin/provider/cloudflare-ai-gateway.js +127 -123
- package/dist/plugin/provider/cloudflare-workers-ai.js +127 -123
- package/dist/plugin/provider/configured.js +125 -121
- package/dist/plugin/provider/credential-settings.js +84 -84
- package/dist/plugin/provider/databricks.js +1 -1
- package/dist/plugin/provider/digitalocean.js +105 -105
- package/dist/plugin/provider/dynamic.js +2 -2
- package/dist/plugin/provider/github-copilot.js +107 -107
- package/dist/plugin/provider/gitlab.js +106 -106
- package/dist/plugin/provider/google-vertex.js +126 -122
- package/dist/plugin/provider/kilo.js +1 -1
- package/dist/plugin/provider/llmgateway.js +88 -88
- package/dist/plugin/provider/lmstudio.js +138 -134
- package/dist/plugin/provider/local.js +135 -131
- package/dist/plugin/provider/modal.js +104 -104
- package/dist/plugin/provider/neon.js +1 -1
- package/dist/plugin/provider/nvidia.js +1 -1
- package/dist/plugin/provider/ollama.js +138 -134
- package/dist/plugin/provider/openai-context-caps.js +102 -102
- package/dist/plugin/provider/openai.js +131 -127
- package/dist/plugin/provider/opencode.js +131 -128
- package/dist/plugin/provider/openrouter.js +103 -103
- package/dist/plugin/provider/poe.js +89 -89
- package/dist/plugin/provider/prompt-cache-key.js +1 -1
- package/dist/plugin/provider/sap-ai-core.js +103 -103
- package/dist/plugin/provider/sdk-factory.js +1 -1
- package/dist/plugin/provider/snowflake-cortex.js +128 -124
- package/dist/plugin/provider/vllm.js +138 -134
- package/dist/plugin/provider/xai.js +103 -103
- package/dist/plugin/provider/zenmux.js +1 -1
- package/dist/plugin/provider.js +209 -176
- package/dist/plugin/sdk.js +86 -86
- package/dist/plugin/service.js +3 -3
- package/dist/plugin/skill.js +148 -145
- package/dist/plugin/source-directory.js +1 -1
- package/dist/plugin/supervisor.js +403 -369
- package/dist/plugin/tool-input-repair.js +4 -4
- package/dist/plugin/update.js +6 -6
- package/dist/plugin/vcs/git.js +98 -98
- package/dist/plugin/vcs/hg.js +98 -98
- package/dist/plugin/verbosity.js +105 -105
- package/dist/plugin/warming.js +127 -123
- package/dist/plugin/websearch/exa.js +7 -7
- package/dist/plugin/websearch/firecrawl.js +8 -8
- package/dist/plugin/websearch/index.js +9 -9
- package/dist/plugin/websearch/mcp.js +6 -6
- package/dist/plugin/websearch/parallel.js +8 -8
- package/dist/plugin/websearch/tavily.js +6 -6
- package/dist/plugin/websearch/tinyfish.js +8 -8
- package/dist/plugin.js +242 -238
- package/dist/project/icon.js +5 -5
- package/dist/project/schema.js +8 -8
- package/dist/project/sql.js +4 -4
- package/dist/project.js +102 -102
- package/dist/provider.js +109 -109
- package/dist/pty/protocol.js +1 -1
- package/dist/pty/ticket.js +1 -1
- package/dist/pty.js +108 -108
- package/dist/reference/instructions.js +100 -100
- package/dist/reference.js +102 -102
- package/dist/repository-cache.js +92 -92
- package/dist/repository.js +3 -3
- package/dist/ripgrep/binary.js +2 -2
- package/dist/ripgrep.js +107 -107
- package/dist/rpc.js +98 -98
- package/dist/schedule/check.js +238 -233
- package/dist/schedule/sql.js +6 -6
- package/dist/schedule.js +252 -247
- package/dist/schema.js +1 -1
- package/dist/session/affinity.js +1 -1
- package/dist/session/background.js +1 -1
- package/dist/session/blob.js +128 -124
- package/dist/session/command.js +84 -84
- package/dist/session/compaction.js +170 -166
- package/dist/session/context.js +197 -192
- package/dist/session/diff.js +100 -100
- 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 +240 -236
- package/dist/session/execution.js +159 -156
- package/dist/session/generate.js +199 -194
- package/dist/session/history.js +137 -133
- package/dist/session/inbox.js +148 -144
- package/dist/session/info.js +3 -3
- package/dist/session/instruction-entry.js +89 -89
- package/dist/session/instruction-state.js +8 -8
- package/dist/session/instructions.js +140 -136
- package/dist/session/message-updater.js +2 -2
- package/dist/session/message.js +1 -1
- package/dist/session/model-request.js +167 -159
- package/dist/session/model-transport.js +9 -9
- package/dist/session/move.js +163 -160
- package/dist/session/projector.js +142 -138
- package/dist/session/prompt.js +147 -144
- package/dist/session/recent-text.js +1 -1
- package/dist/session/revert.js +138 -134
- package/dist/session/run-coordinator.js +3 -3
- package/dist/session/runner/index.js +3 -3
- package/dist/session/runner/llm.js +247 -243
- package/dist/session/runner/max-steps.js +1 -1
- package/dist/session/runner/model.js +112 -112
- package/dist/session/runner/publish-llm-event.js +148 -145
- package/dist/session/runner/retry.js +5 -5
- package/dist/session/runner/step.js +162 -158
- package/dist/session/runner/to-llm-message.js +136 -132
- package/dist/session/schema.js +5 -5
- package/dist/session/session.js +181 -178
- package/dist/session/shell.js +145 -141
- package/dist/session/skill.js +146 -143
- package/dist/session/sql.js +5 -5
- package/dist/session/stats.js +85 -85
- package/dist/session/store.js +141 -137
- package/dist/session/stored.js +2 -2
- package/dist/session/subagent-completion.js +1 -1
- package/dist/session/subagent-job.js +227 -223
- package/dist/session/system-prompt.js +7 -7
- package/dist/session/title.js +201 -196
- package/dist/session/to-session-error.js +147 -144
- package/dist/session/transfer.js +240 -236
- package/dist/session/usage.js +1 -1
- package/dist/session.js +235 -231
- package/dist/shell/parse.js +7 -9
- package/dist/shell/result.js +3 -3
- package/dist/shell/scan.js +6 -2007
- package/dist/shell/select.js +11 -11
- package/dist/shell.js +145 -141
- package/dist/skill/discovery.js +6 -6
- package/dist/skill/instructions.js +150 -147
- package/dist/skill.js +157 -154
- package/dist/snapshot.js +101 -101
- package/dist/state.js +3 -3
- package/dist/tool/html-markdown.js +1 -1
- package/dist/tool/http-body.js +1 -1
- package/dist/tool/mcp.js +177 -169
- package/dist/tool/plugin/edit.js +159 -156
- package/dist/tool/plugin/file-diff.js +1 -1
- package/dist/tool/plugin/glob.js +167 -164
- package/dist/tool/plugin/grep.js +167 -164
- package/dist/tool/plugin/image-generate.js +237 -233
- package/dist/tool/plugin/mcp-resource.js +161 -158
- package/dist/tool/plugin/opencode.js +160 -157
- package/dist/tool/plugin/patch.js +165 -162
- package/dist/tool/plugin/question.js +147 -144
- package/dist/tool/plugin/read.js +168 -165
- package/dist/tool/plugin/schedule.js +244 -239
- package/dist/tool/plugin/shell.js +231 -226
- package/dist/tool/plugin/skill.js +156 -153
- package/dist/tool/plugin/subagent.js +234 -230
- package/dist/tool/plugin/todo.js +152 -149
- package/dist/tool/plugin/webfetch.js +150 -147
- package/dist/tool/plugin/websearch.js +152 -149
- package/dist/tool/plugin/write.js +165 -162
- package/dist/tool/read-filesystem.js +114 -114
- package/dist/tool/runtime.js +1 -1
- package/dist/tool-output.js +7 -7
- package/dist/tool.js +158 -14
- package/dist/types/agent.d.ts +2 -0
- package/dist/types/aisdk.d.ts +1 -0
- package/dist/types/codemode/execution.d.ts +7 -0
- package/dist/types/codemode/fetch.d.ts +33 -0
- package/dist/types/codemode/tool.d.ts +41 -1
- package/dist/types/config/integration.d.ts +29 -7
- package/dist/types/config/managed.d.ts +10 -0
- package/dist/types/config/plugin/policy.d.ts +4 -1
- package/dist/types/instance.d.ts +1 -1
- package/dist/types/instructions/index.d.ts +8 -1
- package/dist/types/managed-policy.d.ts +16 -2
- package/dist/types/model-resolver.d.ts +6 -0
- package/dist/types/model.d.ts +4 -0
- package/dist/types/plugin/provider/claude-agent/aisdk.d.ts +5 -0
- package/dist/types/plugin/provider/claude-agent/claude/agent-sdk.d.ts +1 -0
- package/dist/types/plugin/provider/claude-agent/claude/agent-sdk.workerd.d.ts +1 -0
- package/dist/types/plugin/provider/claude-agent/claude/fork.d.ts +6 -0
- package/dist/types/plugin/provider/claude-agent/claude/io.d.ts +12 -0
- package/dist/types/plugin/provider/claude-agent/claude/probe.d.ts +23 -0
- package/dist/types/plugin/provider/claude-agent/claude/query-options.d.ts +29 -0
- package/dist/types/plugin/provider/claude-agent/claude/sdk.d.ts +3 -0
- package/dist/types/plugin/provider/claude-agent/claude/session.d.ts +19 -0
- package/dist/types/plugin/provider/claude-agent/claude/sessions.d.ts +38 -0
- package/dist/types/plugin/provider/claude-agent/claude/status.d.ts +25 -0
- package/dist/types/plugin/provider/claude-agent/index.d.ts +18 -0
- package/dist/types/plugin/provider/claude-agent/instructions.d.ts +4 -0
- package/dist/types/plugin/provider/claude-agent/integration.d.ts +7 -0
- package/dist/types/plugin/provider/claude-agent/language-model/claude-agent-error.d.ts +3 -0
- package/dist/types/plugin/provider/claude-agent/language-model/claude-agent-language-model.d.ts +17 -0
- package/dist/types/plugin/provider/claude-agent/language-model/convert-claude-stream.d.ts +4 -0
- package/dist/types/plugin/provider/claude-agent/language-model/convert-to-claude-message.d.ts +5 -0
- package/dist/types/plugin/provider/claude-agent/language-model/request-kind.d.ts +4 -0
- package/dist/types/plugin/provider/claude-agent/language-model/system-prompt.d.ts +11 -0
- package/dist/types/plugin/provider/claude-agent/language-model/usage.d.ts +16 -0
- package/dist/types/plugin/provider/claude-agent/provider.d.ts +9 -0
- package/dist/types/plugin/provider/claude-agent/session.d.ts +4 -0
- package/dist/types/plugin/provider/claude-agent/sync/catch-up.d.ts +4 -0
- package/dist/types/plugin/provider/claude-agent/sync/checkpoints.d.ts +14 -0
- package/dist/types/plugin/provider/claude-agent/sync/decide.d.ts +18 -0
- package/dist/types/plugin/provider/claude-agent/sync/fingerprint.d.ts +11 -0
- package/dist/types/plugin/provider/claude-agent/sync/record.d.ts +31 -0
- package/dist/types/plugin/provider/claude-agent/tools/hooks.d.ts +4 -0
- package/dist/types/plugin/provider/claude-agent/tools/names.d.ts +6 -0
- package/dist/types/plugin/provider/claude-agent/tools/pending.d.ts +12 -0
- package/dist/types/plugin/provider/claude-agent/tools/result.d.ts +14 -0
- package/dist/types/plugin/provider/claude-agent/tools/server.d.ts +5 -0
- package/dist/types/provider.d.ts +4 -0
- package/dist/types/schedule/check.d.ts +35 -4
- package/dist/types/schedule/sql.d.ts +3 -0
- package/dist/types/session/context.d.ts +1 -1
- package/dist/types/session/history.d.ts +2 -2
- package/dist/types/session/instruction-state.d.ts +2 -2
- package/dist/types/session/model-request.d.ts +2 -1
- package/dist/types/session/runner/model.d.ts +1 -0
- package/dist/types/session/schema.d.ts +2 -0
- package/dist/types/session/transfer.d.ts +8 -0
- package/dist/types/shell/parse.d.ts +1 -6
- package/dist/types/shell/scan.d.ts +1 -0
- package/dist/types/tool/plugin/schedule.d.ts +12 -0
- package/dist/types/tool/plugin/shell.d.ts +1 -2
- package/dist/types/tool.d.ts +14 -0
- package/dist/types/usage-limits.d.ts +1 -0
- package/dist/types/websearch.d.ts +2 -0
- package/dist/usage-limits.js +99 -99
- package/dist/util/error-summary.js +1 -1
- package/dist/util/git-executable.js +3 -3
- 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 +3 -3
- package/dist/v1/config/agent.js +5 -5
- package/dist/v1/config/command.js +5 -5
- package/dist/v1/config/mcp.js +6 -6
- package/dist/v1/config/migrate.js +104 -104
- package/dist/v1/config/permission.js +3 -3
- package/dist/v1/config/plugin.js +1 -1
- package/dist/v1/config/provider-options.js +1 -1
- package/dist/v1/config/provider.js +8 -8
- package/dist/variant.js +103 -103
- package/dist/vcs/patch.js +1 -1
- package/dist/vcs.js +101 -101
- package/dist/voice.js +100 -100
- package/dist/websearch.js +94 -94
- package/dist/wellknown/plugin.js +86 -86
- package/dist/wellknown.js +89 -89
- package/dist/workspace/driver.js +7 -7
- package/dist/workspace/sql.js +1 -1
- package/dist/workspace.js +92 -92
- package/dist/worktree/directory.js +2 -2
- package/dist/worktree/git.js +11 -11
- package/dist/worktree/sql.js +5 -5
- package/dist/worktree/strategies.js +101 -101
- package/dist/worktree.js +110 -110
- package/package.json +22 -18
- package/dist/chunks/session-014m13nx.js +0 -181
- package/dist/chunks/session-034tev2y.js +0 -43
- package/dist/chunks/session-04e5fydp.js +0 -79
- package/dist/chunks/session-0b3avwgb.js +0 -80
- package/dist/chunks/session-0h3385jp.js +0 -62
- package/dist/chunks/session-0jkhv5fd.js +0 -348
- package/dist/chunks/session-0k31egm0.js +0 -75
- package/dist/chunks/session-0n8a0ffz.js +0 -597
- package/dist/chunks/session-0rn5673z.js +0 -42
- package/dist/chunks/session-0s6ncdyq.js +0 -26
- package/dist/chunks/session-0xedkqrk.js +0 -177
- package/dist/chunks/session-0yyf9pa6.js +0 -148
- package/dist/chunks/session-107zh63q.js +0 -7
- package/dist/chunks/session-1347qshx.js +0 -76
- package/dist/chunks/session-14bt511q.js +0 -552
- package/dist/chunks/session-1a21k8vn.js +0 -46
- package/dist/chunks/session-1c1q46gq.js +0 -272
- package/dist/chunks/session-1ep2p91f.js +0 -18
- package/dist/chunks/session-1g08w5qk.js +0 -565
- package/dist/chunks/session-1ga2wj5n.js +0 -247
- package/dist/chunks/session-1kn6jdkn.js +0 -196
- package/dist/chunks/session-1m6jkbyv.js +0 -106
- package/dist/chunks/session-1p2sk048.js +0 -35
- package/dist/chunks/session-1x2knyw4.js +0 -42
- package/dist/chunks/session-204s3925.js +0 -175
- package/dist/chunks/session-214k5kca.js +0 -224
- package/dist/chunks/session-25h84942.js +0 -17
- package/dist/chunks/session-29e51n1b.js +0 -38
- package/dist/chunks/session-2bg8s655.js +0 -140
- package/dist/chunks/session-2ekes0ek.js +0 -63
- package/dist/chunks/session-2fxvvp3e.js +0 -101
- package/dist/chunks/session-2kg89srt.js +0 -31
- package/dist/chunks/session-2tfsq0e5.js +0 -222
- package/dist/chunks/session-2vpr0s80.js +0 -96
- package/dist/chunks/session-2zp5a6yg.js +0 -262
- package/dist/chunks/session-306wmwj5.js +0 -444
- package/dist/chunks/session-3d1dxbz0.js +0 -71
- package/dist/chunks/session-3fm477c7.js +0 -544
- package/dist/chunks/session-3hepkmqq.js +0 -13
- package/dist/chunks/session-3nnrz6f6.js +0 -13
- package/dist/chunks/session-3ntfh06s.js +0 -83
- package/dist/chunks/session-3z1690bs.js +0 -377
- package/dist/chunks/session-40za9wsf.js +0 -64
- package/dist/chunks/session-42qtrm15.js +0 -215
- package/dist/chunks/session-4bev3xhy.js +0 -489
- package/dist/chunks/session-4cyw8nx1.js +0 -167
- package/dist/chunks/session-4p4bzch3.js +0 -36
- package/dist/chunks/session-4pyp9zr9.js +0 -63
- package/dist/chunks/session-4v008n1t.js +0 -13
- package/dist/chunks/session-4w3brme9.js +0 -81
- package/dist/chunks/session-4x23c0v6.js +0 -214
- package/dist/chunks/session-511h5e8a.js +0 -269
- package/dist/chunks/session-5ac4cxmk.js +0 -591
- package/dist/chunks/session-5aytyrt3.js +0 -99
- package/dist/chunks/session-5m9w47nd.js +0 -21
- package/dist/chunks/session-5q32avkb.js +0 -95
- package/dist/chunks/session-5sh8dy76.js +0 -198
- package/dist/chunks/session-5svmm7fm.js +0 -135
- package/dist/chunks/session-5v99ekdb.js +0 -236
- package/dist/chunks/session-5w1z1d8q.js +0 -355
- package/dist/chunks/session-6cahmqzr.js +0 -61
- package/dist/chunks/session-6esdw8yj.js +0 -34
- package/dist/chunks/session-6hy9r9dj.js +0 -49
- package/dist/chunks/session-6hybw9g3.js +0 -123
- package/dist/chunks/session-6k3pn0ym.js +0 -66
- package/dist/chunks/session-6kff7ze5.js +0 -107
- package/dist/chunks/session-6kj7g8xp.js +0 -111
- package/dist/chunks/session-6kxp06hb.js +0 -118
- package/dist/chunks/session-6zwd6715.js +0 -283
- package/dist/chunks/session-74sxx59s.js +0 -33
- package/dist/chunks/session-76cb1hcw.js +0 -63
- package/dist/chunks/session-7bmhse3q.js +0 -118
- package/dist/chunks/session-7sdtxe0n.js +0 -450
- package/dist/chunks/session-7svxnz6h.js +0 -51
- package/dist/chunks/session-7tt92bnf.js +0 -416
- package/dist/chunks/session-7w2ypzdf.js +0 -62
- package/dist/chunks/session-83bdf6kd.js +0 -184
- package/dist/chunks/session-83y1ztr9.js +0 -40
- package/dist/chunks/session-84041qcw.js +0 -82
- package/dist/chunks/session-8gej5d5g.js +0 -235
- package/dist/chunks/session-8jztxfpf.js +0 -31
- package/dist/chunks/session-8p2jpvs0.js +0 -315
- package/dist/chunks/session-8wqqaqzt.js +0 -1332
- package/dist/chunks/session-8wtp7s3z.js +0 -14
- package/dist/chunks/session-90zstvax.js +0 -129
- package/dist/chunks/session-994b2pxg.js +0 -185
- package/dist/chunks/session-99awmhkb.js +0 -921
- package/dist/chunks/session-9f3sjfep.js +0 -53
- package/dist/chunks/session-9y9v7zvr.js +0 -465
- package/dist/chunks/session-a1vq38jw.js +0 -102
- package/dist/chunks/session-a3r0se63.js +0 -80
- package/dist/chunks/session-a4zme8rz.js +0 -278
- package/dist/chunks/session-afm1mqfd.js +0 -200
- package/dist/chunks/session-ajs99hkw.js +0 -58
- package/dist/chunks/session-apc99ahs.js +0 -343
- package/dist/chunks/session-aq8fvkrh.js +0 -166
- package/dist/chunks/session-avgzkss2.js +0 -94
- package/dist/chunks/session-ayjs7tqn.js +0 -17
- package/dist/chunks/session-b3vf0bc4.js +0 -96
- package/dist/chunks/session-b5z3fqjc.js +0 -368
- package/dist/chunks/session-b6vsg801.js +0 -406
- package/dist/chunks/session-ba56jx13.js +0 -378
- package/dist/chunks/session-btnkw9ag.js +0 -410
- package/dist/chunks/session-c0j43jcq.js +0 -43
- package/dist/chunks/session-c6x7d2ts.js +0 -21
- package/dist/chunks/session-cbvv2732.js +0 -201
- package/dist/chunks/session-cf4j1xxh.js +0 -51
- package/dist/chunks/session-cp0d67wz.js +0 -278
- package/dist/chunks/session-csjqfz54.js +0 -137
- package/dist/chunks/session-cwrgdav8.js +0 -83
- package/dist/chunks/session-cxzp2bsp.js +0 -162
- package/dist/chunks/session-d0zcdp69.js +0 -75
- package/dist/chunks/session-d2887f8n.js +0 -82
- package/dist/chunks/session-d4v9tmah.js +0 -25
- package/dist/chunks/session-d77dj7jw.js +0 -18
- package/dist/chunks/session-d7htzk6m.js +0 -356
- package/dist/chunks/session-ddp1c6wr.js +0 -227
- package/dist/chunks/session-dh8t6pa0.js +0 -147
- package/dist/chunks/session-dp6am7n6.js +0 -291
- package/dist/chunks/session-dt77769w.js +0 -53
- package/dist/chunks/session-dwpz7zn0.js +0 -42
- package/dist/chunks/session-e2e8g6me.js +0 -201
- package/dist/chunks/session-e3me9f8n.js +0 -94
- package/dist/chunks/session-e834z07m.js +0 -50
- package/dist/chunks/session-epet3xcy.js +0 -537
- package/dist/chunks/session-eq0bj8vr.js +0 -74
- package/dist/chunks/session-et8sht6e.js +0 -282
- package/dist/chunks/session-evmcva0v.js +0 -41
- package/dist/chunks/session-ewzp24hx.js +0 -73
- package/dist/chunks/session-f1bbj6f0.js +0 -668
- package/dist/chunks/session-f3t0m2cs.js +0 -123
- package/dist/chunks/session-f4177rbw.js +0 -48
- package/dist/chunks/session-f52hekk8.js +0 -126
- package/dist/chunks/session-fffv3p7h.js +0 -143
- package/dist/chunks/session-fg8bmn5r.js +0 -213
- package/dist/chunks/session-fg9p65nk.js +0 -37
- package/dist/chunks/session-fydb03qw.js +0 -49
- package/dist/chunks/session-fznmdakp.js +0 -22
- package/dist/chunks/session-g1e2r5aa.js +0 -41
- package/dist/chunks/session-g3p0pw3f.js +0 -103
- package/dist/chunks/session-g5y8y9ka.js +0 -72
- package/dist/chunks/session-gc07wgt0.js +0 -196
- package/dist/chunks/session-gd8sx287.js +0 -173
- package/dist/chunks/session-gk8m8gwv.js +0 -180
- package/dist/chunks/session-gvfwbdg5.js +0 -89
- package/dist/chunks/session-gvj3fga6.js +0 -187
- package/dist/chunks/session-gyka3hze.js +0 -241
- package/dist/chunks/session-h45rwca9.js +0 -400
- package/dist/chunks/session-h57hnx26.js +0 -73
- package/dist/chunks/session-h7rsa5h4.js +0 -126
- package/dist/chunks/session-hc4wny2n.js +0 -148
- package/dist/chunks/session-hfmn2zba.js +0 -34
- package/dist/chunks/session-hh7kjqtw.js +0 -66
- package/dist/chunks/session-hht3wrh4.js +0 -544
- package/dist/chunks/session-hj48n5g3.js +0 -97
- package/dist/chunks/session-hjnjc3ts.js +0 -72
- package/dist/chunks/session-hjpa6ehn.js +0 -107
- package/dist/chunks/session-hjvvwd9m.js +0 -238
- package/dist/chunks/session-hm2g1pam.js +0 -535
- package/dist/chunks/session-hpg1pkwy.js +0 -20
- package/dist/chunks/session-hqqbfxm4.js +0 -120
- package/dist/chunks/session-hvktc1vq.js +0 -94
- package/dist/chunks/session-hy8c1z76.js +0 -32
- package/dist/chunks/session-j3v6xgsf.js +0 -313
- package/dist/chunks/session-j6pgq882.js +0 -35
- package/dist/chunks/session-jcjsjw6m.js +0 -157
- package/dist/chunks/session-jcnk5dbh.js +0 -183
- package/dist/chunks/session-jfaecv01.js +0 -50
- package/dist/chunks/session-jhdr5shj.js +0 -38
- package/dist/chunks/session-jrzhkn60.js +0 -111
- package/dist/chunks/session-js3ekr85.js +0 -71
- package/dist/chunks/session-jtnps1zs.js +0 -154
- package/dist/chunks/session-jw3xc4w3.js +0 -126
- package/dist/chunks/session-k7fyma4a.js +0 -156
- package/dist/chunks/session-k814nvkf.js +0 -78
- package/dist/chunks/session-k9zkdd2y.js +0 -83
- package/dist/chunks/session-kb90rkdq.js +0 -121
- package/dist/chunks/session-kmshagc5.js +0 -88
- package/dist/chunks/session-kr5yk018.js +0 -125
- package/dist/chunks/session-krdv82ye.js +0 -247
- package/dist/chunks/session-kt3bjfbg.js +0 -26
- package/dist/chunks/session-kxbt2msb.js +0 -84
- package/dist/chunks/session-ky596kc3.js +0 -18
- package/dist/chunks/session-m1714858.js +0 -39
- package/dist/chunks/session-m6br695y.js +0 -115
- package/dist/chunks/session-m9w0rfyh.js +0 -123
- package/dist/chunks/session-mb7mbhnz.js +0 -133
- package/dist/chunks/session-mg356nz4.js +0 -302
- package/dist/chunks/session-mjzr7bcb.js +0 -75
- package/dist/chunks/session-mwqmxszj.js +0 -123
- package/dist/chunks/session-mz14xksf.js +0 -224
- package/dist/chunks/session-mzx60t1x.js +0 -336
- package/dist/chunks/session-n05pjf0z.js +0 -357
- package/dist/chunks/session-n5f56dyg.js +0 -221
- package/dist/chunks/session-n5szpsx2.js +0 -86
- package/dist/chunks/session-n9f4a7bt.js +0 -226
- package/dist/chunks/session-nah043kf.js +0 -42
- package/dist/chunks/session-ncqqe42p.js +0 -9
- package/dist/chunks/session-ng70ej78.js +0 -56
- package/dist/chunks/session-nma643tt.js +0 -377
- package/dist/chunks/session-nqmf97tx.js +0 -388
- package/dist/chunks/session-ntqvm2fg.js +0 -31
- package/dist/chunks/session-nz2ac0f6.js +0 -587
- package/dist/chunks/session-p015t6z3.js +0 -38
- package/dist/chunks/session-p58rp8mt.js +0 -141
- package/dist/chunks/session-p7vhpwh8.js +0 -16
- package/dist/chunks/session-p916h210.js +0 -90
- package/dist/chunks/session-pcve4y50.js +0 -672
- package/dist/chunks/session-pfhvw22f.js +0 -38
- package/dist/chunks/session-pj80she1.js +0 -104
- package/dist/chunks/session-pknna89w.js +0 -18
- package/dist/chunks/session-prh1gakp.js +0 -443
- package/dist/chunks/session-prveawz9.js +0 -257
- package/dist/chunks/session-py1kgbbs.js +0 -184
- package/dist/chunks/session-qg5z9cfk.js +0 -748
- package/dist/chunks/session-qn0q7ss9.js +0 -664
- package/dist/chunks/session-qp7r0hxv.js +0 -120
- package/dist/chunks/session-qqvy8y24.js +0 -45
- package/dist/chunks/session-qtbtp5y4.js +0 -31
- package/dist/chunks/session-qvfyc67n.js +0 -37
- package/dist/chunks/session-r0543gnn.js +0 -258
- package/dist/chunks/session-r4pw3xq2.js +0 -70
- package/dist/chunks/session-r542h3bh.js +0 -54
- package/dist/chunks/session-rb9dy4dg.js +0 -116
- package/dist/chunks/session-rbc1s8g1.js +0 -311
- package/dist/chunks/session-rd86k9nx.js +0 -40
- package/dist/chunks/session-rjnacbrz.js +0 -155
- package/dist/chunks/session-rkc457kn.js +0 -201
- package/dist/chunks/session-rt5dr6hb.js +0 -14
- package/dist/chunks/session-rwvswa9y.js +0 -20
- package/dist/chunks/session-sa3fpqfw.js +0 -46
- package/dist/chunks/session-sj8cf4xn.js +0 -90
- package/dist/chunks/session-skhfmn6d.js +0 -348
- package/dist/chunks/session-sqjzf8x2.js +0 -41
- package/dist/chunks/session-svcy3p9a.js +0 -38
- package/dist/chunks/session-tczq8hjw.js +0 -25
- package/dist/chunks/session-teh5t5jp.js +0 -97
- package/dist/chunks/session-tf0cgyr6.js +0 -333
- package/dist/chunks/session-tg9kr0y0.js +0 -81
- package/dist/chunks/session-tj6nb54t.js +0 -22
- package/dist/chunks/session-tjand230.js +0 -133
- package/dist/chunks/session-tkfkfkf0.js +0 -207
- package/dist/chunks/session-tkgn6n4e.js +0 -319
- package/dist/chunks/session-tp4q3xqc.js +0 -98
- package/dist/chunks/session-ts17rpp3.js +0 -195
- package/dist/chunks/session-twssxy5n.js +0 -170
- package/dist/chunks/session-v1mxzh7z.js +0 -351
- package/dist/chunks/session-v27eh5cj.js +0 -261
- package/dist/chunks/session-v2r1d0zg.js +0 -86
- package/dist/chunks/session-v35fmwg5.js +0 -279
- package/dist/chunks/session-v8vd993n.js +0 -31
- package/dist/chunks/session-vaq1yek0.js +0 -59
- package/dist/chunks/session-vp9b3xr6.js +0 -186
- package/dist/chunks/session-vre2328q.js +0 -142
- package/dist/chunks/session-vyevn7ez.js +0 -108
- package/dist/chunks/session-w1g6eztn.js +0 -153
- package/dist/chunks/session-w3wsvvr9.js +0 -80
- package/dist/chunks/session-w8cbkq7x.js +0 -139
- package/dist/chunks/session-wakvkjy4.js +0 -79
- package/dist/chunks/session-wd87259q.js +0 -102
- package/dist/chunks/session-wegkxhrn.js +0 -37
- package/dist/chunks/session-wgy4vw39.js +0 -868
- package/dist/chunks/session-wnhgecwx.js +0 -93
- package/dist/chunks/session-wrd39zd3.js +0 -54
- package/dist/chunks/session-wtem00hm.js +0 -37
- package/dist/chunks/session-wvphax15.js +0 -128
- package/dist/chunks/session-wwgpyqzb.js +0 -31
- package/dist/chunks/session-wzytqp0z.js +0 -182
- package/dist/chunks/session-x15zq3xe.js +0 -96
- package/dist/chunks/session-x78h82an.js +0 -789
- package/dist/chunks/session-x7sfbxcq.js +0 -43
- package/dist/chunks/session-x968pprt.js +0 -116
- package/dist/chunks/session-xd9cc171.js +0 -175
- package/dist/chunks/session-xk2zn0cv.js +0 -26
- package/dist/chunks/session-xnh55p1t.js +0 -49
- package/dist/chunks/session-xq6kn9sb.js +0 -182
- package/dist/chunks/session-xvk346a2.js +0 -171
- package/dist/chunks/session-y5qd0fdx.js +0 -342
- package/dist/chunks/session-yara3q77.js +0 -132
- package/dist/chunks/session-yb20nhc3.js +0 -229
- package/dist/chunks/session-ycbkkxa6.js +0 -49
- package/dist/chunks/session-yg4xtd5c.js +0 -302
- package/dist/chunks/session-yk92hh7b.js +0 -122
- package/dist/chunks/session-ymz7p2c9.js +0 -31
- package/dist/chunks/session-yne29hzv.js +0 -65
- package/dist/chunks/session-ynx6mseh.js +0 -44
- package/dist/chunks/session-yt5wjcy6.js +0 -75
- package/dist/chunks/session-yv82jfb9.js +0 -173
- package/dist/chunks/session-yvdwn3rt.js +0 -128
- package/dist/chunks/session-yxtp6v20.js +0 -226
- package/dist/chunks/session-yy77v243.js +0 -710
- package/dist/chunks/session-z1gzwszr.js +0 -35
- package/dist/chunks/session-z38nccrw.js +0 -19
- package/dist/chunks/session-z9dbc4cd.js +0 -184
- package/dist/chunks/session-zqzhvas5.js +0 -252
- package/dist/codemode/web.js +0 -10
- package/dist/shell/parser-wasm.bun.js +0 -8
- package/dist/shell/parser-wasm.node.js +0 -11
- package/dist/shell/parser-wasm.workerd.js +0 -5
- package/dist/types/codemode/web.d.ts +0 -30
- package/dist/types/shell/parser-wasm.bun.d.ts +0 -5
- package/dist/types/shell/parser-wasm.node.d.ts +0 -5
- package/dist/types/shell/parser-wasm.workerd.d.ts +0 -5
- /package/dist/chunks/{session-0qkdqm5v.js → usage-limits-0qkdqm5v.js} +0 -0
- /package/dist/chunks/{session-0zkw76rk.js → usage-limits-0zkw76rk.js} +0 -0
- /package/dist/chunks/{session-17cy0kzp.js → usage-limits-17cy0kzp.js} +0 -0
- /package/dist/chunks/{session-1cnp2v09.js → usage-limits-1cnp2v09.js} +0 -0
- /package/dist/chunks/{session-1kah00gy.js → usage-limits-1kah00gy.js} +0 -0
- /package/dist/chunks/{session-24dcb14g.js → usage-limits-24dcb14g.js} +0 -0
- /package/dist/chunks/{session-2710q6r3.js → usage-limits-2710q6r3.js} +0 -0
- /package/dist/chunks/{session-2bv980vf.js → usage-limits-2bv980vf.js} +0 -0
- /package/dist/chunks/{session-2c3vjs8z.js → usage-limits-2c3vjs8z.js} +0 -0
- /package/dist/chunks/{session-359p4xyc.js → usage-limits-359p4xyc.js} +0 -0
- /package/dist/chunks/{session-3asan66x.js → usage-limits-3asan66x.js} +0 -0
- /package/dist/chunks/{session-3v8g72cx.js → usage-limits-3v8g72cx.js} +0 -0
- /package/dist/chunks/{session-3wcehsnq.js → usage-limits-3wcehsnq.js} +0 -0
- /package/dist/chunks/{session-43n2bw4t.js → usage-limits-43n2bw4t.js} +0 -0
- /package/dist/chunks/{session-4knz6hnm.js → usage-limits-4knz6hnm.js} +0 -0
- /package/dist/chunks/{session-4vcrnpx2.js → usage-limits-4vcrnpx2.js} +0 -0
- /package/dist/chunks/{session-4y7fprxs.js → usage-limits-4y7fprxs.js} +0 -0
- /package/dist/chunks/{session-53557ph1.js → usage-limits-53557ph1.js} +0 -0
- /package/dist/chunks/{session-550bvhaj.js → usage-limits-550bvhaj.js} +0 -0
- /package/dist/chunks/{session-5w3e23ze.js → usage-limits-5w3e23ze.js} +0 -0
- /package/dist/chunks/{session-6prwharc.js → usage-limits-6prwharc.js} +0 -0
- /package/dist/chunks/{session-6q2bdcd1.js → usage-limits-6q2bdcd1.js} +0 -0
- /package/dist/chunks/{session-7akdwqpd.js → usage-limits-7akdwqpd.js} +0 -0
- /package/dist/chunks/{session-7m9af43g.js → usage-limits-7m9af43g.js} +0 -0
- /package/dist/chunks/{session-7stb81gk.js → usage-limits-7stb81gk.js} +0 -0
- /package/dist/chunks/{session-822emrt2.js → usage-limits-822emrt2.js} +0 -0
- /package/dist/chunks/{session-84wd9syh.js → usage-limits-84wd9syh.js} +0 -0
- /package/dist/chunks/{session-88xbtdfr.js → usage-limits-88xbtdfr.js} +0 -0
- /package/dist/chunks/{session-8n3pysct.js → usage-limits-8n3pysct.js} +0 -0
- /package/dist/chunks/{session-8wj87zfr.js → usage-limits-8wj87zfr.js} +0 -0
- /package/dist/chunks/{session-9a4afbnw.js → usage-limits-9a4afbnw.js} +0 -0
- /package/dist/chunks/{session-9rqn6x4v.js → usage-limits-9rqn6x4v.js} +0 -0
- /package/dist/chunks/{session-a058387c.js → usage-limits-a058387c.js} +0 -0
- /package/dist/chunks/{session-a6k6eb26.js → usage-limits-a6k6eb26.js} +0 -0
- /package/dist/chunks/{session-af5trqkr.js → usage-limits-af5trqkr.js} +0 -0
- /package/dist/chunks/{session-afrmfg78.js → usage-limits-afrmfg78.js} +0 -0
- /package/dist/chunks/{session-aqzs7mqg.js → usage-limits-aqzs7mqg.js} +0 -0
- /package/dist/chunks/{session-atq7p7m5.js → usage-limits-atq7p7m5.js} +0 -0
- /package/dist/chunks/{session-beh6qq61.js → usage-limits-beh6qq61.js} +0 -0
- /package/dist/chunks/{session-bkyjaxrp.js → usage-limits-bkyjaxrp.js} +0 -0
- /package/dist/chunks/{session-bmr6ed5q.js → usage-limits-bmr6ed5q.js} +0 -0
- /package/dist/chunks/{session-cf4snx6d.js → usage-limits-cf4snx6d.js} +0 -0
- /package/dist/chunks/{session-cqv5kn06.js → usage-limits-cqv5kn06.js} +0 -0
- /package/dist/chunks/{session-cvy3z8tj.js → usage-limits-cvy3z8tj.js} +0 -0
- /package/dist/chunks/{session-d9fn303g.js → usage-limits-d9fn303g.js} +0 -0
- /package/dist/chunks/{session-d9jj8t3e.js → usage-limits-d9jj8t3e.js} +0 -0
- /package/dist/chunks/{session-dap0rakb.js → usage-limits-dap0rakb.js} +0 -0
- /package/dist/chunks/{session-df08tz66.js → usage-limits-df08tz66.js} +0 -0
- /package/dist/chunks/{session-dy18nga0.js → usage-limits-dy18nga0.js} +0 -0
- /package/dist/chunks/{session-e5kj55wp.js → usage-limits-e5kj55wp.js} +0 -0
- /package/dist/chunks/{session-e73j6tqm.js → usage-limits-e73j6tqm.js} +0 -0
- /package/dist/chunks/{session-ean2d8b5.js → usage-limits-ean2d8b5.js} +0 -0
- /package/dist/chunks/{session-ec1grn59.js → usage-limits-ec1grn59.js} +0 -0
- /package/dist/chunks/{session-eh3zwz77.js → usage-limits-eh3zwz77.js} +0 -0
- /package/dist/chunks/{session-emrn6kk6.js → usage-limits-emrn6kk6.js} +0 -0
- /package/dist/chunks/{session-f0mxakyp.js → usage-limits-f0mxakyp.js} +0 -0
- /package/dist/chunks/{session-f6n9ztr4.js → usage-limits-f6n9ztr4.js} +0 -0
- /package/dist/chunks/{session-faypxj3z.js → usage-limits-faypxj3z.js} +0 -0
- /package/dist/chunks/{session-fd410y7t.js → usage-limits-fd410y7t.js} +0 -0
- /package/dist/chunks/{session-fkpq3x5p.js → usage-limits-fkpq3x5p.js} +0 -0
- /package/dist/chunks/{session-g4wezp1m.js → usage-limits-g4wezp1m.js} +0 -0
- /package/dist/chunks/{session-g86h250q.js → usage-limits-g86h250q.js} +0 -0
- /package/dist/chunks/{session-gebd4c9n.js → usage-limits-gebd4c9n.js} +0 -0
- /package/dist/chunks/{session-gftt206x.js → usage-limits-gftt206x.js} +0 -0
- /package/dist/chunks/{session-hcxmzztb.js → usage-limits-hcxmzztb.js} +0 -0
- /package/dist/chunks/{session-hk9envan.js → usage-limits-hk9envan.js} +0 -0
- /package/dist/chunks/{session-j2ntwpah.js → usage-limits-j2ntwpah.js} +0 -0
- /package/dist/chunks/{session-j5zkgpj8.js → usage-limits-j5zkgpj8.js} +0 -0
- /package/dist/chunks/{session-jjkms2e6.js → usage-limits-jjkms2e6.js} +0 -0
- /package/dist/chunks/{session-jr7sbwjy.js → usage-limits-jr7sbwjy.js} +0 -0
- /package/dist/chunks/{session-jwfs4k6c.js → usage-limits-jwfs4k6c.js} +0 -0
- /package/dist/chunks/{session-jwr30sdr.js → usage-limits-jwr30sdr.js} +0 -0
- /package/dist/chunks/{session-jze0r7bz.js → usage-limits-jze0r7bz.js} +0 -0
- /package/dist/chunks/{session-jzg6c2d5.js → usage-limits-jzg6c2d5.js} +0 -0
- /package/dist/chunks/{session-m18g726c.js → usage-limits-m18g726c.js} +0 -0
- /package/dist/chunks/{session-mp448xyj.js → usage-limits-mp448xyj.js} +0 -0
- /package/dist/chunks/{session-msx8hqn2.js → usage-limits-msx8hqn2.js} +0 -0
- /package/dist/chunks/{session-n05xt0ee.js → usage-limits-n05xt0ee.js} +0 -0
- /package/dist/chunks/{session-n3j8tn72.js → usage-limits-n3j8tn72.js} +0 -0
- /package/dist/chunks/{session-nh4v3znn.js → usage-limits-nh4v3znn.js} +0 -0
- /package/dist/chunks/{session-njntx4h6.js → usage-limits-njntx4h6.js} +0 -0
- /package/dist/chunks/{session-p71gwv9c.js → usage-limits-p71gwv9c.js} +0 -0
- /package/dist/chunks/{session-q3sfg36h.js → usage-limits-q3sfg36h.js} +0 -0
- /package/dist/chunks/{session-q74kybfr.js → usage-limits-q74kybfr.js} +0 -0
- /package/dist/chunks/{session-qaymkmh1.js → usage-limits-qaymkmh1.js} +0 -0
- /package/dist/chunks/{session-qb87gjwd.js → usage-limits-qb87gjwd.js} +0 -0
- /package/dist/chunks/{session-qfa1cgps.js → usage-limits-qfa1cgps.js} +0 -0
- /package/dist/chunks/{session-qg3g05ea.js → usage-limits-qg3g05ea.js} +0 -0
- /package/dist/chunks/{session-qrg20bc0.js → usage-limits-qrg20bc0.js} +0 -0
- /package/dist/chunks/{session-rcb2kzg1.js → usage-limits-rcb2kzg1.js} +0 -0
- /package/dist/chunks/{session-sdp7kfr6.js → usage-limits-sdp7kfr6.js} +0 -0
- /package/dist/chunks/{session-ssg3fenm.js → usage-limits-ssg3fenm.js} +0 -0
- /package/dist/chunks/{session-stkk57rt.js → usage-limits-stkk57rt.js} +0 -0
- /package/dist/chunks/{session-t03h4f5z.js → usage-limits-t03h4f5z.js} +0 -0
- /package/dist/chunks/{session-ty7weeps.js → usage-limits-ty7weeps.js} +0 -0
- /package/dist/chunks/{session-ve7vex1e.js → usage-limits-ve7vex1e.js} +0 -0
- /package/dist/chunks/{session-w803qqfp.js → usage-limits-w803qqfp.js} +0 -0
- /package/dist/chunks/{session-wc3fc9cn.js → usage-limits-wc3fc9cn.js} +0 -0
- /package/dist/chunks/{session-wer8tq1h.js → usage-limits-wer8tq1h.js} +0 -0
- /package/dist/chunks/{session-wtztk69x.js → usage-limits-wtztk69x.js} +0 -0
- /package/dist/chunks/{session-x0ckcb58.js → usage-limits-x0ckcb58.js} +0 -0
- /package/dist/chunks/{session-x61499pn.js → usage-limits-x61499pn.js} +0 -0
- /package/dist/chunks/{session-y44na4kk.js → usage-limits-y44na4kk.js} +0 -0
- /package/dist/chunks/{session-y8f7s663.js → usage-limits-y8f7s663.js} +0 -0
- /package/dist/chunks/{session-ygaqb7jw.js → usage-limits-ygaqb7jw.js} +0 -0
- /package/dist/chunks/{session-z5v4ffb3.js → usage-limits-z5v4ffb3.js} +0 -0
- /package/dist/chunks/{session-z9919s4g.js → usage-limits-z9919s4g.js} +0 -0
|
@@ -0,0 +1,2158 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__export
|
|
3
|
+
} from "./usage-limits-9rqn6x4v.js";
|
|
4
|
+
|
|
5
|
+
// src/shell/scan.ts
|
|
6
|
+
var exports_scan = {};
|
|
7
|
+
__export(exports_scan, {
|
|
8
|
+
ShellScan: () => exports_scan,
|
|
9
|
+
scan: () => scan4,
|
|
10
|
+
scanPowerShell: () => scanPowerShell2
|
|
11
|
+
});
|
|
12
|
+
var BASH_REDIRECTS = ["&>>", "&>", "<<<", "<<-", "<<", "<>", "<&", ">&", ">|", ">>", ">", "<"];
|
|
13
|
+
var BASH_LIST_OPERATORS = ["&&", "||", "|&"];
|
|
14
|
+
var ZSH_LIST_OPERATORS = ["&&", "||", "|&", "&!", "&|"];
|
|
15
|
+
var BASH_CASE_OPERATORS = [";;&", ";;", ";&", ";|", ...BASH_LIST_OPERATORS];
|
|
16
|
+
var ZSH_CASE_OPERATORS = [";;&", ";;", ";&", ";|", ...ZSH_LIST_OPERATORS];
|
|
17
|
+
var BASH_BINDING_BUILTINS = new Set([
|
|
18
|
+
"declare",
|
|
19
|
+
"typeset",
|
|
20
|
+
"local",
|
|
21
|
+
"export",
|
|
22
|
+
"readonly",
|
|
23
|
+
"private",
|
|
24
|
+
"unset",
|
|
25
|
+
"read",
|
|
26
|
+
"getln",
|
|
27
|
+
"vared",
|
|
28
|
+
"getopts",
|
|
29
|
+
"mapfile",
|
|
30
|
+
"readarray",
|
|
31
|
+
"compgen",
|
|
32
|
+
"zparseopts",
|
|
33
|
+
"zregexparse",
|
|
34
|
+
"zformat",
|
|
35
|
+
"zstyle",
|
|
36
|
+
"zstat",
|
|
37
|
+
"stat"
|
|
38
|
+
]);
|
|
39
|
+
var BASH_ARITHMETIC_COMPARISONS = new Set(["-eq", "-ne", "-lt", "-le", "-gt", "-ge"]);
|
|
40
|
+
var BASH_EXPANSION_RE = /\$(?:\\.|\\\n)*[({]|`/;
|
|
41
|
+
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})/;
|
|
42
|
+
var BASH_ASSIGNMENT_DECLARATIONS = new Set(["declare", "typeset", "export", "readonly", "local"]);
|
|
43
|
+
var BASH_DECLARATIONS = new Set([...BASH_ASSIGNMENT_DECLARATIONS, "unset", "unsetenv"]);
|
|
44
|
+
var BASH_PRECOMMANDS = new Set(["builtin", "command", "time", "coproc", "!"]);
|
|
45
|
+
var ZSH_PRECOMMANDS = new Set(["noglob", "nocorrect", "exec", "-"]);
|
|
46
|
+
var ZSH_ARITHMETIC_BUILTINS = new Set([
|
|
47
|
+
"integer",
|
|
48
|
+
"float",
|
|
49
|
+
"exit",
|
|
50
|
+
"return",
|
|
51
|
+
"shift",
|
|
52
|
+
"break",
|
|
53
|
+
"continue",
|
|
54
|
+
"bye",
|
|
55
|
+
"logout"
|
|
56
|
+
]);
|
|
57
|
+
var BASH_NON_FUNCTION_KEYWORDS = new Set([
|
|
58
|
+
"if",
|
|
59
|
+
"for",
|
|
60
|
+
"select",
|
|
61
|
+
"case",
|
|
62
|
+
"then",
|
|
63
|
+
"elif",
|
|
64
|
+
"else",
|
|
65
|
+
"fi",
|
|
66
|
+
"do",
|
|
67
|
+
"done",
|
|
68
|
+
"in",
|
|
69
|
+
"esac"
|
|
70
|
+
]);
|
|
71
|
+
var BASH_UNIT_STARTS = "\\$'\"`<>";
|
|
72
|
+
var MAX_INPUT_LENGTH = 64 * 1024;
|
|
73
|
+
var MAX_SUBSTITUTION_DEPTH = 32;
|
|
74
|
+
var TOKEN_RE = /[A-Za-z_][A-Za-z0-9_]*(?=(?:\\\n)*(?:[ \t\n;|&()<>]|$))/y;
|
|
75
|
+
var BRACE_CLOSE_AHEAD_RE = /(?:\\\n)*(?:[ \t\n;&|()<>]|$)/y;
|
|
76
|
+
var SPACE_CONTINUATION_AHEAD_RE = /(?:\\\n)*[ \t\n]/y;
|
|
77
|
+
var NEGATION_AHEAD_RE = /(?:\\\n)*[ \t\n(]/y;
|
|
78
|
+
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;
|
|
79
|
+
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;
|
|
80
|
+
var FUNCTION_HEAD_RE = /(function[ \t](?:[ \t]|\\\n)*)?([A-Za-z_][\w.:+@%-]*)?(?:[ \t]|\\\n)*(\([ \t]*\))?((?:[ \t\n]|\\\n|#[^\n]*\n)*)/y;
|
|
81
|
+
var FUNCTION_BODY_RE = /[{(]|\[\[(?=(?:\\\n)*[ \t\n])|(?:if|while|until|for|select|case|repeat)(?=(?:\\\n)*(?:[ \t\n(]|$))/y;
|
|
82
|
+
var DO_AHEAD_RE = /(?:[ \t\n;]|\\\n|#[^\n]*(?:\n|$))*(?:do(?=(?:\\\n)*(?:[ \t\n;{(]|$))|\{(?=(?:\\\n)*[ \t\n]))/y;
|
|
83
|
+
var NOFORK_OPEN_RE = /\$\{(?:\\\n)*(?:[ \t\n]|\|)/y;
|
|
84
|
+
var ZSH_SAFE_FLAGS_RE = /\$\{\((?:[@AaBbCcDEfFikLMmNnOopPqStUuVvWwXZz0-]|q[-+]?|[js]([^({[<\\])(?:(?!\1)[^)])*\1)*\)/y;
|
|
85
|
+
var ZSH_QUOTED_FLAG_ARG_RE = /[js]([^({[<\\])(?:(?!\1)[^)])*\1/g;
|
|
86
|
+
var ZSH_GLOB_MODIFIER_RE = /(?:[\^=~#+]|\\\n)*~/y;
|
|
87
|
+
var ZSH_GLOB_QUALIFIER_RE = /\((?:[/F.@=*rwxAIERWsStUG^MTNDn-]|[oO][nLlamcdN]|[amc][Mwhmsd]?[-+]?\d+|L[kKmMpPgGtT]?[-+]?\d+|[lY][-+]?\d+|\[[-+]?\d+(?:,[-+]?\d+)?\]|,)+\)(?=(?:\\\n)*(?:[ \t\n;&|<>)]|$))/y;
|
|
88
|
+
var ZSH_SUBSCRIPT_RE = /\$(?:[\^=+~#]|\\\n)*(?:[A-Za-z_](?:[A-Za-z0-9_]|\\\n)*|[@*#?$!0-9-])(?:\\\n)*\[/y;
|
|
89
|
+
var LINE_CONTINUATION_RE = /(?:\\\n)*/y;
|
|
90
|
+
var PARAMETER_PREFIX_RE = /(?:\\\n)*(?:\([^)]*\))?(?:[!#^=+~]|\\\n)*/y;
|
|
91
|
+
var PARAMETER_NAME_RE = /(?:[A-Za-z_](?:[A-Za-z0-9_]|\\\n)*|\d(?:\d|\\\n)*|[@*#?$!-])(?:\\\n)*/y;
|
|
92
|
+
var PARAMETER_PROMPT_RE = /@(?:\\\n)*[EP](?:\\\n)*\}/y;
|
|
93
|
+
var BASH_ANSI_ESCAPES = {
|
|
94
|
+
a: "\x07",
|
|
95
|
+
b: "\b",
|
|
96
|
+
e: "\x1B",
|
|
97
|
+
E: "\x1B",
|
|
98
|
+
f: "\f",
|
|
99
|
+
n: `
|
|
100
|
+
`,
|
|
101
|
+
r: "\r",
|
|
102
|
+
t: "\t",
|
|
103
|
+
v: "\v",
|
|
104
|
+
"\\": "\\",
|
|
105
|
+
"'": "'",
|
|
106
|
+
'"': '"',
|
|
107
|
+
"?": "?"
|
|
108
|
+
};
|
|
109
|
+
function scan4(input, dialect = "posix") {
|
|
110
|
+
if (input.length > MAX_INPUT_LENGTH)
|
|
111
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
112
|
+
const context = { remaining: MAX_INPUT_LENGTH * MAX_SUBSTITUTION_DEPTH, dialect };
|
|
113
|
+
const result = scanBash(input, 0, 0, context);
|
|
114
|
+
if (result.kind === "opaque")
|
|
115
|
+
return result;
|
|
116
|
+
if (context.boundDollar && context.boundOpen && (context.evalSink || (context.boundBracket || context.sinkBracket) && context.variableSink))
|
|
117
|
+
return { kind: "opaque", reason: "dynamic-execution" };
|
|
118
|
+
return { kind: "scanned", commands: result.commands };
|
|
119
|
+
}
|
|
120
|
+
function bashStatement(state) {
|
|
121
|
+
const structure = state.structures.at(-1);
|
|
122
|
+
if (structure)
|
|
123
|
+
structure.count++;
|
|
124
|
+
}
|
|
125
|
+
function bashInHeader(state) {
|
|
126
|
+
const phase = state.structures.at(-1)?.phase;
|
|
127
|
+
return phase === "header" || phase === "pattern" || phase === "do";
|
|
128
|
+
}
|
|
129
|
+
function atCommandStart(state) {
|
|
130
|
+
return !state.words.length && !state.hasRedirect && !state.compoundEnd && !bashInHeader(state);
|
|
131
|
+
}
|
|
132
|
+
function pending(state) {
|
|
133
|
+
return state.wordStarted || state.words.length > 0 || state.hasRedirect || state.compoundEnd;
|
|
134
|
+
}
|
|
135
|
+
function endBashList(state) {
|
|
136
|
+
if (pending(state))
|
|
137
|
+
finishBashCommand(state, false, true);
|
|
138
|
+
return !state.dangling;
|
|
139
|
+
}
|
|
140
|
+
function closeBashList(state, end) {
|
|
141
|
+
if (!endBashList(state))
|
|
142
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
143
|
+
if (state.invalid)
|
|
144
|
+
return { kind: "opaque", reason: state.invalid };
|
|
145
|
+
if (state.structures.length)
|
|
146
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
147
|
+
return { kind: "scanned", commands: state.commands, end };
|
|
148
|
+
}
|
|
149
|
+
function finishBashWord(state) {
|
|
150
|
+
if (!state.wordStarted)
|
|
151
|
+
return;
|
|
152
|
+
if (/PS4/.test(state.word))
|
|
153
|
+
state.context.evalSink = true;
|
|
154
|
+
const evaluation = bashWordEvaluation(state);
|
|
155
|
+
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)))
|
|
156
|
+
state.invalid ??= "dynamic-execution";
|
|
157
|
+
if (evaluation && bashEvaluatesExpansion(state, evaluation, state.context))
|
|
158
|
+
state.invalid ??= "dynamic-execution";
|
|
159
|
+
if (state.word !== state.literal && state.commandWordIndex >= 0) {
|
|
160
|
+
const builtin = state.words[bashBuiltinIndex(state)];
|
|
161
|
+
if (builtin === "declare" || builtin === "typeset" || builtin === "local")
|
|
162
|
+
state.context.evalSink = true;
|
|
163
|
+
}
|
|
164
|
+
if (state.outer)
|
|
165
|
+
state.outer.output += ` ${state.literal} ${state.output}`;
|
|
166
|
+
const structure = state.structures.at(-1);
|
|
167
|
+
const repeatHeader = structure?.kind === "repeat" && structure.phase === "header";
|
|
168
|
+
if (!state.redirectTarget && repeatHeader)
|
|
169
|
+
structure.phase = "do";
|
|
170
|
+
if (!state.redirectTarget && !repeatHeader) {
|
|
171
|
+
if (!state.assignmentWord && state.commandWordIndex < 0)
|
|
172
|
+
state.commandWordIndex = state.words.length;
|
|
173
|
+
state.commandStart ??= state.wordStart;
|
|
174
|
+
state.words.push(state.word);
|
|
175
|
+
state.rawWords.push(state.input.slice(state.wordStart, state.wordEnd));
|
|
176
|
+
}
|
|
177
|
+
if (state.redirectTarget) {
|
|
178
|
+
if (!state.dupRedirect || !/^(?:\d+-?|-)$/.test(state.input.slice(state.wordStart, state.wordEnd)))
|
|
179
|
+
state.hasFileRedirect = true;
|
|
180
|
+
state.redirectPrefixEnd ??= state.wordEnd;
|
|
181
|
+
}
|
|
182
|
+
state.redirectTarget = false;
|
|
183
|
+
state.dupRedirect = false;
|
|
184
|
+
state.hereString = false;
|
|
185
|
+
state.word = "";
|
|
186
|
+
state.literal = "";
|
|
187
|
+
state.output = "";
|
|
188
|
+
state.wordStarted = false;
|
|
189
|
+
state.assignmentWord = false;
|
|
190
|
+
state.assignmentHeadUnsafe = false;
|
|
191
|
+
}
|
|
192
|
+
function bashWordEvaluation(state) {
|
|
193
|
+
if (state.redirectTarget)
|
|
194
|
+
return state.hereString ? "deferred" : undefined;
|
|
195
|
+
const structure = state.structures.at(-1);
|
|
196
|
+
if (structure?.kind === "repeat" && structure.phase === "header")
|
|
197
|
+
return "arithmetic";
|
|
198
|
+
if (structure?.kind === "for" && structure.phase === "header" && structure.sawIn)
|
|
199
|
+
return "deferred";
|
|
200
|
+
if (state.commandWordIndex < 0)
|
|
201
|
+
return state.assignmentWord ? "deferred" : undefined;
|
|
202
|
+
const name = bashBuiltinIndex(state);
|
|
203
|
+
const command = state.words[name];
|
|
204
|
+
if (command === undefined)
|
|
205
|
+
return;
|
|
206
|
+
if (command === "let" || state.context.dialect !== "bash" && ZSH_ARITHMETIC_BUILTINS.has(command))
|
|
207
|
+
return "arithmetic";
|
|
208
|
+
if (command === "set")
|
|
209
|
+
return state.words.slice(name + 1).some((word) => /^[-+][A-Za-z0-9]*A/.test(word)) ? "binding" : "deferred";
|
|
210
|
+
if (BASH_BINDING_BUILTINS.has(command)) {
|
|
211
|
+
const options = state.words.slice(name + 1);
|
|
212
|
+
if (options.some((word) => word.startsWith("-") && /[EFin]/.test(word)))
|
|
213
|
+
return "arithmetic";
|
|
214
|
+
if (state.assignmentWord && BASH_ASSIGNMENT_DECLARATIONS.has(command) && options.every((word) => !word.startsWith("-")) && (command === "export" || command === "readonly" || state.context.dialect === "zsh" || !/\+?=(?:\(|[$`])/.test(state.word)))
|
|
215
|
+
return "deferred";
|
|
216
|
+
return "binding";
|
|
217
|
+
}
|
|
218
|
+
if (command === "printf" || command === "print") {
|
|
219
|
+
const options = [...state.words.slice(name + 1), state.word];
|
|
220
|
+
const flag = command === "print" ? /^-[A-Za-z]*v/ : /^-v/;
|
|
221
|
+
return options.some((word) => flag.test(word)) ? "binding" : undefined;
|
|
222
|
+
}
|
|
223
|
+
if (command === "wait")
|
|
224
|
+
return /^-[nf]*p/.test(state.word) || /^-[nf]*p$/.test(state.words.at(-1) ?? "") ? "binding" : undefined;
|
|
225
|
+
if (command === "test" || command === "[") {
|
|
226
|
+
if (state.words.at(-1) === "-v")
|
|
227
|
+
return "binding";
|
|
228
|
+
if (state.context.dialect !== "bash" && state.words.at(-1) === "-t")
|
|
229
|
+
return "arithmetic";
|
|
230
|
+
}
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
function bashBuiltinIndex(state) {
|
|
234
|
+
let name = state.commandWordIndex;
|
|
235
|
+
while (BASH_PRECOMMANDS.has(state.words[name] ?? "") || state.context.dialect !== "bash" && ZSH_PRECOMMANDS.has(state.words[name] ?? "")) {
|
|
236
|
+
const precommand = state.words[name++];
|
|
237
|
+
while (precommand !== "-" && state.words[name]?.startsWith("-")) {
|
|
238
|
+
if (precommand === "exec" && /^-[cl]*a$/.test(state.words[name]))
|
|
239
|
+
name++;
|
|
240
|
+
name++;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return name;
|
|
244
|
+
}
|
|
245
|
+
function finishBashCommand(state, boundary = false, newline = false) {
|
|
246
|
+
finishBashWord(state);
|
|
247
|
+
if (state.redirectTarget)
|
|
248
|
+
state.invalid ??= "invalid-redirect";
|
|
249
|
+
state.redirectTarget = false;
|
|
250
|
+
if (state.compoundEnd && state.words.length > 0)
|
|
251
|
+
state.invalid ??= "invalid-structure";
|
|
252
|
+
const name = state.commandWordIndex;
|
|
253
|
+
const inHeader = bashInHeader(state);
|
|
254
|
+
if (name >= 0 && !state.words[name])
|
|
255
|
+
state.invalid ??= "invalid-structure";
|
|
256
|
+
if (name >= 0 && !inHeader) {
|
|
257
|
+
const resource = state.input.slice(state.commandStart, state.wordEnd).replace(/^[ \t\n]+|[ \t\n]+$/g, "");
|
|
258
|
+
const command = {
|
|
259
|
+
resource,
|
|
260
|
+
words: state.words.slice(name),
|
|
261
|
+
rawWords: state.rawWords.slice(name),
|
|
262
|
+
...name === 0 && !state.hasRedirect && BASH_DECLARATIONS.has(state.rawWords[0]) && resource.startsWith(state.rawWords[0]) ? { declaration: true } : {},
|
|
263
|
+
...state.redirectWordCount !== undefined && state.redirectWordCount < state.words.length ? { redirectWordCount: state.redirectWordCount - name } : {}
|
|
264
|
+
};
|
|
265
|
+
state.commands.push(command);
|
|
266
|
+
const builtin = bashBuiltinIndex(state);
|
|
267
|
+
const builtinName = state.words[builtin];
|
|
268
|
+
const builtinArgs = state.words.slice(builtin + 1);
|
|
269
|
+
if (builtinName === "eval")
|
|
270
|
+
state.context.evalSink = true;
|
|
271
|
+
if (builtinName === "set" && builtinArgs.some((word) => /^-[A-Za-z0-9]*k/.test(word) || word === "keyword"))
|
|
272
|
+
state.invalid ??= "dynamic-execution";
|
|
273
|
+
if (builtinName === "alias" && builtinArgs.some((word) => word.includes("=")))
|
|
274
|
+
state.invalid ??= "dynamic-execution";
|
|
275
|
+
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, "")))))
|
|
276
|
+
state.invalid ??= "dynamic-execution";
|
|
277
|
+
if (state.context.dialect !== "zsh" && builtinName === "compgen" && builtinArgs.some((word) => word.startsWith("-") && /[CF]/.test(word)))
|
|
278
|
+
state.invalid ??= "dynamic-execution";
|
|
279
|
+
if (BASH_BINDING_BUILTINS.has(builtinName ?? "")) {
|
|
280
|
+
for (const heredoc of state.heredocs)
|
|
281
|
+
heredoc.binding ??= true;
|
|
282
|
+
}
|
|
283
|
+
for (const heredoc of state.heredocs) {
|
|
284
|
+
if (heredoc.owned)
|
|
285
|
+
continue;
|
|
286
|
+
heredoc.owned = true;
|
|
287
|
+
if (newline) {
|
|
288
|
+
heredoc.command = command;
|
|
289
|
+
heredoc.start = state.commandStart;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
} else if (name < 0 && !inHeader && state.commandStart !== undefined && (state.hasFileRedirect || state.hasRedirect && !state.compoundEnd)) {
|
|
293
|
+
const rawSpan = state.input.slice(state.commandStart, state.wordEnd);
|
|
294
|
+
const leading = /^[ \t\n]+/.exec(rawSpan)?.[0].length ?? 0;
|
|
295
|
+
const resource = rawSpan.slice(leading).replace(/[ \t\n]+$/g, "");
|
|
296
|
+
if (resource) {
|
|
297
|
+
const prefixEnd = state.redirectPrefixEnd !== undefined ? Math.max(1, Math.min(resource.length, state.redirectPrefixEnd - state.commandStart - leading)) : resource.length;
|
|
298
|
+
const prefixToken = resource.slice(0, prefixEnd);
|
|
299
|
+
const command = {
|
|
300
|
+
resource,
|
|
301
|
+
words: [prefixToken],
|
|
302
|
+
rawWords: [prefixToken],
|
|
303
|
+
redirectPrefixEnd: prefixEnd
|
|
304
|
+
};
|
|
305
|
+
state.commands.push(command);
|
|
306
|
+
for (const heredoc of state.heredocs) {
|
|
307
|
+
if (heredoc.owned)
|
|
308
|
+
continue;
|
|
309
|
+
heredoc.owned = true;
|
|
310
|
+
if (newline) {
|
|
311
|
+
heredoc.command = command;
|
|
312
|
+
heredoc.start = state.commandStart;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
for (const heredoc of state.heredocs)
|
|
318
|
+
heredoc.owned = true;
|
|
319
|
+
if (boundary && !state.words.length && !state.hasRedirect && !state.compoundEnd && !inHeader)
|
|
320
|
+
state.invalid ??= "invalid-structure";
|
|
321
|
+
if (state.words.length > (state.ampersandRedirectWords ?? Infinity))
|
|
322
|
+
state.invalid ??= "invalid-redirect";
|
|
323
|
+
state.commands.push(...state.nestedCommands.splice(0));
|
|
324
|
+
if (!inHeader && (state.words.length > 0 || state.hasRedirect))
|
|
325
|
+
bashStatement(state);
|
|
326
|
+
state.words.length = 0;
|
|
327
|
+
state.rawWords.length = 0;
|
|
328
|
+
state.commandWordIndex = -1;
|
|
329
|
+
state.commandStart = undefined;
|
|
330
|
+
state.dupRedirect = false;
|
|
331
|
+
state.hasRedirect = false;
|
|
332
|
+
state.hasFileRedirect = false;
|
|
333
|
+
state.redirectWordCount = undefined;
|
|
334
|
+
state.redirectPrefixEnd = undefined;
|
|
335
|
+
state.ampersandRedirectWords = undefined;
|
|
336
|
+
state.compoundEnd = false;
|
|
337
|
+
state.dangling = false;
|
|
338
|
+
}
|
|
339
|
+
function scanBash(input, start, depth, context, close, heredocs, outer) {
|
|
340
|
+
if (depth > MAX_SUBSTITUTION_DEPTH || context.remaining < 0)
|
|
341
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
342
|
+
const state = {
|
|
343
|
+
input,
|
|
344
|
+
context,
|
|
345
|
+
commands: [],
|
|
346
|
+
nestedCommands: [],
|
|
347
|
+
words: [],
|
|
348
|
+
rawWords: [],
|
|
349
|
+
heredocs: heredocs ?? [],
|
|
350
|
+
structures: [],
|
|
351
|
+
word: "",
|
|
352
|
+
literal: "",
|
|
353
|
+
output: "",
|
|
354
|
+
wordStarted: false,
|
|
355
|
+
wordStart: start,
|
|
356
|
+
wordEnd: start,
|
|
357
|
+
commandStart: undefined,
|
|
358
|
+
redirectWordCount: undefined,
|
|
359
|
+
redirectPrefixEnd: undefined,
|
|
360
|
+
ampersandRedirectWords: undefined,
|
|
361
|
+
commandWordIndex: -1,
|
|
362
|
+
assignmentWord: false,
|
|
363
|
+
assignmentHeadUnsafe: false,
|
|
364
|
+
invalid: undefined,
|
|
365
|
+
redirectTarget: false,
|
|
366
|
+
dupRedirect: false,
|
|
367
|
+
hereString: false,
|
|
368
|
+
hasRedirect: false,
|
|
369
|
+
hasFileRedirect: false,
|
|
370
|
+
compoundEnd: false,
|
|
371
|
+
dangling: false,
|
|
372
|
+
outer
|
|
373
|
+
};
|
|
374
|
+
for (let index = start;index < input.length; index++) {
|
|
375
|
+
if (--context.remaining < 0)
|
|
376
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
377
|
+
const char = input[index];
|
|
378
|
+
if (char === "\\" && input[index + 1] === `
|
|
379
|
+
`) {
|
|
380
|
+
index++;
|
|
381
|
+
continue;
|
|
382
|
+
}
|
|
383
|
+
if (!state.wordStarted) {
|
|
384
|
+
state.wordStart = index;
|
|
385
|
+
if (char === " " || char === "\t")
|
|
386
|
+
continue;
|
|
387
|
+
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))))
|
|
388
|
+
return closeBashList(state, index);
|
|
389
|
+
if (char === "}")
|
|
390
|
+
return { kind: "opaque", reason: state.structures.length ? "compound-command" : "invalid-structure" };
|
|
391
|
+
const step = scanBashCommandStart(state, index, depth, context);
|
|
392
|
+
if (typeof step === "object")
|
|
393
|
+
return step;
|
|
394
|
+
if (step !== undefined) {
|
|
395
|
+
index = step;
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
if (char === "\\" && index + 1 >= input.length)
|
|
400
|
+
return { kind: "opaque", reason: "unterminated-escape" };
|
|
401
|
+
if (!state.assignmentWord && (`'"\\`.includes(char) || char === "$" && (input[index + 1] === "'" || input[index + 1] === '"')))
|
|
402
|
+
state.assignmentHeadUnsafe = true;
|
|
403
|
+
const inCasePattern = state.structures.at(-1)?.phase === "pattern";
|
|
404
|
+
const array = (char === "=" || char === "(") && state.assignmentWord && state.word.length > 1 && state.word.endsWith("=") && !state.word.endsWith("==") && (state.commandWordIndex < 0 || BASH_ASSIGNMENT_DECLARATIONS.has(state.rawWords[state.commandWordIndex]));
|
|
405
|
+
if (char === "=" && (!state.wordStarted || array) && input[index + 1] === "(") {
|
|
406
|
+
const end = scanBashNested(input, index + 2, depth, context, state.nestedCommands, ")");
|
|
407
|
+
if (typeof end === "object")
|
|
408
|
+
return end;
|
|
409
|
+
state.wordStarted = true;
|
|
410
|
+
state.word += input.slice(index, end + 1);
|
|
411
|
+
index = end;
|
|
412
|
+
state.wordEnd = index + 1;
|
|
413
|
+
continue;
|
|
414
|
+
}
|
|
415
|
+
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;
|
|
416
|
+
if (typeof unit === "object")
|
|
417
|
+
return unit;
|
|
418
|
+
if (unit !== undefined) {
|
|
419
|
+
state.wordStarted = true;
|
|
420
|
+
index = unit;
|
|
421
|
+
state.wordEnd = index + 1;
|
|
422
|
+
continue;
|
|
423
|
+
}
|
|
424
|
+
if (char === "[" && !inCasePattern && !state.assignmentWord && !state.assignmentHeadUnsafe && state.commandWordIndex < 0 && /^[A-Za-z_][A-Za-z0-9_]*$/.test(state.word)) {
|
|
425
|
+
const subscript = [];
|
|
426
|
+
const end = scanBashSubscript(input, index + 1, depth, context, subscript, BASH_SPANS.assignmentSubscript);
|
|
427
|
+
if (typeof end === "object")
|
|
428
|
+
return end;
|
|
429
|
+
const assign = bashOperator(input, end + 1, ["+=", "="]);
|
|
430
|
+
if (typeof assign === "object")
|
|
431
|
+
return assign;
|
|
432
|
+
if (assign) {
|
|
433
|
+
if (context.dialect === "posix" && /[$`]/.test(input.slice(index + 1, end)))
|
|
434
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
435
|
+
state.nestedCommands.push(...subscript);
|
|
436
|
+
state.assignmentWord = true;
|
|
437
|
+
state.word += input.slice(index, end + 1);
|
|
438
|
+
index = end;
|
|
439
|
+
state.wordEnd = index + 1;
|
|
440
|
+
continue;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
if (char === "(" && (array || (inCasePattern || context.dialect === "bash") && /[?*+@!]$/.test(state.word))) {
|
|
444
|
+
const mode = array ? "array" : "pattern";
|
|
445
|
+
const end = scanBashArrayOrPattern(input, index, depth + 1, context, state.nestedCommands, mode);
|
|
446
|
+
if (typeof end === "object")
|
|
447
|
+
return end;
|
|
448
|
+
if (bashCrossesHeredoc(state, index, end))
|
|
449
|
+
return { kind: "opaque", reason: "heredoc" };
|
|
450
|
+
if (array && end + 1 < input.length && !`
|
|
451
|
+
;&|<>)`.includes(input[end + 1]))
|
|
452
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
453
|
+
state.wordStarted = true;
|
|
454
|
+
state.word += input.slice(index, end + 1);
|
|
455
|
+
index = end;
|
|
456
|
+
state.wordEnd = index + 1;
|
|
457
|
+
continue;
|
|
458
|
+
}
|
|
459
|
+
if (char === "#" && !state.wordStarted) {
|
|
460
|
+
const newline = input.indexOf(`
|
|
461
|
+
`, index);
|
|
462
|
+
if (newline === -1)
|
|
463
|
+
break;
|
|
464
|
+
index = newline - 1;
|
|
465
|
+
continue;
|
|
466
|
+
}
|
|
467
|
+
if (`<>&|;
|
|
468
|
+
`.includes(char)) {
|
|
469
|
+
const step = scanBashOperatorOrSeparator(state, index, depth, context);
|
|
470
|
+
if (typeof step === "object")
|
|
471
|
+
return step;
|
|
472
|
+
index = step;
|
|
473
|
+
continue;
|
|
474
|
+
}
|
|
475
|
+
if (inCasePattern && char === ")") {
|
|
476
|
+
finishBashWord(state);
|
|
477
|
+
index--;
|
|
478
|
+
continue;
|
|
479
|
+
}
|
|
480
|
+
if (char === ")") {
|
|
481
|
+
if (close !== ")" || state.structures.length > 0 || heredocs === undefined && state.heredocs.length > 0)
|
|
482
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
483
|
+
return closeBashList(state, index);
|
|
484
|
+
}
|
|
485
|
+
if (char === "(" && context.dialect === "zsh" && state.wordStarted && !inCasePattern && (ZSH_GLOB_QUALIFIER_RE.lastIndex = index, ZSH_GLOB_QUALIFIER_RE.test(input))) {
|
|
486
|
+
const end = ZSH_GLOB_QUALIFIER_RE.lastIndex - 1;
|
|
487
|
+
bashAppend(state, input.slice(index, end + 1));
|
|
488
|
+
index = end;
|
|
489
|
+
state.wordEnd = index + 1;
|
|
490
|
+
continue;
|
|
491
|
+
}
|
|
492
|
+
if (char === "(")
|
|
493
|
+
return { kind: "opaque", reason: state.wordStarted ? "dynamic-execution" : "compound-command" };
|
|
494
|
+
if (/\s/.test(char) && !`
|
|
495
|
+
`.includes(char))
|
|
496
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
497
|
+
if (char === " " || char === "\t") {
|
|
498
|
+
finishBashWord(state);
|
|
499
|
+
continue;
|
|
500
|
+
}
|
|
501
|
+
state.wordStarted = true;
|
|
502
|
+
if (char === "=" && !state.assignmentWord && !state.assignmentHeadUnsafe && /^[A-Za-z_][A-Za-z0-9_]*\+?$/.test(state.word))
|
|
503
|
+
state.assignmentWord = true;
|
|
504
|
+
bashAppend(state, char);
|
|
505
|
+
state.wordEnd = index + 1;
|
|
506
|
+
}
|
|
507
|
+
if (close)
|
|
508
|
+
return { kind: "opaque", reason: close === ")" ? "command-substitution" : "invalid-structure" };
|
|
509
|
+
if (state.heredocs.length)
|
|
510
|
+
return { kind: "opaque", reason: "heredoc" };
|
|
511
|
+
return closeBashList(state, input.length);
|
|
512
|
+
}
|
|
513
|
+
function scanBashOperatorOrSeparator(state, index, depth, context) {
|
|
514
|
+
const input = state.input;
|
|
515
|
+
const char = input[index];
|
|
516
|
+
const redirect = "<>&".includes(char) ? bashOperator(input, index, BASH_REDIRECTS) : undefined;
|
|
517
|
+
if (typeof redirect === "object")
|
|
518
|
+
return redirect;
|
|
519
|
+
const caseHead = state.structures.at(-1);
|
|
520
|
+
if (redirect && caseHead?.kind === "case" && caseHead.phase !== "body")
|
|
521
|
+
return { kind: "opaque", reason: "invalid-redirect" };
|
|
522
|
+
if (redirect) {
|
|
523
|
+
state.hasRedirect = true;
|
|
524
|
+
state.commandStart ??= state.wordStart;
|
|
525
|
+
if (state.redirectTarget)
|
|
526
|
+
state.invalid ??= "invalid-redirect";
|
|
527
|
+
const fdPrefix = state.wordStarted && !state.assignmentHeadUnsafe && /^(?:\d+|\{[A-Za-z_][A-Za-z0-9_]*\})$/.test(state.word);
|
|
528
|
+
if (fdPrefix) {
|
|
529
|
+
state.word = "";
|
|
530
|
+
state.literal = "";
|
|
531
|
+
state.output = "";
|
|
532
|
+
state.wordStarted = false;
|
|
533
|
+
}
|
|
534
|
+
if (!fdPrefix)
|
|
535
|
+
finishBashWord(state);
|
|
536
|
+
if (redirect.startsWith("&") && context.dialect === "posix")
|
|
537
|
+
state.ampersandRedirectWords ??= state.words.length;
|
|
538
|
+
if (state.redirectWordCount === undefined && state.commandWordIndex >= 0) {
|
|
539
|
+
state.redirectWordCount = state.words.length;
|
|
540
|
+
}
|
|
541
|
+
if (redirect === "<<" || redirect === "<<-") {
|
|
542
|
+
const delimiter = bashHeredocDelimiter(input, index + redirect.length, redirect === "<<-");
|
|
543
|
+
if (!delimiter)
|
|
544
|
+
return { kind: "opaque", reason: "invalid-redirect" };
|
|
545
|
+
state.hasFileRedirect = true;
|
|
546
|
+
state.redirectPrefixEnd ??= " \t".includes(input[index + redirect.length] ?? "") ? index + redirect.length : delimiter.end + 1;
|
|
547
|
+
state.heredocs.push(delimiter);
|
|
548
|
+
state.wordEnd = delimiter.end + 1;
|
|
549
|
+
state.redirectTarget = false;
|
|
550
|
+
state.dupRedirect = false;
|
|
551
|
+
return delimiter.end;
|
|
552
|
+
}
|
|
553
|
+
if (`
|
|
554
|
+
`.includes(input[index + redirect.length] ?? ""))
|
|
555
|
+
state.redirectPrefixEnd ??= index + redirect.length;
|
|
556
|
+
state.redirectTarget = true;
|
|
557
|
+
state.dupRedirect = redirect === "<&" || redirect === ">&";
|
|
558
|
+
state.hereString = redirect === "<<<";
|
|
559
|
+
return index + redirect.length - 1;
|
|
560
|
+
}
|
|
561
|
+
if (state.structures.at(-1)?.phase === "pattern" && char === "|") {
|
|
562
|
+
finishBashWord(state);
|
|
563
|
+
return index - 1;
|
|
564
|
+
}
|
|
565
|
+
const structure = state.structures.at(-1);
|
|
566
|
+
const caseBody = structure?.kind === "case" && structure.phase === "body";
|
|
567
|
+
const operators = context.dialect === "zsh" ? caseBody ? ZSH_CASE_OPERATORS : ZSH_LIST_OPERATORS : caseBody ? BASH_CASE_OPERATORS : BASH_LIST_OPERATORS;
|
|
568
|
+
const operator = bashOperator(input, index, operators);
|
|
569
|
+
if (typeof operator === "object")
|
|
570
|
+
return operator;
|
|
571
|
+
const separator = operator ?? char;
|
|
572
|
+
if (caseBody && separator.startsWith(";") && separator.length > 1) {
|
|
573
|
+
if (!endBashList(state))
|
|
574
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
575
|
+
structure.phase = "pattern";
|
|
576
|
+
structure.patternStarted = false;
|
|
577
|
+
return index + separator.length - 1;
|
|
578
|
+
}
|
|
579
|
+
if (structure?.kind === "case" && (structure.phase === "header" || structure.phase === "pattern")) {
|
|
580
|
+
if (separator !== `
|
|
581
|
+
`)
|
|
582
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
583
|
+
if (structure.phase === "pattern" && (state.wordStarted || state.words.length > 0))
|
|
584
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
585
|
+
finishBashWord(state);
|
|
586
|
+
return readBashHeredocs(state, index, depth, context);
|
|
587
|
+
}
|
|
588
|
+
if ((structure?.kind === "for" || structure?.kind === "repeat") && (structure.phase === "header" || structure.phase === "do")) {
|
|
589
|
+
if (separator !== ";" && separator !== `
|
|
590
|
+
`)
|
|
591
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
592
|
+
if (structure.phase === "header" && !structure.sawIn && !state.wordStarted && state.words.length === 0)
|
|
593
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
594
|
+
}
|
|
595
|
+
if (separator === `
|
|
596
|
+
` && !pending(state))
|
|
597
|
+
return readBashHeredocs(state, index, depth, context);
|
|
598
|
+
if (separator === ";" && context.dialect === "zsh" && !pending(state) && !state.dangling)
|
|
599
|
+
return index;
|
|
600
|
+
finishBashCommand(state, true, separator === `
|
|
601
|
+
`);
|
|
602
|
+
if (structure?.kind === "for" && structure.phase === "header")
|
|
603
|
+
structure.phase = "do";
|
|
604
|
+
state.dangling = !(separator === ";" || separator === `
|
|
605
|
+
` || separator.startsWith("&") && separator !== "&&");
|
|
606
|
+
if (separator === `
|
|
607
|
+
` && state.heredocs.length)
|
|
608
|
+
return index - 1;
|
|
609
|
+
return index + separator.length - 1;
|
|
610
|
+
}
|
|
611
|
+
function bashCommandKey(command) {
|
|
612
|
+
return JSON.stringify([command.resource, command.words]);
|
|
613
|
+
}
|
|
614
|
+
function readBashHeredocs(state, index, depth, context) {
|
|
615
|
+
let end = index;
|
|
616
|
+
for (const heredoc of state.heredocs.splice(0)) {
|
|
617
|
+
const body = bashHeredoc(state.input, end + 1, heredoc);
|
|
618
|
+
if (!body)
|
|
619
|
+
return { kind: "opaque", reason: "heredoc" };
|
|
620
|
+
if (heredoc.command)
|
|
621
|
+
heredoc.command.resource = state.input.slice(heredoc.start, body.end).trim();
|
|
622
|
+
const text = heredoc.quoted ? { word: body.source, literal: body.source, output: "" } : bashText();
|
|
623
|
+
if (!heredoc.quoted) {
|
|
624
|
+
const expansion = scanBashSpan(body.source, 0, depth, context, state.commands, BASH_SPANS.heredoc, true, text);
|
|
625
|
+
if (typeof expansion === "object")
|
|
626
|
+
return expansion;
|
|
627
|
+
}
|
|
628
|
+
if (heredoc.binding)
|
|
629
|
+
bashEvaluatesExpansion(text, "deferred", context);
|
|
630
|
+
end = body.end;
|
|
631
|
+
}
|
|
632
|
+
return end;
|
|
633
|
+
}
|
|
634
|
+
function bashCrossesHeredoc(state, start, end) {
|
|
635
|
+
return state.heredocs.length > 0 && state.input.slice(start, end).includes(`
|
|
636
|
+
`);
|
|
637
|
+
}
|
|
638
|
+
function scanBashCommandStart(state, index, depth, context) {
|
|
639
|
+
const input = state.input;
|
|
640
|
+
const char = input[index];
|
|
641
|
+
const structure = state.structures.at(-1);
|
|
642
|
+
if (structure?.phase === "pattern" && !structure.patternStarted && !state.words.length && char === "(") {
|
|
643
|
+
structure.patternStarted = true;
|
|
644
|
+
return index;
|
|
645
|
+
}
|
|
646
|
+
if (structure?.phase === "pattern" && char === "|") {
|
|
647
|
+
if (!state.words.length)
|
|
648
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
649
|
+
finishBashWord(state);
|
|
650
|
+
structure.patternStarted = true;
|
|
651
|
+
return index;
|
|
652
|
+
}
|
|
653
|
+
if (structure?.phase === "pattern" && char === ")") {
|
|
654
|
+
if (!state.words.length)
|
|
655
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
656
|
+
finishBashCommand(state);
|
|
657
|
+
structure.phase = "body";
|
|
658
|
+
structure.count = 0;
|
|
659
|
+
return index;
|
|
660
|
+
}
|
|
661
|
+
if (structure?.kind === "for" && structure.phase === "header" && char === "(" && input[index + 1] !== "(") {
|
|
662
|
+
const end = scanBashArrayOrPattern(input, index, depth + 1, context, state.nestedCommands, "array");
|
|
663
|
+
if (typeof end === "object")
|
|
664
|
+
return end;
|
|
665
|
+
if (bashCrossesHeredoc(state, index, end))
|
|
666
|
+
return { kind: "opaque", reason: "heredoc" };
|
|
667
|
+
finishBashCommand(state);
|
|
668
|
+
structure.phase = "do";
|
|
669
|
+
structure.parenthesized = true;
|
|
670
|
+
DO_AHEAD_RE.lastIndex = end + 1;
|
|
671
|
+
if (!DO_AHEAD_RE.test(input))
|
|
672
|
+
state.structures.pop();
|
|
673
|
+
return end;
|
|
674
|
+
}
|
|
675
|
+
if (structure?.kind === "repeat" && structure.phase === "do" && char !== `
|
|
676
|
+
` && char !== "#" && char !== ";") {
|
|
677
|
+
TOKEN_RE.lastIndex = index;
|
|
678
|
+
if (TOKEN_RE.exec(input)?.[0] !== "do")
|
|
679
|
+
state.structures.pop();
|
|
680
|
+
}
|
|
681
|
+
const keywordStep = scanBashKeyword(state, index, depth, context);
|
|
682
|
+
if (keywordStep !== undefined)
|
|
683
|
+
return keywordStep;
|
|
684
|
+
if (structure?.kind === "for" && structure.phase === "do" && char !== `
|
|
685
|
+
` && char !== "#" && char !== ";") {
|
|
686
|
+
SPACE_CONTINUATION_AHEAD_RE.lastIndex = index + 1;
|
|
687
|
+
if (char !== "{" || !SPACE_CONTINUATION_AHEAD_RE.test(input))
|
|
688
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
689
|
+
state.structures.pop();
|
|
690
|
+
}
|
|
691
|
+
const atStart = atCommandStart(state);
|
|
692
|
+
const functionHead = atStart && char === "(" ? bashFunctionHeadLength(input, index) : 0;
|
|
693
|
+
if (functionHead)
|
|
694
|
+
return index + functionHead - 1;
|
|
695
|
+
if (atStart && char === "!") {
|
|
696
|
+
NEGATION_AHEAD_RE.lastIndex = index + 1;
|
|
697
|
+
if (NEGATION_AHEAD_RE.test(input))
|
|
698
|
+
return index;
|
|
699
|
+
}
|
|
700
|
+
const forHeader = structure?.kind === "for" && structure.phase === "header";
|
|
701
|
+
const compoundOpen = (atStart || forHeader) && "([".includes(char) ? bashOperator(input, index, ["((", "[["]) : undefined;
|
|
702
|
+
if (typeof compoundOpen === "object")
|
|
703
|
+
return compoundOpen;
|
|
704
|
+
if (compoundOpen === "((") {
|
|
705
|
+
if (forHeader && state.words.length > 0)
|
|
706
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
707
|
+
const span = forHeader ? BASH_SPANS.forArithmetic : BASH_SPANS.arithmetic;
|
|
708
|
+
const end = scanBashArithmetic(input, index + 2, depth, context, state.commands, span);
|
|
709
|
+
if (typeof end === "number") {
|
|
710
|
+
if (bashCrossesHeredoc(state, index, end))
|
|
711
|
+
return { kind: "opaque", reason: "heredoc" };
|
|
712
|
+
if (!forHeader && context.dialect === "posix") {
|
|
713
|
+
const subshells = scanBash(input, index + 1, depth + 1, context, ")");
|
|
714
|
+
if (subshells.kind === "opaque")
|
|
715
|
+
return subshells;
|
|
716
|
+
if (subshells.end !== end)
|
|
717
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
718
|
+
const seen = new Set(state.commands.map(bashCommandKey));
|
|
719
|
+
state.commands.push(...subshells.commands.filter((command) => !seen.has(bashCommandKey(command))));
|
|
720
|
+
}
|
|
721
|
+
if (forHeader) {
|
|
722
|
+
structure.phase = "do";
|
|
723
|
+
structure.sawIn = true;
|
|
724
|
+
}
|
|
725
|
+
if (!forHeader) {
|
|
726
|
+
bashStatement(state);
|
|
727
|
+
state.compoundEnd = true;
|
|
728
|
+
}
|
|
729
|
+
return end;
|
|
730
|
+
}
|
|
731
|
+
if (end)
|
|
732
|
+
return end;
|
|
733
|
+
if (forHeader)
|
|
734
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
735
|
+
}
|
|
736
|
+
if (atStart && (char === "(" || char === "{" && (SPACE_CONTINUATION_AHEAD_RE.lastIndex = index + 1, SPACE_CONTINUATION_AHEAD_RE.test(input)))) {
|
|
737
|
+
const group = scanBash(input, index + 1, depth + 1, context, char === "{" ? "}" : ")", state.heredocs);
|
|
738
|
+
if (group.kind === "opaque")
|
|
739
|
+
return group;
|
|
740
|
+
if (!input.slice(index + 1, group.end).trim())
|
|
741
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
742
|
+
state.commands.push(...group.commands);
|
|
743
|
+
bashStatement(state);
|
|
744
|
+
state.compoundEnd = true;
|
|
745
|
+
return group.end;
|
|
746
|
+
}
|
|
747
|
+
if (atStart && compoundOpen === "[[" && (SPACE_CONTINUATION_AHEAD_RE.lastIndex = index + 2, SPACE_CONTINUATION_AHEAD_RE.test(input))) {
|
|
748
|
+
const end = scanBashConditional(input, index + 2, depth, context, state.commands);
|
|
749
|
+
if (typeof end === "object")
|
|
750
|
+
return end;
|
|
751
|
+
if (bashCrossesHeredoc(state, index, end))
|
|
752
|
+
return { kind: "opaque", reason: "heredoc" };
|
|
753
|
+
bashStatement(state);
|
|
754
|
+
state.compoundEnd = true;
|
|
755
|
+
return end;
|
|
756
|
+
}
|
|
757
|
+
return;
|
|
758
|
+
}
|
|
759
|
+
function scanBashKeyword(state, index, depth, context) {
|
|
760
|
+
const input = state.input;
|
|
761
|
+
const char = input[index];
|
|
762
|
+
if (!(char >= "A" && char <= "Z" || char >= "a" && char <= "z" || char === "_"))
|
|
763
|
+
return;
|
|
764
|
+
const structure = state.structures.at(-1);
|
|
765
|
+
TOKEN_RE.lastIndex = index;
|
|
766
|
+
const token = TOKEN_RE.exec(input)?.[0];
|
|
767
|
+
const end = index + (token?.length ?? 0) - 1;
|
|
768
|
+
if (structure?.kind === "case" && structure.phase === "header" && token === "in") {
|
|
769
|
+
if (state.words.length !== 1 || state.hasRedirect)
|
|
770
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
771
|
+
finishBashCommand(state);
|
|
772
|
+
structure.phase = "pattern";
|
|
773
|
+
structure.patternStarted = false;
|
|
774
|
+
return end;
|
|
775
|
+
}
|
|
776
|
+
if (structure?.kind === "for" && (structure.phase === "header" || structure.phase === "do") && !structure.sawIn && !structure.parenthesized && token === "in" && (structure.phase === "do" || state.words.length >= 1)) {
|
|
777
|
+
structure.sawIn = true;
|
|
778
|
+
structure.phase = "header";
|
|
779
|
+
return end;
|
|
780
|
+
}
|
|
781
|
+
if (structure?.phase === "pattern" && !structure.patternStarted && !state.words.length && token === "esac") {
|
|
782
|
+
state.structures.pop();
|
|
783
|
+
bashStatement(state);
|
|
784
|
+
state.compoundEnd = true;
|
|
785
|
+
return end;
|
|
786
|
+
}
|
|
787
|
+
if (structure?.kind === "for" && structure.phase === "header" && !structure.sawIn && state.words.length === 1 && !state.hasRedirect && token === "do") {
|
|
788
|
+
finishBashCommand(state);
|
|
789
|
+
structure.phase = "do";
|
|
790
|
+
}
|
|
791
|
+
const inHeader = bashInHeader(state);
|
|
792
|
+
if (token && ["then", "elif", "else", "fi", "do", "done", "esac"].includes(token) && !state.words.length && !state.redirectTarget && (!inHeader || token === "do" && structure?.phase === "do")) {
|
|
793
|
+
if (state.hasRedirect && context.dialect !== "zsh" || !endBashList(state) || !structure)
|
|
794
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
795
|
+
if (token === "then") {
|
|
796
|
+
if (structure.kind !== "if" || structure.phase !== "condition" || !structure.count)
|
|
797
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
798
|
+
structure.phase = "body";
|
|
799
|
+
structure.count = 0;
|
|
800
|
+
return end;
|
|
801
|
+
}
|
|
802
|
+
if (token === "elif" || token === "else") {
|
|
803
|
+
if (structure.kind !== "if" || structure.phase !== "body" || !structure.count || structure.sawElse)
|
|
804
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
805
|
+
structure.phase = token === "elif" ? "condition" : "body";
|
|
806
|
+
structure.sawElse = token === "else";
|
|
807
|
+
structure.count = 0;
|
|
808
|
+
return end;
|
|
809
|
+
}
|
|
810
|
+
if (token === "do") {
|
|
811
|
+
if (!["for", "while", "until", "repeat"].includes(structure.kind) || !["condition", "do"].includes(structure.phase) || structure.kind !== "for" && structure.kind !== "repeat" && !structure.count)
|
|
812
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
813
|
+
structure.phase = "body";
|
|
814
|
+
structure.count = 0;
|
|
815
|
+
return end;
|
|
816
|
+
}
|
|
817
|
+
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"))
|
|
818
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
819
|
+
state.structures.pop();
|
|
820
|
+
bashStatement(state);
|
|
821
|
+
state.compoundEnd = true;
|
|
822
|
+
return end;
|
|
823
|
+
}
|
|
824
|
+
if (!atCommandStart(state))
|
|
825
|
+
return;
|
|
826
|
+
const definitionLength = bashFunctionHeadLength(input, index);
|
|
827
|
+
if (definitionLength > 0)
|
|
828
|
+
return index + definitionLength - 1;
|
|
829
|
+
if (token === "if" || token === "while" || token === "until" || token === "for" || token === "select" || token === "case" || token === "repeat" && context.dialect !== "bash") {
|
|
830
|
+
if (depth + state.structures.length >= MAX_SUBSTITUTION_DEPTH)
|
|
831
|
+
return { kind: "opaque", reason: "compound-command" };
|
|
832
|
+
state.structures.push({
|
|
833
|
+
kind: token === "select" ? "for" : token,
|
|
834
|
+
phase: ["for", "select", "case", "repeat"].includes(token) ? "header" : "condition",
|
|
835
|
+
count: 0
|
|
836
|
+
});
|
|
837
|
+
state.dangling = false;
|
|
838
|
+
return end;
|
|
839
|
+
}
|
|
840
|
+
if (token === "coproc") {
|
|
841
|
+
COPROC_AHEAD_RE.lastIndex = index;
|
|
842
|
+
const coprocMatch = COPROC_AHEAD_RE.exec(input)?.[0];
|
|
843
|
+
if (coprocMatch)
|
|
844
|
+
return index + coprocMatch.length - 1;
|
|
845
|
+
}
|
|
846
|
+
if (token === "time") {
|
|
847
|
+
TIME_AHEAD_RE.lastIndex = index;
|
|
848
|
+
const timeMatch = TIME_AHEAD_RE.exec(input)?.[0];
|
|
849
|
+
if (timeMatch)
|
|
850
|
+
return index + timeMatch.length - 1;
|
|
851
|
+
}
|
|
852
|
+
return;
|
|
853
|
+
}
|
|
854
|
+
function bashFunctionHeadLength(input, start) {
|
|
855
|
+
FUNCTION_HEAD_RE.lastIndex = start;
|
|
856
|
+
const head = FUNCTION_HEAD_RE.exec(input);
|
|
857
|
+
if (!head || (head[1] ? !head[2] : !head[3] || BASH_NON_FUNCTION_KEYWORDS.has(head[2] ?? "")))
|
|
858
|
+
return 0;
|
|
859
|
+
FUNCTION_BODY_RE.lastIndex = start + head[0].length;
|
|
860
|
+
return FUNCTION_BODY_RE.test(input) ? head[0].length - head[4].length : 0;
|
|
861
|
+
}
|
|
862
|
+
var BASH_SPANS = {
|
|
863
|
+
double: { close: '"', reject: "", mode: "quoted" },
|
|
864
|
+
heredoc: { reject: "", mode: "quoted" },
|
|
865
|
+
arithmetic: { open: "(", close: ")", reject: ";#}", mode: "arithmetic" },
|
|
866
|
+
forArithmetic: { open: "(", close: ")", reject: "#}", mode: "arithmetic" },
|
|
867
|
+
bracketArithmetic: { close: "]", reject: `;|&<>()[
|
|
868
|
+
'"\\#`, mode: "arithmetic" },
|
|
869
|
+
subscript: { open: "[", close: "]", reject: '"}', mode: "arithmetic" },
|
|
870
|
+
quotedSubscript: { open: "[", close: "]", reject: '"', mode: "quoted" },
|
|
871
|
+
assignmentSubscript: { open: "[", close: "]", reject: `
|
|
872
|
+
\r\v\f;&|<>()`, mode: "arithmetic" },
|
|
873
|
+
arithmeticQuote: { close: "'", reject: '()[];"}', mode: "quoted" },
|
|
874
|
+
arithmeticDouble: { close: '"', reject: "()[];}", mode: "quoted" },
|
|
875
|
+
parameterQuote: { close: "'", reject: '"}[]', mode: "quoted" }
|
|
876
|
+
};
|
|
877
|
+
function scanBashUnit(input, index, depth, context, commands, mode, allowBracket, text) {
|
|
878
|
+
const char = input[index];
|
|
879
|
+
const next = input[index + 1] ?? "\x00";
|
|
880
|
+
if (char === "\\") {
|
|
881
|
+
if (mode === "quoted" && !'$`"\\\n'.includes(next))
|
|
882
|
+
return;
|
|
883
|
+
if (text && next !== `
|
|
884
|
+
`)
|
|
885
|
+
bashAppend(text, input.slice(index + 1, index + 2));
|
|
886
|
+
return index + 1;
|
|
887
|
+
}
|
|
888
|
+
if (char === "$" && context.dialect !== "bash" && zshEvaluates(input, index))
|
|
889
|
+
return { kind: "opaque", reason: "dynamic-execution" };
|
|
890
|
+
if (char === "$" && context.dialect !== "bash" && (mode === "word" || mode === "quoted") && (ZSH_SUBSCRIPT_RE.lastIndex = index, ZSH_SUBSCRIPT_RE.test(input))) {
|
|
891
|
+
const bracket = ZSH_SUBSCRIPT_RE.lastIndex;
|
|
892
|
+
const subscript = bashText();
|
|
893
|
+
const span = mode === "quoted" ? BASH_SPANS.quotedSubscript : BASH_SPANS.subscript;
|
|
894
|
+
const end = scanBashSpan(input, bracket, depth, context, commands, span, false, subscript);
|
|
895
|
+
if (typeof end === "object")
|
|
896
|
+
return end;
|
|
897
|
+
context.sinkBracket = true;
|
|
898
|
+
if (bashEvaluatesExpansion(subscript, "arithmetic", context))
|
|
899
|
+
return { kind: "opaque", reason: "dynamic-execution" };
|
|
900
|
+
if (text)
|
|
901
|
+
text.word += `${input.slice(index, bracket)}${subscript.word}]`;
|
|
902
|
+
return end;
|
|
903
|
+
}
|
|
904
|
+
const opener = char === "$" ? bashOperator(input, index, ["$$", "$((", "$(", "${", "$[", "$'", '$"']) : mode === "word" && (char === "<" || char === ">") ? bashOperator(input, index, [`${char}(`]) : undefined;
|
|
905
|
+
if (typeof opener === "object")
|
|
906
|
+
return opener;
|
|
907
|
+
if (opener === "$$") {
|
|
908
|
+
LINE_CONTINUATION_RE.lastIndex = index + 2;
|
|
909
|
+
const quoteStart = LINE_CONTINUATION_RE.exec(input) ? LINE_CONTINUATION_RE.lastIndex : index + 2;
|
|
910
|
+
if (input[quoteStart] === "'") {
|
|
911
|
+
const nextQuote = input.indexOf("'", quoteStart + 1);
|
|
912
|
+
if (nextQuote < 0)
|
|
913
|
+
return { kind: "opaque", reason: "unterminated-quote" };
|
|
914
|
+
if (input.slice(quoteStart + 1, nextQuote).includes("\\") && input.includes("'", nextQuote + 1))
|
|
915
|
+
return { kind: "opaque", reason: "unterminated-quote" };
|
|
916
|
+
}
|
|
917
|
+
if (text)
|
|
918
|
+
text.word += "$$";
|
|
919
|
+
return index + 1;
|
|
920
|
+
}
|
|
921
|
+
if (mode === "word" && opener === "$'") {
|
|
922
|
+
const quote = bashAnsiQuote(input, index + 1);
|
|
923
|
+
if (!quote)
|
|
924
|
+
return { kind: "opaque", reason: "unterminated-quote" };
|
|
925
|
+
const firstQuote = input.indexOf("'", index + 2);
|
|
926
|
+
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)))))
|
|
927
|
+
return { kind: "opaque", reason: "unterminated-quote" };
|
|
928
|
+
if (text)
|
|
929
|
+
bashAppend(text, quote.value);
|
|
930
|
+
return quote.end;
|
|
931
|
+
}
|
|
932
|
+
if (mode === "arithmetic" && opener === "$'") {
|
|
933
|
+
const quote = bashAnsiQuote(input, index + 1);
|
|
934
|
+
if (!quote || quote.end !== input.indexOf("'", index + 2) || /[()[\];"}]/.test(quote.value))
|
|
935
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
936
|
+
if (text)
|
|
937
|
+
bashAppend(text, quote.value);
|
|
938
|
+
return scanBashSpan(input, index + 2, depth, context, commands, BASH_SPANS.arithmeticQuote, allowBracket, text);
|
|
939
|
+
}
|
|
940
|
+
if (mode === "word" && char === "'") {
|
|
941
|
+
const end = input.indexOf("'", index + 1);
|
|
942
|
+
if (end < 0)
|
|
943
|
+
return { kind: "opaque", reason: "unterminated-quote" };
|
|
944
|
+
if (text)
|
|
945
|
+
bashAppend(text, input.slice(index + 1, end));
|
|
946
|
+
return end;
|
|
947
|
+
}
|
|
948
|
+
if (mode === "arithmetic" && char === "'")
|
|
949
|
+
return scanBashSpan(input, index + 1, depth, context, commands, BASH_SPANS.arithmeticQuote, allowBracket, text);
|
|
950
|
+
if (mode === "word" && opener === '$"')
|
|
951
|
+
return scanBashSpan(input, index + 2, depth, context, commands, BASH_SPANS.double, allowBracket, text);
|
|
952
|
+
if (mode !== "quoted" && char === '"') {
|
|
953
|
+
const span = mode === "arithmetic" ? BASH_SPANS.arithmeticDouble : BASH_SPANS.double;
|
|
954
|
+
return scanBashSpan(input, index + 1, depth, context, commands, span, allowBracket, text);
|
|
955
|
+
}
|
|
956
|
+
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;
|
|
957
|
+
if (end === undefined && char === "$" && /[A-Za-z_0-9@*#?$!-]/.test(next)) {
|
|
958
|
+
if (text)
|
|
959
|
+
text.word += "$";
|
|
960
|
+
return index;
|
|
961
|
+
}
|
|
962
|
+
if (text && typeof end === "number")
|
|
963
|
+
text.word += input.slice(index, end + 1);
|
|
964
|
+
return end;
|
|
965
|
+
}
|
|
966
|
+
function zshEvaluates(input, index) {
|
|
967
|
+
let at = index + 1;
|
|
968
|
+
if (input.startsWith("{\\\n", at))
|
|
969
|
+
return true;
|
|
970
|
+
if (input[at] === "{" && input[at + 1] === "(") {
|
|
971
|
+
ZSH_SAFE_FLAGS_RE.lastIndex = index;
|
|
972
|
+
if (!ZSH_SAFE_FLAGS_RE.test(input))
|
|
973
|
+
return true;
|
|
974
|
+
at = ZSH_SAFE_FLAGS_RE.lastIndex;
|
|
975
|
+
}
|
|
976
|
+
if (input[at] === "{")
|
|
977
|
+
at++;
|
|
978
|
+
ZSH_GLOB_MODIFIER_RE.lastIndex = at;
|
|
979
|
+
return ZSH_GLOB_MODIFIER_RE.test(input);
|
|
980
|
+
}
|
|
981
|
+
function bashAppend(text, value) {
|
|
982
|
+
text.word += value;
|
|
983
|
+
text.literal += value;
|
|
984
|
+
}
|
|
985
|
+
function bashEvaluatesExpansion(text, evaluation, context) {
|
|
986
|
+
const combined = `${text.literal} ${text.output}`;
|
|
987
|
+
const hasExpansion = BASH_EXPANSION_RE.test(combined);
|
|
988
|
+
const hasEscape = BASH_ESCAPE_RE.test(combined);
|
|
989
|
+
if (hasExpansion || hasEscape || /[$`]/.test(text.literal))
|
|
990
|
+
context.boundDollar = true;
|
|
991
|
+
if (hasExpansion || hasEscape || /[({`]/.test(text.literal))
|
|
992
|
+
context.boundOpen = true;
|
|
993
|
+
if (hasExpansion || hasEscape || text.output.trim() || combined.includes("["))
|
|
994
|
+
context.boundBracket = true;
|
|
995
|
+
if (evaluation === "deferred")
|
|
996
|
+
return false;
|
|
997
|
+
if (text.word.includes("[") || combined.includes("["))
|
|
998
|
+
context.sinkBracket = true;
|
|
999
|
+
if (evaluation === "arithmetic" ? /[A-Za-z_]|(?:\$(?![?#!-]|\$(?!\[)))/.test(text.word) : text.word.includes("$") || combined.includes("["))
|
|
1000
|
+
context.variableSink = true;
|
|
1001
|
+
if (evaluation === "arithmetic")
|
|
1002
|
+
return hasExpansion;
|
|
1003
|
+
return combined.includes("[") && hasExpansion;
|
|
1004
|
+
}
|
|
1005
|
+
function bashText() {
|
|
1006
|
+
return { word: "", literal: "", output: "" };
|
|
1007
|
+
}
|
|
1008
|
+
function scanBashSubscript(input, start, depth, context, commands, span = BASH_SPANS.subscript) {
|
|
1009
|
+
const text = bashText();
|
|
1010
|
+
const end = scanBashSpan(input, start, depth, context, commands, span, false, text);
|
|
1011
|
+
if (typeof end === "number") {
|
|
1012
|
+
context.sinkBracket = true;
|
|
1013
|
+
if (bashEvaluatesExpansion(text, "arithmetic", context))
|
|
1014
|
+
return { kind: "opaque", reason: "dynamic-execution" };
|
|
1015
|
+
}
|
|
1016
|
+
return end;
|
|
1017
|
+
}
|
|
1018
|
+
function scanBashSpan(input, start, depth, context, commands, span, allowBracket, text) {
|
|
1019
|
+
let nesting = 0;
|
|
1020
|
+
for (let index = start;index < input.length; index++) {
|
|
1021
|
+
if (--context.remaining < 0)
|
|
1022
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1023
|
+
const char = input[index];
|
|
1024
|
+
if (char === span.close && !nesting)
|
|
1025
|
+
return index;
|
|
1026
|
+
if (span.reject.includes(char) && !(char === "#" && /[\d$]/.test(input[index - 1] ?? "")))
|
|
1027
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1028
|
+
if (char === span.open && ++nesting + depth > MAX_SUBSTITUTION_DEPTH)
|
|
1029
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1030
|
+
if (char === span.close)
|
|
1031
|
+
nesting--;
|
|
1032
|
+
const unit = char === span.open || char === span.close ? undefined : scanBashUnit(input, index, depth, context, commands, span.mode, allowBracket, text);
|
|
1033
|
+
if (typeof unit === "object")
|
|
1034
|
+
return unit;
|
|
1035
|
+
if (unit !== undefined)
|
|
1036
|
+
index = unit;
|
|
1037
|
+
else if (char === "\\" && (input[index + 1] === span.open || input[index + 1] === span.close)) {
|
|
1038
|
+
if (text)
|
|
1039
|
+
bashAppend(text, input.slice(index, index + 2));
|
|
1040
|
+
index++;
|
|
1041
|
+
} else if (text)
|
|
1042
|
+
bashAppend(text, char);
|
|
1043
|
+
}
|
|
1044
|
+
return span.close ? { kind: "opaque", reason: "unterminated-quote" } : input.length;
|
|
1045
|
+
}
|
|
1046
|
+
function scanBashNested(input, start, depth, context, commands, close, text) {
|
|
1047
|
+
const nested = scanBash(input, start, depth + 1, context, close, undefined, text);
|
|
1048
|
+
if (nested.kind === "opaque")
|
|
1049
|
+
return nested;
|
|
1050
|
+
commands.push(...nested.commands);
|
|
1051
|
+
return nested.end;
|
|
1052
|
+
}
|
|
1053
|
+
function bashOperator(input, index, operators) {
|
|
1054
|
+
let text = "";
|
|
1055
|
+
for (let cursor = index;text.length < 3 && cursor < input.length; cursor++) {
|
|
1056
|
+
if (input.startsWith("\\\n", cursor))
|
|
1057
|
+
cursor++;
|
|
1058
|
+
else
|
|
1059
|
+
text += input[cursor];
|
|
1060
|
+
}
|
|
1061
|
+
const operator = operators.find((candidate) => text.startsWith(candidate));
|
|
1062
|
+
if (operator && !input.startsWith(operator, index))
|
|
1063
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1064
|
+
return operator;
|
|
1065
|
+
}
|
|
1066
|
+
function scanBashDollarOrBacktick(input, start, depth, context, commands, quoted, allowBracket, text) {
|
|
1067
|
+
if (depth >= MAX_SUBSTITUTION_DEPTH)
|
|
1068
|
+
return { kind: "opaque", reason: "command-substitution" };
|
|
1069
|
+
if (input[start] === "`")
|
|
1070
|
+
return scanBashBacktick(input, start, depth + 1, context, commands, quoted, text);
|
|
1071
|
+
if (input.startsWith("$((", start)) {
|
|
1072
|
+
const end = scanBashArithmetic(input, start + 3, depth + 1, context, commands, BASH_SPANS.arithmetic);
|
|
1073
|
+
if (end !== undefined)
|
|
1074
|
+
return end;
|
|
1075
|
+
}
|
|
1076
|
+
if (input.startsWith("$(", start))
|
|
1077
|
+
return scanBashNested(input, start + 2, depth, context, commands, ")", text);
|
|
1078
|
+
NOFORK_OPEN_RE.lastIndex = start;
|
|
1079
|
+
const nofork = NOFORK_OPEN_RE.exec(input);
|
|
1080
|
+
if (nofork)
|
|
1081
|
+
return scanBashNested(input, start + nofork[0].length, depth, context, commands, "nofork", text);
|
|
1082
|
+
if (input.startsWith("${", start)) {
|
|
1083
|
+
const parameter = bashText();
|
|
1084
|
+
const end = scanBashParameter(input, start + 2, depth + 1, context, commands, quoted, parameter);
|
|
1085
|
+
const indirect = /^(?:\\\n)*!/.test(input.slice(start + 2)) || context.dialect !== "bash" && input[start + 2] === "(" && (ZSH_SAFE_FLAGS_RE.lastIndex = start, ZSH_SAFE_FLAGS_RE.test(input)) && input.slice(start + 3, ZSH_SAFE_FLAGS_RE.lastIndex - 1).replace(ZSH_QUOTED_FLAG_ARG_RE, "").includes("P");
|
|
1086
|
+
if (indirect) {
|
|
1087
|
+
context.variableSink = true;
|
|
1088
|
+
if (bashEvaluatesExpansion(parameter, "binding", context))
|
|
1089
|
+
return { kind: "opaque", reason: "dynamic-execution" };
|
|
1090
|
+
}
|
|
1091
|
+
if (text) {
|
|
1092
|
+
text.literal += parameter.literal;
|
|
1093
|
+
text.output += parameter.output;
|
|
1094
|
+
}
|
|
1095
|
+
return end;
|
|
1096
|
+
}
|
|
1097
|
+
if (!allowBracket && context.dialect === "posix")
|
|
1098
|
+
return { kind: "opaque", reason: "command-substitution" };
|
|
1099
|
+
const expression = bashText();
|
|
1100
|
+
const end = scanBashSpan(input, start + 2, depth + 1, context, commands, BASH_SPANS.bracketArithmetic, true, expression);
|
|
1101
|
+
if (typeof end === "number" && bashEvaluatesExpansion(expression, "arithmetic", context))
|
|
1102
|
+
return { kind: "opaque", reason: "dynamic-execution" };
|
|
1103
|
+
return end;
|
|
1104
|
+
}
|
|
1105
|
+
function scanBashArithmetic(input, start, depth, context, commands, span) {
|
|
1106
|
+
const arithmetic = [];
|
|
1107
|
+
const text = bashText();
|
|
1108
|
+
const end = scanBashSpan(input, start, depth, context, arithmetic, span, true, text);
|
|
1109
|
+
if (typeof end === "object")
|
|
1110
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1111
|
+
const close = bashOperator(input, end, ["))"]);
|
|
1112
|
+
if (typeof close === "object")
|
|
1113
|
+
return close;
|
|
1114
|
+
if (!close)
|
|
1115
|
+
return;
|
|
1116
|
+
if (bashEvaluatesExpansion(text, "arithmetic", context))
|
|
1117
|
+
return { kind: "opaque", reason: "dynamic-execution" };
|
|
1118
|
+
commands.push(...arithmetic);
|
|
1119
|
+
return end + 1;
|
|
1120
|
+
}
|
|
1121
|
+
function scanBashBacktick(input, start, depth, context, commands, quoted, text) {
|
|
1122
|
+
let source = "";
|
|
1123
|
+
for (let index = start + 1;index < input.length; index++) {
|
|
1124
|
+
if (--context.remaining < 0)
|
|
1125
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1126
|
+
if (input[index] === "`") {
|
|
1127
|
+
const inner = scanBash(source, 0, depth, context, undefined, undefined, text);
|
|
1128
|
+
if (inner.kind === "opaque")
|
|
1129
|
+
return { kind: "opaque", reason: "command-substitution" };
|
|
1130
|
+
commands.push(...inner.commands);
|
|
1131
|
+
return index;
|
|
1132
|
+
}
|
|
1133
|
+
const next = input[index + 1] ?? "\x00";
|
|
1134
|
+
if (input[index] === "\\" && ("$`\\\n".includes(next) || quoted && next === '"')) {
|
|
1135
|
+
index++;
|
|
1136
|
+
if (next !== `
|
|
1137
|
+
`)
|
|
1138
|
+
source += next;
|
|
1139
|
+
continue;
|
|
1140
|
+
}
|
|
1141
|
+
source += input[index];
|
|
1142
|
+
}
|
|
1143
|
+
return { kind: "opaque", reason: "command-substitution" };
|
|
1144
|
+
}
|
|
1145
|
+
function scanBashParameter(input, start, depth, context, commands, quoted, text) {
|
|
1146
|
+
PARAMETER_PREFIX_RE.lastIndex = start;
|
|
1147
|
+
const nameStart = PARAMETER_PREFIX_RE.exec(input) ? PARAMETER_PREFIX_RE.lastIndex : start;
|
|
1148
|
+
PARAMETER_NAME_RE.lastIndex = nameStart;
|
|
1149
|
+
let colon = PARAMETER_NAME_RE.test(input) ? PARAMETER_NAME_RE.lastIndex : -1;
|
|
1150
|
+
const name = colon > nameStart ? input.slice(nameStart, colon).replace(/\\\n/g, "") : "";
|
|
1151
|
+
if (context.dialect !== "bash" && (/^(?:READ)?NULLCMD$/.test(name) || /^(?:(?:dis_)?(?:functions|[gs]?aliases)|options|commands)$/.test(name) && "[=:".includes(input[colon] ?? "")))
|
|
1152
|
+
return { kind: "opaque", reason: "dynamic-execution" };
|
|
1153
|
+
if (name === "PS4")
|
|
1154
|
+
context.evalSink = true;
|
|
1155
|
+
let evaluation;
|
|
1156
|
+
let wordOffset = 0;
|
|
1157
|
+
let literalOffset = 0;
|
|
1158
|
+
for (let index = start;index < input.length; index++) {
|
|
1159
|
+
if (--context.remaining < 0)
|
|
1160
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1161
|
+
const char = input[index];
|
|
1162
|
+
if (char === "}") {
|
|
1163
|
+
if (evaluation && bashEvaluatesExpansion({ word: text.word.slice(wordOffset), literal: text.literal.slice(literalOffset), output: text.output }, evaluation, context))
|
|
1164
|
+
return { kind: "opaque", reason: "dynamic-execution" };
|
|
1165
|
+
return index;
|
|
1166
|
+
}
|
|
1167
|
+
if (index === colon && !evaluation) {
|
|
1168
|
+
if (char === ":" && !"-=?+".includes(input[index + 1] ?? ""))
|
|
1169
|
+
evaluation = "arithmetic";
|
|
1170
|
+
if (char === "=" || char === ":" && input[index + 1] === "=")
|
|
1171
|
+
evaluation = "deferred";
|
|
1172
|
+
if (evaluation) {
|
|
1173
|
+
wordOffset = text.word.length;
|
|
1174
|
+
literalOffset = text.literal.length;
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
if (char === "@") {
|
|
1178
|
+
PARAMETER_PROMPT_RE.lastIndex = index;
|
|
1179
|
+
if (PARAMETER_PROMPT_RE.test(input))
|
|
1180
|
+
return { kind: "opaque", reason: "dynamic-execution" };
|
|
1181
|
+
}
|
|
1182
|
+
if (!quoted && context.dialect !== "bash" && char === "(" && index > start)
|
|
1183
|
+
return { kind: "opaque", reason: "dynamic-execution" };
|
|
1184
|
+
if (quoted && char === "'" && input[index - 1] === "$") {
|
|
1185
|
+
const ansi = bashAnsiQuote(input, index);
|
|
1186
|
+
if (!ansi)
|
|
1187
|
+
return { kind: "opaque", reason: "unterminated-quote" };
|
|
1188
|
+
text.literal += ansi.value;
|
|
1189
|
+
}
|
|
1190
|
+
const subscript = index === colon && char === "[";
|
|
1191
|
+
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);
|
|
1192
|
+
if (typeof unit === "object")
|
|
1193
|
+
return unit;
|
|
1194
|
+
if (quoted && unit !== undefined && input.startsWith("$(", index) && input.slice(index, unit + 1).includes("}"))
|
|
1195
|
+
return { kind: "opaque", reason: "command-substitution" };
|
|
1196
|
+
if (subscript || index === nameStart && input.startsWith("${", index) && unit !== undefined) {
|
|
1197
|
+
LINE_CONTINUATION_RE.lastIndex = Number(unit) + 1;
|
|
1198
|
+
colon = LINE_CONTINUATION_RE.exec(input) ? LINE_CONTINUATION_RE.lastIndex : Number(unit) + 1;
|
|
1199
|
+
}
|
|
1200
|
+
if (unit !== undefined)
|
|
1201
|
+
index = unit;
|
|
1202
|
+
else
|
|
1203
|
+
bashAppend(text, char);
|
|
1204
|
+
}
|
|
1205
|
+
return { kind: "opaque", reason: "command-substitution" };
|
|
1206
|
+
}
|
|
1207
|
+
function scanBashConditional(input, start, depth, context, commands) {
|
|
1208
|
+
const words = [];
|
|
1209
|
+
let text = bashText();
|
|
1210
|
+
let wordStarted = false;
|
|
1211
|
+
let hasWord = false;
|
|
1212
|
+
let parenDepth = 0;
|
|
1213
|
+
let patternParenDepth = 0;
|
|
1214
|
+
const flushWord = () => {
|
|
1215
|
+
if (!hasWord)
|
|
1216
|
+
return;
|
|
1217
|
+
words.push(text);
|
|
1218
|
+
text = bashText();
|
|
1219
|
+
hasWord = false;
|
|
1220
|
+
};
|
|
1221
|
+
for (let index = start;index < input.length; index++) {
|
|
1222
|
+
if (--context.remaining < 0)
|
|
1223
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1224
|
+
const char = input[index];
|
|
1225
|
+
if (char === "\\" && input[index + 1] === `
|
|
1226
|
+
`) {
|
|
1227
|
+
index++;
|
|
1228
|
+
continue;
|
|
1229
|
+
}
|
|
1230
|
+
if (!wordStarted)
|
|
1231
|
+
flushWord();
|
|
1232
|
+
const close = !wordStarted && char === "]" ? bashOperator(input, index, ["]]"]) : undefined;
|
|
1233
|
+
if (typeof close === "object")
|
|
1234
|
+
return close;
|
|
1235
|
+
if (close) {
|
|
1236
|
+
BRACE_CLOSE_AHEAD_RE.lastIndex = index + 2;
|
|
1237
|
+
if (BRACE_CLOSE_AHEAD_RE.test(input)) {
|
|
1238
|
+
if (parenDepth !== 0)
|
|
1239
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1240
|
+
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));
|
|
1241
|
+
if (evaluated)
|
|
1242
|
+
return { kind: "opaque", reason: "dynamic-execution" };
|
|
1243
|
+
return index + 1;
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
if (!wordStarted && char === "#") {
|
|
1247
|
+
const newline = input.indexOf(`
|
|
1248
|
+
`, index);
|
|
1249
|
+
if (newline < 0)
|
|
1250
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1251
|
+
index = newline;
|
|
1252
|
+
continue;
|
|
1253
|
+
}
|
|
1254
|
+
if (char === " " || char === "\t" || char === `
|
|
1255
|
+
`) {
|
|
1256
|
+
if (!patternParenDepth)
|
|
1257
|
+
wordStarted = false;
|
|
1258
|
+
continue;
|
|
1259
|
+
}
|
|
1260
|
+
if (char === ";")
|
|
1261
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1262
|
+
if (char === "(" || char === ")") {
|
|
1263
|
+
if (char === ")" && parenDepth === 0)
|
|
1264
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1265
|
+
const inPattern = patternParenDepth > 0 || char === "(" && ["=", "==", "!=", "=~"].includes(words.at(-1)?.word ?? "");
|
|
1266
|
+
parenDepth += char === "(" ? 1 : -1;
|
|
1267
|
+
if (inPattern) {
|
|
1268
|
+
patternParenDepth += char === "(" ? 1 : -1;
|
|
1269
|
+
wordStarted = true;
|
|
1270
|
+
hasWord = true;
|
|
1271
|
+
bashAppend(text, char);
|
|
1272
|
+
continue;
|
|
1273
|
+
}
|
|
1274
|
+
flushWord();
|
|
1275
|
+
words.push({ word: char, literal: "", output: "" });
|
|
1276
|
+
wordStarted = false;
|
|
1277
|
+
continue;
|
|
1278
|
+
}
|
|
1279
|
+
const unit = scanBashUnit(input, index, depth, context, commands, "word", true, text);
|
|
1280
|
+
if (typeof unit === "object")
|
|
1281
|
+
return unit;
|
|
1282
|
+
if (unit !== undefined)
|
|
1283
|
+
index = unit;
|
|
1284
|
+
if (unit === undefined && !patternParenDepth && "&|<>".includes(char)) {
|
|
1285
|
+
flushWord();
|
|
1286
|
+
words.push({ word: char, literal: "", output: "" });
|
|
1287
|
+
wordStarted = false;
|
|
1288
|
+
continue;
|
|
1289
|
+
}
|
|
1290
|
+
wordStarted = true;
|
|
1291
|
+
hasWord = true;
|
|
1292
|
+
if (unit === undefined)
|
|
1293
|
+
bashAppend(text, char);
|
|
1294
|
+
}
|
|
1295
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1296
|
+
}
|
|
1297
|
+
function scanBashArrayOrPattern(input, start, depth, context, commands, mode) {
|
|
1298
|
+
if (depth > MAX_SUBSTITUTION_DEPTH)
|
|
1299
|
+
return { kind: "opaque", reason: "command-substitution" };
|
|
1300
|
+
const text = mode === "array" ? bashText() : undefined;
|
|
1301
|
+
let wordStarted = false;
|
|
1302
|
+
for (let index = start + 1;index < input.length; index++) {
|
|
1303
|
+
if (--context.remaining < 0)
|
|
1304
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1305
|
+
const char = input[index];
|
|
1306
|
+
if (char === "\\" && input[index + 1] === `
|
|
1307
|
+
`) {
|
|
1308
|
+
index++;
|
|
1309
|
+
continue;
|
|
1310
|
+
}
|
|
1311
|
+
if (text && (char === ")" || char === " " || char === "\t" || char === `
|
|
1312
|
+
`)) {
|
|
1313
|
+
bashEvaluatesExpansion(text, "deferred", context);
|
|
1314
|
+
text.literal = "";
|
|
1315
|
+
text.output = "";
|
|
1316
|
+
}
|
|
1317
|
+
if (char === ")")
|
|
1318
|
+
return index;
|
|
1319
|
+
if (mode === "array" && !wordStarted && char === "#") {
|
|
1320
|
+
const newline = input.indexOf(`
|
|
1321
|
+
`, index);
|
|
1322
|
+
if (newline < 0)
|
|
1323
|
+
return { kind: "opaque", reason: "command-substitution" };
|
|
1324
|
+
index = newline;
|
|
1325
|
+
continue;
|
|
1326
|
+
}
|
|
1327
|
+
if (char === " " || char === "\t" || mode === "array" && char === `
|
|
1328
|
+
`) {
|
|
1329
|
+
wordStarted = false;
|
|
1330
|
+
continue;
|
|
1331
|
+
}
|
|
1332
|
+
if (mode === "array" && wordStarted && char === "(" && context.dialect === "zsh" && (ZSH_GLOB_QUALIFIER_RE.lastIndex = index, ZSH_GLOB_QUALIFIER_RE.test(input))) {
|
|
1333
|
+
const end = ZSH_GLOB_QUALIFIER_RE.lastIndex - 1;
|
|
1334
|
+
if (text)
|
|
1335
|
+
text.literal += input.slice(index, end + 1);
|
|
1336
|
+
index = end;
|
|
1337
|
+
continue;
|
|
1338
|
+
}
|
|
1339
|
+
if (char === `
|
|
1340
|
+
` || char === ";" || char === "&" || mode === "array" && "|(".includes(char))
|
|
1341
|
+
return { kind: "opaque", reason: "command-substitution" };
|
|
1342
|
+
wordStarted = true;
|
|
1343
|
+
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);
|
|
1344
|
+
if (typeof unit === "object")
|
|
1345
|
+
return unit;
|
|
1346
|
+
if (unit !== undefined)
|
|
1347
|
+
index = unit;
|
|
1348
|
+
else if (text)
|
|
1349
|
+
text.literal += char;
|
|
1350
|
+
}
|
|
1351
|
+
return { kind: "opaque", reason: "command-substitution" };
|
|
1352
|
+
}
|
|
1353
|
+
function bashAnsiQuote(input, start, allowUnicode = true) {
|
|
1354
|
+
let value = "";
|
|
1355
|
+
for (let index = start + 1;index < input.length; index++) {
|
|
1356
|
+
if (input[index] === "'")
|
|
1357
|
+
return { value, end: index };
|
|
1358
|
+
if (input[index] !== "\\") {
|
|
1359
|
+
value += input[index];
|
|
1360
|
+
continue;
|
|
1361
|
+
}
|
|
1362
|
+
const escaped = input[++index];
|
|
1363
|
+
if (escaped === undefined)
|
|
1364
|
+
return;
|
|
1365
|
+
if (escaped in BASH_ANSI_ESCAPES) {
|
|
1366
|
+
value += BASH_ANSI_ESCAPES[escaped];
|
|
1367
|
+
continue;
|
|
1368
|
+
}
|
|
1369
|
+
const digits = escaped === "x" ? /^[\da-fA-F]{1,2}/.exec(input.slice(index + 1, index + 3))?.[0] : allowUnicode && escaped === "u" ? /^[\da-fA-F]{1,4}/.exec(input.slice(index + 1, index + 5))?.[0] : allowUnicode && escaped === "U" ? /^[\da-fA-F]{1,8}/.exec(input.slice(index + 1, index + 9))?.[0] : /[0-7]/.test(escaped) ? /^[0-7]{1,3}/.exec(input.slice(index, index + 3))?.[0] : undefined;
|
|
1370
|
+
if (!digits)
|
|
1371
|
+
return;
|
|
1372
|
+
const octal = /[0-7]/.test(escaped);
|
|
1373
|
+
const point = parseInt(digits, octal ? 8 : 16);
|
|
1374
|
+
if (point === 0 || point > 1114111 || point >= 55296 && point <= 57343)
|
|
1375
|
+
return;
|
|
1376
|
+
value += String.fromCodePoint(point);
|
|
1377
|
+
index += digits.length - (octal ? 1 : 0);
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
function bashHeredocDelimiter(input, start, tabs) {
|
|
1381
|
+
let delimiter = "";
|
|
1382
|
+
let dashDelimiter;
|
|
1383
|
+
let quoted = false;
|
|
1384
|
+
let quote;
|
|
1385
|
+
let end = start;
|
|
1386
|
+
let started = false;
|
|
1387
|
+
for (let index = start;index < input.length; index++) {
|
|
1388
|
+
const char = input[index];
|
|
1389
|
+
if (!started && /[ \t]/.test(char))
|
|
1390
|
+
continue;
|
|
1391
|
+
if (!started && char === "#")
|
|
1392
|
+
return;
|
|
1393
|
+
if (!quote && /[ \t\n;&|()<>]/.test(char))
|
|
1394
|
+
return started ? { delimiter, dashDelimiter, quoted, tabs, end } : undefined;
|
|
1395
|
+
if (!quote && char === "$" && input.startsWith("\\\n", index + 1))
|
|
1396
|
+
return;
|
|
1397
|
+
if (!quote && input.startsWith("$'", index)) {
|
|
1398
|
+
const literal = bashAnsiQuote(input, index + 1, false);
|
|
1399
|
+
if (!literal || literal.end !== input.indexOf("'", index + 2))
|
|
1400
|
+
return;
|
|
1401
|
+
dashDelimiter = `${dashDelimiter ?? delimiter}$${input.slice(index + 2, literal.end)}`;
|
|
1402
|
+
delimiter += literal.value;
|
|
1403
|
+
quoted = true;
|
|
1404
|
+
started = true;
|
|
1405
|
+
index = literal.end;
|
|
1406
|
+
end = index;
|
|
1407
|
+
continue;
|
|
1408
|
+
}
|
|
1409
|
+
if (!quote && input.startsWith('$"', index))
|
|
1410
|
+
return;
|
|
1411
|
+
if (char === quote) {
|
|
1412
|
+
quote = undefined;
|
|
1413
|
+
end = index;
|
|
1414
|
+
continue;
|
|
1415
|
+
}
|
|
1416
|
+
if (char === "\\" && quote !== "'") {
|
|
1417
|
+
const next = input[index + 1];
|
|
1418
|
+
if (next === undefined)
|
|
1419
|
+
return;
|
|
1420
|
+
if (next === `
|
|
1421
|
+
`) {
|
|
1422
|
+
index++;
|
|
1423
|
+
continue;
|
|
1424
|
+
}
|
|
1425
|
+
if (!quote || '$`"\\'.includes(next)) {
|
|
1426
|
+
quoted = true;
|
|
1427
|
+
started = true;
|
|
1428
|
+
const escaped = input[++index];
|
|
1429
|
+
if (dashDelimiter !== undefined)
|
|
1430
|
+
dashDelimiter += escaped;
|
|
1431
|
+
delimiter += escaped;
|
|
1432
|
+
end = index;
|
|
1433
|
+
continue;
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
if (!quote && (char === "'" || char === '"')) {
|
|
1437
|
+
quote = char;
|
|
1438
|
+
quoted = true;
|
|
1439
|
+
started = true;
|
|
1440
|
+
end = index;
|
|
1441
|
+
continue;
|
|
1442
|
+
}
|
|
1443
|
+
if (dashDelimiter !== undefined)
|
|
1444
|
+
dashDelimiter += char;
|
|
1445
|
+
delimiter += char;
|
|
1446
|
+
started = true;
|
|
1447
|
+
end = index;
|
|
1448
|
+
}
|
|
1449
|
+
if (started && !quote)
|
|
1450
|
+
return { delimiter, dashDelimiter, quoted, tabs, end };
|
|
1451
|
+
}
|
|
1452
|
+
function bashHeredoc(input, start, delimiter) {
|
|
1453
|
+
const bodyStart = start;
|
|
1454
|
+
let lineStart = start;
|
|
1455
|
+
let line = "";
|
|
1456
|
+
let backslashes = 0;
|
|
1457
|
+
for (let index = start;index <= input.length; index++) {
|
|
1458
|
+
if (index < input.length && input[index] !== `
|
|
1459
|
+
`)
|
|
1460
|
+
continue;
|
|
1461
|
+
const text = delimiter.tabs && start === lineStart ? input.slice(start, index).replace(/^\t+/, "") : input.slice(start, index);
|
|
1462
|
+
let run = 0;
|
|
1463
|
+
while (text[text.length - 1 - run] === "\\")
|
|
1464
|
+
run++;
|
|
1465
|
+
backslashes = run === text.length ? backslashes + run : run;
|
|
1466
|
+
const continued = !delimiter.quoted && backslashes % 2 === 1 && index < input.length;
|
|
1467
|
+
const maxLength = Math.max(delimiter.delimiter.length, delimiter.dashDelimiter?.length ?? 0);
|
|
1468
|
+
if (line.length <= maxLength)
|
|
1469
|
+
line += continued ? text.slice(0, -1) : text;
|
|
1470
|
+
if (continued) {
|
|
1471
|
+
backslashes--;
|
|
1472
|
+
start = index + 1;
|
|
1473
|
+
continue;
|
|
1474
|
+
}
|
|
1475
|
+
if (delimiter.dashDelimiter !== undefined && line === delimiter.dashDelimiter)
|
|
1476
|
+
return;
|
|
1477
|
+
if (line === delimiter.delimiter) {
|
|
1478
|
+
if (start > lineStart && input.slice(index + 1).includes(delimiter.delimiter))
|
|
1479
|
+
return;
|
|
1480
|
+
return { source: input.slice(bodyStart, lineStart), end: index };
|
|
1481
|
+
}
|
|
1482
|
+
line = "";
|
|
1483
|
+
backslashes = 0;
|
|
1484
|
+
start = index + 1;
|
|
1485
|
+
lineStart = start;
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
function scanPowerShell2(input) {
|
|
1489
|
+
if (input.length > MAX_INPUT_LENGTH)
|
|
1490
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1491
|
+
if (/[\0\u0085\u2013-\u2015\u2018-\u201e\ufeff]/.test(input))
|
|
1492
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1493
|
+
const result = scanPowerShellList(input, 0, 0, { remaining: MAX_INPUT_LENGTH * MAX_SUBSTITUTION_DEPTH });
|
|
1494
|
+
if (result.kind === "opaque")
|
|
1495
|
+
return result;
|
|
1496
|
+
return { kind: "scanned", commands: result.commands };
|
|
1497
|
+
}
|
|
1498
|
+
function scanPowerShellList(input, start, depth, budget, close, hash = false, skipped) {
|
|
1499
|
+
if (depth >= MAX_SUBSTITUTION_DEPTH || budget.remaining < 0)
|
|
1500
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1501
|
+
const commands = [];
|
|
1502
|
+
const nestedCommands = [];
|
|
1503
|
+
const words = [];
|
|
1504
|
+
const rawWords = [];
|
|
1505
|
+
const wordEnds = [];
|
|
1506
|
+
const initialExpression = hash === true || hash === "clause";
|
|
1507
|
+
const initialClause = hash === "clause" || hash === "switch" ? "member" : undefined;
|
|
1508
|
+
let segment = start;
|
|
1509
|
+
let word = "";
|
|
1510
|
+
let started = false;
|
|
1511
|
+
let wordStart = start;
|
|
1512
|
+
let quote;
|
|
1513
|
+
let standalone = false;
|
|
1514
|
+
let expression = initialExpression;
|
|
1515
|
+
let clause = initialClause;
|
|
1516
|
+
let after;
|
|
1517
|
+
let indexable = false;
|
|
1518
|
+
let memberChainStart;
|
|
1519
|
+
let hasMemberAccess = false;
|
|
1520
|
+
let hasFileRedirect = false;
|
|
1521
|
+
let stopParsing = false;
|
|
1522
|
+
let commandEnd = start;
|
|
1523
|
+
let statementHead = true;
|
|
1524
|
+
let invalid = false;
|
|
1525
|
+
let redirectTarget = false;
|
|
1526
|
+
let dangling = false;
|
|
1527
|
+
let invocation = false;
|
|
1528
|
+
const resetMember = () => {
|
|
1529
|
+
indexable = false;
|
|
1530
|
+
memberChainStart = undefined;
|
|
1531
|
+
hasMemberAccess = false;
|
|
1532
|
+
};
|
|
1533
|
+
const finishWord = (end) => {
|
|
1534
|
+
if (!started)
|
|
1535
|
+
return;
|
|
1536
|
+
if (word === "--%" && words.length > 0 && !expression && !clause && !redirectTarget && !/['"]/.test(input[wordStart]) && !rawWords.at(-1)?.endsWith(",") && !POWERSHELL_PARAMETER_COLON_RE.test(rawWords.at(-1) ?? ""))
|
|
1537
|
+
stopParsing = true;
|
|
1538
|
+
if (!redirectTarget) {
|
|
1539
|
+
if (!words.length && !invocation)
|
|
1540
|
+
segment = wordStart;
|
|
1541
|
+
words.push(word);
|
|
1542
|
+
rawWords.push(input.slice(wordStart, end));
|
|
1543
|
+
wordEnds.push(end);
|
|
1544
|
+
dangling = false;
|
|
1545
|
+
}
|
|
1546
|
+
commandEnd = end;
|
|
1547
|
+
redirectTarget = false;
|
|
1548
|
+
word = "";
|
|
1549
|
+
started = false;
|
|
1550
|
+
};
|
|
1551
|
+
const finishCommand = (end, required = false) => {
|
|
1552
|
+
finishWord(end);
|
|
1553
|
+
if (words.length && (!expression && !clause || hasFileRedirect))
|
|
1554
|
+
commands.push({
|
|
1555
|
+
resource: input.slice(segment, commandEnd).trimEnd(),
|
|
1556
|
+
words: [...words],
|
|
1557
|
+
rawWords: [...rawWords],
|
|
1558
|
+
wordEnds: wordEnds.map((value) => value - segment),
|
|
1559
|
+
...statementHead && !invocation && !expression && !clause ? { statementHead: true } : {}
|
|
1560
|
+
});
|
|
1561
|
+
else if (!expression && !clause && invocation || required && !words.length && !nestedCommands.length || clause !== undefined && clause !== "member")
|
|
1562
|
+
invalid = true;
|
|
1563
|
+
if (redirectTarget)
|
|
1564
|
+
invalid = true;
|
|
1565
|
+
commands.push(...nestedCommands.splice(0));
|
|
1566
|
+
words.length = 0;
|
|
1567
|
+
rawWords.length = 0;
|
|
1568
|
+
wordEnds.length = 0;
|
|
1569
|
+
redirectTarget = false;
|
|
1570
|
+
hasFileRedirect = false;
|
|
1571
|
+
invocation = false;
|
|
1572
|
+
expression = initialExpression;
|
|
1573
|
+
clause = initialClause;
|
|
1574
|
+
after = undefined;
|
|
1575
|
+
resetMember();
|
|
1576
|
+
stopParsing = false;
|
|
1577
|
+
};
|
|
1578
|
+
let index = start;
|
|
1579
|
+
for (;index < input.length; index++) {
|
|
1580
|
+
if (--budget.remaining < 0)
|
|
1581
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1582
|
+
if (skipped?.has(index))
|
|
1583
|
+
continue;
|
|
1584
|
+
const char = input[index];
|
|
1585
|
+
const inExpression = expression && !redirectTarget;
|
|
1586
|
+
const atBoundary = !started || !inExpression && word.endsWith(",");
|
|
1587
|
+
if (!started)
|
|
1588
|
+
wordStart = index;
|
|
1589
|
+
if (stopParsing) {
|
|
1590
|
+
const stop = powerShellStopParsing(input, index, skipped);
|
|
1591
|
+
const text = input.slice(index, stop).trim();
|
|
1592
|
+
if (text) {
|
|
1593
|
+
wordStart = index + input.slice(index, stop).search(/\S/);
|
|
1594
|
+
word = text;
|
|
1595
|
+
started = true;
|
|
1596
|
+
finishWord(wordStart + text.length);
|
|
1597
|
+
}
|
|
1598
|
+
stopParsing = false;
|
|
1599
|
+
index = stop - 1;
|
|
1600
|
+
continue;
|
|
1601
|
+
}
|
|
1602
|
+
if (quote) {
|
|
1603
|
+
let nextQuote = index + 1;
|
|
1604
|
+
while (skipped?.has(nextQuote))
|
|
1605
|
+
nextQuote++;
|
|
1606
|
+
if (char === quote && input[nextQuote] === quote) {
|
|
1607
|
+
word += quote;
|
|
1608
|
+
index = nextQuote;
|
|
1609
|
+
} else if (char === quote) {
|
|
1610
|
+
quote = undefined;
|
|
1611
|
+
if (standalone) {
|
|
1612
|
+
finishWord(index + 1);
|
|
1613
|
+
indexable = "closed";
|
|
1614
|
+
}
|
|
1615
|
+
} else if (quote === '"' && char === "`") {
|
|
1616
|
+
const escape = powerShellEscape(input, index, false, skipped);
|
|
1617
|
+
if (!escape)
|
|
1618
|
+
return { kind: "opaque", reason: "unterminated-escape" };
|
|
1619
|
+
word += escape.value;
|
|
1620
|
+
index = escape.end;
|
|
1621
|
+
} else if (quote === '"' && char === "$" && input[index + 1] === "{") {
|
|
1622
|
+
const end = powerShellBracedVariable(input, index, skipped);
|
|
1623
|
+
if (end === undefined)
|
|
1624
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1625
|
+
word += input.slice(index, end + 1);
|
|
1626
|
+
index = end;
|
|
1627
|
+
} else if (quote === '"' && char === "$" && input[index + 1] === "(") {
|
|
1628
|
+
const sub = powerShellSubExpression(input, index + 2, false, budget, skipped);
|
|
1629
|
+
if (!sub)
|
|
1630
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1631
|
+
const result = scanPowerShellList(input, index + 2, depth + 1, budget, ")", false, sub.skipped);
|
|
1632
|
+
if (result.kind === "opaque")
|
|
1633
|
+
return result;
|
|
1634
|
+
nestedCommands.push(...result.commands);
|
|
1635
|
+
const end = sub.rawEnd !== undefined && sub.rawEnd > result.end ? sub.rawEnd : result.end;
|
|
1636
|
+
word += input.slice(index, end + 1);
|
|
1637
|
+
index = end;
|
|
1638
|
+
} else
|
|
1639
|
+
word += char;
|
|
1640
|
+
continue;
|
|
1641
|
+
}
|
|
1642
|
+
if (char === "'" || char === '"') {
|
|
1643
|
+
if (!started && words.length === 0 && !invocation)
|
|
1644
|
+
expression = true;
|
|
1645
|
+
quote = char;
|
|
1646
|
+
const dynamicMember = indexable === "member" && /[.:]$/.test(started ? word : words.at(-1) ?? "");
|
|
1647
|
+
standalone = atBoundary || expression && !redirectTarget || dynamicMember;
|
|
1648
|
+
if (dynamicMember)
|
|
1649
|
+
hasMemberAccess = true;
|
|
1650
|
+
else if (standalone) {
|
|
1651
|
+
memberChainStart = index;
|
|
1652
|
+
hasMemberAccess = false;
|
|
1653
|
+
} else
|
|
1654
|
+
resetMember();
|
|
1655
|
+
started = true;
|
|
1656
|
+
continue;
|
|
1657
|
+
}
|
|
1658
|
+
if (char === "`") {
|
|
1659
|
+
const escape = powerShellEscape(input, index, atBoundary || inExpression, skipped);
|
|
1660
|
+
if (!escape)
|
|
1661
|
+
return { kind: "opaque", reason: "unterminated-escape" };
|
|
1662
|
+
const rawSpace = /\s/.test(input[index + 1] ?? "");
|
|
1663
|
+
if ((inExpression || atBoundary) && started && rawSpace)
|
|
1664
|
+
finishWord(index);
|
|
1665
|
+
else if (!atBoundary || !rawSpace) {
|
|
1666
|
+
started = true;
|
|
1667
|
+
if (!(indexable === "member" && /[\p{L}\p{Nl}\d_]/u.test(escape.value)))
|
|
1668
|
+
resetMember();
|
|
1669
|
+
word += escape.value;
|
|
1670
|
+
}
|
|
1671
|
+
index = escape.end;
|
|
1672
|
+
continue;
|
|
1673
|
+
}
|
|
1674
|
+
if (!started && words.length > 0 && !expression && !clause && !redirectTarget && testAt(POWERSHELL_STOP_PARSING_RE, input, index)) {
|
|
1675
|
+
word = "--%";
|
|
1676
|
+
started = true;
|
|
1677
|
+
finishWord(index + 3);
|
|
1678
|
+
index += 2;
|
|
1679
|
+
continue;
|
|
1680
|
+
}
|
|
1681
|
+
if (char === "<" && input[index + 1] === "#" && (atBoundary || inExpression || indexable === "member")) {
|
|
1682
|
+
const memberOperator = indexable === "member" && /[.:]$/.test(started ? word : words.at(-1) ?? "");
|
|
1683
|
+
if (started)
|
|
1684
|
+
finishWord(index);
|
|
1685
|
+
const end = input.indexOf("#>", index + 2);
|
|
1686
|
+
if (end < 0)
|
|
1687
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1688
|
+
if (!memberOperator)
|
|
1689
|
+
resetMember();
|
|
1690
|
+
index = end + 1;
|
|
1691
|
+
continue;
|
|
1692
|
+
}
|
|
1693
|
+
if (char === "#" && (atBoundary || indexable === "member" || inExpression && !(close === "]" && /^[\p{L}\p{Nl}_][\p{L}\p{Nl}\d_.#+`\\]*$/u.test(word)))) {
|
|
1694
|
+
const prev = started ? word : words.at(-1) ?? "";
|
|
1695
|
+
const memberOperator = indexable === "member" && /[.:]$/.test(prev);
|
|
1696
|
+
if (clause && clause !== "member" || prev.endsWith(",") || memberOperator)
|
|
1697
|
+
finishWord(index);
|
|
1698
|
+
else if (words.length || started || invocation)
|
|
1699
|
+
finishCommand(index);
|
|
1700
|
+
statementHead = !dangling;
|
|
1701
|
+
const endings = [input.indexOf(`
|
|
1702
|
+
`, index), input.indexOf("\r", index)].filter((ending) => ending >= 0);
|
|
1703
|
+
const newline = endings.length > 0 ? Math.min(...endings) : -1;
|
|
1704
|
+
if (newline === -1) {
|
|
1705
|
+
index = input.length;
|
|
1706
|
+
break;
|
|
1707
|
+
}
|
|
1708
|
+
index = input[newline] === "\r" && input[newline + 1] === `
|
|
1709
|
+
` ? newline + 1 : newline;
|
|
1710
|
+
continue;
|
|
1711
|
+
}
|
|
1712
|
+
if (inExpression && started && (char === ">" || char === "*" && input[index + 1] === ">"))
|
|
1713
|
+
finishWord(index);
|
|
1714
|
+
const redirect = !started && (char === ">" || char === "*" || /\d/.test(char) && (words.length > 0 || testAt(POWERSHELL_MERGE_REDIRECT_RE, input, index))) ? powerShellRedirect(input, index) : undefined;
|
|
1715
|
+
if (redirect === false)
|
|
1716
|
+
return { kind: "opaque", reason: "invalid-redirect" };
|
|
1717
|
+
if (redirect) {
|
|
1718
|
+
if (redirectTarget || words.length === 0 || clause && clause !== "member")
|
|
1719
|
+
return { kind: "opaque", reason: "invalid-redirect" };
|
|
1720
|
+
redirectTarget = !redirect.includes("&");
|
|
1721
|
+
if (redirectTarget)
|
|
1722
|
+
hasFileRedirect = true;
|
|
1723
|
+
resetMember();
|
|
1724
|
+
index += redirect.length - 1;
|
|
1725
|
+
commandEnd = index + 1;
|
|
1726
|
+
continue;
|
|
1727
|
+
}
|
|
1728
|
+
if (!started && !words.length && !invocation && !expression && !clause && char === ":") {
|
|
1729
|
+
const label = matchAt(POWERSHELL_LABEL_RE, input, index);
|
|
1730
|
+
if (label) {
|
|
1731
|
+
index += label[0].length - 1;
|
|
1732
|
+
continue;
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
if (!started && !invocation && !clause && (!words.length ? !expression : words.every((item) => item.startsWith("["))) && /[A-Za-z]/.test(char)) {
|
|
1736
|
+
const keyword = matchAt(POWERSHELL_KEYWORD_RE, input, index)?.[0]?.toLowerCase();
|
|
1737
|
+
if (keyword && (words.length > 0 ? keyword === "param" && testAt(POWERSHELL_PARAM_RE, input, index) || keyword === "class" || keyword === "enum" : keyword === "param" && testAt(POWERSHELL_PARAM_RE, input, index) || keyword === "foreach" && testAt(POWERSHELL_FOREACH_RE, input, index) || keyword === "until" && after === "do" || (keyword === "else" || keyword === "elseif") && after === "if" || (keyword === "catch" || keyword === "finally") && after === "try" || /^(?:if|for|while|do|switch|function|filter|workflow|parallel|sequence|configuration|try|begin|process|end|clean|trap|class|enum|data|dynamicparam|using|break|continue)$/.test(keyword))) {
|
|
1738
|
+
expression = /^(?:class|enum|break|continue)$/.test(keyword);
|
|
1739
|
+
clause = keyword === "using" || keyword === "break" || keyword === "continue" ? "member" : keyword === "param" || keyword === "until" || keyword === "while" && after === "do" ? "paren" : keyword === "do" ? "do" : keyword === "if" || keyword === "elseif" ? "if" : keyword === "try" || keyword === "catch" ? "try" : keyword === "switch" ? "switch" : keyword === "class" || keyword === "enum" ? "clause" : "block";
|
|
1740
|
+
after = undefined;
|
|
1741
|
+
index += keyword.length - 1;
|
|
1742
|
+
continue;
|
|
1743
|
+
}
|
|
1744
|
+
if (!words.length && keyword && /^(?:return|throw|exit)$/.test(keyword)) {
|
|
1745
|
+
after = undefined;
|
|
1746
|
+
index += keyword.length - 1;
|
|
1747
|
+
continue;
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
const assign = inExpression && !clause && (char === "=" || /[-+*/%]/.test(char) && input[index + 1] === "=");
|
|
1751
|
+
if (assign || inExpression && close === ")" && !started && testAt(POWERSHELL_IN_RE, input, index)) {
|
|
1752
|
+
if (assign)
|
|
1753
|
+
finishWord(index);
|
|
1754
|
+
words.length = 0;
|
|
1755
|
+
rawWords.length = 0;
|
|
1756
|
+
wordEnds.length = 0;
|
|
1757
|
+
expression = false;
|
|
1758
|
+
hasFileRedirect = false;
|
|
1759
|
+
resetMember();
|
|
1760
|
+
if (!assign || char !== "=")
|
|
1761
|
+
index++;
|
|
1762
|
+
continue;
|
|
1763
|
+
}
|
|
1764
|
+
if (atBoundary && char === "@" && !testAt(POWERSHELL_AT_OPENER_RE, input, index + 1))
|
|
1765
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1766
|
+
if (atBoundary && char === "@" && (input[index + 1] === "'" || input[index + 1] === '"')) {
|
|
1767
|
+
if (started)
|
|
1768
|
+
finishWord(index);
|
|
1769
|
+
wordStart = index;
|
|
1770
|
+
const literal = powerShellHereString(input, index, depth, budget, skipped);
|
|
1771
|
+
if (literal.kind === "opaque")
|
|
1772
|
+
return literal;
|
|
1773
|
+
if (!words.length && !invocation)
|
|
1774
|
+
expression = true;
|
|
1775
|
+
nestedCommands.push(...literal.commands);
|
|
1776
|
+
word = literal.source;
|
|
1777
|
+
started = true;
|
|
1778
|
+
index = literal.end;
|
|
1779
|
+
finishWord(index + 1);
|
|
1780
|
+
memberChainStart = wordStart;
|
|
1781
|
+
hasMemberAccess = false;
|
|
1782
|
+
indexable = "closed";
|
|
1783
|
+
continue;
|
|
1784
|
+
}
|
|
1785
|
+
if (char === "$" && input[index + 1] === "{") {
|
|
1786
|
+
const end = powerShellBracedVariable(input, index, skipped);
|
|
1787
|
+
if (end === undefined)
|
|
1788
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1789
|
+
if (!started && !words.length && !invocation && hash !== "switch")
|
|
1790
|
+
expression = true;
|
|
1791
|
+
const dynamicMember = indexable === "member" && /[.:]$/.test(started ? word : words.at(-1) ?? "");
|
|
1792
|
+
if (dynamicMember) {
|
|
1793
|
+
indexable = "closed";
|
|
1794
|
+
hasMemberAccess = true;
|
|
1795
|
+
} else if (atBoundary) {
|
|
1796
|
+
memberChainStart = index;
|
|
1797
|
+
hasMemberAccess = false;
|
|
1798
|
+
indexable = "closed";
|
|
1799
|
+
} else
|
|
1800
|
+
resetMember();
|
|
1801
|
+
word += input.slice(index, end + 1);
|
|
1802
|
+
started = true;
|
|
1803
|
+
index = end;
|
|
1804
|
+
if (expression && !redirectTarget && input[index + 1] !== "[")
|
|
1805
|
+
finishWord(index + 1);
|
|
1806
|
+
continue;
|
|
1807
|
+
}
|
|
1808
|
+
const opener = (char === "$" || atBoundary && char === "@") && input[index + 1] === "(" ? index + 1 : atBoundary && char === "@" && input[index + 1] === "{" ? index + 1 : char === "(" || char === "{" || char === "[" && (inExpression || Boolean(indexable) || !started && !invocation && (!words.length || clause === "block" || clause === "try")) ? index : undefined;
|
|
1809
|
+
if (opener !== undefined) {
|
|
1810
|
+
const tokenIndex = index;
|
|
1811
|
+
const openChar = input[opener];
|
|
1812
|
+
const prevMemberWord = started ? word : words.at(-1) ?? "";
|
|
1813
|
+
const dynamicMemberOpener = indexable === "member" && /[.:]$/.test(prevMemberWord);
|
|
1814
|
+
const priorIndexable = Boolean(indexable);
|
|
1815
|
+
const isMethodCall = char === "(" && opener === tokenIndex && memberChainStart !== undefined && (indexable === "member" && started && !/[.:]$/.test(word) || indexable === "closed" && !started && hasMemberAccess);
|
|
1816
|
+
const standaloneBlock = atBoundary || inExpression || char === "(" || openChar === "{";
|
|
1817
|
+
const blockClose = openChar === "(" ? ")" : openChar === "[" ? "]" : "}";
|
|
1818
|
+
const blockHash = openChar === "[" ? true : char === "@" && openChar === "{" ? true : clause === "switch" && openChar === "{" ? "switch" : clause === "clause" && openChar === "{" ? "clause" : close === "]" && char === "(" && started ? "clause" : false;
|
|
1819
|
+
if (started && (char === "{" || char === "(" || char === "@" && atBoundary)) {
|
|
1820
|
+
finishWord(index);
|
|
1821
|
+
if (stopParsing) {
|
|
1822
|
+
index--;
|
|
1823
|
+
continue;
|
|
1824
|
+
}
|
|
1825
|
+
wordStart = index;
|
|
1826
|
+
}
|
|
1827
|
+
if (!started && !words.length && !invocation)
|
|
1828
|
+
expression = true;
|
|
1829
|
+
const result = scanPowerShellList(input, opener + 1, depth + 1, budget, blockClose, blockHash, skipped);
|
|
1830
|
+
if (result.kind === "opaque")
|
|
1831
|
+
return result;
|
|
1832
|
+
nestedCommands.push(...result.commands);
|
|
1833
|
+
started = true;
|
|
1834
|
+
word += input.slice(index, result.end + 1);
|
|
1835
|
+
index = result.end;
|
|
1836
|
+
if (isMethodCall && memberChainStart !== undefined) {
|
|
1837
|
+
finishWord(index + 1);
|
|
1838
|
+
const callResource = input.slice(memberChainStart, result.end + 1);
|
|
1839
|
+
const head = input.slice(memberChainStart, opener);
|
|
1840
|
+
const args = input.slice(opener, result.end + 1);
|
|
1841
|
+
nestedCommands.push({
|
|
1842
|
+
resource: callResource,
|
|
1843
|
+
words: [head, args],
|
|
1844
|
+
rawWords: [head, args],
|
|
1845
|
+
wordEnds: [head.length, callResource.length]
|
|
1846
|
+
});
|
|
1847
|
+
indexable = "closed";
|
|
1848
|
+
hasMemberAccess = false;
|
|
1849
|
+
} else if (openChar === "[") {
|
|
1850
|
+
indexable = "closed";
|
|
1851
|
+
if (!priorIndexable)
|
|
1852
|
+
memberChainStart = tokenIndex;
|
|
1853
|
+
if (input[index + 1] !== "[")
|
|
1854
|
+
finishWord(index + 1);
|
|
1855
|
+
} else if (standaloneBlock) {
|
|
1856
|
+
finishWord(index + 1);
|
|
1857
|
+
indexable = "closed";
|
|
1858
|
+
if (!dynamicMemberOpener)
|
|
1859
|
+
memberChainStart = tokenIndex;
|
|
1860
|
+
hasMemberAccess = dynamicMemberOpener;
|
|
1861
|
+
}
|
|
1862
|
+
if (clause === "paren" && char === "(" || clause && clause !== "paren" && char === "{") {
|
|
1863
|
+
const completed = clause === "do" || clause === "if" || clause === "try" ? clause : undefined;
|
|
1864
|
+
clause = "member";
|
|
1865
|
+
finishCommand(index + 1);
|
|
1866
|
+
after = completed;
|
|
1867
|
+
}
|
|
1868
|
+
continue;
|
|
1869
|
+
}
|
|
1870
|
+
if (char === close)
|
|
1871
|
+
break;
|
|
1872
|
+
if (char === "}" || char === ")" || char === "]" && inExpression)
|
|
1873
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1874
|
+
if (!started && words.length === 0 && (char === "&" && input[index + 1] !== "&" || char === "." && (!input[index + 1] || /[\s"'$(),;{|}&]/.test(input[index + 1])))) {
|
|
1875
|
+
if (invocation)
|
|
1876
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1877
|
+
segment = index;
|
|
1878
|
+
invocation = true;
|
|
1879
|
+
after = undefined;
|
|
1880
|
+
continue;
|
|
1881
|
+
}
|
|
1882
|
+
if (/\s/.test(char) && char !== `
|
|
1883
|
+
` && char !== "\r") {
|
|
1884
|
+
const memberOperator = indexable === "member" && /[.:]$/.test(started ? word : words.at(-1) ?? "");
|
|
1885
|
+
finishWord(index);
|
|
1886
|
+
if (!memberOperator)
|
|
1887
|
+
resetMember();
|
|
1888
|
+
continue;
|
|
1889
|
+
}
|
|
1890
|
+
const next = input[index + 1];
|
|
1891
|
+
const separator = char === "\r" && next === `
|
|
1892
|
+
` ? char + next : char === "&" && next === "&" || char === "|" && next === "|" ? char + next : char === ";" || char === "|" || char === "&" || char === `
|
|
1893
|
+
` || char === "\r" ? char : undefined;
|
|
1894
|
+
if (separator) {
|
|
1895
|
+
if (close === "]" && (separator === ";" || separator === "|" || separator === "||" || separator === "&&" || separator === "&"))
|
|
1896
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1897
|
+
if (separator === `
|
|
1898
|
+
` || separator === "\r" || separator === `\r
|
|
1899
|
+
`) {
|
|
1900
|
+
const prev = started ? word : words.at(-1) ?? "";
|
|
1901
|
+
const memberOperator = indexable === "member" && /[.:]$/.test(prev);
|
|
1902
|
+
if (clause && clause !== "member" || prev.endsWith(",") || memberOperator) {
|
|
1903
|
+
finishWord(index);
|
|
1904
|
+
index += separator.length - 1;
|
|
1905
|
+
if (!memberOperator)
|
|
1906
|
+
resetMember();
|
|
1907
|
+
continue;
|
|
1908
|
+
}
|
|
1909
|
+
if (!started && !words.length && !invocation) {
|
|
1910
|
+
index += separator.length - 1;
|
|
1911
|
+
resetMember();
|
|
1912
|
+
continue;
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
finishCommand(index, dangling || ![";", `
|
|
1916
|
+
`, "\r", `\r
|
|
1917
|
+
`].includes(separator));
|
|
1918
|
+
dangling = ![";", "&", `
|
|
1919
|
+
`, "\r", `\r
|
|
1920
|
+
`].includes(separator);
|
|
1921
|
+
statementHead = !dangling;
|
|
1922
|
+
index += separator.length - 1;
|
|
1923
|
+
continue;
|
|
1924
|
+
}
|
|
1925
|
+
if (!started && !words.length && !invocation && hash !== "switch" && testAt(POWERSHELL_EXPRESSION_RE, input, index))
|
|
1926
|
+
expression = true;
|
|
1927
|
+
const prevMember = started ? word : words.at(-1) ?? "";
|
|
1928
|
+
if ((atBoundary || indexable === "member" && /[.:]$/.test(prevMember)) && char === "$") {
|
|
1929
|
+
if (testAt(POWERSHELL_INDEXABLE_VAR_RE, input, index + 1)) {
|
|
1930
|
+
if (indexable === "member" && /[.:]$/.test(prevMember))
|
|
1931
|
+
hasMemberAccess = true;
|
|
1932
|
+
else {
|
|
1933
|
+
memberChainStart = index;
|
|
1934
|
+
hasMemberAccess = false;
|
|
1935
|
+
}
|
|
1936
|
+
indexable = "variable";
|
|
1937
|
+
} else
|
|
1938
|
+
resetMember();
|
|
1939
|
+
} else if (indexable === "closed") {
|
|
1940
|
+
indexable = char === "." && input[index + 1] !== "." && (!/\s/.test(input[index + 1] ?? "") || inExpression) || !started && char === ":" && input[index + 1] === ":" || !started && char === "?" && input[index + 1] === "." && input[index + 2] !== "." && (!/\s/.test(input[index + 2] ?? "") || inExpression) ? "member" : !started && char === "?" && input[index + 1] === "[" ? "closed" : false;
|
|
1941
|
+
if (indexable === "member")
|
|
1942
|
+
hasMemberAccess = true;
|
|
1943
|
+
else if (!indexable)
|
|
1944
|
+
resetMember();
|
|
1945
|
+
} else if (indexable === "variable") {
|
|
1946
|
+
indexable = char === "." && input[index + 1] !== "." && (!/\s/.test(input[index + 1] ?? "") || inExpression) || char === ":" && input[index + 1] === ":" ? "member" : char === "." && input[index + 1] === "." || !/[\p{L}\p{Nl}\d_:?]/u.test(char) ? false : "variable";
|
|
1947
|
+
if (indexable === "member")
|
|
1948
|
+
hasMemberAccess = true;
|
|
1949
|
+
else if (!indexable)
|
|
1950
|
+
resetMember();
|
|
1951
|
+
} else if (indexable === "member") {
|
|
1952
|
+
indexable = char === "." && input[index + 1] === "." ? false : char === "." && (!/\s/.test(input[index + 1] ?? "") || inExpression) || char === ":" && (input[index + 1] === ":" || input[index - 1] === ":") || char === "?" && input[index + 1] === "." && input[index + 2] !== "." || /[\p{L}\p{Nl}\d_]/u.test(char) ? "member" : false;
|
|
1953
|
+
if (!indexable)
|
|
1954
|
+
resetMember();
|
|
1955
|
+
}
|
|
1956
|
+
after = undefined;
|
|
1957
|
+
started = true;
|
|
1958
|
+
dangling = false;
|
|
1959
|
+
word += char;
|
|
1960
|
+
}
|
|
1961
|
+
if (close !== undefined && input[index] !== close)
|
|
1962
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1963
|
+
if (quote)
|
|
1964
|
+
return { kind: "opaque", reason: "unterminated-quote" };
|
|
1965
|
+
finishCommand(index);
|
|
1966
|
+
if (redirectTarget || invalid || dangling)
|
|
1967
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
1968
|
+
if (commands.some((command) => !command.words[0]))
|
|
1969
|
+
return { kind: "opaque", reason: "dynamic-command-name" };
|
|
1970
|
+
return { kind: "scanned", commands, end: index };
|
|
1971
|
+
}
|
|
1972
|
+
var POWERSHELL_STOP_PARSING_RE = /--%(?=$|[\s;|&(){}])/y;
|
|
1973
|
+
var POWERSHELL_PARAMETER_COLON_RE = /^-[\p{L}\p{Nl}_?][\p{L}\p{Nl}\d_?-]*:$/u;
|
|
1974
|
+
var POWERSHELL_MERGE_REDIRECT_RE = /\d>&/y;
|
|
1975
|
+
var POWERSHELL_LABEL_RE = /:[A-Za-z_]\w*(?=\s*(?:while|for|foreach|do|switch)(?=$|[\s&(),;{|}]))/iy;
|
|
1976
|
+
var POWERSHELL_KEYWORD_RE = /[A-Za-z]+(?=$|[\s&(),;{|}])/y;
|
|
1977
|
+
var POWERSHELL_FOREACH_RE = /foreach\s*\(/isy;
|
|
1978
|
+
var POWERSHELL_PARAM_RE = /param\s*\(/isy;
|
|
1979
|
+
var POWERSHELL_IN_RE = /in(?=$|[\s&(),;{|}])/iy;
|
|
1980
|
+
var POWERSHELL_AT_OPENER_RE = /[({'"\p{L}\p{Nl}\d_?]/uy;
|
|
1981
|
+
var POWERSHELL_INDEXABLE_VAR_RE = /(?::[\p{L}\p{Nl}\d_?]+|[\p{L}\p{Nl}\d_][\p{L}\p{Nl}\d_?]*)/uy;
|
|
1982
|
+
var POWERSHELL_HERE_HEADER_RE = /@['"][^\S\r\n]*(?:\r\n|\r|\n)/y;
|
|
1983
|
+
var POWERSHELL_UNICODE_ESCAPE_RE = /u\{([0-9a-f]{1,6})\}/iy;
|
|
1984
|
+
var POWERSHELL_EXPRESSION_RE = /(?:!*(?:\+\+|--|[+-])?\$(?:\{|(?:\?|\$|\^)(?=$|[\s;|&(){},#>])|:[\p{L}\p{Nl}\d_?]+|[\p{L}\p{Nl}\d_][\p{L}\p{Nl}\d_?]*(?::[\p{L}\p{Nl}\d_?]+)?)|!(?![\p{L}\p{Nl}_.\d])|\+(?![=\p{L}\p{Nl}_.\d])|--(?!=)|-(?![=\p{L}\p{Nl}\d_?.])|,(?!\s*$)|!*[+-]?(?:0[xX][\da-fA-F]+|0[bB][01]+|(?:\d+(?:\.(?!\.)\d*|(?!\.(?!\.)))|\.\d+)(?:[eE][+-]?\d+)?)(?:[dDlLnN]|[uU][sSyYlL]?|[sSyY])?(?:[kKmMgGtTpP][bB])?(?=$|[\s!#%&()*+,\-/.;<=>\]|{}])|-(?:not|bnot|join|[ic]?split)(?![\p{L}\p{Nl}]))/iuy;
|
|
1985
|
+
var POWERSHELL_ESCAPES = {
|
|
1986
|
+
"0": "\x00",
|
|
1987
|
+
a: "\x07",
|
|
1988
|
+
b: "\b",
|
|
1989
|
+
e: "\x1B",
|
|
1990
|
+
f: "\f",
|
|
1991
|
+
n: `
|
|
1992
|
+
`,
|
|
1993
|
+
r: "\r",
|
|
1994
|
+
t: "\t",
|
|
1995
|
+
v: "\v"
|
|
1996
|
+
};
|
|
1997
|
+
function matchAt(regex, input, index) {
|
|
1998
|
+
regex.lastIndex = index;
|
|
1999
|
+
return regex.exec(input);
|
|
2000
|
+
}
|
|
2001
|
+
function testAt(regex, input, index) {
|
|
2002
|
+
regex.lastIndex = index;
|
|
2003
|
+
return regex.test(input);
|
|
2004
|
+
}
|
|
2005
|
+
function powerShellEscape(input, start, lineContinuation = false, skipped) {
|
|
2006
|
+
let next = start + 1;
|
|
2007
|
+
while (skipped?.has(next))
|
|
2008
|
+
next++;
|
|
2009
|
+
const char = input[next];
|
|
2010
|
+
if (char === undefined)
|
|
2011
|
+
return;
|
|
2012
|
+
if (char === "\r" || char === `
|
|
2013
|
+
`)
|
|
2014
|
+
return {
|
|
2015
|
+
value: lineContinuation && char === "\r" && input[next + 1] === `
|
|
2016
|
+
` ? `\r
|
|
2017
|
+
` : char,
|
|
2018
|
+
end: next + (lineContinuation && char === "\r" && input[next + 1] === `
|
|
2019
|
+
` ? 1 : 0)
|
|
2020
|
+
};
|
|
2021
|
+
if (char === "u" && input[next + 1] === "{") {
|
|
2022
|
+
const code = matchAt(POWERSHELL_UNICODE_ESCAPE_RE, input, next);
|
|
2023
|
+
if (!code || Number.parseInt(code[1], 16) > 1114111)
|
|
2024
|
+
return;
|
|
2025
|
+
return { value: String.fromCodePoint(Number.parseInt(code[1], 16)), end: next + code[0].length - 1 };
|
|
2026
|
+
}
|
|
2027
|
+
return { value: POWERSHELL_ESCAPES[char] ?? char, end: next };
|
|
2028
|
+
}
|
|
2029
|
+
function powerShellBracedVariable(input, start, skipped) {
|
|
2030
|
+
for (let index = start + 2;index < input.length; index++) {
|
|
2031
|
+
if (skipped?.has(index))
|
|
2032
|
+
continue;
|
|
2033
|
+
if (input[index] === "`") {
|
|
2034
|
+
const escape = powerShellEscape(input, index, false, skipped);
|
|
2035
|
+
if (!escape)
|
|
2036
|
+
return;
|
|
2037
|
+
index = escape.end;
|
|
2038
|
+
continue;
|
|
2039
|
+
}
|
|
2040
|
+
if (input[index] === "}")
|
|
2041
|
+
return index > start + 2 ? index : undefined;
|
|
2042
|
+
}
|
|
2043
|
+
}
|
|
2044
|
+
function powerShellSubExpression(input, start, hereString, budget, skipped) {
|
|
2045
|
+
const nextSkipped = new Set(skipped);
|
|
2046
|
+
let depth = 1;
|
|
2047
|
+
let rawEnd;
|
|
2048
|
+
for (let index = start;index < input.length; index++) {
|
|
2049
|
+
if (--budget.remaining < 0)
|
|
2050
|
+
return;
|
|
2051
|
+
if (nextSkipped.has(index))
|
|
2052
|
+
continue;
|
|
2053
|
+
const char = input[index];
|
|
2054
|
+
if (char === "(")
|
|
2055
|
+
depth++;
|
|
2056
|
+
else if (char === ")") {
|
|
2057
|
+
if (--depth === 0 && rawEnd === undefined)
|
|
2058
|
+
rawEnd = index;
|
|
2059
|
+
} else if (!hereString && (char === '"' || char === "`")) {
|
|
2060
|
+
let next = index + 1;
|
|
2061
|
+
while (nextSkipped.has(next))
|
|
2062
|
+
next++;
|
|
2063
|
+
if (input[next] === '"') {
|
|
2064
|
+
nextSkipped.add(index);
|
|
2065
|
+
index = next;
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
}
|
|
2069
|
+
return { skipped: nextSkipped, rawEnd };
|
|
2070
|
+
}
|
|
2071
|
+
function powerShellStopParsing(input, start, skipped) {
|
|
2072
|
+
let quoted = false;
|
|
2073
|
+
for (let index = start;index < input.length; index++) {
|
|
2074
|
+
if (skipped?.has(index))
|
|
2075
|
+
continue;
|
|
2076
|
+
if (input[index] === '"')
|
|
2077
|
+
quoted = !quoted;
|
|
2078
|
+
if (input[index] === "\r" || input[index] === `
|
|
2079
|
+
` || (input[index] === "|" || input[index] === "&" && input[index + 1] === "&") && !quoted)
|
|
2080
|
+
return index;
|
|
2081
|
+
}
|
|
2082
|
+
return input.length;
|
|
2083
|
+
}
|
|
2084
|
+
function powerShellHereString(input, start, depth, budget, skipped) {
|
|
2085
|
+
const header = matchAt(POWERSHELL_HERE_HEADER_RE, input, start);
|
|
2086
|
+
if (!header)
|
|
2087
|
+
return { kind: "opaque", reason: "unterminated-quote" };
|
|
2088
|
+
const quote = input[start + 1];
|
|
2089
|
+
const body = start + header[0].length;
|
|
2090
|
+
const commands = [];
|
|
2091
|
+
let lineStart = true;
|
|
2092
|
+
for (let index = body;index < input.length; index++) {
|
|
2093
|
+
if (--budget.remaining < 0)
|
|
2094
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
2095
|
+
if (skipped?.has(index))
|
|
2096
|
+
continue;
|
|
2097
|
+
if (lineStart && input[index] === quote && input[index + 1] === "@") {
|
|
2098
|
+
const end = index > body && input[index - 1] === `
|
|
2099
|
+
` && input[index - 2] === "\r" ? index - 2 : index > body ? index - 1 : index;
|
|
2100
|
+
return { kind: "scanned", commands, source: input.slice(body, end), end: index + 1 };
|
|
2101
|
+
}
|
|
2102
|
+
if (quote === '"') {
|
|
2103
|
+
if (input[index] === "`") {
|
|
2104
|
+
const escape = powerShellEscape(input, index, false, skipped);
|
|
2105
|
+
if (!escape)
|
|
2106
|
+
return { kind: "opaque", reason: "unterminated-escape" };
|
|
2107
|
+
index = escape.end;
|
|
2108
|
+
lineStart = false;
|
|
2109
|
+
continue;
|
|
2110
|
+
}
|
|
2111
|
+
if (input[index] === "$" && input[index + 1] === "{") {
|
|
2112
|
+
const end = powerShellBracedVariable(input, index, skipped);
|
|
2113
|
+
if (end === undefined)
|
|
2114
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
2115
|
+
index = end;
|
|
2116
|
+
lineStart = false;
|
|
2117
|
+
continue;
|
|
2118
|
+
}
|
|
2119
|
+
if (input[index] === "$" && input[index + 1] === "(") {
|
|
2120
|
+
const sub = powerShellSubExpression(input, index + 2, true, budget, skipped);
|
|
2121
|
+
if (!sub)
|
|
2122
|
+
return { kind: "opaque", reason: "invalid-structure" };
|
|
2123
|
+
const result = scanPowerShellList(input, index + 2, depth + 1, budget, ")", false, sub.skipped);
|
|
2124
|
+
if (result.kind === "opaque")
|
|
2125
|
+
return result;
|
|
2126
|
+
commands.push(...result.commands);
|
|
2127
|
+
index = sub.rawEnd !== undefined && sub.rawEnd > result.end ? sub.rawEnd : result.end;
|
|
2128
|
+
lineStart = false;
|
|
2129
|
+
continue;
|
|
2130
|
+
}
|
|
2131
|
+
}
|
|
2132
|
+
lineStart = input[index] === "\r" || input[index] === `
|
|
2133
|
+
`;
|
|
2134
|
+
}
|
|
2135
|
+
return { kind: "opaque", reason: "unterminated-quote" };
|
|
2136
|
+
}
|
|
2137
|
+
function powerShellRedirect(input, index) {
|
|
2138
|
+
let cursor = index;
|
|
2139
|
+
if (input[cursor] === "*")
|
|
2140
|
+
cursor++;
|
|
2141
|
+
else
|
|
2142
|
+
while (/\d/.test(input[cursor] ?? ""))
|
|
2143
|
+
cursor++;
|
|
2144
|
+
if (input[cursor] !== ">")
|
|
2145
|
+
return;
|
|
2146
|
+
cursor++;
|
|
2147
|
+
if (input[cursor] === ">")
|
|
2148
|
+
cursor++;
|
|
2149
|
+
if (input[cursor] === "&") {
|
|
2150
|
+
cursor++;
|
|
2151
|
+
while (/\d/.test(input[cursor] ?? ""))
|
|
2152
|
+
cursor++;
|
|
2153
|
+
}
|
|
2154
|
+
const redirect = input.slice(index, cursor);
|
|
2155
|
+
return /^(?:(?:[1-6]|\*)?>>?|[2-6*]>&1)$/.test(redirect) ? redirect : false;
|
|
2156
|
+
}
|
|
2157
|
+
|
|
2158
|
+
export { scan4, scanPowerShell2, exports_scan };
|