@mycodemap/mycodemap 0.1.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 +17 -0
- package/LICENSE +21 -0
- package/README.md +559 -0
- package/dist/ai/claude.d.ts +38 -0
- package/dist/ai/claude.d.ts.map +1 -0
- package/dist/ai/claude.js +169 -0
- package/dist/ai/claude.js.map +1 -0
- package/dist/ai/codex.d.ts +38 -0
- package/dist/ai/codex.d.ts.map +1 -0
- package/dist/ai/codex.js +169 -0
- package/dist/ai/codex.js.map +1 -0
- package/dist/ai/factory.d.ts +48 -0
- package/dist/ai/factory.d.ts.map +1 -0
- package/dist/ai/factory.js +95 -0
- package/dist/ai/factory.js.map +1 -0
- package/dist/ai/index.d.ts +12 -0
- package/dist/ai/index.d.ts.map +1 -0
- package/dist/ai/index.js +29 -0
- package/dist/ai/index.js.map +1 -0
- package/dist/ai/provider.d.ts +70 -0
- package/dist/ai/provider.d.ts.map +1 -0
- package/dist/ai/provider.js +31 -0
- package/dist/ai/provider.js.map +1 -0
- package/dist/ai/subagent-caller.d.ts +90 -0
- package/dist/ai/subagent-caller.d.ts.map +1 -0
- package/dist/ai/subagent-caller.js +280 -0
- package/dist/ai/subagent-caller.js.map +1 -0
- package/dist/ai/types.d.ts +70 -0
- package/dist/ai/types.d.ts.map +1 -0
- package/dist/ai/types.js +5 -0
- package/dist/ai/types.js.map +1 -0
- package/dist/cache/file-hash-cache.d.ts +76 -0
- package/dist/cache/file-hash-cache.d.ts.map +1 -0
- package/dist/cache/file-hash-cache.js +159 -0
- package/dist/cache/file-hash-cache.js.map +1 -0
- package/dist/cache/index.d.ts +151 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/index.js +303 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/cache/lru-cache.d.ts +93 -0
- package/dist/cache/lru-cache.d.ts.map +1 -0
- package/dist/cache/lru-cache.js +194 -0
- package/dist/cache/lru-cache.js.map +1 -0
- package/dist/cache/parse-cache.d.ts +68 -0
- package/dist/cache/parse-cache.d.ts.map +1 -0
- package/dist/cache/parse-cache.js +173 -0
- package/dist/cache/parse-cache.js.map +1 -0
- package/dist/cli/commands/analyze.d.ts +96 -0
- package/dist/cli/commands/analyze.d.ts.map +1 -0
- package/dist/cli/commands/analyze.js +567 -0
- package/dist/cli/commands/analyze.js.map +1 -0
- package/dist/cli/commands/ci.d.ts +25 -0
- package/dist/cli/commands/ci.d.ts.map +1 -0
- package/dist/cli/commands/ci.js +481 -0
- package/dist/cli/commands/ci.js.map +1 -0
- package/dist/cli/commands/complexity.d.ts +70 -0
- package/dist/cli/commands/complexity.d.ts.map +1 -0
- package/dist/cli/commands/complexity.js +479 -0
- package/dist/cli/commands/complexity.js.map +1 -0
- package/dist/cli/commands/cycles.d.ts +10 -0
- package/dist/cli/commands/cycles.d.ts.map +1 -0
- package/dist/cli/commands/cycles.js +202 -0
- package/dist/cli/commands/cycles.js.map +1 -0
- package/dist/cli/commands/deps.d.ts +61 -0
- package/dist/cli/commands/deps.d.ts.map +1 -0
- package/dist/cli/commands/deps.js +340 -0
- package/dist/cli/commands/deps.js.map +1 -0
- package/dist/cli/commands/generate.d.ts +8 -0
- package/dist/cli/commands/generate.d.ts.map +1 -0
- package/dist/cli/commands/generate.js +61 -0
- package/dist/cli/commands/generate.js.map +1 -0
- package/dist/cli/commands/impact.d.ts +55 -0
- package/dist/cli/commands/impact.d.ts.map +1 -0
- package/dist/cli/commands/impact.js +455 -0
- package/dist/cli/commands/impact.js.map +1 -0
- package/dist/cli/commands/init.d.ts +4 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +50 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/query.d.ts +22 -0
- package/dist/cli/commands/query.d.ts.map +1 -0
- package/dist/cli/commands/query.js +718 -0
- package/dist/cli/commands/query.js.map +1 -0
- package/dist/cli/commands/watch-foreground.d.ts +9 -0
- package/dist/cli/commands/watch-foreground.d.ts.map +1 -0
- package/dist/cli/commands/watch-foreground.js +67 -0
- package/dist/cli/commands/watch-foreground.js.map +1 -0
- package/dist/cli/commands/watch.d.ts +12 -0
- package/dist/cli/commands/watch.d.ts.map +1 -0
- package/dist/cli/commands/watch.js +114 -0
- package/dist/cli/commands/watch.js.map +1 -0
- package/dist/cli/commands/workflow.d.ts +25 -0
- package/dist/cli/commands/workflow.d.ts.map +1 -0
- package/dist/cli/commands/workflow.js +488 -0
- package/dist/cli/commands/workflow.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +115 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/paths.d.ts +90 -0
- package/dist/cli/paths.d.ts.map +1 -0
- package/dist/cli/paths.js +136 -0
- package/dist/cli/paths.js.map +1 -0
- package/dist/cli/runtime-logger.d.ts +13 -0
- package/dist/cli/runtime-logger.d.ts.map +1 -0
- package/dist/cli/runtime-logger.js +213 -0
- package/dist/cli/runtime-logger.js.map +1 -0
- package/dist/core/analyzer.d.ts +3 -0
- package/dist/core/analyzer.d.ts.map +1 -0
- package/dist/core/analyzer.js +359 -0
- package/dist/core/analyzer.js.map +1 -0
- package/dist/core/ast-complexity-analyzer.d.ts +40 -0
- package/dist/core/ast-complexity-analyzer.d.ts.map +1 -0
- package/dist/core/ast-complexity-analyzer.js +279 -0
- package/dist/core/ast-complexity-analyzer.js.map +1 -0
- package/dist/core/global-index.d.ts +69 -0
- package/dist/core/global-index.d.ts.map +1 -0
- package/dist/core/global-index.js +388 -0
- package/dist/core/global-index.js.map +1 -0
- package/dist/generator/ai-overview.d.ts +51 -0
- package/dist/generator/ai-overview.d.ts.map +1 -0
- package/dist/generator/ai-overview.js +160 -0
- package/dist/generator/ai-overview.js.map +1 -0
- package/dist/generator/context.d.ts +5 -0
- package/dist/generator/context.d.ts.map +1 -0
- package/dist/generator/context.js +514 -0
- package/dist/generator/context.js.map +1 -0
- package/dist/generator/file-describer.d.ts +93 -0
- package/dist/generator/file-describer.d.ts.map +1 -0
- package/dist/generator/file-describer.js +375 -0
- package/dist/generator/file-describer.js.map +1 -0
- package/dist/generator/index.d.ts +8 -0
- package/dist/generator/index.d.ts.map +1 -0
- package/dist/generator/index.js +259 -0
- package/dist/generator/index.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/orchestrator/adapters/ast-grep-adapter.d.ts +75 -0
- package/dist/orchestrator/adapters/ast-grep-adapter.d.ts.map +1 -0
- package/dist/orchestrator/adapters/ast-grep-adapter.js +242 -0
- package/dist/orchestrator/adapters/ast-grep-adapter.js.map +1 -0
- package/dist/orchestrator/adapters/base-adapter.d.ts +24 -0
- package/dist/orchestrator/adapters/base-adapter.d.ts.map +1 -0
- package/dist/orchestrator/adapters/base-adapter.js +2 -0
- package/dist/orchestrator/adapters/base-adapter.js.map +1 -0
- package/dist/orchestrator/adapters/codemap-adapter.d.ts +56 -0
- package/dist/orchestrator/adapters/codemap-adapter.d.ts.map +1 -0
- package/dist/orchestrator/adapters/codemap-adapter.js +163 -0
- package/dist/orchestrator/adapters/codemap-adapter.js.map +1 -0
- package/dist/orchestrator/adapters/index.d.ts +10 -0
- package/dist/orchestrator/adapters/index.d.ts.map +1 -0
- package/dist/orchestrator/adapters/index.js +3 -0
- package/dist/orchestrator/adapters/index.js.map +1 -0
- package/dist/orchestrator/ai-feed-generator.d.ts +210 -0
- package/dist/orchestrator/ai-feed-generator.d.ts.map +1 -0
- package/dist/orchestrator/ai-feed-generator.js +377 -0
- package/dist/orchestrator/ai-feed-generator.js.map +1 -0
- package/dist/orchestrator/commit-validator.d.ts +30 -0
- package/dist/orchestrator/commit-validator.d.ts.map +1 -0
- package/dist/orchestrator/commit-validator.js +87 -0
- package/dist/orchestrator/commit-validator.js.map +1 -0
- package/dist/orchestrator/confidence.d.ts +25 -0
- package/dist/orchestrator/confidence.d.ts.map +1 -0
- package/dist/orchestrator/confidence.js +138 -0
- package/dist/orchestrator/confidence.js.map +1 -0
- package/dist/orchestrator/file-header-scanner.d.ts +48 -0
- package/dist/orchestrator/file-header-scanner.d.ts.map +1 -0
- package/dist/orchestrator/file-header-scanner.js +158 -0
- package/dist/orchestrator/file-header-scanner.js.map +1 -0
- package/dist/orchestrator/git-analyzer.d.ts +192 -0
- package/dist/orchestrator/git-analyzer.d.ts.map +1 -0
- package/dist/orchestrator/git-analyzer.js +539 -0
- package/dist/orchestrator/git-analyzer.js.map +1 -0
- package/dist/orchestrator/index.d.ts +20 -0
- package/dist/orchestrator/index.d.ts.map +1 -0
- package/dist/orchestrator/index.js +16 -0
- package/dist/orchestrator/index.js.map +1 -0
- package/dist/orchestrator/intent-router.d.ts +41 -0
- package/dist/orchestrator/intent-router.d.ts.map +1 -0
- package/dist/orchestrator/intent-router.js +98 -0
- package/dist/orchestrator/intent-router.js.map +1 -0
- package/dist/orchestrator/result-fusion.d.ts +114 -0
- package/dist/orchestrator/result-fusion.d.ts.map +1 -0
- package/dist/orchestrator/result-fusion.js +332 -0
- package/dist/orchestrator/result-fusion.js.map +1 -0
- package/dist/orchestrator/test-linker.d.ts +166 -0
- package/dist/orchestrator/test-linker.d.ts.map +1 -0
- package/dist/orchestrator/test-linker.js +570 -0
- package/dist/orchestrator/test-linker.js.map +1 -0
- package/dist/orchestrator/tool-orchestrator.d.ts +108 -0
- package/dist/orchestrator/tool-orchestrator.d.ts.map +1 -0
- package/dist/orchestrator/tool-orchestrator.js +247 -0
- package/dist/orchestrator/tool-orchestrator.js.map +1 -0
- package/dist/orchestrator/types.d.ts +162 -0
- package/dist/orchestrator/types.d.ts.map +1 -0
- package/dist/orchestrator/types.js +39 -0
- package/dist/orchestrator/types.js.map +1 -0
- package/dist/orchestrator/workflow/ci-executor.d.ts +157 -0
- package/dist/orchestrator/workflow/ci-executor.d.ts.map +1 -0
- package/dist/orchestrator/workflow/ci-executor.js +423 -0
- package/dist/orchestrator/workflow/ci-executor.js.map +1 -0
- package/dist/orchestrator/workflow/config.d.ts +97 -0
- package/dist/orchestrator/workflow/config.d.ts.map +1 -0
- package/dist/orchestrator/workflow/config.js +115 -0
- package/dist/orchestrator/workflow/config.js.map +1 -0
- package/dist/orchestrator/workflow/git-analyzer.d.ts +173 -0
- package/dist/orchestrator/workflow/git-analyzer.d.ts.map +1 -0
- package/dist/orchestrator/workflow/git-analyzer.js +473 -0
- package/dist/orchestrator/workflow/git-analyzer.js.map +1 -0
- package/dist/orchestrator/workflow/index.d.ts +21 -0
- package/dist/orchestrator/workflow/index.d.ts.map +1 -0
- package/dist/orchestrator/workflow/index.js +21 -0
- package/dist/orchestrator/workflow/index.js.map +1 -0
- package/dist/orchestrator/workflow/phase-checkpoint.d.ts +38 -0
- package/dist/orchestrator/workflow/phase-checkpoint.d.ts.map +1 -0
- package/dist/orchestrator/workflow/phase-checkpoint.js +75 -0
- package/dist/orchestrator/workflow/phase-checkpoint.js.map +1 -0
- package/dist/orchestrator/workflow/phase-inheritance.d.ts +128 -0
- package/dist/orchestrator/workflow/phase-inheritance.d.ts.map +1 -0
- package/dist/orchestrator/workflow/phase-inheritance.js +266 -0
- package/dist/orchestrator/workflow/phase-inheritance.js.map +1 -0
- package/dist/orchestrator/workflow/result-fusion.d.ts +117 -0
- package/dist/orchestrator/workflow/result-fusion.d.ts.map +1 -0
- package/dist/orchestrator/workflow/result-fusion.js +246 -0
- package/dist/orchestrator/workflow/result-fusion.js.map +1 -0
- package/dist/orchestrator/workflow/templates.d.ts +116 -0
- package/dist/orchestrator/workflow/templates.d.ts.map +1 -0
- package/dist/orchestrator/workflow/templates.js +546 -0
- package/dist/orchestrator/workflow/templates.js.map +1 -0
- package/dist/orchestrator/workflow/test-linker.d.ts +152 -0
- package/dist/orchestrator/workflow/test-linker.d.ts.map +1 -0
- package/dist/orchestrator/workflow/test-linker.js +342 -0
- package/dist/orchestrator/workflow/test-linker.js.map +1 -0
- package/dist/orchestrator/workflow/types.d.ts +202 -0
- package/dist/orchestrator/workflow/types.d.ts.map +1 -0
- package/dist/orchestrator/workflow/types.js +4 -0
- package/dist/orchestrator/workflow/types.js.map +1 -0
- package/dist/orchestrator/workflow/visualizer.d.ts +56 -0
- package/dist/orchestrator/workflow/visualizer.d.ts.map +1 -0
- package/dist/orchestrator/workflow/visualizer.js +300 -0
- package/dist/orchestrator/workflow/visualizer.js.map +1 -0
- package/dist/orchestrator/workflow/workflow-context.d.ts +50 -0
- package/dist/orchestrator/workflow/workflow-context.d.ts.map +1 -0
- package/dist/orchestrator/workflow/workflow-context.js +105 -0
- package/dist/orchestrator/workflow/workflow-context.js.map +1 -0
- package/dist/orchestrator/workflow/workflow-orchestrator.d.ts +126 -0
- package/dist/orchestrator/workflow/workflow-orchestrator.d.ts.map +1 -0
- package/dist/orchestrator/workflow/workflow-orchestrator.js +489 -0
- package/dist/orchestrator/workflow/workflow-orchestrator.js.map +1 -0
- package/dist/orchestrator/workflow/workflow-persistence.d.ts +38 -0
- package/dist/orchestrator/workflow/workflow-persistence.d.ts.map +1 -0
- package/dist/orchestrator/workflow/workflow-persistence.js +166 -0
- package/dist/orchestrator/workflow/workflow-persistence.js.map +1 -0
- package/dist/parser/implementations/fast-parser.d.ts +65 -0
- package/dist/parser/implementations/fast-parser.d.ts.map +1 -0
- package/dist/parser/implementations/fast-parser.js +299 -0
- package/dist/parser/implementations/fast-parser.js.map +1 -0
- package/dist/parser/implementations/smart-parser.d.ts +220 -0
- package/dist/parser/implementations/smart-parser.d.ts.map +1 -0
- package/dist/parser/implementations/smart-parser.js +1536 -0
- package/dist/parser/implementations/smart-parser.js.map +1 -0
- package/dist/parser/implementations/tree-sitter-parser.d.ts +57 -0
- package/dist/parser/implementations/tree-sitter-parser.d.ts.map +1 -0
- package/dist/parser/implementations/tree-sitter-parser.js +375 -0
- package/dist/parser/implementations/tree-sitter-parser.js.map +1 -0
- package/dist/parser/index.d.ts +19 -0
- package/dist/parser/index.d.ts.map +1 -0
- package/dist/parser/index.js +449 -0
- package/dist/parser/index.js.map +1 -0
- package/dist/parser/interfaces/IParser.d.ts +218 -0
- package/dist/parser/interfaces/IParser.d.ts.map +1 -0
- package/dist/parser/interfaces/IParser.js +22 -0
- package/dist/parser/interfaces/IParser.js.map +1 -0
- package/dist/plugins/built-in/call-graph.d.ts +38 -0
- package/dist/plugins/built-in/call-graph.d.ts.map +1 -0
- package/dist/plugins/built-in/call-graph.js +135 -0
- package/dist/plugins/built-in/call-graph.js.map +1 -0
- package/dist/plugins/built-in/complexity-analyzer.d.ts +45 -0
- package/dist/plugins/built-in/complexity-analyzer.d.ts.map +1 -0
- package/dist/plugins/built-in/complexity-analyzer.js +155 -0
- package/dist/plugins/built-in/complexity-analyzer.js.map +1 -0
- package/dist/plugins/index.d.ts +34 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +103 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/plugin-loader.d.ts +22 -0
- package/dist/plugins/plugin-loader.d.ts.map +1 -0
- package/dist/plugins/plugin-loader.js +200 -0
- package/dist/plugins/plugin-loader.js.map +1 -0
- package/dist/plugins/plugin-registry.d.ts +20 -0
- package/dist/plugins/plugin-registry.d.ts.map +1 -0
- package/dist/plugins/plugin-registry.js +143 -0
- package/dist/plugins/plugin-registry.js.map +1 -0
- package/dist/plugins/types.d.ts +72 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/plugins/types.js +5 -0
- package/dist/plugins/types.js.map +1 -0
- package/dist/types/index.d.ts +373 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +7 -0
- package/dist/types/index.js.map +1 -0
- package/dist/watcher/daemon.d.ts +64 -0
- package/dist/watcher/daemon.d.ts.map +1 -0
- package/dist/watcher/daemon.js +189 -0
- package/dist/watcher/daemon.js.map +1 -0
- package/dist/watcher/file-watcher.d.ts +70 -0
- package/dist/watcher/file-watcher.d.ts.map +1 -0
- package/dist/watcher/file-watcher.js +127 -0
- package/dist/watcher/file-watcher.js.map +1 -0
- package/dist/watcher/index.d.ts +5 -0
- package/dist/watcher/index.d.ts.map +1 -0
- package/dist/watcher/index.js +6 -0
- package/dist/watcher/index.js.map +1 -0
- package/dist/watcher/watch-worker.d.ts +2 -0
- package/dist/watcher/watch-worker.d.ts.map +1 -0
- package/dist/watcher/watch-worker.js +57 -0
- package/dist/watcher/watch-worker.js.map +1 -0
- package/dist/worker/index.d.ts +76 -0
- package/dist/worker/index.d.ts.map +1 -0
- package/dist/worker/index.js +155 -0
- package/dist/worker/index.js.map +1 -0
- package/dist/worker/parse-worker.d.ts +2 -0
- package/dist/worker/parse-worker.d.ts.map +1 -0
- package/dist/worker/parse-worker.js +202 -0
- package/dist/worker/parse-worker.js.map +1 -0
- package/mycodemap.config.schema.json +42 -0
- package/package.json +69 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## [0.1.0] - 2024-03-04
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- Initial release of MyCodeMap
|
|
9
|
+
- Dual parsing mode: fast (regex) and smart (TypeScript AST)
|
|
10
|
+
- Multi-format output: AI_MAP.md, CONTEXT.md, codemap.json
|
|
11
|
+
- Dependency graph visualization (Mermaid format)
|
|
12
|
+
- Incremental caching with file hash-based LRU
|
|
13
|
+
- Watch mode for file change detection
|
|
14
|
+
- Complexity analysis (cyclomatic, cognitive complexity, maintainability)
|
|
15
|
+
- Orchestration layer: intent routing, confidence scoring, result fusion
|
|
16
|
+
- CI gateway: commit format validation, file header checks, risk assessment
|
|
17
|
+
- Workflow orchestration: stage management, context persistence, checkpoint mechanism
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 MyCodeMap
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,559 @@
|
|
|
1
|
+
# CodeMap
|
|
2
|
+
|
|
3
|
+
> TypeScript 代码地图工具 - 为 AI 辅助开发提供结构化上下文
|
|
4
|
+
|
|
5
|
+
CodeMap 是一个专为 TypeScript/JavaScript 项目设计的代码分析工具。它通过静态分析自动生成项目的结构化代码地图,帮助 AI 编程助手(如 Claude、Copilot)快速理解项目架构、模块关系和代码上下文。
|
|
6
|
+
|
|
7
|
+
## 特性
|
|
8
|
+
|
|
9
|
+
- **双层解析模式** - 提供 `fast`(快速正则)和 `smart`(TypeScript AST)两种解析模式,按需平衡速度与精度
|
|
10
|
+
- **多格式输出** - 自动生成 `AI_MAP.md`(全局概览)、`CONTEXT.md` + `context/`(模块上下文)、`codemap.json`(结构化数据)
|
|
11
|
+
- **依赖图可视化** - 生成 Mermaid 格式的模块依赖关系图
|
|
12
|
+
- **增量缓存** - 基于文件哈希的 LRU 缓存机制,仅重新分析变更文件
|
|
13
|
+
- **Watch 模式** - 监听文件变更并自动增量更新代码地图,支持后台守护进程
|
|
14
|
+
- **交互式查询** - 支持按符号、模块、依赖进行精确或模糊查询
|
|
15
|
+
- **复杂度分析** - 计算圈复杂度、认知复杂度和可维护性指数
|
|
16
|
+
- **调用图分析** - 分析函数/方法间的调用关系
|
|
17
|
+
- **工作流编排** - v2.5 新增:6 阶段智能工作流 (reference → impact → risk → implementation → commit → ci)
|
|
18
|
+
- **CI 门禁** - v2.5 新增:提交格式检查、风险评估、输出契约验证
|
|
19
|
+
- **插件系统** - 可扩展的插件架构,支持自定义分析和输出
|
|
20
|
+
|
|
21
|
+
## 安装
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# 使用 npm
|
|
25
|
+
npm install codemap
|
|
26
|
+
|
|
27
|
+
# 使用 yarn
|
|
28
|
+
yarn add codemap
|
|
29
|
+
|
|
30
|
+
# 使用 pnpm
|
|
31
|
+
pnpm add codemap
|
|
32
|
+
|
|
33
|
+
# 全局安装(推荐,可直接使用 CLI)
|
|
34
|
+
npm install -g codemap
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**环境要求**: Node.js >= 18.0.0
|
|
38
|
+
|
|
39
|
+
## 快速开始
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# 1. 在项目根目录初始化配置
|
|
43
|
+
codemap init
|
|
44
|
+
|
|
45
|
+
# 2. 生成代码地图
|
|
46
|
+
codemap generate
|
|
47
|
+
|
|
48
|
+
# 3. 查看生成的文件
|
|
49
|
+
ls .codemap/
|
|
50
|
+
# AI_MAP.md - 项目全局概览(供 AI 使用)
|
|
51
|
+
# CONTEXT.md - 上下文入口(跳转到 context/README.md)
|
|
52
|
+
# context/ - 各模块的详细上下文
|
|
53
|
+
# codemap.json - 结构化 JSON 数据
|
|
54
|
+
# dependency-graph.md - Mermaid 依赖图
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
生成后,将 `.codemap/AI_MAP.md` 的内容提供给 AI 助手即可让其快速理解你的项目结构。
|
|
58
|
+
|
|
59
|
+
## CLI 命令
|
|
60
|
+
|
|
61
|
+
### `codemap init`
|
|
62
|
+
|
|
63
|
+
初始化项目的 CodeMap 配置文件。
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
codemap init # 交互式创建配置
|
|
67
|
+
codemap init -y # 使用默认配置直接创建
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
| 选项 | 说明 |
|
|
71
|
+
|------|------|
|
|
72
|
+
| `-y, --yes` | 跳过交互,使用默认配置 |
|
|
73
|
+
|
|
74
|
+
执行后会在项目根目录生成 `codemap.config.json` 配置文件。
|
|
75
|
+
|
|
76
|
+
### `codemap generate`
|
|
77
|
+
|
|
78
|
+
分析项目并生成代码地图文件。
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
codemap generate # 使用默认 hybrid 模式
|
|
82
|
+
codemap generate -m smart # 使用 smart 模式(AST 深度分析)
|
|
83
|
+
codemap generate -o ./docs/codemap # 指定输出目录
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
| 选项 | 说明 | 默认值 |
|
|
87
|
+
|------|------|--------|
|
|
88
|
+
| `-m, --mode <mode>` | 分析模式:`fast`(正则匹配)、`smart`(TypeScript AST)或 `hybrid`(自动选择) | `hybrid` |
|
|
89
|
+
| `-o, --output <dir>` | 输出目录 | `.codemap` |
|
|
90
|
+
| `--ai-context` | 为每个文件生成描述 | - |
|
|
91
|
+
|
|
92
|
+
**模式说明:**
|
|
93
|
+
|
|
94
|
+
| 模式 | 速度 | 精度 | 适用场景 |
|
|
95
|
+
|------|------|------|----------|
|
|
96
|
+
| `fast` | 极快 | 基本结构 | 日常开发、大型项目快速预览 |
|
|
97
|
+
| `smart` | 较慢 | 完整语义 | 深度分析、复杂度评估、类型推导 |
|
|
98
|
+
| `hybrid` | 自动 | 自适应 | **推荐** - 文件数<50用fast,≥50用smart |
|
|
99
|
+
|
|
100
|
+
### `codemap watch`
|
|
101
|
+
|
|
102
|
+
监听文件变更并自动增量更新代码地图。
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
codemap watch # 前台运行
|
|
106
|
+
codemap watch -d # 以后台守护进程运行
|
|
107
|
+
codemap watch -s # 停止后台守护进程
|
|
108
|
+
codemap watch -t # 查看守护进程状态
|
|
109
|
+
codemap watch -m smart # 使用 smart 模式监听
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
| 选项 | 说明 | 默认值 |
|
|
113
|
+
|------|------|--------|
|
|
114
|
+
| `-m, --mode <mode>` | 分析模式 (fast/smart/hybrid) | `hybrid` |
|
|
115
|
+
| `-o, --output <dir>` | 输出目录 | `.codemap` |
|
|
116
|
+
| `-d, --detach` | 以后台守护进程方式运行 | - |
|
|
117
|
+
| `-s, --stop` | 停止后台守护进程 | - |
|
|
118
|
+
| `-t, --status` | 查看后台守护进程状态 | - |
|
|
119
|
+
|
|
120
|
+
### `codemap query`
|
|
121
|
+
|
|
122
|
+
查询代码地图中的符号、模块和依赖信息。
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
codemap query -s "ModuleInfo" # 精确查询符号
|
|
126
|
+
codemap query -m "src/parser" # 查询模块信息
|
|
127
|
+
codemap query -d "analyzer" # 查询依赖关系
|
|
128
|
+
codemap query -S "cache" # 模糊搜索
|
|
129
|
+
codemap query -S "parse" -j # JSON 格式输出
|
|
130
|
+
codemap query -S "plugin" -l 5 # 限制结果数量
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
| 选项 | 说明 | 默认值 |
|
|
134
|
+
|------|------|------|
|
|
135
|
+
| `-s, --symbol <name>` | 精确查询符号 | - |
|
|
136
|
+
| `-m, --module <path>` | 查询模块信息 | - |
|
|
137
|
+
| `-d, --deps <name>` | 查询依赖关系 | - |
|
|
138
|
+
| `-S, --search <word>` | 模糊搜索 | - |
|
|
139
|
+
| `-l, --limit <number>` | 限制结果数量 | `20` |
|
|
140
|
+
| `-j, --json` | 以 JSON 格式输出 | - |
|
|
141
|
+
|
|
142
|
+
### `codemap deps`
|
|
143
|
+
|
|
144
|
+
分析并输出模块的依赖关系树。
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
codemap deps # 查看所有模块的依赖统计
|
|
148
|
+
codemap deps -m "src/parser" # 查看指定模块的依赖树
|
|
149
|
+
codemap deps -m "src/parser" -j # JSON 格式输出
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
| 选项 | 说明 | 默认值 |
|
|
153
|
+
|------|------|--------|
|
|
154
|
+
| `-m, --module <path>` | 查询指定模块的依赖 | - |
|
|
155
|
+
| `-j, --json` | 以 JSON 格式输出 | - |
|
|
156
|
+
|
|
157
|
+
### `codemap cycles`
|
|
158
|
+
|
|
159
|
+
检测项目中的循环依赖。
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
codemap cycles # 检测所有循环依赖
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### `codemap complexity`
|
|
166
|
+
|
|
167
|
+
分析代码复杂度,输出圈复杂度、认知复杂度和可维护性指数。
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
codemap complexity # 分析整个项目的复杂度
|
|
171
|
+
codemap complexity -f src/cli/index.ts # 分析指定文件的复杂度
|
|
172
|
+
codemap complexity -j # JSON 格式输出
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
| 选项 | 说明 | 默认值 |
|
|
176
|
+
|------|------|--------|
|
|
177
|
+
| `-f, --file <path>` | 查看指定文件的复杂度 | - |
|
|
178
|
+
| `-j, --json` | 以 JSON 格式输出 | - |
|
|
179
|
+
|
|
180
|
+
### `codemap impact`
|
|
181
|
+
|
|
182
|
+
评估指定文件或模块变更的影响范围。
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
codemap impact -f src/cli/index.ts # 分析指定文件的变更影响
|
|
186
|
+
codemap impact -f src/cli/index.ts --transitive # 包含传递依赖
|
|
187
|
+
codemap impact -f src/cli/index.ts -j # JSON 格式输出
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
| 选项 | 说明 | 默认值 |
|
|
191
|
+
|------|------|------|
|
|
192
|
+
| `-f, --file <path>` | **必填** 指定要分析的文件 | - |
|
|
193
|
+
| `-t, --transitive` | 包含传递依赖(间接影响) | - |
|
|
194
|
+
| `-j, --json` | 以 JSON 格式输出 | - |
|
|
195
|
+
|
|
196
|
+
## 工作流编排 (v2.5)
|
|
197
|
+
|
|
198
|
+
CodeMap v2.5 引入智能工作流编排系统,将复杂任务分解为 6 个有序阶段,每个阶段自动分析并传递上下文。
|
|
199
|
+
|
|
200
|
+
### 工作流阶段
|
|
201
|
+
|
|
202
|
+
```
|
|
203
|
+
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
|
|
204
|
+
│ reference │ → │ impact │ → │ risk │
|
|
205
|
+
│ 参考搜索 │ │ 影响分析 │ │ 风险评估 │
|
|
206
|
+
└─────────────┘ └─────────────┘ └─────────────┘
|
|
207
|
+
↓
|
|
208
|
+
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
|
|
209
|
+
│ ci │ ← │ commit │ ← │implementation│
|
|
210
|
+
│ CI验证 │ │ 提交验证 │ │ 代码实现 │
|
|
211
|
+
└─────────────┘ └─────────────┘ └─────────────┘
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
| 阶段 | 说明 | 自动分析 | 交付物 |
|
|
215
|
+
|------|------|----------|--------|
|
|
216
|
+
| **reference** | 参考搜索:查找相关代码和文档 | 符号搜索、依赖分析 | 相关文件列表 |
|
|
217
|
+
| **impact** | 影响分析:评估变更影响范围 | 依赖图分析、传递依赖 | 影响文件清单 |
|
|
218
|
+
| **risk** | 风险评估:基于 Git 历史评估风险 | 文件热度、修改频率、风险评分 | 风险报告 |
|
|
219
|
+
| **implementation** | 代码实现:执行具体修改 | - | 代码变更 |
|
|
220
|
+
| **commit** | 提交验证:验证提交格式 | Commit 格式检查 | 验证报告 |
|
|
221
|
+
| **ci** | CI验证:运行测试和检查 | 单元测试、类型检查、契约验证 | CI 报告 |
|
|
222
|
+
|
|
223
|
+
### 工作流 CLI 命令
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
# 启动工作流
|
|
227
|
+
codemap workflow start "实现用户认证模块"
|
|
228
|
+
# 启动工作流并指定模板(会直接影响阶段推进顺序)
|
|
229
|
+
codemap workflow start "修复登录接口 500" --template bugfix
|
|
230
|
+
|
|
231
|
+
# 查看当前工作流状态
|
|
232
|
+
codemap workflow status
|
|
233
|
+
|
|
234
|
+
# 可视化当前工作流(支持 --timeline / --results)
|
|
235
|
+
codemap workflow visualize
|
|
236
|
+
|
|
237
|
+
# 推进到下一阶段
|
|
238
|
+
codemap workflow proceed
|
|
239
|
+
|
|
240
|
+
# 恢复当前活动工作流(可选传 workflow-id)
|
|
241
|
+
codemap workflow resume
|
|
242
|
+
codemap workflow resume <workflow-id>
|
|
243
|
+
|
|
244
|
+
# 创建检查点
|
|
245
|
+
codemap workflow checkpoint
|
|
246
|
+
|
|
247
|
+
# 列出所有工作流
|
|
248
|
+
codemap workflow list
|
|
249
|
+
|
|
250
|
+
# 删除工作流
|
|
251
|
+
codemap workflow delete <workflow-id>
|
|
252
|
+
|
|
253
|
+
# 模板管理
|
|
254
|
+
codemap workflow template list --all
|
|
255
|
+
codemap workflow template info bugfix
|
|
256
|
+
codemap workflow template apply bugfix
|
|
257
|
+
codemap workflow template recommend "紧急修复支付超时"
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### 工作流使用示例
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
# 示例:实现新功能
|
|
264
|
+
$ codemap workflow start "添加缓存过期机制"
|
|
265
|
+
🚀 启动工作流: 添加缓存过期机制
|
|
266
|
+
📍 当前阶段: reference
|
|
267
|
+
|
|
268
|
+
# 系统会自动分析相关代码,生成参考搜索结果
|
|
269
|
+
# 确认后进入下一阶段
|
|
270
|
+
$ codemap workflow proceed
|
|
271
|
+
📍 进入阶段: impact
|
|
272
|
+
📊 影响范围: 3 个文件
|
|
273
|
+
- src/cache/lru-cache.ts
|
|
274
|
+
- src/cache/index.ts
|
|
275
|
+
- src/cli/commands/query.ts
|
|
276
|
+
|
|
277
|
+
# 继续推进
|
|
278
|
+
$ codemap workflow proceed
|
|
279
|
+
📍 进入阶段: risk
|
|
280
|
+
⚠️ 风险等级: medium
|
|
281
|
+
- src/cache/lru-cache.ts: 近期频繁修改 (5次/30天)
|
|
282
|
+
|
|
283
|
+
# 实现代码后
|
|
284
|
+
$ codemap workflow proceed
|
|
285
|
+
📍 进入阶段: implementation
|
|
286
|
+
✅ 代码实现完成
|
|
287
|
+
|
|
288
|
+
# 提交前验证
|
|
289
|
+
$ codemap workflow proceed
|
|
290
|
+
📍 进入阶段: commit
|
|
291
|
+
✅ Commit 格式验证通过
|
|
292
|
+
|
|
293
|
+
# CI 验证
|
|
294
|
+
$ codemap workflow proceed
|
|
295
|
+
📍 进入阶段: ci
|
|
296
|
+
✅ 所有检查通过
|
|
297
|
+
🎉 工作流完成!
|
|
298
|
+
|
|
299
|
+
# 示例:模板会改变阶段推进顺序
|
|
300
|
+
$ codemap workflow start "修复线上缓存失效" --template bugfix
|
|
301
|
+
$ codemap workflow proceed --force
|
|
302
|
+
📍 下一阶段: implementation # bugfix 模板: reference -> implementation
|
|
303
|
+
|
|
304
|
+
# 示例:对当前活动工作流应用模板
|
|
305
|
+
$ codemap workflow template apply bugfix
|
|
306
|
+
Applied template: bugfix
|
|
307
|
+
Current phase: reference
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
## CI 门禁 (v2.5)
|
|
311
|
+
|
|
312
|
+
CodeMap 提供 CI 阶段自动检查,确保代码质量。
|
|
313
|
+
|
|
314
|
+
```bash
|
|
315
|
+
# 检查提交格式 ([TAG] scope: message)
|
|
316
|
+
codemap ci check-commits
|
|
317
|
+
|
|
318
|
+
# 检查文件头注释 ([META], [WHY])
|
|
319
|
+
codemap ci check-headers
|
|
320
|
+
|
|
321
|
+
# 评估变更风险
|
|
322
|
+
codemap ci assess-risk -f src/cache/lru-cache.ts
|
|
323
|
+
|
|
324
|
+
# 检查输出契约
|
|
325
|
+
codemap ci check-output-contract
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
## 配置说明
|
|
329
|
+
|
|
330
|
+
通过 `codemap init` 生成的 `codemap.config.json` 配置文件支持以下选项:
|
|
331
|
+
|
|
332
|
+
```jsonc
|
|
333
|
+
{
|
|
334
|
+
// JSON Schema(可选,提供编辑器智能提示)
|
|
335
|
+
"$schema": "https://codemap.dev/schema.json",
|
|
336
|
+
|
|
337
|
+
// 分析模式:"fast" 或 "smart"
|
|
338
|
+
"mode": "fast",
|
|
339
|
+
|
|
340
|
+
// 包含的文件 glob 模式
|
|
341
|
+
"include": [
|
|
342
|
+
"src/**/*.ts"
|
|
343
|
+
],
|
|
344
|
+
|
|
345
|
+
// 排除的文件 glob 模式
|
|
346
|
+
"exclude": [
|
|
347
|
+
"node_modules/**",
|
|
348
|
+
"dist/**",
|
|
349
|
+
"build/**",
|
|
350
|
+
"*.test.ts",
|
|
351
|
+
"*.spec.ts"
|
|
352
|
+
],
|
|
353
|
+
|
|
354
|
+
// 输出目录
|
|
355
|
+
"output": ".codemap"
|
|
356
|
+
}
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
| 配置项 | 类型 | 说明 | 默认值 |
|
|
360
|
+
|--------|------|------|--------|
|
|
361
|
+
| `mode` | `"fast" \| "smart"` | 分析模式 | `"fast"` |
|
|
362
|
+
| `include` | `string[]` | 包含的文件 glob 模式 | `["src/**/*.ts"]` |
|
|
363
|
+
| `exclude` | `string[]` | 排除的文件 glob 模式 | `["node_modules/**", "dist/**", ...]` |
|
|
364
|
+
| `output` | `string` | 输出目录路径 | `".codemap"` |
|
|
365
|
+
|
|
366
|
+
## 输出文件说明
|
|
367
|
+
|
|
368
|
+
运行 `codemap generate` 后,会在输出目录(默认 `.codemap/`)中生成以下文件:
|
|
369
|
+
|
|
370
|
+
### `AI_MAP.md`
|
|
371
|
+
|
|
372
|
+
项目全局概览文件,专为 AI 助手设计,包含:
|
|
373
|
+
- 项目基本信息(文件数、代码行数、模块数等)
|
|
374
|
+
- 入口点列表
|
|
375
|
+
- 模块组织表(导出数、依赖数、类型)
|
|
376
|
+
- Mermaid 格式的依赖关系图
|
|
377
|
+
- 类型摘要和导出统计
|
|
378
|
+
|
|
379
|
+
### `CONTEXT.md` 与 `context/`
|
|
380
|
+
|
|
381
|
+
`CONTEXT.md` 是上下文入口文件,详细模块内容位于 `context/` 目录,包含:
|
|
382
|
+
- 模块概述(类型、代码行数)
|
|
383
|
+
- 导出列表(名称、类型、是否默认导出)
|
|
384
|
+
- 导入列表(来源、引入的符号)
|
|
385
|
+
- 符号列表(函数、类、接口等)
|
|
386
|
+
- 依赖和被依赖关系
|
|
387
|
+
|
|
388
|
+
### `codemap.json`
|
|
389
|
+
|
|
390
|
+
完整的结构化 JSON 数据,包含所有分析结果,适用于程序化消费。数据结构包括:
|
|
391
|
+
- `project` - 项目基本信息
|
|
392
|
+
- `summary` - 统计摘要
|
|
393
|
+
- `modules` - 模块详情数组(符号、导入、导出、复杂度等)
|
|
394
|
+
- `dependencies` - 依赖图(节点和边)
|
|
395
|
+
|
|
396
|
+
### `dependency-graph.md`
|
|
397
|
+
|
|
398
|
+
独立的 Mermaid 依赖关系图文件,可在支持 Mermaid 的 Markdown 渲染器中直接预览。
|
|
399
|
+
|
|
400
|
+
## 项目架构
|
|
401
|
+
|
|
402
|
+
```
|
|
403
|
+
src/
|
|
404
|
+
├── cli/ # CLI 命令入口
|
|
405
|
+
│ ├── index.ts # Commander 命令注册
|
|
406
|
+
│ └── commands/ # 各子命令实现
|
|
407
|
+
│ ├── analyze.ts # 统一分析入口(支持多意图路由)
|
|
408
|
+
│ ├── impact.ts # 影响范围分析
|
|
409
|
+
│ ├── deps.ts # 依赖分析
|
|
410
|
+
│ ├── complexity.ts # 复杂度分析
|
|
411
|
+
│ ├── workflow.ts # 工作流编排命令
|
|
412
|
+
│ └── ci.ts # CI 门禁命令
|
|
413
|
+
├── core/ # 核心分析引擎
|
|
414
|
+
│ └── analyzer.ts # 主分析器
|
|
415
|
+
├── parser/ # 解析器层
|
|
416
|
+
│ ├── interfaces/ # 解析器接口定义 (IParser)
|
|
417
|
+
│ └── implementations/
|
|
418
|
+
│ ├── fast-parser.ts # 快速正则解析器
|
|
419
|
+
│ └── smart-parser.ts # TypeScript AST 解析器
|
|
420
|
+
├── orchestrator/ # 编排层(v2.5 新增)
|
|
421
|
+
│ ├── index.ts # 统一导出
|
|
422
|
+
│ ├── types.ts # UnifiedResult 类型定义
|
|
423
|
+
│ ├── confidence.ts # 置信度计算
|
|
424
|
+
│ ├── result-fusion.ts # 结果融合
|
|
425
|
+
│ ├── tool-orchestrator.ts # 工具编排器
|
|
426
|
+
│ ├── intent-router.ts # 意图路由
|
|
427
|
+
│ ├── test-linker.ts # 测试关联器
|
|
428
|
+
│ ├── git-analyzer.ts # Git 分析器
|
|
429
|
+
│ ├── ai-feed-generator.ts # AI 饲料生成器
|
|
430
|
+
│ ├── file-header-scanner.ts # 文件头扫描器
|
|
431
|
+
│ ├── commit-validator.ts # 提交验证器
|
|
432
|
+
│ ├── adapters/ # 工具适配器
|
|
433
|
+
│ │ ├── base-adapter.ts # 适配器基类
|
|
434
|
+
│ │ ├── codemap-adapter.ts # CodeMap 适配器
|
|
435
|
+
│ │ └── ast-grep-adapter.ts # AstGrep 适配器
|
|
436
|
+
│ └── workflow/ # 工作流模块
|
|
437
|
+
│ ├── workflow-orchestrator.ts # 工作流编排器
|
|
438
|
+
│ ├── workflow-persistence.ts # 工作流持久化
|
|
439
|
+
│ ├── phase-checkpoint.ts # 阶段检查点
|
|
440
|
+
│ └── config.ts # 工作流配置
|
|
441
|
+
├── generator/ # 输出生成器
|
|
442
|
+
│ ├── index.ts # AI_MAP / JSON / Mermaid 生成
|
|
443
|
+
│ └── context.ts # CONTEXT.md 生成
|
|
444
|
+
├── cache/ # 缓存系统
|
|
445
|
+
│ ├── lru-cache.ts # LRU 缓存实现
|
|
446
|
+
│ ├── parse-cache.ts # 解析结果缓存
|
|
447
|
+
│ └── file-hash-cache.ts # 文件哈希缓存
|
|
448
|
+
├── watcher/ # 文件监听
|
|
449
|
+
│ ├── file-watcher.ts # 文件变更监听
|
|
450
|
+
│ ├── daemon.ts # 守护进程管理
|
|
451
|
+
│ └── watch-worker.ts # 监听工作线程
|
|
452
|
+
├── plugins/ # 插件系统
|
|
453
|
+
│ ├── types.ts # 插件接口定义
|
|
454
|
+
│ ├── plugin-registry.ts # 插件注册中心
|
|
455
|
+
│ ├── plugin-loader.ts # 插件加载器
|
|
456
|
+
│ └── built-in/ # 内置插件
|
|
457
|
+
│ ├── complexity-analyzer.ts # 复杂度分析
|
|
458
|
+
│ └── call-graph.ts # 调用图分析
|
|
459
|
+
└── types/ # 类型定义
|
|
460
|
+
└── index.ts # 核心类型
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
## 新增 CLI 命令
|
|
464
|
+
|
|
465
|
+
### `codemap analyze`
|
|
466
|
+
|
|
467
|
+
统一分析入口,支持多意图路由:
|
|
468
|
+
|
|
469
|
+
```bash
|
|
470
|
+
codemap analyze "分析 tool-orchestrator 的影响范围"
|
|
471
|
+
codemap analyze --intent impact --file src/cli/index.ts
|
|
472
|
+
codemap analyze --intent dependency --file src/cli/index.ts
|
|
473
|
+
codemap analyze --intent search "UnifiedResult"
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
## 贡献指南
|
|
477
|
+
|
|
478
|
+
欢迎提交 Issue 和 Pull Request!
|
|
479
|
+
|
|
480
|
+
### 开发环境搭建
|
|
481
|
+
|
|
482
|
+
```bash
|
|
483
|
+
# 克隆仓库
|
|
484
|
+
git clone <repo-url>
|
|
485
|
+
cd codemap
|
|
486
|
+
|
|
487
|
+
# 安装依赖
|
|
488
|
+
npm install
|
|
489
|
+
|
|
490
|
+
# 编译
|
|
491
|
+
npm run build
|
|
492
|
+
|
|
493
|
+
# 开发模式(监听编译)
|
|
494
|
+
npm run dev
|
|
495
|
+
|
|
496
|
+
# 运行测试
|
|
497
|
+
npm test # 功能测试(src/**/*.test.ts)
|
|
498
|
+
npm run benchmark # 性能基准测试(refer/benchmark-quality.test.ts)
|
|
499
|
+
npm run test:all # 功能 + 基准(串联执行)
|
|
500
|
+
|
|
501
|
+
# 类型检查
|
|
502
|
+
npm run typecheck
|
|
503
|
+
|
|
504
|
+
# 代码检查
|
|
505
|
+
npm run lint
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
### 提交规范
|
|
509
|
+
|
|
510
|
+
请遵循以下 commit message 格式:
|
|
511
|
+
|
|
512
|
+
```
|
|
513
|
+
[TAG] scope: message
|
|
514
|
+
|
|
515
|
+
BUGFIX Bug 修复
|
|
516
|
+
FEATURE 新功能
|
|
517
|
+
REFACTOR 代码重构
|
|
518
|
+
CONFIG 配置/构建变更
|
|
519
|
+
DOCS 文档变更
|
|
520
|
+
DELETE 删除代码/文件
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
示例:`[FEATURE] cli: add new command`
|
|
524
|
+
|
|
525
|
+
### 文件规范
|
|
526
|
+
|
|
527
|
+
所有 TypeScript 源文件(除测试文件和类型定义外)头部必须包含以下注释:
|
|
528
|
+
|
|
529
|
+
```typescript
|
|
530
|
+
// [META] since:YYYY-MM | owner:team | stable:false
|
|
531
|
+
// [WHY] 说明该文件存在的原因和业务价值
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
- `[META]`:元数据注释,包含创建时间、负责团队、稳定性状态
|
|
535
|
+
- `[WHY]`:解释文件存在的业务理由,帮助 AI 理解上下文
|
|
536
|
+
|
|
537
|
+
### 开发注意事项
|
|
538
|
+
|
|
539
|
+
- 项目使用 ESM 模块格式(`"type": "module"`)
|
|
540
|
+
- TypeScript 严格模式
|
|
541
|
+
- 使用 Vitest 作为测试框架
|
|
542
|
+
- **提交前会自动运行与变更相关的测试,失败将阻断提交**
|
|
543
|
+
- **提交前会检查文件头注释规范([META]/[WHY])**
|
|
544
|
+
- 新增功能请同步补充测试和文档
|
|
545
|
+
|
|
546
|
+
### 运行日志(调试追踪)
|
|
547
|
+
|
|
548
|
+
- CLI 运行日志默认写入 `.codemap/logs/codemap-YYYY-MM-DD.log`
|
|
549
|
+
- 默认保留 14 天、最多保留 30 个日志文件(自动清理)
|
|
550
|
+
- 可通过环境变量调整:
|
|
551
|
+
- `CODEMAP_RUNTIME_LOG_ENABLED=false`:关闭运行日志
|
|
552
|
+
- `CODEMAP_RUNTIME_LOG_DIR=<dir>`:自定义日志目录
|
|
553
|
+
- `CODEMAP_RUNTIME_LOG_RETENTION_DAYS=<days>`:设置保留天数
|
|
554
|
+
- `CODEMAP_RUNTIME_LOG_MAX_FILES=<n>`:设置最大保留文件数
|
|
555
|
+
- `CODEMAP_RUNTIME_LOG_MAX_SIZE_MB=<mb>`:单个日志文件大小上限(超限后自动轮转并 gzip)
|
|
556
|
+
|
|
557
|
+
## 许可证
|
|
558
|
+
|
|
559
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { AIProvider, type AIProviderConfig, type AIResponse } from './provider.js';
|
|
2
|
+
import type { CodeMap } from '../types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Claude Provider 配置
|
|
5
|
+
*/
|
|
6
|
+
export interface ClaudeProviderConfig extends AIProviderConfig {
|
|
7
|
+
/** CLI 路径,默认 claude */
|
|
8
|
+
cliPath?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Claude Provider - 通过 CLI 调用 Claude
|
|
12
|
+
*/
|
|
13
|
+
export declare class ClaudeProvider extends AIProvider {
|
|
14
|
+
readonly name: "claude";
|
|
15
|
+
private cliPath;
|
|
16
|
+
constructor(config?: ClaudeProviderConfig);
|
|
17
|
+
/**
|
|
18
|
+
* 执行 AI 推理
|
|
19
|
+
*/
|
|
20
|
+
execute(prompt: string, context?: CodeMap): Promise<AIResponse>;
|
|
21
|
+
/**
|
|
22
|
+
* 检查 Claude CLI 是否可用
|
|
23
|
+
*/
|
|
24
|
+
isAvailable(): Promise<boolean>;
|
|
25
|
+
/**
|
|
26
|
+
* 构建提示词
|
|
27
|
+
*/
|
|
28
|
+
private buildPrompt;
|
|
29
|
+
/**
|
|
30
|
+
* 总结 CodeMap 上下文
|
|
31
|
+
*/
|
|
32
|
+
private summarizeContext;
|
|
33
|
+
/**
|
|
34
|
+
* 解析 Claude CLI JSON 响应
|
|
35
|
+
*/
|
|
36
|
+
private parseResponse;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=claude.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude.d.ts","sourceRoot":"","sources":["../../src/ai/claude.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,KAAK,gBAAgB,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AACnF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAWjD;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,gBAAgB;IAC5D,uBAAuB;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,UAAU;IAC5C,SAAgB,IAAI,EAAG,QAAQ,CAAU;IACzC,OAAO,CAAC,OAAO,CAAS;gBAEZ,MAAM,GAAE,oBAAyB;IAK7C;;OAEG;IACG,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC;IAoErE;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAsBrC;;OAEG;IACH,OAAO,CAAC,WAAW;IAWnB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAsCxB;;OAEG;IACH,OAAO,CAAC,aAAa;CA6BtB"}
|