scip-query 0.19.6 → 0.19.8
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 +37 -0
- package/README.md +28 -15
- package/dist/augment-vue-worker.js +1 -1
- package/dist/chunk-2465DLHK.js +3 -0
- package/dist/{chunk-2CVXCGL4.js → chunk-24GTWJ3N.js} +2 -2
- package/dist/{chunk-XVJ3V7LM.js → chunk-2SNGN6U4.js} +2 -2
- package/dist/{chunk-FKGN4A4E.js → chunk-2U3OLUNJ.js} +2 -2
- package/dist/{chunk-UUJBLG6J.js → chunk-33KUO7CG.js} +2 -2
- package/dist/{chunk-N3SE646F.js → chunk-33XTHFKR.js} +2 -2
- package/dist/{chunk-WXAAURU7.js → chunk-3EDFLQ6A.js} +2 -2
- package/dist/chunk-3ZSJ3PWF.js +16 -0
- package/dist/{chunk-G4UQL4CP.js → chunk-43KC6EQZ.js} +2 -2
- package/dist/{chunk-NQLSSVOB.js → chunk-464PLI5O.js} +2 -2
- package/dist/chunk-46XGSFNI.js +2 -0
- package/dist/{chunk-NN4ZIRPK.js → chunk-47BU5Z4T.js} +2 -2
- package/dist/chunk-4BV4QAZJ.js +5 -0
- package/dist/chunk-4YTUWQ6M.js +18 -0
- package/dist/{chunk-LMFVTUW2.js → chunk-5ML2BNRH.js} +2 -2
- package/dist/{chunk-OP3MTFJR.js → chunk-5YLUDDAF.js} +2 -2
- package/dist/chunk-67QRR5YC.js +6 -0
- package/dist/{chunk-273W2U4Y.js → chunk-6GXYN7YA.js} +2 -2
- package/dist/{chunk-JELJLXEE.js → chunk-6M7RONVB.js} +2 -2
- package/dist/{chunk-MLGTCX56.js → chunk-7FT5Y65S.js} +2 -2
- package/dist/{chunk-F42A3AKG.js → chunk-7KYNAMMH.js} +2 -2
- package/dist/{chunk-VP542C25.js → chunk-7LSVMFX7.js} +2 -2
- package/dist/{chunk-YWB2EBNB.js → chunk-7QHY3H7P.js} +2 -2
- package/dist/{chunk-UQK5CRUK.js → chunk-7RAG65VK.js} +2 -2
- package/dist/{chunk-CYJM7CYF.js → chunk-7SWJEWJF.js} +2 -2
- package/dist/{chunk-47X75ZKH.js → chunk-7VCOXZH3.js} +2 -2
- package/dist/chunk-A2TNXAXO.js +8 -0
- package/dist/{chunk-TYQ76QHQ.js → chunk-A3QXWFBK.js} +2 -2
- package/dist/{chunk-S2GP3CU3.js → chunk-AA4UWRNL.js} +2 -2
- package/dist/{chunk-OBKDTVZ3.js → chunk-ACAM6O5R.js} +2 -2
- package/dist/chunk-AQOFWNQJ.js +1 -0
- package/dist/chunk-AZFUMCQB.js +2 -0
- package/dist/{chunk-IYAOX36F.js → chunk-BDOIKGDI.js} +2 -2
- package/dist/{chunk-7E3TH5ZN.js → chunk-BNXICU42.js} +2 -2
- package/dist/chunk-C5Q44Q5D.js +3 -0
- package/dist/{chunk-OQ2A4G2G.js → chunk-CTF2GDEX.js} +2 -2
- package/dist/chunk-DHEQMPLW.js +2 -0
- package/dist/{chunk-EVOC5I5I.js → chunk-DQBCO2UY.js} +2 -2
- package/dist/{chunk-YLVE3SXZ.js → chunk-DQGSM7RZ.js} +2 -2
- package/dist/chunk-E2LAW7SL.js +30 -0
- package/dist/chunk-E3HYEQO7.js +2 -0
- package/dist/chunk-E4NFOAD4.js +6 -0
- package/dist/chunk-E5HNT4X2.js +3 -0
- package/dist/{chunk-6XHTISLI.js → chunk-ELLMY7XJ.js} +2 -2
- package/dist/chunk-FD3HFKXR.js +5 -0
- package/dist/{chunk-RJHCPSZ7.js → chunk-FIJCV235.js} +2 -2
- package/dist/{chunk-KLVJABXA.js → chunk-FJ5UDTQF.js} +2 -2
- package/dist/{chunk-SHKZ7OVJ.js → chunk-GHKEJTCE.js} +2 -2
- package/dist/{chunk-JERWGHQT.js → chunk-GLZTVKAB.js} +3 -3
- package/dist/{chunk-A43URCQ3.js → chunk-GNC4JVAN.js} +2 -2
- package/dist/chunk-HIB452NU.js +949 -0
- package/dist/{chunk-U5CNPPTZ.js → chunk-HZYDQPNY.js} +2 -2
- package/dist/chunk-IF6FP6B2.js +66 -0
- package/dist/{chunk-CSTYYXKC.js → chunk-JAY7YWS3.js} +2 -2
- package/dist/{chunk-6XFC7PQ5.js → chunk-JHF3E4YM.js} +2 -2
- package/dist/chunk-JORHF5AL.js +108 -0
- package/dist/{chunk-QBYYWGAT.js → chunk-K2WO7XY7.js} +2 -2
- package/dist/chunk-KFZNKUNT.js +2 -0
- package/dist/{chunk-J7VT2CRB.js → chunk-KJ2IIBZN.js} +2 -2
- package/dist/{chunk-336DC5NJ.js → chunk-KKME5ZAI.js} +2 -2
- package/dist/chunk-KSGTULOS.js +9 -0
- package/dist/{chunk-E2ZXPB7J.js → chunk-KXDJAG4N.js} +3 -3
- package/dist/{chunk-Z2LHPIOM.js → chunk-L4S2A7BV.js} +2 -2
- package/dist/chunk-LP3ARJKF.js +8 -0
- package/dist/chunk-LSOR3LQG.js +3 -0
- package/dist/{chunk-FHCTEANE.js → chunk-MLFZP76A.js} +2 -2
- package/dist/{chunk-RBFFD4V2.js → chunk-MNSTUIDD.js} +2 -2
- package/dist/{chunk-3OIKRYU5.js → chunk-MSBDMFER.js} +2 -2
- package/dist/{chunk-7LABSJSR.js → chunk-MZZBAITE.js} +5 -5
- package/dist/{chunk-QQWOFXNW.js → chunk-NE3TZUCI.js} +2 -2
- package/dist/{chunk-JZNLMHWY.js → chunk-NTUMF2X3.js} +2 -2
- package/dist/{chunk-DD5BOU5I.js → chunk-O23I56NA.js} +2 -2
- package/dist/{chunk-YHXBD52M.js → chunk-O3O4XXO6.js} +2 -2
- package/dist/{chunk-FQTPPXNA.js → chunk-OUBAF226.js} +2 -2
- package/dist/chunk-P3UO3EH3.js +2 -0
- package/dist/{chunk-5OC3HWP5.js → chunk-QGGLL3UH.js} +2 -2
- package/dist/chunk-QIQ63BHW.js +16 -0
- package/dist/{chunk-RWRLUZ6U.js → chunk-QJIVBYEK.js} +2 -2
- package/dist/chunk-QOXBSI6G.js +20 -0
- package/dist/{chunk-7Q6VYYCH.js → chunk-QXK6UUSM.js} +2 -2
- package/dist/{chunk-ZTTISZ7J.js → chunk-RA3AYNWP.js} +2 -2
- package/dist/chunk-RJMDJR3A.js +2 -0
- package/dist/{chunk-TFUU5MQQ.js → chunk-RLH5VUMG.js} +2 -2
- package/dist/{chunk-OHWZKLVA.js → chunk-S4S2WOIX.js} +2 -2
- package/dist/{chunk-YTUD45PU.js → chunk-SERUIGV5.js} +2 -2
- package/dist/{chunk-2OXVAGGT.js → chunk-SMQWE25B.js} +2 -2
- package/dist/{chunk-K42M2KWT.js → chunk-TAVELHYR.js} +2 -2
- package/dist/{chunk-MGBJHRFB.js → chunk-TWMJ3Y3G.js} +2 -2
- package/dist/chunk-VAXNI5NE.js +146 -0
- package/dist/chunk-VVY2G5ET.js +2 -0
- package/dist/{chunk-XF3KLXN3.js → chunk-W3DBTGL4.js} +2 -2
- package/dist/{chunk-26X7KCJR.js → chunk-WANA4KAQ.js} +2 -2
- package/dist/chunk-WJL2L6MV.js +60 -0
- package/dist/chunk-WUW7YUAH.js +11 -0
- package/dist/{chunk-PC44K7RF.js → chunk-WWKWUPSU.js} +2 -2
- package/dist/{chunk-2EZSOTSY.js → chunk-WY45BHKQ.js} +2 -2
- package/dist/chunk-X4FR5BZF.js +9 -0
- package/dist/chunk-X6RKPDY7.js +2 -0
- package/dist/{chunk-GK3GRUJX.js → chunk-YLFORA5G.js} +2 -2
- package/dist/{chunk-NBRUH7OE.js → chunk-YTVWB7YJ.js} +2 -2
- package/dist/{chunk-YGQN3XGZ.js → chunk-ZCEJ63SP.js} +2 -2
- package/dist/{chunk-2GSQR6YA.js → chunk-ZJ5CBXK3.js} +2 -2
- package/dist/chunk-ZL2OGDCD.js +2 -0
- package/dist/cli.js +8 -3
- package/dist/command-descriptors-ZW5J4ZEM.js +631 -0
- package/dist/{config-types-BWQ5xPGI.d.ts → config-types-B6MEoRNy.d.ts} +4 -0
- package/dist/{db-B0r1o7Vt.d.ts → db-DYLKr9Wn.d.ts} +1 -1
- package/dist/direct-navigation-42YHQPOI.js +3 -0
- package/dist/{health-CFnlCiTz.d.ts → health-DgxIDXJC.d.ts} +1 -1
- package/dist/index.d.ts +2 -2
- 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 +2 -2
- package/dist/queries/change-surface.js +1 -1
- package/dist/queries/cleanup-plan.d.ts +2 -2
- package/dist/queries/cleanup-plan.js +1 -1
- package/dist/queries/co-change.d.ts +2 -2
- package/dist/queries/co-change.js +1 -1
- package/dist/queries/code.d.ts +2 -2
- package/dist/queries/code.js +1 -1
- package/dist/queries/complexity-hotspots.d.ts +2 -2
- package/dist/queries/complexity-hotspots.js +1 -1
- package/dist/queries/complexity.d.ts +2 -2
- package/dist/queries/complexity.js +1 -1
- package/dist/queries/convergence.d.ts +2 -2
- package/dist/queries/convergence.js +1 -1
- package/dist/queries/coupling.d.ts +2 -2
- package/dist/queries/coupling.js +1 -1
- package/dist/queries/cycles.d.ts +2 -2
- package/dist/queries/cycles.js +1 -1
- package/dist/queries/dataflow.d.ts +2 -2
- package/dist/queries/dataflow.js +1 -1
- package/dist/queries/dead.d.ts +2 -2
- package/dist/queries/dead.js +1 -1
- package/dist/queries/decorative-checkers.d.ts +2 -2
- package/dist/queries/decorative-checkers.js +1 -1
- package/dist/queries/deep-chains.d.ts +2 -2
- package/dist/queries/deep-chains.js +1 -1
- package/dist/queries/deps.d.ts +2 -2
- package/dist/queries/deps.js +1 -1
- package/dist/queries/diff-gate.d.ts +2 -2
- package/dist/queries/diff-gate.js +1 -1
- package/dist/queries/diff-impact.d.ts +2 -2
- package/dist/queries/diff-impact.js +1 -1
- package/dist/queries/doc-drift.d.ts +2 -2
- package/dist/queries/doc-drift.js +1 -1
- package/dist/queries/drift.d.ts +2 -2
- package/dist/queries/drift.js +1 -1
- package/dist/queries/duplicate-bodies.d.ts +2 -2
- package/dist/queries/duplicate-bodies.js +1 -1
- package/dist/queries/extract-candidates.d.ts +2 -2
- package/dist/queries/extract-candidates.js +1 -1
- package/dist/queries/fan.d.ts +2 -2
- package/dist/queries/fan.js +1 -1
- package/dist/queries/files.d.ts +2 -2
- package/dist/queries/health.d.ts +3 -3
- package/dist/queries/health.js +1 -1
- package/dist/queries/hierarchy.d.ts +2 -2
- package/dist/queries/hierarchy.js +1 -1
- package/dist/queries/hotspots.d.ts +2 -2
- package/dist/queries/hotspots.js +1 -1
- package/dist/queries/imports.d.ts +2 -2
- package/dist/queries/imports.js +1 -1
- package/dist/queries/incomplete-migration.d.ts +2 -2
- package/dist/queries/incomplete-migration.js +1 -1
- package/dist/queries/index.d.ts +3 -3
- package/dist/queries/index.js +1 -1
- package/dist/queries/isolated.d.ts +2 -2
- package/dist/queries/isolated.js +1 -1
- package/dist/queries/locality-candidates.d.ts +2 -2
- package/dist/queries/locality-candidates.js +1 -1
- package/dist/queries/members.d.ts +2 -2
- package/dist/queries/members.js +1 -1
- package/dist/queries/methods.d.ts +2 -2
- package/dist/queries/methods.js +1 -1
- package/dist/queries/not-implemented.d.ts +2 -2
- package/dist/queries/not-implemented.js +1 -1
- package/dist/queries/outline.d.ts +2 -2
- package/dist/queries/outline.js +1 -1
- package/dist/queries/passthrough-candidates.d.ts +2 -2
- package/dist/queries/passthrough-candidates.js +1 -1
- package/dist/queries/plan-context.d.ts +2 -2
- package/dist/queries/plan-context.js +1 -1
- package/dist/queries/react-component-duplicates.d.ts +2 -2
- package/dist/queries/react-component-duplicates.js +1 -1
- package/dist/queries/react-hook-candidates.d.ts +2 -2
- package/dist/queries/react-hook-candidates.js +1 -1
- package/dist/queries/react-large-component-pressure.d.ts +2 -2
- package/dist/queries/react-large-component-pressure.js +1 -1
- package/dist/queries/recent-duplicates.d.ts +2 -2
- package/dist/queries/recent-duplicates.js +1 -1
- package/dist/queries/redundant-reexports.d.ts +2 -2
- package/dist/queries/redundant-reexports.js +1 -1
- package/dist/queries/refs.d.ts +2 -2
- package/dist/queries/refs.js +1 -1
- package/dist/queries/self-audit.d.ts +2 -2
- package/dist/queries/self-audit.js +1 -1
- package/dist/queries/similar-chains.d.ts +2 -2
- package/dist/queries/similar-chains.js +1 -1
- package/dist/queries/similar-files.d.ts +2 -2
- package/dist/queries/similar-files.js +1 -1
- package/dist/queries/similar-signatures.d.ts +2 -2
- package/dist/queries/similar-signatures.js +1 -1
- package/dist/queries/similar.d.ts +2 -2
- package/dist/queries/similar.js +1 -1
- package/dist/queries/slice.d.ts +2 -2
- package/dist/queries/slice.js +1 -1
- package/dist/queries/stale-abstractions.d.ts +2 -2
- package/dist/queries/stale-abstractions.js +1 -1
- package/dist/queries/stats.d.ts +2 -2
- package/dist/queries/surface.d.ts +2 -2
- package/dist/queries/surface.js +1 -1
- package/dist/queries/symbols.d.ts +2 -2
- package/dist/queries/symbols.js +1 -1
- package/dist/queries/system.d.ts +2 -2
- package/dist/queries/system.js +1 -1
- package/dist/queries/test-quality.d.ts +2 -2
- package/dist/queries/test-quality.js +1 -1
- package/dist/queries/trace.d.ts +2 -2
- package/dist/queries/trace.js +1 -1
- package/dist/queries/twin-ab.d.ts +2 -2
- package/dist/queries/twin-ab.js +1 -1
- package/dist/queries/twin-drift.d.ts +2 -2
- package/dist/queries/twin-drift.js +1 -1
- package/dist/queries/unused-imports.d.ts +2 -2
- package/dist/queries/unused-imports.js +1 -1
- package/dist/queries/unused-params.d.ts +2 -2
- package/dist/queries/unused-params.js +1 -1
- package/dist/queries/vue-component-duplicates.d.ts +2 -2
- package/dist/queries/vue-component-duplicates.js +1 -1
- package/dist/queries/vue-composable-candidates.d.ts +2 -2
- package/dist/queries/vue-composable-candidates.js +1 -1
- package/dist/queries/vue-large-view-pressure.d.ts +2 -2
- package/dist/queries/vue-large-view-pressure.js +1 -1
- package/dist/queries/wrapper-candidates.d.ts +2 -2
- package/dist/queries/wrapper-candidates.js +1 -1
- package/dist/reindex-worker.js +26 -25
- package/dist/reindex.d.ts +7 -3
- package/dist/reindex.js +34 -33
- package/dist/runtime.d.ts +3 -10
- 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-DCvnlZCu.d.ts → scip-cli-Cc6c00-a.d.ts} +2 -2
- package/dist/watch-server.js +5 -5
- package/docs/AGENT_GUIDE.md +19 -3
- package/docs/CLI_JSON_OUTPUT.md +86 -1
- package/docs/COMMAND_REFERENCE.md +5 -3
- package/docs/SECURITY_MODEL.md +129 -0
- package/docs/TELEMETRY_RETENTION.md +5 -0
- package/docs/schemas/cli-output-page.schema.json +104 -0
- package/package.json +8 -7
- package/skills/_shared/SKILL.md +4 -2
- package/skills/scip-audit/SKILL.md +3 -2
- package/skills/scip-explore/SKILL.md +1 -1
- package/skills/scip-improve/SKILL.md +1 -1
- package/skills/scip-plan/SKILL.md +1 -1
- package/skills/scip-verify/SKILL.md +7 -2
- package/dist/chunk-24QNP7MN.js +0 -2
- package/dist/chunk-2ZOCHAL2.js +0 -8
- package/dist/chunk-35SQLYCQ.js +0 -2
- package/dist/chunk-4CGVLUDP.js +0 -18
- package/dist/chunk-4RI4BJGT.js +0 -8
- package/dist/chunk-52HQTTPB.js +0 -2
- package/dist/chunk-A63U2W3P.js +0 -3
- package/dist/chunk-ADFSIJP2.js +0 -16
- package/dist/chunk-AOLE4DYM.js +0 -6
- package/dist/chunk-B5MHCHP3.js +0 -107
- package/dist/chunk-DGAGY7RJ.js +0 -60
- package/dist/chunk-DGMCFMPG.js +0 -11
- package/dist/chunk-GA64UPMI.js +0 -6
- package/dist/chunk-HEBAY673.js +0 -2
- package/dist/chunk-HELS7KFF.js +0 -2
- package/dist/chunk-IPDCSB6N.js +0 -6
- package/dist/chunk-JJJCO4QC.js +0 -945
- package/dist/chunk-KP4KBDVF.js +0 -3
- package/dist/chunk-LRTP3DKL.js +0 -3
- package/dist/chunk-P6HBYNBE.js +0 -5
- package/dist/chunk-QHKUY4FW.js +0 -2
- package/dist/chunk-QHRL4LKM.js +0 -2
- package/dist/chunk-UXP636P5.js +0 -144
- package/dist/chunk-VEVBIAOJ.js +0 -16
- package/dist/chunk-VKRQDBW5.js +0 -9
- package/dist/chunk-VOQFGC2W.js +0 -67
- package/dist/chunk-WMXRRBII.js +0 -8
- package/dist/chunk-X3NLZHPA.js +0 -20
- package/dist/chunk-Z5QQPJ3U.js +0 -30
- package/dist/chunk-ZLJLE6LK.js +0 -2
- package/dist/command-descriptors-SJDZ7QGR.js +0 -617
- package/dist/direct-navigation-HTKOZEOM.js +0 -3
package/dist/runtime.d.ts
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
import { P as ProjectConfig, a as SupportedLanguage, T as TypeScriptProjectMode } from './config-types-
|
|
1
|
+
import { P as ProjectConfig, a as SupportedLanguage, T as TypeScriptProjectMode } from './config-types-B6MEoRNy.js';
|
|
2
2
|
import { watch } from 'chokidar';
|
|
3
|
-
import { R as RefreshTrigger, W as WatcherStatus } from './scip-cli-
|
|
4
|
-
export { g as getScipVersion, i as isScipInstalled, p as printScipInstallInstructions } from './scip-cli-
|
|
3
|
+
import { R as RefreshTrigger, W as WatcherStatus } from './scip-cli-Cc6c00-a.js';
|
|
4
|
+
export { g as getScipVersion, i as isScipInstalled, p as printScipInstallInstructions } from './scip-cli-Cc6c00-a.js';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* Resolve all storage paths for a project's index files (cache dir, SQLite
|
|
8
|
-
* db, .scip index, meta.json). Distinct from queries/internal/file-resolution.ts's
|
|
9
|
-
* resolveIndexedPaths, which resolves a file-pattern query against the
|
|
10
|
-
* already-indexed documents table -- a different job that happens to share
|
|
11
|
-
* "resolve" + "index" + "paths" vocabulary.
|
|
12
|
-
*/
|
|
13
6
|
declare function resolveIndexStoragePaths(projectRoot: string, config?: ProjectConfig): {
|
|
14
7
|
cacheDir: string;
|
|
15
8
|
dbPath: string;
|
package/dist/runtime.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`}import{createHash as J}from"crypto";import{closeSync as Ce,fstatSync as U,openSync as Re,readFileSync as Se,rmSync as xe}from"fs";import{dirname as Ee}from"path";var we=2e3,be=10,ke=3,x=class extends Error{constructor(r,n,i){super(`Concurrent edit detected for ${r}; expected revision ${Y(n)}, but found ${Y(i)}. The latest file was left untouched.`);this.path=r;this.original=n;this.latest=i;this.name="FileRevisionConflictError"}path;original;latest};function B(t,e,r={}){let n=Pe(t,r.lockTimeoutMs??we,r.monotonicNow??R);try{let i=Math.max(0,Math.floor(r.maxRetries??ke));for(let s=0;;s+=1){let o=S(t),l=e(o,s);if(l.kind==="unchanged")return{changed:!1,attempts:s+1,previous:o,current:o};r.onBeforeCommit?.({attempt:s,snapshot:o,mutation:l});let c=S(t);if(!_e(o.revision,c.revision)){if(s<i)continue;throw new x(t,o.revision,c.revision)}try{Te(t,l,o.revision)}catch(u){if(u.code==="EEXIST"){let d=S(t);if(s<i)continue;throw new x(t,o.revision,d.revision)}throw u}return{changed:!0,attempts:s+1,previous:o,current:S(t)}}}finally{n.release()}}function S(t){for(let e=0;e<4;e+=1){let r;try{r=Re(t,"r");let n=H(U(r)),i=Se(r,"utf8"),s=H(U(r));if(!K(n,s))continue;return{path:t,text:i,revision:{exists:!0,hash:J("sha256").update(i).digest("hex"),identity:s}}}catch(n){if(n.code==="ENOENT")return{path:t,text:"",revision:{exists:!1,hash:J("sha256").update("").digest("hex")}};throw n}finally{r!==void 0&&Ce(r)}}throw new Error(`Could not read a stable revision of ${t}; the file is changing continuously.`)}function Pe(t,e,r){let n=`${t}.scip-query-write.lock`,i=r()+Math.max(0,e);for(;;){let s=L(n,{kind:"revisioned-file-mutation",detail:{target:t}});if(s.kind==="acquired")return s.lock;if(r()>=i)throw new Error(`Timed out after ${e}ms waiting to update ${t}; the file was left untouched.`);Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,be)}}function Te(t,e,r){if(e.kind==="delete"){if(!r.exists)return;xe(t),$(Ee(t));return}let n=e.mode??r.identity?.mode;r.exists?N(t,e.text,{durability:"durable",mode:n}):M(t,e.text,{durability:"durable",mode:n})}function _e(t,e){return t.exists===e.exists&&t.hash===e.hash&&(t.identity===void 0?e.identity===void 0:e.identity!==void 0&&K(t.identity,e.identity))}function H(t){return{dev:t.dev,ino:t.ino,size:t.size,mtimeMs:t.mtimeMs,mode:t.mode&511}}function K(t,e){return t.dev===e.dev&&t.ino===e.ino&&t.size===e.size&&t.mtimeMs===e.mtimeMs&&t.mode===e.mode}function Y(t){return t.exists?t.hash.slice(0,12):"<absent>"}var v=".scipquery.json",X=250,Q=0,Z=10*6e4,Oe={enabled:!1,debounceMs:X,cooldownMs:Q,gitPollMs:2e3,idleTimeoutMs:Z,autoRefresh:!0,ignore:[]};var jt=new Set(O);function P(t){let e=z(t,v);if(!Ie(e))return{};let r;try{r=je(e,"utf-8")}catch(n){let i=n instanceof Error?n.message:String(n);throw new Error(`unable to read ${v} at ${e}: ${i}`,{cause:n})}return $e(G(r),e,"read").config}function ee(t){return{...Oe,...t.watch}}function Ne(t,e){let r=z(t,v),n={languages:e,watch:{enabled:!0,debounceMs:X,cooldownMs:Q,gitPollMs:2e3,idleTimeoutMs:Z,autoRefresh:!0}};return B(r,i=>i.revision.exists?{kind:"unchanged"}:{kind:"write",text:Me(n)}),r}function Me(t){return q(t)}function $e(t,e,r){if(t.kind==="legacy"||t.kind==="supported")return t;if(t.kind==="malformed"){let i=r==="read"?`invalid ${v} at ${e}: ${t.reason}`:`Cannot update ${e}: the latest project config is ${t.reason}.`;throw new Error(`${i} The file was left untouched.`)}let n=r==="read"?`invalid ${v} at ${e}`:`Cannot update ${e}: the latest project config is invalid`;throw new Error(`${n} (unsupported ${t.direction} schemaVersion ${t.schemaVersion}; this scip-query reads legacy v${p} and current v${f}). Upgrade scip-query before retrying; the file was left untouched.`)}import{statSync as Ae}from"fs";import{basename as Fe,isAbsolute as Le,join as Ve,relative as We}from"path";import{watch as De}from"chokidar";import Ge from"ignore";var T=class{projectRoot;config;watchConfig;languages;pnpmWorkspaces;typescriptProjectMode;typescriptProjects;clojureConfigPath;indexerConcurrency;onStatus;onReindexComplete;onReindexError;onRefreshSuppressed;onError;reindexRunner;subscriptionFactory;clock;activeOperation=null;stopPromise=null;stopInProgress=!1;status={state:"idle"};debounceTimer=null;cooldownTimer=null;dirty=!1;changedFiles=0;pendingTrigger=null;reindexInFlight=!1;lastReindexEnd=0;fsWatchers=[];sourcePollingFallbackStarted=!1;gitPollTimer=null;lastGitState=null;gitignoreFilter;extraIgnore;stopped=!1;constructor(e){this.projectRoot=e.projectRoot,this.config=e.config,this.watchConfig=ee(e.config),this.languages=e.languages,this.pnpmWorkspaces=e.config.indexer?.typescript?.pnpmWorkspaces??!1,this.typescriptProjectMode=e.config.indexer?.typescript?.projectMode,this.typescriptProjects=e.config.indexer?.typescript?.projects,this.clojureConfigPath=e.config.indexer?.clojure?.configPath,this.indexerConcurrency=e.config.indexerConcurrency,this.onStatus=e.onStatus??(()=>{}),this.onReindexComplete=e.onReindexComplete??(()=>{}),this.onReindexError=e.onReindexError??(()=>{}),this.onRefreshSuppressed=e.onRefreshSuppressed??(()=>{}),this.onError=e.onError??(r=>console.error(r.message)),this.clock=e.clock??qe,this.reindexRunner=e.reindexRunner??ie(),this.subscriptionFactory=e.subscriptionFactory??Je,this.gitignoreFilter=F(e.projectRoot),this.extraIgnore=Ge(),this.watchConfig.ignore.length>0&&this.extraIgnore.add(this.watchConfig.ignore)}start(){if(this.stopInProgress)throw new Error("Cannot restart a watcher while its previous ownership is still draining.");this.stopped=!1,this.stopPromise=null,this.sourcePollingFallbackStarted=!1,this.setStatus({state:"idle"}),this.startGitStatePolling();try{this.startSourceWatcher()}catch(e){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(e)}`))}}stop(){if(this.stopPromise)return this.stopPromise;this.stopped=!0,this.stopInProgress=!0;let e=this.fsWatchers;this.fsWatchers=[],this.clearDebounceTimer(),this.clearCooldownTimer(),this.clearGitPollTimer();let r=this.activeOperation;return r&&this.setStatus({state:"draining",startedAt:this.wallNow(),reason:"waiting for the active reindex worker to exit"}),this.stopPromise=this.finishStop(e,r).finally(()=>{this.stopInProgress=!1}),this.stopPromise}requestRefresh(e,r={}){if(!this.stopped){if(!r.immediate||this.reindexInFlight||this.status.state==="cooldown"){this.scheduleReindex(e);return}this.pendingTrigger=re(this.pendingTrigger,e),this.changedFiles+=1,this.clearDebounceTimer(),this.triggerReindex()}}startSourceWatcher(e=!1){let r=this.subscriptionFactory(this.projectRoot,{ignoreInitial:!0,ignored:(n,i)=>this.isIgnoredWatchPath(n,i?.isDirectory()??!1),usePolling:e,...e?{interval:500,binaryInterval:1e3}:{}});r.on("all",(n,i)=>{this.stopped||this.handleFileChange(i)}),r.on("error",n=>this.handleSourceWatcherError(r,n,e)),this.fsWatchers.push(r)}handleSourceWatcherError(e,r,n){if(n||this.sourcePollingFallbackStarted||!Ke(r)||this.stopped){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(r)}`));return}this.sourcePollingFallbackStarted=!0,this.fsWatchers=this.fsWatchers.filter(i=>i!==e),e.close();try{this.startSourceWatcher(!0)}catch(i){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(i)}`))}}isIgnoredWatchPath(e,r){let n=this.relativeWatchPath(e);if(!n)return!1;let i=r?`${n}/`:n;return i===".git/"||i.startsWith(".git/")?!0:this.gitignoreFilter.isIgnored(i)||this.extraIgnore.ignores(i)}handleFileChange(e){let r=this.relativeWatchPath(e);!r||r===".."||r.startsWith("../")||r===".git"||r.startsWith(".git/")||this.gitignoreFilter.isIgnored(r)||this.extraIgnore.ignores(r)||r.endsWith("index.db")||r.endsWith("index.scip")||r.endsWith("index.db.tmp")||Fe(r).startsWith(V)||this.scheduleReindex({kind:"watch-source",detail:r})}relativeWatchPath(e){let r=Le(e)?e:Ve(this.projectRoot,e);return We(this.projectRoot,r).replaceAll("\\","/")}scheduleReindex(e){if(this.pendingTrigger=re(this.pendingTrigger,e),this.changedFiles++,this.reindexInFlight){this.dirty=!0,this.setStatus({state:"indexing",startedAt:this.status.startedAt});return}if(this.status.state==="cooldown"){this.dirty=!0,this.setStatus({state:"cooldown",until:this.status.until,dirty:!0});return}this.clearDebounceTimer();let r=this.wallNow()+this.watchConfig.debounceMs;this.setStatus({state:"waiting",changedFiles:this.changedFiles,reindexAt:r}),this.debounceTimer=this.clock.setTimeout(()=>{this.debounceTimer=null,this.triggerReindex()},this.watchConfig.debounceMs)}triggerReindex(){if(this.reindexInFlight||this.stopped)return;let e=this.clock.now()-this.lastReindexEnd;if(this.lastReindexEnd>0&&e<this.watchConfig.cooldownMs){let s=this.watchConfig.cooldownMs-e;this.dirty=!0;let o=this.wallNow()+s;this.setStatus({state:"cooldown",until:o,dirty:!0}),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},s);return}this.reindexInFlight=!0,this.dirty=!1,this.changedFiles=0;let r=this.pendingTrigger??{kind:"watch-source"};this.pendingTrigger=null;let n=this.wallNow();this.setStatus({state:"indexing",startedAt:n});let i=this.reindexRunner.start(this.reindexRequest(r));this.activeOperation=i,i.completion.then(s=>{if(this.reindexInFlight=!1,this.lastReindexEnd=this.clock.now(),this.stopped)return;let o=!1;try{o=this.onReindexComplete(s,r)===!0}catch(l){this.onError(l instanceof Error?l:new Error(String(l)))}if(this.dirty&&!this.stopped){if(o){let c=this.pendingTrigger??{kind:"unknown"};this.dirty=!1,this.changedFiles=0,this.pendingTrigger=null,this.onRefreshSuppressed(c),this.setStatus({state:"idle"});return}let l=this.wallNow()+this.watchConfig.cooldownMs;this.setStatus({state:"cooldown",until:l,dirty:!0}),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped?(this.dirty=!1,this.triggerReindex()):this.setStatus({state:"idle"})},this.watchConfig.cooldownMs)}else this.setStatus({state:"idle"})}).catch(s=>{if(this.reindexInFlight=!1,this.lastReindexEnd=this.clock.now(),this.stopped)return;let o=s instanceof Error?s:new Error(String(s));this.onReindexError(o,r),this.onError(o),this.setStatus({state:"idle"})}).finally(()=>{this.activeOperation===i&&(this.activeOperation=null)})}async finishStop(e,r){let n=[],i=r?r.cancel():null,s=await Promise.allSettled(e.map(o=>Promise.resolve().then(()=>o.close())));for(let o of s)o.status==="rejected"&&n.push(`watch subscription close failed: ${String(o.reason)}`);if(i)try{let o=await i;o.state==="degraded"&&n.push(o.reason)}catch(o){n.push(`reindex cancellation failed: ${o instanceof Error?o.message:String(o)}`)}return n.length>0?(this.setStatus({state:"draining",startedAt:this.wallNow(),reason:n.join("; ")}),{state:"degraded",reasons:n}):(this.setStatus({state:"idle"}),{state:"stopped"})}wallNow(){return this.clock.wallNow?.()??this.clock.now()}reindexRequest(e){return{projectRoot:this.projectRoot,config:this.config,languages:this.languages,pnpmWorkspaces:this.pnpmWorkspaces,typescriptProjectMode:this.typescriptProjectMode,typescriptProjects:this.typescriptProjects,clojureConfigPath:this.clojureConfigPath,indexerConcurrency:this.indexerConcurrency,trigger:e}}setStatus(e){this.status=e,this.onStatus(e)}clearDebounceTimer(){this.debounceTimer&&(this.clock.clearTimeout(this.debounceTimer),this.debounceTimer=null)}clearCooldownTimer(){this.cooldownTimer&&(this.clock.clearTimeout(this.cooldownTimer),this.cooldownTimer=null)}startGitStatePolling(){this.lastGitState=this.readGitState(),this.lastGitState&&(this.gitPollTimer=this.clock.setInterval(()=>this.pollGitState(),this.watchConfig.gitPollMs),this.gitPollTimer.unref?.())}pollGitState(){let e=this.lastGitState,r=this.readGitState();if(!e||!r||this.stopped){this.lastGitState=r;return}this.lastGitState=r;let n=e.head!==r.head,i=e.indexPath!==r.indexPath||e.indexMtimeMs!==r.indexMtimeMs||e.indexSize!==r.indexSize;n&&i?this.scheduleReindex({kind:"watch-git-state",detail:"HEAD and index changed"}):n?this.scheduleReindex({kind:"watch-git-head",detail:"HEAD changed"}):i&&this.scheduleReindex({kind:"watch-git-index",detail:r.indexPath??"index changed"})}readGitState(){let e=w(this.projectRoot,["rev-parse","--git-path","index"]);if(!e)return null;let r=A(this.projectRoot,e),n={head:w(this.projectRoot,["rev-parse","--verify","HEAD"]),indexPath:r};try{let i=Ae(r);n.indexMtimeMs=i.mtimeMs,n.indexSize=i.size}catch{n.indexMtimeMs=void 0,n.indexSize=void 0}return n}clearGitPollTimer(){this.gitPollTimer&&(this.clock.clearInterval(this.gitPollTimer),this.gitPollTimer=null)}};function ne(t){let{projectRoot:e,config:r,languages:n,pnpmWorkspaces:i,typescriptProjectMode:s,typescriptProjects:o,clojureConfigPath:l,indexerConcurrency:c,trigger:u}=t,d=P(e),a=Object.keys(d).length>0?d:r,C=b(e,a),E=a.indexer?.typescript,fe=a.indexer?.clojure;return{workerPath:new URL("./reindex-worker.js",import.meta.url).pathname,env:{...process.env,SCIP_REINDEX_PROJECT_ROOT:e,SCIP_REINDEX_OUTPUT_SCIP:C.indexPath,SCIP_REINDEX_OUTPUT_DB:C.dbPath,SCIP_REINDEX_LANGUAGES:(a.languages??n)?.join(",")??"",SCIP_REINDEX_INDEXER_CONCURRENCY:String(a.indexerConcurrency??c??""),SCIP_REINDEX_PNPM_WORKSPACES:E?.pnpmWorkspaces??i?"1":"",SCIP_REINDEX_TYPESCRIPT_CONFIG:JSON.stringify({projectMode:E?.projectMode??s,projects:E?.projects??o??[]}),SCIP_REINDEX_CLOJURE_CONFIG_PATH:fe?.configPath??l??"",SCIP_REINDEX_TRIGGER_KIND:u.kind,SCIP_REINDEX_TRIGGER_DETAIL:u.detail??"",SCIP_REINDEX_PROCESS_GROUP_LEADER:"1"}}}var qe={now:R,wallNow:()=>Date.now(),setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},Je=(t,e)=>De(t,e),Ue=15*6e4,He=1e3,Ye=64*1024;function Be(){return{stdoutTail:"",stderrTail:"",stdoutTruncated:!1,stderrTruncated:!1}}function te(t,e){let r=t instanceof Error?t.message:String(t),n=e.stderrTail.trim()||e.stdoutTail.trim();return n?`${r}
|
|
3
|
-
${n}`:r}function
|
|
1
|
+
import{e as b,i as Re,j as Ce,k as Se,m as G,r as q,v as J,w as U}from"./chunk-KSGTULOS.js";import{a as D}from"./chunk-WJL2L6MV.js";import"./chunk-DHEQMPLW.js";import{h as C,k as F,l as L,m as W,p as w,q as V}from"./chunk-LSOR3LQG.js";import{g as h,j as O,k as N,l as M,q as A,s as $}from"./chunk-VVY2G5ET.js";import{existsSync as Ne}from"fs";import{isAbsolute as Tt,join as ee,relative as _t,resolve as It}from"path";var p=1,f=2,xe="./node_modules/scip-query/docs/schemas/project-config.schema.json";function B(t){let e=t;if(typeof t=="string")try{e=JSON.parse(t)}catch(l){return{kind:"malformed",reason:`invalid JSON: ${l instanceof Error?l.message:String(l)}`}}if(!h(e))return{kind:"malformed",reason:"project config must be a JSON object"};let r=e.schemaVersion;if(r!==void 0&&!Number.isInteger(r))return{kind:"malformed",reason:"schemaVersion must be an integer"};let n=r===void 0?p:r;if(n!==p&&n!==f)return{kind:"unsupported",schemaVersion:n,direction:n<p?"older":"future"};let i=e.$schema;if(i!==void 0&&(typeof i!="string"||i.trim()===""))return{kind:"malformed",reason:"$schema must be a non-empty string when present"};let s=k(e),o=n!==f||typeof e.$schema!="string";return n===p?{kind:"legacy",sourceVersion:p,config:s,needsMigration:o}:{kind:"supported",sourceVersion:f,config:s,needsMigration:o}}function k(t){let e=t,{$schema:r,schemaVersion:n,...i}=e;return{$schema:typeof r=="string"&&r.trim()!==""?r:xe,schemaVersion:f,...i}}function H(t){return`${JSON.stringify(k(t),null,2)}
|
|
2
|
+
`}import{createHash as Y}from"crypto";import{closeSync as Ee,fstatSync as K,openSync as we,rmSync as be}from"fs";import{dirname as ke}from"path";var Pe=2e3,Te=10,_e=3,x=class extends Error{constructor(r,n,i){super(`Concurrent edit detected for ${r}; expected revision ${X(n)}, but found ${X(i)}. The latest file was left untouched.`);this.path=r;this.original=n;this.latest=i;this.name="FileRevisionConflictError"}path;original;latest};function Q(t,e,r={}){let n=Ie(t,r.lockTimeoutMs??Pe,r.monotonicNow??C);try{let i=Math.max(0,Math.floor(r.maxRetries??_e));for(let s=0;;s+=1){let o=S(t),l=e(o,s);if(l.kind==="unchanged")return{changed:!1,attempts:s+1,previous:o,current:o};r.onBeforeCommit?.({attempt:s,snapshot:o,mutation:l});let c=S(t);if(!Oe(o.revision,c.revision)){if(s<i)continue;throw new x(t,o.revision,c.revision)}try{je(t,l,o.revision)}catch(u){if(u.code==="EEXIST"){let d=S(t);if(s<i)continue;throw new x(t,o.revision,d.revision)}throw u}return{changed:!0,attempts:s+1,previous:o,current:S(t)}}}finally{n.release()}}function S(t){for(let e=0;e<4;e+=1){let r;try{r=we(t,"r");let n=z(K(r)),i=$(r,{maxBytes:M,inputKind:"revisioned text file"}),s=z(K(r));if(!Z(n,s))continue;return{path:t,text:i,revision:{exists:!0,hash:Y("sha256").update(i).digest("hex"),identity:s}}}catch(n){if(n.code==="ENOENT")return{path:t,text:"",revision:{exists:!1,hash:Y("sha256").update("").digest("hex")}};throw n}finally{r!==void 0&&Ee(r)}}throw new Error(`Could not read a stable revision of ${t}; the file is changing continuously.`)}function Ie(t,e,r){let n=`${t}.scip-query-write.lock`,i=r()+Math.max(0,e);for(;;){let s=G(n,{kind:"revisioned-file-mutation",detail:{target:t}});if(s.kind==="acquired")return s.lock;if(r()>=i)throw new Error(`Timed out after ${e}ms waiting to update ${t}; the file was left untouched.`);Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,Te)}}function je(t,e,r){if(e.kind==="delete"){if(!r.exists)return;be(t),W(ke(t));return}let n=e.mode??r.identity?.mode;r.exists?F(t,e.text,{durability:"durable",mode:n}):L(t,e.text,{durability:"durable",mode:n})}function Oe(t,e){return t.exists===e.exists&&t.hash===e.hash&&(t.identity===void 0?e.identity===void 0:e.identity!==void 0&&Z(t.identity,e.identity))}function z(t){return{dev:t.dev,ino:t.ino,size:t.size,mtimeMs:t.mtimeMs,mode:t.mode&511}}function Z(t,e){return t.dev===e.dev&&t.ino===e.ino&&t.size===e.size&&t.mtimeMs===e.mtimeMs&&t.mode===e.mode}function X(t){return t.exists?t.hash.slice(0,12):"<absent>"}var v=".scipquery.json",te=250,re=0,ne=10*6e4,Me={enabled:!1,debounceMs:te,cooldownMs:re,gitPollMs:2e3,idleTimeoutMs:ne,autoRefresh:!0,ignore:[]};var At=new Set(O);function P(t){let e=ee(t,v);if(!Ne(e))return{};let r;try{r=A(e,{maxBytes:N,inputKind:"scip-query project config"})}catch(n){let i=n instanceof Error?n.message:String(n);throw new Error(`unable to read ${v} at ${e}: ${i}`,{cause:n})}return Fe(B(r),e,"read").config}function ie(t){return{...Me,...t.watch}}function Ae(t,e){let r=ee(t,v),n={languages:e,watch:{enabled:!0,debounceMs:te,cooldownMs:re,gitPollMs:2e3,idleTimeoutMs:ne,autoRefresh:!0}};return Q(r,i=>i.revision.exists?{kind:"unchanged"}:{kind:"write",text:$e(n)}),r}function $e(t){return H(t)}function Fe(t,e,r){if(t.kind==="legacy"||t.kind==="supported")return t;if(t.kind==="malformed"){let i=r==="read"?`invalid ${v} at ${e}: ${t.reason}`:`Cannot update ${e}: the latest project config is ${t.reason}.`;throw new Error(`${i} The file was left untouched.`)}let n=r==="read"?`invalid ${v} at ${e}`:`Cannot update ${e}: the latest project config is invalid`;throw new Error(`${n} (unsupported ${t.direction} schemaVersion ${t.schemaVersion}; this scip-query reads legacy v${p} and current v${f}). Upgrade scip-query before retrying; the file was left untouched.`)}import{statSync as Le}from"fs";import{basename as We,isAbsolute as Ve,join as De,relative as Ge}from"path";import{watch as qe}from"chokidar";import Je from"ignore";var T=class{projectRoot;config;watchConfig;languages;pnpmWorkspaces;typescriptProjectMode;typescriptProjects;clojureConfigPath;indexerConcurrency;onStatus;onReindexComplete;onReindexError;onRefreshSuppressed;onError;reindexRunner;subscriptionFactory;clock;activeOperation=null;stopPromise=null;stopInProgress=!1;status={state:"idle"};debounceTimer=null;cooldownTimer=null;dirty=!1;changedFiles=0;pendingTrigger=null;reindexInFlight=!1;lastReindexEnd=0;fsWatchers=[];sourcePollingFallbackStarted=!1;gitPollTimer=null;lastGitState=null;gitignoreFilter;extraIgnore;stopped=!1;constructor(e){this.projectRoot=e.projectRoot,this.config=e.config,this.watchConfig=ie(e.config),this.languages=e.languages,this.pnpmWorkspaces=e.config.indexer?.typescript?.pnpmWorkspaces??!1,this.typescriptProjectMode=e.config.indexer?.typescript?.projectMode,this.typescriptProjects=e.config.indexer?.typescript?.projects,this.clojureConfigPath=e.config.indexer?.clojure?.configPath,this.indexerConcurrency=e.config.indexerConcurrency,this.onStatus=e.onStatus??(()=>{}),this.onReindexComplete=e.onReindexComplete??(()=>{}),this.onReindexError=e.onReindexError??(()=>{}),this.onRefreshSuppressed=e.onRefreshSuppressed??(()=>{}),this.onError=e.onError??(r=>console.error(r.message)),this.clock=e.clock??Ue,this.reindexRunner=e.reindexRunner??ce(),this.subscriptionFactory=e.subscriptionFactory??Be,this.gitignoreFilter=D(e.projectRoot),this.extraIgnore=Je(),this.watchConfig.ignore.length>0&&this.extraIgnore.add(this.watchConfig.ignore)}start(){if(this.stopInProgress)throw new Error("Cannot restart a watcher while its previous ownership is still draining.");this.stopped=!1,this.stopPromise=null,this.sourcePollingFallbackStarted=!1,this.setStatus({state:"idle"}),this.startGitStatePolling();try{this.startSourceWatcher()}catch(e){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(e)}`))}}stop(){if(this.stopPromise)return this.stopPromise;this.stopped=!0,this.stopInProgress=!0;let e=this.fsWatchers;this.fsWatchers=[],this.clearDebounceTimer(),this.clearCooldownTimer(),this.clearGitPollTimer();let r=this.activeOperation;return r&&this.setStatus({state:"draining",startedAt:this.wallNow(),reason:"waiting for the active reindex worker to exit"}),this.stopPromise=this.finishStop(e,r).finally(()=>{this.stopInProgress=!1}),this.stopPromise}requestRefresh(e,r={}){if(!this.stopped){if(!r.immediate||this.reindexInFlight||this.status.state==="cooldown"){this.scheduleReindex(e);return}this.pendingTrigger=se(this.pendingTrigger,e),this.changedFiles+=1,this.clearDebounceTimer(),this.triggerReindex()}}startSourceWatcher(e=!1){let r=this.subscriptionFactory(this.projectRoot,{ignoreInitial:!0,ignored:(n,i)=>this.isIgnoredWatchPath(n,i?.isDirectory()??!1),usePolling:e,...e?{interval:500,binaryInterval:1e3}:{}});r.on("all",(n,i)=>{this.stopped||this.handleFileChange(i)}),r.on("error",n=>this.handleSourceWatcherError(r,n,e)),this.fsWatchers.push(r)}handleSourceWatcherError(e,r,n){if(n||this.sourcePollingFallbackStarted||!Xe(r)||this.stopped){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(r)}`));return}this.sourcePollingFallbackStarted=!0,this.fsWatchers=this.fsWatchers.filter(i=>i!==e),e.close();try{this.startSourceWatcher(!0)}catch(i){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(i)}`))}}isIgnoredWatchPath(e,r){let n=this.relativeWatchPath(e);if(!n)return!1;let i=r?`${n}/`:n;return i===".git/"||i.startsWith(".git/")?!0:this.gitignoreFilter.isIgnored(i)||this.extraIgnore.ignores(i)}handleFileChange(e){let r=this.relativeWatchPath(e);!r||r===".."||r.startsWith("../")||r===".git"||r.startsWith(".git/")||this.gitignoreFilter.isIgnored(r)||this.extraIgnore.ignores(r)||r.endsWith("index.db")||r.endsWith("index.scip")||r.endsWith("index.db.tmp")||We(r).startsWith(q)||this.scheduleReindex({kind:"watch-source",detail:r})}relativeWatchPath(e){let r=Ve(e)?e:De(this.projectRoot,e);return Ge(this.projectRoot,r).replaceAll("\\","/")}scheduleReindex(e){if(this.pendingTrigger=se(this.pendingTrigger,e),this.changedFiles++,this.reindexInFlight){this.dirty=!0,this.setStatus({state:"indexing",startedAt:this.status.startedAt});return}if(this.status.state==="cooldown"){this.dirty=!0,this.setStatus({state:"cooldown",until:this.status.until,dirty:!0});return}this.clearDebounceTimer();let r=this.wallNow()+this.watchConfig.debounceMs;this.setStatus({state:"waiting",changedFiles:this.changedFiles,reindexAt:r}),this.debounceTimer=this.clock.setTimeout(()=>{this.debounceTimer=null,this.triggerReindex()},this.watchConfig.debounceMs)}triggerReindex(){if(this.reindexInFlight||this.stopped)return;let e=this.clock.now()-this.lastReindexEnd;if(this.lastReindexEnd>0&&e<this.watchConfig.cooldownMs){let s=this.watchConfig.cooldownMs-e;this.dirty=!0;let o=this.wallNow()+s;this.setStatus({state:"cooldown",until:o,dirty:!0}),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},s);return}this.reindexInFlight=!0,this.dirty=!1,this.changedFiles=0;let r=this.pendingTrigger??{kind:"watch-source"};this.pendingTrigger=null;let n=this.wallNow();this.setStatus({state:"indexing",startedAt:n});let i=this.reindexRunner.start(this.reindexRequest(r));this.activeOperation=i,i.completion.then(s=>{if(this.reindexInFlight=!1,this.lastReindexEnd=this.clock.now(),this.stopped)return;let o=!1;try{o=this.onReindexComplete(s,r)===!0}catch(l){this.onError(l instanceof Error?l:new Error(String(l)))}if(this.dirty&&!this.stopped){if(o){let c=this.pendingTrigger??{kind:"unknown"};this.dirty=!1,this.changedFiles=0,this.pendingTrigger=null,this.onRefreshSuppressed(c),this.setStatus({state:"idle"});return}let l=this.wallNow()+this.watchConfig.cooldownMs;this.setStatus({state:"cooldown",until:l,dirty:!0}),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped?(this.dirty=!1,this.triggerReindex()):this.setStatus({state:"idle"})},this.watchConfig.cooldownMs)}else this.setStatus({state:"idle"})}).catch(s=>{if(this.reindexInFlight=!1,this.lastReindexEnd=this.clock.now(),this.stopped)return;let o=s instanceof Error?s:new Error(String(s));this.onReindexError(o,r),this.onError(o),this.setStatus({state:"idle"})}).finally(()=>{this.activeOperation===i&&(this.activeOperation=null)})}async finishStop(e,r){let n=[],i=r?r.cancel():null,s=await Promise.allSettled(e.map(o=>Promise.resolve().then(()=>o.close())));for(let o of s)o.status==="rejected"&&n.push(`watch subscription close failed: ${String(o.reason)}`);if(i)try{let o=await i;o.state==="degraded"&&n.push(o.reason)}catch(o){n.push(`reindex cancellation failed: ${o instanceof Error?o.message:String(o)}`)}return n.length>0?(this.setStatus({state:"draining",startedAt:this.wallNow(),reason:n.join("; ")}),{state:"degraded",reasons:n}):(this.setStatus({state:"idle"}),{state:"stopped"})}wallNow(){return this.clock.wallNow?.()??this.clock.now()}reindexRequest(e){return{projectRoot:this.projectRoot,config:this.config,languages:this.languages,pnpmWorkspaces:this.pnpmWorkspaces,typescriptProjectMode:this.typescriptProjectMode,typescriptProjects:this.typescriptProjects,clojureConfigPath:this.clojureConfigPath,indexerConcurrency:this.indexerConcurrency,trigger:e}}setStatus(e){this.status=e,this.onStatus(e)}clearDebounceTimer(){this.debounceTimer&&(this.clock.clearTimeout(this.debounceTimer),this.debounceTimer=null)}clearCooldownTimer(){this.cooldownTimer&&(this.clock.clearTimeout(this.cooldownTimer),this.cooldownTimer=null)}startGitStatePolling(){this.lastGitState=this.readGitState(),this.lastGitState&&(this.gitPollTimer=this.clock.setInterval(()=>this.pollGitState(),this.watchConfig.gitPollMs),this.gitPollTimer.unref?.())}pollGitState(){let e=this.lastGitState,r=this.readGitState();if(!e||!r||this.stopped){this.lastGitState=r;return}this.lastGitState=r;let n=e.head!==r.head,i=e.indexPath!==r.indexPath||e.indexMtimeMs!==r.indexMtimeMs||e.indexSize!==r.indexSize;n&&i?this.scheduleReindex({kind:"watch-git-state",detail:"HEAD and index changed"}):n?this.scheduleReindex({kind:"watch-git-head",detail:"HEAD changed"}):i&&this.scheduleReindex({kind:"watch-git-index",detail:r.indexPath??"index changed"})}readGitState(){let e=w(this.projectRoot,["rev-parse","--git-path","index"]);if(!e)return null;let r=V(this.projectRoot,e),n={head:w(this.projectRoot,["rev-parse","--verify","HEAD"]),indexPath:r};try{let i=Le(r);n.indexMtimeMs=i.mtimeMs,n.indexSize=i.size}catch{n.indexMtimeMs=void 0,n.indexSize=void 0}return n}clearGitPollTimer(){this.gitPollTimer&&(this.clock.clearInterval(this.gitPollTimer),this.gitPollTimer=null)}};function ae(t){let{projectRoot:e,config:r,languages:n,pnpmWorkspaces:i,typescriptProjectMode:s,typescriptProjects:o,clojureConfigPath:l,indexerConcurrency:c,trigger:u}=t,d=P(e),a=Object.keys(d).length>0?d:r,R=b(e,a),E=a.indexer?.typescript,ve=a.indexer?.clojure;return{workerPath:new URL("./reindex-worker.js",import.meta.url).pathname,env:{...process.env,SCIP_REINDEX_PROJECT_ROOT:e,SCIP_REINDEX_OUTPUT_SCIP:R.indexPath,SCIP_REINDEX_OUTPUT_DB:R.dbPath,SCIP_REINDEX_LANGUAGES:(a.languages??n)?.join(",")??"",SCIP_REINDEX_INDEXER_CONCURRENCY:String(a.indexerConcurrency??c??""),SCIP_REINDEX_PNPM_WORKSPACES:E?.pnpmWorkspaces??i?"1":"",SCIP_REINDEX_TYPESCRIPT_CONFIG:JSON.stringify({projectMode:E?.projectMode??s,projects:E?.projects??o??[]}),SCIP_REINDEX_CLOJURE_CONFIG_PATH:ve?.configPath??l??"",SCIP_REINDEX_TRIGGER_KIND:u.kind,SCIP_REINDEX_TRIGGER_DETAIL:u.detail??"",SCIP_REINDEX_PROCESS_GROUP_LEADER:"1"}}}var Ue={now:C,wallNow:()=>Date.now(),setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},Be=(t,e)=>qe(t,e),He=15*6e4,Ye=1e3,Ke=64*1024;function ze(){return{stdoutTail:"",stderrTail:"",stdoutTruncated:!1,stderrTruncated:!1}}function oe(t,e){let r=t instanceof Error?t.message:String(t),n=e.stderrTail.trim()||e.stdoutTail.trim();return n?`${r}
|
|
3
|
+
${n}`:r}function ce(t={}){let e=t.timeoutMs??He,r=t.terminationGraceMs??Ye,n=t.maxOutputBytes??Ke,i=t.resolveLaunch??ae;return{start(s){let o=i(s),l=new AbortController,c=ze(),u=!1,d=U({command:process.execPath,args:[...process.execArgv,o.workerPath],label:"watch reindex worker",env:o.env,timeoutMs:e,terminationGraceMs:r,maxStdoutBytes:n,maxStderrBytes:n,outputLimitBehavior:"truncate-tail",signal:l.signal,detached:!0}).then(a=>{if(c={stdoutTail:a.stdout,stderrTail:a.stderr,stdoutTruncated:a.stdoutTruncated,stderrTruncated:a.stderrTruncated},a.status!==0)throw new Error(oe(new Error(`Reindex worker exited with ${a.signal?`signal ${a.signal}`:`code ${a.status}`}`),c));return a.durationMs}).catch(a=>{throw a instanceof J&&(c={stdoutTail:a.stdout,stderrTail:a.stderr,stdoutTruncated:a.stdoutTruncated,stderrTruncated:a.stderrTruncated}),new Error(oe(a,c),{cause:a})}).finally(()=>{u=!0});return{completion:d,async cancel(){u||l.abort();try{await d}catch{}return{state:"exited",diagnostics:c}},diagnostics:()=>c}}}}function se(t,e){return t?t.kind===e.kind?t.detail===e.detail?t:{kind:t.kind,detail:"multiple changes"}:{kind:"watch-git-state",detail:`${t.kind}, ${e.kind}`}:e}function Xe(t){return t instanceof Error&&"code"in t&&t.code==="EMFILE"||String(t).includes("EMFILE: too many open files")}import{existsSync as _,mkdirSync as Qe,symlinkSync as Ze,readlinkSync as le,unlinkSync as ue,readdirSync as et}from"fs";import{join as g,dirname as j,resolve as m,relative as tt,isAbsolute as rt}from"path";import{homedir as I,platform as nt}from"os";import{fileURLToPath as it}from"url";var ot=nt()==="win32",de=["_shared","scip-query","scip-setup","scip-explore","scip-plan","scip-diagnose","scip-audit","scip-improve","scip-verify"];function st(t={}){let e=t.quiet?()=>{}:console.log,r=it(import.meta.url),n=m(j(r),"..","skills"),i=[g(I(),".claude","skills"),g(I(),".codex","skills"),g(I(),".agents","skills")],s={installed:[],skipped:[],alreadyLinked:[],pruned:[]};for(let o of i){let l=j(o);if(!_(l))continue;Qe(o,{recursive:!0});let c=lt(o);at(o,n,c,s,e);for(let u of de){let d=g(n,u),a=g(o,u);if(!_(d)){s.skipped.push(`${c}/${u}`);continue}if(_(a)){try{let R=le(a);if(m(R)===m(d)){s.alreadyLinked.push(`${c}/${u}`),e(` ok: ${u} \u2192 ${c} (already linked)`);continue}}catch{s.skipped.push(`${c}/${u}`),e(` skip: ${u} \u2192 ${c} (exists, not a symlink)`);continue}ue(a)}Ze(d,a,ot?"junction":"dir"),s.installed.push(`${c}/${u}`),e(` done: ${u} \u2192 ${c}`)}}return s}function at(t,e,r,n,i){let s=new Set(de);for(let o of et(t)){if(s.has(o))continue;let l=g(t,o),c;try{c=m(j(l),le(l))}catch{continue}ct(c,e)&&(ue(l),n.pruned.push(`${r}/${o}`),i(` prune: ${o} \u2192 ${r} (removed stale scip-query skill link)`))}}function ct(t,e){let r=tt(m(e),m(t));return r===""||!r.startsWith("..")&&!rt(r)}function lt(t){return t.includes(".codex")?"Codex":t.includes(".agents")?"Agents":"Claude"}var fe="scip-query-result",ge=0,y=1,ut=1;function me(t){if(!h(t))return{kind:"malformed",reason:"CLI JSON output must be an object."};let e=Object.hasOwn(t,"kind"),r=Object.hasOwn(t,"schemaVersion");if(!e&&!r){let o=pe(t);return o?{kind:"malformed",reason:`Legacy CLI JSON envelope: ${o}`}:{kind:"legacy",schemaVersion:ge,envelope:t}}if(!e||!r)return{kind:"malformed",reason:"CLI JSON envelope must contain both kind and schemaVersion."};if(t.kind!==fe)return{kind:"malformed",reason:`Unsupported CLI JSON envelope kind: ${ft(t.kind)}.`};let n=t.schemaVersion;if(!Number.isSafeInteger(n)||Number(n)<1)return{kind:"malformed",reason:"CLI JSON envelope schemaVersion must be a positive safe integer."};if(n!==y)return{kind:"unsupported",schemaVersion:Number(n),direction:Number(n)<y?"older":"future",...he(t.producer)?{producer:t.producer}:{}};let i=pe(t);if(i)return{kind:"malformed",reason:`CLI JSON envelope v1: ${i}`};if(!he(t.producer))return{kind:"malformed",reason:"CLI JSON envelope v1: producer must identify scip-query and its non-empty version."};if(!ht(t.resultSchemaVersion))return{kind:"malformed",reason:"CLI JSON envelope v1: resultSchemaVersion must be a positive safe integer."};let s=ye(t.command);return s.includes(t.resultSchemaVersion)?{kind:"supported",schemaVersion:y,envelope:t}:{kind:"unsupported-result",schemaVersion:y,command:t.command,resultSchemaVersion:t.resultSchemaVersion,supportedResultSchemaVersions:s}}function dt(t){let e=me(t);if(e.kind==="legacy"||e.kind==="supported")return e;if(e.kind==="unsupported"){let r=e.producer?` from ${e.producer.name}@${e.producer.version}`:"";throw new Error(`Unsupported scip-query CLI JSON schemaVersion ${e.schemaVersion}${r}; this consumer supports the legacy unversioned envelope and schemaVersion ${y}.`)}throw e.kind==="unsupported-result"?new Error(`Unsupported resultSchemaVersion ${e.resultSchemaVersion} for scip-query command ${JSON.stringify(e.command)}; this consumer supports ${e.supportedResultSchemaVersions.join(", ")}.`):new Error(`Malformed scip-query CLI JSON envelope: ${e.reason}`)}function ye(t){return pt[t]??[ut]}var pt={};function pe(t){return typeof t.command!="string"||t.command.length===0?"command must be a non-empty string.":Array.isArray(t.args)?h(t.options)?Object.hasOwn(t,"result")?null:"result is required.":"options must be an object.":"args must be an array."}function he(t){return h(t)&&t.name==="scip-query"&&typeof t.version=="string"&&t.version.length>0}function ht(t){return Number.isSafeInteger(t)&&Number(t)>0}function ft(t){return typeof t=="string"?JSON.stringify(t):String(t)}export{fe as CLI_JSON_ENVELOPE_KIND,y as CURRENT_CLI_JSON_ENVELOPE_SCHEMA_VERSION,ge as LEGACY_CLI_JSON_ENVELOPE_SCHEMA_VERSION,T as Watcher,ce as createReindexRunner,me as decodeCliJsonEnvelope,Ce as getScipVersion,Ae as initProjectConfig,st as installSkills,Re as isScipInstalled,P as loadProjectConfig,Se as printScipInstallInstructions,dt as requireCompatibleCliJsonEnvelope,b as resolveIndexStoragePaths,ae as resolveReindexWorkerLaunch,ye as supportedCliResultSchemaVersions};
|
|
4
4
|
//# sourceMappingURL=runtime.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"./chunk-P5XHIJHI.js";import{A as G,B as X,C as Z,a as D,c as j,d as I,e as v,f as K,i as E,j as k,l as Y,q as H,r as A,s as _,t as C,u as P,v as N,w as $,y as Q,z as J}from"./chunk-VKRQDBW5.js";import{a as V,g as z}from"./chunk-HGFDYOVB.js";import{a as g}from"./chunk-APMMR5Y2.js";import p from"process";import{randomUUID as Ue}from"crypto";import{rmSync as Oe}from"fs";import{resolve as T}from"path";import{pathToFileURL as Be}from"url";import{spawn as Ie}from"child_process";import{createHash as ge,randomUUID as Me}from"crypto";import{existsSync as De,readFileSync as pn,realpathSync as Rn,rmSync as fn}from"fs";import{tmpdir as yn}from"os";import{resolve as Sn}from"path";import{createHash as Re}from"crypto";import{resolve as fe}from"path";var m=3;function q(e){return Re("sha256").update(A({kind:"scip-query-durable-rust-mailbox",protocolVersion:m,sessionDir:fe(e)})).digest("hex")}function B(e,n){if(!D(e)||typeof e.id!="string"||!e.id)return w("Durable Rust semantic helper received an invalid mailbox request.");if(e.id!==n.claimRequestId)return w("Durable Rust semantic request identity does not match its mailbox path.");if(e.protocolVersion===void 0){if(e.mailboxVersion!==void 0||e.operationKey!==void 0||e.clientId!==void 0||e.enqueuedAtMs!==void 0||e.deadlineAtMs!==void 0||e.sessionIdentity!==void 0)return w("Durable Rust semantic helper received a partially versioned request without a protocol version.");let o=ee(e.request);if(!o)return w("Durable Rust semantic helper received an invalid legacy request kind or payload.");let c=n.nowMs+Math.max(1,o.timeoutMs);return{ok:!0,compatibility:"legacy-v2",value:{mailboxVersion:_,protocolVersion:m,id:e.id,operationKey:N("rust-semantic-v2",{id:e.id,request:o}),clientId:"legacy-v2",enqueuedAtMs:n.nowMs,deadlineAtMs:c,sessionIdentity:n.sessionIdentity,request:o}}}let t=me(e,n);if(!t.ok)return t;if(e.protocolVersion!==m)return{ok:!1,code:"unsupported-protocol",error:`Durable Rust semantic helper does not support mailbox protocol ${String(e.protocolVersion)}.`,responseIdentity:t.responseIdentity};let i=ee(e.request);return i?t.operationKey!==N("rust-semantic-v3",i)?{ok:!1,code:"malformed-request",error:"Durable Rust semantic helper received a mismatched mailbox operation identity.",responseIdentity:t.responseIdentity}:t.deadlineAtMs-t.enqueuedAtMs!==i.timeoutMs?{ok:!1,code:"malformed-request",error:"Durable Rust semantic helper received a deadline that does not match the request timeout.",responseIdentity:t.responseIdentity}:t.deadlineAtMs<n.nowMs?{ok:!1,code:"expired-request",error:"Durable Rust semantic request expired before processing.",responseIdentity:t.responseIdentity}:{ok:!0,compatibility:t.priorSessionIdentity?"prior-v3":"current-v3",value:{mailboxVersion:_,protocolVersion:m,id:e.id,operationKey:t.operationKey,clientId:t.clientId,enqueuedAtMs:t.enqueuedAtMs,deadlineAtMs:t.deadlineAtMs,sessionIdentity:n.sessionIdentity,request:i}}:{ok:!1,code:"malformed-request",error:"Durable Rust semantic helper received an invalid request kind or payload.",responseIdentity:t.responseIdentity}}function me(e,n){if(e.mailboxVersion!==_||typeof e.protocolVersion!="number"||!Number.isInteger(e.protocolVersion)||typeof e.operationKey!="string"||!ne(e.operationKey)||e.id!==$(e.operationKey)||typeof e.clientId!="string"||!e.clientId||typeof e.enqueuedAtMs!="number"||!Number.isFinite(e.enqueuedAtMs)||typeof e.deadlineAtMs!="number"||!Number.isFinite(e.deadlineAtMs)||e.deadlineAtMs<e.enqueuedAtMs||e.sessionIdentity!==void 0&&(typeof e.sessionIdentity!="string"||!ne(e.sessionIdentity))||e.sessionIdentity===void 0&&e.protocolVersion!==m)return w("Durable Rust semantic helper received an invalid mailbox lifecycle.");let t={id:n.claimRequestId,sessionIdentity:n.sessionIdentity,deadlineAtMs:e.deadlineAtMs};return e.sessionIdentity!==void 0&&e.sessionIdentity!==n.sessionIdentity?{ok:!1,code:"malformed-request",error:"Durable Rust semantic request belongs to a different mailbox session.",responseIdentity:t}:{ok:!0,responseIdentity:t,operationKey:e.operationKey,clientId:e.clientId,enqueuedAtMs:e.enqueuedAtMs,deadlineAtMs:e.deadlineAtMs,priorSessionIdentity:e.sessionIdentity===void 0}}function ee(e){return!D(e)||typeof e.identityKey!="string"||!e.identityKey||!v(e.timeoutMs)||e.workerEnvironment!==void 0&&!j(e.workerEnvironment)?null:e.kind==="semantic"&&ye(e.request)?{kind:"semantic",identityKey:e.identityKey,...e.workerEnvironment===void 0?{}:{workerEnvironment:e.workerEnvironment},request:e.request,timeoutMs:e.timeoutMs}:e.kind==="import-definitions"&&be(e.request)?{kind:"import-definitions",identityKey:e.identityKey,...e.workerEnvironment===void 0?{}:{workerEnvironment:e.workerEnvironment},request:e.request,timeoutMs:e.timeoutMs}:null}function ye(e){return!D(e)||!h(e.projectRoot)||!h(e.rustAnalyzerBinary)||!re(e.definitions)?!1:U(e.referenceDefinitions)&&U(e.calleeDefinitions)&&U(e.signatureDefinitions)&&b(e.requestTimeoutMs)&&b(e.readinessDeadlineMs)&&b(e.referenceRetryTimeoutMs)&&b(e.diagnosticsTimeoutMs)&&b(e.settleDelayMs)&&se(e.concurrency)&&O(e.includeReferences)&&O(e.includeCallees)&&O(e.includeSignatures)}function be(e){return!D(e)||!h(e.projectRoot)||!h(e.rustAnalyzerBinary)||!h(e.file)||!Array.isArray(e.positions)||!e.positions.every(n=>D(n)&&h(n.id)&&h(n.file)&&I(n.line)&&I(n.column))?!1:b(e.requestTimeoutMs)&&b(e.readinessDeadlineMs)&&b(e.diagnosticsTimeoutMs)&&b(e.settleDelayMs)&&se(e.concurrency)}function re(e){return Array.isArray(e)&&e.every(Se)}function U(e){return e===void 0||re(e)}function Se(e){return D(e)&&I(e.symbolId)&&I(e.documentId)&&I(e.startLine)&&te(e.startChar)&&I(e.endLine)&&te(e.endChar)&&typeof e.symbol=="string"&&typeof e.relativePath=="string"&&typeof e.leaf=="string"&&(e.parentTypeName===null||typeof e.parentTypeName=="string")&&typeof e.isFunctionLike=="boolean"&&typeof e.isTypeLike=="boolean"&&(e.kind===null||Number.isSafeInteger(e.kind))&&(e.documentation===null||typeof e.documentation=="string")&&(e.enclosingSymbol===null||typeof e.enclosingSymbol=="string")}function w(e){return{ok:!1,code:"malformed-request",error:e}}function ne(e){return/^[a-f0-9]{64}$/.test(e)}function h(e){return typeof e=="string"&&e.length>0}function se(e){return e===void 0||v(e)}function te(e){return e===void 0||I(e)}function b(e){return e===void 0||K(e)}function O(e){return e===void 0||typeof e=="boolean"}var x=class{constructor(n,t=we){this.createRequester=n;this.applyEnvironment=t}createRequester;applyEnvironment;requester=null;identityKey=null;semanticResponseCache=null;handle(n){this.applyEnvironment(n.workerEnvironment??{});let t;if(this.requester?this.identityKey!==n.identityKey?(this.semanticResponseCache=null,this.requester.shutdown(),this.requester=this.createRequester(),this.identityKey=n.identityKey,t="invalidated"):t="reused":(this.requester=this.createRequester(),this.identityKey=n.identityKey,t="created"),n.kind==="semantic"){let i=he(n.request),o=t==="reused"&&i!==null&&this.semanticResponseCache?.identityKey===n.identityKey&&this.semanticResponseCache.requestKey===i?this.semanticResponseCache.response:null;if(o)return oe(!0,n.request.definitions.length),{session:t,response:o};let c=this.requester.requestSemantic(n.request,n.timeoutMs);return i!==null&&Ee(c)&&(this.semanticResponseCache={identityKey:n.identityKey,requestKey:i,response:c}),oe(!1,n.request.definitions.length),{session:t,response:c}}return{session:t,response:this.requester.requestImportDefinitions(n.request,n.timeoutMs)}}shutdown(){this.requester?.shutdown(),this.requester=null,this.identityKey=null,this.semanticResponseCache=null}};function he(e){if(e.includeReferences===!1||e.includeCallees!==!0||e.includeSignatures===!0||(e.referenceDefinitions?.length??0)===0||(e.calleeDefinitions?.length??0)===0)return null;let{readinessDeadlineMs:n,...t}=e;return _e(A(t))}function Ee(e){return e.available&&Array.isArray(e.callees)&&(e.incompleteReferenceSymbolIds?.length??0)===0}function oe(e,n){V()&&z({type:"span",name:"rust.semantic.durable-session.response-cache",durationMs:0,ok:!0,hit:e,definitions:n})}function we(e){for(let n of Object.keys(process.env))Ae(n)&&delete process.env[n];for(let[n,t]of Object.entries(e))t!==null&&(process.env[n]=t)}function ke(e){return e==="HOME"||e==="PATH"||e.startsWith("CARGO_")||e.startsWith("RA_")||e.startsWith("RUST")}function Ae(e){return ke(e)||e.startsWith("SCIP_RUST_")||e==="SCIP_QUERY_PROFILE"||e==="SCIP_QUERY_PROFILE_CACHE_STATE"||e==="SCIP_QUERY_PROFILE_COMMAND"||e==="SCIP_QUERY_PROFILE_OUT"||e==="SCIP_QUERY_PROFILE_RUN_ID"||e==="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY"||e==="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY_KIND"||e==="SCIP_QUERY_PROFILE_MIN_MS"}var En={now:Date.now,monotonicNow:g,randomId:Me,isProcessAlive:k,readProcessIdentity:E,spawnServer(e,n,t){if(!De(e))throw new Error(`Durable Rust semantic session helper was not found at ${e}. Run npm run build first.`);Ie(process.execPath,[e,n,t],{detached:!0,stdio:"ignore"}).unref()},sleep(e){let n=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(n,0,0,e)}};function _e(e){return ge("sha256").update(e).digest("hex")}import{existsSync as qe,mkdtempSync as ie,readFileSync as ae,rmSync as L}from"fs";import{tmpdir as ue}from"os";import{join as W}from"path";import{fileURLToPath as le,pathToFileURL as xe}from"url";import{SHARE_ENV as Te,Worker as ve}from"worker_threads";function de(e={}){let n=null,t=null,i=1,o=!1,c=()=>{t&&(L(t,{recursive:!0,force:!0}),t=null)},S=()=>{let r=n;n=null,r&&r.terminate(),c()},M=()=>{if(n)return n;let r=e.semanticWorkerPath?xe(e.semanticWorkerPath):Ne();if(!qe(le(r)))throw new Error(`Rust semantic session worker was not found at ${le(r)}. Run npm run build before using built semantic Rust queries.`);return t=ie(W(ue(),"scip-query-rust-session-")),n=new ve(r,e.shareEnvironment?{env:Te}:void 0),n.unref(),n},y=()=>{let r=t??ie(W(ue(),"scip-query-rust-session-"));return t=r,W(r,`${i++}.json`)};return{requestSemantic(r,s){if(o)throw new Error("Rust semantic session was already disposed.");let f=M(),l=y(),u=new SharedArrayBuffer(4),R=new Int32Array(u);if(f.postMessage({kind:"semantic",request:r,responsePath:l,sharedBuffer:u}),Atomics.wait(R,0,0,s)==="timed-out")throw S(),new Error(`Rust semantic session worker timed out after ${(s/1e3).toFixed(0)}s`);try{let a=Ce(ae(l,"utf8"));if(!a.ok)throw new Error(a.error);return a.response}finally{L(l,{force:!0})}},requestImportDefinitions(r,s){if(o)throw new Error("Rust semantic session was already disposed.");let f=M(),l=y(),u=new SharedArrayBuffer(4),R=new Int32Array(u);if(f.postMessage({kind:"import-definitions",request:r,responsePath:l,sharedBuffer:u}),Atomics.wait(R,0,0,s)==="timed-out")throw S(),new Error(`Rust semantic import-definition session worker timed out after ${(s/1e3).toFixed(0)}s`);try{let a=Pe(ae(l,"utf8"));if(!a.ok)throw new Error(a.error);return a.response}finally{L(l,{force:!0})}},shutdown(){if(o)return;if(o=!0,!n){c();return}let r=y(),s=new SharedArrayBuffer(4),f=new Int32Array(s);n.postMessage({kind:"shutdown",responsePath:r,sharedBuffer:s}),Atomics.wait(f,0,0,5e3),S()}}}function Ce(e){let n=JSON.parse(e);if(!n||typeof n!="object")return{ok:!1,error:"Rust semantic session worker wrote a non-object response."};let t=n;return t.ok===!0&&"response"in t?{ok:!0,response:t.response}:{ok:!1,error:typeof n.error=="string"?n.error:"Rust semantic session worker failed."}}function Pe(e){let n=JSON.parse(e);if(!n||typeof n!="object")return{ok:!1,error:"Rust semantic session worker wrote a non-object response."};let t=n;return t.ok===!0&&"response"in t?{ok:!0,response:t.response}:{ok:!1,error:typeof n.error=="string"?n.error:"Rust semantic session worker failed."}}function Ne(){return new URL("./rust-semantic-session-worker.js",import.meta.url)}var Le=10*6e4,We=10,Fe=1e3;function je(e,n,t={}){let i=C(e);P(i);let o=t.now??(t.nowMs===void 0?Date.now:()=>t.nowMs),c=o(),S=q(e),M=Q(i,{ownerId:t.ownerId??Je,nowMs:c,limits:t.limits,owner:Ge,liveness:Xe}),y=0;for(let r of M){let s=null,f,l="handler-error";try{let u=J(r,t.limits),R;try{R=JSON.parse(u)}catch{throw l="malformed-request",new Error("Durable Rust semantic helper received malformed request JSON.")}let d=B(R,{claimRequestId:r.requestId,sessionIdentity:S,nowMs:o()});if(!d.ok)throw l=d.code,f=d.responseIdentity,new Error(d.error);s=d.value,f={id:s.id,sessionIdentity:s.sessionIdentity,deadlineAtMs:s.deadlineAtMs};let a=Ke(s.request,t.monotonicNowMs??g());t.beforeRequest?.(a);let pe=n.handle(a),F=o();if(s.deadlineAtMs<F)throw l="expired-request",new Error("Durable Rust semantic request expired while the helper was processing it.");G(i,r,{ok:!0,protocolVersion:m,id:s.id,sessionIdentity:s.sessionIdentity,deadlineAtMs:s.deadlineAtMs,...pe},{nowMs:F,limits:t.limits})}catch(u){let R=o(),d=f??(s?{id:s.id,sessionIdentity:s.sessionIdentity,deadlineAtMs:s.deadlineAtMs}:void 0),a=u instanceof Error?u.message:String(u);X(i,r,{ok:!1,protocolVersion:m,id:d?.id??r.requestId,...d?{sessionIdentity:d.sessionIdentity,deadlineAtMs:d.deadlineAtMs}:{},errorCode:l,error:a},a,{nowMs:R,limits:t.limits})}y+=1}return y}function Ke(e,n){let t=n+Math.max(1,e.timeoutMs-1e3);return{...e,request:{...e.request,readinessDeadlineMs:t}}}async function Ve(e,n){let t=C(e);P(t);let i=T(e,"server.lock"),o=Ye(i);if(!o)return;let c=new x(()=>de({semanticWorkerPath:n,shareEnvironment:!0})),S=!1,M=g(),y=Number.NEGATIVE_INFINITY,r,s=E(p.pid),f=q(e),l=()=>{S=!0};p.once("SIGINT",l),p.once("SIGTERM",l);let u=(R=!1)=>{let d=Date.now(),a=g();!R&&a-y<Fe||(y=a,H(T(e,"server.json"),{protocolVersion:m,sessionIdentity:f,pid:p.pid,...s?{processIdentity:s}:{},heartbeatAtMs:d,...r===void 0?{}:{busyUntilMs:r},mailbox:Z(t)}))};try{u(!0);let R=He();for(;!S&&g()-M<R;)je(e,c,{beforeRequest(a){r=Date.now()+a.timeoutMs+5e3,u(!0)}})>0?(M=g(),r=void 0,u(!0)):u(),await $e(We)}finally{c.shutdown(),Oe(T(e,"server.json"),{force:!0}),o.release()}}var ze=e=>{let n=Number(e);return Number.isInteger(n)&&n>0?{pid:n}:null};function Ye(e){let n=Y(e,{kind:"rust-durable-session-server",parseLegacy:ze});return n.kind==="acquired"?n.lock:null}function He(){let e=Number(p.env.SCIP_RUST_SEMANTIC_DURABLE_IDLE_MS);return Number.isInteger(e)&&e>=0?e:Le}function $e(e){return new Promise(n=>setTimeout(n,e))}var Qe=p.argv[1]?Be(T(p.argv[1])).href:null;if(Qe===import.meta.url){let e=p.argv[2],n=p.argv[3];!e||!n?(console.error("durable-rust-session: expected <session-dir> <semantic-worker-path>"),p.exitCode=1):await Ve(e,n)}var Je=`rust-semantic-${p.pid}-${Ue()}`,ce=E(p.pid),Ge={pid:p.pid,...ce?{processIdentity:ce}:{}},Xe={isProcessAlive:k,readProcessIdentity:E};export{Ye as acquireDurableRustSessionServerLock,je as processDurableRustSessionRequests};
|
|
1
|
+
import"./chunk-P5XHIJHI.js";import{A as Z,B as ee,D as ne,a as D,c as V,d as I,e as P,f as z,i as E,j as k,l as $,q as Q,r as A,s as _,t as N,u as B,v as U,w as J,y as X,z as G}from"./chunk-X4FR5BZF.js";import{a as Y,g as H}from"./chunk-HGFDYOVB.js";import{a as g}from"./chunk-APMMR5Y2.js";import{b as C,g as v}from"./chunk-46XGSFNI.js";import p from"process";import{randomUUID as Ue}from"crypto";import{rmSync as Oe}from"fs";import{resolve as T}from"path";import{pathToFileURL as Le}from"url";import{spawn as ge}from"child_process";import{createHash as Me,randomUUID as De}from"crypto";import{existsSync as he,realpathSync as Rn,rmSync as fn}from"fs";import{tmpdir as yn}from"os";import{resolve as Sn}from"path";import{createHash as fe}from"crypto";import{resolve as me}from"path";var m=3;function q(e){return fe("sha256").update(A({kind:"scip-query-durable-rust-mailbox",protocolVersion:m,sessionDir:me(e)})).digest("hex")}function W(e,n){if(!D(e)||typeof e.id!="string"||!e.id)return w("Durable Rust semantic helper received an invalid mailbox request.");if(e.id!==n.claimRequestId)return w("Durable Rust semantic request identity does not match its mailbox path.");if(e.protocolVersion===void 0){if(e.mailboxVersion!==void 0||e.operationKey!==void 0||e.clientId!==void 0||e.enqueuedAtMs!==void 0||e.deadlineAtMs!==void 0||e.sessionIdentity!==void 0)return w("Durable Rust semantic helper received a partially versioned request without a protocol version.");let o=te(e.request);if(!o)return w("Durable Rust semantic helper received an invalid legacy request kind or payload.");let c=n.nowMs+Math.max(1,o.timeoutMs);return{ok:!0,compatibility:"legacy-v2",value:{mailboxVersion:_,protocolVersion:m,id:e.id,operationKey:U("rust-semantic-v2",{id:e.id,request:o}),clientId:"legacy-v2",enqueuedAtMs:n.nowMs,deadlineAtMs:c,sessionIdentity:n.sessionIdentity,request:o}}}let t=ye(e,n);if(!t.ok)return t;if(e.protocolVersion!==m)return{ok:!1,code:"unsupported-protocol",error:`Durable Rust semantic helper does not support mailbox protocol ${String(e.protocolVersion)}.`,responseIdentity:t.responseIdentity};let i=te(e.request);return i?t.operationKey!==U("rust-semantic-v3",i)?{ok:!1,code:"malformed-request",error:"Durable Rust semantic helper received a mismatched mailbox operation identity.",responseIdentity:t.responseIdentity}:t.deadlineAtMs-t.enqueuedAtMs!==i.timeoutMs?{ok:!1,code:"malformed-request",error:"Durable Rust semantic helper received a deadline that does not match the request timeout.",responseIdentity:t.responseIdentity}:t.deadlineAtMs<n.nowMs?{ok:!1,code:"expired-request",error:"Durable Rust semantic request expired before processing.",responseIdentity:t.responseIdentity}:{ok:!0,compatibility:t.priorSessionIdentity?"prior-v3":"current-v3",value:{mailboxVersion:_,protocolVersion:m,id:e.id,operationKey:t.operationKey,clientId:t.clientId,enqueuedAtMs:t.enqueuedAtMs,deadlineAtMs:t.deadlineAtMs,sessionIdentity:n.sessionIdentity,request:i}}:{ok:!1,code:"malformed-request",error:"Durable Rust semantic helper received an invalid request kind or payload.",responseIdentity:t.responseIdentity}}function ye(e,n){if(e.mailboxVersion!==_||typeof e.protocolVersion!="number"||!Number.isInteger(e.protocolVersion)||typeof e.operationKey!="string"||!re(e.operationKey)||e.id!==J(e.operationKey)||typeof e.clientId!="string"||!e.clientId||typeof e.enqueuedAtMs!="number"||!Number.isFinite(e.enqueuedAtMs)||typeof e.deadlineAtMs!="number"||!Number.isFinite(e.deadlineAtMs)||e.deadlineAtMs<e.enqueuedAtMs||e.sessionIdentity!==void 0&&(typeof e.sessionIdentity!="string"||!re(e.sessionIdentity))||e.sessionIdentity===void 0&&e.protocolVersion!==m)return w("Durable Rust semantic helper received an invalid mailbox lifecycle.");let t={id:n.claimRequestId,sessionIdentity:n.sessionIdentity,deadlineAtMs:e.deadlineAtMs};return e.sessionIdentity!==void 0&&e.sessionIdentity!==n.sessionIdentity?{ok:!1,code:"malformed-request",error:"Durable Rust semantic request belongs to a different mailbox session.",responseIdentity:t}:{ok:!0,responseIdentity:t,operationKey:e.operationKey,clientId:e.clientId,enqueuedAtMs:e.enqueuedAtMs,deadlineAtMs:e.deadlineAtMs,priorSessionIdentity:e.sessionIdentity===void 0}}function te(e){return!D(e)||typeof e.identityKey!="string"||!e.identityKey||!P(e.timeoutMs)||e.workerEnvironment!==void 0&&!V(e.workerEnvironment)?null:e.kind==="semantic"&&be(e.request)?{kind:"semantic",identityKey:e.identityKey,...e.workerEnvironment===void 0?{}:{workerEnvironment:e.workerEnvironment},request:e.request,timeoutMs:e.timeoutMs}:e.kind==="import-definitions"&&Se(e.request)?{kind:"import-definitions",identityKey:e.identityKey,...e.workerEnvironment===void 0?{}:{workerEnvironment:e.workerEnvironment},request:e.request,timeoutMs:e.timeoutMs}:null}function be(e){return!D(e)||!h(e.projectRoot)||!h(e.rustAnalyzerBinary)||!oe(e.definitions)?!1:O(e.referenceDefinitions)&&O(e.calleeDefinitions)&&O(e.signatureDefinitions)&&b(e.requestTimeoutMs)&&b(e.readinessDeadlineMs)&&b(e.referenceRetryTimeoutMs)&&b(e.diagnosticsTimeoutMs)&&b(e.settleDelayMs)&&ie(e.concurrency)&&L(e.includeReferences)&&L(e.includeCallees)&&L(e.includeSignatures)}function Se(e){return!D(e)||!h(e.projectRoot)||!h(e.rustAnalyzerBinary)||!h(e.file)||!Array.isArray(e.positions)||!e.positions.every(n=>D(n)&&h(n.id)&&h(n.file)&&I(n.line)&&I(n.column))?!1:b(e.requestTimeoutMs)&&b(e.readinessDeadlineMs)&&b(e.diagnosticsTimeoutMs)&&b(e.settleDelayMs)&&ie(e.concurrency)}function oe(e){return Array.isArray(e)&&e.every(Ie)}function O(e){return e===void 0||oe(e)}function Ie(e){return D(e)&&I(e.symbolId)&&I(e.documentId)&&I(e.startLine)&&se(e.startChar)&&I(e.endLine)&&se(e.endChar)&&typeof e.symbol=="string"&&typeof e.relativePath=="string"&&typeof e.leaf=="string"&&(e.parentTypeName===null||typeof e.parentTypeName=="string")&&typeof e.isFunctionLike=="boolean"&&typeof e.isTypeLike=="boolean"&&(e.kind===null||Number.isSafeInteger(e.kind))&&(e.documentation===null||typeof e.documentation=="string")&&(e.enclosingSymbol===null||typeof e.enclosingSymbol=="string")}function w(e){return{ok:!1,code:"malformed-request",error:e}}function re(e){return/^[a-f0-9]{64}$/.test(e)}function h(e){return typeof e=="string"&&e.length>0}function ie(e){return e===void 0||P(e)}function se(e){return e===void 0||I(e)}function b(e){return e===void 0||z(e)}function L(e){return e===void 0||typeof e=="boolean"}var x=class{constructor(n,t=ke){this.createRequester=n;this.applyEnvironment=t}createRequester;applyEnvironment;requester=null;identityKey=null;semanticResponseCache=null;handle(n){this.applyEnvironment(n.workerEnvironment??{});let t;if(this.requester?this.identityKey!==n.identityKey?(this.semanticResponseCache=null,this.requester.shutdown(),this.requester=this.createRequester(),this.identityKey=n.identityKey,t="invalidated"):t="reused":(this.requester=this.createRequester(),this.identityKey=n.identityKey,t="created"),n.kind==="semantic"){let i=Ee(n.request),o=t==="reused"&&i!==null&&this.semanticResponseCache?.identityKey===n.identityKey&&this.semanticResponseCache.requestKey===i?this.semanticResponseCache.response:null;if(o)return ae(!0,n.request.definitions.length),{session:t,response:o};let c=this.requester.requestSemantic(n.request,n.timeoutMs);return i!==null&&we(c)&&(this.semanticResponseCache={identityKey:n.identityKey,requestKey:i,response:c}),ae(!1,n.request.definitions.length),{session:t,response:c}}return{session:t,response:this.requester.requestImportDefinitions(n.request,n.timeoutMs)}}shutdown(){this.requester?.shutdown(),this.requester=null,this.identityKey=null,this.semanticResponseCache=null}};function Ee(e){if(e.includeReferences===!1||e.includeCallees!==!0||e.includeSignatures===!0||(e.referenceDefinitions?.length??0)===0||(e.calleeDefinitions?.length??0)===0)return null;let{readinessDeadlineMs:n,...t}=e;return qe(A(t))}function we(e){return e.available&&Array.isArray(e.callees)&&(e.incompleteReferenceSymbolIds?.length??0)===0}function ae(e,n){Y()&&H({type:"span",name:"rust.semantic.durable-session.response-cache",durationMs:0,ok:!0,hit:e,definitions:n})}function ke(e){for(let n of Object.keys(process.env))_e(n)&&delete process.env[n];for(let[n,t]of Object.entries(e))t!==null&&(process.env[n]=t)}function Ae(e){return e==="HOME"||e==="PATH"||e.startsWith("CARGO_")||e.startsWith("RA_")||e.startsWith("RUST")}function _e(e){return Ae(e)||e.startsWith("SCIP_RUST_")||e==="SCIP_QUERY_PROFILE"||e==="SCIP_QUERY_PROFILE_CACHE_STATE"||e==="SCIP_QUERY_PROFILE_COMMAND"||e==="SCIP_QUERY_PROFILE_OUT"||e==="SCIP_QUERY_PROFILE_RUN_ID"||e==="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY"||e==="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY_KIND"||e==="SCIP_QUERY_PROFILE_MIN_MS"}var En={now:Date.now,monotonicNow:g,randomId:De,isProcessAlive:k,readProcessIdentity:E,spawnServer(e,n,t){if(!he(e))throw new Error(`Durable Rust semantic session helper was not found at ${e}. Run npm run build first.`);ge(process.execPath,[e,n,t],{detached:!0,stdio:"ignore"}).unref()},sleep(e){let n=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(n,0,0,e)}};function qe(e){return Me("sha256").update(e).digest("hex")}import{existsSync as xe,mkdtempSync as ue,rmSync as F}from"fs";import{tmpdir as le}from"os";import{join as K}from"path";import{fileURLToPath as de,pathToFileURL as Te}from"url";import{SHARE_ENV as Ce,Worker as ve}from"worker_threads";function ce(e={}){let n=null,t=null,i=1,o=!1,c=()=>{t&&(F(t,{recursive:!0,force:!0}),t=null)},S=()=>{let r=n;n=null,r&&r.terminate(),c()},M=()=>{if(n)return n;let r=e.semanticWorkerPath?Te(e.semanticWorkerPath):Be();if(!xe(de(r)))throw new Error(`Rust semantic session worker was not found at ${de(r)}. Run npm run build before using built semantic Rust queries.`);return t=ue(K(le(),"scip-query-rust-session-")),n=new ve(r,e.shareEnvironment?{env:Ce}:void 0),n.unref(),n},y=()=>{let r=t??ue(K(le(),"scip-query-rust-session-"));return t=r,K(r,`${i++}.json`)};return{requestSemantic(r,s){if(o)throw new Error("Rust semantic session was already disposed.");let f=M(),l=y(),u=new SharedArrayBuffer(4),R=new Int32Array(u);if(f.postMessage({kind:"semantic",request:r,responsePath:l,sharedBuffer:u}),Atomics.wait(R,0,0,s)==="timed-out")throw S(),new Error(`Rust semantic session worker timed out after ${(s/1e3).toFixed(0)}s`);try{let a=Pe(v(l,{maxBytes:C,inputKind:"Rust semantic worker response"}));if(!a.ok)throw new Error(a.error);return a.response}finally{F(l,{force:!0})}},requestImportDefinitions(r,s){if(o)throw new Error("Rust semantic session was already disposed.");let f=M(),l=y(),u=new SharedArrayBuffer(4),R=new Int32Array(u);if(f.postMessage({kind:"import-definitions",request:r,responsePath:l,sharedBuffer:u}),Atomics.wait(R,0,0,s)==="timed-out")throw S(),new Error(`Rust semantic import-definition session worker timed out after ${(s/1e3).toFixed(0)}s`);try{let a=Ne(v(l,{maxBytes:C,inputKind:"Rust import-definition worker response"}));if(!a.ok)throw new Error(a.error);return a.response}finally{F(l,{force:!0})}},shutdown(){if(o)return;if(o=!0,!n){c();return}let r=y(),s=new SharedArrayBuffer(4),f=new Int32Array(s);n.postMessage({kind:"shutdown",responsePath:r,sharedBuffer:s}),Atomics.wait(f,0,0,5e3),S()}}}function Pe(e){let n=JSON.parse(e);if(!n||typeof n!="object")return{ok:!1,error:"Rust semantic session worker wrote a non-object response."};let t=n;return t.ok===!0&&"response"in t?{ok:!0,response:t.response}:{ok:!1,error:typeof n.error=="string"?n.error:"Rust semantic session worker failed."}}function Ne(e){let n=JSON.parse(e);if(!n||typeof n!="object")return{ok:!1,error:"Rust semantic session worker wrote a non-object response."};let t=n;return t.ok===!0&&"response"in t?{ok:!0,response:t.response}:{ok:!1,error:typeof n.error=="string"?n.error:"Rust semantic session worker failed."}}function Be(){return new URL("./rust-semantic-session-worker.js",import.meta.url)}var We=10*6e4,Fe=10,Ke=1e3;function je(e,n,t={}){let i=N(e);B(i);let o=t.now??(t.nowMs===void 0?Date.now:()=>t.nowMs),c=o(),S=q(e),M=X(i,{ownerId:t.ownerId??Xe,nowMs:c,limits:t.limits,owner:Ge,liveness:Ze}),y=0;for(let r of M){let s=null,f,l="handler-error";try{let u=G(r,t.limits),R;try{R=JSON.parse(u)}catch{throw l="malformed-request",new Error("Durable Rust semantic helper received malformed request JSON.")}let d=W(R,{claimRequestId:r.requestId,sessionIdentity:S,nowMs:o()});if(!d.ok)throw l=d.code,f=d.responseIdentity,new Error(d.error);s=d.value,f={id:s.id,sessionIdentity:s.sessionIdentity,deadlineAtMs:s.deadlineAtMs};let a=Ve(s.request,t.monotonicNowMs??g());t.beforeRequest?.(a);let Re=n.handle(a),j=o();if(s.deadlineAtMs<j)throw l="expired-request",new Error("Durable Rust semantic request expired while the helper was processing it.");Z(i,r,{ok:!0,protocolVersion:m,id:s.id,sessionIdentity:s.sessionIdentity,deadlineAtMs:s.deadlineAtMs,...Re},{nowMs:j,limits:t.limits})}catch(u){let R=o(),d=f??(s?{id:s.id,sessionIdentity:s.sessionIdentity,deadlineAtMs:s.deadlineAtMs}:void 0),a=u instanceof Error?u.message:String(u);ee(i,r,{ok:!1,protocolVersion:m,id:d?.id??r.requestId,...d?{sessionIdentity:d.sessionIdentity,deadlineAtMs:d.deadlineAtMs}:{},errorCode:l,error:a},a,{nowMs:R,limits:t.limits})}y+=1}return y}function Ve(e,n){let t=n+Math.max(1,e.timeoutMs-1e3);return{...e,request:{...e.request,readinessDeadlineMs:t}}}async function ze(e,n){let t=N(e);B(t);let i=T(e,"server.lock"),o=He(i);if(!o)return;let c=new x(()=>ce({semanticWorkerPath:n,shareEnvironment:!0})),S=!1,M=g(),y=Number.NEGATIVE_INFINITY,r,s=E(p.pid),f=q(e),l=()=>{S=!0};p.once("SIGINT",l),p.once("SIGTERM",l);let u=(R=!1)=>{let d=Date.now(),a=g();!R&&a-y<Ke||(y=a,Q(T(e,"server.json"),{protocolVersion:m,sessionIdentity:f,pid:p.pid,...s?{processIdentity:s}:{},heartbeatAtMs:d,...r===void 0?{}:{busyUntilMs:r},mailbox:ne(t)}))};try{u(!0);let R=$e();for(;!S&&g()-M<R;)je(e,c,{beforeRequest(a){r=Date.now()+a.timeoutMs+5e3,u(!0)}})>0?(M=g(),r=void 0,u(!0)):u(),await Qe(Fe)}finally{c.shutdown(),Oe(T(e,"server.json"),{force:!0}),o.release()}}var Ye=e=>{let n=Number(e);return Number.isInteger(n)&&n>0?{pid:n}:null};function He(e){let n=$(e,{kind:"rust-durable-session-server",parseLegacy:Ye});return n.kind==="acquired"?n.lock:null}function $e(){let e=Number(p.env.SCIP_RUST_SEMANTIC_DURABLE_IDLE_MS);return Number.isInteger(e)&&e>=0?e:We}function Qe(e){return new Promise(n=>setTimeout(n,e))}var Je=p.argv[1]?Le(T(p.argv[1])).href:null;if(Je===import.meta.url){let e=p.argv[2],n=p.argv[3];!e||!n?(console.error("durable-rust-session: expected <session-dir> <semantic-worker-path>"),p.exitCode=1):await ze(e,n)}var Xe=`rust-semantic-${p.pid}-${Ue()}`,pe=E(p.pid),Ge={pid:p.pid,...pe?{processIdentity:pe}:{}},Ze={isProcessAlive:k,readProcessIdentity:E};export{He as acquireDurableRustSessionServerLock,je as processDurableRustSessionRequests};
|
|
2
2
|
//# sourceMappingURL=rust-semantic-session-server.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{A as ue,B as de,C as b,D as S,a as q,b as ee,c as A,d as G,e as N,f as F,g as B,h as E,i as ne,j as te,k as ie,l as se,n as j,o as H,p as U,q as W,r as re,u as ae,v as oe,w as le,x as ce,y as k}from"./chunk-4RI4BJGT.js";import{a as O,f as d,g as D}from"./chunk-HGFDYOVB.js";import"./chunk-APMMR5Y2.js";import _ from"process";import{existsSync as pe,readFileSync as we,writeFileSync as Pe}from"fs";import{isAbsolute as De,resolve as K}from"path";import{performance as L}from"perf_hooks";import{parentPort as ke}from"worker_threads";var be="SCIP_RUST_SEMANTIC_REFERENCE_TASK_PROFILE_MS",Se="SCIP_RUST_SEMANTIC_CALLEE_TASK_PROFILE_MS",P=new Map,fe=Promise.resolve();ke?.on("message",e=>{fe=fe.then(()=>Te(e)).catch(()=>{})});async function Te(e){if(e.kind==="shutdown"){await We(),g(e.responsePath,{ok:!0},e.sharedBuffer);return}if(e.kind==="import-definitions"){try{let t=await ze(e.request);g(e.responsePath,{ok:!0,response:t},e.sharedBuffer)}catch(t){let i=B(t);if(i){g(e.responsePath,i,e.sharedBuffer);return}let n={available:!1,reason:t instanceof Error?t.message:String(t),sourcePaths:e.request.positions.map(r=>[r.id,null])};g(e.responsePath,{ok:!0,response:n},e.sharedBuffer)}return}try{let t=await ve(e.request);g(e.responsePath,{ok:!0,response:t},e.sharedBuffer)}catch(t){let i=B(t);if(i){g(e.responsePath,i,e.sharedBuffer);return}let n=ye(e.request,t instanceof Error?t.message:String(t));g(e.responsePath,{ok:!0,response:n},e.sharedBuffer)}}async function ze(e){let t={timeoutMs:e.requestTimeoutMs,deadlineMs:e.readinessDeadlineMs},i=await d("rust.semantic.worker.session",()=>Re(e.projectRoot,e.rustAnalyzerBinary,[e.file],{requestTimeoutMs:e.requestTimeoutMs,readinessDeadlineMs:e.readinessDeadlineMs}),()=>({kind:"import-definitions",files:1,positions:e.positions.length}));if(!i.capabilities.definitionProvider)return{available:!1,reason:"rust-analyzer initialized without textDocument/definition support.",sourcePaths:e.positions.map(o=>[o.id,null])};let n=0;await F(()=>d("rust.semantic.worker.open-source-documents",async()=>{n=await Ae(i,e.projectRoot,[e.file],{diagnosticsTimeoutMs:e.diagnosticsTimeoutMs,settleDelayMs:e.settleDelayMs,readinessDeadlineMs:e.readinessDeadlineMs})},()=>({files:1,openedDocuments:n,positions:e.positions.length})),()=>ge(P,i,e.readinessDeadlineMs));let r=0;return{available:!0,sourcePaths:await d("rust.semantic.worker.import-definitions",()=>S(e.positions,e.concurrency??8,async o=>{let c=await i.client.definition({textDocument:{uri:E(e.projectRoot,o.file)},position:{line:o.line,character:o.column}},t),f=Fe(e.projectRoot,c);return f&&(r+=1),[o.id,f]}),()=>({positions:e.positions.length,resolvedPositions:r,concurrency:e.concurrency??8}))}}async function ve(e){let t={timeoutMs:e.requestTimeoutMs,deadlineMs:e.readinessDeadlineMs},i=e.includeReferences!==!1,n=e.includeCallees===!0,r=e.includeSignatures===!0,a=j(e),o=H(e),c=U(e),f=W(e),l=await d("rust.semantic.worker.session",()=>Ie(e),()=>({kind:"semantic",definitions:f.length,referenceDefinitions:a.length,calleeDefinitions:o.length,signatureDefinitions:c.length,references:i,callees:n,signatures:r})),p=Ee(l.capabilities,{references:i,callees:n,signatures:r});if(p)return ye(e,p);let u=0;await F(()=>d("rust.semantic.worker.open-definition-documents",async()=>{u=await Ce(l,e)},()=>({definitions:f.length,openedDocuments:u})),()=>ge(P,l,e.readinessDeadlineMs));let m=0,M=0,y=O(),J=y?new Map:null,T=y?me(_.env[be]):null,V=()=>i?d("rust.semantic.worker.references",()=>S(a,e.concurrency??8,async s=>{let w=y?L.now():0,h=await ue(l.client,te(e.projectRoot,s,!1),{requestTimeoutMs:e.requestTimeoutMs,retryTimeoutMs:e.referenceRetryTimeoutMs,deadlineMs:e.readinessDeadlineMs}),R=se(ie(e.projectRoot,h.locations)),C=y?Math.round(L.now()-w):0;return _e(J,s.relativePath,{durationMs:C,references:R.length,hasReferences:R.length>0,slow:T!==null&&C>=T}),T!==null&&C>=T&&D({type:"span",name:"rust.semantic.worker.reference-task",durationMs:C,ok:!0,symbolId:s.symbolId,relativePath:s.relativePath,leaf:s.leaf,kind:s.kind,startLine:s.startLine,endLine:s.endLine,references:R.length,complete:h.complete}),R.length>0&&(M+=1),m+=R.length,{symbolId:s.symbolId,references:R,complete:h.complete}}),()=>({definitions:a.length,concurrency:e.concurrency??8,definitionsWithReferences:M,references:m})):Promise.resolve(a.map(s=>({symbolId:s.symbolId,references:[],complete:!0}))),Q=0,X=0,z=O(),Y=z?new Map:null,v=z?me(_.env[Se]):null,Z=()=>n?d("rust.semantic.worker.callees",()=>S(o,e.concurrency??8,async s=>{let w=z?L.now():0,h=await de(l.client,e.projectRoot,s,t),R=z?Math.round(L.now()-w):0;return Ge(Y,s.relativePath,{durationMs:R,callees:h.length,hasCallees:h.length>0,slow:v!==null&&R>=v}),v!==null&&R>=v&&D({type:"span",name:"rust.semantic.worker.callee-task",durationMs:R,ok:!0,symbolId:s.symbolId,relativePath:s.relativePath,leaf:s.leaf,kind:s.kind,startLine:s.startLine,endLine:s.endLine,callees:h.length}),h.length>0&&(X+=1),Q+=h.length,{symbolId:s.symbolId,callees:h}}),()=>({definitions:o.length,concurrency:e.concurrency??8,definitionsWithCallees:X,callees:Q})):Promise.resolve([]),I,x;i&&n&&a.length>0&&o.length>0&&je()?[I,x]=await Promise.all([V(),Z()]):(I=await V(),x=await Z()),xe(J),Ne(Y);let $=0,Me=r?await d("rust.semantic.worker.signatures",()=>S(c,e.concurrency??8,async s=>{let w=await re(l.client,e.projectRoot,s,t);return w&&($+=1),{symbolId:s.symbolId,signature:w}}),()=>({definitions:c.length,concurrency:e.concurrency??8,signaturesFound:$})):[];return{available:!0,references:I.filter(s=>s.complete).map(s=>[s.symbolId,s.references]),incompleteReferenceSymbolIds:I.filter(s=>!s.complete).map(s=>s.symbolId),...n?{callees:x.map(s=>[s.symbolId,s.callees])}:{},...r?{signatures:Me.map(s=>[s.symbolId,s.signature])}:{}}}async function Ie(e){return Re(e.projectRoot,e.rustAnalyzerBinary,W(e).map(t=>t.relativePath),{requestTimeoutMs:e.requestTimeoutMs,readinessDeadlineMs:e.readinessDeadlineMs})}async function Re(e,t,i,n){let r=le(e,i.map(M=>({relativePath:M}))),a=oe(e,r),o=Le(t,a,r),c=P.get(o);if(c)return c;let f=ae(r),l=new q(ee(t,a),{requestTimeoutMs:n.requestTimeoutMs,configuration:f}),p=n.readinessDeadlineMs===void 0?null:{afterGeneration:l.serverStatusGeneration(),deadlineMs:n.readinessDeadlineMs},u=await F(()=>d("rust.semantic.worker.initialize",()=>l.initialize({processId:_.pid,rootUri:E(a,"."),capabilities:{textDocument:{references:{dynamicRegistration:!1},definition:{dynamicRegistration:!1},callHierarchy:{dynamicRegistration:!1},hover:{dynamicRegistration:!1}}},initializationOptions:f},{timeoutMs:n.requestTimeoutMs,deadlineMs:n.readinessDeadlineMs}),()=>({linkedProjects:r.length,relativePaths:i.length})),()=>l.shutdown({deadlineMs:n.readinessDeadlineMs}).catch(()=>{})),m={key:o,client:l,capabilities:u.capabilities,openedPaths:new Set,initializationReadiness:p};return P.set(o,m),m}async function Ce(e,t){let i=W(t).filter(l=>e.openedPaths.has(l.relativePath)?!1:pe(K(t.projectRoot,l.relativePath)));if(i.length===0)return await he(e),0;let n=e.initializationReadiness,r=t.readinessDeadlineMs===void 0?null:{statusSnapshot:n?null:e.client.serverStatusSnapshot(),initializationGeneration:n?.afterGeneration,deadlineMs:t.readinessDeadlineMs},a=ce(e.client,t.projectRoot,i);for(let l of i)e.openedPaths.add(l.relativePath);let o=t.diagnosticsTimeoutMs??1e4,c=o;await d("rust.semantic.worker.diagnostics",()=>r?N(l=>(c=l,k(e.client,a,l)),o,r.deadlineMs):k(e.client,a,o),()=>({openedDocuments:a.length,timeoutMs:c}));let f=t.settleDelayMs??5e3;if(!r)await d("rust.semantic.worker.settle",()=>b(f),()=>({openedDocuments:a.length,settleDelayMs:f}));else{let l;await d("rust.semantic.worker.readiness",async()=>{let p=m=>d("rust.semantic.worker.settle",()=>b(m),()=>({openedDocuments:a.length,settleDelayMs:m})),u=r.initializationGeneration===void 0?await G(e.client,r.statusSnapshot,a.length,r.deadlineMs,f,Date.now,p):await A(e.client,r.initializationGeneration,a.length,r.deadlineMs,f,Date.now,p);r.initializationGeneration!==void 0&&(e.initializationReadiness=null),l=u?.health},()=>({phase:r.initializationGeneration===void 0?"didOpen":"initialize+didOpen",openedDocuments:a.length,health:l}))}return a.length}async function Ae(e,t,i,n){let r=i.filter(u=>e.openedPaths.has(u)?!1:pe(K(t,u)));if(r.length===0)return await he(e),0;let a=e.initializationReadiness,o=n.readinessDeadlineMs===void 0?null:{statusSnapshot:a?null:e.client.serverStatusSnapshot(),initializationGeneration:a?.afterGeneration,deadlineMs:n.readinessDeadlineMs},c=[];for(let u of r){let m=E(t,u);e.client.didOpenTextDocument({uri:m,languageId:"rust",version:1,text:we(K(t,u),"utf8")}),e.openedPaths.add(u),c.push(m)}let f=n.diagnosticsTimeoutMs??1e4,l=f;await d("rust.semantic.worker.diagnostics",()=>o?N(u=>(l=u,k(e.client,c,u)),f,o.deadlineMs):k(e.client,c,f),()=>({openedDocuments:c.length,timeoutMs:l}));let p=n.settleDelayMs??5e3;if(!o)await d("rust.semantic.worker.settle",()=>b(p),()=>({openedDocuments:c.length,settleDelayMs:p}));else{let u;await d("rust.semantic.worker.readiness",async()=>{let m=y=>d("rust.semantic.worker.settle",()=>b(y),()=>({openedDocuments:c.length,settleDelayMs:y})),M=o.initializationGeneration===void 0?await G(e.client,o.statusSnapshot,c.length,o.deadlineMs,p,Date.now,m):await A(e.client,o.initializationGeneration,c.length,o.deadlineMs,p,Date.now,m);o.initializationGeneration!==void 0&&(e.initializationReadiness=null),u=M?.health},()=>({phase:o.initializationGeneration===void 0?"didOpen":"initialize+didOpen",openedDocuments:c.length,health:u}))}return c.length}async function he(e){let t=e.initializationReadiness;if(!t)return;let i;await d("rust.semantic.worker.readiness",async()=>{i=(await A(e.client,t.afterGeneration,0,t.deadlineMs,0)).health,e.initializationReadiness=null},()=>({phase:"initialize",openedDocuments:0,health:i}))}function Fe(e,t){for(let i of t){let n=ne(e,i.uri);if(!(!n||n===".."||n.startsWith("../")||De(n)))return n}return null}function Ee(e,t){return t.references&&!e.referencesProvider?"rust-analyzer initialized without textDocument/references support.":t.callees&&!e.callHierarchyProvider?"rust-analyzer initialized without call hierarchy support.":t.signatures&&!e.hoverProvider?"rust-analyzer initialized without hover support.":null}function ye(e,t){let i=j(e),n=H(e),r=U(e);return{available:!1,reason:t,references:i.map(a=>[a.symbolId,[]]),...e.includeCallees?{callees:n.map(a=>[a.symbolId,[]])}:{},...e.includeSignatures?{signatures:r.map(a=>[a.symbolId,null])}:{}}}async function We(){let e=[...P.values()];P.clear(),await Promise.all(e.map(t=>t.client.shutdown().catch(()=>{})))}async function ge(e,t,i){e.get(t.key)===t&&e.delete(t.key),await t.client.shutdown({deadlineMs:i}).catch(()=>{})}function Le(e,t,i){return JSON.stringify({binary:e,sessionRoot:t,linkedProjects:i})}function _e(e,t,i){if(!e)return;let n=Oe(e,t);n.definitions+=1,i.hasReferences&&(n.definitionsWithReferences+=1),n.references+=i.references,n.durationMs+=i.durationMs,n.maxDurationMs=Math.max(n.maxDurationMs,i.durationMs),i.slow&&(n.slowTasks+=1)}function xe(e){if(!e)return;let t=[...e.entries()].sort(([i,n],[r,a])=>a.durationMs-n.durationMs||i.localeCompare(r));for(let[i,n]of t)D({type:"span",name:"rust.semantic.worker.references.by-file",durationMs:n.durationMs,ok:!0,relativePath:i,definitions:n.definitions,definitionsWithReferences:n.definitionsWithReferences,references:n.references,maxDurationMs:n.maxDurationMs,slowTasks:n.slowTasks,aggregate:"sum-task-duration"})}function Oe(e,t){let i=e.get(t);if(i)return i;let n={definitions:0,definitionsWithReferences:0,references:0,durationMs:0,maxDurationMs:0,slowTasks:0};return e.set(t,n),n}function Ge(e,t,i){if(!e)return;let n=Be(e,t);n.definitions+=1,i.hasCallees&&(n.definitionsWithCallees+=1),n.callees+=i.callees,n.durationMs+=i.durationMs,n.maxDurationMs=Math.max(n.maxDurationMs,i.durationMs),i.slow&&(n.slowTasks+=1)}function Ne(e){if(!e)return;let t=[...e.entries()].sort(([i,n],[r,a])=>a.durationMs-n.durationMs||i.localeCompare(r));for(let[i,n]of t)D({type:"span",name:"rust.semantic.worker.callees.by-file",durationMs:n.durationMs,ok:!0,relativePath:i,definitions:n.definitions,definitionsWithCallees:n.definitionsWithCallees,callees:n.callees,maxDurationMs:n.maxDurationMs,slowTasks:n.slowTasks,aggregate:"sum-task-duration"})}function Be(e,t){let i=e.get(t);if(i)return i;let n={definitions:0,definitionsWithCallees:0,callees:0,durationMs:0,maxDurationMs:0,slowTasks:0};return e.set(t,n),n}function me(e){if(e===void 0||e==="")return null;let t=Number(e);return Number.isInteger(t)&&t>=0?t:null}function je(){let e=_.env.SCIP_RUST_SEMANTIC_PARALLEL_OPERATIONS;return e!=="0"&&e!=="false"}function g(e,t,i){Pe(e,JSON.stringify(t));let n=new Int32Array(i);Atomics.store(n,0,1),Atomics.notify(n,0)}export{ge as discardRustAnalyzerSession};
|
|
1
|
+
import{A as de,B as fe,C as b,D as S,a as ee,b as ne,c as A,d as j,e as G,f as F,g as N,h as E,i as te,j as ie,k as se,l as re,n as B,o as H,p as U,q as W,r as ae,u as oe,v as le,w as ce,x as ue,y as k}from"./chunk-A2TNXAXO.js";import{l as $,m as q}from"./chunk-C5Q44Q5D.js";import{a as O,f as u,g as D}from"./chunk-HGFDYOVB.js";import"./chunk-APMMR5Y2.js";import"./chunk-46XGSFNI.js";import _ from"process";import{existsSync as we,writeFileSync as Pe}from"fs";import{isAbsolute as De,resolve as ke}from"path";import{performance as L}from"perf_hooks";import{parentPort as be}from"worker_threads";var Se="SCIP_RUST_SEMANTIC_REFERENCE_TASK_PROFILE_MS",Te="SCIP_RUST_SEMANTIC_CALLEE_TASK_PROFILE_MS",P=new Map,me=Promise.resolve();be?.on("message",e=>{me=me.then(()=>ze(e)).catch(()=>{})});async function ze(e){if(e.kind==="shutdown"){await Le(),g(e.responsePath,{ok:!0},e.sharedBuffer);return}if(e.kind==="import-definitions"){try{let t=await ve(e.request);g(e.responsePath,{ok:!0,response:t},e.sharedBuffer)}catch(t){let i=N(t);if(i){g(e.responsePath,i,e.sharedBuffer);return}let n={available:!1,reason:t instanceof Error?t.message:String(t),sourcePaths:e.request.positions.map(r=>[r.id,null])};g(e.responsePath,{ok:!0,response:n},e.sharedBuffer)}return}try{let t=await Ie(e.request);g(e.responsePath,{ok:!0,response:t},e.sharedBuffer)}catch(t){let i=N(t);if(i){g(e.responsePath,i,e.sharedBuffer);return}let n=ye(e.request,t instanceof Error?t.message:String(t));g(e.responsePath,{ok:!0,response:n},e.sharedBuffer)}}async function ve(e){let t={timeoutMs:e.requestTimeoutMs,deadlineMs:e.readinessDeadlineMs},i=await u("rust.semantic.worker.session",()=>Re(e.projectRoot,e.rustAnalyzerBinary,[e.file],{requestTimeoutMs:e.requestTimeoutMs,readinessDeadlineMs:e.readinessDeadlineMs}),()=>({kind:"import-definitions",files:1,positions:e.positions.length}));if(!i.capabilities.definitionProvider)return{available:!1,reason:"rust-analyzer initialized without textDocument/definition support.",sourcePaths:e.positions.map(o=>[o.id,null])};let n=0;await F(()=>u("rust.semantic.worker.open-source-documents",async()=>{n=await Fe(i,e.projectRoot,[e.file],{diagnosticsTimeoutMs:e.diagnosticsTimeoutMs,settleDelayMs:e.settleDelayMs,readinessDeadlineMs:e.readinessDeadlineMs})},()=>({files:1,openedDocuments:n,positions:e.positions.length})),()=>ge(P,i,e.readinessDeadlineMs));let r=0;return{available:!0,sourcePaths:await u("rust.semantic.worker.import-definitions",()=>S(e.positions,e.concurrency??8,async o=>{let c=await i.client.definition({textDocument:{uri:E(e.projectRoot,o.file)},position:{line:o.line,character:o.column}},t),f=Ee(e.projectRoot,c);return f&&(r+=1),[o.id,f]}),()=>({positions:e.positions.length,resolvedPositions:r,concurrency:e.concurrency??8}))}}async function Ie(e){let t={timeoutMs:e.requestTimeoutMs,deadlineMs:e.readinessDeadlineMs},i=e.includeReferences!==!1,n=e.includeCallees===!0,r=e.includeSignatures===!0,a=B(e),o=H(e),c=U(e),f=W(e),l=await u("rust.semantic.worker.session",()=>Ce(e),()=>({kind:"semantic",definitions:f.length,referenceDefinitions:a.length,calleeDefinitions:o.length,signatureDefinitions:c.length,references:i,callees:n,signatures:r})),p=We(l.capabilities,{references:i,callees:n,signatures:r});if(p)return ye(e,p);let d=0;await F(()=>u("rust.semantic.worker.open-definition-documents",async()=>{d=await Ae(l,e)},()=>({definitions:f.length,openedDocuments:d})),()=>ge(P,l,e.readinessDeadlineMs));let m=0,M=0,y=O(),K=y?new Map:null,T=y?pe(_.env[Se]):null,J=()=>i?u("rust.semantic.worker.references",()=>S(a,e.concurrency??8,async s=>{let w=y?L.now():0,h=await de(l.client,ie(e.projectRoot,s,!1),{requestTimeoutMs:e.requestTimeoutMs,retryTimeoutMs:e.referenceRetryTimeoutMs,deadlineMs:e.readinessDeadlineMs}),R=re(se(e.projectRoot,h.locations)),C=y?Math.round(L.now()-w):0;return xe(K,s.relativePath,{durationMs:C,references:R.length,hasReferences:R.length>0,slow:T!==null&&C>=T}),T!==null&&C>=T&&D({type:"span",name:"rust.semantic.worker.reference-task",durationMs:C,ok:!0,symbolId:s.symbolId,relativePath:s.relativePath,leaf:s.leaf,kind:s.kind,startLine:s.startLine,endLine:s.endLine,references:R.length,complete:h.complete}),R.length>0&&(M+=1),m+=R.length,{symbolId:s.symbolId,references:R,complete:h.complete}}),()=>({definitions:a.length,concurrency:e.concurrency??8,definitionsWithReferences:M,references:m})):Promise.resolve(a.map(s=>({symbolId:s.symbolId,references:[],complete:!0}))),V=0,Q=0,z=O(),X=z?new Map:null,v=z?pe(_.env[Te]):null,Y=()=>n?u("rust.semantic.worker.callees",()=>S(o,e.concurrency??8,async s=>{let w=z?L.now():0,h=await fe(l.client,e.projectRoot,s,t),R=z?Math.round(L.now()-w):0;return Ge(X,s.relativePath,{durationMs:R,callees:h.length,hasCallees:h.length>0,slow:v!==null&&R>=v}),v!==null&&R>=v&&D({type:"span",name:"rust.semantic.worker.callee-task",durationMs:R,ok:!0,symbolId:s.symbolId,relativePath:s.relativePath,leaf:s.leaf,kind:s.kind,startLine:s.startLine,endLine:s.endLine,callees:h.length}),h.length>0&&(Q+=1),V+=h.length,{symbolId:s.symbolId,callees:h}}),()=>({definitions:o.length,concurrency:e.concurrency??8,definitionsWithCallees:Q,callees:V})):Promise.resolve([]),I,x;i&&n&&a.length>0&&o.length>0&&He()?[I,x]=await Promise.all([J(),Y()]):(I=await J(),x=await Y()),Oe(K),Ne(X);let Z=0,Me=r?await u("rust.semantic.worker.signatures",()=>S(c,e.concurrency??8,async s=>{let w=await ae(l.client,e.projectRoot,s,t);return w&&(Z+=1),{symbolId:s.symbolId,signature:w}}),()=>({definitions:c.length,concurrency:e.concurrency??8,signaturesFound:Z})):[];return{available:!0,references:I.filter(s=>s.complete).map(s=>[s.symbolId,s.references]),incompleteReferenceSymbolIds:I.filter(s=>!s.complete).map(s=>s.symbolId),...n?{callees:x.map(s=>[s.symbolId,s.callees])}:{},...r?{signatures:Me.map(s=>[s.symbolId,s.signature])}:{}}}async function Ce(e){return Re(e.projectRoot,e.rustAnalyzerBinary,W(e).map(t=>t.relativePath),{requestTimeoutMs:e.requestTimeoutMs,readinessDeadlineMs:e.readinessDeadlineMs})}async function Re(e,t,i,n){let r=ce(e,i.map(M=>({relativePath:M}))),a=le(e,r),o=_e(t,a,r),c=P.get(o);if(c)return c;let f=oe(r),l=new ee(ne(t,a),{requestTimeoutMs:n.requestTimeoutMs,configuration:f}),p=n.readinessDeadlineMs===void 0?null:{afterGeneration:l.serverStatusGeneration(),deadlineMs:n.readinessDeadlineMs},d=await F(()=>u("rust.semantic.worker.initialize",()=>l.initialize({processId:_.pid,rootUri:E(a,"."),capabilities:{textDocument:{references:{dynamicRegistration:!1},definition:{dynamicRegistration:!1},callHierarchy:{dynamicRegistration:!1},hover:{dynamicRegistration:!1}}},initializationOptions:f},{timeoutMs:n.requestTimeoutMs,deadlineMs:n.readinessDeadlineMs}),()=>({linkedProjects:r.length,relativePaths:i.length})),()=>l.shutdown({deadlineMs:n.readinessDeadlineMs}).catch(()=>{})),m={key:o,client:l,capabilities:d.capabilities,openedPaths:new Set,initializationReadiness:p};return P.set(o,m),m}async function Ae(e,t){let i=W(t).filter(l=>e.openedPaths.has(l.relativePath)?!1:we(ke(t.projectRoot,l.relativePath)));if(i.length===0)return await he(e),0;let n=e.initializationReadiness,r=t.readinessDeadlineMs===void 0?null:{statusSnapshot:n?null:e.client.serverStatusSnapshot(),initializationGeneration:n?.afterGeneration,deadlineMs:t.readinessDeadlineMs},a=ue(e.client,t.projectRoot,i);for(let l of i)e.openedPaths.add(l.relativePath);let o=t.diagnosticsTimeoutMs??1e4,c=o;await u("rust.semantic.worker.diagnostics",()=>r?G(l=>(c=l,k(e.client,a,l)),o,r.deadlineMs):k(e.client,a,o),()=>({openedDocuments:a.length,timeoutMs:c}));let f=t.settleDelayMs??5e3;if(!r)await u("rust.semantic.worker.settle",()=>b(f),()=>({openedDocuments:a.length,settleDelayMs:f}));else{let l;await u("rust.semantic.worker.readiness",async()=>{let p=m=>u("rust.semantic.worker.settle",()=>b(m),()=>({openedDocuments:a.length,settleDelayMs:m})),d=r.initializationGeneration===void 0?await j(e.client,r.statusSnapshot,a.length,r.deadlineMs,f,Date.now,p):await A(e.client,r.initializationGeneration,a.length,r.deadlineMs,f,Date.now,p);r.initializationGeneration!==void 0&&(e.initializationReadiness=null),l=d?.health},()=>({phase:r.initializationGeneration===void 0?"didOpen":"initialize+didOpen",openedDocuments:a.length,health:l}))}return a.length}async function Fe(e,t,i,n){let r=i.filter(d=>!e.openedPaths.has(d));if(r.length===0)return await he(e),0;let a=e.initializationReadiness,o=n.readinessDeadlineMs===void 0?null:{statusSnapshot:a?null:e.client.serverStatusSnapshot(),initializationGeneration:a?.afterGeneration,deadlineMs:n.readinessDeadlineMs},c=[];for(let d of r)try{let m=E(t,d);e.client.didOpenTextDocument({uri:m,languageId:"rust",version:1,text:$(t,d,{inputKind:"indexed Rust source file"})}),e.openedPaths.add(d),c.push(m)}catch(m){if(!q(m))throw m}let f=n.diagnosticsTimeoutMs??1e4,l=f;await u("rust.semantic.worker.diagnostics",()=>o?G(d=>(l=d,k(e.client,c,d)),f,o.deadlineMs):k(e.client,c,f),()=>({openedDocuments:c.length,timeoutMs:l}));let p=n.settleDelayMs??5e3;if(!o)await u("rust.semantic.worker.settle",()=>b(p),()=>({openedDocuments:c.length,settleDelayMs:p}));else{let d;await u("rust.semantic.worker.readiness",async()=>{let m=y=>u("rust.semantic.worker.settle",()=>b(y),()=>({openedDocuments:c.length,settleDelayMs:y})),M=o.initializationGeneration===void 0?await j(e.client,o.statusSnapshot,c.length,o.deadlineMs,p,Date.now,m):await A(e.client,o.initializationGeneration,c.length,o.deadlineMs,p,Date.now,m);o.initializationGeneration!==void 0&&(e.initializationReadiness=null),d=M?.health},()=>({phase:o.initializationGeneration===void 0?"didOpen":"initialize+didOpen",openedDocuments:c.length,health:d}))}return c.length}async function he(e){let t=e.initializationReadiness;if(!t)return;let i;await u("rust.semantic.worker.readiness",async()=>{i=(await A(e.client,t.afterGeneration,0,t.deadlineMs,0)).health,e.initializationReadiness=null},()=>({phase:"initialize",openedDocuments:0,health:i}))}function Ee(e,t){for(let i of t){let n=te(e,i.uri);if(!(!n||n===".."||n.startsWith("../")||De(n)))return n}return null}function We(e,t){return t.references&&!e.referencesProvider?"rust-analyzer initialized without textDocument/references support.":t.callees&&!e.callHierarchyProvider?"rust-analyzer initialized without call hierarchy support.":t.signatures&&!e.hoverProvider?"rust-analyzer initialized without hover support.":null}function ye(e,t){let i=B(e),n=H(e),r=U(e);return{available:!1,reason:t,references:i.map(a=>[a.symbolId,[]]),...e.includeCallees?{callees:n.map(a=>[a.symbolId,[]])}:{},...e.includeSignatures?{signatures:r.map(a=>[a.symbolId,null])}:{}}}async function Le(){let e=[...P.values()];P.clear(),await Promise.all(e.map(t=>t.client.shutdown().catch(()=>{})))}async function ge(e,t,i){e.get(t.key)===t&&e.delete(t.key),await t.client.shutdown({deadlineMs:i}).catch(()=>{})}function _e(e,t,i){return JSON.stringify({binary:e,sessionRoot:t,linkedProjects:i})}function xe(e,t,i){if(!e)return;let n=je(e,t);n.definitions+=1,i.hasReferences&&(n.definitionsWithReferences+=1),n.references+=i.references,n.durationMs+=i.durationMs,n.maxDurationMs=Math.max(n.maxDurationMs,i.durationMs),i.slow&&(n.slowTasks+=1)}function Oe(e){if(!e)return;let t=[...e.entries()].sort(([i,n],[r,a])=>a.durationMs-n.durationMs||i.localeCompare(r));for(let[i,n]of t)D({type:"span",name:"rust.semantic.worker.references.by-file",durationMs:n.durationMs,ok:!0,relativePath:i,definitions:n.definitions,definitionsWithReferences:n.definitionsWithReferences,references:n.references,maxDurationMs:n.maxDurationMs,slowTasks:n.slowTasks,aggregate:"sum-task-duration"})}function je(e,t){let i=e.get(t);if(i)return i;let n={definitions:0,definitionsWithReferences:0,references:0,durationMs:0,maxDurationMs:0,slowTasks:0};return e.set(t,n),n}function Ge(e,t,i){if(!e)return;let n=Be(e,t);n.definitions+=1,i.hasCallees&&(n.definitionsWithCallees+=1),n.callees+=i.callees,n.durationMs+=i.durationMs,n.maxDurationMs=Math.max(n.maxDurationMs,i.durationMs),i.slow&&(n.slowTasks+=1)}function Ne(e){if(!e)return;let t=[...e.entries()].sort(([i,n],[r,a])=>a.durationMs-n.durationMs||i.localeCompare(r));for(let[i,n]of t)D({type:"span",name:"rust.semantic.worker.callees.by-file",durationMs:n.durationMs,ok:!0,relativePath:i,definitions:n.definitions,definitionsWithCallees:n.definitionsWithCallees,callees:n.callees,maxDurationMs:n.maxDurationMs,slowTasks:n.slowTasks,aggregate:"sum-task-duration"})}function Be(e,t){let i=e.get(t);if(i)return i;let n={definitions:0,definitionsWithCallees:0,callees:0,durationMs:0,maxDurationMs:0,slowTasks:0};return e.set(t,n),n}function pe(e){if(e===void 0||e==="")return null;let t=Number(e);return Number.isInteger(t)&&t>=0?t:null}function He(){let e=_.env.SCIP_RUST_SEMANTIC_PARALLEL_OPERATIONS;return e!=="0"&&e!=="false"}function g(e,t,i){Pe(e,JSON.stringify(t));let n=new Int32Array(i);Atomics.store(n,0,1),Atomics.notify(n,0)}export{ge as discardRustAnalyzerSession};
|
|
2
2
|
//# sourceMappingURL=rust-semantic-session-worker.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{A as o,B as p,C as q,D as r,m as a,n as b,o as c,p as d,q as e,r as f,s as g,t as h,u as i,v as j,w as k,x as l,y as m,z as n}from"./chunk-
|
|
1
|
+
import{A as o,B as p,C as q,D as r,m as a,n as b,o as c,p as d,q as e,r as f,s as g,t as h,u as i,v as j,w as k,x as l,y as m,z as n}from"./chunk-A2TNXAXO.js";import"./chunk-C5Q44Q5D.js";import"./chunk-APMMR5Y2.js";import"./chunk-46XGSFNI.js";export{p as calleesForDefinition,k as cargoManifestsForDefinitions,h as hoverToRustSignature,g as hoverWithRetry,l as openDefinitionDocuments,o as referencesWithCompletion,n as referencesWithRetry,a as runRustAnalyzerReferenceBatch,r as runWithConcurrency,i as rustAnalyzerInitializationOptions,j as rustAnalyzerSessionRoot,c as rustRequestCalleeDefinitions,b as rustRequestReferenceDefinitions,e as rustRequestSessionDefinitions,d as rustRequestSignatureDefinitions,f as signatureForDefinition,q as sleep,m as waitForOpenedDocuments};
|
|
2
2
|
//# sourceMappingURL=rust-semantic-worker.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as SupportedLanguage } from './config-types-
|
|
1
|
+
import { a as SupportedLanguage } from './config-types-B6MEoRNy.js';
|
|
2
2
|
|
|
3
3
|
type WatcherStatus = {
|
|
4
4
|
state: 'idle';
|
|
@@ -52,7 +52,7 @@ declare function getScipVersion(): string | null;
|
|
|
52
52
|
declare function printScipInstallInstructions(): void;
|
|
53
53
|
/**
|
|
54
54
|
* Attempt to auto-install the `scip` CLI binary.
|
|
55
|
-
*
|
|
55
|
+
* Uses an immutable Go module identity, then prints versioned manual instructions.
|
|
56
56
|
* Returns true if installation succeeded.
|
|
57
57
|
*/
|
|
58
58
|
declare function tryInstallScipCli(onStatus: (msg: string) => void): boolean;
|