@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,12 +1,15 @@
|
|
|
1
1
|
// [META] since:2024-03 | owner:core-team | stable:true
|
|
2
2
|
// [WHY] 提供代码地图生成 CLI 命令,协调分析器和生成器创建项目文档
|
|
3
3
|
import fs from 'node:fs/promises';
|
|
4
|
+
import { execFile } from 'node:child_process';
|
|
4
5
|
import path from 'node:path';
|
|
6
|
+
import { promisify } from 'node:util';
|
|
5
7
|
import chalk from 'chalk';
|
|
6
8
|
import ora from 'ora';
|
|
7
9
|
import { analyze } from '../../core/analyzer.js';
|
|
10
|
+
import { buildAnalysisContext } from '../../composition/parser-composition.js';
|
|
8
11
|
import { generateAIMap, generateJSON, generateContext, generateMermaidGraph } from '../../generator/index.js';
|
|
9
|
-
import { resolveOutputDir } from '../paths.js';
|
|
12
|
+
import { resolveDataPath, resolveOutputDir } from '../paths.js';
|
|
10
13
|
import { storageFactory } from '../../infrastructure/storage/StorageFactory.js';
|
|
11
14
|
import { CodeGraphRepositoryImpl } from '../../infrastructure/repositories/CodeGraphRepositoryImpl.js';
|
|
12
15
|
import { Project } from '../../domain/entities/Project.js';
|
|
@@ -17,6 +20,27 @@ import { CodeGraph } from '../../domain/entities/CodeGraph.js';
|
|
|
17
20
|
import { randomUUID } from 'crypto';
|
|
18
21
|
import { PluginSystem } from '../../plugins/index.js';
|
|
19
22
|
import { loadCodemapConfig } from '../config-loader.js';
|
|
23
|
+
import { formatError } from '../output/index.js';
|
|
24
|
+
import { collectIncrementalNeighborhood } from '../../infrastructure/storage/graph-helpers.js';
|
|
25
|
+
const execFileAsync = promisify(execFile);
|
|
26
|
+
class IncrementalRefreshFailure extends Error {
|
|
27
|
+
result;
|
|
28
|
+
constructor(result) {
|
|
29
|
+
super(result.refresh?.diagnostics[0]?.message ?? 'Incremental refresh failed');
|
|
30
|
+
this.result = result;
|
|
31
|
+
this.name = 'IncrementalRefreshFailure';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function resolveDependencyConfidence(evidenceKind) {
|
|
35
|
+
switch (evidenceKind) {
|
|
36
|
+
case 'direct-parser':
|
|
37
|
+
return 'EXTRACTED';
|
|
38
|
+
case 'heuristic':
|
|
39
|
+
return 'INFERRED';
|
|
40
|
+
case 'ambiguous-target':
|
|
41
|
+
return 'AMBIGUOUS';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
20
44
|
function hasExplicitOverride(value, source) {
|
|
21
45
|
if (source === undefined) {
|
|
22
46
|
return value !== undefined;
|
|
@@ -75,6 +99,146 @@ async function writePluginGeneratedFiles(files, outputDir) {
|
|
|
75
99
|
function createGeneratedId(prefix) {
|
|
76
100
|
return `${prefix}_${randomUUID().replace(/-/g, '').slice(0, 16)}`;
|
|
77
101
|
}
|
|
102
|
+
function createSilentSpinner() {
|
|
103
|
+
return {
|
|
104
|
+
start() {
|
|
105
|
+
return this;
|
|
106
|
+
},
|
|
107
|
+
stop() {
|
|
108
|
+
return this;
|
|
109
|
+
},
|
|
110
|
+
succeed() {
|
|
111
|
+
return this;
|
|
112
|
+
},
|
|
113
|
+
fail() {
|
|
114
|
+
return this;
|
|
115
|
+
},
|
|
116
|
+
text: '',
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function suppressConsoleNoise(enabled) {
|
|
120
|
+
if (!enabled) {
|
|
121
|
+
return () => undefined;
|
|
122
|
+
}
|
|
123
|
+
const originalLog = console.log;
|
|
124
|
+
const originalWarn = console.warn;
|
|
125
|
+
console.log = () => undefined;
|
|
126
|
+
console.warn = () => undefined;
|
|
127
|
+
return () => {
|
|
128
|
+
console.log = originalLog;
|
|
129
|
+
console.warn = originalWarn;
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function normalizePath(filePath) {
|
|
133
|
+
return filePath.replace(/\\/gu, '/');
|
|
134
|
+
}
|
|
135
|
+
function toAbsolutePath(rootDir, filePath) {
|
|
136
|
+
return normalizePath(path.resolve(rootDir, filePath));
|
|
137
|
+
}
|
|
138
|
+
function toRelativePattern(rootDir, filePath) {
|
|
139
|
+
return normalizePath(path.relative(rootDir, filePath));
|
|
140
|
+
}
|
|
141
|
+
function createRefreshDiagnostic(code, message) {
|
|
142
|
+
return { code, message };
|
|
143
|
+
}
|
|
144
|
+
function createEmptyAffected() {
|
|
145
|
+
return {
|
|
146
|
+
changed: [],
|
|
147
|
+
reused: [],
|
|
148
|
+
recomputed: [],
|
|
149
|
+
invalidated: [],
|
|
150
|
+
failed: [],
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
function createRefreshSummary(input) {
|
|
154
|
+
const affected = createEmptyAffected();
|
|
155
|
+
affected.changed = input.changedFiles.map((filePath) => ({
|
|
156
|
+
path: filePath,
|
|
157
|
+
reason: input.scopeSource === 'explicit' ? 'explicit changed file input' : 'git diff changed file',
|
|
158
|
+
}));
|
|
159
|
+
affected.reused = input.reusedFiles.map((filePath) => ({
|
|
160
|
+
path: filePath,
|
|
161
|
+
reason: 'outside invalidation boundary, reused existing truth',
|
|
162
|
+
}));
|
|
163
|
+
affected.recomputed = input.recomputedFiles.map((filePath) => ({
|
|
164
|
+
path: filePath,
|
|
165
|
+
reason: 'recomputed after 2-hop invalidation',
|
|
166
|
+
}));
|
|
167
|
+
affected.invalidated = input.invalidatedFiles.map((filePath) => ({
|
|
168
|
+
path: filePath,
|
|
169
|
+
reason: 'within 2-hop bidirectional invalidation boundary',
|
|
170
|
+
}));
|
|
171
|
+
affected.failed = input.failedFiles.map((filePath) => ({
|
|
172
|
+
path: filePath,
|
|
173
|
+
reason: 'recompute failed; kept previous persisted slice as stale truth',
|
|
174
|
+
}));
|
|
175
|
+
return {
|
|
176
|
+
status: input.status,
|
|
177
|
+
scopeSource: input.scopeSource,
|
|
178
|
+
counts: {
|
|
179
|
+
changed: input.changedFiles.length,
|
|
180
|
+
reused: input.reusedFiles.length,
|
|
181
|
+
recomputed: input.recomputedFiles.length,
|
|
182
|
+
invalidated: input.invalidatedFiles.length,
|
|
183
|
+
failed: input.failedFiles.length,
|
|
184
|
+
},
|
|
185
|
+
diagnostics: input.diagnostics,
|
|
186
|
+
affected,
|
|
187
|
+
remediation: input.remediation,
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
function createResult(input) {
|
|
191
|
+
return {
|
|
192
|
+
...input,
|
|
193
|
+
generated_at: input.generatedAt ?? new Date().toISOString(),
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
async function readCodeMapSnapshot(dataPath) {
|
|
197
|
+
const snapshot = await fs.readFile(dataPath, 'utf8');
|
|
198
|
+
return JSON.parse(snapshot);
|
|
199
|
+
}
|
|
200
|
+
async function resolveIncrementalScope(options, rootDir) {
|
|
201
|
+
const diagnostics = [];
|
|
202
|
+
if (options.changedFiles && options.changedFiles.length > 0) {
|
|
203
|
+
if (options.base || options.against) {
|
|
204
|
+
diagnostics.push(createRefreshDiagnostic('INCREMENTAL_CHANGED_FILES_OVERRIDE', '--changed-files 已显式提供,忽略 --base/--against'));
|
|
205
|
+
}
|
|
206
|
+
const changedFiles = options.changedFiles.map((filePath) => toAbsolutePath(rootDir, filePath));
|
|
207
|
+
return {
|
|
208
|
+
scopeSource: 'explicit',
|
|
209
|
+
changedFiles,
|
|
210
|
+
diagnostics,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
const diffBase = options.base ?? 'HEAD';
|
|
214
|
+
const diffAgainst = options.against ?? '';
|
|
215
|
+
const diffArgs = diffAgainst
|
|
216
|
+
? ['-C', rootDir, 'diff', '--name-only', `${diffBase}...${diffAgainst}`]
|
|
217
|
+
: ['-C', rootDir, 'diff', '--name-only', diffBase];
|
|
218
|
+
try {
|
|
219
|
+
const { stdout } = await execFileAsync('git', diffArgs);
|
|
220
|
+
const changedFiles = stdout
|
|
221
|
+
.split(/\r?\n/u)
|
|
222
|
+
.map((line) => line.trim())
|
|
223
|
+
.filter(Boolean)
|
|
224
|
+
.map((filePath) => toAbsolutePath(rootDir, filePath));
|
|
225
|
+
return {
|
|
226
|
+
scopeSource: 'git-diff',
|
|
227
|
+
changedFiles,
|
|
228
|
+
diagnostics,
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
catch (error) {
|
|
232
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
233
|
+
return {
|
|
234
|
+
scopeSource: 'git-diff',
|
|
235
|
+
changedFiles: [],
|
|
236
|
+
diagnostics: [
|
|
237
|
+
createRefreshDiagnostic('INCREMENTAL_SCOPE_UNRELIABLE', `无法从 git diff 解析 changed files: ${message}`),
|
|
238
|
+
],
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
}
|
|
78
242
|
function normalizeFileKey(rootDir, filePath) {
|
|
79
243
|
const absolutePath = path.isAbsolute(filePath)
|
|
80
244
|
? filePath
|
|
@@ -90,6 +254,12 @@ function normalizeSymbolLocation(modulePath, location) {
|
|
|
90
254
|
file: shouldUseModulePath ? modulePath : location.file,
|
|
91
255
|
};
|
|
92
256
|
}
|
|
257
|
+
function createModuleDependencyId(sourceModulePath, targetModulePath) {
|
|
258
|
+
return Dependency.createCanonicalId(Dependency.createModuleReference(sourceModulePath), Dependency.createModuleReference(targetModulePath), 'import', 'module', 'module');
|
|
259
|
+
}
|
|
260
|
+
function createSymbolDependencyId(sourceEntry, targetEntry, filePath) {
|
|
261
|
+
return Dependency.createCanonicalId(Dependency.createSymbolReference(sourceEntry.filePath, sourceEntry.name, sourceEntry.line, sourceEntry.column), Dependency.createSymbolReference(targetEntry.filePath, targetEntry.name, targetEntry.line, targetEntry.column), 'call', 'symbol', 'symbol', filePath);
|
|
262
|
+
}
|
|
93
263
|
function formatSymbolSignature(symbol) {
|
|
94
264
|
if (!symbol.signature) {
|
|
95
265
|
return undefined;
|
|
@@ -144,129 +314,484 @@ function resolveCallTarget(moduleInfo, call, rootDir, registryByFileAndName, reg
|
|
|
144
314
|
return globalCandidates.length === 1 ? globalCandidates[0] : null;
|
|
145
315
|
}
|
|
146
316
|
export async function generateCommand(options) {
|
|
147
|
-
|
|
317
|
+
if (options.structured && !options.json) {
|
|
318
|
+
throw new Error('--structured 需要配合 --json 使用');
|
|
319
|
+
}
|
|
320
|
+
const outputMode = options.json ? 'json' : 'human';
|
|
321
|
+
const spinner = (outputMode === 'json' ? createSilentSpinner() : ora('扫描项目文件...')).start();
|
|
322
|
+
const restoreConsole = suppressConsoleNoise(outputMode === 'json');
|
|
148
323
|
try {
|
|
149
|
-
const
|
|
324
|
+
const rootDir = process.cwd();
|
|
325
|
+
const loadedConfig = await loadCodemapConfig(rootDir);
|
|
150
326
|
const mode = hasExplicitOverride(options.mode, options.__optionSources?.mode)
|
|
151
327
|
? options.mode
|
|
152
328
|
: loadedConfig.config.mode;
|
|
153
329
|
const configuredOutput = hasExplicitOverride(options.output, options.__optionSources?.output)
|
|
154
330
|
? options.output
|
|
155
331
|
: loadedConfig.config.output;
|
|
156
|
-
const { outputDir, isLegacy } = resolveOutputDir(configuredOutput);
|
|
157
|
-
|
|
158
|
-
|
|
332
|
+
const { outputDir, isLegacy } = resolveOutputDir(configuredOutput, rootDir);
|
|
333
|
+
const runIncremental = options.incremental === true
|
|
334
|
+
|| (options.changedFiles?.length ?? 0) > 0
|
|
335
|
+
|| Boolean(options.base)
|
|
336
|
+
|| Boolean(options.against);
|
|
337
|
+
if (outputMode === 'human') {
|
|
338
|
+
console.log(chalk.blue('🔍 使用默认 parser 主路径生成代码地图...'));
|
|
159
339
|
}
|
|
160
|
-
|
|
161
|
-
console.log(chalk.blue(`🔍 使用 ${mode} 模式生成代码地图...`));
|
|
162
|
-
}
|
|
163
|
-
if (isLegacy) {
|
|
340
|
+
if (outputMode === 'human' && isLegacy) {
|
|
164
341
|
console.warn(chalk.yellow('⚠️ 检测到使用旧目录 .codemap,请迁移到 .mycodemap'));
|
|
165
342
|
}
|
|
166
|
-
if (loadedConfig.exists && loadedConfig.isLegacy) {
|
|
343
|
+
if (outputMode === 'human' && loadedConfig.exists && loadedConfig.isLegacy) {
|
|
167
344
|
console.warn(chalk.yellow('⚠️ 检测到旧配置文件 codemap.config.json,建议迁移到 mycodemap.config.json'));
|
|
168
345
|
}
|
|
169
|
-
// 执行分析(保持原始 output 传递以向后兼容)
|
|
170
346
|
const analysisOptions = {
|
|
171
347
|
mode,
|
|
172
|
-
rootDir
|
|
348
|
+
rootDir,
|
|
173
349
|
include: loadedConfig.config.include,
|
|
174
350
|
exclude: loadedConfig.config.exclude,
|
|
175
351
|
output: configuredOutput || '.mycodemap',
|
|
176
352
|
watch: loadedConfig.config.watch,
|
|
177
353
|
};
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
const writtenPluginFiles = await writePluginGeneratedFiles(pluginGenerateRun.allFiles, outputDir);
|
|
194
|
-
generatedPluginFiles = writtenPluginFiles.writtenFiles;
|
|
195
|
-
pluginDiagnostics.push(...pluginGenerateRun.diagnostics, ...writtenPluginFiles.diagnostics);
|
|
196
|
-
loadedPlugins = pluginSystem.getLoadedPlugins();
|
|
197
|
-
}
|
|
198
|
-
catch (error) {
|
|
199
|
-
const reason = error instanceof Error ? error.message : String(error);
|
|
200
|
-
pluginDiagnostics.push({
|
|
201
|
-
stage: 'generate',
|
|
202
|
-
level: 'error',
|
|
203
|
-
message: `插件运行时主流程失败: ${reason}`,
|
|
354
|
+
let result;
|
|
355
|
+
if (runIncremental) {
|
|
356
|
+
if (loadedConfig.hasExplicitPluginConfig) {
|
|
357
|
+
const refresh = createRefreshSummary({
|
|
358
|
+
status: 'failed',
|
|
359
|
+
scopeSource: options.changedFiles?.length ? 'explicit' : 'git-diff',
|
|
360
|
+
changedFiles: [],
|
|
361
|
+
reusedFiles: [],
|
|
362
|
+
recomputedFiles: [],
|
|
363
|
+
invalidatedFiles: [],
|
|
364
|
+
failedFiles: [],
|
|
365
|
+
diagnostics: [
|
|
366
|
+
createRefreshDiagnostic('INCREMENTAL_FULL_REBUILD_REQUIRED', '插件参与的 generate 当前不支持 scoped incremental refresh,请先运行完整 generate。'),
|
|
367
|
+
],
|
|
368
|
+
remediation: 'Run `mycodemap generate --symbol-level` to rebuild full truth.',
|
|
204
369
|
});
|
|
370
|
+
throw new IncrementalRefreshFailure(createResult({
|
|
371
|
+
status: 'failed',
|
|
372
|
+
mode: 'incremental',
|
|
373
|
+
graph_status: 'partial',
|
|
374
|
+
storage_type: String(loadedConfig.config.storage.type),
|
|
375
|
+
output_dir: outputDir,
|
|
376
|
+
refresh,
|
|
377
|
+
}));
|
|
205
378
|
}
|
|
206
|
-
|
|
379
|
+
spinner.text = '解析 changed files 与增量范围...';
|
|
380
|
+
result = await runIncrementalGenerate({
|
|
381
|
+
options,
|
|
382
|
+
analysisOptions,
|
|
383
|
+
outputDir,
|
|
384
|
+
storageConfig: loadedConfig.config.storage,
|
|
385
|
+
});
|
|
386
|
+
if (outputMode === 'human') {
|
|
387
|
+
spinner.succeed(chalk.green(result.status === 'partial' ? '⚠️ 增量刷新完成(partial)' : '✅ 增量刷新完成!'));
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
else {
|
|
391
|
+
const codeMap = await analyze({
|
|
392
|
+
...analysisOptions,
|
|
393
|
+
...buildAnalysisContext(analysisOptions.rootDir, analysisOptions.enhanceTypes ?? true),
|
|
394
|
+
});
|
|
395
|
+
let pluginReport;
|
|
396
|
+
if (loadedConfig.hasExplicitPluginConfig) {
|
|
397
|
+
const pluginSystem = new PluginSystem(loadedConfig.config);
|
|
398
|
+
const pluginDiagnostics = [];
|
|
399
|
+
let loadedPlugins = [];
|
|
400
|
+
let generatedPluginFiles = [];
|
|
401
|
+
let pluginMetrics = {};
|
|
207
402
|
try {
|
|
208
|
-
await pluginSystem.
|
|
403
|
+
pluginDiagnostics.push(...await pluginSystem.initialize(loadedConfig.config.plugins));
|
|
404
|
+
const pluginAnalyzeRun = await pluginSystem.runAnalyze(codeMap.modules);
|
|
405
|
+
codeMap.dependencies.edges = mergePluginDependencyEdges(codeMap.dependencies.edges, pluginAnalyzeRun.additionalEdges);
|
|
406
|
+
pluginMetrics = pluginAnalyzeRun.mergedMetrics;
|
|
407
|
+
pluginDiagnostics.push(...pluginAnalyzeRun.diagnostics);
|
|
408
|
+
const pluginGenerateRun = await pluginSystem.runGenerate(codeMap);
|
|
409
|
+
const writtenPluginFiles = await writePluginGeneratedFiles(pluginGenerateRun.allFiles, outputDir);
|
|
410
|
+
generatedPluginFiles = writtenPluginFiles.writtenFiles;
|
|
411
|
+
pluginDiagnostics.push(...pluginGenerateRun.diagnostics, ...writtenPluginFiles.diagnostics);
|
|
412
|
+
loadedPlugins = pluginSystem.getLoadedPlugins();
|
|
209
413
|
}
|
|
210
414
|
catch (error) {
|
|
211
415
|
const reason = error instanceof Error ? error.message : String(error);
|
|
212
416
|
pluginDiagnostics.push({
|
|
213
417
|
stage: 'generate',
|
|
214
418
|
level: 'error',
|
|
215
|
-
message:
|
|
419
|
+
message: `插件运行时主流程失败: ${reason}`,
|
|
216
420
|
});
|
|
217
421
|
}
|
|
422
|
+
finally {
|
|
423
|
+
try {
|
|
424
|
+
await pluginSystem.dispose();
|
|
425
|
+
}
|
|
426
|
+
catch (error) {
|
|
427
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
428
|
+
pluginDiagnostics.push({
|
|
429
|
+
stage: 'generate',
|
|
430
|
+
level: 'error',
|
|
431
|
+
message: `插件系统释放失败: ${reason}`,
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
pluginReport = createPluginReport(loadedPlugins, generatedPluginFiles, pluginMetrics, pluginDiagnostics);
|
|
436
|
+
codeMap.pluginReport = pluginReport;
|
|
437
|
+
}
|
|
438
|
+
spinner.text = '生成输出文件...';
|
|
439
|
+
await generateAIMap(codeMap, outputDir);
|
|
440
|
+
await generateJSON(codeMap, outputDir);
|
|
441
|
+
await generateMermaidGraph(codeMap, outputDir);
|
|
442
|
+
await generateContext(codeMap, outputDir);
|
|
443
|
+
spinner.text = '保存到代码图存储...';
|
|
444
|
+
const storageSaveResult = await saveToCodeGraphStorage(codeMap, loadedConfig.config.storage, options.symbolLevel === true);
|
|
445
|
+
result = createResult({
|
|
446
|
+
status: 'success',
|
|
447
|
+
mode: 'full',
|
|
448
|
+
graph_status: codeMap.graphStatus ?? 'complete',
|
|
449
|
+
storage_type: storageSaveResult.storageType,
|
|
450
|
+
output_dir: outputDir,
|
|
451
|
+
generatedAt: codeMap.generatedAt,
|
|
452
|
+
});
|
|
453
|
+
if (outputMode === 'human') {
|
|
454
|
+
spinner.succeed(chalk.green('✅ 代码地图生成完成!'));
|
|
455
|
+
logHumanGenerateSummary(codeMap, storageSaveResult.storageType, pluginReport);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
emitGenerateResult(result, outputMode, options.structured === true);
|
|
459
|
+
return result;
|
|
460
|
+
}
|
|
461
|
+
catch (error) {
|
|
462
|
+
if (error instanceof IncrementalRefreshFailure) {
|
|
463
|
+
if (outputMode === 'human') {
|
|
464
|
+
spinner.fail(chalk.red('❌ 增量刷新失败'));
|
|
218
465
|
}
|
|
219
|
-
|
|
220
|
-
codeMap.pluginReport = pluginReport;
|
|
466
|
+
emitGenerateResult(error.result, outputMode, options.structured === true);
|
|
221
467
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
// 生成上下文文件(不带 AI 描述)
|
|
228
|
-
await generateContext(codeMap, outputDir);
|
|
229
|
-
// 保存到 MVP3 storage
|
|
230
|
-
spinner.text = '保存到代码图存储...';
|
|
231
|
-
const storageSaveResult = await saveToCodeGraphStorage(codeMap, loadedConfig.config.storage, options.symbolLevel === true);
|
|
232
|
-
spinner.succeed(chalk.green('✅ 代码地图生成完成!'));
|
|
233
|
-
// 显示摘要
|
|
234
|
-
console.log(chalk.gray('\n📊 项目统计:'));
|
|
235
|
-
console.log(chalk.gray(` 文件总数: ${codeMap.summary.totalFiles}`));
|
|
236
|
-
console.log(chalk.gray(` 代码行数: ${codeMap.summary.totalLines}`));
|
|
237
|
-
console.log(chalk.gray(` 模块数量: ${codeMap.summary.totalModules}`));
|
|
238
|
-
console.log(chalk.gray(` 导出符号: ${codeMap.summary.totalExports}`));
|
|
239
|
-
console.log(chalk.gray(` 图状态: ${codeMap.graphStatus ?? 'complete'}`
|
|
240
|
-
+ (codeMap.failedFileCount && codeMap.failedFileCount > 0
|
|
241
|
-
? ` (${codeMap.failedFileCount} 个文件失败)`
|
|
242
|
-
: '')));
|
|
243
|
-
// 显示实际使用的模式(Hybrid 模式下)
|
|
244
|
-
if (codeMap.actualMode) {
|
|
245
|
-
console.log(chalk.gray(` 解析模式: ${codeMap.actualMode} (自动选择)`));
|
|
468
|
+
else {
|
|
469
|
+
if (outputMode === 'human') {
|
|
470
|
+
spinner.fail(chalk.red('❌ 生成失败'));
|
|
471
|
+
}
|
|
472
|
+
console.error(formatError(error, outputMode, 'mycodemap generate'));
|
|
246
473
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
console.log(chalk.gray(
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
474
|
+
process.exit(1);
|
|
475
|
+
}
|
|
476
|
+
finally {
|
|
477
|
+
restoreConsole();
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
function emitGenerateResult(result, outputMode, structured) {
|
|
481
|
+
if (outputMode === 'human') {
|
|
482
|
+
if (result.mode === 'incremental' && result.refresh) {
|
|
483
|
+
console.log(chalk.gray('\n🔄 增量刷新摘要:'));
|
|
484
|
+
console.log(chalk.gray(` 状态: ${result.refresh.status}`));
|
|
485
|
+
console.log(chalk.gray(` changed/reused/recomputed/invalidated/failed: ${result.refresh.counts.changed}/${result.refresh.counts.reused}/${result.refresh.counts.recomputed}/${result.refresh.counts.invalidated}/${result.refresh.counts.failed}`));
|
|
486
|
+
if (result.refresh.diagnostics.length > 0) {
|
|
487
|
+
console.log(chalk.gray(' diagnostics:'));
|
|
488
|
+
for (const diagnostic of result.refresh.diagnostics) {
|
|
489
|
+
console.log(chalk.gray(` - ${diagnostic.code}: ${diagnostic.message}`));
|
|
262
490
|
}
|
|
263
491
|
}
|
|
264
492
|
}
|
|
493
|
+
return;
|
|
265
494
|
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
495
|
+
const payload = structured
|
|
496
|
+
? result
|
|
497
|
+
: {
|
|
498
|
+
status: result.status,
|
|
499
|
+
mode: result.mode,
|
|
500
|
+
graph_status: result.graph_status,
|
|
501
|
+
generated_at: result.generated_at,
|
|
502
|
+
storage_type: result.storage_type,
|
|
503
|
+
output_dir: result.output_dir,
|
|
504
|
+
refresh: result.refresh,
|
|
505
|
+
};
|
|
506
|
+
process.stdout.write(`${JSON.stringify(payload, null, 2)}\n`);
|
|
507
|
+
}
|
|
508
|
+
function logHumanGenerateSummary(codeMap, storageType, pluginReport) {
|
|
509
|
+
console.log(chalk.gray('\n📊 项目统计:'));
|
|
510
|
+
console.log(chalk.gray(` 文件总数: ${codeMap.summary.totalFiles}`));
|
|
511
|
+
console.log(chalk.gray(` 代码行数: ${codeMap.summary.totalLines}`));
|
|
512
|
+
console.log(chalk.gray(` 模块数量: ${codeMap.summary.totalModules}`));
|
|
513
|
+
console.log(chalk.gray(` 导出符号: ${codeMap.summary.totalExports}`));
|
|
514
|
+
console.log(chalk.gray(` 图状态: ${codeMap.graphStatus ?? 'complete'}`
|
|
515
|
+
+ (codeMap.failedFileCount && codeMap.failedFileCount > 0
|
|
516
|
+
? ` (${codeMap.failedFileCount} 个文件失败)`
|
|
517
|
+
: '')));
|
|
518
|
+
console.log(chalk.gray('\n📁 输出文件:'));
|
|
519
|
+
console.log(chalk.gray(' AI_MAP.md'));
|
|
520
|
+
console.log(chalk.gray(' codemap.json'));
|
|
521
|
+
console.log(chalk.gray(' dependency-graph.md'));
|
|
522
|
+
console.log(chalk.gray(` context/ (${codeMap.summary.totalFiles} 个文件)`));
|
|
523
|
+
console.log(chalk.gray(` 治理图存储 (${storageType})`));
|
|
524
|
+
if (!pluginReport) {
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
console.log(chalk.gray('\n🔌 插件摘要:'));
|
|
528
|
+
console.log(chalk.gray(` 已加载插件: ${pluginReport.loadedPlugins.length > 0 ? pluginReport.loadedPlugins.join(', ') : '0 个'}`));
|
|
529
|
+
console.log(chalk.gray(` 插件生成文件: ${pluginReport.generatedFiles.length}`));
|
|
530
|
+
if (pluginReport.diagnostics.length > 0) {
|
|
531
|
+
console.warn(chalk.yellow(`⚠️ 插件诊断: ${pluginReport.diagnostics.length} 条`));
|
|
532
|
+
for (const diagnostic of pluginReport.diagnostics.slice(0, 5)) {
|
|
533
|
+
const pluginLabel = diagnostic.plugin ? `${diagnostic.plugin} / ` : '';
|
|
534
|
+
console.warn(chalk.yellow(` - ${pluginLabel}${diagnostic.stage}: ${diagnostic.message}`));
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
async function runIncrementalGenerate(input) {
|
|
539
|
+
const { options, analysisOptions, outputDir, storageConfig } = input;
|
|
540
|
+
const rootDir = analysisOptions.rootDir;
|
|
541
|
+
const dataPath = resolveDataPath(rootDir, analysisOptions.output);
|
|
542
|
+
const storage = await storageFactory.createForProject(rootDir, storageConfig);
|
|
543
|
+
try {
|
|
544
|
+
const previousGraph = await storage.loadCodeGraph().catch(() => null);
|
|
545
|
+
if (!previousGraph) {
|
|
546
|
+
const refresh = createRefreshSummary({
|
|
547
|
+
status: 'failed',
|
|
548
|
+
scopeSource: options.changedFiles?.length ? 'explicit' : 'git-diff',
|
|
549
|
+
changedFiles: [],
|
|
550
|
+
reusedFiles: [],
|
|
551
|
+
recomputedFiles: [],
|
|
552
|
+
invalidatedFiles: [],
|
|
553
|
+
failedFiles: [],
|
|
554
|
+
diagnostics: [
|
|
555
|
+
createRefreshDiagnostic('INCREMENTAL_FULL_REBUILD_REQUIRED', '未检测到已持久化 graph truth,不能安全执行 scoped incremental refresh。'),
|
|
556
|
+
],
|
|
557
|
+
remediation: 'Run `mycodemap generate --symbol-level` to create the initial full graph.',
|
|
558
|
+
});
|
|
559
|
+
throw new IncrementalRefreshFailure(createResult({
|
|
560
|
+
status: 'failed',
|
|
561
|
+
mode: 'incremental',
|
|
562
|
+
graph_status: 'partial',
|
|
563
|
+
storage_type: String(storage.type),
|
|
564
|
+
output_dir: outputDir,
|
|
565
|
+
refresh,
|
|
566
|
+
}));
|
|
567
|
+
}
|
|
568
|
+
const previousCodeMap = await readCodeMapSnapshot(dataPath).catch(() => null);
|
|
569
|
+
if (!previousCodeMap) {
|
|
570
|
+
const refresh = createRefreshSummary({
|
|
571
|
+
status: 'failed',
|
|
572
|
+
scopeSource: options.changedFiles?.length ? 'explicit' : 'git-diff',
|
|
573
|
+
changedFiles: [],
|
|
574
|
+
reusedFiles: [],
|
|
575
|
+
recomputedFiles: [],
|
|
576
|
+
invalidatedFiles: [],
|
|
577
|
+
failedFiles: [],
|
|
578
|
+
diagnostics: [
|
|
579
|
+
createRefreshDiagnostic('INCREMENTAL_FULL_REBUILD_REQUIRED', '缺少现有 codemap.json,不能证明 direct-execution truth 与 SQLite truth 同步。'),
|
|
580
|
+
],
|
|
581
|
+
remediation: 'Run `mycodemap generate --symbol-level` to rebuild both SQLite and codemap.json truth.',
|
|
582
|
+
});
|
|
583
|
+
throw new IncrementalRefreshFailure(createResult({
|
|
584
|
+
status: 'failed',
|
|
585
|
+
mode: 'incremental',
|
|
586
|
+
graph_status: previousGraph.graphStatus ?? 'partial',
|
|
587
|
+
storage_type: String(storage.type),
|
|
588
|
+
output_dir: outputDir,
|
|
589
|
+
refresh,
|
|
590
|
+
}));
|
|
591
|
+
}
|
|
592
|
+
const scope = await resolveIncrementalScope(options, rootDir);
|
|
593
|
+
const changedFiles = Array.from(new Set(scope.changedFiles));
|
|
594
|
+
const existingModulePaths = new Set(previousGraph.modules.map((module) => normalizePath(module.path)));
|
|
595
|
+
const missingChangedFile = changedFiles.find((filePath) => !existingModulePaths.has(filePath));
|
|
596
|
+
if (scope.diagnostics.some((diagnostic) => diagnostic.code === 'INCREMENTAL_SCOPE_UNRELIABLE')) {
|
|
597
|
+
const refresh = createRefreshSummary({
|
|
598
|
+
status: 'failed',
|
|
599
|
+
scopeSource: scope.scopeSource,
|
|
600
|
+
changedFiles: changedFiles.map((filePath) => toRelativePattern(rootDir, filePath)),
|
|
601
|
+
reusedFiles: [],
|
|
602
|
+
recomputedFiles: [],
|
|
603
|
+
invalidatedFiles: [],
|
|
604
|
+
failedFiles: [],
|
|
605
|
+
diagnostics: scope.diagnostics,
|
|
606
|
+
remediation: 'Run `mycodemap generate --symbol-level` to perform a full rebuild.',
|
|
607
|
+
});
|
|
608
|
+
throw new IncrementalRefreshFailure(createResult({
|
|
609
|
+
status: 'failed',
|
|
610
|
+
mode: 'incremental',
|
|
611
|
+
graph_status: previousGraph.graphStatus ?? 'partial',
|
|
612
|
+
storage_type: String(storage.type),
|
|
613
|
+
output_dir: outputDir,
|
|
614
|
+
refresh,
|
|
615
|
+
}));
|
|
616
|
+
}
|
|
617
|
+
if (changedFiles.length === 0) {
|
|
618
|
+
const refresh = createRefreshSummary({
|
|
619
|
+
status: 'failed',
|
|
620
|
+
scopeSource: scope.scopeSource,
|
|
621
|
+
changedFiles: [],
|
|
622
|
+
reusedFiles: [],
|
|
623
|
+
recomputedFiles: [],
|
|
624
|
+
invalidatedFiles: [],
|
|
625
|
+
failedFiles: [],
|
|
626
|
+
diagnostics: [
|
|
627
|
+
...scope.diagnostics,
|
|
628
|
+
createRefreshDiagnostic('INCREMENTAL_SCOPE_EMPTY', 'changed-file set 为空,拒绝静默退化为 full generate。'),
|
|
629
|
+
],
|
|
630
|
+
remediation: 'Provide --changed-files or make workspace changes, otherwise run full generate explicitly.',
|
|
631
|
+
});
|
|
632
|
+
throw new IncrementalRefreshFailure(createResult({
|
|
633
|
+
status: 'failed',
|
|
634
|
+
mode: 'incremental',
|
|
635
|
+
graph_status: previousGraph.graphStatus ?? 'partial',
|
|
636
|
+
storage_type: String(storage.type),
|
|
637
|
+
output_dir: outputDir,
|
|
638
|
+
refresh,
|
|
639
|
+
}));
|
|
640
|
+
}
|
|
641
|
+
if (missingChangedFile) {
|
|
642
|
+
const refresh = createRefreshSummary({
|
|
643
|
+
status: 'failed',
|
|
644
|
+
scopeSource: scope.scopeSource,
|
|
645
|
+
changedFiles: changedFiles.map((filePath) => toRelativePattern(rootDir, filePath)),
|
|
646
|
+
reusedFiles: [],
|
|
647
|
+
recomputedFiles: [],
|
|
648
|
+
invalidatedFiles: [],
|
|
649
|
+
failedFiles: [],
|
|
650
|
+
diagnostics: [
|
|
651
|
+
...scope.diagnostics,
|
|
652
|
+
createRefreshDiagnostic('INCREMENTAL_INVALIDATION_BOUNDARY_UNRESOLVED', `changed file 不在当前 persisted graph truth 中: ${toRelativePattern(rootDir, missingChangedFile)}`),
|
|
653
|
+
],
|
|
654
|
+
remediation: 'Run `mycodemap generate --symbol-level` to rebuild full truth before retrying incremental refresh.',
|
|
655
|
+
});
|
|
656
|
+
throw new IncrementalRefreshFailure(createResult({
|
|
657
|
+
status: 'failed',
|
|
658
|
+
mode: 'incremental',
|
|
659
|
+
graph_status: previousGraph.graphStatus ?? 'partial',
|
|
660
|
+
storage_type: String(storage.type),
|
|
661
|
+
output_dir: outputDir,
|
|
662
|
+
refresh,
|
|
663
|
+
}));
|
|
664
|
+
}
|
|
665
|
+
const neighborhood = collectIncrementalNeighborhood(previousGraph, changedFiles);
|
|
666
|
+
const invalidatedPaths = Array.from(new Set(neighborhood.invalidatedModulePaths));
|
|
667
|
+
if (invalidatedPaths.length === 0) {
|
|
668
|
+
const refresh = createRefreshSummary({
|
|
669
|
+
status: 'failed',
|
|
670
|
+
scopeSource: scope.scopeSource,
|
|
671
|
+
changedFiles: changedFiles.map((filePath) => toRelativePattern(rootDir, filePath)),
|
|
672
|
+
reusedFiles: [],
|
|
673
|
+
recomputedFiles: [],
|
|
674
|
+
invalidatedFiles: [],
|
|
675
|
+
failedFiles: [],
|
|
676
|
+
diagnostics: [
|
|
677
|
+
...scope.diagnostics,
|
|
678
|
+
createRefreshDiagnostic('INCREMENTAL_INVALIDATION_BOUNDARY_UNRESOLVED', '未能从 persisted graph truth 推导有效的 2-hop invalidation boundary。'),
|
|
679
|
+
],
|
|
680
|
+
remediation: 'Run `mycodemap generate --symbol-level` to perform a full rebuild.',
|
|
681
|
+
});
|
|
682
|
+
throw new IncrementalRefreshFailure(createResult({
|
|
683
|
+
status: 'failed',
|
|
684
|
+
mode: 'incremental',
|
|
685
|
+
graph_status: previousGraph.graphStatus ?? 'partial',
|
|
686
|
+
storage_type: String(storage.type),
|
|
687
|
+
output_dir: outputDir,
|
|
688
|
+
refresh,
|
|
689
|
+
}));
|
|
690
|
+
}
|
|
691
|
+
const symbolLevel = options.symbolLevel === true || previousGraph.dependencies.some((dependency) => dependency.sourceEntityType === 'symbol' || dependency.targetEntityType === 'symbol');
|
|
692
|
+
const incrementalCodeMap = await analyze({
|
|
693
|
+
...analysisOptions,
|
|
694
|
+
include: invalidatedPaths.map((filePath) => toRelativePattern(rootDir, filePath)),
|
|
695
|
+
...buildAnalysisContext(rootDir, analysisOptions.enhanceTypes ?? true),
|
|
696
|
+
});
|
|
697
|
+
const recomputedPaths = Array.from(new Set(incrementalCodeMap.modules.map((moduleInfo) => normalizePath(moduleInfo.absolutePath || moduleInfo.path))));
|
|
698
|
+
const failedPaths = invalidatedPaths.filter((filePath) => !recomputedPaths.includes(filePath));
|
|
699
|
+
const invalidatedSet = new Set(invalidatedPaths);
|
|
700
|
+
const recomputedSet = new Set(recomputedPaths);
|
|
701
|
+
const oldFailureSet = new Set((previousCodeMap.parseFailureFiles ?? []).map((filePath) => toAbsolutePath(rootDir, filePath)));
|
|
702
|
+
const retainedOldFailures = Array.from(oldFailureSet).filter((filePath) => !recomputedSet.has(filePath));
|
|
703
|
+
const mergedFailurePaths = Array.from(new Set([
|
|
704
|
+
...retainedOldFailures,
|
|
705
|
+
...failedPaths,
|
|
706
|
+
])).sort();
|
|
707
|
+
const previousModules = previousCodeMap.modules.filter((moduleInfo) => !recomputedSet.has(normalizePath(moduleInfo.absolutePath || moduleInfo.path)));
|
|
708
|
+
const mergedModules = [
|
|
709
|
+
...previousModules,
|
|
710
|
+
...incrementalCodeMap.modules,
|
|
711
|
+
].sort((left, right) => normalizePath(left.path).localeCompare(normalizePath(right.path)));
|
|
712
|
+
const reusedFiles = previousCodeMap.modules
|
|
713
|
+
.map((moduleInfo) => normalizePath(moduleInfo.absolutePath || moduleInfo.path))
|
|
714
|
+
.filter((filePath) => !invalidatedSet.has(filePath))
|
|
715
|
+
.sort();
|
|
716
|
+
const refreshStatus = recomputedPaths.length === 0
|
|
717
|
+
? 'failed'
|
|
718
|
+
: failedPaths.length > 0
|
|
719
|
+
? 'partial'
|
|
720
|
+
: 'success';
|
|
721
|
+
const diagnostics = [...scope.diagnostics];
|
|
722
|
+
if (failedPaths.length > 0) {
|
|
723
|
+
diagnostics.push(createRefreshDiagnostic('INCREMENTAL_PARTIAL_SLICE_FAILURE', `共有 ${failedPaths.length} 个 slice 重算失败,已保留旧 truth。`));
|
|
724
|
+
}
|
|
725
|
+
diagnostics.push(createRefreshDiagnostic('INCREMENTAL_SNAPSHOT_REPLACED', '已保留单个 pre-refresh snapshot,并用最新 refresh 覆盖旧 snapshot。'));
|
|
726
|
+
const remediation = refreshStatus === 'failed'
|
|
727
|
+
? 'Run `mycodemap generate --symbol-level` to perform a full rebuild.'
|
|
728
|
+
: undefined;
|
|
729
|
+
const mergedCodeMap = {
|
|
730
|
+
...previousCodeMap,
|
|
731
|
+
generatedAt: new Date().toISOString(),
|
|
732
|
+
modules: mergedModules,
|
|
733
|
+
summary: calculateProjectSummary(mergedModules),
|
|
734
|
+
dependencies: buildDependencyGraphForModules(mergedModules),
|
|
735
|
+
graphStatus: mergedFailurePaths.length > 0 ? 'partial' : 'complete',
|
|
736
|
+
failedFileCount: mergedFailurePaths.length,
|
|
737
|
+
parseFailureFiles: mergedFailurePaths.map((filePath) => toRelativePattern(rootDir, filePath)),
|
|
738
|
+
};
|
|
739
|
+
mergedCodeMap.lastRefresh = createRefreshSummary({
|
|
740
|
+
status: refreshStatus,
|
|
741
|
+
scopeSource: scope.scopeSource,
|
|
742
|
+
changedFiles: changedFiles.map((filePath) => toRelativePattern(rootDir, filePath)),
|
|
743
|
+
reusedFiles: reusedFiles.map((filePath) => toRelativePattern(rootDir, filePath)),
|
|
744
|
+
recomputedFiles: recomputedPaths.map((filePath) => toRelativePattern(rootDir, filePath)),
|
|
745
|
+
invalidatedFiles: invalidatedPaths.map((filePath) => toRelativePattern(rootDir, filePath)),
|
|
746
|
+
failedFiles: failedPaths.map((filePath) => toRelativePattern(rootDir, filePath)),
|
|
747
|
+
diagnostics,
|
|
748
|
+
remediation,
|
|
749
|
+
});
|
|
750
|
+
const repository = new CodeGraphRepositoryImpl(storage);
|
|
751
|
+
const mergedGraph = convertToCodeGraph(mergedCodeMap, { symbolLevel });
|
|
752
|
+
try {
|
|
753
|
+
await repository.saveWithRefreshSummary(mergedGraph, mergedCodeMap.lastRefresh);
|
|
754
|
+
}
|
|
755
|
+
catch (error) {
|
|
756
|
+
const refresh = createRefreshSummary({
|
|
757
|
+
status: 'failed',
|
|
758
|
+
scopeSource: scope.scopeSource,
|
|
759
|
+
changedFiles: changedFiles.map((filePath) => toRelativePattern(rootDir, filePath)),
|
|
760
|
+
reusedFiles: reusedFiles.map((filePath) => toRelativePattern(rootDir, filePath)),
|
|
761
|
+
recomputedFiles: recomputedPaths.map((filePath) => toRelativePattern(rootDir, filePath)),
|
|
762
|
+
invalidatedFiles: invalidatedPaths.map((filePath) => toRelativePattern(rootDir, filePath)),
|
|
763
|
+
failedFiles: failedPaths.map((filePath) => toRelativePattern(rootDir, filePath)),
|
|
764
|
+
diagnostics: [
|
|
765
|
+
...diagnostics,
|
|
766
|
+
createRefreshDiagnostic('INCREMENTAL_WRITEBACK_FAILED', error instanceof Error ? error.message : String(error)),
|
|
767
|
+
],
|
|
768
|
+
remediation: 'Run `mycodemap generate --symbol-level` to restore persisted truth.',
|
|
769
|
+
});
|
|
770
|
+
throw new IncrementalRefreshFailure(createResult({
|
|
771
|
+
status: 'failed',
|
|
772
|
+
mode: 'incremental',
|
|
773
|
+
graph_status: mergedCodeMap.graphStatus ?? 'partial',
|
|
774
|
+
storage_type: String(storage.type),
|
|
775
|
+
output_dir: outputDir,
|
|
776
|
+
refresh,
|
|
777
|
+
}));
|
|
778
|
+
}
|
|
779
|
+
await generateJSON(mergedCodeMap, outputDir);
|
|
780
|
+
await generateAIMap(mergedCodeMap, outputDir);
|
|
781
|
+
await generateMermaidGraph(mergedCodeMap, outputDir);
|
|
782
|
+
await generateContext(mergedCodeMap, outputDir);
|
|
783
|
+
return createResult({
|
|
784
|
+
status: refreshStatus,
|
|
785
|
+
mode: 'incremental',
|
|
786
|
+
graph_status: mergedCodeMap.graphStatus ?? 'complete',
|
|
787
|
+
storage_type: String(storage.type),
|
|
788
|
+
output_dir: outputDir,
|
|
789
|
+
generatedAt: mergedCodeMap.generatedAt,
|
|
790
|
+
refresh: mergedCodeMap.lastRefresh,
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
finally {
|
|
794
|
+
await storage.close();
|
|
270
795
|
}
|
|
271
796
|
}
|
|
272
797
|
/**
|
|
@@ -324,8 +849,10 @@ function convertToCodeGraph(codeMap, options) {
|
|
|
324
849
|
const registryEntry = {
|
|
325
850
|
id: symbolEntity.id,
|
|
326
851
|
name: symbolEntity.name,
|
|
852
|
+
filePath: normalizedLocation.file,
|
|
327
853
|
fileKey: normalizeFileKey(codeMap.project.rootDir, normalizedLocation.file),
|
|
328
854
|
line: normalizedLocation.line,
|
|
855
|
+
column: normalizedLocation.column,
|
|
329
856
|
};
|
|
330
857
|
registerSymbolEntry(symbolRegistryByFileAndName, symbolRegistryByName, symbolRegistryByFileAndLine, registryEntry);
|
|
331
858
|
}
|
|
@@ -339,7 +866,7 @@ function convertToCodeGraph(codeMap, options) {
|
|
|
339
866
|
const targetId = moduleIdMap.get(depPath);
|
|
340
867
|
if (!targetId)
|
|
341
868
|
continue; // 外部依赖,跳过
|
|
342
|
-
const dependency = new Dependency(
|
|
869
|
+
const dependency = new Dependency(createModuleDependencyId(mod.path, depPath), sourceId, targetId, 'import', 'module', 'module', resolveDependencyConfidence('direct-parser'));
|
|
343
870
|
try {
|
|
344
871
|
codeGraph.addDependency(dependency);
|
|
345
872
|
}
|
|
@@ -363,7 +890,7 @@ function convertToCodeGraph(codeMap, options) {
|
|
|
363
890
|
continue;
|
|
364
891
|
}
|
|
365
892
|
try {
|
|
366
|
-
codeGraph.addDependency(new Dependency(
|
|
893
|
+
codeGraph.addDependency(new Dependency(createSymbolDependencyId(sourceEntry, targetEntry, mod.path), sourceEntry.id, targetEntry.id, 'call', 'symbol', 'symbol', resolveDependencyConfidence('direct-parser'), mod.path, call.line));
|
|
367
894
|
}
|
|
368
895
|
catch {
|
|
369
896
|
// 跳过重复或无法验证的调用边
|
|
@@ -374,6 +901,125 @@ function convertToCodeGraph(codeMap, options) {
|
|
|
374
901
|
}
|
|
375
902
|
return codeGraph;
|
|
376
903
|
}
|
|
904
|
+
function buildDependencyGraphForModules(modules) {
|
|
905
|
+
const nodes = [];
|
|
906
|
+
const edges = [];
|
|
907
|
+
const moduleIndex = new Map();
|
|
908
|
+
for (const mod of modules) {
|
|
909
|
+
const absolutePath = normalizePath(mod.absolutePath || mod.path);
|
|
910
|
+
const lookupKeys = buildLookupKeys(absolutePath);
|
|
911
|
+
for (const key of lookupKeys) {
|
|
912
|
+
moduleIndex.set(key, mod);
|
|
913
|
+
}
|
|
914
|
+
nodes.push({
|
|
915
|
+
id: mod.id,
|
|
916
|
+
path: mod.path,
|
|
917
|
+
category: categorizeModule(mod.path),
|
|
918
|
+
});
|
|
919
|
+
}
|
|
920
|
+
const edgeSet = new Set();
|
|
921
|
+
const moduleById = new Map(modules.map((mod) => [mod.id, mod]));
|
|
922
|
+
for (const mod of modules) {
|
|
923
|
+
mod.dependents = [];
|
|
924
|
+
const fromPath = normalizePath(mod.absolutePath || mod.path);
|
|
925
|
+
for (const depPath of mod.dependencies) {
|
|
926
|
+
const targetModule = resolveDependencyModule(fromPath, depPath, moduleIndex);
|
|
927
|
+
if (!targetModule || targetModule.id === mod.id) {
|
|
928
|
+
continue;
|
|
929
|
+
}
|
|
930
|
+
const edgeKey = `${mod.id}->${targetModule.id}:import`;
|
|
931
|
+
if (edgeSet.has(edgeKey)) {
|
|
932
|
+
continue;
|
|
933
|
+
}
|
|
934
|
+
edgeSet.add(edgeKey);
|
|
935
|
+
edges.push({
|
|
936
|
+
from: mod.id,
|
|
937
|
+
to: targetModule.id,
|
|
938
|
+
type: 'import',
|
|
939
|
+
weight: 1,
|
|
940
|
+
});
|
|
941
|
+
const target = moduleById.get(targetModule.id);
|
|
942
|
+
if (target && !target.dependents.includes(mod.id)) {
|
|
943
|
+
target.dependents.push(mod.id);
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
return { nodes, edges };
|
|
948
|
+
}
|
|
949
|
+
function calculateProjectSummary(modules) {
|
|
950
|
+
let totalLines = 0;
|
|
951
|
+
let totalExports = 0;
|
|
952
|
+
for (const mod of modules) {
|
|
953
|
+
totalLines += mod.stats.lines;
|
|
954
|
+
totalExports += mod.exports.length;
|
|
955
|
+
}
|
|
956
|
+
return {
|
|
957
|
+
totalFiles: modules.length,
|
|
958
|
+
totalLines,
|
|
959
|
+
totalModules: modules.length,
|
|
960
|
+
totalExports,
|
|
961
|
+
totalTypes: modules.filter((moduleInfo) => moduleInfo.type === 'source').length,
|
|
962
|
+
};
|
|
963
|
+
}
|
|
964
|
+
function buildLookupKeys(filePath) {
|
|
965
|
+
const withoutExt = stripKnownExt(filePath);
|
|
966
|
+
const keys = new Set([filePath, withoutExt]);
|
|
967
|
+
if (withoutExt.endsWith('/index')) {
|
|
968
|
+
keys.add(withoutExt.slice(0, -('/index'.length)));
|
|
969
|
+
}
|
|
970
|
+
return Array.from(keys);
|
|
971
|
+
}
|
|
972
|
+
function stripKnownExt(filePath) {
|
|
973
|
+
return filePath.replace(/\.(ts|tsx|js|jsx|mjs|cjs)$/iu, '');
|
|
974
|
+
}
|
|
975
|
+
function resolveDependencyModule(importerPath, depPath, moduleIndex) {
|
|
976
|
+
const rawDependency = depPath.trim();
|
|
977
|
+
const normalizedDependency = normalizePath(rawDependency);
|
|
978
|
+
const candidates = [];
|
|
979
|
+
if (rawDependency.startsWith('./')
|
|
980
|
+
|| rawDependency.startsWith('../')
|
|
981
|
+
|| rawDependency.startsWith('.\\')
|
|
982
|
+
|| rawDependency.startsWith('..\\')) {
|
|
983
|
+
candidates.push(normalizePath(path.resolve(path.dirname(importerPath), rawDependency)));
|
|
984
|
+
}
|
|
985
|
+
else if (path.isAbsolute(normalizedDependency)) {
|
|
986
|
+
candidates.push(normalizedDependency);
|
|
987
|
+
}
|
|
988
|
+
else {
|
|
989
|
+
return undefined;
|
|
990
|
+
}
|
|
991
|
+
for (const candidate of candidates) {
|
|
992
|
+
const withoutExt = stripKnownExt(candidate);
|
|
993
|
+
const expanded = [
|
|
994
|
+
candidate,
|
|
995
|
+
withoutExt,
|
|
996
|
+
`${withoutExt}.ts`,
|
|
997
|
+
`${withoutExt}.tsx`,
|
|
998
|
+
`${withoutExt}.js`,
|
|
999
|
+
`${withoutExt}/index`,
|
|
1000
|
+
`${withoutExt}/index.ts`,
|
|
1001
|
+
`${withoutExt}/index.tsx`,
|
|
1002
|
+
`${withoutExt}/index.js`,
|
|
1003
|
+
];
|
|
1004
|
+
for (const key of expanded) {
|
|
1005
|
+
const resolved = moduleIndex.get(normalizePath(key));
|
|
1006
|
+
if (resolved) {
|
|
1007
|
+
return resolved;
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
return undefined;
|
|
1012
|
+
}
|
|
1013
|
+
function categorizeModule(filePath) {
|
|
1014
|
+
const lower = filePath.toLowerCase();
|
|
1015
|
+
if (lower.includes('core') || lower.includes('engine'))
|
|
1016
|
+
return 'core';
|
|
1017
|
+
if (lower.includes('feature') || lower.includes('module'))
|
|
1018
|
+
return 'feature';
|
|
1019
|
+
if (lower.includes('util') || lower.includes('helper'))
|
|
1020
|
+
return 'utility';
|
|
1021
|
+
return 'external';
|
|
1022
|
+
}
|
|
377
1023
|
/**
|
|
378
1024
|
* 根据文件路径检测语言
|
|
379
1025
|
*/
|