@herbertgao/pi-extensions 2026.10.0 → 2026.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -12
- package/THIRD_PARTY_NOTICES.md +3 -3
- package/node_modules/@dietrichgebert/ponytail/.opencode/command/ponytail-audit.md +2 -2
- package/node_modules/@dietrichgebert/ponytail/.opencode/command/ponytail-debt.md +2 -2
- package/node_modules/@dietrichgebert/ponytail/.opencode/command/ponytail-gain.md +1 -1
- package/node_modules/@dietrichgebert/ponytail/.opencode/command/ponytail-help.md +1 -1
- package/node_modules/@dietrichgebert/ponytail/.opencode/command/ponytail-review.md +2 -2
- package/node_modules/@dietrichgebert/ponytail/.opencode/command/ponytail.md +1 -1
- package/node_modules/@dietrichgebert/ponytail/.opencode/plugins/index.js +4 -0
- package/node_modules/@dietrichgebert/ponytail/.opencode/plugins/ponytail-frontmatter.cjs +43 -3
- package/node_modules/@dietrichgebert/ponytail/.opencode/plugins/ponytail.mjs +142 -59
- package/node_modules/@dietrichgebert/ponytail/.qoder/rules/ponytail.md +21 -21
- package/node_modules/@dietrichgebert/ponytail/.qoder-plugin/plugin.json +1 -1
- package/node_modules/@dietrichgebert/ponytail/AGENTS.md +21 -21
- package/node_modules/@dietrichgebert/ponytail/README.md +52 -242
- package/node_modules/@dietrichgebert/ponytail/hooks/claude-codex-hooks.json +3 -3
- package/node_modules/@dietrichgebert/ponytail/hooks/copilot-hooks.json +4 -4
- package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-activate.js +70 -16
- package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-config.js +8 -7
- package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-instructions.js +30 -30
- package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-map.js +103 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-mode-tracker.js +46 -23
- package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-runtime.js +39 -7
- package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-subagent.js +20 -3
- package/node_modules/@dietrichgebert/ponytail/hooks/qoder-hooks.json +3 -3
- package/node_modules/@dietrichgebert/ponytail/package.json +3 -3
- package/node_modules/@dietrichgebert/ponytail/pi-extension/index.js +47 -17
- package/node_modules/@dietrichgebert/ponytail/scripts/uninstall.js +21 -7
- package/node_modules/@dietrichgebert/ponytail/skills/plugin.json +5 -0
- package/node_modules/@dietrichgebert/ponytail/skills/ponytail/SKILL.md +33 -101
- package/node_modules/@dietrichgebert/ponytail/skills/ponytail-audit/SKILL.md +89 -27
- package/node_modules/@dietrichgebert/ponytail/skills/ponytail-debt/SKILL.md +13 -12
- package/node_modules/@dietrichgebert/ponytail/skills/ponytail-gain/SKILL.md +21 -18
- package/node_modules/@dietrichgebert/ponytail/skills/ponytail-help/SKILL.md +12 -13
- package/node_modules/@dietrichgebert/ponytail/skills/ponytail-review/SKILL.md +96 -52
- package/node_modules/@herbertgao/pi-agency/LICENSE +21 -0
- package/node_modules/@herbertgao/pi-agency/README.md +40 -0
- package/node_modules/@herbertgao/pi-agency/package.json +53 -0
- package/node_modules/@herbertgao/pi-agency/src/index.ts +441 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/compact-thinking.ts +12 -12
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/compact-mode.ts +30 -6
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/default-mode.ts +15 -9
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/interaction.ts +27 -9
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/codemode.ts +4 -1
- package/node_modules/@herbertgao/pi-cc-extensions/package.json +2 -2
- package/node_modules/@narumitw/pi-caffeinate/package.json +4 -4
- package/node_modules/@tifan/pi-mermaid-open/package.json +5 -1
- package/node_modules/@tifan/pi-mermaid-open/src/index.ts +26 -9
- package/node_modules/@tifan/pi-recap/package.json +1 -1
- package/node_modules/@tifan/pi-recap/src/index.ts +104 -20
- package/node_modules/@tifan/pi-recap/src/models.ts +46 -4
- package/node_modules/pi-antigravity/README.md +23 -2
- package/node_modules/pi-antigravity/package.json +5 -3
- package/node_modules/pi-antigravity/src/diagnostics/diagnostics.ts +3 -2
- package/node_modules/pi-antigravity/src/features/generate-image.ts +72 -0
- package/node_modules/pi-antigravity/src/features/google-search.ts +71 -0
- package/node_modules/pi-antigravity/src/image/image.ts +86 -47
- package/node_modules/pi-antigravity/src/image/native.ts +69 -0
- package/node_modules/pi-antigravity/src/index.ts +52 -137
- package/node_modules/pi-antigravity/src/search/search.ts +130 -31
- package/node_modules/pi-antigravity/src/stream/stream.ts +162 -113
- package/node_modules/pi-antigravity/src/types/enums.ts +1 -0
- package/node_modules/pi-antigravity/src/types/types.ts +1 -1
- package/node_modules/pi-antigravity/src/utils/security.ts +47 -1
- package/node_modules/pi-antigravity/src/utils/util.ts +38 -6
- package/node_modules/pi-lens/CHANGELOG.md +1064 -0
- package/node_modules/pi-lens/README.md +115 -25
- package/node_modules/pi-lens/config/dependency-cruiser-eager-allowlist.json +6 -2
- package/node_modules/pi-lens/dist/chunk-22AVIGXS.js +560 -0
- package/node_modules/pi-lens/dist/chunk-27BBHSZC.js +106 -0
- package/node_modules/pi-lens/dist/chunk-2BEMIWEW.js +51 -0
- package/node_modules/pi-lens/dist/chunk-2EECBNC5.js +89 -0
- package/node_modules/pi-lens/dist/chunk-34U7PLGE.js +23 -0
- package/node_modules/pi-lens/dist/chunk-3I5QFT3N.js +181 -0
- package/node_modules/pi-lens/dist/chunk-3MED75HT.js +37 -0
- package/node_modules/pi-lens/dist/chunk-47D2BO4S.js +87 -0
- package/node_modules/pi-lens/dist/chunk-4RERDEXR.js +348 -0
- package/node_modules/pi-lens/dist/chunk-4W2PLC4J.js +27 -0
- package/node_modules/pi-lens/dist/chunk-52H5B5TC.js +202 -0
- package/node_modules/pi-lens/dist/chunk-54B42YRX.js +27 -0
- package/node_modules/pi-lens/dist/chunk-5RXBNSW2.js +266 -0
- package/node_modules/pi-lens/dist/chunk-5THXD6X5.js +201 -0
- package/node_modules/pi-lens/dist/chunk-5W3R6LFT.js +24 -0
- package/node_modules/pi-lens/dist/chunk-5ZEJHV35.js +341 -0
- package/node_modules/pi-lens/dist/chunk-6P62QVEA.js +118 -0
- package/node_modules/pi-lens/dist/chunk-6QIUX4EP.js +459 -0
- package/node_modules/pi-lens/dist/chunk-6VCD4VKZ.js +78 -0
- package/node_modules/pi-lens/dist/chunk-7F72PXY2.js +326 -0
- package/node_modules/pi-lens/dist/chunk-7FBF7NPR.js +998 -0
- package/node_modules/pi-lens/dist/chunk-7U2IDNXN.js +37 -0
- package/node_modules/pi-lens/dist/chunk-ABBOA7UD.js +157 -0
- package/node_modules/pi-lens/dist/chunk-AHDW3GPE.js +50 -0
- package/node_modules/pi-lens/dist/chunk-AJ3QXTRQ.js +756 -0
- package/node_modules/pi-lens/dist/chunk-AJVLWNFN.js +1610 -0
- package/node_modules/pi-lens/dist/chunk-AJXODZY6.js +112 -0
- package/node_modules/pi-lens/dist/chunk-ARFCXG7S.js +84 -0
- package/node_modules/pi-lens/dist/chunk-AS44CFQ4.js +708 -0
- package/node_modules/pi-lens/dist/chunk-AWE5TMPO.js +38 -0
- package/node_modules/pi-lens/dist/chunk-B3I2UUT4.js +4692 -0
- package/node_modules/pi-lens/dist/chunk-BRJKOBZP.js +331 -0
- package/node_modules/pi-lens/dist/chunk-BW5KFIQC.js +59 -0
- package/node_modules/pi-lens/dist/chunk-C2AUYXQH.js +149 -0
- package/node_modules/pi-lens/dist/chunk-CGGAIP7J.js +29 -0
- package/node_modules/pi-lens/dist/chunk-D6QS3U6M.js +30 -0
- package/node_modules/pi-lens/dist/chunk-DFVMIKMQ.js +349 -0
- package/node_modules/pi-lens/dist/chunk-DIULIWKU.js +169 -0
- package/node_modules/pi-lens/dist/chunk-DQ2NZ7C4.js +2317 -0
- package/node_modules/pi-lens/dist/chunk-E2WFBRHM.js +213 -0
- package/node_modules/pi-lens/dist/chunk-E4MAEDPM.js +50 -0
- package/node_modules/pi-lens/dist/chunk-EOKRQ3SA.js +30 -0
- package/node_modules/pi-lens/dist/chunk-F3AU2TMM.js +2626 -0
- package/node_modules/pi-lens/dist/chunk-F3P7VQ7H.js +170 -0
- package/node_modules/pi-lens/dist/chunk-FC4RP4I2.js +12 -0
- package/node_modules/pi-lens/dist/chunk-FJNKANOS.js +32 -0
- package/node_modules/pi-lens/dist/chunk-GUOGVTCQ.js +146 -0
- package/node_modules/pi-lens/dist/chunk-GVXA6CCE.js +18 -0
- package/node_modules/pi-lens/dist/chunk-HHYAELLJ.js +2334 -0
- package/node_modules/pi-lens/dist/chunk-HMFXILPV.js +83 -0
- package/node_modules/pi-lens/dist/chunk-HVUZXSWK.js +421 -0
- package/node_modules/pi-lens/dist/chunk-HWBZIGMJ.js +62 -0
- package/node_modules/pi-lens/dist/chunk-I3R7GKDR.js +17 -0
- package/node_modules/pi-lens/dist/chunk-I7SPGOWI.js +55 -0
- package/node_modules/pi-lens/dist/chunk-IIXOAGHR.js +38 -0
- package/node_modules/pi-lens/dist/chunk-IVP5KAB7.js +2250 -0
- package/node_modules/pi-lens/dist/chunk-IXEBJSUE.js +22 -0
- package/node_modules/pi-lens/dist/chunk-JOLITGCC.js +27 -0
- package/node_modules/pi-lens/dist/chunk-K6VYLB2U.js +145 -0
- package/node_modules/pi-lens/dist/chunk-LJDODBBZ.js +78 -0
- package/node_modules/pi-lens/dist/chunk-LNAKEO63.js +78 -0
- package/node_modules/pi-lens/dist/chunk-LSMJ6KBE.js +4139 -0
- package/node_modules/pi-lens/dist/chunk-LW6XKDZQ.js +5565 -0
- package/node_modules/pi-lens/dist/chunk-N3YQJI6O.js +899 -0
- package/node_modules/pi-lens/dist/chunk-NABLC7W3.js +148 -0
- package/node_modules/pi-lens/dist/chunk-NKOUFPQF.js +659 -0
- package/node_modules/pi-lens/dist/chunk-NL5GLMFI.js +211 -0
- package/node_modules/pi-lens/dist/chunk-NMABWBZN.js +327 -0
- package/node_modules/pi-lens/dist/chunk-NTHH2J74.js +27 -0
- package/node_modules/pi-lens/dist/chunk-NTUJEGDZ.js +59 -0
- package/node_modules/pi-lens/dist/chunk-NXL4FFQQ.js +47 -0
- package/node_modules/pi-lens/dist/chunk-NXPS2L6U.js +466 -0
- package/node_modules/pi-lens/dist/chunk-O5WILGMI.js +42 -0
- package/node_modules/pi-lens/dist/chunk-O6TQT6RI.js +48 -0
- package/node_modules/pi-lens/dist/chunk-OAXNDZJ7.js +323 -0
- package/node_modules/pi-lens/dist/chunk-ODEEOXPH.js +44 -0
- package/node_modules/pi-lens/dist/chunk-OQGFCZJ4.js +4533 -0
- package/node_modules/pi-lens/dist/chunk-ORTMY4Q4.js +282 -0
- package/node_modules/pi-lens/dist/chunk-OS32RNR2.js +442 -0
- package/node_modules/pi-lens/dist/chunk-PAK6IDME.js +189 -0
- package/node_modules/pi-lens/dist/chunk-PWFHBTSF.js +406 -0
- package/node_modules/pi-lens/dist/chunk-Q5U6FMDI.js +2352 -0
- package/node_modules/pi-lens/dist/chunk-QOZXJ4NA.js +3364 -0
- package/node_modules/pi-lens/dist/chunk-QYF5S6P6.js +45 -0
- package/node_modules/pi-lens/dist/chunk-RIISMHKN.js +36 -0
- package/node_modules/pi-lens/dist/chunk-RPD4ZSB7.js +25 -0
- package/node_modules/pi-lens/dist/chunk-RPD5K5NC.js +79 -0
- package/node_modules/pi-lens/dist/chunk-RUOG5D2C.js +262 -0
- package/node_modules/pi-lens/dist/chunk-T4ERT73Y.js +599 -0
- package/node_modules/pi-lens/dist/chunk-T6D4Q4AQ.js +54 -0
- package/node_modules/pi-lens/dist/chunk-TGPXLY2J.js +391 -0
- package/node_modules/pi-lens/dist/chunk-TLGFBM3F.js +12116 -0
- package/node_modules/pi-lens/dist/chunk-TO6WL3GM.js +88 -0
- package/node_modules/pi-lens/dist/chunk-TT22N74J.js +517 -0
- package/node_modules/pi-lens/dist/chunk-TVN5N6GY.js +21216 -0
- package/node_modules/pi-lens/dist/chunk-U3VGR4VU.js +308 -0
- package/node_modules/pi-lens/dist/chunk-UK3CMEAL.js +1250 -0
- package/node_modules/pi-lens/dist/chunk-UOPVJQ4N.js +103 -0
- package/node_modules/pi-lens/dist/chunk-UXVNL3D7.js +23 -0
- package/node_modules/pi-lens/dist/chunk-UY752QSN.js +45 -0
- package/node_modules/pi-lens/dist/chunk-V5PXFSZK.js +188 -0
- package/node_modules/pi-lens/dist/chunk-V7R425XG.js +398 -0
- package/node_modules/pi-lens/dist/chunk-VCSRSYLF.js +81 -0
- package/node_modules/pi-lens/dist/chunk-VD4JQCQC.js +162 -0
- package/node_modules/pi-lens/dist/chunk-VDBPVIKD.js +62 -0
- package/node_modules/pi-lens/dist/chunk-VHQLPIRJ.js +114 -0
- package/node_modules/pi-lens/dist/chunk-VN2AXLEX.js +5414 -0
- package/node_modules/pi-lens/dist/chunk-VNMT7C64.js +478 -0
- package/node_modules/pi-lens/dist/chunk-WONERJTP.js +309 -0
- package/node_modules/pi-lens/dist/chunk-XECLWQZN.js +85 -0
- package/node_modules/pi-lens/dist/chunk-XIMYZ3JA.js +27 -0
- package/node_modules/pi-lens/dist/chunk-XK4CIILI.js +144 -0
- package/node_modules/pi-lens/dist/chunk-Y4T27COV.js +562 -0
- package/node_modules/pi-lens/dist/chunk-YGVYKNSN.js +1860 -0
- package/node_modules/pi-lens/dist/chunk-YLF3PPT5.js +308 -0
- package/node_modules/pi-lens/dist/chunk-YSNFMJKN.js +14 -0
- package/node_modules/pi-lens/dist/chunk-Z3CCVDUB.js +76 -0
- package/node_modules/pi-lens/dist/chunk-Z54ZSOBZ.js +61 -0
- package/node_modules/pi-lens/dist/chunk-ZAWW3AF6.js +97 -0
- package/node_modules/pi-lens/dist/chunk-ZMOL6RQC.js +167 -0
- package/node_modules/pi-lens/dist/index.js +16456 -8335
- package/node_modules/pi-lens/dist/mcp/analyze-cli.js +186 -232
- package/node_modules/pi-lens/dist/mcp/cli.js +137 -98
- package/node_modules/pi-lens/dist/mcp/server.js +22589 -1573
- package/node_modules/pi-lens/dist/mcp/worker.js +97 -38
- package/node_modules/pi-lens/dist/probes/installer.js +135 -0
- package/node_modules/pi-lens/dist/workers/project-snapshot-persist-worker.js +22 -0
- package/node_modules/pi-lens/dist/workers/review-graph-persist-worker.js +15 -0
- package/node_modules/pi-lens/docs/agent-guide.md +13 -4
- package/node_modules/pi-lens/docs/agent-tools.md +42 -0
- package/node_modules/pi-lens/docs/ast-grep_rules_catalog.md +3 -2
- package/node_modules/pi-lens/docs/configuration.md +20 -1
- package/node_modules/pi-lens/docs/environment-variables.md +52 -2
- package/node_modules/pi-lens/docs/features.md +8 -4
- package/node_modules/pi-lens/docs/globalconfig.md +1 -0
- package/node_modules/pi-lens/docs/io-bridge-v2-migration.md +94 -0
- package/node_modules/pi-lens/docs/lsp-capability-matrix.md +36 -4
- package/node_modules/pi-lens/docs/lsp-idle-eviction.md +124 -0
- package/node_modules/pi-lens/docs/mcp.md +21 -5
- package/node_modules/pi-lens/docs/merge-queue-rollout.md +77 -0
- package/node_modules/pi-lens/docs/pi-lens-fixer.md +156 -88
- package/node_modules/pi-lens/docs/pi-lens-investigator.md +74 -26
- package/node_modules/pi-lens/docs/pi-lens-merge-policy.md +694 -0
- package/node_modules/pi-lens/docs/pi-lens-monitor.md +73 -7
- package/node_modules/pi-lens/docs/pi-lens-retro.md +6 -4
- package/node_modules/pi-lens/docs/pi-lens-reviewer.md +188 -48
- package/node_modules/pi-lens/docs/pi-lens-subagent.md +246 -45
- package/node_modules/pi-lens/docs/pi-lens-warden.md +18 -7
- package/node_modules/pi-lens/docs/public-api-stability.md +55 -0
- package/node_modules/pi-lens/docs/release-qa-baseline.md +84 -17
- package/node_modules/pi-lens/docs/rfcs/3654-unified-io-bridge-v2.md +316 -0
- package/node_modules/pi-lens/docs/servercapabilities.md +53 -49
- package/node_modules/pi-lens/docs/settings.md +1 -0
- package/node_modules/pi-lens/docs/usage.md +5 -1
- package/node_modules/pi-lens/grammars/tree-sitter-bash.wasm +0 -0
- package/node_modules/pi-lens/grammars/tree-sitter-bash.wasm.json +3 -3
- package/node_modules/pi-lens/package.json +18 -6
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/advisory-registry-subset-test.yml +41 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/advisory-registry-subset.yml +50 -0
- package/node_modules/pi-lens/scripts/analyze-pi-lens-logs.mjs +1275 -62
- package/node_modules/pi-lens/scripts/download-grammars.js +5 -0
- package/node_modules/pi-lens/scripts/grammars.lock.json +6 -1
- package/node_modules/pi-lens/scripts/install-selftest.mjs +33 -34
- package/node_modules/pi-lens/scripts/lib/host-provided-deps.mjs +13 -4
- package/node_modules/pi-lens/scripts/lib/web-tree-sitter-dir.mjs +18 -0
- package/node_modules/pi-typesafe/README.md +1 -1
- package/node_modules/pi-typesafe/dist/backends.d.ts +15 -5
- package/node_modules/pi-typesafe/dist/backends.js +18 -0
- package/node_modules/pi-typesafe/dist/client.d.ts +4 -3
- package/node_modules/pi-typesafe/dist/client.js +22 -7
- package/node_modules/pi-typesafe/dist/index.d.ts +2 -2
- package/node_modules/pi-typesafe/dist/index.js +1 -1
- package/node_modules/pi-typesafe/dist/usage.d.ts +14 -4
- package/node_modules/pi-typesafe/dist/usage.js +147 -42
- package/node_modules/pi-typesafe/package.json +1 -1
- package/node_modules/pi-web-access/CHANGELOG.md +48 -0
- package/node_modules/pi-web-access/README.md +57 -11
- package/node_modules/pi-web-access/brave-rate-limit.ts +8 -2
- package/node_modules/pi-web-access/curator-page.ts +5 -1
- package/node_modules/pi-web-access/curator-server.ts +2 -0
- package/node_modules/pi-web-access/declared-web-links.ts +2 -2
- package/node_modules/pi-web-access/degoog.ts +323 -0
- package/node_modules/pi-web-access/dist/index.js +3483 -2745
- package/node_modules/pi-web-access/dist/mcp-cli.js +27443 -0
- package/node_modules/pi-web-access/exa.ts +5 -1
- package/node_modules/pi-web-access/extract.ts +41 -3
- package/node_modules/pi-web-access/firecrawl.ts +35 -4
- package/node_modules/pi-web-access/gemini-search.ts +34 -11
- package/node_modules/pi-web-access/gemini-web.ts +14 -9
- package/node_modules/pi-web-access/index.ts +153 -1202
- package/node_modules/pi-web-access/keenable.ts +221 -0
- package/node_modules/pi-web-access/mcp-cli.ts +40 -0
- package/node_modules/pi-web-access/mcp-server.ts +81 -0
- package/node_modules/pi-web-access/mcp-tool-definitions.ts +117 -0
- package/node_modules/pi-web-access/openai-search.ts +34 -1
- package/node_modules/pi-web-access/package.json +23 -5
- package/node_modules/pi-web-access/perplexity.ts +64 -56
- package/node_modules/pi-web-access/tool-arguments.ts +20 -0
- package/node_modules/pi-web-access/video-extract.ts +1 -1
- package/node_modules/pi-web-access/web-tool-contract.ts +86 -0
- package/node_modules/pi-web-access/web-tool-core.ts +1502 -0
- package/node_modules/pi-web-access/youtube-extract.ts +2 -5
- package/package.json +17 -12
- package/node_modules/@dietrichgebert/ponytail/README.es.md +0 -329
- package/node_modules/@dietrichgebert/ponytail/README.ko.md +0 -346
- package/node_modules/@dietrichgebert/ponytail/assets/benchmark-3model.svg +0 -21
- package/node_modules/@dietrichgebert/ponytail/assets/benchmark-agentic.svg +0 -62
- package/node_modules/@dietrichgebert/ponytail/assets/logo-dark.png +0 -0
- package/node_modules/@dietrichgebert/ponytail/assets/logo-dark.svg +0 -115
- package/node_modules/@dietrichgebert/ponytail/assets/logo-greenpt-dark.svg +0 -27
- package/node_modules/@dietrichgebert/ponytail/assets/logo-greenpt.svg +0 -27
- package/node_modules/@dietrichgebert/ponytail/assets/logo.png +0 -0
- package/node_modules/@dietrichgebert/ponytail/assets/retriever-icon.png +0 -0
- package/node_modules/@dietrichgebert/ponytail/assets/retriever-logo-dark.svg +0 -4
- package/node_modules/@dietrichgebert/ponytail/assets/retriever-logo-light.svg +0 -4
- package/node_modules/@dietrichgebert/ponytail/assets/social-preview.png +0 -0
- package/node_modules/@dietrichgebert/ponytail/assets/waitlist-banner-es.png +0 -0
- package/node_modules/@dietrichgebert/ponytail/assets/waitlist-banner-ko.png +0 -0
- package/node_modules/@dietrichgebert/ponytail/assets/waitlist-banner.png +0 -0
- package/node_modules/pi-lens/dist/clients/actionable-warnings-logger.js +0 -35
- package/node_modules/pi-lens/dist/clients/actionable-warnings.js +0 -1610
- package/node_modules/pi-lens/dist/clients/advisory-provenance.js +0 -593
- package/node_modules/pi-lens/dist/clients/agent-behavior-client.js +0 -147
- package/node_modules/pi-lens/dist/clients/agent-nudge.js +0 -325
- package/node_modules/pi-lens/dist/clients/analysed-root.js +0 -1
- package/node_modules/pi-lens/dist/clients/ast-grep-client.js +0 -731
- package/node_modules/pi-lens/dist/clients/ast-grep-rule-manager.js +0 -146
- package/node_modules/pi-lens/dist/clients/ast-grep-tool-logger.js +0 -118
- package/node_modules/pi-lens/dist/clients/ast-grep-types.js +0 -10
- package/node_modules/pi-lens/dist/clients/ast-grep-yaml-synth.js +0 -154
- package/node_modules/pi-lens/dist/clients/atomic-write-staging.js +0 -75
- package/node_modules/pi-lens/dist/clients/atomic-write.js +0 -189
- package/node_modules/pi-lens/dist/clients/availability-probe-flight.js +0 -12
- package/node_modules/pi-lens/dist/clients/bash-file-access.js +0 -1056
- package/node_modules/pi-lens/dist/clients/biome-client.js +0 -357
- package/node_modules/pi-lens/dist/clients/blocker-freshness.js +0 -837
- package/node_modules/pi-lens/dist/clients/blocker-past-eof.js +0 -129
- package/node_modules/pi-lens/dist/clients/bootstrap.js +0 -569
- package/node_modules/pi-lens/dist/clients/bounded-cache.js +0 -190
- package/node_modules/pi-lens/dist/clients/bounded-pid-file-lock.js +0 -202
- package/node_modules/pi-lens/dist/clients/bounded-telemetry.js +0 -295
- package/node_modules/pi-lens/dist/clients/build-identity.js +0 -95
- package/node_modules/pi-lens/dist/clients/bundled-resource-health.js +0 -113
- package/node_modules/pi-lens/dist/clients/bus-events-logger.js +0 -105
- package/node_modules/pi-lens/dist/clients/bus-publish.js +0 -171
- package/node_modules/pi-lens/dist/clients/cache/rule-cache.js +0 -190
- package/node_modules/pi-lens/dist/clients/cache-manager.js +0 -524
- package/node_modules/pi-lens/dist/clients/cache-observability.js +0 -1313
- package/node_modules/pi-lens/dist/clients/call-graph.js +0 -852
- package/node_modules/pi-lens/dist/clients/cargo-manifest.js +0 -422
- package/node_modules/pi-lens/dist/clients/cascade-budget.js +0 -196
- package/node_modules/pi-lens/dist/clients/cascade-format.js +0 -315
- package/node_modules/pi-lens/dist/clients/cascade-logger.js +0 -31
- package/node_modules/pi-lens/dist/clients/cascade-types.js +0 -9
- package/node_modules/pi-lens/dist/clients/child-unref.js +0 -124
- package/node_modules/pi-lens/dist/clients/code-quality-warnings.js +0 -286
- package/node_modules/pi-lens/dist/clients/codebase-model.js +0 -173
- package/node_modules/pi-lens/dist/clients/collateral-test-role.js +0 -40
- package/node_modules/pi-lens/dist/clients/complexity-client.js +0 -462
- package/node_modules/pi-lens/dist/clients/config-core/deny.js +0 -221
- package/node_modules/pi-lens/dist/clients/config-core/index.js +0 -50
- package/node_modules/pi-lens/dist/clients/config-core/merge.js +0 -357
- package/node_modules/pi-lens/dist/clients/config-core/normalize.js +0 -340
- package/node_modules/pi-lens/dist/clients/config-core/process-spec.js +0 -248
- package/node_modules/pi-lens/dist/clients/config-core/provenance.js +0 -164
- package/node_modules/pi-lens/dist/clients/config-core/records.js +0 -218
- package/node_modules/pi-lens/dist/clients/config-core/resolve.js +0 -125
- package/node_modules/pi-lens/dist/clients/config-core/safe-object.js +0 -78
- package/node_modules/pi-lens/dist/clients/config-core/schema.js +0 -165
- package/node_modules/pi-lens/dist/clients/config-diagnostic-codes.js +0 -285
- package/node_modules/pi-lens/dist/clients/config-locations.js +0 -388
- package/node_modules/pi-lens/dist/clients/config-resolve.js +0 -798
- package/node_modules/pi-lens/dist/clients/config-schema.js +0 -251
- package/node_modules/pi-lens/dist/clients/config-warn.js +0 -407
- package/node_modules/pi-lens/dist/clients/console-guard-install.js +0 -26
- package/node_modules/pi-lens/dist/clients/cooperative-budget.js +0 -42
- package/node_modules/pi-lens/dist/clients/dead-code-client.js +0 -510
- package/node_modules/pi-lens/dist/clients/dead-code-logger.js +0 -30
- package/node_modules/pi-lens/dist/clients/deadline-utils.js +0 -280
- package/node_modules/pi-lens/dist/clients/debug-handles.js +0 -211
- package/node_modules/pi-lens/dist/clients/debug-heap.js +0 -174
- package/node_modules/pi-lens/dist/clients/deferred-lsp-work.js +0 -106
- package/node_modules/pi-lens/dist/clients/degradation-ledger.js +0 -426
- package/node_modules/pi-lens/dist/clients/demoted-finding-render.js +0 -169
- package/node_modules/pi-lens/dist/clients/dependency-checker.js +0 -885
- package/node_modules/pi-lens/dist/clients/deps/ast-grep-napi.js +0 -22
- package/node_modules/pi-lens/dist/clients/deps/js-yaml.js +0 -9
- package/node_modules/pi-lens/dist/clients/deps/minimatch.js +0 -4
- package/node_modules/pi-lens/dist/clients/deps/pi-tui.js +0 -14
- package/node_modules/pi-lens/dist/clients/deps/typebox.js +0 -14
- package/node_modules/pi-lens/dist/clients/deps/vscode-jsonrpc.js +0 -1
- package/node_modules/pi-lens/dist/clients/deps/web-tree-sitter.js +0 -24
- package/node_modules/pi-lens/dist/clients/diagnostic-dispositions.js +0 -630
- package/node_modules/pi-lens/dist/clients/diagnostic-line-freshness.js +0 -305
- package/node_modules/pi-lens/dist/clients/diagnostic-logger.js +0 -73
- package/node_modules/pi-lens/dist/clients/diagnostic-tracker.js +0 -105
- package/node_modules/pi-lens/dist/clients/diagnostics-publish.js +0 -230
- package/node_modules/pi-lens/dist/clients/dispatch/ast-grep-catalog.js +0 -65
- package/node_modules/pi-lens/dist/clients/dispatch/auxiliary-lsp.js +0 -343
- package/node_modules/pi-lens/dist/clients/dispatch/collect-later-tier.js +0 -35
- package/node_modules/pi-lens/dist/clients/dispatch/diagnostic-taxonomy.js +0 -66
- package/node_modules/pi-lens/dist/clients/dispatch/dispatcher.js +0 -1269
- package/node_modules/pi-lens/dist/clients/dispatch/fact-provider-types.js +0 -1
- package/node_modules/pi-lens/dist/clients/dispatch/fact-rule-runner.js +0 -17
- package/node_modules/pi-lens/dist/clients/dispatch/fact-runner.js +0 -30
- package/node_modules/pi-lens/dist/clients/dispatch/fact-scheduler.js +0 -68
- package/node_modules/pi-lens/dist/clients/dispatch/fact-store.js +0 -377
- package/node_modules/pi-lens/dist/clients/dispatch/facts/comment-facts.js +0 -22
- package/node_modules/pi-lens/dist/clients/dispatch/facts/file-content.js +0 -19
- package/node_modules/pi-lens/dist/clients/dispatch/facts/function-facts.js +0 -348
- package/node_modules/pi-lens/dist/clients/dispatch/facts/import-facts.js +0 -204
- package/node_modules/pi-lens/dist/clients/dispatch/facts/tree-sitter-facts.js +0 -34
- package/node_modules/pi-lens/dist/clients/dispatch/facts/try-catch-facts.js +0 -119
- package/node_modules/pi-lens/dist/clients/dispatch/finding-policy.js +0 -339
- package/node_modules/pi-lens/dist/clients/dispatch/indent-detect.js +0 -417
- package/node_modules/pi-lens/dist/clients/dispatch/inline-suppressions.js +0 -89
- package/node_modules/pi-lens/dist/clients/dispatch/integration.js +0 -2377
- package/node_modules/pi-lens/dist/clients/dispatch/lazy.js +0 -11
- package/node_modules/pi-lens/dist/clients/dispatch/pending-runner-findings.js +0 -87
- package/node_modules/pi-lens/dist/clients/dispatch/plan.js +0 -278
- package/node_modules/pi-lens/dist/clients/dispatch/priorities.js +0 -20
- package/node_modules/pi-lens/dist/clients/dispatch/rule-id-normalize.js +0 -50
- package/node_modules/pi-lens/dist/clients/dispatch/rule-ignores.js +0 -69
- package/node_modules/pi-lens/dist/clients/dispatch/rule-policy.js +0 -135
- package/node_modules/pi-lens/dist/clients/dispatch/rules/async-noise.js +0 -40
- package/node_modules/pi-lens/dist/clients/dispatch/rules/async-unnecessary-wrapper.js +0 -27
- package/node_modules/pi-lens/dist/clients/dispatch/rules/cors-wildcard.js +0 -54
- package/node_modules/pi-lens/dist/clients/dispatch/rules/error-obscuring.js +0 -32
- package/node_modules/pi-lens/dist/clients/dispatch/rules/error-swallowing.js +0 -31
- package/node_modules/pi-lens/dist/clients/dispatch/rules/framework-call-noise.js +0 -67
- package/node_modules/pi-lens/dist/clients/dispatch/rules/high-complexity.js +0 -72
- package/node_modules/pi-lens/dist/clients/dispatch/rules/high-fan-out.js +0 -74
- package/node_modules/pi-lens/dist/clients/dispatch/rules/high-import-coupling.js +0 -37
- package/node_modules/pi-lens/dist/clients/dispatch/rules/missing-error-propagation.js +0 -62
- package/node_modules/pi-lens/dist/clients/dispatch/rules/no-commented-credentials.js +0 -52
- package/node_modules/pi-lens/dist/clients/dispatch/rules/pass-through-wrappers.js +0 -42
- package/node_modules/pi-lens/dist/clients/dispatch/rules/placeholder-comments.js +0 -40
- package/node_modules/pi-lens/dist/clients/dispatch/rules/unsafe-boundary.js +0 -126
- package/node_modules/pi-lens/dist/clients/dispatch/runner-context.js +0 -52
- package/node_modules/pi-lens/dist/clients/dispatch/runners/actionlint.js +0 -111
- package/node_modules/pi-lens/dist/clients/dispatch/runners/ast-grep-napi.js +0 -1196
- package/node_modules/pi-lens/dist/clients/dispatch/runners/biome-check.js +0 -296
- package/node_modules/pi-lens/dist/clients/dispatch/runners/cpp-check.js +0 -219
- package/node_modules/pi-lens/dist/clients/dispatch/runners/credo.js +0 -82
- package/node_modules/pi-lens/dist/clients/dispatch/runners/cue-vet.js +0 -416
- package/node_modules/pi-lens/dist/clients/dispatch/runners/dart-analyze.js +0 -183
- package/node_modules/pi-lens/dist/clients/dispatch/runners/detekt.js +0 -176
- package/node_modules/pi-lens/dist/clients/dispatch/runners/dotnet-build.js +0 -164
- package/node_modules/pi-lens/dist/clients/dispatch/runners/elixir-check.js +0 -195
- package/node_modules/pi-lens/dist/clients/dispatch/runners/eslint.js +0 -137
- package/node_modules/pi-lens/dist/clients/dispatch/runners/fact-rules.js +0 -29
- package/node_modules/pi-lens/dist/clients/dispatch/runners/fish-indent.js +0 -69
- package/node_modules/pi-lens/dist/clients/dispatch/runners/gleam-check.js +0 -167
- package/node_modules/pi-lens/dist/clients/dispatch/runners/go-vet.js +0 -104
- package/node_modules/pi-lens/dist/clients/dispatch/runners/golangci-lint.js +0 -135
- package/node_modules/pi-lens/dist/clients/dispatch/runners/hadolint.js +0 -91
- package/node_modules/pi-lens/dist/clients/dispatch/runners/helm-lint.js +0 -171
- package/node_modules/pi-lens/dist/clients/dispatch/runners/helm-render.js +0 -940
- package/node_modules/pi-lens/dist/clients/dispatch/runners/htmlhint.js +0 -117
- package/node_modules/pi-lens/dist/clients/dispatch/runners/index.js +0 -108
- package/node_modules/pi-lens/dist/clients/dispatch/runners/javac.js +0 -99
- package/node_modules/pi-lens/dist/clients/dispatch/runners/ktlint.js +0 -110
- package/node_modules/pi-lens/dist/clients/dispatch/runners/lsp.js +0 -379
- package/node_modules/pi-lens/dist/clients/dispatch/runners/markdownlint.js +0 -167
- package/node_modules/pi-lens/dist/clients/dispatch/runners/mypy.js +0 -102
- package/node_modules/pi-lens/dist/clients/dispatch/runners/oxlint.js +0 -414
- package/node_modules/pi-lens/dist/clients/dispatch/runners/php-lint.js +0 -85
- package/node_modules/pi-lens/dist/clients/dispatch/runners/phpstan.js +0 -120
- package/node_modules/pi-lens/dist/clients/dispatch/runners/prisma-validate.js +0 -62
- package/node_modules/pi-lens/dist/clients/dispatch/runners/psscriptanalyzer.js +0 -445
- package/node_modules/pi-lens/dist/clients/dispatch/runners/pyright.js +0 -169
- package/node_modules/pi-lens/dist/clients/dispatch/runners/rubocop.js +0 -99
- package/node_modules/pi-lens/dist/clients/dispatch/runners/ruff.js +0 -88
- package/node_modules/pi-lens/dist/clients/dispatch/runners/rust-clippy.js +0 -256
- package/node_modules/pi-lens/dist/clients/dispatch/runners/shellcheck.js +0 -173
- package/node_modules/pi-lens/dist/clients/dispatch/runners/shfmt.js +0 -102
- package/node_modules/pi-lens/dist/clients/dispatch/runners/spellcheck.js +0 -128
- package/node_modules/pi-lens/dist/clients/dispatch/runners/spotbugs.js +0 -259
- package/node_modules/pi-lens/dist/clients/dispatch/runners/sqlfluff.js +0 -183
- package/node_modules/pi-lens/dist/clients/dispatch/runners/stylelint.js +0 -166
- package/node_modules/pi-lens/dist/clients/dispatch/runners/swiftlint.js +0 -163
- package/node_modules/pi-lens/dist/clients/dispatch/runners/taplo.js +0 -174
- package/node_modules/pi-lens/dist/clients/dispatch/runners/terragrunt.js +0 -168
- package/node_modules/pi-lens/dist/clients/dispatch/runners/tflint.js +0 -125
- package/node_modules/pi-lens/dist/clients/dispatch/runners/tree-sitter.js +0 -643
- package/node_modules/pi-lens/dist/clients/dispatch/runners/trivy-config.js +0 -253
- package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/availability-policy.js +0 -496
- package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/candidate-probe.js +0 -90
- package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/diagnostic-parsers.js +0 -95
- package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/lazy-installer.js +0 -274
- package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/runner-helpers.js +0 -1701
- package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/spawn-outcome.js +0 -101
- package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/tool-failure.js +0 -235
- package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/toolchain-availability.js +0 -169
- package/node_modules/pi-lens/dist/clients/dispatch/runners/utils.js +0 -15
- package/node_modules/pi-lens/dist/clients/dispatch/runners/vale.js +0 -128
- package/node_modules/pi-lens/dist/clients/dispatch/runners/yaml-rule-parser.js +0 -242
- package/node_modules/pi-lens/dist/clients/dispatch/runners/yamllint.js +0 -95
- package/node_modules/pi-lens/dist/clients/dispatch/runners/zig-check.js +0 -79
- package/node_modules/pi-lens/dist/clients/dispatch/suppress-writer.js +0 -79
- package/node_modules/pi-lens/dist/clients/dispatch/tool-profile.js +0 -30
- package/node_modules/pi-lens/dist/clients/dispatch/types.js +0 -21
- package/node_modules/pi-lens/dist/clients/dispatch/utils/format-utils.js +0 -45
- package/node_modules/pi-lens/dist/clients/dispatch/utils/lsp-diagnostics.js +0 -35
- package/node_modules/pi-lens/dist/clients/disposition-logger.js +0 -32
- package/node_modules/pi-lens/dist/clients/disposition-publish.js +0 -124
- package/node_modules/pi-lens/dist/clients/durable-store.js +0 -97
- package/node_modules/pi-lens/dist/clients/effective-config.js +0 -415
- package/node_modules/pi-lens/dist/clients/env-utils.js +0 -83
- package/node_modules/pi-lens/dist/clients/error-class.js +0 -23
- package/node_modules/pi-lens/dist/clients/eval-timestamp.js +0 -17
- package/node_modules/pi-lens/dist/clients/event-loop-hold.js +0 -274
- package/node_modules/pi-lens/dist/clients/event-loop-monitor.js +0 -250
- package/node_modules/pi-lens/dist/clients/extension-log.js +0 -504
- package/node_modules/pi-lens/dist/clients/extension-mode.js +0 -73
- package/node_modules/pi-lens/dist/clients/feature-hints.js +0 -103
- package/node_modules/pi-lens/dist/clients/file-kinds.js +0 -412
- package/node_modules/pi-lens/dist/clients/file-role.js +0 -134
- package/node_modules/pi-lens/dist/clients/file-time.js +0 -160
- package/node_modules/pi-lens/dist/clients/file-utils.js +0 -1032
- package/node_modules/pi-lens/dist/clients/finding-delivery-gate.js +0 -494
- package/node_modules/pi-lens/dist/clients/finding-identity.js +0 -88
- package/node_modules/pi-lens/dist/clients/fix-worklog.js +0 -103
- package/node_modules/pi-lens/dist/clients/format-events-publish.js +0 -343
- package/node_modules/pi-lens/dist/clients/format-service.js +0 -222
- package/node_modules/pi-lens/dist/clients/formatters-lazy.js +0 -9
- package/node_modules/pi-lens/dist/clients/formatters.js +0 -2032
- package/node_modules/pi-lens/dist/clients/freshness-cadence.js +0 -17
- package/node_modules/pi-lens/dist/clients/freshness.js +0 -38
- package/node_modules/pi-lens/dist/clients/generated-artifacts.js +0 -394
- package/node_modules/pi-lens/dist/clients/generation-guard.js +0 -215
- package/node_modules/pi-lens/dist/clients/git-guard.js +0 -1136
- package/node_modules/pi-lens/dist/clients/git-tracked-ignore.js +0 -243
- package/node_modules/pi-lens/dist/clients/gitleaks-client.js +0 -509
- package/node_modules/pi-lens/dist/clients/go-client.js +0 -104
- package/node_modules/pi-lens/dist/clients/govulncheck-client.js +0 -605
- package/node_modules/pi-lens/dist/clients/gradle-ktfmt-style.js +0 -348
- package/node_modules/pi-lens/dist/clients/grammar-source.js +0 -465
- package/node_modules/pi-lens/dist/clients/gzip-stage-write.js +0 -135
- package/node_modules/pi-lens/dist/clients/hashline-anchor.js +0 -424
- package/node_modules/pi-lens/dist/clients/hook-budgets.js +0 -76
- package/node_modules/pi-lens/dist/clients/host-edit-normalize.js +0 -140
- package/node_modules/pi-lens/dist/clients/host-ports.js +0 -39
- package/node_modules/pi-lens/dist/clients/indent-retarget.js +0 -154
- package/node_modules/pi-lens/dist/clients/inline-blocker-dispositions.js +0 -186
- package/node_modules/pi-lens/dist/clients/install-diagnostics.js +0 -156
- package/node_modules/pi-lens/dist/clients/installer/index.js +0 -5416
- package/node_modules/pi-lens/dist/clients/installer/managed-tool-refresh-session.js +0 -58
- package/node_modules/pi-lens/dist/clients/installer/managed-tool-refresh.js +0 -783
- package/node_modules/pi-lens/dist/clients/instance-reaper-state.js +0 -7
- package/node_modules/pi-lens/dist/clients/instance-reaper.js +0 -1137
- package/node_modules/pi-lens/dist/clients/instance-registry-lock.js +0 -145
- package/node_modules/pi-lens/dist/clients/instance-registry.js +0 -773
- package/node_modules/pi-lens/dist/clients/jscpd-client.js +0 -378
- package/node_modules/pi-lens/dist/clients/json-cache-read.js +0 -65
- package/node_modules/pi-lens/dist/clients/knip-client.js +0 -788
- package/node_modules/pi-lens/dist/clients/language-policy.js +0 -252
- package/node_modules/pi-lens/dist/clients/language-profile.js +0 -361
- package/node_modules/pi-lens/dist/clients/language-registry.js +0 -603
- package/node_modules/pi-lens/dist/clients/latency-logger.js +0 -727
- package/node_modules/pi-lens/dist/clients/lazy-import.js +0 -21
- package/node_modules/pi-lens/dist/clients/ledger-bounds.js +0 -54
- package/node_modules/pi-lens/dist/clients/lens-config.js +0 -404
- package/node_modules/pi-lens/dist/clients/lens-engine.js +0 -358
- package/node_modules/pi-lens/dist/clients/lens-events.js +0 -125
- package/node_modules/pi-lens/dist/clients/lens-flag-registry.js +0 -467
- package/node_modules/pi-lens/dist/clients/lens-map.js +0 -1156
- package/node_modules/pi-lens/dist/clients/live-bus-emitter.js +0 -74
- package/node_modules/pi-lens/dist/clients/log-cleanup.js +0 -222
- package/node_modules/pi-lens/dist/clients/lsp/aggregation.js +0 -178
- package/node_modules/pi-lens/dist/clients/lsp/cascade-tier.js +0 -421
- package/node_modules/pi-lens/dist/clients/lsp/client.js +0 -4593
- package/node_modules/pi-lens/dist/clients/lsp/config.js +0 -691
- package/node_modules/pi-lens/dist/clients/lsp/content-limits.js +0 -41
- package/node_modules/pi-lens/dist/clients/lsp/diagnostic-binding.js +0 -225
- package/node_modules/pi-lens/dist/clients/lsp/document-drift.js +0 -467
- package/node_modules/pi-lens/dist/clients/lsp/edits.js +0 -1219
- package/node_modules/pi-lens/dist/clients/lsp/index.js +0 -8305
- package/node_modules/pi-lens/dist/clients/lsp/inferred-project.js +0 -216
- package/node_modules/pi-lens/dist/clients/lsp/jvm-runtime.js +0 -298
- package/node_modules/pi-lens/dist/clients/lsp/language.js +0 -63
- package/node_modules/pi-lens/dist/clients/lsp/launch.js +0 -746
- package/node_modules/pi-lens/dist/clients/lsp/lombok.js +0 -158
- package/node_modules/pi-lens/dist/clients/lsp/path-utils.js +0 -5
- package/node_modules/pi-lens/dist/clients/lsp/pending-aux-coverage.js +0 -251
- package/node_modules/pi-lens/dist/clients/lsp/position-encoding.js +0 -61
- package/node_modules/pi-lens/dist/clients/lsp/ruby-drive-dirs.js +0 -83
- package/node_modules/pi-lens/dist/clients/lsp/server.js +0 -3290
- package/node_modules/pi-lens/dist/clients/lsp/session-roots.js +0 -192
- package/node_modules/pi-lens/dist/clients/lsp/spawn-history.js +0 -17
- package/node_modules/pi-lens/dist/clients/lsp/sync-kind.js +0 -56
- package/node_modules/pi-lens/dist/clients/lsp/tsserver-sync.js +0 -332
- package/node_modules/pi-lens/dist/clients/lsp/wait-policy/capability-snapshot.js +0 -1
- package/node_modules/pi-lens/dist/clients/lsp/wait-policy/classification.js +0 -85
- package/node_modules/pi-lens/dist/clients/lsp/wait-policy/index.js +0 -10
- package/node_modules/pi-lens/dist/clients/lsp/wait-policy/strategies.js +0 -392
- package/node_modules/pi-lens/dist/clients/lsp/watch-queue.js +0 -61
- package/node_modules/pi-lens/dist/clients/lsp/workspace-diagnostics-cache.js +0 -639
- package/node_modules/pi-lens/dist/clients/lsp/workspace-diagnostics-session.js +0 -30
- package/node_modules/pi-lens/dist/clients/lsp/workspace-sweep-hold.js +0 -184
- package/node_modules/pi-lens/dist/clients/lsp-budget.js +0 -186
- package/node_modules/pi-lens/dist/clients/lsp-document-symbols.js +0 -110
- package/node_modules/pi-lens/dist/clients/lsp-lazy.js +0 -9
- package/node_modules/pi-lens/dist/clients/lsp-mutation.js +0 -396
- package/node_modules/pi-lens/dist/clients/lsp-status.js +0 -59
- package/node_modules/pi-lens/dist/clients/map-with-concurrency.js +0 -40
- package/node_modules/pi-lens/dist/clients/mcp/analyze.js +0 -420
- package/node_modules/pi-lens/dist/clients/mcp/host-shim.js +0 -31
- package/node_modules/pi-lens/dist/clients/mcp/ipc.js +0 -523
- package/node_modules/pi-lens/dist/clients/mcp/review.js +0 -197
- package/node_modules/pi-lens/dist/clients/mcp/session.js +0 -412
- package/node_modules/pi-lens/dist/clients/memory-sampler.js +0 -208
- package/node_modules/pi-lens/dist/clients/message-end-attribution.js +0 -30
- package/node_modules/pi-lens/dist/clients/metrics-client.js +0 -107
- package/node_modules/pi-lens/dist/clients/metrics-history.js +0 -327
- package/node_modules/pi-lens/dist/clients/middle-man-analysis.js +0 -263
- package/node_modules/pi-lens/dist/clients/model-provider.js +0 -53
- package/node_modules/pi-lens/dist/clients/module-report-lsp.js +0 -189
- package/node_modules/pi-lens/dist/clients/module-report.js +0 -2150
- package/node_modules/pi-lens/dist/clients/mutating-tool.js +0 -651
- package/node_modules/pi-lens/dist/clients/mutation-attribution.js +0 -368
- package/node_modules/pi-lens/dist/clients/mutation-bridge.js +0 -240
- package/node_modules/pi-lens/dist/clients/ndjson-logger.js +0 -734
- package/node_modules/pi-lens/dist/clients/observed-mutation-sources.js +0 -101
- package/node_modules/pi-lens/dist/clients/observed-mutation.js +0 -1253
- package/node_modules/pi-lens/dist/clients/oldtext-autopatch.js +0 -128
- package/node_modules/pi-lens/dist/clients/opaque-mutation-scan.js +0 -496
- package/node_modules/pi-lens/dist/clients/opengrep-client.js +0 -333
- package/node_modules/pi-lens/dist/clients/opengrep-config.js +0 -76
- package/node_modules/pi-lens/dist/clients/package-manager.js +0 -607
- package/node_modules/pi-lens/dist/clients/package-root.js +0 -38
- package/node_modules/pi-lens/dist/clients/partial-edit-apply.js +0 -439
- package/node_modules/pi-lens/dist/clients/path-attribution-telemetry.js +0 -43
- package/node_modules/pi-lens/dist/clients/path-keyed-map.js +0 -108
- package/node_modules/pi-lens/dist/clients/path-utils.js +0 -1244
- package/node_modules/pi-lens/dist/clients/performance-report.js +0 -331
- package/node_modules/pi-lens/dist/clients/persist-debounce.js +0 -70
- package/node_modules/pi-lens/dist/clients/persistent-reverify.js +0 -271
- package/node_modules/pi-lens/dist/clients/php-cs-fixer-config.js +0 -119
- package/node_modules/pi-lens/dist/clients/pipeline.js +0 -1480
- package/node_modules/pi-lens/dist/clients/post-autofix-notice.js +0 -37
- package/node_modules/pi-lens/dist/clients/print-mode.js +0 -21
- package/node_modules/pi-lens/dist/clients/probe-home-state.js +0 -228
- package/node_modules/pi-lens/dist/clients/process-bridge.js +0 -66
- package/node_modules/pi-lens/dist/clients/process-singletons.js +0 -210
- package/node_modules/pi-lens/dist/clients/process-snapshot.js +0 -68
- package/node_modules/pi-lens/dist/clients/project-changes.js +0 -181
- package/node_modules/pi-lens/dist/clients/project-conventions.js +0 -171
- package/node_modules/pi-lens/dist/clients/project-diagnostics/cache.js +0 -137
- package/node_modules/pi-lens/dist/clients/project-diagnostics/extractors.js +0 -109
- package/node_modules/pi-lens/dist/clients/project-diagnostics/fresh-fetch.js +0 -668
- package/node_modules/pi-lens/dist/clients/project-diagnostics/runner-adapters/call-graph-impact.js +0 -118
- package/node_modules/pi-lens/dist/clients/project-diagnostics/runner-adapters/dead-code.js +0 -47
- package/node_modules/pi-lens/dist/clients/project-diagnostics/runner-adapters/gitleaks.js +0 -40
- package/node_modules/pi-lens/dist/clients/project-diagnostics/runner-adapters/govulncheck.js +0 -34
- package/node_modules/pi-lens/dist/clients/project-diagnostics/runner-adapters/jscpd.js +0 -38
- package/node_modules/pi-lens/dist/clients/project-diagnostics/runner-adapters/knip.js +0 -47
- package/node_modules/pi-lens/dist/clients/project-diagnostics/runner-adapters/madge.js +0 -48
- package/node_modules/pi-lens/dist/clients/project-diagnostics/runner-adapters/opengrep.js +0 -40
- package/node_modules/pi-lens/dist/clients/project-diagnostics/runner-adapters/runner-findings.js +0 -127
- package/node_modules/pi-lens/dist/clients/project-diagnostics/runner-adapters/trivy.js +0 -81
- package/node_modules/pi-lens/dist/clients/project-diagnostics/scanner.js +0 -520
- package/node_modules/pi-lens/dist/clients/project-diagnostics/types.js +0 -1
- package/node_modules/pi-lens/dist/clients/project-lens-config.js +0 -807
- package/node_modules/pi-lens/dist/clients/project-report.js +0 -701
- package/node_modules/pi-lens/dist/clients/project-scale.js +0 -237
- package/node_modules/pi-lens/dist/clients/project-scan-policy.js +0 -11
- package/node_modules/pi-lens/dist/clients/project-snapshot-fingerprint.js +0 -48
- package/node_modules/pi-lens/dist/clients/project-snapshot-persist-worker.js +0 -20
- package/node_modules/pi-lens/dist/clients/project-snapshot.js +0 -1653
- package/node_modules/pi-lens/dist/clients/project-trust.js +0 -181
- package/node_modules/pi-lens/dist/clients/python-environment.js +0 -217
- package/node_modules/pi-lens/dist/clients/python-provenance.js +0 -639
- package/node_modules/pi-lens/dist/clients/quiet-window-config.js +0 -47
- package/node_modules/pi-lens/dist/clients/quiet-window.js +0 -236
- package/node_modules/pi-lens/dist/clients/read-bridge.js +0 -139
- package/node_modules/pi-lens/dist/clients/read-expansion.js +0 -266
- package/node_modules/pi-lens/dist/clients/read-guard-logger.js +0 -251
- package/node_modules/pi-lens/dist/clients/read-guard-tool-lines.js +0 -1306
- package/node_modules/pi-lens/dist/clients/read-guard.js +0 -1561
- package/node_modules/pi-lens/dist/clients/recent-touches.js +0 -240
- package/node_modules/pi-lens/dist/clients/redact/secrets.js +0 -449
- package/node_modules/pi-lens/dist/clients/resource-sampler.js +0 -628
- package/node_modules/pi-lens/dist/clients/reverse-deps.js +0 -270
- package/node_modules/pi-lens/dist/clients/review-graph/builder.js +0 -5126
- package/node_modules/pi-lens/dist/clients/review-graph/format.js +0 -33
- package/node_modules/pi-lens/dist/clients/review-graph/git-identity.js +0 -163
- package/node_modules/pi-lens/dist/clients/review-graph/import-resolvers.js +0 -481
- package/node_modules/pi-lens/dist/clients/review-graph/persist-worker.js +0 -10
- package/node_modules/pi-lens/dist/clients/review-graph/query.js +0 -244
- package/node_modules/pi-lens/dist/clients/review-graph/revision-drift.js +0 -21
- package/node_modules/pi-lens/dist/clients/review-graph/service.js +0 -96
- package/node_modules/pi-lens/dist/clients/review-graph/shared-extraction-ir.js +0 -82
- package/node_modules/pi-lens/dist/clients/review-graph/symbol-id.js +0 -103
- package/node_modules/pi-lens/dist/clients/review-graph/tsconfig-paths.js +0 -299
- package/node_modules/pi-lens/dist/clients/review-graph/types.js +0 -1
- package/node_modules/pi-lens/dist/clients/review-graph/workspace-modules.js +0 -449
- package/node_modules/pi-lens/dist/clients/review-graph-logger.js +0 -81
- package/node_modules/pi-lens/dist/clients/ruff-client.js +0 -179
- package/node_modules/pi-lens/dist/clients/rules-scanner.js +0 -131
- package/node_modules/pi-lens/dist/clients/run-duration.js +0 -55
- package/node_modules/pi-lens/dist/clients/runtime-agent-end.js +0 -746
- package/node_modules/pi-lens/dist/clients/runtime-config.js +0 -77
- package/node_modules/pi-lens/dist/clients/runtime-context.js +0 -211
- package/node_modules/pi-lens/dist/clients/runtime-coordinator.js +0 -1324
- package/node_modules/pi-lens/dist/clients/runtime-session.js +0 -2485
- package/node_modules/pi-lens/dist/clients/runtime-tool-call.js +0 -1295
- package/node_modules/pi-lens/dist/clients/runtime-tool-result.js +0 -2049
- package/node_modules/pi-lens/dist/clients/runtime-turn.js +0 -3767
- package/node_modules/pi-lens/dist/clients/rust-client.js +0 -97
- package/node_modules/pi-lens/dist/clients/safe-spawn.js +0 -2357
- package/node_modules/pi-lens/dist/clients/sanitize.js +0 -286
- package/node_modules/pi-lens/dist/clients/scan-utils.js +0 -25
- package/node_modules/pi-lens/dist/clients/scratch-tree-policy.js +0 -165
- package/node_modules/pi-lens/dist/clients/search-read-registration.js +0 -94
- package/node_modules/pi-lens/dist/clients/secret-findings.js +0 -114
- package/node_modules/pi-lens/dist/clients/security-scan-client.js +0 -352
- package/node_modules/pi-lens/dist/clients/session-event-guard.js +0 -297
- package/node_modules/pi-lens/dist/clients/session-lifecycle.js +0 -484
- package/node_modules/pi-lens/dist/clients/session-start-observability.js +0 -94
- package/node_modules/pi-lens/dist/clients/session-state-store.js +0 -101
- package/node_modules/pi-lens/dist/clients/session-summary.js +0 -15
- package/node_modules/pi-lens/dist/clients/sessionstart-logger.js +0 -27
- package/node_modules/pi-lens/dist/clients/sg-runner.js +0 -876
- package/node_modules/pi-lens/dist/clients/sgconfig.js +0 -347
- package/node_modules/pi-lens/dist/clients/shared-checkout-guard.js +0 -338
- package/node_modules/pi-lens/dist/clients/single-flight.js +0 -158
- package/node_modules/pi-lens/dist/clients/situational-tool-telemetry.js +0 -108
- package/node_modules/pi-lens/dist/clients/skills-resolver.js +0 -141
- package/node_modules/pi-lens/dist/clients/slow-fs.js +0 -138
- package/node_modules/pi-lens/dist/clients/smells-rollup.js +0 -231
- package/node_modules/pi-lens/dist/clients/source-filter.js +0 -596
- package/node_modules/pi-lens/dist/clients/source-walker.js +0 -211
- package/node_modules/pi-lens/dist/clients/spawn-output-cap.js +0 -120
- package/node_modules/pi-lens/dist/clients/spawn-timeout-cooldown.js +0 -110
- package/node_modules/pi-lens/dist/clients/stale-marker.js +0 -17
- package/node_modules/pi-lens/dist/clients/startup-scan.js +0 -400
- package/node_modules/pi-lens/dist/clients/startup-timing.js +0 -130
- package/node_modules/pi-lens/dist/clients/string-utils.js +0 -33
- package/node_modules/pi-lens/dist/clients/subagent-mode.js +0 -111
- package/node_modules/pi-lens/dist/clients/symbol-containment.js +0 -24
- package/node_modules/pi-lens/dist/clients/symbol-types.js +0 -5
- package/node_modules/pi-lens/dist/clients/test-runner-client.js +0 -2507
- package/node_modules/pi-lens/dist/clients/test-runner-delivery.js +0 -287
- package/node_modules/pi-lens/dist/clients/todo-scanner.js +0 -229
- package/node_modules/pi-lens/dist/clients/tool-agreement.js +0 -423
- package/node_modules/pi-lens/dist/clients/tool-config.js +0 -249
- package/node_modules/pi-lens/dist/clients/tool-cwd.js +0 -270
- package/node_modules/pi-lens/dist/clients/tool-definition.js +0 -47
- package/node_modules/pi-lens/dist/clients/tool-event.js +0 -105
- package/node_modules/pi-lens/dist/clients/tool-policy.js +0 -2755
- package/node_modules/pi-lens/dist/clients/tool-probe.js +0 -53
- package/node_modules/pi-lens/dist/clients/tool-render.js +0 -156
- package/node_modules/pi-lens/dist/clients/tool-set-policy.js +0 -118
- package/node_modules/pi-lens/dist/clients/tree-sitter-cache.js +0 -364
- package/node_modules/pi-lens/dist/clients/tree-sitter-client.js +0 -4195
- package/node_modules/pi-lens/dist/clients/tree-sitter-logger.js +0 -100
- package/node_modules/pi-lens/dist/clients/tree-sitter-navigator.js +0 -269
- package/node_modules/pi-lens/dist/clients/tree-sitter-query-loader.js +0 -569
- package/node_modules/pi-lens/dist/clients/tree-sitter-shared.js +0 -158
- package/node_modules/pi-lens/dist/clients/tree-sitter-symbol-extractor.js +0 -1265
- package/node_modules/pi-lens/dist/clients/trivy-client.js +0 -467
- package/node_modules/pi-lens/dist/clients/tui-fit.js +0 -50
- package/node_modules/pi-lens/dist/clients/turn-context.js +0 -52
- package/node_modules/pi-lens/dist/clients/turn-end/lane.js +0 -51
- package/node_modules/pi-lens/dist/clients/turn-end/lanes/govulncheck.js +0 -112
- package/node_modules/pi-lens/dist/clients/turn-end/lanes/secrets.js +0 -204
- package/node_modules/pi-lens/dist/clients/turn-summary-render.js +0 -72
- package/node_modules/pi-lens/dist/clients/turn-summary.js +0 -132
- package/node_modules/pi-lens/dist/clients/typos-config.js +0 -29
- package/node_modules/pi-lens/dist/clients/user-notify.js +0 -51
- package/node_modules/pi-lens/dist/clients/vanished-instance-marker.js +0 -57
- package/node_modules/pi-lens/dist/clients/warm-attach.js +0 -305
- package/node_modules/pi-lens/dist/clients/widget-state.js +0 -1808
- package/node_modules/pi-lens/dist/clients/word-index-logger.js +0 -49
- package/node_modules/pi-lens/dist/clients/word-index-store.js +0 -459
- package/node_modules/pi-lens/dist/clients/word-index.js +0 -2080
- package/node_modules/pi-lens/dist/clients/workspace-topology.js +0 -443
- package/node_modules/pi-lens/dist/clients/write-ordering-guard.js +0 -65
- package/node_modules/pi-lens/dist/clients/zizmor-config.js +0 -340
- package/node_modules/pi-lens/dist/i18n.js +0 -69
- package/node_modules/pi-lens/dist/mcp/build-staleness.js +0 -124
- package/node_modules/pi-lens/dist/scripts/lib/process-scan.mjs +0 -583
- package/node_modules/pi-lens/dist/scripts/lib/skills-predicate.mjs +0 -129
- package/node_modules/pi-lens/dist/scripts/lib/web-tree-sitter-dir.mjs +0 -123
- package/node_modules/pi-lens/dist/tools/activate-tools.js +0 -87
- package/node_modules/pi-lens/dist/tools/ast-grep-outline.js +0 -137
- package/node_modules/pi-lens/dist/tools/ast-grep-replace.js +0 -244
- package/node_modules/pi-lens/dist/tools/ast-grep-search.js +0 -762
- package/node_modules/pi-lens/dist/tools/effective-config.js +0 -90
- package/node_modules/pi-lens/dist/tools/lens-diagnostic-mark.js +0 -375
- package/node_modules/pi-lens/dist/tools/lens-diagnostics.js +0 -2571
- package/node_modules/pi-lens/dist/tools/lsp-diagnostics.js +0 -1745
- package/node_modules/pi-lens/dist/tools/lsp-navigation.js +0 -1367
- package/node_modules/pi-lens/dist/tools/lsp-structured-output.js +0 -294
- package/node_modules/pi-lens/dist/tools/module-report.js +0 -382
- package/node_modules/pi-lens/dist/tools/project-report.js +0 -86
- package/node_modules/pi-lens/dist/tools/render-compact.js +0 -374
- package/node_modules/pi-lens/dist/tools/scan-progress.js +0 -53
- package/node_modules/pi-lens/dist/tools/shared.js +0 -29
- package/node_modules/pi-lens/dist/tools/symbol-search.js +0 -155
|
@@ -0,0 +1,1860 @@
|
|
|
1
|
+
import { createRequire as __pilensCreateRequire } from "node:module"; const require = __pilensCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
getWordIndexMaxFilesDerived
|
|
4
|
+
} from "./chunk-LNAKEO63.js";
|
|
5
|
+
import {
|
|
6
|
+
PathKeyedMap
|
|
7
|
+
} from "./chunk-Z3CCVDUB.js";
|
|
8
|
+
import {
|
|
9
|
+
createSingleFlight
|
|
10
|
+
} from "./chunk-BW5KFIQC.js";
|
|
11
|
+
import {
|
|
12
|
+
createDeadline,
|
|
13
|
+
forEachCooperatively,
|
|
14
|
+
yieldIfOverBudget
|
|
15
|
+
} from "./chunk-QYF5S6P6.js";
|
|
16
|
+
import {
|
|
17
|
+
KIND_EXTENSIONS
|
|
18
|
+
} from "./chunk-5ZEJHV35.js";
|
|
19
|
+
import {
|
|
20
|
+
isTestFileName
|
|
21
|
+
} from "./chunk-DQ2NZ7C4.js";
|
|
22
|
+
import {
|
|
23
|
+
incrementDegradationCount
|
|
24
|
+
} from "./chunk-N3YQJI6O.js";
|
|
25
|
+
import {
|
|
26
|
+
createNdjsonLogger,
|
|
27
|
+
getGlobalPiLensLogDir,
|
|
28
|
+
getMaxLogSizeMB,
|
|
29
|
+
isTestMode
|
|
30
|
+
} from "./chunk-UK3CMEAL.js";
|
|
31
|
+
import {
|
|
32
|
+
isAtOrAboveHomeDir,
|
|
33
|
+
normalizeEphemeralMapKey,
|
|
34
|
+
normalizeFilePath
|
|
35
|
+
} from "./chunk-Q5U6FMDI.js";
|
|
36
|
+
|
|
37
|
+
// dist/clients/word-index.js
|
|
38
|
+
import * as fs from "node:fs";
|
|
39
|
+
import * as path2 from "node:path";
|
|
40
|
+
|
|
41
|
+
// dist/clients/persist-debounce.js
|
|
42
|
+
function createDebounceScheduler(args) {
|
|
43
|
+
const { write, debounceMs } = args;
|
|
44
|
+
const pending = /* @__PURE__ */ new Map();
|
|
45
|
+
const timers = /* @__PURE__ */ new Map();
|
|
46
|
+
function flush(key) {
|
|
47
|
+
const payload = pending.get(key);
|
|
48
|
+
if (payload === void 0)
|
|
49
|
+
return;
|
|
50
|
+
pending.delete(key);
|
|
51
|
+
const timer = timers.get(key);
|
|
52
|
+
if (timer) {
|
|
53
|
+
clearTimeout(timer);
|
|
54
|
+
timers.delete(key);
|
|
55
|
+
}
|
|
56
|
+
write(key, payload);
|
|
57
|
+
}
|
|
58
|
+
function flushAll() {
|
|
59
|
+
for (const key of pending.keys())
|
|
60
|
+
flush(key);
|
|
61
|
+
}
|
|
62
|
+
function schedule(key, payload) {
|
|
63
|
+
pending.set(key, payload);
|
|
64
|
+
const debounce = debounceMs();
|
|
65
|
+
const existing = timers.get(key);
|
|
66
|
+
if (existing)
|
|
67
|
+
clearTimeout(existing);
|
|
68
|
+
if (debounce === 0) {
|
|
69
|
+
flush(key);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const timer = setTimeout(() => flush(key), debounce);
|
|
73
|
+
if (typeof timer.unref === "function")
|
|
74
|
+
timer.unref();
|
|
75
|
+
timers.set(key, timer);
|
|
76
|
+
}
|
|
77
|
+
return { schedule, flush, flushAll };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// dist/clients/word-index-store.js
|
|
81
|
+
var WORD_POSTING_ENTRY_BYTES = 8;
|
|
82
|
+
var WORD_POSTING_LIST_OVERHEAD_BYTES = 160;
|
|
83
|
+
var DEFAULT_POSTING_CAPACITY_ENTRIES = 2;
|
|
84
|
+
var WordPostingList = class _WordPostingList {
|
|
85
|
+
/**
|
|
86
|
+
* The `Int32Array` these postings live in. Either private to this list, or —
|
|
87
|
+
* after {@link compactPostingsIntoArena} — a SHARED arena in which this list
|
|
88
|
+
* owns the half-open lane range `[laneStart, laneStart + capacityEntries*2)`.
|
|
89
|
+
* Held as an offset rather than a `subarray` view on purpose: 37,500 views
|
|
90
|
+
* cost 2.5 MB of `JSTypedArray` headers on this repository's corpus, and two
|
|
91
|
+
* integer fields are free by comparison.
|
|
92
|
+
*/
|
|
93
|
+
lanes;
|
|
94
|
+
laneStart = 0;
|
|
95
|
+
capacityEntries;
|
|
96
|
+
entryCount = 0;
|
|
97
|
+
/**
|
|
98
|
+
* The canonical instance of this list’s token.
|
|
99
|
+
*
|
|
100
|
+
* The tokenizer allocates a FRESH string for every occurrence
|
|
101
|
+
* (`toLowerCase()`, `split()`), and a `Map` key is not addressable, so
|
|
102
|
+
* every structure that stores a token name would otherwise hold its own
|
|
103
|
+
* copy. The forward index does exactly that, once per (document, token):
|
|
104
|
+
* 536,978 separate strings, measured at 17 MB on this repository’s corpus.
|
|
105
|
+
* Holding the first-seen instance here gives every later writer one
|
|
106
|
+
* addressable canonical string to point at, with no second interning map
|
|
107
|
+
* to keep in step with the postings map.
|
|
108
|
+
*/
|
|
109
|
+
token;
|
|
110
|
+
constructor(token, capacityEntries = DEFAULT_POSTING_CAPACITY_ENTRIES) {
|
|
111
|
+
this.token = token;
|
|
112
|
+
this.capacityEntries = Math.max(1, capacityEntries);
|
|
113
|
+
this.lanes = new Int32Array(this.capacityEntries * 2);
|
|
114
|
+
}
|
|
115
|
+
/** Number of postings held. */
|
|
116
|
+
get length() {
|
|
117
|
+
return this.entryCount;
|
|
118
|
+
}
|
|
119
|
+
/** This list's share of backing store, its own spare capacity included. */
|
|
120
|
+
get byteLength() {
|
|
121
|
+
return this.capacityEntries * WORD_POSTING_ENTRY_BYTES;
|
|
122
|
+
}
|
|
123
|
+
fileIdAt(entry) {
|
|
124
|
+
return this.lanes[this.laneStart + entry * 2];
|
|
125
|
+
}
|
|
126
|
+
lineAt(entry) {
|
|
127
|
+
return this.lanes[this.laneStart + entry * 2 + 1];
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Grow so at least `entries` postings fit without another reallocation. The
|
|
131
|
+
* grown store is always PRIVATE: a list that outgrows its arena slice must
|
|
132
|
+
* not write past it into the next token's postings.
|
|
133
|
+
*
|
|
134
|
+
* Returns `true` when it allocated a fresh private store, so the index can
|
|
135
|
+
* keep an O(1) running tally of distinct backing stores instead of rebuilding
|
|
136
|
+
* a `Set` over the whole vocabulary on every edit (#2117).
|
|
137
|
+
*/
|
|
138
|
+
reserve(entries) {
|
|
139
|
+
if (entries <= this.capacityEntries)
|
|
140
|
+
return false;
|
|
141
|
+
const grown = new Int32Array(entries * 2);
|
|
142
|
+
grown.set(this.lanes.subarray(this.laneStart, this.laneStart + this.entryCount * 2));
|
|
143
|
+
this.lanes = grown;
|
|
144
|
+
this.laneStart = 0;
|
|
145
|
+
this.capacityEntries = entries;
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
push(fileId, line) {
|
|
149
|
+
if (this.entryCount === this.capacityEntries) {
|
|
150
|
+
this.reserve(Math.max(DEFAULT_POSTING_CAPACITY_ENTRIES, this.capacityEntries * 2));
|
|
151
|
+
}
|
|
152
|
+
const at = this.laneStart + this.entryCount * 2;
|
|
153
|
+
this.lanes[at] = fileId;
|
|
154
|
+
this.lanes[at + 1] = line;
|
|
155
|
+
this.entryCount += 1;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Re-home this list's lanes into `arena` at lane index `offset`, returning
|
|
159
|
+
* the offset past the range it now owns. Used only by
|
|
160
|
+
* {@link compactPostingsIntoArena}, which sizes the arena from the same
|
|
161
|
+
* entry counts, so the range always fits.
|
|
162
|
+
*/
|
|
163
|
+
adoptArena(arena, offset) {
|
|
164
|
+
const width = this.entryCount * 2;
|
|
165
|
+
for (let i = 0; i < width; i += 1) {
|
|
166
|
+
arena[offset + i] = this.lanes[this.laneStart + i];
|
|
167
|
+
}
|
|
168
|
+
this.lanes = arena;
|
|
169
|
+
this.laneStart = offset;
|
|
170
|
+
this.capacityEntries = this.entryCount;
|
|
171
|
+
return offset + width;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* A new list with every posting for `fileId` removed, exactly sized. Returns
|
|
175
|
+
* a fresh list rather than mutating in place because the incremental refresh
|
|
176
|
+
* stages removals off to the side and publishes them without an await, and
|
|
177
|
+
* because an untouched token's list must keep its reference identity.
|
|
178
|
+
*/
|
|
179
|
+
withoutFile(fileId) {
|
|
180
|
+
let surviving = 0;
|
|
181
|
+
for (let i = 0; i < this.entryCount; i += 1) {
|
|
182
|
+
if (this.fileIdAt(i) !== fileId)
|
|
183
|
+
surviving += 1;
|
|
184
|
+
}
|
|
185
|
+
const next = new _WordPostingList(this.token, Math.max(1, surviving));
|
|
186
|
+
for (let i = 0; i < this.entryCount; i += 1) {
|
|
187
|
+
if (this.fileIdAt(i) === fileId)
|
|
188
|
+
continue;
|
|
189
|
+
next.push(this.fileIdAt(i), this.lineAt(i));
|
|
190
|
+
}
|
|
191
|
+
return next;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* The backing store these lanes live in. Exposed so a memory guard can prove
|
|
195
|
+
* the arena is shared rather than inferring it from a heap delta; nothing in
|
|
196
|
+
* the index reads it.
|
|
197
|
+
*/
|
|
198
|
+
get backingStore() {
|
|
199
|
+
return this.lanes;
|
|
200
|
+
}
|
|
201
|
+
/** Build a list from flat `[fileId, line, …]` lanes, exactly sized. */
|
|
202
|
+
static fromLanes(token, lanes) {
|
|
203
|
+
const entries = Math.floor(lanes.length / 2);
|
|
204
|
+
const list = new _WordPostingList(token, Math.max(1, entries));
|
|
205
|
+
for (let i = 0; i < entries; i += 1) {
|
|
206
|
+
list.push(lanes[i * 2], lanes[i * 2 + 1]);
|
|
207
|
+
}
|
|
208
|
+
return list;
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
function compactPostingsIntoArena(postings) {
|
|
212
|
+
let lanes = 0;
|
|
213
|
+
for (const list of postings.values())
|
|
214
|
+
lanes += list.length * 2;
|
|
215
|
+
if (lanes === 0)
|
|
216
|
+
return;
|
|
217
|
+
const arena = new Int32Array(lanes);
|
|
218
|
+
let offset = 0;
|
|
219
|
+
for (const list of postings.values())
|
|
220
|
+
offset = list.adoptArena(arena, offset);
|
|
221
|
+
}
|
|
222
|
+
async function compactPostingsIntoArenaCooperatively(postings, options) {
|
|
223
|
+
const planned = [];
|
|
224
|
+
let lanes = 0;
|
|
225
|
+
for (const [token, list] of postings) {
|
|
226
|
+
const width = list.length * 2;
|
|
227
|
+
planned.push({ token, list, width });
|
|
228
|
+
lanes += width;
|
|
229
|
+
}
|
|
230
|
+
if (lanes === 0)
|
|
231
|
+
return;
|
|
232
|
+
const arena = new Int32Array(lanes);
|
|
233
|
+
let offset = 0;
|
|
234
|
+
const deadline = options?.deadline ?? createDeadline(8);
|
|
235
|
+
for (const plan of planned) {
|
|
236
|
+
if (postings.get(plan.token) === plan.list && plan.list.length * 2 === plan.width && offset + plan.width <= arena.length) {
|
|
237
|
+
offset = plan.list.adoptArena(arena, offset);
|
|
238
|
+
}
|
|
239
|
+
if (deadline.expired()) {
|
|
240
|
+
await options?.beforeYield?.();
|
|
241
|
+
await yieldIfOverBudget(deadline);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
function countPostingBackingStores(postings) {
|
|
246
|
+
const stores = /* @__PURE__ */ new Set();
|
|
247
|
+
for (const list of postings.values())
|
|
248
|
+
stores.add(list.backingStore);
|
|
249
|
+
return stores.size;
|
|
250
|
+
}
|
|
251
|
+
function countPostingEntries(store) {
|
|
252
|
+
let count = 0;
|
|
253
|
+
for (const list of store.postings.values())
|
|
254
|
+
count += list.length;
|
|
255
|
+
return count;
|
|
256
|
+
}
|
|
257
|
+
function estimateWordIndexStoreBytes(store) {
|
|
258
|
+
let bytes = 0;
|
|
259
|
+
const backingStores = /* @__PURE__ */ new Set();
|
|
260
|
+
for (const list of store.postings.values()) {
|
|
261
|
+
backingStores.add(list.backingStore);
|
|
262
|
+
bytes += WORD_POSTING_LIST_OVERHEAD_BYTES;
|
|
263
|
+
}
|
|
264
|
+
for (const backingStore of backingStores)
|
|
265
|
+
bytes += backingStore.byteLength;
|
|
266
|
+
for (const entry of store.forward?.values() ?? []) {
|
|
267
|
+
bytes += entry.estimatedBytes;
|
|
268
|
+
}
|
|
269
|
+
return bytes;
|
|
270
|
+
}
|
|
271
|
+
var WordForwardEntry = class _WordForwardEntry {
|
|
272
|
+
tokenNames;
|
|
273
|
+
lineCounts;
|
|
274
|
+
constructor(tokenNames, lineCounts) {
|
|
275
|
+
this.tokenNames = tokenNames;
|
|
276
|
+
this.lineCounts = lineCounts;
|
|
277
|
+
}
|
|
278
|
+
/** Distinct tokens recorded for this document. */
|
|
279
|
+
get size() {
|
|
280
|
+
return this.tokenNames.length;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Distinct-line count for `token`, or `undefined`. Linear in the document's
|
|
284
|
+
* token count: the hot paths iterate this entry, they do not probe it, so a
|
|
285
|
+
* hash table would cost 40 bytes an entry to serve lookups nobody makes.
|
|
286
|
+
*/
|
|
287
|
+
get(token) {
|
|
288
|
+
const at = this.tokenNames.indexOf(token);
|
|
289
|
+
return at === -1 ? void 0 : this.lineCounts[at];
|
|
290
|
+
}
|
|
291
|
+
keys() {
|
|
292
|
+
return this.tokenNames[Symbol.iterator]();
|
|
293
|
+
}
|
|
294
|
+
*entries() {
|
|
295
|
+
for (let i = 0; i < this.tokenNames.length; i += 1) {
|
|
296
|
+
yield [this.tokenNames[i], this.lineCounts[i]];
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
[Symbol.iterator]() {
|
|
300
|
+
return this.entries();
|
|
301
|
+
}
|
|
302
|
+
/** Estimated resident bytes: packed lanes plus fixed headers. */
|
|
303
|
+
get estimatedBytes() {
|
|
304
|
+
return this.tokenNames.length * WORD_FORWARD_ENTRY_BYTES + WORD_POSTING_LIST_OVERHEAD_BYTES;
|
|
305
|
+
}
|
|
306
|
+
/** Pack a tokenizer tally. Insertion order is preserved. */
|
|
307
|
+
static fromTally(tally) {
|
|
308
|
+
const tokenNames = [];
|
|
309
|
+
tokenNames.length = tally.size;
|
|
310
|
+
const lineCounts = new Int32Array(tally.size);
|
|
311
|
+
let i = 0;
|
|
312
|
+
for (const [token, count] of tally) {
|
|
313
|
+
tokenNames[i] = token;
|
|
314
|
+
lineCounts[i] = count;
|
|
315
|
+
i += 1;
|
|
316
|
+
}
|
|
317
|
+
return new _WordForwardEntry(tokenNames, lineCounts);
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
var WORD_FORWARD_ENTRY_BYTES = 8;
|
|
321
|
+
var WordIndexFileTable = class {
|
|
322
|
+
idByKey = /* @__PURE__ */ new Map();
|
|
323
|
+
pathById = [];
|
|
324
|
+
freeIds = [];
|
|
325
|
+
/** Live file count. */
|
|
326
|
+
get size() {
|
|
327
|
+
return this.idByKey.size;
|
|
328
|
+
}
|
|
329
|
+
/** Width of the id space, live plus recycled. Bounded growth is the point. */
|
|
330
|
+
get idSpaceWidth() {
|
|
331
|
+
return this.pathById.length;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Id for `key`, allocating one on first sight. First writer wins on the
|
|
335
|
+
* display path, matching the interning the boxed representation had: a
|
|
336
|
+
* second walk spelling of the same file reuses the first spelling's id and
|
|
337
|
+
* does not re-write the stored display path.
|
|
338
|
+
*/
|
|
339
|
+
intern(key, displayPath) {
|
|
340
|
+
const existing = this.idByKey.get(key);
|
|
341
|
+
if (existing !== void 0)
|
|
342
|
+
return existing;
|
|
343
|
+
const id = this.freeIds.pop() ?? this.pathById.length;
|
|
344
|
+
this.pathById[id] = displayPath;
|
|
345
|
+
this.idByKey.set(key, id);
|
|
346
|
+
return id;
|
|
347
|
+
}
|
|
348
|
+
idFor(key) {
|
|
349
|
+
return this.idByKey.get(key);
|
|
350
|
+
}
|
|
351
|
+
pathFor(id) {
|
|
352
|
+
return this.pathById[id];
|
|
353
|
+
}
|
|
354
|
+
/** Drop `key` and recycle its id. Returns the freed id, or `undefined`. */
|
|
355
|
+
release(key) {
|
|
356
|
+
const id = this.idByKey.get(key);
|
|
357
|
+
if (id === void 0)
|
|
358
|
+
return void 0;
|
|
359
|
+
this.idByKey.delete(key);
|
|
360
|
+
this.pathById[id] = void 0;
|
|
361
|
+
this.freeIds.push(id);
|
|
362
|
+
return id;
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
// dist/clients/word-index-logger.js
|
|
367
|
+
import * as path from "node:path";
|
|
368
|
+
var WORD_INDEX_LOG_FILE = path.join(getGlobalPiLensLogDir(), "word-index.log");
|
|
369
|
+
var writer = createNdjsonLogger({
|
|
370
|
+
filePath: WORD_INDEX_LOG_FILE,
|
|
371
|
+
maxBytes: getMaxLogSizeMB() * 1024 * 1024
|
|
372
|
+
});
|
|
373
|
+
function logWordIndex(entry) {
|
|
374
|
+
if (isTestMode()) {
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
writer.log({
|
|
378
|
+
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
379
|
+
...entry,
|
|
380
|
+
cwd: normalizeFilePath(entry.cwd)
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
// dist/clients/word-index.js
|
|
385
|
+
var wordIndexKey = normalizeEphemeralMapKey;
|
|
386
|
+
var STOPWORDS = /* @__PURE__ */ new Set([
|
|
387
|
+
"the",
|
|
388
|
+
"and",
|
|
389
|
+
"for",
|
|
390
|
+
"let",
|
|
391
|
+
"var",
|
|
392
|
+
"const",
|
|
393
|
+
"function",
|
|
394
|
+
"return",
|
|
395
|
+
"if",
|
|
396
|
+
"else",
|
|
397
|
+
"import",
|
|
398
|
+
"export",
|
|
399
|
+
"from",
|
|
400
|
+
"class",
|
|
401
|
+
"interface",
|
|
402
|
+
"type",
|
|
403
|
+
"enum",
|
|
404
|
+
"new",
|
|
405
|
+
"this",
|
|
406
|
+
"self",
|
|
407
|
+
"void",
|
|
408
|
+
"null",
|
|
409
|
+
"true",
|
|
410
|
+
"false",
|
|
411
|
+
"async",
|
|
412
|
+
"await",
|
|
413
|
+
"public",
|
|
414
|
+
"private",
|
|
415
|
+
"protected",
|
|
416
|
+
"static",
|
|
417
|
+
"def",
|
|
418
|
+
"fn",
|
|
419
|
+
"func",
|
|
420
|
+
"struct",
|
|
421
|
+
"impl",
|
|
422
|
+
"pub",
|
|
423
|
+
"use",
|
|
424
|
+
"mod",
|
|
425
|
+
"in",
|
|
426
|
+
"of",
|
|
427
|
+
"as",
|
|
428
|
+
"is",
|
|
429
|
+
"not",
|
|
430
|
+
"with"
|
|
431
|
+
]);
|
|
432
|
+
var VENDOR_DIR_RE = /(^|[\\/])(?:tests?|__tests__|spec|specs|__mocks__|vendor|node_modules|examples?|fixtures?|\.git|dist|build|coverage)([\\/]|$)/i;
|
|
433
|
+
var DOC_FILE_RE = /\.(?:md|mdx|markdown|json|json5|jsonc|txt|rst|lock|ya?ml|toml|csv)$/i;
|
|
434
|
+
var TEST_VENDOR_PENALTY = 0.3;
|
|
435
|
+
var DOC_FILE_PENALTY = 0.5;
|
|
436
|
+
var BM25_K1 = 1.2;
|
|
437
|
+
var BM25_B = 0.75;
|
|
438
|
+
function isTestOrVendor(file) {
|
|
439
|
+
return isTestFileName(file) || VENDOR_DIR_RE.test(file);
|
|
440
|
+
}
|
|
441
|
+
function isDocFile(file) {
|
|
442
|
+
return DOC_FILE_RE.test(file);
|
|
443
|
+
}
|
|
444
|
+
function splitIdentifier(identifier) {
|
|
445
|
+
const parts = /* @__PURE__ */ new Set();
|
|
446
|
+
const whole = identifier.toLowerCase();
|
|
447
|
+
if (whole.length >= 2 && !STOPWORDS.has(whole))
|
|
448
|
+
parts.add(whole);
|
|
449
|
+
for (const chunk of identifier.split(/[^A-Za-z0-9]+/)) {
|
|
450
|
+
if (!chunk)
|
|
451
|
+
continue;
|
|
452
|
+
const spaced = chunk.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[A-Z](?=[A-Z][a-z])/g, "$& ").replace(/([A-Za-z])([0-9])/g, "$1 $2").replace(/([0-9])([A-Za-z])/g, "$1 $2");
|
|
453
|
+
for (const sub of spaced.split(/\s+/)) {
|
|
454
|
+
const token = sub.toLowerCase();
|
|
455
|
+
if (token.length >= 2 && !STOPWORDS.has(token))
|
|
456
|
+
parts.add(token);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
return [...parts];
|
|
460
|
+
}
|
|
461
|
+
function tokenizeLine(line) {
|
|
462
|
+
const tokens = [];
|
|
463
|
+
const matches = line.match(/[A-Za-z_$][A-Za-z0-9_$]*/g);
|
|
464
|
+
if (!matches)
|
|
465
|
+
return tokens;
|
|
466
|
+
for (const match of matches) {
|
|
467
|
+
for (const token of splitIdentifier(match))
|
|
468
|
+
tokens.push(token);
|
|
469
|
+
}
|
|
470
|
+
return tokens;
|
|
471
|
+
}
|
|
472
|
+
var WORD_INDEX_BUILD_YIELD_BUDGET_MS = 8;
|
|
473
|
+
var WORD_INDEX_LONG_LINE_YIELD_CHARS = 4096;
|
|
474
|
+
function createEmptyWordIndex(truncated) {
|
|
475
|
+
return {
|
|
476
|
+
postings: /* @__PURE__ */ new Map(),
|
|
477
|
+
fileTable: new WordIndexFileTable(),
|
|
478
|
+
docLengths: new PathKeyedMap(wordIndexKey),
|
|
479
|
+
totalTokens: 0,
|
|
480
|
+
docCount: 0,
|
|
481
|
+
truncated,
|
|
482
|
+
forward: new PathKeyedMap(wordIndexKey),
|
|
483
|
+
fileMtimes: new PathKeyedMap(wordIndexKey),
|
|
484
|
+
fileSizes: new PathKeyedMap(wordIndexKey),
|
|
485
|
+
replacementStats: { count: 0, totalMs: 0, maxMs: 0 },
|
|
486
|
+
dirtyFiles: /* @__PURE__ */ new Set(),
|
|
487
|
+
postingStoreCount: 0,
|
|
488
|
+
recompactFlight: createSingleFlight()
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
function countWordIndexPostingEntries(index) {
|
|
492
|
+
return countPostingEntries(index);
|
|
493
|
+
}
|
|
494
|
+
function estimateWordIndexResidentBytes(index) {
|
|
495
|
+
return estimateWordIndexStoreBytes(index);
|
|
496
|
+
}
|
|
497
|
+
function recordOrphanWordIndexFileId(fileId, token, seam) {
|
|
498
|
+
incrementDegradationCount({
|
|
499
|
+
kind: "word-index-orphan-file-id",
|
|
500
|
+
subject: `fileId:${fileId}`,
|
|
501
|
+
reason: `${seam} dropped a posting for token "${token}": the file table has no path for this id`
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
function wordIndexPostingHits(index, token) {
|
|
505
|
+
const list = index.postings.get(token);
|
|
506
|
+
if (!list)
|
|
507
|
+
return [];
|
|
508
|
+
const hits = [];
|
|
509
|
+
for (let i = 0; i < list.length; i += 1) {
|
|
510
|
+
const fileId = list.fileIdAt(i);
|
|
511
|
+
const file = index.fileTable.pathFor(fileId);
|
|
512
|
+
if (file === void 0) {
|
|
513
|
+
recordOrphanWordIndexFileId(fileId, token, "decode");
|
|
514
|
+
continue;
|
|
515
|
+
}
|
|
516
|
+
hits.push({ file, line: list.lineAt(i) });
|
|
517
|
+
}
|
|
518
|
+
return hits;
|
|
519
|
+
}
|
|
520
|
+
function compactWordIndexPostings(index) {
|
|
521
|
+
compactPostingsIntoArena(index.postings);
|
|
522
|
+
index.postingStoreCount = countPostingBackingStores(index.postings);
|
|
523
|
+
}
|
|
524
|
+
function notePostingStoresAllocated(index, count) {
|
|
525
|
+
index.postingStoreCount = (index.postingStoreCount ?? 0) + count;
|
|
526
|
+
}
|
|
527
|
+
var WORD_INDEX_RECOMPACT_STORE_FLOOR = 64;
|
|
528
|
+
var WORD_INDEX_RECOMPACT_STORE_FRACTION = 0.1;
|
|
529
|
+
function wordIndexRecompactThreshold(index) {
|
|
530
|
+
return Math.max(WORD_INDEX_RECOMPACT_STORE_FLOOR, Math.floor(index.postings.size * WORD_INDEX_RECOMPACT_STORE_FRACTION));
|
|
531
|
+
}
|
|
532
|
+
async function recompactWordIndexPostingsIfNeeded(index, root) {
|
|
533
|
+
const threshold = wordIndexRecompactThreshold(index);
|
|
534
|
+
const beforeStores = countPostingBackingStores(index.postings);
|
|
535
|
+
if (beforeStores <= threshold) {
|
|
536
|
+
index.postingStoreCount = beforeStores;
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
const beforeBytes = estimateWordIndexResidentBytes(index);
|
|
540
|
+
await compactPostingsIntoArenaCooperatively(index.postings);
|
|
541
|
+
const afterStores = countPostingBackingStores(index.postings);
|
|
542
|
+
index.postingStoreCount = afterStores;
|
|
543
|
+
const afterBytes = estimateWordIndexResidentBytes(index);
|
|
544
|
+
const firstForRoot = incrementDegradationCount({
|
|
545
|
+
kind: "word-index-arena-recompact",
|
|
546
|
+
subject: path2.resolve(root),
|
|
547
|
+
reason: `arena store threshold ${threshold} exceeded`,
|
|
548
|
+
metadata: { beforeBytes, afterBytes, beforeStores, afterStores }
|
|
549
|
+
});
|
|
550
|
+
if (firstForRoot) {
|
|
551
|
+
logWordIndex({
|
|
552
|
+
phase: "incremental_refresh",
|
|
553
|
+
cwd: path2.resolve(root),
|
|
554
|
+
trigger: "incremental_refresh",
|
|
555
|
+
reason: `arena_recompact beforeBytes=${beforeBytes} afterBytes=${afterBytes} beforeStores=${beforeStores} afterStores=${afterStores}`
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
function enqueueWordIndexRecompact(index, root) {
|
|
560
|
+
if ((index.postingStoreCount ?? 0) <= wordIndexRecompactThreshold(index)) {
|
|
561
|
+
return Promise.resolve();
|
|
562
|
+
}
|
|
563
|
+
const flight = index.recompactFlight ??= createSingleFlight();
|
|
564
|
+
return flight.run("recompact", () => enqueueAsyncWordIndexOperation(index, () => recompactWordIndexPostingsIfNeeded(index, root)));
|
|
565
|
+
}
|
|
566
|
+
function scheduleWordIndexRecompact(index, filePath) {
|
|
567
|
+
void enqueueWordIndexRecompact(index, path2.dirname(filePath));
|
|
568
|
+
}
|
|
569
|
+
async function flushWordIndexRecompactionsForTests(index) {
|
|
570
|
+
await (asyncWordIndexOperations.get(index) ?? Promise.resolve());
|
|
571
|
+
}
|
|
572
|
+
function recordWordIndexReplacement(index, startedAt) {
|
|
573
|
+
const stats = index.replacementStats ?? { count: 0, totalMs: 0, maxMs: 0 };
|
|
574
|
+
const durationMs = Math.max(0, Date.now() - startedAt);
|
|
575
|
+
stats.count += 1;
|
|
576
|
+
stats.totalMs += durationMs;
|
|
577
|
+
stats.maxMs = Math.max(stats.maxMs, durationMs);
|
|
578
|
+
index.replacementStats = stats;
|
|
579
|
+
}
|
|
580
|
+
function internWordIndexFile(index, filePath) {
|
|
581
|
+
return index.fileTable.intern(wordIndexKey(filePath), filePath);
|
|
582
|
+
}
|
|
583
|
+
function appendWordIndexPostings(index, filePath, perTokenHits) {
|
|
584
|
+
const fileId = internWordIndexFile(index, filePath);
|
|
585
|
+
const tokenLineCounts = /* @__PURE__ */ new Map();
|
|
586
|
+
for (const [token, lineNumbers] of perTokenHits) {
|
|
587
|
+
let list = index.postings.get(token);
|
|
588
|
+
if (list) {
|
|
589
|
+
if (list.reserve(list.length + lineNumbers.length)) {
|
|
590
|
+
notePostingStoresAllocated(index, 1);
|
|
591
|
+
}
|
|
592
|
+
} else {
|
|
593
|
+
list = new WordPostingList(token, lineNumbers.length);
|
|
594
|
+
index.postings.set(token, list);
|
|
595
|
+
notePostingStoresAllocated(index, 1);
|
|
596
|
+
}
|
|
597
|
+
tokenLineCounts.set(list.token, lineNumbers.length);
|
|
598
|
+
for (const line of lineNumbers)
|
|
599
|
+
list.push(fileId, line);
|
|
600
|
+
}
|
|
601
|
+
return tokenLineCounts;
|
|
602
|
+
}
|
|
603
|
+
function commitWordIndexDocumentReplacement(index, doc, perTokenHits, docLength, startedAt) {
|
|
604
|
+
const tokenLineCounts = appendWordIndexPostings(index, doc.path, perTokenHits);
|
|
605
|
+
index.docLengths.set(doc.path, docLength);
|
|
606
|
+
index.forward.set(doc.path, WordForwardEntry.fromTally(tokenLineCounts));
|
|
607
|
+
index.fileMtimes.set(doc.path, -1);
|
|
608
|
+
index.fileSizes.set(doc.path, Buffer.byteLength(doc.content, "utf-8"));
|
|
609
|
+
index.dirtyFiles?.add(wordIndexKey(doc.path));
|
|
610
|
+
index.totalTokens += docLength;
|
|
611
|
+
index.docCount += 1;
|
|
612
|
+
recordWordIndexReplacement(index, startedAt);
|
|
613
|
+
}
|
|
614
|
+
function indexWordLine(index, fileId, line, lineNumber, tokenLineCounts) {
|
|
615
|
+
const lineTokens = tokenizeLine(line);
|
|
616
|
+
const seenOnLine = /* @__PURE__ */ new Set();
|
|
617
|
+
for (const token of lineTokens) {
|
|
618
|
+
if (seenOnLine.has(token))
|
|
619
|
+
continue;
|
|
620
|
+
seenOnLine.add(token);
|
|
621
|
+
let list = index.postings.get(token);
|
|
622
|
+
if (!list) {
|
|
623
|
+
list = new WordPostingList(token, 1);
|
|
624
|
+
index.postings.set(token, list);
|
|
625
|
+
}
|
|
626
|
+
list.push(fileId, lineNumber);
|
|
627
|
+
const canonical = list.token;
|
|
628
|
+
tokenLineCounts.set(canonical, (tokenLineCounts.get(canonical) ?? 0) + 1);
|
|
629
|
+
}
|
|
630
|
+
return lineTokens.length;
|
|
631
|
+
}
|
|
632
|
+
function finishWordIndexDocument(index, doc, docLength, tokenLineCounts) {
|
|
633
|
+
index.docLengths.set(doc.path, docLength);
|
|
634
|
+
index.forward?.set(doc.path, WordForwardEntry.fromTally(tokenLineCounts));
|
|
635
|
+
index.fileMtimes.set(doc.path, doc.mtimeMs ?? 0);
|
|
636
|
+
index.fileSizes.set(doc.path, doc.size ?? Buffer.byteLength(doc.content, "utf-8"));
|
|
637
|
+
index.dirtyFiles?.add(wordIndexKey(doc.path));
|
|
638
|
+
index.totalTokens += docLength;
|
|
639
|
+
index.docCount += 1;
|
|
640
|
+
}
|
|
641
|
+
function indexWordDocument(index, doc) {
|
|
642
|
+
const fileId = internWordIndexFile(index, doc.path);
|
|
643
|
+
const lines = doc.content.split(/\r?\n/);
|
|
644
|
+
const tokenLineCounts = /* @__PURE__ */ new Map();
|
|
645
|
+
let docLength = 0;
|
|
646
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
647
|
+
docLength += indexWordLine(index, fileId, lines[i], i + 1, tokenLineCounts);
|
|
648
|
+
}
|
|
649
|
+
finishWordIndexDocument(index, doc, docLength, tokenLineCounts);
|
|
650
|
+
}
|
|
651
|
+
function buildWordIndex(files) {
|
|
652
|
+
const index = createEmptyWordIndex(files.truncated ?? false);
|
|
653
|
+
for (const doc of files)
|
|
654
|
+
indexWordDocument(index, doc);
|
|
655
|
+
compactWordIndexPostings(index);
|
|
656
|
+
return index;
|
|
657
|
+
}
|
|
658
|
+
async function buildWordIndexAsync(files, shouldContinue = () => true) {
|
|
659
|
+
const index = createEmptyWordIndex(files.truncated ?? false);
|
|
660
|
+
const deadline = createDeadline(WORD_INDEX_BUILD_YIELD_BUDGET_MS);
|
|
661
|
+
for (const doc of files) {
|
|
662
|
+
if (!shouldContinue())
|
|
663
|
+
throw new Error("word index build superseded");
|
|
664
|
+
const fileId = internWordIndexFile(index, doc.path);
|
|
665
|
+
const lines = doc.content.split(/\r?\n/);
|
|
666
|
+
const tokenLineCounts = /* @__PURE__ */ new Map();
|
|
667
|
+
let docLength = 0;
|
|
668
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
669
|
+
const line = lines[i];
|
|
670
|
+
docLength += indexWordLine(index, fileId, line, i + 1, tokenLineCounts);
|
|
671
|
+
if (line.length >= WORD_INDEX_LONG_LINE_YIELD_CHARS || deadline.expired()) {
|
|
672
|
+
await yieldIfOverBudget(deadline);
|
|
673
|
+
if (!shouldContinue())
|
|
674
|
+
throw new Error("word index build superseded");
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
finishWordIndexDocument(index, doc, docLength, tokenLineCounts);
|
|
678
|
+
if (deadline.expired() && await yieldIfOverBudget(deadline)) {
|
|
679
|
+
if (!shouldContinue())
|
|
680
|
+
throw new Error("word index build superseded");
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
compactWordIndexPostings(index);
|
|
684
|
+
return index;
|
|
685
|
+
}
|
|
686
|
+
function removeWordIndexDocument(index, filePath) {
|
|
687
|
+
if (!index.forward)
|
|
688
|
+
return false;
|
|
689
|
+
const tokenLineCounts = index.forward.get(filePath);
|
|
690
|
+
if (!tokenLineCounts)
|
|
691
|
+
return false;
|
|
692
|
+
const removedKey = wordIndexKey(filePath);
|
|
693
|
+
const removedId = index.fileTable.idFor(removedKey);
|
|
694
|
+
if (removedId === void 0)
|
|
695
|
+
return false;
|
|
696
|
+
for (const token of tokenLineCounts.keys()) {
|
|
697
|
+
const list = index.postings.get(token);
|
|
698
|
+
if (!list)
|
|
699
|
+
continue;
|
|
700
|
+
const next = list.withoutFile(removedId);
|
|
701
|
+
if (next.length > 0) {
|
|
702
|
+
index.postings.set(token, next);
|
|
703
|
+
notePostingStoresAllocated(index, 1);
|
|
704
|
+
} else
|
|
705
|
+
index.postings.delete(token);
|
|
706
|
+
}
|
|
707
|
+
const docLength = index.docLengths.get(filePath) ?? 0;
|
|
708
|
+
index.docLengths.delete(filePath);
|
|
709
|
+
index.forward.delete(filePath);
|
|
710
|
+
index.fileMtimes.delete(filePath);
|
|
711
|
+
index.fileSizes.delete(filePath);
|
|
712
|
+
index.dirtyFiles?.add(wordIndexKey(filePath));
|
|
713
|
+
index.fileTable.release(removedKey);
|
|
714
|
+
index.totalTokens -= docLength;
|
|
715
|
+
index.docCount = Math.max(0, index.docCount - 1);
|
|
716
|
+
return true;
|
|
717
|
+
}
|
|
718
|
+
function updateWordIndexDocument(index, doc) {
|
|
719
|
+
if (!index.forward)
|
|
720
|
+
return false;
|
|
721
|
+
const startedAt = Date.now();
|
|
722
|
+
if (index.forward.has(doc.path)) {
|
|
723
|
+
removeWordIndexDocument(index, doc.path);
|
|
724
|
+
}
|
|
725
|
+
const lines = doc.content.split(/\r?\n/);
|
|
726
|
+
const perTokenHits = /* @__PURE__ */ new Map();
|
|
727
|
+
let docLength = 0;
|
|
728
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
729
|
+
const lineTokens = tokenizeLine(lines[i]);
|
|
730
|
+
docLength += lineTokens.length;
|
|
731
|
+
const seenOnLine = /* @__PURE__ */ new Set();
|
|
732
|
+
for (const token of lineTokens) {
|
|
733
|
+
if (seenOnLine.has(token))
|
|
734
|
+
continue;
|
|
735
|
+
seenOnLine.add(token);
|
|
736
|
+
const arr = perTokenHits.get(token);
|
|
737
|
+
if (arr)
|
|
738
|
+
arr.push(i + 1);
|
|
739
|
+
else
|
|
740
|
+
perTokenHits.set(token, [i + 1]);
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
commitWordIndexDocumentReplacement(index, doc, perTokenHits, docLength, startedAt);
|
|
744
|
+
scheduleWordIndexRecompact(index, doc.path);
|
|
745
|
+
return true;
|
|
746
|
+
}
|
|
747
|
+
var asyncWordIndexOperations = /* @__PURE__ */ new WeakMap();
|
|
748
|
+
function enqueueAsyncWordIndexOperation(index, operation) {
|
|
749
|
+
const previous = asyncWordIndexOperations.get(index) ?? Promise.resolve();
|
|
750
|
+
const run = previous.catch(() => void 0).then(operation);
|
|
751
|
+
const settled = run.then(() => void 0, () => void 0);
|
|
752
|
+
asyncWordIndexOperations.set(index, settled);
|
|
753
|
+
return run.finally(() => {
|
|
754
|
+
if (asyncWordIndexOperations.get(index) === settled) {
|
|
755
|
+
asyncWordIndexOperations.delete(index);
|
|
756
|
+
}
|
|
757
|
+
});
|
|
758
|
+
}
|
|
759
|
+
async function stageWordIndexDocumentRemoval(index, filePath, shouldContinue) {
|
|
760
|
+
if (!index.forward)
|
|
761
|
+
return void 0;
|
|
762
|
+
const tokenLineCounts = index.forward.get(filePath);
|
|
763
|
+
if (!tokenLineCounts)
|
|
764
|
+
return void 0;
|
|
765
|
+
const removedKey = wordIndexKey(filePath);
|
|
766
|
+
const removedId = index.fileTable.idFor(removedKey);
|
|
767
|
+
if (removedId === void 0)
|
|
768
|
+
return void 0;
|
|
769
|
+
const postings = /* @__PURE__ */ new Map();
|
|
770
|
+
const deadline = createDeadline(WORD_INDEX_BUILD_YIELD_BUDGET_MS);
|
|
771
|
+
for (const token of tokenLineCounts.keys()) {
|
|
772
|
+
if (!shouldContinue())
|
|
773
|
+
throw new Error("word index refresh superseded");
|
|
774
|
+
const list = index.postings.get(token);
|
|
775
|
+
if (!list)
|
|
776
|
+
continue;
|
|
777
|
+
const survivors = list.withoutFile(removedId);
|
|
778
|
+
postings.set(token, survivors.length > 0 ? survivors : void 0);
|
|
779
|
+
if (deadline.expired() && await yieldIfOverBudget(deadline)) {
|
|
780
|
+
if (!shouldContinue())
|
|
781
|
+
throw new Error("word index refresh superseded");
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
return { postings, docLength: index.docLengths.get(filePath) ?? 0 };
|
|
785
|
+
}
|
|
786
|
+
function commitWordIndexDocumentRemoval(index, filePath, staged) {
|
|
787
|
+
for (const [token, list] of staged.postings) {
|
|
788
|
+
if (list) {
|
|
789
|
+
index.postings.set(token, list);
|
|
790
|
+
notePostingStoresAllocated(index, 1);
|
|
791
|
+
} else
|
|
792
|
+
index.postings.delete(token);
|
|
793
|
+
}
|
|
794
|
+
index.docLengths.delete(filePath);
|
|
795
|
+
index.forward?.delete(filePath);
|
|
796
|
+
index.fileMtimes.delete(filePath);
|
|
797
|
+
index.fileSizes.delete(filePath);
|
|
798
|
+
index.dirtyFiles?.add(wordIndexKey(filePath));
|
|
799
|
+
index.fileTable.release(wordIndexKey(filePath));
|
|
800
|
+
index.totalTokens -= staged.docLength;
|
|
801
|
+
index.docCount = Math.max(0, index.docCount - 1);
|
|
802
|
+
}
|
|
803
|
+
async function removeWordIndexDocumentAsync(index, filePath, shouldContinue = () => true) {
|
|
804
|
+
return enqueueAsyncWordIndexOperation(index, async () => {
|
|
805
|
+
const staged = await stageWordIndexDocumentRemoval(index, filePath, shouldContinue);
|
|
806
|
+
if (!staged)
|
|
807
|
+
return false;
|
|
808
|
+
if (!shouldContinue())
|
|
809
|
+
throw new Error("word index refresh superseded");
|
|
810
|
+
commitWordIndexDocumentRemoval(index, filePath, staged);
|
|
811
|
+
return true;
|
|
812
|
+
});
|
|
813
|
+
}
|
|
814
|
+
async function updateWordIndexDocumentForEdit(index, doc) {
|
|
815
|
+
const updated = await updateWordIndexDocumentAsync(index, doc);
|
|
816
|
+
if (updated)
|
|
817
|
+
scheduleWordIndexRecompact(index, doc.path);
|
|
818
|
+
return updated;
|
|
819
|
+
}
|
|
820
|
+
async function updateWordIndexDocumentAsync(index, doc, shouldContinue = () => true) {
|
|
821
|
+
return enqueueAsyncWordIndexOperation(index, () => updateWordIndexDocumentAsyncUnsafe(index, doc, shouldContinue));
|
|
822
|
+
}
|
|
823
|
+
async function updateWordIndexDocumentAsyncUnsafe(index, doc, shouldContinue) {
|
|
824
|
+
if (!index.forward)
|
|
825
|
+
return false;
|
|
826
|
+
const startedAt = Date.now();
|
|
827
|
+
const removal = index.forward.has(doc.path) ? await stageWordIndexDocumentRemoval(index, doc.path, shouldContinue) : void 0;
|
|
828
|
+
if (index.forward.has(doc.path) && !removal)
|
|
829
|
+
return false;
|
|
830
|
+
const perTokenHits = /* @__PURE__ */ new Map();
|
|
831
|
+
let docLength = 0;
|
|
832
|
+
const lines = doc.content.split(/\r?\n/);
|
|
833
|
+
await forEachCooperatively(lines, (line, i) => {
|
|
834
|
+
const lineTokens = tokenizeLine(line);
|
|
835
|
+
docLength += lineTokens.length;
|
|
836
|
+
const seenOnLine = /* @__PURE__ */ new Set();
|
|
837
|
+
for (const token of lineTokens) {
|
|
838
|
+
if (seenOnLine.has(token))
|
|
839
|
+
continue;
|
|
840
|
+
seenOnLine.add(token);
|
|
841
|
+
const arr = perTokenHits.get(token);
|
|
842
|
+
if (arr)
|
|
843
|
+
arr.push(i + 1);
|
|
844
|
+
else
|
|
845
|
+
perTokenHits.set(token, [i + 1]);
|
|
846
|
+
}
|
|
847
|
+
}, {
|
|
848
|
+
budgetMs: WORD_INDEX_BUILD_YIELD_BUDGET_MS,
|
|
849
|
+
shouldContinue,
|
|
850
|
+
abortMessage: "word index refresh superseded"
|
|
851
|
+
});
|
|
852
|
+
if (!shouldContinue())
|
|
853
|
+
throw new Error("word index refresh superseded");
|
|
854
|
+
if (removal)
|
|
855
|
+
commitWordIndexDocumentRemoval(index, doc.path, removal);
|
|
856
|
+
commitWordIndexDocumentReplacement(index, doc, perTokenHits, docLength, startedAt);
|
|
857
|
+
return true;
|
|
858
|
+
}
|
|
859
|
+
var WORD_INDEX_MAX_BYTES = 512 * 1024;
|
|
860
|
+
async function collectWordIndexDocs(root, shouldContinue = () => true, preflightFiles) {
|
|
861
|
+
const { collectSourceFilesAsync } = await import("./chunk-E4MAEDPM.js");
|
|
862
|
+
const maxFiles = preflightFiles?.length ?? getWordIndexMaxFilesDerived(root);
|
|
863
|
+
const files = preflightFiles ? preflightFiles.map((file) => file.path) : await collectSourceFilesAsync(root, {
|
|
864
|
+
maxFiles,
|
|
865
|
+
prioritizeCodeKinds: true
|
|
866
|
+
});
|
|
867
|
+
const truncated = preflightFiles?.truncated ?? files.length === maxFiles;
|
|
868
|
+
const docs = Object.assign([], { truncated, skipped: 0 });
|
|
869
|
+
if (!shouldContinue())
|
|
870
|
+
return docs;
|
|
871
|
+
const deadline = createDeadline(WORD_INDEX_BUILD_YIELD_BUDGET_MS);
|
|
872
|
+
for (const file of files.slice(0, maxFiles)) {
|
|
873
|
+
if (!shouldContinue())
|
|
874
|
+
return docs;
|
|
875
|
+
try {
|
|
876
|
+
const stat = fs.statSync(file);
|
|
877
|
+
if (stat.size <= WORD_INDEX_MAX_BYTES) {
|
|
878
|
+
docs.push({
|
|
879
|
+
path: file,
|
|
880
|
+
content: fs.readFileSync(file, "utf-8"),
|
|
881
|
+
mtimeMs: stat.mtimeMs,
|
|
882
|
+
size: stat.size
|
|
883
|
+
});
|
|
884
|
+
} else {
|
|
885
|
+
docs.skipped += 1;
|
|
886
|
+
}
|
|
887
|
+
} catch {
|
|
888
|
+
docs.skipped += 1;
|
|
889
|
+
}
|
|
890
|
+
if (deadline.expired() && await yieldIfOverBudget(deadline)) {
|
|
891
|
+
if (!shouldContinue())
|
|
892
|
+
return docs;
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
return docs;
|
|
896
|
+
}
|
|
897
|
+
var WORD_INDEX_STAT_CONCURRENCY = 8;
|
|
898
|
+
var WORD_INDEX_INCREMENTAL_CHURN_THRESHOLD = 0.3;
|
|
899
|
+
var WORD_INDEX_DENSE_REFRESH_MIN_DOCUMENTS = 32;
|
|
900
|
+
var WORD_INDEX_FILE_READ_TOKEN_COST = 300;
|
|
901
|
+
var WORD_INDEX_POSTING_SCAN_TOKEN_COST = 0.2;
|
|
902
|
+
async function refreshWordIndexIncrementally(index, root, shouldContinue = () => true, options = {}) {
|
|
903
|
+
if (!index.forward || !index.fileMtimes || !index.fileSizes) {
|
|
904
|
+
return {
|
|
905
|
+
mode: "full-required",
|
|
906
|
+
reason: "missing-incremental-metadata",
|
|
907
|
+
timings: { sourceWalkMs: 0, statWalkMs: 0, refreshReadsMs: 0 }
|
|
908
|
+
};
|
|
909
|
+
}
|
|
910
|
+
const { collectSourceFilesAsync } = await import("./chunk-E4MAEDPM.js");
|
|
911
|
+
const maxFiles = getWordIndexMaxFilesDerived(root);
|
|
912
|
+
const sourceWalkStartMs = Date.now();
|
|
913
|
+
const walked = await collectSourceFilesAsync(root, {
|
|
914
|
+
maxFiles,
|
|
915
|
+
prioritizeCodeKinds: true
|
|
916
|
+
});
|
|
917
|
+
const sourceWalkMs = Date.now() - sourceWalkStartMs;
|
|
918
|
+
if (!shouldContinue())
|
|
919
|
+
throw new Error("word index refresh superseded");
|
|
920
|
+
const current = /* @__PURE__ */ new Map();
|
|
921
|
+
const statWalkStartMs = Date.now();
|
|
922
|
+
const statFile = options.statFile ?? ((file) => fs.promises.stat(file));
|
|
923
|
+
const requestedConcurrency = options.statConcurrency ?? WORD_INDEX_STAT_CONCURRENCY;
|
|
924
|
+
const statConcurrency = Number.isFinite(requestedConcurrency) && requestedConcurrency > 0 ? Math.max(1, Math.floor(requestedConcurrency)) : WORD_INDEX_STAT_CONCURRENCY;
|
|
925
|
+
const statResults = [];
|
|
926
|
+
statResults.length = walked.length;
|
|
927
|
+
let cursor = 0;
|
|
928
|
+
let superseded = false;
|
|
929
|
+
const worker = async () => {
|
|
930
|
+
while (true) {
|
|
931
|
+
if (!shouldContinue()) {
|
|
932
|
+
superseded = true;
|
|
933
|
+
return;
|
|
934
|
+
}
|
|
935
|
+
const slot = cursor++;
|
|
936
|
+
if (slot >= walked.length)
|
|
937
|
+
return;
|
|
938
|
+
const file = walked[slot];
|
|
939
|
+
try {
|
|
940
|
+
const stat = await statFile(file);
|
|
941
|
+
if (stat.size <= WORD_INDEX_MAX_BYTES) {
|
|
942
|
+
statResults[slot] = {
|
|
943
|
+
path: file,
|
|
944
|
+
mtimeMs: stat.mtimeMs,
|
|
945
|
+
size: stat.size
|
|
946
|
+
};
|
|
947
|
+
}
|
|
948
|
+
} catch {
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
};
|
|
952
|
+
await Promise.all(Array.from({ length: Math.min(statConcurrency, walked.length) }, () => worker()));
|
|
953
|
+
if (superseded || !shouldContinue()) {
|
|
954
|
+
throw new Error("word index refresh superseded");
|
|
955
|
+
}
|
|
956
|
+
const statWalkMs = Date.now() - statWalkStartMs;
|
|
957
|
+
for (const result of statResults) {
|
|
958
|
+
if (result)
|
|
959
|
+
current.set(wordIndexKey(result.path), result);
|
|
960
|
+
}
|
|
961
|
+
const timings = { sourceWalkMs, statWalkMs, refreshReadsMs: 0 };
|
|
962
|
+
const preflightFiles = Object.assign([...current.values()], {
|
|
963
|
+
truncated: walked.length === maxFiles
|
|
964
|
+
});
|
|
965
|
+
const oldSet = new Set([...index.docLengths.keys()].map(wordIndexKey));
|
|
966
|
+
let changedSet = 0;
|
|
967
|
+
for (const key of oldSet)
|
|
968
|
+
if (!current.has(key))
|
|
969
|
+
changedSet++;
|
|
970
|
+
for (const key of current.keys())
|
|
971
|
+
if (!oldSet.has(key))
|
|
972
|
+
changedSet++;
|
|
973
|
+
const denominator = Math.max(oldSet.size, current.size, 1);
|
|
974
|
+
if (changedSet / denominator > WORD_INDEX_INCREMENTAL_CHURN_THRESHOLD) {
|
|
975
|
+
return {
|
|
976
|
+
mode: "full-required",
|
|
977
|
+
reason: "file-set-churn",
|
|
978
|
+
preflightFiles,
|
|
979
|
+
timings
|
|
980
|
+
};
|
|
981
|
+
}
|
|
982
|
+
let staleDocuments = 0;
|
|
983
|
+
for (const { path: file, mtimeMs, size } of current.values()) {
|
|
984
|
+
if (index.fileMtimes.get(file) !== mtimeMs || (index.fileSizes.get(file) ?? -1) !== size) {
|
|
985
|
+
staleDocuments += 1;
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
let postingEntries = 0;
|
|
989
|
+
let weightedPostingEntries = 0;
|
|
990
|
+
for (const list of index.postings.values()) {
|
|
991
|
+
postingEntries += list.length;
|
|
992
|
+
weightedPostingEntries += list.length * list.length;
|
|
993
|
+
}
|
|
994
|
+
const expectedPostingLength = postingEntries > 0 ? weightedPostingEntries / postingEntries : 0;
|
|
995
|
+
let distinctTokenEntries = 0;
|
|
996
|
+
for (const tokenLineCounts of index.forward.values()) {
|
|
997
|
+
distinctTokenEntries += tokenLineCounts.size;
|
|
998
|
+
}
|
|
999
|
+
const expectedDocumentTokens = index.docCount > 0 ? distinctTokenEntries / index.docCount : 0;
|
|
1000
|
+
const estimatedIncrementalWork = staleDocuments * (expectedDocumentTokens * expectedPostingLength * WORD_INDEX_POSTING_SCAN_TOKEN_COST + WORD_INDEX_FILE_READ_TOKEN_COST);
|
|
1001
|
+
const estimatedFullRebuildWork = index.totalTokens + current.size * WORD_INDEX_FILE_READ_TOKEN_COST;
|
|
1002
|
+
if (staleDocuments >= WORD_INDEX_DENSE_REFRESH_MIN_DOCUMENTS && staleDocuments / Math.max(current.size, 1) > WORD_INDEX_INCREMENTAL_CHURN_THRESHOLD || estimatedIncrementalWork > estimatedFullRebuildWork) {
|
|
1003
|
+
return {
|
|
1004
|
+
mode: "full-required",
|
|
1005
|
+
reason: "stale-document-churn",
|
|
1006
|
+
preflightFiles,
|
|
1007
|
+
timings
|
|
1008
|
+
};
|
|
1009
|
+
}
|
|
1010
|
+
const deadline = createDeadline(WORD_INDEX_BUILD_YIELD_BUDGET_MS);
|
|
1011
|
+
let dropped = 0;
|
|
1012
|
+
for (const key of oldSet) {
|
|
1013
|
+
if (!current.has(key)) {
|
|
1014
|
+
if (!await removeWordIndexDocumentAsync(index, key, shouldContinue)) {
|
|
1015
|
+
throw new Error(`failed to drop word-index document: ${key}`);
|
|
1016
|
+
}
|
|
1017
|
+
dropped++;
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
let refreshed = 0;
|
|
1021
|
+
let skipped = 0;
|
|
1022
|
+
const refreshReadsStartMs = Date.now();
|
|
1023
|
+
for (const { path: file, mtimeMs, size } of current.values()) {
|
|
1024
|
+
if (index.fileMtimes.get(file) !== mtimeMs || (index.fileSizes.get(file) ?? -1) !== size) {
|
|
1025
|
+
let content;
|
|
1026
|
+
try {
|
|
1027
|
+
content = fs.readFileSync(file, "utf-8");
|
|
1028
|
+
} catch {
|
|
1029
|
+
skipped++;
|
|
1030
|
+
continue;
|
|
1031
|
+
}
|
|
1032
|
+
if (!await updateWordIndexDocumentAsync(index, { path: file, content }, shouldContinue)) {
|
|
1033
|
+
throw new Error(`failed to refresh word-index document: ${file}`);
|
|
1034
|
+
}
|
|
1035
|
+
index.fileMtimes.set(file, mtimeMs);
|
|
1036
|
+
index.fileSizes.set(file, size);
|
|
1037
|
+
refreshed++;
|
|
1038
|
+
}
|
|
1039
|
+
if (deadline.expired() && await yieldIfOverBudget(deadline)) {
|
|
1040
|
+
if (!shouldContinue())
|
|
1041
|
+
throw new Error("word index refresh superseded");
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
timings.refreshReadsMs = Date.now() - refreshReadsStartMs;
|
|
1045
|
+
await enqueueWordIndexRecompact(index, root);
|
|
1046
|
+
index.truncated = walked.length === maxFiles;
|
|
1047
|
+
return {
|
|
1048
|
+
mode: "incremental",
|
|
1049
|
+
refreshed,
|
|
1050
|
+
dropped,
|
|
1051
|
+
skipped,
|
|
1052
|
+
reused: current.size - refreshed - skipped,
|
|
1053
|
+
timings
|
|
1054
|
+
};
|
|
1055
|
+
}
|
|
1056
|
+
var WORD_INDEX_QUERY_FILTER_KEYS = [
|
|
1057
|
+
"lang",
|
|
1058
|
+
"file",
|
|
1059
|
+
"ext"
|
|
1060
|
+
];
|
|
1061
|
+
var WordIndexQueryError = class extends Error {
|
|
1062
|
+
constructor(message) {
|
|
1063
|
+
super(message);
|
|
1064
|
+
this.name = "WordIndexQueryError";
|
|
1065
|
+
}
|
|
1066
|
+
};
|
|
1067
|
+
var WORD_INDEX_FILTER_TOKEN_RE = /^(-)?([A-Za-z][A-Za-z0-9_-]*):(.+)$/;
|
|
1068
|
+
function parseWordIndexQuery(query) {
|
|
1069
|
+
const filters = [];
|
|
1070
|
+
const termParts = [];
|
|
1071
|
+
for (const raw of query.split(/\s+/)) {
|
|
1072
|
+
if (!raw)
|
|
1073
|
+
continue;
|
|
1074
|
+
const match = raw.match(WORD_INDEX_FILTER_TOKEN_RE);
|
|
1075
|
+
if (!match) {
|
|
1076
|
+
termParts.push(raw);
|
|
1077
|
+
continue;
|
|
1078
|
+
}
|
|
1079
|
+
const [, negation, keyRaw, value] = match;
|
|
1080
|
+
const key = keyRaw.toLowerCase();
|
|
1081
|
+
if (!value) {
|
|
1082
|
+
termParts.push(raw);
|
|
1083
|
+
continue;
|
|
1084
|
+
}
|
|
1085
|
+
if (!WORD_INDEX_QUERY_FILTER_KEYS.includes(key)) {
|
|
1086
|
+
termParts.push(raw);
|
|
1087
|
+
continue;
|
|
1088
|
+
}
|
|
1089
|
+
filters.push({
|
|
1090
|
+
key,
|
|
1091
|
+
value,
|
|
1092
|
+
negated: negation === "-"
|
|
1093
|
+
});
|
|
1094
|
+
}
|
|
1095
|
+
return { terms: termParts.join(" "), filters };
|
|
1096
|
+
}
|
|
1097
|
+
function resolveLangExtensions(value) {
|
|
1098
|
+
const kind = value.toLowerCase();
|
|
1099
|
+
const extensions = KIND_EXTENSIONS[kind];
|
|
1100
|
+
if (!extensions) {
|
|
1101
|
+
const known = Object.keys(KIND_EXTENSIONS).sort((a, b) => a < b ? -1 : a > b ? 1 : 0).join(", ");
|
|
1102
|
+
throw new WordIndexQueryError(`Unknown lang: "${value}" in word-index query \u2014 supported languages: ${known}.`);
|
|
1103
|
+
}
|
|
1104
|
+
return extensions;
|
|
1105
|
+
}
|
|
1106
|
+
function normalizeExtFilterValue(value) {
|
|
1107
|
+
return `.${value.replace(/^\.+/, "").toLowerCase()}`;
|
|
1108
|
+
}
|
|
1109
|
+
function resolveWordIndexFilter(filter) {
|
|
1110
|
+
if (filter.key === "lang") {
|
|
1111
|
+
const extensions = resolveLangExtensions(filter.value);
|
|
1112
|
+
return {
|
|
1113
|
+
key: filter.key,
|
|
1114
|
+
negated: filter.negated,
|
|
1115
|
+
test: (file) => extensions.includes(path2.extname(file).toLowerCase())
|
|
1116
|
+
};
|
|
1117
|
+
}
|
|
1118
|
+
if (filter.key === "ext") {
|
|
1119
|
+
const normalized = normalizeExtFilterValue(filter.value);
|
|
1120
|
+
return {
|
|
1121
|
+
key: filter.key,
|
|
1122
|
+
negated: filter.negated,
|
|
1123
|
+
test: (file) => path2.extname(file).toLowerCase() === normalized
|
|
1124
|
+
};
|
|
1125
|
+
}
|
|
1126
|
+
const needle = wordIndexKey(filter.value);
|
|
1127
|
+
return {
|
|
1128
|
+
key: filter.key,
|
|
1129
|
+
negated: filter.negated,
|
|
1130
|
+
test: (_file, displayPath) => displayPath.includes(needle)
|
|
1131
|
+
};
|
|
1132
|
+
}
|
|
1133
|
+
function buildWordIndexQueryFilter(filters) {
|
|
1134
|
+
if (filters.length === 0)
|
|
1135
|
+
return void 0;
|
|
1136
|
+
const resolved = filters.map(resolveWordIndexFilter);
|
|
1137
|
+
const positivesByKey = /* @__PURE__ */ new Map();
|
|
1138
|
+
const negatives = [];
|
|
1139
|
+
for (const r of resolved) {
|
|
1140
|
+
if (r.negated) {
|
|
1141
|
+
negatives.push(r);
|
|
1142
|
+
continue;
|
|
1143
|
+
}
|
|
1144
|
+
const group = positivesByKey.get(r.key) ?? [];
|
|
1145
|
+
group.push(r);
|
|
1146
|
+
positivesByKey.set(r.key, group);
|
|
1147
|
+
}
|
|
1148
|
+
return (file) => {
|
|
1149
|
+
const displayPath = wordIndexKey(file);
|
|
1150
|
+
for (const negative of negatives) {
|
|
1151
|
+
if (negative.test(file, displayPath))
|
|
1152
|
+
return false;
|
|
1153
|
+
}
|
|
1154
|
+
for (const group of positivesByKey.values()) {
|
|
1155
|
+
if (!group.some((r) => r.test(file, displayPath)))
|
|
1156
|
+
return false;
|
|
1157
|
+
}
|
|
1158
|
+
return true;
|
|
1159
|
+
};
|
|
1160
|
+
}
|
|
1161
|
+
function combineFileFilters(a, b) {
|
|
1162
|
+
if (!a)
|
|
1163
|
+
return b;
|
|
1164
|
+
if (!b)
|
|
1165
|
+
return a;
|
|
1166
|
+
return (file) => a(file) && b(file);
|
|
1167
|
+
}
|
|
1168
|
+
function searchWordIndex(index, query, options = {}) {
|
|
1169
|
+
const { demoteTestVendor = true, demoteDocs = true, centrality, limit = 20, fileFilter } = options;
|
|
1170
|
+
const parsedQuery = parseWordIndexQuery(query);
|
|
1171
|
+
const queryFilter = buildWordIndexQueryFilter(parsedQuery.filters);
|
|
1172
|
+
const combinedFilter = combineFileFilters(fileFilter, queryFilter);
|
|
1173
|
+
const queryTokens = [...new Set(tokenizeLine(parsedQuery.terms))];
|
|
1174
|
+
if (queryTokens.length === 0)
|
|
1175
|
+
return [];
|
|
1176
|
+
const docCount = index.docCount || 1;
|
|
1177
|
+
const avgDocLength = index.totalTokens / docCount || 1;
|
|
1178
|
+
const scores = /* @__PURE__ */ new Map();
|
|
1179
|
+
for (const token of queryTokens) {
|
|
1180
|
+
const posting = index.postings.get(token);
|
|
1181
|
+
if (!posting)
|
|
1182
|
+
continue;
|
|
1183
|
+
const linesByFileId = /* @__PURE__ */ new Map();
|
|
1184
|
+
for (let i = 0; i < posting.length; i += 1) {
|
|
1185
|
+
const fileId = posting.fileIdAt(i);
|
|
1186
|
+
const arr = linesByFileId.get(fileId);
|
|
1187
|
+
if (arr)
|
|
1188
|
+
arr.push(posting.lineAt(i));
|
|
1189
|
+
else
|
|
1190
|
+
linesByFileId.set(fileId, [posting.lineAt(i)]);
|
|
1191
|
+
}
|
|
1192
|
+
const docFrequency = linesByFileId.size;
|
|
1193
|
+
const idf = Math.log(1 + (docCount - docFrequency + 0.5) / (docFrequency + 0.5));
|
|
1194
|
+
for (const [fileId, lines] of linesByFileId) {
|
|
1195
|
+
const file = index.fileTable.pathFor(fileId);
|
|
1196
|
+
if (file === void 0) {
|
|
1197
|
+
recordOrphanWordIndexFileId(fileId, token, "search");
|
|
1198
|
+
continue;
|
|
1199
|
+
}
|
|
1200
|
+
if (combinedFilter && !combinedFilter(file))
|
|
1201
|
+
continue;
|
|
1202
|
+
const termFrequency = lines.length;
|
|
1203
|
+
const docLength = index.docLengths.get(file) ?? avgDocLength;
|
|
1204
|
+
const denominator = termFrequency + BM25_K1 * (1 - BM25_B + BM25_B * (docLength / avgDocLength));
|
|
1205
|
+
const termScore = idf * (termFrequency * (BM25_K1 + 1) / denominator);
|
|
1206
|
+
const entry = scores.get(file) ?? {
|
|
1207
|
+
score: 0,
|
|
1208
|
+
hits: 0,
|
|
1209
|
+
lines: /* @__PURE__ */ new Set()
|
|
1210
|
+
};
|
|
1211
|
+
entry.score += termScore;
|
|
1212
|
+
entry.hits += termFrequency;
|
|
1213
|
+
for (const line of lines)
|
|
1214
|
+
entry.lines.add(line);
|
|
1215
|
+
scores.set(file, entry);
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
const results = [];
|
|
1219
|
+
for (const [file, entry] of scores) {
|
|
1220
|
+
let score = entry.score;
|
|
1221
|
+
if (demoteTestVendor && isTestOrVendor(file))
|
|
1222
|
+
score *= TEST_VENDOR_PENALTY;
|
|
1223
|
+
if (demoteDocs && isDocFile(file))
|
|
1224
|
+
score *= DOC_FILE_PENALTY;
|
|
1225
|
+
const connections = centrality?.get(file);
|
|
1226
|
+
if (connections && connections > 0) {
|
|
1227
|
+
score *= 1 + Math.log(1 + connections) / 4;
|
|
1228
|
+
}
|
|
1229
|
+
results.push({
|
|
1230
|
+
file,
|
|
1231
|
+
score,
|
|
1232
|
+
hits: entry.hits,
|
|
1233
|
+
lines: [...entry.lines].sort((a, b) => a - b)
|
|
1234
|
+
});
|
|
1235
|
+
}
|
|
1236
|
+
results.sort((a, b) => b.score - a.score || a.file.localeCompare(b.file));
|
|
1237
|
+
return results.slice(0, Math.max(0, limit));
|
|
1238
|
+
}
|
|
1239
|
+
function centralityFromReverseDeps(index, reverseDeps, normalizeKey = (file) => file) {
|
|
1240
|
+
const centrality = /* @__PURE__ */ new Map();
|
|
1241
|
+
if (!reverseDeps)
|
|
1242
|
+
return centrality;
|
|
1243
|
+
for (const file of index.docLengths.keys()) {
|
|
1244
|
+
const importers = reverseDeps[normalizeKey(file)];
|
|
1245
|
+
if (importers && importers.length > 0) {
|
|
1246
|
+
centrality.set(file, importers.length);
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
return centrality;
|
|
1250
|
+
}
|
|
1251
|
+
var WORD_INDEX_FORMAT_VERSION = 2;
|
|
1252
|
+
var WORD_INDEX_INT32_MAX = 2147483647;
|
|
1253
|
+
var WORD_INDEX_PACKED_FILE_ID_MAX = 4194303;
|
|
1254
|
+
function isCanonicalWordIndexNumber(value) {
|
|
1255
|
+
return typeof value === "number" && Number.isFinite(value) && Number.isSafeInteger(value) && !Object.is(value, -0);
|
|
1256
|
+
}
|
|
1257
|
+
function isCanonicalWordIndexToken(token) {
|
|
1258
|
+
return typeof token === "string" && token.length >= 2 && token === token.toLowerCase() && /^[a-z0-9_$]+$/.test(token) && !STOPWORDS.has(token);
|
|
1259
|
+
}
|
|
1260
|
+
var serializedWordIndexCaches = /* @__PURE__ */ new WeakMap();
|
|
1261
|
+
var serializedWordIndexSources = /* @__PURE__ */ new WeakMap();
|
|
1262
|
+
function getWordIndexWireBytes(index) {
|
|
1263
|
+
return serializedWordIndexCaches.get(index)?.wireBytes ?? null;
|
|
1264
|
+
}
|
|
1265
|
+
function recordPersistedWordIndexWireBytes(serialized, wireBytes) {
|
|
1266
|
+
if (!serialized || wireBytes === void 0)
|
|
1267
|
+
return;
|
|
1268
|
+
const index = serializedWordIndexSources.get(serialized);
|
|
1269
|
+
const cache = index && serializedWordIndexCaches.get(index);
|
|
1270
|
+
if (cache?.serialized === serialized)
|
|
1271
|
+
cache.wireBytes = wireBytes;
|
|
1272
|
+
}
|
|
1273
|
+
var _lastSerializeWork;
|
|
1274
|
+
function getLastWordIndexSerializeWork() {
|
|
1275
|
+
return _lastSerializeWork;
|
|
1276
|
+
}
|
|
1277
|
+
function serializeWordIndexFull(index) {
|
|
1278
|
+
const files = [...index.docLengths.keys()];
|
|
1279
|
+
const slotByFileId = /* @__PURE__ */ new Map();
|
|
1280
|
+
files.forEach((file, i) => {
|
|
1281
|
+
const fileId = index.fileTable.idFor(wordIndexKey(file));
|
|
1282
|
+
if (fileId !== void 0)
|
|
1283
|
+
slotByFileId.set(fileId, i);
|
|
1284
|
+
});
|
|
1285
|
+
const postings = [];
|
|
1286
|
+
for (const [token, list] of index.postings) {
|
|
1287
|
+
const flat = [];
|
|
1288
|
+
for (let i = 0; i < list.length; i += 1) {
|
|
1289
|
+
const slot = slotByFileId.get(list.fileIdAt(i));
|
|
1290
|
+
if (slot === void 0)
|
|
1291
|
+
continue;
|
|
1292
|
+
flat.push(slot, list.lineAt(i));
|
|
1293
|
+
}
|
|
1294
|
+
if (flat.length > 0)
|
|
1295
|
+
postings.push([token, flat]);
|
|
1296
|
+
}
|
|
1297
|
+
const forward = index.forward ? files.map((file, i) => [
|
|
1298
|
+
i,
|
|
1299
|
+
[...index.forward.get(file)?.entries() ?? []]
|
|
1300
|
+
]) : void 0;
|
|
1301
|
+
const serialized = {
|
|
1302
|
+
version: WORD_INDEX_FORMAT_VERSION,
|
|
1303
|
+
files,
|
|
1304
|
+
postings,
|
|
1305
|
+
docLengths: files.map((file) => index.docLengths.get(file) ?? 0),
|
|
1306
|
+
totalTokens: index.totalTokens,
|
|
1307
|
+
indexedFileCount: index.docCount,
|
|
1308
|
+
truncated: index.truncated,
|
|
1309
|
+
fileMtimes: files.map((file) => index.fileMtimes.get(file) ?? 0),
|
|
1310
|
+
fileSizes: files.map((file) => index.fileSizes.get(file) ?? 0),
|
|
1311
|
+
forward
|
|
1312
|
+
};
|
|
1313
|
+
const tokensByFile = /* @__PURE__ */ new Map();
|
|
1314
|
+
if (index.forward) {
|
|
1315
|
+
for (const file of files) {
|
|
1316
|
+
tokensByFile.set(wordIndexKey(file), new Set(index.forward.get(file)?.keys() ?? []));
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
_lastSerializeWork = {
|
|
1320
|
+
affectedTokenCount: postings.length,
|
|
1321
|
+
tookFullPath: true
|
|
1322
|
+
};
|
|
1323
|
+
return {
|
|
1324
|
+
serialized,
|
|
1325
|
+
slotByFileId,
|
|
1326
|
+
tokensByFile,
|
|
1327
|
+
wireBytes: null
|
|
1328
|
+
};
|
|
1329
|
+
}
|
|
1330
|
+
function serializeWordIndexIncrementally(index, cache) {
|
|
1331
|
+
const files = [...index.docLengths.keys()];
|
|
1332
|
+
const priorFiles = cache.serialized.files;
|
|
1333
|
+
const currentKeys = new Set(files.map(wordIndexKey));
|
|
1334
|
+
const priorKeys = new Set(priorFiles.map(wordIndexKey));
|
|
1335
|
+
if ([...priorKeys].some((key) => !currentKeys.has(key))) {
|
|
1336
|
+
return serializeWordIndexFull(index);
|
|
1337
|
+
}
|
|
1338
|
+
const dirty = index.dirtyFiles;
|
|
1339
|
+
if (dirty && dirty.size * 2 > files.length) {
|
|
1340
|
+
return serializeWordIndexFull(index);
|
|
1341
|
+
}
|
|
1342
|
+
const filesInWireOrder = [
|
|
1343
|
+
...priorFiles,
|
|
1344
|
+
...files.filter((file) => !priorKeys.has(wordIndexKey(file)))
|
|
1345
|
+
];
|
|
1346
|
+
if (!dirty || dirty.size === 0) {
|
|
1347
|
+
_lastSerializeWork = { affectedTokenCount: 0, tookFullPath: false };
|
|
1348
|
+
return cache;
|
|
1349
|
+
}
|
|
1350
|
+
const slotByFileId = new Map(cache.slotByFileId);
|
|
1351
|
+
for (let i = priorFiles.length; i < filesInWireOrder.length; i += 1) {
|
|
1352
|
+
const fileId = index.fileTable.idFor(wordIndexKey(filesInWireOrder[i]));
|
|
1353
|
+
if (fileId !== void 0)
|
|
1354
|
+
slotByFileId.set(fileId, i);
|
|
1355
|
+
}
|
|
1356
|
+
const postings = cache.serialized.postings.slice();
|
|
1357
|
+
const postingAt = /* @__PURE__ */ new Map();
|
|
1358
|
+
postings.forEach(([token], i) => postingAt.set(token, i));
|
|
1359
|
+
const removedTokens = /* @__PURE__ */ new Set();
|
|
1360
|
+
const tokensByFile = new Map(cache.tokensByFile);
|
|
1361
|
+
const fileByKey = new Map(filesInWireOrder.map((file) => [wordIndexKey(file), file]));
|
|
1362
|
+
const affectedTokens = /* @__PURE__ */ new Set();
|
|
1363
|
+
for (const fileKey of dirty) {
|
|
1364
|
+
const file = fileByKey.get(fileKey);
|
|
1365
|
+
const oldTokens = tokensByFile.get(fileKey) ?? /* @__PURE__ */ new Set();
|
|
1366
|
+
const currentEntry = file === void 0 ? void 0 : index.forward?.get(file);
|
|
1367
|
+
const currentTokens = new Set(currentEntry?.keys() ?? []);
|
|
1368
|
+
for (const token of oldTokens)
|
|
1369
|
+
affectedTokens.add(token);
|
|
1370
|
+
for (const token of currentTokens)
|
|
1371
|
+
affectedTokens.add(token);
|
|
1372
|
+
if (file === void 0)
|
|
1373
|
+
tokensByFile.delete(fileKey);
|
|
1374
|
+
else
|
|
1375
|
+
tokensByFile.set(fileKey, currentTokens);
|
|
1376
|
+
}
|
|
1377
|
+
for (const token of affectedTokens) {
|
|
1378
|
+
const list = index.postings.get(token);
|
|
1379
|
+
const flat = [];
|
|
1380
|
+
if (list) {
|
|
1381
|
+
for (let i = 0; i < list.length; i += 1) {
|
|
1382
|
+
const slot = slotByFileId.get(list.fileIdAt(i));
|
|
1383
|
+
if (slot !== void 0)
|
|
1384
|
+
flat.push(slot, list.lineAt(i));
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
const at = postingAt.get(token);
|
|
1388
|
+
if (flat.length === 0) {
|
|
1389
|
+
if (at !== void 0)
|
|
1390
|
+
removedTokens.add(token);
|
|
1391
|
+
} else if (at === void 0) {
|
|
1392
|
+
postings.push([token, flat]);
|
|
1393
|
+
postingAt.set(token, postings.length - 1);
|
|
1394
|
+
} else {
|
|
1395
|
+
postings[at] = [postings[at][0], flat];
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
const compactedPostings = removedTokens.size ? postings.filter(([token]) => !removedTokens.has(token)) : postings;
|
|
1399
|
+
const forward = index.forward ? cache.serialized.forward?.slice().map((entry) => [entry[0], entry[1]]) ?? [] : void 0;
|
|
1400
|
+
for (const fileKey of dirty) {
|
|
1401
|
+
const file = fileByKey.get(fileKey);
|
|
1402
|
+
const fileId = file === void 0 ? void 0 : index.fileTable.idFor(wordIndexKey(file));
|
|
1403
|
+
const slot = fileId === void 0 ? void 0 : slotByFileId.get(fileId);
|
|
1404
|
+
if (slot === void 0 || !forward || file === void 0)
|
|
1405
|
+
continue;
|
|
1406
|
+
forward[slot] = [slot, [...index.forward?.get(file)?.entries() ?? []]];
|
|
1407
|
+
}
|
|
1408
|
+
const serialized = {
|
|
1409
|
+
...cache.serialized,
|
|
1410
|
+
files: filesInWireOrder,
|
|
1411
|
+
postings: compactedPostings,
|
|
1412
|
+
docLengths: filesInWireOrder.map((file) => index.docLengths.get(file) ?? 0),
|
|
1413
|
+
fileMtimes: filesInWireOrder.map((file) => index.fileMtimes.get(file) ?? 0),
|
|
1414
|
+
fileSizes: filesInWireOrder.map((file) => index.fileSizes.get(file) ?? 0),
|
|
1415
|
+
forward,
|
|
1416
|
+
totalTokens: index.totalTokens,
|
|
1417
|
+
indexedFileCount: index.docCount,
|
|
1418
|
+
truncated: index.truncated
|
|
1419
|
+
};
|
|
1420
|
+
_lastSerializeWork = {
|
|
1421
|
+
affectedTokenCount: affectedTokens.size,
|
|
1422
|
+
tookFullPath: false
|
|
1423
|
+
};
|
|
1424
|
+
return {
|
|
1425
|
+
serialized,
|
|
1426
|
+
slotByFileId,
|
|
1427
|
+
tokensByFile,
|
|
1428
|
+
wireBytes: null
|
|
1429
|
+
};
|
|
1430
|
+
}
|
|
1431
|
+
function serializeWordIndex(index) {
|
|
1432
|
+
const prior = serializedWordIndexCaches.get(index);
|
|
1433
|
+
const cache = prior ? serializeWordIndexIncrementally(index, prior) : serializeWordIndexFull(index);
|
|
1434
|
+
serializedWordIndexCaches.set(index, cache);
|
|
1435
|
+
serializedWordIndexSources.set(cache.serialized, index);
|
|
1436
|
+
index.dirtyFiles?.clear();
|
|
1437
|
+
return cache.serialized;
|
|
1438
|
+
}
|
|
1439
|
+
function deserializeWordIndex(data) {
|
|
1440
|
+
if (!data || data.version !== WORD_INDEX_FORMAT_VERSION || !Array.isArray(data.files) || !Array.isArray(data.postings) || !Array.isArray(data.docLengths) || !Array.isArray(data.fileMtimes)) {
|
|
1441
|
+
return null;
|
|
1442
|
+
}
|
|
1443
|
+
let canonical = data.docLengths.length === data.files.length && data.fileMtimes.length === data.files.length;
|
|
1444
|
+
let needsDeepSanitize = !Array.isArray(data.forward);
|
|
1445
|
+
if (needsDeepSanitize)
|
|
1446
|
+
canonical = false;
|
|
1447
|
+
const fileKeys = /* @__PURE__ */ new Set();
|
|
1448
|
+
for (const file of data.files) {
|
|
1449
|
+
if (typeof file !== "string")
|
|
1450
|
+
return null;
|
|
1451
|
+
const key = wordIndexKey(file);
|
|
1452
|
+
if (fileKeys.has(key)) {
|
|
1453
|
+
canonical = false;
|
|
1454
|
+
needsDeepSanitize = true;
|
|
1455
|
+
}
|
|
1456
|
+
fileKeys.add(key);
|
|
1457
|
+
}
|
|
1458
|
+
const docLengths = new PathKeyedMap(wordIndexKey);
|
|
1459
|
+
const fileTable = new WordIndexFileTable();
|
|
1460
|
+
const fileIdBySlot = data.files.map((file) => fileTable.intern(wordIndexKey(file), file));
|
|
1461
|
+
const slotByFileId = /* @__PURE__ */ new Map();
|
|
1462
|
+
fileIdBySlot.forEach((fileId, slot) => {
|
|
1463
|
+
if (!slotByFileId.has(fileId))
|
|
1464
|
+
slotByFileId.set(fileId, slot);
|
|
1465
|
+
});
|
|
1466
|
+
const fileMtimes = new PathKeyedMap(wordIndexKey);
|
|
1467
|
+
const fileSizes = new PathKeyedMap(wordIndexKey);
|
|
1468
|
+
data.files.forEach((file, i) => {
|
|
1469
|
+
const value = data.docLengths[i];
|
|
1470
|
+
if (!isCanonicalWordIndexNumber(value) || value < 0)
|
|
1471
|
+
canonical = false;
|
|
1472
|
+
docLengths.set(file, isCanonicalWordIndexNumber(value) && value >= 0 ? value : 0);
|
|
1473
|
+
});
|
|
1474
|
+
data.files.forEach((file, i) => {
|
|
1475
|
+
const value = data.fileMtimes[i];
|
|
1476
|
+
if (typeof value !== "number" || !Number.isFinite(value))
|
|
1477
|
+
canonical = false;
|
|
1478
|
+
fileMtimes.set(file, typeof value === "number" && Number.isFinite(value) ? value : 0);
|
|
1479
|
+
});
|
|
1480
|
+
if (Array.isArray(data.fileSizes) && data.fileSizes.length === data.files.length) {
|
|
1481
|
+
data.files.forEach((file, i) => {
|
|
1482
|
+
const value = data.fileSizes?.[i];
|
|
1483
|
+
if (!isCanonicalWordIndexNumber(value) || value < 0)
|
|
1484
|
+
canonical = false;
|
|
1485
|
+
fileSizes.set(file, isCanonicalWordIndexNumber(value) && value >= 0 ? value : 0);
|
|
1486
|
+
});
|
|
1487
|
+
} else {
|
|
1488
|
+
canonical = false;
|
|
1489
|
+
}
|
|
1490
|
+
const postings = /* @__PURE__ */ new Map();
|
|
1491
|
+
const postingTokens = /* @__PURE__ */ new Set();
|
|
1492
|
+
const postingFileCounts = /* @__PURE__ */ new Map();
|
|
1493
|
+
for (const posting of data.postings) {
|
|
1494
|
+
if (!Array.isArray(posting) || posting.length !== 2) {
|
|
1495
|
+
canonical = false;
|
|
1496
|
+
needsDeepSanitize = true;
|
|
1497
|
+
continue;
|
|
1498
|
+
}
|
|
1499
|
+
const [token, flat] = posting;
|
|
1500
|
+
if (!isCanonicalWordIndexToken(token) || postingTokens.has(token) || !Array.isArray(flat) || flat.length === 0 || flat.length % 2 !== 0) {
|
|
1501
|
+
canonical = false;
|
|
1502
|
+
needsDeepSanitize = true;
|
|
1503
|
+
continue;
|
|
1504
|
+
}
|
|
1505
|
+
postingTokens.add(token);
|
|
1506
|
+
const lanes = [];
|
|
1507
|
+
const seenPairs = /* @__PURE__ */ new Set();
|
|
1508
|
+
const observedCounts = /* @__PURE__ */ new Map();
|
|
1509
|
+
for (let i = 0; i < flat.length; i += 2) {
|
|
1510
|
+
const slot = flat[i];
|
|
1511
|
+
const line = flat[i + 1];
|
|
1512
|
+
if (!isCanonicalWordIndexNumber(slot) || slot < 0 || slot >= fileIdBySlot.length || !isCanonicalWordIndexNumber(line) || line < 1 || line > WORD_INDEX_INT32_MAX) {
|
|
1513
|
+
canonical = false;
|
|
1514
|
+
needsDeepSanitize = true;
|
|
1515
|
+
continue;
|
|
1516
|
+
}
|
|
1517
|
+
const fileId = fileIdBySlot[slot];
|
|
1518
|
+
const pairKey = fileId <= WORD_INDEX_PACKED_FILE_ID_MAX ? fileId * (WORD_INDEX_INT32_MAX + 1) + line : `${fileId}:${line}`;
|
|
1519
|
+
if (seenPairs.has(pairKey)) {
|
|
1520
|
+
canonical = false;
|
|
1521
|
+
needsDeepSanitize = true;
|
|
1522
|
+
}
|
|
1523
|
+
seenPairs.add(pairKey);
|
|
1524
|
+
lanes.push(fileId, line);
|
|
1525
|
+
observedCounts.set(fileId, (observedCounts.get(fileId) ?? 0) + 1);
|
|
1526
|
+
}
|
|
1527
|
+
if (lanes.length === 0)
|
|
1528
|
+
continue;
|
|
1529
|
+
const list = WordPostingList.fromLanes(token, lanes);
|
|
1530
|
+
postings.set(token, list);
|
|
1531
|
+
postingFileCounts.set(token, observedCounts);
|
|
1532
|
+
}
|
|
1533
|
+
compactPostingsIntoArena(postings);
|
|
1534
|
+
let forward;
|
|
1535
|
+
if (Array.isArray(data.forward)) {
|
|
1536
|
+
const candidate = data.files.map(() => /* @__PURE__ */ new Map());
|
|
1537
|
+
const forwardTotals = /* @__PURE__ */ new Map();
|
|
1538
|
+
if (data.forward.length !== data.files.length)
|
|
1539
|
+
canonical = false;
|
|
1540
|
+
if (data.forward.length !== data.files.length)
|
|
1541
|
+
needsDeepSanitize = true;
|
|
1542
|
+
for (const [entryIndex, entry] of data.forward.entries()) {
|
|
1543
|
+
if (!Array.isArray(entry) || entry.length !== 2) {
|
|
1544
|
+
canonical = false;
|
|
1545
|
+
needsDeepSanitize = true;
|
|
1546
|
+
continue;
|
|
1547
|
+
}
|
|
1548
|
+
const [fileIdx, tokenCounts] = entry;
|
|
1549
|
+
if (!isCanonicalWordIndexNumber(fileIdx) || fileIdx !== entryIndex || fileIdx < 0 || fileIdx >= data.files.length || !Array.isArray(tokenCounts)) {
|
|
1550
|
+
canonical = false;
|
|
1551
|
+
needsDeepSanitize = true;
|
|
1552
|
+
continue;
|
|
1553
|
+
}
|
|
1554
|
+
for (const pair of tokenCounts) {
|
|
1555
|
+
if (!Array.isArray(pair) || pair.length !== 2 || !isCanonicalWordIndexToken(pair[0]) || !isCanonicalWordIndexNumber(pair[1]) || pair[1] < 1 || pair[1] > WORD_INDEX_INT32_MAX || candidate[fileIdx].has(pair[0])) {
|
|
1556
|
+
canonical = false;
|
|
1557
|
+
needsDeepSanitize = true;
|
|
1558
|
+
continue;
|
|
1559
|
+
}
|
|
1560
|
+
candidate[fileIdx].set(pair[0], pair[1]);
|
|
1561
|
+
forwardTotals.set(pair[0], (forwardTotals.get(pair[0]) ?? 0) + pair[1]);
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
let forwardMatchesPostings = true;
|
|
1565
|
+
for (const [token, list] of postings) {
|
|
1566
|
+
if (forwardTotals.get(token) !== list.length) {
|
|
1567
|
+
forwardMatchesPostings = false;
|
|
1568
|
+
}
|
|
1569
|
+
const observed = postingFileCounts.get(token);
|
|
1570
|
+
if (!observed) {
|
|
1571
|
+
forwardMatchesPostings = false;
|
|
1572
|
+
continue;
|
|
1573
|
+
}
|
|
1574
|
+
for (const [fileId, count] of observed) {
|
|
1575
|
+
const slot = slotByFileId.get(fileId);
|
|
1576
|
+
if (slot === void 0 || candidate[slot].get(token) !== count) {
|
|
1577
|
+
forwardMatchesPostings = false;
|
|
1578
|
+
}
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
for (const token of forwardTotals.keys()) {
|
|
1582
|
+
if (!postingTokens.has(token))
|
|
1583
|
+
forwardMatchesPostings = false;
|
|
1584
|
+
}
|
|
1585
|
+
if (!forwardMatchesPostings)
|
|
1586
|
+
canonical = false;
|
|
1587
|
+
if (!forwardMatchesPostings)
|
|
1588
|
+
needsDeepSanitize = true;
|
|
1589
|
+
forward = new PathKeyedMap(wordIndexKey);
|
|
1590
|
+
for (let i = 0; i < data.files.length; i += 1) {
|
|
1591
|
+
forward.set(data.files[i], WordForwardEntry.fromTally(candidate[i]));
|
|
1592
|
+
}
|
|
1593
|
+
} else if (Object.prototype.hasOwnProperty.call(data, "forward")) {
|
|
1594
|
+
canonical = false;
|
|
1595
|
+
needsDeepSanitize = true;
|
|
1596
|
+
}
|
|
1597
|
+
if (needsDeepSanitize) {
|
|
1598
|
+
const actualForwardCounts = data.files.map(() => /* @__PURE__ */ new Map());
|
|
1599
|
+
for (const [token, list] of postings) {
|
|
1600
|
+
const seenPairs = /* @__PURE__ */ new Set();
|
|
1601
|
+
const sanitized = new WordPostingList(token, list.length);
|
|
1602
|
+
for (let i = 0; i < list.length; i += 1) {
|
|
1603
|
+
const fileId = list.fileIdAt(i);
|
|
1604
|
+
const line = list.lineAt(i);
|
|
1605
|
+
const pairKey = `${fileId}:${line}`;
|
|
1606
|
+
if (seenPairs.has(pairKey))
|
|
1607
|
+
continue;
|
|
1608
|
+
seenPairs.add(pairKey);
|
|
1609
|
+
sanitized.push(fileId, line);
|
|
1610
|
+
const slot = slotByFileId.get(fileId);
|
|
1611
|
+
if (slot !== void 0) {
|
|
1612
|
+
const counts = actualForwardCounts[slot];
|
|
1613
|
+
counts.set(token, (counts.get(token) ?? 0) + 1);
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
postings.set(token, sanitized);
|
|
1617
|
+
}
|
|
1618
|
+
compactPostingsIntoArena(postings);
|
|
1619
|
+
if (Array.isArray(data.forward)) {
|
|
1620
|
+
forward = new PathKeyedMap(wordIndexKey);
|
|
1621
|
+
for (let i = 0; i < data.files.length; i += 1) {
|
|
1622
|
+
const canonicalSlot = slotByFileId.get(fileIdBySlot[i]) ?? i;
|
|
1623
|
+
forward.set(data.files[i], WordForwardEntry.fromTally(actualForwardCounts[canonicalSlot]));
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
const expectedTotalTokens = [...docLengths.values()].reduce((total, length) => total + length, 0);
|
|
1628
|
+
const totalTokens = isCanonicalWordIndexNumber(expectedTotalTokens) ? expectedTotalTokens : 0;
|
|
1629
|
+
if (!isCanonicalWordIndexNumber(data.totalTokens) || data.totalTokens !== totalTokens) {
|
|
1630
|
+
canonical = false;
|
|
1631
|
+
}
|
|
1632
|
+
if (typeof data.indexedFileCount !== "number" || data.indexedFileCount !== docLengths.size) {
|
|
1633
|
+
canonical = false;
|
|
1634
|
+
}
|
|
1635
|
+
if (typeof data.truncated !== "boolean")
|
|
1636
|
+
canonical = false;
|
|
1637
|
+
const index = {
|
|
1638
|
+
postings,
|
|
1639
|
+
fileTable,
|
|
1640
|
+
docLengths,
|
|
1641
|
+
totalTokens,
|
|
1642
|
+
docCount: docLengths.size,
|
|
1643
|
+
truncated: data.truncated === true,
|
|
1644
|
+
forward,
|
|
1645
|
+
fileMtimes,
|
|
1646
|
+
fileSizes,
|
|
1647
|
+
// Postings were just packed into one arena above, so the running gate
|
|
1648
|
+
// starts from the exact post-compaction store count (#2117).
|
|
1649
|
+
postingStoreCount: countPostingBackingStores(postings),
|
|
1650
|
+
recompactFlight: createSingleFlight(),
|
|
1651
|
+
// A deserialized index is a fresh object distinct from whichever index
|
|
1652
|
+
// produced `data`. Without this, every per-edit dirty mark on a
|
|
1653
|
+
// session-start reload (#2068) is a no-op against `undefined`, and
|
|
1654
|
+
// serializeWordIndexIncrementally's `!dirty` branch then returns the
|
|
1655
|
+
// stale cached wire view forever, silently dropping every later edit
|
|
1656
|
+
// from the persisted snapshot.
|
|
1657
|
+
dirtyFiles: /* @__PURE__ */ new Set()
|
|
1658
|
+
};
|
|
1659
|
+
const tokensByFile = /* @__PURE__ */ new Map();
|
|
1660
|
+
if (forward) {
|
|
1661
|
+
for (const file of data.files) {
|
|
1662
|
+
tokensByFile.set(wordIndexKey(file), new Set(forward.get(file)?.keys() ?? []));
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
if (canonical) {
|
|
1666
|
+
serializedWordIndexCaches.set(index, {
|
|
1667
|
+
serialized: data,
|
|
1668
|
+
slotByFileId,
|
|
1669
|
+
tokensByFile,
|
|
1670
|
+
wireBytes: null
|
|
1671
|
+
});
|
|
1672
|
+
}
|
|
1673
|
+
return index;
|
|
1674
|
+
}
|
|
1675
|
+
var buildStatuses = /* @__PURE__ */ new Map();
|
|
1676
|
+
function getWordIndexBuildStatus(cwd) {
|
|
1677
|
+
return buildStatuses.get(path2.resolve(cwd));
|
|
1678
|
+
}
|
|
1679
|
+
function _resetWordIndexBuildGuardForTests() {
|
|
1680
|
+
buildStatuses.clear();
|
|
1681
|
+
}
|
|
1682
|
+
function triggerBackgroundWordIndexBuild(cwd, dbg, options = {}) {
|
|
1683
|
+
const key = path2.resolve(cwd);
|
|
1684
|
+
if (isAtOrAboveHomeDir(key, options.homeDir)) {
|
|
1685
|
+
const reason = `root at/above home directory (${key})`;
|
|
1686
|
+
dbg?.(`word-index cold-build: skipped \u2014 ${reason}`);
|
|
1687
|
+
logWordIndex({
|
|
1688
|
+
phase: "cold_build_refused",
|
|
1689
|
+
cwd: key,
|
|
1690
|
+
trigger: "cold_query",
|
|
1691
|
+
reason
|
|
1692
|
+
});
|
|
1693
|
+
const status2 = { state: "refused", reason };
|
|
1694
|
+
buildStatuses.set(key, status2);
|
|
1695
|
+
return status2;
|
|
1696
|
+
}
|
|
1697
|
+
const current = buildStatuses.get(key);
|
|
1698
|
+
if (current?.state === "building")
|
|
1699
|
+
return current;
|
|
1700
|
+
const status = { state: "building" };
|
|
1701
|
+
buildStatuses.set(key, status);
|
|
1702
|
+
void (async () => {
|
|
1703
|
+
const startMs = Date.now();
|
|
1704
|
+
try {
|
|
1705
|
+
const { loadProjectSnapshot, saveProjectSnapshot, PROJECT_SNAPSHOT_VERSION } = await import("./chunk-AJXODZY6.js");
|
|
1706
|
+
const docs = await collectWordIndexDocs(key);
|
|
1707
|
+
const index = await buildWordIndexAsync(docs);
|
|
1708
|
+
const existing = loadProjectSnapshot(key);
|
|
1709
|
+
const snapshot = existing ?? {
|
|
1710
|
+
version: PROJECT_SNAPSHOT_VERSION,
|
|
1711
|
+
projectRoot: key,
|
|
1712
|
+
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1713
|
+
seq: 0,
|
|
1714
|
+
files: {},
|
|
1715
|
+
symbols: {},
|
|
1716
|
+
reverseDeps: {},
|
|
1717
|
+
cachedExports: []
|
|
1718
|
+
};
|
|
1719
|
+
snapshot.generatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1720
|
+
snapshot.wordIndex = serializeWordIndex(index);
|
|
1721
|
+
saveProjectSnapshot(key, snapshot);
|
|
1722
|
+
dbg?.(`word-index cold-build: ${index.docCount} files, ${index.postings.size} tokens (${Date.now() - startMs}ms)`);
|
|
1723
|
+
logWordIndex({
|
|
1724
|
+
phase: "cold_build",
|
|
1725
|
+
cwd: key,
|
|
1726
|
+
trigger: "cold_query",
|
|
1727
|
+
durationMs: Date.now() - startMs,
|
|
1728
|
+
indexedFileCount: index.docCount,
|
|
1729
|
+
tokens: index.postings.size,
|
|
1730
|
+
postingEntries: countWordIndexPostingEntries(index),
|
|
1731
|
+
residentBytes: estimateWordIndexResidentBytes(index),
|
|
1732
|
+
truncated: index.truncated,
|
|
1733
|
+
skipped: docs.skipped
|
|
1734
|
+
});
|
|
1735
|
+
buildStatuses.delete(key);
|
|
1736
|
+
} catch (err) {
|
|
1737
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
1738
|
+
buildStatuses.set(key, { state: "failed", reason });
|
|
1739
|
+
dbg?.(`word-index cold-build: failed: ${reason}`);
|
|
1740
|
+
logWordIndex({
|
|
1741
|
+
phase: "cold_build_failed",
|
|
1742
|
+
cwd: key,
|
|
1743
|
+
trigger: "cold_query",
|
|
1744
|
+
durationMs: Date.now() - startMs,
|
|
1745
|
+
error: reason
|
|
1746
|
+
});
|
|
1747
|
+
}
|
|
1748
|
+
})();
|
|
1749
|
+
return status;
|
|
1750
|
+
}
|
|
1751
|
+
var WORD_INDEX_PERSIST_DEBOUNCE_MS_DEFAULT = 1500;
|
|
1752
|
+
function wordIndexPersistDebounceMs() {
|
|
1753
|
+
const raw = Number(process.env.PI_LENS_WORD_INDEX_PERSIST_DEBOUNCE_MS);
|
|
1754
|
+
return Number.isFinite(raw) && raw >= 0 ? raw : WORD_INDEX_PERSIST_DEBOUNCE_MS_DEFAULT;
|
|
1755
|
+
}
|
|
1756
|
+
var wordIndexPersistScheduler;
|
|
1757
|
+
function getWordIndexPersistScheduler() {
|
|
1758
|
+
if (wordIndexPersistScheduler)
|
|
1759
|
+
return wordIndexPersistScheduler;
|
|
1760
|
+
wordIndexPersistScheduler = createDebounceScheduler({
|
|
1761
|
+
debounceMs: wordIndexPersistDebounceMs,
|
|
1762
|
+
write(_key, pending) {
|
|
1763
|
+
void writeWordIndexSnapshot(pending.cwd, pending.index, pending.dbg);
|
|
1764
|
+
}
|
|
1765
|
+
});
|
|
1766
|
+
return wordIndexPersistScheduler;
|
|
1767
|
+
}
|
|
1768
|
+
async function writeWordIndexSnapshot(cwd, index, dbg) {
|
|
1769
|
+
const persistStartedAt = Date.now();
|
|
1770
|
+
try {
|
|
1771
|
+
const { loadProjectSnapshot, saveProjectSnapshot, PROJECT_SNAPSHOT_VERSION } = await import("./chunk-AJXODZY6.js");
|
|
1772
|
+
const existing = loadProjectSnapshot(cwd);
|
|
1773
|
+
const snapshot = existing ?? {
|
|
1774
|
+
version: PROJECT_SNAPSHOT_VERSION,
|
|
1775
|
+
projectRoot: path2.resolve(cwd),
|
|
1776
|
+
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1777
|
+
seq: 0,
|
|
1778
|
+
files: {},
|
|
1779
|
+
symbols: {},
|
|
1780
|
+
reverseDeps: {},
|
|
1781
|
+
cachedExports: []
|
|
1782
|
+
};
|
|
1783
|
+
snapshot.generatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1784
|
+
const serializeStartedAt = performance.now();
|
|
1785
|
+
snapshot.wordIndex = serializeWordIndex(index);
|
|
1786
|
+
const serializeMs = performance.now() - serializeStartedAt;
|
|
1787
|
+
saveProjectSnapshot(cwd, snapshot);
|
|
1788
|
+
const writeMs = performance.now() - serializeStartedAt - serializeMs;
|
|
1789
|
+
dbg?.(`word-index persist: ${index.docCount} files, ${index.postings.size} tokens`);
|
|
1790
|
+
logWordIndex({
|
|
1791
|
+
phase: "persist_succeeded",
|
|
1792
|
+
cwd: path2.resolve(cwd),
|
|
1793
|
+
trigger: "per_edit",
|
|
1794
|
+
durationMs: Date.now() - persistStartedAt,
|
|
1795
|
+
serializeMs,
|
|
1796
|
+
writeMs,
|
|
1797
|
+
indexedFileCount: index.docCount,
|
|
1798
|
+
tokens: index.postings.size,
|
|
1799
|
+
postingEntries: countWordIndexPostingEntries(index),
|
|
1800
|
+
residentBytes: estimateWordIndexResidentBytes(index),
|
|
1801
|
+
replacementCount: index.replacementStats?.count ?? 0,
|
|
1802
|
+
totalReplacementMs: index.replacementStats?.totalMs ?? 0,
|
|
1803
|
+
maxReplacementMs: index.replacementStats?.maxMs ?? 0
|
|
1804
|
+
});
|
|
1805
|
+
index.replacementStats = { count: 0, totalMs: 0, maxMs: 0 };
|
|
1806
|
+
} catch (err) {
|
|
1807
|
+
dbg?.(`word-index persist: failed: ${err}`);
|
|
1808
|
+
logWordIndex({
|
|
1809
|
+
phase: "persist_failed",
|
|
1810
|
+
cwd: path2.resolve(cwd),
|
|
1811
|
+
trigger: "per_edit",
|
|
1812
|
+
indexedFileCount: index.docCount,
|
|
1813
|
+
error: err instanceof Error ? err.message : String(err)
|
|
1814
|
+
});
|
|
1815
|
+
}
|
|
1816
|
+
}
|
|
1817
|
+
function scheduleWordIndexPersist(cwd, index, dbg) {
|
|
1818
|
+
const key = path2.resolve(cwd);
|
|
1819
|
+
getWordIndexPersistScheduler().schedule(key, { cwd: key, index, dbg });
|
|
1820
|
+
}
|
|
1821
|
+
function flushWordIndexPersistsForTests() {
|
|
1822
|
+
getWordIndexPersistScheduler().flushAll();
|
|
1823
|
+
}
|
|
1824
|
+
|
|
1825
|
+
export {
|
|
1826
|
+
logWordIndex,
|
|
1827
|
+
wordIndexKey,
|
|
1828
|
+
splitIdentifier,
|
|
1829
|
+
tokenizeLine,
|
|
1830
|
+
countWordIndexPostingEntries,
|
|
1831
|
+
estimateWordIndexResidentBytes,
|
|
1832
|
+
wordIndexPostingHits,
|
|
1833
|
+
flushWordIndexRecompactionsForTests,
|
|
1834
|
+
buildWordIndex,
|
|
1835
|
+
buildWordIndexAsync,
|
|
1836
|
+
removeWordIndexDocument,
|
|
1837
|
+
updateWordIndexDocument,
|
|
1838
|
+
removeWordIndexDocumentAsync,
|
|
1839
|
+
updateWordIndexDocumentForEdit,
|
|
1840
|
+
updateWordIndexDocumentAsync,
|
|
1841
|
+
WORD_INDEX_MAX_BYTES,
|
|
1842
|
+
collectWordIndexDocs,
|
|
1843
|
+
refreshWordIndexIncrementally,
|
|
1844
|
+
WordIndexQueryError,
|
|
1845
|
+
parseWordIndexQuery,
|
|
1846
|
+
buildWordIndexQueryFilter,
|
|
1847
|
+
searchWordIndex,
|
|
1848
|
+
centralityFromReverseDeps,
|
|
1849
|
+
WORD_INDEX_FORMAT_VERSION,
|
|
1850
|
+
getWordIndexWireBytes,
|
|
1851
|
+
recordPersistedWordIndexWireBytes,
|
|
1852
|
+
getLastWordIndexSerializeWork,
|
|
1853
|
+
serializeWordIndex,
|
|
1854
|
+
deserializeWordIndex,
|
|
1855
|
+
getWordIndexBuildStatus,
|
|
1856
|
+
_resetWordIndexBuildGuardForTests,
|
|
1857
|
+
triggerBackgroundWordIndexBuild,
|
|
1858
|
+
scheduleWordIndexPersist,
|
|
1859
|
+
flushWordIndexPersistsForTests
|
|
1860
|
+
};
|