scip-query 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/README.md +1 -0
- package/dist/augment-vue-worker.js +1 -1
- package/dist/{chunk-OTTHMUMV.js → chunk-2FAJTZSX.js} +2 -2
- package/dist/{chunk-EJ65IVPV.js → chunk-2ZNZSNVW.js} +2 -2
- package/dist/chunk-35NLDRZC.js +2 -0
- package/dist/{chunk-QPF7CS5W.js → chunk-3KQOIXLO.js} +2 -2
- package/dist/{chunk-VCRMI56V.js → chunk-3OSRXJKK.js} +2 -2
- package/dist/chunk-42QYU6FD.js +3 -0
- package/dist/{chunk-ODH4FT3P.js → chunk-4ZCNFENR.js} +2 -2
- package/dist/{chunk-GWCW25ON.js → chunk-4ZHJAHLE.js} +2 -2
- package/dist/chunk-547VY366.js +18 -0
- package/dist/{chunk-NX2YAXVQ.js → chunk-54UYBTZW.js} +2 -2
- package/dist/{chunk-7ROLM67J.js → chunk-6DHPQS72.js} +2 -2
- package/dist/chunk-6SHX42QQ.js +6 -0
- package/dist/{chunk-ABDXTPCT.js → chunk-7EI4MU5A.js} +2 -2
- package/dist/{chunk-J7IMQRCU.js → chunk-7FG5M53V.js} +2 -2
- package/dist/chunk-A45K6VUK.js +2 -0
- package/dist/{chunk-MPBN5DO4.js → chunk-AEDB4WXE.js} +2 -2
- package/dist/{chunk-O5A7BTMA.js → chunk-AERYQJ52.js} +2 -2
- package/dist/chunk-AM2LGOEX.js +3 -0
- package/dist/{chunk-43QUXX3E.js → chunk-AWSRND4W.js} +2 -2
- package/dist/{chunk-5GAUXLOE.js → chunk-BOXAKNN6.js} +2 -2
- package/dist/{chunk-IKMOYFUM.js → chunk-BYPVNKJT.js} +2 -2
- package/dist/chunk-DQIJMKNE.js +3 -0
- package/dist/{chunk-K65T4TJS.js → chunk-DV6B262O.js} +2 -2
- package/dist/chunk-DWN7QDTV.js +26 -0
- package/dist/{chunk-HOZ3IXZ5.js → chunk-EZGT3NJX.js} +2 -2
- package/dist/{chunk-SW7LKHRU.js → chunk-EZHARAL4.js} +2 -2
- package/dist/chunk-F334Z5UA.js +38 -0
- package/dist/{chunk-SWJEREML.js → chunk-F5L7WEZF.js} +2 -2
- package/dist/{chunk-5CJ6AQN7.js → chunk-FLIF3JWA.js} +2 -2
- package/dist/chunk-FMC3BI4I.js +2 -0
- package/dist/{chunk-YMFHC5J2.js → chunk-G6QQCX45.js} +2 -2
- package/dist/{chunk-35TZERMO.js → chunk-G6RQVDTI.js} +2 -2
- package/dist/chunk-GBB2RUDN.js +927 -0
- package/dist/{chunk-LL5NQB5V.js → chunk-GJ3FR5WG.js} +2 -2
- package/dist/chunk-GMZYT44R.js +5 -0
- package/dist/{chunk-OQFPCIXO.js → chunk-GNJHHPZE.js} +2 -2
- package/dist/chunk-HOXI4F5I.js +4 -0
- package/dist/{chunk-PV3GKBO5.js → chunk-IWK562KR.js} +2 -2
- package/dist/chunk-IXORBCMR.js +120 -0
- package/dist/chunk-J3U47L4Q.js +2 -0
- package/dist/{chunk-O5Y3ISO3.js → chunk-J65FQLDL.js} +2 -2
- package/dist/{chunk-45QWQSWS.js → chunk-J6BR4MD6.js} +2 -2
- package/dist/{chunk-J7WYG63U.js → chunk-JFGUBZWE.js} +2 -2
- package/dist/{chunk-FMD46HAG.js → chunk-KD6TPIXM.js} +2 -2
- package/dist/{chunk-3M2UCPFS.js → chunk-KHE7J5ZN.js} +1 -1
- package/dist/{chunk-IG6X65MG.js → chunk-KWBA6FDD.js} +2 -2
- package/dist/{chunk-LADYDOS5.js → chunk-LJD7V7UO.js} +2 -2
- package/dist/{chunk-D5F3IQYP.js → chunk-MDDF67O2.js} +2 -2
- package/dist/{chunk-BAMVG4WQ.js → chunk-MFBXBLHA.js} +2 -2
- package/dist/{chunk-VXDMXZKC.js → chunk-MTFHE7ZO.js} +2 -2
- package/dist/chunk-NEG77KKH.js +4 -0
- package/dist/{chunk-WA64GKWB.js → chunk-NH7WNNQC.js} +3 -3
- package/dist/{chunk-K3UVTL3J.js → chunk-OGHGTD6Z.js} +2 -2
- package/dist/chunk-OYYZLJVT.js +2 -0
- package/dist/{chunk-MNRKD3WP.js → chunk-PAZFJMXB.js} +2 -2
- package/dist/{chunk-U244OVE6.js → chunk-PBADFBRR.js} +2 -2
- package/dist/{chunk-UWR52GNZ.js → chunk-PKAPOFF5.js} +2 -2
- package/dist/{chunk-POGZSZPX.js → chunk-PXJIEMND.js} +2 -2
- package/dist/{chunk-PZV2PGBR.js → chunk-QB5WSOTY.js} +2 -2
- package/dist/{chunk-MN54AGZ3.js → chunk-QHOUNTDZ.js} +2 -2
- package/dist/chunk-QN67MWDU.js +2 -0
- package/dist/{chunk-JLZUM476.js → chunk-QNMOZ3CJ.js} +2 -2
- package/dist/{chunk-AWYKDRYV.js → chunk-RIGY5DDE.js} +2 -2
- package/dist/chunk-RJLU7IMR.js +10 -0
- package/dist/{chunk-AV54WZUK.js → chunk-S65OEY2G.js} +2 -2
- package/dist/chunk-SATRCB5O.js +20 -0
- package/dist/chunk-T5CSWYAZ.js +2 -0
- package/dist/{chunk-H4T2AST4.js → chunk-TC3X33N6.js} +2 -2
- package/dist/{chunk-3CJXFMR5.js → chunk-TCVRJ56J.js} +2 -2
- package/dist/{chunk-7XP7ZRSI.js → chunk-TDGCALH6.js} +2 -2
- package/dist/chunk-TDZXQAH7.js +2 -0
- package/dist/{chunk-SUYCF4SX.js → chunk-TOYQTO44.js} +2 -2
- package/dist/chunk-UJL3N6TC.js +5 -0
- package/dist/chunk-UVMME4FI.js +16 -0
- package/dist/{chunk-6JSTKSZH.js → chunk-UXOVHGT6.js} +2 -2
- package/dist/chunk-VV5WJLRO.js +67 -0
- package/dist/{chunk-GTANVH72.js → chunk-WT7TOU2C.js} +2 -2
- package/dist/{chunk-4FLF7BHJ.js → chunk-X36LKKVG.js} +2 -2
- package/dist/{chunk-OSBLECSI.js → chunk-X3OOU7CF.js} +2 -2
- package/dist/chunk-X65VYV2S.js +2 -0
- package/dist/chunk-XBN5VO53.js +2 -0
- package/dist/{chunk-TLTLJ4SW.js → chunk-XDSB47KO.js} +2 -2
- package/dist/{chunk-4L4X66GE.js → chunk-XDVT7QPG.js} +2 -2
- package/dist/chunk-XESK6725.js +2 -0
- package/dist/{chunk-P4L5QQT5.js → chunk-XPYXEEDO.js} +2 -2
- package/dist/{chunk-T4P27T6S.js → chunk-XTSVYYAL.js} +2 -2
- package/dist/{chunk-27YDE22N.js → chunk-YBAC3RON.js} +2 -2
- package/dist/{chunk-2DBY4MO7.js → chunk-YHYTDWFT.js} +2 -2
- package/dist/chunk-YYR7ADNB.js +2 -0
- package/dist/chunk-ZL5Y23AJ.js +3 -0
- package/dist/{chunk-CMLHZWRS.js → chunk-ZNSLF5AC.js} +2 -2
- package/dist/chunk-ZXWFN7CK.js +2 -0
- package/dist/cli.js +2 -2
- package/dist/{command-descriptors-AQWWJNTT.js → command-descriptors-SWFWGIFK.js} +173 -167
- package/dist/{config-types-70s7NxKB.d.ts → config-types-BA3xLCfG.d.ts} +28 -1
- package/dist/{db-BBmJ0v3b.d.ts → db-CzA-9_rL.d.ts} +6 -18
- package/dist/direct-navigation-RKMPBXMI.js +3 -0
- package/dist/{health-CWpFL_6z.d.ts → health-DYy13GAe.d.ts} +3 -1
- package/dist/index.d.ts +23 -41
- package/dist/index.js +1 -1
- package/dist/postinstall.js +1 -1
- package/dist/queries/affected.d.ts +2 -2
- package/dist/queries/affected.js +1 -1
- package/dist/queries/architecture.d.ts +83 -0
- package/dist/queries/architecture.js +2 -0
- package/dist/queries/bottlenecks.d.ts +2 -2
- package/dist/queries/bottlenecks.js +1 -1
- package/dist/queries/by-kind.d.ts +2 -2
- package/dist/queries/by-kind.js +1 -1
- package/dist/queries/call-graph.d.ts +2 -2
- package/dist/queries/call-graph.js +1 -1
- package/dist/queries/change-surface.d.ts +2 -2
- package/dist/queries/change-surface.js +1 -1
- package/dist/queries/cleanup-plan.d.ts +2 -2
- package/dist/queries/cleanup-plan.js +1 -1
- package/dist/queries/co-change.d.ts +2 -2
- package/dist/queries/co-change.js +1 -1
- package/dist/queries/code.d.ts +2 -2
- package/dist/queries/code.js +1 -1
- package/dist/queries/complexity-hotspots.d.ts +2 -2
- package/dist/queries/complexity-hotspots.js +1 -1
- package/dist/queries/complexity.d.ts +2 -2
- package/dist/queries/complexity.js +1 -1
- package/dist/queries/convergence.d.ts +2 -2
- package/dist/queries/convergence.js +1 -1
- package/dist/queries/coupling.d.ts +2 -2
- package/dist/queries/coupling.js +1 -1
- package/dist/queries/cycles.d.ts +2 -2
- package/dist/queries/cycles.js +1 -1
- package/dist/queries/dataflow.d.ts +2 -2
- package/dist/queries/dataflow.js +1 -1
- package/dist/queries/dead.d.ts +2 -2
- package/dist/queries/dead.js +1 -1
- package/dist/queries/decorative-checkers.d.ts +2 -2
- package/dist/queries/decorative-checkers.js +1 -1
- package/dist/queries/deep-chains.d.ts +2 -2
- package/dist/queries/deep-chains.js +1 -1
- package/dist/queries/deps.d.ts +2 -2
- package/dist/queries/deps.js +1 -1
- package/dist/queries/diff-gate.d.ts +5 -3
- package/dist/queries/diff-gate.js +1 -1
- package/dist/queries/diff-impact.d.ts +2 -2
- package/dist/queries/diff-impact.js +1 -1
- package/dist/queries/doc-drift.d.ts +2 -2
- package/dist/queries/doc-drift.js +1 -1
- package/dist/queries/drift.d.ts +27 -10
- package/dist/queries/drift.js +1 -1
- package/dist/queries/duplicate-bodies.d.ts +2 -2
- package/dist/queries/duplicate-bodies.js +1 -1
- package/dist/queries/extract-candidates.d.ts +2 -2
- package/dist/queries/extract-candidates.js +1 -1
- package/dist/queries/fan.d.ts +2 -2
- package/dist/queries/fan.js +1 -1
- package/dist/queries/files.d.ts +2 -2
- package/dist/queries/health.d.ts +3 -3
- package/dist/queries/health.js +1 -1
- package/dist/queries/hierarchy.d.ts +2 -2
- package/dist/queries/hierarchy.js +1 -1
- package/dist/queries/hotspots.d.ts +2 -2
- package/dist/queries/hotspots.js +1 -1
- package/dist/queries/imports.d.ts +2 -2
- package/dist/queries/imports.js +1 -1
- package/dist/queries/incomplete-migration.d.ts +2 -2
- package/dist/queries/incomplete-migration.js +1 -1
- package/dist/queries/index.d.ts +5 -4
- package/dist/queries/index.js +1 -1
- package/dist/queries/isolated.d.ts +2 -2
- package/dist/queries/isolated.js +1 -1
- package/dist/queries/locality-candidates.d.ts +2 -2
- package/dist/queries/locality-candidates.js +1 -1
- package/dist/queries/members.d.ts +2 -2
- package/dist/queries/members.js +1 -1
- package/dist/queries/methods.d.ts +2 -2
- package/dist/queries/methods.js +1 -1
- package/dist/queries/not-implemented.d.ts +2 -2
- package/dist/queries/not-implemented.js +1 -1
- package/dist/queries/outline.d.ts +2 -2
- package/dist/queries/outline.js +1 -1
- package/dist/queries/passthrough-candidates.d.ts +2 -2
- package/dist/queries/passthrough-candidates.js +1 -1
- package/dist/queries/plan-context.d.ts +2 -2
- package/dist/queries/plan-context.js +1 -1
- package/dist/queries/react-component-duplicates.d.ts +2 -2
- package/dist/queries/react-component-duplicates.js +1 -1
- package/dist/queries/react-hook-candidates.d.ts +2 -2
- package/dist/queries/react-hook-candidates.js +1 -1
- package/dist/queries/react-large-component-pressure.d.ts +2 -2
- package/dist/queries/react-large-component-pressure.js +1 -1
- package/dist/queries/recent-duplicates.d.ts +2 -2
- package/dist/queries/recent-duplicates.js +1 -1
- package/dist/queries/redundant-reexports.d.ts +2 -2
- package/dist/queries/redundant-reexports.js +1 -1
- package/dist/queries/refs.d.ts +2 -2
- package/dist/queries/refs.js +1 -1
- package/dist/queries/self-audit.d.ts +2 -2
- package/dist/queries/self-audit.js +1 -1
- package/dist/queries/similar-chains.d.ts +2 -2
- package/dist/queries/similar-chains.js +1 -1
- package/dist/queries/similar-files.d.ts +2 -2
- package/dist/queries/similar-files.js +1 -1
- package/dist/queries/similar-signatures.d.ts +2 -2
- package/dist/queries/similar-signatures.js +1 -1
- package/dist/queries/similar.d.ts +2 -2
- package/dist/queries/similar.js +1 -1
- package/dist/queries/slice.d.ts +2 -2
- package/dist/queries/slice.js +1 -1
- package/dist/queries/stale-abstractions.d.ts +2 -2
- package/dist/queries/stale-abstractions.js +1 -1
- package/dist/queries/stats.d.ts +2 -2
- package/dist/queries/surface.d.ts +2 -2
- package/dist/queries/surface.js +1 -1
- package/dist/queries/symbols.d.ts +2 -2
- package/dist/queries/symbols.js +1 -1
- package/dist/queries/system.d.ts +2 -2
- package/dist/queries/system.js +1 -1
- package/dist/queries/test-quality.d.ts +2 -2
- package/dist/queries/test-quality.js +1 -1
- package/dist/queries/trace.d.ts +2 -2
- package/dist/queries/trace.js +1 -1
- package/dist/queries/twin-ab.d.ts +2 -2
- package/dist/queries/twin-ab.js +1 -1
- package/dist/queries/twin-drift.d.ts +2 -2
- package/dist/queries/twin-drift.js +1 -1
- package/dist/queries/unused-imports.d.ts +2 -2
- package/dist/queries/unused-imports.js +1 -1
- package/dist/queries/unused-params.d.ts +2 -2
- package/dist/queries/unused-params.js +1 -1
- package/dist/queries/vue-component-duplicates.d.ts +2 -2
- package/dist/queries/vue-component-duplicates.js +1 -1
- package/dist/queries/vue-composable-candidates.d.ts +2 -2
- package/dist/queries/vue-composable-candidates.js +1 -1
- package/dist/queries/vue-large-view-pressure.d.ts +2 -2
- package/dist/queries/vue-large-view-pressure.js +1 -1
- package/dist/queries/wrapper-candidates.d.ts +2 -2
- package/dist/queries/wrapper-candidates.js +1 -1
- package/dist/reindex-worker.js +24 -24
- package/dist/reindex.d.ts +12 -10
- package/dist/reindex.js +38 -38
- package/dist/runtime.d.ts +10 -9
- package/dist/runtime.js +2 -1
- package/dist/rust-semantic-session-server.js +1 -1
- package/dist/{scip-cli-CoMzb7Zu.d.ts → scip-cli-1bVKJgXi.d.ts} +1 -1
- package/dist/watch-server.js +7 -6
- package/docs/AI_FAILURE_MODES.md +1 -0
- package/docs/COMMAND_REFERENCE.md +3 -2
- package/docs/DETECTOR_GUIDE.md +5 -3
- package/docs/analyzer-inventory.md +16 -6
- package/docs/analyzer-validation-ledger.md +12 -1
- package/docs/architecture-coherence-vision.md +219 -0
- package/package.json +5 -1
- package/skills/_shared/SKILL.md +4 -3
- package/skills/scip-conductor/SKILL.md +1 -1
- package/skills/scip-directory-architecture/SKILL.md +116 -2
- package/skills/scip-maintainability/SKILL.md +3 -3
- package/skills/scip-query/SKILL.md +1 -1
- package/skills/scip-twin-drift/SKILL.md +1 -1
- package/skills/scip-verify/SKILL.md +1 -1
- package/dist/chunk-2GX3TNOW.js +0 -38
- package/dist/chunk-45XOH33S.js +0 -2
- package/dist/chunk-4MFMTEJ4.js +0 -5
- package/dist/chunk-BECOMXAL.js +0 -2
- package/dist/chunk-BJJHBKEC.js +0 -2
- package/dist/chunk-DDGO34I2.js +0 -26
- package/dist/chunk-DUKRAHV2.js +0 -2
- package/dist/chunk-EMEXMHOP.js +0 -7
- package/dist/chunk-GWNE2WJN.js +0 -3
- package/dist/chunk-H4JNB7RT.js +0 -3
- package/dist/chunk-L2RE5P3X.js +0 -2
- package/dist/chunk-L2TSLMPT.js +0 -5
- package/dist/chunk-NQBMGFFD.js +0 -2
- package/dist/chunk-OINSINYW.js +0 -2
- package/dist/chunk-OM6JHEW3.js +0 -16
- package/dist/chunk-OUXPJ4H5.js +0 -3
- package/dist/chunk-OWXNDSG3.js +0 -2
- package/dist/chunk-Q4UM4JJP.js +0 -2
- package/dist/chunk-QEIGJJBC.js +0 -20
- package/dist/chunk-R4VPIS4D.js +0 -10
- package/dist/chunk-RDX6WWHN.js +0 -4
- package/dist/chunk-RUQE7DZT.js +0 -2
- package/dist/chunk-S43DIBME.js +0 -18
- package/dist/chunk-SALRDXWM.js +0 -121
- package/dist/chunk-SMBIGBGN.js +0 -67
- package/dist/chunk-VQWDZ34M.js +0 -928
- package/dist/chunk-W3557RPL.js +0 -3
- package/dist/chunk-W3SKYOTF.js +0 -2
- package/dist/chunk-XEEQX5X3.js +0 -3
- package/dist/direct-navigation-K3CTVVBU.js +0 -3
package/dist/chunk-SALRDXWM.js
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import{a as _n,b as x,c as ft,d as Dn,e as ke,f as An,g as jn}from"./chunk-SMBIGBGN.js";import{a as H,b as P}from"./chunk-3M2UCPFS.js";import{a as rr,b as nr,e as ir}from"./chunk-JHK2DMUQ.js";import{spawn as Ls}from"child_process";import{closeSync as Ms,existsSync as $s,mkdirSync as Ws,openSync as Gs,readFileSync as ur,rmSync as Me,writeFileSync as Us}from"fs";import{dirname as Vs,join as cr,resolve as dr}from"path";import{fileURLToPath as af}from"url";import{spawnSync as Is}from"child_process";import{createHash as Es}from"crypto";import{existsSync as ws,lstatSync as Cs,realpathSync as ks}from"fs";import{dirname as Ts,isAbsolute as Ps,join as Rs,resolve as gt}from"path";var ht={run(e,t){let r=On(e,t);return r.kind==="success"?r.output:void 0},runResult:On},Ns=["rev-parse","--show-toplevel","--absolute-git-dir","--git-common-dir","HEAD","HEAD^{tree}"],Fn=/^[0-9a-f]{40,64}$/;function Ln(e,t=ht){let r=t.runResult(e,Ns);if(r.kind==="success"){let n=_s(r.output);if(n)return Ds(n,t)}return As(e,t)}function _s(e){let t=e.split(`
|
|
2
|
-
`).map(c=>c.trim());if(t.length!==5)return;let[r,n,i,o,s]=t;if(!r||!n||!i||!o||!s||!Fn.test(o)||!Fn.test(s))return;let a=U(r);return{root:a,gitDir:U(mt(a,n)),commonDir:U(mt(a,i)),headCommit:o,treeOid:s}}function Ds(e,t){let r=t.run(e.root,["status","--porcelain=v1","-z","--untracked-files=all"]);return r===void 0?void 0:{...Mn(e.root,e.gitDir),commonDir:e.commonDir,repositoryId:ar("repository",e.commonDir),headCommit:e.headCommit,treeOid:e.treeOid,clean:r.length===0}}function As(e,t){let r=sr(e,t);if(r.kind!=="worktree")return;let n=r.identity,i=n.projectRoot,o=t.run(i,["rev-parse","--git-common-dir"])?.trim();if(!o)return;let s=U(mt(i,o)),a=or(t.run(i,["rev-parse","--verify","HEAD"])),c=or(t.run(i,["rev-parse","--verify","HEAD^{tree}"])),l=t.run(i,["status","--porcelain=v1","-z","--untracked-files=all"]);if(l!==void 0)return{...n,commonDir:s,repositoryId:ar("repository",s),headCommit:a,treeOid:c,clean:l.length===0}}function sr(e,t=ht){let r=t.runResult(e,["rev-parse","--show-toplevel"]);if(r.kind==="not-repository")return{kind:"non-git"};if(r.kind==="error")return r;let n=r.output.trim();if(!n)return{kind:"error",message:"Git returned an empty worktree root."};let i=U(n),o=t.run(i,["rev-parse","--absolute-git-dir"])?.trim();if(!o)return{kind:"error",message:"Git did not return an absolute worktree directory."};let s=U(mt(i,o));return{kind:"worktree",identity:Mn(i,s)}}function Mn(e,t){return{projectRoot:e,gitDir:t,worktreeId:ar("worktree",`${e}\0${t}`)}}function js(e,t=ht){let r=t.run(e,["worktree","list","--porcelain","-z"]);return r===void 0?[]:Fs(r)}function Fs(e){let t=[],r;for(let n of e.split("\0")){if(n===""){r&&t.push(r),r=void 0;continue}let i=n.indexOf(" "),o=i<0?n:n.slice(0,i),s=i<0?"":n.slice(i+1);if(o==="worktree"){r&&t.push(r),r={path:U(s),detached:!1,bare:!1,prunable:!1,locked:!1};continue}r&&(o==="HEAD"?r.head=s:o==="branch"?r.branch=s:o==="detached"?r.detached=!0:o==="bare"?r.bare=!0:o==="prunable"?r.prunable=!0:o==="locked"&&(r.locked=!0))}return r&&t.push(r),t}function ef(e,t,r=ht){return or(r.run(e,t))}function mt(e,t){return Ps(t)?t:gt(e,t)}function U(e){try{return ks(e)}catch{return gt(e)}}function ar(e,t){return Es("sha256").update(`${e}\0${t}`).digest("hex").slice(0,24)}function or(e){return e?.trim()||void 0}function On(e,t){let r=Is("git",["-C",e,...t],{encoding:"utf-8",env:{...process.env,LC_ALL:"C"},maxBuffer:52428800,stdio:["ignore","pipe","pipe"]});if(r.status===0)return{kind:"success",output:r.stdout.trimEnd()};let i=(typeof r.stderr=="string"?r.stderr.trim():"")||r.error?.message||`git exited with status ${r.status??"unknown"}`,o=r.error?.code;return(/not a git repository/i.test(i)||o==="ENOENT"&&ws(gt(e)))&&!Os(e)?{kind:"not-repository"}:{kind:"error",message:i}}function Os(e){if(process.env.GIT_DIR||process.env.GIT_COMMON_DIR)return!0;let t=gt(e);for(;;){try{return Cs(Rs(t,".git")),!0}catch(n){let i=n.code;if(i!=="ENOENT"&&i!=="ENOTDIR")return!0}let r=Ts(t);if(r===t)return!1;t=r}}var uf=4,df=5e3,Bs="watch.lock",Hs="watch-state.json",qs="watch-activity.json";var zs=2e3,Js=10;function Ks(e){return{lockPath:cr(e,Bs),statePath:cr(e,Hs),activityPath:cr(e,qs)}}function ff(e,t,r){let n=U(dr(e));if(r&&U(r.projectRoot)===n)return{projectRoot:n,worktreeKind:"git",worktreeId:r.worktreeId,cliVersion:t};let i=sr(n);if(i.kind==="error")throw new Error(`Could not establish Git worktree identity for ${n}: ${i.message}`);return i.kind==="non-git"?{projectRoot:n,worktreeKind:"non-git",cliVersion:t}:{projectRoot:n,worktreeKind:"git",worktreeId:i.identity.worktreeId,cliVersion:t}}function mf(e){let t=e.runtime??ea,r=Ks(e.cacheDir),n=Ys(r.statePath),i=n?t.isProcessAlive(n.pid)?{kind:"live",state:n}:{kind:"stale",state:n,reason:"dead-process"}:{kind:"stopped"},o=Qs("stop",i);if(o.kind==="signal-stop")return $n(o.state.pid,e,t),lr(r,o.state.pid,t),{disposition:"stopped",pid:o.state.pid};if(o.kind==="clean-stale")return lr(r,o.state.pid,t),{disposition:"stopped",pid:o.state.pid};let s=$e(r.lockPath);return o.kind==="already-stopped"&&s&&t.isProcessAlive(s.pid)?($n(s.pid,e,t),lr(r,s.pid,t),{disposition:"stopped",pid:s.pid}):{disposition:"already-stopped"}}function Ys(e){try{return Xs(JSON.parse(ur(e,"utf8")))}catch{return null}}function gf(e,t){P(e,t)}function hf(e){try{let t=JSON.parse(ur(e,"utf8"));return t.version!==1||!I(t.at)||t.refreshRequestedAt!==void 0&&!I(t.refreshRequestedAt)||t.refreshDetail!==void 0&&typeof t.refreshDetail!="string"?null:{atMs:Date.parse(t.at),...t.refreshRequestedAt===void 0?{}:{refreshRequestedAtMs:Date.parse(t.refreshRequestedAt)},...t.refreshDetail===void 0?{}:{refreshDetail:t.refreshDetail}}}catch{return null}}function yf(e,t,r={}){let n=r.pid??process.pid,i=r.isProcessAlive??H,o=()=>{},s=$e(e);if(s&&i(s.pid))return{acquired:!1,lockPath:e,message:Wn(e,t,s),release:o};s&&Me(e,{force:!0}),Ws(Vs(e),{recursive:!0});let a;try{a=Gs(e,"wx")}catch(p){if(Zs(p)==="EEXIST")return{acquired:!1,lockPath:e,message:Wn(e,t,$e(e)),release:o};throw p}let c={version:1,pid:n,projectRoot:dr(t),startedAt:(r.now??(()=>new Date))().toISOString()};Us(a,`${JSON.stringify(c)}
|
|
3
|
-
`);let l=!1;return{acquired:!0,lockPath:e,message:"",release:()=>{if(l)return;l=!0,Ms(a);let p=$e(e);p?.pid===c.pid&&p.startedAt===c.startedAt&&Me(e,{force:!0})}}}function $e(e){try{let t=JSON.parse(ur(e,"utf-8"));return t.version!==1||typeof t.pid!="number"||!Number.isInteger(t.pid)||t.pid<=0||typeof t.projectRoot!="string"||!I(t.startedAt)?null:t}catch{return null}}function Xs(e){if(!e||typeof e!="object")return null;let t=e;return t.version!==1||typeof t.protocolVersion!="number"||typeof t.pid!="number"||!Number.isInteger(t.pid)||t.pid<=0||typeof t.projectRoot!="string"||t.worktreeId!==void 0&&(typeof t.worktreeId!="string"||t.worktreeId.length===0)||typeof t.cliVersion!="string"||!I(t.startedAt)||!I(t.heartbeatAt)||!I(t.lastActivityAt)||!ta(t.watcher)||t.idleDeadlineAt!==void 0&&!I(t.idleDeadlineAt)||t.indexGeneration!==void 0&&!/^[a-f0-9]{64}$/.test(t.indexGeneration)||t.lastError!==void 0&&!ra(t.lastError)||t.lastRefresh!==void 0&&!na(t.lastRefresh)||t.typescriptSemantic!==void 0&&!ia(t.typescriptSemantic)||t.typescriptIndex!==void 0&&!oa(t.typescriptIndex)?null:t}function Qs(e,t){switch(e){case"status":return{kind:"report",classification:t};case"ensure":switch(t.kind){case"stopped":return{kind:"start"};case"stale":return t.reason==="old-heartbeat"?{kind:"replace",state:t.state}:{kind:"start"};case"live":return{kind:"reuse",state:t.state};case"incompatible":return{kind:"replace",state:t.state};default:return pr(t)}case"stop":switch(t.kind){case"stopped":return{kind:"already-stopped"};case"stale":return t.reason==="old-heartbeat"?{kind:"signal-stop",state:t.state}:{kind:"clean-stale",state:t.state};case"live":case"incompatible":return{kind:"signal-stop",state:t.state};default:return pr(t)}default:return pr(e)}}function Sf(e){return e.idleTimeoutMs===0||e.watcher.state!=="idle"?!1:e.nowMs-e.lastActivityAtMs>=e.idleTimeoutMs}function $n(e,t,r){if(!r.isProcessAlive(e))return;r.signalProcess(e);let n=t.stopTimeoutMs??zs,i=r.now()+n;for(;r.now()<=i;){if(!r.isProcessAlive(e))return;r.sleep(Js)}throw new Error(`scip-query watch service pid ${e} did not stop within ${n}ms.`)}function lr(e,t,r){Me(e.statePath,{force:!0}),Me(e.activityPath,{force:!0}),$e(e.lockPath)?.pid===t&&!r.isProcessAlive(t)&&Me(e.lockPath,{force:!0})}function Wn(e,t,r){return`error: scip-query watch is already running for ${dr(t)}${r?` (pid ${r.pid}, started ${r.startedAt}; lock: ${e})`:` (lock: ${e})`}. Stop that watcher before starting another.`}function Zs(e){return typeof e=="object"&&e&&"code"in e?e.code:void 0}var ea={now:Date.now,isProcessAlive:H,spawnServer(e,t,r,n){if(!$s(e))throw new Error(`Watch service helper was not found at ${e}. Run npm run build first.`);Ls(process.execPath,[e,t,r,JSON.stringify(n)],{detached:!0,stdio:"ignore",env:{...process.env,SCIP_QUERY_SKIP_WATCH_SERVICE:"1"}}).unref()},signalProcess(e){process.kill(e,"SIGTERM")},sleep(e){let t=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(t,0,0,e)}};function I(e){return typeof e=="string"&&Number.isFinite(Date.parse(e))}function ta(e){if(!e||typeof e!="object"||!("state"in e))return!1;let t=e;switch(t.state){case"idle":return!0;case"waiting":return A(t.changedFiles)&&A(t.reindexAt);case"indexing":return A(t.startedAt);case"cooldown":return A(t.until)&&typeof t.dirty=="boolean";default:return!1}}function ra(e){if(!e||typeof e!="object")return!1;let t=e;return I(t.at)&&typeof t.message=="string"}function na(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.trigger?.kind=="string"&&typeof t.result=="string"&&I(t.startedAt)&&I(t.completedAt)&&A(t.durationMs)}function ia(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.protocolVersion=="number"&&(t.state==="idle"||t.state==="ready"||t.state==="unavailable"||t.state==="error")&&A(t.requests)&&A(t.sessionsCreated)&&A(t.sessionsReused)&&A(t.sessionsRefreshed)&&A(t.sessionsReplaced)&&A(t.projectsCreated)&&(t.lastRequestAt===void 0||I(t.lastRequestAt))&&(t.lastError===void 0||typeof t.lastError=="string")&&(t.busyUntil===void 0||I(t.busyUntil))}function oa(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.protocolVersion=="number"&&(t.state==="idle"||t.state==="ready"||t.state==="unavailable"||t.state==="error")&&pe(t.requests)&&pe(t.sessionsCreated)&&pe(t.sessionsReplaced)&&pe(t.initializations)&&pe(t.programUpdates)&&pe(t.documentsEmitted)&&pe(t.documentsRemoved)&&(t.lastRequestAt===void 0||I(t.lastRequestAt))&&(t.lastDurationMs===void 0||A(t.lastDurationMs)&&t.lastDurationMs>=0)&&(t.lastError===void 0||typeof t.lastError=="string")&&(t.busyUntil===void 0||I(t.busyUntil))}function A(e){return typeof e=="number"&&Number.isFinite(e)}function pe(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0}function pr(e){throw new Error(`Unhandled watch service value: ${JSON.stringify(e)}`)}import{readFileSync as sa,writeFileSync as vf,existsSync as aa,mkdirSync as ca,realpathSync as la}from"fs";import{isAbsolute as Ef,join as Q,relative as wf,resolve as Gn}from"path";import{createHash as pa}from"crypto";import{homedir as ua}from"os";var fr=".scipquery.json",da=250,fa=0,ma=10*6e4,ga={enabled:!1,debounceMs:da,cooldownMs:fa,gitPollMs:2e3,idleTimeoutMs:ma,autoRefresh:!0,ignore:[]},ha=["typescript","javascript","java","scala","kotlin","rust","python","ruby","go","cpp","c","csharp","vb","dart","php","clojure"];var Tf=new Set(ha);function Pf(e){let t=Q(e,fr);if(!aa(t))return{};try{let r=sa(t,"utf-8");return JSON.parse(r)}catch(r){let n=r instanceof Error?r.message:String(r);throw r instanceof SyntaxError?new Error(`invalid ${fr} at ${t}: ${n}`,{cause:r}):new Error(`unable to read ${fr} at ${t}: ${n}`,{cause:r})}}function Rf(e){return{...ga,...e.watch}}function ya(e,t){let r=process.env.SCIP_QUERY_CACHE_DIR;if(r)return mr(r);if(t?.dbPath)return mr(Gn(e,t.dbPath));let n=gr(e);return mr(n)}function Un(){let e=process.env.XDG_CACHE_HOME;return Q(e||Q(ua(),".cache"),"scip-query")}function gr(e){let t=Gn(e);try{t=la(t)}catch{}let r=pa("sha256").update(t).digest("hex").slice(0,12);return Q(Un(),"projects",r)}function hr(e){if(!/^[a-f0-9]{24}$/.test(e))throw new Error(`invalid repository cache identity: ${e}`);return Q(Un(),"repositories",e)}function yr(e){return process.env.SCIP_QUERY_SHARED_CACHE!=="0"&&!process.env.SCIP_QUERY_CACHE_DIR&&!process.env.SCIP_QUERY_INDEX_DB&&!e?.dbPath}function Nf(e,t){let r=ya(e,t);return{cacheDir:r,dbPath:Q(r,"index.db"),indexPath:Q(r,"index.scip"),metaPath:Q(r,"meta.json")}}function mr(e){return ca(e,{recursive:!0}),e}import{createHash as Sa}from"crypto";import{readFileSync as ba}from"fs";import{dirname as xa,join as yt}from"path";var va=2,Ia="typescript-index";function Ff(e){let t=yt(e,Ia);return{rootDir:t,requestDir:yt(t,"requests"),responseDir:yt(t,"responses")}}function Of(e){let t=JSON.parse(e);if(t.protocolVersion!==va||typeof t.id!="string"||!t.id||typeof t.baseGeneration!="string"||!t.baseGeneration||typeof t.deadlineAtMs!="number"||!Number.isFinite(t.deadlineAtMs)||!Ea(t.request))throw new Error("TypeScript index service received an invalid mailbox request.");return t}function Lf(e){try{let t=JSON.parse(ba(yt(xa(e),"meta.json"),"utf8"));return t.version!==2&&t.version!==3||t.status!=="complete"||typeof t.updatedAt!="string"||t.fingerprint===void 0?null:Sa("sha256").update(JSON.stringify({version:t.version,status:t.status,updatedAt:t.updatedAt,fingerprint:t.fingerprint,indexedLanguages:t.indexedLanguages})).digest("hex")}catch{return null}}function Ea(e){if(!e||typeof e!="object")return!1;let t=e,r=Vn(t.modifiedFiles)?t.modifiedFiles:null,n=Vn(t.affectedFiles)?t.affectedFiles:null;return t.kind==="emit-documents"&&typeof t.tsconfigPath=="string"&&!!t.tsconfigPath&&typeof t.projectArgument=="string"&&!!t.projectArgument&&typeof t.projectIdentity=="string"&&!!t.projectIdentity&&typeof t.producerIdentity=="string"&&!!t.producerIdentity&&r!==null&&r.length>0&&new Set(r).size===r.length&&n!==null&&n.length>0&&new Set(n).size===n.length&&r.every(i=>n.includes(i))}function Vn(e){return Array.isArray(e)&&e.every(t=>typeof t=="string"&&t.length>0)}import{randomUUID as Bn}from"crypto";import{closeSync as Hn,mkdirSync as wa,openSync as qn,readFileSync as zn,unlinkSync as Jn,writeFileSync as Kn}from"fs";import{dirname as Ca,join as ka}from"path";function Yn(e,t={}){return Sr(ka(e,"gc.lock"),t)}function Sr(e,t={}){let r=t.waitMs??0,n=t.pollMs??10,i=t.now??Date.now,o=Date.now()+r;wa(Ca(e),{recursive:!0});do{let s=Bn();try{let a=qn(e,"wx");try{let c={version:1,pid:process.pid,token:s,startedAt:new Date(i()).toISOString()};Kn(a,`${JSON.stringify(c)}
|
|
4
|
-
`)}finally{Hn(a)}return{release:()=>Qn(e,s)}}catch(a){if(a.code!=="EEXIST")return null;let c=Xn(e);if(c&&(c.pid===void 0||!H(c.pid))){Ta(e,c);continue}if(Date.now()>=o)return null;Pa(Math.min(n,Math.max(1,o-Date.now())))}}while(Date.now()<=o);return null}function Xn(e){try{let t=zn(e,"utf8"),r=JSON.parse(t),n=typeof r.pid=="number"&&Number.isSafeInteger(r.pid)&&r.pid>0?r.pid:void 0;return{raw:t,...n===void 0?{}:{pid:n}}}catch{return null}}function Ta(e,t){let r=`${e}.reclaim`,n=Bn(),i;try{i=qn(r,"wx")}catch{return!1}try{Kn(i,`${JSON.stringify({version:1,pid:process.pid,token:n,startedAt:new Date().toISOString()})}
|
|
5
|
-
`)}finally{Hn(i)}try{let o=Xn(e);return!o||o.raw!==t.raw||o.pid!==void 0&&H(o.pid)?!1:(Jn(e),!0)}catch{return!1}finally{Qn(r,n)}}function Qn(e,t){try{let r=JSON.parse(zn(e,"utf8"));r.pid===process.pid&&r.token===t&&Jn(e)}catch{}}function Pa(e){let t=new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));Atomics.wait(t,0,0,e)}import Ra from"better-sqlite3";var Na=["node_modules",".git","dist","build","out","coverage","target",".next",".nuxt",".cache",".turbo",".nbb",".cpcache",".shadow-cljs",".scipquery-cache","__pycache__",".venv","venv"],Zn=class{db;config;pathFilter;statementCache=new Map;constructor(t,r){this.config=t,this.pathFilter=r??null,this.db=new Ra(t.dbPath,{readonly:!0}),this.db.pragma("busy_timeout = 5000"),this.db.pragma("query_only = ON"),this.db.pragma("temp_store = MEMORY"),this.db.pragma("cache_size = -64000"),this.db.pragma("mmap_size = 268435456")}isIgnored(t){return this.pathFilter?.isIgnored(t)??!1}get localSymbolPredicate(){return`(
|
|
6
|
-
EXISTS (
|
|
7
|
-
SELECT 1
|
|
8
|
-
FROM defn_enclosing_ranges local_der
|
|
9
|
-
JOIN documents local_d ON local_der.document_id = local_d.id
|
|
10
|
-
WHERE local_der.symbol_id = gs.id
|
|
11
|
-
${this.pathExclusionsFor("local_d").trimStart()}
|
|
12
|
-
)
|
|
13
|
-
OR EXISTS (
|
|
14
|
-
SELECT 1
|
|
15
|
-
FROM mentions local_m
|
|
16
|
-
JOIN chunks local_c ON local_m.chunk_id = local_c.id
|
|
17
|
-
JOIN documents local_d ON local_c.document_id = local_d.id
|
|
18
|
-
WHERE local_m.symbol_id = gs.id
|
|
19
|
-
AND local_m.role = 1
|
|
20
|
-
${this.pathExclusionsFor("local_d").trimStart()}
|
|
21
|
-
)
|
|
22
|
-
)`}get pathExclusions(){return this.pathExclusionsFor("d")}get symbolNoise(){return this.symbolNoiseFor("gs")}pathExclusionsFor(...t){return t.flatMap(r=>Na.flatMap(n=>[`AND ${r}.relative_path NOT LIKE '${n}/%'`,`AND ${r}.relative_path NOT LIKE '%/${n}/%'`])).join(`
|
|
23
|
-
`)}symbolNoiseFor(t){return`AND ${t}.symbol NOT LIKE '%().(%' AND ${t}.symbol NOT LIKE '%typeLiteral%'`}all(t,...r){return this.statement(t).all(...r)}get(t,...r){return this.statement(t).get(...r)}close(){this.statementCache.clear(),this.db.close()}statement(t){let r=this.statementCache.get(t);return r||(r=this.db.prepare(t),this.statementCache.set(t,r)),r}};import{createHash as _a}from"crypto";import{existsSync as Da,mkdirSync as Aa,readFileSync as ja}from"fs";import{dirname as br,join as ei}from"path";import xr from"better-sqlite3";var Fa="evidence.db";var Oa=["source-facts","definition-exclusions","doc-path-tokens","react-component-behavior-profiles"],vr=new Set(Oa),La=25e4,Ma=512*1024*1024;var St=new WeakMap,$a=x("evidence-content-hash",{clearGroups:["whole-project","source-file"]}),Wa=x("evidence-project-fingerprint",{clearGroups:["whole-project"]}),Z="evidence-v1",Te="version NOT LIKE 'evidence-%'";function bt(e){return _a("sha256").update(e).digest("hex")}function We(e,t,r){return $a.get(e,t,()=>bt(r))}function ti(e){return Wa.get(e,"current",()=>{try{let t=JSON.parse(ja(ei(br(e.config.dbPath),"meta.json"),"utf-8"));if(t.version!==2&&t.version!==3||t.status!=="complete"&&t.status!=="partial"||t.fingerprint===void 0)return null;let r=Array.isArray(t.indexedLanguages)?[...t.indexedLanguages].sort():[];return bt(JSON.stringify({fingerprint:t.fingerprint,indexedLanguages:r,status:t.status}))}catch(t){return Pe("project fingerprint unavailable",t),null}})}function Pe(e,t){process.env.SCIP_QUERY_DEBUG&&console.error(`evidence-cache: ${e}: ${t instanceof Error?t.message:String(t)}`)}function Ge(e){if(St.has(e))return St.get(e)??null;let t=null;try{let r=new xr(ei(br(e.config.dbPath),Fa));r.pragma("journal_mode = WAL"),r.pragma("busy_timeout = 5000"),r.pragma("synchronous = NORMAL"),r.exec(`
|
|
24
|
-
CREATE TABLE IF NOT EXISTS file_evidence (
|
|
25
|
-
kind TEXT NOT NULL,
|
|
26
|
-
relative_path TEXT NOT NULL,
|
|
27
|
-
content_hash TEXT NOT NULL,
|
|
28
|
-
version TEXT NOT NULL,
|
|
29
|
-
payload TEXT NOT NULL,
|
|
30
|
-
PRIMARY KEY (kind, relative_path)
|
|
31
|
-
);
|
|
32
|
-
CREATE TABLE IF NOT EXISTS project_evidence (
|
|
33
|
-
kind TEXT NOT NULL,
|
|
34
|
-
cache_key TEXT NOT NULL,
|
|
35
|
-
project_fingerprint TEXT NOT NULL,
|
|
36
|
-
version TEXT NOT NULL,
|
|
37
|
-
payload TEXT NOT NULL,
|
|
38
|
-
PRIMARY KEY (kind, cache_key)
|
|
39
|
-
);
|
|
40
|
-
CREATE TABLE IF NOT EXISTS semantic_callees (
|
|
41
|
-
relative_path TEXT NOT NULL,
|
|
42
|
-
symbol TEXT NOT NULL,
|
|
43
|
-
content_hash TEXT NOT NULL,
|
|
44
|
-
deps_digest TEXT NOT NULL,
|
|
45
|
-
version TEXT NOT NULL,
|
|
46
|
-
payload TEXT NOT NULL,
|
|
47
|
-
PRIMARY KEY (relative_path, symbol)
|
|
48
|
-
);
|
|
49
|
-
CREATE TABLE IF NOT EXISTS semantic_references (
|
|
50
|
-
relative_path TEXT NOT NULL,
|
|
51
|
-
symbol TEXT NOT NULL,
|
|
52
|
-
project_fingerprint TEXT NOT NULL,
|
|
53
|
-
version TEXT NOT NULL,
|
|
54
|
-
payload TEXT NOT NULL,
|
|
55
|
-
PRIMARY KEY (relative_path, symbol)
|
|
56
|
-
);
|
|
57
|
-
CREATE TABLE IF NOT EXISTS finding_outcome_ledger (
|
|
58
|
-
check_name TEXT NOT NULL,
|
|
59
|
-
finding_id TEXT NOT NULL,
|
|
60
|
-
first_seen INTEGER NOT NULL,
|
|
61
|
-
last_seen INTEGER NOT NULL,
|
|
62
|
-
times_shown INTEGER NOT NULL,
|
|
63
|
-
outcome TEXT NOT NULL,
|
|
64
|
-
PRIMARY KEY (check_name, finding_id)
|
|
65
|
-
);
|
|
66
|
-
`),t={evidence:r,shared:Ga(e.config.sharedEvidenceDbPath),readFileEvidence:r.prepare("SELECT payload FROM file_evidence WHERE kind = ? AND relative_path = ? AND content_hash = ? AND version = ?"),readLegacyFileEvidence:r.prepare(`SELECT payload FROM file_evidence
|
|
67
|
-
WHERE kind = ? AND relative_path = ? AND content_hash = ? AND ${Te}
|
|
68
|
-
ORDER BY version DESC
|
|
69
|
-
LIMIT 1`),writeFileEvidence:r.prepare("INSERT OR REPLACE INTO file_evidence (kind, relative_path, content_hash, version, payload) VALUES (?, ?, ?, ?, ?)"),readProjectEvidence:r.prepare("SELECT payload FROM project_evidence WHERE kind = ? AND cache_key = ? AND project_fingerprint = ? AND version = ?"),readLegacyProjectEvidence:r.prepare(`SELECT payload FROM project_evidence
|
|
70
|
-
WHERE kind = ? AND cache_key = ? AND project_fingerprint = ? AND ${Te}
|
|
71
|
-
ORDER BY version DESC
|
|
72
|
-
LIMIT 1`),writeProjectEvidence:r.prepare("INSERT OR REPLACE INTO project_evidence (kind, cache_key, project_fingerprint, version, payload) VALUES (?, ?, ?, ?, ?)"),readCallees:r.prepare(`SELECT payload FROM semantic_callees
|
|
73
|
-
WHERE relative_path = ? AND symbol = ? AND content_hash = ? AND deps_digest = ? AND version = ?`),readLegacyCallees:r.prepare(`SELECT payload FROM semantic_callees
|
|
74
|
-
WHERE relative_path = ? AND symbol = ? AND content_hash = ? AND deps_digest = ? AND ${Te}
|
|
75
|
-
ORDER BY version DESC
|
|
76
|
-
LIMIT 1`),readCalleesForFile:r.prepare(`SELECT symbol, payload FROM semantic_callees
|
|
77
|
-
WHERE relative_path = ? AND content_hash = ? AND deps_digest = ? AND version = ?`),readLegacyCalleesForFile:r.prepare(`SELECT symbol, payload FROM semantic_callees
|
|
78
|
-
WHERE relative_path = ? AND content_hash = ? AND deps_digest = ? AND ${Te}
|
|
79
|
-
ORDER BY symbol, version DESC`),writeCallees:r.prepare(`INSERT OR REPLACE INTO semantic_callees
|
|
80
|
-
(relative_path, symbol, content_hash, deps_digest, version, payload) VALUES (?, ?, ?, ?, ?, ?)`),dropStaleCallees:r.prepare("DELETE FROM semantic_callees WHERE relative_path = ? AND content_hash != ?"),readReferences:r.prepare(`SELECT payload FROM semantic_references
|
|
81
|
-
WHERE relative_path = ? AND symbol = ? AND project_fingerprint = ? AND version = ?`),readLegacyReferences:r.prepare(`SELECT payload FROM semantic_references
|
|
82
|
-
WHERE relative_path = ? AND symbol = ? AND project_fingerprint = ? AND ${Te}
|
|
83
|
-
ORDER BY version DESC
|
|
84
|
-
LIMIT 1`),readReferencesForFile:r.prepare(`SELECT symbol, payload FROM semantic_references
|
|
85
|
-
WHERE relative_path = ? AND project_fingerprint = ? AND version = ?`),readLegacyReferencesForFile:r.prepare(`SELECT symbol, payload FROM semantic_references
|
|
86
|
-
WHERE relative_path = ? AND project_fingerprint = ? AND ${Te}
|
|
87
|
-
ORDER BY symbol, version DESC`),writeReferences:r.prepare(`INSERT OR REPLACE INTO semantic_references
|
|
88
|
-
(relative_path, symbol, project_fingerprint, version, payload) VALUES (?, ?, ?, ?, ?)`),dropStaleReferences:r.prepare("DELETE FROM semantic_references WHERE relative_path = ? AND project_fingerprint != ?"),readFindingOutcomeLedger:r.prepare("SELECT check_name, finding_id, first_seen, last_seen, times_shown, outcome FROM finding_outcome_ledger"),deleteFindingOutcomeLedgerForCheck:r.prepare("DELETE FROM finding_outcome_ledger WHERE check_name = ?"),writeFindingOutcomeLedgerRow:r.prepare(`INSERT INTO finding_outcome_ledger
|
|
89
|
-
(check_name, finding_id, first_seen, last_seen, times_shown, outcome) VALUES (?, ?, ?, ?, ?, ?)`)}}catch(r){Pe("disabled (open failed)",r)}return St.set(e,t),t}function Ue(e,t,r){Pe(`disabled (${t})`,r),St.set(e,null)}function Ga(e){if(!e)return null;try{Aa(br(e),{recursive:!0});let t=new xr(e);return t.pragma("journal_mode = WAL"),t.pragma("busy_timeout = 250"),t.pragma("synchronous = NORMAL"),t.exec(`
|
|
90
|
-
CREATE TABLE IF NOT EXISTS file_evidence (
|
|
91
|
-
kind TEXT NOT NULL,
|
|
92
|
-
relative_path TEXT NOT NULL,
|
|
93
|
-
content_hash TEXT NOT NULL,
|
|
94
|
-
version TEXT NOT NULL,
|
|
95
|
-
payload TEXT NOT NULL,
|
|
96
|
-
last_accessed_at INTEGER NOT NULL,
|
|
97
|
-
PRIMARY KEY (kind, relative_path, content_hash, version)
|
|
98
|
-
);
|
|
99
|
-
`),{evidence:t,readFileEvidence:t.prepare("SELECT payload FROM file_evidence WHERE kind = ? AND relative_path = ? AND content_hash = ? AND version = ?"),writeFileEvidence:t.prepare(`INSERT INTO file_evidence (kind, relative_path, content_hash, version, payload, last_accessed_at)
|
|
100
|
-
VALUES (?, ?, ?, ?, ?, ?)
|
|
101
|
-
ON CONFLICT(kind, relative_path, content_hash, version)
|
|
102
|
-
DO UPDATE SET payload = excluded.payload, last_accessed_at = excluded.last_accessed_at`)}}catch(t){return Pe("shared cache disabled (open failed)",t),null}}function Ir(e,t,r){Pe(`shared cache disabled (${t})`,r);try{e.shared?.evidence.close()}catch{}e.shared=null}function Xf(e,t={}){if(!Da(e))return null;let r;try{r=new xr(e),r.pragma("busy_timeout = 50"),r.pragma("wal_checkpoint(TRUNCATE)");let n=r.prepare("SELECT COUNT(*) AS count FROM file_evidence").get().count,i=t.maxRows??La,o=t.budgetBytes??Ma,s=Number(r.pragma("page_size",{simple:!0})),a=Number(r.pragma("page_count",{simple:!0})),c=Number(r.pragma("freelist_count",{simple:!0})),l=Math.max(0,a-c)*s,p=n>0&&l>o?Math.min(n,Math.ceil((l-o)/Math.max(1,l/n))):0,u=Math.max(n-i,p);return u>0&&(r.prepare(`DELETE FROM file_evidence WHERE rowid IN (
|
|
103
|
-
SELECT rowid FROM file_evidence ORDER BY last_accessed_at ASC, rowid ASC LIMIT ?
|
|
104
|
-
)`).run(u),r.pragma("wal_checkpoint(TRUNCATE)")),{deletedRows:u,remainingRows:n-u}}catch(n){return Pe("shared cache maintenance skipped",n),null}finally{try{r?.close()}catch{}}}function ri(e,t,r,n){let i=Ge(e);if(!i)return null;try{let o=i.readFileEvidence.get(t,r,n,Z)??i.readLegacyFileEvidence.get(t,r,n);if(o?.payload!==void 0)return o.payload;if(!vr.has(t)||!i.shared)return null;try{return i.shared.readFileEvidence.get(t,r,n,Z)?.payload??null}catch(s){return Ir(i,"file_evidence read",s),null}}catch(o){return Ue(e,"file_evidence read",o),null}}function ni(e,t,r,n,i){let o=Ge(e);if(o)try{if(o.writeFileEvidence.run(t,r,n,Z,i),vr.has(t)&&o.shared)try{o.shared.writeFileEvidence.run(t,r,n,Z,i,Date.now())}catch(s){Ir(o,"file_evidence write",s)}}catch(s){Ue(e,"file_evidence write",s)}}function ii(e,t){if(t.length===0)return;let r=Ge(e);if(r)try{r.evidence.transaction(()=>{for(let i of t)r.writeFileEvidence.run(i.kind,i.relativePath,i.contentHash,Z,i.payload)})();let n=t.filter(i=>vr.has(i.kind));if(n.length>0&&r.shared)try{r.shared.evidence.transaction(()=>{for(let i of n)r.shared.writeFileEvidence.run(i.kind,i.relativePath,i.contentHash,Z,i.payload,Date.now())})()}catch(i){Ir(r,"file_evidence batch write",i)}}catch(n){Ue(e,"file_evidence batch write",n)}}function oi(e,t,r,n){let i=Ge(e);if(!i)return null;try{return(i.readProjectEvidence.get(t,r,n,Z)??i.readLegacyProjectEvidence.get(t,r,n))?.payload??null}catch(o){return Ue(e,"project_evidence read",o),null}}function si(e,t,r,n,i){let o=Ge(e);if(o)try{o.writeProjectEvidence.run(t,r,n,Z,i)}catch(s){Ue(e,"project_evidence write",s)}}function Re(e){return typeof e=="object"&&e!==null}function Er(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")?e:null}function rm(e){return!Re(e)||typeof e.version!="number"||Er(e.languages)===null||typeof e.pnpmWorkspaces!="boolean"||typeof e.typescriptProjectMode!="string"||Er(e.typescriptProjects)===null||e.clojureConfigPath!==void 0&&typeof e.clojureConfigPath!="string"||!Array.isArray(e.files)||!e.files.every(Ua)?null:e}function nm(e,t){let r=new Map((e?.files??[]).map(a=>[a.path,a])),n=new Map(t.files.map(a=>[a.path,a])),i=new Set([...r.keys(),...n.keys()]),o=[];for(let a of[...i].sort()){let c=r.get(a),l=n.get(a),p=jn(a,t.languages);!c&&l?o.push({kind:"added",path:a,inputKind:p,after:l}):c&&!l?o.push({kind:"deleted",path:a,inputKind:p,before:c}):c&&l&&(c.hash!==l.hash||c.size!==l.size)&&o.push({kind:"modified",path:a,inputKind:p,before:c,after:l})}let s=new Set;return e||s.add("prior-snapshot-unavailable"),e&&e.version!==t.version&&s.add("snapshot-version-changed"),(ai(e?.files??[])||ai(t.files))&&s.add("duplicate-input-path"),[...e?.files??[],...t.files].some(Va)&&s.add("unreadable-input"),{version:1,changes:o,projectIdentityChanged:e?!qa(e,t):!0,uncertainty:[...s].sort()}}function ai(e){return new Set(e.map(t=>t.path)).size!==e.length}function Ua(e){return Re(e)&&typeof e.path=="string"&&typeof e.size=="number"&&typeof e.hash=="string"}function Va(e){return e.hash==="unreadable"||e.size<0}function Ba(e){let t=new Set;for(let r of e.uncertainty)t.add(r);e.projectIdentityChanged&&t.add("project-identity-changed");for(let r of e.changes)r.kind==="added"&&t.add("file-added"),r.kind==="deleted"&&t.add("file-deleted"),r.inputKind==="config"&&t.add("configuration-changed"),r.inputKind==="ambient"&&t.add("ambient-declaration-changed"),r.inputKind==="other"&&t.add("unclassified-input");return{fullProject:t.size>0,reasons:[...t].sort()}}function im(e,t,r){let n=e.changes.map(a=>a.path).sort();if(n.length===0&&!e.projectIdentityChanged&&e.uncertainty.length===0)return{mode:"none",changedFiles:n,affectedFiles:[],reasons:[]};let i=new Set(r),o=Ba(e),s=new Set(o.reasons);return n.some(a=>!i.has(a))&&s.add("changed-file-outside-project"),t===null?(s.add("dependency-graph-unavailable"),ci(n,i,s)):s.size>0?ci(n,i,s):{mode:"closure",changedFiles:n,affectedFiles:Ha(n,t,i),reasons:[]}}function ci(e,t,r){return{mode:"full-project",changedFiles:e,affectedFiles:[...t].sort(),reasons:[...r].sort()}}function Ha(e,t,r){let n=new Map;for(let[s,a]of t)if(r.has(s))for(let c of a){if(!r.has(c))continue;let l=n.get(c)??new Set;l.add(s),n.set(c,l)}let i=new Set(e),o=[...e];for(let s=0;s<o.length;s+=1){let a=o[s];if(a!==void 0)for(let c of n.get(a)??[])i.has(c)||(i.add(c),o.push(c))}return[...i].sort()}function qa(e,t){return li(e.languages,t.languages)&&e.pnpmWorkspaces===t.pnpmWorkspaces&&e.typescriptProjectMode===t.typescriptProjectMode&&li(e.typescriptProjects,t.typescriptProjects)&&e.clojureConfigPath===t.clojureConfigPath}function li(e,t){if(e.length!==t.length)return!1;let r=[...e].sort(),n=[...t].sort();return r.every((i,o)=>i===n[o])}import{execFileSync as za}from"child_process";import{existsSync as Ja,readdirSync as ui}from"fs";import{extname as di,join as fi}from"path";var mi=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),Ka=[{language:"typescript",files:["tsconfig.json","tsconfig.base.json"],extensions:[".ts",".tsx",".mts",".cts"]},{language:"rust",files:["Cargo.toml"],extensions:[".rs"]},{language:"go",files:["go.mod"],extensions:[".go"]},{language:"java",files:["pom.xml","build.gradle","build.gradle.kts"],extensions:[".java"]},{language:"kotlin",files:["build.gradle.kts"],extensions:[".kt",".kts"]},{language:"scala",files:["build.sbt"],extensions:[".scala"]},{language:"clojure",files:["deps.edn","project.clj","bb.edn","shadow-cljs.edn"],extensions:[".clj",".cljs",".cljc"]},{language:"python",files:["pyproject.toml","setup.py","setup.cfg","Pipfile"],extensions:[".py",".pyi"]},{language:"ruby",files:["Gemfile"],extensions:[".rb"]},{language:"cpp",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".cc",".cpp",".cxx",".hpp",".hh",".hxx"]},{language:"c",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".c",".h"]},{language:"csharp",globs:["*.csproj","*.sln"],extensions:[".cs"]},{language:"vb",globs:["*.vbproj"],extensions:[".vb"]},{language:"dart",files:["pubspec.yaml"],extensions:[".dart"]},{language:"php",files:["composer.json"],extensions:[".php"]},{language:"javascript",files:["package.json"],extensions:[".js",".jsx",".mjs",".cjs"]}];function lm(e){let t=[],r=Ya(e),n=ec(e);for(let i of Ka){if(Xa(e,i.files)){t.push(i.language);continue}if(Qa(r,i.globs)){t.push(i.language);continue}rc(n,i.extensions)&&t.push(i.language)}return t.includes("typescript")&&pi(t,"javascript"),t.includes("cpp")&&!n.has(".c")&&pi(t,"c"),t}function Ya(e){try{return ui(e)}catch{return[]}}function Xa(e,t){return t?.length?t.some(r=>Ja(fi(e,r))):!1}function Qa(e,t){return t?.length?e.some(r=>t.some(n=>Za(r,n))):!1}function Za(e,t){if(t==="*")return!0;if(!t.includes("*"))return e===t;let[r,n]=t.split("*");return e.startsWith(r??"")&&e.endsWith(n??"")}function ec(e){let t=tc(e);if(t)return t;let r=new Set,n=[e];for(;n.length>0;){let i=n.pop();if(!i)continue;let o;try{o=ui(i,{withFileTypes:!0})}catch{continue}for(let s of o){if(s.name.startsWith(".")&&!s.name.endsWith("proj")&&!s.name.endsWith("sln")&&s.isDirectory())continue;let a=fi(i,s.name);if(s.isDirectory()){mi.has(s.name)||n.push(a);continue}let c=di(s.name).toLowerCase();c&&r.add(c)}}return r}function tc(e){try{let t=za("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:26214400,stdio:["ignore","pipe","ignore"]}),r=new Set;for(let n of t.split(`
|
|
105
|
-
`)){if(!n||n.split("/").some(o=>mi.has(o)))continue;let i=di(n).toLowerCase();i&&r.add(i)}return r}catch{return null}}function rc(e,t){return t?.length?t.some(r=>e.has(r)):!1}function pi(e,t){let r=e.indexOf(t);r!==-1&&e.splice(r,1)}import{readFileSync as nc,writeFileSync as ic}from"fs";import{create as gi}from"@bufbuild/protobuf";import{deserializeSCIP as oc,DocumentSchema as sc,IndexSchema as ac,serializeSCIP as cc,SymbolRole as lc}from"@c4312/scip";function mm(e){let t;try{t=oc(nc(e))}catch{return{removedDefinitionOccurrences:0,touchedDocuments:0}}let r=wr(t);return r.removedDefinitionOccurrences>0&&ic(e,Buffer.from(cc(r.index))),{removedDefinitionOccurrences:r.removedDefinitionOccurrences,touchedDocuments:r.touchedDocuments}}function wr(e){let t=new Set;for(let o of e.documents)for(let s of o.symbols)s.symbol&&t.add(s.symbol);for(let o of e.externalSymbols)o.symbol&&t.add(o.symbol);let r=0,n=0,i=[];for(let o of e.documents){let s=o.occurrences.filter(a=>(a.symbolRoles&lc.Definition)===0||t.has(a.symbol)?!0:(r+=1,!1));if(s.length===o.occurrences.length){i.push(o);continue}n+=1,i.push(gi(sc,{language:o.language,relativePath:o.relativePath,occurrences:s,symbols:o.symbols,text:o.text,positionEncoding:o.positionEncoding}))}return{index:r===0?e:gi(ac,{metadata:e.metadata,documents:i,externalSymbols:e.externalSymbols}),removedDefinitionOccurrences:r,touchedDocuments:n}}import{readFileSync as Cr,writeFileSync as kr}from"fs";import{create as Ve}from"@bufbuild/protobuf";import{deserializeSCIP as Tr,serializeSCIP as Pr,DocumentSchema as pc,IndexSchema as hi,MetadataSchema as uc,SymbolInformationSchema as dc}from"@c4312/scip";function yi(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let t=mc(e),r=gc(e.flatMap(i=>i.documents??[])),n=bi(e.flatMap(i=>i.externalSymbols??[]));return Ve(hi,{metadata:t,documents:r,externalSymbols:n})}function xm(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let r=e.map(i=>Tr(Cr(i))),n=yi(r);return kr(t,Buffer.from(Pr(n))),{documentCount:n.documents.length,externalSymbolCount:n.externalSymbols.length,inputCount:e.length}}function vm(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let r=e.map(i=>Tr(Cr(i))),n=wr(yi(r));return kr(t,Buffer.from(Pr(n.index))),{documentCount:n.index.documents.length,externalSymbolCount:n.index.externalSymbols.length,inputCount:e.length,removedDefinitionOccurrences:n.removedDefinitionOccurrences,touchedDocuments:n.touchedDocuments}}function fc(e,t,r){let n=e.metadata;if(!n)throw new Error("Cannot rebase a SCIP index without metadata");if(n.projectRoot!==t)throw new Error(`Cannot rebase SCIP project root: expected ${t}, got ${n.projectRoot}`);return Ve(hi,{metadata:Ve(uc,{...n,projectRoot:r}),documents:e.documents,externalSymbols:e.externalSymbols})}function Si(e,t,r){let n=Tr(Cr(e)),i=fc(n,t,r);kr(e,Buffer.from(Pr(i)))}function mc(e){let t=e[0]?.metadata;if(!t)return;let r=t.projectRoot;for(let n of e.slice(1)){let i=n.metadata?.projectRoot;if(r&&i&&i!==r)throw new Error(`Cannot merge SCIP indexes with different project roots: ${r} vs ${i}`)}return t}function gc(e){let t=new Map;for(let r of e){let n=t.get(r.relativePath);if(!n){t.set(r.relativePath,r);continue}t.set(r.relativePath,Ve(pc,{language:n.language||r.language,relativePath:n.relativePath||r.relativePath,occurrences:hc([...n.occurrences,...r.occurrences]),symbols:bi([...n.symbols,...r.symbols]),text:Sc(n.text,r.text),positionEncoding:n.positionEncoding||r.positionEncoding}))}return[...t.values()]}function hc(e){let t=new Set,r=[];for(let n of e){let i=JSON.stringify(n);t.has(i)||(t.add(i),r.push(n))}return r}function bi(e){let t=new Map;for(let r of e){let n=t.get(r.symbol);if(!n){t.set(r.symbol,r);continue}t.set(r.symbol,Ve(dc,{symbol:n.symbol,documentation:bc([...n.documentation,...r.documentation]),relationships:yc([...n.relationships,...r.relationships]),kind:n.kind||r.kind,displayName:n.displayName||r.displayName,enclosingSymbol:n.enclosingSymbol||r.enclosingSymbol,signatureDocumentation:n.signatureDocumentation??r.signatureDocumentation}))}return[...t.values()]}function yc(e){let t=new Set,r=[];for(let n of e){let i=[n.symbol,n.isReference?"1":"0",n.isImplementation?"1":"0",n.isTypeDefinition?"1":"0",n.isDefinition?"1":"0"].join("|");t.has(i)||(t.add(i),r.push(n))}return r}function Sc(e,t){return e?t?e.length>=t.length?e:t:e:t}function bc(e){return[...new Set(e)]}import{createHash as Pc}from"crypto";import{existsSync as He,mkdirSync as Rc,readFileSync as ze,readdirSync as Ar,renameSync as Nc,rmSync as Fi,writeFileSync as _c}from"fs";import{join as $}from"path";import{createHash as xc}from"crypto";import{existsSync as Nr,mkdirSync as vc,readFileSync as xt,readdirSync as Cm,renameSync as Ic,rmSync as km,writeFileSync as Ec}from"fs";import{join as Ne}from"path";import{create as vi,fromBinary as Ii,toBinary as wc}from"@bufbuild/protobuf";import{deserializeSCIP as vt,DocumentSchema as _r,IndexSchema as Ei,serializeSCIP as wi}from"@c4312/scip";var It=1,Be="typescript-scip-fragments";function _m(e){if(e.length===0)throw new Error("affected TypeScript mini index requires documents");let t=new Set,r=[];for(let o of e){let s=ue(o.relativePath);if(t.has(s))throw new Error(`duplicate TypeScript fragment replacement: ${s}`);if(t.add(s),o.bytes===null)throw new Error(`affected TypeScript mini index cannot contain a deleted document: ${s}`);let a=Ii(_r,o.bytes);if(a.relativePath!==s)throw new Error(`TypeScript fragment path mismatch: expected ${s}, got ${a.relativePath}`);r.push(a)}let n=wi(vi(Ei,{documents:r,externalSymbols:[]})),i=vt(n);if(i.documents.length!==r.length||i.externalSymbols.length!==0)throw new Error("affected TypeScript SCIP index failed structural verification");return n}function Et(e){let t=Ne(e,Be);return{rootDir:t,blobDir:Ne(t,"blobs"),generationDir:Ne(t,"generations")}}function Cc(e){let t=vt(e.indexBytes);Ai(t.metadata,ji(e)),Di(t.externalSymbols);let r=new Set,n=[];for(let o of t.documents){let s=ue(o.relativePath);if(r.has(s))throw new Error(`duplicate TypeScript SCIP document path: ${s}`);r.add(s);let a=wc(_r,o),c=e.documentIdentities.get(s)??(e.allowUntrackedDocuments?de(JSON.stringify({version:1,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,untrackedDocument:s,contentHash:de(a)})):null);if(!c)throw new Error(`missing TypeScript document identity: ${s}`);n.push(Pi(e.cacheDir,{relativePath:s,bytes:a,occurrences:o.occurrences.length,symbols:o.symbols.length,referenceFragments:[]},c))}let i=Ri(e,n);return Ni(e.cacheDir,i),i}function Dm(e){let t=Et(e.cacheDir);if(!Nr(Dr(t,e.generationIdentity)))return Cc(e);let r=Ci({cacheDir:e.cacheDir,generationIdentity:e.generationIdentity,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity});if(!e.allowUntrackedDocuments&&r.manifest.documents.length!==e.documentIdentities.size)throw new Error("TypeScript fragment generation document identities changed");for(let n of r.manifest.documents){let i=e.documentIdentities.get(n.relativePath);if(!(i===void 0&&e.allowUntrackedDocuments)&&i!==n.documentIdentity)throw new Error(`TypeScript fragment generation document identity changed: ${n.relativePath}`)}return r.manifest}function Am(e){let t=Ci({cacheDir:e.cacheDir,generationIdentity:e.previousGenerationIdentity,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity}).manifest,r=new Map(t.documents.map(o=>[o.relativePath,o])),n=new Set;for(let o of e.fragments){let s=ue(o.relativePath);if(n.has(s))throw new Error(`duplicate TypeScript fragment replacement: ${s}`);if(n.add(s),!r.has(s))throw new Error(`TypeScript fragment replacement has no prior document: ${s}`);let a=e.documentIdentities.get(s);if(!a)throw new Error(`missing TypeScript document identity: ${s}`);o.bytes===null?r.delete(s):r.set(s,Pi(e.cacheDir,o,a))}if(n.size===0)throw new Error("TypeScript fragment generation requires at least one replacement");let i=Ri(e,[...r.values()]);return Ni(e.cacheDir,i),i}function Ci(e){let t=Et(e.cacheDir),r=Dr(t,e.generationIdentity),n;try{n=_i(xt(r,"utf8"))}catch(o){throw new Error(`TypeScript fragment generation is unavailable: ${o instanceof Error?o.message:String(o)}`,{cause:o})}if(n.generationIdentity!==e.generationIdentity)throw new Error("TypeScript fragment generation identity does not match its manifest path");if(e.producerIdentity&&n.producerIdentity!==e.producerIdentity)throw new Error("TypeScript fragment producer identity changed");if(e.projectIdentity&&n.projectIdentity!==e.projectIdentity)throw new Error("TypeScript fragment project identity changed");let i=new Map;for(let o of n.documents){let s=Ne(t.blobDir,`${o.blobHash}.scipdoc`),a=xt(s);if(a.byteLength!==o.byteLength||de(a)!==o.blobHash)throw new Error(`TypeScript fragment blob is corrupt: ${o.relativePath}`);i.set(o.relativePath,a)}return{manifest:n,fragments:i}}function ki(e){let t=Ti(e);return Rr(t.baseIndex,t.completeDocuments,"assembled")}function jm(e){let t=Ti(e);return kc(t.deletedAffectedPaths),{completeIndexBytes:Rr(t.baseIndex,t.completeDocuments,"assembled"),affectedIndexBytes:Rr(t.baseIndex,t.affectedDocuments,"affected")}}function Ti(e){let t=vt(e.baseIndexBytes);Ai(t.metadata,ji(e)),Di(t.externalSymbols);let r=new Map;for(let a of e.fragments){let c=ue(a.relativePath);if(r.has(c))throw new Error(`duplicate TypeScript fragment replacement: ${c}`);r.set(c,a)}if(r.size===0)throw new Error("TypeScript index assembly requires at least one replacement");let n=new Set,i=[],o=[],s=[];for(let a of t.documents){let c=ue(a.relativePath);if(n.has(c))throw new Error(`duplicate TypeScript SCIP document path: ${c}`);n.add(c);let l=r.get(c);if(!l){i.push(a);continue}if(r.delete(c),l.bytes===null){s.push(c);continue}let p=Ii(_r,l.bytes);if(p.relativePath!==c)throw new Error(`TypeScript fragment path mismatch: expected ${c}, got ${p.relativePath}`);i.push(p),o.push(p)}if(r.size>0)throw new Error(`TypeScript fragment replacement has no prior document: ${[...r.keys()].sort()[0]}`);return{baseIndex:t,completeDocuments:i,affectedDocuments:o,deletedAffectedPaths:s}}function Rr(e,t,r){let n=wi(vi(Ei,{metadata:e.metadata,documents:t,externalSymbols:[]})),i=vt(n);if(i.documents.length!==t.length||i.externalSymbols.length!==0)throw new Error(`${r} TypeScript SCIP index failed structural verification`);return n}function kc(e){if(e.length>0)throw new Error(`affected TypeScript mini index cannot contain a deleted document: ${e[0]}`)}function Pi(e,t,r){if(t.bytes===null)throw new Error(`cannot persist an empty TypeScript fragment: ${t.relativePath}`);let n=ue(t.relativePath),i=Buffer.from(t.bytes),o=de(i),s=Et(e);vc(s.blobDir,{recursive:!0});let a=Ne(s.blobDir,`${o}.scipdoc`);if(Nr(a)){let c=xt(a);if(c.byteLength!==i.byteLength||de(c)!==o)throw new Error(`existing TypeScript fragment blob is corrupt: ${n}`)}else{let c=`${a}.${process.pid}.${Date.now()}.tmp`;Ec(c,i),Ic(c,a)}return{relativePath:n,blobHash:o,byteLength:i.byteLength,documentIdentity:r}}function Ri(e,t){if(!e.producerIdentity||!e.projectIdentity||!e.generationIdentity)throw new Error("TypeScript fragment generation identities must be non-empty");let r=[...t].sort((n,i)=>n.relativePath.localeCompare(i.relativePath));if(new Set(r.map(n=>n.relativePath)).size!==r.length)throw new Error("TypeScript fragment generation contains duplicate document paths");return{version:It,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,generationIdentity:e.generationIdentity,createdAt:(e.now??(()=>new Date))().toISOString(),documents:r}}function Ni(e,t){let r=Et(e),n=Dr(r,t.generationIdentity);if(Nr(n)){let i=_i(xt(n,"utf8"));if(xi(i)!==xi(t))throw new Error(`TypeScript fragment generation is immutable: ${t.generationIdentity}`);return}P(n,t,{spacing:2,trailingNewline:!0})}function xi(e){return de(JSON.stringify({version:e.version,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,generationIdentity:e.generationIdentity,documents:e.documents}))}function _i(e){let t=JSON.parse(e);if(t.version!==It||typeof t.producerIdentity!="string"||typeof t.projectIdentity!="string"||typeof t.generationIdentity!="string"||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!Array.isArray(t.documents))throw new Error("invalid TypeScript fragment generation manifest");let r=new Set;for(let n of t.documents){if(!n||typeof n.relativePath!="string"||typeof n.blobHash!="string"||!/^[a-f0-9]{64}$/.test(n.blobHash)||typeof n.byteLength!="number"||!Number.isInteger(n.byteLength)||n.byteLength<0||typeof n.documentIdentity!="string"||!n.documentIdentity)throw new Error("invalid TypeScript fragment record");if(ue(n.relativePath),r.has(n.relativePath))throw new Error("duplicate TypeScript fragment record");r.add(n.relativePath)}return t}function Dr(e,t){return Ne(e.generationDir,Tc(t))}function Tc(e){if(!e)throw new Error("TypeScript fragment generation identity must be non-empty");return`${de(e)}.json`}function Di(e){if(e.length>0)throw new Error("scip-typescript emitted external symbols; incremental document assembly is unsupported")}function Ai(e,t){if(!e||typeof e!="object")throw new Error("TypeScript SCIP shard has no producer metadata");let r=e,n=r.toolInfo??r.tool_info;if(!n||typeof n!="object")throw new Error("TypeScript SCIP shard has no producer tool identity");let i=n;if(i.name!=="scip-typescript"||i.version!==t)throw new Error("TypeScript SCIP shard producer identity changed")}function ji(e){let t=e.packageVersion??e.runtime?.packageVersion;if(!t)throw new Error("scip-typescript package version is unavailable");return t}function ue(e){if(!e||e.startsWith("/")||e.startsWith("\\")||e.includes("\\"))throw new Error(`invalid TypeScript SCIP document path: ${e}`);let t=e.split("/");if(t.includes("")||t.includes(".")||t.includes(".."))throw new Error(`invalid TypeScript SCIP document path: ${e}`);return e}function de(e){return xc("sha256").update(e).digest("hex")}var wt=1,Gm=64*1024*1024,Je="typescript-scip-overlays";function Um(e){let t=Li(e.cacheDir,e.previousGenerationIdentity);if(!t&&!e.baseShardCurrent)throw new Error("deferred TypeScript SCIP base has no matching overlay generation");if(t&&(t.producerIdentity!==e.producerIdentity||t.projectIdentity!==e.projectIdentity))throw new Error("TypeScript overlay producer or project identity changed");let r=new Map((t?.overlays??[]).map(o=>[o.relativePath,o])),n=new Set;for(let o of e.fragments){let s=Or(o.relativePath);if(n.has(s))throw new Error(`duplicate TypeScript overlay: ${s}`);n.add(s),r.set(s,Dc(e.cacheDir,o))}if(n.size===0)throw new Error("TypeScript overlay generation requires affected documents");let i={version:wt,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:t?.baseGenerationIdentity??e.previousGenerationIdentity,generationIdentity:e.nextGenerationIdentity,createdAt:(e.now??(()=>new Date))().toISOString(),overlays:[...r.values()].sort((o,s)=>o.relativePath.localeCompare(s.relativePath))};return Ac(e.cacheDir,i),i}function Vm(e){let t=Li(e.cacheDir,e.generationIdentity);if(!t)throw new Error("TypeScript overlay generation is unavailable");let r=t.overlays.map(n=>{if(n.blobHash===null)return{relativePath:n.relativePath,bytes:null,occurrences:0,symbols:0,referenceFragments:[]};let i=ze($(Ke(e.cacheDir),"blobs",`${n.blobHash}.scipdoc`));if(i.byteLength!==n.byteLength||qe(i)!==n.blobHash)throw new Error(`TypeScript overlay blob is corrupt: ${n.relativePath}`);return{relativePath:n.relativePath,bytes:i,occurrences:0,symbols:0,referenceFragments:[]}});return ki({packageVersion:e.packageVersion,baseIndexBytes:e.baseIndexBytes,fragments:r})}function Bm(e,t){let r=Ke(e),n=$(r,"generations");if(!He(n))return;let i=new Set(t.map(Fr)),o=new Set;for(let a of Ar(n).filter(c=>i.has(c))){let c=jr(ze($(n,a),"utf8"));for(let l of c.overlays)l.blobHash&&o.add(`${l.blobHash}.scipdoc`)}for(let a of Ar(n))i.has(a)||Fi($(n,a),{force:!0});let s=$(r,"blobs");if(He(s))for(let a of Ar(s))o.has(a)||Fi($(s,a),{force:!0})}function Li(e,t){let r=$(Ke(e),"generations",Fr(t));if(!He(r))return null;let n=jr(ze(r,"utf8"));if(n.generationIdentity!==t)throw new Error("TypeScript overlay generation identity does not match its path");return n}function Dc(e,t){let r=Or(t.relativePath);if(t.bytes===null)return{relativePath:r,blobHash:null,byteLength:0};let n=Buffer.from(t.bytes),i=qe(n),o=$(Ke(e),"blobs");Rc(o,{recursive:!0});let s=$(o,`${i}.scipdoc`);if(He(s)){let a=ze(s);if(a.byteLength!==n.byteLength||qe(a)!==i)throw new Error(`existing TypeScript overlay blob is corrupt: ${r}`)}else{let a=`${s}.${process.pid}.${Date.now()}.tmp`;_c(a,n),Nc(a,s)}return{relativePath:r,blobHash:i,byteLength:n.byteLength}}function Ac(e,t){let r=$(Ke(e),"generations",Fr(t.generationIdentity));if(He(r)){let n=jr(ze(r,"utf8"));if(Oi(n)!==Oi(t))throw new Error(`TypeScript overlay generation is immutable: ${t.generationIdentity}`);return}P(r,t,{spacing:2,trailingNewline:!0})}function jr(e){let t=JSON.parse(e);if(t.version!==wt||typeof t.producerIdentity!="string"||!t.producerIdentity||typeof t.projectIdentity!="string"||!t.projectIdentity||typeof t.baseGenerationIdentity!="string"||!t.baseGenerationIdentity||typeof t.generationIdentity!="string"||!t.generationIdentity||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!Array.isArray(t.overlays))throw new Error("invalid TypeScript overlay manifest");let r=new Set;for(let n of t.overlays){if(!n||typeof n.relativePath!="string"||n.blobHash!==null&&(typeof n.blobHash!="string"||!/^[a-f0-9]{64}$/.test(n.blobHash))||!Number.isInteger(n.byteLength)||n.byteLength<0||n.blobHash===null&&n.byteLength!==0)throw new Error("invalid TypeScript overlay record");if(Or(n.relativePath),r.has(n.relativePath))throw new Error("duplicate TypeScript overlay record");r.add(n.relativePath)}return t}function Ke(e){return $(e,Je)}function Fr(e){if(!e)throw new Error("TypeScript overlay generation identity must be non-empty");return`${qe(e)}.json`}function Oi(e){return qe(JSON.stringify({version:e.version,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:e.baseGenerationIdentity,generationIdentity:e.generationIdentity,overlays:e.overlays}))}function Or(e){if(!e||e.startsWith("/")||e.includes("\\")||e.split("/").some(t=>!t||t==="."))throw new Error(`invalid TypeScript overlay path: ${e}`);if(e.split("/").includes(".."))throw new Error(`invalid TypeScript overlay path: ${e}`);return e}function qe(e){return Pc("sha256").update(e).digest("hex")}import{createHash as jc}from"crypto";import{copyFileSync as Mi,existsSync as ee,linkSync as Fc,mkdirSync as $i,readFileSync as Ui,readdirSync as Wi,renameSync as Mr,rmSync as kt,statSync as Oc}from"fs";import{basename as Ct,dirname as Ye,join as E,relative as Gi}from"path";var _e=1,Tt=".scipquery-generations";function Vi(e){let t=Pt(e.outputDb),r=Lc(e,t);e.onStage?.("after-recovery-retained"),e.preserveOutputScip||Lr(e.tempOutputScip,e.outputScip),e.onStage?.("after-scip-handoff"),Lr(e.tempOutputDb,e.outputDb),e.onStage?.("after-database-handoff"),Lr(e.tempMetaPath,e.metaPath),e.onStage?.("after-metadata-handoff");let n=Rt(e.metaPath,e.outputDb),i={version:_e,currentGeneration:n,...r?{previousGeneration:r}:{},...e.publication?{publication:e.publication}:{},publishedAt:(e.now??(()=>new Date))().toISOString()};return P(E(t,"state.json"),i,{spacing:2,trailingNewline:!0}),{currentGeneration:n,...r?{previousGeneration:r}:{}}}function Bi(e){try{let t=JSON.parse(Ui(E(Pt(e),"state.json"),"utf8"));return t.version!==_e||typeof t.currentGeneration!="string"||!t.currentGeneration||typeof t.publishedAt!="string"||!Number.isFinite(Date.parse(t.publishedAt))||!Wc(t.previousGeneration)||!Gc(t.publication)?null:t}catch{return null}}function Ym(e,t,r=()=>new Date){if(!ee(e)||!ee(t))throw new Error("metadata-only generation refresh requires stable database and metadata files");let n=Bi(e),i={version:_e,currentGeneration:Rt(t,e),...n?.previousGeneration?{previousGeneration:n.previousGeneration}:{},...n?.publication?{publication:n.publication}:{},publishedAt:r().toISOString()};return P(E(Pt(e),"state.json"),i,{spacing:2,trailingNewline:!0}),i}function $r(e,t=E(Ye(e),"meta.json")){let r=E(Pt(e),"state.json");if(!ee(r))return{state:"legacy",statePath:r};let n=Bi(e);if(!n)return{state:"invalid",statePath:r,reason:"generation state is malformed"};try{let i=Rt(t,e),o=n.currentGeneration===i,s=n.previousGeneration?ee(E(Ye(e),n.previousGeneration.databasePath)):!0;return!o||!s?{state:"drifted",statePath:r,currentMatches:o,recoveryExists:s,generation:n,reason:o?"retained recovery database is missing":"stable database or metadata no longer matches the published generation"}:{state:"current",statePath:r,currentMatches:o,recoveryExists:s,generation:n}}catch(i){return{state:"drifted",statePath:r,currentMatches:!1,recoveryExists:!1,generation:n,reason:i instanceof Error?i.message:String(i)}}}function Pt(e){return E(Ye(e),Tt)}function Lc(e,t){if(!ee(e.outputDb))return;let r=Rt(e.metaPath,e.outputDb),n=E(t,r),i=E(n,Ct(e.outputDb)),o=ee(e.metaPath)?E(n,Ct(e.metaPath)):void 0;if(!ee(i)){let s=`${n}.${process.pid}.${Date.now()}.tmp`;kt(s,{recursive:!0,force:!0}),$i(s,{recursive:!0});let a=E(s,Ct(e.outputDb));try{Fc(e.outputDb,a)}catch{Mi(e.outputDb,a)}o&&Mi(e.metaPath,E(s,Ct(e.metaPath))),$i(t,{recursive:!0}),Mr(s,n)}return Mc(t,r),{generationIdentity:r,databasePath:Gi(Ye(e.outputDb),i),...o?{metadataPath:Gi(Ye(e.outputDb),o)}:{}}}function Mc(e,t){for(let r of Wi(e,{withFileTypes:!0}))!r.isDirectory()||r.name===t||r.name.endsWith(".tmp")||kt(E(e,r.name),{recursive:!0,force:!0});for(let r of Wi(e,{withFileTypes:!0}))r.isDirectory()&&r.name.endsWith(".tmp")&&kt(E(e,r.name),{recursive:!0,force:!0})}function Rt(e,t){let r=jc("sha256").update(`sqlite-generation-v${_e}\0`);ee(e)&&r.update($c(Ui(e,"utf8")));let n=Oc(t);return r.update(`\0${n.size}`),r.digest("hex")}function $c(e){try{let t=JSON.parse(e);if((t.version===2||t.version===3)&&t.status==="complete"&&typeof t.updatedAt=="string"&&t.fingerprint!==void 0)return JSON.stringify({version:t.version,status:t.status,updatedAt:t.updatedAt,fingerprint:t.fingerprint,indexedLanguages:t.indexedLanguages,scipCompanion:t.scipCompanion})}catch{}return e}function Lr(e,t){kt(`${t}.tmp-replace`,{force:!0}),Mr(e,`${t}.tmp-replace`),Mr(`${t}.tmp-replace`,t)}function Wc(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e;return typeof t.generationIdentity=="string"&&!!t.generationIdentity&&typeof t.databasePath=="string"&&!!t.databasePath&&(t.metadataPath===void 0||typeof t.metadataPath=="string"&&!!t.metadataPath)}function Gc(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e,r=[t.converterDurationMs,t.affectedDocumentCount,t.changedDocumentCount,t.producerDurationMs,t.materializationDurationMs,t.patchDurationMs].filter(n=>n!==void 0);return(t.mode==="incremental"||t.mode==="full")&&t.validation==="passed"&&t.converterDurationMs!==void 0&&r.every(n=>typeof n=="number"&&Number.isFinite(n)&&n>=0)&&(t.scipCompanion===void 0||t.scipCompanion==="current"||t.scipCompanion==="deferred")&&(t.typescriptOverlayGeneration===void 0||typeof t.typescriptOverlayGeneration=="string"&&!!t.typescriptOverlayGeneration)&&(t.scipCompanion!=="deferred"||!!t.typescriptOverlayGeneration)&&(t.fallbackReason===void 0||typeof t.fallbackReason=="string")}import{createHash as Zi,randomUUID as Br}from"crypto";import{closeSync as eo,constants as Xc,copyFileSync as Ki,existsSync as re,lstatSync as Qc,mkdirSync as q,mkdtempSync as to,openSync as ro,readdirSync as Zc,readFileSync as W,realpathSync as el,renameSync as fe,rmSync as te,statSync as tl,unlinkSync as Ur,writeFileSync as no}from"fs";import{dirname as io,join as f,resolve as et}from"path";import{setTimeout as rl}from"timers/promises";import{pathToFileURL as Yi}from"url";import{deserializeSCIP as oo}from"@c4312/scip";import nl from"better-sqlite3";import{createRequire as Uc}from"module";var Vc=Uc(import.meta.url),Hi=Bc().version;function Bc(){for(let e of["../package.json","../../package.json"])try{return Vc(e)}catch{}return{version:"0.0.0"}}import{lstatSync as Hc,readdirSync as qc}from"fs";import{join as zc,relative as Jc,resolve as Wr,sep as Kc}from"path";var Xe=1,Gr="language-indexes",qi=["index.db","index.scip","meta.json"],zi=[Gr,Be,Je];function Nt(e){let t=[];for(let r of qi)Yc(e,r),t.push(r);for(let r of zi)Ji(e,r,t);return{version:Xe,files:t.sort()}}function _t(e){if(!e||e.includes("\0")||e.startsWith("/")||e.includes("\\"))throw new Error(`invalid index artifact path: ${e||"<empty>"}`);let t=e.split("/");if(t.some(n=>!n||n==="."||n===".."))throw new Error(`invalid index artifact path: ${e}`);let r=t[0];if(!qi.includes(e)&&!zi.includes(r))throw new Error(`index artifact path is not shareable: ${e}`);return e}function V(e,t){let r=_t(t),n=Wr(e),i=Wr(n,...r.split("/"));if(i!==n&&!i.startsWith(`${n}${Kc}`))throw new Error(`index artifact escapes cache: ${t}`);return i}function Ji(e,t,r){let n=zc(e,t),i;try{i=qc(n,{withFileTypes:!0,encoding:"utf8"})}catch{return}for(let o of i){let s=`${t}/${o.name}`;if(o.isSymbolicLink())throw new Error(`index artifact cannot be a symlink: ${s}`);o.isDirectory()?Ji(e,s,r):o.isFile()&&r.push(_t(s))}}function Yc(e,t){let r=V(e,t),n;try{n=Hc(r)}catch{throw new Error(`required index artifact is missing: ${t}`)}if(!n.isFile()||n.isSymbolicLink())throw new Error(`required index artifact is not a regular file: ${t}`);if(Jc(Wr(e),r).startsWith(".."))throw new Error(`index artifact escapes cache: ${t}`)}var Hr=1,Xi="SCIP_QUERY_SHARED_CACHE",Vr=JSON.stringify({cliVersion:Hi,artifactCatalogVersion:Xe,sqliteGenerationStoreVersion:_e,typescriptFragmentStoreVersion:It,typescriptOverlayStoreVersion:wt}),so="manifest.json",il="shared-cache.json",qr=[Gr,Be,Je];function Eg(e,t){if(!e.clean||!e.treeOid)return;let r=rt(JSON.stringify({version:Hr,repositoryId:e.repositoryId,treeOid:e.treeOid,fingerprint:t,producerIdentity:Vr}));return{repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,fingerprint:t,producerIdentity:Vr,generationId:r,repositoryCacheDir:hr(e.repositoryId)}}function wg(e,t,r){if(process.env[Xi]==="0")return`${Xi}=0`;if(!yr(r))return"explicit cache or database override";if(et(t)!==et(f(gr(e),"index.db")))return"index database is outside the managed worktree cache"}function Cg(e,t,r){if(!yr(t))return;let n=r??Ln(e);return n?f(hr(n.repositoryId),"evidence.db"):void 0}function Ze(e,t=!0){let r=zr(e),n;try{n=al(W(f(r,so),"utf8"))}catch{return null}if(n.generationId!==e.generationId||n.repositoryId!==e.repositoryId||n.treeOid!==e.treeOid||n.producerIdentity!==e.producerIdentity||JSON.stringify(n.fingerprint)!==JSON.stringify(e.fingerprint))return null;if(!t)return n;try{for(let i of n.artifacts){let o=V(r,i.path),s=tl(o);if(!s.isFile()||s.size!==i.size||rt(W(o))!==i.sha256)return null}}catch{return null}return n}function kg(e){let t=Ze(e.snapshot);if(t)return t;if(!lo(e.sourceCacheDir,e.sourceProjectRoot,e.snapshot.fingerprint))throw new Error("source index is incomplete, incompatible, or corrupt");let r=Qi(e.sourceCacheDir);if(!r)throw new Error("source index artifacts are incomplete");let n=Nt(e.sourceCacheDir),i=f(e.snapshot.repositoryCacheDir,"generations");q(i,{recursive:!0});let o=to(f(i,`.tmp-${process.pid}-`));try{let s=[];for(let u of n.files){let d=V(e.sourceCacheDir,u),m=V(o,u);tt(d,m);let h=W(m);s.push({path:u,size:h.byteLength,sha256:rt(h)})}let a=oo(W(f(o,"index.scip"))).metadata?.projectRoot;if(!a)throw new Error("shared SCIP generation has no project root metadata");let c=Jr(e.sourceProjectRoot);if(a!==c)throw new Error("shared SCIP generation root does not match its source worktree");if(Qi(e.sourceCacheDir)!==r||e.sourceStillValid&&!e.sourceStillValid())throw new Error("source index changed while staging a shared generation");let l={version:Hr,artifactCatalogVersion:Xe,generationId:e.snapshot.generationId,repositoryId:e.snapshot.repositoryId,treeOid:e.snapshot.treeOid,fingerprint:e.snapshot.fingerprint,producerIdentity:e.snapshot.producerIdentity,sourceProjectRoot:e.sourceProjectRoot,scipProjectRoot:a,createdAt:(e.now??(()=>new Date))().toISOString(),artifacts:s.sort((u,d)=>u.path.localeCompare(d.path))};P(f(o,so),l,{spacing:2,trailingNewline:!0});let p=zr(e.snapshot);try{if(re(p)&&!Ze(e.snapshot)){let u=`${p}.corrupt-${process.pid}-${Date.now()}`;fe(p,u),te(u,{recursive:!0,force:!0})}fe(o,p)}catch(u){let d=Ze(e.snapshot);if(d)return d;throw u}return l}finally{te(o,{recursive:!0,force:!0})}}function Tg(e){let t=zr(e.snapshot);q(e.targetCacheDir,{recursive:!0});let r=Sr(f(e.targetCacheDir,"cache-lifecycle.lock"),{waitMs:3e4});if(!r)throw new Error("timed out waiting for another cache hydration");let n,i,o=!1;try{n=to(f(e.targetCacheDir,".shared-hydrate-")),gl(e.manifest,e.snapshot);for(let c of e.manifest.artifacts){let l=V(t,c.path),p=V(n,c.path);tt(l,p);let u=W(p);if(u.byteLength!==c.size||rt(u)!==c.sha256)throw new Error(`shared artifact is corrupt: ${c.path}`)}let s=Jr(e.targetProjectRoot);if(s!==e.manifest.scipProjectRoot)for(let c of e.manifest.artifacts)c.path.endsWith(".scip")&&Si(V(n,c.path),e.manifest.scipProjectRoot,s);if(!lo(n,e.targetProjectRoot,e.snapshot.fingerprint,!1))throw new Error("staged shared generation failed completeness or integrity validation");i=dl(e.targetCacheDir,n),o=!0,fl(n,e.targetCacheDir,i),Vi({tempOutputScip:f(n,"index.scip"),tempOutputDb:f(n,"index.db"),tempMetaPath:f(n,"meta.json"),outputScip:f(e.targetCacheDir,"index.scip"),outputDb:f(e.targetCacheDir,"index.db"),metaPath:f(e.targetCacheDir,"meta.json"),now:e.now});let a=$r(f(e.targetCacheDir,"index.db"),f(e.targetCacheDir,"meta.json"));if(a.state==="invalid"||a.state==="drifted")throw new Error(`hydrated SQLite generation failed validation: ${a.reason}`);ol(e.snapshot,e.targetCacheDir,e.action??"attached",e.now)}catch(s){throw o&&i&&ml(e.targetCacheDir,i),s}finally{n&&te(n,{recursive:!0,force:!0}),r.release()}}async function Pg(e,t={}){let r=t.timeoutMs??3e4,n=t.pollMs??100,i=t.now??Date.now,o=i()+r,s=f(e.repositoryCacheDir,"locks"),a=f(s,`${e.generationId}.lock`);for(q(s,{recursive:!0});i()<=o;){if(Ze(e))return{kind:"generation-ready"};let c=Br();try{let l=ro(a,"wx");try{no(l,`${JSON.stringify({version:1,pid:process.pid,token:c,generationId:e.generationId,startedAt:new Date(i()).toISOString()})}
|
|
106
|
-
`)}finally{eo(l)}return{kind:"owner",release:()=>{try{let p=JSON.parse(W(a,"utf8"));p.pid===process.pid&&p.token===c&&Ur(a)}catch{}}}}catch(l){if(l.code!=="EEXIST")return{kind:"timeout"};let p=ao(a);if(p&&(p.pid===void 0||!H(p.pid))){pl(a,p);continue}await rl(n)}}return Ze(e)?{kind:"generation-ready"}:{kind:"timeout"}}function ol(e,t,r,n=void 0){let i={version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,localCacheDir:t,baseGenerationId:e.generationId,activeGenerationId:e.generationId,lastAction:r,lastSeenAt:(n??(()=>new Date))().toISOString()},o={...i,ownershipChecksum:sl(i)};return ul(e.repositoryCacheDir,o,!0),o}function sl(e){return rt(JSON.stringify({version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:et(e.projectRoot),localCacheDir:et(e.localCacheDir)}))}function al(e){let t=JSON.parse(e);if(t.version!==Hr||t.artifactCatalogVersion!==Xe||typeof t.generationId!="string"||!/^[a-f0-9]{64}$/.test(t.generationId)||typeof t.repositoryId!="string"||!/^[a-f0-9]{24}$/.test(t.repositoryId)||typeof t.treeOid!="string"||!t.treeOid||typeof t.producerIdentity!="string"||t.producerIdentity!==Vr||typeof t.sourceProjectRoot!="string"||typeof t.scipProjectRoot!="string"||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!t.fingerprint||!Array.isArray(t.artifacts))throw new Error("invalid shared generation manifest");let r=new Set;for(let n of t.artifacts){if(!n||typeof n.path!="string"||typeof n.size!="number"||n.size<0||typeof n.sha256!="string"||!/^[a-f0-9]{64}$/.test(n.sha256))throw new Error("invalid shared generation artifact");if(_t(n.path),r.has(n.path))throw new Error(`duplicate shared generation artifact: ${n.path}`);r.add(n.path)}for(let n of["index.db","index.scip","meta.json"])if(!r.has(n))throw new Error(`shared generation is missing ${n}`);return t}function tt(e,t){q(io(t),{recursive:!0});try{Ki(e,t,Xc.COPYFILE_FICLONE)}catch{Ki(e,t)}}function cl(e,t,r){q(e,{recursive:!0}),P(f(e,il),{version:1,repositoryId:t,worktreeId:r},{spacing:2,trailingNewline:!0})}function Qi(e){try{let t=Nt(e),r=Zi("sha256");for(let n of t.files){let i=W(V(e,n));r.update(n).update("\0").update(String(i.byteLength)).update("\0").update(i).update("\0")}return r.digest("hex")}catch{return null}}function ll(e){try{return JSON.parse(W(f(e,"meta.json"),"utf8"))}catch{return}}function zr(e){return f(e.repositoryCacheDir,"generations",e.generationId)}function ao(e){try{let t=W(e,"utf8"),r=JSON.parse(t),n=typeof r.pid=="number"&&Number.isSafeInteger(r.pid)&&r.pid>0?r.pid:void 0;return{raw:t,...n===void 0?{}:{pid:n}}}catch{return null}}function pl(e,t){let r=`${e}.reclaim`,n=Br(),i;try{i=ro(r,"wx")}catch{return!1}try{no(i,`${JSON.stringify({version:1,pid:process.pid,token:n,startedAt:new Date().toISOString()})}
|
|
107
|
-
`)}finally{eo(i)}try{let o=ao(e);return!o||o.raw!==t.raw||o.pid!==void 0&&H(o.pid)?!1:(Ur(e),!0)}catch{return!1}finally{try{let o=JSON.parse(W(r,"utf8"));o.pid===process.pid&&o.token===n&&Ur(r)}catch{}}}function ul(e,t,r){let n=Yn(e,{waitMs:5e3});if(!n)throw new Error("repository cache cleanup is busy");try{if(r){let o=t.activeGenerationId;if(!o||!re(f(e,"generations",o)))throw new Error("shared generation disappeared before its lease was attached")}let i=f(e,"worktrees");q(i,{recursive:!0}),P(f(i,`${t.worktreeId}.json`),t,{spacing:2,trailingNewline:!0}),cl(t.localCacheDir,t.repositoryId,t.worktreeId)}finally{n.release()}}function dl(e,t){let r=f(t,".rollback"),n=new Map,i=new Map;q(r,{recursive:!0});for(let a of["index.scip","index.db","meta.json"]){let c=f(e,a),l=re(c);n.set(a,l),l&&tt(c,f(r,"stable",a))}for(let a of qr){let c=f(e,a),l=re(c);if(l){let p=Qc(c);if(!p.isDirectory()||p.isSymbolicLink())throw new Error(`managed artifact path is not a directory: ${a}`)}i.set(a,l)}let o=f(e,Tt),s=re(o);return s&&co(o,f(r,"sqlite-generations")),{root:r,stableFiles:n,managedDirectories:i,generationStoreExisted:s}}function fl(e,t,r){for(let n of qr){let i=f(t,n);if(r.managedDirectories.get(n)){let s=f(r.root,"managed",n);q(io(s),{recursive:!0}),fe(i,s)}let o=f(e,n);re(o)&&fe(o,i)}}function ml(e,t){for(let i of qr){let o=f(e,i),s=f(t.root,"managed",i);t.managedDirectories.get(i)?re(s)&&(te(o,{recursive:!0,force:!0}),fe(s,o)):te(o,{recursive:!0,force:!0})}for(let[i,o]of t.stableFiles){let s=f(e,i);if(!o){te(s,{force:!0});continue}let a=`${s}.shared-restore-${Br()}`;tt(f(t.root,"stable",i),a),te(s,{force:!0}),fe(a,s)}let r=f(e,Tt);te(r,{recursive:!0,force:!0});let n=f(t.root,"sqlite-generations");t.generationStoreExisted&&re(n)&&fe(n,r)}function co(e,t){q(t,{recursive:!0});for(let r of Zc(e,{withFileTypes:!0})){let n=f(e,r.name),i=f(t,r.name);if(r.isSymbolicLink())throw new Error(`managed cache backup cannot contain a symlink: ${n}`);r.isDirectory()?co(n,i):r.isFile()&&tt(n,i)}}function gl(e,t){if(e.generationId!==t.generationId||e.repositoryId!==t.repositoryId||e.treeOid!==t.treeOid||e.producerIdentity!==t.producerIdentity||JSON.stringify(e.fingerprint)!==JSON.stringify(t.fingerprint))throw new Error("shared generation manifest does not match the requested snapshot")}function lo(e,t,r,n=!0,i=!0){try{let o=ll(e);if(o?.status!=="complete"||JSON.stringify(o.fingerprint)!==JSON.stringify(r)||JSON.stringify([...o.indexedLanguages??[]].sort())!==JSON.stringify([...r.languages].sort()))return Qe("source validation rejected metadata"),!1;let s=Nt(e),a=$r(f(e,"index.db"),f(e,"meta.json"));if(n?a.state!=="current":a.state==="invalid"||a.state==="drifted")return Qe(`source validation rejected SQLite generation state ${a.state}`),!1;let c=new nl(f(e,"index.db"),{readonly:!0,fileMustExist:!0});try{if(i){if(c.pragma("quick_check(1)",{simple:!0})!=="ok")return!1}else c.pragma("schema_version",{simple:!0})}finally{c.close()}let l=Jr(t),u=(i?s.files.filter(d=>d.endsWith(".scip")):["index.scip"]).every(d=>{let m=oo(W(V(e,d))).metadata?.projectRoot;return m!==l&&Qe(`source validation rejected SCIP root for ${d}: ${String(m)}`),m===l});return u||Qe("source validation rejected SCIP project roots"),u}catch(o){return Qe(`source validation failed: ${o instanceof Error?o.message:String(o)}`),!1}}function Qe(e){process.env.SCIP_QUERY_DEBUG&&console.error(`shared-cache: ${e}`)}function Jr(e){try{return Yi(el(e)).href}catch{return Yi(et(e)).href}}function rt(e){return Zi("sha256").update(e).digest("hex")}import{readFileSync as po}from"fs";import{createRequire as hl}from"module";import{dirname as Qr,isAbsolute as yl,relative as go,resolve as ie,sep as Kr}from"path";var ne=hl(import.meta.url),Sl=1,uo="0.4.0";function bl(){try{let e=ho();if(!e.available)return e;let{packageRoot:t}=e,r=ne.resolve("typescript",{paths:[t]}),n=ne(r),{FileIndexer:i}=ne(ie(t,"dist/src/FileIndexer.js")),{Input:o}=ne(ie(t,"dist/src/Input.js")),{Packages:s}=ne(ie(t,"dist/src/Packages.js")),a=ne(ie(t,"dist/src/scip.js"));if(!i||!o||!s||!a.scip?.Document||!a.scip.Index)return{available:!1,reason:"scip-typescript document runtime has an unsupported module shape"};let c={packageVersion:e.packageVersion,typescript:n,Document:a.scip.Document,Index:a.scip.Index,FileIndexer:i,Input:o,Packages:s};return{available:!0,runtime:c,producerIdentity:Zr(c)}}catch(e){return{available:!1,reason:`scip-typescript document runtime unavailable: ${e instanceof Error?e.message:String(e)}`}}}function Ag(){let e=ho();return e.available?{available:!0,packageVersion:e.packageVersion,typescriptVersion:e.typescriptVersion,producerIdentity:e.producerIdentity}:e}function ho(){try{let e=ne.resolve("@sourcegraph/scip-typescript/package.json"),t=JSON.parse(po(e,"utf8"));if(t.version!==uo)return{available:!1,reason:`unsupported scip-typescript version ${String(t.version??"unknown")}; expected ${uo}`};let r=Qr(e),n=ne.resolve("typescript/package.json",{paths:[r]}),i=JSON.parse(po(n,"utf8"));return typeof i.version!="string"||!i.version?{available:!1,reason:"scip-typescript TypeScript compiler version is unavailable"}:{available:!0,packageRoot:r,packageVersion:t.version,typescriptVersion:i.version,producerIdentity:yo(t.version,i.version)}}catch(e){return{available:!1,reason:`scip-typescript document producer unavailable: ${e instanceof Error?e.message:String(e)}`}}}function jg(e){let t=e.runtime===void 0?bl():e.runtime===null?{available:!1,reason:"scip-typescript document runtime unavailable"}:{available:!0,runtime:e.runtime,producerIdentity:Zr(e.runtime)};return t.available?{available:!0,emitter:new Yr(e,t.runtime)}:t}var Yr=class{producerIdentity;workspaceRoot;tsconfigPath;projectRoot;maxFileByteSize;runtime;host;config=null;includedFiles=new Set;program=null;checker=null;symbolTable=new Map;constructorTable=new Map;packages;fragments=new Map;stats={initializations:0,programUpdates:0,documentsEmitted:0,documentsRemoved:0,sourceNodesReused:0,sourceNodesReplaced:0,symbolEntriesPruned:0};constructor(t,r){this.workspaceRoot=ie(t.workspaceRoot),this.tsconfigPath=ie(this.workspaceRoot,t.tsconfigPath),this.projectRoot=t.projectRoot??vl(this.workspaceRoot,Qr(this.tsconfigPath)),this.maxFileByteSize=t.maxFileByteSize??1024*1024,this.runtime=r,this.producerIdentity=Zr(r);let n=fo(r.typescript,this.tsconfigPath);this.config=n,this.host=new Xr(r.typescript,n.options,this.workspaceRoot),this.packages=new r.Packages(this.projectRoot)}initialize(){let t=performance.now(),r=this.config??fo(this.runtime.typescript,this.tsconfigPath);this.includedFiles=new Set(r.fileNames.map(De)),this.program=this.runtime.typescript.createProgram(r.fileNames,r.options,this.host.compilerHost),this.checker=this.program.getTypeChecker(),this.stats.initializations+=1;let n=[];for(let i of this.program.getSourceFiles())this.includedFiles.has(De(i.fileName))&&n.push(this.emitSourceFile(i));return this.result(n,t)}advance(t){if(!this.program||!this.checker||!this.config)return this.initializeAndAdvance(t);let r=performance.now(),n=Dt(t.modifiedFiles),i=Dt(t.affectedFiles);this.validateIncrementalPaths(n,i);let o=this.program,s=new Map;for(let c of n){let l=nt(this.workspaceRoot,c),p=o.getSourceFile(l);if(!p)throw new Error(`modified TypeScript source is unavailable: ${c}`);s.set(c,p),this.stats.symbolEntriesPruned+=mo(this.symbolTable,p),this.stats.symbolEntriesPruned+=mo(this.constructorTable,p),this.host.invalidate(l)}this.program=this.runtime.typescript.createProgram(this.config.fileNames,this.config.options,this.host.compilerHost,o),this.checker=this.program.getTypeChecker(),this.stats.programUpdates+=1;for(let[c,l]of s)this.program.getSourceFile(nt(this.workspaceRoot,c))===l?this.stats.sourceNodesReused+=1:this.stats.sourceNodesReplaced+=1;let a=i.map(c=>{let l=nt(this.workspaceRoot,c),p=this.program.getSourceFile(l);if(!p)throw new Error(`affected TypeScript source is unavailable: ${c}`);return this.emitSourceFile(p)});return this.result(a,r)}fragment(t){return this.fragments.get(At(t))??null}snapshotStats(){return{...this.stats}}initializeAndAdvance(t){let r=this.initialize(),n=Dt(t.modifiedFiles),i=Dt(t.affectedFiles);this.validateIncrementalPaths(n,i);let o=new Set(i);return{...r,fragments:r.fragments.filter(s=>o.has(s.relativePath))}}validateIncrementalPaths(t,r){if(t.length===0)throw new Error("incremental TypeScript document update requires a modified file");if(r.length===0)throw new Error("incremental TypeScript document update requires an affected file");for(let n of t){let i=nt(this.workspaceRoot,n);if(!this.includedFiles.has(De(i)))throw new Error(`modified TypeScript file is outside the configured project: ${n}`)}for(let n of r){let i=nt(this.workspaceRoot,n);if(!this.includedFiles.has(De(i)))throw new Error(`affected TypeScript file is outside the configured project: ${n}`)}}emitSourceFile(t){if(!this.checker)throw new Error("TypeScript document emitter is not initialized");let r=At(go(this.workspaceRoot,t.fileName)),n=new this.runtime.Document({relative_path:r,occurrences:[]});if(new this.runtime.FileIndexer(this.checker,{cwd:this.workspaceRoot,projectRoot:this.projectRoot,projectDisplayName:this.projectRoot,maxFileByteSizeNumber:this.maxFileByteSize},new this.runtime.Input(t.fileName,t.getText()),n,this.symbolTable,this.constructorTable,this.packages,t).index(),this.stats.documentsEmitted+=1,n.occurrences.length===0)return this.fragments.delete(r),this.stats.documentsRemoved+=1,{relativePath:r,bytes:null,occurrences:0,symbols:n.symbols.length,referenceFragments:[]};let o=n.serializeBinary();return this.fragments.set(r,o),{relativePath:r,bytes:o,occurrences:n.occurrences.length,symbols:n.symbols.length,referenceFragments:xl(r,n)}}result(t,r){return{producerIdentity:this.producerIdentity,fragments:t,durationMs:performance.now()-r,stats:this.snapshotStats()}}};function xl(e,t){let r=new Map;for(let n of t.occurrences){if(!n.symbol||(n.symbol_roles&1)!==0||n.range.length<3)continue;let i=n.range[0],o=n.range[1];if(!Number.isInteger(i)||!Number.isInteger(o))continue;let s={targetSymbol:n.symbol,location:{file:e,line:i,column:o}};r.set(`${n.symbol}\0${i}\0${o}`,s)}return[...r.values()].sort((n,i)=>n.targetSymbol.localeCompare(i.targetSymbol)||n.location.line-i.location.line||n.location.column-i.location.column)}var Xr=class{compilerHost;sourceFiles=new Map;constructor(t,r,n){let i=t.createCompilerHost(r),o=i.getSourceFile.bind(i);this.compilerHost={...i,getCurrentDirectory:()=>n,getSourceFile:(s,a,c,l)=>{let p=De(s);if(this.sourceFiles.has(p))return this.sourceFiles.get(p);let u=o(s,a,c,l);return this.sourceFiles.set(p,u),u}}}invalidate(t){this.sourceFiles.delete(De(t))}};function fo(e,t){let r=e.readConfigFile(t,e.sys.readFile);if(r.error)throw new Error(e.formatDiagnostics([r.error],e.createCompilerHost({})));let n=e.parseJsonConfigFileContent(r.config,e.sys,Qr(t)),i=n.errors.filter(o=>o.code!==18003);if(i.length>0)throw new Error(e.formatDiagnostics(i,e.createCompilerHost({})));return n}function Zr(e){return yo(e.packageVersion,e.typescript.version)}function yo(e,t){return`scip-typescript:${e}:typescript:${t}:document-adapter:${Sl}`}function vl(e,t){return At(go(e,t))||"."}function nt(e,t){if(yl(t))throw new Error(`expected a project-relative path: ${t}`);let r=ie(e,t),n=e.endsWith(Kr)?e:`${e}${Kr}`;if(r!==e&&!r.startsWith(n))throw new Error(`path escapes the project root: ${t}`);return r}function Dt(e){return[...new Set(e.map(At))].sort()}function At(e){return e.split(Kr).join("/").replace(/^\.\//,"")}function De(e){return ie(e)}function mo(e,t){let r=0;for(let n of e.keys())if(Il(n)){try{if(n.getSourceFile()!==t)continue}catch{continue}e.delete(n),r+=1}return r}function Il(e){return!!(e&&typeof e=="object"&&"kind"in e&&"getSourceFile"in e)}var El=[w("source-facts",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/source/source-facts.ts"}),w("file-definitions",{dependsOn:["content-hash","project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","relativePath","contentHash","projectFingerprint","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/symbols/definition-catalog.ts"}),w("definition-exclusions",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/analysis/framework-patterns.ts"}),w("doc-path-tokens",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/storage/evidence-products.test.ts",owner:"tests/storage/evidence-cache.test.ts"}),w("doc-path-evidence",{dependsOn:["content-hash","git-history","git-head","tool-version"],keyParts:["kind","relativePath","contentHash","trackedFiles","historyWindow","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/queries/cleanup/doc-drift.ts"}),w("source-imports",{dependsOn:["content-hash","import-resolution-fingerprint","config","tool-version"],keyParts:["kind","relativePath","contentHash","importResolutionFingerprint","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/language-parsers/index.ts"}),w("source-reexports",{dependsOn:["content-hash","import-resolution-fingerprint","config","tool-version"],keyParts:["kind","relativePath","contentHash","importResolutionFingerprint","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/language-parsers/index.ts"}),w("source-fingerprints",{dependsOn:["content-hash","project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","relativePath","contentHash","projectFingerprint","payloadVersion"],stalenessTest:"tests/symbols/definition-catalog.test.ts",owner:"src/queries/cleanup/similar.ts"}),w("consumer-file-usage",{dependsOn:["content-hash","project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","relativePath","contentHash","projectFingerprint","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/queries/internal/consumer-evidence.ts"}),w("react-component-behavior-profiles",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/source/react-profile.ts"}),w("git-file-adds",{dependsOn:["git-head","git-history","tool-version"],keyParts:["kind","cacheKey","head","historyWindow","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/analysis/git-history.ts"}),w("typescript-reference-fragments",{dependsOn:["content-hash","transitive-deps-digest","config","tool-version"],keyParts:["kind","relativePath","semanticIdentity","payloadVersion"],stalenessTest:"tests/semantic/typescript/typescript-reference-fragments.test.ts",owner:"src/semantic/typescript/reference-fragment-shadow.ts"}),w("typescript-import-usage",{dependsOn:["content-hash","transitive-deps-digest","config","tool-version"],keyParts:["kind","relativePath","semanticIdentity","payloadVersion"],stalenessTest:"tests/semantic/typescript/typescript-semantic-provider.test.ts",owner:"src/semantic/shared-primitives.ts"}),w("typescript-signatures",{dependsOn:["content-hash","transitive-deps-digest","config","tool-version"],keyParts:["kind","relativePath","semanticIdentity","payloadVersion"],stalenessTest:"tests/semantic/typescript/typescript-semantic-provider.test.ts",owner:"src/semantic/shared-primitives.ts"}),jt("file-dependency-graph",{dependsOn:["project-fingerprint","indexed-language-set","import-resolution-fingerprint","tool-version"],keyParts:["kind","scope","projectFingerprint","payloadVersion"],stalenessTest:"tests/symbols/file-dep-graph.test.ts",owner:"src/symbols/graph/file-dep-graph.ts"}),jt("semantic-import-usage",{dependsOn:["project-fingerprint","indexed-language-set","import-resolution-fingerprint","tool-version"],keyParts:["kind","relativePath","projectFingerprint","language","semanticEngine","payloadVersion"],stalenessTest:"tests/semantic/rust/rust-semantic-cache-gate.test.ts",owner:"src/semantic/shared-primitives.ts"}),jt("semantic-signatures",{dependsOn:["project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","relativePath","symbol","projectFingerprint","language","semanticEngine","payloadVersion"],stalenessTest:"tests/semantic/rust/rust-semantic-cache-gate.test.ts",owner:"src/semantic/shared-primitives.ts"}),jt("health-semantic-prewarm",{dependsOn:["project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","scope","cliVersion","projectFingerprint","payloadVersion"],stalenessTest:"tests/runtime/cli-support.test.ts",owner:"src/runtime/cli-support.ts"})];function it(e){let t=new Map;return{kind:e.kind,read(r,n,i){let o=!1,s=0,a;if(rr()){let c=ti(r);if(c){let l=`${c}\0${n}\0${i}`;a=t.get(l),a||(a=nr(["evidence-product-file-read-v1",e.kind,c,n,i]),t.set(l,a))}}return ir("evidence-product.file.read",()=>{let c=ri(r,e.kind,n,i);if(c===null)return null;s=c.length;try{let l=e.deserialize(c);return o=l!==null,l}catch{return null}},()=>({...a?{workIdentity:a,workOutcome:"computed"}:{},scope:"file",kind:e.kind,available:!0,hit:o,payloadBytes:s}))},write(r,n,i,o){ni(r,e.kind,n,i,e.serialize(o))},writeBatch(r,n){ii(r,n.map(i=>({kind:e.kind,relativePath:i.relativePath,contentHash:i.contentHash,payload:e.serialize(i.value)})))}}}function Wg(e){let t=new Map;return{kind:e.kind,read(r,n,i){let o=!1,s=0,a;if(rr()){let c=`${i}\0${n}`;a=t.get(c),a||(a=nr(["evidence-product-project-read-v1",e.kind,i,n]),t.set(c,a))}return ir("evidence-product.project.read",()=>{let c=oi(r,e.kind,n,i);if(c===null)return null;s=c.length;try{let l=e.deserialize(c);return o=l!==null,l}catch{return null}},()=>({...a?{workIdentity:a,workOutcome:"computed"}:{},scope:"project",kind:e.kind,available:!0,hit:o,payloadBytes:s}))},write(r,n,i,o){si(r,e.kind,n,i,e.serialize(o))}}}function ot(e){let t=El.find(r=>r.kind===e);if(!t)throw new Error(`missing evidence product manifest entry for ${e}`);return t.invalidation}function w(e,t){return{scope:"file",kind:e,invalidation:{scope:"file",...t}}}function jt(e,t){return{scope:"project",kind:e,invalidation:{scope:"project",...t}}}import{isAbsolute as wl,relative as Cl}from"path";function C(e){return e.replace(/\\/g,"/")}function Vg(e,t){let r=Cl(e,t);return r===""||!r.startsWith("..")&&!wl(r)}var kl=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"];function Hg(e){let t=e.toLowerCase();return kl.some(r=>t.endsWith(r))}import{createRequire as Tl}from"module";var So=Tl(import.meta.url),st,Ft;function Pl(){if(st!==void 0)return st;try{st=So("ts-morph")}catch{st=null}return st}function Jg(){if(Ft)return Ft;let e=Pl();if(!e)return"ts-morph:unavailable";let t="unknown";try{t=So("ts-morph/package.json").version??"unknown"}catch{}return Ft=`ts-morph:${t}:typescript:${e.ts.version}`,Ft}function Kg(e,t){return t.map(r=>({tsconfigPath:r,project:new e.Project({tsConfigFilePath:r,skipFileDependencyResolution:!0})}))}function Yg(e,t,r){return{language:"typescript",availability:()=>({available:!1,reason:e,tsconfigPath:t,tsconfigPaths:r}),importUsage:()=>[],referencesFor:()=>[],calleesFor:()=>[],signatureFor:()=>null}}function Qg(e,t,r){let n=new Set(r),i=new Map(r.map(o=>[o,[]]));for(let o of e)for(let s of t.get(o.symbolId)??[])n.has(s.file)&&i.get(s.file).push({targetSymbol:o.symbol,location:s});for(let[o,s]of i)i.set(o,Rl(s));return i}function Rl(e){let t=new Map;for(let r of e){let{location:n}=r;t.set(`${r.targetSymbol}\0${n.file}\0${n.line}\0${n.column}`,r)}return[...t.values()].sort((r,n)=>r.targetSymbol.localeCompare(n.targetSymbol)||Nl(r.location,n.location))}function Nl(e,t){return e.file.localeCompare(t.file)||e.line-t.line||e.column-t.column}import{existsSync as tn,readFileSync as rn,readdirSync as _l,statSync as Dl}from"fs";import{join as Ae,relative as Al}from"path";function bo(e){let t=jl(e)??Ml(e);if(!t||t.length===0)return[];let r=[],n=new Set;for(let i of t)for(let o of $l(e,i)){if(n.has(o))continue;n.add(o);let s=Wl(e,o);s&&r.push(s)}return r}function jl(e){let t=Ae(e,"pnpm-workspace.yaml");if(!tn(t))return null;try{return Fl(rn(t,"utf8"))}catch{return null}}function Fl(e){let t=[],r=!1;for(let n of e.split(/\r?\n/)){let i=Ol(n);if(!r){/^packages\s*:\s*$/.test(i.trim())&&(r=!0);continue}let o=/^\s+-\s*(.+)$/.exec(i);if(o){let s=Ll(o[1].trim());s&&t.push(s);continue}if(i.trim()!=="")break}return t}function Ol(e){let t=e.indexOf("#");return t===-1?e:e.slice(0,t)}function Ll(e){return e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1):e}function Ml(e){let t=Ae(e,"package.json");if(!tn(t))return null;try{let r=JSON.parse(rn(t,"utf8"));return r.workspaces?Array.isArray(r.workspaces)?r.workspaces:r.workspaces.packages??[]:null}catch{return null}}function $l(e,t){if(!t||t.startsWith("!")||t.includes("node_modules"))return[];if(!t.includes("*")){let s=Ae(e,t);return en(s)?[s]:[]}let r=t.indexOf("*"),n=t.slice(0,r).replace(/\/$/,""),i=t.slice(r+1).replace(/^\//,""),o=Ae(e,n||".");return en(o)?_l(o).map(s=>Ae(o,s,i)).filter(en):[]}function en(e){try{return Dl(e).isDirectory()}catch{return!1}}function Wl(e,t){let r=Ae(t,"package.json");if(!tn(r))return null;try{let n=JSON.parse(rn(r,"utf8"));return typeof n.name!="string"||n.name.length===0?null:{name:n.name,relativeDir:Al(e,t).replace(/\\/g,"/"),exports:n.exports}}catch{return null}}import{createRequire as Gl}from"module";import{existsSync as he}from"fs";import{basename as xo,dirname as R,extname as z,join as j,relative as me,resolve as b,sep as Ul}from"path";var Vl=ft("indexed-paths",{clearGroups:[]}),Bl=ft("indexed-path-digest",{clearGroups:[]}),Hl=x("tsconfig-alias-config",{clearGroups:["whole-project"]}),ql=x("tsconfig-alias-config-for-dir",{clearGroups:["whole-project"]}),zl=Gl(import.meta.url),at;function Jl(){if(at!==void 0)return at;try{at=zl("typescript")}catch{at=null}return at}var Kl=["tsconfig.json","tsconfig.app.json","tsconfig.node.json","tsconfig.base.json"],Yl=ft("workspace-packages",{clearGroups:["whole-project"]}),ge=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs",".vue"],Ot=[".py",".pyi"],N=[".java",".scala",".kt",".kts"],Lt=[".rs"],Mt=[".rb"],$t=[".c",".h",".cc",".cpp",".cxx",".hpp",".hh",".hxx"],oe=[".cs",".vb"],Wt=[".dart"],ye=[".php"],je=[".clj",".cljs",".cljc"],Xl=new Set(ge),nn=new Set(Ot),vo=new Set(N),on=new Set(Lt),sn=new Set(Mt),Io=new Set($t),Eo=new Set(oe),an=new Set(Wt),wo=new Set(ye),Co=new Set(je),Ql=[{extensions:ge,lookup:Xl},{extensions:Ot,lookup:nn},{extensions:N,lookup:vo},{extensions:Lt,lookup:on},{extensions:Mt,lookup:sn},{extensions:$t,lookup:Io},{extensions:oe,lookup:Eo},{extensions:Wt,lookup:an},{extensions:ye,lookup:wo},{extensions:je,lookup:Co}];function J(e,t){return t.has(z(e).toLowerCase())}function Zl(e){return J(e,nn)}function ep(e){return J(e,vo)}function tp(e){return J(e,on)}function rp(e){return J(e,sn)}function np(e){return J(e,Io)}function ip(e){return J(e,Eo)}function ko(e){return z(e).toLowerCase()===".vb"}function op(e){return J(e,an)}function sp(e){return J(e,wo)}function ap(e){return J(e,Co)}function cn(e){let t=z(e).toLowerCase();for(let r of Ql)if(r.lookup.has(t))return r.extensions;return ge}function cp(e){return ep(e)||ip(e)||sp(e)}function se(e,t,r){return Zl(t)?Fe(e,t,r):tp(t)?K(e,t,r):rp(t)?Gt(e,t,r):np(t)?Ut(e,t,r):cp(t)?y(e,r.replace(/\\/g,"."),cn(t)):op(t)?Vt(e,t,r):ap(t)?ln(e,r):lp(e,t,r)}function lp(e,t,r){if(!r.startsWith(".")&&!r.startsWith("/"))return pp(e,t,r)??dp(e,r);let n=R(j(e.config.projectRoot,t)),i=b(n,r),o=Y(e);for(let s of un(i)){let a=C(me(e.config.projectRoot,s));if(o.has(a)||he(s))return a}return C(me(e.config.projectRoot,i))}function pp(e,t,r){let n=Sp(e,t);if(!n)return null;let i=Y(e);for(let o of up(n,r)){let s=b(n.baseUrl,o);for(let a of un(s)){let c=C(me(e.config.projectRoot,a));if(i.has(c)||he(a))return c}}return null}function up(e,t){let r=[];for(let[n,i]of Object.entries(e.paths)){let o=n.indexOf("*");if(o===-1){if(t!==n)continue;r.push(...i);continue}let s=n.slice(0,o),a=n.slice(o+1);if(!t.startsWith(s)||!t.endsWith(a)||t.length<s.length+a.length)continue;let c=t.slice(s.length,t.length-a.length);for(let l of i)r.push(l.includes("*")?l.replace("*",c):l)}return r}function dp(e,t){let r=mp(fp(e),t);if(!r)return null;let n=Y(e);for(let i of gp(r)){let o=b(e.config.projectRoot,r.pkg.relativeDir,i);for(let s of un(o)){let a=C(me(e.config.projectRoot,s));if(n.has(a)||he(s))return a}}return null}function fp(e){return Yl.get(e,()=>bo(e.config.projectRoot))}function mp(e,t){let r=null;for(let n of e){let i=null;t===n.name?i="":t.startsWith(`${n.name}/`)&&(i=t.slice(n.name.length+1)),i!==null&&(!r||n.name.length>r.pkg.name.length)&&(r={pkg:n,subpath:i})}return r}function gp(e){let t=[],r=hp(e.pkg.exports,e.subpath);if(r){let n=yp(r);n&&t.push(n)}return t.push(e.subpath?`src/${e.subpath}`:"src/index"),t}function hp(e,t){if(!e||typeof e!="object")return null;let r=t===""?".":`./${t}`;return To(e[r])}function To(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;let t=e;for(let r of["types","import","default","require","node"]){let n=To(t[r]);if(n)return n}return null}function yp(e){let t=e.replace(/^\.\//,"");return t.startsWith("dist/")?`src/${t.slice(5)}`:null}function Sp(e,t){let r=C(R(t));return ql.get(e,r,()=>bp(e,r))}function bp(e,t){let r=Jl();if(!r)return null;let n=b(e.config.projectRoot),i=b(n,t);for(;i===n||i.startsWith(n+Ul);){for(let s of Kl){let a=j(i,s);if(!he(a))continue;let c=Hl.get(e,a,()=>xp(r,a));if(c)return c}let o=R(i);if(o===i)break;i=o}return null}function xp(e,t){try{let r=e.readConfigFile(t,e.sys.readFile);if(r.error||!r.config)return null;let n=e.parseJsonConfigFileContent(r.config,e.sys,R(t)),i=n.options.paths;return!i||Object.keys(i).length===0?null:{baseUrl:n.options.baseUrl?b(R(t),n.options.baseUrl):R(t),paths:i}}catch{return null}}function Fe(e,t,r){let n=Y(e),i;if(r.startsWith(".")){let o=r.match(/^(\.+)(.*)$/);if(!o)return null;let s=o[1].length,a=o[2].replace(/^\./,""),c=R(j(e.config.projectRoot,t));for(let l=1;l<s;l++)c=R(c);i=a?b(c,a.replace(/\./g,"/")):c}else i=b(e.config.projectRoot,r.replace(/\./g,"/"));for(let o of vp(i)){let s=C(me(e.config.projectRoot,o));if(n.has(s)||he(o))return s}return null}function K(e,t,r){if(!r)return null;let n=r.replace(/\s+as\s+.+$/,"").trim();if(!n.startsWith("crate::")&&!n.startsWith("self::")&&!n.startsWith("super::"))return null;let i=R(j(e.config.projectRoot,t)),o;return n.startsWith("crate::")?o=b(e.config.projectRoot,"src",n.slice(7).replace(/::/g,"/")):n.startsWith("self::")?o=b(i,n.slice(6).replace(/::/g,"/")):o=b(R(i),n.slice(7).replace(/::/g,"/")),pn(e,Ip(o))}function Gt(e,t,r){let n=R(j(e.config.projectRoot,t)),i=b(n,r);return pn(e,Ep(i))}function Ut(e,t,r){let n=R(j(e.config.projectRoot,t)),i=[b(n,r),b(e.config.projectRoot,r),b(e.config.projectRoot,"include",r),b(e.config.projectRoot,"src",r)];return pn(e,i)}function y(e,t,r){let n=Y(e),i=t.replace(/\\/g,".").replace(/::/g,".").replace(/^global::/,""),o=i.replace(/\./g,"/"),s=i.split(".").pop()??i;for(let c of r){let l=`${o}${c}`,p=[...n].find(u=>u.endsWith(l));if(p)return p}for(let c of r){let l=[...n].find(p=>xo(p)===`${s}${c}`);if(l)return l}let a=[...n].filter(c=>r.includes(z(c).toLowerCase())).filter(c=>c.includes(`/${o}/`)||c.includes(`/${s}/`)).sort((c,l)=>c.localeCompare(l));return a.length===1?a[0]:null}function Vt(e,t,r){let n=Y(e);if(r.startsWith("package:")){let s=r.slice(8),a=s.indexOf("/");if(a<0)return null;let c=s.slice(a+1),l=C(c.startsWith("lib/")?c:`lib/${c}`);return n.has(l)?l:null}let i=R(j(e.config.projectRoot,t)),o=b(i,r);for(let s of wp(o)){let a=C(me(e.config.projectRoot,s));if(n.has(a)||he(s))return a}return null}function ln(e,t){let r=t.replace(/-/g,"_").replace(/\./g,"/"),n=Y(e);for(let i of je){let o=`${r}${i}`,s=[...n].find(a=>a.endsWith(o));if(s)return s}for(let i of je){let o=[...n].find(s=>xo(s)===`${r.split("/").pop()}${i}`);if(o)return o}return null}function vp(e){let t=z(e);return nn.has(t)?[e]:[`${e}.py`,`${e}.pyi`,j(e,"__init__.py"),j(e,"__init__.pyi")]}function pn(e,t){let r=Y(e);for(let n of t){let i=C(me(e.config.projectRoot,n));if(r.has(i)||he(n))return i}return null}function Ip(e){let t=z(e);return on.has(t)?[e]:[`${e}.rs`,j(e,"mod.rs")]}function Ep(e){let t=z(e);return sn.has(t)?[e]:[`${e}.rb`,j(e,"index.rb")]}function wp(e){let t=z(e);return an.has(t)?[e]:[`${e}.dart`,e]}function un(e){let t=z(e),r=new Set;if(t){r.add(e);for(let n of ge)r.add(e.slice(0,-t.length)+n)}else for(let n of ge)r.add(`${e}${n}`),r.add(j(e,`index${n}`));return[...r]}function Y(e){return Vl.get(e,()=>new Set(An(e,{includeIgnored:!1}).map(C)))}function dn(e){return Bl.get(e,()=>bt([...Y(e)].sort().join(`
|
|
108
|
-
`)))}import{readFileSync as Cp}from"fs";import{join as kp}from"path";var Tp=x("source-text",{clearGroups:["whole-project","source-file"]}),Pp=x("source-lines",{clearGroups:["whole-project","source-file"]});function _(e,t){let r=t.replace(/\\/g,"/");return Tp.get(e,r,()=>{let n=kp(e.config.projectRoot,r);try{return Cp(n,"utf-8")}catch(i){if(Rp(i))return"";throw i}})}function Rp(e){return typeof e=="object"&&e!==null&&"code"in e&&(e.code==="ENOENT"||e.code==="ENOTDIR")}function gh(e,t){let r=t.replace(/\\/g,"/");return Pp.get(e,r,()=>{let n=_(e,r);return n?n.split(`
|
|
109
|
-
`):[]})}import{basename as Zo}from"path";function Se(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Np(e){return e.replace(/'''[\s\S]*?'''/g,ae).replace(/"""[\s\S]*?"""/g,ae).replace(/#.*$/gm,ae).replace(/\/\/.*$/gm,ae).replace(/\/\*[\s\S]*?\*\//g,ae).replace(/`(?:\\[\s\S]|[^`])*`/g,ae).replace(/'(?:\\.|[^'\\\r\n])*'/g,ae).replace(/"(?:\\.|[^"\\\r\n])*"/g,ae)}function ae(e){return e.replace(/[^\r\n]/g," ")}var vh=ke("stripped-lines",{clearGroups:["whole-project","source-file"]});_n({name:"stripped-source-singleton",groups:["whole-project","source-file"],clearAll:()=>{Bt=null,ct=""},clearFile:()=>{Bt=null,ct=""}});var Bt=null,ct="";function _p(e){return Bt===e||(Bt=e,ct=Np(e)),ct}function ce(e,t,r){let n=_p(e);return`${n.slice(0,t)}${" ".repeat(r-t)}${n.slice(r)}`}function k(e,t){return new RegExp(`\\b${Se(t)}\\b`,"m").test(e)}function Oe(e,t){let r=new Set,n=new RegExp(`\\b${Se(t)}\\s*\\.\\s*([A-Za-z_$][\\w$]*)`,"g");for(let i of e.matchAll(n)){let o=i[1];o&&r.add(o)}return[...r]}function fn(e){let t=0;for(let r of e)r==="("&&(t+=1),r===")"&&(t-=1);return t}import{extname as Po}from"path";var Dp={".rs":"rust",".ts":"typescript",".mts":"typescript",".cts":"typescript",".tsx":"tsx",".js":"javascript",".jsx":"javascript",".mjs":"javascript",".cjs":"javascript",".py":"python",".pyi":"python",".java":"java",".kt":"kotlin",".kts":"kotlin",".scala":"scala",".sc":"scala",".rb":"ruby",".c":"c",".h":"c",".cc":"cpp",".cpp":"cpp",".cxx":"cpp",".hpp":"cpp",".hh":"cpp",".hxx":"cpp",".cs":"csharp",".php":"php",".vb":"vb",".clj":"clojure",".cljs":"clojure",".cljc":"clojure"};function be(e){return Dp[Po(e).toLowerCase()]??null}function xe(e){return Po(e).toLowerCase()===".vue"}import{createRequire as Ap}from"module";var v=Ap(import.meta.url),Ht=null,Ro=!1;function jp(){if(Ro)return null;if(Ht)return Ht;try{return Ht=v("tree-sitter"),Ht}catch{return Ro=!0,null}}var No=new Map,qt=new Set;function Fp(e){if(qt.has(e))return null;let t=No.get(e);if(t)return t;let r;try{switch(e){case"rust":r=v("tree-sitter-rust");break;case"typescript":r=v("tree-sitter-typescript").typescript;break;case"tsx":r=v("tree-sitter-typescript").tsx;break;case"javascript":r=v("tree-sitter-javascript");break;case"python":r=v("tree-sitter-python");break;case"java":r=v("tree-sitter-java");break;case"kotlin":r=v("tree-sitter-kotlin");break;case"scala":r=v("tree-sitter-scala");break;case"ruby":r=v("tree-sitter-ruby");break;case"c":r=v("tree-sitter-c");break;case"cpp":r=v("tree-sitter-cpp");break;case"csharp":r=v("tree-sitter-c-sharp");break;case"php":r=v("tree-sitter-php").php;break;case"vb":{let n=v("tree-sitter-vb-dotnet");r=n.language??n;break}case"clojure":return qt.add(e),null}}catch{return qt.add(e),null}return No.set(e,r),r}var _o=new Map;function Op(e){let t=_o.get(e);if(t)return t;let r=Fp(e);if(!r)return null;let n=jp();if(!n)return null;let i=new n;try{i.setLanguage(r)}catch{return qt.add(e),null}return _o.set(e,i),i}function Lp(e,t){return e.parse(n=>n>=t.length?null:t.slice(n,Math.min(t.length,n+16384)))}function mn(e,t){let r=Op(e);if(!r)return null;try{return Lp(r,t)}catch{return null}}import{posix as gn}from"path";import{parse as Mp}from"@vue/compiler-sfc";var _h=Dn("vue-sfc-units");function $p(e){return e.replace(/\\/g,"/").replace(/^\.\//,"")}function Wp(e){let t=e?.toLowerCase();return!t||t==="js"||t==="javascript"||t==="jsx"?"javascript":t==="ts"||t==="typescript"?"typescript":t==="tsx"?"tsx":null}function jo(e,t,r){let n={relativePath:t,template:null,scripts:[],styles:[],customBlocks:[],errors:[]};if(!r)return n;let i;try{i=Mp(r,{filename:t})}catch(s){return n.errors.push(Ao(s)),n}n.errors.push(...i.errors.map(Ao));let{descriptor:o}=i;return o.template&&(n.template=zt(e,t,"template",o.template)),o.script&&n.scripts.push(Do(e,t,o.script,!1)),o.scriptSetup&&n.scripts.push(Do(e,t,o.scriptSetup,!0)),n.styles=o.styles.map(s=>zt(e,t,"style",s)),n.customBlocks=o.customBlocks.map(s=>zt(e,t,"custom",s)),n.errors.push(...[n.template,...n.scripts,...n.styles,...n.customBlocks].flatMap(s=>s?.errors??[])),n}function Do(e,t,r,n){let i=zt(e,t,"script",r);return{...i,kind:"script",setup:n,astLanguage:Wp(i.lang)}}function zt(e,t,r,n){let i=Up(n.attrs),o=typeof i.lang=="string"?i.lang:null,s=typeof i.src=="string"?i.src:typeof n.src=="string"?n.src:void 0;if(s){let c=Gp(t,s);if(!c)return{kind:r,ownerPath:t,sourcePath:t,external:!0,src:s,attrs:i,lang:o,body:"",startLine:0,endLine:0,errors:[`Could not resolve Vue ${r} block source: ${s}`]};let l=_(e,c),p=l?Math.max(0,l.split(`
|
|
110
|
-
`).length-1):0;return{kind:r,ownerPath:t,sourcePath:c,external:!0,src:s,attrs:i,lang:o,body:l,startLine:0,endLine:p,errors:l?[]:[`Vue ${r} block source not found: ${c}`]}}let a=Math.max(0,n.loc.start.line-1);return{kind:r,ownerPath:t,sourcePath:t,external:!1,attrs:i,lang:o,body:n.content,startLine:a,endLine:Math.max(a,n.loc.end.line-1),errors:[]}}function Gp(e,t){let r=t.split(/[?#]/,1)[0];if(!r||r.startsWith("/")||r.includes("://"))return null;let n=$p(gn.normalize(gn.join(gn.dirname(e),r)));return n===".."||n.startsWith("../")?null:n}function Up(e){return{...e}}function Ao(e){return e instanceof Error?e.message:String(e)}function Jt(e,t,r){let i=jo(e,t,r).scripts.filter(s=>s.astLanguage&&s.body.length>0),o=i[0]?.astLanguage;return o?{body:i.map(s=>`${`
|
|
111
|
-
`.repeat(s.startLine)}${s.body}`).join(`
|
|
112
|
-
`),startLine:0,language:o}:null}var Fo=ke("ast-trees",{clearGroups:["whole-project","source-file"]});function B(e,t){if(xe(t))return Vp(e,t);let r=be(t);if(!r)return null;let n=_(e,t);return n?Fo.get(e,t,n,()=>mn(r,n)):null}function Vp(e,t){let r=_(e,t);return r?Fo.get(e,t,r,()=>{let n=Jt(e,t,r);if(!n)return null;let i=`
|
|
113
|
-
`.repeat(n.startLine)+n.body;return mn(n.language,i)}):null}function Oo(e,t){let r=Bp(e,t);if(!r)return null;let n=ve(r);return n?{calleeLeaf:n,memberAccess:Hp(r),line:e.startPosition.row}:null}function Bp(e,t){if(t==="rust")return e.type==="call_expression"?e.childForFieldName("function")??e.namedChild(0):e.type==="macro_invocation"?e.childForFieldName("macro")??e.namedChild(0):null;if(t==="python")return e.type!=="call"?null:e.childForFieldName("function")??e.namedChild(0);if(t==="typescript"||t==="tsx"||t==="javascript"){if(e.type==="call_expression")return e.childForFieldName("function")??e.namedChild(0);if(e.type==="new_expression")return e.childForFieldName("constructor")??e.namedChild(0)}return null}function Hp(e){switch(e.type){case"field_expression":case"member_expression":case"attribute":return!0;default:return!1}}function ve(e){switch(e.type){case"identifier":case"type_identifier":case"field_identifier":case"property_identifier":case"shorthand_property_identifier":return e.text;case"field_expression":case"member_expression":case"attribute":{let t=e.namedChild(e.namedChildCount-1);return t?ve(t):null}case"generic_function":{let t=e.childForFieldName("function")??e.namedChild(0);return t?ve(t):null}case"scoped_identifier":{let t=e.childForFieldName("name")??e.namedChild(e.namedChildCount-1);return t?ve(t):null}case"super":case"self":case"this":return null;default:return null}}function lt(e){return e.type==="comment"||e.type==="line_comment"||e.type==="block_comment"}var qp=new Set(["function_declaration","method_definition","method_signature","function_signature"]);function Go(e,t){let r=Jp(e,t);if(r)return{name:r.name,startLine:r.definitionNode.startPosition.row,endLine:r.definitionNode.endPosition.row,paramCount:$o(r.functionNode),params:Lo(r.functionNode),paramsEndLine:Mo(r.functionNode),isLiteralPassthrough:Wo(r.functionNode,t)};if(!zp(e.type,t))return null;let n=e.childForFieldName("name")??e.namedChildren.find(i=>i.type==="identifier"||i.type==="property_identifier");return n?{name:n.text,startLine:e.startPosition.row,endLine:e.endPosition.row,paramCount:$o(e),params:Lo(e),paramsEndLine:Mo(e),isLiteralPassthrough:Wo(e,t)}:null}function Uo(e){return e.namedChildren.find(t=>t.type==="parameters"||t.type==="formal_parameters")}function Lo(e){let t=Uo(e);if(!t)return[];let r=[];for(let n of t.namedChildren){if(lt(n))continue;if(n.type==="identifier"){r.push({name:n.text,simple:!0});continue}let i=n.namedChildren.some(a=>a.type.endsWith("_modifier"))||/^\s*(?:public|private|protected|readonly|override)\b/.test(n.text),o=n.childForFieldName("pattern");if(!i&&o&&o.type==="identifier"){r.push({name:o.text,simple:!0});continue}let s=n.namedChildren.find(a=>a.type==="identifier");r.push({name:o?.type==="identifier"?o.text:s?.text??"",simple:!1})}return r}function Mo(e){let t=Uo(e);return t?t.endPosition.row:e.startPosition.row}function zp(e,t){return t==="rust"?e==="function_item"||e==="function_signature_item":t==="python"?e==="function_definition":t==="typescript"||t==="tsx"||t==="javascript"?qp.has(e):!1}function Jp(e,t){if(t!=="typescript"&&t!=="tsx"&&t!=="javascript")return null;if(e.type==="variable_declarator"){let r=e.childForFieldName("name")??e.namedChild(0),n=e.childForFieldName("value")??e.namedChild(1);return!r||!n||n.type!=="arrow_function"&&n.type!=="function_expression"?null:{name:r.text,definitionNode:e,functionNode:n}}if(e.type==="public_field_definition"){let r=e.childForFieldName("name")??e.namedChild(0),n=e.childForFieldName("value")??e.namedChild(1);return!r||!n||n.type!=="arrow_function"&&n.type!=="function_expression"?null:{name:r.text,definitionNode:e,functionNode:n}}return null}function $o(e){let t=e.namedChildren.find(n=>n.type==="parameters"||n.type==="formal_parameters");if(!t)return 0;let r=0;for(let n of t.namedChildren)lt(n)||(r+=1);return r}function Wo(e,t){let r=e.namedChildren.find(u=>u.type==="block"||u.type==="statement_block");if(!r)return!1;let n=r.namedChildren.filter(u=>!lt(u));if(n.length!==1)return!1;let i=n[0],o=null;if(i.type==="return_statement"||i.type==="expression_statement"?o=i.namedChild(0)??null:t==="rust"&&(i.type==="call_expression"||i.type==="macro_invocation")&&(o=i),!o)return!1;let s=t==="python"?"call":"call_expression";if(o.type!==s)return!1;let a=o.namedChildren.find(u=>u.type==="arguments"||u.type==="argument_list");if(!a)return!1;let c=a.namedChildren.filter(u=>!lt(u)),l=e.namedChildren.find(u=>u.type==="parameters"||u.type==="formal_parameters");if(!l)return!1;let p=[];for(let u of l.namedChildren){if(u.type==="identifier"){p.push(u.text);continue}let d=u.namedChildren.find(m=>m.type==="identifier");d&&p.push(d.text)}if(c.length!==p.length)return!1;for(let u=0;u<p.length;u+=1){let d=c[u];if(d.type!=="identifier"||d.text!==p[u])return!1}return!0}var Kp=new Set(["identifier","type_identifier","field_identifier"]),Yp=new Set(["identifier"]),Xp=new Set(["identifier","property_identifier","type_identifier","shorthand_property_identifier","shorthand_property_identifier_pattern"]),Qp=new Set(["rust","python"]),Zp=/\{([^{}]*)\}/g,eu=/\b([A-Za-z_][\w]*)\b/g;function Vo(e,t){return tu(t).has(e.type)}function Bo(e,t){return Qp.has(t)&&e.type==="string_content"}function hn(e){let t=0;for(let n of e.values()){let i=n[n.length-1];i!==void 0&&i>t&&(t=i)}let r=new Array(t+1);for(let n=0;n<=t;n+=1)r[n]=new Set;for(let[n,i]of e)for(let o of i)r[o].add(n);return r}function tu(e){return e==="rust"?Kp:e==="python"?Yp:Xp}function Ho(e,t){let r=e.startPosition.row;for(let n of e.text.matchAll(Zp)){let i=n[1]??"";for(let o of i.matchAll(eu))o[1]&&t(o[1],r)}}var ru=[/\bdefault\s*=\s*"([^"]+)"/g,/\bwith\s*=\s*"([^"]+)"/g,/\bserialize_with\s*=\s*"([^"]+)"/g,/\bdeserialize_with\s*=\s*"([^"]+)"/g,/\bskip_serializing_if\s*=\s*"([^"]+)"/g,/\bgetter\s*=\s*"([^"]+)"/g,/\brename_all_with\s*=\s*"([^"]+)"/g,/\bschema_with\s*=\s*"([^"]+)"/g],nu=/^#!?\[\s*serde\s*\(/,iu=/^#!?\[\s*schemars\s*\(/,ou=/^#!?\[\s*validate\s*\(/,su=new Set(["invoke","invokeTauriCommand","listen","once","emit","subscribe","dispatch","sendCommand","callRust"]);function qo(e,t,r){if(t!=="typescript"&&t!=="tsx"&&t!=="javascript"||e.type!=="call_expression")return;let n=e.childForFieldName("function")??e.namedChild(0);if(!n)return;let i=ve(n);if(!i||!su.has(i))return;let o=e.namedChildren.find(c=>c.type==="arguments");if(!o)return;let s=o.namedChild(0);if(!s||s.type!=="string")return;let a=s.namedChildren.find(c=>c.type==="string_fragment");a&&r.add(a.text)}function zo(e,t){let r=nu.test(e),n=iu.test(e),i=ou.test(e);if(!(!r&&!n&&!i))for(let o of ru){o.lastIndex=0;let s;for(;(s=o.exec(e))!==null;){let a=s[1],c=a.split("::").pop()??a;c==="is_none"&&/\bOption\b/.test(a)||c==="is_empty"&&/\b(String|Vec|HashMap|BTreeMap|HashSet|BTreeSet)\b/.test(a)||c&&t.add(c)}}}function Jo(e,t){let r=new Map,n=(s,a)=>{if(s===a)return;let c=r.get(s);c||(c=new Set,r.set(s,c)),c.add(a)},i=t==="python"?new Set(["identifier"]):new Set(["type_identifier"]),o=(s,a)=>{let c=l=>{i.has(l.type)&&l.text!==a&&n(l.text,a);for(let p of l.children)c(p)};for(let l of s.children)c(l)};if(t==="rust")for(let s of e.rootNode.descendantsOfType(["struct_item","enum_item","union_item","type_item"])){let a=s.namedChildren.find(l=>l.type==="type_identifier")?.text;if(!a)continue;let c=s.namedChildren.find(l=>l.type==="field_declaration_list"||l.type==="enum_variant_list"||l.type==="ordered_field_declaration_list");c&&o(c,a),s.type==="type_item"&&o(s,a)}else if(t==="python")for(let s of e.rootNode.descendantsOfType("class_definition")){let a=s.namedChildren.find(p=>p.type==="identifier")?.text;if(!a)continue;let c=s.childForFieldName("superclasses");c&&o(c,a);let l=s.namedChildren.find(p=>p.type==="block");if(l)for(let p of l.descendantsOfType("type"))for(let u of p.descendantsOfType("identifier"))u.text!==a&&n(u.text,a)}else for(let s of e.rootNode.descendantsOfType(["interface_declaration","type_alias_declaration","class_declaration"])){let a=s.namedChildren.find(c=>c.type==="type_identifier")?.text;a&&o(s,a)}return r}var au=new Map([["defn","function"],["defn-","function"],["defmacro","macro"],["defmacro-","macro"],["defmethod","method"]]),yn=new Set(["catch","comment","def","defprotocol","defrecord","deftype","defmethod","defmacro","defmacro-","defn","defn-","do","doseq","dotimes","fn","for","if","let","loop","ns","quote","recur","throw","try","extend-protocol","extend-type","when","when-let","when-not"]);function Ko(e){let t=[],r=[],n=[],i=new Map,o=[],s=0,a=0,c=(l,p)=>{let u=i.get(l);if(!u){i.set(l,[p]);return}u[u.length-1]!==p&&u.push(p)};for(;a<e.length;){let l=e[a];if(l===`
|
|
114
|
-
`){s+=1,a+=1;continue}if(/\s|,/.test(l)){a+=1;continue}if(l===";"){a=Yt(e,a);continue}if(l==='"'){let h=ut(e,a,s);s=h.line,a=h.index;continue}if(l==="("||l==="["||l==="{"){o.push({kind:l,startLine:s,endLine:s,headTokens:[],tokens:[],children:[]}),a+=1;continue}if(l===")"||l==="]"||l==="}"){let h=o.pop();h&&(h.endLine=s,cu(h,{callables:t,callSites:r,clojureMembers:n,recordIdentifier:c}),o[o.length-1]?.children.push(h)),a+=1;continue}if(Sn(l)){a+=1;continue}let p=s,u=a;for(;a<e.length&&!bn(e[a]);)a+=1;let d=e.slice(u,a);if(!d)continue;let m={text:d,line:p};lu(o[o.length-1],m),c(F(d),p)}return{language:"clojure",callables:t,callSites:r,clojureMembers:n,typeContainerMap:new Map,identifierLineMap:i,identifiersByLine:mu(i),fileIdentifiers:new Set(i.keys()),rustAttrReferencedNames:new Set,crossLanguageDispatchNames:new Set}}function cu(e,t){if(e.kind!=="("||e.headTokens.length===0)return;let r=e.headTokens[0],n=F(r.text),i=au.get(r.text);if(i){let s=e.headTokens[1];if(s){let a=F(s.text);t.recordIdentifier(a,s.line),t.callables.push({name:a,startLine:e.startLine,endLine:e.endLine,paramCount:0,params:[],paramsEndLine:s.line,isLiteralPassthrough:!1,clojureKind:i})}}if(pu(e,t),!n||yn.has(r.text)||yn.has(n)||n.startsWith(":"))return;let o=fu(r.text);t.callSites.push({calleeLeaf:o.leaf,calleeQualifier:o.qualifier,calleeText:o.text,memberAccess:!1,line:r.line})}function lu(e,t){e&&(e.headTokens.length<2&&e.headTokens.push(t),e.tokens.length<200&&e.tokens.push(t))}function pu(e,t){let r=F(e.tokens[0]?.text??"");if(r==="defprotocol"){let n=F(e.tokens[1]?.text??"");if(!n)return;for(let i of Kt(e))pt(t,n,"protocol",i,"protocol-method");return}if(r==="defrecord"||r==="deftype"){let n=F(e.tokens[1]?.text??"");if(!n)return;let i=r==="defrecord"?"record":"type",o=r==="defrecord"?"record-method":"type-method";for(let s of Kt(e))pt(t,n,i,s,o);return}if(r==="extend-type"){let n=F(e.tokens[1]?.text??"");if(!n)return;for(let i of Kt(e))pt(t,n,"extension",i,"extension-method");return}if(r==="extend-protocol"){let n=F(e.tokens[1]?.text??"");for(let i of Kt(e)){n&&pt(t,n,"extension",i,"extension-method");let o=du(e,i.startLine);o&&o!==n&&pt(t,o,"extension",i,"extension-method")}}}function Kt(e){return e.children.filter(uu)}function uu(e){if(e.kind!=="(")return!1;let t=F(e.tokens[0]?.text??"");return!!(t&&!yn.has(t)&&!t.startsWith(":"))}function pt(e,t,r,n,i){let o=n.tokens[0],s=F(o?.text??"");!o||!s||(e.recordIdentifier(s,o.line),e.clojureMembers.push({ownerName:t,ownerKind:r,memberName:s,memberKind:i,startLine:n.startLine,endLine:n.endLine}))}function du(e,t){let r=null;for(let n=2;n<e.tokens.length;n+=1){let i=e.tokens[n];if(i.line>t)break;let o=F(i.text);o&&!o.startsWith(":")&&(r=o)}return r}function F(e){return e.replace(/^#?['`~@]+/,"").split("/").pop()?.replace(/^\./,"")??""}function fu(e){let t=e.replace(/^#?['`~@]+/,""),r=t.lastIndexOf("/"),n=F(t);if(r<=0)return{leaf:n,text:t};let i=t.slice(0,r);return{leaf:n,qualifier:i,text:t}}function Yt(e,t){let r=t;for(;r<e.length&&e[r]!==`
|
|
115
|
-
`;)r+=1;return r}function ut(e,t,r){let n=t+1,i=r;for(;n<e.length;){let o=e[n];if(o==="\\"){n+=2;continue}if(o===`
|
|
116
|
-
`&&(i+=1),n+=1,o==='"')break}return{index:n,line:i}}function Sn(e){return e==="'"||e==="`"||e==="~"||e==="@"||e==="^"||e==="#"}function bn(e){return/\s|,/.test(e)||e==="("||e===")"||e==="["||e==="]"||e==="{"||e==="}"||e==='"'||e===";"}function mu(e){let t=[];for(let[r,n]of e)for(let i of n)t[i]??=new Set,t[i].add(r);return t}var Yo=3,gu=ke("source-facts",{clearGroups:["whole-project","source-file"]}),xn=it({kind:"source-facts",invalidation:ot("source-facts"),serialize:bu,deserialize:xu});function Xo(e,t){return hu(e,t).facts}function hu(e,t){let r=_(e,t);if(!r)return{facts:null};let n=yu(e,t,r);return n?gu.get(e,t,r,()=>Su(e,t,n,r)):{facts:null}}function yu(e,t,r){return xe(t)?Jt(e,t,r)?.language??null:be(t)}function Su(e,t,r,n){let i=We(e,t,n),o=xn.read(e,t,i);if(o&&o.language===r)return{facts:o};if(r==="clojure"){let c=Ko(n);return xn.write(e,t,i,c),{facts:c}}let s=B(e,t);if(!s)return{facts:null,unavailable:{language:r,reason:"parser-unavailable"}};let a=vu(s,r);return xn.write(e,t,i,a),{facts:a}}function bu(e){let t={version:Yo,language:e.language,callables:e.callables,callSites:e.callSites,clojureMembers:e.clojureMembers,typeContainerMap:[...e.typeContainerMap.entries()].map(([r,n])=>[r,[...n]]),identifierLineMap:[...e.identifierLineMap.entries()],rustAttrReferencedNames:[...e.rustAttrReferencedNames],crossLanguageDispatchNames:[...e.crossLanguageDispatchNames]};return JSON.stringify(t)}function xu(e){try{let t=JSON.parse(e);if(t.version!==Yo||t.language==="clojure"&&(t.clojureMembers===void 0||t.callSites.some(n=>n.calleeText===void 0)))return null;let r=new Map(t.identifierLineMap);return{language:t.language,callables:t.callables,callSites:t.callSites,clojureMembers:t.clojureMembers??[],typeContainerMap:new Map(t.typeContainerMap.map(([n,i])=>[n,new Set(i)])),identifierLineMap:r,identifiersByLine:hn(r),fileIdentifiers:new Set(r.keys()),rustAttrReferencedNames:new Set(t.rustAttrReferencedNames),crossLanguageDispatchNames:new Set(t.crossLanguageDispatchNames)}}catch{return null}}function vu(e,t){let r=[],n=[],i=new Set,o=new Set,s=new Map,a=(l,p)=>{let u=s.get(l);if(!u){s.set(l,[p]);return}u[u.length-1]!==p&&u.push(p)},c=l=>{let p=Go(l,t);p&&r.push(p);let u=Oo(l,t);u&&n.push(u),qo(l,t,o),t==="rust"&&(l.type==="attribute_item"||l.type==="inner_attribute_item")&&zo(l.text,i),Vo(l,t)&&a(l.text,l.startPosition.row),Bo(l,t)&&Ho(l,a);for(let d of l.children)c(d)};return c(e.rootNode),{language:t,callables:r,callSites:n,clojureMembers:[],typeContainerMap:Jo(e,t),identifierLineMap:s,identifiersByLine:hn(s),fileIdentifiers:new Set(s.keys()),rustAttrReferencedNames:i,crossLanguageDispatchNames:o}}var Iu=new Set(["rust","typescript","tsx","javascript","python","clojure"]);function Eu(e,t){let r=Xo(e,t);return!r||!Iu.has(r.language)?null:r.callables.map(n=>({name:n.name,startLine:n.startLine,endLine:n.endLine}))}function Qo(e,t){return e.split(t).filter(Boolean).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")}var wu=new Set(["identifier","type_identifier","property_identifier","shorthand_property_identifier","field_identifier"]);function T(e){let t=[],r=0,n=0;for(let i=0;i<e.length;i++){let o=e[i];(o==="{"||o==="["||o==="(")&&r++,(o==="}"||o==="]"||o===")")&&r--,o===","&&r===0&&(t.push(e.slice(n,i)),n=i+1)}return t.push(e.slice(n)),t}function D(e,t){for(let r of e.namedChildren)if(r.type===t)return r;return null}function S(e,t){let r=new Set,n=(i,o)=>{let s=o||t.has(i.type);!s&&wu.has(i.type)&&r.add(i.text);for(let a of i.children)n(a,s)};return n(e.rootNode,!1),r}function G(e,t,r,n,i,o,s){return{importedName:i,localName:o,sourcePath:s??y(e,n,cn(t)),kind:"named",used:k(r,o),usedMembers:[]}}function g(e,t,r,n,i="named",o={}){return{importedName:e,localName:t,sourcePath:r,kind:i,used:n.has(t),usedMembers:[],isTypeOnly:o.isTypeOnly}}function X(e,t,r,n,i="named",o=[],s={}){return{importedName:e,localName:t,sourcePath:r,kind:i,used:n,usedMembers:o,isTypeOnly:s.isTypeOnly}}function Ie(e,t){return{importedName:e,localName:null,sourcePath:t,kind:"side-effect",used:!0,usedMembers:[]}}function Ee(e,t,r={}){return{importedName:e,localName:r.localName??null,sourcePath:t,kind:"namespace",used:r.used??!0,usedMembers:r.usedMembers??[],isTypeOnly:r.isTypeOnly}}function O(e,t,r){let n=[];for(let i of e.matchAll(t)){let o=i[0];if(!o||typeof i.index!="number")continue;let s=ce(e,i.index,i.index+o.length);for(let a of r(i,s))n.push(a)}return n}function L(e,t,r,n){let i=B(e,t);if(i){let o=r(i);if(o)return o}return n()}function Xt(e,t,r,n){let i=B(e,t),o=be(t),s=o?r[o]:void 0;return i&&s?s(i):n()}function es(e,t,r){return L(e,t,n=>ku(e,t,n),()=>Cu(e,t,r))}function Cu(e,t,r){return O(r,/^[ \t]*#include\s+[<"]([^">]+)[">]\s*$/gm,(n,i)=>{let o=n[1]?.trim();if(!o)return[];let s=Zo(o).replace(/\.[^.]+$/,"");return[X(o,s,Ut(e,t,o),k(i,s))]})}function ku(e,t,r){let n=S(r,new Set(["preproc_include"])),i=[];for(let o of r.rootNode.descendantsOfType("preproc_include")){let s=null;for(let c of o.namedChildren){if(c.type==="system_lib_string"){s=c.text.replace(/^<|>$/g,"");break}if(c.type==="string_literal"){s=c.namedChildren.find(p=>p.type==="string_content")?.text??c.text.replace(/^"|"$/g,"");break}}if(!s)continue;let a=Zo(s).replace(/\.[^.]+$/,"");i.push(g(s,a,Ut(e,t,s),n))}return i}var Tu=new Set([":require",":require-macros",":use"]),En=String.raw`A-Za-z0-9_$*+!?.<>=-`;function rs(e,t,r){let n=Mu(r);if(!n)return[];let i=Lu(r,n.start,n.end),o=[];for(let s of n.children.slice(2)){if(s.type!=="list"||s.children.length===0)continue;let a=M(s.children[0]);if(a){if(Tu.has(a)){for(let c of Nu(s.children.slice(1)))o.push(...Ru(e,c,i));continue}if(a===":import")for(let c of Du(s.children.slice(1)))o.push(c)}}return o}function Pu(e){return e.type==="list"&&M(e.children[0])==="ns"}function Ru(e,t,r){let n=ln(e,t.namespace),i=t.alias??t.namespace,o=ju(r,i),s=[{importedName:t.namespace,localName:i,sourcePath:n,kind:"namespace",used:t.refers.length>0||t.referAll||o.length>0||Fu(r,t.namespace),usedMembers:o}];t.referAll&&s.push({importedName:"*",localName:null,sourcePath:n,kind:"side-effect",used:!0,usedMembers:[]});for(let a of t.refers)s.push({importedName:a,localName:a,sourcePath:n,kind:"named",used:Ou(r,a),usedMembers:[]});return s}function Nu(e){return e.flatMap(t=>Qt(t,null))}function Qt(e,t){if(e.type==="atom")return e.text.startsWith(":")?[]:[{namespace:In(t,e.text),alias:null,refers:[],referAll:!1}];if(e.type==="vector")return e.children.length>0&&M(e.children[0])===null?e.children.flatMap(r=>Qt(r,t)):_u(e,t);if(e.type==="list"&&e.children.length>0){let r=M(e.children[0]);return r?!r||r.startsWith(":")?[]:e.children.slice(1).flatMap(n=>Qt(n,In(t,r))):e.children.flatMap(n=>Qt(n,t))}return[]}function _u(e,t){let r=M(e.children[0]);if(!r||r.startsWith(":"))return[];let n={namespace:In(t,r),alias:null,refers:[],referAll:!1};for(let i=1;i<e.children.length;i+=1){let o=M(e.children[i]);if(!o?.startsWith(":"))continue;let s=e.children[i+1];if((o===":as"||o===":as-alias")&&s){n.alias=M(s),i+=1;continue}o===":refer"&&s&&(M(s)===":all"?n.referAll=!0:(s.type==="vector"||s.type==="list")&&n.refers.push(...s.children.map(M).filter(Au)),i+=1)}return[n]}function Du(e){let t=[];for(let r of e){if(r.type==="atom"){let i=r.text.split(".").pop()??r.text;t.push(X(i,i,null,!0));continue}if(r.type!=="vector")continue;let n=M(r.children[0]);if(n)for(let i of r.children.slice(1)){let o=M(i);o&&t.push(X(`${n}.${o}`,o,null,!0))}}return t}function In(e,t){return e?`${e}.${t}`:t}function M(e){return e?.type==="atom"?e.text:null}function Au(e){return!!(e&&!e.startsWith(":"))}function ju(e,t){let r=new Set,n=new RegExp(`${wn()}${Se(t)}\\s*/\\s*([${En}]+)`,"g");for(let i of e.matchAll(n)){let o=i[1];o&&r.add(o)}return[...r]}function Fu(e,t){return new RegExp(`${wn()}${Se(t)}\\s*/`,"m").test(e)}function Ou(e,t){return new RegExp(`${wn()}${Se(t)}(?![${En}])`,"m").test(e)}function wn(){return`(?<![${En}])`}function Lu(e,t,r){let n="",i=0;for(;i<e.length;){if(i>=t&&i<r){n+=e[i]===`
|
|
117
|
-
`?`
|
|
118
|
-
`:" ",i+=1;continue}let o=e[i];if(o===";"){let s=Yt(e,i);n+=ts(e.slice(i,s)),i=s;continue}if(o==='"'){let s=ut(e,i,0).index;n+=ts(e.slice(i,s)),i=s;continue}n+=o,i+=1}return n}function Mu(e){let t=0;for(;t<e.length&&(t=Cn(e,t),!(t>=e.length));){let r=Zt(e,t);if(!r){t+=1;continue}if(Pu(r.form))return r.form;t=r.index}return null}function Zt(e,t){let r=Cn(e,t);if(e.startsWith("#?@",r)||e.startsWith("#?",r))return $u(e,r);if(e.startsWith("#_",r)){let i=Zt(e,r+2);return i?{form:{type:"atom",text:"",start:r,end:i.index},index:i.index}:null}for(;Sn(e[r]);)r+=1;let n=e[r];return n?n==="("?vn(e,r,"list",")"):n==="["?vn(e,r,"vector","]"):n==="{"?vn(e,r,"map","}"):n==='"'?{form:{type:"atom",text:"",start:r,end:ut(e,r,0).index},index:ut(e,r,0).index}:Gu(e,r):null}function $u(e,t){let r=e.startsWith("#?@",t)?3:2,n=Zt(e,t+r);return n?{form:{type:"list",children:n.form.type==="list"||n.form.type==="vector"||n.form.type==="map"?Wu(n.form.children):[],start:t,end:n.index},index:n.index}:null}function Wu(e){let t=[];for(let r=0;r<e.length;r+=2){let n=M(e[r]),i=e[r+1];n?.startsWith(":")&&i&&t.push(i)}return t}function vn(e,t,r,n){let i=[],o=t+1;for(;o<e.length;){if(o=Cn(e,o),e[o]===n)return{form:{type:r,children:i,start:t,end:o+1},index:o+1};let s=Zt(e,o);if(!s){o+=1;continue}s.form.type==="atom"&&s.form.text===""||i.push(s.form),o=s.index}return{form:{type:r,children:i,start:t,end:e.length},index:e.length}}function Gu(e,t){let r=t;for(;r<e.length&&!bn(e[r]);)r+=1;return{form:{type:"atom",text:e.slice(t,r),start:t,end:r},index:r}}function Cn(e,t){let r=t;for(;r<e.length;){let n=e[r];if(/\s|,/.test(n)){r+=1;continue}if(n===";"){r=Yt(e,r);continue}break}return r}function ts(e){return e.replace(/[^\r\n]/g," ")}function ns(e,t,r){let n=[];for(let i of r.matchAll(/^[ \t]*import\s+['"]([^'"]+)['"](?:\s+as\s+([A-Za-z_]\w*))?[\s\S]*?;$/gm)){let o=i[1]?.trim(),s=i[2]?.trim()??null,a=i[0];if(!o||!a||typeof i.index!="number")continue;let c=ce(r,i.index,i.index+a.length);n.push({importedName:o,localName:s,sourcePath:Vt(e,t,o),kind:s?"namespace":"side-effect",used:s?k(c,s):!0,usedMembers:s?Oe(c,s):[]})}return n}function is(e,t,r){let n=[];for(let i of r.matchAll(/^[ \t]*export\s+['"]([^'"]+)['"][\s\S]*?;$/gm)){let o=i[1]?.trim();o&&n.push({specifier:o,sourcePath:Vt(e,t,o)})}return n}function os(e,t,r){return Xt(e,t,{csharp:n=>Vu(e,t,n),vb:n=>Uu(e,t,n)},()=>{let n=ko(t)?/^[ \t]*Imports\s+(.+?)\s*$/gm:/^[ \t]*using\s+(.+?)\s*;$/gm;return O(r,n,(i,o)=>{let s=i[1]?.trim();if(!s)return[];let[a,c]=s.split(/\s*=\s*/),l=!!c,p=(l?c:a)?.trim()??s,u=p.split(".").pop()??p,d=l?a?.trim()??u:u;return[G(e,t,o,p,u,d,y(e,p,oe))]})})}function Uu(e,t,r){let n=S(r,new Set(["imports_statement"])),i=[];for(let o of r.rootNode.descendantsOfType("imports_statement")){let s=o.namedChildren.filter(d=>d.type==="namespace_name");if(s.length===0)continue;let a=s[s.length-1],c=s.length>1?s[0]:null,l=a.text,p=l.split(".").pop()??l,u=c?.text??p;i.push(g(p,u,y(e,l,oe),n,c?"namespace":"named"))}return i}function Vu(e,t,r){let n=S(r,new Set(["using_directive"])),i=[];for(let o of r.rootNode.descendantsOfType("using_directive")){let s=o.namedChildren;if(s.length===0)continue;let a=null,c;s.length>=2&&s[0].type==="identifier"&&(s[1].type==="qualified_name"||s[1].type==="identifier")?(a=s[0],c=s[1]):c=s[s.length-1];let l=c.text,p=l.split(".").pop()??l,u=a?.text??p;i.push(g(p,u,y(e,l,oe),n,a?"namespace":"named"))}return i}var Bu=x("vue-non-script-identifiers",{clearGroups:["whole-project","source-file"]});function ss(e,t){return Bu.get(e,t,()=>{let r=new Set,n=_(e,t);if(!n)return r;let o=n.replace(/<script\b[^>]*>[\s\S]*?<\/script>/g,s=>s.replace(/[^\r\n]/g," ")).replace(/<!--[\s\S]*?-->/g,s=>s.replace(/[^\r\n]/g," ")).replace(/\/\*[\s\S]*?\*\//g,s=>s.replace(/[^\r\n]/g," "));for(let s of o.matchAll(/[A-Za-z_$][\w$]*/g))r.add(s[0]);return r})}function kn(e,t,r){return L(e,t,n=>qu(e,t,n),()=>Hu(e,t,r))}function Hu(e,t,r){return nd(r).flatMap(n=>id(e,t,n.clause,n.specifier,n.start,n.end,r))}function qu(e,t,r){let n=zu(e,t,r),i=[];for(let o of r.rootNode.descendantsOfType("import_statement"))i.push(...Ju(e,t,r,o,n));return i}function zu(e,t,r){let n=S(r,new Set(["import_statement"]));if(xe(t))for(let i of ss(e,t))n.add(i);return n}function Ju(e,t,r,n,i){let o=Zu(n);if(!o)return[];let s=se(e,t,o),a=D(n,"import_clause");return a?Ku(r,a,s,i,ed(n.text)):[Ie("*",s)]}function Ku(e,t,r,n,i){let o=[];for(let s of t.namedChildren)if(s.type==="identifier")o.push(Yu(s.text,r,n,i));else if(s.type==="namespace_import"){let a=Xu(e,s,r,n,i);a&&o.push(a)}else s.type==="named_imports"&&o.push(...Qu(s,r,n,i));return o}function Yu(e,t,r,n){return g("default",e,t,r,"default",{isTypeOnly:n})}function Xu(e,t,r,n,i){let s=D(t,"identifier")?.text??"";if(!s)return null;let a=rd(e,s);return Ee("*",r,{localName:s,usedMembers:a,isTypeOnly:i,used:a.length>0||n.has(s)})}function Qu(e,t,r,n){let i=[];for(let o of e.namedChildren){if(o.type!=="import_specifier")continue;let s=o.namedChild(0),a=o.namedChild(1);if(!s)continue;let c=s.text,l=a?.text??c;i.push(g(c,l,t,r,"named",{isTypeOnly:n||td(o.text)}))}return i}function Zu(e){let t=D(e,"string");if(!t)return null;let r=D(t,"string_fragment");return r?r.text:null}function ed(e){return/^\s*import\s+type\b/.test(e)}function td(e){return/^\s*type\b/.test(e.trim())}function rd(e,t){let r=new Set;for(let n of e.rootNode.descendantsOfType("member_expression")){let i=n.namedChild(0),o=n.namedChild(1);!i||!o||i.type!=="identifier"||i.text!==t||(o.type==="property_identifier"||o.type==="identifier")&&r.add(o.text)}return[...r]}function nd(e){let t=[],r=/^[ \t]*import\s+([\s\S]*?)\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let i of e.matchAll(r)){let o=i[0],s=i[1],a=i[2];!o||!a||typeof i.index!="number"||t.push({clause:s,specifier:a,start:i.index,end:i.index+o.length})}let n=/^[ \t]*import\s+['"]([^'"]+)['"]\s*;?/gm;for(let i of e.matchAll(n)){let o=i[0],s=i[1];!o||!s||typeof i.index!="number"||t.push({clause:null,specifier:s,start:i.index,end:i.index+o.length})}return t.sort((i,o)=>i.start-o.start)}function id(e,t,r,n,i,o,s){let a=se(e,t,n),c=ce(s,i,o);return r?od(r).map(p=>({...p,sourcePath:a})).map(p=>{if(p.kind==="namespace"){let u=Oe(c,p.localName);return Ee(p.importedName,p.sourcePath,{localName:p.localName,usedMembers:u,used:u.length>0||k(c,p.localName),isTypeOnly:p.isTypeOnly})}return p.kind==="side-effect"?Ie(p.importedName,p.sourcePath):X(p.importedName,p.localName??"",p.sourcePath,p.localName?k(c,p.localName):!1,p.kind,[],{isTypeOnly:p.isTypeOnly})}):[Ie("*",a)]}function od(e){let t=e.trim(),r=/^type\b/.test(t),n=t.replace(/^type\s+/,""),[i,o]=sd(n),s=[];return i&&s.push(...as(i,r)),o&&s.push(...as(o,r)),s}function as(e,t){let r=e.trim();if(!r)return[];if(r.startsWith("{")){let n=r.slice(1,-1).trim();return n?T(n).map(i=>{let o=i.trim(),s=t||/^type\b/.test(o),a=o.replace(/^type\s+/,""),[c,l]=a.split(/\s+as\s+/);return{importedName:c.trim(),localName:(l??c).trim(),kind:"named",isTypeOnly:s}}):[]}return r.startsWith("* as ")?[{importedName:"*",localName:r.slice(5).trim(),kind:"namespace",isTypeOnly:t}]:[{importedName:"default",localName:r,kind:"default",isTypeOnly:t}]}function sd(e){let t=0;for(let r=0;r<e.length;r++){let n=e[r];if(n==="{"&&t++,n==="}"&&t--,n===","&&t===0)return[e.slice(0,r).trim(),e.slice(r+1).trim()]}return[e.trim(),null]}function Tn(e,t,r){let n=B(e,t);return n?dd(e,t,n):ad(e,t,r)}function ad(e,t,r){return[...cd(e,t,r),...ld(e,t,r),...pd(e,t,r)]}function cd(e,t,r){let n=[],i=/^[ \t]*export\s+(?:type\s+)?\{([\s\S]*?)\}\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let o of r.matchAll(i)){if(typeof o.index!="number")continue;let s=o[1]??"",a=o[2]??"",c=T(s).map(u=>ud(u.trim())).filter(u=>!!u),l=Le(r,o.index),p=Le(r,o.index+o[0].length-1);n.push({kind:"named",sourcePath:se(e,t,a),names:c,startLine:l,endLine:p})}return n}function ld(e,t,r){let n=[],i=/^[ \t]*export\s+\*\s+as\s+(\w+)\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let o of r.matchAll(i)){if(typeof o.index!="number")continue;let s=o[2]??"",a=Le(r,o.index),c=Le(r,o.index+o[0].length-1);n.push({kind:"star-as",sourcePath:se(e,t,s),names:[],startLine:a,endLine:c})}return n}function pd(e,t,r){let n=[],i=/^[ \t]*export\s+\*\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let o of r.matchAll(i)){if(typeof o.index!="number")continue;let s=o[1]??"",a=Le(r,o.index),c=Le(r,o.index+o[0].length-1);n.push({kind:"star",sourcePath:se(e,t,s),names:[],startLine:a,endLine:c})}return n}function ud(e){if(!e)return null;let t=e.replace(/^type\s+/,"").trim();if(!t)return null;let r=t.match(/^(\w+)\s+as\s+(\w+)$/);if(r)return r[2]??null;let n=t.match(/^(\w+)$/);return n?n[1]??null:null}function Le(e,t){let r=0;for(let n=0;n<t&&n<e.length;n++)e.charCodeAt(n)===10&&r++;return r}function dd(e,t,r){let n=[];for(let i of r.rootNode.descendantsOfType("export_statement")){let o=fd(e,t,i);if(o===void 0)continue;let s=i.startPosition.row,a=i.endPosition.row,c=md(i,o,s,a);n.push(c)}return n}function fd(e,t,r){let n=D(r,"string");if(!n)return;let i=D(n,"string_fragment");if(i)return se(e,t,i.text)}function md(e,t,r,n){let i=D(e,"export_clause");if(i){let s=[];for(let a of i.namedChildren){if(a.type!=="export_specifier")continue;let c=a.namedChild(0),l=a.namedChild(1);c&&s.push((l??c).text)}return{kind:"named",sourcePath:t,names:s,startLine:r,endLine:n}}return D(e,"namespace_export")?{kind:"star-as",sourcePath:t,names:[],startLine:r,endLine:n}:{kind:"star",sourcePath:t,names:[],startLine:r,endLine:n}}function cs(e,t,r){return Xt(e,t,{java:n=>gd(e,t,n),kotlin:n=>hd(e,t,n),scala:n=>yd(e,t,n)},()=>O(r,/^[ \t]*import\s+(?:static\s+)?(.+?)\s*;?$/gm,(n,i)=>{let o=n[1]?.trim();return o?Sd(e,t,o,i):[]}))}function gd(e,t,r){let n=S(r,new Set(["import_declaration"])),i=[];for(let o of r.rootNode.descendantsOfType("import_declaration")){let s=o.children.some(u=>u.type==="asterisk"),c=o.namedChildren.find(u=>u.type==="scoped_identifier")??o.namedChildren.find(u=>u.type==="identifier");if(!c)continue;let l=c.text;if(s){i.push(Ee("*",y(e,l,N)));continue}let p=l.split(".").pop()??l;i.push(g(p,p,y(e,l,N),n))}return i}function hd(e,t,r){let n=S(r,new Set(["import_header","import_list"])),i=[];for(let o of r.rootNode.descendantsOfType("import_header")){let s=o.namedChildren.find(m=>m.type==="identifier");if(!s)continue;let a=o.namedChildren.some(m=>m.type==="wildcard_import"),c=o.namedChildren.find(m=>m.type==="import_alias");if(a){i.push(Ee("*",y(e,s.text,N)));continue}let l=s.text,p=l.split(".").pop()??l,d=c?.namedChild(0)?.text??p;i.push(g(p,d,y(e,l,N),n))}return i}function yd(e,t,r){let n=S(r,new Set(["import_declaration"])),i=[];for(let o of r.rootNode.descendantsOfType("import_declaration")){let s=o.namedChildren.find(u=>u.type==="namespace_selectors"||u.type==="namespace_wildcard"),a=o.namedChildren.filter(u=>u!==s&&(u.type==="identifier"||u.type==="stable_identifier")),c=a.map(u=>u.text).join(".");if(!c)continue;if(s?.type==="namespace_wildcard"){i.push(Ee("*",y(e,c,N)));continue}if(s?.type==="namespace_selectors"){for(let u of s.namedChildren)if(u.type==="arrow_renamed_identifier"){let[d,m]=u.namedChildren;if(!d)continue;let h=d.text,we=m?.text??h;if(h==="_")continue;i.push(g(h,we,y(e,`${c}.${h}`,N),n))}else if(u.type==="identifier"){let d=u.text;i.push(g(d,d,y(e,`${c}.${d}`,N),n))}continue}let l=a[a.length-1]?.text??c,p=a.slice(0,-1).map(u=>u.text).join(".")||c;i.push(g(l,l,y(e,p&&a.length>1?`${p}.${l}`:c,N),n))}return i}function Sd(e,t,r,n){if(r.includes("{")&&r.includes("}")){let i=r.slice(0,r.indexOf("{")).replace(/\.$/,"").trim(),o=r.slice(r.indexOf("{")+1,r.lastIndexOf("}")).trim();return T(o).flatMap(s=>{let a=s.trim();if(!a)return[];let[c,l]=a.includes("=>")?a.split(/\s*=>\s*/):a.split(/\s+as\s+/),p=c?.trim();if(!p||p==="_")return[];let u=(l??p.split(".").pop()??p).trim(),d=p==="_"?i:`${i}.${p}`.replace(/\.\./g,".");return[G(e,t,n,d,p,u)]})}return[G(e,t,n,r,r.split(".").pop()??r,r.split(".").pop()??r)]}function ps(e,t,r){return L(e,t,n=>bd(e,t,n),()=>O(r,/^[ \t]*use\s+(.+?)\s*;$/gm,(n,i)=>{let o=n[1]?.trim();return o?T(o).flatMap(s=>{let a=s.trim();if(!a)return[];let[c,l]=a.split(/\s+as\s+/i),p=c?.trim()??a,u=p.split("\\").pop()??p,d=(l??u).trim();return[G(e,t,i,p,u,d,y(e,p.replace(/\\/g,"."),ye))]}):[]}))}function bd(e,t,r){let n=S(r,new Set(["namespace_use_declaration"])),i=[],o=(s,a,c)=>{i.push(g(a,c,y(e,s.replace(/\\/g,"."),ye),n))};for(let s of r.rootNode.descendantsOfType("namespace_use_declaration")){let a=s.namedChildren.find(c=>c.type==="namespace_use_group");if(a){let c=s.namedChildren.find(l=>l.type==="namespace_name")?.text??"";for(let l of a.namedChildren){if(l.type!=="namespace_use_clause")continue;let{importedName:p,localName:u,qualified:d}=ls(l,c);p&&o(d,p,u)}continue}for(let c of s.namedChildren){if(c.type!=="namespace_use_clause")continue;let{importedName:l,localName:p,qualified:u}=ls(c,"");l&&o(u,l,p)}}return i}function ls(e,t){let r=e.namedChildren.find(l=>l.type==="qualified_name"),n=e.namedChildren.filter(l=>l.type==="name"),i="";r?i=r.text:n.length>=1&&(i=n[0].text);let o=r&&n.length>0?n[n.length-1]:null,s=i.split("\\").pop()??i,a=o?.text??s,c=t?`${t}\\${i}`:i;return{importedName:s,localName:a,qualified:c}}function ds(e,t,r){return L(e,t,n=>xd(e,t,n),()=>Id(r).flatMap(n=>wd(e,t,n,r)))}function xd(e,t,r){let n=S(r,new Set(["import_statement","import_from_statement"])),i=[];for(let o of r.rootNode.descendantsOfType("import_statement"))for(let s of o.namedChildren){let a=us(s);if(!a)continue;let c=Fe(e,t,a.qualifiedName);i.push({importedName:a.qualifiedName,localName:a.localName,sourcePath:c,kind:"namespace",used:n.has(a.localName),usedMembers:[]})}for(let o of r.rootNode.descendantsOfType("import_from_statement")){let s=o.namedChild(0);if(!s)continue;let a=vd(s);if(a===null)continue;let c=Fe(e,t,a);for(let l=1;l<o.namedChildCount;l+=1){let p=o.namedChild(l);if(p.type==="wildcard_import"){i.push({importedName:"*",localName:null,sourcePath:c,kind:"side-effect",used:!0,usedMembers:[]});continue}let u=us(p);u&&i.push({importedName:u.qualifiedName,localName:u.localName,sourcePath:c,kind:"named",used:n.has(u.localName),usedMembers:[]})}}return i}function us(e){if(e.type==="aliased_import"){let t=e.namedChild(0),r=e.namedChild(1);return!t||!r?null:{qualifiedName:t.text,localName:r.text}}if(e.type==="dotted_name"){let t=e.text;return{qualifiedName:t,localName:t.split(".")[0]??t}}return e.type==="identifier"?{qualifiedName:e.text,localName:e.text}:null}function vd(e){if(e.type==="dotted_name")return e.text;if(e.type==="relative_import"){let t=D(e,"import_prefix")?.text??"",r=D(e,"dotted_name")?.text??"";return`${t}${r}`}return null}function Id(e){let t=e.split(`
|
|
119
|
-
`),r=[],n=0;for(let i=0;i<t.length;i++){let o=t[i],s=o.trimStart(),a=n;if(n+=o.length+1,!s.startsWith("import ")&&!s.startsWith("from "))continue;let c=o,l=a+o.length,p=fn(o);for(;i+1<t.length&&(p>0||c.trimEnd().endsWith("\\"));){i++;let d=t[i];c+=`
|
|
120
|
-
${d}`,l+=1+d.length,p+=fn(d),n+=d.length+1}let u=Ed(c);u&&r.push({...u,start:a,end:l})}return r}function Ed(e){let t=e.replace(/\\\s*\n/g," ").trim();if(t.startsWith("import "))return{kind:"import",module:null,clause:t.slice(7).trim()};let r=t.match(/^from\s+([.\w]+)\s+import\s+([\s\S]+)$/);if(!r)return null;let n=r[2].trim();return n.startsWith("(")&&n.endsWith(")")&&(n=n.slice(1,-1).trim()),{kind:"from",module:r[1],clause:n}}function wd(e,t,r,n){let i=ce(n,r.start,r.end),o=r.clause.replace(/\n/g," ").trim();if(r.kind==="import")return T(o).flatMap(c=>{let l=c.trim().replace(/,$/,"");if(!l)return[];let[p,u]=l.split(/\s+as\s+/),d=p.trim(),m=(u??d.split(".")[0]??d).trim(),h=Fe(e,t,d),we=Oe(i,m);return[{importedName:d,localName:m,sourcePath:h,kind:"namespace",used:k(i,m)||we.length>0,usedMembers:we}]});let s=r.module?Fe(e,t,r.module):null,a=[];for(let c of T(o)){let l=c.trim().replace(/,$/,"");if(!l)continue;if(l==="*"){a.push({importedName:"*",localName:null,sourcePath:s,kind:"side-effect",used:!0,usedMembers:[]});continue}let[p,u]=l.split(/\s+as\s+/),d=(u??p).trim();a.push({importedName:p.trim(),localName:d,sourcePath:s,kind:"named",used:k(i,d),usedMembers:[]})}return a}import{basename as Cd}from"path";function fs(e,t,r){return L(e,t,n=>Td(e,t,n),()=>kd(e,t,r))}function kd(e,t,r){return O(r,/^[ \t]*(require_relative|require)\s+["']([^"']+)["']\s*$/gm,(n,i)=>{let o=n[1],s=n[2];if(!o||!s)return[];let a=o==="require_relative"?Gt(e,t,s):null;if(a){let c=ms(s);return[X(c,c,a,k(i,c))]}return[Ie(s,a)]})}function Td(e,t,r){let n=S(r,new Set([])),i=[],o=new Set(["require","require_relative","load"]);for(let s of r.rootNode.descendantsOfType("call")){let a=s.namedChild(0);if(!a||a.type!=="identifier"||!o.has(a.text))continue;let l=s.namedChildren.find(m=>m.type==="argument_list")?.namedChild(0);if(!l||l.type!=="string")continue;let u=l.namedChildren.find(m=>m.type==="string_content")?.text;if(!u)continue;let d=a.text==="require_relative"?Gt(e,t,u):null;if(d){let m=ms(u);i.push(g(m,m,d,n))}else i.push(Ie(u,d))}return i}function ms(e){return Qo(Cd(e).replace(/\.[^.]+$/,""),/_/)}function gs(e,t,r){return L(e,t,n=>Pd(e,t,n),()=>O(r,/^[ \t]*use\s+(.+?)\s*;$/gm,(n,i)=>{let o=n[1]?.trim();return o?Rd(e,t,o,i):[]}))}function Pd(e,t,r){let n=S(r,new Set(["use_declaration"])),i=[];for(let o of r.rootNode.descendantsOfType("use_declaration")){let s=o.namedChild(0);if(s)for(let a of dt(s,"")){if(!a.importedName||a.importedName==="*")continue;let c=K(e,t,a.qualifiedName)??K(e,t,a.qualifiedName.split("::").slice(0,-1).join("::"));i.push(g(a.importedName,a.localName,c,n))}}return i}function dt(e,t){switch(e.type){case"identifier":case"super":case"crate":{let r=e.text;return[{qualifiedName:er(t,r),importedName:r,localName:r}]}case"self":{let r=t.split("::").filter(Boolean).pop()??"self";return[{qualifiedName:t||"self",importedName:r,localName:r}]}case"scoped_identifier":{let r=e.text,n=r.split("::").pop()??r;return[{qualifiedName:er(t,r),importedName:n,localName:n}]}case"scoped_use_list":{let r=e.namedChild(0),n=e.namedChild(1);if(!r||!n)return[];let i=er(t,r.text),o=[];for(let s of n.namedChildren)o.push(...dt(s,i));return o}case"use_list":{let r=[];for(let n of e.namedChildren)r.push(...dt(n,t));return r}case"use_as_clause":{let r=e.namedChild(0),n=e.namedChild(1);if(!r||!n)return[];let i=dt(r,t),o=n.text;return i.map(s=>({...s,localName:o}))}case"use_wildcard":{let r=e.namedChild(0),n=r?r.text:"";return[{qualifiedName:er(t,`${n}::*`),importedName:"*",localName:"*"}]}default:return[]}}function er(e,t){return e?t?`${e}::${t}`:e:t}function Rd(e,t,r,n){let i=r.trim();if(i.includes("{")&&i.includes("}")){let p=i.slice(0,i.indexOf("{")).replace(/::$/,"").trim(),u=i.slice(i.indexOf("{")+1,i.lastIndexOf("}")).trim();return T(u).flatMap(d=>{let m=d.trim();if(!m)return[];if(m==="self"){let tr=p.split("::").filter(Boolean).pop();return tr?[G(e,t,n,p,tr,tr)]:[]}let[h,we]=m.split(/\s+as\s+/),Ce=h?.trim();if(!Ce)return[];let xs=(we??Ce.split("::").pop()??Ce).trim(),vs=`${p}::${Ce}`.replace(/::::/g,"::");return[G(e,t,n,vs,Ce.split("::").pop()??Ce,xs,K(e,t,p))]})}let[o,s]=i.split(/\s+as\s+/),a=o?.trim()??i,c=(s??a.split("::").pop()??a).trim(),l=K(e,t,a)??K(e,t,a.split("::").slice(0,-1).join("::"));return[G(e,t,n,a,a.split("::").pop()??a,c,l)]}function hs(e,t,r){let n=B(e,t);if(n)return Nd(e,t,n);let i=[];for(let o of r.matchAll(/^[ \t]*pub\s+use\s+(.+?)\s*;$/gm)){let s=o[1]?.trim();s&&i.push(...Dd(e,t,s))}return i}function Nd(e,t,r){let n=[];for(let i of r.rootNode.descendantsOfType("use_declaration")){if(!_d(i))continue;let o=i.namedChildren.find(s=>s.type!=="visibility_modifier");if(o)for(let s of dt(o,""))s.importedName&&n.push(Pn(e,t,s.qualifiedName))}return n}function _d(e){for(let t of e.children)if(t.type==="visibility_modifier"&&t.text.startsWith("pub"))return!0;return!1}function Dd(e,t,r){let n=r.trim();if(n.includes("{")&&n.includes("}")){let i=n.slice(0,n.indexOf("{")).replace(/::$/,"").trim(),o=n.slice(n.indexOf("{")+1,n.lastIndexOf("}")).trim();return T(o).flatMap(s=>{let a=s.trim();if(!a||a==="self")return[];let[c]=a.split(/\s+as\s+/),l=`${i}::${c?.trim()??a}`.replace(/::::/g,"::");return[Pn(e,t,l)]})}return[Pn(e,t,n)]}function Pn(e,t,r){return{specifier:r,sourcePath:K(e,t,r)??K(e,t,r.split("::").slice(0,-1).join("::"))}}function le({language:e,extensions:t,imports:r,parseImports:n}){return{language:e,extensions:t,capabilities:{imports:r},parseImports:n}}function ys(e,t){let r=t.toLowerCase();for(let n of e)for(let i of n.extensions)if(r.endsWith(i))return n;return null}var Ad={language:"javascript",extensions:ge,capabilities:{imports:"ast-with-regex-fallback",reExports:"ast-with-regex-fallback"},parseImports:kn,parseReExports:Tn},jd=le({language:"python",extensions:Ot,imports:"ast-with-regex-fallback",parseImports:ds}),Fd=le({language:"jvm",extensions:N,imports:"ast-dispatch-with-regex-fallback",parseImports:cs}),Od={language:"rust",extensions:Lt,capabilities:{imports:"ast-with-regex-fallback",exports:"ast-with-regex-fallback"},parseImports:gs,parseExports:hs},Ld=le({language:"ruby",extensions:Mt,imports:"ast-with-regex-fallback",parseImports:fs}),Md=le({language:"c/cpp",extensions:$t,imports:"ast-with-regex-fallback",parseImports:es}),$d=le({language:"dotnet",extensions:oe,imports:"ast-dispatch-with-regex-fallback",parseImports:os}),Wd={language:"dart",extensions:Wt,capabilities:{imports:"regex-only",exports:"regex-only"},parseImports:ns,parseExports:is},Gd=le({language:"php",extensions:ye,imports:"ast-with-regex-fallback",parseImports:ps}),Ud=le({language:"clojure",extensions:je,imports:"regex-only",parseImports:rs}),Vd=[Ad,jd,Fd,Od,Ld,Md,$d,Wd,Gd,Ud];function Rn(e){return ys(Vd,e)}var Nn={clearGroups:["whole-project","source-file"]},Bd=x("source-imports",Nn),VS=x("source-exports",Nn),Hd=x("source-reexports",Nn),Ss=it({kind:"source-imports",invalidation:ot("source-imports"),serialize:qd,deserialize:zd}),bs=it({kind:"source-reexports",invalidation:ot("source-reexports"),serialize:Jd,deserialize:Kd});function BS(e,t){let r=C(t);return Hd.get(e,r,()=>{let n=Rn(r);if(!n?.parseReExports)return[];let i=_(e,r);if(!i)return[];let o=We(e,r,i),s=dn(e),a=bs.read(e,r,o);if(a?.resolutionFingerprint===s)return a.reExports;let c=n.parseReExports(e,r,i);return bs.write(e,r,o,{resolutionFingerprint:s,reExports:c}),c})}function HS(e,t){let r=C(t);return Bd.get(e,r,()=>{let n=Rn(r);if(!n)return[];let i=_(e,r);if(!i)return[];let o=We(e,r,i),s=dn(e),a=Ss.read(e,r,o);if(a?.resolutionFingerprint===s)return a.imports;let c=n.parseImports(e,r,i);return Ss.write(e,r,o,{resolutionFingerprint:s,imports:c}),c})}function qd(e){return JSON.stringify(e)}function zd(e){try{let t=JSON.parse(e);return!Re(t)||typeof t.resolutionFingerprint!="string"||!Array.isArray(t.imports)?null:{resolutionFingerprint:t.resolutionFingerprint,imports:t.imports}}catch{return null}}function Jd(e){return JSON.stringify(e)}function Kd(e){try{let t=JSON.parse(e);return!Re(t)||typeof t.resolutionFingerprint!="string"||!Array.isArray(t.reExports)?null:{resolutionFingerprint:t.resolutionFingerprint,reExports:t.reExports}}catch{return null}}export{Ln as a,js as b,ef as c,mt as d,U as e,Yn as f,Sr as g,Zn as h,bt as i,We as j,ti as k,Xf as l,it as m,Wg as n,ot as o,_ as p,gh as q,B as r,hu as s,Eu as t,Vg as u,bo as v,$l as w,se as x,Re as y,Er as z,Se as A,BS as B,HS as C,uf as D,df as E,Ks as F,ff as G,mf as H,Ys as I,gf as J,hf as K,yf as L,Sf as M,kl as N,Hg as O,Pl as P,Jg as Q,Kg as R,Yg as S,Qg as T,rm as U,nm as V,Ba as W,im as X,lm as Y,mm as Z,xm as _,vm as $,Pf as aa,Rf as ba,Un as ca,gr as da,yr as ea,Nf as fa,_m as ga,Dm as ha,Am as ia,jm as ja,Gm as ka,Um as la,Vm as ma,Bm as na,Vi as oa,Ym as pa,$r as qa,Eg as ra,wg as sa,Cg as ta,Ze as ua,kg as va,Tg as wa,Pg as xa,ol as ya,sl as za,Ag as Aa,jg as Ba,va as Ca,Ff as Da,Of as Ea,Lf as Fa};
|
|
121
|
-
//# sourceMappingURL=chunk-SALRDXWM.js.map
|
package/dist/chunk-SMBIGBGN.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import{execFileSync as F}from"child_process";import{createHash as m}from"crypto";import{lstatSync as k,readdirSync as V,readFileSync as w,readlinkSync as I,realpathSync as b}from"fs";import{isAbsolute as A,join as y,relative as _,sep as L}from"path";function se(e,t){let r=e.split("/").at(-1)??e;if(j.has(r)||r===".scipquery.json"||/^tsconfig(?:\..+)?\.json$/.test(r))return"config";if(/\.d\.(?:ts|mts|cts)$/.test(e.toLowerCase()))return"ambient";let s=e.includes(".")?`.${e.split(".").at(-1).toLowerCase()}`:"";return t.some(n=>(P[n]??[]).includes(s))?"source":"other"}function O(e){return[...new Set((e??[]).map(t=>t.trim()).filter(Boolean))].sort((t,r)=>t.localeCompare(r))}function E(e){return(T(e)??W(e)).filter(t=>t&&!S(t)).sort()}function G(e,t={}){let r=E(e).filter(n=>!t.language||M(n,t.language,t.markerFiles)).filter(n=>!t.includePath||t.includePath(n)),s=b(e);return r.map(n=>{let i=y(e,n);try{if(k(i).isSymbolicLink()){let o=b(i),c=_(s,o);if(c===".."||c.startsWith(`..${L}`)||A(c))throw new Error("external symlink");let l=I(i);return{path:n,size:Buffer.byteLength(l),hash:m("sha256").update("symlink\0").update(l).digest("hex")}}let a=w(i);return{path:n,size:a.byteLength,hash:m("sha256").update(a).digest("hex")}}catch{return{path:n,size:-1,hash:"unreadable"}}})}function ae(e,t,r){return{version:2,languages:[...t].sort(),pnpmWorkspaces:r.typescriptProjectMode!=="workspace"&&r.pnpmWorkspaces===!0,typescriptProjectMode:r.typescriptProjectMode??"single",typescriptProjects:O(r.typescriptProjects),clojureConfigPath:$(r.clojureConfigPath),files:G(e)}}function $(e){return e?.trim()||void 0}function M(e,t,r){let s=e.split("/").at(-1)??e;if(r?.includes(e)||r?.includes(s)||j.has(s))return!0;let n=e.includes(".")?`.${e.split(".").at(-1).toLowerCase()}`:"";return(P[t]??[]).includes(n)}function T(e){try{return F("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:50*1024*1024,stdio:["ignore","pipe","ignore"]}).split(`
|
|
2
|
-
`).filter(Boolean)}catch{return null}}function W(e){let t=[],r=[""];for(;r.length>0;){let s=r.pop(),n=s?y(e,s):e,i;try{i=V(n,{withFileTypes:!0})}catch{continue}for(let a of i){let o=s?`${s}/${a.name}`:a.name;if(a.isDirectory()){S(o)||r.push(o);continue}t.push(o)}}return t}function S(e){let t=e.split("/");return e==="meta.json"||t.some(r=>K.has(r))||e.endsWith(".db")||e.endsWith(".db-wal")||e.endsWith(".db-shm")||e.endsWith(".scip")}var K=new Set([".git","node_modules",".scipquery-cache",".scipquery-generations",".stryker-tmp","dist","build","coverage",".next",".nuxt","target"]),j=new Set(["package.json","package-lock.json","pnpm-lock.yaml","yarn.lock","bun.lockb","tsconfig.json","tsconfig.base.json","pyproject.toml","setup.py","setup.cfg","Cargo.toml","Cargo.lock","go.mod","go.sum","pom.xml","build.gradle","build.gradle.kts","build.sbt","compile_commands.json","CMakeLists.txt","Makefile","Gemfile","Gemfile.lock","composer.json","composer.lock","pubspec.yaml","pubspec.lock","deps.edn","project.clj","bb.edn","shadow-cljs.edn"]),P={typescript:[".ts",".tsx",".mts",".cts"],javascript:[".js",".jsx",".mjs",".cjs"],java:[".java"],scala:[".scala"],kotlin:[".kt",".kts"],rust:[".rs"],python:[".py",".pyi"],ruby:[".rb"],go:[".go"],cpp:[".cc",".cpp",".cxx",".hpp",".hh",".hxx"],c:[".c",".h"],csharp:[".cs"],vb:[".vb"],dart:[".dart"],php:[".php"],clojure:[".clj",".cljs",".cljc"]};import z from"ignore";import{readFileSync as N,existsSync as C,readdirSync as R}from"fs";import{dirname as g,isAbsolute as x,join as u,relative as B,resolve as q}from"path";function ue(e){let t=z();return U(e,t)||t.add(X),{isIgnored:s=>f(t,e,s),filter:s=>s.filter(n=>!f(t,e,n))}}function U(e,t){let r=new Set,s=(a,o)=>{if(!(r.has(a)||!C(a)))try{let c=N(a,"utf-8");t.add(o?H(c,o):c),r.add(a)}catch{}},n=g(e),i=0;for(;n!==g(n)&&i<5&&(s(u(n,".gitignore"),""),!C(u(n,".git")));)n=g(n),i++;return D(e,"",t,s),r.size>0}function D(e,t,r,s){let n=t?u(e,t):e;s(u(n,".gitignore"),t);let i;try{i=R(n,{withFileTypes:!0})}catch{return}for(let a of i){if(!a.isDirectory()||a.name===".git")continue;let o=t?`${t}/${a.name}`:a.name;f(r,e,`${o}/`)||D(e,o,r,s)}}function H(e,t){let r=t.replaceAll("\\","/").replace(/\/+$/,"");return e.split(/\r?\n/).map(s=>J(s,r)).join(`
|
|
3
|
-
`)}function J(e,t){let r=e.trimStart();if(!r||r.startsWith("#"))return e;let s=e.slice(0,e.length-r.length),n=r.startsWith("!"),i=n?r.slice(1):r;if(!i||i.startsWith("#"))return e;let a=i.startsWith("/"),o=a?i.slice(1):i,p=(o.endsWith("/")?o.slice(0,-1):o).includes("/")||a?`${t}/${o}`:`${t}/**/${o}`;return`${s}${n?"!":""}${p}`}var X=`
|
|
4
|
-
# Dependencies
|
|
5
|
-
node_modules/
|
|
6
|
-
vendor/
|
|
7
|
-
.bundle/
|
|
8
|
-
|
|
9
|
-
# Build output
|
|
10
|
-
dist/
|
|
11
|
-
build/
|
|
12
|
-
out/
|
|
13
|
-
target/
|
|
14
|
-
bin/
|
|
15
|
-
obj/
|
|
16
|
-
|
|
17
|
-
# Python
|
|
18
|
-
__pycache__/
|
|
19
|
-
*.pyc
|
|
20
|
-
*.pyo
|
|
21
|
-
.venv/
|
|
22
|
-
venv/
|
|
23
|
-
.env/
|
|
24
|
-
env/
|
|
25
|
-
*.egg-info/
|
|
26
|
-
|
|
27
|
-
# Rust
|
|
28
|
-
target/
|
|
29
|
-
|
|
30
|
-
# Java / Kotlin / Scala
|
|
31
|
-
*.class
|
|
32
|
-
.gradle/
|
|
33
|
-
.mvn/
|
|
34
|
-
|
|
35
|
-
# C# / .NET
|
|
36
|
-
bin/
|
|
37
|
-
obj/
|
|
38
|
-
packages/
|
|
39
|
-
|
|
40
|
-
# Go
|
|
41
|
-
vendor/
|
|
42
|
-
|
|
43
|
-
# Dart
|
|
44
|
-
.dart_tool/
|
|
45
|
-
build/
|
|
46
|
-
|
|
47
|
-
# PHP
|
|
48
|
-
vendor/
|
|
49
|
-
|
|
50
|
-
# IDE / OS
|
|
51
|
-
.idea/
|
|
52
|
-
.vscode/
|
|
53
|
-
*.swp
|
|
54
|
-
*.swo
|
|
55
|
-
.DS_Store
|
|
56
|
-
Thumbs.db
|
|
57
|
-
|
|
58
|
-
# Type definitions (often noise in queries)
|
|
59
|
-
*.d.ts
|
|
60
|
-
`;function f(e,t,r){let s=Y(t,r);if(!s)return!1;try{return e.ignores(s)}catch{return!1}}function Y(e,t){if(!t||t===".")return null;if(!x(t)&&!t.startsWith(".."))return t.replaceAll("\\","/");let r=x(t)?t:q(e,t),s=B(e,r).replaceAll("\\","/");return!s||s==="."||s.startsWith("..")?null:s}var Q=[];function d(e){e.groups.length>0&&Q.push(e)}function v(){let e=new WeakMap;return{cache:e,ensure(t){let r=e.get(t);return r||(r=new Map,e.set(t,r)),r}}}function he(e,t){let{cache:r,ensure:s}=v(),n={get(i,a,o){let c=s(i);if(c.has(a))return c.get(a);let l=o();return c.set(a,l),l},invalidate(i,a){r.get(i)?.delete(a)},invalidateAll(i){r.delete(i)},size(i){return r.get(i)?.size??0}};return d({name:e,groups:t.clearGroups,clearAll:i=>n.invalidateAll(i),clearFile:(i,a)=>n.invalidate(i,a)}),n}function me(e,t){let r=new WeakMap,s={get(n,i){let a=r.get(n);if(a)return a.value;let o=i();return r.set(n,{value:o}),o},invalidate(n){r.delete(n)},has(n){return r.has(n)}};return d({name:e,groups:t.clearGroups,clearAll:n=>s.invalidate(n)}),s}var Z={clearGroups:["whole-project","source-file"]};function be(e){return ee(e,Z)}function ee(e,t){let{cache:r,ensure:s}=v(),n={get(i,a,o,c){let l=s(i),p=l.get(a);if(p&&p.source===o)return p.value;let h=c();return l.set(a,{source:o,value:h}),h},invalidate(i,a){r.get(i)?.delete(a)},invalidateAll(i){r.delete(i)}};return d({name:e,groups:t.clearGroups,clearAll:i=>n.invalidateAll(i),clearFile:(i,a)=>n.invalidate(i,a)}),n}function Se(e,t={}){let r=t.scope?"AND relative_path LIKE ?":"",s=t.like?"AND relative_path LIKE ?":"",n=[...t.scope?[`%${t.scope}%`]:[],...t.like?[t.like]:[]],i=e.all(`SELECT relative_path
|
|
61
|
-
FROM documents
|
|
62
|
-
WHERE 1 = 1
|
|
63
|
-
${e.pathExclusionsFor("documents")}
|
|
64
|
-
${r}
|
|
65
|
-
${s}
|
|
66
|
-
ORDER BY relative_path`,...n).map(o=>o.relative_path),a=t.extensions?i.filter(o=>t.extensions.some(c=>o.toLowerCase().endsWith(c.toLowerCase()))):i;return t.includeIgnored===!1?a.filter(o=>!e.isIgnored(o)):a}export{d as a,he as b,me as c,be as d,ee as e,Se as f,se as g,O as h,G as i,ae as j,ue as k};
|
|
67
|
-
//# sourceMappingURL=chunk-SMBIGBGN.js.map
|