@caspian2026/agent-sdk 0.0.2
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/chunk-018smjq7.js +26 -0
- package/dist/chunk-055q0a2m.js +146 -0
- package/dist/chunk-07069jq1.js +30 -0
- package/dist/chunk-0731m51q.js +8 -0
- package/dist/chunk-0awwmrwr.js +46 -0
- package/dist/chunk-0htx82k2.js +64 -0
- package/dist/chunk-0jmt5sx1.js +104 -0
- package/dist/chunk-0kj8bq80.js +252 -0
- package/dist/chunk-0kxcq8h9.js +86 -0
- package/dist/chunk-0paqc2yw.js +15 -0
- package/dist/chunk-0vkfrmqm.js +690 -0
- package/dist/chunk-0xjaqda8.js +1124 -0
- package/dist/chunk-10qhq6f8.js +458 -0
- package/dist/chunk-15m49c67.js +121 -0
- package/dist/chunk-15sfg4bs.js +65 -0
- package/dist/chunk-162ewhvy.js +869 -0
- package/dist/chunk-177s15bv.js +120 -0
- package/dist/chunk-19e603rv.js +284 -0
- package/dist/chunk-1ax1znzj.js +537 -0
- package/dist/chunk-1c4j7qn2.js +319 -0
- package/dist/chunk-1gx78081.js +66 -0
- package/dist/chunk-1h2famwb.js +49 -0
- package/dist/chunk-1nk93fqz.js +357 -0
- package/dist/chunk-1xct96nd.js +2520 -0
- package/dist/chunk-1xvcvdef.js +90 -0
- package/dist/chunk-1yrcnrs7.js +261 -0
- package/dist/chunk-21bcvwr7.js +660 -0
- package/dist/chunk-2352ts05.js +667 -0
- package/dist/chunk-23jzrwsw.js +43 -0
- package/dist/chunk-26hg7303.js +62 -0
- package/dist/chunk-2f21meep.js +122 -0
- package/dist/chunk-2fwze72g.js +24 -0
- package/dist/chunk-2gzv8nrw.js +205 -0
- package/dist/chunk-2h05vtpv.js +83 -0
- package/dist/chunk-2h0y6m16.js +465 -0
- package/dist/chunk-2n7bbxm6.js +168 -0
- package/dist/chunk-2nv3d0he.js +108 -0
- package/dist/chunk-2vqrdwx9.js +1811 -0
- package/dist/chunk-3389cj3w.js +120 -0
- package/dist/chunk-35sgv3er.js +231 -0
- package/dist/chunk-3c25bcsw.js +17 -0
- package/dist/chunk-3e20cj49.js +443 -0
- package/dist/chunk-3mr5ryx4.js +122 -0
- package/dist/chunk-3nk79af8.js +8 -0
- package/dist/chunk-3qbdzsvm.js +120 -0
- package/dist/chunk-3yprydpw.js +213 -0
- package/dist/chunk-430yrtmk.js +492 -0
- package/dist/chunk-46hd1gyd.js +140 -0
- package/dist/chunk-46hdszda.js +63 -0
- package/dist/chunk-46n7byh8.js +102 -0
- package/dist/chunk-4cp6193g.js +9076 -0
- package/dist/chunk-4dn3n459.js +409 -0
- package/dist/chunk-4hv90qcz.js +8 -0
- package/dist/chunk-4jm600zv.js +13 -0
- package/dist/chunk-4nspekjp.js +69 -0
- package/dist/chunk-505mxxa9.js +19 -0
- package/dist/chunk-50bay5qy.js +224 -0
- package/dist/chunk-537qfvn5.js +345 -0
- package/dist/chunk-55raexh7.js +14358 -0
- package/dist/chunk-572vjq78.js +56 -0
- package/dist/chunk-5apfzkpy.js +87 -0
- package/dist/chunk-5ccdsxgy.js +74 -0
- package/dist/chunk-5dmhsqap.js +32 -0
- package/dist/chunk-5fs6nkjr.js +98 -0
- package/dist/chunk-5nchekqe.js +87 -0
- package/dist/chunk-5pp28k2r.js +120 -0
- package/dist/chunk-5rt4b8q9.js +116 -0
- package/dist/chunk-5rv9c8yd.js +1072 -0
- package/dist/chunk-5z28bqne.js +6748 -0
- package/dist/chunk-64c1avct.js +13 -0
- package/dist/chunk-66zry909.js +11 -0
- package/dist/chunk-682qgta2.js +102 -0
- package/dist/chunk-68ffk5qa.js +14 -0
- package/dist/chunk-68w91pzt.js +79 -0
- package/dist/chunk-69fgaak0.js +654 -0
- package/dist/chunk-69n11zng.js +436 -0
- package/dist/chunk-6dj5t602.js +341 -0
- package/dist/chunk-6gh20s05.js +146 -0
- package/dist/chunk-6maej1hh.js +502 -0
- package/dist/chunk-6nsd9606.js +790 -0
- package/dist/chunk-6p4cyhb3.js +16 -0
- package/dist/chunk-6t4a9cgj.js +877 -0
- package/dist/chunk-6t8yqfks.js +227 -0
- package/dist/chunk-6vthy0fj.js +213 -0
- package/dist/chunk-70cw4cg9.js +1026 -0
- package/dist/chunk-70eey1nh.js +164 -0
- package/dist/chunk-76j2e9vy.js +68 -0
- package/dist/chunk-7acgdm7x.js +93 -0
- package/dist/chunk-7aw745vx.js +40175 -0
- package/dist/chunk-7gvwg1v9.js +122 -0
- package/dist/chunk-7h2ybnf3.js +636 -0
- package/dist/chunk-7kcm5hn2.js +155 -0
- package/dist/chunk-7m2hp89m.js +73 -0
- package/dist/chunk-7mqab3z7.js +31 -0
- package/dist/chunk-7sgtxrsc.js +1059 -0
- package/dist/chunk-7wm5s02e.js +216 -0
- package/dist/chunk-7xyswgjh.js +8 -0
- package/dist/chunk-7yxvpj5j.js +1452 -0
- package/dist/chunk-80a8vabn.js +93 -0
- package/dist/chunk-83e71kz6.js +180 -0
- package/dist/chunk-83hfzbx3.js +10 -0
- package/dist/chunk-8g5pe1gr.js +37 -0
- package/dist/chunk-8g747a8x.js +26 -0
- package/dist/chunk-8hj8ms5q.js +111 -0
- package/dist/chunk-8mkwsdk1.js +61 -0
- package/dist/chunk-8n42zyfx.js +40 -0
- package/dist/chunk-8qhxyqj9.js +1155 -0
- package/dist/chunk-8y30k9pz.js +38 -0
- package/dist/chunk-960ze3jj.js +124 -0
- package/dist/chunk-97wgdsab.js +35 -0
- package/dist/chunk-9grztvcg.js +93 -0
- package/dist/chunk-9x5zgy22.js +12 -0
- package/dist/chunk-a8792r1c.js +620 -0
- package/dist/chunk-ahr1r7c6.js +4275 -0
- package/dist/chunk-ase86y73.js +15 -0
- package/dist/chunk-b0kf00ff.js +637 -0
- package/dist/chunk-b0qptb1k.js +640 -0
- package/dist/chunk-b1kcd3ss.js +27 -0
- package/dist/chunk-b2fd462a.js +54 -0
- package/dist/chunk-bdrjvs5k.js +157 -0
- package/dist/chunk-beg7bdyz.js +90 -0
- package/dist/chunk-bg4x9ex0.js +21 -0
- package/dist/chunk-bktfq0ns.js +95 -0
- package/dist/chunk-bmbq6nt1.js +145 -0
- package/dist/chunk-bvf2z3g6.js +1003 -0
- package/dist/chunk-bxcfz5gy.js +56 -0
- package/dist/chunk-c11swzas.js +5368 -0
- package/dist/chunk-c37j5zxe.js +57 -0
- package/dist/chunk-c5mz5vw2.js +117 -0
- package/dist/chunk-c6sjhj89.js +1284 -0
- package/dist/chunk-c7jwbe76.js +29030 -0
- package/dist/chunk-cc2tg4q8.js +311 -0
- package/dist/chunk-cdhmrbj4.js +6353 -0
- package/dist/chunk-cdz5yb0r.js +57 -0
- package/dist/chunk-cfv996bs.js +22 -0
- package/dist/chunk-cgfdkzhb.js +12 -0
- package/dist/chunk-chakj069.js +310 -0
- package/dist/chunk-chsyvavm.js +3435 -0
- package/dist/chunk-cnsj3vq2.js +35 -0
- package/dist/chunk-ctdg0qxh.js +1386 -0
- package/dist/chunk-cxq7gc42.js +386 -0
- package/dist/chunk-d1pyf9as.js +8586 -0
- package/dist/chunk-d4kwjqjy.js +308 -0
- package/dist/chunk-d4mdda98.js +94 -0
- package/dist/chunk-d7886r6a.js +13870 -0
- package/dist/chunk-d7f1pzkq.js +95 -0
- package/dist/chunk-ddsjkqs4.js +39 -0
- package/dist/chunk-dm3n2qgd.js +24 -0
- package/dist/chunk-e2mv8ts8.js +115 -0
- package/dist/chunk-e4bhfc6d.js +2720 -0
- package/dist/chunk-e4p1jbs4.js +58 -0
- package/dist/chunk-e7h4qxgw.js +21 -0
- package/dist/chunk-e8p3fy6v.js +202 -0
- package/dist/chunk-e97mp86b.js +111 -0
- package/dist/chunk-ebqwkhyf.js +145 -0
- package/dist/chunk-eenq3avg.js +69 -0
- package/dist/chunk-efgjfast.js +61 -0
- package/dist/chunk-ehtwnxpg.js +1591 -0
- package/dist/chunk-en8wkxh7.js +173 -0
- package/dist/chunk-enkdxqas.js +33 -0
- package/dist/chunk-eqp1rfft.js +17 -0
- package/dist/chunk-ercvcek8.js +266 -0
- package/dist/chunk-etgh9xvt.js +369 -0
- package/dist/chunk-ev3qkf76.js +106 -0
- package/dist/chunk-evp5pb9x.js +3567 -0
- package/dist/chunk-ewadzrm8.js +103 -0
- package/dist/chunk-exah13mz.js +94 -0
- package/dist/chunk-f0rzvqmq.js +87 -0
- package/dist/chunk-f1m9pect.js +258 -0
- package/dist/chunk-fajg8x36.js +8158 -0
- package/dist/chunk-fbv4apne.js +51 -0
- package/dist/chunk-fbvw6wq9.js +116 -0
- package/dist/chunk-feyzykye.js +10 -0
- package/dist/chunk-fn1vvj8k.js +894 -0
- package/dist/chunk-fshfxw2q.js +183 -0
- package/dist/chunk-fyc5fepv.js +10 -0
- package/dist/chunk-g9f19ttm.js +15 -0
- package/dist/chunk-gcpfxk0c.js +644 -0
- package/dist/chunk-gdg6411p.js +106 -0
- package/dist/chunk-gkyzz8er.js +849 -0
- package/dist/chunk-gxahdggv.js +71 -0
- package/dist/chunk-h6fsks9j.js +220 -0
- package/dist/chunk-h9n54swm.js +27 -0
- package/dist/chunk-hakdhagh.js +16606 -0
- package/dist/chunk-hchy0hq6.js +159 -0
- package/dist/chunk-hh3k5s1s.js +180 -0
- package/dist/chunk-hqqkj5pg.js +202 -0
- package/dist/chunk-htpehq9t.js +251 -0
- package/dist/chunk-hwfknpxv.js +39 -0
- package/dist/chunk-hwn8vetn.js +394 -0
- package/dist/chunk-hx3j6n92.js +178 -0
- package/dist/chunk-hyb749hd.js +194 -0
- package/dist/chunk-hzgnejb1.js +90 -0
- package/dist/chunk-hzknr99c.js +477 -0
- package/dist/chunk-j3zhb8vv.js +152 -0
- package/dist/chunk-j5bth84e.js +97 -0
- package/dist/chunk-j64ga6ta.js +8035 -0
- package/dist/chunk-jaaxk89e.js +113 -0
- package/dist/chunk-jd32zbps.js +15 -0
- package/dist/chunk-jfja8q7w.js +91 -0
- package/dist/chunk-jgjqa49s.js +27 -0
- package/dist/chunk-jgpmpgx6.js +19 -0
- package/dist/chunk-jgwd85hp.js +91 -0
- package/dist/chunk-jk69qtzx.js +277 -0
- package/dist/chunk-jr1xm1dd.js +147 -0
- package/dist/chunk-jss0azv7.js +2337 -0
- package/dist/chunk-jxpmkae9.js +108 -0
- package/dist/chunk-jy9rxxqe.js +102 -0
- package/dist/chunk-jyw3np47.js +264 -0
- package/dist/chunk-jzthz1bx.js +15 -0
- package/dist/chunk-k0p9w03v.js +4957 -0
- package/dist/chunk-k2rybwww.js +92 -0
- package/dist/chunk-k3939ggz.js +168 -0
- package/dist/chunk-k591cwbg.js +345 -0
- package/dist/chunk-k5ez1h65.js +108 -0
- package/dist/chunk-k8vp0atq.js +2331 -0
- package/dist/chunk-kajf3jgq.js +694 -0
- package/dist/chunk-kbm69rtz.js +276 -0
- package/dist/chunk-kjh11txh.js +419 -0
- package/dist/chunk-kqggbte3.js +326 -0
- package/dist/chunk-kr6qfwq0.js +95 -0
- package/dist/chunk-kvfg8eeg.js +150 -0
- package/dist/chunk-kwekc97v.js +18 -0
- package/dist/chunk-m1cehfta.js +861 -0
- package/dist/chunk-m87bhhqv.js +61 -0
- package/dist/chunk-mg7pbk0r.js +151 -0
- package/dist/chunk-mpbfkp8j.js +418 -0
- package/dist/chunk-mpk1sjyk.js +117 -0
- package/dist/chunk-msecaxyj.js +74 -0
- package/dist/chunk-mswx2nma.js +103 -0
- package/dist/chunk-mw1kpeg9.js +6895 -0
- package/dist/chunk-mxr2s6d1.js +89 -0
- package/dist/chunk-my40g5hp.js +560 -0
- package/dist/chunk-n0kmh4ra.js +338 -0
- package/dist/chunk-n18q5yqs.js +397 -0
- package/dist/chunk-n7pnyq43.js +131 -0
- package/dist/chunk-naybw0p0.js +32 -0
- package/dist/chunk-nb6abcch.js +83 -0
- package/dist/chunk-ne5r3k03.js +350 -0
- package/dist/chunk-nebezy1d.js +997 -0
- package/dist/chunk-netzwgv1.js +154 -0
- package/dist/chunk-nhapyawz.js +32994 -0
- package/dist/chunk-npnvheft.js +156 -0
- package/dist/chunk-nrtksr2p.js +51 -0
- package/dist/chunk-nw9t5pq9.js +132 -0
- package/dist/chunk-nxgsnh2y.js +735 -0
- package/dist/chunk-p11xp4xp.js +266 -0
- package/dist/chunk-p1hwrf72.js +74 -0
- package/dist/chunk-p1zj9mg9.js +567 -0
- package/dist/chunk-p39a677r.js +115 -0
- package/dist/chunk-p7vkh4wx.js +15 -0
- package/dist/chunk-p8na2wwp.js +14 -0
- package/dist/chunk-pcb7fbyg.js +259 -0
- package/dist/chunk-pckwmrzd.js +409 -0
- package/dist/chunk-ped973jn.js +111 -0
- package/dist/chunk-phd1qfpc.js +5971 -0
- package/dist/chunk-pkkngdv0.js +524 -0
- package/dist/chunk-ppwjyveh.js +8 -0
- package/dist/chunk-pqvr8jq7.js +324 -0
- package/dist/chunk-prcah3ys.js +106 -0
- package/dist/chunk-ps49ymvj.js +43 -0
- package/dist/chunk-pwwa7s62.js +11 -0
- package/dist/chunk-pxdzy0jh.js +134 -0
- package/dist/chunk-q3jr5t07.js +62 -0
- package/dist/chunk-q6cfkntd.js +675 -0
- package/dist/chunk-q6m26rc8.js +88 -0
- package/dist/chunk-q6xs51jj.js +332 -0
- package/dist/chunk-q7jnesv8.js +74 -0
- package/dist/chunk-q7zpf4r2.js +440 -0
- package/dist/chunk-q8c88vjm.js +24 -0
- package/dist/chunk-qajrkk97.js +298 -0
- package/dist/chunk-qatfdxvd.js +34 -0
- package/dist/chunk-qb6k2afy.js +153 -0
- package/dist/chunk-qfk94vcn.js +329 -0
- package/dist/chunk-qj2e1apf.js +471 -0
- package/dist/chunk-qj2mk79w.js +111 -0
- package/dist/chunk-qk7dfae6.js +267 -0
- package/dist/chunk-qnfx3qtx.js +617 -0
- package/dist/chunk-qp2qdcda.js +100 -0
- package/dist/chunk-qq0phwn8.js +458 -0
- package/dist/chunk-qwqjesx7.js +258 -0
- package/dist/chunk-qygmcg7w.js +60 -0
- package/dist/chunk-qz2x630m.js +49145 -0
- package/dist/chunk-qzj4e8fn.js +357 -0
- package/dist/chunk-ratvcbmn.js +255 -0
- package/dist/chunk-rkg741k3.js +37 -0
- package/dist/chunk-rn0v1hk8.js +34 -0
- package/dist/chunk-rsq0h0rz.js +91 -0
- package/dist/chunk-rvnb2gn6.js +1053 -0
- package/dist/chunk-rx278zpa.js +75 -0
- package/dist/chunk-s3hsqf80.js +473 -0
- package/dist/chunk-s4cb0bcb.js +655 -0
- package/dist/chunk-s8kj6ajy.js +32 -0
- package/dist/chunk-sd36yzx8.js +954 -0
- package/dist/chunk-sfcpjh4r.js +98 -0
- package/dist/chunk-spybh2dy.js +175 -0
- package/dist/chunk-sw9ax3ym.js +92 -0
- package/dist/chunk-szj5wvdy.js +28 -0
- package/dist/chunk-t29a6zb5.js +45 -0
- package/dist/chunk-t9p85zff.js +24 -0
- package/dist/chunk-tc1aazk4.js +131 -0
- package/dist/chunk-tdbz9gbm.js +1030 -0
- package/dist/chunk-tjcfpk38.js +208 -0
- package/dist/chunk-tp2jxmcx.js +8427 -0
- package/dist/chunk-tqmtkm0k.js +92 -0
- package/dist/chunk-tvgvt220.js +22820 -0
- package/dist/chunk-v0qraze5.js +291 -0
- package/dist/chunk-v1kzp02e.js +785 -0
- package/dist/chunk-v78fj8by.js +145 -0
- package/dist/chunk-v8g3kad0.js +101 -0
- package/dist/chunk-v9smspw2.js +4301 -0
- package/dist/chunk-vawgyev5.js +157 -0
- package/dist/chunk-vb3x3cxe.js +375 -0
- package/dist/chunk-vf612n57.js +472 -0
- package/dist/chunk-vjn8mbcw.js +198 -0
- package/dist/chunk-vmbfv1y5.js +295 -0
- package/dist/chunk-vrf54kmt.js +321 -0
- package/dist/chunk-vyjeh50y.js +2149 -0
- package/dist/chunk-vzgkedm9.js +159745 -0
- package/dist/chunk-w004kfw0.js +245 -0
- package/dist/chunk-w0yhbmxn.js +132 -0
- package/dist/chunk-w4yn8cq7.js +123 -0
- package/dist/chunk-waqwgprq.js +1164 -0
- package/dist/chunk-wayfjcwt.js +447 -0
- package/dist/chunk-wby6yd4m.js +91 -0
- package/dist/chunk-wha6v7za.js +705 -0
- package/dist/chunk-wjcq2vkf.js +641 -0
- package/dist/chunk-wtjt9qyk.js +2670 -0
- package/dist/chunk-x2pvw7xw.js +42 -0
- package/dist/chunk-x6r4v44b.js +8 -0
- package/dist/chunk-x8d2ehd7.js +19 -0
- package/dist/chunk-xd6kmmb1.js +95 -0
- package/dist/chunk-xp61y5ba.js +125 -0
- package/dist/chunk-xv3era3s.js +8 -0
- package/dist/chunk-xxw9a0bq.js +58 -0
- package/dist/chunk-xzhaa7gd.js +112 -0
- package/dist/chunk-y1784krc.js +19 -0
- package/dist/chunk-y4ca9kqz.js +3830 -0
- package/dist/chunk-yff68ex1.js +113 -0
- package/dist/chunk-yg4vgpxs.js +436 -0
- package/dist/chunk-yk62vxj2.js +2964 -0
- package/dist/chunk-ym5r3jnk.js +2007 -0
- package/dist/chunk-ysanv95x.js +225 -0
- package/dist/chunk-yvtzznds.js +63 -0
- package/dist/chunk-yyex5gsf.js +269 -0
- package/dist/chunk-yyf72f78.js +456 -0
- package/dist/chunk-z19sd3bt.js +1648 -0
- package/dist/chunk-z2dp53wn.js +17 -0
- package/dist/chunk-z9n0183s.js +39 -0
- package/dist/chunk-zb8f6h5g.js +9174 -0
- package/dist/chunk-zctfbr1v.js +594 -0
- package/dist/chunk-zesnmkg3.js +2840 -0
- package/dist/chunk-zf47r1b7.js +94 -0
- package/dist/chunk-zghtdbat.js +253 -0
- package/dist/chunk-zpmwvd09.js +275 -0
- package/dist/chunk-zqncgyf6.js +127 -0
- package/dist/chunk-zr6mz36s.js +281 -0
- package/dist/chunk-zshzdw1n.js +141 -0
- package/dist/chunk-zx5kw7z4.js +40 -0
- package/dist/chunk-zzm33q8x.js +8 -0
- package/dist/cli.js +91 -0
- package/dist/download-ripgrep.js +24821 -0
- package/dist/vendor/audio-capture/arm64-darwin/audio-capture.node +0 -0
- package/dist/vendor/audio-capture/arm64-linux/audio-capture.node +0 -0
- package/dist/vendor/audio-capture/arm64-win32/audio-capture.node +0 -0
- package/dist/vendor/audio-capture/x64-darwin/audio-capture.node +0 -0
- package/dist/vendor/audio-capture/x64-linux/audio-capture.node +0 -0
- package/dist/vendor/audio-capture/x64-win32/audio-capture.node +0 -0
- package/dist/vendor/ripgrep/x64-win32/rg.exe +0 -0
- package/package.json +122 -0
- package/scripts/postinstall.cjs +319 -0
|
@@ -0,0 +1,1030 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
init_memoize as init_memoize2,
|
|
4
|
+
memoizeWithLRU
|
|
5
|
+
} from "./chunk-0awwmrwr.js";
|
|
6
|
+
import {
|
|
7
|
+
execFileNoThrow,
|
|
8
|
+
init_execFileNoThrow
|
|
9
|
+
} from "./chunk-70eey1nh.js";
|
|
10
|
+
import {
|
|
11
|
+
init_log
|
|
12
|
+
} from "./chunk-1nk93fqz.js";
|
|
13
|
+
import {
|
|
14
|
+
getCwd,
|
|
15
|
+
init_cwd
|
|
16
|
+
} from "./chunk-s8kj6ajy.js";
|
|
17
|
+
import {
|
|
18
|
+
init_which,
|
|
19
|
+
whichSync
|
|
20
|
+
} from "./chunk-eenq3avg.js";
|
|
21
|
+
import {
|
|
22
|
+
getFsImplementation,
|
|
23
|
+
init_cleanupRegistry,
|
|
24
|
+
init_debug,
|
|
25
|
+
init_fsOperations,
|
|
26
|
+
init_slowOperations,
|
|
27
|
+
jsonStringify,
|
|
28
|
+
logForDebugging,
|
|
29
|
+
registerCleanup
|
|
30
|
+
} from "./chunk-phd1qfpc.js";
|
|
31
|
+
import {
|
|
32
|
+
init_state,
|
|
33
|
+
waitForScrollIdle
|
|
34
|
+
} from "./chunk-k8vp0atq.js";
|
|
35
|
+
import {
|
|
36
|
+
init_memoize,
|
|
37
|
+
memoize_default
|
|
38
|
+
} from "./chunk-vf612n57.js";
|
|
39
|
+
import {
|
|
40
|
+
__esm,
|
|
41
|
+
__require
|
|
42
|
+
} from "./chunk-qp2qdcda.js";
|
|
43
|
+
|
|
44
|
+
// src/utils/diagLogs.ts
|
|
45
|
+
import { dirname } from "path";
|
|
46
|
+
function logForDiagnosticsNoPII(level, event, data) {
|
|
47
|
+
const logFile = getDiagnosticLogFile();
|
|
48
|
+
if (!logFile) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const entry = {
|
|
52
|
+
timestamp: new Date().toISOString(),
|
|
53
|
+
level,
|
|
54
|
+
event,
|
|
55
|
+
data: data ?? {}
|
|
56
|
+
};
|
|
57
|
+
const fs = getFsImplementation();
|
|
58
|
+
const line = jsonStringify(entry) + `
|
|
59
|
+
`;
|
|
60
|
+
try {
|
|
61
|
+
fs.appendFileSync(logFile, line);
|
|
62
|
+
} catch {
|
|
63
|
+
try {
|
|
64
|
+
fs.mkdirSync(dirname(logFile));
|
|
65
|
+
fs.appendFileSync(logFile, line);
|
|
66
|
+
} catch {}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function getDiagnosticLogFile() {
|
|
70
|
+
return process.env.CLAUDE_CODE_DIAGNOSTICS_FILE;
|
|
71
|
+
}
|
|
72
|
+
async function withDiagnosticsTiming(event, fn, getData) {
|
|
73
|
+
const startTime = Date.now();
|
|
74
|
+
logForDiagnosticsNoPII("info", `${event}_started`);
|
|
75
|
+
try {
|
|
76
|
+
const result = await fn();
|
|
77
|
+
const additionalData = getData ? getData(result) : {};
|
|
78
|
+
logForDiagnosticsNoPII("info", `${event}_completed`, {
|
|
79
|
+
duration_ms: Date.now() - startTime,
|
|
80
|
+
...additionalData
|
|
81
|
+
});
|
|
82
|
+
return result;
|
|
83
|
+
} catch (error) {
|
|
84
|
+
logForDiagnosticsNoPII("error", `${event}_failed`, {
|
|
85
|
+
duration_ms: Date.now() - startTime
|
|
86
|
+
});
|
|
87
|
+
throw error;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
var init_diagLogs = __esm(() => {
|
|
91
|
+
init_fsOperations();
|
|
92
|
+
init_slowOperations();
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// src/utils/git/gitConfigParser.ts
|
|
96
|
+
import { readFile } from "fs/promises";
|
|
97
|
+
import { join } from "path";
|
|
98
|
+
async function parseGitConfigValue(gitDir, section, subsection, key) {
|
|
99
|
+
try {
|
|
100
|
+
const config = await readFile(join(gitDir, "config"), "utf-8");
|
|
101
|
+
return parseConfigString(config, section, subsection, key);
|
|
102
|
+
} catch {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function parseConfigString(config, section, subsection, key) {
|
|
107
|
+
const lines = config.split(`
|
|
108
|
+
`);
|
|
109
|
+
const sectionLower = section.toLowerCase();
|
|
110
|
+
const keyLower = key.toLowerCase();
|
|
111
|
+
let inSection = false;
|
|
112
|
+
for (const line of lines) {
|
|
113
|
+
const trimmed = line.trim();
|
|
114
|
+
if (trimmed.length === 0 || trimmed[0] === "#" || trimmed[0] === ";") {
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
if (trimmed[0] === "[") {
|
|
118
|
+
inSection = matchesSectionHeader(trimmed, sectionLower, subsection);
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
if (!inSection) {
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
const parsed = parseKeyValue(trimmed);
|
|
125
|
+
if (parsed && parsed.key.toLowerCase() === keyLower) {
|
|
126
|
+
return parsed.value;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
function parseKeyValue(line) {
|
|
132
|
+
let i = 0;
|
|
133
|
+
while (i < line.length && isKeyChar(line[i])) {
|
|
134
|
+
i++;
|
|
135
|
+
}
|
|
136
|
+
if (i === 0) {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
const key = line.slice(0, i);
|
|
140
|
+
while (i < line.length && (line[i] === " " || line[i] === "\t")) {
|
|
141
|
+
i++;
|
|
142
|
+
}
|
|
143
|
+
if (i >= line.length || line[i] !== "=") {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
i++;
|
|
147
|
+
while (i < line.length && (line[i] === " " || line[i] === "\t")) {
|
|
148
|
+
i++;
|
|
149
|
+
}
|
|
150
|
+
const value = parseValue(line, i);
|
|
151
|
+
return { key, value };
|
|
152
|
+
}
|
|
153
|
+
function parseValue(line, start) {
|
|
154
|
+
let result = "";
|
|
155
|
+
let inQuote = false;
|
|
156
|
+
let i = start;
|
|
157
|
+
while (i < line.length) {
|
|
158
|
+
const ch = line[i];
|
|
159
|
+
if (!inQuote && (ch === "#" || ch === ";")) {
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
if (ch === '"') {
|
|
163
|
+
inQuote = !inQuote;
|
|
164
|
+
i++;
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
if (ch === "\\" && i + 1 < line.length) {
|
|
168
|
+
const next = line[i + 1];
|
|
169
|
+
if (inQuote) {
|
|
170
|
+
switch (next) {
|
|
171
|
+
case "n":
|
|
172
|
+
result += `
|
|
173
|
+
`;
|
|
174
|
+
break;
|
|
175
|
+
case "t":
|
|
176
|
+
result += "\t";
|
|
177
|
+
break;
|
|
178
|
+
case "b":
|
|
179
|
+
result += "\b";
|
|
180
|
+
break;
|
|
181
|
+
case '"':
|
|
182
|
+
result += '"';
|
|
183
|
+
break;
|
|
184
|
+
case "\\":
|
|
185
|
+
result += "\\";
|
|
186
|
+
break;
|
|
187
|
+
default:
|
|
188
|
+
result += next;
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
191
|
+
i += 2;
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
if (next === "\\") {
|
|
195
|
+
result += "\\";
|
|
196
|
+
i += 2;
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
result += ch;
|
|
201
|
+
i++;
|
|
202
|
+
}
|
|
203
|
+
if (!inQuote) {
|
|
204
|
+
result = trimTrailingWhitespace(result);
|
|
205
|
+
}
|
|
206
|
+
return result;
|
|
207
|
+
}
|
|
208
|
+
function trimTrailingWhitespace(s) {
|
|
209
|
+
let end = s.length;
|
|
210
|
+
while (end > 0 && (s[end - 1] === " " || s[end - 1] === "\t")) {
|
|
211
|
+
end--;
|
|
212
|
+
}
|
|
213
|
+
return s.slice(0, end);
|
|
214
|
+
}
|
|
215
|
+
function matchesSectionHeader(line, sectionLower, subsection) {
|
|
216
|
+
let i = 1;
|
|
217
|
+
while (i < line.length && line[i] !== "]" && line[i] !== " " && line[i] !== "\t" && line[i] !== '"') {
|
|
218
|
+
i++;
|
|
219
|
+
}
|
|
220
|
+
const foundSection = line.slice(1, i).toLowerCase();
|
|
221
|
+
if (foundSection !== sectionLower) {
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
if (subsection === null) {
|
|
225
|
+
return i < line.length && line[i] === "]";
|
|
226
|
+
}
|
|
227
|
+
while (i < line.length && (line[i] === " " || line[i] === "\t")) {
|
|
228
|
+
i++;
|
|
229
|
+
}
|
|
230
|
+
if (i >= line.length || line[i] !== '"') {
|
|
231
|
+
return false;
|
|
232
|
+
}
|
|
233
|
+
i++;
|
|
234
|
+
let foundSubsection = "";
|
|
235
|
+
while (i < line.length && line[i] !== '"') {
|
|
236
|
+
if (line[i] === "\\" && i + 1 < line.length) {
|
|
237
|
+
const next = line[i + 1];
|
|
238
|
+
if (next === "\\" || next === '"') {
|
|
239
|
+
foundSubsection += next;
|
|
240
|
+
i += 2;
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
foundSubsection += next;
|
|
244
|
+
i += 2;
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
foundSubsection += line[i];
|
|
248
|
+
i++;
|
|
249
|
+
}
|
|
250
|
+
if (i >= line.length || line[i] !== '"') {
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
i++;
|
|
254
|
+
if (i >= line.length || line[i] !== "]") {
|
|
255
|
+
return false;
|
|
256
|
+
}
|
|
257
|
+
return foundSubsection === subsection;
|
|
258
|
+
}
|
|
259
|
+
function isKeyChar(ch) {
|
|
260
|
+
return ch >= "a" && ch <= "z" || ch >= "A" && ch <= "Z" || ch >= "0" && ch <= "9" || ch === "-";
|
|
261
|
+
}
|
|
262
|
+
var init_gitConfigParser = () => {};
|
|
263
|
+
|
|
264
|
+
// src/constants/files.ts
|
|
265
|
+
function hasBinaryExtension(filePath) {
|
|
266
|
+
const ext = filePath.slice(filePath.lastIndexOf(".")).toLowerCase();
|
|
267
|
+
return BINARY_EXTENSIONS.has(ext);
|
|
268
|
+
}
|
|
269
|
+
var BINARY_EXTENSIONS;
|
|
270
|
+
var init_files = __esm(() => {
|
|
271
|
+
BINARY_EXTENSIONS = new Set([
|
|
272
|
+
".png",
|
|
273
|
+
".jpg",
|
|
274
|
+
".jpeg",
|
|
275
|
+
".gif",
|
|
276
|
+
".bmp",
|
|
277
|
+
".ico",
|
|
278
|
+
".webp",
|
|
279
|
+
".tiff",
|
|
280
|
+
".tif",
|
|
281
|
+
".mp4",
|
|
282
|
+
".mov",
|
|
283
|
+
".avi",
|
|
284
|
+
".mkv",
|
|
285
|
+
".webm",
|
|
286
|
+
".wmv",
|
|
287
|
+
".flv",
|
|
288
|
+
".m4v",
|
|
289
|
+
".mpeg",
|
|
290
|
+
".mpg",
|
|
291
|
+
".mp3",
|
|
292
|
+
".wav",
|
|
293
|
+
".ogg",
|
|
294
|
+
".flac",
|
|
295
|
+
".aac",
|
|
296
|
+
".m4a",
|
|
297
|
+
".wma",
|
|
298
|
+
".aiff",
|
|
299
|
+
".opus",
|
|
300
|
+
".zip",
|
|
301
|
+
".tar",
|
|
302
|
+
".gz",
|
|
303
|
+
".bz2",
|
|
304
|
+
".7z",
|
|
305
|
+
".rar",
|
|
306
|
+
".xz",
|
|
307
|
+
".z",
|
|
308
|
+
".tgz",
|
|
309
|
+
".iso",
|
|
310
|
+
".exe",
|
|
311
|
+
".dll",
|
|
312
|
+
".so",
|
|
313
|
+
".dylib",
|
|
314
|
+
".bin",
|
|
315
|
+
".o",
|
|
316
|
+
".a",
|
|
317
|
+
".obj",
|
|
318
|
+
".lib",
|
|
319
|
+
".app",
|
|
320
|
+
".msi",
|
|
321
|
+
".deb",
|
|
322
|
+
".rpm",
|
|
323
|
+
".pdf",
|
|
324
|
+
".doc",
|
|
325
|
+
".docx",
|
|
326
|
+
".xls",
|
|
327
|
+
".xlsx",
|
|
328
|
+
".ppt",
|
|
329
|
+
".pptx",
|
|
330
|
+
".odt",
|
|
331
|
+
".ods",
|
|
332
|
+
".odp",
|
|
333
|
+
".ttf",
|
|
334
|
+
".otf",
|
|
335
|
+
".woff",
|
|
336
|
+
".woff2",
|
|
337
|
+
".eot",
|
|
338
|
+
".pyc",
|
|
339
|
+
".pyo",
|
|
340
|
+
".class",
|
|
341
|
+
".jar",
|
|
342
|
+
".war",
|
|
343
|
+
".ear",
|
|
344
|
+
".node",
|
|
345
|
+
".wasm",
|
|
346
|
+
".rlib",
|
|
347
|
+
".sqlite",
|
|
348
|
+
".sqlite3",
|
|
349
|
+
".db",
|
|
350
|
+
".mdb",
|
|
351
|
+
".idx",
|
|
352
|
+
".psd",
|
|
353
|
+
".ai",
|
|
354
|
+
".eps",
|
|
355
|
+
".sketch",
|
|
356
|
+
".fig",
|
|
357
|
+
".xd",
|
|
358
|
+
".blend",
|
|
359
|
+
".3ds",
|
|
360
|
+
".max",
|
|
361
|
+
".swf",
|
|
362
|
+
".fla",
|
|
363
|
+
".lockb",
|
|
364
|
+
".dat",
|
|
365
|
+
".data"
|
|
366
|
+
]);
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
// src/utils/git.ts
|
|
370
|
+
import { readFileSync, realpathSync, statSync } from "fs";
|
|
371
|
+
import { basename, dirname as dirname2, join as join2, resolve, sep } from "path";
|
|
372
|
+
function createFindGitRoot() {
|
|
373
|
+
function wrapper(startPath) {
|
|
374
|
+
const result = findGitRootImpl(startPath);
|
|
375
|
+
return result === GIT_ROOT_NOT_FOUND ? null : result;
|
|
376
|
+
}
|
|
377
|
+
wrapper.cache = findGitRootImpl.cache;
|
|
378
|
+
return wrapper;
|
|
379
|
+
}
|
|
380
|
+
function createFindCanonicalGitRoot() {
|
|
381
|
+
function wrapper(startPath) {
|
|
382
|
+
const root = findGitRoot(startPath);
|
|
383
|
+
if (!root) {
|
|
384
|
+
return null;
|
|
385
|
+
}
|
|
386
|
+
return resolveCanonicalRoot(root);
|
|
387
|
+
}
|
|
388
|
+
wrapper.cache = resolveCanonicalRoot.cache;
|
|
389
|
+
return wrapper;
|
|
390
|
+
}
|
|
391
|
+
function getGitDir(cwd) {
|
|
392
|
+
return resolveGitDir(cwd);
|
|
393
|
+
}
|
|
394
|
+
async function getGitState() {
|
|
395
|
+
try {
|
|
396
|
+
const [
|
|
397
|
+
commitHash,
|
|
398
|
+
branchName,
|
|
399
|
+
remoteUrl,
|
|
400
|
+
isHeadOnRemote,
|
|
401
|
+
isClean,
|
|
402
|
+
worktreeCount
|
|
403
|
+
] = await Promise.all([
|
|
404
|
+
getHead(),
|
|
405
|
+
getBranch(),
|
|
406
|
+
getRemoteUrl(),
|
|
407
|
+
getIsHeadOnRemote(),
|
|
408
|
+
getIsClean(),
|
|
409
|
+
getWorktreeCount()
|
|
410
|
+
]);
|
|
411
|
+
return {
|
|
412
|
+
commitHash,
|
|
413
|
+
branchName,
|
|
414
|
+
remoteUrl,
|
|
415
|
+
isHeadOnRemote,
|
|
416
|
+
isClean,
|
|
417
|
+
worktreeCount
|
|
418
|
+
};
|
|
419
|
+
} catch (_) {
|
|
420
|
+
return null;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
async function getGithubRepo() {
|
|
424
|
+
const { parseGitRemote } = await import("./chunk-z9n0183s.js");
|
|
425
|
+
const remoteUrl = await getRemoteUrl();
|
|
426
|
+
if (!remoteUrl) {
|
|
427
|
+
logForDebugging("Local GitHub repo: unknown");
|
|
428
|
+
return null;
|
|
429
|
+
}
|
|
430
|
+
const parsed = parseGitRemote(remoteUrl);
|
|
431
|
+
if (parsed && parsed.host === "github.com") {
|
|
432
|
+
const result = `${parsed.owner}/${parsed.name}`;
|
|
433
|
+
logForDebugging(`Local GitHub repo: ${result}`);
|
|
434
|
+
return result;
|
|
435
|
+
}
|
|
436
|
+
logForDebugging("Local GitHub repo: unknown");
|
|
437
|
+
return null;
|
|
438
|
+
}
|
|
439
|
+
function isCurrentDirectoryBareGitRepo() {
|
|
440
|
+
const fs = getFsImplementation();
|
|
441
|
+
const cwd = getCwd();
|
|
442
|
+
const gitPath = join2(cwd, ".git");
|
|
443
|
+
try {
|
|
444
|
+
const stats = fs.statSync(gitPath);
|
|
445
|
+
if (stats.isFile()) {
|
|
446
|
+
return false;
|
|
447
|
+
}
|
|
448
|
+
if (stats.isDirectory()) {
|
|
449
|
+
const gitHeadPath = join2(gitPath, "HEAD");
|
|
450
|
+
try {
|
|
451
|
+
if (fs.statSync(gitHeadPath).isFile()) {
|
|
452
|
+
return false;
|
|
453
|
+
}
|
|
454
|
+
} catch {}
|
|
455
|
+
}
|
|
456
|
+
} catch {}
|
|
457
|
+
try {
|
|
458
|
+
if (fs.statSync(join2(cwd, "HEAD")).isFile())
|
|
459
|
+
return true;
|
|
460
|
+
} catch {}
|
|
461
|
+
try {
|
|
462
|
+
if (fs.statSync(join2(cwd, "objects")).isDirectory())
|
|
463
|
+
return true;
|
|
464
|
+
} catch {}
|
|
465
|
+
try {
|
|
466
|
+
if (fs.statSync(join2(cwd, "refs")).isDirectory())
|
|
467
|
+
return true;
|
|
468
|
+
} catch {}
|
|
469
|
+
return false;
|
|
470
|
+
}
|
|
471
|
+
var GIT_ROOT_NOT_FOUND, findGitRootImpl, findGitRoot, resolveCanonicalRoot, findCanonicalGitRoot, gitExe, getIsGit, dirIsInGitRepo = async (cwd) => {
|
|
472
|
+
return findGitRoot(cwd) !== null;
|
|
473
|
+
}, getHead = async () => {
|
|
474
|
+
return getCachedHead();
|
|
475
|
+
}, getBranch = async () => {
|
|
476
|
+
return getCachedBranch();
|
|
477
|
+
}, getDefaultBranch = async () => {
|
|
478
|
+
return getCachedDefaultBranch();
|
|
479
|
+
}, getRemoteUrl = async () => {
|
|
480
|
+
return getCachedRemoteUrl();
|
|
481
|
+
}, getIsHeadOnRemote = async () => {
|
|
482
|
+
const { code } = await execFileNoThrow(gitExe(), ["rev-parse", "@{u}"], {
|
|
483
|
+
preserveOutputOnError: false
|
|
484
|
+
});
|
|
485
|
+
return code === 0;
|
|
486
|
+
}, getIsClean = async (options) => {
|
|
487
|
+
const args = ["--no-optional-locks", "status", "--porcelain"];
|
|
488
|
+
if (options?.ignoreUntracked) {
|
|
489
|
+
args.push("-uno");
|
|
490
|
+
}
|
|
491
|
+
const { stdout } = await execFileNoThrow(gitExe(), args, {
|
|
492
|
+
preserveOutputOnError: false
|
|
493
|
+
});
|
|
494
|
+
return stdout.trim().length === 0;
|
|
495
|
+
}, getFileStatus = async () => {
|
|
496
|
+
const { stdout } = await execFileNoThrow(gitExe(), ["--no-optional-locks", "status", "--porcelain"], {
|
|
497
|
+
preserveOutputOnError: false
|
|
498
|
+
});
|
|
499
|
+
const tracked = [];
|
|
500
|
+
const untracked = [];
|
|
501
|
+
stdout.trim().split(`
|
|
502
|
+
`).filter((line) => line.length > 0).forEach((line) => {
|
|
503
|
+
const status = line.substring(0, 2);
|
|
504
|
+
const filename = line.substring(2).trim();
|
|
505
|
+
if (status === "??") {
|
|
506
|
+
untracked.push(filename);
|
|
507
|
+
} else if (filename) {
|
|
508
|
+
tracked.push(filename);
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
return { tracked, untracked };
|
|
512
|
+
}, getWorktreeCount = async () => {
|
|
513
|
+
return getWorktreeCountFromFs();
|
|
514
|
+
}, stashToCleanState = async (message) => {
|
|
515
|
+
try {
|
|
516
|
+
const stashMessage = message || `Claude Code auto-stash - ${new Date().toISOString()}`;
|
|
517
|
+
const { untracked } = await getFileStatus();
|
|
518
|
+
if (untracked.length > 0) {
|
|
519
|
+
const { code: addCode } = await execFileNoThrow(gitExe(), ["add", ...untracked], { preserveOutputOnError: false });
|
|
520
|
+
if (addCode !== 0) {
|
|
521
|
+
return false;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
const { code } = await execFileNoThrow(gitExe(), ["stash", "push", "--message", stashMessage], { preserveOutputOnError: false });
|
|
525
|
+
return code === 0;
|
|
526
|
+
} catch (_) {
|
|
527
|
+
return false;
|
|
528
|
+
}
|
|
529
|
+
};
|
|
530
|
+
var init_git = __esm(() => {
|
|
531
|
+
init_memoize();
|
|
532
|
+
init_files();
|
|
533
|
+
init_cwd();
|
|
534
|
+
init_debug();
|
|
535
|
+
init_diagLogs();
|
|
536
|
+
init_execFileNoThrow();
|
|
537
|
+
init_fsOperations();
|
|
538
|
+
init_gitFilesystem();
|
|
539
|
+
init_log();
|
|
540
|
+
init_memoize2();
|
|
541
|
+
init_which();
|
|
542
|
+
GIT_ROOT_NOT_FOUND = Symbol("git-root-not-found");
|
|
543
|
+
findGitRootImpl = memoizeWithLRU((startPath) => {
|
|
544
|
+
const startTime = Date.now();
|
|
545
|
+
logForDiagnosticsNoPII("info", "find_git_root_started");
|
|
546
|
+
let current = resolve(startPath);
|
|
547
|
+
const root = current.substring(0, current.indexOf(sep) + 1) || sep;
|
|
548
|
+
let statCount = 0;
|
|
549
|
+
while (current !== root) {
|
|
550
|
+
try {
|
|
551
|
+
const gitPath = join2(current, ".git");
|
|
552
|
+
statCount++;
|
|
553
|
+
const stat = statSync(gitPath);
|
|
554
|
+
if (stat.isDirectory() || stat.isFile()) {
|
|
555
|
+
logForDiagnosticsNoPII("info", "find_git_root_completed", {
|
|
556
|
+
duration_ms: Date.now() - startTime,
|
|
557
|
+
stat_count: statCount,
|
|
558
|
+
found: true
|
|
559
|
+
});
|
|
560
|
+
return current.normalize("NFC");
|
|
561
|
+
}
|
|
562
|
+
} catch {}
|
|
563
|
+
const parent = dirname2(current);
|
|
564
|
+
if (parent === current) {
|
|
565
|
+
break;
|
|
566
|
+
}
|
|
567
|
+
current = parent;
|
|
568
|
+
}
|
|
569
|
+
try {
|
|
570
|
+
const gitPath = join2(root, ".git");
|
|
571
|
+
statCount++;
|
|
572
|
+
const stat = statSync(gitPath);
|
|
573
|
+
if (stat.isDirectory() || stat.isFile()) {
|
|
574
|
+
logForDiagnosticsNoPII("info", "find_git_root_completed", {
|
|
575
|
+
duration_ms: Date.now() - startTime,
|
|
576
|
+
stat_count: statCount,
|
|
577
|
+
found: true
|
|
578
|
+
});
|
|
579
|
+
return root.normalize("NFC");
|
|
580
|
+
}
|
|
581
|
+
} catch {}
|
|
582
|
+
logForDiagnosticsNoPII("info", "find_git_root_completed", {
|
|
583
|
+
duration_ms: Date.now() - startTime,
|
|
584
|
+
stat_count: statCount,
|
|
585
|
+
found: false
|
|
586
|
+
});
|
|
587
|
+
return GIT_ROOT_NOT_FOUND;
|
|
588
|
+
}, (path) => path, 50);
|
|
589
|
+
findGitRoot = createFindGitRoot();
|
|
590
|
+
resolveCanonicalRoot = memoizeWithLRU((gitRoot) => {
|
|
591
|
+
try {
|
|
592
|
+
const gitContent = readFileSync(join2(gitRoot, ".git"), "utf-8").trim();
|
|
593
|
+
if (!gitContent.startsWith("gitdir:")) {
|
|
594
|
+
return gitRoot;
|
|
595
|
+
}
|
|
596
|
+
const worktreeGitDir = resolve(gitRoot, gitContent.slice("gitdir:".length).trim());
|
|
597
|
+
const commonDir = resolve(worktreeGitDir, readFileSync(join2(worktreeGitDir, "commondir"), "utf-8").trim());
|
|
598
|
+
if (resolve(dirname2(worktreeGitDir)) !== join2(commonDir, "worktrees")) {
|
|
599
|
+
return gitRoot;
|
|
600
|
+
}
|
|
601
|
+
const backlink = realpathSync(readFileSync(join2(worktreeGitDir, "gitdir"), "utf-8").trim());
|
|
602
|
+
if (backlink !== join2(realpathSync(gitRoot), ".git")) {
|
|
603
|
+
return gitRoot;
|
|
604
|
+
}
|
|
605
|
+
if (basename(commonDir) !== ".git") {
|
|
606
|
+
return commonDir.normalize("NFC");
|
|
607
|
+
}
|
|
608
|
+
return dirname2(commonDir).normalize("NFC");
|
|
609
|
+
} catch {
|
|
610
|
+
return gitRoot;
|
|
611
|
+
}
|
|
612
|
+
}, (root) => root, 50);
|
|
613
|
+
findCanonicalGitRoot = createFindCanonicalGitRoot();
|
|
614
|
+
gitExe = memoize_default(() => {
|
|
615
|
+
return whichSync("git") || "git";
|
|
616
|
+
});
|
|
617
|
+
getIsGit = memoize_default(async () => {
|
|
618
|
+
const startTime = Date.now();
|
|
619
|
+
logForDiagnosticsNoPII("info", "is_git_check_started");
|
|
620
|
+
const isGit = findGitRoot(getCwd()) !== null;
|
|
621
|
+
logForDiagnosticsNoPII("info", "is_git_check_completed", {
|
|
622
|
+
duration_ms: Date.now() - startTime,
|
|
623
|
+
is_git: isGit
|
|
624
|
+
});
|
|
625
|
+
return isGit;
|
|
626
|
+
});
|
|
627
|
+
});
|
|
628
|
+
|
|
629
|
+
// src/utils/git/gitFilesystem.ts
|
|
630
|
+
import { unwatchFile, watchFile } from "fs";
|
|
631
|
+
import { readdir, readFile as readFile2, stat } from "fs/promises";
|
|
632
|
+
import { join as join3, resolve as resolve2 } from "path";
|
|
633
|
+
function clearResolveGitDirCache() {
|
|
634
|
+
resolveGitDirCache.clear();
|
|
635
|
+
}
|
|
636
|
+
async function resolveGitDir(startPath) {
|
|
637
|
+
const cwd = resolve2(startPath ?? getCwd());
|
|
638
|
+
const cached = resolveGitDirCache.get(cwd);
|
|
639
|
+
if (cached !== undefined) {
|
|
640
|
+
return cached;
|
|
641
|
+
}
|
|
642
|
+
const root = findGitRoot(cwd);
|
|
643
|
+
if (!root) {
|
|
644
|
+
resolveGitDirCache.set(cwd, null);
|
|
645
|
+
return null;
|
|
646
|
+
}
|
|
647
|
+
const gitPath = join3(root, ".git");
|
|
648
|
+
try {
|
|
649
|
+
const st = await stat(gitPath);
|
|
650
|
+
if (st.isFile()) {
|
|
651
|
+
const content = (await readFile2(gitPath, "utf-8")).trim();
|
|
652
|
+
if (content.startsWith("gitdir:")) {
|
|
653
|
+
const rawDir = content.slice("gitdir:".length).trim();
|
|
654
|
+
const resolved = resolve2(root, rawDir);
|
|
655
|
+
resolveGitDirCache.set(cwd, resolved);
|
|
656
|
+
return resolved;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
resolveGitDirCache.set(cwd, gitPath);
|
|
660
|
+
return gitPath;
|
|
661
|
+
} catch {
|
|
662
|
+
resolveGitDirCache.set(cwd, null);
|
|
663
|
+
return null;
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
function isSafeRefName(name) {
|
|
667
|
+
if (!name || name.startsWith("-") || name.startsWith("/")) {
|
|
668
|
+
return false;
|
|
669
|
+
}
|
|
670
|
+
if (name.includes("..")) {
|
|
671
|
+
return false;
|
|
672
|
+
}
|
|
673
|
+
if (name.split("/").some((c) => c === "." || c === "")) {
|
|
674
|
+
return false;
|
|
675
|
+
}
|
|
676
|
+
if (!/^[a-zA-Z0-9/._+@-]+$/.test(name)) {
|
|
677
|
+
return false;
|
|
678
|
+
}
|
|
679
|
+
return true;
|
|
680
|
+
}
|
|
681
|
+
function isValidGitSha(s) {
|
|
682
|
+
return /^[0-9a-f]{40}$/.test(s) || /^[0-9a-f]{64}$/.test(s);
|
|
683
|
+
}
|
|
684
|
+
async function readGitHead(gitDir) {
|
|
685
|
+
try {
|
|
686
|
+
const content = (await readFile2(join3(gitDir, "HEAD"), "utf-8")).trim();
|
|
687
|
+
if (content.startsWith("ref:")) {
|
|
688
|
+
const ref = content.slice("ref:".length).trim();
|
|
689
|
+
if (ref.startsWith("refs/heads/")) {
|
|
690
|
+
const name = ref.slice("refs/heads/".length);
|
|
691
|
+
if (!isSafeRefName(name)) {
|
|
692
|
+
return null;
|
|
693
|
+
}
|
|
694
|
+
return { type: "branch", name };
|
|
695
|
+
}
|
|
696
|
+
if (!isSafeRefName(ref)) {
|
|
697
|
+
return null;
|
|
698
|
+
}
|
|
699
|
+
const sha = await resolveRef(gitDir, ref);
|
|
700
|
+
return sha ? { type: "detached", sha } : { type: "detached", sha: "" };
|
|
701
|
+
}
|
|
702
|
+
if (!isValidGitSha(content)) {
|
|
703
|
+
return null;
|
|
704
|
+
}
|
|
705
|
+
return { type: "detached", sha: content };
|
|
706
|
+
} catch {
|
|
707
|
+
return null;
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
async function resolveRef(gitDir, ref) {
|
|
711
|
+
const result = await resolveRefInDir(gitDir, ref);
|
|
712
|
+
if (result) {
|
|
713
|
+
return result;
|
|
714
|
+
}
|
|
715
|
+
const commonDir = await getCommonDir(gitDir);
|
|
716
|
+
if (commonDir && commonDir !== gitDir) {
|
|
717
|
+
return resolveRefInDir(commonDir, ref);
|
|
718
|
+
}
|
|
719
|
+
return null;
|
|
720
|
+
}
|
|
721
|
+
async function resolveRefInDir(dir, ref) {
|
|
722
|
+
try {
|
|
723
|
+
const content = (await readFile2(join3(dir, ref), "utf-8")).trim();
|
|
724
|
+
if (content.startsWith("ref:")) {
|
|
725
|
+
const target = content.slice("ref:".length).trim();
|
|
726
|
+
if (!isSafeRefName(target)) {
|
|
727
|
+
return null;
|
|
728
|
+
}
|
|
729
|
+
return resolveRef(dir, target);
|
|
730
|
+
}
|
|
731
|
+
if (!isValidGitSha(content)) {
|
|
732
|
+
return null;
|
|
733
|
+
}
|
|
734
|
+
return content;
|
|
735
|
+
} catch {}
|
|
736
|
+
try {
|
|
737
|
+
const packed = await readFile2(join3(dir, "packed-refs"), "utf-8");
|
|
738
|
+
for (const line of packed.split(`
|
|
739
|
+
`)) {
|
|
740
|
+
if (line.startsWith("#") || line.startsWith("^")) {
|
|
741
|
+
continue;
|
|
742
|
+
}
|
|
743
|
+
const spaceIdx = line.indexOf(" ");
|
|
744
|
+
if (spaceIdx === -1) {
|
|
745
|
+
continue;
|
|
746
|
+
}
|
|
747
|
+
if (line.slice(spaceIdx + 1) === ref) {
|
|
748
|
+
const sha = line.slice(0, spaceIdx);
|
|
749
|
+
return isValidGitSha(sha) ? sha : null;
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
} catch {}
|
|
753
|
+
return null;
|
|
754
|
+
}
|
|
755
|
+
async function getCommonDir(gitDir) {
|
|
756
|
+
try {
|
|
757
|
+
const content = (await readFile2(join3(gitDir, "commondir"), "utf-8")).trim();
|
|
758
|
+
return resolve2(gitDir, content);
|
|
759
|
+
} catch {
|
|
760
|
+
return null;
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
async function readRawSymref(gitDir, refPath, branchPrefix) {
|
|
764
|
+
try {
|
|
765
|
+
const content = (await readFile2(join3(gitDir, refPath), "utf-8")).trim();
|
|
766
|
+
if (content.startsWith("ref:")) {
|
|
767
|
+
const target = content.slice("ref:".length).trim();
|
|
768
|
+
if (target.startsWith(branchPrefix)) {
|
|
769
|
+
const name = target.slice(branchPrefix.length);
|
|
770
|
+
if (!isSafeRefName(name)) {
|
|
771
|
+
return null;
|
|
772
|
+
}
|
|
773
|
+
return name;
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
} catch {}
|
|
777
|
+
return null;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
class GitFileWatcher {
|
|
781
|
+
gitDir = null;
|
|
782
|
+
commonDir = null;
|
|
783
|
+
initialized = false;
|
|
784
|
+
initPromise = null;
|
|
785
|
+
watchedPaths = [];
|
|
786
|
+
branchRefPath = null;
|
|
787
|
+
cache = new Map;
|
|
788
|
+
async ensureStarted() {
|
|
789
|
+
if (this.initialized) {
|
|
790
|
+
return;
|
|
791
|
+
}
|
|
792
|
+
if (this.initPromise) {
|
|
793
|
+
return this.initPromise;
|
|
794
|
+
}
|
|
795
|
+
this.initPromise = this.start();
|
|
796
|
+
return this.initPromise;
|
|
797
|
+
}
|
|
798
|
+
async start() {
|
|
799
|
+
this.gitDir = await resolveGitDir();
|
|
800
|
+
this.initialized = true;
|
|
801
|
+
if (!this.gitDir) {
|
|
802
|
+
return;
|
|
803
|
+
}
|
|
804
|
+
this.commonDir = await getCommonDir(this.gitDir);
|
|
805
|
+
this.watchPath(join3(this.gitDir, "HEAD"), () => {
|
|
806
|
+
this.onHeadChanged();
|
|
807
|
+
});
|
|
808
|
+
this.watchPath(join3(this.commonDir ?? this.gitDir, "config"), () => {
|
|
809
|
+
this.invalidate();
|
|
810
|
+
});
|
|
811
|
+
await this.watchCurrentBranchRef();
|
|
812
|
+
registerCleanup(async () => {
|
|
813
|
+
this.stopWatching();
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
watchPath(path, callback) {
|
|
817
|
+
this.watchedPaths.push(path);
|
|
818
|
+
watchFile(path, { interval: WATCH_INTERVAL_MS }, callback);
|
|
819
|
+
}
|
|
820
|
+
async watchCurrentBranchRef() {
|
|
821
|
+
if (!this.gitDir) {
|
|
822
|
+
return;
|
|
823
|
+
}
|
|
824
|
+
const head = await readGitHead(this.gitDir);
|
|
825
|
+
const refsDir = this.commonDir ?? this.gitDir;
|
|
826
|
+
const refPath = head?.type === "branch" ? join3(refsDir, "refs", "heads", head.name) : null;
|
|
827
|
+
if (refPath === this.branchRefPath) {
|
|
828
|
+
return;
|
|
829
|
+
}
|
|
830
|
+
if (this.branchRefPath) {
|
|
831
|
+
unwatchFile(this.branchRefPath);
|
|
832
|
+
this.watchedPaths = this.watchedPaths.filter((p) => p !== this.branchRefPath);
|
|
833
|
+
}
|
|
834
|
+
this.branchRefPath = refPath;
|
|
835
|
+
if (!refPath) {
|
|
836
|
+
return;
|
|
837
|
+
}
|
|
838
|
+
this.watchPath(refPath, () => {
|
|
839
|
+
this.invalidate();
|
|
840
|
+
});
|
|
841
|
+
}
|
|
842
|
+
async onHeadChanged() {
|
|
843
|
+
this.invalidate();
|
|
844
|
+
await waitForScrollIdle();
|
|
845
|
+
await this.watchCurrentBranchRef();
|
|
846
|
+
}
|
|
847
|
+
invalidate() {
|
|
848
|
+
for (const entry of this.cache.values()) {
|
|
849
|
+
entry.dirty = true;
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
stopWatching() {
|
|
853
|
+
for (const path of this.watchedPaths) {
|
|
854
|
+
unwatchFile(path);
|
|
855
|
+
}
|
|
856
|
+
this.watchedPaths = [];
|
|
857
|
+
this.branchRefPath = null;
|
|
858
|
+
}
|
|
859
|
+
async get(key, compute) {
|
|
860
|
+
await this.ensureStarted();
|
|
861
|
+
const existing = this.cache.get(key);
|
|
862
|
+
if (existing && !existing.dirty) {
|
|
863
|
+
return existing.value;
|
|
864
|
+
}
|
|
865
|
+
if (existing) {
|
|
866
|
+
existing.dirty = false;
|
|
867
|
+
}
|
|
868
|
+
const value = await compute();
|
|
869
|
+
const entry = this.cache.get(key);
|
|
870
|
+
if (entry && !entry.dirty) {
|
|
871
|
+
entry.value = value;
|
|
872
|
+
}
|
|
873
|
+
if (!entry) {
|
|
874
|
+
this.cache.set(key, { value, dirty: false, compute });
|
|
875
|
+
}
|
|
876
|
+
return value;
|
|
877
|
+
}
|
|
878
|
+
reset() {
|
|
879
|
+
this.stopWatching();
|
|
880
|
+
this.cache.clear();
|
|
881
|
+
this.initialized = false;
|
|
882
|
+
this.initPromise = null;
|
|
883
|
+
this.gitDir = null;
|
|
884
|
+
this.commonDir = null;
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
async function computeBranch() {
|
|
888
|
+
const gitDir = await resolveGitDir();
|
|
889
|
+
if (!gitDir) {
|
|
890
|
+
return "HEAD";
|
|
891
|
+
}
|
|
892
|
+
const head = await readGitHead(gitDir);
|
|
893
|
+
if (!head) {
|
|
894
|
+
return "HEAD";
|
|
895
|
+
}
|
|
896
|
+
return head.type === "branch" ? head.name : "HEAD";
|
|
897
|
+
}
|
|
898
|
+
async function computeHead() {
|
|
899
|
+
const gitDir = await resolveGitDir();
|
|
900
|
+
if (!gitDir) {
|
|
901
|
+
return "";
|
|
902
|
+
}
|
|
903
|
+
const head = await readGitHead(gitDir);
|
|
904
|
+
if (!head) {
|
|
905
|
+
return "";
|
|
906
|
+
}
|
|
907
|
+
if (head.type === "branch") {
|
|
908
|
+
return await resolveRef(gitDir, `refs/heads/${head.name}`) ?? "";
|
|
909
|
+
}
|
|
910
|
+
return head.sha;
|
|
911
|
+
}
|
|
912
|
+
async function computeRemoteUrl() {
|
|
913
|
+
const gitDir = await resolveGitDir();
|
|
914
|
+
if (!gitDir) {
|
|
915
|
+
return null;
|
|
916
|
+
}
|
|
917
|
+
const url = await parseGitConfigValue(gitDir, "remote", "origin", "url");
|
|
918
|
+
if (url) {
|
|
919
|
+
return url;
|
|
920
|
+
}
|
|
921
|
+
const commonDir = await getCommonDir(gitDir);
|
|
922
|
+
if (commonDir && commonDir !== gitDir) {
|
|
923
|
+
return parseGitConfigValue(commonDir, "remote", "origin", "url");
|
|
924
|
+
}
|
|
925
|
+
return null;
|
|
926
|
+
}
|
|
927
|
+
async function computeDefaultBranch() {
|
|
928
|
+
const gitDir = await resolveGitDir();
|
|
929
|
+
if (!gitDir) {
|
|
930
|
+
return "main";
|
|
931
|
+
}
|
|
932
|
+
const commonDir = await getCommonDir(gitDir) ?? gitDir;
|
|
933
|
+
const branchFromSymref = await readRawSymref(commonDir, "refs/remotes/origin/HEAD", "refs/remotes/origin/");
|
|
934
|
+
if (branchFromSymref) {
|
|
935
|
+
return branchFromSymref;
|
|
936
|
+
}
|
|
937
|
+
for (const candidate of ["main", "master"]) {
|
|
938
|
+
const sha = await resolveRef(commonDir, `refs/remotes/origin/${candidate}`);
|
|
939
|
+
if (sha) {
|
|
940
|
+
return candidate;
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
return "main";
|
|
944
|
+
}
|
|
945
|
+
function getCachedBranch() {
|
|
946
|
+
return gitWatcher.get("branch", computeBranch);
|
|
947
|
+
}
|
|
948
|
+
function getCachedHead() {
|
|
949
|
+
return gitWatcher.get("head", computeHead);
|
|
950
|
+
}
|
|
951
|
+
function getCachedRemoteUrl() {
|
|
952
|
+
return gitWatcher.get("remoteUrl", computeRemoteUrl);
|
|
953
|
+
}
|
|
954
|
+
function getCachedDefaultBranch() {
|
|
955
|
+
return gitWatcher.get("defaultBranch", computeDefaultBranch);
|
|
956
|
+
}
|
|
957
|
+
async function getHeadForDir(cwd) {
|
|
958
|
+
const gitDir = await resolveGitDir(cwd);
|
|
959
|
+
if (!gitDir) {
|
|
960
|
+
return null;
|
|
961
|
+
}
|
|
962
|
+
const head = await readGitHead(gitDir);
|
|
963
|
+
if (!head) {
|
|
964
|
+
return null;
|
|
965
|
+
}
|
|
966
|
+
if (head.type === "branch") {
|
|
967
|
+
return resolveRef(gitDir, `refs/heads/${head.name}`);
|
|
968
|
+
}
|
|
969
|
+
return head.sha;
|
|
970
|
+
}
|
|
971
|
+
async function readWorktreeHeadSha(worktreePath) {
|
|
972
|
+
let gitDir;
|
|
973
|
+
try {
|
|
974
|
+
const ptr = (await readFile2(join3(worktreePath, ".git"), "utf-8")).trim();
|
|
975
|
+
if (!ptr.startsWith("gitdir:")) {
|
|
976
|
+
return null;
|
|
977
|
+
}
|
|
978
|
+
gitDir = resolve2(worktreePath, ptr.slice("gitdir:".length).trim());
|
|
979
|
+
} catch {
|
|
980
|
+
return null;
|
|
981
|
+
}
|
|
982
|
+
const head = await readGitHead(gitDir);
|
|
983
|
+
if (!head) {
|
|
984
|
+
return null;
|
|
985
|
+
}
|
|
986
|
+
if (head.type === "branch") {
|
|
987
|
+
return resolveRef(gitDir, `refs/heads/${head.name}`);
|
|
988
|
+
}
|
|
989
|
+
return head.sha;
|
|
990
|
+
}
|
|
991
|
+
async function getRemoteUrlForDir(cwd) {
|
|
992
|
+
const gitDir = await resolveGitDir(cwd);
|
|
993
|
+
if (!gitDir) {
|
|
994
|
+
return null;
|
|
995
|
+
}
|
|
996
|
+
const url = await parseGitConfigValue(gitDir, "remote", "origin", "url");
|
|
997
|
+
if (url) {
|
|
998
|
+
return url;
|
|
999
|
+
}
|
|
1000
|
+
const commonDir = await getCommonDir(gitDir);
|
|
1001
|
+
if (commonDir && commonDir !== gitDir) {
|
|
1002
|
+
return parseGitConfigValue(commonDir, "remote", "origin", "url");
|
|
1003
|
+
}
|
|
1004
|
+
return null;
|
|
1005
|
+
}
|
|
1006
|
+
async function getWorktreeCountFromFs() {
|
|
1007
|
+
try {
|
|
1008
|
+
const gitDir = await resolveGitDir();
|
|
1009
|
+
if (!gitDir) {
|
|
1010
|
+
return 0;
|
|
1011
|
+
}
|
|
1012
|
+
const commonDir = await getCommonDir(gitDir) ?? gitDir;
|
|
1013
|
+
const entries = await readdir(join3(commonDir, "worktrees"));
|
|
1014
|
+
return entries.length + 1;
|
|
1015
|
+
} catch {
|
|
1016
|
+
return 1;
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
var resolveGitDirCache, WATCH_INTERVAL_MS = 1000, gitWatcher;
|
|
1020
|
+
var init_gitFilesystem = __esm(() => {
|
|
1021
|
+
init_state();
|
|
1022
|
+
init_cleanupRegistry();
|
|
1023
|
+
init_cwd();
|
|
1024
|
+
init_git();
|
|
1025
|
+
init_gitConfigParser();
|
|
1026
|
+
resolveGitDirCache = new Map;
|
|
1027
|
+
gitWatcher = new GitFileWatcher;
|
|
1028
|
+
});
|
|
1029
|
+
|
|
1030
|
+
export { hasBinaryExtension, init_files, logForDiagnosticsNoPII, withDiagnosticsTiming, init_diagLogs, parseGitConfigValue, init_gitConfigParser, clearResolveGitDirCache, resolveGitDir, resolveRef, getCommonDir, getHeadForDir, readWorktreeHeadSha, getRemoteUrlForDir, init_gitFilesystem, findGitRoot, findCanonicalGitRoot, gitExe, getIsGit, getGitDir, dirIsInGitRepo, getBranch, getDefaultBranch, getRemoteUrl, getIsClean, getFileStatus, getWorktreeCount, stashToCleanState, getGitState, getGithubRepo, isCurrentDirectoryBareGitRepo, init_git };
|