@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
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [2.7.0] - 2026-05-11 - Agent Effectiveness Validation
|
|
6
|
+
|
|
7
|
+
### 🛠️ Infrastructure
|
|
8
|
+
|
|
9
|
+
- **agent-metrics**: 新增 `codemap agent-metrics` 命令家族,支持 token 成本分析、报告聚合、CI threshold gate
|
|
10
|
+
- **agent-metrics**: `codemap agent-metrics token` 对代表性查询执行 token 成本分析(响应大小、估算 token 数、原始字符数)
|
|
11
|
+
- **agent-metrics**: `codemap agent-metrics report` 输出格式化报告,支持人类可读表格和 JSON 两种模式
|
|
12
|
+
- **agent-metrics**: `codemap agent-metrics gate` CI 管道阈值检测,默认 warn-only 模式
|
|
13
|
+
|
|
14
|
+
### 📊 Intelligence
|
|
15
|
+
|
|
16
|
+
- **trends**: 追踪 latest-vs-previous 绝对 token 趋势,按查询类型分组
|
|
17
|
+
- **distribution**: 提供 `p50/p95/max` 分布深度,用于异常值检测
|
|
18
|
+
- **advisory**: 识别最高成本查询类型和样本,提供优化建议
|
|
19
|
+
|
|
20
|
+
### 📝 Documentation
|
|
21
|
+
|
|
22
|
+
- **release**: 同步 `llms.txt`、`AI_GUIDE.md`、`AI_DISCOVERY.md`、`ai-document-index.yaml` 到 `v2.7.0`
|
|
23
|
+
- **changelog**: 新增 v2.7.0 发布条目,记录 agent-effectiveness-validation milestone
|
|
24
|
+
|
|
5
25
|
## [2.0.0] - 2026-05-01 - Agent-Native Foundation
|
|
6
26
|
|
|
7
27
|
### 🏗️ Architecture
|
package/README.md
CHANGED
|
@@ -1,241 +1,116 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
> AI-Native, Human-Friendly Code Architecture Governance Infrastructure — `v2.0` Milestone
|
|
4
|
-
|
|
5
|
-
[中文版本](./README.zh-CN.md)
|
|
6
|
-
|
|
7
|
-
CodeMap is an AI-Native-first, human-friendly code architecture governance infrastructure for TypeScript/JavaScript/Go projects. `v2.0` upgraded the CLI surface to a schema-driven self-describing unified interface: a single contract schema simultaneously generates the parser, MCP tool definitions, `--help-json`, and shell completions. `codemap doctor` provides continuous health diagnostics, the `Failure-to-Action Protocol` turns errors into structured state transitions, and the WASM-first build foundation eliminates the #1 installation drop-off caused by native dependency compilation failures. Human users get table/color output via `--human` or TTY auto-detection; AI/Agents receive JSON/NDJSON by default.
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## Features
|
|
1
|
+
<!-- generated-by: gsd-doc-writer -->
|
|
12
2
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
- **Interface Contract Schema** — A single machine-readable schema defines the entire CLI surface; `codemap --schema` outputs the full contract JSON for agent introspection and dynamic adaptation
|
|
16
|
-
- **CLI-as-MCP Automatic Gateway** — All schema-defined CLI commands are automatically exposed as MCP tools with zero handwritten maintenance; new commands automatically get MCP exposure
|
|
17
|
-
- **AI-First Default Output** — JSON/NDJSON by default; `--human` flag renders tables/colors on demand; TTY auto-detection preserves interactive experience; progress events go to stderr
|
|
18
|
-
- **`codemap doctor`** — Continuous health diagnostics detecting ghost commands, native dependency issues, workspace drift, and agent connectivity
|
|
19
|
-
- **Failure-to-Action Protocol** — Every error returns structured `rootCause` + `remediationPlan` + `confidence` + `nextCommand`; agents can attempt automatic remediation
|
|
20
|
-
- **Validation Router** — Routes minimal verification by change type; docs guardrail validates that referenced commands are real and runnable
|
|
21
|
-
- **WASM-First Build Foundation** — `tree-sitter` / `better-sqlite3` provide WASM fallback paths; `--native` forces native mode; `codemap benchmark` compares WASM vs Native performance
|
|
3
|
+
# CodeMap
|
|
22
4
|
|
|
23
|
-
|
|
5
|
+
CodeMap is an AI-Native TypeScript code map tool for AI-assisted development. It analyzes a repository, builds symbol and dependency graphs, exposes the results through a CLI, HTTP API, and MCP server, and writes structured artifacts that agents can consume directly.
|
|
24
6
|
|
|
25
|
-
|
|
26
|
-
- **Core analysis commands** — `generate`, `query`, `deps`, `impact`, `complexity`, `cycles`, `analyze`, `design`, `export`, `ci`
|
|
27
|
-
- **Layered architecture (MVP3)** — Clear boundaries: `Interface → Infrastructure → Domain → Server → CLI`
|
|
28
|
-
- **Dual parsing modes** — `fast` (regex) and `smart` (TypeScript AST)
|
|
29
|
-
- **Multi-language support** — TypeScript/JavaScript, Go, Python (extensible architecture)
|
|
30
|
-
- **Dependency / impact / complexity analysis** — For change impact assessment, refactoring inventory, and architecture retrospectives
|
|
31
|
-
- **CI gate and docs guardrail** — Commit format, file headers, risk assessment, docs/output contract checks
|
|
32
|
-
- **Multi-format export and storage abstraction** — Export graph data with filesystem / memory / sqlite backends
|
|
7
|
+
AI/Agent 是主要消费者,人类主要负责启动、审查和发布。
|
|
33
8
|
|
|
34
|
-
|
|
9
|
+
[](https://www.npmjs.com/package/@mycodemap/mycodemap)
|
|
10
|
+
[](LICENSE)
|
|
11
|
+
[](https://github.com/yuanyuanyuan/mycodemap/actions/workflows/ci-gateway.yml)
|
|
35
12
|
|
|
36
|
-
##
|
|
13
|
+
## Install
|
|
37
14
|
|
|
38
15
|
```bash
|
|
39
|
-
# Using npm
|
|
40
|
-
npm install @mycodemap/mycodemap
|
|
41
|
-
|
|
42
|
-
# Using yarn
|
|
43
|
-
yarn add @mycodemap/mycodemap
|
|
44
|
-
|
|
45
|
-
# Using pnpm
|
|
46
|
-
pnpm add @mycodemap/mycodemap
|
|
47
|
-
|
|
48
|
-
# Global install (recommended for CLI access)
|
|
49
16
|
npm install -g @mycodemap/mycodemap
|
|
50
17
|
```
|
|
51
18
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
### No Build Tools? No Problem
|
|
19
|
+
Requirements:
|
|
55
20
|
|
|
56
|
-
|
|
57
|
-
-
|
|
58
|
-
- `better-sqlite3` automatically falls back to `node:sqlite` (Node.js 22+) or `sql.js` (WASM)
|
|
59
|
-
- No manual intervention required — fallback activates on first run
|
|
60
|
-
|
|
61
|
-
### Force Native (Performance)
|
|
62
|
-
|
|
63
|
-
If you have build tools installed and want maximum performance:
|
|
64
|
-
```bash
|
|
65
|
-
mycodemap --native <command>
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
---
|
|
21
|
+
- Node.js `>= 20.0.0`
|
|
22
|
+
- A project with source files to analyze
|
|
69
23
|
|
|
70
24
|
## Quick Start
|
|
71
25
|
|
|
72
26
|
```bash
|
|
73
|
-
# 1. Initialize
|
|
27
|
+
# 1. Initialize a project (preview mode)
|
|
74
28
|
mycodemap init
|
|
75
29
|
|
|
76
|
-
# 2.
|
|
77
|
-
mycodemap
|
|
78
|
-
|
|
79
|
-
# 3. View generated files
|
|
80
|
-
ls .mycodemap/
|
|
81
|
-
# AI_MAP.md - Project overview (for AI)
|
|
82
|
-
# CONTEXT.md - Context entry (links to context/README.md)
|
|
83
|
-
# context/ - Detailed module contexts
|
|
84
|
-
# codemap.json - Structured JSON data
|
|
85
|
-
# dependency-graph.md - Mermaid dependency graph
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
```bash
|
|
89
|
-
# 4. For AI/Agent: structured output is the default
|
|
90
|
-
mycodemap impact -f src/cli/index.ts -j
|
|
91
|
-
|
|
92
|
-
# Human-readable output on demand
|
|
93
|
-
mycodemap analyze -i read -t src/cli/index.ts --human
|
|
94
|
-
|
|
95
|
-
# Human design → design contract → AI/Agent consumption
|
|
96
|
-
cp docs/product-specs/DESIGN_CONTRACT_TEMPLATE.md mycodemap.design.md
|
|
97
|
-
mycodemap design validate mycodemap.design.md --json
|
|
98
|
-
mycodemap design map mycodemap.design.md --json
|
|
99
|
-
mycodemap design handoff mycodemap.design.md --json
|
|
100
|
-
mycodemap design verify mycodemap.design.md --json
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
After generation, provide `.mycodemap/AI_MAP.md` to your AI assistant for rapid project understanding. For structured results, use JSON/machine mode.
|
|
30
|
+
# 2. Apply the config with --yes
|
|
31
|
+
mycodemap init --yes
|
|
104
32
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
## CLI Commands
|
|
108
|
-
|
|
109
|
-
### `mycodemap init`
|
|
110
|
-
|
|
111
|
-
Initialize and reconcile the project's CodeMap workspace / config / hooks / rules state.
|
|
112
|
-
|
|
113
|
-
```bash
|
|
114
|
-
mycodemap init # Show reconciliation preview (default: no write)
|
|
115
|
-
mycodemap init --interactive # Explicitly show preview (same as default)
|
|
116
|
-
mycodemap init -y # Write with defaults
|
|
33
|
+
# 3. Generate the code map
|
|
34
|
+
mycodemap generate
|
|
117
35
|
```
|
|
118
36
|
|
|
119
|
-
|
|
37
|
+
`mycodemap init` previews the reconciliation plan by default. Use `--yes` to apply it immediately, or `--profile <name>` to bypass auto-detection.
|
|
120
38
|
|
|
121
|
-
|
|
39
|
+
`mycodemap generate` writes analysis output to `.mycodemap/` by default. The canonical config path is `.mycodemap/config.json`; the loader still accepts <!-- VERIFY: `mycodemap.config.json` --> and legacy <!-- VERIFY: `codemap.config.json` --> for compatibility.
|
|
122
40
|
|
|
123
|
-
|
|
124
|
-
mycodemap generate # Default hybrid mode
|
|
125
|
-
mycodemap generate -m smart # Smart mode (AST deep analysis)
|
|
126
|
-
mycodemap generate -o ./docs/codemap # Custom output directory
|
|
127
|
-
mycodemap generate --symbol-level # Extra symbol-level call deps
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
| Option | Description | Default |
|
|
131
|
-
|--------|-------------|---------|
|
|
132
|
-
| `-m, --mode <mode>` | Analysis mode: `fast`, `smart`, or `hybrid` | `hybrid` |
|
|
133
|
-
| `-o, --output <dir>` | Output directory | `.mycodemap` |
|
|
134
|
-
| `--symbol-level` | Materialize symbol-level `call` deps | `false` |
|
|
41
|
+
## Usage Examples
|
|
135
42
|
|
|
136
|
-
###
|
|
137
|
-
|
|
138
|
-
Query symbols, modules, and dependencies in the code map.
|
|
43
|
+
### Search symbols across the project
|
|
139
44
|
|
|
140
45
|
```bash
|
|
141
|
-
mycodemap query
|
|
142
|
-
mycodemap query -m "src/parser" # Module info
|
|
143
|
-
mycodemap query -S "cache" # Fuzzy search
|
|
144
|
-
mycodemap query -S "parse" -j # JSON output
|
|
46
|
+
mycodemap query --symbol createCheckCommand
|
|
145
47
|
```
|
|
146
48
|
|
|
147
|
-
###
|
|
148
|
-
|
|
149
|
-
Unified analysis entry with four intents: `find`, `read`, `link`, `show`.
|
|
49
|
+
### Analyze with intent-driven output
|
|
150
50
|
|
|
151
51
|
```bash
|
|
152
52
|
mycodemap analyze -i find -k SourceLocation
|
|
153
|
-
mycodemap analyze -i read -t src/cli/index.ts --
|
|
53
|
+
mycodemap analyze -i read -t src/cli/index.ts --include-tests --json
|
|
154
54
|
mycodemap analyze -i link -t src/cli/index.ts
|
|
155
55
|
mycodemap analyze -i show -t src/orchestrator
|
|
156
56
|
```
|
|
157
57
|
|
|
158
|
-
###
|
|
159
|
-
|
|
160
|
-
Output the full Interface Contract Schema JSON for agent introspection.
|
|
58
|
+
### Detect circular dependencies
|
|
161
59
|
|
|
162
60
|
```bash
|
|
163
|
-
mycodemap
|
|
164
|
-
mycodemap --schema | jq '.' # Pretty-print with jq
|
|
61
|
+
mycodemap cycles
|
|
165
62
|
```
|
|
166
63
|
|
|
167
|
-
###
|
|
168
|
-
|
|
169
|
-
Continuous health diagnostics for the CodeMap ecosystem.
|
|
64
|
+
### Export the dependency graph
|
|
170
65
|
|
|
171
66
|
```bash
|
|
172
|
-
mycodemap
|
|
173
|
-
mycodemap doctor --json # Machine-readable JSON
|
|
67
|
+
mycodemap export --format mermaid
|
|
174
68
|
```
|
|
175
69
|
|
|
176
|
-
|
|
177
|
-
|----------|--------|
|
|
178
|
-
| **install** | Native deps (`tree-sitter`, `better-sqlite3`) load status |
|
|
179
|
-
| **config** | `.mycodemap/` workspace configuration integrity |
|
|
180
|
-
| **runtime** | Ghost commands, command stubs, package.json consistency |
|
|
181
|
-
| **agent** | MCP connectivity, schema validity, tool registration |
|
|
182
|
-
|
|
183
|
-
### `mycodemap benchmark`
|
|
184
|
-
|
|
185
|
-
Compare WASM vs Native performance.
|
|
70
|
+
## Main Commands
|
|
186
71
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
mycodemap
|
|
190
|
-
mycodemap
|
|
191
|
-
|
|
72
|
+
| Command | Purpose |
|
|
73
|
+
|---|---|
|
|
74
|
+
| `mycodemap generate` | Analyze the project and write the code map artifacts |
|
|
75
|
+
| `mycodemap query` | Search symbols, modules, and dependencies |
|
|
76
|
+
| `mycodemap deps` | Inspect module dependency relationships |
|
|
77
|
+
| `mycodemap cycles` | Detect circular dependencies |
|
|
78
|
+
| `mycodemap complexity` | Inspect file and function complexity |
|
|
79
|
+
| `mycodemap impact` | Estimate the impact of a file change |
|
|
80
|
+
| `mycodemap analyze` | Unified analysis entry with intent-driven output |
|
|
81
|
+
| `mycodemap doctor` | Run health diagnostics for config, runtime, and agents |
|
|
82
|
+
| `mycodemap benchmark` | Compare WASM and native startup/performance |
|
|
83
|
+
| `mycodemap export` | Export graph data as JSON, GraphML, DOT, or Mermaid |
|
|
84
|
+
| `mycodemap ship` | Release workflow helpers |
|
|
192
85
|
|
|
193
|
-
|
|
86
|
+
Additional operational commands include `ci`, `check`, `workflow`, `history`, `preview`, `env-contract`, `mcp`, and `readiness-gate`.
|
|
194
87
|
|
|
195
|
-
|
|
88
|
+
### 已移除的公共 CLI 命令
|
|
196
89
|
|
|
197
|
-
|
|
198
|
-
mycodemap
|
|
199
|
-
mycodemap
|
|
200
|
-
|
|
90
|
+
- `mycodemap server`
|
|
91
|
+
- `mycodemap watch`
|
|
92
|
+
- `mycodemap report`
|
|
93
|
+
- `mycodemap logs`
|
|
201
94
|
|
|
202
|
-
|
|
203
|
-
- Dynamic tool registration: add command to schema → restart MCP server → new tool appears automatically
|
|
204
|
-
- See `docs/ai-guide/INTEGRATION.md` for details
|
|
95
|
+
These commands are no longer part of the public CLI surface. Use the current `mycodemap` entry points and the `/api/v1` HTTP server instead.
|
|
205
96
|
|
|
206
|
-
|
|
97
|
+
`server`、`watch`、`report`、`logs` 已从 public CLI 移除,并在调用时给出迁移提示。
|
|
207
98
|
|
|
208
99
|
## Documentation
|
|
209
100
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
### 🤖 AI / Agent Docs
|
|
220
|
-
|
|
221
|
-
| Document | Description |
|
|
222
|
-
|----------|-------------|
|
|
223
|
-
| **[📘 AI_GUIDE.md](AI_GUIDE.md)** | **AI main guide** — quick reference, command decision tree, prompt templates |
|
|
224
|
-
| **[🚀 Quick Start](docs/ai-guide/QUICKSTART.md)** | Scenario-to-command mapping |
|
|
225
|
-
| **[📚 Commands](docs/ai-guide/COMMANDS.md)** | Full CLI command reference |
|
|
226
|
-
| **[📊 Output Schema](docs/ai-guide/OUTPUT.md)** | JSON output structure parsing |
|
|
227
|
-
| **[🔧 Integration](docs/ai-guide/INTEGRATION.md)** | MCP/Agent integration, error handling |
|
|
228
|
-
| **[🛡️ AGENTS.md](AGENTS.md)** | Repository-level constraints |
|
|
229
|
-
| **[⚡ CLAUDE.md](CLAUDE.md)** | AI entry routing |
|
|
230
|
-
|
|
231
|
-
---
|
|
101
|
+
- [AI Guide](AI_GUIDE.md)
|
|
102
|
+
- [Getting Started](docs/GETTING-STARTED.md)
|
|
103
|
+
- [Development](docs/DEVELOPMENT.md)
|
|
104
|
+
- [Testing](docs/TESTING.md)
|
|
105
|
+
- [Configuration](docs/CONFIGURATION.md)
|
|
106
|
+
- [API Reference](docs/API.md)
|
|
107
|
+
- [Contributing](CONTRIBUTING.md)
|
|
108
|
+
- [Architecture](ARCHITECTURE.md)
|
|
232
109
|
|
|
233
110
|
## Contributing
|
|
234
111
|
|
|
235
|
-
See [
|
|
236
|
-
|
|
237
|
-
---
|
|
112
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
238
113
|
|
|
239
114
|
## License
|
|
240
115
|
|
|
241
|
-
[
|
|
116
|
+
MIT. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AgentMetricsReportResult, AgentMetricsTokenRunResult } from '../../../orchestrator/agent-metrics-service.js';
|
|
2
|
+
export declare function formatAgentMetricsTokenRunHuman(result: AgentMetricsTokenRunResult): string;
|
|
3
|
+
export declare function formatAgentMetricsReportHuman(result: AgentMetricsReportResult): string;
|
|
4
|
+
//# sourceMappingURL=human.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"human.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/agent-metrics/human.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,wBAAwB,EACxB,0BAA0B,EAC3B,MAAM,gDAAgD,CAAC;AA+DxD,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,0BAA0B,GAAG,MAAM,CAqB1F;AAED,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,wBAAwB,GAAG,MAAM,CAuFtF"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// [META] since:2026-05-10 | owner:cli-team | stable:false
|
|
2
|
+
// [WHY] Human renderer for agent-metrics outputs while keeping shared output mode as the primary surface
|
|
3
|
+
function formatTotals(totals) {
|
|
4
|
+
return [
|
|
5
|
+
`Queries: ${totals.queryCount}`,
|
|
6
|
+
`Response bytes: ${totals.responseSizeBytes}`,
|
|
7
|
+
`Raw chars: ${totals.rawCharCount}`,
|
|
8
|
+
`Estimated input tokens: ${totals.estimatedInputTokens}`,
|
|
9
|
+
`Estimated output tokens: ${totals.estimatedOutputTokens}`,
|
|
10
|
+
`Estimated total tokens: ${totals.estimatedTotalTokens}`,
|
|
11
|
+
`Execution time: ${totals.executionTimeMs}ms`,
|
|
12
|
+
];
|
|
13
|
+
}
|
|
14
|
+
function formatTable(headers, rows) {
|
|
15
|
+
const widths = headers.map((header, index) => Math.max(header.length, ...rows.map((row) => row[index]?.length ?? 0)));
|
|
16
|
+
const formatRow = (row) => row.map((cell, index) => cell.padEnd(widths[index] ?? cell.length)).join(' | ');
|
|
17
|
+
return [
|
|
18
|
+
formatRow(headers),
|
|
19
|
+
widths.map((width) => '-'.repeat(width)).join('-|-'),
|
|
20
|
+
...rows.map((row) => formatRow(row)),
|
|
21
|
+
];
|
|
22
|
+
}
|
|
23
|
+
function formatGateBlock(gate) {
|
|
24
|
+
const lines = ['Gate:'];
|
|
25
|
+
if (gate.warnOnly) {
|
|
26
|
+
lines.push('verdict=warn warn_only=true threshold=none');
|
|
27
|
+
lines.push('No default calibrated threshold yet; showing the worst observed row only.');
|
|
28
|
+
if (gate.maxRow) {
|
|
29
|
+
lines.push(`Worst row: ${gate.maxRow.queryType} | ${gate.maxRow.commandSlug} | est_total=${gate.maxRow.estimatedTotalTokens}`);
|
|
30
|
+
}
|
|
31
|
+
return lines;
|
|
32
|
+
}
|
|
33
|
+
lines.push(`verdict=${gate.verdict} warn_only=false threshold=${gate.threshold ?? 'none'} violation_count=${gate.violationCount}`);
|
|
34
|
+
if (gate.maxRow) {
|
|
35
|
+
lines.push(`Worst row: ${gate.maxRow.queryType} | ${gate.maxRow.commandSlug} | est_total=${gate.maxRow.estimatedTotalTokens}`);
|
|
36
|
+
}
|
|
37
|
+
if (gate.violations.length > 0) {
|
|
38
|
+
lines.push('Violations:');
|
|
39
|
+
for (const violation of gate.violations.slice(0, 3)) {
|
|
40
|
+
lines.push(`- ${violation.queryType} | ${violation.commandSlug} | est_total=${violation.estimatedTotalTokens}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return lines;
|
|
44
|
+
}
|
|
45
|
+
export function formatAgentMetricsTokenRunHuman(result) {
|
|
46
|
+
const lines = [
|
|
47
|
+
'Agent Metrics Token Run',
|
|
48
|
+
`Run ID: ${result.runId}`,
|
|
49
|
+
`Recorded: ${result.recordedAt}`,
|
|
50
|
+
`Sample set: ${result.sampleSetVersion}`,
|
|
51
|
+
`Estimator: ${result.estimatorVersion} (estimated values, not tokenizer-exact)`,
|
|
52
|
+
'',
|
|
53
|
+
'Per-query results:',
|
|
54
|
+
];
|
|
55
|
+
for (const item of result.items) {
|
|
56
|
+
lines.push(`- ${item.queryType} | ${item.commandSlug}`, ` bytes=${item.responseSizeBytes} chars=${item.rawCharCount} est_in=${item.estimatedInputTokens} est_out=${item.estimatedOutputTokens} est_total=${item.estimatedTotalTokens} time=${item.executionTimeMs}ms`);
|
|
57
|
+
}
|
|
58
|
+
lines.push('', 'Totals:');
|
|
59
|
+
lines.push(...formatTotals(result.totals));
|
|
60
|
+
return lines.join('\n');
|
|
61
|
+
}
|
|
62
|
+
export function formatAgentMetricsReportHuman(result) {
|
|
63
|
+
const lines = [
|
|
64
|
+
'Agent Metrics Report',
|
|
65
|
+
`Run ID: ${result.runId}`,
|
|
66
|
+
`Recorded: ${result.recordedAt}`,
|
|
67
|
+
`Generated: ${result.generatedAt}`,
|
|
68
|
+
`Sample set: ${result.sampleSetVersion}`,
|
|
69
|
+
`Estimator: ${result.estimatorVersion} (estimated values, not tokenizer-exact)`,
|
|
70
|
+
'',
|
|
71
|
+
'Summary:',
|
|
72
|
+
];
|
|
73
|
+
lines.push(...formatGateBlock(result.gate));
|
|
74
|
+
lines.push(...formatTotals(result.totals));
|
|
75
|
+
lines.push('', 'By query type:');
|
|
76
|
+
lines.push(...formatTable(['Query type', 'Count', 'Hist', 'Avg tok', 'P50 tok', 'P95 tok', 'Max tok', 'Avg bytes', 'Min bytes', 'Max bytes'], result.queryTypeSummaries.map((summary) => [
|
|
77
|
+
summary.queryType,
|
|
78
|
+
String(summary.queryCount),
|
|
79
|
+
String(summary.historicalSampleCount),
|
|
80
|
+
String(summary.avgEstimatedTotalTokens),
|
|
81
|
+
String(summary.p50EstimatedTotalTokens),
|
|
82
|
+
String(summary.p95EstimatedTotalTokens),
|
|
83
|
+
String(summary.maxEstimatedTotalTokens),
|
|
84
|
+
String(summary.avgResponseSizeBytes),
|
|
85
|
+
String(summary.minResponseSizeBytes),
|
|
86
|
+
String(summary.maxResponseSizeBytes),
|
|
87
|
+
])));
|
|
88
|
+
lines.push('', 'Per-query rows:');
|
|
89
|
+
lines.push(...formatTable(['Query type', 'Command', 'Bytes', 'Chars', 'Est in', 'Est out', 'Est total', 'Time'], result.rows.map((row) => [
|
|
90
|
+
row.queryType,
|
|
91
|
+
row.commandSlug,
|
|
92
|
+
String(row.responseSizeBytes),
|
|
93
|
+
String(row.rawCharCount),
|
|
94
|
+
String(row.estimatedInputTokens),
|
|
95
|
+
String(row.estimatedOutputTokens),
|
|
96
|
+
String(row.estimatedTotalTokens),
|
|
97
|
+
`${row.executionTimeMs}ms`,
|
|
98
|
+
])));
|
|
99
|
+
lines.push('', 'Trend vs previous run:');
|
|
100
|
+
if (result.queryTypeTrends.length === 0) {
|
|
101
|
+
lines.push('- none');
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
for (const trend of result.queryTypeTrends.slice(0, 3)) {
|
|
105
|
+
const previous = trend.previousEstimatedTotalTokens ?? 'none';
|
|
106
|
+
const delta = trend.deltaEstimatedTotalTokens ?? 'none';
|
|
107
|
+
const deltaPercent = trend.deltaPercent === null ? 'none' : `${trend.deltaPercent}%`;
|
|
108
|
+
lines.push(`- ${trend.queryType} | latest=${trend.latestEstimatedTotalTokens} previous=${previous} delta=${delta} delta_percent=${deltaPercent}`);
|
|
109
|
+
if (!trend.baselineAvailable) {
|
|
110
|
+
lines.push(' Baseline unavailable for comparison.');
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
lines.push('', 'Highest cost query types:');
|
|
115
|
+
if (result.highestCostQueryTypes.length === 0) {
|
|
116
|
+
lines.push('- none');
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
for (const item of result.highestCostQueryTypes.slice(0, 3)) {
|
|
120
|
+
lines.push(`- ${item.queryType} | est_total=${item.estimatedTotalTokens} | ${item.riskNote}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
lines.push('', 'Highest cost samples:');
|
|
124
|
+
if (result.highestCostRows.length === 0) {
|
|
125
|
+
lines.push('- none');
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
for (const item of result.highestCostRows.slice(0, 3)) {
|
|
129
|
+
lines.push(`- ${item.queryType} | ${item.commandSlug} | est_total=${item.estimatedTotalTokens} | ${item.riskNote}`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return lines.join('\n');
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=human.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"human.js","sourceRoot":"","sources":["../../../../src/cli/commands/agent-metrics/human.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,yGAAyG;AAQzG,SAAS,YAAY,CAAC,MAA4C;IAChE,OAAO;QACL,YAAY,MAAM,CAAC,UAAU,EAAE;QAC/B,mBAAmB,MAAM,CAAC,iBAAiB,EAAE;QAC7C,cAAc,MAAM,CAAC,YAAY,EAAE;QACnC,2BAA2B,MAAM,CAAC,oBAAoB,EAAE;QACxD,4BAA4B,MAAM,CAAC,qBAAqB,EAAE;QAC1D,2BAA2B,MAAM,CAAC,oBAAoB,EAAE;QACxD,mBAAmB,MAAM,CAAC,eAAe,IAAI;KAC9C,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,OAAiB,EAAE,IAAgB;IACtD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAC3C,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC,CAAC,CAAC,CACvE,CAAC;IAEF,MAAM,SAAS,GAAG,CAAC,GAAa,EAAU,EAAE,CAC1C,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC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entMetricsTokenRunResult } from '../../../orchestrator/agent-metrics-service.js';
|
|
3
|
+
export interface AgentMetricsCommandOptions {
|
|
4
|
+
json?: boolean;
|
|
5
|
+
human?: boolean;
|
|
6
|
+
maxTokensPerQuery?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface AgentMetricsServiceLike {
|
|
9
|
+
executeTokenRun(rootDir: string): Promise<AgentMetricsTokenRunResult>;
|
|
10
|
+
runReportFlow(rootDir: string): Promise<AgentMetricsReportResult>;
|
|
11
|
+
requireLatestReport(rootDir: string): Promise<AgentMetricsReportResult>;
|
|
12
|
+
}
|
|
13
|
+
export declare function createAgentMetricsCommand(service?: AgentMetricsServiceLike): Command;
|
|
14
|
+
export declare const agentMetricsCommand: Command;
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/agent-metrics/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASpC,OAAO,EAEL,KAAK,wBAAwB,EAC7B,KAAK,0BAA0B,EAChC,MAAM,gDAAgD,CAAC;AAMxD,MAAM,WAAW,0BAA0B;IACzC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,uBAAuB;IACtC,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;IACtE,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;IAClE,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;CACzE;AA0HD,wBAAgB,yBAAyB,CACvC,OAAO,GAAE,uBAAmD,GAC3D,OAAO,CAkCT;AAED,eAAO,MAAM,mBAAmB,SAA8B,CAAC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
// [META] since:2026-05-10 | owner:cli-team | stable:false
|
|
2
|
+
// [WHY] Thin CLI wrapper for agent-metrics so measurement/report logic stays in the dedicated service
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
import { cwd } from 'node:process';
|
|
5
|
+
import { createProgressEmitter, formatError, renderOutput, resolveOutputMode, } from '../../output/index.js';
|
|
6
|
+
import { AgentMetricsService, } from '../../../orchestrator/agent-metrics-service.js';
|
|
7
|
+
import { formatAgentMetricsReportHuman, formatAgentMetricsTokenRunHuman, } from './human.js';
|
|
8
|
+
function applyOutputOptions(command) {
|
|
9
|
+
return command
|
|
10
|
+
.option('-j, --json', 'JSON 格式输出')
|
|
11
|
+
.option('--human', '强制人类可读输出');
|
|
12
|
+
}
|
|
13
|
+
function applyThresholdOption(command) {
|
|
14
|
+
return command.option('--max-tokens-per-query <number>', '报告路径允许的单次查询最大估算 token 数');
|
|
15
|
+
}
|
|
16
|
+
function toMode(options) {
|
|
17
|
+
return resolveOutputMode({ json: options.json, human: options.human });
|
|
18
|
+
}
|
|
19
|
+
function toCommandOptions(command) {
|
|
20
|
+
return command.opts();
|
|
21
|
+
}
|
|
22
|
+
function toCommandOptionsWithGlobals(command) {
|
|
23
|
+
return command.optsWithGlobals();
|
|
24
|
+
}
|
|
25
|
+
function resolveMaxTokensPerQuery(options) {
|
|
26
|
+
if (options.maxTokensPerQuery === undefined) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
const parsed = Number(options.maxTokensPerQuery);
|
|
30
|
+
if (!Number.isFinite(parsed) || parsed < 0) {
|
|
31
|
+
const error = new Error(`Invalid --max-tokens-per-query value: ${options.maxTokensPerQuery}`);
|
|
32
|
+
error.code = 'AGENT_METRICS_INVALID_THRESHOLD';
|
|
33
|
+
error.remediation = 'Provide a finite non-negative number for --max-tokens-per-query.';
|
|
34
|
+
error.nextCommand = 'codemap agent-metrics report --max-tokens-per-query 160';
|
|
35
|
+
error.confidence = 0.95;
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
return parsed;
|
|
39
|
+
}
|
|
40
|
+
function renderReportResult(result, mode, maxTokensPerQuery) {
|
|
41
|
+
const gatedResult = AgentMetricsService.withGate(result, maxTokensPerQuery);
|
|
42
|
+
renderOutput(gatedResult, formatAgentMetricsReportHuman, mode);
|
|
43
|
+
if (maxTokensPerQuery !== undefined && gatedResult.gate.verdict === 'fail') {
|
|
44
|
+
process.exitCode = 1;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async function handleTokenCommand(service, options) {
|
|
48
|
+
const mode = toMode(options);
|
|
49
|
+
const progress = createProgressEmitter(mode, 'Measuring token costs...');
|
|
50
|
+
try {
|
|
51
|
+
progress.update(30, 'Running built-in agent-metrics samples...');
|
|
52
|
+
const result = await service.executeTokenRun(cwd());
|
|
53
|
+
progress.complete();
|
|
54
|
+
renderOutput(result, formatAgentMetricsTokenRunHuman, mode);
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
progress.fail();
|
|
58
|
+
process.stdout.write(formatError(error, mode, 'codemap agent-metrics token') + '\n');
|
|
59
|
+
process.exitCode = 1;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
async function handleReportCommand(service, options) {
|
|
63
|
+
const mode = toMode(options);
|
|
64
|
+
const progress = createProgressEmitter(mode, 'Building agent-metrics report...');
|
|
65
|
+
try {
|
|
66
|
+
const maxTokensPerQuery = resolveMaxTokensPerQuery(options);
|
|
67
|
+
progress.update(30, 'Loading latest persisted run...');
|
|
68
|
+
const result = await service.requireLatestReport(cwd());
|
|
69
|
+
progress.complete();
|
|
70
|
+
renderReportResult(result, mode, maxTokensPerQuery);
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
progress.fail();
|
|
74
|
+
process.stdout.write(formatError(error, mode, 'codemap agent-metrics report') + '\n');
|
|
75
|
+
process.exitCode = 1;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async function handleRootCommand(service, options) {
|
|
79
|
+
const mode = toMode(options);
|
|
80
|
+
const progress = createProgressEmitter(mode, 'Building agent-metrics report...');
|
|
81
|
+
try {
|
|
82
|
+
const maxTokensPerQuery = resolveMaxTokensPerQuery(options);
|
|
83
|
+
progress.update(30, 'Loading latest run or executing the fixed sample set...');
|
|
84
|
+
const result = await service.runReportFlow(cwd());
|
|
85
|
+
progress.complete();
|
|
86
|
+
renderReportResult(result, mode, maxTokensPerQuery);
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
progress.fail();
|
|
90
|
+
process.stdout.write(formatError(error, mode, 'codemap agent-metrics') + '\n');
|
|
91
|
+
process.exitCode = 1;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
export function createAgentMetricsCommand(service = new AgentMetricsService()) {
|
|
95
|
+
const command = applyThresholdOption(applyOutputOptions(new Command('agent-metrics')
|
|
96
|
+
.description('分析 CodeMap 查询响应的估算 LLM token 成本')));
|
|
97
|
+
const tokenCommand = applyOutputOptions(command.command('token')
|
|
98
|
+
.description('执行固定 built-in 查询样本并持久化 token-cost 明细'));
|
|
99
|
+
tokenCommand.action(async (...args) => {
|
|
100
|
+
const actionCommand = args.at(-1);
|
|
101
|
+
await handleTokenCommand(service, toCommandOptions(actionCommand));
|
|
102
|
+
});
|
|
103
|
+
const reportCommand = applyThresholdOption(applyOutputOptions(command.command('report')
|
|
104
|
+
.description('输出最新一次 token-cost run 的最小报告;若不存在则提示先运行测量')));
|
|
105
|
+
reportCommand.action(async (...args) => {
|
|
106
|
+
const actionCommand = args.at(-1);
|
|
107
|
+
await handleReportCommand(service, toCommandOptionsWithGlobals(actionCommand));
|
|
108
|
+
});
|
|
109
|
+
command.action(async (...args) => {
|
|
110
|
+
const actionCommand = args.at(-1);
|
|
111
|
+
await handleRootCommand(service, toCommandOptionsWithGlobals(actionCommand));
|
|
112
|
+
});
|
|
113
|
+
return command;
|
|
114
|
+
}
|
|
115
|
+
export const agentMetricsCommand = createAgentMetricsCommand();
|
|
116
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/cli/commands/agent-metrics/index.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,sGAAsG;AAEtG,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EACL,qBAAqB,EACrB,WAAW,EACX,YAAY,EACZ,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,mBAAmB,GAGpB,MAAM,gDAAgD,CAAC;AACxD,OAAO,EACL,6BAA6B,EAC7B,+BAA+B,GAChC,MAAM,YAAY,CAAC;AAcpB,SAAS,kBAAkB,CAAC,OAAgB;IAC1C,OAAO,OAAO;SACX,MAAM,CAAC,YAAY,EAAE,WAAW,CAAC;SACjC,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,oBAAoB,CAAC,OAAgB;IAC5C,OAAO,OAAO,CAAC,MAAM,CACnB,iCAAiC,EACjC,yBAAyB,CAC1B,CAAC;AACJ,CAAC;AAED,SAAS,MAAM,CAAC,OAAmC;IACjD,OAAO,iBAAiB,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;AACzE,CAAC;AAED,SAAS,gBAAgB,CAAC,OAAgB;IACxC,OAAO,OAAO,CAAC,IAAI,EAAgC,CAAC;AACtD,CAAC;AAED,SAAS,2BAA2B,CAAC,OAAgB;IACnD,OAAO,OAAO,CAAC,eAAe,EAAgC,CAAC;AACjE,CAAC;AAED,SAAS,wBAAwB,CAAC,OAAmC;IACnE,IAAI,OAAO,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC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