@mycodemap/mycodemap 2.0.0 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/README.md +59 -184
- package/dist/cli/commands/agent-metrics/human.d.ts +4 -0
- package/dist/cli/commands/agent-metrics/human.d.ts.map +1 -0
- package/dist/cli/commands/agent-metrics/human.js +134 -0
- package/dist/cli/commands/agent-metrics/human.js.map +1 -0
- package/dist/cli/commands/agent-metrics/index.d.ts +15 -0
- package/dist/cli/commands/agent-metrics/index.d.ts.map +1 -0
- package/dist/cli/commands/agent-metrics/index.js +116 -0
- package/dist/cli/commands/agent-metrics/index.js.map +1 -0
- package/dist/cli/commands/analyze.d.ts +3 -196
- package/dist/cli/commands/analyze.d.ts.map +1 -1
- package/dist/cli/commands/analyze.js +9 -1163
- package/dist/cli/commands/analyze.js.map +1 -1
- package/dist/cli/commands/benchmark.d.ts.map +1 -1
- package/dist/cli/commands/benchmark.js +5 -2
- package/dist/cli/commands/benchmark.js.map +1 -1
- package/dist/cli/commands/complexity.d.ts.map +1 -1
- package/dist/cli/commands/complexity.js +62 -95
- package/dist/cli/commands/complexity.js.map +1 -1
- package/dist/cli/commands/deps.d.ts +3 -60
- package/dist/cli/commands/deps.d.ts.map +1 -1
- package/dist/cli/commands/deps.js +16 -351
- package/dist/cli/commands/deps.js.map +1 -1
- package/dist/cli/commands/env-contract.d.ts +3 -0
- package/dist/cli/commands/env-contract.d.ts.map +1 -0
- package/dist/cli/commands/env-contract.js +221 -0
- package/dist/cli/commands/env-contract.js.map +1 -0
- package/dist/cli/commands/generate.d.ts +19 -1
- package/dist/cli/commands/generate.d.ts.map +1 -1
- package/dist/cli/commands/generate.js +735 -89
- package/dist/cli/commands/generate.js.map +1 -1
- package/dist/cli/commands/impact.d.ts +4 -38
- package/dist/cli/commands/impact.d.ts.map +1 -1
- package/dist/cli/commands/impact.js +133 -375
- package/dist/cli/commands/impact.js.map +1 -1
- package/dist/cli/commands/init.d.ts +1 -0
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +61 -2
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/preview.d.ts +3 -0
- package/dist/cli/commands/preview.d.ts.map +1 -0
- package/dist/cli/commands/preview.js +216 -0
- package/dist/cli/commands/preview.js.map +1 -0
- package/dist/cli/commands/query.d.ts +2 -21
- package/dist/cli/commands/query.d.ts.map +1 -1
- package/dist/cli/commands/query.js +15 -683
- package/dist/cli/commands/query.js.map +1 -1
- package/dist/cli/commands/watch-foreground.d.ts.map +1 -1
- package/dist/cli/commands/watch-foreground.js +5 -1
- package/dist/cli/commands/watch-foreground.js.map +1 -1
- package/dist/cli/config-loader.d.ts.map +1 -1
- package/dist/cli/config-loader.js +51 -13
- package/dist/cli/config-loader.js.map +1 -1
- package/dist/cli/doctor/check-env-contract.d.ts +3 -0
- package/dist/cli/doctor/check-env-contract.d.ts.map +1 -0
- package/dist/cli/doctor/check-env-contract.js +96 -0
- package/dist/cli/doctor/check-env-contract.js.map +1 -0
- package/dist/cli/doctor/check-native-deps.d.ts.map +1 -1
- package/dist/cli/doctor/check-native-deps.js +20 -4
- package/dist/cli/doctor/check-native-deps.js.map +1 -1
- package/dist/cli/doctor/orchestrator.d.ts.map +1 -1
- package/dist/cli/doctor/orchestrator.js +5 -2
- package/dist/cli/doctor/orchestrator.js.map +1 -1
- package/dist/cli/env-contract/check.d.ts +18 -0
- package/dist/cli/env-contract/check.d.ts.map +1 -0
- package/dist/cli/env-contract/check.js +118 -0
- package/dist/cli/env-contract/check.js.map +1 -0
- package/dist/cli/env-contract/discovery.d.ts +12 -0
- package/dist/cli/env-contract/discovery.d.ts.map +1 -0
- package/dist/cli/env-contract/discovery.js +249 -0
- package/dist/cli/env-contract/discovery.js.map +1 -0
- package/dist/cli/env-contract/filters.d.ts +10 -0
- package/dist/cli/env-contract/filters.d.ts.map +1 -0
- package/dist/cli/env-contract/filters.js +23 -0
- package/dist/cli/env-contract/filters.js.map +1 -0
- package/dist/cli/env-contract/index.d.ts +6 -0
- package/dist/cli/env-contract/index.d.ts.map +1 -0
- package/dist/cli/env-contract/index.js +8 -0
- package/dist/cli/env-contract/index.js.map +1 -0
- package/dist/cli/env-contract/reminder-engine.d.ts +34 -0
- package/dist/cli/env-contract/reminder-engine.d.ts.map +1 -0
- package/dist/cli/env-contract/reminder-engine.js +51 -0
- package/dist/cli/env-contract/reminder-engine.js.map +1 -0
- package/dist/cli/env-contract/reminder-hook-runner.d.ts +45 -0
- package/dist/cli/env-contract/reminder-hook-runner.d.ts.map +1 -0
- package/dist/cli/env-contract/reminder-hook-runner.js +273 -0
- package/dist/cli/env-contract/reminder-hook-runner.js.map +1 -0
- package/dist/cli/env-contract/reminder-ledger.d.ts +11 -0
- package/dist/cli/env-contract/reminder-ledger.d.ts.map +1 -0
- package/dist/cli/env-contract/reminder-ledger.js +37 -0
- package/dist/cli/env-contract/reminder-ledger.js.map +1 -0
- package/dist/cli/env-contract/types.d.ts +48 -0
- package/dist/cli/env-contract/types.d.ts.map +1 -0
- package/dist/cli/env-contract/types.js +22 -0
- package/dist/cli/env-contract/types.js.map +1 -0
- package/dist/cli/env-contract/validation.d.ts +10 -0
- package/dist/cli/env-contract/validation.d.ts.map +1 -0
- package/dist/cli/env-contract/validation.js +116 -0
- package/dist/cli/env-contract/validation.js.map +1 -0
- package/dist/cli/first-run-guide.d.ts.map +1 -1
- package/dist/cli/first-run-guide.js +8 -3
- package/dist/cli/first-run-guide.js.map +1 -1
- package/dist/cli/index.js +23 -3
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/init/assistant-plan.d.ts +14 -0
- package/dist/cli/init/assistant-plan.d.ts.map +1 -0
- package/dist/cli/init/assistant-plan.js +208 -0
- package/dist/cli/init/assistant-plan.js.map +1 -0
- package/dist/cli/init/detect.d.ts +28 -0
- package/dist/cli/init/detect.d.ts.map +1 -0
- package/dist/cli/init/detect.js +63 -0
- package/dist/cli/init/detect.js.map +1 -0
- package/dist/cli/init/env-contract-plan.d.ts +28 -0
- package/dist/cli/init/env-contract-plan.d.ts.map +1 -0
- package/dist/cli/init/env-contract-plan.js +184 -0
- package/dist/cli/init/env-contract-plan.js.map +1 -0
- package/dist/cli/init/manifest-extractors.d.ts +22 -0
- package/dist/cli/init/manifest-extractors.d.ts.map +1 -0
- package/dist/cli/init/manifest-extractors.js +185 -0
- package/dist/cli/init/manifest-extractors.js.map +1 -0
- package/dist/cli/init/profile-loader.d.ts +49 -0
- package/dist/cli/init/profile-loader.d.ts.map +1 -0
- package/dist/cli/init/profile-loader.js +107 -0
- package/dist/cli/init/profile-loader.js.map +1 -0
- package/dist/cli/init/profile-plan.d.ts +38 -0
- package/dist/cli/init/profile-plan.d.ts.map +1 -0
- package/dist/cli/init/profile-plan.js +120 -0
- package/dist/cli/init/profile-plan.js.map +1 -0
- package/dist/cli/init/profiles/generic.json +16 -0
- package/dist/cli/init/profiles/go.json +12 -0
- package/dist/cli/init/profiles/nodejs.json +16 -0
- package/dist/cli/init/profiles/python.json +17 -0
- package/dist/cli/init/profiles/rust.json +12 -0
- package/dist/cli/init/receipt.d.ts.map +1 -1
- package/dist/cli/init/receipt.js +107 -7
- package/dist/cli/init/receipt.js.map +1 -1
- package/dist/cli/init/reconciler.d.ts +10 -1
- package/dist/cli/init/reconciler.d.ts.map +1 -1
- package/dist/cli/init/reconciler.js +85 -15
- package/dist/cli/init/reconciler.js.map +1 -1
- package/dist/cli/interface-contract/commands/agent-metrics.d.ts +3 -0
- package/dist/cli/interface-contract/commands/agent-metrics.d.ts.map +1 -0
- package/dist/cli/interface-contract/commands/agent-metrics.js +217 -0
- package/dist/cli/interface-contract/commands/agent-metrics.js.map +1 -0
- package/dist/cli/interface-contract/commands/analyze.d.ts.map +1 -1
- package/dist/cli/interface-contract/commands/analyze.js +1 -0
- package/dist/cli/interface-contract/commands/analyze.js.map +1 -1
- package/dist/cli/interface-contract/commands/benchmark.d.ts.map +1 -1
- package/dist/cli/interface-contract/commands/benchmark.js +1 -0
- package/dist/cli/interface-contract/commands/benchmark.js.map +1 -1
- package/dist/cli/interface-contract/commands/deps.d.ts.map +1 -1
- package/dist/cli/interface-contract/commands/deps.js +1 -0
- package/dist/cli/interface-contract/commands/deps.js.map +1 -1
- package/dist/cli/interface-contract/commands/doctor.d.ts.map +1 -1
- package/dist/cli/interface-contract/commands/doctor.js +1 -0
- package/dist/cli/interface-contract/commands/doctor.js.map +1 -1
- package/dist/cli/interface-contract/commands/env-contract.d.ts +3 -0
- package/dist/cli/interface-contract/commands/env-contract.d.ts.map +1 -0
- package/dist/cli/interface-contract/commands/env-contract.js +168 -0
- package/dist/cli/interface-contract/commands/env-contract.js.map +1 -0
- package/dist/cli/interface-contract/commands/index.d.ts +5 -2
- package/dist/cli/interface-contract/commands/index.d.ts.map +1 -1
- package/dist/cli/interface-contract/commands/index.js +7 -1
- package/dist/cli/interface-contract/commands/index.js.map +1 -1
- package/dist/cli/interface-contract/commands/init.d.ts.map +1 -1
- package/dist/cli/interface-contract/commands/init.js +9 -0
- package/dist/cli/interface-contract/commands/init.js.map +1 -1
- package/dist/cli/interface-contract/commands/preview.d.ts +3 -0
- package/dist/cli/interface-contract/commands/preview.d.ts.map +1 -0
- package/dist/cli/interface-contract/commands/preview.js +118 -0
- package/dist/cli/interface-contract/commands/preview.js.map +1 -0
- package/dist/cli/interface-contract/commands/query.d.ts.map +1 -1
- package/dist/cli/interface-contract/commands/query.js +1 -0
- package/dist/cli/interface-contract/commands/query.js.map +1 -1
- package/dist/cli/interface-contract/index.d.ts +1 -1
- package/dist/cli/interface-contract/index.d.ts.map +1 -1
- package/dist/cli/interface-contract/index.js +2 -2
- package/dist/cli/interface-contract/index.js.map +1 -1
- package/dist/cli/interface-contract/schema.d.ts.map +1 -1
- package/dist/cli/interface-contract/schema.js +1 -0
- package/dist/cli/interface-contract/schema.js.map +1 -1
- package/dist/cli/interface-contract/types.d.ts +1 -0
- package/dist/cli/interface-contract/types.d.ts.map +1 -1
- package/dist/cli/output/error-codes.d.ts +2 -0
- package/dist/cli/output/error-codes.d.ts.map +1 -1
- package/dist/cli/output/error-codes.js +12 -0
- package/dist/cli/output/error-codes.js.map +1 -1
- package/dist/cli/output/errors.d.ts.map +1 -1
- package/dist/cli/output/errors.js +12 -0
- package/dist/cli/output/errors.js.map +1 -1
- package/dist/cli/output/wasm-fallback.d.ts +1 -0
- package/dist/cli/output/wasm-fallback.d.ts.map +1 -1
- package/dist/cli/output/wasm-fallback.js.map +1 -1
- package/dist/cli/preview/complexity-scanner.d.ts +21 -0
- package/dist/cli/preview/complexity-scanner.d.ts.map +1 -0
- package/dist/cli/preview/complexity-scanner.js +52 -0
- package/dist/cli/preview/complexity-scanner.js.map +1 -0
- package/dist/cli/preview/dependency-extractor.d.ts +38 -0
- package/dist/cli/preview/dependency-extractor.d.ts.map +1 -0
- package/dist/cli/preview/dependency-extractor.js +140 -0
- package/dist/cli/preview/dependency-extractor.js.map +1 -0
- package/dist/cli/preview/preview-renderer.d.ts +32 -0
- package/dist/cli/preview/preview-renderer.d.ts.map +1 -0
- package/dist/cli/preview/preview-renderer.js +54 -0
- package/dist/cli/preview/preview-renderer.js.map +1 -0
- package/dist/cli/storage-runtime.d.ts +7 -0
- package/dist/cli/storage-runtime.d.ts.map +1 -1
- package/dist/cli/storage-runtime.js +22 -0
- package/dist/cli/storage-runtime.js.map +1 -1
- package/dist/cli-new/index.js +1 -1
- package/dist/cli-new/index.js.map +1 -1
- package/dist/composition/parser-composition.d.ts +7 -0
- package/dist/composition/parser-composition.d.ts.map +1 -0
- package/dist/composition/parser-composition.js +15 -0
- package/dist/composition/parser-composition.js.map +1 -0
- package/dist/core/analyzer.d.ts.map +1 -1
- package/dist/core/analyzer.js +83 -67
- package/dist/core/analyzer.js.map +1 -1
- package/dist/core/ast-complexity-analyzer.d.ts +12 -6
- package/dist/core/ast-complexity-analyzer.d.ts.map +1 -1
- package/dist/core/ast-complexity-analyzer.js +368 -209
- package/dist/core/ast-complexity-analyzer.js.map +1 -1
- package/dist/core/file-discovery.d.ts +1 -1
- package/dist/core/file-discovery.d.ts.map +1 -1
- package/dist/core/file-discovery.js +3 -0
- package/dist/core/file-discovery.js.map +1 -1
- package/dist/core/global-index.d.ts +3 -1
- package/dist/core/global-index.d.ts.map +1 -1
- package/dist/core/global-index.js +69 -4
- package/dist/core/global-index.js.map +1 -1
- package/dist/domain/entities/CodeGraph.d.ts +3 -0
- package/dist/domain/entities/CodeGraph.d.ts.map +1 -1
- package/dist/domain/entities/CodeGraph.js +19 -2
- package/dist/domain/entities/CodeGraph.js.map +1 -1
- package/dist/domain/entities/Dependency.d.ts +5 -2
- package/dist/domain/entities/Dependency.d.ts.map +1 -1
- package/dist/domain/entities/Dependency.js +49 -3
- package/dist/domain/entities/Dependency.js.map +1 -1
- package/dist/domain/repositories/CodeGraphRepository.d.ts +5 -0
- package/dist/domain/repositories/CodeGraphRepository.d.ts.map +1 -1
- package/dist/domain/repositories/CodeGraphRepository.js.map +1 -1
- package/dist/execution/contract-tools/analyze.d.ts +205 -0
- package/dist/execution/contract-tools/analyze.d.ts.map +1 -0
- package/dist/execution/contract-tools/analyze.js +1215 -0
- package/dist/execution/contract-tools/analyze.js.map +1 -0
- package/dist/execution/contract-tools/deps.d.ts +62 -0
- package/dist/execution/contract-tools/deps.d.ts.map +1 -0
- package/dist/execution/contract-tools/deps.js +234 -0
- package/dist/execution/contract-tools/deps.js.map +1 -0
- package/dist/execution/contract-tools/index.d.ts +5 -0
- package/dist/execution/contract-tools/index.d.ts.map +1 -0
- package/dist/execution/contract-tools/index.js +7 -0
- package/dist/execution/contract-tools/index.js.map +1 -0
- package/dist/execution/contract-tools/query.d.ts +60 -0
- package/dist/execution/contract-tools/query.d.ts.map +1 -0
- package/dist/execution/contract-tools/query.js +532 -0
- package/dist/execution/contract-tools/query.js.map +1 -0
- package/dist/execution/contract-tools/types.d.ts +26 -0
- package/dist/execution/contract-tools/types.d.ts.map +1 -0
- package/dist/execution/contract-tools/types.js +32 -0
- package/dist/execution/contract-tools/types.js.map +1 -0
- package/dist/generator/index.d.ts.map +1 -1
- package/dist/generator/index.js +0 -3
- package/dist/generator/index.js.map +1 -1
- package/dist/infrastructure/parser/enhancers/TypeScriptTypeEnhancer.d.ts +12 -0
- package/dist/infrastructure/parser/enhancers/TypeScriptTypeEnhancer.d.ts.map +1 -0
- package/dist/infrastructure/parser/enhancers/TypeScriptTypeEnhancer.js +55 -0
- package/dist/infrastructure/parser/enhancers/TypeScriptTypeEnhancer.js.map +1 -0
- package/dist/infrastructure/parser/implementations/GoParser.d.ts +2 -1
- package/dist/infrastructure/parser/implementations/GoParser.d.ts.map +1 -1
- package/dist/infrastructure/parser/implementations/GoParser.js +13 -1
- package/dist/infrastructure/parser/implementations/GoParser.js.map +1 -1
- package/dist/infrastructure/parser/implementations/PythonTreeSitterParser.d.ts +114 -0
- package/dist/infrastructure/parser/implementations/PythonTreeSitterParser.d.ts.map +1 -0
- package/dist/infrastructure/parser/implementations/PythonTreeSitterParser.js +1022 -0
- package/dist/infrastructure/parser/implementations/PythonTreeSitterParser.js.map +1 -0
- package/dist/infrastructure/parser/implementations/TreeSitterParser.d.ts +78 -0
- package/dist/infrastructure/parser/implementations/TreeSitterParser.d.ts.map +1 -0
- package/dist/infrastructure/parser/implementations/TreeSitterParser.js +648 -0
- package/dist/infrastructure/parser/implementations/TreeSitterParser.js.map +1 -0
- package/dist/infrastructure/parser/implementations/TypeScriptParser.d.ts +3 -55
- package/dist/infrastructure/parser/implementations/TypeScriptParser.d.ts.map +1 -1
- package/dist/infrastructure/parser/implementations/TypeScriptParser.js +4 -411
- package/dist/infrastructure/parser/implementations/TypeScriptParser.js.map +1 -1
- package/dist/infrastructure/parser/index.d.ts +2 -0
- package/dist/infrastructure/parser/index.d.ts.map +1 -1
- package/dist/infrastructure/parser/index.js +9 -6
- package/dist/infrastructure/parser/index.js.map +1 -1
- package/dist/infrastructure/parser/interfaces/ParserBase.d.ts.map +1 -1
- package/dist/infrastructure/parser/interfaces/ParserBase.js +1 -0
- package/dist/infrastructure/parser/interfaces/ParserBase.js.map +1 -1
- package/dist/infrastructure/repositories/CodeGraphRepositoryImpl.d.ts +2 -0
- package/dist/infrastructure/repositories/CodeGraphRepositoryImpl.d.ts.map +1 -1
- package/dist/infrastructure/repositories/CodeGraphRepositoryImpl.js +4 -0
- package/dist/infrastructure/repositories/CodeGraphRepositoryImpl.js.map +1 -1
- package/dist/infrastructure/storage/StorageFactory.d.ts +5 -18
- package/dist/infrastructure/storage/StorageFactory.d.ts.map +1 -1
- package/dist/infrastructure/storage/StorageFactory.js +30 -98
- package/dist/infrastructure/storage/StorageFactory.js.map +1 -1
- package/dist/infrastructure/storage/adapters/SQLiteStorage.d.ts +13 -1
- package/dist/infrastructure/storage/adapters/SQLiteStorage.d.ts.map +1 -1
- package/dist/infrastructure/storage/adapters/SQLiteStorage.js +321 -75
- package/dist/infrastructure/storage/adapters/SQLiteStorage.js.map +1 -1
- package/dist/infrastructure/storage/adapters/sqlite-loader.d.ts +22 -0
- package/dist/infrastructure/storage/adapters/sqlite-loader.d.ts.map +1 -1
- package/dist/infrastructure/storage/adapters/sqlite-loader.js +78 -22
- package/dist/infrastructure/storage/adapters/sqlite-loader.js.map +1 -1
- package/dist/infrastructure/storage/community-helpers.d.ts +4 -0
- package/dist/infrastructure/storage/community-helpers.d.ts.map +1 -0
- package/dist/infrastructure/storage/community-helpers.js +392 -0
- package/dist/infrastructure/storage/community-helpers.js.map +1 -0
- package/dist/infrastructure/storage/graph-helpers.d.ts +22 -5
- package/dist/infrastructure/storage/graph-helpers.d.ts.map +1 -1
- package/dist/infrastructure/storage/graph-helpers.js +496 -91
- package/dist/infrastructure/storage/graph-helpers.js.map +1 -1
- package/dist/infrastructure/storage/index.d.ts +1 -1
- package/dist/infrastructure/storage/index.d.ts.map +1 -1
- package/dist/infrastructure/storage/index.js +1 -1
- package/dist/infrastructure/storage/index.js.map +1 -1
- package/dist/infrastructure/storage/interfaces/StorageBase.d.ts +2 -2
- package/dist/infrastructure/storage/interfaces/StorageBase.d.ts.map +1 -1
- package/dist/infrastructure/storage/interfaces/StorageBase.js.map +1 -1
- package/dist/infrastructure/storage/sqlite/GovernanceGraphCache.d.ts +2 -0
- package/dist/infrastructure/storage/sqlite/GovernanceGraphCache.d.ts.map +1 -1
- package/dist/infrastructure/storage/sqlite/GovernanceGraphCache.js +52 -12
- package/dist/infrastructure/storage/sqlite/GovernanceGraphCache.js.map +1 -1
- package/dist/infrastructure/storage/sqlite/schema.d.ts +2 -2
- package/dist/infrastructure/storage/sqlite/schema.d.ts.map +1 -1
- package/dist/infrastructure/storage/sqlite/schema.js +49 -1
- package/dist/infrastructure/storage/sqlite/schema.js.map +1 -1
- package/dist/interface/config/index.d.ts +5 -3
- package/dist/interface/config/index.d.ts.map +1 -1
- package/dist/interface/types/index.d.ts +37 -6
- package/dist/interface/types/index.d.ts.map +1 -1
- package/dist/interface/types/parser.d.ts +85 -0
- package/dist/interface/types/parser.d.ts.map +1 -1
- package/dist/interface/types/storage.d.ts +227 -10
- package/dist/interface/types/storage.d.ts.map +1 -1
- package/dist/orchestrator/agent-metrics-service.d.ts +126 -0
- package/dist/orchestrator/agent-metrics-service.d.ts.map +1 -0
- package/dist/orchestrator/agent-metrics-service.js +444 -0
- package/dist/orchestrator/agent-metrics-service.js.map +1 -0
- package/dist/parser/enhancers/PythonTypeEnhancer.d.ts +26 -0
- package/dist/parser/enhancers/PythonTypeEnhancer.d.ts.map +1 -0
- package/dist/parser/enhancers/PythonTypeEnhancer.js +440 -0
- package/dist/parser/enhancers/PythonTypeEnhancer.js.map +1 -0
- package/dist/parser/implementations/smart-parser.d.ts.map +1 -1
- package/dist/parser/implementations/smart-parser.js +7 -69
- package/dist/parser/implementations/smart-parser.js.map +1 -1
- package/dist/parser/implementations/tree-sitter-loader.d.ts +2 -0
- package/dist/parser/implementations/tree-sitter-loader.d.ts.map +1 -1
- package/dist/parser/implementations/tree-sitter-loader.js +46 -15
- package/dist/parser/implementations/tree-sitter-loader.js.map +1 -1
- package/dist/parser/index.d.ts +5 -3
- package/dist/parser/index.d.ts.map +1 -1
- package/dist/parser/index.js +68 -6
- package/dist/parser/index.js.map +1 -1
- package/dist/parser/interfaces/IParser.d.ts +19 -6
- package/dist/parser/interfaces/IParser.d.ts.map +1 -1
- package/dist/parser/interfaces/IParser.js +2 -3
- package/dist/parser/interfaces/IParser.js.map +1 -1
- package/dist/server/handlers/AnalysisHandler.d.ts +13 -2
- package/dist/server/handlers/AnalysisHandler.d.ts.map +1 -1
- package/dist/server/handlers/AnalysisHandler.js +24 -0
- package/dist/server/handlers/AnalysisHandler.js.map +1 -1
- package/dist/server/handlers/QueryHandler.d.ts.map +1 -1
- package/dist/server/handlers/QueryHandler.js +11 -30
- package/dist/server/handlers/QueryHandler.js.map +1 -1
- package/dist/server/mcp/context-tool.d.ts +9 -0
- package/dist/server/mcp/context-tool.d.ts.map +1 -0
- package/dist/server/mcp/context-tool.js +257 -0
- package/dist/server/mcp/context-tool.js.map +1 -0
- package/dist/server/mcp/schema-adapter.d.ts +11 -1
- package/dist/server/mcp/schema-adapter.d.ts.map +1 -1
- package/dist/server/mcp/schema-adapter.js +126 -7
- package/dist/server/mcp/schema-adapter.js.map +1 -1
- package/dist/server/mcp/server.d.ts +3 -3
- package/dist/server/mcp/server.d.ts.map +1 -1
- package/dist/server/mcp/server.js +114 -30
- package/dist/server/mcp/server.js.map +1 -1
- package/dist/server/mcp/service.d.ts +6 -2
- package/dist/server/mcp/service.d.ts.map +1 -1
- package/dist/server/mcp/service.js +138 -36
- package/dist/server/mcp/service.js.map +1 -1
- package/dist/server/mcp/stdio-transport.d.ts +23 -0
- package/dist/server/mcp/stdio-transport.d.ts.map +1 -0
- package/dist/server/mcp/stdio-transport.js +101 -0
- package/dist/server/mcp/stdio-transport.js.map +1 -0
- package/dist/server/mcp/types.d.ts +133 -8
- package/dist/server/mcp/types.d.ts.map +1 -1
- package/dist/server/routes/api.d.ts.map +1 -1
- package/dist/server/routes/api.js +11 -2
- package/dist/server/routes/api.js.map +1 -1
- package/docs/AI_ASSISTANT_SETUP.md +112 -0
- package/docs/API.md +170 -0
- package/docs/CONFIGURATION.md +141 -0
- package/docs/DEVELOPMENT.md +96 -0
- package/docs/GETTING-STARTED.md +114 -0
- package/docs/SETUP_GUIDE.md +49 -0
- package/docs/TESTING.md +81 -0
- package/docs/ai-guide/OUTPUT.md +51 -8
- package/docs/backlog.md +232 -144
- package/docs/brainstorms/2026-05-10-agent-effectiveness-validation-requirements.md +112 -0
- package/docs/generated/phase-58/subagent-evidence/claude-hook-example.json +15 -0
- package/docs/generated/phase-58/subagent-evidence/claude-session.md +146 -0
- package/docs/generated/phase-58/subagent-evidence/claude-subagent.json +28 -0
- package/docs/generated/phase-58/subagent-evidence/codex-agent-example.toml +19 -0
- package/docs/generated/phase-58/subagent-evidence/codex-session.md +150 -0
- package/docs/generated/phase-58/subagent-evidence/codex-subagent.json +20 -0
- package/docs/generated/phase-58/subagent-evidence/negative-no-retrieval.json +12 -0
- package/docs/generated/phase-58/subagent-evidence/verification-manifest.json +19 -0
- package/docs/ideation/2026-05-02-subagent-environment-contract-injection-ideation.md +183 -0
- package/docs/ideation/2026-05-04-subagent-hooks-deep-dive-ideation.md +133 -0
- package/docs/ideation/2026-05-10-agent-effectiveness-validation-ideation.md +219 -0
- package/package.json +8 -3
- package/scripts/copy-build-assets.mjs +23 -0
- package/scripts/hooks/templates/pre-commit +33 -2
- package/scripts/tests/test_rule_control_workflow.py +15 -1
- package/scripts/verify-subagent-env-contract.mjs +279 -0
- package/dist/parser/implementations/tree-sitter-parser.d.ts +0 -60
- package/dist/parser/implementations/tree-sitter-parser.d.ts.map +0 -1
- package/dist/parser/implementations/tree-sitter-parser.js +0 -380
- package/dist/parser/implementations/tree-sitter-parser.js.map +0 -1
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
// ============================================
|
|
6
6
|
import { mkdir } from 'node:fs/promises';
|
|
7
7
|
import { dirname, join } from 'node:path';
|
|
8
|
+
import { Dependency as DomainDependency } from '../../../domain/entities/Dependency.js';
|
|
8
9
|
import { StorageBase, StorageError } from '../interfaces/StorageBase.js';
|
|
9
|
-
import { calculateImpactInGraph, cloneCodeGraph, createEmptyCodeGraph, deserializeCodeGraphSnapshot, detectCyclesInGraph, getProjectStatisticsFromGraph, serializeCodeGraphSnapshot, upsertModuleInGraph, } from '../graph-helpers.js';
|
|
10
|
+
import { calculateImpactInGraph, calculateSymbolImpactInGraph, cloneCodeGraph, createEmptyCodeGraph, deserializeCodeGraphSnapshot, detectCyclesInGraph, getProjectStatisticsFromGraph, serializeCodeGraphSnapshot, upsertModuleInGraph, } from '../graph-helpers.js';
|
|
10
11
|
import { CURRENT_SQLITE_SCHEMA_VERSION, SQLITE_GOVERNANCE_SCHEMA_SQL, SQLITE_SCHEMA_VERSION_UPSERT_SQL, } from '../sqlite/schema.js';
|
|
11
12
|
import { GovernanceGraphCache, readGovernanceGraphFromSQLite, } from '../sqlite/GovernanceGraphCache.js';
|
|
12
13
|
import { DEFAULT_GOVERNANCE_GRAPH_PERF_THRESHOLDS, } from '../sqlite/perf-thresholds.js';
|
|
@@ -14,7 +15,14 @@ const GRAPH_STATUS_METADATA_KEY = 'graph_status';
|
|
|
14
15
|
const FAILED_FILE_COUNT_METADATA_KEY = 'failed_file_count';
|
|
15
16
|
const PARSE_FAILURE_FILES_METADATA_KEY = 'parse_failure_files_json';
|
|
16
17
|
const LAST_GRAPH_SYNC_AT_METADATA_KEY = 'last_graph_sync_at';
|
|
17
|
-
|
|
18
|
+
const LAST_REFRESH_METADATA_KEY = 'last_refresh_summary_json';
|
|
19
|
+
const VALID_DEPENDENCY_CONFIDENCE = new Set([
|
|
20
|
+
'EXTRACTED',
|
|
21
|
+
'INFERRED',
|
|
22
|
+
'AMBIGUOUS',
|
|
23
|
+
]);
|
|
24
|
+
const SQLITE_REBUILD_REQUIRED_MESSAGE = 'Graph schema is outdated. Run `mycodemap generate` to rebuild the SQLite graph.';
|
|
25
|
+
import { getLastSQLiteLoadDiagnostics, loadSQLite, } from './sqlite-loader.js';
|
|
18
26
|
async function loadSQLiteModule() {
|
|
19
27
|
return loadSQLite();
|
|
20
28
|
}
|
|
@@ -55,6 +63,54 @@ function normalizeParseFailureFiles(value) {
|
|
|
55
63
|
}
|
|
56
64
|
return parsedValue.filter((item) => typeof item === 'string');
|
|
57
65
|
}
|
|
66
|
+
function deduplicateDependenciesForStorage(dependencies, symbolIds) {
|
|
67
|
+
const seen = new Set();
|
|
68
|
+
const deduped = [];
|
|
69
|
+
for (const dependency of dependencies) {
|
|
70
|
+
const sourceEntityType = resolveEntityType(dependency.sourceEntityType, dependency.sourceId, symbolIds);
|
|
71
|
+
const targetEntityType = resolveEntityType(dependency.targetEntityType, dependency.targetId, symbolIds);
|
|
72
|
+
const key = DomainDependency.createKey(dependency.sourceId, dependency.targetId, dependency.type, sourceEntityType, targetEntityType, dependency.filePath);
|
|
73
|
+
if (seen.has(key)) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
seen.add(key);
|
|
77
|
+
deduped.push({
|
|
78
|
+
...dependency,
|
|
79
|
+
sourceEntityType,
|
|
80
|
+
targetEntityType,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return deduped;
|
|
84
|
+
}
|
|
85
|
+
function buildModuleReferenceById(modules) {
|
|
86
|
+
return new Map(modules.map(module => [
|
|
87
|
+
module.id,
|
|
88
|
+
DomainDependency.createModuleReference(module.path),
|
|
89
|
+
]));
|
|
90
|
+
}
|
|
91
|
+
function buildSymbolReferenceById(symbols, moduleReferenceById) {
|
|
92
|
+
return new Map(symbols.map(symbol => {
|
|
93
|
+
const symbolFilePath = moduleReferenceById.get(symbol.moduleId) ?? symbol.location.file;
|
|
94
|
+
return [
|
|
95
|
+
symbol.id,
|
|
96
|
+
DomainDependency.createSymbolReference(symbolFilePath, symbol.name, symbol.location.line, symbol.location.column),
|
|
97
|
+
];
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
function resolveDependencyReference(entityId, entityType, moduleReferenceById, symbolReferenceById) {
|
|
101
|
+
const stableReference = entityType === 'symbol'
|
|
102
|
+
? symbolReferenceById.get(entityId)
|
|
103
|
+
: moduleReferenceById.get(entityId);
|
|
104
|
+
return stableReference ?? entityId;
|
|
105
|
+
}
|
|
106
|
+
function normalizeDependencyIdsForStorage(dependencies, modules, symbols) {
|
|
107
|
+
const moduleReferenceById = buildModuleReferenceById(modules);
|
|
108
|
+
const symbolReferenceById = buildSymbolReferenceById(symbols, moduleReferenceById);
|
|
109
|
+
return dependencies.map((dependency) => ({
|
|
110
|
+
...dependency,
|
|
111
|
+
id: DomainDependency.createCanonicalId(resolveDependencyReference(dependency.sourceId, dependency.sourceEntityType ?? 'module', moduleReferenceById, symbolReferenceById), resolveDependencyReference(dependency.targetId, dependency.targetEntityType ?? 'module', moduleReferenceById, symbolReferenceById), dependency.type, dependency.sourceEntityType ?? 'module', dependency.targetEntityType ?? 'module', dependency.filePath),
|
|
112
|
+
}));
|
|
113
|
+
}
|
|
58
114
|
function readGraphIntegrityMetadata(database) {
|
|
59
115
|
const metadataRows = database.prepare(`
|
|
60
116
|
SELECT key, value
|
|
@@ -81,9 +137,9 @@ function readGraphMetadata(database) {
|
|
|
81
137
|
.prepare(`
|
|
82
138
|
SELECT key, value
|
|
83
139
|
FROM metadata
|
|
84
|
-
WHERE key IN (?, ?, ?, ?)
|
|
140
|
+
WHERE key IN (?, ?, ?, ?, ?)
|
|
85
141
|
`)
|
|
86
|
-
.all(GRAPH_STATUS_METADATA_KEY, FAILED_FILE_COUNT_METADATA_KEY, PARSE_FAILURE_FILES_METADATA_KEY, LAST_GRAPH_SYNC_AT_METADATA_KEY);
|
|
142
|
+
.all(GRAPH_STATUS_METADATA_KEY, FAILED_FILE_COUNT_METADATA_KEY, PARSE_FAILURE_FILES_METADATA_KEY, LAST_GRAPH_SYNC_AT_METADATA_KEY, LAST_REFRESH_METADATA_KEY);
|
|
87
143
|
const metadataMap = new Map(metadataRows.map(row => [toStringValue(row.key), row.value]));
|
|
88
144
|
const parseFailureFiles = normalizeParseFailureFiles(metadataMap.get(PARSE_FAILURE_FILES_METADATA_KEY));
|
|
89
145
|
const moduleCount = toNumberValue(countsRow?.module_count);
|
|
@@ -98,13 +154,31 @@ function readGraphMetadata(database) {
|
|
|
98
154
|
parseFailureFiles,
|
|
99
155
|
moduleCount,
|
|
100
156
|
symbolCount,
|
|
157
|
+
lastRefresh: parseRefreshSummary(metadataMap.get(LAST_REFRESH_METADATA_KEY)),
|
|
101
158
|
};
|
|
102
159
|
}
|
|
160
|
+
function parseRefreshSummary(value) {
|
|
161
|
+
const raw = toStringValue(value);
|
|
162
|
+
if (!raw) {
|
|
163
|
+
return undefined;
|
|
164
|
+
}
|
|
165
|
+
try {
|
|
166
|
+
return JSON.parse(raw);
|
|
167
|
+
}
|
|
168
|
+
catch {
|
|
169
|
+
return undefined;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
103
172
|
function createHistorySnapshotId(recordedAt) {
|
|
104
173
|
const compactTimestamp = recordedAt.replace(/[^0-9]/g, '');
|
|
105
174
|
const entropy = Math.random().toString(16).slice(2, 10);
|
|
106
175
|
return `history-${compactTimestamp}-${entropy}`;
|
|
107
176
|
}
|
|
177
|
+
function createAgentMetricsRunId(recordedAt) {
|
|
178
|
+
const compactTimestamp = recordedAt.replace(/[^0-9]/g, '');
|
|
179
|
+
const entropy = Math.random().toString(16).slice(2, 10);
|
|
180
|
+
return `agent-metrics-run-${compactTimestamp}-${entropy}`;
|
|
181
|
+
}
|
|
108
182
|
function inferEntityType(entityId, symbolIds) {
|
|
109
183
|
return symbolIds.has(entityId) ? 'symbol' : 'module';
|
|
110
184
|
}
|
|
@@ -115,6 +189,17 @@ function hasColumn(database, tableName, columnName) {
|
|
|
115
189
|
const rows = database.prepare(`PRAGMA table_info(${tableName})`).all();
|
|
116
190
|
return rows.some((row) => toStringValue(row.name) === columnName);
|
|
117
191
|
}
|
|
192
|
+
function hasTable(database, tableName) {
|
|
193
|
+
const row = database
|
|
194
|
+
.prepare(`
|
|
195
|
+
SELECT name
|
|
196
|
+
FROM sqlite_master
|
|
197
|
+
WHERE type = 'table' AND name = ?
|
|
198
|
+
LIMIT 1
|
|
199
|
+
`)
|
|
200
|
+
.get(tableName);
|
|
201
|
+
return Boolean(row?.name);
|
|
202
|
+
}
|
|
118
203
|
function addColumnIfMissing(database, tableName, columnName, definition) {
|
|
119
204
|
if (!hasColumn(database, tableName, columnName)) {
|
|
120
205
|
database.exec(`ALTER TABLE ${tableName} ADD COLUMN ${definition}`);
|
|
@@ -134,6 +219,19 @@ function createUnavailableHistoryDiagnostics(reason) {
|
|
|
134
219
|
requiresPrecompute: false,
|
|
135
220
|
};
|
|
136
221
|
}
|
|
222
|
+
function createGraphRebuildRequiredError(reason) {
|
|
223
|
+
return new StorageError(`${reason} ${SQLITE_REBUILD_REQUIRED_MESSAGE}`, 'GRAPH_SCHEMA_REBUILD_REQUIRED');
|
|
224
|
+
}
|
|
225
|
+
function normalizeDependencyConfidence(value) {
|
|
226
|
+
if (value === null || value === undefined || toStringValue(value) === '') {
|
|
227
|
+
return undefined;
|
|
228
|
+
}
|
|
229
|
+
const confidence = toStringValue(value);
|
|
230
|
+
if (VALID_DEPENDENCY_CONFIDENCE.has(confidence)) {
|
|
231
|
+
return confidence;
|
|
232
|
+
}
|
|
233
|
+
throw new StorageError(`Invalid dependency confidence "${confidence}". Run \`mycodemap generate\` to rebuild the SQLite graph.`, 'GRAPH_INVALID_DEPENDENCY_CONFIDENCE');
|
|
234
|
+
}
|
|
137
235
|
function createUnavailableSymbolHistoryResult(query, reason) {
|
|
138
236
|
return {
|
|
139
237
|
query,
|
|
@@ -176,6 +274,9 @@ export class SQLiteStorage extends StorageBase {
|
|
|
176
274
|
this.storageConfig = config;
|
|
177
275
|
this.runtimeOptions = runtimeOptions;
|
|
178
276
|
}
|
|
277
|
+
static getLastLoadDiagnostics() {
|
|
278
|
+
return getLastSQLiteLoadDiagnostics();
|
|
279
|
+
}
|
|
179
280
|
async doInitialize() {
|
|
180
281
|
if (!this.projectPath) {
|
|
181
282
|
throw new StorageError('Project path not set', 'PROJECT_PATH_NOT_SET');
|
|
@@ -189,12 +290,15 @@ export class SQLiteStorage extends StorageBase {
|
|
|
189
290
|
this.database = new Database(databasePath);
|
|
190
291
|
this.database.pragma?.('journal_mode = WAL');
|
|
191
292
|
this.database.pragma?.('foreign_keys = ON');
|
|
293
|
+
this.assertSchemaCompatibility(this.database);
|
|
192
294
|
this.database.exec(SQLITE_GOVERNANCE_SCHEMA_SQL);
|
|
193
295
|
this.ensureSchemaColumns(this.database);
|
|
296
|
+
this.assertProjectionParity(this.database);
|
|
194
297
|
this.database
|
|
195
298
|
.prepare(SQLITE_SCHEMA_VERSION_UPSERT_SQL)
|
|
196
299
|
.run('schema_version', CURRENT_SQLITE_SCHEMA_VERSION);
|
|
197
300
|
this.backfillLegacySnapshotIfNeeded(this.database);
|
|
301
|
+
this.backfillCanonicalDependencyIdsIfNeeded(this.database);
|
|
198
302
|
this.refreshGovernanceGraphCache(this.database);
|
|
199
303
|
}
|
|
200
304
|
catch (error) {
|
|
@@ -221,6 +325,8 @@ export class SQLiteStorage extends StorageBase {
|
|
|
221
325
|
async deleteProject() {
|
|
222
326
|
const database = this.getDatabase();
|
|
223
327
|
this.runInTransaction(database, () => {
|
|
328
|
+
database.prepare('DELETE FROM agent_metrics').run();
|
|
329
|
+
database.prepare('DELETE FROM agent_metrics_runs').run();
|
|
224
330
|
database.prepare('DELETE FROM history_relations').run();
|
|
225
331
|
database.prepare('DELETE FROM history_snapshots').run();
|
|
226
332
|
database.prepare('DELETE FROM dependencies').run();
|
|
@@ -354,69 +460,7 @@ export class SQLiteStorage extends StorageBase {
|
|
|
354
460
|
return calculateImpactInGraph(this.readGovernanceGraphForAnalysis(this.getDatabase()), moduleId, depth);
|
|
355
461
|
}
|
|
356
462
|
async calculateSymbolImpact(symbolId, depth, limit) {
|
|
357
|
-
|
|
358
|
-
const rootSymbol = await this.findSymbolById(symbolId);
|
|
359
|
-
if (!rootSymbol) {
|
|
360
|
-
throw new StorageError(`Symbol ${symbolId} not found`, 'SYMBOL_NOT_FOUND');
|
|
361
|
-
}
|
|
362
|
-
const selectCallers = database.prepare(`
|
|
363
|
-
SELECT s.id, s.module_id, s.name, s.kind, s.signature, s.file_path, s.line, s.column_number, s.end_line, s.end_column, s.visibility
|
|
364
|
-
FROM dependencies d
|
|
365
|
-
INNER JOIN symbols s ON s.id = d.source_id
|
|
366
|
-
WHERE d.target_id = ?
|
|
367
|
-
AND d.dependency_type = 'call'
|
|
368
|
-
ORDER BY d.id, s.id
|
|
369
|
-
`);
|
|
370
|
-
const affectedSymbols = [];
|
|
371
|
-
const visited = new Set([symbolId]);
|
|
372
|
-
const queue = [{
|
|
373
|
-
id: symbolId,
|
|
374
|
-
level: 0,
|
|
375
|
-
path: [symbolId],
|
|
376
|
-
}];
|
|
377
|
-
let truncated = false;
|
|
378
|
-
while (queue.length > 0) {
|
|
379
|
-
const current = queue.shift();
|
|
380
|
-
if (!current) {
|
|
381
|
-
continue;
|
|
382
|
-
}
|
|
383
|
-
if (current.level >= depth) {
|
|
384
|
-
continue;
|
|
385
|
-
}
|
|
386
|
-
const callerRows = selectCallers.all(current.id);
|
|
387
|
-
for (const row of callerRows) {
|
|
388
|
-
if (affectedSymbols.length >= limit) {
|
|
389
|
-
truncated = true;
|
|
390
|
-
queue.length = 0;
|
|
391
|
-
break;
|
|
392
|
-
}
|
|
393
|
-
const callerId = toStringValue(row.id);
|
|
394
|
-
if (visited.has(callerId)) {
|
|
395
|
-
continue;
|
|
396
|
-
}
|
|
397
|
-
visited.add(callerId);
|
|
398
|
-
const callerSymbol = this.mapSymbolRow(row);
|
|
399
|
-
const nextLevel = current.level + 1;
|
|
400
|
-
const nextPath = [...current.path, callerId];
|
|
401
|
-
affectedSymbols.push({
|
|
402
|
-
symbol: callerSymbol,
|
|
403
|
-
depth: nextLevel,
|
|
404
|
-
path: nextPath,
|
|
405
|
-
});
|
|
406
|
-
queue.push({
|
|
407
|
-
id: callerId,
|
|
408
|
-
level: nextLevel,
|
|
409
|
-
path: nextPath,
|
|
410
|
-
});
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
return {
|
|
414
|
-
rootSymbol,
|
|
415
|
-
affectedSymbols,
|
|
416
|
-
depth,
|
|
417
|
-
limit,
|
|
418
|
-
truncated,
|
|
419
|
-
};
|
|
463
|
+
return calculateSymbolImpactInGraph(await this.loadCodeGraph(), symbolId, depth, limit);
|
|
420
464
|
}
|
|
421
465
|
async getStatistics() {
|
|
422
466
|
const database = this.getDatabase();
|
|
@@ -595,6 +639,96 @@ export class SQLiteStorage extends StorageBase {
|
|
|
595
639
|
diagnostics: metadata.diagnostics,
|
|
596
640
|
};
|
|
597
641
|
}
|
|
642
|
+
async saveAgentMetricsRun(payload) {
|
|
643
|
+
const database = this.getDatabase();
|
|
644
|
+
const recordedAt = payload.recordedAt ?? new Date().toISOString();
|
|
645
|
+
const runId = payload.id ?? createAgentMetricsRunId(recordedAt);
|
|
646
|
+
const projectId = toStringValue(database.prepare('SELECT id FROM projects LIMIT 1').get()?.id, 'agent-metrics-project');
|
|
647
|
+
const insertRun = database.prepare(`
|
|
648
|
+
INSERT INTO agent_metrics_runs (
|
|
649
|
+
id, project_id, recorded_at, sample_set_version, estimator_version, detail_count, metadata_json
|
|
650
|
+
)
|
|
651
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
652
|
+
`);
|
|
653
|
+
const insertDetail = database.prepare(`
|
|
654
|
+
INSERT INTO agent_metrics (
|
|
655
|
+
id, run_id, query_type, command_slug, response_size_bytes, raw_char_count,
|
|
656
|
+
estimated_input_tokens, estimated_output_tokens, estimated_total_tokens,
|
|
657
|
+
execution_time_ms, metadata_json
|
|
658
|
+
)
|
|
659
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
660
|
+
`);
|
|
661
|
+
this.runInTransaction(database, () => {
|
|
662
|
+
insertRun.run(runId, projectId, recordedAt, payload.sampleSetVersion, payload.estimatorVersion, payload.items.length, payload.metadata ? JSON.stringify(payload.metadata) : null);
|
|
663
|
+
payload.items.forEach((item, index) => {
|
|
664
|
+
insertDetail.run(item.id ?? `${runId}:${index + 1}`, runId, item.queryType, item.commandSlug, item.responseSizeBytes, item.rawCharCount, item.estimatedInputTokens, item.estimatedOutputTokens, item.estimatedTotalTokens, item.executionTimeMs ?? null, item.metadata ? JSON.stringify(item.metadata) : null);
|
|
665
|
+
});
|
|
666
|
+
});
|
|
667
|
+
return {
|
|
668
|
+
id: runId,
|
|
669
|
+
projectId,
|
|
670
|
+
recordedAt,
|
|
671
|
+
sampleSetVersion: payload.sampleSetVersion,
|
|
672
|
+
estimatorVersion: payload.estimatorVersion,
|
|
673
|
+
detailCount: payload.items.length,
|
|
674
|
+
metadata: payload.metadata ?? null,
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
async loadLatestAgentMetricsRun() {
|
|
678
|
+
const row = this.getDatabase()
|
|
679
|
+
.prepare(`
|
|
680
|
+
SELECT id, project_id, recorded_at, sample_set_version, estimator_version, detail_count, metadata_json
|
|
681
|
+
FROM agent_metrics_runs
|
|
682
|
+
ORDER BY recorded_at DESC, id DESC
|
|
683
|
+
LIMIT 1
|
|
684
|
+
`)
|
|
685
|
+
.get();
|
|
686
|
+
return row ? this.mapAgentMetricsRunRow(row) : null;
|
|
687
|
+
}
|
|
688
|
+
async listRecentAgentMetricsRuns(limit) {
|
|
689
|
+
const normalizedLimit = Math.max(0, Math.floor(limit));
|
|
690
|
+
if (normalizedLimit === 0) {
|
|
691
|
+
return [];
|
|
692
|
+
}
|
|
693
|
+
const rows = this.getDatabase()
|
|
694
|
+
.prepare(`
|
|
695
|
+
SELECT id, project_id, recorded_at, sample_set_version, estimator_version, detail_count, metadata_json
|
|
696
|
+
FROM agent_metrics_runs
|
|
697
|
+
ORDER BY recorded_at DESC, id DESC
|
|
698
|
+
LIMIT ?
|
|
699
|
+
`)
|
|
700
|
+
.all(normalizedLimit);
|
|
701
|
+
return rows.map((row) => this.mapAgentMetricsRunRow(row));
|
|
702
|
+
}
|
|
703
|
+
async listAgentMetricsByRun(runId) {
|
|
704
|
+
const rows = this.getDatabase()
|
|
705
|
+
.prepare(`
|
|
706
|
+
SELECT id, run_id, query_type, command_slug, response_size_bytes, raw_char_count,
|
|
707
|
+
estimated_input_tokens, estimated_output_tokens, estimated_total_tokens,
|
|
708
|
+
execution_time_ms, metadata_json
|
|
709
|
+
FROM agent_metrics
|
|
710
|
+
WHERE run_id = ?
|
|
711
|
+
ORDER BY id
|
|
712
|
+
`)
|
|
713
|
+
.all(runId);
|
|
714
|
+
return rows.map((row) => this.mapAgentMetricsDetailRow(row));
|
|
715
|
+
}
|
|
716
|
+
async listAgentMetricsHistoryByQueryType(queryType) {
|
|
717
|
+
const rows = this.getDatabase()
|
|
718
|
+
.prepare(`
|
|
719
|
+
SELECT agent_metrics.id, agent_metrics.run_id, agent_metrics.query_type, agent_metrics.command_slug,
|
|
720
|
+
agent_metrics.response_size_bytes, agent_metrics.raw_char_count,
|
|
721
|
+
agent_metrics.estimated_input_tokens, agent_metrics.estimated_output_tokens,
|
|
722
|
+
agent_metrics.estimated_total_tokens, agent_metrics.execution_time_ms,
|
|
723
|
+
agent_metrics.metadata_json
|
|
724
|
+
FROM agent_metrics
|
|
725
|
+
INNER JOIN agent_metrics_runs ON agent_metrics_runs.id = agent_metrics.run_id
|
|
726
|
+
WHERE agent_metrics.query_type = ?
|
|
727
|
+
ORDER BY agent_metrics_runs.recorded_at DESC, agent_metrics_runs.id DESC, agent_metrics.id ASC
|
|
728
|
+
`)
|
|
729
|
+
.all(queryType);
|
|
730
|
+
return rows.map((row) => this.mapAgentMetricsDetailRow(row));
|
|
731
|
+
}
|
|
598
732
|
getGovernanceGraphRuntimeStats() {
|
|
599
733
|
return this.governanceGraphCache?.getStats() ?? {
|
|
600
734
|
cacheMode: 'sqlite-direct',
|
|
@@ -612,6 +746,47 @@ export class SQLiteStorage extends StorageBase {
|
|
|
612
746
|
addColumnIfMissing(database, 'dependencies', 'line', 'line INTEGER');
|
|
613
747
|
addColumnIfMissing(database, 'dependencies', 'confidence', 'confidence TEXT');
|
|
614
748
|
}
|
|
749
|
+
assertSchemaCompatibility(database) {
|
|
750
|
+
if (!hasTable(database, 'metadata')) {
|
|
751
|
+
return;
|
|
752
|
+
}
|
|
753
|
+
const schemaVersion = toStringValue(database.prepare('SELECT value FROM metadata WHERE key = ? LIMIT 1').get('schema_version')?.value);
|
|
754
|
+
const projectCount = hasTable(database, 'projects')
|
|
755
|
+
? toNumberValue(database.prepare('SELECT COUNT(*) AS count FROM projects').get()?.count)
|
|
756
|
+
: 0;
|
|
757
|
+
const dependencyCount = hasTable(database, 'dependencies')
|
|
758
|
+
? toNumberValue(database.prepare('SELECT COUNT(*) AS count FROM dependencies').get()?.count)
|
|
759
|
+
: 0;
|
|
760
|
+
const snapshotCount = hasTable(database, 'snapshots')
|
|
761
|
+
? toNumberValue(database.prepare('SELECT COUNT(*) AS count FROM snapshots').get()?.count)
|
|
762
|
+
: 0;
|
|
763
|
+
const hasMaterializedGraph = projectCount > 0 || dependencyCount > 0;
|
|
764
|
+
if (!hasMaterializedGraph && (schemaVersion === '' || schemaVersion === 'bootstrap-v1') && snapshotCount > 0) {
|
|
765
|
+
return;
|
|
766
|
+
}
|
|
767
|
+
if (schemaVersion === '' && !hasMaterializedGraph) {
|
|
768
|
+
return;
|
|
769
|
+
}
|
|
770
|
+
if (schemaVersion !== CURRENT_SQLITE_SCHEMA_VERSION) {
|
|
771
|
+
throw createGraphRebuildRequiredError(`Found SQLite schema version "${schemaVersion || 'unknown'}" but expected "${CURRENT_SQLITE_SCHEMA_VERSION}".`);
|
|
772
|
+
}
|
|
773
|
+
if (dependencyCount > 0 && !hasTable(database, 'graph_edges')) {
|
|
774
|
+
throw createGraphRebuildRequiredError('Traversal projection table "graph_edges" is missing.');
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
assertProjectionParity(database) {
|
|
778
|
+
if (!hasTable(database, 'dependencies') || !hasTable(database, 'graph_edges')) {
|
|
779
|
+
return;
|
|
780
|
+
}
|
|
781
|
+
const dependencyCount = toNumberValue(database.prepare('SELECT COUNT(*) AS count FROM dependencies').get()?.count);
|
|
782
|
+
const projectionCount = toNumberValue(database.prepare('SELECT COUNT(*) AS count FROM graph_edges').get()?.count);
|
|
783
|
+
if (dependencyCount === 0 && projectionCount === 0) {
|
|
784
|
+
return;
|
|
785
|
+
}
|
|
786
|
+
if (dependencyCount !== projectionCount) {
|
|
787
|
+
throw createGraphRebuildRequiredError(`Traversal projection drift detected (${projectionCount}/${dependencyCount} rows).`);
|
|
788
|
+
}
|
|
789
|
+
}
|
|
615
790
|
backfillLegacySnapshotIfNeeded(database) {
|
|
616
791
|
const hasCurrentProject = toNumberValue(database.prepare('SELECT COUNT(*) AS count FROM projects').get()?.count) > 0;
|
|
617
792
|
if (hasCurrentProject) {
|
|
@@ -636,6 +811,23 @@ export class SQLiteStorage extends StorageBase {
|
|
|
636
811
|
.prepare(SQLITE_SCHEMA_VERSION_UPSERT_SQL)
|
|
637
812
|
.run('legacy_snapshot_backfilled_at', recordedAt);
|
|
638
813
|
}
|
|
814
|
+
backfillCanonicalDependencyIdsIfNeeded(database) {
|
|
815
|
+
const dependencyCount = toNumberValue(database.prepare('SELECT COUNT(*) AS count FROM dependencies').get()?.count);
|
|
816
|
+
if (dependencyCount === 0) {
|
|
817
|
+
return;
|
|
818
|
+
}
|
|
819
|
+
const currentGraph = this.readCodeGraph(database);
|
|
820
|
+
const normalizedGraph = this.normalizeGraph(currentGraph);
|
|
821
|
+
const requiresRewrite = currentGraph.dependencies.some((dependency, index) => (dependency.id !== normalizedGraph.dependencies[index]?.id));
|
|
822
|
+
if (!requiresRewrite) {
|
|
823
|
+
return;
|
|
824
|
+
}
|
|
825
|
+
const recordedAt = new Date().toISOString();
|
|
826
|
+
this.replaceCurrentGraph(database, currentGraph, 'edge-id-normalization-backfill', recordedAt);
|
|
827
|
+
database
|
|
828
|
+
.prepare(SQLITE_SCHEMA_VERSION_UPSERT_SQL)
|
|
829
|
+
.run('edge_id_normalized_at', recordedAt);
|
|
830
|
+
}
|
|
639
831
|
replaceCurrentGraph(database, graph, historySource, recordedAt = new Date().toISOString()) {
|
|
640
832
|
const normalizedGraph = this.normalizeGraph(graph);
|
|
641
833
|
const symbolIds = new Set(normalizedGraph.symbols.map(symbol => symbol.id));
|
|
@@ -661,6 +853,12 @@ export class SQLiteStorage extends StorageBase {
|
|
|
661
853
|
id, source_id, source_entity_type, target_id, target_entity_type, dependency_type, file_path, line, confidence
|
|
662
854
|
)
|
|
663
855
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
856
|
+
`);
|
|
857
|
+
const insertGraphEdge = database.prepare(`
|
|
858
|
+
INSERT INTO graph_edges (
|
|
859
|
+
dependency_id, source_id, source_entity_type, target_id, target_entity_type, dependency_type, confidence, file_path, line
|
|
860
|
+
)
|
|
861
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
664
862
|
`);
|
|
665
863
|
const insertSnapshotMirror = database.prepare(`
|
|
666
864
|
INSERT INTO snapshots (id, project_id, graph_json, updated_at)
|
|
@@ -681,6 +879,7 @@ export class SQLiteStorage extends StorageBase {
|
|
|
681
879
|
const snapshotId = createHistorySnapshotId(recordedAt);
|
|
682
880
|
this.runInTransaction(database, () => {
|
|
683
881
|
database.prepare('DELETE FROM dependencies').run();
|
|
882
|
+
database.prepare('DELETE FROM graph_edges').run();
|
|
684
883
|
database.prepare('DELETE FROM symbols').run();
|
|
685
884
|
database.prepare('DELETE FROM modules').run();
|
|
686
885
|
database.prepare('DELETE FROM projects').run();
|
|
@@ -695,7 +894,9 @@ export class SQLiteStorage extends StorageBase {
|
|
|
695
894
|
for (const dependency of normalizedGraph.dependencies) {
|
|
696
895
|
const sourceEntityType = resolveEntityType(dependency.sourceEntityType, dependency.sourceId, symbolIds);
|
|
697
896
|
const targetEntityType = resolveEntityType(dependency.targetEntityType, dependency.targetId, symbolIds);
|
|
698
|
-
|
|
897
|
+
const confidence = normalizeDependencyConfidence(dependency.confidence);
|
|
898
|
+
insertDependency.run(dependency.id, dependency.sourceId, sourceEntityType, dependency.targetId, targetEntityType, dependency.type, dependency.filePath ?? null, dependency.line ?? null, confidence ?? null);
|
|
899
|
+
insertGraphEdge.run(dependency.id, dependency.sourceId, sourceEntityType, dependency.targetId, targetEntityType, dependency.type, confidence ?? 'EXTRACTED', dependency.filePath ?? null, dependency.line ?? null);
|
|
699
900
|
}
|
|
700
901
|
insertSnapshotMirror.run('codemap-snapshot', normalizedGraph.project.id, serializeCodeGraphSnapshot(normalizedGraph), recordedAt);
|
|
701
902
|
insertHistorySnapshot.run(snapshotId, normalizedGraph.project.id, recordedAt, historySource, normalizedGraph.modules.length, normalizedGraph.symbols.length, normalizedGraph.dependencies.length);
|
|
@@ -715,10 +916,11 @@ export class SQLiteStorage extends StorageBase {
|
|
|
715
916
|
for (const dependency of normalizedGraph.dependencies) {
|
|
716
917
|
const sourceEntityType = resolveEntityType(dependency.sourceEntityType, dependency.sourceId, symbolIds);
|
|
717
918
|
const targetEntityType = resolveEntityType(dependency.targetEntityType, dependency.targetId, symbolIds);
|
|
919
|
+
const confidence = normalizeDependencyConfidence(dependency.confidence);
|
|
718
920
|
insertHistoryRelation.run(`${snapshotId}:dependency:${dependency.id}`, snapshotId, 'dependency_snapshot', dependency.sourceId, sourceEntityType, dependency.targetId, targetEntityType, recordedAt, JSON.stringify({
|
|
719
921
|
dependencyId: dependency.id,
|
|
720
922
|
dependencyType: dependency.type,
|
|
721
|
-
confidence:
|
|
923
|
+
confidence: confidence ?? null,
|
|
722
924
|
filePath: dependency.filePath ?? null,
|
|
723
925
|
line: dependency.line ?? null,
|
|
724
926
|
}));
|
|
@@ -727,11 +929,24 @@ export class SQLiteStorage extends StorageBase {
|
|
|
727
929
|
upsertMetadata.run(FAILED_FILE_COUNT_METADATA_KEY, String(normalizedGraph.failedFileCount ?? 0));
|
|
728
930
|
upsertMetadata.run(PARSE_FAILURE_FILES_METADATA_KEY, JSON.stringify(normalizedGraph.parseFailureFiles ?? []));
|
|
729
931
|
upsertMetadata.run(LAST_GRAPH_SYNC_AT_METADATA_KEY, recordedAt);
|
|
932
|
+
upsertMetadata.run('schema_version', CURRENT_SQLITE_SCHEMA_VERSION);
|
|
933
|
+
upsertMetadata.run(LAST_REFRESH_METADATA_KEY, normalizedGraph.lastRefresh ? JSON.stringify(normalizedGraph.lastRefresh) : '');
|
|
730
934
|
});
|
|
935
|
+
this.assertProjectionParity(database);
|
|
731
936
|
this.refreshGovernanceGraphCache(database);
|
|
732
937
|
}
|
|
733
938
|
normalizeGraph(graph) {
|
|
734
939
|
const projectRootPath = graph.project.rootPath || this.projectPath || '';
|
|
940
|
+
const symbols = graph.symbols.map(symbol => ({
|
|
941
|
+
...symbol,
|
|
942
|
+
location: { ...symbol.location },
|
|
943
|
+
}));
|
|
944
|
+
const symbolIds = new Set(symbols.map(symbol => symbol.id));
|
|
945
|
+
const dependencies = deduplicateDependenciesForStorage(graph.dependencies.map(dependency => ({
|
|
946
|
+
...dependency,
|
|
947
|
+
confidence: normalizeDependencyConfidence(dependency.confidence),
|
|
948
|
+
})), symbolIds);
|
|
949
|
+
const canonicalDependencies = normalizeDependencyIdsForStorage(dependencies, graph.modules, symbols);
|
|
735
950
|
return {
|
|
736
951
|
project: {
|
|
737
952
|
...graph.project,
|
|
@@ -743,17 +958,17 @@ export class SQLiteStorage extends StorageBase {
|
|
|
743
958
|
...module,
|
|
744
959
|
stats: { ...module.stats },
|
|
745
960
|
})),
|
|
746
|
-
symbols
|
|
747
|
-
|
|
748
|
-
location: { ...symbol.location },
|
|
749
|
-
})),
|
|
750
|
-
dependencies: graph.dependencies.map(dependency => ({ ...dependency })),
|
|
961
|
+
symbols,
|
|
962
|
+
dependencies: canonicalDependencies,
|
|
751
963
|
graphStatus: graph.graphStatus ?? 'complete',
|
|
752
964
|
failedFileCount: graph.failedFileCount ?? 0,
|
|
753
965
|
parseFailureFiles: [...(graph.parseFailureFiles ?? [])],
|
|
966
|
+
lastRefresh: graph.lastRefresh,
|
|
754
967
|
};
|
|
755
968
|
}
|
|
756
969
|
readCodeGraph(database) {
|
|
970
|
+
this.assertSchemaCompatibility(database);
|
|
971
|
+
this.assertProjectionParity(database);
|
|
757
972
|
const projectRow = database
|
|
758
973
|
.prepare(`
|
|
759
974
|
SELECT id, name, root_path, created_at, updated_at
|
|
@@ -803,6 +1018,7 @@ export class SQLiteStorage extends StorageBase {
|
|
|
803
1018
|
graphStatus: graphIntegrity.graphStatus,
|
|
804
1019
|
failedFileCount: graphIntegrity.failedFileCount,
|
|
805
1020
|
parseFailureFiles: graphIntegrity.parseFailureFiles,
|
|
1021
|
+
lastRefresh: readGraphMetadata(database).lastRefresh,
|
|
806
1022
|
};
|
|
807
1023
|
}
|
|
808
1024
|
mapModuleRow(row) {
|
|
@@ -846,7 +1062,33 @@ export class SQLiteStorage extends StorageBase {
|
|
|
846
1062
|
type: toStringValue(row.dependency_type),
|
|
847
1063
|
filePath: toStringValue(row.file_path) || undefined,
|
|
848
1064
|
line: toOptionalNumberValue(row.line),
|
|
849
|
-
confidence:
|
|
1065
|
+
confidence: normalizeDependencyConfidence(row.confidence),
|
|
1066
|
+
};
|
|
1067
|
+
}
|
|
1068
|
+
mapAgentMetricsRunRow(row) {
|
|
1069
|
+
return {
|
|
1070
|
+
id: toStringValue(row.id),
|
|
1071
|
+
projectId: toStringValue(row.project_id),
|
|
1072
|
+
recordedAt: toStringValue(row.recorded_at),
|
|
1073
|
+
sampleSetVersion: toStringValue(row.sample_set_version),
|
|
1074
|
+
estimatorVersion: toStringValue(row.estimator_version),
|
|
1075
|
+
detailCount: toNumberValue(row.detail_count),
|
|
1076
|
+
metadata: parseJsonValue(row.metadata_json),
|
|
1077
|
+
};
|
|
1078
|
+
}
|
|
1079
|
+
mapAgentMetricsDetailRow(row) {
|
|
1080
|
+
return {
|
|
1081
|
+
id: toStringValue(row.id),
|
|
1082
|
+
runId: toStringValue(row.run_id),
|
|
1083
|
+
queryType: toStringValue(row.query_type),
|
|
1084
|
+
commandSlug: toStringValue(row.command_slug),
|
|
1085
|
+
responseSizeBytes: toNumberValue(row.response_size_bytes),
|
|
1086
|
+
rawCharCount: toNumberValue(row.raw_char_count),
|
|
1087
|
+
estimatedInputTokens: toNumberValue(row.estimated_input_tokens),
|
|
1088
|
+
estimatedOutputTokens: toNumberValue(row.estimated_output_tokens),
|
|
1089
|
+
estimatedTotalTokens: toNumberValue(row.estimated_total_tokens),
|
|
1090
|
+
executionTimeMs: toOptionalNumberValue(row.execution_time_ms),
|
|
1091
|
+
metadata: parseJsonValue(row.metadata_json),
|
|
850
1092
|
};
|
|
851
1093
|
}
|
|
852
1094
|
runInTransaction(database, callback) {
|
|
@@ -868,9 +1110,13 @@ export class SQLiteStorage extends StorageBase {
|
|
|
868
1110
|
return this.database;
|
|
869
1111
|
}
|
|
870
1112
|
readGovernanceGraphForAnalysis(database) {
|
|
1113
|
+
this.assertSchemaCompatibility(database);
|
|
1114
|
+
this.assertProjectionParity(database);
|
|
871
1115
|
return readGovernanceGraphFromSQLite(database, this.projectPath ?? '');
|
|
872
1116
|
}
|
|
873
1117
|
refreshGovernanceGraphCache(database) {
|
|
1118
|
+
this.assertSchemaCompatibility(database);
|
|
1119
|
+
this.assertProjectionParity(database);
|
|
874
1120
|
const cache = new GovernanceGraphCache(database, this.projectPath ?? '', this.runtimeOptions.governanceGraphThresholds ?? DEFAULT_GOVERNANCE_GRAPH_PERF_THRESHOLDS);
|
|
875
1121
|
cache.hydrate();
|
|
876
1122
|
this.governanceGraphCache = cache;
|