scip-query 0.19.8 → 0.20.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 +97 -0
- package/README.md +158 -48
- package/dist/augment-vue-worker.js +1 -1
- package/dist/chunk-26QA6FAI.js +8 -0
- package/dist/{chunk-KJ2IIBZN.js → chunk-2HPVVXM5.js} +2 -2
- package/dist/chunk-2KAZEZ6M.js +2 -0
- package/dist/chunk-32LVLCLN.js +40 -0
- package/dist/{chunk-24GTWJ3N.js → chunk-3CLX5EOX.js} +2 -2
- package/dist/{chunk-QGGLL3UH.js → chunk-3G66UZBH.js} +2 -2
- package/dist/{chunk-AA4UWRNL.js → chunk-3ORVDL3H.js} +2 -2
- package/dist/chunk-4MAK2HOY.js +6 -0
- package/dist/{chunk-QIQ63BHW.js → chunk-4TURLRL5.js} +2 -2
- package/dist/chunk-4UQVNCQE.js +2 -0
- package/dist/chunk-55Q3WLZX.js +2 -0
- package/dist/{chunk-CTF2GDEX.js → chunk-5E4WNAVD.js} +2 -2
- package/dist/{chunk-ZCEJ63SP.js → chunk-5I5G2QOX.js} +2 -2
- package/dist/chunk-6LDJQXAH.js +2 -0
- package/dist/{chunk-3EDFLQ6A.js → chunk-6O5TICIZ.js} +2 -2
- package/dist/{chunk-ACAM6O5R.js → chunk-6SHPK5ZE.js} +2 -2
- package/dist/chunk-7BAVHKMJ.js +49 -0
- package/dist/chunk-7O5IKBTZ.js +16 -0
- package/dist/{chunk-WJL2L6MV.js → chunk-7PIO7NKH.js} +2 -2
- package/dist/chunk-7S5E7KWT.js +2 -0
- package/dist/{chunk-YLFORA5G.js → chunk-7SQQWSY3.js} +2 -2
- package/dist/chunk-7WPLAODU.js +5 -0
- package/dist/chunk-A73XVBCR.js +20 -0
- package/dist/chunk-AFHORGLH.js +42 -0
- package/dist/chunk-AIE7TFJW.js +9 -0
- package/dist/{chunk-TWMJ3Y3G.js → chunk-AZJQQKDD.js} +2 -2
- package/dist/{chunk-BDOIKGDI.js → chunk-B2PX5I6M.js} +2 -2
- package/dist/{chunk-DQBCO2UY.js → chunk-B7PBSLZN.js} +2 -2
- package/dist/chunk-BBW6JFHN.js +2 -0
- package/dist/{chunk-YTVWB7YJ.js → chunk-BDCC2NPY.js} +2 -2
- package/dist/{chunk-O23I56NA.js → chunk-BNXCIFVY.js} +2 -2
- package/dist/{chunk-MLFZP76A.js → chunk-BPAPWKP6.js} +2 -2
- package/dist/chunk-BS2NMXQZ.js +4 -0
- package/dist/chunk-C3KV2II6.js +2 -0
- package/dist/chunk-C43RDDP4.js +20 -0
- package/dist/{chunk-K2WO7XY7.js → chunk-CJST5ETY.js} +2 -2
- package/dist/chunk-DAFAHMNB.js +42 -0
- package/dist/{chunk-KKME5ZAI.js → chunk-DQGFVPUV.js} +2 -2
- package/dist/chunk-DQLPXMH6.js +8 -0
- package/dist/chunk-EKZTZXHZ.js +117 -0
- package/dist/{chunk-FJ5UDTQF.js → chunk-EN3O7VJA.js} +2 -2
- package/dist/{chunk-HZYDQPNY.js → chunk-EW2NTSFA.js} +2 -2
- package/dist/chunk-F3Z4OUDS.js +8 -0
- package/dist/chunk-FJH2NW7J.js +66 -0
- package/dist/{chunk-MSBDMFER.js → chunk-FKSELJQF.js} +2 -2
- package/dist/chunk-FTFP6O3L.js +11 -0
- package/dist/chunk-FYLK2DEJ.js +2 -0
- package/dist/{chunk-WUW7YUAH.js → chunk-GH74ASD6.js} +2 -2
- package/dist/{chunk-464PLI5O.js → chunk-GMXWZP2B.js} +2 -2
- package/dist/chunk-GOUBFH5O.js +3 -0
- package/dist/{chunk-FIJCV235.js → chunk-HLF2TX6R.js} +2 -2
- package/dist/{chunk-WWKWUPSU.js → chunk-HX4GQPZP.js} +2 -2
- package/dist/chunk-HX7M4BDI.js +30 -0
- package/dist/chunk-HZ72SESS.js +128 -0
- package/dist/{chunk-SERUIGV5.js → chunk-IB2N4FIY.js} +2 -2
- package/dist/chunk-ILMHV3KM.js +2 -0
- package/dist/chunk-IZYYAFN5.js +2 -0
- package/dist/{chunk-GNC4JVAN.js → chunk-JAYYFEQY.js} +2 -2
- package/dist/{chunk-QJIVBYEK.js → chunk-JDOEX4E6.js} +2 -2
- package/dist/chunk-JFGGXWQF.js +947 -0
- package/dist/chunk-JN4NMBEX.js +8 -0
- package/dist/{chunk-6M7RONVB.js → chunk-JVYA47YU.js} +2 -2
- package/dist/{chunk-7KYNAMMH.js → chunk-JW56N3KI.js} +2 -2
- package/dist/{chunk-OUBAF226.js → chunk-JZ2OXNWB.js} +2 -2
- package/dist/chunk-KMKTIO2G.js +8 -0
- package/dist/chunk-L5GJNV2T.js +8 -0
- package/dist/{chunk-MNSTUIDD.js → chunk-L7AW2QB5.js} +2 -2
- package/dist/chunk-L7JDSCDF.js +4 -0
- package/dist/chunk-LU47HG23.js +14 -0
- package/dist/chunk-LVY7NPF7.js +2 -0
- package/dist/chunk-LY4WC4AD.js +74 -0
- package/dist/{chunk-7FT5Y65S.js → chunk-MKCDWWGV.js} +2 -2
- package/dist/chunk-MNE7YG56.js +2 -0
- package/dist/{chunk-7QHY3H7P.js → chunk-MRXBEXSY.js} +2 -2
- package/dist/chunk-MV7OWDUX.js +2 -0
- package/dist/{chunk-ZJ5CBXK3.js → chunk-N5W4YZMK.js} +2 -2
- package/dist/chunk-NGEXCJJW.js +11 -0
- package/dist/{chunk-7SWJEWJF.js → chunk-NIW6JDC5.js} +2 -2
- package/dist/{chunk-O3O4XXO6.js → chunk-O64IZ6UX.js} +2 -2
- package/dist/{chunk-3ZSJ3PWF.js → chunk-PBUQFCNB.js} +2 -2
- package/dist/{chunk-7RAG65VK.js → chunk-POAVPHH7.js} +2 -2
- package/dist/{chunk-A3QXWFBK.js → chunk-PQCI4SQX.js} +2 -2
- package/dist/{chunk-4BV4QAZJ.js → chunk-PXY7F6Y4.js} +2 -2
- package/dist/chunk-RDO52JGY.js +2 -0
- package/dist/chunk-RJT3TUUZ.js +2 -0
- package/dist/{chunk-S4S2WOIX.js → chunk-RUJURYSV.js} +2 -2
- package/dist/{chunk-JAY7YWS3.js → chunk-RVLDN63O.js} +2 -2
- package/dist/chunk-RXOXSKY3.js +2 -0
- package/dist/chunk-S7OYBOCK.js +2 -0
- package/dist/chunk-SMNXQT5Z.js +3 -0
- package/dist/{chunk-NE3TZUCI.js → chunk-SRAFT254.js} +2 -2
- package/dist/{chunk-ELLMY7XJ.js → chunk-SXP2MBJH.js} +2 -2
- package/dist/chunk-T7YQSHPQ.js +3 -0
- package/dist/{chunk-WY45BHKQ.js → chunk-TFRAYKN6.js} +2 -2
- package/dist/{chunk-2SNGN6U4.js → chunk-UJCOIXDY.js} +2 -2
- package/dist/{chunk-MZZBAITE.js → chunk-UJPRPGCO.js} +2 -2
- package/dist/chunk-W4ETQAXM.js +2 -0
- package/dist/chunk-WCCFZ7V7.js +113 -0
- package/dist/chunk-WUPW3UN3.js +3 -0
- package/dist/{chunk-7LSVMFX7.js → chunk-WXZLAAWK.js} +2 -2
- package/dist/{chunk-5ML2BNRH.js → chunk-X54AGLVX.js} +2 -2
- package/dist/chunk-XKWKXZKW.js +20 -0
- package/dist/{chunk-5YLUDDAF.js → chunk-XSRF6Q77.js} +2 -2
- package/dist/chunk-Y2MVPNKY.js +5 -0
- package/dist/{chunk-JHF3E4YM.js → chunk-YKUU5AIC.js} +2 -2
- package/dist/{chunk-E3HYEQO7.js → chunk-YLCJLTPL.js} +2 -2
- package/dist/{chunk-7VCOXZH3.js → chunk-YTQVETEO.js} +2 -2
- package/dist/chunk-Z4N3MZYA.js +38 -0
- package/dist/chunk-ZHXX42OH.js +18 -0
- package/dist/chunk-ZJOOT3BG.js +2 -0
- package/dist/{chunk-P3UO3EH3.js → chunk-ZK26BAQL.js} +2 -2
- package/dist/{chunk-33KUO7CG.js → chunk-ZTETIQ35.js} +2 -2
- package/dist/cli.js +3 -8
- package/dist/command-descriptors-DSS46KXI.js +642 -0
- package/dist/{config-types-B6MEoRNy.d.ts → config-types-jVM3D7MA.d.ts} +68 -2
- package/dist/{db-DYLKr9Wn.d.ts → db-B5PM5yNk.d.ts} +20 -2
- package/dist/{diff-gate-types-C9BoYwYD.d.ts → diff-gate-types-B0QYpDv1.d.ts} +2 -1
- package/dist/direct-navigation-6YHV6IB5.js +3 -0
- package/dist/{health-DgxIDXJC.d.ts → health-Do5TKSJI.d.ts} +1 -1
- package/dist/index.d.ts +3 -3
- 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 +2 -2
- package/dist/queries/architecture.js +1 -1
- 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 +22 -3
- 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 +3 -3
- package/dist/queries/complexity-hotspots.js +1 -1
- package/dist/queries/complexity.d.ts +3 -3
- 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 +40 -7
- package/dist/queries/diff-gate.js +1 -1
- package/dist/queries/diff-impact.d.ts +84 -6
- package/dist/queries/diff-impact.js +1 -1
- package/dist/queries/doc-drift.d.ts +3 -3
- package/dist/queries/doc-drift.js +1 -1
- package/dist/queries/drift.d.ts +2 -2
- package/dist/queries/drift.js +1 -1
- package/dist/queries/duplicate-bodies.d.ts +3 -3
- 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 +12 -3
- package/dist/queries/files.js +1 -1
- 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 +8 -6
- package/dist/queries/incomplete-migration.js +1 -1
- package/dist/queries/index.d.ts +141 -10
- 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 +34 -3
- 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 +3 -3
- package/dist/queries/passthrough-candidates.js +1 -1
- package/dist/queries/plan-context.d.ts +3 -3
- 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 +14 -3
- 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 +21 -21
- package/dist/reindex.d.ts +3 -3
- package/dist/reindex.js +33 -33
- package/dist/runtime.d.ts +5 -3
- package/dist/runtime.js +3 -3
- package/dist/rust-semantic-session-server.js +1 -1
- package/dist/rust-semantic-session-worker.js +1 -1
- package/dist/rust-semantic-worker.js +1 -1
- package/dist/{scip-cli-Cc6c00-a.d.ts → scip-cli-BnEwZRLJ.d.ts} +1 -1
- package/dist/{symbol-types-BgWU6lhL.d.ts → symbol-types-BIQwfoAx.d.ts} +7 -1
- package/dist/typescript-mailbox-worker.js +2 -0
- package/dist/watch-server.js +2 -42
- package/docs/AGENT_GUIDE.md +13 -6
- package/docs/CLI_JSON_OUTPUT.md +110 -22
- package/docs/COMMAND_REFERENCE.md +88 -88
- package/docs/COMMITTED_RECORD_COMPATIBILITY.md +55 -18
- package/docs/DURABILITY.md +88 -38
- package/docs/INDEX_GENERATIONS.md +65 -19
- package/docs/MAILBOX_LIFECYCLE.md +28 -1
- package/docs/REINDEX_METADATA_COMPATIBILITY.md +18 -8
- package/docs/SECURITY_MODEL.md +31 -14
- package/docs/TELEMETRY_RETENTION.md +11 -4
- package/docs/WATCH_REFRESH_REQUESTS.md +34 -21
- package/docs/WINDOWS_SIDECAR_RELEASE.md +9 -4
- package/docs/analyzer-inventory.md +31 -22
- package/docs/analyzer-validation-ledger.md +8 -0
- package/docs/schemas/outcome-event-record.schema.json +57 -1
- package/docs/schemas/project-config.schema.json +82 -1
- package/docs/schemas/suppression-record.schema.json +84 -3
- package/package.json +5 -5
- package/skills/_shared/SKILL.md +2 -2
- package/skills/_shared/references/agent-contract-catalog.md +1 -1
- package/skills/_shared/references/detector-precision-and-diffgate.md +1 -1
- package/skills/scip-audit/SKILL.md +6 -6
- package/skills/scip-audit/references/claims.md +1 -1
- package/skills/scip-audit/references/cleanup.md +19 -20
- package/skills/scip-audit/references/directory.md +4 -4
- package/skills/scip-audit/references/frontend.md +10 -10
- package/skills/scip-audit/references/twin-drift.md +2 -2
- package/skills/scip-diagnose/references/debug.md +8 -8
- package/skills/scip-diagnose/references/root-cause.md +3 -3
- package/skills/scip-diagnose/references/triage.md +10 -10
- package/skills/scip-explore/SKILL.md +3 -3
- package/skills/scip-improve/SKILL.md +10 -10
- package/skills/scip-improve/references/cleanup-batches.md +3 -3
- package/skills/scip-improve/references/directory-moves.md +3 -3
- package/skills/scip-improve/references/doc-reconcile.md +1 -1
- package/skills/scip-improve/references/frontend-extraction.md +2 -2
- package/skills/scip-improve/references/twin-drift.md +3 -3
- package/skills/scip-plan/SKILL.md +2 -2
- package/skills/scip-plan/references/api-impact.md +5 -5
- package/skills/scip-plan/references/conductor.md +2 -2
- package/skills/scip-plan/references/hyper-optimization.md +1 -1
- package/skills/scip-query/SKILL.md +15 -5
- package/skills/scip-setup/references/bootstrap-workflow.md +7 -8
- package/skills/scip-setup/references/language-verification.md +2 -2
- package/skills/scip-setup/references/per-repo-triage.md +1 -1
- package/skills/scip-verify/SKILL.md +10 -10
- package/skills/scip-verify/references/calibrate-detectors.md +7 -7
- package/dist/chunk-2465DLHK.js +0 -3
- package/dist/chunk-2U3OLUNJ.js +0 -61
- package/dist/chunk-33XTHFKR.js +0 -2
- package/dist/chunk-43KC6EQZ.js +0 -2
- package/dist/chunk-47BU5Z4T.js +0 -8
- package/dist/chunk-4YTUWQ6M.js +0 -18
- package/dist/chunk-64MNV6AB.js +0 -8
- package/dist/chunk-67QRR5YC.js +0 -6
- package/dist/chunk-6GXYN7YA.js +0 -40
- package/dist/chunk-A2TNXAXO.js +0 -8
- package/dist/chunk-APMMR5Y2.js +0 -2
- package/dist/chunk-AZFUMCQB.js +0 -2
- package/dist/chunk-BNXICU42.js +0 -33
- package/dist/chunk-C5Q44Q5D.js +0 -3
- package/dist/chunk-DQGSM7RZ.js +0 -20
- package/dist/chunk-E2LAW7SL.js +0 -30
- package/dist/chunk-E4NFOAD4.js +0 -6
- package/dist/chunk-E5HNT4X2.js +0 -3
- package/dist/chunk-FD3HFKXR.js +0 -5
- package/dist/chunk-GHKEJTCE.js +0 -35
- package/dist/chunk-GLZTVKAB.js +0 -16
- package/dist/chunk-HIB452NU.js +0 -949
- package/dist/chunk-IF6FP6B2.js +0 -66
- package/dist/chunk-JORHF5AL.js +0 -108
- package/dist/chunk-KSGTULOS.js +0 -9
- package/dist/chunk-KXDJAG4N.js +0 -38
- package/dist/chunk-L4S2A7BV.js +0 -2
- package/dist/chunk-LP3ARJKF.js +0 -8
- package/dist/chunk-LSOR3LQG.js +0 -3
- package/dist/chunk-NTUMF2X3.js +0 -56
- package/dist/chunk-QOXBSI6G.js +0 -20
- package/dist/chunk-QXK6UUSM.js +0 -2
- package/dist/chunk-RA3AYNWP.js +0 -112
- package/dist/chunk-RJMDJR3A.js +0 -2
- package/dist/chunk-RLH5VUMG.js +0 -2
- package/dist/chunk-SMQWE25B.js +0 -3
- package/dist/chunk-TAVELHYR.js +0 -2
- package/dist/chunk-VAXNI5NE.js +0 -146
- package/dist/chunk-VVY2G5ET.js +0 -2
- package/dist/chunk-W3DBTGL4.js +0 -11
- package/dist/chunk-WANA4KAQ.js +0 -5
- package/dist/chunk-X4FR5BZF.js +0 -9
- package/dist/chunk-X6RKPDY7.js +0 -2
- package/dist/chunk-YCPASUCX.js +0 -2
- package/dist/chunk-ZL2OGDCD.js +0 -2
- package/dist/command-descriptors-ZW5J4ZEM.js +0 -631
- package/dist/direct-navigation-42YHQPOI.js +0 -3
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{e as se,f as ae,g as ce,j as H,k as de,l as U,m as q,q as A,s as le,t as ue,u as fe}from"./chunk-BS2NMXQZ.js";import{i as F,j,k as ie,m as oe}from"./chunk-2KAZEZ6M.js";import{a as re,e as J,f as ne}from"./chunk-C3KV2II6.js";import{createHash as he,randomUUID as Je}from"crypto";import{chmodSync as ye,existsSync as S,linkSync as Fe,lstatSync as C,readdirSync as z,realpathSync as y,unlinkSync as je,writeSync as He}from"fs";import{homedir as Ue}from"os";import{basename as qe,dirname as k,isAbsolute as me,join as u,resolve as I}from"path";import{createRequire as $e}from"module";var De=$e(import.meta.url),ge=Me().version;function Me(){for(let e of["../package.json","../../package.json"])try{return De(e)}catch{}return{version:"0.0.0"}}var xe=1,b=".scip-query-cache-owner.json",We=16*1024,Re=Object.freeze({...H,randomToken:()=>Je(),linkFile:(e,r)=>Fe(e,r),removeFile:e=>je(e),writeFile:(e,r,t,n)=>He(e,r,t,n)});function T(e,r){return Object.assign(new Error(`refusing unsafe project dbPath ${JSON.stringify(e)} (${r}); use a repository-relative directory that remains inside the checkout`),{name:"UnsafeCachePathError",code:"SCIP_QUERY_UNSAFE_CACHE_PATH",configuredPath:e,reason:r})}function h(e,r){return Object.assign(new Error(`refusing unowned cache directory ${JSON.stringify(e)} (${r}); move unrelated data elsewhere or choose a new empty dbPath`),{name:"CacheOwnershipError",code:"SCIP_QUERY_CACHE_OWNERSHIP",cacheDir:e,reason:r})}function Ve(e,r){let t=y(e),n=process.env.SCIP_QUERY_CACHE_DIR;return n?W(t,I(n)):r?.dbPath?W(t,Ye(t,r.dbPath)):W(t,ze(t))}function Se(){let e=process.env.XDG_CACHE_HOME;return u(e||u(Ue(),".cache"),"scip-query")}function ze(e){let r=I(e);try{r=y(r)}catch{}let t=he("sha256").update(r).digest("hex").slice(0,12);return u(Se(),"projects",t)}function Vt(e){if(!/^[a-f0-9]{24}$/.test(e))throw new Error(`invalid repository cache identity: ${e}`);let r=u(Se(),"repositories",e);return ve(r),y(r)}function zt(e){return process.env.SCIP_QUERY_SHARED_CACHE!=="0"&&!process.env.SCIP_QUERY_CACHE_DIR&&!process.env.SCIP_QUERY_INDEX_DB&&!e?.dbPath}function Gt(e,r){let t=Ve(e,r);return{cacheDir:t,dbPath:u(t,"index.db"),indexPath:u(t,"index.scip"),metaPath:u(t,"meta.json")}}function W(e,r,t=Re){return Ge(e,r,t).cacheDir}function Ge(e,r,t=Re){let n=y(e),o=S(r)?"synced":ve(r,t),i=y(r),s=u(i,b);if(S(s))return V(n,i),G(s),v(i),{kind:"existing",cacheDir:i};pe(i),et(i),pe(i);let d=`${JSON.stringify({schemaVersion:xe,canonicalProjectRoot:n,canonicalCacheDir:i,creatorVersion:ge},null,2)}
|
|
2
|
+
`;try{let l=tt(s,d,t),f=q(o,l);return{kind:"published",cacheDir:i,achievedDurability:f==="synced"?"directory-durable":"file-flushed",directorySync:f}}catch(l){if(nt(l))return V(n,i),{kind:"existing",cacheDir:i};throw l}}function V(e,r){let t=y(e),n=y(r);return Ke(n,t,n)}function Yt(e,r){return S(u(r,b))?(V(e,r),we(r),!0):!1}function Ye(e,r){let t;try{t=ne(r)}catch(s){throw s instanceof re?T(r,s.reason):s}let n=I(e,...t.split("/"));if(n===e||!J(e,n))throw T(r,"outside-project");let o=Xe(n),i=y(o);if(!J(e,i)&&i!==e)throw T(r,"symlink-escape");return n}function Xe(e){let r=e;for(;!S(r);){let t=k(r);if(t===r)throw T(e,"no-existing-ancestor");r=t}return r}function Ke(e,r,t){let n=u(e,b);if(!S(n)||C(n).isSymbolicLink())throw h(e,"missing regular ownership record");let o=C(n);if(!o.isFile()||o.size>We)throw h(e,"invalid ownership record file");let i=oe(n,"cache ownership record"),s=Qe(i,e);if(s.canonicalProjectRoot!==r)throw h(e,"ownership record belongs to a different project");if(s.canonicalCacheDir!==t)throw h(e,"ownership record names a different cache directory");return{record:s,ownerSha256:he("sha256").update(i).digest("hex"),physicalCacheDir:e}}function Qe(e,r){try{let t=JSON.parse(e);if(t.schemaVersion!==xe||typeof t.canonicalProjectRoot!="string"||typeof t.canonicalCacheDir!="string"||typeof t.creatorVersion!="string"||!me(t.canonicalProjectRoot)||!me(t.canonicalCacheDir))throw new Error("invalid fields");return t}catch(t){throw h(r,`malformed ownership record: ${t instanceof Error?t.message:String(t)}`)}}function pe(e){let r=z(e).filter(t=>t!==b&&!Ze(t));if(r.length>0)throw h(e,`unrecognized existing entries: ${r.slice(0,3).join(", ")}`)}function Ze(e){return e.startsWith(`${b}.tmp-`)||[".scipquery-generations","affected-shadow-latest.json","affected-shadow.jsonl","agent-hooks","augment-vue-meta.json","cache-lifecycle.lock","evidence.db","evidence.db-shm","evidence.db-wal","health-report-cache.json","index.db","index.db-shm","index.db-wal","index.lock","index.scip","language-indexes","meta.json","reindex-activity.jsonl","shared-cache.json","typescript-index","typescript-scip-fragments","typescript-scip-overlays","typescript-semantic","watch-activity.json","watch-refresh-requests","watch-state.json","watch.lock"].includes(e)?!0:/^(?:reindex-|rust-|typescript-)/.test(e)}function et(e){for(let r of z(e)){let t=u(e,r),n=C(t);if(n.isSymbolicLink())throw h(e,`legacy cache entry ${r} is a symlink`);if(n.isDirectory())v(t);else if(n.isFile())G(t);else throw h(e,`legacy cache entry ${r} is not a file or directory`)}v(e)}function we(e){let r=C(e);if(r.isSymbolicLink())throw h(e,"managed cache tree contains a symlink");if(r.isFile()){G(e);return}if(!r.isDirectory())throw h(e,"managed cache tree contains a special file");v(e);for(let t of z(e))we(u(e,t))}function ve(e,r=H){let t=de(e,r);return v(e),t}function tt(e,r,t){let n=`${e}.tmp-${process.pid}-${t.randomToken()}`,o,i=!1;try{o=t.openFile(n,"wx",384),i=!0,ae(o,Buffer.from(r),t,"cache ownership record"),t.syncFile(o),t.closeFile(o),o=void 0,t.linkFile(n,e);let s=U(k(e),t);return t.removeFile(n),i=!1,q(s,U(k(e),t))}finally{if(o!==void 0)try{t.closeFile(o)}catch{}if(i)try{t.removeFile(n)}catch{}}}function v(e){process.platform!=="win32"&&ye(e,448)}function G(e){process.platform!=="win32"&&ye(e,384)}function rt(e){if(S(e))return y(e);let r=y(k(e));return u(r,qe(e))}function Xt(e){return rt(I(e))}function nt(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="EEXIST"}import{execFileSync as be}from"child_process";import{createRequire as it}from"module";import{existsSync as ot}from"fs";import{platform as P,arch as Pe}from"os";var O="v0.8.1",Y="https://github.com/sourcegraph/scip",_=`github.com/sourcegraph/scip/cmd/scip@${O}`,Oe=it(import.meta.url),Ee="SCIP_QUERY_SCIP_BIN";function st(e){if(e.isOnPath("scip"))return{source:"path",path:"scip"};let r=e.env[Ee];if(r&&e.fileExists(r))return{source:"env",path:r};if(e.platform==="win32"){let t=e.resolveSidecar(e.arch);if(t&&e.fileExists(t))return{source:"sidecar",path:t}}return null}function at(e){for(let r of e==="arm64"?["arm64","x64"]:[e])try{return Oe.resolve(`scip-query-scip-windows/scip-win32-${r}.exe`)}catch{}return null}function X(e=process.env){let r=st({platform:P(),arch:Pe(),env:e,isOnPath:A,fileExists:ot,resolveSidecar:at});return r?.source==="path"?le("scip")??r.path:r?.path??null}function nr(){return X()!==null}function ct(){let e=X();if(!e)return null;try{return be(e,["--version"],{stdio:"pipe",timeout:1e4,killSignal:"SIGKILL"}).toString().trim()}catch{return null}}function dt(){let e=P(),r=Pe(),t,n,o;switch(e){case"darwin":t="darwin",o="tar.gz";break;case"linux":t="linux",o="tar.gz";break;default:return null}switch(r){case"arm64":n="arm64";break;case"x64":n="amd64";break;default:return null}let i=`scip-${t}-${n}.${o}`;return{url:`${Y}/releases/download/${O}/${i}`,filename:i}}function ir(){let e=dt();if(console.log("\nThe `scip` CLI is required but not found on PATH.\n"),P()==="darwin"||P()==="linux")console.log("Install the reviewed version with Go:"),console.log(` go install ${_}
|
|
3
|
+
`),console.log("Or download that exact release manually:");else if(P()==="win32"){let r=lt();console.log("On Windows the scip binary ships via the npm sidecar package scip-query-scip-windows,"),console.log("installed automatically with scip-query. If it is missing:"),console.log(` npm install -g ${r}`),console.log(`Or set ${Ee} to a local scip.exe path.
|
|
4
|
+
`),console.log("Upstream release page:")}else console.log("Download from:");console.log(e?` ${e.url}
|
|
5
|
+
`:` ${Y}/releases/tag/${O}
|
|
6
|
+
`),console.log("After installing, ensure `scip` is on your PATH and run `scip-query reindex`.")}function lt(){let r=Oe("../../package.json").optionalDependencies?.["scip-query-scip-windows"];if(!r||!/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/.test(r))throw new Error("scip-query package metadata does not declare an exact Windows sidecar version.");return`scip-query-scip-windows@${r}`}function or(e){if(A("go")){e(`Installing immutable ${_} via go install into the Go bin directory (GOBIN or GOPATH/bin); expected executable: scip.`);try{if(be("go",["install",_],{stdio:"inherit",timeout:3e5,env:process.env}),A("scip")){let r=X(),t=ct();if(r&&t&&t.includes(O))return e(`Successfully installed ${_}; resolved executable: ${r}; reported version: ${t}.`),!0;e(`go install completed, but the resolved scip executable did not report ${O} (executable: ${r??"unresolved"}; version: ${t??"unavailable"}).`)}}catch(r){let t=r instanceof Error?r.message:String(r);e(`go install failed: ${t}`)}}return e("Could not auto-install scip CLI."),e(`Install manually from: ${Y}/releases`),!1}import{statSync as Et}from"fs";import{dirname as Bt,join as At}from"path";import{appendFileSync as ut,existsSync as ft,mkdirSync as gt,renameSync as mt,rmSync as pt,statSync as ht,truncateSync as yt}from"fs";import{basename as xt,dirname as Rt}from"path";var Z=".previous",St=".rotation.lock",wt=2e3,K=class extends Error{constructor(t,n){super(`Timed out after ${n}ms waiting for rotating JSONL lock: ${t}`);this.lockPath=t;this.timeoutMs=n;this.name="RotatingJsonlLockTimeoutError"}lockPath;timeoutMs;code="ROTATING_JSONL_LOCK_TIMEOUT"},Q=class extends Error{constructor(t){super(`Rotating JSONL lock ownership changed before release: ${t}`);this.lockPath=t;this.name="RotatingJsonlLockReleaseError"}lockPath;code="ROTATING_JSONL_LOCK_RELEASE_FAILED"},vt=Object.freeze({monotonicNow:se,wait(e){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e)},tryAcquireLock(e,r){let t=ce(e,{kind:"rotating-jsonl",detail:{target:xt(r)}});return t.kind==="acquired"?{kind:"acquired",lock:t.lock}:{kind:"contended"}},makeDirectory(e){gt(e,{recursive:!0})},exists:ft,readBytes(e){return ie(e,{maxBytes:F,inputKind:"rotating JSONL segment"})},size(e){return ht(e).size},truncate:yt,remove(e){pt(e,{force:!0})},rename:mt,append:ut});function Be(e,r,t){let n=t.runtime??vt,o=JSON.stringify(r);if(o===void 0)throw new TypeError("Rotating JSONL records must be JSON-serializable values.");let i=Buffer.from(`${o}
|
|
7
|
+
`),s=Math.max(1,Math.floor(t.maxSegmentBytes),i.length);return bt(e,t.lockTimeoutMs,n,()=>{n.makeDirectory(Rt(e));let m=Pt(e,F,n);t.onPhase?.("tail-repaired");let d=`${e}${t.previousSuffix??Z}`,l=!1,f=!1;return n.exists(e)&&n.size(e)+i.length>s&&(n.exists(d)&&(n.remove(d),f=!0),t.onPhase?.("previous-pruned"),n.rename(e,d),l=!0,t.onPhase?.("current-rotated")),n.append(e,i),t.onPhase?.("record-appended"),{lineBytes:i.length,segmentLimitBytes:s,repairedTailBytes:m,rotated:l,prunedPrevious:f}})}function bt(e,r,t,n){let o=`${e}${St}`,i=Math.max(0,r??wt),s=t.monotonicNow()+i,m;for(;;){let p=t.tryAcquireLock(o,e);if(p.kind==="acquired"){m=p.lock;break}let g=s-t.monotonicNow();if(g<=0)throw new K(o,i);t.wait(Math.min(5,g))}let d=!1,l,f;try{f=n()}catch(p){d=!0,l=p}let R=!1;try{R=m.release()}catch(p){if(!d)throw p}if(d)throw l;if(!R)throw new Q(o);return f}function Pt(e,r,t){if(!t.exists(e))return 0;let n=Ot(e,r,t);if(n.length===0||n[n.length-1]===10)return 0;let o=n.lastIndexOf(10),i=o<0?0:o+1;return t.truncate(e,i),n.length-i}function Ot(e,r,t){let n=t.size(e);if(n>r)throw new j("rotating JSONL segment",e,"too-large",n,r);let o=t.readBytes(e),i=t.size(e);if(i!==n||o.byteLength!==n)throw new j("rotating JSONL segment",e,"changed-during-read",i,r);return o}var Tt="reindex-activity.jsonl",Ct=Z,kt=1024*1024,yr=1440*60*1e3;function Te(e){return At(Bt(e),Tt)}function It(e){if(e.reused)return 0;let r=Ae(e.indexPath)+Ae(e.dbPath);for(let t of e.shards??[])!t.reused&&t.outputBytes!==null&&(r+=t.outputBytes);return r}function xr(e,r){let t=r.lastRefresh;return t?Ce(Te(e),{version:1,event:"run",recordedAt:t.completedAt,trigger:t.trigger,result:t.result,durationMs:t.durationMs,estimatedLogicalOutputBytes:It(r)}):{state:"failed",reason:"reindex result has no refresh metadata"}}function Rr(e,r){return Ce(Te(e),{version:1,event:"run",recordedAt:r.completedAt,trigger:r.trigger,result:"failed",durationMs:r.durationMs,estimatedLogicalOutputBytes:0})}function _t(e,r,t=kt,n){Be(e,r,{maxSegmentBytes:t,previousSuffix:Ct,...n?{runtime:n}:{}})}function Ce(e,r){try{return _t(e,r),{state:"recorded"}}catch(t){return{state:"failed",reason:t instanceof Error?t.message:String(t)}}}function Ae(e){try{return Et(e).size}catch{return 0}}import{spawn as Lt}from"child_process";import{platform as ke}from"os";import{performance as Ie}from"perf_hooks";var Or={probe:1e4,git:3e4,analysis:18e4,install:3e5,indexer:6e5},B=class extends Error{constructor(t,n,o,i={}){super(o,i.cause===void 0?void 0:{cause:i.cause});this.kind=t;this.label=n;this.name="BoundedProcessError",this.timedOut=i.timedOut??!1,this.reaped=i.reaped??!1,this.stdout=i.stdout??"",this.stderr=i.stderr??"",this.stdoutTruncated=i.stdoutTruncated??!1,this.stderrTruncated=i.stderrTruncated??!1}kind;label;timedOut;reaped;stdout;stderr;stdoutTruncated;stderrTruncated};function E(e,r){if(!Number.isFinite(e)||e<=0)throw new TypeError(`${r} must be a positive finite number.`)}function _e(e,r,t,n){let o=Math.max(0,n-t);o>0&&e.push(r.subarray(0,o))}function Le(e,r,t){let n=Buffer.concat([...e,r]);e.length=0,e.push(n.subarray(Math.max(0,n.length-t)))}function Er(e){E(e.timeoutMs,"timeoutMs"),E(e.maxStdoutBytes,"maxStdoutBytes"),E(e.maxStderrBytes,"maxStderrBytes");let r=e.terminationGraceMs??1e3;E(r,"terminationGraceMs");let t=e.terminationForceMs??r;return E(t,"terminationForceMs"),new Promise((n,o)=>{let i=Ie.now(),s;try{let a=ke()!=="win32";s=Lt(e.command,[...e.args??[]],{cwd:e.cwd,env:e.env,detached:a?!0:e.detached,stdio:["pipe","pipe","pipe"]})}catch(a){o(new B("spawn",e.label,`${e.label} could not start.`,{cause:a,reaped:!0}));return}let m=[],d=[],l=0,f=0,R=!1,p=!1,g=null,x=!1,Ne=ke()!=="win32",ee=s.pid===void 0?null:ue(s.pid,Ne),L=()=>{clearTimeout(te),e.signal?.removeEventListener("abort",$)},N=a=>{if(x||!g)return;x=!0,L();let c=Buffer.concat(m).toString("utf8"),D=Buffer.concat(d).toString("utf8"),M=a.reaped||!a.detail?"":` Process-tree cleanup failed: ${a.detail}`;o(new B(g.kind,e.label,`${g.message}${M}`,{timedOut:g.timedOut,reaped:a.reaped,stdout:c,stderr:D,stdoutTruncated:R,stderrTruncated:p}))},w=a=>{if(!(g||x)){if(g=a,!ee){N({reaped:s.pid===void 0,reason:s.pid===void 0?"terminated":"identity-unavailable"});return}fe(ee,{gracefulMs:r,forceMs:t}).then(N,c=>{N({reaped:!1,reason:"signal-failed",detail:c instanceof Error?c.message:String(c)})})}},te=setTimeout(()=>{w({kind:"timeout",timedOut:!0,message:`${e.label} timed out after ${e.timeoutMs}ms.`})},e.timeoutMs);te.unref();let $=()=>{w({kind:"aborted",timedOut:!1,message:`${e.label} was cancelled.`})};e.signal?.addEventListener("abort",$,{once:!0}),e.signal?.aborted&&$(),s.stdout.on("data",a=>{let c=Buffer.isBuffer(a)?a:Buffer.from(a);e.outputLimitBehavior==="truncate-tail"?Le(m,c,e.maxStdoutBytes):_e(m,c,l,e.maxStdoutBytes),l+=c.length,l>e.maxStdoutBytes&&(R=!0,e.outputLimitBehavior!=="truncate-tail"&&w({kind:"stdout-limit",timedOut:!1,message:`${e.label} exceeded stdout limit (${e.maxStdoutBytes} bytes).`}))}),s.stderr.on("data",a=>{let c=Buffer.isBuffer(a)?a:Buffer.from(a);e.outputLimitBehavior==="truncate-tail"?Le(d,c,e.maxStderrBytes):_e(d,c,f,e.maxStderrBytes),f+=c.length,f>e.maxStderrBytes&&(p=!0,e.outputLimitBehavior!=="truncate-tail"&&w({kind:"stderr-limit",timedOut:!1,message:`${e.label} exceeded stderr limit (${e.maxStderrBytes} bytes).`}))}),s.on("error",a=>{if(!x&&!g){if(s.pid===void 0){L(),x=!0,o(new B("spawn",e.label,`${e.label} could not start: ${a.message}`,{cause:a,reaped:!0}));return}w({kind:"spawn",timedOut:!1,message:`${e.label} failed after start: ${a.message}`})}}),s.on("close",(a,c)=>{if(x||g)return;x=!0,L();let D=Buffer.concat(m).toString("utf8"),M=Buffer.concat(d).toString("utf8");n({status:a,signal:c,stdout:D,stderr:M,timedOut:!1,durationMs:Ie.now()-i,stdoutTruncated:R,stderrTruncated:p})}),e.input===void 0?s.stdin.end():s.stdin.end(e.input)})}export{ge as a,ze as b,Vt as c,zt as d,Gt as e,Yt as f,Xt as g,X as h,nr as i,ct as j,ir as k,or as l,Z as m,Be as n,Tt as o,xr as p,Rr as q,Or as r,B as s,Er as t};
|
|
8
|
+
//# sourceMappingURL=chunk-JN4NMBEX.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{c as p}from"./chunk-
|
|
1
|
+
import{c as p}from"./chunk-RUJURYSV.js";import{b as D}from"./chunk-B75HZHUP.js";import{a as m}from"./chunk-BGBBVSH4.js";import{d as g,t as B}from"./chunk-EKZTZXHZ.js";import{b as f}from"./chunk-UJPRPGCO.js";import{K as y,N as d}from"./chunk-WCCFZ7V7.js";import{createHash as A}from"crypto";var h=3;function H(e,t={}){let{scope:o,maxLoc:n=15,minLoc:i=h,limit:r,scanLimit:s}=t,l=p(e),u=L(e,{scope:o,maxLoc:n,scanLimit:s}).map(a=>x(e,a,l,i)).filter(a=>a!==null),c=v(u);return r?c.slice(0,r):c}function M(e,t,o={}){let{scope:n,maxLoc:i=15,minLoc:r=h,scanLimit:s}=o,l=p(e),u=L(e,{scope:n,maxLoc:i,scanLimit:s}).map(a=>x(e,a,l,r)).filter(a=>a!==null),c=u.find(a=>a.symbol===t);return c?u.filter(a=>a.symbol!==c.symbol&&a.normalizedBody===c.normalizedBody&&a.file!==c.file).sort(z).map(({normalizedBody:a,...C})=>C):[]}function I(e){let t=S(e);return f(t).replace(/\s+/g,"")}function v(e){let t=new Map;for(let n of e){if(n.normalizedBody.length<8)continue;let i=F(n.normalizedBody),r=t.get(i)??[];r.push(n),t.set(i,r)}let o=[];for(let[n,i]of t){let r=new Set(i.map(l=>l.file));if(i.length<2||r.size<2)continue;let s=[...i].sort(z).map(({normalizedBody:l,...u})=>u);o.push({hash:n,canonical:s[0],functions:s})}return o.sort((n,i)=>{let r=i.functions.length-n.functions.length;if(r!==0)return r;let s=b(i)-b(n);return s!==0?s:n.canonical.file.localeCompare(i.canonical.file)}),o}function L(e,t){let o=B(e,{scope:t.scope}).filter(n=>n.isFunctionLike&&!e.isIgnored(n.relativePath)).filter(n=>!d(e,n.relativePath,n.startLine,"similar")).filter(n=>m(n)<=t.maxLoc);return o.sort((n,i)=>m(i)-m(n)||n.relativePath.localeCompare(i.relativePath)),D(o,t.scanLimit)}function x(e,t,o,n){let i=E(e,t);if(!i||W(i)<n)return null;let r=P(e,t);return r?{symbol:t.symbol,shortName:g(t.symbol),file:t.relativePath,startLine:t.startLine,endLine:t.endLine,loc:m(t),ageCommits:o?.get(t.relativePath)?.commitsAgo??null,normalizedBody:r}:null}function P(e,t){let o=E(e,t);return o&&I(o)||null}function E(e,t){let o=y(e,t.relativePath);return o.length===0?null:o.slice(t.startLine,t.endLine+1).join(`
|
|
2
2
|
`)}function S(e){let t=e.indexOf("{"),o=e.lastIndexOf("}");if(t>=0&&o>t)return e.slice(t+1,o);let n=e.indexOf("=>");return n>=0?e.slice(n+2).replace(/;+\s*$/,""):e}function W(e){return S(e).split(/\r?\n/).map(o=>o.trim()).filter(o=>o.length>0).length}function F(e){return A("sha256").update(e).digest("hex").slice(0,16)}function z(e,t){let o=e.ageCommits??-1;return(t.ageCommits??-1)-o||e.file.localeCompare(t.file)||e.startLine-t.startLine}function b(e){return e.functions.reduce((t,o)=>t+o.loc,0)}export{H as a,M as b,I as c,v as d,P as e,E as f,S as g};
|
|
3
|
-
//# sourceMappingURL=chunk-
|
|
3
|
+
//# sourceMappingURL=chunk-JVYA47YU.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as M}from"./chunk-
|
|
1
|
+
import{a as M}from"./chunk-ZTETIQ35.js";import{c as C}from"./chunk-4TURLRL5.js";import{b as f,c as I}from"./chunk-UJCOIXDY.js";import{h as d}from"./chunk-HX7M4BDI.js";import{d as h}from"./chunk-MTDBHTSF.js";import{d as g}from"./chunk-EKZTZXHZ.js";import{f as y}from"./chunk-UJPRPGCO.js";var x=new Set(h());function N(e,n){let{scope:o,minLoc:r=10,limit:i=30,scanLimit:t}=n??{},s=new I(e);return M({candidates:()=>s.productionCallableDefinitions({scope:o,minLoc:r,requireFunctionLikeSymbol:!0,includeSuppressed:!0,sortByLocDesc:typeof t=="number"&&t>0}),scanLimit:t,filterCandidate:S,profile:{name:"complexity-hotspots"},prepare:a=>{let l=B(e,a),m=n?.semantic!==!1,c=m?d(e):null;c?.materializeReferences(a,{prefetchCallees:!0});let u=s.crossFileCallerMap(a,{semantic:!1});return{callerMap:c?f(u,c.callerMap(a)):u,calleeMap:s.calleeMap(a,{semantic:m}),languageByFile:l,clojureCallableIds:D(e,a,l),branchEstimates:C(e,a)}},evaluate:(a,l)=>L(a,l,r),orderResults:(a,l)=>l.score-a.score||l.loc-a.loc,limit:i})}function S(e){return e.symbol.startsWith("rust-analyzer ")?typeof e.kind=="number"&&x.has(e.kind):!0}function L(e,n,o){if(n.languageByFile.get(e.relativePath)==="clojure"&&!n.clojureCallableIds.has(e.symbolId))return null;let r=e.endLine-e.startLine+1;if(r<o)return null;let i=n.callerMap.get(e.symbolId)?.size??0,t=n.calleeMap.get(e.symbolId)??[],s=new Set,a=new Set;for(let p of t){let b=`${p.symbol}|${p.file}`;s.add(b),p.file!==e.relativePath&&a.add(b)}let l=a.size,m=s.size,c=n.branchEstimates.get(e.symbolId)??{branches:0,estimateBasis:"regex-fallback"},u=c.branches+1;return{symbol:e.symbol,shortName:g(e.symbol),file:e.relativePath,startLine:e.startLine,endLine:e.endLine,loc:r,fanIn:i,fanOut:l,calleeCount:m,branches:c.branches,estimateBasis:c.estimateBasis,score:Math.round(r/50*(i/5)*Math.max(l/5,1)*Math.max(u/5,1)*100)/100}}function B(e,n){let o=[...new Set(n.map(t=>t.relativePath))];if(o.length===0)return new Map;let r=o.map(()=>"?").join(", "),i=e.all(`SELECT relative_path, language
|
|
2
2
|
FROM documents
|
|
3
3
|
WHERE relative_path IN (${r})`,...o);return new Map(i.map(t=>[t.relative_path,t.language?.toLowerCase()??null]))}function D(e,n,o){let r=new Set,i=new Map;for(let t of n){if(o.get(t.relativePath)!=="clojure")continue;let s=i.get(t.relativePath);s||(s=new Set((y(e,t.relativePath)?.callables??[]).map(a=>`${a.name}:${a.startLine}`)),i.set(t.relativePath,s)),s.has(`${t.leaf}:${t.startLine}`)&&r.add(t.symbolId)}return r}export{N as a};
|
|
4
|
-
//# sourceMappingURL=chunk-
|
|
4
|
+
//# sourceMappingURL=chunk-JW56N3KI.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as P}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{c as P}from"./chunk-UJCOIXDY.js";import{n as O,o as C}from"./chunk-7O5IKBTZ.js";import{h as x,k as v,o as T}from"./chunk-HX7M4BDI.js";import{d as A}from"./chunk-EKZTZXHZ.js";import{f as b}from"./chunk-UJPRPGCO.js";import{x as g}from"./chunk-GH74ASD6.js";function U(e,n={}){let{samples:o=50,scope:r,maxDisagreements:u=5}=n,l=new P(e),a=K(l.productionCallableDefinitions({scope:r,minLoc:2,requireFunctionLikeSymbol:!0}),o),c=z(e,a);if(a.length===0||!c)return{available:!1,sampleSize:a.length,oracleCoverage:0,scores:[],topDisagreements:[]};let t={references:Q(),callees:Q()},i=[],f=0,m=c==="semantic"?T(e,a):new Map,I=c==="source"?_(e,l,a):null;for(let s of a){let p=S(s,c==="semantic"?v(e,s).map(d=>d.file):[...I?.referencesBySymbolId.get(s.symbolId)??[]]),L=S(s,c==="semantic"?(m.get(s.symbolId)??[]).map(d=>d.file):[...I?.calleesBySymbolId.get(s.symbolId)??[]]);f+=1;let k=S(s,O(e,s,{semanticEvidence:C}).map(d=>d.file)),w=S(s,(l.calleeMap([s],{semantic:!1}).get(s.symbolId)??[]).map(d=>d.file)),R=y(c,"references"),B=y(c,"callees");M(t.references,s,"references",k,p,R,i),M(t.callees,s,"callees",w,L,B,i)}return i.sort((s,p)=>p.cheapOnly.length+p.oracleOnly.length-(s.cheapOnly.length+s.oracleOnly.length)),{available:!0,sampleSize:a.length,oracleCoverage:a.length>0?D(f/a.length):0,oracleKind:c,scores:["references","callees"].map(s=>F(s,t[s],c)),topDisagreements:i.slice(0,u)}}function Q(){return{comparedSymbols:0,agreed:0,cheapTotal:0,oracleTotal:0,skippedOraclePartial:0}}function K(e,n){let o=[...e].sort((l,a)=>l.symbolId-a.symbolId);if(o.length<=n)return o;let r=o.length/n,u=[];for(let l=0;l<n;l++)u.push(o[Math.floor(l*r)]);return u}function z(e,n){let o=n[0];if(!o)return null;if(h(e,o))return"source";try{if(x(e).capability("semantic-references",o.relativePath).available)return"semantic"}catch{}return n.some(r=>h(e,r))?"source":null}function S(e,n){let o=new Set;for(let r of n)r!==e.relativePath&&o.add(r);return o}function M(e,n,o,r,u,l,a){if(!l&&u.size===0){e.skippedOraclePartial+=1;return}e.comparedSymbols+=1,e.cheapTotal+=r.size,e.oracleTotal+=u.size;let c=[],t=[];for(let i of r)u.has(i)?e.agreed+=1:c.push(i);for(let i of u)r.has(i)||t.push(i);(c.length>0||t.length>0)&&a.push({symbol:A(n.symbol),question:o,cheapOnly:c,oracleOnly:t})}var E={references:!0,callees:!1};function F(e,n,o){let r=n.oracleTotal>0?n.agreed/n.oracleTotal:1,u=n.cheapTotal-n.agreed,l=y(o,e);return{question:e,comparedSymbols:n.comparedSymbols,precision:l&&n.cheapTotal>0?D(n.agreed/n.cheapTotal):null,recall:D(r),unverified:u,skippedOraclePartial:n.skippedOraclePartial}}function y(e,n){return e==="semantic"?E[n]:!1}function h(e,n){return g(n.relativePath)==="clojure"&&b(e,n.relativePath)!==null}function _(e,n,o){let r=new Map,u=new Map,l=o.filter(t=>h(e,t)),a=new Map;for(let t of l){let i=a.get(t.leaf)??[];i.push(t),a.set(t.leaf,i)}for(let t of n.sourceFiles()){if(g(t)!=="clojure")continue;let i=b(e,t);if(i)for(let f of i.fileIdentifiers)for(let m of a.get(f)??[])j(r,m.symbolId,t)}let c=new Map;for(let t of n.scopedDefinitions()){if(g(t.relativePath)!=="clojure")continue;let i=c.get(t.leaf)??[];i.push(t),c.set(t.leaf,i)}for(let t of l){let i=b(e,t.relativePath);if(i){for(let f of i.callSites)if(!(f.line<t.startLine||f.line>t.endLine))for(let m of c.get(f.calleeLeaf)??[])j(u,t.symbolId,m.relativePath)}}return{referencesBySymbolId:r,calleesBySymbolId:u}}function j(e,n,o){let r=e.get(n);if(r){r.add(o);return}e.set(n,new Set([o]))}function D(e){return Math.round(e*1e3)/1e3}export{U as a};
|
|
2
|
+
//# sourceMappingURL=chunk-JZ2OXNWB.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{a as A,c as E,i as T,k as B}from"./chunk-ZHXX42OH.js";import{j as L,o as H}from"./chunk-Y2MVPNKY.js";import{d as D}from"./chunk-KMVGRIO2.js";import{c as _}from"./chunk-UJCOIXDY.js";import{d as C,e as y}from"./chunk-EKZTZXHZ.js";import{a as N}from"./chunk-UJPRPGCO.js";var J=5;function se(e,n={}){let{base:i="HEAD",minContainment:r=.7,minCallees:s=3,minSiteCoverage:t=.4,maxHelpers:m=Number.POSITIVE_INFINITY,limit:c=20,scanLimit:d}=n,g=n.semantic!==!1,l=n.diffPlan??E(e,{base:i}),a={available:l.note!==A,base:i,changedFiles:l.changedFiles,helpersChecked:0,skipped:[],findings:[],...l.note?{note:l.note}:{}};if(!a.available||l.changedFiles.length===0)return a;let v=new _(e),x=new Set(l.changedFiles),j=new Map(l.renamedFiles.map(o=>[o.to,o.from]));if(n.baseContentAt&&n.baseContentResultAt)throw new Error("Specify only one of baseContentAt or baseContentResultAt.");let $=n.baseContentResultAt?n.baseContentResultAt:n.baseContentAt?Q(n.baseContentAt):T({projectRoot:e.config.projectRoot,base:i,preloadPaths:B(l)}),f=Z(v,x,j,$);if(f.unavailable)return a.available=!1,a.note=`Base content unavailable: ${f.unavailable.reason}`,a;if(f.definitions.length===0)return a;let k=f.definitions.slice(0,m);f.definitions.length>m&&(a.note=`helper scoring capped at ${m} of ${f.definitions.length} new symbols`);let z=v.calleeMap(k,{semantic:g}),q=k.map(o=>({def:o,callees:H((z.get(o.symbolId)??[]).map(p=>p.symbol))})),V=L(e),M,G=()=>(M??=V.calleeIndex({minCallees:Math.min(3,s),scanLimit:d,semantic:g}),M);for(let{def:o,callees:p}of q){let u=C(o.symbol);if(p.size<s){a.skipped.push({helperShortName:u,helperFile:o.relativePath,reason:`fewer than ${s} meaningful callees \u2014 too small to score`});continue}let P=G(),w=Y(p,P);if(w===0){a.skipped.push({helperShortName:u,helperFile:o.relativePath,reason:"helper callee pattern is all project-wide infrastructure \u2014 too generic to score"});continue}let S=ee(e,o.symbolId);if(S.length===0){a.skipped.push({helperShortName:u,helperFile:o.relativePath,reason:"no references yet \u2014 covered by the new-dead check"});continue}a.helpersChecked+=1;let I=K({candidateIndex:P,changed:x,helperCallees:p,helperFile:o.relativePath,helperSymbol:o.symbol,minContainment:r,minSiteCoverage:t,migratedFiles:S});I.length!==0&&(I.sort((h,b)=>O(b.migrationScope)-O(h.migrationScope)||b.containment-h.containment||b.siteCoverage-h.siteCoverage||h.file.localeCompare(b.file)),a.findings.push({helperSymbol:o.symbol,helperShortName:u,helperFile:o.relativePath,helperShape:"specific-callee-cluster",helperCalleeCount:p.size,specificHelperCalleeCount:w,migratedFiles:S.sort(),leftovers:I.slice(0,J)}))}return a.findings.sort((o,p)=>(p.leftovers[0]?.containment??0)-(o.leftovers[0]?.containment??0)||o.helperFile.localeCompare(p.helperFile)),a.findings=a.findings.slice(0,c),a}function K(e){let n=[],i=U(e.helperSymbol,e.helperFile,e.migratedFiles),r=new Set;for(let s of e.helperCallees)for(let t of e.candidateIndex.candidateIndexesByCallee.get(s)??[])r.add(t);for(let s of r){let t=e.candidateIndex.corpus[s];if(t.symbol===e.helperSymbol||e.changed.has(t.file)||t.callees.has(e.helperSymbol))continue;let m=D(e.helperCallees,t.callees);if(m<e.minContainment)continue;let c=[...e.helperCallees].filter(l=>t.callees.has(l)),d=t.callees.size===0?0:c.length/t.callees.size;if(d<e.minSiteCoverage||!c.some(l=>(e.candidateIndex.docFreq.get(l)??0)<=e.candidateIndex.ubiquityThreshold))continue;let g=W(i,t.symbol,t.file);n.push({symbol:t.symbol,shortName:C(t.symbol),file:t.file,...g,containment:m,siteCoverage:d,uniqueSiteCalleeCount:Math.max(0,t.callees.size-c.length),sharedCallees:c.map(C).sort()})}return n}function O(e){return e==="same-scope"?2:e==="unknown"?1:0}function U(e,n,i){let r=new Set([...F(n),...R(y(e))]);for(let s of i)for(let t of F(s))r.add(t);return r}function W(e,n,i){let r=new Set([...F(i),...R(y(n))]);if(e.size===0||r.size===0)return{migrationScope:"unknown",migrationScopeReasons:["insufficient path/name tokens to infer migration scope"]};let s=[...r].filter(t=>e.has(t)).sort();return s.length>0?{migrationScope:"same-scope",migrationScopeReasons:[`shares migration-scope token(s): ${s.slice(0,5).join(", ")}`]}:{migrationScope:"possible-subtype",migrationScopeReasons:["no path/name tokens shared with the helper or already migrated files"]}}var X=new Set(["app","apps","common","component","components","helper","helpers","index","lib","package","packages","page","pages","route","routes","service","services","shared","spec","src","test","tests","util","utils"]);function F(e){return R(e.replace(/\.[^.]+$/,""))}function R(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(n=>n.length>1&&!X.has(n))}function Y(e,n){let i=0;for(let r of e)(n.docFreq.get(r)??0)<=n.ubiquityThreshold&&(i+=1);return i}function Z(e,n,i,r){let s=[];for(let t of e.productionCallableDefinitions({files:[...n],requireFunctionLikeSymbol:!0})){if(!n.has(t.relativePath))continue;let m=i.get(t.relativePath)??t.relativePath,c=r(m);if(c.state==="unavailable")return{definitions:[],unavailable:c};(c.state==="absent"||!new RegExp(`\\b${N(t.leaf)}\\b`).test(c.content))&&s.push(t)}return{definitions:s}}function Q(e){return n=>{let i=e(n);return i===null?{state:"absent"}:{state:"present",content:i}}}function ee(e,n){return e.all(`SELECT DISTINCT ref_d.relative_path
|
|
2
|
+
FROM mentions m
|
|
3
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
4
|
+
JOIN documents ref_d ON c.document_id = ref_d.id
|
|
5
|
+
WHERE m.symbol_id = ?
|
|
6
|
+
AND m.role != 1
|
|
7
|
+
${e.pathExclusionsFor("ref_d")}`,n).map(r=>r.relative_path)}export{se as a};
|
|
8
|
+
//# sourceMappingURL=chunk-KMKTIO2G.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{a as U,b as G}from"./chunk-IZYYAFN5.js";import{b as w,d as a,f as N,n as z}from"./chunk-AIE7TFJW.js";import{a as V,b as D}from"./chunk-MNE7YG56.js";import{d as A,e as _,f as j,h as v}from"./chunk-46XGSFNI.js";import{statSync as Ae}from"fs";import{dirname as ve,join as we}from"path";import{appendFileSync as ue,existsSync as ce,mkdirSync as le,renameSync as fe,rmSync as me,statSync as pe,truncateSync as ge}from"fs";import{basename as ye,dirname as xe}from"path";var B=".previous",Re=".rotation.lock",be=2e3,C=class extends Error{constructor(r,n){super(`Timed out after ${n}ms waiting for rotating JSONL lock: ${r}`);this.lockPath=r;this.timeoutMs=n;this.name="RotatingJsonlLockTimeoutError"}lockPath;timeoutMs;code="ROTATING_JSONL_LOCK_TIMEOUT"},J=class extends Error{constructor(r){super(`Rotating JSONL lock ownership changed before release: ${r}`);this.lockPath=r;this.name="RotatingJsonlLockReleaseError"}lockPath;code="ROTATING_JSONL_LOCK_RELEASE_FAILED"},H=Object.freeze({monotonicNow:V,wait(e){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e)},tryAcquireLock(e,t){let r=z(e,{kind:"rotating-jsonl",detail:{target:ye(t)}});return r.kind==="acquired"?{kind:"acquired",lock:r.lock}:{kind:"contended"}},makeDirectory(e){le(e,{recursive:!0})},exists:ce,readBytes(e){return j(e,{maxBytes:A,inputKind:"rotating JSONL segment"})},size(e){return pe(e).size},truncate:ge,remove(e){me(e,{force:!0})},rename:fe,append:ue});function K(e,t,r){let n=r.runtime??H,o=JSON.stringify(t);if(o===void 0)throw new TypeError("Rotating JSONL records must be JSON-serializable values.");let s=Buffer.from(`${o}
|
|
2
|
+
`),i=Math.max(1,Math.floor(r.maxSegmentBytes),s.length);return Y(e,r.lockTimeoutMs,n,()=>{n.makeDirectory(xe(e));let f=Se(e,A,n);r.onPhase?.("tail-repaired");let u=`${e}${r.previousSuffix??B}`,l=!1,c=!1;return n.exists(e)&&n.size(e)+s.length>i&&(n.exists(u)&&(n.remove(u),c=!0),r.onPhase?.("previous-pruned"),n.rename(e,u),l=!0,r.onPhase?.("current-rotated")),n.append(e,s),r.onPhase?.("record-appended"),{lineBytes:s.length,segmentLimitBytes:i,repairedTailBytes:f,rotated:l,prunedPrevious:c}})}function X(e,t={}){let r=t.runtime??H,n=he(t.maxSegmentBytes);return Y(e,t.lockTimeoutMs,r,()=>{let o=[],s=0,i=`${e}${t.previousSuffix??B}`;for(let f of[i,e]){if(!r.exists(f))continue;let u=Te(Q(f,n,r));o.push(...u.lines),s+=u.partialTailBytes}return{lines:o,ignoredPartialTailBytes:s}})}function Y(e,t,r,n){let o=`${e}${Re}`,s=Math.max(0,t??be),i=r.monotonicNow()+s,f;for(;;){let x=r.tryAcquireLock(o,e);if(x.kind==="acquired"){f=x.lock;break}let y=i-r.monotonicNow();if(y<=0)throw new C(o,s);r.wait(Math.min(5,y))}let u=!1,l,c;try{c=n()}catch(x){u=!0,l=x}let R=!1;try{R=f.release()}catch(x){if(!u)throw x}if(u)throw l;if(!R)throw new J(o);return c}function Se(e,t,r){if(!r.exists(e))return 0;let n=Q(e,t,r);if(n.length===0||n[n.length-1]===10)return 0;let o=n.lastIndexOf(10),s=o<0?0:o+1;return r.truncate(e,s),n.length-s}function he(e){let t=e??A;if(!Number.isSafeInteger(t)||t<=0)throw new RangeError(`maxSegmentBytes must be a positive safe integer; received ${t}`);return t}function Q(e,t,r){let n=r.size(e);if(n>t)throw new _("rotating JSONL segment",e,"too-large",n,t);let o=r.readBytes(e),s=r.size(e);if(s!==n||o.byteLength!==n)throw new _("rotating JSONL segment",e,"changed-during-read",s,t);return o}function Te(e){let t=e.lastIndexOf(10),r=t<0?0:t+1;return{lines:e.subarray(0,r).toString("utf8").split(`
|
|
3
|
+
`).filter(o=>o.length>0),partialTailBytes:e.length-r}}var Be="reindex-activity.jsonl",W=B,Ee=1024*1024,Pe=1440*60*1e3,Z=e=>v(e,"reindex activity segment");function E(e){return we(ve(e),Be)}function Oe(e){if(e.reused)return 0;let t=ee(e.indexPath)+ee(e.dbPath);for(let r of e.shards??[])!r.reused&&r.outputBytes!==null&&(t+=r.outputBytes);return t}function lt(e,t){let r=t.lastRefresh;return r?F(E(e),{version:1,event:"run",recordedAt:r.completedAt,trigger:r.trigger,result:r.result,durationMs:r.durationMs,estimatedLogicalOutputBytes:Oe(t)}):{state:"failed",reason:"reindex result has no refresh metadata"}}function ft(e,t){return F(E(e),{version:1,event:"run",recordedAt:t.completedAt,trigger:t.trigger,result:"failed",durationMs:t.durationMs,estimatedLogicalOutputBytes:0})}function mt(e,t,r=new Date){return F(E(e),{version:1,event:"suppressed",recordedAt:r.toISOString(),trigger:t,reason:"completed-index-is-fresh"})}function ke(e,t,r=Ee,n){K(e,t,{maxSegmentBytes:r,previousSuffix:W,...n?{runtime:n}:{}})}function pt(e,t=new Date,r=Pe,n=Z){let o=t.getTime(),s=o-r,i={confidence:"complete",recordsRead:0,invalidRecords:0,skippedRecords:0,readErrors:0,ignoredPartialTailBytes:0,windowStartedAt:new Date(s).toISOString(),windowEndedAt:t.toISOString(),runs:0,rebuilt:0,reused:0,failed:0,suppressed:0,estimatedLogicalOutputBytes:0,byTrigger:{}},f=E(e),u=[];if(n===Z)try{let l=X(f,{previousSuffix:W});u=l.lines,i.ignoredPartialTailBytes=l.ignoredPartialTailBytes}catch{i.readErrors+=1,i.confidence="unavailable"}else{let l=0;for(let c of[`${f}${W}`,f])try{u.push(...Me(n(c))),l+=1}catch{i.readErrors+=1}l===0?i.confidence="unavailable":i.readErrors>0&&(i.confidence="partial")}for(let l of u){i.recordsRead+=1;let c=Le(l);if(!c){i.invalidRecords+=1,i.confidence!=="unavailable"&&(i.confidence="partial");continue}let R=Date.parse(c.recordedAt);if(R<s||R>o){i.skippedRecords+=1;continue}if(i.byTrigger[c.trigger.kind]=(i.byTrigger[c.trigger.kind]??0)+1,c.event==="suppressed"){i.suppressed+=1;continue}i.runs+=1,i[c.result]+=1,i.estimatedLogicalOutputBytes+=c.estimatedLogicalOutputBytes}return i.ignoredPartialTailBytes>0&&i.confidence!=="unavailable"&&(i.confidence="partial"),i}function F(e,t){try{return ke(e,t),{state:"recorded"}}catch(r){return{state:"failed",reason:r instanceof Error?r.message:String(r)}}}function Le(e){try{let t=JSON.parse(e);if(!t||typeof t!="object")return null;let r=t;return r.version!==1||!w(r.recordedAt)||!r.trigger||!Ie(r.trigger.kind)?null:r.event==="suppressed"?r.reason==="completed-index-is-fresh"?r:null:r.event!=="run"||r.result!=="rebuilt"&&r.result!=="reused"&&r.result!=="failed"||!N(r.durationMs)||!N(r.estimatedLogicalOutputBytes)?null:r}catch{return null}}function Ie(e){return e==="manual-cli"||e==="setup"||e==="watch-source"||e==="watch-startup"||e==="watch-demand"||e==="watch-git-head"||e==="watch-git-index"||e==="watch-git-state"||e==="unknown"}function ee(e){try{return Ae(e).size}catch{return 0}}function Me(e){return e.endsWith(`
|
|
4
|
+
`)||(e=e.slice(0,Math.max(0,e.lastIndexOf(`
|
|
5
|
+
`)+1))),e.split(`
|
|
6
|
+
`).filter(t=>t.length>0)}import{join as P}from"path";var St=5;var _e="watch.lock",Ne="watch-state.json",Ce="watch-activity.json",Je="watch-refresh-requests";function ht(e){return{lockPath:P(e,_e),statePath:P(e,Ne),activityPath:P(e,Ce),refreshRequestsPath:P(e,Je)}}function Tt(e){try{return We(JSON.parse(v(e,"watch service state")))}catch{return null}}function We(e){if(!e||typeof e!="object")return null;let t=e;if(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"||!g(t.startedAt)||!g(t.heartbeatAt)||!g(t.lastActivityAt)||!Fe(t.watcher)||t.idleDeadlineAt!==void 0&&!g(t.idleDeadlineAt))return null;if(t.processIdentity!==void 0){let r=D(t.processIdentity);if(!r||r.pid!==t.pid)return null;t.processIdentity=r}return t.indexGeneration!==void 0&&!/^[a-f0-9]{64}$/.test(t.indexGeneration)||t.lastError!==void 0&&!qe(t.lastError)||t.lastRefresh!==void 0&&!$e(t.lastRefresh)||t.reindexActivity!==void 0&&!je(t.reindexActivity)||t.refreshRequests!==void 0&&!Ve(t.refreshRequests)||t.typescriptSemantic!==void 0&&!De(t.typescriptSemantic)||t.typescriptIndex!==void 0&&!ze(t.typescriptIndex)?null:t}function g(e){return w(e)}function Fe(e){if(!e||typeof e!="object"||!("state"in e))return!1;let t=e;switch(t.state){case"idle":return!0;case"waiting":return p(t.changedFiles)&&p(t.reindexAt);case"indexing":return p(t.startedAt);case"cooldown":return p(t.until)&&typeof t.dirty=="boolean";case"draining":return p(t.startedAt)&&typeof t.reason=="string";default:return!1}}function qe(e){if(!e||typeof e!="object")return!1;let t=e;return g(t.at)&&typeof t.message=="string"}function $e(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.trigger?.kind=="string"&&typeof t.result=="string"&&g(t.startedAt)&&g(t.completedAt)&&p(t.durationMs)}function je(e){if(!e||typeof e!="object")return!1;let t=e;return t.confidence!==void 0&&t.confidence!=="complete"&&t.confidence!=="partial"&&t.confidence!=="unavailable"||t.recordsRead!==void 0&&!a(t.recordsRead)||t.invalidRecords!==void 0&&!a(t.invalidRecords)||t.skippedRecords!==void 0&&!a(t.skippedRecords)||t.readErrors!==void 0&&!a(t.readErrors)||t.ignoredPartialTailBytes!==void 0&&!a(t.ignoredPartialTailBytes)||!g(t.windowStartedAt)||!g(t.windowEndedAt)||!a(t.runs)||!a(t.rebuilt)||!a(t.reused)||!a(t.failed)||!a(t.suppressed)||!p(t.estimatedLogicalOutputBytes)||t.estimatedLogicalOutputBytes<0||!t.byTrigger||typeof t.byTrigger!="object"?!1:Object.values(t.byTrigger).every(r=>r===void 0||a(r))}function Ve(e){if(!e||typeof e!="object")return!1;let t=e;return a(t.pending)&&a(t.claimed)&&a(t.completed)&&a(t.expired)&&a(t.invalid)&&(t.oldestPendingAt===void 0||g(t.oldestPendingAt))}function De(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")&&p(t.requests)&&p(t.sessionsCreated)&&p(t.sessionsReused)&&p(t.sessionsRefreshed)&&p(t.sessionsReplaced)&&p(t.projectsCreated)&&(t.lastRequestAt===void 0||g(t.lastRequestAt))&&(t.lastError===void 0||typeof t.lastError=="string")&&(t.busyUntil===void 0||g(t.busyUntil))&&(t.mailbox===void 0||te(t.mailbox))}function ze(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.sessionsReplaced)&&a(t.initializations)&&a(t.programUpdates)&&a(t.documentsEmitted)&&a(t.documentsRemoved)&&(t.lastRequestAt===void 0||g(t.lastRequestAt))&&(t.lastDurationMs===void 0||p(t.lastDurationMs)&&t.lastDurationMs>=0)&&(t.lastError===void 0||typeof t.lastError=="string")&&(t.busyUntil===void 0||g(t.busyUntil))&&(t.mailbox===void 0||te(t.mailbox))}function te(e){if(!e||typeof e!="object")return!1;let t=e;return a(t.pending)&&a(t.inflight)&&a(t.responses)&&a(t.deadLetters)&&a(t.invalid)&&a(t.totalItems)&&p(t.totalBytes)&&t.totalBytes>=0&&t.totalItems===t.pending+t.inflight+t.responses+t.deadLetters&&(t.oldestPendingAt===void 0||g(t.oldestPendingAt))}function p(e){return typeof e=="number"&&Number.isFinite(e)}var Ue=new Map([[8,"\u2408"],[9,"\u2409"],[10,"\u2424"],[13,"\u240D"]]);function Ge(e,t={}){let r=t.allowNewlines??!0,n=t.allowTabs??!0,o="";for(let s=0;s<e.length;){let i=e.charCodeAt(s);if(i===27){s=He(e,s);continue}if(i===155){s=re(e,s+1);continue}if(i===144||i===152||i===157||i===158||i===159){s=ne(e,s+1);continue}if(Ye(i)){i===10&&r?o+=`
|
|
7
|
+
`:i===9&&n?o+=" ":o+=Ue.get(i)??"\uFFFD",s+=1;continue}if(Qe(i)){o+="\uFFFD",s+=1;continue}o+=e[s],s+=1}return o}function vt(e){return Ge(e,{allowNewlines:!1,allowTabs:!1})}function He(e,t){let r=e.charCodeAt(t+1);if(Number.isNaN(r))return e.length;if(r===91)return re(e,t+2);if(r===80||r===88||r===93||r===94||r===95)return ne(e,t+2);let n=t+1;for(;n<e.length&&Ke(e.charCodeAt(n));)n+=1;return n<e.length&&Xe(e.charCodeAt(n))?n+1:t+1}function re(e,t){let r=t;for(;r<e.length;){let n=e.charCodeAt(r);if(r+=1,n>=64&&n<=126)return r}return e.length}function ne(e,t){let r=t;for(;r<e.length;){let n=e.charCodeAt(r);if(n===7||n===156)return r+1;if(n===27&&e.charCodeAt(r+1)===92)return r+2;r+=1}return e.length}function Ke(e){return e>=32&&e<=47}function Xe(e){return e>=48&&e<=126}function Ye(e){return e<=31||e>=127&&e<=159}function Qe(e){return e===1564||e===8206||e===8207||e>=8234&&e<=8238||e>=8294&&e<=8297}import{spawn as Ze}from"child_process";import{platform as ie}from"os";import{performance as se}from"perf_hooks";var kt={probe:1e4,git:3e4,analysis:18e4,install:3e5,indexer:6e5},T=class extends Error{constructor(r,n,o,s={}){super(o,s.cause===void 0?void 0:{cause:s.cause});this.kind=r;this.label=n;this.name="BoundedProcessError",this.timedOut=s.timedOut??!1,this.reaped=s.reaped??!1,this.stdout=s.stdout??"",this.stderr=s.stderr??"",this.stdoutTruncated=s.stdoutTruncated??!1,this.stderrTruncated=s.stderrTruncated??!1}kind;label;timedOut;reaped;stdout;stderr;stdoutTruncated;stderrTruncated};function h(e,t){if(!Number.isFinite(e)||e<=0)throw new TypeError(`${t} must be a positive finite number.`)}function oe(e,t,r,n){let o=Math.max(0,n-r);o>0&&e.push(t.subarray(0,o))}function ae(e,t,r){let n=Buffer.concat([...e,t]);e.length=0,e.push(n.subarray(Math.max(0,n.length-r)))}function Lt(e){h(e.timeoutMs,"timeoutMs"),h(e.maxStdoutBytes,"maxStdoutBytes"),h(e.maxStderrBytes,"maxStderrBytes");let t=e.terminationGraceMs??1e3;h(t,"terminationGraceMs");let r=e.terminationForceMs??t;return h(r,"terminationForceMs"),new Promise((n,o)=>{let s=se.now(),i;try{let d=ie()!=="win32";i=Ze(e.command,[...e.args??[]],{cwd:e.cwd,env:e.env,detached:d?!0:e.detached,stdio:["pipe","pipe","pipe"]})}catch(d){o(new T("spawn",e.label,`${e.label} could not start.`,{cause:d,reaped:!0}));return}let f=[],u=[],l=0,c=0,R=!1,x=!1,y=null,b=!1,de=ie()!=="win32",q=i.pid===void 0?null:U(i.pid,de),O=()=>{clearTimeout($),e.signal?.removeEventListener("abort",L)},k=d=>{if(b||!y)return;b=!0,O();let m=Buffer.concat(f).toString("utf8"),I=Buffer.concat(u).toString("utf8"),M=d.reaped||!d.detail?"":` Process-tree cleanup failed: ${d.detail}`;o(new T(y.kind,e.label,`${y.message}${M}`,{timedOut:y.timedOut,reaped:d.reaped,stdout:m,stderr:I,stdoutTruncated:R,stderrTruncated:x}))},S=d=>{if(!(y||b)){if(y=d,!q){k({reaped:i.pid===void 0,reason:i.pid===void 0?"terminated":"identity-unavailable"});return}G(q,{gracefulMs:t,forceMs:r}).then(k,m=>{k({reaped:!1,reason:"signal-failed",detail:m instanceof Error?m.message:String(m)})})}},$=setTimeout(()=>{S({kind:"timeout",timedOut:!0,message:`${e.label} timed out after ${e.timeoutMs}ms.`})},e.timeoutMs);$.unref();let L=()=>{S({kind:"aborted",timedOut:!1,message:`${e.label} was cancelled.`})};e.signal?.addEventListener("abort",L,{once:!0}),e.signal?.aborted&&L(),i.stdout.on("data",d=>{let m=Buffer.isBuffer(d)?d:Buffer.from(d);e.outputLimitBehavior==="truncate-tail"?ae(f,m,e.maxStdoutBytes):oe(f,m,l,e.maxStdoutBytes),l+=m.length,l>e.maxStdoutBytes&&(R=!0,e.outputLimitBehavior!=="truncate-tail"&&S({kind:"stdout-limit",timedOut:!1,message:`${e.label} exceeded stdout limit (${e.maxStdoutBytes} bytes).`}))}),i.stderr.on("data",d=>{let m=Buffer.isBuffer(d)?d:Buffer.from(d);e.outputLimitBehavior==="truncate-tail"?ae(u,m,e.maxStderrBytes):oe(u,m,c,e.maxStderrBytes),c+=m.length,c>e.maxStderrBytes&&(x=!0,e.outputLimitBehavior!=="truncate-tail"&&S({kind:"stderr-limit",timedOut:!1,message:`${e.label} exceeded stderr limit (${e.maxStderrBytes} bytes).`}))}),i.on("error",d=>{if(!b&&!y){if(i.pid===void 0){O(),b=!0,o(new T("spawn",e.label,`${e.label} could not start: ${d.message}`,{cause:d,reaped:!0}));return}S({kind:"spawn",timedOut:!1,message:`${e.label} failed after start: ${d.message}`})}}),i.on("close",(d,m)=>{if(b||y)return;b=!0,O();let I=Buffer.concat(f).toString("utf8"),M=Buffer.concat(u).toString("utf8");n({status:d,signal:m,stdout:I,stderr:M,timedOut:!1,durationMs:se.now()-s,stdoutTruncated:R,stderrTruncated:x})}),e.input===void 0?i.stdin.end():i.stdin.end(e.input)})}export{B as a,K as b,Be as c,lt as d,ft as e,mt as f,pt as g,St as h,ht as i,Tt as j,g as k,kt as l,T as m,Lt as n,vt as o};
|
|
8
|
+
//# sourceMappingURL=chunk-L5GJNV2T.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as g}from"./chunk-
|
|
1
|
+
import{a as g}from"./chunk-S7OYBOCK.js";import{j as p}from"./chunk-HX7M4BDI.js";import{a as f}from"./chunk-T7YQSHPQ.js";import{d as u,e as _,i as N}from"./chunk-EKZTZXHZ.js";import{p as d}from"./chunk-UJPRPGCO.js";import{x as l}from"./chunk-GH74ASD6.js";import{J as b}from"./chunk-WCCFZ7V7.js";import{a as I}from"./chunk-NGEXCJJW.js";import{c}from"./chunk-C3KV2II6.js";function Y(e,t,r={}){return T(e,t,r)?.map(s=>({symbol:s.symbol,shortName:s.shortName,fromFile:s.fromFile}))??[]}function Z(e,t){let r=f(e,t),s=O(e,t);if(s.length>0&&!x(r))return s;let o=k(e,t,r);return h(t)&&o.length>0?o:D([...s,...o])}function G(e,t,r={}){let s=g(e,t);if(!s)return[];let o=S(e,s),n=r.semantic===!1?null:E(e,s);return(n?R(n,o):o).filter(m=>!m.used).map(m=>({symbol:m.symbol,shortName:m.shortName,importedIn:m.importer}))}function R(e,t){let r=new Map;for(let o of t){let n=r.get(o.shortName);n?n.push(o):r.set(o.shortName,[o])}let s=e.map(o=>{let n=r.get(o.shortName),i=n?.shift();return n?.length===0&&r.delete(o.shortName),i?{...o,used:o.used||i.used}:o});return s.push(...[...r.values()].flat()),s}function O(e,t){return e.all(`SELECT DISTINCT gs.symbol, d.relative_path AS importer
|
|
2
2
|
FROM mentions m
|
|
3
3
|
JOIN chunks c ON m.chunk_id = c.id
|
|
4
4
|
JOIN documents d ON c.document_id = d.id
|
|
@@ -32,4 +32,4 @@ import{a as g}from"./chunk-33XTHFKR.js";import{j as p}from"./chunk-E2LAW7SL.js";
|
|
|
32
32
|
WHERE imp_d.relative_path = ?
|
|
33
33
|
AND m.role = 2
|
|
34
34
|
ORDER BY def_d.relative_path, gs.symbol`,t).filter(n=>!e.isIgnored(n.importer));if(o.length>0){let n=r.semantic===!1?[]:p(e,t);return o.map(i=>({symbol:i.symbol,shortName:u(i.symbol),fromFile:i.from_file??"(external)",importer:i.importer,used:i.used!==0||n.some(m=>m.isUsed&&m.sourcePath===i.from_file)}))}return null}function E(e,t){let r=p(e,t);return r.length>0?r.map(s=>{let o=y(s.importedName,s.localName,s.kind);return{symbol:o,shortName:o,fromFile:s.sourcePath??"(external)",importer:t,used:s.kind==="side-effect"?!0:s.isUsed}}):null}function S(e,t){let r=A(t,b(e,t));return d(e,t).map(s=>{let o=y(s.importedName,s.localName,s.kind),n=s.kind==="side-effect"||v(t,s)||r.has(s.localName??s.importedName)?!0:s.used;return{symbol:o,shortName:o,fromFile:s.sourcePath??"(external)",importer:t,used:n}})}function A(e,t){let r=new Set;if(l(e)!=="python")return r;let s=/(?:^|\n)\s*__all__\s*(?:\+?=)\s*[[(]([\s\S]*?)[\])]/g;for(let o of t.matchAll(s)){let n=o[1]??"";for(let i of n.matchAll(/(['"])([A-Za-z_]\w*)\1/g))r.add(i[2])}return r}function v(e,t){if(l(e)!=="rust"||t.used||t.kind==="side-effect")return!1;let r=t.localName??t.importedName;return r==="_"||/^[A-Z]/.test(r)}function y(e,t,r){return r==="namespace"&&e==="*"&&t?`* as ${t}`:r==="default"&&t?`default as ${t}`:r==="side-effect"?"(side effect import)":t&&t!==e?`${e} as ${t}`:e}function $(e){return/\.(?:c|h|cc|cpp|cxx|hpp|hh|hxx)$/i.test(e)}export{Y as a,Z as b,G as c};
|
|
35
|
-
//# sourceMappingURL=chunk-
|
|
35
|
+
//# sourceMappingURL=chunk-L7AW2QB5.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{a as r}from"./chunk-AFHORGLH.js";import{b as l}from"./chunk-S7OYBOCK.js";import{x as n}from"./chunk-EKZTZXHZ.js";function R(e,i){let s=l(e,i);if(s.length===0)return{files:[],symbols:[],dependsOn:[],dependedOnBy:[]};let a=s.map(()=>"?").join(", "),o=e.all(`SELECT relative_path FROM documents
|
|
2
|
+
WHERE relative_path IN (${a})
|
|
3
|
+
ORDER BY relative_path`,...s).map(t=>t.relative_path).filter(t=>!e.isIgnored(t)),m=n(e,o,{onlyDocumented:!0,sort:!0}).map(({relativePath:t,...f})=>f),p=r(e,"forward",s).filter(t=>!e.isIgnored(t)),d=r(e,"reverse",s).filter(t=>!e.isIgnored(t));return{files:o,symbols:m,dependsOn:p,dependedOnBy:d}}export{R as a};
|
|
4
|
+
//# sourceMappingURL=chunk-L7JDSCDF.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{$a as ne,A as y,Ee as Je,Fa as S,Ga as H,Gd as ce,Ha as W,Ia as E,Ja as U,Ma as te,Na as _e,Oa as Le,Pa as C,Qa as re,Xa as qe,Ya as Me,_a as k,ab as De,cb as se,db as Ne,eb as He,f as T,hb as ie,he as ze,ie as Ve,oe as Fe,p as We,pb as oe,qb as $,rb as ae,sb as Ue,tb as $e,ub as Be,wf as Ke,xd as B,yd as Ge,zd as je}from"./chunk-JFGGXWQF.js";import{spawn as dr}from"child_process";import{existsSync as pr,rmSync as Xe}from"fs";import{dirname as hr,resolve as J}from"path";import{fileURLToPath as lr}from"url";import{createHash as jt,randomUUID as Ye}from"crypto";import{existsSync as zt,linkSync as Vt,readdirSync as Ft,rmSync as Jt}from"fs";import{basename as Kt,dirname as Yt,join as I}from"path";var j=1,Qt=10*6e4,Rn=10080*6e4,ue="requests",Xt="claims",Zt="completions",er="staging";function Qe(e,t,r={}){let n=r.now?.()??new Date,s=ar(r.ttlMs),i=cr(r.idempotencyKey),c=i?`key-${jt("sha256").update(i).digest("hex")}`:`request-${(r.randomId??Ye)()}`,o={version:j,requestId:c,...i?{idempotencyKey:i}:{},createdAt:n.toISOString(),deadlineAt:new Date(n.getTime()+s).toISOString(),detail:t.trim().slice(0,2048)||"stale index observed by a command"},a=or(e,c),u=nr(e,a,o,r.onStage);if(u.published)return{disposition:"accepted",request:o,achievedDurability:u.achievedDurability,directorySync:u.directorySync};let d=de(a);if(!d)throw new Error(`Watch refresh request identity ${c} exists but is malformed.`);return{disposition:"duplicate",request:d}}function On(e){let t=sr(e),r=new Map,n=ir(I(e,ue),de);for(let a of G(I(e,Zt))){let u=rr(a);if(!u){n++;continue}r.set(u.requestId,u)}let s=new Set;for(let a of G(I(e,Xt))){let u=tr(a);if(!u){n++;continue}s.add(u.requestId)}let i=t.filter(a=>!r.has(a.requestId)&&!s.has(a.requestId)),c=[...r.values()].filter(a=>a.outcome==="completed").length,o=[...r.values()].filter(a=>a.outcome==="expired").length;return{pending:i.length,claimed:t.filter(a=>!r.has(a.requestId)&&s.has(a.requestId)).length,completed:c,expired:o,invalid:n,...i.length>0?{oldestPendingAt:i.map(a=>a.createdAt).reduce((a,u)=>ur(a,u))}:{}}}function de(e){return pe(e,t=>{let r=t;return r.version===j&&_(r.requestId)&&(r.idempotencyKey===void 0||typeof r.idempotencyKey=="string")&&T(r.createdAt)&&T(r.deadlineAt)&&Date.parse(r.deadlineAt)>=Date.parse(r.createdAt)&&typeof r.detail=="string"&&r.detail.length>0})}function tr(e){return pe(e,t=>{let r=t;return r.version===j&&_(r.requestId)&&_(r.claimId)&&T(r.claimedAt)})}function rr(e){return pe(e,t=>{let r=t;return r.version===j&&_(r.requestId)&&(r.claimId===void 0||_(r.claimId))&&(r.outcome==="completed"||r.outcome==="expired")&&T(r.completedAt)})}function nr(e,t,r,n){let s=I(e,er),i=Yt(t),c=te(s),o=te(i),a=I(s,`${Kt(t)}.${process.pid}.${Ye()}.tmp`);try{let u=re(a,r,{spacing:2,trailingNewline:!0});n?.("after-staged");try{Vt(a,t)}catch(h){if(h.code==="EEXIST")return{published:!1};throw h}let d=Le(c,o,u.directorySync,_e(i));return n?.("after-published"),{published:!0,achievedDurability:d==="synced"?"directory-durable":"file-flushed",directorySync:d}}finally{Jt(a,{force:!0})}}function sr(e){let t=[];for(let r of G(I(e,ue))){let n=de(r);n&&t.push(n)}return t}function ir(e,t){return G(e).filter(r=>!t(r)).length}function G(e,t=".json"){return zt(e)?Ft(e,{withFileTypes:!0}).filter(r=>r.isFile()&&r.name.endsWith(t)).map(r=>I(e,r.name)).sort():[]}function pe(e,t){try{let r=JSON.parse(y(e,"watch refresh request record"));return t(r)?r:null}catch{return null}}function or(e,t){return I(e,ue,`${t}.json`)}function ar(e){if(e===void 0)return Qt;if(!Number.isFinite(e)||e<=0)throw new Error("Watch refresh request ttlMs must be positive.");return Math.floor(e)}function cr(e){let t=e?.trim();return t?t.slice(0,512):void 0}function _(e){return typeof e=="string"&&/^[a-z0-9][a-z0-9-]{0,127}$/i.test(e)}function ur(e,t){return Date.parse(t)<Date.parse(e)?t:e}var Ze=5e3,fr=6e3,gr=1e3,le=10,mr=new Set(["bench","config-validate","hook-context","hook-stop","init","reindex","setup","setup-agent","setup-ci","setup-hooks","uninstall","watch","work-audit"]);function Hn(e){let t=e.classification;if(t.kind!=="live")return;let{state:r}=t;return r.watcher.state==="idle"&&r.lastError===void 0?r.indexGeneration:void 0}function yr(e,t=process.env){return t.SCIP_QUERY_SKIP_WATCH_SERVICE!=="1"&&!e.startsWith("__")&&!mr.has(e)}function Un(e){let t=e.env??process.env;if(t.SCIP_QUERY_SKIP_WATCH_SERVICE==="1")return{kind:"skipped",reason:"environment"};if(!yr(e.commandName,t))return{kind:"skipped",reason:"excluded-command"};if(e.config.watch?.enabled!==!0)return{kind:"skipped",reason:"disabled"};try{let r=Sr({projectRoot:e.projectRoot,cacheDir:e.cacheDir,cliVersion:e.cliVersion,gitContext:e.gitContext,runtime:e.runtime});return{kind:r.disposition,state:r.state}}catch(r){return{kind:"failed",message:r instanceof Error?r.message:String(r)}}}function rt(e,t,r){let n=ie(J(e));if(r&&ie(r.projectRoot)===n)return{projectRoot:n,worktreeKind:"git",worktreeId:r.worktreeId,cliVersion:t};let s=Ne(n);if(s.kind==="error")throw new Error(`Could not establish Git worktree identity for ${n}: ${s.message}`);return s.kind==="non-git"?{projectRoot:n,worktreeKind:"non-git",cliVersion:t}:{projectRoot:n,worktreeKind:"git",worktreeId:s.identity.worktreeId,cliVersion:t}}function $n(e){return V(e,rt(e.projectRoot,e.cliVersion,e.gitContext))}function V(e,t){let r=e.runtime??ye,n=k(e.cacheDir),s=ne(n.statePath),i=me(n.lockPath);return{identity:t,classification:vr(s,t,r.now(),r.isProcessAlive),lock:i,lockIsLive:i!==null&&r.isProcessAlive(i.pid),paths:n}}function Sr(e){let t=e.runtime??ye,r=rt(e.projectRoot,e.cliVersion,e.gitContext),n=V(e,r),s=fe("ensure",n.classification);if(s.kind==="reuse")return z(n.paths.activityPath,t),{disposition:"reused",state:s.state};if(s.kind==="refuse-replace")throw new Error(`scip-query watch service pid ${s.state.pid} is still alive but its heartbeat is old. Refusing automatic replacement because civil-clock age alone cannot authorize a process signal.`);if(s.kind==="replace")ge(s.state,e,t),L(n.paths,s.state.pid,t);else if(s.kind==="start"){if(n.lockIsLive){let o=et(e,r,t,Math.min(e.startupTimeoutMs??1e3,1e3));if(o)return z(n.paths.activityPath,t),{disposition:"reused",state:o};throw new Error(`scip-query watch is already running for ${J(e.projectRoot)} (pid ${n.lock?.pid}; lock: ${n.paths.lockPath}) without compatible daemon state. Stop the foreground watcher before starting the service.`)}n.classification.kind==="stale"&&L(n.paths,n.classification.state.pid,t)}else throw new Error(`Unexpected ensure action: ${s.kind}`);if(n=V(e,r),s=fe("ensure",n.classification),s.kind==="reuse")return z(n.paths.activityPath,t),{disposition:"reused",state:s.state};if(s.kind==="refuse-replace")throw new Error(`scip-query watch service pid ${s.state.pid} remains alive with an old heartbeat; automatic replacement is not authorized.`);let i=e.serverPath??lr(new URL("./watch-server.js",import.meta.url));t.spawnServer(i,r.projectRoot,e.cliVersion,e.watchOverrides??{});let c=et(e,r,t,e.startupTimeoutMs??Ze);if(!c)throw new Error(`scip-query watch service did not become ready within ${e.startupTimeoutMs??Ze}ms.`);return z(n.paths.activityPath,t),{disposition:"started",state:c}}function nt(e){let t=e.runtime??ye,r=k(e.cacheDir),n=ne(r.statePath),s=n?t.isProcessAlive(n.pid)?{kind:"live",state:n}:{kind:"stale",state:n,reason:"dead-process"}:{kind:"stopped"},i=fe("stop",s);if(i.kind==="signal-stop")return ge(i.state,e,t),L(r,i.state.pid,t),{disposition:"stopped",pid:i.state.pid};if(i.kind==="clean-stale")return L(r,i.state.pid,t),{disposition:"stopped",pid:i.state.pid};let c=me(r.lockPath);return i.kind==="already-stopped"&&c&&t.isProcessAlive(c.pid)?(ge(c,e,t),L(r,c.pid,t),{disposition:"stopped",pid:c.pid}):{disposition:"already-stopped"}}function st(e,t=Date.now()){C(e,{version:1,at:new Date(t).toISOString()})}function Bn(e,t,r=Date.now(),n={}){Qe(k(hr(e)).refreshRequestsPath,t,{...n,now:()=>new Date(r)}),st(e,r)}function Gn(e,t,r={}){let n=r.pid??process.pid,s=r.isProcessAlive??S,i=()=>{},c=r.readProcessIdentity??E,o=r.now??(()=>new Date),a={...oe,wallNow:()=>o().getTime(),isProcessAlive:s,readProcessIdentity:c},u=$(e,{kind:"watch",pid:n,processIdentity:c(n),detail:{projectRoot:J(t)},parseLegacy:F,runtime:a});if(u.kind==="contended"){let d=it(u.observation);return{acquired:!1,lockPath:e,message:wr(e,t,d),release:i}}return{acquired:!0,lockPath:e,message:"",release:()=>{u.lock.release()}}}function me(e){return it(ae(e,{parseLegacy:F}))}var F=e=>{let t=ot(e);return t?{pid:t.pid,...t.processIdentity?{processIdentity:t.processIdentity}:{}}:null};function it(e){if(e.state==="valid"&&e.record?.kind==="watch"){let t=e.record.detail?.projectRoot;return typeof t!="string"?null:{version:1,pid:e.record.pid,...e.record.processIdentity?{processIdentity:e.record.processIdentity}:{},projectRoot:t,startedAt:e.record.startedAt}}return ot(e.parsed)}function ot(e){try{let t=e;if(t.version!==1||typeof t.pid!="number"||!Number.isInteger(t.pid)||t.pid<=0||typeof t.projectRoot!="string"||!De(t.startedAt))return null;let r=t.processIdentity===void 0?null:H(t.processIdentity);return t.processIdentity!==void 0&&(!r||r.pid!==t.pid)?null:{version:1,pid:t.pid,...r?{processIdentity:r}:{},projectRoot:t.projectRoot,startedAt:t.startedAt}}catch{return null}}function vr(e,t,r,n){if(!e)return{kind:"stopped"};if(e.protocolVersion!==qe)return{kind:"incompatible",state:e,reason:"protocol"};if(e.projectRoot!==t.projectRoot)return{kind:"incompatible",state:e,reason:"project"};let s=t.worktreeKind==="git"?t.worktreeId:void 0;if(e.worktreeId!==s)return{kind:"incompatible",state:e,reason:"worktree"};if(e.cliVersion!==t.cliVersion)return{kind:"incompatible",state:e,reason:"cli-version"};if(!n(e.pid))return{kind:"stale",state:e,reason:"dead-process"};let i=Date.parse(e.heartbeatAt);return r-i>Me?{kind:"stale",state:e,reason:"old-heartbeat"}:{kind:"live",state:e}}function fe(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:"refuse-replace",state:t.state,reason:"old-heartbeat"}:{kind:"start"};case"live":return{kind:"reuse",state:t.state};case"incompatible":return{kind:"replace",state:t.state};default:return he(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 he(t)}default:return he(e)}}function et(e,t,r,n){let s=r.monotonicNow??U,i=s()+n;for(;s()<=i;){let c=V(e,t).classification;if(c.kind==="live")return c.state;r.sleep(le)}return null}function ge(e,t,r){let{pid:n}=e;if(!r.isProcessAlive(n))return;tt(e,r),r.signalProcess(n);let s=t.stopTimeoutMs??fr,i=r.monotonicNow??U,c=i()+s;for(;i()<=c;){if(!r.isProcessAlive(n))return;r.sleep(le)}if(!r.forceSignalProcess)throw new Error(`scip-query watch service pid ${n} did not stop within ${s}ms and forced termination is unavailable.`);tt(e,r),r.forceSignalProcess(n);let o=t.forceStopTimeoutMs??gr,a=i()+o;for(;i()<=a;){if(!r.isProcessAlive(n))return;let u=r.readProcessIdentity(n);if(e.processIdentity&&u&&!W(e.processIdentity,u))return;r.sleep(le)}throw new Error(`scip-query watch service pid ${n} remained alive ${o}ms after forced termination.`)}function L(e,t,r){if(Xe(e.statePath,{force:!0}),Xe(e.activityPath,{force:!0}),me(e.lockPath)?.pid===t&&!r.isProcessAlive(t)){let s={...oe,wallNow:r.now,isProcessAlive:r.isProcessAlive,readProcessIdentity:r.readProcessIdentity},i=ae(e.lockPath,{parseLegacy:F,runtime:s});Ue(e.lockPath,i,{parseLegacy:F,runtime:s})}}function wr(e,t,r){return`error: scip-query watch is already running for ${J(t)}${r?` (pid ${r.pid}, started ${r.startedAt}; lock: ${e})`:` (lock: ${e})`}. Stop that watcher before starting another.`}function z(e,t){try{(t.recordActivity??st)(e,t.now())}catch(r){let n=Ir(r);if(n!=="EPERM"&&n!=="EACCES"&&n!=="EROFS")throw r}}function Ir(e){return e.code}var ye={now:Date.now,monotonicNow:U,isProcessAlive:S,readProcessIdentity:E,spawnServer(e,t,r,n){if(!pr(e))throw new Error(`Watch service helper was not found at ${e}. Run npm run build first.`);dr(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")},forceSignalProcess(e){process.kill(e,"SIGKILL")},sleep(e){let t=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(t,0,0,e)}};function tt(e,t){if(!e.processIdentity)throw new Error(`Refusing to signal scip-query watch pid ${e.pid}: its ownership record has no process identity.`);let r=t.readProcessIdentity(e.pid);if(!r)throw new Error(`Refusing to signal scip-query watch pid ${e.pid}: its process identity is unavailable.`);if(!W(e.processIdentity,r))throw new Error(`Refusing to signal scip-query watch pid ${e.pid}: its process identity does not match the ownership record.`)}function he(e){throw new Error(`Unhandled watch service value: ${JSON.stringify(e)}`)}import{createHash as Y,randomUUID as br}from"crypto";import{chmodSync as Cr,closeSync as ve,fstatSync as at,lstatSync as Rr,mkdirSync as Or,openSync as ht,readSync as Pr,readdirSync as lt,renameSync as Er,rmSync as ft,statSync as kr,writeSync as Ar}from"fs";import{tmpdir as xr}from"os";import{join as M}from"path";import{StringDecoder as gt}from"string_decoder";import{InvalidArgumentError as ct}from"commander";var Tr="scip-query-output-page",Wr=1,K=12e3,A=256,x=1e5,ut=4096,we=32e6,_r=64*1024*1024,Lr=256*1024*1024,qr=32,Ie=32768,Oe=3600*1e3,mt=3;function yt(){return M(xr(),`scip-query-output-pages-${typeof process.getuid=="function"?process.getuid():"user"}`)}var b=/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u,St=1,Mr="quota.lock",Dr=2e3,Nr=5,dt=1024*1024,Hr=new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)),Se,Ur=Object.freeze({maxSnapshotBytes:_r,maxAggregateBytes:Lr,maxSnapshotCount:qr});var $r={writeStdout:e=>{process.stdout.write(e)},writeStderr:e=>{process.stderr.write(e)}};async function ss(e,t,r=$r){let n=e.pageSize??K,s=e.snapshotRoot??yt(),i=Kr(e.snapshotLimits),c=e.maxOutputCharacters??we;if(!Number.isSafeInteger(c)||c<=0)throw new Error("Output character safety limit must be a positive integer.");let o=Math.min(c,we);if(vt(n),e.cursor!==void 0&&e.cursor.length>ut)throw new Error(`Output cursor exceeds the ${ut}-character limit. Run the command again without --output-cursor.`);if(e.json&&e.pageSize===void 0&&e.cursor===void 0){await Br(e,t,r);return}let a=Et(e.argv),u=xt(e.invocationPrefix),d=Pt(e.command,e.cwd,u,a),h=e.cursor===void 0?void 0:an(e.cursor,d),l=h?.snapshotId,p;if(h)try{p=zr(h,n,o,s,e.onSnapshotRead)}catch(v){let Z=v instanceof Error?v.message:String(v);throw new Error(`${Z} Restart with: ${kt(u,a,n)}`,{cause:v})}else{let v=new Ce(d,u,e.command,e.cwd,a,n,o,s,i,!e.json),Z=Gr(ee=>v.write(ee)),Te=!1;try{await t(),Te=!0}finally{Z(),Te||v.abort()}let P;try{P=v.complete()}catch(ee){throw v.abort(),ee}l=P.snapshotId,p={content:P.content,offset:0,pageIndex:0,pageCount:P.pageCount,totalCharacters:P.totalCharacters,outputHash:P.outputHash}}let g=p.offset+p.content.length,f=p.pageIndex+1>=p.pageCount,O=f?void 0:sn({filteredArgv:a,invocationPrefix:u,invocationHash:d,nextPageIndex:p.pageIndex+1,outputHash:p.outputHash,pageSize:n,snapshotId:tn(l)});if(p.offset===0&&f&&e.cursor===void 0){r.writeStdout(p.content),l&&R(l,s);return}let xe={kind:Tr,schemaVersion:Wr,producer:{name:"scip-query",version:e.producerVersion},command:e.command,contentType:e.json?"application/json":"text/plain",agentInstruction:O?"INCOMPLETE EVIDENCE: do not draw conclusions or report completion from this partial page. Run page.continuation.command exactly, then repeat until page.complete is true.":"OUTPUT COMPLETE: all rendered characters have been retrieved. Evaluate the command result's own coverage separately.",page:O?{offset:p.offset,returnedCharacters:p.content.length,totalCharacters:p.totalCharacters,omittedCharacters:p.totalCharacters-p.content.length,remainingCharacters:p.totalCharacters-g,complete:!1,outputHash:p.outputHash,continuation:O}:{offset:p.offset,returnedCharacters:p.content.length,totalCharacters:p.totalCharacters,omittedCharacters:p.totalCharacters-p.content.length,remainingCharacters:p.totalCharacters-g,complete:!0,outputHash:p.outputHash},content:p.content};if(e.json){r.writeStdout(`${JSON.stringify(xe)}
|
|
3
|
+
`),f&&l&&R(l,s);return}r.writeStdout(pn(xe)),f&&l&&R(l,s)}function is(e){if(!/^\d+$/u.test(e))throw new ct(`Output page size must be an integer from ${A} through ${x}.`);let t=Number(e);try{vt(t)}catch{throw new ct(`Output page size must be an integer from ${A} through ${x}.`)}return t}function vt(e){if(!Number.isSafeInteger(e)||e<A||e>x)throw new Error(`Output page size must be an integer from ${A} through ${x}.`)}async function Br(e,t,r){let n=new be(K,e.maxOutputCharacters??we),s=process.stdout.write,i=!1,c=`${Je(`scip-query: JSON output exceeds ${K} characters and may be truncated by the client. Do not use possibly partial client output as evidence. Read every page with: ${kt(xt(e.invocationPrefix),Et(e.argv),K)}`)}
|
|
4
|
+
`;process.stdout.write=((o,a,u)=>{let d=n.push(o,a);return d!==void 0&&(i||(i=!0,r.writeStderr(c)),s.call(process.stdout,d)),wt(a,u),!0});try{await t();let o=n.finish();o.crossedPageBoundary&&!i&&(i=!0,r.writeStderr(c)),o.bytes.length>0&&s.call(process.stdout,o.bytes),i&&r.writeStderr(c)}finally{process.stdout.write=s}}function Gr(e){let t=process.stdout.write;return process.stdout.write=((r,n,s)=>{let i=jr(r,n);return e(i),wt(n,s),!0}),()=>{process.stdout.write=t}}function jr(e,t){return typeof e=="string"?Buffer.from(e,typeof t=="string"?t:"utf8"):Buffer.from(e)}function wt(e,t){let r=typeof e=="function"?e:t;typeof r=="function"&&r()}var be=class{constructor(t,r){this.limit=t;this.maxOutputCharacters=r}limit;maxOutputCharacters;decoder=new gt("utf8");chunks=[];overflowed=!1;totalCharacters=0;push(t,r){let n=typeof t=="string"?Buffer.from(t,typeof r=="string"?r:"utf8"):Buffer.from(t);if(this.addCharacters(this.decoder.write(n)),this.overflowed)return n;if(this.chunks.push(n),this.totalCharacters<=this.limit)return;this.overflowed=!0;let s=Buffer.concat(this.chunks);return this.chunks.length=0,s}finish(){this.addCharacters(this.decoder.end());let t=this.totalCharacters>this.limit,r=Buffer.concat(this.chunks);return this.chunks.length=0,{bytes:r,crossedPageBoundary:t}}addCharacters(t){if(this.totalCharacters+=t.length,!Number.isSafeInteger(this.totalCharacters)||this.totalCharacters>this.maxOutputCharacters)throw new Error(`Command output exceeds the ${this.maxOutputCharacters}-character safety limit. Narrow the query before retrying.`)}},Ce=class{constructor(t,r,n,s,i,c,o,a,u,d){this.invocationHash=t;this.invocationPrefix=r;this.command=n;this.cwd=s;this.argv=i;this.pageSize=c;this.maxOutputCharacters=o;this.snapshotRoot=a;this.limits=u;this.preferLineBoundaries=d;Pe(a),this.snapshotId=br(),this.temporaryPath=w(a,this.snapshotId,"tmp")}invocationHash;invocationPrefix;command;cwd;argv;pageSize;maxOutputCharacters;snapshotRoot;limits;preferLineBoundaries;snapshotId;temporaryPath;decoder=new gt("utf8");hash=Y("sha256");pages=[];descriptor=null;pending="";firstPageContent="";totalCharacters=0;pageCharacterOffset=0;byteLength=0;reservedBytes=0;opened=!1;finished=!1;write(t){if(this.finished)throw new Error("Output snapshot writer is closed.");this.appendDecoded(this.decoder.write(t))}complete(){if(this.finished)throw new Error("Output snapshot writer is closed.");if(this.appendDecoded(this.decoder.end()),this.finished=!0,!this.opened){let s=this.pending,i=Buffer.from(s);return this.assertWithinByteLimit(i.length),this.hash.update(i),this.pending="",{content:s,totalCharacters:this.totalCharacters,outputHash:this.hash.digest("hex"),pageCount:1}}if((this.pending.length>0||this.pages.length===0)&&(this.flushPage(this.pending),this.pending=""),this.descriptor===null)throw new Error("Output snapshot writer is not open.");ve(this.descriptor),this.descriptor=null;let t=this.hash.digest("hex"),r=w(this.snapshotRoot,this.snapshotId,"output"),n=w(this.snapshotRoot,this.snapshotId,"json");try{Er(this.temporaryPath,r);let s={version:mt,snapshotId:this.snapshotId,invocationHash:this.invocationHash,invocationPrefix:[...this.invocationPrefix],command:this.command,cwd:this.cwd,argv:[...this.argv],outputHash:t,pageSize:this.pageSize,pages:this.pages,totalCharacters:this.totalCharacters,byteLength:this.byteLength,createdAtMs:Date.now()};return C(n,s),pt(this.snapshotRoot,this.snapshotId,this.byteLength,"complete",this.limits),this.reservedBytes=this.byteLength,{content:this.firstPageContent,totalCharacters:this.totalCharacters,outputHash:t,pageCount:this.pages.length,snapshotId:this.snapshotId}}catch(s){throw R(this.snapshotId,this.snapshotRoot),s}}abort(){this.descriptor!==null&&(ve(this.descriptor),this.descriptor=null),this.finished=!0,R(this.snapshotId,this.snapshotRoot)}appendDecoded(t){if(t.length===0)return;let r=this.totalCharacters+t.length;if(!Number.isSafeInteger(r)||r>this.maxOutputCharacters)throw new Error(`Command output exceeds the ${this.maxOutputCharacters}-character safety limit. Narrow the query before retrying.`);for(this.totalCharacters=r,this.pending+=t,this.assertWithinByteLimit(this.byteLength+Buffer.byteLength(this.pending));this.pending.length>this.pageSize;){this.open();let n=nn(this.pending,this.pageSize,this.preferLineBoundaries),s=this.pending.slice(0,n);this.pending=this.pending.slice(n),this.flushPage(s)}}open(){if(!this.opened){Yr(this.snapshotRoot,this.snapshotId,0,this.limits);try{this.descriptor=ht(this.temporaryPath,"wx",384),this.opened=!0}catch(t){throw Qr(this.snapshotRoot,this.snapshotId),t}}}flushPage(t){if(this.descriptor===null)throw new Error("Output snapshot writer is not open.");if(this.pages.length>=Ie)throw new Error(`Command output requires more than ${Ie} snapshot pages. Retry with a larger --output-page-size or narrow the query.`);let r=Buffer.from(t),n=this.byteLength+r.length;if(this.assertWithinByteLimit(n),n>this.reservedBytes){let c=Math.min(this.limits.maxSnapshotBytes,Math.ceil(n/dt)*dt);pt(this.snapshotRoot,this.snapshotId,c,"active",this.limits),this.reservedBytes=c}let s=0;for(;s<r.length;){let c=Ar(this.descriptor,r,s,r.length-s);if(c<=0)throw new Error("Output snapshot write made no progress.");s+=c}let i={characterOffset:this.pageCharacterOffset,characterLength:t.length,byteOffset:this.byteLength,byteLength:r.length,hash:Y("sha256").update(r).digest("hex")};this.pages.length===0&&(this.firstPageContent=t),this.pages.push(i),this.hash.update(r),this.pageCharacterOffset+=t.length,this.byteLength=n}assertWithinByteLimit(t){if(!Number.isSafeInteger(t)||t>this.limits.maxSnapshotBytes)throw new Error(`Command output exceeds the ${this.limits.maxSnapshotBytes}-byte snapshot limit. Narrow the query before retrying.`)}};function zr(e,t,r,n,s){Pe(n);let i=It(e.snapshotId,n);if(i.invocationHash!==e.invocationHash||i.outputHash!==e.outputHash||i.snapshotId!==e.snapshotId)throw new Error("Output snapshot identity does not match this cursor.");if(e.pageSize!==t||i.pageSize!==t)throw new Error(`Output page size changed after this cursor was issued; use ${i.pageSize}.`);let c=i.pages[e.pageIndex];if(!c)throw new Error("Output cursor points past the current result.");if(i.totalCharacters>r)throw new Error(`Output snapshot exceeds the ${r}-character safety limit.`);if(Date.now()-i.createdAtMs>Oe)throw R(e.snapshotId,n),new Error("Output snapshot expired before all pages were read.");let o=w(n,e.snapshotId,"output"),a=ht(o,"r");try{let u=at(a);if(!u.isFile()||u.size!==i.byteLength)throw new Error("Output snapshot size or type changed.");let d=Buffer.allocUnsafe(c.byteLength),h=0;for(;h<d.length;){let g=Pr(a,d,h,d.length-h,c.byteOffset+h);if(g===0)break;h+=g,s?.(g)}let l=at(a);if(l.dev!==u.dev||l.ino!==u.ino||l.size!==u.size||h!==c.byteLength)throw new Error("Output snapshot changed while it was being read.");if(Y("sha256").update(d).digest("hex")!==c.hash)throw new Error("Output snapshot page no longer matches its metadata.");let p=d.toString("utf8");if(p.length!==c.characterLength)throw new Error("Output snapshot page character count changed.");return{content:p,offset:c.characterOffset,pageIndex:e.pageIndex,pageCount:i.pages.length,totalCharacters:i.totalCharacters,outputHash:i.outputHash}}catch(u){throw R(e.snapshotId,n),u}finally{ve(a)}}function It(e,t){if(!b.test(e))throw new Error("Output snapshot identifier is invalid.");let r;try{r=JSON.parse(y(w(t,e,"json"),"output snapshot metadata"))}catch(n){throw new Error("Output snapshot is unavailable.",{cause:n})}if(!Vr(r))throw new Error("Output snapshot metadata is invalid.");return r}function Vr(e){if(!e||typeof e!="object")return!1;let t=e;return t.version===mt&&typeof t.snapshotId=="string"&&b.test(t.snapshotId)&&q(t.invocationHash)&&Tt(t.invocationPrefix)&&typeof t.command=="string"&&t.command.length>0&&t.command.length<=256&&typeof t.cwd=="string"&&t.cwd.length>0&&t.cwd.length<=8192&&un(t.argv)&&Pt(t.command,t.cwd,t.invocationPrefix,t.argv)===t.invocationHash&&q(t.outputHash)&&Number.isSafeInteger(t.pageSize)&&(t.pageSize??0)>=A&&(t.pageSize??0)<=x&&Array.isArray(t.pages)&&t.pages.length>1&&t.pages.length<=Ie&&t.pages.every(Fr)&&Jr(t.pages)&&Number.isSafeInteger(t.totalCharacters)&&(t.totalCharacters??-1)>=0&&t.pages.reduce((r,n)=>r+n.characterLength,0)===t.totalCharacters&&Number.isSafeInteger(t.byteLength)&&(t.byteLength??-1)>=0&&t.pages.reduce((r,n)=>r+n.byteLength,0)===t.byteLength&&Number.isSafeInteger(t.createdAtMs)&&(t.createdAtMs??-1)>=0}function Fr(e){if(!e||typeof e!="object")return!1;let t=e;return Number.isSafeInteger(t.characterOffset)&&(t.characterOffset??-1)>=0&&Number.isSafeInteger(t.characterLength)&&(t.characterLength??0)>0&&Number.isSafeInteger(t.byteOffset)&&(t.byteOffset??-1)>=0&&Number.isSafeInteger(t.byteLength)&&(t.byteLength??0)>0&&q(t.hash)}function Jr(e){let t=0,r=0;for(let n of e){if(n.characterOffset!==t||n.byteOffset!==r)return!1;t+=n.characterLength,r+=n.byteLength}return!0}function Pe(e){Or(e,{recursive:!0,mode:448});let t=Rr(e);if(!t.isDirectory()||t.isSymbolicLink())throw new Error(`Output snapshot root is not a private directory: ${e}`);if(typeof process.getuid=="function"&&t.uid!==process.getuid())throw new Error(`Output snapshot root is not owned by the current user: ${e}`);process.platform!=="win32"&&Cr(e,448)}function Kr(e){let t={...Ur,...e};for(let[r,n]of Object.entries(t))if(!Number.isSafeInteger(n)||n<=0)throw new Error(`Output snapshot ${r} must be a positive integer.`);if(t.maxSnapshotBytes>t.maxAggregateBytes)throw new Error("Output snapshot maxSnapshotBytes cannot exceed maxAggregateBytes.");return t}function Yr(e,t,r,n){Q(e,()=>{Zr(e),bt(e,t,r,"active",n)})}function pt(e,t,r,n,s){if(!Number.isSafeInteger(r)||r<0||r>s.maxSnapshotBytes)throw new Error(`Command output exceeds the ${s.maxSnapshotBytes}-byte snapshot limit.`);Q(e,()=>{bt(e,t,r,n,s)})}function bt(e,t,r,n,s){if(!Number.isSafeInteger(r)||r<0||r>s.maxSnapshotBytes)throw new Error(`Command output exceeds the ${s.maxSnapshotBytes}-byte snapshot limit.`);let i=Xr(e),c=i.find(h=>h.snapshotId===t),o=i.reduce((h,l)=>h+l.reservedBytes,0)-(c?.reservedBytes??0)+r,a=i.length+(c?0:1);if(a>s.maxSnapshotCount||o>s.maxAggregateBytes)throw new Error(`Output snapshot capacity is full (${a}/${s.maxSnapshotCount} snapshots, ${o}/${s.maxAggregateBytes} bytes). Narrow the query or finish an existing pagination sequence before retrying.`);let u=Date.now(),d={version:St,snapshotId:t,pid:process.pid,...Re()?{processIdentity:Re()}:{},reservedBytes:r,state:n,createdAtMs:c?.createdAtMs??u,updatedAtMs:u};C(w(e,t,"reserve"),d)}function Qr(e,t){Q(e,()=>{ft(w(e,t,"reserve"),{force:!0})})}function Xr(e){let t=[];for(let r of lt(e,{withFileTypes:!0})){if(!r.isFile()||!r.name.endsWith(".reserve"))continue;let n=r.name.slice(0,-8);if(b.test(n))try{let s=JSON.parse(y(M(e,r.name),"output snapshot reservation"));if(!Ct(s)||s.snapshotId!==n)throw new Error("reservation identity is invalid");t.push(s)}catch(s){throw new Error(`Output snapshot reservation ${r.name} is invalid; retry after its owning process or snapshot expires.`,{cause:s})}}return t}function Ct(e){if(!e||typeof e!="object")return!1;let t=e;return t.version===St&&typeof t.snapshotId=="string"&&b.test(t.snapshotId)&&Number.isSafeInteger(t.pid)&&(t.pid??0)>0&&(t.processIdentity===void 0||H(t.processIdentity)!==null&&t.processIdentity.pid===t.pid)&&Number.isSafeInteger(t.reservedBytes)&&(t.reservedBytes??-1)>=0&&(t.state==="active"||t.state==="complete")&&Number.isSafeInteger(t.createdAtMs)&&Number.isSafeInteger(t.updatedAtMs)}function Zr(e){let t=Date.now();for(let r of lt(e,{withFileTypes:!0})){if(!r.isFile()||!r.name.endsWith(".reserve"))continue;let n=r.name.slice(0,-8);if(!b.test(n))continue;let s=null;try{let a=JSON.parse(y(M(e,r.name),"output snapshot reservation"));s=Ct(a)?a:null}catch{s=null}let i=en(w(e,n,"json")),c=s?.state==="active"&&S(s.pid)&&(s.processIdentity===void 0||(()=>{let a=E(s.pid);return a!==null&&W(s.processIdentity,a)})()),o=s?t-s.updatedAtMs>Oe:!1;c||i&&!o||!i&&s&&!o&&s.state==="complete"||Rt(n,e)}}function en(e){try{return kr(e),!0}catch{return!1}}function Q(e,t){Pe(e);let r=M(e,Mr),n=Date.now()+Dr;for(;;){let s=$(r,{kind:"output-snapshot-quota",processIdentity:Re()});if(s.kind==="acquired")try{return t()}finally{s.lock.release()}if(Date.now()>=n)throw new Error("Output snapshot quota is busy. Retry the command.");Atomics.wait(Hr,0,0,Nr)}}function Re(){return Se===void 0&&(Se=E(process.pid)),Se}function R(e,t){b.test(e)&&Q(t,()=>Rt(e,t))}function Rt(e,t){for(let r of["json","output","tmp","reserve"])ft(w(t,e,r),{force:!0})}function w(e,t,r){if(!b.test(t))throw new Error("Output snapshot identifier is invalid.");return M(e,`${t}.${r}`)}function tn(e){if(!e)throw new Error("Incomplete output did not create a resumable snapshot.");return e}function rn(e){return e>=55296&&e<=56319}function nn(e,t,r){if(r){let n=e.lastIndexOf(`
|
|
5
|
+
`,t-1);if(n>=0)return n+1}return rn(e.charCodeAt(t-1))?t-1:t}function sn(e){let t=on({invocationHash:e.invocationHash,pageIndex:e.nextPageIndex,pageSize:e.pageSize,outputHash:e.outputHash,snapshotId:e.snapshotId});return{cursor:t,command:At(e.invocationPrefix,e.filteredArgv,e.pageSize,t)}}function on(e){return Ke({version:3,...e})}function an(e,t){let r=Ot(e);if(!r)throw new Error("Invalid output cursor. Run the command again without --output-cursor.");if(r.invocationHash!==t)throw new Error("This output cursor belongs to a different command, working directory, or argument set. Run again without --output-cursor.");return r}function Ot(e){try{let t=JSON.parse(Buffer.from(e,"base64url").toString("utf8"));return cn(t)?t:null}catch{return null}}function os(e,t=yt()){let r=Ot(e);if(r)try{let n=It(r.snapshotId,t);if(n.invocationHash!==r.invocationHash||n.outputHash!==r.outputHash||n.pageSize!==r.pageSize||Date.now()-n.createdAtMs>Oe||!n.pages[r.pageIndex])return;let s=n.pages[r.pageIndex];return{snapshotId:n.snapshotId,pageIndex:r.pageIndex,command:n.command,cwd:n.cwd,continuationCommand:At(n.invocationPrefix,n.argv,n.pageSize,e),remainingCharacters:n.totalCharacters-s.characterOffset,totalCharacters:n.totalCharacters,outputHash:n.outputHash,createdAtMs:n.createdAtMs}}catch{return}}function cn(e){if(!e||typeof e!="object")return!1;let t=e;return t.version===3&&q(t.invocationHash)&&Number.isSafeInteger(t.pageIndex)&&(t.pageIndex??-1)>=1&&Number.isSafeInteger(t.pageSize)&&(t.pageSize??0)>=A&&(t.pageSize??0)<=x&&q(t.outputHash)&&typeof t.snapshotId=="string"&&b.test(t.snapshotId)}function q(e){return typeof e=="string"&&/^[a-f0-9]{64}$/u.test(e)}function Pt(e,t,r,n){return Y("sha256").update(JSON.stringify({command:e,cwd:t,invocationPrefix:r,argv:n})).digest("hex")}function Et(e){let t=[];for(let r=0;r<e.length;r+=1){let n=e[r];if(n==="--output-page-size"||n==="--output-cursor"){r+=1;continue}n.startsWith("--output-page-size=")||n.startsWith("--output-cursor=")||t.push(n)}return t}function kt(e,t,r){return Wt([...e,...t,"--output-page-size",String(r)])}function At(e,t,r,n){return Wt([...e,...t,"--output-page-size",String(r),"--output-cursor",n])}function xt(e){let t=e===void 0?["scip-query"]:[...e];if(!Tt(t))throw new Error("Output pagination invocation prefix must contain one to sixteen non-empty shell arguments.");return t}function Tt(e){return Array.isArray(e)&&e.length>0&&e.length<=16&&e.every(t=>typeof t=="string"&&t.length>0&&t.length<=2048&&!t.includes("\0")&&!t.includes("\r")&&!t.includes(`
|
|
6
|
+
`))}function un(e){return Array.isArray(e)&&e.length>0&&e.length<=256&&e.every(t=>typeof t=="string"&&t.length<=8192&&!t.includes("\0")&&!t.includes("\r")&&!t.includes(`
|
|
7
|
+
`))}function Wt(e){return e.map(dn).join(" ")}function dn(e){return/^[A-Za-z0-9_@%+=:,./-]+$/u.test(e)?e:`'${e.replaceAll("'",`'"'"'`)}'`}function pn(e){let t=e.page.continuation,r=Math.max(e.page.offset,e.page.offset+e.page.returnedCharacters-1),n=`[scip-query output page: characters ${e.page.offset}-${r} of ${e.page.totalCharacters}]
|
|
8
|
+
`,s=t?`
|
|
9
|
+
[Incomplete: ${e.page.remainingCharacters} characters remain. Continue exactly:
|
|
10
|
+
${t.command}]
|
|
11
|
+
`:`
|
|
12
|
+
[scip-query transport complete; evaluate command coverage separately]
|
|
13
|
+
`;return`${n}${e.content}${s}`}import{existsSync as Mt,lstatSync as X,readdirSync as Dt,realpathSync as _t,rmSync as D,statSync as Nt}from"fs";import{join as m,resolve as N,sep as Lt}from"path";var hn=3600*1e3,ln=2*1024*1024*1024,fn=300*1e3;function gn(e){let t=e.leases.filter(o=>o.managed&&!o.live&&!o.busy),r=Ht(e.leases,e.locks),n={};for(let o of e.generations)r.has(o.generationId)||(n[o.generationId]=o.unreferencedAt??e.nowMs);let s=e.generations.filter(o=>!r.has(o.generationId)).sort((o,a)=>n[o.generationId]-n[a.generationId]||o.generationId.localeCompare(a.generationId)),i=new Set;for(let o of s)e.nowMs-n[o.generationId]>=e.policy.generationTtlMs&&i.add(o.generationId);let c=e.generations.filter(o=>!i.has(o.generationId)).reduce((o,a)=>o+a.size,0);for(let o of s){if(c<=e.policy.budgetBytes)break;i.has(o.generationId)||(i.add(o.generationId),c-=o.size)}for(let o of i)delete n[o];return{deleteWorktrees:t,deleteGenerations:e.generations.filter(o=>i.has(o.generationId)),deleteLocks:e.locks.filter(o=>!o.live),deleteTemporaries:e.temporaries.filter(o=>!o.live),protectedGenerationIds:[...r].sort(),unreferencedSince:n}}function Ht(e,t){let r=new Set(e.filter(n=>n.managed&&(n.live||n.busy)).flatMap(n=>[n.lease.baseGenerationId,n.lease.activeGenerationId]).filter(n=>n!==void 0));for(let n of t)n.live&&r.add(n.generationId);return r}function ws(e,t,r={}){if(!je())return{kind:"disabled"};let n=se(e);if(!n)return{kind:"unavailable"};let s=m(B(),"repositories",n.repositoryId);if(!Mt(s))return{kind:"unavailable"};let i=(r.now??Date.now)(),c=m(s,"gc-state.json"),o=Gt(c);if(!r.force&&o&&i-Date.parse(o.lastSweepAt)<fn)return{kind:"throttled",sweptAt:o.lastSweepAt};let a=$e(s,{now:()=>i});if(!a)return{kind:"busy"};try{let u=Ut(e,s,n.repositoryId,o?.unreferencedSince??{}),d=gn({nowMs:i,...u,policy:{generationTtlMs:r.policy?.generationTtlMs??hn,budgetBytes:r.policy?.budgetBytes??ln}}),h=0,l=0;for(let f of d.deleteWorktrees){if(!$t(f.lease))continue;let O=Be(m(f.lease.localCacheDir,"cache-lifecycle.lock"));if(O)try{if(ke(f.lease,!0))continue;try{nt({projectRoot:f.lease.projectRoot,cacheDir:f.lease.localCacheDir,cliVersion:t})}catch{continue}if(ke(f.lease,!0))continue;D(f.lease.localCacheDir,{recursive:!0,force:!0}),D(f.leasePath,{force:!0}),l+=1}finally{O.release()}}for(let f of d.deleteLocks)D(f.path,{force:!0});for(let f of d.deleteTemporaries)D(f.path,{recursive:!0,force:!0});for(let f of d.deleteGenerations)D(f.path,{recursive:!0,force:!0}),h+=f.size;We(m(s,"evidence.db"));let p={kind:"swept",sweptAt:new Date(i).toISOString(),deletedWorktrees:l,deletedGenerations:d.deleteGenerations.length,deletedBytes:h,protectedGenerations:d.protectedGenerationIds.length},g={version:1,lastSweepAt:p.sweptAt,unreferencedSince:d.unreferencedSince,lastResult:p};return C(c,g,{spacing:2,trailingNewline:!0}),p}catch(u){return{kind:"failed",error:u instanceof Error?u.message:String(u)}}finally{a.release()}}function Is(e,t,r){let n=ze(e,r.dbPath,t);if(n)return{state:"bypassed",reason:n,localCacheDir:r.cacheDir,generations:0,generationBytes:0,protectedGenerations:0,unreferencedGenerations:0,unreferencedBytes:0,temporaryGenerations:0,sharedEvidence:{exists:!1,bytes:0}};let s=se(e);if(!s)return{state:"unavailable",reason:"Git worktree identity is unavailable",localCacheDir:r.cacheDir,generations:0,generationBytes:0,protectedGenerations:0,unreferencedGenerations:0,unreferencedBytes:0,temporaryGenerations:0,sharedEvidence:{exists:!1,bytes:0}};let i=m(B(),"repositories",s.repositoryId),c=Bt(m(i,"worktrees",`${s.worktreeId}.json`)),o=Gt(m(i,"gc-state.json")),a=Ut(e,i,s.repositoryId,o?.unreferencedSince??{}),u=Ht(a.leases,a.locks),d=a.generations.filter(g=>!u.has(g.generationId)),h=a.generations.reduce((g,f)=>g+f.size,0),l=Ve(e,t),p=0;return l&&(p=mn(l)),{state:"managed",repositoryId:s.repositoryId,worktreeId:s.worktreeId,localCacheDir:r.cacheDir,...c?{baseGenerationId:c.baseGenerationId,activeGenerationId:c.activeGenerationId,lastAction:c.lastAction,reason:c.lastReason,lastSeenAt:c.lastSeenAt}:{},generations:a.generations.length,generationBytes:h,protectedGenerations:a.generations.filter(g=>u.has(g.generationId)).length,unreferencedGenerations:d.length,unreferencedBytes:d.reduce((g,f)=>g+f.size,0),temporaryGenerations:a.temporaries.length,sharedEvidence:{path:l,exists:p>0,bytes:p},cleanup:o?.lastResult}}function mn(e){return[e,`${e}-wal`,`${e}-shm`].reduce((t,r)=>{try{return t+Nt(r).size}catch{return t}},0)}function Ut(e,t,r,n){let s=new Set(He(e).map(u=>N(u.path))),i=[];for(let u of Ee(m(t,"worktrees"))){if(!u.endsWith(".json"))continue;let d=m(t,"worktrees",u),h=Bt(d);if(!h)continue;let l=N(h.projectRoot);i.push({leasePath:d,lease:h,managed:h.repositoryId===r&&$t(h),live:s.has(l)||Mt(l),busy:ke(h)})}let c=[];for(let u of Ee(m(t,"locks"))){let d=/^([a-f0-9]{64})\.lock$/.exec(u);if(!d)continue;let h=m(t,"locks",u),l=Ae(h),p=l!==void 0&&S(l),g=d[1];c.push({generationId:g,path:h,live:p})}let o=[],a=[];for(let u of Ee(m(t,"generations"))){let d=/^\.tmp-(\d+)-/.exec(u);if(d){let p=m(t,"generations",u),g=Number(d[1]);try{a.push({path:p,size:qt(p),live:Number.isSafeInteger(g)&&S(g)})}catch{}continue}if(!/^[a-f0-9]{64}$/.test(u))continue;let h=m(t,"generations",u),l;try{l=X(h)}catch{continue}!l.isDirectory()||l.isSymbolicLink()||o.push({generationId:u,path:h,size:qt(h),...n[u]===void 0?{}:{unreferencedAt:n[u]}})}return{leases:i,generations:o,locks:c,temporaries:a}}function $t(e){if(e.ownershipChecksum!==Fe(e)||ce(e.localCacheDir)!==ce(Ge(e.projectRoot)))return!1;let t=N(B()),r=N(m(t,"projects")),n=N(e.localCacheDir);if(!n.startsWith(`${r}${Lt}`))return!1;try{let s=X(t),i=X(r),c=X(n);if(!s.isDirectory()||s.isSymbolicLink()||!i.isDirectory()||i.isSymbolicLink()||!c.isDirectory()||c.isSymbolicLink())return!1;let o=_t(r);return _t(n).startsWith(`${o}${Lt}`)}catch{return!1}}function ke(e,t=!1){for(let n of t?["index.lock"]:["index.lock","cache-lifecycle.lock"]){let s=Ae(m(e.localCacheDir,n));if(s!==void 0&&S(s))return!0}let r=Ae(k(e.localCacheDir).lockPath);return r!==void 0&&S(r)}function Bt(e){try{let t=JSON.parse(y(e,"worktree cache lease"));return t.version!==1||typeof t.repositoryId!="string"||typeof t.worktreeId!="string"||typeof t.projectRoot!="string"||t.treeOid!==void 0&&typeof t.treeOid!="string"||typeof t.localCacheDir!="string"||t.baseGenerationId!==void 0&&typeof t.baseGenerationId!="string"||t.activeGenerationId!==void 0&&typeof t.activeGenerationId!="string"||typeof t.ownershipChecksum!="string"||!/^[a-f0-9]{64}$/.test(t.ownershipChecksum)||typeof t.lastAction!="string"||t.lastReason!==void 0&&typeof t.lastReason!="string"||typeof t.lastSeenAt!="string"?null:t}catch{return null}}function Ae(e){try{let t=JSON.parse(y(e,"watch lock record"));return typeof t.pid=="number"&&Number.isSafeInteger(t.pid)&&t.pid>0?t.pid:void 0}catch{return}}function Gt(e){try{let t=JSON.parse(y(e,"repository cache GC state"));return t.version!==1||typeof t.lastSweepAt!="string"||!Number.isFinite(Date.parse(t.lastSweepAt))||!t.unreferencedSince||typeof t.unreferencedSince!="object"||!t.lastResult?null:t}catch{return null}}function Ee(e){try{return Dt(e)}catch{return[]}}function qt(e){let t=0,r=[e];for(;r.length>0;){let n=r.pop();for(let s of Dt(n,{withFileTypes:!0})){let i=m(n,s.name);s.isDirectory()?r.push(i):s.isFile()&&(t+=Nt(i).size)}}return t}export{On as a,Hn as b,yr as c,Un as d,$n as e,Sr as f,nt as g,Bn as h,Gn as i,ss as j,is as k,os as l,ws as m,Is as n};
|
|
14
|
+
//# sourceMappingURL=chunk-LU47HG23.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a}from"./chunk-NGEXCJJW.js";import{f as o}from"./chunk-C3KV2II6.js";function c(t){return/[*?]/.test(t)?t.replace(/\*\*/g,"%").replace(/\*/g,"%").replace(/\?/g,"_"):`%${t}%`}function b(t,r){let n=c(r);return a(t,{like:n,includeIgnored:!1}).filter(e=>f({pattern:r,relativePath:e})).map(e=>({relativePath:e}))}function f(t,r){let n=typeof t=="string"?{pattern:t,relativePath:r}:t;if(typeof n.pattern!="string"||typeof n.relativePath!="string")throw new TypeError("pathMatchesGlob requires pattern and relativePath.");let e=o(n.pattern),s=o(n.relativePath);if(!/[*?]/.test(e))return s.includes(e);let l=e.includes("/")?e:`**/${e}`;return i(l.split("/"),s.split("/"))}function i(t,r){if(t.length===0)return r.length===0;let[n,...e]=t;return n==="**"?i(e,r)||r.length>0&&i(t,r.slice(1)):r.length===0||!h(n??"",r[0]??"")?!1:i(e,r.slice(1))}function h(t,r){let n="^";for(let e of t)e==="*"?n+="[^/]*":e==="?"?n+="[^/]":n+=u(e);return n+="$",new RegExp(n).test(r)}function u(t){return/[\\^$.*+?()[\]{}|]/.test(t)?`\\${t}`:t}export{b as a,f as b};
|
|
2
|
+
//# sourceMappingURL=chunk-LVY7NPF7.js.map
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import{c as f}from"./chunk-UJCOIXDY.js";import{a as b,e as g}from"./chunk-26QA6FAI.js";import{d as m}from"./chunk-EKZTZXHZ.js";import{o as u,p as _,q as a}from"./chunk-UJPRPGCO.js";import{J as p}from"./chunk-WCCFZ7V7.js";import{a as l}from"./chunk-NGEXCJJW.js";function B(e,t={}){let{scope:o,limit:r}=t,i=new f(e),s=T([...x(e,o),...y(e,i,o)]);return F(s),r?s.slice(0,r):s}function x(e,t){let o=[];for(let r of N(e,t)){if(e.isIgnored(r.barrel_path)||e.isIgnored(r.original_path)||g(e,r.barrel_path)||p(e,r.barrel_path)&&a(e,r.barrel_path).length===0)continue;let i=I(e,r),s=i?.barrel_consumers??0,n=i?.direct_consumers??0;s!==0||n!==0||o.push({barrelFile:r.barrel_path,symbol:r.symbol,shortName:m(r.symbol),originalFile:r.original_path,barrelConsumers:s,directConsumers:n,...h(e,r.barrel_path)})}return o}function N(e,t){let o=t?"AND barrel_d.relative_path LIKE ?":"",r=t?[`%${t}%`]:[];return e.all(`WITH barrel_refs AS MATERIALIZED (
|
|
2
|
+
SELECT DISTINCT
|
|
3
|
+
barrel_d.id AS barrel_doc_id,
|
|
4
|
+
barrel_d.relative_path AS barrel_path,
|
|
5
|
+
m.symbol_id
|
|
6
|
+
FROM documents barrel_d
|
|
7
|
+
JOIN chunks c ON c.document_id = barrel_d.id
|
|
8
|
+
JOIN mentions m ON m.chunk_id = c.id
|
|
9
|
+
WHERE m.role != 1
|
|
10
|
+
AND (barrel_d.relative_path LIKE '%/index.ts'
|
|
11
|
+
OR barrel_d.relative_path LIKE '%/index.js'
|
|
12
|
+
OR barrel_d.relative_path = 'index.ts'
|
|
13
|
+
OR barrel_d.relative_path = 'index.js')
|
|
14
|
+
${e.pathExclusionsFor("barrel_d")}
|
|
15
|
+
${o}
|
|
16
|
+
),
|
|
17
|
+
sym_def AS MATERIALIZED (
|
|
18
|
+
SELECT m2.symbol_id, c2.document_id
|
|
19
|
+
FROM barrel_refs br
|
|
20
|
+
-- Keep the bounded barrel-symbol set on the outer side. An ordinary
|
|
21
|
+
-- JOIN lets SQLite scan every definition mention before applying the
|
|
22
|
+
-- barrel-symbol bloom filter on large indexes.
|
|
23
|
+
CROSS JOIN mentions m2 ON m2.symbol_id = br.symbol_id
|
|
24
|
+
AND m2.role = 1
|
|
25
|
+
JOIN chunks c2 ON m2.chunk_id = c2.id
|
|
26
|
+
GROUP BY m2.symbol_id
|
|
27
|
+
)
|
|
28
|
+
SELECT DISTINCT
|
|
29
|
+
br.barrel_doc_id,
|
|
30
|
+
br.barrel_path,
|
|
31
|
+
gs.id AS symbol_id,
|
|
32
|
+
gs.symbol AS symbol,
|
|
33
|
+
orig_d.id AS original_doc_id,
|
|
34
|
+
orig_d.relative_path AS original_path
|
|
35
|
+
FROM barrel_refs br
|
|
36
|
+
JOIN global_symbols gs ON br.symbol_id = gs.id
|
|
37
|
+
JOIN sym_def ON sym_def.symbol_id = gs.id
|
|
38
|
+
JOIN documents orig_d ON sym_def.document_id = orig_d.id
|
|
39
|
+
WHERE orig_d.id != br.barrel_doc_id
|
|
40
|
+
${e.pathExclusionsFor("orig_d")}
|
|
41
|
+
${e.symbolNoiseFor("gs")}
|
|
42
|
+
-- Only function-level symbols (ending with ().), not module-level
|
|
43
|
+
AND gs.symbol LIKE '%().'
|
|
44
|
+
ORDER BY br.barrel_path, gs.symbol`,...r)}function I(e,t){return e.get(`SELECT
|
|
45
|
+
SUM(CASE WHEN uses_barrel = 1 THEN 1 ELSE 0 END) AS barrel_consumers,
|
|
46
|
+
SUM(CASE WHEN uses_barrel = 0 THEN 1 ELSE 0 END) AS direct_consumers
|
|
47
|
+
FROM (
|
|
48
|
+
SELECT
|
|
49
|
+
consumer_d.id AS consumer_doc_id,
|
|
50
|
+
MAX(CASE WHEN EXISTS (
|
|
51
|
+
SELECT 1
|
|
52
|
+
FROM mentions barrel_m
|
|
53
|
+
JOIN chunks barrel_c ON barrel_m.chunk_id = barrel_c.id
|
|
54
|
+
WHERE barrel_c.document_id = consumer_d.id
|
|
55
|
+
AND barrel_m.role != 1
|
|
56
|
+
AND barrel_m.symbol_id IN (
|
|
57
|
+
SELECT m2.symbol_id
|
|
58
|
+
FROM mentions m2
|
|
59
|
+
JOIN chunks c2 ON m2.chunk_id = c2.id
|
|
60
|
+
WHERE c2.document_id = ?
|
|
61
|
+
AND m2.role != 1
|
|
62
|
+
)
|
|
63
|
+
) THEN 1 ELSE 0 END) AS uses_barrel
|
|
64
|
+
FROM mentions ref_m
|
|
65
|
+
JOIN chunks ref_c ON ref_m.chunk_id = ref_c.id
|
|
66
|
+
JOIN documents consumer_d ON ref_c.document_id = consumer_d.id
|
|
67
|
+
WHERE ref_m.symbol_id = ?
|
|
68
|
+
AND ref_m.role != 1
|
|
69
|
+
AND consumer_d.id != ?
|
|
70
|
+
AND consumer_d.id != ?
|
|
71
|
+
${e.pathExclusionsFor("consumer_d")}
|
|
72
|
+
GROUP BY consumer_d.id
|
|
73
|
+
)`,t.barrel_doc_id,t.symbol_id,t.barrel_doc_id,t.original_doc_id)}function y(e,t,o){let r=[],i=C(e);for(let s of O(e,o))E(i,s,s)>0||r.push(...D(e,t,s,i));return r}function O(e,t){return l(e,{scope:t,includeIgnored:!1}).filter(o=>a(e,o).length>0||u(e,o).length>0)}function D(e,t,o,r){let i=a(e,o).filter(n=>n.sourcePath&&!e.isIgnored(n.sourcePath)).flatMap(n=>R(e,t,o,n.sourcePath,r,[A(n.specifier)])),s=u(e,o).filter(n=>n.sourcePath&&!e.isIgnored(n.sourcePath)).flatMap(n=>R(e,t,o,n.sourcePath,r,n.kind==="named"&&n.names.length>0?n.names:[n.kind==="star"?`* from ${n.sourcePath}`:`* namespace from ${n.sourcePath}`]));return[...i,...s]}function R(e,t,o,r,i,s){let n=t.definitionsForFile(r);return s.map(c=>{let d=n.find(S=>S.leaf===c);return{barrelFile:o,symbol:d?.symbol??`source-reexport:${o}:${c}`,shortName:d?m(d.symbol):c,originalFile:r,barrelConsumers:0,directConsumers:E(i,r,o),...h(e,o)}})}function A(e){return e.split("::").at(-1)?.split("/").at(-1)?.replace(/\.[^.]+$/,"")??e}function h(e,t){return b(e,t)?{actionTier:"signal",surfaceEvidence:["barrel file is declared on the package public surface"],recommendation:"Review the package API before removing this re-export; local consumers are zero, but external consumers may import through the public barrel."}:{actionTier:"direct",surfaceEvidence:[],recommendation:"Remove this unused re-export when the barrel is not part of an external API surface."}}function C(e){let t=new Map;for(let o of l(e,{includeIgnored:!1}))for(let r of _(e,o)){if(!r.sourcePath)continue;let i=t.get(r.sourcePath)??new Set;i.add(o),t.set(r.sourcePath,i)}return t}function E(e,t,o){let r=e.get(t);return r?r.size-(r.has(o)?1:0):0}function T(e){let t=new Set,o=[];for(let r of e){let i=`${r.barrelFile}|${r.symbol}|${r.originalFile}`;t.has(i)||(t.add(i),o.push(r))}return o}function F(e){e.sort((t,o)=>o.directConsumers-t.directConsumers||t.barrelFile.localeCompare(o.barrelFile)||t.shortName.localeCompare(o.shortName))}export{B as a};
|
|
74
|
+
//# sourceMappingURL=chunk-LY4WC4AD.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as D,b as v,c as $,d as B}from"./chunk-
|
|
1
|
+
import{a as D,b as v,c as $,d as B}from"./chunk-MV7OWDUX.js";import{a as K}from"./chunk-ZTETIQ35.js";import{b as I,c as A}from"./chunk-UJCOIXDY.js";import{c as M,h as R}from"./chunk-26QA6FAI.js";import{a as g}from"./chunk-BGBBVSH4.js";import{b as k,d as F,e as b}from"./chunk-EKZTZXHZ.js";import{l as w}from"./chunk-UJPRPGCO.js";import{J as C}from"./chunk-WCCFZ7V7.js";function de(t,e){let{scope:n,minLoc:i=3,maxLoc:s=80,limit:r=30,includeLowConfidence:l=!1,scanLimit:o}=e??{},d=e?.semantic!==!1,a=new A(t),m=a.scopedDefinitions(n),y=Q(a,n),p={high:0,medium:1,low:2};return K({candidates:()=>O(t,a,m,{minLoc:i,maxLoc:s}),orderCandidates:(u,c)=>g(c)-g(u)||u.relativePath.localeCompare(c.relativePath),scanLimit:o,profile:{name:"stale-abstractions"},prepare:u=>{let c=U(u),f=W(t,a,u,c,{semantic:d}),h=u.filter(P=>{let x=S(t,P,f,c);return x.realConsumers.length<=1&&!x.transitivelyReachable&&j(P,x.realConsumers.length,y)});return{consumerFileMap:f,singletonBackedClassIds:H(t,a,m,h,{semantic:d}),candidateIndex:c}},evaluate:(u,c)=>{if(c.singletonBackedClassIds.has(u.symbolId))return null;let f=S(t,u,c.consumerFileMap,c.candidateIndex);if(f.transitivelyReachable||f.realConsumers.length>1||f.realConsumers.length===0&&f.barrelConsumers>0||!j(f.definition,f.realConsumers.length,y))return null;let h=V(t,f);return!l&&h.confidence==="low"?null:h},orderResults:(u,c)=>p[u.confidence]-p[c.confidence]||c.loc-u.loc||u.file.localeCompare(c.file)||u.startLine-c.startLine,limit:r})}function O(t,e,n,i){return n.filter(s=>s.isTypeLike&&g(s)>=i.minLoc).filter(s=>g(s)<=i.maxLoc).filter(s=>!t.isIgnored(s.relativePath)).filter(s=>!s.relativePath.endsWith(".d.ts")).filter(s=>M(s.relativePath)!=="test").filter(s=>!R(t,s.symbol,s.relativePath)).filter(s=>!X(s.symbol)).filter(s=>!e.hasSuppressionComment(s))}function L(t,e,n,i){return v(D(t,e).forDefinitions(n,{semantic:i.semantic,sourceFallback:i.sourceFallback}))}function W(t,e,n,i,s){let r=L(t,e,n,{semantic:!1,sourceFallback:!1}),l=n.filter(a=>{let m=S(t,a,r,i);return m.realConsumers.length<=1&&!(m.realConsumers.length>0&&T(a.relativePath))}),o=s.semantic&&l.length>0?I(r,L(t,e,l,{semantic:!0,sourceFallback:!1})):r,d=l.filter(a=>S(t,a,o,i).realConsumers.length<=1);return I(o,L(t,e,d,{semantic:!1,sourceFallback:!0}))}function U(t){let e=new Map;for(let n of t){let i=e.get(n.relativePath);i||(i=new Map,e.set(n.relativePath,i));let s=b(n.symbol);s&&i.set(s,n)}return e}function S(t,e,n,i){let r=[...n.get(e.symbolId)??new Set].filter(m=>m!==e.relativePath&&!t.isIgnored(m)),{realConsumers:l,barrelConsumers:o,importOnlyConsumers:d}=$(t,e,r),a=Y(t,e,n,i);return{definition:e,realConsumers:l,barrelConsumers:o+d,transitivelyReachable:a}}function V(t,e){let n=E(t,e.definition.relativePath,e.definition.startLine),i=T(e.definition.relativePath)?!0:ee(t,e.definition),{confidence:s,reason:r}=ne(e.realConsumers.length,n,i),l=z(e.realConsumers.length,n,i);return{symbol:e.definition.symbol,shortName:F(e.definition.symbol),file:e.definition.relativePath,startLine:e.definition.startLine,endLine:e.definition.endLine,loc:g(e.definition),consumers:e.realConsumers.length,barrelConsumers:e.barrelConsumers,kind:n,definerUsesType:i,confidence:s,reason:r,actionTier:l.actionTier,stalenessKind:l.stalenessKind,recommendation:l.recommendation}}function z(t,e,n){return t===0?{actionTier:"direct",stalenessKind:"unused-abstraction",recommendation:"Delete the abstraction or wire the missing consumer after checking public/package surfaces."}:e==="class"?{actionTier:"signal",stalenessKind:"one-to-one-class-encapsulation",recommendation:"Treat as weak signal: a one-consumer class may be intentional encapsulation, so inline only after reviewing ownership and state boundaries."}:n?{actionTier:"signal",stalenessKind:"single-consumer-abstraction",recommendation:"Review whether this single-consumer abstraction earns its name or should be folded into the owning feature."}:{actionTier:"signal",stalenessKind:"misplaced-single-consumer-type",recommendation:"Review moving or co-locating the type with its only real consumer; keep it here only if this file owns the public contract."}}function H(t,e,n,i,s){let r=_(t,Z(n),i),l=r.map(a=>a.singleton);if(r.length===0)return new Set;let o=v(D(t,e).forDefinitions(l,{semantic:s.semantic,sourceFallback:!0})),d=new Set;for(let{singleton:a,classId:m}of r)G(t,a,o)&&d.add(m);return d}function Z(t){let e=new Map;for(let n of t){let i=b(n.symbol);i&&e.set(N(n.relativePath,i),n)}return e}function _(t,e,n){let i=[];for(let s of n){let r=q(t,e,s);r&&i.push({singleton:r,classId:s.symbolId})}return i}function q(t,e,n){if(E(t,n.relativePath,n.startLine)!=="class")return null;let i=b(n.symbol);if(!i)return null;let s=J(t,n.relativePath,i);return s?e.get(N(n.relativePath,s))??null:null}function G(t,e,n){let i=b(e.symbol),s=n.get(e.symbolId);return!i||!s?!1:[...s].some(r=>r!==e.relativePath&&!t.isIgnored(r)&&!B(t,r,i))}function N(t,e){return`${t}\0${e}`}function J(t,e,n){let i=C(t,e);if(!i)return null;let s=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=new RegExp(`\\bexport\\s+const\\s+([A-Za-z_$][\\w$]*)\\s*=\\s*new\\s+${s}\\s*\\(`);return i.match(r)?.[1]??null}function Q(t,e){return new Set(t.scopedDefinitions(e).filter(n=>n.isFunctionLike).map(n=>n.relativePath))}function X(t){let e=k(t);if("kind"in e)return!1;let n=e.descriptors;if(n.length<2)return!1;let i=n[n.length-1],s=n[n.length-2];return i?.suffix==="type"&&s?.suffix==="type"}function T(t){let n=(t.split("/").pop()??"").replace(/\.[^.]+$/,"");return!!(n==="types"||n.endsWith("-types")||n==="models"||n==="schema"||n==="common"||n==="protocol"||n==="proto"||n==="dto"||n==="mod"||n==="contracts"||/(^|\/)types(\/|\.)/.test(t)||/(^|\/)models?(\/|\.)/.test(t)||/(^|\/)proto(?:col)?(\/|\.)/.test(t)||/(^|\/)schema(\/|\.)/.test(t)||/(^|\/)contracts?(\/|\.)/.test(t))}function j(t,e,n){return!(T(t.relativePath)&&e>0||e===0&&n.has(t.relativePath))}function Y(t,e,n,i){let s=w(t,e.relativePath),r=b(e.symbol);if(!r)return!1;let l=i.get(e.relativePath);if(!l)return!1;let o=[...s.get(r)??[]],d=new Set;for(;o.length>0;){let a=o.pop();if(d.has(a))continue;d.add(a);let m=l.get(a);if(!m)continue;let y=n.get(m.symbolId);if(y){for(let p of y)if(p!==e.relativePath&&!t.isIgnored(p))return!0}for(let p of s.get(a)??[])o.push(p)}return!1}function E(t,e,n){let i=C(t,e);if(!i)return"other";let s=i.split(`
|
|
2
2
|
`),r=Math.max(0,n-2),l=Math.min(s.length-1,n+2);for(let o=r;o<=l;o++){let a=(s[o]??"").replace(/^\s*\/\/.*$/g,"");if(/\b(?:export\s+)?(?:abstract\s+)?class\s+\w/.test(a))return"class";if(/\b(?:export\s+)?interface\s+\w/.test(a))return"interface";if(/\b(?:export\s+)?type\s+\w/.test(a))return"type";if(/\b(?:export\s+)?(?:const\s+)?enum\s+\w/.test(a))return"enum"}return"other"}function ee(t,e){let n=C(t,e.relativePath);if(!n)return!1;let i=b(e.symbol);if(!i)return!1;let s=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=new RegExp(`\\b${s}\\b`),l=n.split(`
|
|
3
3
|
`);for(let o=0;o<l.length;o++)if(!(o>=e.startLine&&o<=e.endLine)&&r.test(l[o]??""))return!0;return!1}function ne(t,e,n){return t===0?{confidence:"high",reason:"unused \u2014 no consumers and defining file has no real usage"}:t===1&&e==="class"?{confidence:"low",reason:"1 consumer + class kind \u2014 likely 1:1 encapsulation, not over-abstraction"}:t===1&&!n?{confidence:"high",reason:"1 consumer + defining file never uses it \u2014 type belongs with its consumer"}:{confidence:"medium",reason:"1 consumer \u2014 single-use abstraction"}}export{de as a};
|
|
4
|
-
//# sourceMappingURL=chunk-
|
|
4
|
+
//# sourceMappingURL=chunk-MKCDWWGV.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{i as o}from"./chunk-46XGSFNI.js";function P(){return performance.now()}import{execFileSync as m}from"child_process";import{platform as p}from"os";var a=new Set(["aix","android","darwin","freebsd","haiku","linux","openbsd","sunos","win32","cygwin","netbsd"]);function l(r){if(!r||typeof r!="object"||Array.isArray(r))return null;let t=r;return t.version!==1||typeof t.pid!="number"||!Number.isSafeInteger(t.pid)||t.pid<=0||typeof t.platform!="string"||!a.has(t.platform)||typeof t.startToken!="string"||t.startToken.trim()===""?null:{version:1,pid:t.pid,platform:t.platform,startToken:t.startToken}}function f(r,t){return r.version===t.version&&r.pid===t.pid&&r.platform===t.platform&&r.startToken===t.startToken}var u=1e3,s=16*1024;function x(r,t=y){if(!Number.isSafeInteger(r)||r<=0)return null;try{let n=c(r,t);return n?{version:1,pid:r,platform:t.platform,startToken:n}:null}catch{return null}}function c(r,t){if(t.platform==="linux"||t.platform==="android")return d(t.readFile(`/proc/${r}/stat`));if(t.platform==="win32"){let n=`([DateTimeOffset](Get-Process -Id ${r} -ErrorAction Stop).StartTime).ToUnixTimeMilliseconds()`;return i(t.run("powershell.exe",["-NoProfile","-NonInteractive","-Command",n]))}return t.platform==="darwin"||t.platform==="freebsd"||t.platform==="openbsd"||t.platform==="netbsd"?i(t.run("ps",["-p",String(r),"-o","lstart="])):null}function d(r){let t=r.lastIndexOf(")");if(t<0)return null;let e=r.slice(t+1).trim().split(/\s+/)[19];return e&&/^\d+$/.test(e)?e:null}function i(r){let t=r.trim();return t===""?null:t}var y={platform:p(),readFile(r){return o(r,{maxBytes:s,inputKind:"process identity pseudo-file"})},run(r,t){return m(r,[...t],{encoding:"utf8",timeout:u,maxBuffer:s,env:{...process.env,LC_ALL:"C",LANG:"C"},stdio:["ignore","pipe","ignore"]})}};export{P as a,l as b,f as c,x as d};
|
|
2
|
+
//# sourceMappingURL=chunk-MNE7YG56.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as d}from"./chunk-
|
|
1
|
+
import{b as d}from"./chunk-Z4N3MZYA.js";import{o as f}from"./chunk-7O5IKBTZ.js";import{d as r,t as m}from"./chunk-EKZTZXHZ.js";function g(t,o={}){let{limit:n=30,scope:e}=o,s=e?"AND def_d.relative_path LIKE ?":"",c=e?[`%${e}%`]:[],l=t.all(`SELECT
|
|
2
2
|
gs.symbol,
|
|
3
3
|
COUNT(*) AS ref_count,
|
|
4
4
|
COUNT(DISTINCT ref_d.id) AS file_count,
|
|
@@ -23,4 +23,4 @@ import{b as d}from"./chunk-KXDJAG4N.js";import{n as f}from"./chunk-GLZTVKAB.js";
|
|
|
23
23
|
GROUP BY gs.id
|
|
24
24
|
ORDER BY ref_count DESC
|
|
25
25
|
LIMIT ?`,...c,n).filter(i=>!t.isIgnored(i.defined_in)).map(i=>({symbol:i.symbol,shortName:r(i.symbol),refCount:i.ref_count,fileCount:i.file_count,definedIn:i.defined_in}));return l.length>0?l:u(t,e,n)}function u(t,o,n){return m(t,{scope:o}).filter(e=>!t.isIgnored(e.relativePath)).map(e=>a(t,e)).filter(e=>e.refCount>0).sort((e,s)=>s.refCount-e.refCount||s.fileCount-e.fileCount).slice(0,n)}function a(t,o){let e=d(t,o,{limit:500,semanticEvidence:f}).filter(s=>s.file!==o.relativePath);return{symbol:o.symbol,shortName:r(o.symbol),refCount:e.length,fileCount:new Set(e.map(s=>s.file)).size,definedIn:o.relativePath}}export{g as a};
|
|
26
|
-
//# sourceMappingURL=chunk-
|
|
26
|
+
//# sourceMappingURL=chunk-MRXBEXSY.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{l as I}from"./chunk-HX7M4BDI.js";import{a as y,e as g}from"./chunk-EKZTZXHZ.js";import{x as v}from"./chunk-GH74ASD6.js";import{A as x,k as D,l as _,t as F,v as p,y as E}from"./chunk-WCCFZ7V7.js";import{c as b}from"./chunk-7S5E7KWT.js";import{spawnSync as O}from"child_process";import{createHash as U}from"crypto";import{existsSync as k}from"fs";import{dirname as L,join as T}from"path";import{fileURLToPath as j}from"url";var N=b("definition-consumer-file-usage",{clearGroups:["whole-project","source-file"]}),M=E({kind:"consumer-file-usage",invalidation:x("consumer-file-usage"),serialize:Q,deserialize:W});function Le(e,n){return{forDefinitions(r,i){return V(e,n,r,i)}}}function Me(e){let n=new Map;for(let[r,i]of e)n.set(r,new Set(i.files.map(t=>t.file)));return n}function Re(e,n,r){return w(e,n,r).partition}function V(e,n,r,i){let t=h(r.length),s=F()?_(e):null,a=s?B(r,i,s):void 0,o=a?{workIdentity:a,workOutcome:"computed"}:{};return p("consumer-evidence.product",()=>{let l=p("consumer-evidence.provenance",()=>z(e,n,r,i),()=>({...o,definitions:r.length,semantic:i.semantic,sourceFallback:i.sourceFallback!==!1})),u=new Map;t={...t,...l.counters};let c=Y(r,l.sources);return p("consumer-evidence.classify",()=>{let f=q(e,r,l.sources,c);for(let d of r){let m=f.get(d.symbolId)??H();t.realFiles+=m.partition.realConsumers.length,t.reexportOnlyFiles+=m.partition.barrelConsumers,t.importOnlyFiles+=m.partition.importOnlyConsumers,u.set(d.symbolId,{definition:d,files:m.files,...m.partition})}},()=>({...o,...c,realFiles:t.realFiles,reexportOnlyFiles:t.reexportOnlyFiles,importOnlyFiles:t.importOnlyFiles})),u},()=>({...o,...t}))}function B(e,n,r){let i=U("sha256").update("consumer-evidence-v1\0").update(r).update("\0").update(n.semantic?"semantic\0":"indexed\0").update(n.sourceFallback===!1?"no-source-fallback":"source-fallback");for(let t of e.map(s=>s.symbol).sort())i.update("\0").update(t);return i.digest("hex").slice(0,24)}function h(e){return{definitions:e,indexedFiles:0,semanticFiles:0,fallbackFiles:0,totalFiles:0,realFiles:0,reexportOnlyFiles:0,importOnlyFiles:0}}function z(e,n,r,i){let t=h(r.length),s=new Map;return S(s,t,"indexed",n.crossFileCallerMap(r,{semantic:!1})),i.semantic&&S(s,t,"semantic",I(e,r)),i.sourceFallback!==!1&&S(s,t,"source-fallback",n.sourceFallbackCallerFiles(r)),t.totalFiles=[...s.values()].reduce((a,o)=>a+o.size,0),{sources:s,counters:t}}function Y(e,n){return{definitions:e.length,consumerFiles:[...n.values()].reduce((r,i)=>r+i.size,0),nativeAttempted:!1,nativeUsed:!1,nativeReason:"not-attempted"}}function S(e,n,r,i){let t=0;for(let[s,a]of i){let o=e.get(s);o||(o=new Map,e.set(s,o));for(let l of a){t++;let u=o.get(l)??new Set;u.add(r),o.set(l,u)}}r==="indexed"?n.indexedFiles+=t:r==="semantic"?n.semanticFiles+=t:n.fallbackFiles+=t}function q(e,n,r,i){let t=re(e,n,r,i);return t||$(e,n,r)}function $(e,n,r){let i=new Map;for(let t of n){let s=r.get(t.symbolId)??new Map;i.set(t.symbolId,w(e,t,[...s.keys()],s))}return i}function w(e,n,r,i=new Map){let t=[],s=0,a=0,o=g(n.symbol),l=[];for(let u of r){let c;X(e,u,n.relativePath,o)?(s++,c="reexport-only"):J(e,u,o)?(a++,c="import-only"):(t.push(u),c="real"),l.push({file:u,sources:[...i.get(u)??[]],classification:c})}return{partition:{realConsumers:t,barrelConsumers:s,importOnlyConsumers:a},files:l}}function H(){return{partition:{realConsumers:[],barrelConsumers:0,importOnlyConsumers:0},files:[]}}function J(e,n,r){if(!r)return!1;let i=v(n);if(!i)return!1;let t=N.get(e,n,()=>A(e,n,i));return t.importedLeaves.has(r)&&!t.usedLeaves.has(r)}function A(e,n,r){let i=y(e).forFile(n,{text:!0,ast:!0}),t=i.text;if(!t)return G();let s=D(e,n,t),a=M.read(e,n,s);if(a)return a;let o=K(i.ast,r);return M.write(e,n,s,o),o}function K(e,n){let r=new Set,i=new Set;if(!e)return{importedLeaves:r,usedLeaves:i};let t=n==="rust"?new Set(["use_declaration"]):n==="python"?new Set(["import_statement","import_from_statement"]):new Set(["import_statement"]),s=(a,o)=>{let l=o||t.has(a.type);(a.type==="identifier"||a.type==="type_identifier"||a.type==="property_identifier"||a.type==="field_identifier")&&(l?r.add(a.text):i.add(a.text));for(let u of a.children)s(u,l)};return s(e.rootNode,!1),{importedLeaves:r,usedLeaves:i}}function G(){return{importedLeaves:new Set,usedLeaves:new Set}}function Q(e){return JSON.stringify({importedLeaves:[...e.importedLeaves],usedLeaves:[...e.usedLeaves]})}function W(e){try{let n=JSON.parse(e);return!Array.isArray(n.importedLeaves)||!Array.isArray(n.usedLeaves)?null:{importedLeaves:new Set(n.importedLeaves.filter(r=>typeof r=="string")),usedLeaves:new Set(n.usedLeaves.filter(r=>typeof r=="string"))}}catch{return null}}function X(e,n,r,i){if(!i)return!1;let t=y(e).forFile(n,{lines:!0,reexports:!0}),s=t.lines??[];if(s.length===0)return!1;let a=t.reexports??[];return P(s,a,i)}function P(e,n,r){if(e.length===0||n.length===0)return!1;let i=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),t=new RegExp(`\\b${i}\\b`),s=0;for(let a=0;a<e.length;a++){if(!t.test(e[a]??""))continue;if(s++,!n.find(l=>l.startLine<=a&&a<=l.endLine))return!1}return s>0}var Z="SCIP_QUERY_NATIVE_CONSUMER_CLASSIFY",ee="SCIP_QUERY_NATIVE_KERNELS_BIN",ne="SCIP_QUERY_NATIVE_CONSUMER_CLASSIFY_MIN_FILES",R=1e3,ie=5e3,te=64*1024*1024,C;function re(e,n,r,i){let t=process.env[Z]?.toLowerCase();if(t!=="1"&&t!=="true")return i.nativeReason=t==="0"||t==="false"?"disabled":"opt-in-required",null;if(i.consumerFiles<fe())return i.nativeReason="below-threshold",null;let s=me();if(!s)return i.nativeReason="binary-missing",null;i.nativeAttempted=!0;let a=se(e,n,r),o=O(s,["consumer-classify"],{input:JSON.stringify(a),encoding:"utf8",timeout:ie,maxBuffer:te});if(o.status!==0||o.error)return i.nativeReason=o.error?`spawn-error:${o.error.message}`:`exit-${o.status??"null"}`,null;try{let l=JSON.parse(o.stdout),u=ae(l,n);return u?(i.nativeUsed=!0,i.nativeReason="used",u):(i.nativeReason="invalid-response",null)}catch{return i.nativeReason="invalid-json",null}}function se(e,n,r){let i=new Map,t=[];for(let o of n){let l=g(o.symbol),c=[...(r.get(o.symbolId)??new Map).entries()].map(([f,d])=>{let m=i.get(f)??new Set;return l&&m.add(l),i.set(f,m),{file:f,sources:[...d]}});t.push({symbol_id:o.symbolId,leaf:l,consumer_files:c})}let s={},a={};for(let[o,l]of i){let u=v(o);if(u){let f=N.get(e,o,()=>A(e,o,u));s[o]={imported_leaves:[...f.importedLeaves],used_leaves:[...f.usedLeaves]}}let c=oe(e,o,l);c.length>0&&(a[o]=c)}return{definitions:t,file_usages:s,reexport_only_leaves:a}}function oe(e,n,r){if(r.size===0)return[];let i=y(e).forFile(n,{lines:!0,reexports:!0}),t=i.lines??[],s=i.reexports??[];return t.length===0||s.length===0?[]:[...r].filter(a=>P(t,s,a))}function ae(e,n){if(!Array.isArray(e.entries)||e.entries.length!==n.length)return null;let r=new Set(n.map(t=>t.symbolId)),i=new Map;for(let t of e.entries){let s=le(t);if(!s||!r.has(s.symbol_id))return null;i.set(s.symbol_id,{partition:{realConsumers:s.real_consumers,barrelConsumers:s.barrel_consumers,importOnlyConsumers:s.import_only_consumers},files:s.files})}for(let t of r)if(!i.has(t))return null;return i}function le(e){if(!e||typeof e!="object")return null;let n=e;if(typeof n.symbol_id!="number"||!Array.isArray(n.real_consumers)||typeof n.barrel_consumers!="number"||typeof n.import_only_consumers!="number"||!Array.isArray(n.files)||!n.real_consumers.every(i=>typeof i=="string"))return null;let r=[];for(let i of n.files){if(!i||typeof i!="object")return null;let t=i;if(typeof t.file!="string"||!Array.isArray(t.sources)||!t.sources.every(ue)||!ce(t.classification))return null;r.push({file:t.file,sources:t.sources,classification:t.classification})}return{symbol_id:n.symbol_id,real_consumers:n.real_consumers,barrel_consumers:n.barrel_consumers,import_only_consumers:n.import_only_consumers,files:r}}function ue(e){return e==="indexed"||e==="semantic"||e==="source-fallback"}function ce(e){return e==="real"||e==="reexport-only"||e==="import-only"}function fe(){let e=process.env[ne];if(!e)return R;let n=Number(e);return Number.isFinite(n)&&n>=0?n:R}function me(){if(C!==void 0)return C;let e=process.env[ee],n=process.platform==="win32"?"scip-query-kernels.exe":"scip-query-kernels";return C=[...e?[e]:[],...de().map(i=>T(i,"target","release",n))].find(i=>k(i))??null,C}function de(){let e=new Set,n=L(j(import.meta.url));for(let r=0;r<5;r++)e.add(n),n=L(n);return[...e]}export{Le as a,Me as b,Re as c,J as d};
|
|
2
|
+
//# sourceMappingURL=chunk-MV7OWDUX.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{K as c,L as l}from"./chunk-WCCFZ7V7.js";function h(e,a,i,r,n,o){let t=new Set;d(e,a,i,r)&&t.add(n);for(let s of o)s.value&&p(t,s.label,s.value);return[...t].slice(0,6)}function p(e,a,i){let r=u(i);a.endsWith("name")&&y(r)&&e.add(`${a} has type-guard boundary shape`);for(let n of r){let o=f.get(n);o&&e.add(`${a} has ${o} term: ${n}`)}}function d(e,a,i,r){if(i<=0)return!1;let n=c(e,a);if(n.length===0)return!1;for(let o=i-1;o>=0&&o>=i-5;o-=1){let t=(n[o]??"").trim();if(t!==""){if(l(t)===r)return!0;if(!t.startsWith("//")&&!t.startsWith("*")&&!t.startsWith("/*")&&!t.startsWith("@")&&!t.startsWith("#"))return!1}}return!1}function u(e){return e.replace(/([A-Z])([A-Z][a-z])/g,"$1 $2").replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean)}function y(e){return e.some(a=>g.has(a))&&e.some(a=>m.has(a))}var f=new Map([["access","access policy"],["accessible","access policy"],["adapter","adapter"],["adapters","adapter"],["allow","access policy"],["allowed","access policy"],["animation","animation calculation"],["api","api surface"],["apply","settings/application"],["audit","side-effect boundary"],["auth","authorization"],["authorize","authorization"],["audio","audio side-effect"],["can","access policy"],["capabilities","capability boundary"],["capability","capability boundary"],["boundary","boundary"],["begin","lifecycle"],["bridge","bridge"],["bridges","bridge"],["cache","state cache"],["chase","gameplay action"],["command","command boundary"],["context","context policy"],["cooldown","temporal state"],["cooldowns","temporal state"],["controller","controller"],["controllers","controller"],["diagnostic","diagnostics"],["diagnostics","diagnostics"],["effect","side-effect boundary"],["effects","side-effect boundary"],["energy","gameplay calculation"],["expired","temporal state"],["facade","facade"],["facades","facade"],["fire","gameplay action"],["gateway","gateway"],["gateways","gateway"],["guard","guard"],["guards","guard"],["haptic","haptic side-effect"],["haptics","haptic side-effect"],["head","sequence boundary"],["history","state history"],["input","input boundary"],["jump","gameplay action"],["keyboard","input boundary"],["log","side-effect boundary"],["logger","side-effect boundary"],["lock","coordination boundary"],["middleware","middleware"],["multiplier","gameplay calculation"],["mute","audio side-effect"],["normalize","normalization"],["normalise","normalization"],["normalizer","normalization"],["oscillate","animation calculation"],["oscillation","animation calculation"],["overlap","collision predicate"],["performance","diagnostics"],["permission","access policy"],["permissions","access policy"],["policy","policy"],["pool","state pool"],["pooled","state pool"],["pools","state pool"],["predict","prediction"],["presenter","presenter"],["presenters","presenter"],["projectile","gameplay entity"],["provider","provider boundary"],["providers","provider boundary"],["public","public surface"],["quality","settings/application"],["rate","calculation"],["register","registry"],["registry","registry"],["relay","relay"],["relays","relay"],["reseed","state lifecycle"],["reset","state lifecycle"],["respond","response boundary"],["response","response boundary"],["resolve","resolution"],["resolver","resolution"],["route","route boundary"],["routes","route boundary"],["run","lifecycle"],["sample","diagnostics"],["score","gameplay calculation"],["scope","scope policy"],["scroll","position state"],["scrolled","position state"],["seed","state lifecycle"],["seeded","state lifecycle"],["segment","segment boundary"],["segments","segment boundary"],["setting","settings/application"],["settings","settings/application"],["spawn","gameplay lifecycle"],["spawning","gameplay lifecycle"],["speed","gameplay calculation"],["surface","public surface"],["tail","sequence boundary"],["tick","temporal state"],["transaction","transaction"],["transactional","transaction"],["transform","transformation"],["transformer","transformation"],["translate","translation"],["translator","translation"],["try","fallible action"],["validate","validation"],["validation","validation"],["validator","validation"],["visual","diagnostics"],["window","settings/application"],["socket","transport boundary"],["websocket","transport boundary"]]),g=new Set(["can","has","is","should"]),m=new Set(["access","api","auth","collision","expired","input","keyboard","overlap","permission","permissions","policy","projectile","response","route","routes","scope"]);export{h as a};
|
|
2
|
+
//# sourceMappingURL=chunk-N5W4YZMK.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{c as u}from"./chunk-7S5E7KWT.js";import{basename as d}from"path";var f=u("indexed-document-paths",{clearGroups:["whole-project"]});function g(t,e={}){let r=x(e);return[...f.get(t,r,()=>{let s=e.scope?"AND relative_path LIKE ?":"",i=e.like?"AND relative_path LIKE ?":"",c=[...e.scope?[`%${e.scope}%`]:[],...e.like?[e.like]:[]],l=t.all(`SELECT relative_path
|
|
2
|
+
FROM documents
|
|
3
|
+
WHERE 1 = 1
|
|
4
|
+
${t.pathExclusionsFor("documents")}
|
|
5
|
+
${s}
|
|
6
|
+
${i}
|
|
7
|
+
ORDER BY relative_path`,...c).map(a=>a.relative_path),n=e.extensions?l.filter(a=>e.extensions.some(m=>a.toLowerCase().endsWith(m.toLowerCase()))):l;return e.includeIgnored===!1?n.filter(a=>!t.isIgnored(a)):n})]}function x(t){let e=t.extensions?[...new Set(t.extensions.map(r=>r.toLowerCase()))].sort():null;return JSON.stringify({scope:t.scope??null,like:t.like??null,extensions:e,includeIgnored:t.includeIgnored!==!1})}function v(t,e,r){let o=p(e);if(!o)return[];let s=t.all(`SELECT relative_path
|
|
8
|
+
FROM documents
|
|
9
|
+
WHERE relative_path = ?
|
|
10
|
+
${t.pathExclusionsFor("documents")}`,o).filter(n=>!t.isIgnored(n.relative_path)).map(n=>({relativePath:n.relative_path,score:h(n.relative_path,o)}));if(s.length>0)return s;let i=g(t,{includeIgnored:!1}).map(n=>({relativePath:n,score:h(n,o)})).filter(n=>n.score>0).sort((n,a)=>a.score-n.score||n.relativePath.localeCompare(a.relativePath)),c=i.filter(n=>n.score>=1100);if(c.length>0)return r.allowMultiple?c:[c[0]];let l=i.filter(n=>n.score>=800);return l.length>0?r.allowMultiple?l:[l[0]]:r.allowMultiple?i:i.slice(0,1)}function h(t,e){let r=p(t),o=d(r),s=d(e),i=0;return r===e&&(i+=1200),r.endsWith(`/${e}`)&&(i+=1100),o===s&&(i+=900),r.startsWith(`${e}/`)&&(i+=850),r.includes(e)&&(i+=250),i}function p(t){return t.trim().replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,"").replace(/\/+$/,"")}export{g as a,v as b};
|
|
11
|
+
//# sourceMappingURL=chunk-NGEXCJJW.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as l}from"./chunk-
|
|
1
|
+
import{b as l}from"./chunk-S7OYBOCK.js";import{c as a}from"./chunk-UJCOIXDY.js";import{d as i,g as n}from"./chunk-EKZTZXHZ.js";function _(e,r){let t=l(e,r);return t.length===0?[]:m([...d(e,t),...c(e,t)]).filter(o=>!e.isIgnored(o.relative_path)).map(u)}function d(e,r){let t=r.map(()=>"?").join(", ");return e.all(`SELECT DISTINCT d1.relative_path, gs.symbol
|
|
2
2
|
FROM mentions m
|
|
3
3
|
JOIN chunks c ON m.chunk_id = c.id
|
|
4
4
|
JOIN documents d1 ON c.document_id = d1.id
|
|
@@ -26,4 +26,4 @@ import{b as l}from"./chunk-33XTHFKR.js";import{c as a}from"./chunk-2SNGN6U4.js";
|
|
|
26
26
|
AND ${e.localSymbolPredicate}
|
|
27
27
|
${e.pathExclusionsFor("d1")}
|
|
28
28
|
ORDER BY d1.relative_path`,...r,...r,...r)}function c(e,r){let t=new a(e);return r.flatMap(o=>t.definitionsForFile(o).filter(s=>n(s.symbol)).map(s=>({relative_path:o,symbol:s.symbol})))}function m(e){let r=new Set;return e.filter(t=>{let o=`${t.relative_path}|${t.symbol}`;return r.has(o)?!1:(r.add(o),!0)})}function u(e){return{consumer:e.relative_path,symbol:e.symbol,shortName:i(e.symbol)}}export{_ as a};
|
|
29
|
-
//# sourceMappingURL=chunk-
|
|
29
|
+
//# sourceMappingURL=chunk-NIW6JDC5.js.map
|