@iowarp/clio-coder 0.3.1 → 0.3.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/CHANGELOG.md +90 -2
- package/CONTRIBUTING.md +23 -23
- package/README.md +284 -613
- package/dist/{acp-FPR54DGL.js → acp-BIYHVZIM.js} +43 -53
- package/dist/{agents-OGPIHPJH.js → agents-YT6SSRIT.js} +43 -26
- package/dist/assets/codewiki.json +1 -1
- package/dist/{auth-IC3K6NIZ.js → auth-5TWEIYDN.js} +20 -12
- package/dist/{chunk-PV4JUBVJ.js → chunk-2EHAIA3X.js} +40 -21
- package/dist/{chunk-IS3ONKU3.js → chunk-2IR2NMPA.js} +6 -4
- package/dist/chunk-2SFS6XQE.js +122 -0
- package/dist/chunk-2VTFPG5O.js +48 -0
- package/dist/{chunk-MAR7Y6HW.js → chunk-3ZXDFGR5.js} +23 -16
- package/dist/chunk-4BJ5BYCE.js +61 -0
- package/dist/{chunk-474KN5II.js → chunk-4BPJXDWC.js} +111 -181
- package/dist/chunk-4KLWL3UC.js +18 -0
- package/dist/chunk-4VP4KH3K.js +962 -0
- package/dist/chunk-4ZG3XFUR.js +77 -0
- package/dist/chunk-5B2AEOW5.js +5407 -0
- package/dist/{chunk-K2ITRMHZ.js → chunk-5TSRNF4G.js} +6 -138
- package/dist/{chunk-OLBBMFRD.js → chunk-5UUP6MWO.js} +24 -62
- package/dist/chunk-65DEGPJ6.js +52 -0
- package/dist/chunk-6EJMN2Y3.js +17 -0
- package/dist/chunk-6EJV5X2W.js +16405 -0
- package/dist/chunk-6N5PTWMY.js +136 -0
- package/dist/chunk-6XLNIQDB.js +27 -0
- package/dist/{chunk-TEKV33Q5.js → chunk-77VKQEHF.js} +65 -33
- package/dist/chunk-7CR24IG7.js +242 -0
- package/dist/{chunk-M5T5VO65.js → chunk-7EYHLWU7.js} +837 -635
- package/dist/chunk-7MNJORFF.js +22 -0
- package/dist/{chunk-KY56HMHH.js → chunk-A3CYT5EX.js} +125 -31
- package/dist/chunk-AGYYIBLL.js +1069 -0
- package/dist/chunk-AO4RKG4M.js +277 -0
- package/dist/{chunk-GB6QRBXN.js → chunk-APJ265NV.js} +54 -1187
- package/dist/chunk-ARBGF5F7.js +174 -0
- package/dist/{chunk-673JJUWJ.js → chunk-BMEMKKIT.js} +2 -2
- package/dist/chunk-CBCAPZAA.js +229 -0
- package/dist/chunk-CMZWFGD2.js +352 -0
- package/dist/chunk-ECH6PKUQ.js +39 -0
- package/dist/chunk-ED4KHGC3.js +143 -0
- package/dist/chunk-EKMEHE4H.js +340 -0
- package/dist/{chunk-RPTR2H26.js → chunk-EPVUXGXG.js} +21 -15
- package/dist/chunk-FCSXB6T2.js +338 -0
- package/dist/chunk-FJ3H4MN5.js +48 -0
- package/dist/chunk-FQ4SKYE4.js +29 -0
- package/dist/chunk-G2DE3C7R.js +644 -0
- package/dist/chunk-G4BMMOKF.js +182 -0
- package/dist/{chunk-ZPY3JZ5E.js → chunk-GGXXDWE4.js} +183 -1233
- package/dist/chunk-HC4CLZ2Y.js +68 -0
- package/dist/{chunk-LU4TK2PR.js → chunk-HFSBBKSQ.js} +5 -56
- package/dist/{chunk-PIUMUEMV.js → chunk-HKIYEGME.js} +10 -6
- package/dist/chunk-I4HZDVNP.js +73 -0
- package/dist/{chunk-4QKXUHSR.js → chunk-IGLFWIYI.js} +70 -20
- package/dist/chunk-IKCO5N3L.js +162 -0
- package/dist/chunk-IR4CFBFN.js +56 -0
- package/dist/{chunk-PFEFKVGL.js → chunk-J5HN4RYU.js} +13 -11
- package/dist/{chunk-R5KLMSBV.js → chunk-J5Q24KAG.js} +2 -2
- package/dist/{chunk-K5XEMXTI.js → chunk-JVCV3ICN.js} +1 -1
- package/dist/chunk-KJ5LWLOE.js +1077 -0
- package/dist/chunk-LBMZMYH2.js +285 -0
- package/dist/{chunk-G34LV2PF.js → chunk-LBNRH5WM.js} +84 -170
- package/dist/{chunk-H6F6BYOH.js → chunk-LZSJBIVT.js} +7003 -7434
- package/dist/{chunk-HQQID6OA.js → chunk-M6SHUN7Q.js} +5 -5
- package/dist/chunk-MAW544W2.js +1882 -0
- package/dist/chunk-MBS4V7ZP.js +217 -0
- package/dist/{chunk-FST4FYJB.js → chunk-MFFY33HR.js} +99 -140
- package/dist/chunk-MNA4JGU4.js +255 -0
- package/dist/chunk-MQSRRFWA.js +3428 -0
- package/dist/{chunk-BSU2YIWB.js → chunk-MVVUPGPW.js} +131 -136
- package/dist/chunk-OAO4GE4M.js +619 -0
- package/dist/chunk-OHHN2SO4.js +5135 -0
- package/dist/chunk-OKGUZO2U.js +34 -0
- package/dist/{chunk-GAEBEQVI.js → chunk-OOJYHWRB.js} +32 -346
- package/dist/{chunk-Q5WJOSJ7.js → chunk-OQ33BKR3.js} +2 -1
- package/dist/chunk-OQE5J4C6.js +73 -0
- package/dist/{chunk-KKNLWXI6.js → chunk-ORBHGJC5.js} +8 -8
- package/dist/chunk-POHLU5DW.js +1186 -0
- package/dist/chunk-QKMUKYO7.js +4961 -0
- package/dist/{chunk-ASND7OZK.js → chunk-QTYWRVRA.js} +13 -13
- package/dist/{chunk-EYOKLTMF.js → chunk-SRF2PJNW.js} +17 -3
- package/dist/chunk-SST6Z5JA.js +80 -0
- package/dist/chunk-STBPMHSX.js +2456 -0
- package/dist/chunk-T6YILFSB.js +80 -0
- package/dist/chunk-TZTZS7QK.js +227 -0
- package/dist/chunk-UOV2BYIW.js +107 -0
- package/dist/{chunk-Q3RUPKEJ.js → chunk-V4RXGQ5Q.js} +58 -189
- package/dist/chunk-VAKQQHWR.js +434 -0
- package/dist/chunk-VG7TBQIY.js +128 -0
- package/dist/chunk-VJWL6YS5.js +244 -0
- package/dist/chunk-WEH5XRJQ.js +32 -0
- package/dist/chunk-WMSVI4G2.js +2095 -0
- package/dist/chunk-WVO7V2QY.js +797 -0
- package/dist/chunk-X4RCMKVQ.js +641 -0
- package/dist/chunk-X75S7HFS.js +374 -0
- package/dist/chunk-XN3L4EYL.js +46 -0
- package/dist/{chunk-RDLVBZEO.js → chunk-YCWGATWI.js} +6 -4
- package/dist/chunk-YHZX5GEU.js +193 -0
- package/dist/chunk-YXLYO42X.js +91 -0
- package/dist/{chunk-NMOX6HFD.js → chunk-ZDOOVTXZ.js} +29 -77
- package/dist/chunk-ZI647VB5.js +37 -0
- package/dist/{chunk-C4PTHK7P.js → chunk-ZWLZP4ZT.js} +5 -5
- package/dist/cli/index.js +62 -54
- package/dist/clio-4LY5K2AC.js +25 -0
- package/dist/code-nav-7AX6FYE6.js +600 -0
- package/dist/codewiki/build-worker.js +66 -0
- package/dist/compile-cache-CVJMMODC.js +18 -0
- package/dist/{components-DMAOEKFB.js → components-KELWS457.js} +11 -6
- package/dist/{config-IRUQ7SE4.js → config-GTLUW2PR.js} +92 -55
- package/dist/configure-R6A64DHX.js +42 -0
- package/dist/context-5VKGUVJJ.js +866 -0
- package/dist/{context-3KWFLHJG.js → context-JFZEJ7W5.js} +15 -13
- package/dist/{context-5RADCKTR.js → context-RW5HC47S.js} +71 -35
- package/dist/{context-clear-7TSNPAAI.js → context-clear-6ZHBAZZT.js} +54 -28
- package/dist/{context-index-W4RLWOQH.js → context-index-BZ4UYMTC.js} +30 -24
- package/dist/dispatch-runner-VKBRCWQC.js +1997 -0
- package/dist/{docs-5AWSPS37.js → docs-2C2LTVT2.js} +23 -10
- package/dist/{doctor-UC5NAJYQ.js → doctor-KI767GSN.js} +27 -17
- package/dist/{eval-U6TJHRLX.js → eval-XSSNATB4.js} +29 -16
- package/dist/{evidence-YEGUW4L3.js → evidence-UA6AWDQQ.js} +46 -26
- package/dist/{evolve-TXARCTPG.js → evolve-QNTFGV6Z.js} +45 -25
- package/dist/{extensions-OZFJ3A3G.js → extensions-QVDOHDGJ.js} +16 -7
- package/dist/{fleet-6G3DHNYE.js → fleet-Q7UOMUSG.js} +163 -54
- package/dist/{fleet-preflight-DSNT37JK.js → fleet-preflight-DDN536IT.js} +7 -4
- package/dist/{init-KZ5QTF6M.js → init-WBB65ZHQ.js} +69 -32
- package/dist/{memory-73ESV5YC.js → memory-MD3O64RI.js} +48 -27
- package/dist/{models-A4PVNWJK.js → models-BZU34YWD.js} +39 -25
- package/dist/monitor-MEQA5C3I.js +661 -0
- package/dist/{chunk-FCIH3BIZ.js → orchestrator-CGFKEP27.js} +11832 -8687
- package/dist/{paths-C4H6IV77.js → paths-UXLN5YYZ.js} +10 -5
- package/dist/{preload-6WVMHX3A.js → preload-P6DGH2PZ.js} +2 -2
- package/dist/{reset-BGW6OGMV.js → reset-L2FQEE3E.js} +16 -10
- package/dist/{run-YTPEYQOH.js → run-IV4Q6RLN.js} +101 -61
- package/dist/{share-YIFFV4NQ.js → share-S5BZQC5I.js} +15 -8
- package/dist/{skills-2V6RA3OQ.js → skills-LQEKRDTN.js} +34 -14
- package/dist/{skills-eval-S2TVJO4F.js → skills-eval-3DC4HEWS.js} +70 -34
- package/dist/steer-GGWFUJUD.js +77 -0
- package/dist/{targets-TYXLPB23.js → targets-C4SSGQOB.js} +43 -27
- package/dist/terminal-lease-IT5JW2NR.js +395 -0
- package/dist/{trace-GGOJ6Q6Z.js → trace-PNCASAXC.js} +41 -16
- package/dist/{chunk-N6F52NLF.js → tree-sitter-HGKH6LG4.js} +28 -2306
- package/dist/{uninstall-LLLT4F4W.js → uninstall-FZCQCDKC.js} +10 -5
- package/dist/{upgrade-33G2LMM5.js → upgrade-7TT7SQ3G.js} +45 -25
- package/dist/{usage-ZAFSXKKG.js → usage-GV4PKT3M.js} +62 -31
- package/dist/verify-G6V4D2G7.js +716 -0
- package/dist/web-fetch-2YHJ3KTG.js +638 -0
- package/dist/{wiki-generate-NUQCVOQ3.js → wiki-generate-DQF6Z66B.js} +74 -34
- package/dist/worker/entry.js +221 -36
- package/dist/workspace-G4ZWUIPR.js +22 -0
- package/docs/README.md +22 -17
- package/docs/acp.md +168 -16
- package/docs/alcf-provider.md +1 -1
- package/docs/architecture.md +136 -7
- package/docs/artifact-versions.md +1 -1
- package/docs/built-in-agents.md +1 -1
- package/docs/capacity-and-scheduling.md +1 -1
- package/docs/commands-and-modes.md +114 -71
- package/docs/config-knobs-audit.md +1 -3
- package/docs/configuration-and-targets.md +174 -46
- package/docs/context-engine.md +29 -6
- package/docs/development-pipeline.md +26 -1
- package/docs/dispatch-architecture-rationale.md +1 -1
- package/docs/documentation-coverage.md +2 -2
- package/docs/documentation-guide.md +1 -1
- package/docs/environment-variables.md +13 -5
- package/docs/eval-runner.md +1 -1
- package/docs/evals-internal.md +1 -1
- package/docs/evidence-and-memory.md +6 -2
- package/docs/evolution.md +2 -2
- package/docs/exit-codes-and-output.md +15 -9
- package/docs/extensions-and-sharing.md +9 -9
- package/docs/fleet-dispatch.md +7 -5
- package/docs/git-commit-provenance.md +120 -0
- package/docs/glossary.md +1 -1
- package/docs/installation-and-lifecycle.md +34 -27
- package/docs/middleware-and-components.md +1 -1
- package/docs/model-catalog.md +45 -14
- package/docs/observability.md +8 -5
- package/docs/performance-methodology.md +491 -0
- package/docs/pi-boundary.md +72 -0
- package/docs/proactive-memory.md +3 -3
- package/docs/prompt-envelope-and-tools.md +24 -3
- package/docs/provider-adapter-cookbook.md +57 -4
- package/docs/release-cut-checklist.md +129 -115
- package/docs/safety-model.md +9 -5
- package/docs/scientific-validation.md +3 -3
- package/docs/session-lifecycle.md +55 -12
- package/docs/skills-marketplace.md +12 -8
- package/docs/time-conventions.md +1 -1
- package/docs/tool-usage.md +3 -3
- package/docs/trace-store.md +1 -1
- package/docs/troubleshooting.md +10 -7
- package/docs/tui-design.md +47 -10
- package/docs/worker-dispatch-mechanics.md +1 -1
- package/package.json +19 -22
- package/skills/coding/ast-grep/SKILL.md +136 -0
- package/skills/coding/ast-grep/evals.md +56 -0
- package/skills/coding/ast-grep/references/rule_reference.md +297 -0
- package/skills/coding/coding-standards/SKILL.md +113 -0
- package/skills/coding/coding-standards/evals.md +34 -0
- package/skills/coding/prototype/SKILL.md +86 -0
- package/skills/coding/prototype/evals.md +42 -0
- package/skills/coding/prototype/references/LOGIC.md +67 -0
- package/skills/coding/prototype/references/UI.md +112 -0
- package/skills/coding/tdd/SKILL.md +101 -0
- package/skills/coding/tdd/evals.md +41 -0
- package/skills/coding/tdd/references/mocking.md +59 -0
- package/skills/coding/tdd/references/tests.md +77 -0
- package/skills/context/context-handoff/SKILL.md +126 -0
- package/skills/context/context-handoff/evals.md +57 -0
- package/skills/context/context-handoff/scripts/new-handoff.sh +26 -0
- package/skills/context/context-prime/SKILL.md +95 -0
- package/skills/context/context-prime/evals.md +54 -0
- package/skills/meta/clio-dev/SKILL.md +91 -0
- package/skills/meta/clio-dev/evals.md +45 -0
- package/skills/meta/clio-test/SKILL.md +130 -0
- package/skills/meta/clio-test/evals.md +43 -0
- package/skills/meta/clio-test/references/harness.md +97 -0
- package/skills/meta/clio-test/references/test-map.md +59 -0
- package/skills/meta/credentials/SKILL.md +125 -0
- package/skills/meta/credentials/evals.md +104 -0
- package/skills/meta/find-skills/SKILL.md +72 -0
- package/skills/meta/find-skills/evals.md +47 -0
- package/skills/meta/herdr/SKILL.md +127 -0
- package/skills/meta/herdr/evals.md +38 -0
- package/skills/meta/skill-craft/SKILL.md +102 -0
- package/skills/meta/skill-craft/evals.md +41 -0
- package/skills/planning/architecture/SKILL.md +129 -0
- package/skills/planning/architecture/evals.md +36 -0
- package/skills/planning/backlog/SKILL.md +90 -0
- package/skills/planning/backlog/evals.md +43 -0
- package/skills/planning/prd/SKILL.md +82 -0
- package/skills/planning/prd/evals.md +49 -0
- package/skills/planning/product-intent/SKILL.md +112 -0
- package/skills/planning/product-intent/evals.md +36 -0
- package/skills/planning/tech-spec/SKILL.md +115 -0
- package/skills/planning/tech-spec/evals.md +47 -0
- package/skills/registry.yaml +136 -0
- package/skills/research/arxiv-literature/SKILL.md +104 -0
- package/skills/research/arxiv-literature/evals.md +58 -0
- package/skills/research/experiment-protocol/SKILL.md +122 -0
- package/skills/research/experiment-protocol/evals.md +91 -0
- package/skills/research/scientific-debugging/SKILL.md +119 -0
- package/skills/research/scientific-debugging/evals.md +138 -0
- package/skills/research/scientific-modernization/SKILL.md +138 -0
- package/skills/research/scientific-modernization/evals.md +84 -0
- package/skills/workflow/design-council/SKILL.md +139 -0
- package/skills/workflow/design-council/evals.md +97 -0
- package/skills/workflow/grill-me/SKILL.md +186 -0
- package/skills/workflow/grill-me/evals.md +78 -0
- package/skills/workflow/workflow-distiller/SKILL.md +136 -0
- package/skills/workflow/workflow-distiller/evals.md +107 -0
- package/src/cli/acp.ts +31 -4
- package/src/cli/clio.ts +68 -6
- package/src/cli/config-inspect.ts +28 -22
- package/src/cli/configure.ts +47 -9
- package/src/cli/context-clear.ts +2 -2
- package/src/cli/context-index.ts +21 -23
- package/src/cli/context.ts +13 -8
- package/src/cli/default-target.ts +9 -17
- package/src/cli/docs.ts +11 -5
- package/src/cli/evidence.ts +4 -1
- package/src/cli/extensions.ts +10 -1
- package/src/cli/fleet.ts +47 -6
- package/src/cli/index.ts +55 -26
- package/src/cli/memory.ts +3 -1
- package/src/cli/models.ts +1 -1
- package/src/cli/modes/json-stream.ts +37 -1
- package/src/cli/modes/print.ts +24 -9
- package/src/cli/run.ts +2 -2
- package/src/cli/skills-eval.ts +23 -8
- package/src/cli/skills.ts +19 -4
- package/src/cli/targets.ts +4 -0
- package/src/cli/text-layout.ts +15 -5
- package/src/cli/trace.ts +62 -14
- package/src/cli/upgrade.ts +18 -2
- package/src/cli/usage.ts +10 -3
- package/src/cli/wiki-generate.ts +2 -1
- package/src/core/agent-environment.ts +7 -0
- package/src/core/bash-exec.ts +72 -1
- package/src/core/boot-trace.ts +9 -4
- package/src/core/bus-events.ts +20 -4
- package/src/core/commit-attribution.ts +157 -0
- package/src/core/compile-cache.ts +159 -0
- package/src/core/config.ts +131 -2
- package/src/core/defaults.ts +39 -5
- package/src/core/domain-loader.ts +12 -5
- package/src/core/git-commit-attribution.ts +362 -0
- package/src/core/incomplete-installation.ts +45 -0
- package/src/core/response-schema.ts +1 -1
- package/src/core/safe-exec.ts +13 -1
- package/src/core/settings-layers.ts +155 -21
- package/src/core/skill-activation.ts +1 -1
- package/src/core/startup-timer.ts +3 -3
- package/src/core/state-file-lock.ts +13 -1
- package/src/core/termination.ts +78 -5
- package/src/domains/config/classify.ts +15 -3
- package/src/domains/config/extension.ts +19 -13
- package/src/domains/config/index.ts +10 -0
- package/src/domains/config/keybindings.ts +42 -6
- package/src/domains/context/bootstrap-prompt.ts +1 -1
- package/src/domains/context/bootstrap.ts +111 -18
- package/src/domains/context/clear.ts +16 -11
- package/src/domains/context/clio-md.ts +111 -9
- package/src/domains/context/codewiki/artifact.ts +400 -0
- package/src/domains/context/codewiki/build-worker-protocol.ts +24 -0
- package/src/domains/context/codewiki/build-worker.ts +54 -0
- package/src/domains/context/codewiki/coordinator.ts +182 -0
- package/src/domains/context/codewiki/indexer.ts +59 -144
- package/src/domains/context/codewiki/paths.ts +67 -0
- package/src/domains/context/codewiki/schema.ts +80 -0
- package/src/domains/context/codewiki/tree-sitter.ts +1 -1
- package/src/domains/context/contract.ts +11 -5
- package/src/domains/context/extension.ts +94 -143
- package/src/domains/context/fingerprint.ts +3 -1
- package/src/domains/context/index.ts +12 -22
- package/src/domains/context/project-metadata.ts +19 -0
- package/src/domains/context/prompt-context.ts +9 -10
- package/src/domains/context/refresh.ts +29 -21
- package/src/domains/context/runtime.ts +17 -0
- package/src/domains/context/wiki/generate.ts +39 -34
- package/src/domains/context/wiki/plan.ts +1 -1
- package/src/domains/context/wiki/prompts.ts +21 -8
- package/src/domains/dispatch/code-step.ts +20 -1
- package/src/domains/dispatch/extension.ts +158 -21
- package/src/domains/dispatch/failure-classification.ts +6 -0
- package/src/domains/dispatch/fleet-commit-attribution.ts +56 -0
- package/src/domains/dispatch/orphan-recovery.ts +50 -8
- package/src/domains/dispatch/receipt-integrity.ts +5 -0
- package/src/domains/dispatch/state.ts +31 -6
- package/src/domains/dispatch/transport.ts +2 -1
- package/src/domains/dispatch/types.ts +14 -0
- package/src/domains/dispatch/worker-spawn.ts +21 -2
- package/src/domains/eval/metrics/context.ts +1 -1
- package/src/domains/eval/types.ts +0 -1
- package/src/domains/evidence/build.ts +41 -1
- package/src/domains/lifecycle/migrations/2026-08-18-lmstudio-runtime-id.ts +52 -0
- package/src/domains/lifecycle/migrations/index.ts +24 -4
- package/src/domains/middleware/hooks-io.ts +12 -0
- package/src/domains/middleware/skills-reminder.ts +30 -15
- package/src/domains/prompts/compiler.ts +142 -84
- package/src/domains/prompts/contract.ts +18 -2
- package/src/domains/prompts/extension.ts +39 -7
- package/src/domains/prompts/fragment-loader.ts +0 -1
- package/src/domains/prompts/fragments/identity/clio.md +2 -4
- package/src/domains/prompts/fragments/identity/docs-routing.md +10 -0
- package/src/domains/prompts/fragments/identity/self-awareness.md +1 -45
- package/src/domains/prompts/fragments/operating/contract.md +4 -50
- package/src/domains/prompts/fragments/operating/delegation.md +42 -0
- package/src/domains/prompts/fragments/operating/skills.md +26 -0
- package/src/domains/prompts/fragments/operating/worker.md +16 -0
- package/src/domains/prompts/fragments/safety/auto-edit.md +5 -5
- package/src/domains/prompts/fragments/safety/full-auto.md +3 -3
- package/src/domains/prompts/fragments/safety/read-only.md +4 -4
- package/src/domains/prompts/fragments/safety/suggest.md +2 -2
- package/src/domains/prompts/fragments/wiki/page.md +10 -0
- package/src/domains/prompts/fragments/wiki/plan.md +10 -0
- package/src/domains/prompts/preload.ts +3 -3
- package/src/domains/providers/auth/api-key.ts +1 -1
- package/src/domains/providers/auth/backend-file.ts +20 -10
- package/src/domains/providers/auth/backend-memory.ts +59 -4
- package/src/domains/providers/auth/boot-status.ts +65 -0
- package/src/domains/providers/auth/oauth.ts +2 -1
- package/src/domains/providers/auth/storage.ts +97 -38
- package/src/domains/providers/capabilities.ts +12 -4
- package/src/domains/providers/contract.ts +15 -4
- package/src/domains/providers/extension.ts +18 -6
- package/src/domains/providers/model-runtime-capabilities.ts +15 -4
- package/src/domains/providers/models/local-models/clio-local-coding-targets.yaml +118 -35
- package/src/domains/providers/plugins.ts +5 -3
- package/src/domains/providers/probe/fingerprint.ts +25 -5
- package/src/domains/providers/registry.ts +31 -10
- package/src/domains/providers/runtimes/boot-manifest.ts +55 -0
- package/src/domains/providers/runtimes/builtins.ts +2 -2
- package/src/domains/providers/runtimes/common/lmstudio-http.ts +423 -0
- package/src/domains/providers/runtimes/common/local-synth.ts +6 -7
- package/src/domains/providers/runtimes/local-native/lmstudio.ts +241 -0
- package/src/domains/providers/support.ts +6 -3
- package/src/domains/providers/types/local-model-quirks.ts +7 -9
- package/src/domains/providers/types/runtime-descriptor.ts +12 -1
- package/src/domains/providers/types/target-descriptor.ts +22 -0
- package/src/domains/resources/contract.ts +0 -1
- package/src/domains/resources/extension.ts +1 -3
- package/src/domains/resources/loader.ts +3 -4
- package/src/domains/resources/prompts/loader.ts +16 -2
- package/src/domains/resources/prompts/substitute.ts +1 -65
- package/src/domains/resources/skills/content-hash.ts +2 -0
- package/src/domains/resources/skills/install.ts +17 -0
- package/src/domains/resources/skills/loader.ts +17 -10
- package/src/domains/resources/skills/marketplace.ts +55 -9
- package/src/domains/safety/action-classifier.ts +4 -2
- package/src/domains/safety/audit.ts +8 -2
- package/src/domains/safety/extension.ts +1 -1
- package/src/domains/session/compaction/branch-summary.ts +3 -2
- package/src/domains/session/compaction/cut-point.ts +2 -1
- package/src/domains/session/compaction/tokens.ts +2 -1
- package/src/domains/session/context-ledger.ts +14 -0
- package/src/domains/session/contract.ts +15 -0
- package/src/domains/session/decision-board.ts +190 -0
- package/src/domains/session/entries.ts +66 -3
- package/src/domains/session/extension.ts +93 -12
- package/src/domains/session/retry.ts +10 -18
- package/src/domains/session/session-artifacts.ts +107 -0
- package/src/domains/session/task-board.ts +207 -13
- package/src/domains/session/tree/active-path.ts +44 -5
- package/src/domains/session/tree/fork.ts +26 -27
- package/src/domains/session/tree/preview.ts +2 -2
- package/src/domains/session/workspace/git-probe.ts +17 -11
- package/src/domains/user-tasks/store.ts +297 -0
- package/src/engine/acp/errors.ts +96 -0
- package/src/engine/acp/server.ts +1728 -146
- package/src/engine/acp/transport.ts +135 -14
- package/src/engine/acp/types.ts +26 -0
- package/src/engine/agent.ts +3 -3
- package/src/engine/ai.ts +32 -27
- package/src/engine/alcf-oauth.ts +26 -19
- package/src/engine/api-registry.ts +223 -0
- package/src/engine/apis/index.ts +3 -7
- package/src/engine/apis/llamacpp-residency.ts +49 -9
- package/src/engine/apis/lmstudio-residency.ts +5 -21
- package/src/engine/apis/lmstudio.ts +243 -0
- package/src/engine/apis/ollama-native.ts +24 -3
- package/src/engine/apis/openai-completions.ts +170 -91
- package/src/engine/apis/residency.ts +139 -3
- package/src/engine/apis/types.ts +16 -0
- package/src/engine/env-api-keys.ts +98 -0
- package/src/engine/gemma-channel-filter.ts +223 -0
- package/src/engine/instrumented-tui.ts +192 -0
- package/src/engine/messages.ts +14 -0
- package/src/engine/models.ts +42 -0
- package/src/engine/oauth.ts +16 -12
- package/src/engine/prompt-templates.ts +1 -0
- package/src/engine/provider-payload.ts +16 -59
- package/src/engine/strip-tokenizer-sentinels.ts +1 -1
- package/src/engine/truncate.ts +9 -0
- package/src/engine/tui.ts +17 -9
- package/src/engine/types.ts +3 -6
- package/src/engine/worker-runtime-capabilities.ts +5 -0
- package/src/engine/worker-runtime.ts +1 -1
- package/src/engine/worker-tools.ts +9 -4
- package/src/entry/boot-options.ts +50 -0
- package/src/entry/orchestrator.ts +288 -150
- package/src/interactive/application-controller.ts +89 -2
- package/src/interactive/chat-loop.ts +266 -41
- package/src/interactive/chat-panel.ts +173 -47
- package/src/interactive/chat-renderer.ts +262 -72
- package/src/interactive/clio-editor.ts +3 -8
- package/src/interactive/command-fallbacks.ts +2 -2
- package/src/interactive/context-overlay.ts +27 -1
- package/src/interactive/editor-submit.ts +228 -24
- package/src/interactive/export-html/ansi-to-html.ts +161 -0
- package/src/interactive/export-html/index.ts +51 -0
- package/src/interactive/export-html/template.ts +45 -0
- package/src/interactive/export-html/tool-renderer.ts +54 -0
- package/src/interactive/footer/dashboard.ts +4 -0
- package/src/interactive/footer/notifications.ts +1 -1
- package/src/interactive/footer/widgets.ts +20 -2
- package/src/interactive/footer-panel.ts +2 -2
- package/src/interactive/format-time.ts +14 -2
- package/src/interactive/interactive-application.ts +201 -17
- package/src/interactive/interactive-event-projection.ts +6 -1
- package/src/interactive/interactive-input-runtime.ts +50 -4
- package/src/interactive/interactive-presentation.ts +151 -19
- package/src/interactive/interactive-shell.ts +268 -14
- package/src/interactive/interactive-slash-runtime.ts +176 -114
- package/src/interactive/interactive-tickers.ts +38 -7
- package/src/interactive/keybinding-manager.ts +1 -1
- package/src/interactive/layout.ts +40 -3
- package/src/interactive/overlay-frame.ts +1 -1
- package/src/interactive/overlay-general-openers.ts +58 -1
- package/src/interactive/overlay-key-routing.ts +3 -0
- package/src/interactive/overlay-lifecycle.ts +13 -0
- package/src/interactive/overlay-permission-lifecycle.ts +2 -1
- package/src/interactive/overlay-session-lifecycle.ts +69 -12
- package/src/interactive/overlays/decisions.ts +300 -0
- package/src/interactive/overlays/help-reference.ts +15 -10
- package/src/interactive/overlays/model-selector.ts +34 -16
- package/src/interactive/overlays/session-selector.ts +18 -0
- package/src/interactive/overlays/settings.ts +105 -17
- package/src/interactive/overlays/skills-hub.ts +4 -4
- package/src/interactive/overlays/tree-selector.ts +41 -6
- package/src/interactive/render-trace.ts +499 -90
- package/src/interactive/renderers/compaction-summary.ts +2 -2
- package/src/interactive/renderers/diff.ts +115 -104
- package/src/interactive/renderers/mermaid.ts +53 -0
- package/src/interactive/renderers/tool-execution.ts +386 -133
- package/src/interactive/renderers/worker-entry.ts +20 -4
- package/src/interactive/session-switch-settlement.ts +10 -0
- package/src/interactive/slash-autocomplete.ts +6 -114
- package/src/interactive/slash-commands.ts +135 -47
- package/src/interactive/slash-spec.ts +9 -38
- package/src/interactive/status/controller.ts +5 -1
- package/src/interactive/stdout-backpressure.ts +99 -0
- package/src/interactive/stream-pacer.ts +530 -0
- package/src/interactive/stream-pacing-policy.ts +66 -0
- package/src/interactive/tasks-overlay.ts +368 -14
- package/src/interactive/terminal-lease.ts +485 -0
- package/src/interactive/theme/tokens.ts +1 -1
- package/src/interactive/turn-context.ts +4 -3
- package/src/interactive/turn-persistence.ts +30 -13
- package/src/interactive/turn-queues.ts +12 -0
- package/src/interactive/turn-recovery.ts +25 -8
- package/src/interactive/turn-runtime.ts +79 -12
- package/src/interactive/turn-state.ts +10 -0
- package/src/interactive/view/artifacts.ts +114 -4
- package/src/interactive/view/view-overlay.ts +3 -0
- package/src/interactive/welcome-dashboard.ts +17 -16
- package/src/interactive/worker-receipts.ts +52 -3
- package/src/interactive/worker-stream.ts +5 -1
- package/src/tools/agent-tools.ts +23 -3
- package/src/tools/artifact.ts +2 -2
- package/src/tools/ask-user.ts +23 -13
- package/src/tools/bash.ts +30 -2
- package/src/tools/bootstrap.ts +34 -431
- package/src/tools/builtin-tool-catalog.ts +265 -0
- package/src/tools/codewiki/code-nav-surface.ts +29 -0
- package/src/tools/codewiki/code-nav.ts +8 -22
- package/src/tools/codewiki/shared.ts +41 -38
- package/src/tools/context/docs-engine.ts +14 -3
- package/src/tools/context/index.ts +107 -28
- package/src/tools/context/surface.ts +19 -0
- package/src/tools/core-bootstrap.ts +168 -0
- package/src/tools/credential-present.ts +5 -5
- package/src/tools/dispatch-admission.ts +533 -0
- package/src/tools/dispatch-background.ts +54 -0
- package/src/tools/dispatch-event-text.ts +6 -0
- package/src/tools/dispatch-plan.ts +9 -4
- package/src/tools/dispatch-run-events.ts +238 -0
- package/src/tools/dispatch-runner.ts +2370 -0
- package/src/tools/dispatch-scout-admission.ts +295 -0
- package/src/tools/dispatch-types.ts +77 -0
- package/src/tools/dispatch.ts +67 -3161
- package/src/tools/find.ts +4 -2
- package/src/tools/grep.ts +2 -2
- package/src/tools/lazy-tool.ts +60 -0
- package/src/tools/ledger.ts +3 -3
- package/src/tools/monitor-surface.ts +36 -0
- package/src/tools/monitor.ts +2 -32
- package/src/tools/observers.ts +2 -2
- package/src/tools/registry.ts +39 -27
- package/src/tools/safe-exec.ts +2 -2
- package/src/tools/steer-surface.ts +17 -0
- package/src/tools/steer.ts +2 -13
- package/src/tools/tasks.ts +108 -11
- package/src/tools/truncate.ts +25 -184
- package/src/tools/verify/frontend.ts +3 -1
- package/src/tools/verify/index.ts +3 -38
- package/src/tools/verify/surface.ts +46 -0
- package/src/tools/web-fetch-surface.ts +23 -0
- package/src/tools/web-fetch.ts +2 -20
- package/src/tools/write.ts +7 -2
- package/src/worker/entry.ts +39 -2
- package/src/worker/spec-contract.ts +26 -5
- package/dist/chunk-7SS2CTV2.js +0 -61361
- package/dist/chunk-DKGKUHFA.js +0 -924
- package/dist/chunk-GEP36Y4X.js +0 -12796
- package/dist/chunk-XYWBQRDM.js +0 -137
- package/dist/clio-BZVGEUFJ.js +0 -58
- package/dist/configure-S7S6F6CL.js +0 -32
- package/docs/html/agents_blueprint.html +0 -936
- package/docs/html/alcf_blueprint.html +0 -324
- package/docs/html/architecture_blueprint.html +0 -850
- package/docs/html/commands_blueprint.html +0 -939
- package/docs/html/config_knobs_audit_blueprint.html +0 -178
- package/docs/html/configuration_blueprint.html +0 -1080
- package/docs/html/context_blueprint.html +0 -603
- package/docs/html/documentation_blueprint.html +0 -832
- package/docs/html/environment_blueprint.html +0 -404
- package/docs/html/eval_blueprint.html +0 -743
- package/docs/html/evals_internal_blueprint.html +0 -190
- package/docs/html/evolution_blueprint.html +0 -674
- package/docs/html/extensions_blueprint.html +0 -2065
- package/docs/html/fleet_dispatch_blueprint.html +0 -286
- package/docs/html/index.html +0 -919
- package/docs/html/lifecycle_blueprint.html +0 -723
- package/docs/html/memory_blueprint.html +0 -699
- package/docs/html/middleware_blueprint.html +0 -664
- package/docs/html/models_blueprint.html +0 -2366
- package/docs/html/observability_blueprint.html +0 -683
- package/docs/html/provider_adapter_blueprint.html +0 -245
- package/docs/html/safety_blueprint.html +0 -1386
- package/docs/html/shared.css +0 -571
- package/docs/html/shared.js +0 -143
- package/docs/html/skills_blueprint.html +0 -671
- package/docs/html/soak_blueprint.html +0 -182
- package/docs/html/tool_usage_blueprint.html +0 -350
- package/docs/html/tools_blueprint.html +0 -2249
- package/docs/html/trace_blueprint.html +0 -235
- package/docs/html/tui_design_blueprint.html +0 -374
- package/docs/html/validation_blueprint.html +0 -961
- package/docs/html/worker_dispatch_blueprint.html +0 -231
- package/src/core/release.ts +0 -2
- package/src/domains/providers/runtimes/common/lmstudio-logger.ts +0 -32
- package/src/domains/providers/runtimes/local-native/lmstudio-native.ts +0 -491
- package/src/engine/apis/lmstudio-native.ts +0 -1438
- package/src/engine/apis/thinking-replay.ts +0 -11
- package/src/tools/string-enum.ts +0 -15
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { createRequire as __clioCreateRequire } from "node:module"; const require = __clioCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
classifyCHeaderLanguage,
|
|
4
|
+
isAmbiguousHeaderPath
|
|
5
|
+
} from "./chunk-7CR24IG7.js";
|
|
5
6
|
import {
|
|
6
7
|
resolvePackageRoot
|
|
7
8
|
} from "./chunk-IWHMRKLL.js";
|
|
@@ -2048,8 +2049,8 @@ var require_tree_sitter = __commonJS({
|
|
|
2048
2049
|
bytes = Promise.resolve(input);
|
|
2049
2050
|
} else {
|
|
2050
2051
|
if (globalThis.process?.versions.node) {
|
|
2051
|
-
const
|
|
2052
|
-
bytes =
|
|
2052
|
+
const fs2 = await import("fs/promises");
|
|
2053
|
+
bytes = fs2.readFile(input);
|
|
2053
2054
|
} else {
|
|
2054
2055
|
bytes = fetch(input).then((response) => response.arrayBuffer().then((buffer) => {
|
|
2055
2056
|
if (response.ok) {
|
|
@@ -2081,8 +2082,8 @@ ${JSON.stringify(symbolNames, null, 2)}`);
|
|
|
2081
2082
|
var moduleRtn;
|
|
2082
2083
|
var Module = moduleArg;
|
|
2083
2084
|
var readyPromiseResolve, readyPromiseReject;
|
|
2084
|
-
var readyPromise = new Promise((
|
|
2085
|
-
readyPromiseResolve =
|
|
2085
|
+
var readyPromise = new Promise((resolve, reject) => {
|
|
2086
|
+
readyPromiseResolve = resolve;
|
|
2086
2087
|
readyPromiseReject = reject;
|
|
2087
2088
|
});
|
|
2088
2089
|
var ENVIRONMENT_IS_WEB = typeof window == "object";
|
|
@@ -2123,10 +2124,10 @@ ${JSON.stringify(symbolNames, null, 2)}`);
|
|
|
2123
2124
|
}, "readBinary");
|
|
2124
2125
|
readAsync = /* @__PURE__ */ __name((filename, binary2 = true) => {
|
|
2125
2126
|
filename = isFileURI(filename) ? new URL(filename) : nodePath.normalize(filename);
|
|
2126
|
-
return new Promise((
|
|
2127
|
+
return new Promise((resolve, reject) => {
|
|
2127
2128
|
fs.readFile(filename, binary2 ? void 0 : "utf8", (err2, data) => {
|
|
2128
2129
|
if (err2) reject(err2);
|
|
2129
|
-
else
|
|
2130
|
+
else resolve(binary2 ? data.buffer : data);
|
|
2130
2131
|
});
|
|
2131
2132
|
});
|
|
2132
2133
|
}, "readAsync");
|
|
@@ -2167,13 +2168,13 @@ ${JSON.stringify(symbolNames, null, 2)}`);
|
|
|
2167
2168
|
}
|
|
2168
2169
|
readAsync = /* @__PURE__ */ __name((url) => {
|
|
2169
2170
|
if (isFileURI(url)) {
|
|
2170
|
-
return new Promise((reject,
|
|
2171
|
+
return new Promise((reject, resolve) => {
|
|
2171
2172
|
var xhr = new XMLHttpRequest();
|
|
2172
2173
|
xhr.open("GET", url, true);
|
|
2173
2174
|
xhr.responseType = "arraybuffer";
|
|
2174
2175
|
xhr.onload = () => {
|
|
2175
2176
|
if (xhr.status == 200 || xhr.status == 0 && xhr.response) {
|
|
2176
|
-
|
|
2177
|
+
resolve(xhr.response);
|
|
2177
2178
|
}
|
|
2178
2179
|
reject(xhr.status);
|
|
2179
2180
|
};
|
|
@@ -3187,8 +3188,8 @@ ${JSON.stringify(symbolNames, null, 2)}`);
|
|
|
3187
3188
|
}
|
|
3188
3189
|
var libFile = locateFile(libName2);
|
|
3189
3190
|
if (flags2.loadAsync) {
|
|
3190
|
-
return new Promise(function(
|
|
3191
|
-
asyncLoad(libFile,
|
|
3191
|
+
return new Promise(function(resolve, reject) {
|
|
3192
|
+
asyncLoad(libFile, resolve, reject);
|
|
3192
3193
|
});
|
|
3193
3194
|
}
|
|
3194
3195
|
if (!readBinary) {
|
|
@@ -4063,1083 +4064,10 @@ ${JSON.stringify(symbolNames, null, 2)}`);
|
|
|
4063
4064
|
}
|
|
4064
4065
|
});
|
|
4065
4066
|
|
|
4066
|
-
// src/domains/session/workspace/project-type.ts
|
|
4067
|
-
init_esm_shims();
|
|
4068
|
-
import { readFileSync } from "node:fs";
|
|
4069
|
-
import { join as join2 } from "node:path";
|
|
4070
|
-
|
|
4071
|
-
// src/core/c-header-language.ts
|
|
4072
|
-
init_esm_shims();
|
|
4073
|
-
function isAmbiguousHeaderPath(path) {
|
|
4074
|
-
return path.endsWith(".h");
|
|
4075
|
-
}
|
|
4076
|
-
var CPP_ONLY_STD_INCLUDES = /* @__PURE__ */ new Set([
|
|
4077
|
-
"algorithm",
|
|
4078
|
-
"any",
|
|
4079
|
-
"array",
|
|
4080
|
-
"atomic",
|
|
4081
|
-
"barrier",
|
|
4082
|
-
"bit",
|
|
4083
|
-
"bitset",
|
|
4084
|
-
"cassert",
|
|
4085
|
-
"cctype",
|
|
4086
|
-
"cerrno",
|
|
4087
|
-
"cfenv",
|
|
4088
|
-
"cfloat",
|
|
4089
|
-
"charconv",
|
|
4090
|
-
"chrono",
|
|
4091
|
-
"cinttypes",
|
|
4092
|
-
"climits",
|
|
4093
|
-
"clocale",
|
|
4094
|
-
"cmath",
|
|
4095
|
-
"codecvt",
|
|
4096
|
-
"compare",
|
|
4097
|
-
"complex",
|
|
4098
|
-
"concepts",
|
|
4099
|
-
"condition_variable",
|
|
4100
|
-
"coroutine",
|
|
4101
|
-
"csetjmp",
|
|
4102
|
-
"csignal",
|
|
4103
|
-
"cstdarg",
|
|
4104
|
-
"cstddef",
|
|
4105
|
-
"cstdint",
|
|
4106
|
-
"cstdio",
|
|
4107
|
-
"cstdlib",
|
|
4108
|
-
"cstring",
|
|
4109
|
-
"ctime",
|
|
4110
|
-
"cuchar",
|
|
4111
|
-
"cwchar",
|
|
4112
|
-
"cwctype",
|
|
4113
|
-
"deque",
|
|
4114
|
-
"exception",
|
|
4115
|
-
"execution",
|
|
4116
|
-
"expected",
|
|
4117
|
-
"filesystem",
|
|
4118
|
-
"flat_map",
|
|
4119
|
-
"flat_set",
|
|
4120
|
-
"format",
|
|
4121
|
-
"forward_list",
|
|
4122
|
-
"fstream",
|
|
4123
|
-
"functional",
|
|
4124
|
-
"future",
|
|
4125
|
-
"generator",
|
|
4126
|
-
"initializer_list",
|
|
4127
|
-
"iomanip",
|
|
4128
|
-
"ios",
|
|
4129
|
-
"iosfwd",
|
|
4130
|
-
"iostream",
|
|
4131
|
-
"istream",
|
|
4132
|
-
"iterator",
|
|
4133
|
-
"latch",
|
|
4134
|
-
"limits",
|
|
4135
|
-
"list",
|
|
4136
|
-
"locale",
|
|
4137
|
-
"map",
|
|
4138
|
-
"mdspan",
|
|
4139
|
-
"memory",
|
|
4140
|
-
"memory_resource",
|
|
4141
|
-
"mutex",
|
|
4142
|
-
"new",
|
|
4143
|
-
"numbers",
|
|
4144
|
-
"numeric",
|
|
4145
|
-
"optional",
|
|
4146
|
-
"ostream",
|
|
4147
|
-
"print",
|
|
4148
|
-
"queue",
|
|
4149
|
-
"random",
|
|
4150
|
-
"ranges",
|
|
4151
|
-
"ratio",
|
|
4152
|
-
"regex",
|
|
4153
|
-
"scoped_allocator",
|
|
4154
|
-
"semaphore",
|
|
4155
|
-
"set",
|
|
4156
|
-
"shared_mutex",
|
|
4157
|
-
"source_location",
|
|
4158
|
-
"span",
|
|
4159
|
-
"spanstream",
|
|
4160
|
-
"sstream",
|
|
4161
|
-
"stack",
|
|
4162
|
-
"stacktrace",
|
|
4163
|
-
"stdexcept",
|
|
4164
|
-
"stop_token",
|
|
4165
|
-
"streambuf",
|
|
4166
|
-
"string",
|
|
4167
|
-
"string_view",
|
|
4168
|
-
"syncstream",
|
|
4169
|
-
"system_error",
|
|
4170
|
-
"thread",
|
|
4171
|
-
"tuple",
|
|
4172
|
-
"type_traits",
|
|
4173
|
-
"typeindex",
|
|
4174
|
-
"typeinfo",
|
|
4175
|
-
"unordered_map",
|
|
4176
|
-
"unordered_set",
|
|
4177
|
-
"utility",
|
|
4178
|
-
"valarray",
|
|
4179
|
-
"variant",
|
|
4180
|
-
"vector",
|
|
4181
|
-
"version"
|
|
4182
|
-
]);
|
|
4183
|
-
var CPP_SYNTAX_PATTERNS = [
|
|
4184
|
-
/\bnamespace\s+[A-Za-z_{:]/,
|
|
4185
|
-
/\btemplate\s*</,
|
|
4186
|
-
/\btypename\b/,
|
|
4187
|
-
/\bclass\s+[A-Za-z_]/,
|
|
4188
|
-
/\benum\s+(?:class|struct)\b/,
|
|
4189
|
-
/\w::~?[A-Za-z_~]/,
|
|
4190
|
-
/::/,
|
|
4191
|
-
/^\s*(?:public|private|protected)\s*:(?!:)/m,
|
|
4192
|
-
/\b(?:static_cast|dynamic_cast|reinterpret_cast|const_cast)\s*</,
|
|
4193
|
-
/\busing\s+[A-Za-z_]\w*\s*=/,
|
|
4194
|
-
/\busing\s+namespace\b/,
|
|
4195
|
-
/\boperator\s*(?:[+\-*/%^&|~!=<>]|\(\)|\[\])/,
|
|
4196
|
-
/\b(?:constexpr|consteval|constinit|noexcept|nullptr|decltype|thread_local)\b/,
|
|
4197
|
-
/\b(?:virtual|override|friend|mutable)\b/,
|
|
4198
|
-
/\)\s*(?:const|noexcept|override|final)\b/,
|
|
4199
|
-
/^[ \t]*[A-Za-z_]\w*(?:::\w+)*(?:\s*<[^;{}()]+>)?\s*&&?\s*[A-Za-z_]\w*\s*\([^;{}]*\)\s*;/m,
|
|
4200
|
-
/\bauto\s+[A-Za-z_]\w*\s*\([^;{}]*\)\s*->/
|
|
4201
|
-
];
|
|
4202
|
-
function blank(ch) {
|
|
4203
|
-
return ch === "\n" ? "\n" : " ";
|
|
4204
|
-
}
|
|
4205
|
-
function stripForScan(text) {
|
|
4206
|
-
let withStrings = "";
|
|
4207
|
-
let code = "";
|
|
4208
|
-
let state = "code";
|
|
4209
|
-
for (let index = 0; index < text.length; index += 1) {
|
|
4210
|
-
const ch = text[index];
|
|
4211
|
-
const next = text[index + 1];
|
|
4212
|
-
if (state === "code") {
|
|
4213
|
-
if (ch === "/" && next === "/") {
|
|
4214
|
-
state = "line-comment";
|
|
4215
|
-
withStrings += " ";
|
|
4216
|
-
code += " ";
|
|
4217
|
-
continue;
|
|
4218
|
-
}
|
|
4219
|
-
if (ch === "/" && next === "*") {
|
|
4220
|
-
state = "block-comment";
|
|
4221
|
-
withStrings += " ";
|
|
4222
|
-
code += " ";
|
|
4223
|
-
continue;
|
|
4224
|
-
}
|
|
4225
|
-
if (ch === '"') state = "string";
|
|
4226
|
-
else if (ch === "'") state = "char";
|
|
4227
|
-
withStrings += ch;
|
|
4228
|
-
code += state === "code" ? ch : " ";
|
|
4229
|
-
continue;
|
|
4230
|
-
}
|
|
4231
|
-
if (state === "line-comment") {
|
|
4232
|
-
if (ch === "\n") state = "code";
|
|
4233
|
-
withStrings += blank(ch);
|
|
4234
|
-
code += blank(ch);
|
|
4235
|
-
continue;
|
|
4236
|
-
}
|
|
4237
|
-
if (state === "block-comment") {
|
|
4238
|
-
if (ch === "*" && next === "/") {
|
|
4239
|
-
state = "code";
|
|
4240
|
-
index += 1;
|
|
4241
|
-
withStrings += " ";
|
|
4242
|
-
code += " ";
|
|
4243
|
-
continue;
|
|
4244
|
-
}
|
|
4245
|
-
withStrings += blank(ch);
|
|
4246
|
-
code += blank(ch);
|
|
4247
|
-
continue;
|
|
4248
|
-
}
|
|
4249
|
-
if (ch === "\\" && next !== void 0) {
|
|
4250
|
-
withStrings += ch + next;
|
|
4251
|
-
code += blank(ch) + blank(next);
|
|
4252
|
-
index += 1;
|
|
4253
|
-
continue;
|
|
4254
|
-
}
|
|
4255
|
-
if (state === "string" && ch === '"' || state === "char" && ch === "'" || ch === "\n") {
|
|
4256
|
-
state = "code";
|
|
4257
|
-
withStrings += ch;
|
|
4258
|
-
code += blank(ch);
|
|
4259
|
-
continue;
|
|
4260
|
-
}
|
|
4261
|
-
withStrings += ch;
|
|
4262
|
-
code += blank(ch);
|
|
4263
|
-
}
|
|
4264
|
-
return { withStrings, code };
|
|
4265
|
-
}
|
|
4266
|
-
function hasCppInclude(withStrings) {
|
|
4267
|
-
for (const match of withStrings.matchAll(/^[ \t]*#[ \t]*include[ \t]*([<"])([^>"\n]+)[>"]/gm)) {
|
|
4268
|
-
const delimiter = match[1];
|
|
4269
|
-
const target = match[2]?.trim() ?? "";
|
|
4270
|
-
if (/\.(?:hpp|hh|hxx|cuh)$/.test(target)) return true;
|
|
4271
|
-
if (delimiter === "<" && CPP_ONLY_STD_INCLUDES.has(target)) return true;
|
|
4272
|
-
}
|
|
4273
|
-
return false;
|
|
4274
|
-
}
|
|
4275
|
-
function hasCppMemberDeclaration(code) {
|
|
4276
|
-
for (const match of code.matchAll(/\b(?:class|struct)\s+[A-Za-z_]\w*[^;{]*\{([\s\S]*?)\}/g)) {
|
|
4277
|
-
const body2 = match[1] ?? "";
|
|
4278
|
-
for (const rawStatement of body2.split(";")) {
|
|
4279
|
-
const statement = rawStatement.trim();
|
|
4280
|
-
if (statement.length === 0 || /\(\s*[*&]/.test(statement)) continue;
|
|
4281
|
-
const member = /(?:^|\s)(operator\s*[^\s(]+|~?[A-Za-z_]\w*)\s*\([^{};]*\)\s*(?:const\b|noexcept\b|override\b|final\b|=\s*0\s*)*$/.exec(
|
|
4282
|
-
statement
|
|
4283
|
-
);
|
|
4284
|
-
if (!member) continue;
|
|
4285
|
-
const name2 = member[1] ?? "";
|
|
4286
|
-
const prefix = statement.slice(0, member.index);
|
|
4287
|
-
if (prefix.includes("[") || /^[_A-Z][_A-Z0-9]*$/.test(name2)) continue;
|
|
4288
|
-
return true;
|
|
4289
|
-
}
|
|
4290
|
-
}
|
|
4291
|
-
return false;
|
|
4292
|
-
}
|
|
4293
|
-
function classifyCHeaderLanguage(text) {
|
|
4294
|
-
const { withStrings, code } = stripForScan(text);
|
|
4295
|
-
if (hasCppInclude(withStrings)) return "c++";
|
|
4296
|
-
if (hasCppMemberDeclaration(code)) return "c++";
|
|
4297
|
-
for (const pattern of CPP_SYNTAX_PATTERNS) {
|
|
4298
|
-
if (pattern.test(code)) return "c++";
|
|
4299
|
-
}
|
|
4300
|
-
return "c";
|
|
4301
|
-
}
|
|
4302
|
-
|
|
4303
|
-
// src/core/workspace-files.ts
|
|
4304
|
-
init_esm_shims();
|
|
4305
|
-
import { execFile, execFileSync } from "node:child_process";
|
|
4306
|
-
import fs2 from "node:fs";
|
|
4307
|
-
import { join, sep } from "node:path";
|
|
4308
|
-
import { performance as performance2 } from "node:perf_hooks";
|
|
4309
|
-
var DEFAULT_YIELD_BUDGET_MS = 8;
|
|
4310
|
-
function createDefaultTick(budgetMs = DEFAULT_YIELD_BUDGET_MS) {
|
|
4311
|
-
let sliceStart = performance2.now();
|
|
4312
|
-
return {
|
|
4313
|
-
async tick() {
|
|
4314
|
-
if (performance2.now() - sliceStart < budgetMs) return;
|
|
4315
|
-
await new Promise((resolve2) => {
|
|
4316
|
-
setImmediate(resolve2);
|
|
4317
|
-
});
|
|
4318
|
-
sliceStart = performance2.now();
|
|
4319
|
-
}
|
|
4320
|
-
};
|
|
4321
|
-
}
|
|
4322
|
-
var GIT_OUTPUT_LIMIT_BYTES = 128 * 1024 * 1024;
|
|
4323
|
-
var MAX_ENUMERATION_DIAGNOSTIC_PATH_CHARS = 200;
|
|
4324
|
-
var DEFAULT_WORKSPACE_FALLBACK_LIMITS = Object.freeze({
|
|
4325
|
-
maxVisitedEntries: 1e5,
|
|
4326
|
-
maxDepth: 64,
|
|
4327
|
-
maxPathBytes: 64 * 1024 * 1024,
|
|
4328
|
-
maxDurationMs: 5e3
|
|
4329
|
-
});
|
|
4330
|
-
var WorkspaceEnumerationLimitError = class extends Error {
|
|
4331
|
-
constructor(kind, limit) {
|
|
4332
|
-
super(`non-Git workspace enumeration exceeded ${kind} limit (${limit})`);
|
|
4333
|
-
this.kind = kind;
|
|
4334
|
-
this.limit = limit;
|
|
4335
|
-
this.name = "WorkspaceEnumerationLimitError";
|
|
4336
|
-
}
|
|
4337
|
-
kind;
|
|
4338
|
-
limit;
|
|
4339
|
-
code = "WORKSPACE_ENUMERATION_LIMIT";
|
|
4340
|
-
};
|
|
4341
|
-
function boundedDiagnosticPath(path) {
|
|
4342
|
-
const printable = Array.from(path.length > 0 ? path : ".", (character) => {
|
|
4343
|
-
const codePoint = character.codePointAt(0) ?? 0;
|
|
4344
|
-
return codePoint <= 31 || codePoint >= 127 && codePoint <= 159 ? "?" : character;
|
|
4345
|
-
});
|
|
4346
|
-
if (printable.length <= MAX_ENUMERATION_DIAGNOSTIC_PATH_CHARS) return printable.join("");
|
|
4347
|
-
const side = Math.floor((MAX_ENUMERATION_DIAGNOSTIC_PATH_CHARS - 1) / 2);
|
|
4348
|
-
return `${printable.slice(0, side).join("")}\u2026${printable.slice(-side).join("")}`;
|
|
4349
|
-
}
|
|
4350
|
-
function boundedSystemErrorCode(cause) {
|
|
4351
|
-
if (typeof cause !== "object" || cause === null || !("code" in cause)) return "UNKNOWN";
|
|
4352
|
-
const code = cause.code;
|
|
4353
|
-
return typeof code === "string" && /^[A-Z][A-Z0-9_]{0,31}$/.test(code) ? code : "UNKNOWN";
|
|
4354
|
-
}
|
|
4355
|
-
var ENUMERATION_OPERATION_LABELS = Object.freeze({
|
|
4356
|
-
"open-root": "open the workspace root",
|
|
4357
|
-
"read-directory": "read a workspace directory",
|
|
4358
|
-
"open-directory": "open a workspace directory",
|
|
4359
|
-
"inspect-entry": "inspect a workspace entry"
|
|
4360
|
-
});
|
|
4361
|
-
var WorkspaceEnumerationIncompleteError = class extends Error {
|
|
4362
|
-
code = "WORKSPACE_ENUMERATION_INCOMPLETE";
|
|
4363
|
-
operation;
|
|
4364
|
-
path;
|
|
4365
|
-
causeCode;
|
|
4366
|
-
constructor(operation, path, cause) {
|
|
4367
|
-
const diagnosticPath = boundedDiagnosticPath(path);
|
|
4368
|
-
const causeCode = boundedSystemErrorCode(cause);
|
|
4369
|
-
super(
|
|
4370
|
-
`non-Git workspace enumeration could not ${ENUMERATION_OPERATION_LABELS[operation]} at '${diagnosticPath}' (${causeCode})`
|
|
4371
|
-
);
|
|
4372
|
-
this.name = "WorkspaceEnumerationIncompleteError";
|
|
4373
|
-
this.operation = operation;
|
|
4374
|
-
this.path = diagnosticPath;
|
|
4375
|
-
this.causeCode = causeCode;
|
|
4376
|
-
}
|
|
4377
|
-
};
|
|
4378
|
-
var WORKSPACE_EXCLUDED_DIRS = /* @__PURE__ */ new Set([
|
|
4379
|
-
".git",
|
|
4380
|
-
".hg",
|
|
4381
|
-
".svn",
|
|
4382
|
-
".clio-coder",
|
|
4383
|
-
"node_modules",
|
|
4384
|
-
"dist",
|
|
4385
|
-
"build",
|
|
4386
|
-
"coverage",
|
|
4387
|
-
".venv",
|
|
4388
|
-
"venv",
|
|
4389
|
-
"__pycache__",
|
|
4390
|
-
"target",
|
|
4391
|
-
"vendor",
|
|
4392
|
-
".superpowers",
|
|
4393
|
-
".codex",
|
|
4394
|
-
".claude",
|
|
4395
|
-
".clio-coder-benchmark"
|
|
4396
|
-
]);
|
|
4397
|
-
function comparePaths(a, b) {
|
|
4398
|
-
return a === b ? 0 : a < b ? -1 : 1;
|
|
4399
|
-
}
|
|
4400
|
-
function normalizeRelativePath(path) {
|
|
4401
|
-
const posixPath = sep === "\\" ? path.replaceAll("\\", "/") : path;
|
|
4402
|
-
const normalized = posixPath.replace(/^\.\//, "");
|
|
4403
|
-
if (normalized.length === 0 || normalized.includes("\0") || normalized.startsWith("/")) return null;
|
|
4404
|
-
if (/^[A-Za-z]:\//.test(normalized)) return null;
|
|
4405
|
-
const segments = normalized.split("/");
|
|
4406
|
-
if (segments.some((segment) => segment.length === 0 || segment === "." || segment === "..")) return null;
|
|
4407
|
-
return segments.join("/");
|
|
4408
|
-
}
|
|
4409
|
-
function isWorkspacePathExcluded(relPath, excludedDirs = WORKSPACE_EXCLUDED_DIRS) {
|
|
4410
|
-
return relPath.split("/").some((segment) => excludedDirs.has(segment));
|
|
4411
|
-
}
|
|
4412
|
-
function isDisappearedWorkspaceEntry(cause) {
|
|
4413
|
-
if (typeof cause !== "object" || cause === null || !("code" in cause)) return false;
|
|
4414
|
-
const code = cause.code;
|
|
4415
|
-
return code === "ENOENT" || code === "ENOTDIR";
|
|
4416
|
-
}
|
|
4417
|
-
function isRegularWorkspaceFile(cwd, relPath, requireCompleteSnapshot) {
|
|
4418
|
-
try {
|
|
4419
|
-
const stat = fs2.lstatSync(join(cwd, relPath));
|
|
4420
|
-
if (stat.isFile()) return true;
|
|
4421
|
-
if (requireCompleteSnapshot && stat.isDirectory()) {
|
|
4422
|
-
throw new WorkspaceEnumerationIncompleteError("inspect-entry", relPath, { code: "ENTRY_TYPE_CHANGED" });
|
|
4423
|
-
}
|
|
4424
|
-
return false;
|
|
4425
|
-
} catch (cause) {
|
|
4426
|
-
if (cause instanceof WorkspaceEnumerationIncompleteError) throw cause;
|
|
4427
|
-
if (requireCompleteSnapshot) {
|
|
4428
|
-
if (isDisappearedWorkspaceEntry(cause)) return false;
|
|
4429
|
-
throw new WorkspaceEnumerationIncompleteError("inspect-entry", relPath, cause);
|
|
4430
|
-
}
|
|
4431
|
-
return false;
|
|
4432
|
-
}
|
|
4433
|
-
}
|
|
4434
|
-
function gitVisibleFilesArgs(candidates) {
|
|
4435
|
-
const args2 = ["--literal-pathspecs", "ls-files", "-z", "--cached", "--others", "--exclude-standard"];
|
|
4436
|
-
if (candidates) args2.push("--", ...candidates);
|
|
4437
|
-
return args2;
|
|
4438
|
-
}
|
|
4439
|
-
function splitGitPathOutput(output) {
|
|
4440
|
-
return output.split("\0").filter((path) => path.length > 0);
|
|
4441
|
-
}
|
|
4442
|
-
function gitVisibleFiles(cwd, candidates) {
|
|
4443
|
-
let output;
|
|
4444
|
-
try {
|
|
4445
|
-
output = execFileSync("git", gitVisibleFilesArgs(candidates), {
|
|
4446
|
-
cwd,
|
|
4447
|
-
maxBuffer: GIT_OUTPUT_LIMIT_BYTES,
|
|
4448
|
-
stdio: ["ignore", "pipe", "ignore"]
|
|
4449
|
-
});
|
|
4450
|
-
} catch {
|
|
4451
|
-
return null;
|
|
4452
|
-
}
|
|
4453
|
-
return splitGitPathOutput(output.toString("utf8"));
|
|
4454
|
-
}
|
|
4455
|
-
function gitVisibleFilesAsync(cwd, candidates) {
|
|
4456
|
-
return new Promise((resolve2) => {
|
|
4457
|
-
execFile("git", gitVisibleFilesArgs(candidates), { cwd, maxBuffer: GIT_OUTPUT_LIMIT_BYTES }, (error, stdout) => {
|
|
4458
|
-
resolve2(error ? null : splitGitPathOutput(stdout));
|
|
4459
|
-
});
|
|
4460
|
-
});
|
|
4461
|
-
}
|
|
4462
|
-
function resolveFallbackLimits(overrides) {
|
|
4463
|
-
const limits = { ...DEFAULT_WORKSPACE_FALLBACK_LIMITS, ...overrides };
|
|
4464
|
-
for (const [name2, value] of Object.entries(limits)) {
|
|
4465
|
-
if (!Number.isFinite(value) || value < 0 || !Number.isInteger(value)) {
|
|
4466
|
-
throw new RangeError(`workspace fallback ${name2} must be a non-negative integer`);
|
|
4467
|
-
}
|
|
4468
|
-
}
|
|
4469
|
-
return limits;
|
|
4470
|
-
}
|
|
4471
|
-
function fallbackEntryKind(absPath, relPath, entry) {
|
|
4472
|
-
if (!entry) return "disappeared";
|
|
4473
|
-
if (entry.isDirectory()) return "directory";
|
|
4474
|
-
if (entry.isFile()) return "file";
|
|
4475
|
-
try {
|
|
4476
|
-
const stat = fs2.lstatSync(absPath);
|
|
4477
|
-
if (stat.isDirectory()) return "directory";
|
|
4478
|
-
if (stat.isFile()) return "file";
|
|
4479
|
-
return "other";
|
|
4480
|
-
} catch (cause) {
|
|
4481
|
-
if (isDisappearedWorkspaceEntry(cause)) return "disappeared";
|
|
4482
|
-
throw new WorkspaceEnumerationIncompleteError("inspect-entry", relPath, cause);
|
|
4483
|
-
}
|
|
4484
|
-
}
|
|
4485
|
-
function closeFrame(frame) {
|
|
4486
|
-
try {
|
|
4487
|
-
frame.dir.closeSync();
|
|
4488
|
-
} catch {
|
|
4489
|
-
}
|
|
4490
|
-
}
|
|
4491
|
-
function* fallbackFilesWalk(cwd, excludedDirs, limits, elapsedMs) {
|
|
4492
|
-
let visitedEntries = 0;
|
|
4493
|
-
let pathBytes = 0;
|
|
4494
|
-
let root;
|
|
4495
|
-
try {
|
|
4496
|
-
root = fs2.opendirSync(cwd);
|
|
4497
|
-
} catch (cause) {
|
|
4498
|
-
throw new WorkspaceEnumerationIncompleteError("open-root", ".", cause);
|
|
4499
|
-
}
|
|
4500
|
-
const stack = [{ dir: root, absPath: cwd, prefix: "", depth: 0 }];
|
|
4501
|
-
const files = [];
|
|
4502
|
-
try {
|
|
4503
|
-
while (stack.length > 0) {
|
|
4504
|
-
yield;
|
|
4505
|
-
if (elapsedMs() >= limits.maxDurationMs) {
|
|
4506
|
-
throw new WorkspaceEnumerationLimitError("time", limits.maxDurationMs);
|
|
4507
|
-
}
|
|
4508
|
-
const frame = stack.at(-1);
|
|
4509
|
-
if (!frame) break;
|
|
4510
|
-
let entry;
|
|
4511
|
-
try {
|
|
4512
|
-
entry = frame.dir.readSync();
|
|
4513
|
-
} catch (cause) {
|
|
4514
|
-
throw new WorkspaceEnumerationIncompleteError("read-directory", frame.prefix || ".", cause);
|
|
4515
|
-
}
|
|
4516
|
-
if (!entry) {
|
|
4517
|
-
closeFrame(frame);
|
|
4518
|
-
stack.pop();
|
|
4519
|
-
continue;
|
|
4520
|
-
}
|
|
4521
|
-
visitedEntries += 1;
|
|
4522
|
-
if (visitedEntries > limits.maxVisitedEntries) {
|
|
4523
|
-
throw new WorkspaceEnumerationLimitError("entries", limits.maxVisitedEntries);
|
|
4524
|
-
}
|
|
4525
|
-
const depth = frame.depth + 1;
|
|
4526
|
-
if (depth > limits.maxDepth) {
|
|
4527
|
-
throw new WorkspaceEnumerationLimitError("depth", limits.maxDepth);
|
|
4528
|
-
}
|
|
4529
|
-
const relPath = frame.prefix.length > 0 ? `${frame.prefix}/${entry.name}` : entry.name;
|
|
4530
|
-
pathBytes += Buffer.byteLength(relPath, "utf8");
|
|
4531
|
-
if (pathBytes > limits.maxPathBytes) {
|
|
4532
|
-
throw new WorkspaceEnumerationLimitError("path-bytes", limits.maxPathBytes);
|
|
4533
|
-
}
|
|
4534
|
-
const absPath = join(frame.absPath, entry.name);
|
|
4535
|
-
const kind = fallbackEntryKind(absPath, relPath, entry);
|
|
4536
|
-
if (kind === "disappeared" || kind === "other") continue;
|
|
4537
|
-
if (kind === "directory") {
|
|
4538
|
-
if (excludedDirs.has(entry.name)) continue;
|
|
4539
|
-
let child;
|
|
4540
|
-
try {
|
|
4541
|
-
child = fs2.opendirSync(absPath);
|
|
4542
|
-
} catch (cause) {
|
|
4543
|
-
if (isDisappearedWorkspaceEntry(cause)) continue;
|
|
4544
|
-
throw new WorkspaceEnumerationIncompleteError("open-directory", relPath, cause);
|
|
4545
|
-
}
|
|
4546
|
-
stack.push({ dir: child, absPath, prefix: relPath, depth });
|
|
4547
|
-
continue;
|
|
4548
|
-
}
|
|
4549
|
-
files.push(relPath);
|
|
4550
|
-
}
|
|
4551
|
-
return files;
|
|
4552
|
-
} finally {
|
|
4553
|
-
for (const frame of stack) closeFrame(frame);
|
|
4554
|
-
}
|
|
4555
|
-
}
|
|
4556
|
-
function fallbackFiles(cwd, excludedDirs, overrides) {
|
|
4557
|
-
const limits = resolveFallbackLimits(overrides);
|
|
4558
|
-
const startedAt = performance2.now();
|
|
4559
|
-
const walk = fallbackFilesWalk(cwd, excludedDirs, limits, () => performance2.now() - startedAt);
|
|
4560
|
-
let step = walk.next();
|
|
4561
|
-
while (!step.done) step = walk.next();
|
|
4562
|
-
return step.value;
|
|
4563
|
-
}
|
|
4564
|
-
async function fallbackFilesAsync(cwd, excludedDirs, overrides, cooperate) {
|
|
4565
|
-
const limits = resolveFallbackLimits(overrides);
|
|
4566
|
-
let activeMs = 0;
|
|
4567
|
-
let resumedAt = performance2.now();
|
|
4568
|
-
const walk = fallbackFilesWalk(cwd, excludedDirs, limits, () => activeMs + (performance2.now() - resumedAt));
|
|
4569
|
-
let step = walk.next();
|
|
4570
|
-
while (!step.done) {
|
|
4571
|
-
activeMs += performance2.now() - resumedAt;
|
|
4572
|
-
await cooperate.tick();
|
|
4573
|
-
resumedAt = performance2.now();
|
|
4574
|
-
step = walk.next();
|
|
4575
|
-
}
|
|
4576
|
-
return step.value;
|
|
4577
|
-
}
|
|
4578
|
-
function* normalizeVisibleFilesSteps(cwd, paths, excludedDirs, requireCompleteSnapshot) {
|
|
4579
|
-
const visible = /* @__PURE__ */ new Set();
|
|
4580
|
-
for (const path of paths) {
|
|
4581
|
-
yield;
|
|
4582
|
-
const normalized = normalizeRelativePath(path);
|
|
4583
|
-
if (!normalized) {
|
|
4584
|
-
if (requireCompleteSnapshot) {
|
|
4585
|
-
throw new WorkspaceEnumerationIncompleteError("inspect-entry", path, { code: "INVALID_RELATIVE_PATH" });
|
|
4586
|
-
}
|
|
4587
|
-
continue;
|
|
4588
|
-
}
|
|
4589
|
-
if (isWorkspacePathExcluded(normalized, excludedDirs)) continue;
|
|
4590
|
-
if (isRegularWorkspaceFile(cwd, normalized, requireCompleteSnapshot)) visible.add(normalized);
|
|
4591
|
-
}
|
|
4592
|
-
return [...visible].sort(comparePaths);
|
|
4593
|
-
}
|
|
4594
|
-
function normalizeVisibleFiles(cwd, paths, excludedDirs, requireCompleteSnapshot = false) {
|
|
4595
|
-
const steps = normalizeVisibleFilesSteps(cwd, paths, excludedDirs, requireCompleteSnapshot);
|
|
4596
|
-
let step = steps.next();
|
|
4597
|
-
while (!step.done) step = steps.next();
|
|
4598
|
-
return step.value;
|
|
4599
|
-
}
|
|
4600
|
-
async function normalizeVisibleFilesAsync(cwd, paths, excludedDirs, requireCompleteSnapshot, cooperate) {
|
|
4601
|
-
const steps = normalizeVisibleFilesSteps(cwd, paths, excludedDirs, requireCompleteSnapshot);
|
|
4602
|
-
let step = steps.next();
|
|
4603
|
-
while (!step.done) {
|
|
4604
|
-
await cooperate.tick();
|
|
4605
|
-
step = steps.next();
|
|
4606
|
-
}
|
|
4607
|
-
return step.value;
|
|
4608
|
-
}
|
|
4609
|
-
function enumerateWorkspaceFiles(cwd, excludedDirs = WORKSPACE_EXCLUDED_DIRS, fallbackLimits) {
|
|
4610
|
-
const gitFiles = gitVisibleFiles(cwd);
|
|
4611
|
-
if (gitFiles) return normalizeVisibleFiles(cwd, gitFiles, excludedDirs);
|
|
4612
|
-
return normalizeVisibleFiles(cwd, fallbackFiles(cwd, excludedDirs, fallbackLimits), excludedDirs, true);
|
|
4613
|
-
}
|
|
4614
|
-
async function enumerateWorkspaceFilesAsync(cwd, excludedDirs = WORKSPACE_EXCLUDED_DIRS, fallbackLimits, cooperate = createDefaultTick()) {
|
|
4615
|
-
const gitFiles = await gitVisibleFilesAsync(cwd);
|
|
4616
|
-
if (gitFiles) return normalizeVisibleFilesAsync(cwd, gitFiles, excludedDirs, false, cooperate);
|
|
4617
|
-
const walked = await fallbackFilesAsync(cwd, excludedDirs, fallbackLimits, cooperate);
|
|
4618
|
-
return normalizeVisibleFilesAsync(cwd, walked, excludedDirs, true, cooperate);
|
|
4619
|
-
}
|
|
4620
|
-
function filterWorkspaceFileCandidates(cwd, paths, excludedDirs = WORKSPACE_EXCLUDED_DIRS, fallbackLimits) {
|
|
4621
|
-
const candidates = paths.map(normalizeRelativePath).filter((path) => path !== null && !isWorkspacePathExcluded(path, excludedDirs));
|
|
4622
|
-
if (candidates.length === 0) return [];
|
|
4623
|
-
const gitFiles = gitVisibleFiles(cwd, candidates);
|
|
4624
|
-
if (gitFiles) return normalizeVisibleFiles(cwd, gitFiles, excludedDirs);
|
|
4625
|
-
const fallbackVisible = new Set(
|
|
4626
|
-
normalizeVisibleFiles(cwd, fallbackFiles(cwd, excludedDirs, fallbackLimits), excludedDirs, true)
|
|
4627
|
-
);
|
|
4628
|
-
return candidates.filter((path) => fallbackVisible.has(path)).sort(comparePaths);
|
|
4629
|
-
}
|
|
4630
|
-
|
|
4631
|
-
// src/domains/session/workspace/project-type.ts
|
|
4632
|
-
var SOURCE_LANGUAGES = [
|
|
4633
|
-
"typescript",
|
|
4634
|
-
"javascript",
|
|
4635
|
-
"python",
|
|
4636
|
-
"rust",
|
|
4637
|
-
"go",
|
|
4638
|
-
"c",
|
|
4639
|
-
"c++",
|
|
4640
|
-
"java",
|
|
4641
|
-
"ruby",
|
|
4642
|
-
"c#"
|
|
4643
|
-
];
|
|
4644
|
-
var EXTENSION_LANGUAGES = /* @__PURE__ */ new Map([
|
|
4645
|
-
[".ts", "typescript"],
|
|
4646
|
-
[".tsx", "typescript"],
|
|
4647
|
-
[".mts", "typescript"],
|
|
4648
|
-
[".cts", "typescript"],
|
|
4649
|
-
[".js", "javascript"],
|
|
4650
|
-
[".jsx", "javascript"],
|
|
4651
|
-
[".mjs", "javascript"],
|
|
4652
|
-
[".cjs", "javascript"],
|
|
4653
|
-
[".py", "python"],
|
|
4654
|
-
[".pyw", "python"],
|
|
4655
|
-
[".rs", "rust"],
|
|
4656
|
-
[".go", "go"],
|
|
4657
|
-
[".c", "c"],
|
|
4658
|
-
[".h", "c"],
|
|
4659
|
-
[".cc", "c++"],
|
|
4660
|
-
[".cpp", "c++"],
|
|
4661
|
-
[".cxx", "c++"],
|
|
4662
|
-
[".hpp", "c++"],
|
|
4663
|
-
[".hh", "c++"],
|
|
4664
|
-
[".hxx", "c++"],
|
|
4665
|
-
[".cu", "c++"],
|
|
4666
|
-
[".cuh", "c++"],
|
|
4667
|
-
[".java", "java"],
|
|
4668
|
-
[".rb", "ruby"],
|
|
4669
|
-
[".cs", "c#"]
|
|
4670
|
-
]);
|
|
4671
|
-
var MANIFEST_LANGUAGES = [
|
|
4672
|
-
{ name: "package.json", type: "typescript" },
|
|
4673
|
-
{ name: "pyproject.toml", type: "python" },
|
|
4674
|
-
{ name: "setup.py", type: "python" },
|
|
4675
|
-
{ name: "Cargo.toml", type: "rust" },
|
|
4676
|
-
{ name: "go.mod", type: "go" },
|
|
4677
|
-
{ name: "pom.xml", type: "java" },
|
|
4678
|
-
{ name: "CMakeLists.txt", type: "c++" },
|
|
4679
|
-
{ name: "compile_commands.json", type: "c++" },
|
|
4680
|
-
{ name: "Gemfile", type: "ruby" },
|
|
4681
|
-
{ name: "*.csproj", type: "c#" }
|
|
4682
|
-
];
|
|
4683
|
-
function emptyLanguageCounts() {
|
|
4684
|
-
return {
|
|
4685
|
-
typescript: 0,
|
|
4686
|
-
javascript: 0,
|
|
4687
|
-
python: 0,
|
|
4688
|
-
rust: 0,
|
|
4689
|
-
go: 0,
|
|
4690
|
-
c: 0,
|
|
4691
|
-
"c++": 0,
|
|
4692
|
-
java: 0,
|
|
4693
|
-
ruby: 0,
|
|
4694
|
-
"c#": 0
|
|
4695
|
-
};
|
|
4696
|
-
}
|
|
4697
|
-
function extensionOf(name2) {
|
|
4698
|
-
const index = name2.lastIndexOf(".");
|
|
4699
|
-
return index === -1 ? "" : name2.slice(index);
|
|
4700
|
-
}
|
|
4701
|
-
function countManifest(name2, manifestCounts) {
|
|
4702
|
-
for (const marker of MANIFEST_LANGUAGES) {
|
|
4703
|
-
if (marker.name.startsWith("*.")) {
|
|
4704
|
-
const ext = marker.name.slice(1);
|
|
4705
|
-
if (name2.endsWith(ext)) {
|
|
4706
|
-
manifestCounts[marker.type] = (manifestCounts[marker.type] ?? 0) + 1;
|
|
4707
|
-
}
|
|
4708
|
-
} else {
|
|
4709
|
-
if (name2 !== marker.name) continue;
|
|
4710
|
-
manifestCounts[marker.type] = (manifestCounts[marker.type] ?? 0) + 1;
|
|
4711
|
-
}
|
|
4712
|
-
}
|
|
4713
|
-
}
|
|
4714
|
-
function scanFiles(cwd, files, languageCounts, manifestCounts) {
|
|
4715
|
-
for (const path of files) {
|
|
4716
|
-
const name2 = path.split("/").pop() ?? path;
|
|
4717
|
-
countManifest(name2, manifestCounts);
|
|
4718
|
-
if (name2.endsWith(".d.ts")) continue;
|
|
4719
|
-
const extension = extensionOf(name2);
|
|
4720
|
-
let language = EXTENSION_LANGUAGES.get(extension);
|
|
4721
|
-
if (extension === ".h") {
|
|
4722
|
-
try {
|
|
4723
|
-
language = classifyCHeaderLanguage(readFileSync(join2(cwd, path), "utf8"));
|
|
4724
|
-
} catch {
|
|
4725
|
-
language = "c";
|
|
4726
|
-
}
|
|
4727
|
-
}
|
|
4728
|
-
if (language) languageCounts[language] += 1;
|
|
4729
|
-
}
|
|
4730
|
-
}
|
|
4731
|
-
function looksLikeDotfiles(files) {
|
|
4732
|
-
const dotDirs = /* @__PURE__ */ new Set();
|
|
4733
|
-
for (const path of files) {
|
|
4734
|
-
const [root, child] = path.split("/", 2);
|
|
4735
|
-
if (child && root?.startsWith("dot-")) dotDirs.add(root);
|
|
4736
|
-
}
|
|
4737
|
-
return dotDirs.size >= 2;
|
|
4738
|
-
}
|
|
4739
|
-
function dominantFromCounts(counts) {
|
|
4740
|
-
let best;
|
|
4741
|
-
let bestCount = 0;
|
|
4742
|
-
for (const language of SOURCE_LANGUAGES) {
|
|
4743
|
-
const count = counts[language] ?? 0;
|
|
4744
|
-
if (count > bestCount) {
|
|
4745
|
-
best = language;
|
|
4746
|
-
bestCount = count;
|
|
4747
|
-
} else if (count === bestCount && count > 0) {
|
|
4748
|
-
best = void 0;
|
|
4749
|
-
}
|
|
4750
|
-
}
|
|
4751
|
-
return best;
|
|
4752
|
-
}
|
|
4753
|
-
function detectProjectProfile(cwd) {
|
|
4754
|
-
const languageCounts = emptyLanguageCounts();
|
|
4755
|
-
const manifestCounts = {};
|
|
4756
|
-
const files = enumerateWorkspaceFiles(cwd);
|
|
4757
|
-
scanFiles(cwd, files, languageCounts, manifestCounts);
|
|
4758
|
-
const sourceFiles = SOURCE_LANGUAGES.reduce((sum, language) => sum + languageCounts[language], 0);
|
|
4759
|
-
const dominantSource = dominantFromCounts(languageCounts);
|
|
4760
|
-
const dominantCount = dominantSource ? languageCounts[dominantSource] : 0;
|
|
4761
|
-
const polyglot = sourceFiles > 0 && dominantCount / sourceFiles <= 0.7;
|
|
4762
|
-
if (sourceFiles > 0) {
|
|
4763
|
-
return {
|
|
4764
|
-
projectType: polyglot ? "polyglot" : dominantSource ?? "polyglot",
|
|
4765
|
-
sourceFiles,
|
|
4766
|
-
languageCounts,
|
|
4767
|
-
manifestCounts,
|
|
4768
|
-
...dominantSource ? { dominantLanguage: dominantSource } : {},
|
|
4769
|
-
polyglot
|
|
4770
|
-
};
|
|
4771
|
-
}
|
|
4772
|
-
const manifestDominant = dominantFromCounts(manifestCounts);
|
|
4773
|
-
if (manifestDominant) {
|
|
4774
|
-
return {
|
|
4775
|
-
projectType: manifestDominant,
|
|
4776
|
-
sourceFiles,
|
|
4777
|
-
languageCounts,
|
|
4778
|
-
manifestCounts,
|
|
4779
|
-
dominantLanguage: manifestDominant,
|
|
4780
|
-
polyglot: false
|
|
4781
|
-
};
|
|
4782
|
-
}
|
|
4783
|
-
const manifestTotal = SOURCE_LANGUAGES.reduce((sum, language) => sum + (manifestCounts[language] ?? 0), 0);
|
|
4784
|
-
if (manifestTotal > 0) {
|
|
4785
|
-
return {
|
|
4786
|
-
projectType: "polyglot",
|
|
4787
|
-
sourceFiles,
|
|
4788
|
-
languageCounts,
|
|
4789
|
-
manifestCounts,
|
|
4790
|
-
polyglot: true
|
|
4791
|
-
};
|
|
4792
|
-
}
|
|
4793
|
-
return {
|
|
4794
|
-
projectType: looksLikeDotfiles(files) ? "dotfiles" : "unknown",
|
|
4795
|
-
sourceFiles,
|
|
4796
|
-
languageCounts,
|
|
4797
|
-
manifestCounts,
|
|
4798
|
-
polyglot: false
|
|
4799
|
-
};
|
|
4800
|
-
}
|
|
4801
|
-
function detectProjectType(cwd) {
|
|
4802
|
-
return detectProjectProfile(cwd).projectType;
|
|
4803
|
-
}
|
|
4804
|
-
|
|
4805
|
-
// src/domains/context/codewiki/cooperative.ts
|
|
4806
|
-
init_esm_shims();
|
|
4807
|
-
import { setImmediate as yieldToEventLoop } from "node:timers/promises";
|
|
4808
|
-
var INDEX_SLICE_MS = 8;
|
|
4809
|
-
var settled = Promise.resolve();
|
|
4810
|
-
function createSlicer(sliceMs = INDEX_SLICE_MS) {
|
|
4811
|
-
let deadline = performance.now() + sliceMs;
|
|
4812
|
-
let yields = 0;
|
|
4813
|
-
return {
|
|
4814
|
-
tick() {
|
|
4815
|
-
if (performance.now() < deadline) return settled;
|
|
4816
|
-
yields += 1;
|
|
4817
|
-
return yieldToEventLoop().then(() => {
|
|
4818
|
-
deadline = performance.now() + sliceMs;
|
|
4819
|
-
});
|
|
4820
|
-
},
|
|
4821
|
-
get yields() {
|
|
4822
|
-
return yields;
|
|
4823
|
-
}
|
|
4824
|
-
};
|
|
4825
|
-
}
|
|
4826
|
-
|
|
4827
|
-
// src/domains/context/codewiki/indexer.ts
|
|
4828
|
-
init_esm_shims();
|
|
4829
|
-
import { createHash } from "node:crypto";
|
|
4830
|
-
import { existsSync, readFileSync as readFileSync2, statSync } from "node:fs";
|
|
4831
|
-
import { readFile as readFileAsync } from "node:fs/promises";
|
|
4832
|
-
import { dirname, join as join4, relative, resolve } from "node:path";
|
|
4833
|
-
|
|
4834
|
-
// src/domains/context/excluded-dirs.ts
|
|
4835
|
-
init_esm_shims();
|
|
4836
|
-
|
|
4837
|
-
// src/domains/context/codewiki/cmake.ts
|
|
4838
|
-
init_esm_shims();
|
|
4839
|
-
var SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
4840
|
-
".c",
|
|
4841
|
-
".cc",
|
|
4842
|
-
".cpp",
|
|
4843
|
-
".cxx",
|
|
4844
|
-
".cu",
|
|
4845
|
-
".cuh",
|
|
4846
|
-
".h",
|
|
4847
|
-
".hh",
|
|
4848
|
-
".hpp",
|
|
4849
|
-
".hxx",
|
|
4850
|
-
".java",
|
|
4851
|
-
".js",
|
|
4852
|
-
".jsx",
|
|
4853
|
-
".mjs",
|
|
4854
|
-
".cjs",
|
|
4855
|
-
".mts",
|
|
4856
|
-
".cts",
|
|
4857
|
-
".py",
|
|
4858
|
-
".pyw",
|
|
4859
|
-
".rb",
|
|
4860
|
-
".rs",
|
|
4861
|
-
".cs",
|
|
4862
|
-
".ts",
|
|
4863
|
-
".tsx"
|
|
4864
|
-
]);
|
|
4865
|
-
var TARGET_SOURCE_KEYWORDS = /* @__PURE__ */ new Set([
|
|
4866
|
-
"PUBLIC",
|
|
4867
|
-
"PRIVATE",
|
|
4868
|
-
"INTERFACE",
|
|
4869
|
-
"BEFORE",
|
|
4870
|
-
"FILE_SET",
|
|
4871
|
-
"TYPE",
|
|
4872
|
-
"BASE_DIRS",
|
|
4873
|
-
"FILES"
|
|
4874
|
-
]);
|
|
4875
|
-
function compareStrings(a, b) {
|
|
4876
|
-
return a.localeCompare(b);
|
|
4877
|
-
}
|
|
4878
|
-
function uniqueSorted(values) {
|
|
4879
|
-
return [...new Set(values)].sort(compareStrings);
|
|
4880
|
-
}
|
|
4881
|
-
function lineStarts(text) {
|
|
4882
|
-
const starts = [0];
|
|
4883
|
-
for (let index = 0; index < text.length; index += 1) {
|
|
4884
|
-
if (text[index] === "\n") starts.push(index + 1);
|
|
4885
|
-
}
|
|
4886
|
-
return starts;
|
|
4887
|
-
}
|
|
4888
|
-
function lineAt(starts, offset) {
|
|
4889
|
-
let low = 0;
|
|
4890
|
-
let high = starts.length;
|
|
4891
|
-
while (low < high) {
|
|
4892
|
-
const middle = Math.floor((low + high) / 2);
|
|
4893
|
-
if ((starts[middle] ?? 0) <= offset) low = middle + 1;
|
|
4894
|
-
else high = middle;
|
|
4895
|
-
}
|
|
4896
|
-
return Math.max(1, low);
|
|
4897
|
-
}
|
|
4898
|
-
function readBracketBlock(text, index) {
|
|
4899
|
-
if (text[index] !== "[") return null;
|
|
4900
|
-
let delimiterEnd = index + 1;
|
|
4901
|
-
while (text[delimiterEnd] === "=") delimiterEnd += 1;
|
|
4902
|
-
if (text[delimiterEnd] !== "[") return null;
|
|
4903
|
-
const equals = text.slice(index + 1, delimiterEnd);
|
|
4904
|
-
const close = `]${equals}]`;
|
|
4905
|
-
const contentStart = delimiterEnd + 1;
|
|
4906
|
-
const closeStart = text.indexOf(close, contentStart);
|
|
4907
|
-
if (closeStart === -1) return null;
|
|
4908
|
-
return {
|
|
4909
|
-
content: text.slice(contentStart, closeStart),
|
|
4910
|
-
end: closeStart + close.length
|
|
4911
|
-
};
|
|
4912
|
-
}
|
|
4913
|
-
function skipComment(text, index) {
|
|
4914
|
-
const bracket = readBracketBlock(text, index + 1);
|
|
4915
|
-
if (bracket) return bracket.end;
|
|
4916
|
-
const newline = text.indexOf("\n", index + 1);
|
|
4917
|
-
return newline === -1 ? text.length : newline + 1;
|
|
4918
|
-
}
|
|
4919
|
-
function skipTrivia(text, start2) {
|
|
4920
|
-
let index = start2;
|
|
4921
|
-
while (index < text.length) {
|
|
4922
|
-
if (/\s/.test(text[index] ?? "")) {
|
|
4923
|
-
index += 1;
|
|
4924
|
-
continue;
|
|
4925
|
-
}
|
|
4926
|
-
if (text[index] === "#") {
|
|
4927
|
-
index = skipComment(text, index);
|
|
4928
|
-
continue;
|
|
4929
|
-
}
|
|
4930
|
-
break;
|
|
4931
|
-
}
|
|
4932
|
-
return index;
|
|
4933
|
-
}
|
|
4934
|
-
function readQuotedArgument(text, start2) {
|
|
4935
|
-
let content = "";
|
|
4936
|
-
for (let index = start2 + 1; index < text.length; index += 1) {
|
|
4937
|
-
const current = text[index] ?? "";
|
|
4938
|
-
if (current === '"') return { content, end: index + 1 };
|
|
4939
|
-
if (current === "\\") {
|
|
4940
|
-
const next = text[index + 1];
|
|
4941
|
-
if (next === void 0) return null;
|
|
4942
|
-
if (next === "\n") {
|
|
4943
|
-
index += 1;
|
|
4944
|
-
continue;
|
|
4945
|
-
}
|
|
4946
|
-
content += next;
|
|
4947
|
-
index += 1;
|
|
4948
|
-
continue;
|
|
4949
|
-
}
|
|
4950
|
-
content += current;
|
|
4951
|
-
}
|
|
4952
|
-
return null;
|
|
4953
|
-
}
|
|
4954
|
-
function parseInvocation(text, name2, line2, openParen) {
|
|
4955
|
-
const args2 = [];
|
|
4956
|
-
let current = "";
|
|
4957
|
-
let depth = 1;
|
|
4958
|
-
let index = openParen + 1;
|
|
4959
|
-
const flush = () => {
|
|
4960
|
-
if (current.length > 0) args2.push(current);
|
|
4961
|
-
current = "";
|
|
4962
|
-
};
|
|
4963
|
-
while (index < text.length) {
|
|
4964
|
-
const char = text[index] ?? "";
|
|
4965
|
-
if (/\s/.test(char)) {
|
|
4966
|
-
flush();
|
|
4967
|
-
index += 1;
|
|
4968
|
-
continue;
|
|
4969
|
-
}
|
|
4970
|
-
if (char === "#") {
|
|
4971
|
-
flush();
|
|
4972
|
-
index = skipComment(text, index);
|
|
4973
|
-
continue;
|
|
4974
|
-
}
|
|
4975
|
-
if (char === '"') {
|
|
4976
|
-
const quoted = readQuotedArgument(text, index);
|
|
4977
|
-
if (!quoted) return null;
|
|
4978
|
-
current += quoted.content;
|
|
4979
|
-
index = quoted.end;
|
|
4980
|
-
continue;
|
|
4981
|
-
}
|
|
4982
|
-
if (char === "[") {
|
|
4983
|
-
const bracket = readBracketBlock(text, index);
|
|
4984
|
-
if (bracket) {
|
|
4985
|
-
current += bracket.content;
|
|
4986
|
-
index = bracket.end;
|
|
4987
|
-
continue;
|
|
4988
|
-
}
|
|
4989
|
-
}
|
|
4990
|
-
if (char === "\\") {
|
|
4991
|
-
const next = text[index + 1];
|
|
4992
|
-
if (next === void 0) return null;
|
|
4993
|
-
if (next === "\n") {
|
|
4994
|
-
index += 2;
|
|
4995
|
-
continue;
|
|
4996
|
-
}
|
|
4997
|
-
current += next;
|
|
4998
|
-
index += 2;
|
|
4999
|
-
continue;
|
|
5000
|
-
}
|
|
5001
|
-
if (char === ";" && depth === 1) {
|
|
5002
|
-
flush();
|
|
5003
|
-
index += 1;
|
|
5004
|
-
continue;
|
|
5005
|
-
}
|
|
5006
|
-
if (char === "(") {
|
|
5007
|
-
depth += 1;
|
|
5008
|
-
current += char;
|
|
5009
|
-
index += 1;
|
|
5010
|
-
continue;
|
|
5011
|
-
}
|
|
5012
|
-
if (char === ")") {
|
|
5013
|
-
depth -= 1;
|
|
5014
|
-
if (depth === 0) {
|
|
5015
|
-
flush();
|
|
5016
|
-
return {
|
|
5017
|
-
invocation: { name: name2, line: line2, args: args2 },
|
|
5018
|
-
end: index + 1
|
|
5019
|
-
};
|
|
5020
|
-
}
|
|
5021
|
-
current += char;
|
|
5022
|
-
index += 1;
|
|
5023
|
-
continue;
|
|
5024
|
-
}
|
|
5025
|
-
current += char;
|
|
5026
|
-
index += 1;
|
|
5027
|
-
}
|
|
5028
|
-
return null;
|
|
5029
|
-
}
|
|
5030
|
-
function scanInvocations(text) {
|
|
5031
|
-
const invocations = [];
|
|
5032
|
-
const starts = lineStarts(text);
|
|
5033
|
-
let index = 0;
|
|
5034
|
-
while (index < text.length) {
|
|
5035
|
-
index = skipTrivia(text, index);
|
|
5036
|
-
if (index >= text.length) break;
|
|
5037
|
-
if (text[index] === '"') {
|
|
5038
|
-
const quoted = readQuotedArgument(text, index);
|
|
5039
|
-
index = quoted?.end ?? text.length;
|
|
5040
|
-
continue;
|
|
5041
|
-
}
|
|
5042
|
-
if (text[index] === "[") {
|
|
5043
|
-
const bracket = readBracketBlock(text, index);
|
|
5044
|
-
if (bracket) {
|
|
5045
|
-
index = bracket.end;
|
|
5046
|
-
continue;
|
|
5047
|
-
}
|
|
5048
|
-
}
|
|
5049
|
-
const name2 = /^[A-Za-z_][A-Za-z_0-9]*/.exec(text.slice(index))?.[0];
|
|
5050
|
-
if (!name2) {
|
|
5051
|
-
index += 1;
|
|
5052
|
-
continue;
|
|
5053
|
-
}
|
|
5054
|
-
const nameStart = index;
|
|
5055
|
-
const openParen = skipTrivia(text, index + name2.length);
|
|
5056
|
-
if (text[openParen] !== "(") {
|
|
5057
|
-
index += name2.length;
|
|
5058
|
-
continue;
|
|
5059
|
-
}
|
|
5060
|
-
const parsed = parseInvocation(text, name2.toLowerCase(), lineAt(starts, nameStart), openParen);
|
|
5061
|
-
if (!parsed) {
|
|
5062
|
-
index = openParen + 1;
|
|
5063
|
-
continue;
|
|
5064
|
-
}
|
|
5065
|
-
invocations.push(parsed.invocation);
|
|
5066
|
-
index = parsed.end;
|
|
5067
|
-
}
|
|
5068
|
-
return invocations;
|
|
5069
|
-
}
|
|
5070
|
-
function literal(value) {
|
|
5071
|
-
if (!value) return null;
|
|
5072
|
-
const trimmed = value.trim();
|
|
5073
|
-
if (trimmed.length === 0 || trimmed.includes("$")) return null;
|
|
5074
|
-
return trimmed.replace(/\\/g, "/");
|
|
5075
|
-
}
|
|
5076
|
-
function literalTarget(value) {
|
|
5077
|
-
const target = literal(value);
|
|
5078
|
-
return target && /^[A-Za-z0-9_.:+-]+$/.test(target) ? target : null;
|
|
5079
|
-
}
|
|
5080
|
-
function relativeSpecifier(value) {
|
|
5081
|
-
if (value.startsWith("/") || /^[A-Za-z]:\//.test(value)) return null;
|
|
5082
|
-
const normalized = value.replace(/^\.\//, "").replace(/\/+$/g, "");
|
|
5083
|
-
if (normalized.length === 0) return null;
|
|
5084
|
-
return normalized.startsWith(".") ? normalized : `./${normalized}`;
|
|
5085
|
-
}
|
|
5086
|
-
function sourceSpecifier(value) {
|
|
5087
|
-
const path = literal(value);
|
|
5088
|
-
if (!path || path.includes(";") || path.startsWith("-") || TARGET_SOURCE_KEYWORDS.has(path.toUpperCase())) return null;
|
|
5089
|
-
const withoutQuery = path.split(/[?#]/, 1)[0] ?? path;
|
|
5090
|
-
const dot = withoutQuery.lastIndexOf(".");
|
|
5091
|
-
if (dot === -1 || !SOURCE_EXTENSIONS.has(withoutQuery.slice(dot).toLowerCase())) return null;
|
|
5092
|
-
return relativeSpecifier(path);
|
|
5093
|
-
}
|
|
5094
|
-
function childCMakeSpecifier(value) {
|
|
5095
|
-
const directory = literal(value);
|
|
5096
|
-
if (!directory) return null;
|
|
5097
|
-
const relative2 = relativeSpecifier(directory);
|
|
5098
|
-
if (!relative2) return null;
|
|
5099
|
-
return `${relative2}/CMakeLists.txt`.replace(/\/\//g, "/");
|
|
5100
|
-
}
|
|
5101
|
-
function isCMakePath(path) {
|
|
5102
|
-
const name2 = path.split("/").at(-1) ?? path;
|
|
5103
|
-
return name2 === "CMakeLists.txt" || name2.toLowerCase().endsWith(".cmake");
|
|
5104
|
-
}
|
|
5105
|
-
function extractCMake(text) {
|
|
5106
|
-
const symbols = [];
|
|
5107
|
-
const imports = [];
|
|
5108
|
-
for (const invocation of scanInvocations(text)) {
|
|
5109
|
-
if (invocation.name === "add_subdirectory") {
|
|
5110
|
-
const child = childCMakeSpecifier(invocation.args[0]);
|
|
5111
|
-
if (child) imports.push(child);
|
|
5112
|
-
continue;
|
|
5113
|
-
}
|
|
5114
|
-
if (invocation.name === "add_library" || invocation.name === "add_executable") {
|
|
5115
|
-
const target = literalTarget(invocation.args[0]);
|
|
5116
|
-
if (!target) continue;
|
|
5117
|
-
symbols.push({ name: target, kind: "const", line: invocation.line });
|
|
5118
|
-
if (invocation.args[1]?.toUpperCase() === "ALIAS") continue;
|
|
5119
|
-
for (const arg of invocation.args.slice(1)) {
|
|
5120
|
-
const source = sourceSpecifier(arg);
|
|
5121
|
-
if (source) imports.push(source);
|
|
5122
|
-
}
|
|
5123
|
-
continue;
|
|
5124
|
-
}
|
|
5125
|
-
if (invocation.name === "target_sources") {
|
|
5126
|
-
if (!literalTarget(invocation.args[0])) continue;
|
|
5127
|
-
for (const arg of invocation.args.slice(1)) {
|
|
5128
|
-
const source = sourceSpecifier(arg);
|
|
5129
|
-
if (source) imports.push(source);
|
|
5130
|
-
}
|
|
5131
|
-
}
|
|
5132
|
-
}
|
|
5133
|
-
return {
|
|
5134
|
-
symbols: symbols.sort((a, b) => a.line - b.line || a.name.localeCompare(b.name)),
|
|
5135
|
-
imports: uniqueSorted(imports)
|
|
5136
|
-
};
|
|
5137
|
-
}
|
|
5138
|
-
|
|
5139
4067
|
// src/domains/context/codewiki/tree-sitter.ts
|
|
5140
4068
|
init_esm_shims();
|
|
5141
4069
|
var import_tree_sitter_wasm = __toESM(require_tree_sitter(), 1);
|
|
5142
|
-
import { join
|
|
4070
|
+
import { join } from "node:path";
|
|
5143
4071
|
|
|
5144
4072
|
// src/domains/context/codewiki/grammar-assets.ts
|
|
5145
4073
|
init_esm_shims();
|
|
@@ -5148,7 +4076,7 @@ var TREE_SITTER_RUNTIME_WASM = "tree-sitter.wasm";
|
|
|
5148
4076
|
// src/domains/context/codewiki/tree-sitter.ts
|
|
5149
4077
|
var { Language: Language2, Parser: Parser2 } = import_tree_sitter_wasm.default;
|
|
5150
4078
|
function grammarAssetPath(file) {
|
|
5151
|
-
return
|
|
4079
|
+
return join(resolvePackageRoot(), "dist", "assets", "grammars", file);
|
|
5152
4080
|
}
|
|
5153
4081
|
var WASM_BY_GRAMMAR = {
|
|
5154
4082
|
typescript: "tree-sitter-typescript.wasm",
|
|
@@ -5272,11 +4200,11 @@ function addSymbol(target, node, kind, name2 = nameFromNode(node)) {
|
|
|
5272
4200
|
function descendants(root, types) {
|
|
5273
4201
|
return root.descendantsOfType(types).filter((node) => node !== null);
|
|
5274
4202
|
}
|
|
5275
|
-
function
|
|
4203
|
+
function compareStrings(a, b) {
|
|
5276
4204
|
return a.localeCompare(b);
|
|
5277
4205
|
}
|
|
5278
|
-
function
|
|
5279
|
-
return [...new Set([...values].filter((value) => value.trim().length > 0))].sort(
|
|
4206
|
+
function uniqueSorted(values) {
|
|
4207
|
+
return [...new Set([...values].filter((value) => value.trim().length > 0))].sort(compareStrings);
|
|
5280
4208
|
}
|
|
5281
4209
|
function cleanStringLiteral(value) {
|
|
5282
4210
|
const trimmed = value.trim();
|
|
@@ -5577,7 +4505,7 @@ function extractTsJsImports(root) {
|
|
|
5577
4505
|
const source = firstStringValue(node.childForFieldName("arguments"));
|
|
5578
4506
|
if (source) imports.push(source);
|
|
5579
4507
|
}
|
|
5580
|
-
return
|
|
4508
|
+
return uniqueSorted(imports);
|
|
5581
4509
|
}
|
|
5582
4510
|
function extractPythonImports(root) {
|
|
5583
4511
|
const imports = [];
|
|
@@ -5594,7 +4522,7 @@ function extractPythonImports(root) {
|
|
|
5594
4522
|
const moduleName = node.childForFieldName("module_name") ?? namedChildren(node).find((child) => child.type === "relative_import" || child.type === "dotted_name");
|
|
5595
4523
|
if (moduleName) imports.push(moduleName.text);
|
|
5596
4524
|
}
|
|
5597
|
-
return
|
|
4525
|
+
return uniqueSorted(imports);
|
|
5598
4526
|
}
|
|
5599
4527
|
function extractGoImports(root) {
|
|
5600
4528
|
const imports = [];
|
|
@@ -5602,7 +4530,7 @@ function extractGoImports(root) {
|
|
|
5602
4530
|
const source = stringValue(node.childForFieldName("path"));
|
|
5603
4531
|
if (source) imports.push(source);
|
|
5604
4532
|
}
|
|
5605
|
-
return
|
|
4533
|
+
return uniqueSorted(imports);
|
|
5606
4534
|
}
|
|
5607
4535
|
function extractRustImports(root) {
|
|
5608
4536
|
const imports = [];
|
|
@@ -5614,7 +4542,7 @@ function extractRustImports(root) {
|
|
|
5614
4542
|
const name2 = node.childForFieldName("name") ?? namedChildren(node).find((child) => child.type === "identifier");
|
|
5615
4543
|
if (name2) imports.push(name2.text.trim());
|
|
5616
4544
|
}
|
|
5617
|
-
return
|
|
4545
|
+
return uniqueSorted(imports);
|
|
5618
4546
|
}
|
|
5619
4547
|
function extractCFamilyImports(root) {
|
|
5620
4548
|
const imports = [];
|
|
@@ -5625,7 +4553,7 @@ function extractCFamilyImports(root) {
|
|
|
5625
4553
|
const quoted = sourceNode?.text.trim().startsWith('"') === true;
|
|
5626
4554
|
imports.push(quoted && !source.startsWith(".") && !source.startsWith("/") ? `./${source}` : source);
|
|
5627
4555
|
}
|
|
5628
|
-
return
|
|
4556
|
+
return uniqueSorted(imports);
|
|
5629
4557
|
}
|
|
5630
4558
|
function extractJavaImports(root) {
|
|
5631
4559
|
const imports = [];
|
|
@@ -5633,10 +4561,10 @@ function extractJavaImports(root) {
|
|
|
5633
4561
|
const source = node.text.replace(/^import\s+/, "").replace(/^static\s+/, "").replace(/;$/, "").trim();
|
|
5634
4562
|
if (source) imports.push(source);
|
|
5635
4563
|
}
|
|
5636
|
-
return
|
|
4564
|
+
return uniqueSorted(imports);
|
|
5637
4565
|
}
|
|
5638
4566
|
function extractRubyImports(root) {
|
|
5639
|
-
return
|
|
4567
|
+
return uniqueSorted([
|
|
5640
4568
|
...Array.from(root.text.matchAll(/^\s*require\s+["']([^"']+)["']/gm), (match) => match[1] ?? ""),
|
|
5641
4569
|
...Array.from(root.text.matchAll(/^\s*require_relative\s+["']([^"']+)["']/gm), (match) => `./${match[1] ?? ""}`)
|
|
5642
4570
|
]);
|
|
@@ -5650,7 +4578,7 @@ function extractCSharpImports(root) {
|
|
|
5650
4578
|
if (aliasIndex !== -1) source = source.slice(aliasIndex + 1).trim();
|
|
5651
4579
|
if (source) imports.push(source);
|
|
5652
4580
|
}
|
|
5653
|
-
return
|
|
4581
|
+
return uniqueSorted(imports);
|
|
5654
4582
|
}
|
|
5655
4583
|
function extractImportsByGrammar(grammar, root) {
|
|
5656
4584
|
if (grammar === "typescript" || grammar === "tsx" || grammar === "javascript") return extractTsJsImports(root);
|
|
@@ -5739,1213 +4667,7 @@ function languageFromPath(path) {
|
|
|
5739
4667
|
if (path.endsWith(".cs")) return "c#";
|
|
5740
4668
|
return "config";
|
|
5741
4669
|
}
|
|
5742
|
-
|
|
5743
|
-
// src/domains/context/codewiki/indexer.ts
|
|
5744
|
-
var CODEWIKI_SYMBOL_KINDS_WITH_SIG = /* @__PURE__ */ new Set(["func", "class", "method", "type"]);
|
|
5745
|
-
var CODEWIKI_VERSION = 5;
|
|
5746
|
-
var treeSitterExtractorPromise = null;
|
|
5747
|
-
function loadTreeSitterExtractor() {
|
|
5748
|
-
treeSitterExtractorPromise ??= createTreeSitterExtractor();
|
|
5749
|
-
return treeSitterExtractorPromise;
|
|
5750
|
-
}
|
|
5751
|
-
var SOURCE_EXTENSIONS2 = /* @__PURE__ */ new Map([
|
|
5752
|
-
[".ts", "typescript"],
|
|
5753
|
-
[".tsx", "typescript"],
|
|
5754
|
-
[".mts", "typescript"],
|
|
5755
|
-
[".cts", "typescript"],
|
|
5756
|
-
[".js", "javascript"],
|
|
5757
|
-
[".jsx", "javascript"],
|
|
5758
|
-
[".mjs", "javascript"],
|
|
5759
|
-
[".cjs", "javascript"],
|
|
5760
|
-
[".py", "python"],
|
|
5761
|
-
[".pyw", "python"],
|
|
5762
|
-
[".rs", "rust"],
|
|
5763
|
-
[".go", "go"],
|
|
5764
|
-
[".c", "c"],
|
|
5765
|
-
[".h", "c"],
|
|
5766
|
-
[".cc", "c++"],
|
|
5767
|
-
[".cpp", "c++"],
|
|
5768
|
-
[".cxx", "c++"],
|
|
5769
|
-
[".hpp", "c++"],
|
|
5770
|
-
[".hh", "c++"],
|
|
5771
|
-
[".hxx", "c++"],
|
|
5772
|
-
[".cu", "c++"],
|
|
5773
|
-
[".cuh", "c++"],
|
|
5774
|
-
[".java", "java"],
|
|
5775
|
-
[".rb", "ruby"],
|
|
5776
|
-
[".cs", "c#"]
|
|
5777
|
-
]);
|
|
5778
|
-
var CONFIG_FILE_NAMES = /* @__PURE__ */ new Set([
|
|
5779
|
-
"package.json",
|
|
5780
|
-
"pyproject.toml",
|
|
5781
|
-
"setup.py",
|
|
5782
|
-
"Cargo.toml",
|
|
5783
|
-
"go.mod",
|
|
5784
|
-
"pom.xml",
|
|
5785
|
-
"CMakeLists.txt",
|
|
5786
|
-
"compile_commands.json",
|
|
5787
|
-
"Gemfile"
|
|
5788
|
-
]);
|
|
5789
|
-
var RESOLUTION_EXTENSIONS = [
|
|
5790
|
-
".ts",
|
|
5791
|
-
".tsx",
|
|
5792
|
-
".mts",
|
|
5793
|
-
".cts",
|
|
5794
|
-
".js",
|
|
5795
|
-
".jsx",
|
|
5796
|
-
".mjs",
|
|
5797
|
-
".cjs",
|
|
5798
|
-
".py",
|
|
5799
|
-
".go",
|
|
5800
|
-
".rs",
|
|
5801
|
-
".c",
|
|
5802
|
-
".h",
|
|
5803
|
-
".cc",
|
|
5804
|
-
".cpp",
|
|
5805
|
-
".cxx",
|
|
5806
|
-
".hpp",
|
|
5807
|
-
".hh",
|
|
5808
|
-
".hxx",
|
|
5809
|
-
".cu",
|
|
5810
|
-
".cuh",
|
|
5811
|
-
".java",
|
|
5812
|
-
".rb",
|
|
5813
|
-
".cs"
|
|
5814
|
-
];
|
|
5815
|
-
function compareStrings3(a, b) {
|
|
5816
|
-
return a.localeCompare(b);
|
|
5817
|
-
}
|
|
5818
|
-
function stableFileId(path) {
|
|
5819
|
-
return `f_${createHash("sha256").update(path).digest("hex").slice(0, 16)}`;
|
|
5820
|
-
}
|
|
5821
|
-
function contentHash(text) {
|
|
5822
|
-
return createHash("sha256").update(text).digest("hex").slice(0, 16);
|
|
5823
|
-
}
|
|
5824
|
-
function defaultReadFile(path) {
|
|
5825
|
-
try {
|
|
5826
|
-
return readFileSync2(path, "utf8");
|
|
5827
|
-
} catch {
|
|
5828
|
-
return null;
|
|
5829
|
-
}
|
|
5830
|
-
}
|
|
5831
|
-
function extensionOf2(name2) {
|
|
5832
|
-
const index = name2.lastIndexOf(".");
|
|
5833
|
-
return index === -1 ? "" : name2.slice(index);
|
|
5834
|
-
}
|
|
5835
|
-
function normalizeRel(cwd, filePath) {
|
|
5836
|
-
return relative(cwd, filePath).split("\\").join("/");
|
|
5837
|
-
}
|
|
5838
|
-
function normalizeInputPath(path) {
|
|
5839
|
-
return path.split("\\").join("/").replace(/^\.\//, "");
|
|
5840
|
-
}
|
|
5841
|
-
function sourceLanguageForPath(relPath) {
|
|
5842
|
-
if (relPath.endsWith(".d.ts")) return null;
|
|
5843
|
-
return SOURCE_EXTENSIONS2.get(extensionOf2(relPath)) ?? null;
|
|
5844
|
-
}
|
|
5845
|
-
function languageForPath(relPath) {
|
|
5846
|
-
const source = sourceLanguageForPath(relPath);
|
|
5847
|
-
if (source) return source;
|
|
5848
|
-
const name2 = relPath.split("/").pop() ?? relPath;
|
|
5849
|
-
return CONFIG_FILE_NAMES.has(name2) || name2.endsWith(".csproj") || name2.toLowerCase().endsWith(".cmake") ? "config" : null;
|
|
5850
|
-
}
|
|
5851
|
-
function isIndexablePath(relPath) {
|
|
5852
|
-
if (relPath.split("/").some((segment) => WORKSPACE_EXCLUDED_DIRS.has(segment))) return false;
|
|
5853
|
-
return languageForPath(relPath) !== null;
|
|
5854
|
-
}
|
|
5855
|
-
function lineCount(text) {
|
|
5856
|
-
if (text.length === 0) return 0;
|
|
5857
|
-
return text.endsWith("\n") ? text.split("\n").length - 1 : text.split("\n").length;
|
|
5858
|
-
}
|
|
5859
|
-
function roleFor(relPath, language) {
|
|
5860
|
-
if (language === "config") return "config";
|
|
5861
|
-
const lower = relPath.toLowerCase();
|
|
5862
|
-
if (lower.includes("/test/") || lower.includes("/tests/") || /\.(test|spec)\.[cm]?[jt]sx?$/.test(lower) || /(^|\/)test_.*\.py$/.test(lower) || /(^|\/).*_test\.(go|rs|rb)$/.test(lower)) {
|
|
5863
|
-
return "test";
|
|
5864
|
-
}
|
|
5865
|
-
if (/(^|\/)(index|main|server|cli|orchestrator|bootstrap)\.[^.]+$/.test(lower) || lower.endsWith("/__main__.py")) {
|
|
5866
|
-
return "entry";
|
|
5867
|
-
}
|
|
5868
|
-
return "module";
|
|
5869
|
-
}
|
|
5870
|
-
function firstDocSummary(text) {
|
|
5871
|
-
const jsDoc = /\/\*\*([\s\S]*?)\*\//.exec(text)?.[1];
|
|
5872
|
-
const pythonDoc = /^\s*(?:"""([\s\S]*?)"""|'''([\s\S]*?)''')/.exec(text);
|
|
5873
|
-
const raw = jsDoc ?? pythonDoc?.[1] ?? pythonDoc?.[2];
|
|
5874
|
-
if (!raw) return null;
|
|
5875
|
-
const cleaned = raw.split("\n").map((line2) => line2.replace(/^\s*\*\s?/, "").trim()).filter((line2) => line2.length > 0 && !line2.startsWith("@")).join(" ").replace(/\s+/g, " ").trim();
|
|
5876
|
-
return cleaned.length > 0 ? cleaned.slice(0, 160) : null;
|
|
5877
|
-
}
|
|
5878
|
-
function sanitizeSymbolName(value) {
|
|
5879
|
-
return value.trim().replace(/^self\./, "").replace(/^this\./, "").slice(0, 160);
|
|
5880
|
-
}
|
|
5881
|
-
function addSymbol2(target, seen, name2, kind, line2, sig2) {
|
|
5882
|
-
if (!name2) return;
|
|
5883
|
-
const clean = sanitizeSymbolName(name2);
|
|
5884
|
-
if (clean.length === 0) return;
|
|
5885
|
-
const key = `${clean}\0${kind}\0${line2}`;
|
|
5886
|
-
if (seen.has(key)) return;
|
|
5887
|
-
seen.add(key);
|
|
5888
|
-
target.push({
|
|
5889
|
-
name: clean,
|
|
5890
|
-
kind,
|
|
5891
|
-
line: line2,
|
|
5892
|
-
...sig2 && sig2.trim().length > 0 ? { sig: sig2.trim().slice(0, 240) } : {}
|
|
5893
|
-
});
|
|
5894
|
-
}
|
|
5895
|
-
function uniqueSorted3(values) {
|
|
5896
|
-
return [...new Set([...values].filter((item) => item.length > 0))].sort(compareStrings3);
|
|
5897
|
-
}
|
|
5898
|
-
function extractWithLineRegex(text, patterns) {
|
|
5899
|
-
const symbols = [];
|
|
5900
|
-
const seen = /* @__PURE__ */ new Set();
|
|
5901
|
-
const lines = text.split(/\r?\n/);
|
|
5902
|
-
for (const [index, line2] of lines.entries()) {
|
|
5903
|
-
for (const pattern of patterns) {
|
|
5904
|
-
const match = pattern.regex.exec(line2);
|
|
5905
|
-
if (!match) continue;
|
|
5906
|
-
const name2 = match[pattern.nameIndex ?? 1];
|
|
5907
|
-
addSymbol2(symbols, seen, name2, pattern.kind, index + 1, line2.trim());
|
|
5908
|
-
}
|
|
5909
|
-
}
|
|
5910
|
-
return symbols.sort(compareSymbols);
|
|
5911
|
-
}
|
|
5912
|
-
function compareSymbols(a, b) {
|
|
5913
|
-
return a.line - b.line || a.name.localeCompare(b.name) || a.kind.localeCompare(b.kind);
|
|
5914
|
-
}
|
|
5915
|
-
function extractMatches(text, regex, group = 1) {
|
|
5916
|
-
const out2 = [];
|
|
5917
|
-
for (const match of text.matchAll(regex)) {
|
|
5918
|
-
const value = match[group];
|
|
5919
|
-
if (value) out2.push(value);
|
|
5920
|
-
}
|
|
5921
|
-
return out2;
|
|
5922
|
-
}
|
|
5923
|
-
function maskCFamilyCommentsAndStrings(text) {
|
|
5924
|
-
const chars = text.split("");
|
|
5925
|
-
let state = "code";
|
|
5926
|
-
for (let index = 0; index < chars.length; index += 1) {
|
|
5927
|
-
const current = chars[index] ?? "";
|
|
5928
|
-
const next = chars[index + 1] ?? "";
|
|
5929
|
-
if (state === "code") {
|
|
5930
|
-
if (current === "/" && next === "/") {
|
|
5931
|
-
chars[index] = " ";
|
|
5932
|
-
chars[index + 1] = " ";
|
|
5933
|
-
state = "line-comment";
|
|
5934
|
-
index += 1;
|
|
5935
|
-
} else if (current === "/" && next === "*") {
|
|
5936
|
-
chars[index] = " ";
|
|
5937
|
-
chars[index + 1] = " ";
|
|
5938
|
-
state = "block-comment";
|
|
5939
|
-
index += 1;
|
|
5940
|
-
} else if (current === "'") {
|
|
5941
|
-
chars[index] = " ";
|
|
5942
|
-
state = "single-quote";
|
|
5943
|
-
} else if (current === '"') {
|
|
5944
|
-
chars[index] = " ";
|
|
5945
|
-
state = "double-quote";
|
|
5946
|
-
}
|
|
5947
|
-
continue;
|
|
5948
|
-
}
|
|
5949
|
-
if (current === "\n") {
|
|
5950
|
-
if (state === "line-comment") state = "code";
|
|
5951
|
-
continue;
|
|
5952
|
-
}
|
|
5953
|
-
chars[index] = " ";
|
|
5954
|
-
if (state === "block-comment" && current === "*" && next === "/") {
|
|
5955
|
-
chars[index + 1] = " ";
|
|
5956
|
-
state = "code";
|
|
5957
|
-
index += 1;
|
|
5958
|
-
continue;
|
|
5959
|
-
}
|
|
5960
|
-
if ((state === "single-quote" || state === "double-quote") && current === "\\") {
|
|
5961
|
-
if (index + 1 < chars.length && chars[index + 1] !== "\n") {
|
|
5962
|
-
chars[index + 1] = " ";
|
|
5963
|
-
index += 1;
|
|
5964
|
-
}
|
|
5965
|
-
continue;
|
|
5966
|
-
}
|
|
5967
|
-
if (state === "single-quote" && current === "'") state = "code";
|
|
5968
|
-
if (state === "double-quote" && current === '"') state = "code";
|
|
5969
|
-
}
|
|
5970
|
-
return chars.join("");
|
|
5971
|
-
}
|
|
5972
|
-
function cFamilyAliasStatements(text) {
|
|
5973
|
-
const masked = maskCFamilyCommentsAndStrings(text);
|
|
5974
|
-
const statements = [];
|
|
5975
|
-
const token = /\b(?:typedef|using)\b/g;
|
|
5976
|
-
for (let match = token.exec(masked); match; match = token.exec(masked)) {
|
|
5977
|
-
const start2 = match.index;
|
|
5978
|
-
const lineStart = masked.lastIndexOf("\n", start2 - 1) + 1;
|
|
5979
|
-
if (masked.slice(lineStart, start2).trimStart().startsWith("#")) continue;
|
|
5980
|
-
let braces = 0;
|
|
5981
|
-
let parentheses = 0;
|
|
5982
|
-
let brackets = 0;
|
|
5983
|
-
let end = -1;
|
|
5984
|
-
for (let index = token.lastIndex; index < masked.length; index += 1) {
|
|
5985
|
-
const current = masked[index];
|
|
5986
|
-
if (current === "{") braces += 1;
|
|
5987
|
-
else if (current === "}") braces = Math.max(0, braces - 1);
|
|
5988
|
-
else if (current === "(") parentheses += 1;
|
|
5989
|
-
else if (current === ")") parentheses = Math.max(0, parentheses - 1);
|
|
5990
|
-
else if (current === "[") brackets += 1;
|
|
5991
|
-
else if (current === "]") brackets = Math.max(0, brackets - 1);
|
|
5992
|
-
else if (current === ";" && braces === 0 && parentheses === 0 && brackets === 0) {
|
|
5993
|
-
end = index + 1;
|
|
5994
|
-
break;
|
|
5995
|
-
}
|
|
5996
|
-
}
|
|
5997
|
-
if (end === -1) continue;
|
|
5998
|
-
statements.push({
|
|
5999
|
-
text: text.slice(start2, end),
|
|
6000
|
-
masked: masked.slice(start2, end),
|
|
6001
|
-
line: 1 + Array.from(masked.slice(0, start2).matchAll(/\n/g)).length
|
|
6002
|
-
});
|
|
6003
|
-
token.lastIndex = end;
|
|
6004
|
-
}
|
|
6005
|
-
return statements;
|
|
6006
|
-
}
|
|
6007
|
-
function stripCFamilyBraceBodies(statement) {
|
|
6008
|
-
let depth = 0;
|
|
6009
|
-
let result = "";
|
|
6010
|
-
for (const current of statement) {
|
|
6011
|
-
if (current === "{") {
|
|
6012
|
-
depth += 1;
|
|
6013
|
-
result += " ";
|
|
6014
|
-
continue;
|
|
6015
|
-
}
|
|
6016
|
-
if (current === "}") {
|
|
6017
|
-
depth = Math.max(0, depth - 1);
|
|
6018
|
-
result += " ";
|
|
6019
|
-
continue;
|
|
6020
|
-
}
|
|
6021
|
-
result += depth === 0 || current === "\n" ? current : " ";
|
|
6022
|
-
}
|
|
6023
|
-
return result;
|
|
6024
|
-
}
|
|
6025
|
-
function splitCFamilyDeclarators(value) {
|
|
6026
|
-
const parts2 = [];
|
|
6027
|
-
let start2 = 0;
|
|
6028
|
-
let parentheses = 0;
|
|
6029
|
-
let brackets = 0;
|
|
6030
|
-
let angles = 0;
|
|
6031
|
-
for (let index = 0; index < value.length; index += 1) {
|
|
6032
|
-
const current = value[index];
|
|
6033
|
-
if (current === "(") parentheses += 1;
|
|
6034
|
-
else if (current === ")") parentheses = Math.max(0, parentheses - 1);
|
|
6035
|
-
else if (current === "[") brackets += 1;
|
|
6036
|
-
else if (current === "]") brackets = Math.max(0, brackets - 1);
|
|
6037
|
-
else if (current === "<") angles += 1;
|
|
6038
|
-
else if (current === ">") angles = Math.max(0, angles - 1);
|
|
6039
|
-
else if (current === "," && parentheses === 0 && brackets === 0 && angles === 0) {
|
|
6040
|
-
parts2.push(value.slice(start2, index));
|
|
6041
|
-
start2 = index + 1;
|
|
6042
|
-
}
|
|
6043
|
-
}
|
|
6044
|
-
parts2.push(value.slice(start2));
|
|
6045
|
-
return parts2;
|
|
6046
|
-
}
|
|
6047
|
-
var C_FAMILY_TYPE_WORDS = /* @__PURE__ */ new Set([
|
|
6048
|
-
"typedef",
|
|
6049
|
-
"const",
|
|
6050
|
-
"volatile",
|
|
6051
|
-
"restrict",
|
|
6052
|
-
"signed",
|
|
6053
|
-
"unsigned",
|
|
6054
|
-
"short",
|
|
6055
|
-
"long",
|
|
6056
|
-
"void",
|
|
6057
|
-
"char",
|
|
6058
|
-
"int",
|
|
6059
|
-
"float",
|
|
6060
|
-
"double",
|
|
6061
|
-
"struct",
|
|
6062
|
-
"union",
|
|
6063
|
-
"enum",
|
|
6064
|
-
"class",
|
|
6065
|
-
"typename",
|
|
6066
|
-
"auto"
|
|
6067
|
-
]);
|
|
6068
|
-
function stripTrailingCFamilyDeclaratorSuffixes(value) {
|
|
6069
|
-
let end = value.length;
|
|
6070
|
-
while (end > 0) {
|
|
6071
|
-
while (end > 0 && /\s/.test(value[end - 1] ?? "")) end -= 1;
|
|
6072
|
-
const close = value[end - 1];
|
|
6073
|
-
if (close !== ")" && close !== "]") break;
|
|
6074
|
-
const open = close === ")" ? "(" : "[";
|
|
6075
|
-
let depth = 1;
|
|
6076
|
-
let start2 = end - 1;
|
|
6077
|
-
for (start2 -= 1; start2 >= 0; start2 -= 1) {
|
|
6078
|
-
const current = value[start2];
|
|
6079
|
-
if (current === close) depth += 1;
|
|
6080
|
-
else if (current === open) {
|
|
6081
|
-
depth -= 1;
|
|
6082
|
-
if (depth === 0) break;
|
|
6083
|
-
}
|
|
6084
|
-
}
|
|
6085
|
-
if (start2 < 0) break;
|
|
6086
|
-
if (start2 === 0 || !/[A-Za-z_0-9)\]]/.test(value[start2 - 1] ?? "")) break;
|
|
6087
|
-
end = start2;
|
|
6088
|
-
}
|
|
6089
|
-
return value.slice(0, end);
|
|
6090
|
-
}
|
|
6091
|
-
function cFamilyTypedefNames(maskedStatement) {
|
|
6092
|
-
const withoutBodies = stripCFamilyBraceBodies(maskedStatement).replace(/^\s*typedef\b/, "").replace(/;\s*$/, "");
|
|
6093
|
-
const names = [];
|
|
6094
|
-
for (const declarator of splitCFamilyDeclarators(withoutBodies)) {
|
|
6095
|
-
const functionPointerNames = Array.from(
|
|
6096
|
-
declarator.matchAll(
|
|
6097
|
-
/\(\s*(?:[A-Za-z_]\w*\s+)*[*&]+\s*(?:(?:const|volatile|restrict)\s+)*([A-Za-z_]\w*)\s*(?:\[[^\]]*\]\s*)*\)(?=\s*\()/g
|
|
6098
|
-
),
|
|
6099
|
-
(match) => match[1] ?? ""
|
|
6100
|
-
).filter((name3) => name3.length > 0);
|
|
6101
|
-
if (functionPointerNames.length > 0) {
|
|
6102
|
-
names.push(...functionPointerNames);
|
|
6103
|
-
continue;
|
|
6104
|
-
}
|
|
6105
|
-
const declaratorWithoutSuffixes = stripTrailingCFamilyDeclaratorSuffixes(declarator);
|
|
6106
|
-
const identifiers = Array.from(declaratorWithoutSuffixes.matchAll(/\b[A-Za-z_]\w*\b/g), (match) => match[0]).filter(
|
|
6107
|
-
(name3) => !C_FAMILY_TYPE_WORDS.has(name3)
|
|
6108
|
-
);
|
|
6109
|
-
const name2 = identifiers.at(-1);
|
|
6110
|
-
if (name2) names.push(name2);
|
|
6111
|
-
}
|
|
6112
|
-
return uniqueSorted3(names);
|
|
6113
|
-
}
|
|
6114
|
-
function extractCFamilyAliasSymbols(text) {
|
|
6115
|
-
const symbols = [];
|
|
6116
|
-
const seen = /* @__PURE__ */ new Set();
|
|
6117
|
-
for (const statement of cFamilyAliasStatements(text)) {
|
|
6118
|
-
const usingName = /^\s*using\s+([A-Za-z_]\w*)\s*=/.exec(statement.masked)?.[1];
|
|
6119
|
-
const names = usingName ? [usingName] : /^\s*typedef\b/.test(statement.masked) ? cFamilyTypedefNames(statement.masked) : [];
|
|
6120
|
-
const signature = statement.text.replace(/\s+/g, " ").trim();
|
|
6121
|
-
for (const name2 of names) addSymbol2(symbols, seen, name2, "type", statement.line, signature);
|
|
6122
|
-
}
|
|
6123
|
-
return symbols;
|
|
6124
|
-
}
|
|
6125
|
-
var tsJsExtractor = {
|
|
6126
|
-
langs: ["typescript", "javascript"],
|
|
6127
|
-
extractImports(_path, text) {
|
|
6128
|
-
return uniqueSorted3([
|
|
6129
|
-
...extractMatches(text, /\bimport\s+(?:type\s+)?(?:[^'"]*?\s+from\s+)?["']([^"']+)["']/g),
|
|
6130
|
-
...extractMatches(text, /\bexport\s+[^'"]*?\s+from\s+["']([^"']+)["']/g),
|
|
6131
|
-
...extractMatches(text, /\brequire\s*\(\s*["']([^"']+)["']\s*\)/g),
|
|
6132
|
-
...extractMatches(text, /\bimport\s*\(\s*["']([^"']+)["']\s*\)/g)
|
|
6133
|
-
]);
|
|
6134
|
-
},
|
|
6135
|
-
extract(_path, text) {
|
|
6136
|
-
const symbols = extractWithLineRegex(text, [
|
|
6137
|
-
{ regex: /^\s*export\s+default\s+(?:async\s+)?function\s+([A-Za-z_$][\w$]*)?/, kind: "func" },
|
|
6138
|
-
{ regex: /^\s*(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)\s*\(/, kind: "func" },
|
|
6139
|
-
{ regex: /^\s*(?:export\s+)?class\s+([A-Za-z_$][\w$]*)\b/, kind: "class" },
|
|
6140
|
-
{ regex: /^\s*(?:export\s+)?interface\s+([A-Za-z_$][\w$]*)\b/, kind: "iface" },
|
|
6141
|
-
{ regex: /^\s*(?:export\s+)?type\s+([A-Za-z_$][\w$]*)\b/, kind: "type" },
|
|
6142
|
-
{ regex: /^\s*(?:export\s+)?enum\s+([A-Za-z_$][\w$]*)\b/, kind: "type" },
|
|
6143
|
-
{ regex: /^(?:\s*export\s+)?const\s+([A-Za-z_$][\w$]*)\b/, kind: "const" },
|
|
6144
|
-
{ regex: /^(?:\s*export\s+)?(?:let|var)\s+([A-Za-z_$][\w$]*)\b/, kind: "var" },
|
|
6145
|
-
{
|
|
6146
|
-
regex: /^(?: {2,}|\t+)(?:public\s+|private\s+|protected\s+|static\s+|override\s+|abstract\s+|async\s+|get\s+|set\s+)*(?!(?:if|for|while|switch|catch|return|typeof|else|do|new|await|yield)\b)([A-Za-z_$][\w$]*)\s*\([^)]*\)\s*\{?$/,
|
|
6147
|
-
kind: "method"
|
|
6148
|
-
}
|
|
6149
|
-
]);
|
|
6150
|
-
return { symbols, imports: tsJsExtractor.extractImports?.(_path, text) ?? [] };
|
|
6151
|
-
}
|
|
6152
|
-
};
|
|
6153
|
-
var pythonExtractor = {
|
|
6154
|
-
langs: ["python"],
|
|
6155
|
-
extractImports(_path, text) {
|
|
6156
|
-
return uniqueSorted3([
|
|
6157
|
-
...extractMatches(text, /^\s*import\s+([A-Za-z_][\w.]*)(?:\s+as\s+\w+)?/gm),
|
|
6158
|
-
...extractMatches(text, /^\s*from\s+([.\w]+)\s+import\s+/gm)
|
|
6159
|
-
]);
|
|
6160
|
-
},
|
|
6161
|
-
extract(_path, text) {
|
|
6162
|
-
const rawSymbols = extractWithLineRegex(text, [
|
|
6163
|
-
{ regex: /^(\s*)def\s+([A-Za-z_]\w*)\s*\(/, kind: "func", nameIndex: 2 },
|
|
6164
|
-
{ regex: /^(\s*)async\s+def\s+([A-Za-z_]\w*)\s*\(/, kind: "func", nameIndex: 2 },
|
|
6165
|
-
{ regex: /^\s*class\s+([A-Za-z_]\w*)\b/, kind: "class" },
|
|
6166
|
-
{ regex: /^([A-Z][A-Z0-9_]*)\s*=/, kind: "const" },
|
|
6167
|
-
{ regex: /^([A-Za-z_]\w*)\s*=/, kind: "var" }
|
|
6168
|
-
]);
|
|
6169
|
-
const symbols = rawSymbols.map((symbol) => {
|
|
6170
|
-
if ((symbol.kind === "func" || symbol.kind === "var") && /^\s+/.test(symbol.sig ?? "")) {
|
|
6171
|
-
return { ...symbol, kind: symbol.kind === "func" ? "method" : symbol.kind };
|
|
6172
|
-
}
|
|
6173
|
-
return symbol;
|
|
6174
|
-
});
|
|
6175
|
-
return { symbols: symbols.sort(compareSymbols), imports: pythonExtractor.extractImports?.(_path, text) ?? [] };
|
|
6176
|
-
}
|
|
6177
|
-
};
|
|
6178
|
-
var goExtractor = {
|
|
6179
|
-
langs: ["go"],
|
|
6180
|
-
extractImports(_path, text) {
|
|
6181
|
-
return uniqueSorted3([
|
|
6182
|
-
...extractMatches(text, /^\s*import\s+"([^"]+)"/gm),
|
|
6183
|
-
...extractMatches(text, /^\s*"([^"]+)"\s*$/gm)
|
|
6184
|
-
]);
|
|
6185
|
-
},
|
|
6186
|
-
extract(_path, text) {
|
|
6187
|
-
const rawSymbols = extractWithLineRegex(text, [
|
|
6188
|
-
{ regex: /^\s*func\s+(?:\([^)]*\)\s*)?([A-Za-z_]\w*)\s*\(/, kind: "func" },
|
|
6189
|
-
{ regex: /^\s*type\s+([A-Za-z_]\w*)\s+interface\b/, kind: "iface" },
|
|
6190
|
-
{ regex: /^\s*type\s+([A-Za-z_]\w*)\s+struct\b/, kind: "type" },
|
|
6191
|
-
{ regex: /^\s*type\s+([A-Za-z_]\w*)\b/, kind: "type" },
|
|
6192
|
-
{ regex: /^const\s+([A-Za-z_]\w*)\b/, kind: "const" },
|
|
6193
|
-
{ regex: /^var\s+([A-Za-z_]\w*)\b/, kind: "var" }
|
|
6194
|
-
]);
|
|
6195
|
-
const symbols = rawSymbols.map((symbol) => {
|
|
6196
|
-
if (symbol.kind === "func" && /^\s*func\s+\(/.test(symbol.sig ?? "")) return { ...symbol, kind: "method" };
|
|
6197
|
-
return symbol;
|
|
6198
|
-
});
|
|
6199
|
-
return { symbols: symbols.sort(compareSymbols), imports: goExtractor.extractImports?.(_path, text) ?? [] };
|
|
6200
|
-
}
|
|
6201
|
-
};
|
|
6202
|
-
var rustExtractor = {
|
|
6203
|
-
langs: ["rust"],
|
|
6204
|
-
extractImports(_path, text) {
|
|
6205
|
-
return uniqueSorted3([
|
|
6206
|
-
...extractMatches(text, /^\s*use\s+([^;]+);/gm).map((item) => item.trim()),
|
|
6207
|
-
...extractMatches(text, /^\s*extern\s+crate\s+([A-Za-z_]\w*)/gm)
|
|
6208
|
-
]);
|
|
6209
|
-
},
|
|
6210
|
-
extract(_path, text) {
|
|
6211
|
-
const symbols = extractWithLineRegex(text, [
|
|
6212
|
-
{ regex: /^\s*(?:pub(?:\([^)]*\))?\s+)?fn\s+([A-Za-z_]\w*)\s*[<(]/, kind: "func" },
|
|
6213
|
-
{ regex: /^\s*(?:pub(?:\([^)]*\))?\s+)?struct\s+([A-Za-z_]\w*)\b/, kind: "type" },
|
|
6214
|
-
{ regex: /^\s*(?:pub(?:\([^)]*\))?\s+)?enum\s+([A-Za-z_]\w*)\b/, kind: "type" },
|
|
6215
|
-
{ regex: /^\s*(?:pub(?:\([^)]*\))?\s+)?trait\s+([A-Za-z_]\w*)\b/, kind: "trait" },
|
|
6216
|
-
{ regex: /^\s*(?:pub(?:\([^)]*\))?\s+)?type\s+([A-Za-z_]\w*)\b/, kind: "type" },
|
|
6217
|
-
{ regex: /^(?:\s*pub(?:\([^)]*\))?\s+)?const\s+([A-Za-z_]\w*)\b/, kind: "const" },
|
|
6218
|
-
{ regex: /^(?:\s*pub(?:\([^)]*\))?\s+)?static\s+([A-Za-z_]\w*)\b/, kind: "var" }
|
|
6219
|
-
]);
|
|
6220
|
-
return { symbols, imports: rustExtractor.extractImports?.(_path, text) ?? [] };
|
|
6221
|
-
}
|
|
6222
|
-
};
|
|
6223
|
-
var cFamilyExtractor = {
|
|
6224
|
-
langs: ["c", "c++"],
|
|
6225
|
-
extractImports(_path, text) {
|
|
6226
|
-
const imports = [];
|
|
6227
|
-
for (const match of text.matchAll(/^\s*#\s*include\s*(?:"([^"]+)"|<([^>]+)>)/gm)) {
|
|
6228
|
-
const quoted = match[1];
|
|
6229
|
-
const system = match[2];
|
|
6230
|
-
if (quoted) imports.push(quoted.startsWith(".") || quoted.startsWith("/") ? quoted : `./${quoted}`);
|
|
6231
|
-
else if (system) imports.push(system);
|
|
6232
|
-
}
|
|
6233
|
-
return uniqueSorted3(imports);
|
|
6234
|
-
},
|
|
6235
|
-
extract(_path, text) {
|
|
6236
|
-
const regexSymbols = extractWithLineRegex(text, [
|
|
6237
|
-
{ regex: /^\s*class\s+([A-Za-z_]\w*)\b/, kind: "class" },
|
|
6238
|
-
{
|
|
6239
|
-
regex: /^\s*(?:typedef\s+)?(?:struct\s+|union\s+|enum\s+(?:(?:class|struct)\s+)?)([A-Za-z_]\w*)\b/,
|
|
6240
|
-
kind: "type"
|
|
6241
|
-
},
|
|
6242
|
-
{
|
|
6243
|
-
regex: /^\s*(?!(?:typedef|using)\b)(?:template\s*<[^>]+>\s*)?(?:[A-Za-z_][\w:<>,*&\s]+\s+)+(?:(?:[A-Za-z_]\w*)::)*([~A-Za-z_]\w*)\s*\([^;]*\)\s*(?:const\s*)?(?:noexcept\s*)?(?:;|\{)?$/,
|
|
6244
|
-
kind: "func"
|
|
6245
|
-
},
|
|
6246
|
-
{ regex: /^(?:const\s+)?[A-Za-z_][\w:<>,*&\s]+\s+([A-Z][A-Z0-9_]*)\s*=/, kind: "const" }
|
|
6247
|
-
]);
|
|
6248
|
-
const symbolsByKey = /* @__PURE__ */ new Map();
|
|
6249
|
-
for (const symbol of [...regexSymbols, ...extractCFamilyAliasSymbols(text)]) {
|
|
6250
|
-
const key = `${symbol.name}\0${symbol.kind}\0${symbol.line}`;
|
|
6251
|
-
if (!symbolsByKey.has(key)) symbolsByKey.set(key, symbol);
|
|
6252
|
-
}
|
|
6253
|
-
const symbols = [...symbolsByKey.values()].sort(compareSymbols);
|
|
6254
|
-
return { symbols, imports: cFamilyExtractor.extractImports?.(_path, text) ?? [] };
|
|
6255
|
-
}
|
|
6256
|
-
};
|
|
6257
|
-
var javaExtractor = {
|
|
6258
|
-
langs: ["java"],
|
|
6259
|
-
extractImports(_path, text) {
|
|
6260
|
-
return uniqueSorted3(extractMatches(text, /^\s*import\s+(?:static\s+)?([A-Za-z_][\w.*]*);/gm));
|
|
6261
|
-
},
|
|
6262
|
-
extract(_path, text) {
|
|
6263
|
-
const symbols = extractWithLineRegex(text, [
|
|
6264
|
-
{ regex: /^\s*(?:public\s+|private\s+|protected\s+|abstract\s+|final\s+)*class\s+([A-Za-z_]\w*)\b/, kind: "class" },
|
|
6265
|
-
{
|
|
6266
|
-
regex: /^\s*(?:public\s+|private\s+|protected\s+|abstract\s+|final\s+)*interface\s+([A-Za-z_]\w*)\b/,
|
|
6267
|
-
kind: "iface"
|
|
6268
|
-
},
|
|
6269
|
-
{ regex: /^\s*(?:public\s+|private\s+|protected\s+|abstract\s+|final\s+)*enum\s+([A-Za-z_]\w*)\b/, kind: "type" },
|
|
6270
|
-
{
|
|
6271
|
-
regex: /^\s*(?:public\s+|private\s+|protected\s+|static\s+|final\s+|synchronized\s+)*[A-Za-z_][\w<>,[\]\s]*\s+([A-Za-z_]\w*)\s*\([^)]*\)\s*\{?$/,
|
|
6272
|
-
kind: "method"
|
|
6273
|
-
},
|
|
6274
|
-
{
|
|
6275
|
-
regex: /^\s*public\s+(?:static\s+|final\s+)*[A-Za-z_][\w<>,[\]\s]*\s+([A-Z][A-Z0-9_]*)\s*=/,
|
|
6276
|
-
kind: "const"
|
|
6277
|
-
}
|
|
6278
|
-
]);
|
|
6279
|
-
return { symbols, imports: javaExtractor.extractImports?.(_path, text) ?? [] };
|
|
6280
|
-
}
|
|
6281
|
-
};
|
|
6282
|
-
var rubyExtractor = {
|
|
6283
|
-
langs: ["ruby"],
|
|
6284
|
-
extractImports(_path, text) {
|
|
6285
|
-
return uniqueSorted3([
|
|
6286
|
-
...extractMatches(text, /^\s*require\s+["']([^"']+)["']/gm),
|
|
6287
|
-
...extractMatches(text, /^\s*require_relative\s+["']([^"']+)["']/gm).map((item) => `./${item}`)
|
|
6288
|
-
]);
|
|
6289
|
-
},
|
|
6290
|
-
extract(_path, text) {
|
|
6291
|
-
const symbols = extractWithLineRegex(text, [
|
|
6292
|
-
{ regex: /^\s*class\s+([A-Z]\w*(?:::[A-Z]\w*)*)\b/, kind: "class" },
|
|
6293
|
-
{ regex: /^\s*module\s+([A-Z]\w*(?:::[A-Z]\w*)*)\b/, kind: "type" },
|
|
6294
|
-
{ regex: /^\s*def\s+(?:self\.)?([A-Za-z_]\w*[!?=]?)\b/, kind: "func" },
|
|
6295
|
-
{ regex: /^([A-Z][A-Z0-9_]*)\s*=/, kind: "const" }
|
|
6296
|
-
]);
|
|
6297
|
-
return { symbols, imports: rubyExtractor.extractImports?.(_path, text) ?? [] };
|
|
6298
|
-
}
|
|
6299
|
-
};
|
|
6300
|
-
var csharpExtractor = {
|
|
6301
|
-
langs: ["c#"],
|
|
6302
|
-
extractImports(_path, text) {
|
|
6303
|
-
return uniqueSorted3(
|
|
6304
|
-
extractMatches(text, /^\s*using\s+(?:static\s+)?(?:[A-Za-z_]\w*\s*=\s*)?([A-Za-z_][\w.]*)\s*;/gm)
|
|
6305
|
-
);
|
|
6306
|
-
},
|
|
6307
|
-
extract(_path, text) {
|
|
6308
|
-
const symbols = extractWithLineRegex(text, [
|
|
6309
|
-
{
|
|
6310
|
-
regex: /^\s*(?:public\s+|private\s+|protected\s+|internal\s+|static\s+|sealed\s+|abstract\s+|partial\s+)*class\s+([A-Za-z_]\w*)\b/,
|
|
6311
|
-
kind: "class"
|
|
6312
|
-
},
|
|
6313
|
-
{
|
|
6314
|
-
regex: /^\s*(?:public\s+|private\s+|protected\s+|internal\s+|partial\s+)*interface\s+([A-Za-z_]\w*)\b/,
|
|
6315
|
-
kind: "iface"
|
|
6316
|
-
},
|
|
6317
|
-
{
|
|
6318
|
-
regex: /^\s*(?:public\s+|private\s+|protected\s+|internal\s+|readonly\s+|partial\s+)*(?:enum|struct|record)\s+([A-Za-z_]\w*)\b/,
|
|
6319
|
-
kind: "type"
|
|
6320
|
-
},
|
|
6321
|
-
{
|
|
6322
|
-
regex: /^\s*(?:public\s+|private\s+|protected\s+|internal\s+|static\s+|virtual\s+|override\s+|abstract\s+|sealed\s+|async\s+|partial\s+|new\s+)*(?!(?:if|for|foreach|while|switch|catch|return|using|else|do|new|class|interface|enum|struct|record|namespace|lock|throw)\b)[A-Za-z_][\w<>,[\].?\s]*\s+([A-Za-z_]\w*)\s*\([^)]*\)\s*\{?$/,
|
|
6323
|
-
kind: "method"
|
|
6324
|
-
},
|
|
6325
|
-
{
|
|
6326
|
-
regex: /^\s*(?:public\s+|private\s+|protected\s+|internal\s+|static\s+)*const\s+[A-Za-z_][\w<>,[\]\s]*\s+([A-Za-z_]\w*)\s*=/,
|
|
6327
|
-
kind: "const"
|
|
6328
|
-
}
|
|
6329
|
-
]);
|
|
6330
|
-
return { symbols, imports: csharpExtractor.extractImports?.(_path, text) ?? [] };
|
|
6331
|
-
}
|
|
6332
|
-
};
|
|
6333
|
-
var fallbackExtractors = [
|
|
6334
|
-
tsJsExtractor,
|
|
6335
|
-
pythonExtractor,
|
|
6336
|
-
goExtractor,
|
|
6337
|
-
rustExtractor,
|
|
6338
|
-
cFamilyExtractor,
|
|
6339
|
-
javaExtractor,
|
|
6340
|
-
rubyExtractor,
|
|
6341
|
-
csharpExtractor
|
|
6342
|
-
];
|
|
6343
|
-
function extractWithExtractors(extractors, language, relPath, text) {
|
|
6344
|
-
const symbols = /* @__PURE__ */ new Map();
|
|
6345
|
-
const imports = [];
|
|
6346
|
-
for (const extractor of extractors) {
|
|
6347
|
-
if (!extractor.langs.includes(language)) continue;
|
|
6348
|
-
const extracted = extractor.extract(relPath, text);
|
|
6349
|
-
for (const symbol of extracted.symbols) {
|
|
6350
|
-
const key = `${symbol.name}\0${symbol.kind}\0${symbol.line}`;
|
|
6351
|
-
if (!symbols.has(key)) symbols.set(key, symbol);
|
|
6352
|
-
}
|
|
6353
|
-
imports.push(...extracted.imports);
|
|
6354
|
-
}
|
|
6355
|
-
return {
|
|
6356
|
-
symbols: [...symbols.values()].sort(compareSymbols),
|
|
6357
|
-
imports: uniqueSorted3(imports)
|
|
6358
|
-
};
|
|
6359
|
-
}
|
|
6360
|
-
function extractImportsWithExtractors(extractors, language, relPath, text) {
|
|
6361
|
-
const imports = [];
|
|
6362
|
-
for (const extractor of extractors) {
|
|
6363
|
-
if (!extractor.langs.includes(language) || !extractor.extractImports) continue;
|
|
6364
|
-
imports.push(...extractor.extractImports(relPath, text));
|
|
6365
|
-
}
|
|
6366
|
-
return uniqueSorted3(imports);
|
|
6367
|
-
}
|
|
6368
|
-
function mergeTreeSitterWithRegexImports(language, relPath, text, extracted) {
|
|
6369
|
-
const regexImports = extractImportsWithExtractors(fallbackExtractors, language, relPath, text);
|
|
6370
|
-
return {
|
|
6371
|
-
symbols: extracted.symbols.sort(compareSymbols),
|
|
6372
|
-
imports: uniqueSorted3([...extracted.imports, ...regexImports])
|
|
6373
|
-
};
|
|
6374
|
-
}
|
|
6375
|
-
function fallbackExtraction(language, relPath, text) {
|
|
6376
|
-
return extractWithExtractors(fallbackExtractors, language, relPath, text);
|
|
6377
|
-
}
|
|
6378
|
-
function extractSourceFile(language, relPath, text, treeSitterExtractor) {
|
|
6379
|
-
if (!treeSitterExtractor.langs.includes(language)) return fallbackExtraction(language, relPath, text);
|
|
6380
|
-
try {
|
|
6381
|
-
return mergeTreeSitterWithRegexImports(language, relPath, text, treeSitterExtractor.extract(relPath, text));
|
|
6382
|
-
} catch {
|
|
6383
|
-
return fallbackExtraction(language, relPath, text);
|
|
6384
|
-
}
|
|
6385
|
-
}
|
|
6386
|
-
function buildFile(cwd, relPath, treeSitterExtractor, readFile) {
|
|
6387
|
-
const pathLanguage = languageForPath(relPath);
|
|
6388
|
-
if (!pathLanguage) return null;
|
|
6389
|
-
let text;
|
|
6390
|
-
try {
|
|
6391
|
-
text = readFile(join4(cwd, relPath));
|
|
6392
|
-
} catch {
|
|
6393
|
-
return null;
|
|
6394
|
-
}
|
|
6395
|
-
if (text === null) return null;
|
|
6396
|
-
const language = pathLanguage === "c" && isAmbiguousHeaderPath(relPath) ? classifyCHeaderLanguage(text) : pathLanguage;
|
|
6397
|
-
const file = {
|
|
6398
|
-
id: stableFileId(relPath),
|
|
6399
|
-
path: relPath,
|
|
6400
|
-
lang: language,
|
|
6401
|
-
loc: lineCount(text),
|
|
6402
|
-
role: roleFor(relPath, language),
|
|
6403
|
-
hash: contentHash(text),
|
|
6404
|
-
imports: []
|
|
6405
|
-
};
|
|
6406
|
-
if (text.trim().length === 0) return { file, symbols: [] };
|
|
6407
|
-
const extracted = isCMakePath(relPath) ? extractCMake(text) : language !== "config" ? extractSourceFile(language, relPath, text, treeSitterExtractor) : null;
|
|
6408
|
-
if (!extracted) return { file, symbols: [] };
|
|
6409
|
-
const summary = firstDocSummary(text);
|
|
6410
|
-
const sourceFile = {
|
|
6411
|
-
...file,
|
|
6412
|
-
imports: extracted.imports,
|
|
6413
|
-
...summary ? { summary } : {}
|
|
6414
|
-
};
|
|
6415
|
-
const symbols = extracted.symbols.map((symbol) => ({
|
|
6416
|
-
name: symbol.name,
|
|
6417
|
-
kind: symbol.kind,
|
|
6418
|
-
fileId: sourceFile.id,
|
|
6419
|
-
line: symbol.line,
|
|
6420
|
-
...symbolSigFields(symbol.kind, symbol.sig)
|
|
6421
|
-
}));
|
|
6422
|
-
return {
|
|
6423
|
-
file: sourceFile,
|
|
6424
|
-
symbols
|
|
6425
|
-
};
|
|
6426
|
-
}
|
|
6427
|
-
function candidatePathsForImport(cwd, fromRel, specifier) {
|
|
6428
|
-
const fromDir = dirname(join4(cwd, fromRel));
|
|
6429
|
-
const cleaned = specifier.replace(/\\/g, "/");
|
|
6430
|
-
const base = cleaned.startsWith(".") || cleaned.startsWith("/") ? resolve(fromDir, cleaned) : "";
|
|
6431
|
-
if (!base) return [];
|
|
6432
|
-
const candidates = [base];
|
|
6433
|
-
for (const ext of RESOLUTION_EXTENSIONS) candidates.push(`${base}${ext}`);
|
|
6434
|
-
for (const ext of RESOLUTION_EXTENSIONS) candidates.push(join4(base, `index${ext}`));
|
|
6435
|
-
if (cleaned.endsWith(".js")) {
|
|
6436
|
-
const stripped = base.replace(/\.js$/, "");
|
|
6437
|
-
for (const ext of [".ts", ".tsx", ".mts", ".cts"]) candidates.push(`${stripped}${ext}`);
|
|
6438
|
-
}
|
|
6439
|
-
if (/^[.]+[A-Za-z_]/.test(cleaned)) {
|
|
6440
|
-
const pythonModule = cleaned.replace(/^\.+/, "").replace(/\./g, "/");
|
|
6441
|
-
const pythonBase = resolve(fromDir, pythonModule);
|
|
6442
|
-
candidates.push(`${pythonBase}.py`, join4(pythonBase, "__init__.py"));
|
|
6443
|
-
}
|
|
6444
|
-
return uniqueSorted3(
|
|
6445
|
-
candidates.map((candidate) => normalizeRel(cwd, candidate)).filter((candidate) => !candidate.startsWith(".."))
|
|
6446
|
-
);
|
|
6447
|
-
}
|
|
6448
|
-
function createImportResolver(cwd) {
|
|
6449
|
-
const candidatesByOrigin = /* @__PURE__ */ new Map();
|
|
6450
|
-
const onDisk = /* @__PURE__ */ new Map();
|
|
6451
|
-
const candidatesFor = (fromRel, specifier) => {
|
|
6452
|
-
const key = `${dirname(fromRel)}\0${specifier}`;
|
|
6453
|
-
let candidates = candidatesByOrigin.get(key);
|
|
6454
|
-
if (!candidates) {
|
|
6455
|
-
candidates = candidatePathsForImport(cwd, fromRel, specifier);
|
|
6456
|
-
candidatesByOrigin.set(key, candidates);
|
|
6457
|
-
}
|
|
6458
|
-
return candidates;
|
|
6459
|
-
};
|
|
6460
|
-
const isFile = (candidate) => {
|
|
6461
|
-
const cached = onDisk.get(candidate);
|
|
6462
|
-
if (cached !== void 0) return cached;
|
|
6463
|
-
let exists;
|
|
6464
|
-
try {
|
|
6465
|
-
exists = statSync(join4(cwd, candidate)).isFile();
|
|
6466
|
-
} catch {
|
|
6467
|
-
exists = false;
|
|
6468
|
-
}
|
|
6469
|
-
onDisk.set(candidate, exists);
|
|
6470
|
-
return exists;
|
|
6471
|
-
};
|
|
6472
|
-
return {
|
|
6473
|
-
resolve(fromRel, specifier, pathToId) {
|
|
6474
|
-
for (const candidate of candidatesFor(fromRel, specifier)) {
|
|
6475
|
-
if (pathToId.has(candidate)) return pathToId.get(candidate) ?? null;
|
|
6476
|
-
if (isFile(candidate)) return null;
|
|
6477
|
-
}
|
|
6478
|
-
return null;
|
|
6479
|
-
}
|
|
6480
|
-
};
|
|
6481
|
-
}
|
|
6482
|
-
async function buildEdges(cwd, files, slicer) {
|
|
6483
|
-
const pathToId = new Map(files.map((file) => [file.path, file.id]));
|
|
6484
|
-
const resolver = createImportResolver(cwd);
|
|
6485
|
-
const edges = [];
|
|
6486
|
-
const seen = /* @__PURE__ */ new Set();
|
|
6487
|
-
for (const file of files) {
|
|
6488
|
-
for (const specifier of file.imports) {
|
|
6489
|
-
await slicer.tick();
|
|
6490
|
-
const target = resolver.resolve(file.path, specifier, pathToId);
|
|
6491
|
-
const edge = target ? { fileId: file.id, toFileId: target } : { fileId: file.id, externalModule: specifier };
|
|
6492
|
-
const key = "toFileId" in edge ? `${edge.fileId}\0${edge.toFileId}` : `${edge.fileId}\0${edge.externalModule}`;
|
|
6493
|
-
if (seen.has(key)) continue;
|
|
6494
|
-
seen.add(key);
|
|
6495
|
-
edges.push(edge);
|
|
6496
|
-
}
|
|
6497
|
-
}
|
|
6498
|
-
return edges.sort(compareEdges);
|
|
6499
|
-
}
|
|
6500
|
-
function compareFiles(a, b) {
|
|
6501
|
-
return a.path.localeCompare(b.path);
|
|
6502
|
-
}
|
|
6503
|
-
function compareCodewikiSymbols(a, b) {
|
|
6504
|
-
const pathCmp = a.fileId.localeCompare(b.fileId);
|
|
6505
|
-
return pathCmp || a.line - b.line || a.name.localeCompare(b.name) || a.kind.localeCompare(b.kind);
|
|
6506
|
-
}
|
|
6507
|
-
function compareEdges(a, b) {
|
|
6508
|
-
const fileCmp = a.fileId.localeCompare(b.fileId);
|
|
6509
|
-
if (fileCmp !== 0) return fileCmp;
|
|
6510
|
-
const aTarget = "toFileId" in a ? a.toFileId : `~${a.externalModule}`;
|
|
6511
|
-
const bTarget = "toFileId" in b ? b.toFileId : `~${b.externalModule}`;
|
|
6512
|
-
return aTarget.localeCompare(bTarget);
|
|
6513
|
-
}
|
|
6514
|
-
function promoteSingleSourceEntry(files) {
|
|
6515
|
-
const sourceFiles = files.filter((file) => file.lang !== "config");
|
|
6516
|
-
if (sourceFiles.length !== 1) return files;
|
|
6517
|
-
const only = sourceFiles[0];
|
|
6518
|
-
if (only?.role !== "module") return files;
|
|
6519
|
-
return files.map((file) => file.id === only.id ? { ...file, role: "entry" } : file);
|
|
6520
|
-
}
|
|
6521
|
-
async function codewikiFromBuiltFiles(cwd, language, builtFiles, slicer) {
|
|
6522
|
-
const baseBuiltFiles = builtFiles.map((item) => ({
|
|
6523
|
-
...item,
|
|
6524
|
-
file: { ...item.file, role: roleFor(item.file.path, item.file.lang) }
|
|
6525
|
-
}));
|
|
6526
|
-
const files = promoteSingleSourceEntry(baseBuiltFiles.map((item) => item.file).sort(compareFiles));
|
|
6527
|
-
const roleById = new Map(files.map((file) => [file.id, file.role]));
|
|
6528
|
-
const normalizedBuilt = baseBuiltFiles.map((item) => {
|
|
6529
|
-
const role = roleById.get(item.file.id);
|
|
6530
|
-
return role && role !== item.file.role ? { ...item, file: { ...item.file, role } } : item;
|
|
6531
|
-
});
|
|
6532
|
-
const normalizedFiles = normalizedBuilt.map((item) => item.file).sort(compareFiles);
|
|
6533
|
-
return {
|
|
6534
|
-
version: CODEWIKI_VERSION,
|
|
6535
|
-
language,
|
|
6536
|
-
files: normalizedFiles,
|
|
6537
|
-
symbols: normalizedBuilt.flatMap((item) => item.symbols).sort(compareCodewikiSymbols),
|
|
6538
|
-
edges: await buildEdges(cwd, normalizedFiles, slicer)
|
|
6539
|
-
};
|
|
6540
|
-
}
|
|
6541
|
-
async function buildFromPaths(cwd, language, relPaths, options = {}) {
|
|
6542
|
-
const slicer = options.slicer ?? createSlicer();
|
|
6543
|
-
const sortedPaths = [...relPaths].sort(compareStrings3);
|
|
6544
|
-
const treeSitterExtractor = await loadTreeSitterExtractor();
|
|
6545
|
-
await treeSitterExtractor.ensureGrammarsForPaths(sortedPaths);
|
|
6546
|
-
const readFile = options.readFile ?? defaultReadFile;
|
|
6547
|
-
const builtFiles = [];
|
|
6548
|
-
for (const relPath of sortedPaths) {
|
|
6549
|
-
await slicer.tick();
|
|
6550
|
-
const built = buildFile(cwd, relPath, treeSitterExtractor, readFile);
|
|
6551
|
-
if (built) builtFiles.push(built);
|
|
6552
|
-
}
|
|
6553
|
-
return codewikiFromBuiltFiles(cwd, language, builtFiles, slicer);
|
|
6554
|
-
}
|
|
6555
|
-
async function buildCodewiki(input, options = {}) {
|
|
6556
|
-
const slicer = options.slicer ?? createSlicer();
|
|
6557
|
-
const files = (await enumerateWorkspaceFilesAsync(input.cwd, WORKSPACE_EXCLUDED_DIRS, void 0, slicer)).filter(
|
|
6558
|
-
isIndexablePath
|
|
6559
|
-
);
|
|
6560
|
-
return buildFromPaths(input.cwd, input.language, files, { ...options, slicer });
|
|
6561
|
-
}
|
|
6562
|
-
async function updateCodewikiPaths(cwd, codewiki, paths, options = {}) {
|
|
6563
|
-
const normalizedPaths = uniqueSorted3(
|
|
6564
|
-
paths.map(normalizeInputPath).filter((path) => path.length > 0 && !path.startsWith(".."))
|
|
6565
|
-
);
|
|
6566
|
-
if (normalizedPaths.length === 0) return codewiki;
|
|
6567
|
-
if (normalizedPaths.some(
|
|
6568
|
-
(path) => path === ".gitignore" || path.endsWith("/.gitignore") || path === ".git/info/exclude" || path === ".git/index" || path === ".gitmodules"
|
|
6569
|
-
)) {
|
|
6570
|
-
return buildCodewiki({ cwd, language: codewiki.language }, options);
|
|
6571
|
-
}
|
|
6572
|
-
const slicer = options.slicer ?? createSlicer();
|
|
6573
|
-
const existingPaths = new Set(codewiki.files.map((file) => file.path));
|
|
6574
|
-
const visiblePaths = new Set(filterWorkspaceFileCandidates(cwd, normalizedPaths, WORKSPACE_EXCLUDED_DIRS));
|
|
6575
|
-
const readFile = options.readFile ?? defaultReadFile;
|
|
6576
|
-
const changedPathSet = new Set(normalizedPaths);
|
|
6577
|
-
const rebuildPaths = [];
|
|
6578
|
-
let hasIndexChange = false;
|
|
6579
|
-
for (const relPath of normalizedPaths) {
|
|
6580
|
-
const wasIndexed = existingPaths.has(relPath);
|
|
6581
|
-
const isCurrentIndexableFile = isIndexablePath(relPath) && visiblePaths.has(relPath);
|
|
6582
|
-
if (!wasIndexed && !isCurrentIndexableFile) continue;
|
|
6583
|
-
hasIndexChange = true;
|
|
6584
|
-
if (isCurrentIndexableFile) rebuildPaths.push(relPath);
|
|
6585
|
-
}
|
|
6586
|
-
if (!hasIndexChange) return codewiki;
|
|
6587
|
-
const rebuiltFiles = [];
|
|
6588
|
-
if (rebuildPaths.length > 0) {
|
|
6589
|
-
const treeSitterExtractor = await loadTreeSitterExtractor();
|
|
6590
|
-
await treeSitterExtractor.ensureGrammarsForPaths(rebuildPaths);
|
|
6591
|
-
for (const relPath of rebuildPaths) {
|
|
6592
|
-
await slicer.tick();
|
|
6593
|
-
const built = buildFile(cwd, relPath, treeSitterExtractor, readFile);
|
|
6594
|
-
if (built) rebuiltFiles.push(built);
|
|
6595
|
-
}
|
|
6596
|
-
}
|
|
6597
|
-
const removedFileIds = new Set(codewiki.files.filter((file) => changedPathSet.has(file.path)).map((file) => file.id));
|
|
6598
|
-
const symbolsByFileId = /* @__PURE__ */ new Map();
|
|
6599
|
-
for (const symbol of codewiki.symbols) {
|
|
6600
|
-
if (removedFileIds.has(symbol.fileId)) continue;
|
|
6601
|
-
const symbols = symbolsByFileId.get(symbol.fileId) ?? [];
|
|
6602
|
-
symbols.push(symbol);
|
|
6603
|
-
symbolsByFileId.set(symbol.fileId, symbols);
|
|
6604
|
-
}
|
|
6605
|
-
const keptFiles = codewiki.files.filter((file) => !changedPathSet.has(file.path)).map((file) => ({ file, symbols: symbolsByFileId.get(file.id) ?? [] }));
|
|
6606
|
-
return codewikiFromBuiltFiles(cwd, codewiki.language, [...keptFiles, ...rebuiltFiles], slicer);
|
|
6607
|
-
}
|
|
6608
|
-
async function syncCodewiki(cwd, codewiki, options = {}) {
|
|
6609
|
-
const slicer = options.slicer ?? createSlicer();
|
|
6610
|
-
const readFile = options.readFile ?? defaultReadFile;
|
|
6611
|
-
const currentPaths = (await enumerateWorkspaceFilesAsync(cwd, WORKSPACE_EXCLUDED_DIRS, void 0, slicer)).filter(
|
|
6612
|
-
isIndexablePath
|
|
6613
|
-
);
|
|
6614
|
-
const currentFiles = /* @__PURE__ */ new Map();
|
|
6615
|
-
const currentTexts = /* @__PURE__ */ new Map();
|
|
6616
|
-
for (const relPath of currentPaths) {
|
|
6617
|
-
await slicer.tick();
|
|
6618
|
-
const text = readFile(join4(cwd, relPath));
|
|
6619
|
-
if (text !== null) {
|
|
6620
|
-
currentFiles.set(relPath, contentHash(text));
|
|
6621
|
-
currentTexts.set(relPath, text);
|
|
6622
|
-
}
|
|
6623
|
-
}
|
|
6624
|
-
const indexedFiles = new Map(codewiki.files.map((file) => [file.path, file]));
|
|
6625
|
-
const changedPaths = /* @__PURE__ */ new Set();
|
|
6626
|
-
for (const [relPath, hash] of currentFiles) {
|
|
6627
|
-
if (indexedFiles.get(relPath)?.hash !== hash) changedPaths.add(relPath);
|
|
6628
|
-
}
|
|
6629
|
-
for (const relPath of indexedFiles.keys()) {
|
|
6630
|
-
if (!currentFiles.has(relPath)) changedPaths.add(relPath);
|
|
6631
|
-
}
|
|
6632
|
-
if (changedPaths.size === 0) return codewiki;
|
|
6633
|
-
const syncOptions = {
|
|
6634
|
-
...options,
|
|
6635
|
-
slicer,
|
|
6636
|
-
readFile: (path) => currentTexts.get(normalizeRel(cwd, path)) ?? readFile(path)
|
|
6637
|
-
};
|
|
6638
|
-
return updateCodewikiPaths(cwd, codewiki, [...changedPaths], syncOptions);
|
|
6639
|
-
}
|
|
6640
|
-
function codewikiPath(cwd) {
|
|
6641
|
-
return join4(cwd, ".clio-coder", "codewiki.json");
|
|
6642
|
-
}
|
|
6643
|
-
function serializeCodewiki(codewiki) {
|
|
6644
|
-
return `${JSON.stringify(normalizeCodewiki(codewiki))}
|
|
6645
|
-
`;
|
|
6646
|
-
}
|
|
6647
|
-
function writeCodewiki(cwd, codewiki) {
|
|
6648
|
-
const serialized = serializeCodewiki(codewiki);
|
|
6649
|
-
safeResourceWrite(codewikiPath(cwd), serialized, {
|
|
6650
|
-
encoding: "utf8"
|
|
6651
|
-
});
|
|
6652
|
-
return serialized;
|
|
6653
|
-
}
|
|
6654
|
-
function parseCodewikiRaw(raw) {
|
|
6655
|
-
let parsed;
|
|
6656
|
-
try {
|
|
6657
|
-
parsed = JSON.parse(raw);
|
|
6658
|
-
} catch {
|
|
6659
|
-
return null;
|
|
6660
|
-
}
|
|
6661
|
-
return upgradeCodewiki(parsed);
|
|
6662
|
-
}
|
|
6663
|
-
function readCodewikiRaw(cwd) {
|
|
6664
|
-
const filePath = codewikiPath(cwd);
|
|
6665
|
-
if (!existsSync(filePath)) return null;
|
|
6666
|
-
let raw;
|
|
6667
|
-
try {
|
|
6668
|
-
raw = readFileSync2(filePath, "utf8");
|
|
6669
|
-
} catch {
|
|
6670
|
-
return null;
|
|
6671
|
-
}
|
|
6672
|
-
const codewiki = parseCodewikiRaw(raw);
|
|
6673
|
-
return codewiki ? { raw, codewiki } : null;
|
|
6674
|
-
}
|
|
6675
|
-
function readCodewiki(cwd) {
|
|
6676
|
-
return readCodewikiRaw(cwd)?.codewiki ?? null;
|
|
6677
|
-
}
|
|
6678
|
-
async function readCodewikiAsync(cwd) {
|
|
6679
|
-
let raw;
|
|
6680
|
-
try {
|
|
6681
|
-
raw = await readFileAsync(codewikiPath(cwd), "utf8");
|
|
6682
|
-
} catch {
|
|
6683
|
-
return null;
|
|
6684
|
-
}
|
|
6685
|
-
return parseCodewikiRaw(raw);
|
|
6686
|
-
}
|
|
6687
|
-
function codewikiEntries(codewiki) {
|
|
6688
|
-
const fileById = new Map(codewiki.files.map((file) => [file.id, file]));
|
|
6689
|
-
const exportsByFile = /* @__PURE__ */ new Map();
|
|
6690
|
-
for (const symbol of codewiki.symbols) {
|
|
6691
|
-
const list = exportsByFile.get(symbol.fileId) ?? [];
|
|
6692
|
-
list.push(symbol.name);
|
|
6693
|
-
exportsByFile.set(symbol.fileId, list);
|
|
6694
|
-
}
|
|
6695
|
-
const importsByFile = /* @__PURE__ */ new Map();
|
|
6696
|
-
for (const edge of codewiki.edges) {
|
|
6697
|
-
const list = importsByFile.get(edge.fileId) ?? [];
|
|
6698
|
-
if ("toFileId" in edge) {
|
|
6699
|
-
const target = fileById.get(edge.toFileId);
|
|
6700
|
-
if (target) list.push(target.path);
|
|
6701
|
-
} else {
|
|
6702
|
-
list.push(edge.externalModule);
|
|
6703
|
-
}
|
|
6704
|
-
importsByFile.set(edge.fileId, list);
|
|
6705
|
-
}
|
|
6706
|
-
return codewiki.files.filter((file) => file.lang !== "config").map((file) => ({
|
|
6707
|
-
path: file.path,
|
|
6708
|
-
exports: uniqueSorted3(exportsByFile.get(file.id) ?? []),
|
|
6709
|
-
imports: uniqueSorted3(importsByFile.get(file.id) ?? []),
|
|
6710
|
-
kind: file.role === "entry" ? "entry-point" : file.role === "test" ? "test" : "module",
|
|
6711
|
-
...file.summary ? { summary: file.summary } : {}
|
|
6712
|
-
})).sort((a, b) => a.path.localeCompare(b.path));
|
|
6713
|
-
}
|
|
6714
|
-
function codewikiNeedsBackfill(codewiki) {
|
|
6715
|
-
return codewiki.files.some((file) => file.lang !== "config" && file.hash.length === 0);
|
|
6716
|
-
}
|
|
6717
|
-
function structuralCodewikiHash(codewiki) {
|
|
6718
|
-
return createHash("sha256").update(JSON.stringify(normalizeCodewiki(codewiki))).digest("hex");
|
|
6719
|
-
}
|
|
6720
|
-
function normalizeCodewikiFile(file) {
|
|
6721
|
-
return {
|
|
6722
|
-
id: file.id,
|
|
6723
|
-
path: file.path,
|
|
6724
|
-
lang: file.lang,
|
|
6725
|
-
loc: file.loc,
|
|
6726
|
-
role: file.role,
|
|
6727
|
-
hash: file.hash,
|
|
6728
|
-
imports: uniqueSorted3(file.imports),
|
|
6729
|
-
...file.summary ? { summary: file.summary } : {}
|
|
6730
|
-
};
|
|
6731
|
-
}
|
|
6732
|
-
function symbolSigFields(kind, sig2) {
|
|
6733
|
-
if (!CODEWIKI_SYMBOL_KINDS_WITH_SIG.has(kind)) return {};
|
|
6734
|
-
const clean = sig2?.trim().slice(0, 240);
|
|
6735
|
-
return clean && clean.length > 0 ? { sig: clean } : {};
|
|
6736
|
-
}
|
|
6737
|
-
function normalizeCodewikiSymbol(symbol) {
|
|
6738
|
-
return {
|
|
6739
|
-
name: symbol.name,
|
|
6740
|
-
kind: symbol.kind,
|
|
6741
|
-
fileId: symbol.fileId,
|
|
6742
|
-
line: symbol.line,
|
|
6743
|
-
...symbolSigFields(symbol.kind, symbol.sig)
|
|
6744
|
-
};
|
|
6745
|
-
}
|
|
6746
|
-
function normalizeCodewiki(codewiki) {
|
|
6747
|
-
return {
|
|
6748
|
-
version: CODEWIKI_VERSION,
|
|
6749
|
-
language: codewiki.language,
|
|
6750
|
-
files: codewiki.files.map(normalizeCodewikiFile).sort(compareFiles),
|
|
6751
|
-
symbols: codewiki.symbols.map(normalizeCodewikiSymbol).sort(compareCodewikiSymbols),
|
|
6752
|
-
edges: [...codewiki.edges].sort(compareEdges)
|
|
6753
|
-
};
|
|
6754
|
-
}
|
|
6755
|
-
function upgradeCodewiki(value) {
|
|
6756
|
-
if (isCodewikiV5(value)) return normalizeCodewiki(value);
|
|
6757
|
-
if (isCodewikiV4(value)) return upgradeV4Codewiki(value);
|
|
6758
|
-
if (isCodewikiV3(value)) return upgradeV3Codewiki(value);
|
|
6759
|
-
if (isCodewikiV2(value)) return upgradeV2Codewiki(value);
|
|
6760
|
-
return null;
|
|
6761
|
-
}
|
|
6762
|
-
function upgradeV3Codewiki(value) {
|
|
6763
|
-
return normalizeCodewiki({
|
|
6764
|
-
version: CODEWIKI_VERSION,
|
|
6765
|
-
language: value.language,
|
|
6766
|
-
files: value.files.map((file) => ({
|
|
6767
|
-
...file,
|
|
6768
|
-
hash: "",
|
|
6769
|
-
imports: []
|
|
6770
|
-
})),
|
|
6771
|
-
symbols: value.symbols,
|
|
6772
|
-
edges: value.edges
|
|
6773
|
-
});
|
|
6774
|
-
}
|
|
6775
|
-
function upgradeV4Codewiki(value) {
|
|
6776
|
-
return normalizeCodewiki({
|
|
6777
|
-
version: CODEWIKI_VERSION,
|
|
6778
|
-
language: value.language,
|
|
6779
|
-
// v5 changes C-family extraction and adds CUDA paths. Blank hashes force
|
|
6780
|
-
// one complete rebuild instead of treating a structurally obsolete v4
|
|
6781
|
-
// artifact as fresh.
|
|
6782
|
-
files: value.files.map((file) => ({ ...file, hash: "" })),
|
|
6783
|
-
symbols: value.symbols,
|
|
6784
|
-
edges: value.edges
|
|
6785
|
-
});
|
|
6786
|
-
}
|
|
6787
|
-
function upgradeV2Codewiki(value) {
|
|
6788
|
-
const files = value.entries.map((entry) => {
|
|
6789
|
-
const lang = languageForPath(entry.path) ?? (value.language === "unknown" || value.language === "polyglot" || value.language === "dotfiles" ? "config" : value.language);
|
|
6790
|
-
return {
|
|
6791
|
-
id: stableFileId(entry.path),
|
|
6792
|
-
path: entry.path,
|
|
6793
|
-
lang,
|
|
6794
|
-
loc: 0,
|
|
6795
|
-
role: entry.kind === "entry-point" ? "entry" : entry.kind === "test" ? "test" : "module"
|
|
6796
|
-
};
|
|
6797
|
-
});
|
|
6798
|
-
const pathToId = new Map(files.map((file) => [file.path, file.id]));
|
|
6799
|
-
const symbols = [];
|
|
6800
|
-
for (const entry of value.entries) {
|
|
6801
|
-
const fileId = pathToId.get(entry.path);
|
|
6802
|
-
if (!fileId) continue;
|
|
6803
|
-
for (const name2 of entry.exports) symbols.push({ name: name2, kind: "const", fileId, line: 1 });
|
|
6804
|
-
}
|
|
6805
|
-
const edges = [];
|
|
6806
|
-
for (const entry of value.entries) {
|
|
6807
|
-
const fileId = pathToId.get(entry.path);
|
|
6808
|
-
if (!fileId) continue;
|
|
6809
|
-
for (const item of entry.imports) {
|
|
6810
|
-
const toFileId = pathToId.get(item);
|
|
6811
|
-
edges.push(toFileId ? { fileId, toFileId } : { fileId, externalModule: item });
|
|
6812
|
-
}
|
|
6813
|
-
}
|
|
6814
|
-
return upgradeV3Codewiki({
|
|
6815
|
-
version: 3,
|
|
6816
|
-
language: value.language,
|
|
6817
|
-
files,
|
|
6818
|
-
symbols,
|
|
6819
|
-
edges
|
|
6820
|
-
});
|
|
6821
|
-
}
|
|
6822
|
-
function isNormalizedRelativeCodewikiPath(path) {
|
|
6823
|
-
if (path.length === 0 || path.includes("\0") || path.includes("\\") || path.startsWith("/")) return false;
|
|
6824
|
-
if (/^[A-Za-z]:\//.test(path)) return false;
|
|
6825
|
-
const segments = path.split("/");
|
|
6826
|
-
return segments.every((segment) => segment.length > 0 && segment !== "." && segment !== "..");
|
|
6827
|
-
}
|
|
6828
|
-
function hasValidNativeV5Semantics(value) {
|
|
6829
|
-
const fileIds = /* @__PURE__ */ new Set();
|
|
6830
|
-
const filePaths = /* @__PURE__ */ new Set();
|
|
6831
|
-
const locByFileId = /* @__PURE__ */ new Map();
|
|
6832
|
-
for (const file of value.files) {
|
|
6833
|
-
if (fileIds.has(file.id) || filePaths.has(file.path)) return false;
|
|
6834
|
-
if (!isNormalizedRelativeCodewikiPath(file.path) || !/^[0-9a-f]{16}$/.test(file.hash)) return false;
|
|
6835
|
-
fileIds.add(file.id);
|
|
6836
|
-
filePaths.add(file.path);
|
|
6837
|
-
locByFileId.set(file.id, file.loc);
|
|
6838
|
-
}
|
|
6839
|
-
for (const symbol of value.symbols) {
|
|
6840
|
-
const loc = locByFileId.get(symbol.fileId);
|
|
6841
|
-
if (loc === void 0 || symbol.line > loc) return false;
|
|
6842
|
-
}
|
|
6843
|
-
for (const edge of value.edges) {
|
|
6844
|
-
if (!fileIds.has(edge.fileId)) return false;
|
|
6845
|
-
if ("toFileId" in edge && !fileIds.has(edge.toFileId)) return false;
|
|
6846
|
-
}
|
|
6847
|
-
return true;
|
|
6848
|
-
}
|
|
6849
|
-
function isCodewikiV5(value) {
|
|
6850
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
6851
|
-
const obj = value;
|
|
6852
|
-
if (obj.version !== CODEWIKI_VERSION || typeof obj.language !== "string") return false;
|
|
6853
|
-
if (!Array.isArray(obj.files) || !Array.isArray(obj.symbols) || !Array.isArray(obj.edges)) return false;
|
|
6854
|
-
if (!obj.files.every(isCodewikiFile) || !obj.symbols.every(isCodewikiSymbol) || !obj.edges.every(isCodewikiEdge)) {
|
|
6855
|
-
return false;
|
|
6856
|
-
}
|
|
6857
|
-
return hasValidNativeV5Semantics(obj);
|
|
6858
|
-
}
|
|
6859
|
-
function isCodewikiV4(value) {
|
|
6860
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
6861
|
-
const obj = value;
|
|
6862
|
-
if (obj.version !== 4 || typeof obj.language !== "string") return false;
|
|
6863
|
-
if (!Array.isArray(obj.files) || !Array.isArray(obj.symbols) || !Array.isArray(obj.edges)) return false;
|
|
6864
|
-
return obj.files.every(isCodewikiFile) && obj.symbols.every(isCodewikiSymbol) && obj.edges.every(isCodewikiEdge);
|
|
6865
|
-
}
|
|
6866
|
-
function isCodewikiV3(value) {
|
|
6867
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
6868
|
-
const obj = value;
|
|
6869
|
-
if (obj.version !== 3 || typeof obj.language !== "string") return false;
|
|
6870
|
-
if (!Array.isArray(obj.files) || !Array.isArray(obj.symbols) || !Array.isArray(obj.edges)) return false;
|
|
6871
|
-
return obj.files.every(isCodewikiFileV3) && obj.symbols.every(isCodewikiSymbol) && obj.edges.every(isCodewikiEdge);
|
|
6872
|
-
}
|
|
6873
|
-
function isCodewikiV2(value) {
|
|
6874
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
6875
|
-
const obj = value;
|
|
6876
|
-
if (obj.version !== 2 || typeof obj.generatedAt !== "string" || typeof obj.language !== "string") return false;
|
|
6877
|
-
if (!Array.isArray(obj.entries)) return false;
|
|
6878
|
-
return obj.entries.every(isCodewikiEntry);
|
|
6879
|
-
}
|
|
6880
|
-
var CODEWIKI_LANGUAGES = /* @__PURE__ */ new Set([
|
|
6881
|
-
"typescript",
|
|
6882
|
-
"javascript",
|
|
6883
|
-
"python",
|
|
6884
|
-
"rust",
|
|
6885
|
-
"go",
|
|
6886
|
-
"c",
|
|
6887
|
-
"c++",
|
|
6888
|
-
"java",
|
|
6889
|
-
"ruby",
|
|
6890
|
-
"c#",
|
|
6891
|
-
"config"
|
|
6892
|
-
]);
|
|
6893
|
-
var FILE_ROLES = /* @__PURE__ */ new Set(["entry", "test", "module", "config"]);
|
|
6894
|
-
var SYMBOL_KINDS = /* @__PURE__ */ new Set(["func", "class", "method", "type", "const", "var", "trait", "iface"]);
|
|
6895
|
-
function isCodewikiFile(value) {
|
|
6896
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
6897
|
-
const obj = value;
|
|
6898
|
-
return typeof obj.id === "string" && typeof obj.path === "string" && typeof obj.lang === "string" && CODEWIKI_LANGUAGES.has(obj.lang) && typeof obj.loc === "number" && Number.isInteger(obj.loc) && obj.loc >= 0 && typeof obj.role === "string" && FILE_ROLES.has(obj.role) && typeof obj.hash === "string" && Array.isArray(obj.imports) && obj.imports.every((item) => typeof item === "string") && (!("summary" in obj) || typeof obj.summary === "string");
|
|
6899
|
-
}
|
|
6900
|
-
function isCodewikiFileV3(value) {
|
|
6901
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
6902
|
-
const obj = value;
|
|
6903
|
-
return typeof obj.id === "string" && typeof obj.path === "string" && typeof obj.lang === "string" && CODEWIKI_LANGUAGES.has(obj.lang) && typeof obj.loc === "number" && Number.isInteger(obj.loc) && obj.loc >= 0 && typeof obj.role === "string" && FILE_ROLES.has(obj.role);
|
|
6904
|
-
}
|
|
6905
|
-
function isCodewikiSymbol(value) {
|
|
6906
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
6907
|
-
const obj = value;
|
|
6908
|
-
return typeof obj.name === "string" && typeof obj.kind === "string" && SYMBOL_KINDS.has(obj.kind) && typeof obj.fileId === "string" && typeof obj.line === "number" && Number.isInteger(obj.line) && obj.line >= 1 && (!("sig" in obj) || typeof obj.sig === "string");
|
|
6909
|
-
}
|
|
6910
|
-
function isCodewikiEdge(value) {
|
|
6911
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
6912
|
-
const obj = value;
|
|
6913
|
-
if (typeof obj.fileId !== "string") return false;
|
|
6914
|
-
const hasToFile = typeof obj.toFileId === "string";
|
|
6915
|
-
const hasExternal = typeof obj.externalModule === "string";
|
|
6916
|
-
return hasToFile !== hasExternal;
|
|
6917
|
-
}
|
|
6918
|
-
function isCodewikiEntry(value) {
|
|
6919
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
6920
|
-
const obj = value;
|
|
6921
|
-
if (typeof obj.path !== "string") return false;
|
|
6922
|
-
if (!Array.isArray(obj.exports) || obj.exports.some((item) => typeof item !== "string")) return false;
|
|
6923
|
-
if (!Array.isArray(obj.imports) || obj.imports.some((item) => typeof item !== "string")) return false;
|
|
6924
|
-
if (obj.kind !== "entry-point" && obj.kind !== "test" && obj.kind !== "module") return false;
|
|
6925
|
-
if ("summary" in obj && typeof obj.summary !== "string") return false;
|
|
6926
|
-
return true;
|
|
6927
|
-
}
|
|
6928
|
-
|
|
6929
4670
|
export {
|
|
6930
|
-
|
|
6931
|
-
enumerateWorkspaceFiles,
|
|
6932
|
-
enumerateWorkspaceFilesAsync,
|
|
6933
|
-
detectProjectProfile,
|
|
6934
|
-
detectProjectType,
|
|
6935
|
-
INDEX_SLICE_MS,
|
|
6936
|
-
createSlicer,
|
|
6937
|
-
CODEWIKI_VERSION,
|
|
6938
|
-
isIndexablePath,
|
|
6939
|
-
buildCodewiki,
|
|
6940
|
-
updateCodewikiPaths,
|
|
6941
|
-
syncCodewiki,
|
|
6942
|
-
codewikiPath,
|
|
6943
|
-
writeCodewiki,
|
|
6944
|
-
parseCodewikiRaw,
|
|
6945
|
-
readCodewiki,
|
|
6946
|
-
readCodewikiAsync,
|
|
6947
|
-
codewikiEntries,
|
|
6948
|
-
codewikiNeedsBackfill,
|
|
6949
|
-
structuralCodewikiHash
|
|
4671
|
+
createTreeSitterExtractor
|
|
6950
4672
|
};
|
|
6951
|
-
//# sourceMappingURL=
|
|
4673
|
+
//# sourceMappingURL=tree-sitter-HGKH6LG4.js.map
|