@mycodemap/mycodemap 1.9.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 +38 -0
- package/README.md +63 -978
- package/README.zh-CN.md +1096 -0
- 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-options.d.ts.map +1 -1
- package/dist/cli/commands/analyze-options.js +8 -0
- package/dist/cli/commands/analyze-options.js.map +1 -1
- 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 +27 -1162
- package/dist/cli/commands/analyze.js.map +1 -1
- package/dist/cli/commands/benchmark.d.ts +8 -0
- package/dist/cli/commands/benchmark.d.ts.map +1 -0
- package/dist/cli/commands/benchmark.js +153 -0
- package/dist/cli/commands/benchmark.js.map +1 -0
- 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 -59
- package/dist/cli/commands/deps.d.ts.map +1 -1
- package/dist/cli/commands/deps.js +25 -331
- package/dist/cli/commands/deps.js.map +1 -1
- package/dist/cli/commands/doctor.d.ts +3 -0
- package/dist/cli/commands/doctor.d.ts.map +1 -0
- package/dist/cli/commands/doctor.js +34 -0
- package/dist/cli/commands/doctor.js.map +1 -0
- 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 -20
- package/dist/cli/commands/query.d.ts.map +1 -1
- package/dist/cli/commands/query.js +23 -708
- 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-agent.d.ts +3 -0
- package/dist/cli/doctor/check-agent.d.ts.map +1 -0
- package/dist/cli/doctor/check-agent.js +60 -0
- package/dist/cli/doctor/check-agent.js.map +1 -0
- 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-ghost-commands.d.ts +3 -0
- package/dist/cli/doctor/check-ghost-commands.d.ts.map +1 -0
- package/dist/cli/doctor/check-ghost-commands.js +86 -0
- package/dist/cli/doctor/check-ghost-commands.js.map +1 -0
- package/dist/cli/doctor/check-native-deps.d.ts +3 -0
- package/dist/cli/doctor/check-native-deps.d.ts.map +1 -0
- package/dist/cli/doctor/check-native-deps.js +70 -0
- package/dist/cli/doctor/check-native-deps.js.map +1 -0
- package/dist/cli/doctor/check-workspace-drift.d.ts +3 -0
- package/dist/cli/doctor/check-workspace-drift.d.ts.map +1 -0
- package/dist/cli/doctor/check-workspace-drift.js +83 -0
- package/dist/cli/doctor/check-workspace-drift.js.map +1 -0
- package/dist/cli/doctor/formatter.d.ts +20 -0
- package/dist/cli/doctor/formatter.d.ts.map +1 -0
- package/dist/cli/doctor/formatter.js +91 -0
- package/dist/cli/doctor/formatter.js.map +1 -0
- package/dist/cli/doctor/index.d.ts +8 -0
- package/dist/cli/doctor/index.d.ts.map +1 -0
- package/dist/cli/doctor/index.js +9 -0
- package/dist/cli/doctor/index.js.map +1 -0
- package/dist/cli/doctor/orchestrator.d.ts +3 -0
- package/dist/cli/doctor/orchestrator.d.ts.map +1 -0
- package/dist/cli/doctor/orchestrator.js +40 -0
- package/dist/cli/doctor/orchestrator.js.map +1 -0
- package/dist/cli/doctor/types.d.ts +19 -0
- package/dist/cli/doctor/types.d.ts.map +1 -0
- package/dist/cli/doctor/types.js +4 -0
- package/dist/cli/doctor/types.js.map +1 -0
- 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 +94 -22
- 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 +3 -0
- package/dist/cli/interface-contract/commands/analyze.d.ts.map +1 -0
- package/dist/cli/interface-contract/commands/analyze.js +139 -0
- package/dist/cli/interface-contract/commands/analyze.js.map +1 -0
- package/dist/cli/interface-contract/commands/benchmark.d.ts +3 -0
- package/dist/cli/interface-contract/commands/benchmark.d.ts.map +1 -0
- package/dist/cli/interface-contract/commands/benchmark.js +108 -0
- package/dist/cli/interface-contract/commands/benchmark.js.map +1 -0
- package/dist/cli/interface-contract/commands/deps.d.ts +3 -0
- package/dist/cli/interface-contract/commands/deps.d.ts.map +1 -0
- package/dist/cli/interface-contract/commands/deps.js +130 -0
- package/dist/cli/interface-contract/commands/deps.js.map +1 -0
- package/dist/cli/interface-contract/commands/doctor.d.ts +3 -0
- package/dist/cli/interface-contract/commands/doctor.d.ts.map +1 -0
- package/dist/cli/interface-contract/commands/doctor.js +60 -0
- package/dist/cli/interface-contract/commands/doctor.js.map +1 -0
- 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 +12 -0
- package/dist/cli/interface-contract/commands/index.d.ts.map +1 -0
- package/dist/cli/interface-contract/commands/index.js +24 -0
- package/dist/cli/interface-contract/commands/index.js.map +1 -0
- package/dist/cli/interface-contract/commands/init.d.ts +3 -0
- package/dist/cli/interface-contract/commands/init.d.ts.map +1 -0
- package/dist/cli/interface-contract/commands/init.js +96 -0
- package/dist/cli/interface-contract/commands/init.js.map +1 -0
- 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 +3 -0
- package/dist/cli/interface-contract/commands/query.d.ts.map +1 -0
- package/dist/cli/interface-contract/commands/query.js +186 -0
- package/dist/cli/interface-contract/commands/query.js.map +1 -0
- package/dist/cli/interface-contract/index.d.ts +22 -0
- package/dist/cli/interface-contract/index.d.ts.map +1 -0
- package/dist/cli/interface-contract/index.js +41 -0
- package/dist/cli/interface-contract/index.js.map +1 -0
- package/dist/cli/interface-contract/schema.d.ts +30 -0
- package/dist/cli/interface-contract/schema.d.ts.map +1 -0
- package/dist/cli/interface-contract/schema.js +73 -0
- package/dist/cli/interface-contract/schema.js.map +1 -0
- package/dist/cli/interface-contract/types.d.ts +77 -0
- package/dist/cli/interface-contract/types.d.ts.map +1 -0
- package/dist/cli/interface-contract/types.js +4 -0
- package/dist/cli/interface-contract/types.js.map +1 -0
- package/dist/cli/output/apply-suggestion.d.ts +12 -0
- package/dist/cli/output/apply-suggestion.d.ts.map +1 -0
- package/dist/cli/output/apply-suggestion.js +29 -0
- package/dist/cli/output/apply-suggestion.js.map +1 -0
- package/dist/cli/output/error-codes.d.ts +24 -0
- package/dist/cli/output/error-codes.d.ts.map +1 -0
- package/dist/cli/output/error-codes.js +94 -0
- package/dist/cli/output/error-codes.js.map +1 -0
- package/dist/cli/output/errors.d.ts +14 -0
- package/dist/cli/output/errors.d.ts.map +1 -0
- package/dist/cli/output/errors.js +182 -0
- package/dist/cli/output/errors.js.map +1 -0
- package/dist/cli/output/index.d.ts +13 -0
- package/dist/cli/output/index.d.ts.map +1 -0
- package/dist/cli/output/index.js +11 -0
- package/dist/cli/output/index.js.map +1 -0
- package/dist/cli/output/mode.d.ts +12 -0
- package/dist/cli/output/mode.d.ts.map +1 -0
- package/dist/cli/output/mode.js +23 -0
- package/dist/cli/output/mode.js.map +1 -0
- package/dist/cli/output/progress.d.ts +9 -0
- package/dist/cli/output/progress.d.ts.map +1 -0
- package/dist/cli/output/progress.js +65 -0
- package/dist/cli/output/progress.js.map +1 -0
- package/dist/cli/output/render.d.ts +11 -0
- package/dist/cli/output/render.d.ts.map +1 -0
- package/dist/cli/output/render.js +18 -0
- package/dist/cli/output/render.js.map +1 -0
- package/dist/cli/output/types.d.ts +53 -0
- package/dist/cli/output/types.d.ts.map +1 -0
- package/dist/cli/output/types.js +14 -0
- package/dist/cli/output/types.js.map +1 -0
- package/dist/cli/output/wasm-fallback.d.ts +14 -0
- package/dist/cli/output/wasm-fallback.d.ts.map +1 -0
- package/dist/cli/output/wasm-fallback.js +92 -0
- package/dist/cli/output/wasm-fallback.js.map +1 -0
- 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/tree-sitter-check.d.ts +6 -1
- package/dist/cli/tree-sitter-check.d.ts.map +1 -1
- package/dist/cli/tree-sitter-check.js +23 -1
- package/dist/cli/tree-sitter-check.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 +322 -76
- package/dist/infrastructure/storage/adapters/SQLiteStorage.js.map +1 -1
- package/dist/infrastructure/storage/adapters/sqlite-loader.d.ts +45 -0
- package/dist/infrastructure/storage/adapters/sqlite-loader.d.ts.map +1 -0
- package/dist/infrastructure/storage/adapters/sqlite-loader.js +266 -0
- package/dist/infrastructure/storage/adapters/sqlite-loader.js.map +1 -0
- 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/orchestrator/types.d.ts +2 -0
- package/dist/orchestrator/types.d.ts.map +1 -1
- package/dist/orchestrator/types.js.map +1 -1
- 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 +18 -0
- package/dist/parser/implementations/tree-sitter-loader.d.ts.map +1 -0
- package/dist/parser/implementations/tree-sitter-loader.js +136 -0
- package/dist/parser/implementations/tree-sitter-loader.js.map +1 -0
- 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 +55 -0
- package/dist/server/mcp/schema-adapter.d.ts.map +1 -0
- package/dist/server/mcp/schema-adapter.js +409 -0
- package/dist/server/mcp/schema-adapter.js.map +1 -0
- 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 +134 -20
- 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 +281 -12
- 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/README.md +40 -1
- package/docs/SETUP_GUIDE.md +60 -14
- package/docs/TESTING.md +81 -0
- package/docs/ai-guide/COMMANDS.md +68 -10
- package/docs/ai-guide/INTEGRATION.md +77 -10
- package/docs/ai-guide/OUTPUT.md +345 -9
- package/docs/ai-guide/PROMPTS.md +2 -2
- package/docs/ai-guide/QUICKSTART.md +28 -1
- package/docs/ai-guide/README.md +2 -2
- package/docs/archive/ideation/2026-04-15-executable-architecture-constitution-ideation-archive.md +70 -0
- package/docs/archive/ideation/2026-04-20-mycodemap-init-enhancements-ideation-archive.md +109 -0
- package/docs/archive/ideation/2026-04-22-rules-entry-docs-optimization-consolidated-ideation-archive.md +54 -0
- 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-04-15-executable-architecture-constitution-ideation.md +10 -22
- package/docs/ideation/2026-04-20-mycodemap-init-enhancements-ideation.md +15 -60
- package/docs/ideation/2026-04-22-rules-entry-docs-optimization-consolidated-ideation.md +47 -52
- package/docs/ideation/2026-04-29-ux-install-agent-experience-ideation.md +256 -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/docs/plans/2026-04-30-install-guide-and-repo-analyzer-design.md +394 -0
- package/docs/rules/README.md +1 -0
- package/docs/rules/architecture-guardrails.md +2 -1
- package/docs/rules/engineering-with-codex-openai.md +1 -1
- package/docs/rules/harness.md +106 -0
- package/docs/rules/pre-release-checklist.md +28 -0
- package/docs/rules/testing.md +51 -0
- package/examples/claude/skills/mycodemap-repo-analyzer/SKILL.md +294 -0
- package/examples/claude/skills/mycodemap-repo-analyzer/references/analysis-guide.md +166 -0
- package/examples/claude/skills/mycodemap-repo-analyzer/references/module-analysis-guide.md +150 -0
- package/package.json +12 -4
- package/scripts/copy-build-assets.mjs +23 -0
- package/scripts/hooks/templates/pre-commit +33 -2
- package/scripts/sync-analyze-docs.js +2 -2
- package/scripts/tests/test_rule_control_workflow.py +15 -1
- package/scripts/validate-docs.js +113 -16
- package/scripts/verify-subagent-env-contract.mjs +279 -0
- package/dist/parser/implementations/tree-sitter-parser.d.ts +0 -57
- package/dist/parser/implementations/tree-sitter-parser.d.ts.map +0 -1
- package/dist/parser/implementations/tree-sitter-parser.js +0 -375
- package/dist/parser/implementations/tree-sitter-parser.js.map +0 -1
- package/docs/references/tmp.md +0 -527
|
@@ -1,718 +1,33 @@
|
|
|
1
1
|
// [META] since:2026-03-03 | owner:orchestrator-team | stable:true
|
|
2
|
-
// [WHY]
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
MAX_SIZE: 10, // 最大缓存 10 个项目的索引
|
|
12
|
-
};
|
|
13
|
-
const indexCache = new Map();
|
|
14
|
-
/**
|
|
15
|
-
* 标准化依赖名称,用于去重比较
|
|
16
|
-
* 1. 去除扩展名(如 .ts, .js)
|
|
17
|
-
* 2. 去除 ./ 前缀
|
|
18
|
-
* 3. 转换为小写
|
|
19
|
-
*/
|
|
20
|
-
function normalizeDependencyName(name) {
|
|
21
|
-
return name
|
|
22
|
-
.replace(/\.[jt]s$/, "") // 去除 .ts 或 .js 扩展名
|
|
23
|
-
.replace(/^\.\//, "") // 去除 ./ 前缀
|
|
24
|
-
.toLowerCase();
|
|
2
|
+
// [WHY] Thin CLI wrapper for shared query execution so CLI and MCP can converge on one transport-free truth
|
|
3
|
+
import { resolveOutputMode, renderOutput, createProgressEmitter, formatError } from '../output/index.js';
|
|
4
|
+
import { executeQueryTool, formatQueryHuman, } from '../../execution/contract-tools/query.js';
|
|
5
|
+
function toExecutionError(error) {
|
|
6
|
+
const executionError = new Error(error.message);
|
|
7
|
+
executionError.code = error.code;
|
|
8
|
+
executionError.remediation = error.remediation;
|
|
9
|
+
executionError.details = error.details;
|
|
10
|
+
return executionError;
|
|
25
11
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
function buildIndex(codeMap, rootDir) {
|
|
30
|
-
const index = {
|
|
31
|
-
symbols: new Map(),
|
|
32
|
-
symbolsExact: new Map(),
|
|
33
|
-
modules: new Map(),
|
|
34
|
-
dependencies: new Map(),
|
|
35
|
-
prefixIndex: new Map(),
|
|
36
|
-
prefixIndexExact: new Map(),
|
|
37
|
-
};
|
|
38
|
-
for (const module of codeMap.modules) {
|
|
39
|
-
const relativePath = path.relative(rootDir, module.absolutePath);
|
|
40
|
-
const moduleIndex = {
|
|
41
|
-
absolutePath: module.absolutePath,
|
|
42
|
-
relativePath,
|
|
43
|
-
type: module.type,
|
|
44
|
-
exports: module.exports.map(e => e.name),
|
|
45
|
-
};
|
|
46
|
-
// 索引模块(使用相对路径作为主键)
|
|
47
|
-
index.modules.set(relativePath.toLowerCase(), moduleIndex);
|
|
48
|
-
// 索引导出
|
|
49
|
-
for (const exp of module.exports) {
|
|
50
|
-
const entry = {
|
|
51
|
-
name: exp.name,
|
|
52
|
-
kind: exp.kind,
|
|
53
|
-
filePath: relativePath,
|
|
54
|
-
isExported: true,
|
|
55
|
-
};
|
|
56
|
-
// 精确索引(不区分大小写)
|
|
57
|
-
const lowerName = exp.name.toLowerCase();
|
|
58
|
-
if (!index.symbols.has(lowerName)) {
|
|
59
|
-
index.symbols.set(lowerName, []);
|
|
60
|
-
}
|
|
61
|
-
index.symbols.get(lowerName).push(entry);
|
|
62
|
-
// 精确索引(区分大小写)
|
|
63
|
-
if (!index.symbolsExact.has(exp.name)) {
|
|
64
|
-
index.symbolsExact.set(exp.name, []);
|
|
65
|
-
}
|
|
66
|
-
index.symbolsExact.get(exp.name).push(entry);
|
|
67
|
-
// 前缀索引(不区分大小写)
|
|
68
|
-
for (let i = 1; i <= exp.name.length; i++) {
|
|
69
|
-
const prefix = exp.name.substring(0, i).toLowerCase();
|
|
70
|
-
if (!index.prefixIndex.has(prefix)) {
|
|
71
|
-
index.prefixIndex.set(prefix, []);
|
|
72
|
-
}
|
|
73
|
-
index.prefixIndex.get(prefix).push(entry);
|
|
74
|
-
}
|
|
75
|
-
// 前缀索引(区分大小写)
|
|
76
|
-
for (let i = 1; i <= exp.name.length; i++) {
|
|
77
|
-
const prefix = exp.name.substring(0, i);
|
|
78
|
-
if (!index.prefixIndexExact.has(prefix)) {
|
|
79
|
-
index.prefixIndexExact.set(prefix, []);
|
|
80
|
-
}
|
|
81
|
-
index.prefixIndexExact.get(prefix).push(entry);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
// 索引符号
|
|
85
|
-
for (const sym of module.symbols) {
|
|
86
|
-
const entry = {
|
|
87
|
-
name: sym.name,
|
|
88
|
-
kind: sym.kind,
|
|
89
|
-
filePath: relativePath,
|
|
90
|
-
line: sym.location.line,
|
|
91
|
-
column: sym.location.column,
|
|
92
|
-
isExported: false,
|
|
93
|
-
};
|
|
94
|
-
const lowerName = sym.name.toLowerCase();
|
|
95
|
-
if (!index.symbols.has(lowerName)) {
|
|
96
|
-
index.symbols.set(lowerName, []);
|
|
97
|
-
}
|
|
98
|
-
index.symbols.get(lowerName).push(entry);
|
|
99
|
-
// 精确索引(区分大小写)
|
|
100
|
-
if (!index.symbolsExact.has(sym.name)) {
|
|
101
|
-
index.symbolsExact.set(sym.name, []);
|
|
102
|
-
}
|
|
103
|
-
index.symbolsExact.get(sym.name).push(entry);
|
|
104
|
-
// 前缀索引(不区分大小写)
|
|
105
|
-
for (let i = 1; i <= sym.name.length; i++) {
|
|
106
|
-
const prefix = sym.name.substring(0, i).toLowerCase();
|
|
107
|
-
if (!index.prefixIndex.has(prefix)) {
|
|
108
|
-
index.prefixIndex.set(prefix, []);
|
|
109
|
-
}
|
|
110
|
-
index.prefixIndex.get(prefix).push(entry);
|
|
111
|
-
}
|
|
112
|
-
// 前缀索引(区分大小写)
|
|
113
|
-
for (let i = 1; i <= sym.name.length; i++) {
|
|
114
|
-
const prefix = sym.name.substring(0, i);
|
|
115
|
-
if (!index.prefixIndexExact.has(prefix)) {
|
|
116
|
-
index.prefixIndexExact.set(prefix, []);
|
|
117
|
-
}
|
|
118
|
-
index.prefixIndexExact.get(prefix).push(entry);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
// 索引依赖和导入,进行去重处理
|
|
122
|
-
// 使用 Set 跟踪当前模块已添加的依赖(基于标准化名称)
|
|
123
|
-
const seenDeps = new Set();
|
|
124
|
-
// 先索引 dependencies(优先保留)
|
|
125
|
-
for (const dep of module.dependencies) {
|
|
126
|
-
const normalizedDep = normalizeDependencyName(dep);
|
|
127
|
-
const depKey = `${relativePath}:${normalizedDep}`;
|
|
128
|
-
// 跳过已存在的依赖
|
|
129
|
-
if (seenDeps.has(depKey)) {
|
|
130
|
-
continue;
|
|
131
|
-
}
|
|
132
|
-
seenDeps.add(depKey);
|
|
133
|
-
const depEntry = {
|
|
134
|
-
name: dep,
|
|
135
|
-
sourcePath: relativePath,
|
|
136
|
-
type: "dependency",
|
|
137
|
-
};
|
|
138
|
-
const lowerDep = dep.toLowerCase();
|
|
139
|
-
if (!index.dependencies.has(lowerDep)) {
|
|
140
|
-
index.dependencies.set(lowerDep, []);
|
|
141
|
-
}
|
|
142
|
-
index.dependencies.get(lowerDep).push(depEntry);
|
|
143
|
-
}
|
|
144
|
-
// 再索引 imports(如果与 dependency 重复则跳过)
|
|
145
|
-
for (const imp of module.imports) {
|
|
146
|
-
const normalizedSource = normalizeDependencyName(imp.source);
|
|
147
|
-
const impKey = `${relativePath}:${normalizedSource}`;
|
|
148
|
-
// 跳过已存在的依赖(避免与 dependency 重复)
|
|
149
|
-
if (seenDeps.has(impKey)) {
|
|
150
|
-
continue;
|
|
151
|
-
}
|
|
152
|
-
seenDeps.add(impKey);
|
|
153
|
-
const impEntry = {
|
|
154
|
-
name: imp.source,
|
|
155
|
-
sourcePath: relativePath,
|
|
156
|
-
type: "import",
|
|
157
|
-
};
|
|
158
|
-
const lowerSource = imp.source.toLowerCase();
|
|
159
|
-
if (!index.dependencies.has(lowerSource)) {
|
|
160
|
-
index.dependencies.set(lowerSource, []);
|
|
161
|
-
}
|
|
162
|
-
index.dependencies.get(lowerSource).push(impEntry);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return index;
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* 加载代码地图数据(带改进的缓存)
|
|
169
|
-
*/
|
|
170
|
-
function loadCodeMap(rootDir, useCache = true) {
|
|
171
|
-
const codemapPath = resolveDataPath(rootDir);
|
|
172
|
-
const startTime = performance.now();
|
|
173
|
-
// 检查缓存
|
|
174
|
-
if (useCache) {
|
|
175
|
-
const cached = indexCache.get(rootDir);
|
|
176
|
-
if (cached && Date.now() - cached.timestamp < CACHE_CONFIG.TTL) {
|
|
177
|
-
return {
|
|
178
|
-
codeMap: cached.data,
|
|
179
|
-
index: cached.index,
|
|
180
|
-
cacheHit: true,
|
|
181
|
-
loadTime: 0,
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
if (!fs.existsSync(codemapPath)) {
|
|
186
|
-
console.log(chalk.red('错误: 代码地图不存在,请先运行 codemap generate'));
|
|
187
|
-
return { codeMap: null, index: null, cacheHit: false, loadTime: 0 };
|
|
188
|
-
}
|
|
12
|
+
export async function queryCommand(options) {
|
|
13
|
+
const mode = resolveOutputMode({ json: options.json, human: options.human });
|
|
14
|
+
const progress = createProgressEmitter(mode, 'Querying...');
|
|
189
15
|
try {
|
|
190
|
-
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
if (useCache) {
|
|
197
|
-
// 清理超出限制的旧缓存
|
|
198
|
-
if (indexCache.size >= CACHE_CONFIG.MAX_SIZE) {
|
|
199
|
-
// 删除最旧的缓存
|
|
200
|
-
let oldestKey = null;
|
|
201
|
-
let oldestTime = Infinity;
|
|
202
|
-
for (const [key, val] of indexCache.entries()) {
|
|
203
|
-
if (val.timestamp < oldestTime) {
|
|
204
|
-
oldestTime = val.timestamp;
|
|
205
|
-
oldestKey = key;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
if (oldestKey) {
|
|
209
|
-
indexCache.delete(oldestKey);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
indexCache.set(rootDir, {
|
|
213
|
-
data: parsed,
|
|
214
|
-
timestamp: Date.now(),
|
|
215
|
-
path: codemapPath,
|
|
216
|
-
index,
|
|
16
|
+
progress.update(30, 'Loading index...');
|
|
17
|
+
const execution = await executeQueryTool(options, process.cwd());
|
|
18
|
+
if (execution.status !== 'ok' || !execution.result) {
|
|
19
|
+
throw toExecutionError(execution.error ?? {
|
|
20
|
+
code: 'EXECUTION_FAILED',
|
|
21
|
+
message: 'Query execution failed',
|
|
217
22
|
});
|
|
218
23
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
index,
|
|
222
|
-
cacheHit: false,
|
|
223
|
-
loadTime,
|
|
224
|
-
};
|
|
24
|
+
progress.complete();
|
|
25
|
+
renderOutput(execution.result, formatQueryHuman, mode);
|
|
225
26
|
}
|
|
226
27
|
catch (error) {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* 清除缓存
|
|
233
|
-
*/
|
|
234
|
-
function clearCache() {
|
|
235
|
-
indexCache.clear();
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* 查找符号的引用位置
|
|
239
|
-
*/
|
|
240
|
-
function findReferences(codeMap, symbolName, excludeFile, caseSensitive = false) {
|
|
241
|
-
const references = [];
|
|
242
|
-
const searchName = caseSensitive ? symbolName : symbolName.toLowerCase();
|
|
243
|
-
for (const mod of codeMap.modules) {
|
|
244
|
-
const relPath = path.relative(codeMap.project.rootDir, mod.absolutePath);
|
|
245
|
-
// 跳过定义位置文件
|
|
246
|
-
if (relPath === excludeFile)
|
|
247
|
-
continue;
|
|
248
|
-
// 检查 imports 中是否引用了该符号
|
|
249
|
-
for (const imp of mod.imports) {
|
|
250
|
-
// 检查导入源
|
|
251
|
-
const impSource = caseSensitive ? imp.source : imp.source.toLowerCase();
|
|
252
|
-
if (impSource.includes(searchName)) {
|
|
253
|
-
references.push({
|
|
254
|
-
file: relPath,
|
|
255
|
-
line: 1, // 简化处理,显示第一行
|
|
256
|
-
type: 'import',
|
|
257
|
-
});
|
|
258
|
-
continue;
|
|
259
|
-
}
|
|
260
|
-
// 检查导入的 specifiers
|
|
261
|
-
for (const spec of imp.specifiers) {
|
|
262
|
-
const specName = caseSensitive ? spec.name : spec.name.toLowerCase();
|
|
263
|
-
if (specName === searchName) {
|
|
264
|
-
references.push({
|
|
265
|
-
file: relPath,
|
|
266
|
-
line: 1,
|
|
267
|
-
type: 'import',
|
|
268
|
-
});
|
|
269
|
-
break;
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
// 检查 exports 中是否导出该符号
|
|
274
|
-
for (const exp of mod.exports) {
|
|
275
|
-
const expName = caseSensitive ? exp.name : exp.name.toLowerCase();
|
|
276
|
-
if (expName === searchName) {
|
|
277
|
-
references.push({
|
|
278
|
-
file: relPath,
|
|
279
|
-
line: 1,
|
|
280
|
-
type: 'export',
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
return references.slice(0, 20); // 限制引用数量
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
* 读取代码上下文
|
|
289
|
-
*/
|
|
290
|
-
function readCodeContext(filePath, lineNumber, contextLines, rootDir) {
|
|
291
|
-
const fullPath = path.join(rootDir, filePath);
|
|
292
|
-
if (!fs.existsSync(fullPath)) {
|
|
293
|
-
return [];
|
|
294
|
-
}
|
|
295
|
-
try {
|
|
296
|
-
const content = fs.readFileSync(fullPath, 'utf-8');
|
|
297
|
-
const lines = content.split('\n');
|
|
298
|
-
const context = [];
|
|
299
|
-
const startLine = Math.max(1, lineNumber - contextLines);
|
|
300
|
-
const endLine = Math.min(lines.length, lineNumber + contextLines);
|
|
301
|
-
for (let i = startLine; i <= endLine; i++) {
|
|
302
|
-
context.push({
|
|
303
|
-
line: i,
|
|
304
|
-
content: lines[i - 1] || '',
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
return context;
|
|
308
|
-
}
|
|
309
|
-
catch {
|
|
310
|
-
return [];
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
/**
|
|
314
|
-
* 查询符号(使用索引)
|
|
315
|
-
*/
|
|
316
|
-
function querySymbol(index, codeMap, symbolName, limit, caseSensitive = false, includeReferences = false, contextLines = 0) {
|
|
317
|
-
const results = [];
|
|
318
|
-
// 选择正确的索引
|
|
319
|
-
const symbolsMap = caseSensitive ? index.symbolsExact : index.symbols;
|
|
320
|
-
const prefixMap = caseSensitive ? index.prefixIndexExact : index.prefixIndex;
|
|
321
|
-
// 搜索键:不区分大小写时转换为小写
|
|
322
|
-
const searchKey = caseSensitive ? symbolName : symbolName.toLowerCase();
|
|
323
|
-
// 用于去重的 Set
|
|
324
|
-
const seenResults = new Set();
|
|
325
|
-
// 首先尝试精确匹配(完全相等)
|
|
326
|
-
const exactMatches = symbolsMap.get(searchKey);
|
|
327
|
-
if (exactMatches) {
|
|
328
|
-
for (const entry of exactMatches) {
|
|
329
|
-
const key = `${entry.name}:${entry.filePath}`;
|
|
330
|
-
if (!seenResults.has(key)) {
|
|
331
|
-
seenResults.add(key);
|
|
332
|
-
results.push({
|
|
333
|
-
name: entry.name,
|
|
334
|
-
path: path.join(codeMap.project.rootDir, entry.filePath),
|
|
335
|
-
kind: entry.kind,
|
|
336
|
-
details: `${entry.isExported ? '导出于' : '定义于'} ${entry.filePath}${entry.line ? ':' + entry.line : ''}`,
|
|
337
|
-
location: { file: entry.filePath, line: entry.line, column: entry.column },
|
|
338
|
-
isExported: entry.isExported,
|
|
339
|
-
});
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
// 尝试前缀匹配(以搜索词开头)
|
|
344
|
-
const prefixResults = prefixMap.get(searchKey) || [];
|
|
345
|
-
for (const entry of prefixResults) {
|
|
346
|
-
const key = `${entry.name}:${entry.filePath}`;
|
|
347
|
-
if (!seenResults.has(key)) {
|
|
348
|
-
seenResults.add(key);
|
|
349
|
-
results.push({
|
|
350
|
-
name: entry.name,
|
|
351
|
-
path: path.join(codeMap.project.rootDir, entry.filePath),
|
|
352
|
-
kind: entry.kind,
|
|
353
|
-
details: `${entry.isExported ? '导出于' : '定义于'} ${entry.filePath}${entry.line ? ':' + entry.line : ''}`,
|
|
354
|
-
location: { file: entry.filePath, line: entry.line, column: entry.column },
|
|
355
|
-
isExported: entry.isExported,
|
|
356
|
-
});
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
// 尝试子串匹配(包含匹配)
|
|
360
|
-
// 例如:搜索 "Analyzer" 应匹配 "GitAnalyzer"
|
|
361
|
-
for (const [key, entries] of symbolsMap.entries()) {
|
|
362
|
-
if (key.includes(searchKey) && !key.startsWith(searchKey)) {
|
|
363
|
-
// 跳过已经通过精确匹配和前缀匹配找到的键
|
|
364
|
-
for (const entry of entries) {
|
|
365
|
-
const resultKey = `${entry.name}:${entry.filePath}`;
|
|
366
|
-
if (!seenResults.has(resultKey)) {
|
|
367
|
-
seenResults.add(resultKey);
|
|
368
|
-
results.push({
|
|
369
|
-
name: entry.name,
|
|
370
|
-
path: path.join(codeMap.project.rootDir, entry.filePath),
|
|
371
|
-
kind: entry.kind,
|
|
372
|
-
details: `${entry.isExported ? '导出于' : '定义于'} ${entry.filePath}${entry.line ? ':' + entry.line : ''}`,
|
|
373
|
-
location: { file: entry.filePath, line: entry.line, column: entry.column },
|
|
374
|
-
isExported: entry.isExported,
|
|
375
|
-
});
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
// 添加引用信息
|
|
381
|
-
if (includeReferences) {
|
|
382
|
-
for (const result of results) {
|
|
383
|
-
result.references = findReferences(codeMap, symbolName, result.location?.file || '', caseSensitive);
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
// 添加代码上下文
|
|
387
|
-
if (contextLines > 0) {
|
|
388
|
-
for (const result of results) {
|
|
389
|
-
result.context = readCodeContext(result.location?.file || '', result.location?.line || 0, contextLines, codeMap.project.rootDir);
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
return results.slice(0, limit);
|
|
393
|
-
}
|
|
394
|
-
/**
|
|
395
|
-
* 查询模块(使用索引)
|
|
396
|
-
*/
|
|
397
|
-
function queryModule(index, codeMap, modulePath, limit) {
|
|
398
|
-
const results = [];
|
|
399
|
-
const searchPath = modulePath.toLowerCase();
|
|
400
|
-
// 使用索引查找
|
|
401
|
-
for (const [key, moduleIdx] of index.modules.entries()) {
|
|
402
|
-
if (key.includes(searchPath) || moduleIdx.absolutePath.toLowerCase().includes(searchPath)) {
|
|
403
|
-
const exports = moduleIdx.exports.join(', ') || '无导出';
|
|
404
|
-
results.push({
|
|
405
|
-
name: moduleIdx.relativePath,
|
|
406
|
-
path: moduleIdx.absolutePath,
|
|
407
|
-
kind: moduleIdx.type,
|
|
408
|
-
details: `导出: ${exports}`,
|
|
409
|
-
location: { file: moduleIdx.relativePath },
|
|
410
|
-
isExported: moduleIdx.exports.length > 0,
|
|
411
|
-
});
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
return results.slice(0, limit);
|
|
415
|
-
}
|
|
416
|
-
/**
|
|
417
|
-
* 查询依赖(使用索引)
|
|
418
|
-
* @param index 符号索引
|
|
419
|
-
* @param codeMap 代码地图数据
|
|
420
|
-
* @param depName 依赖名称
|
|
421
|
-
* @param limit 结果数量限制
|
|
422
|
-
* @param deduplicate 是否去重(默认true)
|
|
423
|
-
*/
|
|
424
|
-
function queryDeps(index, codeMap, depName, limit, deduplicate = true) {
|
|
425
|
-
const results = [];
|
|
426
|
-
const searchDep = depName.toLowerCase();
|
|
427
|
-
// 使用索引查找
|
|
428
|
-
const depEntries = index.dependencies.get(searchDep);
|
|
429
|
-
if (depEntries) {
|
|
430
|
-
for (const entry of depEntries) {
|
|
431
|
-
results.push({
|
|
432
|
-
name: entry.name,
|
|
433
|
-
path: path.join(codeMap.project.rootDir, entry.sourcePath),
|
|
434
|
-
kind: entry.type,
|
|
435
|
-
details: `${entry.type === 'dependency' ? '被' : '导入自'} ${entry.sourcePath} 引用`,
|
|
436
|
-
location: { file: entry.sourcePath },
|
|
437
|
-
isExported: false,
|
|
438
|
-
});
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
// 去重:基于 name:sourcePath 组合去重,避免 dependency 和 import 重复
|
|
442
|
-
if (deduplicate) {
|
|
443
|
-
const unique = new Map();
|
|
444
|
-
for (const item of results) {
|
|
445
|
-
const key = `${item.name}:${item.path}`;
|
|
446
|
-
if (!unique.has(key)) {
|
|
447
|
-
unique.set(key, item);
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
return Array.from(unique.values()).slice(0, limit);
|
|
451
|
-
}
|
|
452
|
-
return results.slice(0, limit);
|
|
453
|
-
}
|
|
454
|
-
/**
|
|
455
|
-
* 模糊搜索(使用索引)
|
|
456
|
-
* @param index 符号索引
|
|
457
|
-
* @param codeMap 代码地图数据
|
|
458
|
-
* @param keyword 搜索关键词
|
|
459
|
-
* @param limit 结果数量限制
|
|
460
|
-
* @param useRegex 是否使用正则表达式搜索
|
|
461
|
-
* @param caseSensitive 大小写敏感
|
|
462
|
-
* @param contextLines 代码上下文行数
|
|
463
|
-
*/
|
|
464
|
-
function search(index, codeMap, keyword, limit, useRegex = false, caseSensitive = false, contextLines = 0) {
|
|
465
|
-
const results = [];
|
|
466
|
-
// 正则表达式模式
|
|
467
|
-
let regex = null;
|
|
468
|
-
if (useRegex) {
|
|
469
|
-
try {
|
|
470
|
-
const flags = caseSensitive ? '' : 'i';
|
|
471
|
-
regex = new RegExp(keyword, flags);
|
|
472
|
-
}
|
|
473
|
-
catch {
|
|
474
|
-
// 正则表达式无效,回退到普通搜索
|
|
475
|
-
regex = null;
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
// 1. 搜索模块路径
|
|
479
|
-
for (const [key, moduleIdx] of index.modules.entries()) {
|
|
480
|
-
const searchTarget = caseSensitive ? key : key.toLowerCase();
|
|
481
|
-
const keywordLower = keyword.toLowerCase();
|
|
482
|
-
const matches = regex
|
|
483
|
-
? regex.test(key) || regex.test(moduleIdx.relativePath)
|
|
484
|
-
: searchTarget.includes(keywordLower);
|
|
485
|
-
if (matches) {
|
|
486
|
-
results.push({
|
|
487
|
-
name: moduleIdx.relativePath,
|
|
488
|
-
path: moduleIdx.absolutePath,
|
|
489
|
-
kind: 'module',
|
|
490
|
-
details: useRegex ? `正则匹配` : `模块匹配`,
|
|
491
|
-
location: { file: moduleIdx.relativePath },
|
|
492
|
-
isExported: false,
|
|
493
|
-
});
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
// 2. 搜索符号和导出(使用前缀索引)
|
|
497
|
-
// 选择正确的索引
|
|
498
|
-
const symbolsMap = caseSensitive ? index.symbolsExact : index.symbols;
|
|
499
|
-
const prefixMap = caseSensitive ? index.prefixIndexExact : index.prefixIndex;
|
|
500
|
-
if (useRegex && regex) {
|
|
501
|
-
// 正则模式:遍历所有符号进行匹配
|
|
502
|
-
for (const [symbolKey, entries] of symbolsMap.entries()) {
|
|
503
|
-
const matchTarget = caseSensitive ? symbolKey : symbolKey.toLowerCase();
|
|
504
|
-
if (regex.test(matchTarget) || regex.test(symbolKey)) {
|
|
505
|
-
for (const entry of entries) {
|
|
506
|
-
results.push({
|
|
507
|
-
name: entry.name,
|
|
508
|
-
path: path.join(codeMap.project.rootDir, entry.filePath),
|
|
509
|
-
kind: entry.isExported ? `export (${entry.kind})` : entry.kind,
|
|
510
|
-
details: `正则匹配于 ${entry.filePath}${entry.line ? ':' + entry.line : ''}`,
|
|
511
|
-
location: { file: entry.filePath, line: entry.line, column: entry.column },
|
|
512
|
-
isExported: entry.isExported,
|
|
513
|
-
});
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
else {
|
|
519
|
-
// 普通模式:使用前缀索引
|
|
520
|
-
// 搜索键:不区分大小写时转换为小写
|
|
521
|
-
const searchKey = caseSensitive ? keyword : keyword.toLowerCase();
|
|
522
|
-
const prefixResults = prefixMap.get(searchKey) || [];
|
|
523
|
-
for (const entry of prefixResults) {
|
|
524
|
-
results.push({
|
|
525
|
-
name: entry.name,
|
|
526
|
-
path: path.join(codeMap.project.rootDir, entry.filePath),
|
|
527
|
-
kind: entry.isExported ? `export (${entry.kind})` : entry.kind,
|
|
528
|
-
details: `${entry.isExported ? '导出于' : '定义于'} ${entry.filePath}${entry.line ? ':' + entry.line : ''}`,
|
|
529
|
-
location: { file: entry.filePath, line: entry.line, column: entry.column },
|
|
530
|
-
isExported: entry.isExported,
|
|
531
|
-
});
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
// 去重(基于 name:path 组合)
|
|
535
|
-
const unique = new Map();
|
|
536
|
-
for (const item of results) {
|
|
537
|
-
const key = `${item.name}:${item.path}`;
|
|
538
|
-
if (!unique.has(key)) {
|
|
539
|
-
unique.set(key, item);
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
const finalResults = Array.from(unique.values()).slice(0, limit);
|
|
543
|
-
// 添加代码上下文
|
|
544
|
-
if (contextLines > 0) {
|
|
545
|
-
for (const result of finalResults) {
|
|
546
|
-
result.context = readCodeContext(result.location?.file || '', result.location?.line || 0, contextLines, codeMap.project.rootDir);
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
return finalResults;
|
|
550
|
-
}
|
|
551
|
-
/**
|
|
552
|
-
* 格式化输出结果
|
|
553
|
-
*/
|
|
554
|
-
function formatResults(result, isJson, verbose, structured = false) {
|
|
555
|
-
if (isJson) {
|
|
556
|
-
// 如果是 structured 模式,移除 details 字段
|
|
557
|
-
if (structured) {
|
|
558
|
-
const structuredResult = {
|
|
559
|
-
...result,
|
|
560
|
-
results: result.results.map(item => {
|
|
561
|
-
const { details, ...rest } = item;
|
|
562
|
-
void details; // 标记为有意忽略的变量
|
|
563
|
-
return rest;
|
|
564
|
-
})
|
|
565
|
-
};
|
|
566
|
-
console.log(JSON.stringify(structuredResult, null, 2));
|
|
567
|
-
}
|
|
568
|
-
else {
|
|
569
|
-
console.log(JSON.stringify(result, null, 2));
|
|
570
|
-
}
|
|
571
|
-
return;
|
|
572
|
-
}
|
|
573
|
-
console.log(chalk.cyan(`\n查询 "${result.query}" (${result.type})`));
|
|
574
|
-
console.log(chalk.gray(` 找到 ${result.count} 个结果\n`));
|
|
575
|
-
if (result.count === 0) {
|
|
576
|
-
console.log(chalk.yellow(' 未找到匹配结果'));
|
|
577
|
-
return;
|
|
578
|
-
}
|
|
579
|
-
for (const item of result.results) {
|
|
580
|
-
console.log(chalk.green(` ${item.name}`));
|
|
581
|
-
if (item.kind) {
|
|
582
|
-
console.log(chalk.gray(` 类型: ${item.kind}`));
|
|
583
|
-
}
|
|
584
|
-
if (item.path) {
|
|
585
|
-
console.log(chalk.gray(` 路径: ${item.path}`));
|
|
586
|
-
}
|
|
587
|
-
if (item.details) {
|
|
588
|
-
console.log(chalk.gray(` ${item.details}`));
|
|
589
|
-
}
|
|
590
|
-
// 显示引用信息
|
|
591
|
-
if (item.references && item.references.length > 0) {
|
|
592
|
-
console.log(chalk.gray(` 引用:`));
|
|
593
|
-
for (const ref of item.references.slice(0, 5)) {
|
|
594
|
-
console.log(chalk.gray(` - ${ref.type}: ${ref.file}`));
|
|
595
|
-
}
|
|
596
|
-
if (item.references.length > 5) {
|
|
597
|
-
console.log(chalk.gray(` ... 还有 ${item.references.length - 5} 个引用`));
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
// 显示代码上下文
|
|
601
|
-
if (item.context && item.context.length > 0) {
|
|
602
|
-
console.log(chalk.gray(` 代码上下文:`));
|
|
603
|
-
for (const ctx of item.context) {
|
|
604
|
-
const prefix = ctx.line === item.location?.line ? '>' : ' ';
|
|
605
|
-
console.log(chalk.gray(` ${prefix}${ctx.line}: ${ctx.content}`));
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
console.log('');
|
|
609
|
-
}
|
|
610
|
-
// verbose 模式输出性能指标
|
|
611
|
-
if (verbose && result.metrics) {
|
|
612
|
-
const m = result.metrics;
|
|
613
|
-
console.log(chalk.cyan('性能指标:'));
|
|
614
|
-
console.log(chalk.gray(` 索引加载: ${m.indexLoadTime.toFixed(2)}ms ${m.cacheHit ? '(缓存命中)' : ''}`));
|
|
615
|
-
console.log(chalk.gray(` 查询执行: ${m.queryTime.toFixed(2)}ms`));
|
|
616
|
-
console.log(chalk.gray(` 总耗时: ${m.totalTime.toFixed(2)}ms`));
|
|
617
|
-
console.log(chalk.gray(` 索引大小: ${m.indexSize} 个条目`));
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
/**
|
|
621
|
-
* Query 命令实现
|
|
622
|
-
*/
|
|
623
|
-
export async function queryCommand(options) {
|
|
624
|
-
const rootDir = process.cwd();
|
|
625
|
-
const limit = options.limit || 50;
|
|
626
|
-
const useCache = options.cache !== false; // 默认启用缓存
|
|
627
|
-
const verbose = options.verbose || false;
|
|
628
|
-
const useRegex = options.regex || false;
|
|
629
|
-
const depsFormat = options.depsFormat || 'default';
|
|
630
|
-
const caseSensitive = options.caseSensitive || false;
|
|
631
|
-
const contextLines = typeof options.context === 'string' ? parseInt(options.context, 10) : (options.context || 0);
|
|
632
|
-
const includeReferences = options.includeReferences || false;
|
|
633
|
-
// 清除缓存(如果指定 --no-cache)
|
|
634
|
-
if (!useCache) {
|
|
635
|
-
clearCache();
|
|
636
|
-
}
|
|
637
|
-
// 加载代码地图(带缓存)
|
|
638
|
-
const startTotal = performance.now();
|
|
639
|
-
const { codeMap, index, cacheHit, loadTime } = loadCodeMap(rootDir, useCache);
|
|
640
|
-
if (!codeMap || !index) {
|
|
641
|
-
process.exit(1);
|
|
642
|
-
}
|
|
643
|
-
const indexLoadTime = loadTime;
|
|
644
|
-
const indexSize = index.symbols.size + index.modules.size + index.dependencies.size;
|
|
645
|
-
let result;
|
|
646
|
-
const queryStartTime = performance.now();
|
|
647
|
-
// 执行查询
|
|
648
|
-
if (options.symbol) {
|
|
649
|
-
const items = querySymbol(index, codeMap, options.symbol, limit, caseSensitive, includeReferences, contextLines);
|
|
650
|
-
result = {
|
|
651
|
-
type: 'symbol',
|
|
652
|
-
query: options.symbol,
|
|
653
|
-
count: items.length,
|
|
654
|
-
results: items,
|
|
655
|
-
};
|
|
656
|
-
}
|
|
657
|
-
else if (options.module) {
|
|
658
|
-
const items = queryModule(index, codeMap, options.module, limit);
|
|
659
|
-
result = {
|
|
660
|
-
type: 'module',
|
|
661
|
-
query: options.module,
|
|
662
|
-
count: items.length,
|
|
663
|
-
results: items,
|
|
664
|
-
};
|
|
665
|
-
}
|
|
666
|
-
else if (options.deps) {
|
|
667
|
-
// 依赖查询:根据 depsFormat 决定是否去重
|
|
668
|
-
// default 模式下去重,detailed 模式显示完整信息(包含 dependency 和 import)
|
|
669
|
-
const deduplicate = depsFormat !== 'detailed';
|
|
670
|
-
const items = queryDeps(index, codeMap, options.deps, limit, deduplicate);
|
|
671
|
-
result = {
|
|
672
|
-
type: 'deps',
|
|
673
|
-
query: options.deps,
|
|
674
|
-
count: items.length,
|
|
675
|
-
results: items,
|
|
676
|
-
};
|
|
677
|
-
}
|
|
678
|
-
else if (options.search) {
|
|
679
|
-
const items = search(index, codeMap, options.search, limit, useRegex, caseSensitive, contextLines);
|
|
680
|
-
result = {
|
|
681
|
-
type: 'search',
|
|
682
|
-
query: options.search,
|
|
683
|
-
count: items.length,
|
|
684
|
-
results: items,
|
|
685
|
-
};
|
|
686
|
-
}
|
|
687
|
-
else {
|
|
688
|
-
console.log(chalk.red('错误: 请指定查询类型: --symbol, --module, --deps, 或 --search'));
|
|
689
|
-
console.log(chalk.gray('\n用法:'));
|
|
690
|
-
console.log(chalk.gray(' codemap query --symbol <name> # 查询符号'));
|
|
691
|
-
console.log(chalk.gray(' codemap query --module <path> # 查询模块'));
|
|
692
|
-
console.log(chalk.gray(' codemap query --deps <name> # 查询依赖'));
|
|
693
|
-
console.log(chalk.gray(' codemap query --search <word> # 模糊搜索'));
|
|
694
|
-
console.log(chalk.gray('\n选项:'));
|
|
695
|
-
console.log(chalk.gray(' -l, --limit <number> 限制结果数量'));
|
|
696
|
-
console.log(chalk.gray(' -j, --json JSON 格式输出'));
|
|
697
|
-
console.log(chalk.gray(' -v, --verbose 显示性能指标'));
|
|
698
|
-
console.log(chalk.gray(' -r, --regex 使用正则表达式搜索'));
|
|
699
|
-
console.log(chalk.gray(' --deps-format 依赖查询格式 (default|detailed)'));
|
|
700
|
-
console.log(chalk.gray(' --no-cache 禁用缓存'));
|
|
701
|
-
process.exit(1);
|
|
702
|
-
}
|
|
703
|
-
const queryTime = performance.now() - queryStartTime;
|
|
704
|
-
const totalTime = performance.now() - startTotal;
|
|
705
|
-
// 添加性能指标
|
|
706
|
-
if (verbose) {
|
|
707
|
-
result.metrics = {
|
|
708
|
-
indexLoadTime,
|
|
709
|
-
queryTime,
|
|
710
|
-
totalTime,
|
|
711
|
-
cacheHit,
|
|
712
|
-
indexSize,
|
|
713
|
-
};
|
|
28
|
+
progress.fail();
|
|
29
|
+
process.stdout.write(formatError(error, mode, 'codemap query') + '\n');
|
|
30
|
+
process.exitCode = 1;
|
|
714
31
|
}
|
|
715
|
-
// 输出结果
|
|
716
|
-
formatResults(result, options.json || false, verbose, options.structured || false);
|
|
717
32
|
}
|
|
718
33
|
//# sourceMappingURL=query.js.map
|