@mycodemap/mycodemap 2.0.0 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/README.md +59 -184
- package/dist/cli/commands/agent-metrics/human.d.ts +4 -0
- package/dist/cli/commands/agent-metrics/human.d.ts.map +1 -0
- package/dist/cli/commands/agent-metrics/human.js +134 -0
- package/dist/cli/commands/agent-metrics/human.js.map +1 -0
- package/dist/cli/commands/agent-metrics/index.d.ts +15 -0
- package/dist/cli/commands/agent-metrics/index.d.ts.map +1 -0
- package/dist/cli/commands/agent-metrics/index.js +116 -0
- package/dist/cli/commands/agent-metrics/index.js.map +1 -0
- package/dist/cli/commands/analyze.d.ts +3 -196
- package/dist/cli/commands/analyze.d.ts.map +1 -1
- package/dist/cli/commands/analyze.js +9 -1163
- package/dist/cli/commands/analyze.js.map +1 -1
- package/dist/cli/commands/benchmark.d.ts.map +1 -1
- package/dist/cli/commands/benchmark.js +5 -2
- package/dist/cli/commands/benchmark.js.map +1 -1
- package/dist/cli/commands/complexity.d.ts.map +1 -1
- package/dist/cli/commands/complexity.js +62 -95
- package/dist/cli/commands/complexity.js.map +1 -1
- package/dist/cli/commands/deps.d.ts +3 -60
- package/dist/cli/commands/deps.d.ts.map +1 -1
- package/dist/cli/commands/deps.js +16 -351
- package/dist/cli/commands/deps.js.map +1 -1
- package/dist/cli/commands/env-contract.d.ts +3 -0
- package/dist/cli/commands/env-contract.d.ts.map +1 -0
- package/dist/cli/commands/env-contract.js +221 -0
- package/dist/cli/commands/env-contract.js.map +1 -0
- package/dist/cli/commands/generate.d.ts +19 -1
- package/dist/cli/commands/generate.d.ts.map +1 -1
- package/dist/cli/commands/generate.js +735 -89
- package/dist/cli/commands/generate.js.map +1 -1
- package/dist/cli/commands/impact.d.ts +4 -38
- package/dist/cli/commands/impact.d.ts.map +1 -1
- package/dist/cli/commands/impact.js +133 -375
- package/dist/cli/commands/impact.js.map +1 -1
- package/dist/cli/commands/init.d.ts +1 -0
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +61 -2
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/preview.d.ts +3 -0
- package/dist/cli/commands/preview.d.ts.map +1 -0
- package/dist/cli/commands/preview.js +216 -0
- package/dist/cli/commands/preview.js.map +1 -0
- package/dist/cli/commands/query.d.ts +2 -21
- package/dist/cli/commands/query.d.ts.map +1 -1
- package/dist/cli/commands/query.js +15 -683
- package/dist/cli/commands/query.js.map +1 -1
- package/dist/cli/commands/watch-foreground.d.ts.map +1 -1
- package/dist/cli/commands/watch-foreground.js +5 -1
- package/dist/cli/commands/watch-foreground.js.map +1 -1
- package/dist/cli/config-loader.d.ts.map +1 -1
- package/dist/cli/config-loader.js +51 -13
- package/dist/cli/config-loader.js.map +1 -1
- package/dist/cli/doctor/check-env-contract.d.ts +3 -0
- package/dist/cli/doctor/check-env-contract.d.ts.map +1 -0
- package/dist/cli/doctor/check-env-contract.js +96 -0
- package/dist/cli/doctor/check-env-contract.js.map +1 -0
- package/dist/cli/doctor/check-native-deps.d.ts.map +1 -1
- package/dist/cli/doctor/check-native-deps.js +20 -4
- package/dist/cli/doctor/check-native-deps.js.map +1 -1
- package/dist/cli/doctor/orchestrator.d.ts.map +1 -1
- package/dist/cli/doctor/orchestrator.js +5 -2
- package/dist/cli/doctor/orchestrator.js.map +1 -1
- package/dist/cli/env-contract/check.d.ts +18 -0
- package/dist/cli/env-contract/check.d.ts.map +1 -0
- package/dist/cli/env-contract/check.js +118 -0
- package/dist/cli/env-contract/check.js.map +1 -0
- package/dist/cli/env-contract/discovery.d.ts +12 -0
- package/dist/cli/env-contract/discovery.d.ts.map +1 -0
- package/dist/cli/env-contract/discovery.js +249 -0
- package/dist/cli/env-contract/discovery.js.map +1 -0
- package/dist/cli/env-contract/filters.d.ts +10 -0
- package/dist/cli/env-contract/filters.d.ts.map +1 -0
- package/dist/cli/env-contract/filters.js +23 -0
- package/dist/cli/env-contract/filters.js.map +1 -0
- package/dist/cli/env-contract/index.d.ts +6 -0
- package/dist/cli/env-contract/index.d.ts.map +1 -0
- package/dist/cli/env-contract/index.js +8 -0
- package/dist/cli/env-contract/index.js.map +1 -0
- package/dist/cli/env-contract/reminder-engine.d.ts +34 -0
- package/dist/cli/env-contract/reminder-engine.d.ts.map +1 -0
- package/dist/cli/env-contract/reminder-engine.js +51 -0
- package/dist/cli/env-contract/reminder-engine.js.map +1 -0
- package/dist/cli/env-contract/reminder-hook-runner.d.ts +45 -0
- package/dist/cli/env-contract/reminder-hook-runner.d.ts.map +1 -0
- package/dist/cli/env-contract/reminder-hook-runner.js +273 -0
- package/dist/cli/env-contract/reminder-hook-runner.js.map +1 -0
- package/dist/cli/env-contract/reminder-ledger.d.ts +11 -0
- package/dist/cli/env-contract/reminder-ledger.d.ts.map +1 -0
- package/dist/cli/env-contract/reminder-ledger.js +37 -0
- package/dist/cli/env-contract/reminder-ledger.js.map +1 -0
- package/dist/cli/env-contract/types.d.ts +48 -0
- package/dist/cli/env-contract/types.d.ts.map +1 -0
- package/dist/cli/env-contract/types.js +22 -0
- package/dist/cli/env-contract/types.js.map +1 -0
- package/dist/cli/env-contract/validation.d.ts +10 -0
- package/dist/cli/env-contract/validation.d.ts.map +1 -0
- package/dist/cli/env-contract/validation.js +116 -0
- package/dist/cli/env-contract/validation.js.map +1 -0
- package/dist/cli/first-run-guide.d.ts.map +1 -1
- package/dist/cli/first-run-guide.js +8 -3
- package/dist/cli/first-run-guide.js.map +1 -1
- package/dist/cli/index.js +23 -3
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/init/assistant-plan.d.ts +14 -0
- package/dist/cli/init/assistant-plan.d.ts.map +1 -0
- package/dist/cli/init/assistant-plan.js +208 -0
- package/dist/cli/init/assistant-plan.js.map +1 -0
- package/dist/cli/init/detect.d.ts +28 -0
- package/dist/cli/init/detect.d.ts.map +1 -0
- package/dist/cli/init/detect.js +63 -0
- package/dist/cli/init/detect.js.map +1 -0
- package/dist/cli/init/env-contract-plan.d.ts +28 -0
- package/dist/cli/init/env-contract-plan.d.ts.map +1 -0
- package/dist/cli/init/env-contract-plan.js +184 -0
- package/dist/cli/init/env-contract-plan.js.map +1 -0
- package/dist/cli/init/manifest-extractors.d.ts +22 -0
- package/dist/cli/init/manifest-extractors.d.ts.map +1 -0
- package/dist/cli/init/manifest-extractors.js +185 -0
- package/dist/cli/init/manifest-extractors.js.map +1 -0
- package/dist/cli/init/profile-loader.d.ts +49 -0
- package/dist/cli/init/profile-loader.d.ts.map +1 -0
- package/dist/cli/init/profile-loader.js +107 -0
- package/dist/cli/init/profile-loader.js.map +1 -0
- package/dist/cli/init/profile-plan.d.ts +38 -0
- package/dist/cli/init/profile-plan.d.ts.map +1 -0
- package/dist/cli/init/profile-plan.js +120 -0
- package/dist/cli/init/profile-plan.js.map +1 -0
- package/dist/cli/init/profiles/generic.json +16 -0
- package/dist/cli/init/profiles/go.json +12 -0
- package/dist/cli/init/profiles/nodejs.json +16 -0
- package/dist/cli/init/profiles/python.json +17 -0
- package/dist/cli/init/profiles/rust.json +12 -0
- package/dist/cli/init/receipt.d.ts.map +1 -1
- package/dist/cli/init/receipt.js +107 -7
- package/dist/cli/init/receipt.js.map +1 -1
- package/dist/cli/init/reconciler.d.ts +10 -1
- package/dist/cli/init/reconciler.d.ts.map +1 -1
- package/dist/cli/init/reconciler.js +85 -15
- package/dist/cli/init/reconciler.js.map +1 -1
- package/dist/cli/interface-contract/commands/agent-metrics.d.ts +3 -0
- package/dist/cli/interface-contract/commands/agent-metrics.d.ts.map +1 -0
- package/dist/cli/interface-contract/commands/agent-metrics.js +217 -0
- package/dist/cli/interface-contract/commands/agent-metrics.js.map +1 -0
- package/dist/cli/interface-contract/commands/analyze.d.ts.map +1 -1
- package/dist/cli/interface-contract/commands/analyze.js +1 -0
- package/dist/cli/interface-contract/commands/analyze.js.map +1 -1
- package/dist/cli/interface-contract/commands/benchmark.d.ts.map +1 -1
- package/dist/cli/interface-contract/commands/benchmark.js +1 -0
- package/dist/cli/interface-contract/commands/benchmark.js.map +1 -1
- package/dist/cli/interface-contract/commands/deps.d.ts.map +1 -1
- package/dist/cli/interface-contract/commands/deps.js +1 -0
- package/dist/cli/interface-contract/commands/deps.js.map +1 -1
- package/dist/cli/interface-contract/commands/doctor.d.ts.map +1 -1
- package/dist/cli/interface-contract/commands/doctor.js +1 -0
- package/dist/cli/interface-contract/commands/doctor.js.map +1 -1
- package/dist/cli/interface-contract/commands/env-contract.d.ts +3 -0
- package/dist/cli/interface-contract/commands/env-contract.d.ts.map +1 -0
- package/dist/cli/interface-contract/commands/env-contract.js +168 -0
- package/dist/cli/interface-contract/commands/env-contract.js.map +1 -0
- package/dist/cli/interface-contract/commands/index.d.ts +5 -2
- package/dist/cli/interface-contract/commands/index.d.ts.map +1 -1
- package/dist/cli/interface-contract/commands/index.js +7 -1
- package/dist/cli/interface-contract/commands/index.js.map +1 -1
- package/dist/cli/interface-contract/commands/init.d.ts.map +1 -1
- package/dist/cli/interface-contract/commands/init.js +9 -0
- package/dist/cli/interface-contract/commands/init.js.map +1 -1
- package/dist/cli/interface-contract/commands/preview.d.ts +3 -0
- package/dist/cli/interface-contract/commands/preview.d.ts.map +1 -0
- package/dist/cli/interface-contract/commands/preview.js +118 -0
- package/dist/cli/interface-contract/commands/preview.js.map +1 -0
- package/dist/cli/interface-contract/commands/query.d.ts.map +1 -1
- package/dist/cli/interface-contract/commands/query.js +1 -0
- package/dist/cli/interface-contract/commands/query.js.map +1 -1
- package/dist/cli/interface-contract/index.d.ts +1 -1
- package/dist/cli/interface-contract/index.d.ts.map +1 -1
- package/dist/cli/interface-contract/index.js +2 -2
- package/dist/cli/interface-contract/index.js.map +1 -1
- package/dist/cli/interface-contract/schema.d.ts.map +1 -1
- package/dist/cli/interface-contract/schema.js +1 -0
- package/dist/cli/interface-contract/schema.js.map +1 -1
- package/dist/cli/interface-contract/types.d.ts +1 -0
- package/dist/cli/interface-contract/types.d.ts.map +1 -1
- package/dist/cli/output/error-codes.d.ts +2 -0
- package/dist/cli/output/error-codes.d.ts.map +1 -1
- package/dist/cli/output/error-codes.js +12 -0
- package/dist/cli/output/error-codes.js.map +1 -1
- package/dist/cli/output/errors.d.ts.map +1 -1
- package/dist/cli/output/errors.js +12 -0
- package/dist/cli/output/errors.js.map +1 -1
- package/dist/cli/output/wasm-fallback.d.ts +1 -0
- package/dist/cli/output/wasm-fallback.d.ts.map +1 -1
- package/dist/cli/output/wasm-fallback.js.map +1 -1
- package/dist/cli/preview/complexity-scanner.d.ts +21 -0
- package/dist/cli/preview/complexity-scanner.d.ts.map +1 -0
- package/dist/cli/preview/complexity-scanner.js +52 -0
- package/dist/cli/preview/complexity-scanner.js.map +1 -0
- package/dist/cli/preview/dependency-extractor.d.ts +38 -0
- package/dist/cli/preview/dependency-extractor.d.ts.map +1 -0
- package/dist/cli/preview/dependency-extractor.js +140 -0
- package/dist/cli/preview/dependency-extractor.js.map +1 -0
- package/dist/cli/preview/preview-renderer.d.ts +32 -0
- package/dist/cli/preview/preview-renderer.d.ts.map +1 -0
- package/dist/cli/preview/preview-renderer.js +54 -0
- package/dist/cli/preview/preview-renderer.js.map +1 -0
- package/dist/cli/storage-runtime.d.ts +7 -0
- package/dist/cli/storage-runtime.d.ts.map +1 -1
- package/dist/cli/storage-runtime.js +22 -0
- package/dist/cli/storage-runtime.js.map +1 -1
- package/dist/cli-new/index.js +1 -1
- package/dist/cli-new/index.js.map +1 -1
- package/dist/composition/parser-composition.d.ts +7 -0
- package/dist/composition/parser-composition.d.ts.map +1 -0
- package/dist/composition/parser-composition.js +15 -0
- package/dist/composition/parser-composition.js.map +1 -0
- package/dist/core/analyzer.d.ts.map +1 -1
- package/dist/core/analyzer.js +83 -67
- package/dist/core/analyzer.js.map +1 -1
- package/dist/core/ast-complexity-analyzer.d.ts +12 -6
- package/dist/core/ast-complexity-analyzer.d.ts.map +1 -1
- package/dist/core/ast-complexity-analyzer.js +368 -209
- package/dist/core/ast-complexity-analyzer.js.map +1 -1
- package/dist/core/file-discovery.d.ts +1 -1
- package/dist/core/file-discovery.d.ts.map +1 -1
- package/dist/core/file-discovery.js +3 -0
- package/dist/core/file-discovery.js.map +1 -1
- package/dist/core/global-index.d.ts +3 -1
- package/dist/core/global-index.d.ts.map +1 -1
- package/dist/core/global-index.js +69 -4
- package/dist/core/global-index.js.map +1 -1
- package/dist/domain/entities/CodeGraph.d.ts +3 -0
- package/dist/domain/entities/CodeGraph.d.ts.map +1 -1
- package/dist/domain/entities/CodeGraph.js +19 -2
- package/dist/domain/entities/CodeGraph.js.map +1 -1
- package/dist/domain/entities/Dependency.d.ts +5 -2
- package/dist/domain/entities/Dependency.d.ts.map +1 -1
- package/dist/domain/entities/Dependency.js +49 -3
- package/dist/domain/entities/Dependency.js.map +1 -1
- package/dist/domain/repositories/CodeGraphRepository.d.ts +5 -0
- package/dist/domain/repositories/CodeGraphRepository.d.ts.map +1 -1
- package/dist/domain/repositories/CodeGraphRepository.js.map +1 -1
- package/dist/execution/contract-tools/analyze.d.ts +205 -0
- package/dist/execution/contract-tools/analyze.d.ts.map +1 -0
- package/dist/execution/contract-tools/analyze.js +1215 -0
- package/dist/execution/contract-tools/analyze.js.map +1 -0
- package/dist/execution/contract-tools/deps.d.ts +62 -0
- package/dist/execution/contract-tools/deps.d.ts.map +1 -0
- package/dist/execution/contract-tools/deps.js +234 -0
- package/dist/execution/contract-tools/deps.js.map +1 -0
- package/dist/execution/contract-tools/index.d.ts +5 -0
- package/dist/execution/contract-tools/index.d.ts.map +1 -0
- package/dist/execution/contract-tools/index.js +7 -0
- package/dist/execution/contract-tools/index.js.map +1 -0
- package/dist/execution/contract-tools/query.d.ts +60 -0
- package/dist/execution/contract-tools/query.d.ts.map +1 -0
- package/dist/execution/contract-tools/query.js +532 -0
- package/dist/execution/contract-tools/query.js.map +1 -0
- package/dist/execution/contract-tools/types.d.ts +26 -0
- package/dist/execution/contract-tools/types.d.ts.map +1 -0
- package/dist/execution/contract-tools/types.js +32 -0
- package/dist/execution/contract-tools/types.js.map +1 -0
- package/dist/generator/index.d.ts.map +1 -1
- package/dist/generator/index.js +0 -3
- package/dist/generator/index.js.map +1 -1
- package/dist/infrastructure/parser/enhancers/TypeScriptTypeEnhancer.d.ts +12 -0
- package/dist/infrastructure/parser/enhancers/TypeScriptTypeEnhancer.d.ts.map +1 -0
- package/dist/infrastructure/parser/enhancers/TypeScriptTypeEnhancer.js +55 -0
- package/dist/infrastructure/parser/enhancers/TypeScriptTypeEnhancer.js.map +1 -0
- package/dist/infrastructure/parser/implementations/GoParser.d.ts +2 -1
- package/dist/infrastructure/parser/implementations/GoParser.d.ts.map +1 -1
- package/dist/infrastructure/parser/implementations/GoParser.js +13 -1
- package/dist/infrastructure/parser/implementations/GoParser.js.map +1 -1
- package/dist/infrastructure/parser/implementations/PythonTreeSitterParser.d.ts +114 -0
- package/dist/infrastructure/parser/implementations/PythonTreeSitterParser.d.ts.map +1 -0
- package/dist/infrastructure/parser/implementations/PythonTreeSitterParser.js +1022 -0
- package/dist/infrastructure/parser/implementations/PythonTreeSitterParser.js.map +1 -0
- package/dist/infrastructure/parser/implementations/TreeSitterParser.d.ts +78 -0
- package/dist/infrastructure/parser/implementations/TreeSitterParser.d.ts.map +1 -0
- package/dist/infrastructure/parser/implementations/TreeSitterParser.js +648 -0
- package/dist/infrastructure/parser/implementations/TreeSitterParser.js.map +1 -0
- package/dist/infrastructure/parser/implementations/TypeScriptParser.d.ts +3 -55
- package/dist/infrastructure/parser/implementations/TypeScriptParser.d.ts.map +1 -1
- package/dist/infrastructure/parser/implementations/TypeScriptParser.js +4 -411
- package/dist/infrastructure/parser/implementations/TypeScriptParser.js.map +1 -1
- package/dist/infrastructure/parser/index.d.ts +2 -0
- package/dist/infrastructure/parser/index.d.ts.map +1 -1
- package/dist/infrastructure/parser/index.js +9 -6
- package/dist/infrastructure/parser/index.js.map +1 -1
- package/dist/infrastructure/parser/interfaces/ParserBase.d.ts.map +1 -1
- package/dist/infrastructure/parser/interfaces/ParserBase.js +1 -0
- package/dist/infrastructure/parser/interfaces/ParserBase.js.map +1 -1
- package/dist/infrastructure/repositories/CodeGraphRepositoryImpl.d.ts +2 -0
- package/dist/infrastructure/repositories/CodeGraphRepositoryImpl.d.ts.map +1 -1
- package/dist/infrastructure/repositories/CodeGraphRepositoryImpl.js +4 -0
- package/dist/infrastructure/repositories/CodeGraphRepositoryImpl.js.map +1 -1
- package/dist/infrastructure/storage/StorageFactory.d.ts +5 -18
- package/dist/infrastructure/storage/StorageFactory.d.ts.map +1 -1
- package/dist/infrastructure/storage/StorageFactory.js +30 -98
- package/dist/infrastructure/storage/StorageFactory.js.map +1 -1
- package/dist/infrastructure/storage/adapters/SQLiteStorage.d.ts +13 -1
- package/dist/infrastructure/storage/adapters/SQLiteStorage.d.ts.map +1 -1
- package/dist/infrastructure/storage/adapters/SQLiteStorage.js +321 -75
- package/dist/infrastructure/storage/adapters/SQLiteStorage.js.map +1 -1
- package/dist/infrastructure/storage/adapters/sqlite-loader.d.ts +22 -0
- package/dist/infrastructure/storage/adapters/sqlite-loader.d.ts.map +1 -1
- package/dist/infrastructure/storage/adapters/sqlite-loader.js +78 -22
- package/dist/infrastructure/storage/adapters/sqlite-loader.js.map +1 -1
- package/dist/infrastructure/storage/community-helpers.d.ts +4 -0
- package/dist/infrastructure/storage/community-helpers.d.ts.map +1 -0
- package/dist/infrastructure/storage/community-helpers.js +392 -0
- package/dist/infrastructure/storage/community-helpers.js.map +1 -0
- package/dist/infrastructure/storage/graph-helpers.d.ts +22 -5
- package/dist/infrastructure/storage/graph-helpers.d.ts.map +1 -1
- package/dist/infrastructure/storage/graph-helpers.js +496 -91
- package/dist/infrastructure/storage/graph-helpers.js.map +1 -1
- package/dist/infrastructure/storage/index.d.ts +1 -1
- package/dist/infrastructure/storage/index.d.ts.map +1 -1
- package/dist/infrastructure/storage/index.js +1 -1
- package/dist/infrastructure/storage/index.js.map +1 -1
- package/dist/infrastructure/storage/interfaces/StorageBase.d.ts +2 -2
- package/dist/infrastructure/storage/interfaces/StorageBase.d.ts.map +1 -1
- package/dist/infrastructure/storage/interfaces/StorageBase.js.map +1 -1
- package/dist/infrastructure/storage/sqlite/GovernanceGraphCache.d.ts +2 -0
- package/dist/infrastructure/storage/sqlite/GovernanceGraphCache.d.ts.map +1 -1
- package/dist/infrastructure/storage/sqlite/GovernanceGraphCache.js +52 -12
- package/dist/infrastructure/storage/sqlite/GovernanceGraphCache.js.map +1 -1
- package/dist/infrastructure/storage/sqlite/schema.d.ts +2 -2
- package/dist/infrastructure/storage/sqlite/schema.d.ts.map +1 -1
- package/dist/infrastructure/storage/sqlite/schema.js +49 -1
- package/dist/infrastructure/storage/sqlite/schema.js.map +1 -1
- package/dist/interface/config/index.d.ts +5 -3
- package/dist/interface/config/index.d.ts.map +1 -1
- package/dist/interface/types/index.d.ts +37 -6
- package/dist/interface/types/index.d.ts.map +1 -1
- package/dist/interface/types/parser.d.ts +85 -0
- package/dist/interface/types/parser.d.ts.map +1 -1
- package/dist/interface/types/storage.d.ts +227 -10
- package/dist/interface/types/storage.d.ts.map +1 -1
- package/dist/orchestrator/agent-metrics-service.d.ts +126 -0
- package/dist/orchestrator/agent-metrics-service.d.ts.map +1 -0
- package/dist/orchestrator/agent-metrics-service.js +444 -0
- package/dist/orchestrator/agent-metrics-service.js.map +1 -0
- package/dist/parser/enhancers/PythonTypeEnhancer.d.ts +26 -0
- package/dist/parser/enhancers/PythonTypeEnhancer.d.ts.map +1 -0
- package/dist/parser/enhancers/PythonTypeEnhancer.js +440 -0
- package/dist/parser/enhancers/PythonTypeEnhancer.js.map +1 -0
- package/dist/parser/implementations/smart-parser.d.ts.map +1 -1
- package/dist/parser/implementations/smart-parser.js +7 -69
- package/dist/parser/implementations/smart-parser.js.map +1 -1
- package/dist/parser/implementations/tree-sitter-loader.d.ts +2 -0
- package/dist/parser/implementations/tree-sitter-loader.d.ts.map +1 -1
- package/dist/parser/implementations/tree-sitter-loader.js +46 -15
- package/dist/parser/implementations/tree-sitter-loader.js.map +1 -1
- package/dist/parser/index.d.ts +5 -3
- package/dist/parser/index.d.ts.map +1 -1
- package/dist/parser/index.js +68 -6
- package/dist/parser/index.js.map +1 -1
- package/dist/parser/interfaces/IParser.d.ts +19 -6
- package/dist/parser/interfaces/IParser.d.ts.map +1 -1
- package/dist/parser/interfaces/IParser.js +2 -3
- package/dist/parser/interfaces/IParser.js.map +1 -1
- package/dist/server/handlers/AnalysisHandler.d.ts +13 -2
- package/dist/server/handlers/AnalysisHandler.d.ts.map +1 -1
- package/dist/server/handlers/AnalysisHandler.js +24 -0
- package/dist/server/handlers/AnalysisHandler.js.map +1 -1
- package/dist/server/handlers/QueryHandler.d.ts.map +1 -1
- package/dist/server/handlers/QueryHandler.js +11 -30
- package/dist/server/handlers/QueryHandler.js.map +1 -1
- package/dist/server/mcp/context-tool.d.ts +9 -0
- package/dist/server/mcp/context-tool.d.ts.map +1 -0
- package/dist/server/mcp/context-tool.js +257 -0
- package/dist/server/mcp/context-tool.js.map +1 -0
- package/dist/server/mcp/schema-adapter.d.ts +11 -1
- package/dist/server/mcp/schema-adapter.d.ts.map +1 -1
- package/dist/server/mcp/schema-adapter.js +126 -7
- package/dist/server/mcp/schema-adapter.js.map +1 -1
- package/dist/server/mcp/server.d.ts +3 -3
- package/dist/server/mcp/server.d.ts.map +1 -1
- package/dist/server/mcp/server.js +114 -30
- package/dist/server/mcp/server.js.map +1 -1
- package/dist/server/mcp/service.d.ts +6 -2
- package/dist/server/mcp/service.d.ts.map +1 -1
- package/dist/server/mcp/service.js +138 -36
- package/dist/server/mcp/service.js.map +1 -1
- package/dist/server/mcp/stdio-transport.d.ts +23 -0
- package/dist/server/mcp/stdio-transport.d.ts.map +1 -0
- package/dist/server/mcp/stdio-transport.js +101 -0
- package/dist/server/mcp/stdio-transport.js.map +1 -0
- package/dist/server/mcp/types.d.ts +133 -8
- package/dist/server/mcp/types.d.ts.map +1 -1
- package/dist/server/routes/api.d.ts.map +1 -1
- package/dist/server/routes/api.js +11 -2
- package/dist/server/routes/api.js.map +1 -1
- package/docs/AI_ASSISTANT_SETUP.md +112 -0
- package/docs/API.md +170 -0
- package/docs/CONFIGURATION.md +141 -0
- package/docs/DEVELOPMENT.md +96 -0
- package/docs/GETTING-STARTED.md +114 -0
- package/docs/SETUP_GUIDE.md +49 -0
- package/docs/TESTING.md +81 -0
- package/docs/ai-guide/OUTPUT.md +51 -8
- package/docs/backlog.md +232 -144
- package/docs/brainstorms/2026-05-10-agent-effectiveness-validation-requirements.md +112 -0
- package/docs/generated/phase-58/subagent-evidence/claude-hook-example.json +15 -0
- package/docs/generated/phase-58/subagent-evidence/claude-session.md +146 -0
- package/docs/generated/phase-58/subagent-evidence/claude-subagent.json +28 -0
- package/docs/generated/phase-58/subagent-evidence/codex-agent-example.toml +19 -0
- package/docs/generated/phase-58/subagent-evidence/codex-session.md +150 -0
- package/docs/generated/phase-58/subagent-evidence/codex-subagent.json +20 -0
- package/docs/generated/phase-58/subagent-evidence/negative-no-retrieval.json +12 -0
- package/docs/generated/phase-58/subagent-evidence/verification-manifest.json +19 -0
- package/docs/ideation/2026-05-02-subagent-environment-contract-injection-ideation.md +183 -0
- package/docs/ideation/2026-05-04-subagent-hooks-deep-dive-ideation.md +133 -0
- package/docs/ideation/2026-05-10-agent-effectiveness-validation-ideation.md +219 -0
- package/package.json +8 -3
- package/scripts/copy-build-assets.mjs +23 -0
- package/scripts/hooks/templates/pre-commit +33 -2
- package/scripts/tests/test_rule_control_workflow.py +15 -1
- package/scripts/verify-subagent-env-contract.mjs +279 -0
- package/dist/parser/implementations/tree-sitter-parser.d.ts +0 -60
- package/dist/parser/implementations/tree-sitter-parser.d.ts.map +0 -1
- package/dist/parser/implementations/tree-sitter-parser.js +0 -380
- package/dist/parser/implementations/tree-sitter-parser.js.map +0 -1
|
@@ -0,0 +1,648 @@
|
|
|
1
|
+
// [META] since:2026-05 | owner:parser-team | stable:false
|
|
2
|
+
// [WHY] Shared Tree-sitter parser now lives in Infrastructure and provides TS/JS active parsing plus shared AST helpers for Python
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { randomUUID } from 'crypto';
|
|
5
|
+
import { analyzeComplexityFromContent } from '../../../core/ast-complexity-analyzer.js';
|
|
6
|
+
import { loadTreeSitter } from '../../../parser/implementations/tree-sitter-loader.js';
|
|
7
|
+
import { ParserBase } from '../interfaces/ParserBase.js';
|
|
8
|
+
const EXTENSION_LANGUAGE_MAP = {
|
|
9
|
+
ts: { grammar: 'typescript', language: 'typescript' },
|
|
10
|
+
tsx: { grammar: 'tsx', language: 'typescript' },
|
|
11
|
+
js: { grammar: 'tsx', language: 'javascript' },
|
|
12
|
+
jsx: { grammar: 'tsx', language: 'javascript' },
|
|
13
|
+
mjs: { grammar: 'tsx', language: 'javascript' },
|
|
14
|
+
cjs: { grammar: 'tsx', language: 'javascript' },
|
|
15
|
+
py: { grammar: 'python', language: 'python' },
|
|
16
|
+
};
|
|
17
|
+
export class TreeSitterParser extends ParserBase {
|
|
18
|
+
languageId = 'typescript';
|
|
19
|
+
fileExtensions = ['ts', 'tsx', 'js', 'jsx', 'mjs', 'cjs'];
|
|
20
|
+
name = 'TreeSitterParser';
|
|
21
|
+
supportedFeatures = new Set([
|
|
22
|
+
'type-inference',
|
|
23
|
+
'generic-types',
|
|
24
|
+
'decorators',
|
|
25
|
+
'call-graph',
|
|
26
|
+
'cross-file-analysis',
|
|
27
|
+
'complexity-metrics',
|
|
28
|
+
]);
|
|
29
|
+
parser;
|
|
30
|
+
grammars = null;
|
|
31
|
+
parserPromise = null;
|
|
32
|
+
constructor(_options) {
|
|
33
|
+
super();
|
|
34
|
+
}
|
|
35
|
+
async doInitialize() {
|
|
36
|
+
await this.getParserPromise();
|
|
37
|
+
}
|
|
38
|
+
async doDispose() { }
|
|
39
|
+
async initializeParser() {
|
|
40
|
+
const { Parser, TypeScript, Python } = await loadTreeSitter();
|
|
41
|
+
this.parser = new Parser();
|
|
42
|
+
this.grammars = {
|
|
43
|
+
typescript: TypeScript.typescript,
|
|
44
|
+
tsx: TypeScript.tsx ?? TypeScript.typescript,
|
|
45
|
+
python: Python,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
async parseFile(filePath, content, options) {
|
|
49
|
+
this.ensureInitialized();
|
|
50
|
+
const startTime = Date.now();
|
|
51
|
+
const parsed = await this.parseContent(filePath, content);
|
|
52
|
+
const module = {
|
|
53
|
+
id: `mod_${randomUUID().replace(/-/g, '').slice(0, 16)}`,
|
|
54
|
+
projectId: '',
|
|
55
|
+
path: filePath,
|
|
56
|
+
language: parsed.language,
|
|
57
|
+
stats: parsed.stats,
|
|
58
|
+
};
|
|
59
|
+
return {
|
|
60
|
+
filePath,
|
|
61
|
+
language: parsed.language,
|
|
62
|
+
module,
|
|
63
|
+
symbols: parsed.symbols,
|
|
64
|
+
imports: parsed.imports,
|
|
65
|
+
exports: parsed.exports,
|
|
66
|
+
dependencies: this.buildDependencies(parsed.imports),
|
|
67
|
+
callGraph: options?.includeCallGraph ? await this.buildCallGraph(content) : undefined,
|
|
68
|
+
complexity: options?.includeComplexity ? await this.calculateComplexity(content, filePath) : undefined,
|
|
69
|
+
parseTime: Date.now() - startTime,
|
|
70
|
+
parserUsed: parsed.parserUsed,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
async parseContent(filePath, content) {
|
|
74
|
+
const syntaxTree = await this.parseSyntaxTree(filePath, content);
|
|
75
|
+
const { rootNode, language } = syntaxTree;
|
|
76
|
+
if (language === 'python') {
|
|
77
|
+
return {
|
|
78
|
+
filePath,
|
|
79
|
+
language,
|
|
80
|
+
parserUsed: 'TreeSitterParser',
|
|
81
|
+
imports: this.extractPythonImports(rootNode),
|
|
82
|
+
exports: this.extractPythonExports(rootNode),
|
|
83
|
+
symbols: this.extractPythonSymbols(rootNode, filePath),
|
|
84
|
+
dependencies: this.extractDependencies(this.extractPythonImports(rootNode)),
|
|
85
|
+
type: this.detectModuleType(filePath),
|
|
86
|
+
stats: this.calculateStats(content, rootNode),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
const imports = this.extractTypeScriptImports(rootNode);
|
|
90
|
+
return {
|
|
91
|
+
filePath,
|
|
92
|
+
language,
|
|
93
|
+
parserUsed: 'TreeSitterParser',
|
|
94
|
+
imports,
|
|
95
|
+
exports: this.extractTypeScriptExports(rootNode),
|
|
96
|
+
symbols: this.extractTypeScriptSymbols(rootNode, filePath),
|
|
97
|
+
dependencies: this.extractDependencies(imports),
|
|
98
|
+
type: this.detectModuleType(filePath),
|
|
99
|
+
stats: this.calculateStats(content, rootNode),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
async parseSyntaxTree(filePath, content) {
|
|
103
|
+
await this.getParserPromise();
|
|
104
|
+
const selection = this.selectLanguage(filePath);
|
|
105
|
+
this.parser.setLanguage(selection.grammar);
|
|
106
|
+
const tree = this.parser.parse(content);
|
|
107
|
+
return {
|
|
108
|
+
filePath,
|
|
109
|
+
content,
|
|
110
|
+
language: selection.language,
|
|
111
|
+
parserUsed: 'TreeSitterParser',
|
|
112
|
+
tree,
|
|
113
|
+
rootNode: tree.rootNode,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
getParserPromise() {
|
|
117
|
+
if (!this.parserPromise) {
|
|
118
|
+
this.parserPromise = this.initializeParser();
|
|
119
|
+
}
|
|
120
|
+
return this.parserPromise;
|
|
121
|
+
}
|
|
122
|
+
async extractImports(content) {
|
|
123
|
+
this.ensureInitialized();
|
|
124
|
+
const shared = await this.parseContent('/virtual.ts', content);
|
|
125
|
+
return shared.imports;
|
|
126
|
+
}
|
|
127
|
+
async extractExports(content) {
|
|
128
|
+
this.ensureInitialized();
|
|
129
|
+
const shared = await this.parseContent('/virtual.ts', content);
|
|
130
|
+
return shared.exports;
|
|
131
|
+
}
|
|
132
|
+
async extractSymbols(content) {
|
|
133
|
+
this.ensureInitialized();
|
|
134
|
+
const shared = await this.parseContent('/virtual.ts', content);
|
|
135
|
+
return shared.symbols;
|
|
136
|
+
}
|
|
137
|
+
async buildCallGraph(content) {
|
|
138
|
+
const calls = [];
|
|
139
|
+
const calledFunctions = new Set();
|
|
140
|
+
const callRegex = /(\w+)\s*\(/g;
|
|
141
|
+
let match;
|
|
142
|
+
while ((match = callRegex.exec(content)) !== null) {
|
|
143
|
+
const callee = match[1];
|
|
144
|
+
if (callee && !this.isKeyword(callee)) {
|
|
145
|
+
calledFunctions.add(callee);
|
|
146
|
+
calls.push({
|
|
147
|
+
caller: '<anonymous>',
|
|
148
|
+
callee,
|
|
149
|
+
line: this.getLineNumber(content, match.index),
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
const recursive = [];
|
|
154
|
+
const functionRegex = /(?:async\s+)?function\s+(\w+)/g;
|
|
155
|
+
while ((match = functionRegex.exec(content)) !== null) {
|
|
156
|
+
const funcName = match[1];
|
|
157
|
+
if (!funcName || !calledFunctions.has(funcName)) {
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
const funcBody = content.slice(match.index, this.findFunctionEnd(content, match.index));
|
|
161
|
+
if (new RegExp(`\\b${funcName}\\s*\\(`, 'g').test(funcBody)) {
|
|
162
|
+
recursive.push(funcName);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return { calls, recursive, issues: [] };
|
|
166
|
+
}
|
|
167
|
+
async calculateComplexity(content, filePath = '/virtual.ts') {
|
|
168
|
+
const language = this.selectLanguage(filePath).language;
|
|
169
|
+
return analyzeComplexityFromContent({
|
|
170
|
+
filePath,
|
|
171
|
+
content,
|
|
172
|
+
language,
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
selectLanguage(filePath) {
|
|
176
|
+
const extension = path.extname(filePath).slice(1).toLowerCase();
|
|
177
|
+
const selection = EXTENSION_LANGUAGE_MAP[extension];
|
|
178
|
+
if (!selection || !this.grammars) {
|
|
179
|
+
throw new Error(`Unsupported tree-sitter language for file: ${filePath}`);
|
|
180
|
+
}
|
|
181
|
+
const grammar = this.grammars[selection.grammar];
|
|
182
|
+
if (!grammar) {
|
|
183
|
+
throw new Error(`Tree-sitter grammar not available for .${extension}`);
|
|
184
|
+
}
|
|
185
|
+
return { grammar, language: selection.language };
|
|
186
|
+
}
|
|
187
|
+
extractTypeScriptImports(root) {
|
|
188
|
+
const imports = [];
|
|
189
|
+
const importNodes = root.namedChildren.filter((node) => node.type === 'import_statement');
|
|
190
|
+
for (const importNode of importNodes) {
|
|
191
|
+
const stringLiteral = importNode.namedChildren.find((node) => node.type === 'string');
|
|
192
|
+
const source = stringLiteral?.text.replace(/['"]/g, '') || '';
|
|
193
|
+
const importClause = importNode.namedChildren.find((node) => node.type === 'import_clause');
|
|
194
|
+
const specifiers = [];
|
|
195
|
+
if (importClause) {
|
|
196
|
+
const namedImports = importClause.namedChildren.filter((node) => node.type === 'named_imports');
|
|
197
|
+
for (const named of namedImports) {
|
|
198
|
+
const specifierList = named.namedChildren.filter((node) => node.type === 'import_specifier');
|
|
199
|
+
for (const spec of specifierList) {
|
|
200
|
+
const name = spec.namedChildren[0];
|
|
201
|
+
specifiers.push({
|
|
202
|
+
name: name?.text || '',
|
|
203
|
+
alias: spec.namedChildren[1]?.text,
|
|
204
|
+
isTypeOnly: false,
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
const defaultImport = importClause.namedChildren.find((node) => node.type === 'identifier');
|
|
209
|
+
if (defaultImport) {
|
|
210
|
+
specifiers.push({
|
|
211
|
+
name: defaultImport.text,
|
|
212
|
+
isTypeOnly: false,
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
const namespaceImport = importClause.namedChildren.find((node) => node.type === 'namespace_import');
|
|
216
|
+
if (namespaceImport) {
|
|
217
|
+
const alias = namespaceImport.namedChildren[0];
|
|
218
|
+
specifiers.push({
|
|
219
|
+
name: alias?.text || '*',
|
|
220
|
+
isTypeOnly: false,
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
if (specifiers.length > 0 || source) {
|
|
225
|
+
imports.push({
|
|
226
|
+
source,
|
|
227
|
+
sourceType: this.classifyImportSource(source),
|
|
228
|
+
specifiers,
|
|
229
|
+
isTypeOnly: false,
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return imports;
|
|
234
|
+
}
|
|
235
|
+
extractTypeScriptExports(root) {
|
|
236
|
+
const exports = [];
|
|
237
|
+
const exportNodes = root.namedChildren.filter((node) => node.type === 'export_statement');
|
|
238
|
+
for (const exportNode of exportNodes) {
|
|
239
|
+
for (const child of exportNode.namedChildren) {
|
|
240
|
+
switch (child.type) {
|
|
241
|
+
case 'named_exports': {
|
|
242
|
+
const specifiers = child.namedChildren.filter((node) => node.type === 'export_specifier');
|
|
243
|
+
for (const spec of specifiers) {
|
|
244
|
+
const name = spec.namedChildren[0];
|
|
245
|
+
exports.push({
|
|
246
|
+
name: name?.text || '',
|
|
247
|
+
kind: 'function',
|
|
248
|
+
isDefault: false,
|
|
249
|
+
isTypeOnly: false,
|
|
250
|
+
origin: spec.namedChildren[1]?.text,
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
break;
|
|
254
|
+
}
|
|
255
|
+
case 'class_declaration': {
|
|
256
|
+
const className = child.namedChildren.find((node) => node.type === 'type_identifier');
|
|
257
|
+
if (className) {
|
|
258
|
+
exports.push({ name: className.text, kind: 'class', isDefault: false, isTypeOnly: false });
|
|
259
|
+
}
|
|
260
|
+
break;
|
|
261
|
+
}
|
|
262
|
+
case 'function_declaration': {
|
|
263
|
+
const funcName = child.namedChildren.find((node) => node.type === 'identifier');
|
|
264
|
+
if (funcName) {
|
|
265
|
+
exports.push({ name: funcName.text, kind: 'function', isDefault: false, isTypeOnly: false });
|
|
266
|
+
}
|
|
267
|
+
break;
|
|
268
|
+
}
|
|
269
|
+
case 'variable_declaration': {
|
|
270
|
+
const variables = child.namedChildren.filter((node) => node.type === 'variable_declarator');
|
|
271
|
+
for (const variable of variables) {
|
|
272
|
+
const varName = variable.namedChildren[0];
|
|
273
|
+
exports.push({
|
|
274
|
+
name: varName?.text || '',
|
|
275
|
+
kind: 'type',
|
|
276
|
+
isDefault: false,
|
|
277
|
+
isTypeOnly: false,
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
break;
|
|
281
|
+
}
|
|
282
|
+
case 'interface_declaration': {
|
|
283
|
+
const ifaceName = child.namedChildren.find((node) => node.type === 'type_identifier');
|
|
284
|
+
if (ifaceName) {
|
|
285
|
+
exports.push({ name: ifaceName.text, kind: 'interface', isDefault: false, isTypeOnly: false });
|
|
286
|
+
}
|
|
287
|
+
break;
|
|
288
|
+
}
|
|
289
|
+
case 'type_alias_declaration': {
|
|
290
|
+
const typeName = child.namedChildren.find((node) => node.type === 'type_identifier');
|
|
291
|
+
if (typeName) {
|
|
292
|
+
exports.push({ name: typeName.text, kind: 'type', isDefault: false, isTypeOnly: false });
|
|
293
|
+
}
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
case 'enum_declaration': {
|
|
297
|
+
const enumName = child.namedChildren.find((node) => node.type === 'identifier');
|
|
298
|
+
if (enumName) {
|
|
299
|
+
exports.push({ name: enumName.text, kind: 'enum', isDefault: false, isTypeOnly: false });
|
|
300
|
+
}
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
const defaultExport = exportNode.namedChildren.find((node) => node.type === 'default');
|
|
306
|
+
if (defaultExport) {
|
|
307
|
+
exports.push({
|
|
308
|
+
name: 'default',
|
|
309
|
+
kind: 'function',
|
|
310
|
+
isDefault: true,
|
|
311
|
+
isTypeOnly: false,
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
return exports;
|
|
316
|
+
}
|
|
317
|
+
extractTypeScriptSymbols(root, filePath) {
|
|
318
|
+
const symbols = [];
|
|
319
|
+
const declarations = this.findTypeScriptDeclarations(root);
|
|
320
|
+
for (const decl of declarations) {
|
|
321
|
+
symbols.push({
|
|
322
|
+
id: `${decl.name}-${decl.node.startPosition.row}`,
|
|
323
|
+
name: decl.name,
|
|
324
|
+
kind: decl.kind,
|
|
325
|
+
location: {
|
|
326
|
+
file: filePath,
|
|
327
|
+
line: decl.node.startPosition.row + 1,
|
|
328
|
+
column: decl.node.startPosition.column,
|
|
329
|
+
},
|
|
330
|
+
visibility: 'public',
|
|
331
|
+
relatedSymbols: [],
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
return symbols;
|
|
335
|
+
}
|
|
336
|
+
findTypeScriptDeclarations(node) {
|
|
337
|
+
const declarations = [];
|
|
338
|
+
if (node.type === 'class_declaration') {
|
|
339
|
+
const name = node.namedChildren.find((child) => child.type === 'type_identifier');
|
|
340
|
+
if (name)
|
|
341
|
+
declarations.push({ name: name.text, kind: 'class', node });
|
|
342
|
+
}
|
|
343
|
+
if (node.type === 'function_declaration') {
|
|
344
|
+
const name = node.namedChildren.find((child) => child.type === 'identifier');
|
|
345
|
+
if (name)
|
|
346
|
+
declarations.push({ name: name.text, kind: 'function', node });
|
|
347
|
+
}
|
|
348
|
+
if (node.type === 'interface_declaration') {
|
|
349
|
+
const name = node.namedChildren.find((child) => child.type === 'type_identifier');
|
|
350
|
+
if (name)
|
|
351
|
+
declarations.push({ name: name.text, kind: 'interface', node });
|
|
352
|
+
}
|
|
353
|
+
if (node.type === 'type_alias_declaration') {
|
|
354
|
+
const name = node.namedChildren.find((child) => child.type === 'type_identifier');
|
|
355
|
+
if (name)
|
|
356
|
+
declarations.push({ name: name.text, kind: 'type', node });
|
|
357
|
+
}
|
|
358
|
+
if (node.type === 'enum_declaration') {
|
|
359
|
+
const name = node.namedChildren.find((child) => child.type === 'identifier');
|
|
360
|
+
if (name)
|
|
361
|
+
declarations.push({ name: name.text, kind: 'enum', node });
|
|
362
|
+
}
|
|
363
|
+
if (node.type === 'variable_declarator') {
|
|
364
|
+
const name = node.namedChildren[0];
|
|
365
|
+
if (name && name.type === 'identifier') {
|
|
366
|
+
declarations.push({ name: name.text, kind: 'variable', node });
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
for (const child of node.namedChildren) {
|
|
370
|
+
declarations.push(...this.findTypeScriptDeclarations(child));
|
|
371
|
+
}
|
|
372
|
+
return declarations;
|
|
373
|
+
}
|
|
374
|
+
extractPythonImports(root) {
|
|
375
|
+
const imports = [];
|
|
376
|
+
for (const child of root.namedChildren) {
|
|
377
|
+
if (child.type === 'import_statement') {
|
|
378
|
+
imports.push(...this.parsePythonImportStatement(child));
|
|
379
|
+
}
|
|
380
|
+
else if (child.type === 'import_from_statement') {
|
|
381
|
+
imports.push(...this.parsePythonImportFromStatement(child));
|
|
382
|
+
}
|
|
383
|
+
else if (child.type === 'future_import_statement') {
|
|
384
|
+
imports.push(...this.parsePythonFutureImportStatement(child));
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
return imports;
|
|
388
|
+
}
|
|
389
|
+
parsePythonImportStatement(node) {
|
|
390
|
+
const nameField = node.childForFieldName('name');
|
|
391
|
+
if (!nameField)
|
|
392
|
+
return [];
|
|
393
|
+
const specifiers = this.extractPythonImportSpecifiers(nameField);
|
|
394
|
+
if (specifiers.length === 0)
|
|
395
|
+
return [];
|
|
396
|
+
return [{
|
|
397
|
+
source: specifiers[0].name,
|
|
398
|
+
sourceType: specifiers[0].name.startsWith('.') ? 'relative' : 'absolute',
|
|
399
|
+
specifiers,
|
|
400
|
+
isTypeOnly: false,
|
|
401
|
+
}];
|
|
402
|
+
}
|
|
403
|
+
parsePythonImportFromStatement(node) {
|
|
404
|
+
const moduleName = node.childForFieldName('module_name');
|
|
405
|
+
let source = '';
|
|
406
|
+
let sourceType = 'absolute';
|
|
407
|
+
if (moduleName) {
|
|
408
|
+
source = moduleName.text;
|
|
409
|
+
sourceType = source.startsWith('.') ? 'relative' : 'absolute';
|
|
410
|
+
}
|
|
411
|
+
const specifiers = [];
|
|
412
|
+
for (let i = 1; i < node.namedChildren.length; i++) {
|
|
413
|
+
const child = node.namedChildren[i];
|
|
414
|
+
if (child.type === 'dotted_name' || child.type === 'identifier') {
|
|
415
|
+
specifiers.push({ name: child.text, isTypeOnly: false });
|
|
416
|
+
}
|
|
417
|
+
else if (child.type === 'aliased_import') {
|
|
418
|
+
specifiers.push({
|
|
419
|
+
name: child.childForFieldName('name')?.text || '',
|
|
420
|
+
alias: child.childForFieldName('alias')?.text,
|
|
421
|
+
isTypeOnly: false,
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
else if (child.type === 'wildcard_import') {
|
|
425
|
+
specifiers.push({ name: '*', isTypeOnly: false });
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
if (specifiers.length === 0 && !source)
|
|
429
|
+
return [];
|
|
430
|
+
return [{ source, sourceType, specifiers, isTypeOnly: false }];
|
|
431
|
+
}
|
|
432
|
+
parsePythonFutureImportStatement(node) {
|
|
433
|
+
const specifiers = node.namedChildren
|
|
434
|
+
.filter((child) => child.type === 'identifier')
|
|
435
|
+
.map((child) => ({ name: child.text, isTypeOnly: false }));
|
|
436
|
+
return [{
|
|
437
|
+
source: '__future__',
|
|
438
|
+
sourceType: 'absolute',
|
|
439
|
+
specifiers,
|
|
440
|
+
isTypeOnly: false,
|
|
441
|
+
}];
|
|
442
|
+
}
|
|
443
|
+
extractPythonImportSpecifiers(nameNode) {
|
|
444
|
+
if (nameNode.type === 'dotted_name' || nameNode.type === 'identifier') {
|
|
445
|
+
return [{ name: nameNode.text, isTypeOnly: false }];
|
|
446
|
+
}
|
|
447
|
+
if (nameNode.type === 'aliased_import') {
|
|
448
|
+
return [{
|
|
449
|
+
name: nameNode.childForFieldName('name')?.text || '',
|
|
450
|
+
alias: nameNode.childForFieldName('alias')?.text,
|
|
451
|
+
isTypeOnly: false,
|
|
452
|
+
}];
|
|
453
|
+
}
|
|
454
|
+
return nameNode.namedChildren.flatMap((child) => this.extractPythonImportSpecifiers(child));
|
|
455
|
+
}
|
|
456
|
+
extractPythonExports(root) {
|
|
457
|
+
const explicitExports = this.extractPythonAllExports(root);
|
|
458
|
+
if (explicitExports.length > 0) {
|
|
459
|
+
return explicitExports.map((name) => ({
|
|
460
|
+
name,
|
|
461
|
+
kind: 'variable',
|
|
462
|
+
isDefault: false,
|
|
463
|
+
isTypeOnly: false,
|
|
464
|
+
}));
|
|
465
|
+
}
|
|
466
|
+
const exports = [];
|
|
467
|
+
for (const child of root.namedChildren) {
|
|
468
|
+
if (child.type === 'class_definition' || child.type === 'function_definition') {
|
|
469
|
+
const nameNode = child.childForFieldName('name');
|
|
470
|
+
if (nameNode && !nameNode.text.startsWith('_')) {
|
|
471
|
+
exports.push({
|
|
472
|
+
name: nameNode.text,
|
|
473
|
+
kind: child.type === 'class_definition' ? 'class' : 'function',
|
|
474
|
+
isDefault: false,
|
|
475
|
+
isTypeOnly: false,
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
else if (child.type === 'decorated_definition') {
|
|
480
|
+
const definition = child.namedChildren.find((node) => node.type === 'class_definition' || node.type === 'function_definition');
|
|
481
|
+
const nameNode = definition?.childForFieldName('name');
|
|
482
|
+
if (definition && nameNode && !nameNode.text.startsWith('_')) {
|
|
483
|
+
exports.push({
|
|
484
|
+
name: nameNode.text,
|
|
485
|
+
kind: definition.type === 'class_definition' ? 'class' : 'function',
|
|
486
|
+
isDefault: false,
|
|
487
|
+
isTypeOnly: false,
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
return exports;
|
|
493
|
+
}
|
|
494
|
+
extractPythonAllExports(root) {
|
|
495
|
+
const assignment = root.namedChildren.find((child) => child.type === 'expression_statement' && child.text.includes('__all__'));
|
|
496
|
+
if (!assignment)
|
|
497
|
+
return [];
|
|
498
|
+
return Array.from(assignment.text.matchAll(/['"]([^'"]+)['"]/g)).map((match) => match[1] || '');
|
|
499
|
+
}
|
|
500
|
+
extractPythonSymbols(root, filePath) {
|
|
501
|
+
const symbols = [];
|
|
502
|
+
const visit = (node, decorators = []) => {
|
|
503
|
+
if (node.type === 'decorated_definition') {
|
|
504
|
+
const decoratorNodes = node.namedChildren.filter((child) => child.type === 'decorator');
|
|
505
|
+
const nextDecorators = decoratorNodes.map((child) => ({
|
|
506
|
+
name: child.text.replace(/^@/, '').split('(')[0] || child.text,
|
|
507
|
+
target: 'class',
|
|
508
|
+
}));
|
|
509
|
+
const definition = node.namedChildren.find((child) => child.type === 'class_definition' || child.type === 'function_definition');
|
|
510
|
+
if (definition)
|
|
511
|
+
visit(definition, nextDecorators);
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
514
|
+
if (node.type === 'class_definition' || node.type === 'function_definition') {
|
|
515
|
+
const nameNode = node.childForFieldName('name');
|
|
516
|
+
if (nameNode) {
|
|
517
|
+
const kind = node.type === 'class_definition' ? 'class' : 'function';
|
|
518
|
+
const signature = kind === 'function'
|
|
519
|
+
? {
|
|
520
|
+
parameters: [],
|
|
521
|
+
returnType: 'Any',
|
|
522
|
+
async: node.text.startsWith('async def '),
|
|
523
|
+
}
|
|
524
|
+
: undefined;
|
|
525
|
+
symbols.push({
|
|
526
|
+
id: `${nameNode.text}-${node.startPosition.row}`,
|
|
527
|
+
name: nameNode.text,
|
|
528
|
+
kind,
|
|
529
|
+
location: {
|
|
530
|
+
file: filePath,
|
|
531
|
+
line: node.startPosition.row + 1,
|
|
532
|
+
column: node.startPosition.column,
|
|
533
|
+
},
|
|
534
|
+
visibility: nameNode.text.startsWith('_') ? 'internal' : 'public',
|
|
535
|
+
relatedSymbols: [],
|
|
536
|
+
decorators: decorators.length > 0 ? decorators : undefined,
|
|
537
|
+
signature,
|
|
538
|
+
...(kind === 'class' ? { extends: this.extractPythonClassBases(node) } : {}),
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
for (const child of node.namedChildren ?? []) {
|
|
543
|
+
visit(child, []);
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
for (const child of root.namedChildren) {
|
|
547
|
+
visit(child);
|
|
548
|
+
}
|
|
549
|
+
return symbols;
|
|
550
|
+
}
|
|
551
|
+
extractPythonClassBases(node) {
|
|
552
|
+
const superclasses = node.childForFieldName('superclasses');
|
|
553
|
+
if (!superclasses)
|
|
554
|
+
return [];
|
|
555
|
+
return superclasses.namedChildren
|
|
556
|
+
.filter((child) => child.type === 'identifier' || child.type === 'attribute')
|
|
557
|
+
.map((child) => child.text);
|
|
558
|
+
}
|
|
559
|
+
extractDependencies(imports) {
|
|
560
|
+
const deps = new Set();
|
|
561
|
+
for (const imp of imports) {
|
|
562
|
+
if (!imp.source.startsWith('.')) {
|
|
563
|
+
deps.add(imp.source);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
return Array.from(deps);
|
|
567
|
+
}
|
|
568
|
+
detectModuleType(filePath) {
|
|
569
|
+
const basename = path.basename(filePath);
|
|
570
|
+
if (basename.includes('.test.') || basename.includes('.spec.'))
|
|
571
|
+
return 'test';
|
|
572
|
+
if (basename.startsWith('.') || basename.endsWith('.config.') || basename.endsWith('.config.ts'))
|
|
573
|
+
return 'config';
|
|
574
|
+
if (basename.includes('.d.ts') || basename.includes('.types.'))
|
|
575
|
+
return 'type';
|
|
576
|
+
return 'source';
|
|
577
|
+
}
|
|
578
|
+
calculateStats(content, root) {
|
|
579
|
+
const lines = content.split('\n');
|
|
580
|
+
const commentLines = new Set();
|
|
581
|
+
for (const comment of this.findCommentNodes(root)) {
|
|
582
|
+
for (let i = comment.startPosition.row; i <= comment.endPosition.row; i++) {
|
|
583
|
+
commentLines.add(i);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
const blankLines = lines.filter((line) => line.trim() === '').length;
|
|
587
|
+
return {
|
|
588
|
+
lines: lines.length,
|
|
589
|
+
codeLines: lines.length - commentLines.size - blankLines,
|
|
590
|
+
commentLines: commentLines.size,
|
|
591
|
+
blankLines,
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
findCommentNodes(node) {
|
|
595
|
+
const comments = [];
|
|
596
|
+
if (node.type === 'comment')
|
|
597
|
+
comments.push(node);
|
|
598
|
+
for (const child of node.children) {
|
|
599
|
+
comments.push(...this.findCommentNodes(child));
|
|
600
|
+
}
|
|
601
|
+
return comments;
|
|
602
|
+
}
|
|
603
|
+
classifyImportSource(source) {
|
|
604
|
+
if (source.startsWith('.'))
|
|
605
|
+
return 'relative';
|
|
606
|
+
if (source.startsWith('@'))
|
|
607
|
+
return 'alias';
|
|
608
|
+
return 'node_module';
|
|
609
|
+
}
|
|
610
|
+
buildDependencies(imports) {
|
|
611
|
+
return imports.map((imp) => ({
|
|
612
|
+
id: `dep_${randomUUID().replace(/-/g, '').slice(0, 16)}`,
|
|
613
|
+
sourceId: '',
|
|
614
|
+
targetId: '',
|
|
615
|
+
type: 'import',
|
|
616
|
+
filePath: imp.source,
|
|
617
|
+
}));
|
|
618
|
+
}
|
|
619
|
+
getLineNumber(content, index) {
|
|
620
|
+
return content.slice(0, index).split('\n').length;
|
|
621
|
+
}
|
|
622
|
+
isKeyword(word) {
|
|
623
|
+
return [
|
|
624
|
+
'if', 'else', 'while', 'for', 'switch', 'case', 'break', 'continue',
|
|
625
|
+
'return', 'throw', 'try', 'catch', 'finally', 'new', 'typeof', 'instanceof',
|
|
626
|
+
'await', 'yield', 'void', 'delete', 'in', 'of',
|
|
627
|
+
].includes(word);
|
|
628
|
+
}
|
|
629
|
+
findFunctionEnd(content, startIndex) {
|
|
630
|
+
let braceCount = 0;
|
|
631
|
+
let inFunction = false;
|
|
632
|
+
for (let i = startIndex; i < content.length; i++) {
|
|
633
|
+
const char = content[i];
|
|
634
|
+
if (char === '{') {
|
|
635
|
+
braceCount++;
|
|
636
|
+
inFunction = true;
|
|
637
|
+
}
|
|
638
|
+
else if (char === '}') {
|
|
639
|
+
braceCount--;
|
|
640
|
+
if (inFunction && braceCount === 0) {
|
|
641
|
+
return i + 1;
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
return content.length;
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
//# sourceMappingURL=TreeSitterParser.js.map
|