@mycodemap/mycodemap 0.1.0 → 0.2.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 +164 -6
- package/README.md +407 -141
- package/dist/cli/commands/ci.d.ts +7 -1
- package/dist/cli/commands/ci.d.ts.map +1 -1
- package/dist/cli/commands/ci.js +38 -0
- package/dist/cli/commands/ci.js.map +1 -1
- package/dist/cli/commands/cycles.d.ts.map +1 -1
- package/dist/cli/commands/cycles.js +2 -0
- package/dist/cli/commands/cycles.js.map +1 -1
- package/dist/cli/commands/export.d.ts +6 -0
- package/dist/cli/commands/export.d.ts.map +1 -0
- package/dist/cli/commands/export.js +108 -0
- package/dist/cli/commands/export.js.map +1 -0
- package/dist/cli/commands/generate.d.ts.map +1 -1
- package/dist/cli/commands/generate.js +96 -0
- package/dist/cli/commands/generate.js.map +1 -1
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +3 -1
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/logs.d.ts +5 -0
- package/dist/cli/commands/logs.d.ts.map +1 -0
- package/dist/cli/commands/logs.js +189 -0
- package/dist/cli/commands/logs.js.map +1 -0
- package/dist/cli/commands/report.d.ts +12 -0
- package/dist/cli/commands/report.d.ts.map +1 -0
- package/dist/cli/commands/report.js +158 -0
- package/dist/cli/commands/report.js.map +1 -0
- package/dist/cli/commands/server.d.ts +9 -0
- package/dist/cli/commands/server.d.ts.map +1 -0
- package/dist/cli/commands/server.js +68 -0
- package/dist/cli/commands/server.js.map +1 -0
- package/dist/cli/commands/watch-foreground.d.ts.map +1 -1
- package/dist/cli/commands/watch-foreground.js +2 -0
- package/dist/cli/commands/watch-foreground.js.map +1 -1
- package/dist/cli/commands/watch.d.ts.map +1 -1
- package/dist/cli/commands/watch.js +2 -0
- package/dist/cli/commands/watch.js.map +1 -1
- package/dist/cli/first-run-guide.d.ts +23 -0
- package/dist/cli/first-run-guide.d.ts.map +1 -0
- package/dist/cli/first-run-guide.js +83 -0
- package/dist/cli/first-run-guide.js.map +1 -0
- package/dist/cli/index.js +85 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/platform-check.d.ts +21 -0
- package/dist/cli/platform-check.d.ts.map +1 -0
- package/dist/cli/platform-check.js +94 -0
- package/dist/cli/platform-check.js.map +1 -0
- package/dist/cli/tree-sitter-check.d.ts +35 -0
- package/dist/cli/tree-sitter-check.d.ts.map +1 -0
- package/dist/cli/tree-sitter-check.js +133 -0
- package/dist/cli/tree-sitter-check.js.map +1 -0
- package/dist/cli/utils/sanitize.d.ts +54 -0
- package/dist/cli/utils/sanitize.d.ts.map +1 -0
- package/dist/cli/utils/sanitize.js +131 -0
- package/dist/cli/utils/sanitize.js.map +1 -0
- package/dist/cli-new/commands/export.d.ts +15 -0
- package/dist/cli-new/commands/export.d.ts.map +1 -0
- package/dist/cli-new/commands/export.js +107 -0
- package/dist/cli-new/commands/export.js.map +1 -0
- package/dist/cli-new/commands/query.d.ts +14 -0
- package/dist/cli-new/commands/query.d.ts.map +1 -0
- package/dist/cli-new/commands/query.js +120 -0
- package/dist/cli-new/commands/query.js.map +1 -0
- package/dist/cli-new/commands/server.d.ts +13 -0
- package/dist/cli-new/commands/server.d.ts.map +1 -0
- package/dist/cli-new/commands/server.js +94 -0
- package/dist/cli-new/commands/server.js.map +1 -0
- package/dist/cli-new/index.d.ts +11 -0
- package/dist/cli-new/index.d.ts.map +1 -0
- package/dist/cli-new/index.js +63 -0
- package/dist/cli-new/index.js.map +1 -0
- package/dist/cli-new/types/index.d.ts +88 -0
- package/dist/cli-new/types/index.d.ts.map +1 -0
- package/dist/cli-new/types/index.js +7 -0
- package/dist/cli-new/types/index.js.map +1 -0
- package/dist/domain/entities/CodeGraph.d.ts +134 -0
- package/dist/domain/entities/CodeGraph.d.ts.map +1 -0
- package/dist/domain/entities/CodeGraph.js +316 -0
- package/dist/domain/entities/CodeGraph.js.map +1 -0
- package/dist/domain/entities/Dependency.d.ts +78 -0
- package/dist/domain/entities/Dependency.d.ts.map +1 -0
- package/dist/domain/entities/Dependency.js +132 -0
- package/dist/domain/entities/Dependency.js.map +1 -0
- package/dist/domain/entities/Module.d.ts +75 -0
- package/dist/domain/entities/Module.d.ts.map +1 -0
- package/dist/domain/entities/Module.js +151 -0
- package/dist/domain/entities/Module.js.map +1 -0
- package/dist/domain/entities/Project.d.ts +50 -0
- package/dist/domain/entities/Project.d.ts.map +1 -0
- package/dist/domain/entities/Project.js +99 -0
- package/dist/domain/entities/Project.js.map +1 -0
- package/dist/domain/entities/Symbol.d.ts +75 -0
- package/dist/domain/entities/Symbol.d.ts.map +1 -0
- package/dist/domain/entities/Symbol.js +130 -0
- package/dist/domain/entities/Symbol.js.map +1 -0
- package/dist/domain/events/DomainEvent.d.ts +76 -0
- package/dist/domain/events/DomainEvent.d.ts.map +1 -0
- package/dist/domain/events/DomainEvent.js +153 -0
- package/dist/domain/events/DomainEvent.js.map +1 -0
- package/dist/domain/index.d.ts +10 -0
- package/dist/domain/index.d.ts.map +1 -0
- package/dist/domain/index.js +18 -0
- package/dist/domain/index.js.map +1 -0
- package/dist/domain/repositories/CodeGraphRepository.d.ts +58 -0
- package/dist/domain/repositories/CodeGraphRepository.d.ts.map +1 -0
- package/dist/domain/repositories/CodeGraphRepository.js +37 -0
- package/dist/domain/repositories/CodeGraphRepository.js.map +1 -0
- package/dist/domain/services/CodeGraphBuilder.d.ts +50 -0
- package/dist/domain/services/CodeGraphBuilder.d.ts.map +1 -0
- package/dist/domain/services/CodeGraphBuilder.js +121 -0
- package/dist/domain/services/CodeGraphBuilder.js.map +1 -0
- package/dist/infrastructure/parser/implementations/GoParser.d.ts +25 -0
- package/dist/infrastructure/parser/implementations/GoParser.d.ts.map +1 -0
- package/dist/infrastructure/parser/implementations/GoParser.js +158 -0
- package/dist/infrastructure/parser/implementations/GoParser.js.map +1 -0
- package/dist/infrastructure/parser/implementations/PythonParser.d.ts +30 -0
- package/dist/infrastructure/parser/implementations/PythonParser.d.ts.map +1 -0
- package/dist/infrastructure/parser/implementations/PythonParser.js +201 -0
- package/dist/infrastructure/parser/implementations/PythonParser.js.map +1 -0
- package/dist/infrastructure/parser/implementations/TypeScriptParser.d.ts +63 -0
- package/dist/infrastructure/parser/implementations/TypeScriptParser.d.ts.map +1 -0
- package/dist/infrastructure/parser/implementations/TypeScriptParser.js +420 -0
- package/dist/infrastructure/parser/implementations/TypeScriptParser.js.map +1 -0
- package/dist/infrastructure/parser/index.d.ts +13 -0
- package/dist/infrastructure/parser/index.d.ts.map +1 -0
- package/dist/infrastructure/parser/index.js +32 -0
- package/dist/infrastructure/parser/index.js.map +1 -0
- package/dist/infrastructure/parser/interfaces/ParserBase.d.ts +124 -0
- package/dist/infrastructure/parser/interfaces/ParserBase.d.ts.map +1 -0
- package/dist/infrastructure/parser/interfaces/ParserBase.js +200 -0
- package/dist/infrastructure/parser/interfaces/ParserBase.js.map +1 -0
- package/dist/infrastructure/parser/registry/ParserRegistry.d.ts +68 -0
- package/dist/infrastructure/parser/registry/ParserRegistry.d.ts.map +1 -0
- package/dist/infrastructure/parser/registry/ParserRegistry.js +116 -0
- package/dist/infrastructure/parser/registry/ParserRegistry.js.map +1 -0
- package/dist/infrastructure/repositories/CodeGraphRepositoryImpl.d.ts +44 -0
- package/dist/infrastructure/repositories/CodeGraphRepositoryImpl.d.ts.map +1 -0
- package/dist/infrastructure/repositories/CodeGraphRepositoryImpl.js +129 -0
- package/dist/infrastructure/repositories/CodeGraphRepositoryImpl.js.map +1 -0
- package/dist/infrastructure/repositories/index.d.ts +3 -0
- package/dist/infrastructure/repositories/index.d.ts.map +1 -0
- package/dist/infrastructure/repositories/index.js +7 -0
- package/dist/infrastructure/repositories/index.js.map +1 -0
- package/dist/infrastructure/storage/StorageFactory.d.ts +53 -0
- package/dist/infrastructure/storage/StorageFactory.d.ts.map +1 -0
- package/dist/infrastructure/storage/StorageFactory.js +150 -0
- package/dist/infrastructure/storage/StorageFactory.js.map +1 -0
- package/dist/infrastructure/storage/adapters/FileSystemStorage.d.ts +52 -0
- package/dist/infrastructure/storage/adapters/FileSystemStorage.d.ts.map +1 -0
- package/dist/infrastructure/storage/adapters/FileSystemStorage.js +315 -0
- package/dist/infrastructure/storage/adapters/FileSystemStorage.js.map +1 -0
- package/dist/infrastructure/storage/adapters/KuzuDBStorage.d.ts +52 -0
- package/dist/infrastructure/storage/adapters/KuzuDBStorage.d.ts.map +1 -0
- package/dist/infrastructure/storage/adapters/KuzuDBStorage.js +235 -0
- package/dist/infrastructure/storage/adapters/KuzuDBStorage.js.map +1 -0
- package/dist/infrastructure/storage/adapters/MemoryStorage.d.ts +37 -0
- package/dist/infrastructure/storage/adapters/MemoryStorage.d.ts.map +1 -0
- package/dist/infrastructure/storage/adapters/MemoryStorage.js +229 -0
- package/dist/infrastructure/storage/adapters/MemoryStorage.js.map +1 -0
- package/dist/infrastructure/storage/adapters/Neo4jStorage.d.ts +49 -0
- package/dist/infrastructure/storage/adapters/Neo4jStorage.d.ts.map +1 -0
- package/dist/infrastructure/storage/adapters/Neo4jStorage.js +222 -0
- package/dist/infrastructure/storage/adapters/Neo4jStorage.js.map +1 -0
- package/dist/infrastructure/storage/index.d.ts +6 -0
- package/dist/infrastructure/storage/index.d.ts.map +1 -0
- package/dist/infrastructure/storage/index.js +13 -0
- package/dist/infrastructure/storage/index.js.map +1 -0
- package/dist/infrastructure/storage/interfaces/StorageBase.d.ts +76 -0
- package/dist/infrastructure/storage/interfaces/StorageBase.d.ts.map +1 -0
- package/dist/infrastructure/storage/interfaces/StorageBase.js +116 -0
- package/dist/infrastructure/storage/interfaces/StorageBase.js.map +1 -0
- package/dist/interface/config/index.d.ts +102 -0
- package/dist/interface/config/index.d.ts.map +1 -0
- package/dist/interface/config/index.js +7 -0
- package/dist/interface/config/index.js.map +1 -0
- package/dist/interface/types/index.d.ts +425 -0
- package/dist/interface/types/index.d.ts.map +1 -0
- package/dist/interface/types/index.js +8 -0
- package/dist/interface/types/index.js.map +1 -0
- package/dist/interface/types/parser.d.ts +103 -0
- package/dist/interface/types/parser.d.ts.map +1 -0
- package/dist/interface/types/parser.js +7 -0
- package/dist/interface/types/parser.js.map +1 -0
- package/dist/interface/types/storage.d.ts +98 -0
- package/dist/interface/types/storage.d.ts.map +1 -0
- package/dist/interface/types/storage.js +7 -0
- package/dist/interface/types/storage.js.map +1 -0
- package/dist/orchestrator/test-linker.js +1 -1
- package/dist/orchestrator/test-linker.js.map +1 -1
- package/dist/server/CodeMapServer.d.ts +51 -0
- package/dist/server/CodeMapServer.d.ts.map +1 -0
- package/dist/server/CodeMapServer.js +146 -0
- package/dist/server/CodeMapServer.js.map +1 -0
- package/dist/server/handlers/AnalysisHandler.d.ts +82 -0
- package/dist/server/handlers/AnalysisHandler.d.ts.map +1 -0
- package/dist/server/handlers/AnalysisHandler.js +196 -0
- package/dist/server/handlers/AnalysisHandler.js.map +1 -0
- package/dist/server/handlers/QueryHandler.d.ts +57 -0
- package/dist/server/handlers/QueryHandler.d.ts.map +1 -0
- package/dist/server/handlers/QueryHandler.js +260 -0
- package/dist/server/handlers/QueryHandler.js.map +1 -0
- package/dist/server/index.d.ts +7 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +13 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/routes/api.d.ts +8 -0
- package/dist/server/routes/api.d.ts.map +1 -0
- package/dist/server/routes/api.js +372 -0
- package/dist/server/routes/api.js.map +1 -0
- package/dist/server/types/index.d.ts +171 -0
- package/dist/server/types/index.d.ts.map +1 -0
- package/dist/server/types/index.js +7 -0
- package/dist/server/types/index.js.map +1 -0
- package/dist/types/index.d.ts +6 -372
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +9 -3
- package/dist/types/index.js.map +1 -1
- package/docs/AI_ASSISTANT_SETUP.md +811 -0
- package/docs/PUBLISHING.md +162 -0
- package/docs/README.md +37 -0
- package/docs/SETUP_GUIDE.md +493 -0
- package/docs/ai-guide/COMMANDS.md +369 -0
- package/docs/ai-guide/INTEGRATION.md +513 -0
- package/docs/ai-guide/OUTPUT.md +465 -0
- package/docs/ai-guide/PATTERNS.md +409 -0
- package/docs/ai-guide/PROMPTS.md +414 -0
- package/docs/ai-guide/QUICKSTART.md +114 -0
- package/docs/ai-guide/README.md +66 -0
- package/docs/archive/AI_INTEGRATION_GUIDE_ARCHIVED.md +391 -0
- package/docs/archive/ARCHIVE.md +39 -0
- package/docs/archive/MYCLAUDE_GUIDE.md +305 -0
- package/docs/archive/PUBLISH_NPM_DESIGN_V1.md +1699 -0
- package/docs/archive/PUBLISH_NPM_DESIGN_V2.md +396 -0
- package/docs/archive/README.md +29 -0
- package/docs/archive/TASK_DESIGN_COVERAGE_REPORT.md +320 -0
- package/docs/archive/TEST_SUMMARY.md +140 -0
- package/docs/archive/comprehensive_test_report.md +337 -0
- package/docs/archive/design-docs/CI_GATEWAY_DESIGN.md +790 -0
- package/docs/archive/design-docs/PUBLISH_NPM_DESIGN_FINAL.md +491 -0
- package/docs/archive/design-docs/REFACTOR_ARCHITECTURE_OVERVIEW.md +558 -0
- package/docs/archive/design-docs/REFACTOR_CONFIDENCE_DESIGN.md +250 -0
- package/docs/archive/design-docs/REFACTOR_GIT_ANALYZER_DESIGN.md +791 -0
- package/docs/archive/design-docs/REFACTOR_ORCHESTRATOR_DESIGN.md +1071 -0
- package/docs/archive/design-docs/REFACTOR_RESULT_FUSION_DESIGN.md +321 -0
- package/docs/archive/design-docs/REFACTOR_TEST_LINKER_DESIGN.md +317 -0
- package/docs/archive/myclaude.md +1084 -0
- package/docs/archive/plans/2026-03-14-go-language-support-design.md +92 -0
- package/docs/archive/product-specs/REFACTOR_REQUIREMENTS.md +976 -0
- package/docs/archive/scenario-2-deps-analysis.md +353 -0
- package/docs/archive/test-report-symbol-search.md +384 -0
- package/docs/archive/test-scenario-4-complexity-analysis.md +460 -0
- package/docs/archive/test_report_scenario5.md +615 -0
- package/docs/archive/test_scenario_3_impact_analysis_report.md +520 -0
- package/docs/design-docs/README.md +26 -0
- package/docs/exec-plans/MVP3-IMPLEMENTATION-ROADMAP.md +524 -0
- package/docs/exec-plans/README.md +29 -0
- package/docs/exec-plans/active/.gitkeep +0 -0
- package/docs/exec-plans/completed/.gitkeep +0 -0
- package/docs/exec-plans/completed/2026-03-03-deps-path-extension-fix.md +186 -0
- package/docs/exec-plans/completed/2026-03-03-post-task-plan.md +135 -0
- package/docs/exec-plans/completed/harness-engineering-rollout.md +184 -0
- package/docs/exec-plans/tech-debt/.gitkeep +0 -0
- package/docs/exec-plans/tech-debt/2026-03-15-lint-guardrail-gap.md +30 -0
- package/docs/generated/README.md +19 -0
- package/docs/product-specs/MVP3-ARCHITECTURE-COMPARISON.md +504 -0
- package/docs/product-specs/MVP3-ARCHITECTURE-REDESIGN-PRD.md +322 -0
- package/docs/product-specs/MVP3-ARCHITECTURE-REDESIGN-TECH-PRD.md +1374 -0
- package/docs/product-specs/README.md +22 -0
- package/docs/references/README.md +15 -0
- package/docs/references/tmp.md +527 -0
- package/docs/rules/README.md +16 -0
- package/docs/rules/architecture-guardrails.md +349 -0
- package/docs/rules/code-quality-redlines.md +321 -0
- package/docs/rules/deployment.md +23 -0
- package/docs/rules/engineering-with-codex-openai.md +202 -0
- package/docs/rules/testing.md +73 -0
- package/docs/rules/validation.md +39 -0
- package/examples/README.md +61 -0
- package/examples/claude/codemap-skill.md +94 -0
- package/examples/codex/codemap-agent.md +66 -0
- package/examples/copilot/copilot-instructions.md +24 -0
- package/examples/kimi/codemap-skill.md +92 -0
- package/package.json +22 -7
package/README.md
CHANGED
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
> TypeScript 代码地图工具 - 为 AI 辅助开发提供结构化上下文
|
|
4
4
|
|
|
5
|
-
CodeMap 是一个专为 TypeScript/JavaScript 项目设计的代码分析工具。它通过静态分析自动生成项目的结构化代码地图,帮助 AI 编程助手(如 Claude、Copilot)快速理解项目架构、模块关系和代码上下文。
|
|
5
|
+
CodeMap 是一个专为 TypeScript/JavaScript/Go 项目设计的代码分析工具。它通过静态分析自动生成项目的结构化代码地图,帮助 AI 编程助手(如 Claude、Copilot)快速理解项目架构、模块关系和代码上下文。
|
|
6
6
|
|
|
7
7
|
## 特性
|
|
8
8
|
|
|
9
|
+
- **分层架构 (MVP3)** - 清晰的分层设计:Interface → Infrastructure → Domain → Server → CLI
|
|
9
10
|
- **双层解析模式** - 提供 `fast`(快速正则)和 `smart`(TypeScript AST)两种解析模式,按需平衡速度与精度
|
|
11
|
+
- **多语言支持** - 支持 TypeScript/JavaScript、Go、Python(可扩展架构)
|
|
12
|
+
- **HTTP API 服务器** - 内置 REST API 服务器,支持查询、分析、导出
|
|
10
13
|
- **多格式输出** - 自动生成 `AI_MAP.md`(全局概览)、`CONTEXT.md` + `context/`(模块上下文)、`codemap.json`(结构化数据)
|
|
11
14
|
- **依赖图可视化** - 生成 Mermaid 格式的模块依赖关系图
|
|
12
15
|
- **增量缓存** - 基于文件哈希的 LRU 缓存机制,仅重新分析变更文件
|
|
@@ -17,36 +20,41 @@ CodeMap 是一个专为 TypeScript/JavaScript 项目设计的代码分析工具
|
|
|
17
20
|
- **工作流编排** - v2.5 新增:6 阶段智能工作流 (reference → impact → risk → implementation → commit → ci)
|
|
18
21
|
- **CI 门禁** - v2.5 新增:提交格式检查、风险评估、输出契约验证
|
|
19
22
|
- **插件系统** - 可扩展的插件架构,支持自定义分析和输出
|
|
23
|
+
- **存储抽象** - 支持文件系统、内存、KùzuDB、Neo4j 多种存储后端
|
|
20
24
|
|
|
21
25
|
## 安装
|
|
22
26
|
|
|
23
27
|
```bash
|
|
24
28
|
# 使用 npm
|
|
25
|
-
npm install
|
|
29
|
+
npm install @mycodemap/mycodemap
|
|
26
30
|
|
|
27
31
|
# 使用 yarn
|
|
28
|
-
yarn add
|
|
32
|
+
yarn add @mycodemap/mycodemap
|
|
29
33
|
|
|
30
34
|
# 使用 pnpm
|
|
31
|
-
pnpm add
|
|
35
|
+
pnpm add @mycodemap/mycodemap
|
|
32
36
|
|
|
33
37
|
# 全局安装(推荐,可直接使用 CLI)
|
|
34
|
-
npm install -g
|
|
38
|
+
npm install -g @mycodemap/mycodemap
|
|
35
39
|
```
|
|
36
40
|
|
|
37
41
|
**环境要求**: Node.js >= 18.0.0
|
|
38
42
|
|
|
43
|
+
**MVP3 新依赖**:
|
|
44
|
+
- `hono` - HTTP 服务器框架
|
|
45
|
+
- `@hono/node-server` - Node.js 适配器
|
|
46
|
+
|
|
39
47
|
## 快速开始
|
|
40
48
|
|
|
41
49
|
```bash
|
|
42
50
|
# 1. 在项目根目录初始化配置
|
|
43
|
-
|
|
51
|
+
mycodemap init
|
|
44
52
|
|
|
45
53
|
# 2. 生成代码地图
|
|
46
|
-
|
|
54
|
+
mycodemap generate
|
|
47
55
|
|
|
48
56
|
# 3. 查看生成的文件
|
|
49
|
-
ls .
|
|
57
|
+
ls .mycodemap/
|
|
50
58
|
# AI_MAP.md - 项目全局概览(供 AI 使用)
|
|
51
59
|
# CONTEXT.md - 上下文入口(跳转到 context/README.md)
|
|
52
60
|
# context/ - 各模块的详细上下文
|
|
@@ -54,17 +62,51 @@ ls .codemap/
|
|
|
54
62
|
# dependency-graph.md - Mermaid 依赖图
|
|
55
63
|
```
|
|
56
64
|
|
|
57
|
-
生成后,将 `.
|
|
65
|
+
生成后,将 `.mycodemap/AI_MAP.md` 的内容提供给 AI 助手即可让其快速理解你的项目结构。
|
|
66
|
+
|
|
67
|
+
## 文档导航
|
|
68
|
+
|
|
69
|
+
### 人类用户
|
|
70
|
+
|
|
71
|
+
| 文档 | 目标读者 | 内容 |
|
|
72
|
+
|------|----------|------|
|
|
73
|
+
| [🧭 文档索引](docs/README.md) | 所有读者 | 文档分层、阅读顺序与迁移状态 |
|
|
74
|
+
| [🏗️ 架构总图](ARCHITECTURE.md) | 开发者 | 系统地图、模块边界、主执行流 |
|
|
75
|
+
| [📋 MVP3 实施路线图](docs/exec-plans/MVP3-IMPLEMENTATION-ROADMAP.md) | 开发者 | 分层架构重构完整计划与状态 |
|
|
76
|
+
| [📖 安装配置指南](docs/SETUP_GUIDE.md) | 人类开发者 | 完整的安装、配置和使用指南 |
|
|
77
|
+
| [📁 配置示例](examples/) | 所有用户 | 各平台的现成配置文件 |
|
|
78
|
+
|
|
79
|
+
### 🤖 AI / Agent 专属文档
|
|
80
|
+
|
|
81
|
+
> 如果你是 AI 助手或 Agent,**请优先阅读以下文档**:
|
|
82
|
+
|
|
83
|
+
| 文档 | 说明 |
|
|
84
|
+
|------|------|
|
|
85
|
+
| **[📘 AI_GUIDE.md](AI_GUIDE.md)** | **AI 主指南** - 快速参考、命令选择决策树、提示词模板速用 |
|
|
86
|
+
| **[🚀 docs/ai-guide/QUICKSTART.md](docs/ai-guide/QUICKSTART.md)** | 快速开始、场景-命令映射表 |
|
|
87
|
+
| **[📚 docs/ai-guide/COMMANDS.md](docs/ai-guide/COMMANDS.md)** | 完整 CLI 命令参考 |
|
|
88
|
+
| **[📊 docs/ai-guide/OUTPUT.md](docs/ai-guide/OUTPUT.md)** | JSON 输出结构解析 |
|
|
89
|
+
| **[🔄 docs/ai-guide/PATTERNS.md](docs/ai-guide/PATTERNS.md)** | 标准工作流模式 |
|
|
90
|
+
| **[💬 docs/ai-guide/PROMPTS.md](docs/ai-guide/PROMPTS.md)** | 即用型提示词模板 |
|
|
91
|
+
| **[🔧 docs/ai-guide/INTEGRATION.md](docs/ai-guide/INTEGRATION.md)** | 集成指南、错误处理 |
|
|
92
|
+
| **[🛡️ AGENTS.md](AGENTS.md)** | 仓库级强约束、任务分级、代码红线 |
|
|
93
|
+
| **[⚡ CLAUDE.md](CLAUDE.md)** | AI 执行手册、验收清单 |
|
|
94
|
+
| **[🤖 docs/AI_ASSISTANT_SETUP.md](docs/AI_ASSISTANT_SETUP.md)** | AI 助手配置指引 |
|
|
95
|
+
| **[🛠️ docs/rules/engineering-with-codex-openai.md](docs/rules/engineering-with-codex-openai.md) | 面向 agent 的工程约束 |
|
|
96
|
+
|
|
97
|
+
**AI 快速入口**: `.cursorrules` | `.github/copilot-instructions.md`
|
|
58
98
|
|
|
59
99
|
## CLI 命令
|
|
60
100
|
|
|
61
|
-
### `
|
|
101
|
+
### `mycodemap init`
|
|
62
102
|
|
|
63
103
|
初始化项目的 CodeMap 配置文件。
|
|
64
104
|
|
|
65
105
|
```bash
|
|
66
|
-
|
|
67
|
-
|
|
106
|
+
mycodemap init # 交互式创建配置
|
|
107
|
+
mycodemap init -y # 使用默认配置直接创建
|
|
108
|
+
|
|
109
|
+
# 别名:codemap init 也可以使用
|
|
68
110
|
```
|
|
69
111
|
|
|
70
112
|
| 选项 | 说明 |
|
|
@@ -73,20 +115,22 @@ codemap init -y # 使用默认配置直接创建
|
|
|
73
115
|
|
|
74
116
|
执行后会在项目根目录生成 `codemap.config.json` 配置文件。
|
|
75
117
|
|
|
76
|
-
### `
|
|
118
|
+
### `mycodemap generate`
|
|
77
119
|
|
|
78
120
|
分析项目并生成代码地图文件。
|
|
79
121
|
|
|
80
122
|
```bash
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
123
|
+
mycodemap generate # 使用默认 hybrid 模式
|
|
124
|
+
mycodemap generate -m smart # 使用 smart 模式(AST 深度分析)
|
|
125
|
+
mycodemap generate -o ./docs/codemap # 指定输出目录
|
|
126
|
+
|
|
127
|
+
# 别名:codemap generate 也可以使用
|
|
84
128
|
```
|
|
85
129
|
|
|
86
130
|
| 选项 | 说明 | 默认值 |
|
|
87
131
|
|------|------|--------|
|
|
88
132
|
| `-m, --mode <mode>` | 分析模式:`fast`(正则匹配)、`smart`(TypeScript AST)或 `hybrid`(自动选择) | `hybrid` |
|
|
89
|
-
| `-o, --output <dir>` | 输出目录 | `.
|
|
133
|
+
| `-o, --output <dir>` | 输出目录 | `.mycodemap` |
|
|
90
134
|
| `--ai-context` | 为每个文件生成描述 | - |
|
|
91
135
|
|
|
92
136
|
**模式说明:**
|
|
@@ -97,37 +141,39 @@ codemap generate -o ./docs/codemap # 指定输出目录
|
|
|
97
141
|
| `smart` | 较慢 | 完整语义 | 深度分析、复杂度评估、类型推导 |
|
|
98
142
|
| `hybrid` | 自动 | 自适应 | **推荐** - 文件数<50用fast,≥50用smart |
|
|
99
143
|
|
|
100
|
-
### `
|
|
144
|
+
### `mycodemap watch`
|
|
101
145
|
|
|
102
146
|
监听文件变更并自动增量更新代码地图。
|
|
103
147
|
|
|
104
148
|
```bash
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
149
|
+
mycodemap watch # 前台运行
|
|
150
|
+
mycodemap watch -d # 以后台守护进程运行
|
|
151
|
+
mycodemap watch -s # 停止后台守护进程
|
|
152
|
+
mycodemap watch -t # 查看守护进程状态
|
|
153
|
+
mycodemap watch -m smart # 使用 smart 模式监听
|
|
110
154
|
```
|
|
111
155
|
|
|
112
156
|
| 选项 | 说明 | 默认值 |
|
|
113
157
|
|------|------|--------|
|
|
114
158
|
| `-m, --mode <mode>` | 分析模式 (fast/smart/hybrid) | `hybrid` |
|
|
115
|
-
| `-o, --output <dir>` | 输出目录 | `.
|
|
159
|
+
| `-o, --output <dir>` | 输出目录 | `.mycodemap` |
|
|
116
160
|
| `-d, --detach` | 以后台守护进程方式运行 | - |
|
|
117
161
|
| `-s, --stop` | 停止后台守护进程 | - |
|
|
118
162
|
| `-t, --status` | 查看后台守护进程状态 | - |
|
|
119
163
|
|
|
120
|
-
### `
|
|
164
|
+
### `mycodemap query`
|
|
121
165
|
|
|
122
166
|
查询代码地图中的符号、模块和依赖信息。
|
|
123
167
|
|
|
124
168
|
```bash
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
169
|
+
mycodemap query -s "ModuleInfo" # 精确查询符号
|
|
170
|
+
mycodemap query -m "src/parser" # 查询模块信息
|
|
171
|
+
mycodemap query -d "analyzer" # 查询依赖关系
|
|
172
|
+
mycodemap query -S "cache" # 模糊搜索
|
|
173
|
+
mycodemap query -S "parse" -j # JSON 格式输出
|
|
174
|
+
mycodemap query -S "plugin" -l 5 # 限制结果数量
|
|
175
|
+
|
|
176
|
+
# 别名:codemap query 也可以使用
|
|
131
177
|
```
|
|
132
178
|
|
|
133
179
|
| 选项 | 说明 | 默认值 |
|
|
@@ -136,17 +182,17 @@ codemap query -S "plugin" -l 5 # 限制结果数量
|
|
|
136
182
|
| `-m, --module <path>` | 查询模块信息 | - |
|
|
137
183
|
| `-d, --deps <name>` | 查询依赖关系 | - |
|
|
138
184
|
| `-S, --search <word>` | 模糊搜索 | - |
|
|
139
|
-
| `-l, --limit <number>` | 限制结果数量 | `
|
|
185
|
+
| `-l, --limit <number>` | 限制结果数量 | `50` |
|
|
140
186
|
| `-j, --json` | 以 JSON 格式输出 | - |
|
|
141
187
|
|
|
142
|
-
### `
|
|
188
|
+
### `mycodemap deps`
|
|
143
189
|
|
|
144
190
|
分析并输出模块的依赖关系树。
|
|
145
191
|
|
|
146
192
|
```bash
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
193
|
+
mycodemap deps # 查看所有模块的依赖统计
|
|
194
|
+
mycodemap deps -m "src/parser" # 查看指定模块的依赖树
|
|
195
|
+
mycodemap deps -m "src/parser" -j # JSON 格式输出
|
|
150
196
|
```
|
|
151
197
|
|
|
152
198
|
| 选项 | 说明 | 默认值 |
|
|
@@ -154,22 +200,22 @@ codemap deps -m "src/parser" -j # JSON 格式输出
|
|
|
154
200
|
| `-m, --module <path>` | 查询指定模块的依赖 | - |
|
|
155
201
|
| `-j, --json` | 以 JSON 格式输出 | - |
|
|
156
202
|
|
|
157
|
-
### `
|
|
203
|
+
### `mycodemap cycles`
|
|
158
204
|
|
|
159
205
|
检测项目中的循环依赖。
|
|
160
206
|
|
|
161
207
|
```bash
|
|
162
|
-
|
|
208
|
+
mycodemap cycles # 检测所有循环依赖
|
|
163
209
|
```
|
|
164
210
|
|
|
165
|
-
### `
|
|
211
|
+
### `mycodemap complexity`
|
|
166
212
|
|
|
167
213
|
分析代码复杂度,输出圈复杂度、认知复杂度和可维护性指数。
|
|
168
214
|
|
|
169
215
|
```bash
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
216
|
+
mycodemap complexity # 分析整个项目的复杂度
|
|
217
|
+
mycodemap complexity -f src/cli/index.ts # 分析指定文件的复杂度
|
|
218
|
+
mycodemap complexity -j # JSON 格式输出
|
|
173
219
|
```
|
|
174
220
|
|
|
175
221
|
| 选项 | 说明 | 默认值 |
|
|
@@ -177,14 +223,14 @@ codemap complexity -j # JSON 格式输出
|
|
|
177
223
|
| `-f, --file <path>` | 查看指定文件的复杂度 | - |
|
|
178
224
|
| `-j, --json` | 以 JSON 格式输出 | - |
|
|
179
225
|
|
|
180
|
-
### `
|
|
226
|
+
### `mycodemap impact`
|
|
181
227
|
|
|
182
228
|
评估指定文件或模块变更的影响范围。
|
|
183
229
|
|
|
184
230
|
```bash
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
231
|
+
mycodemap impact -f src/cli/index.ts # 分析指定文件的变更影响
|
|
232
|
+
mycodemap impact -f src/cli/index.ts --transitive # 包含传递依赖
|
|
233
|
+
mycodemap impact -f src/cli/index.ts -j # JSON 格式输出
|
|
188
234
|
```
|
|
189
235
|
|
|
190
236
|
| 选项 | 说明 | 默认值 |
|
|
@@ -193,6 +239,97 @@ codemap impact -f src/cli/index.ts -j # JSON 格式输出
|
|
|
193
239
|
| `-t, --transitive` | 包含传递依赖(间接影响) | - |
|
|
194
240
|
| `-j, --json` | 以 JSON 格式输出 | - |
|
|
195
241
|
|
|
242
|
+
### `mycodemap report`
|
|
243
|
+
|
|
244
|
+
生成代码地图分析报告,汇总分析结果和运行日志。
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
mycodemap report # 生成最近 7 天的报告
|
|
248
|
+
mycodemap report -d 14 # 生成最近 14 天的报告
|
|
249
|
+
mycodemap report -o ./reports # 指定输出目录
|
|
250
|
+
mycodemap report -v # 显示详细信息
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
| 选项 | 说明 | 默认值 |
|
|
254
|
+
|------|------|------|
|
|
255
|
+
| `-o, --output <dir>` | 输出目录 | `.mycodemap` |
|
|
256
|
+
| `-d, --days <number>` | 报告覆盖的天数 | `7` |
|
|
257
|
+
| `-j, --json` | JSON 格式输出 | - |
|
|
258
|
+
| `-v, --verbose` | 显示详细信息 | - |
|
|
259
|
+
|
|
260
|
+
### `mycodemap logs`
|
|
261
|
+
|
|
262
|
+
管理代码地图运行时日志(列出、导出、清理)。
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
# 列出日志
|
|
266
|
+
mycodemap logs list # 列出最近 10 条日志
|
|
267
|
+
mycodemap logs list -l 20 # 列出最近 20 条
|
|
268
|
+
mycodemap logs list --level ERROR # 仅列出错误日志
|
|
269
|
+
mycodemap logs list -j # JSON 格式输出
|
|
270
|
+
|
|
271
|
+
# 导出日志
|
|
272
|
+
mycodemap logs export # 导出最近 7 天的日志
|
|
273
|
+
mycodemap logs export -d 30 # 导出最近 30 天的日志
|
|
274
|
+
mycodemap logs export -o ./logs.zip # 指定导出文件
|
|
275
|
+
mycodemap logs export --format txt # 导出为文本格式
|
|
276
|
+
|
|
277
|
+
# 清理日志
|
|
278
|
+
mycodemap logs clear -d 30 --confirm # 清理 30 天前的日志
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
| 选项 | 说明 | 默认值 |
|
|
282
|
+
|------|------|------|
|
|
283
|
+
| `-l, --limit <number>` | 限制显示数量 | `10` |
|
|
284
|
+
| `--level <level>` | 按级别过滤 (`INFO`/`WARN`/`ERROR`/`DEBUG`) | - |
|
|
285
|
+
| `-j, --json` | JSON 格式输出 | - |
|
|
286
|
+
| `-o, --output <file>` | 导出文件路径 | - |
|
|
287
|
+
| `-d, --days <number>` | 天数 | 视子命令而定 |
|
|
288
|
+
| `--format <format>` | 导出格式 (`json`/`txt`) | `json` |
|
|
289
|
+
| `-c, --confirm` | 确认清理操作 | - |
|
|
290
|
+
|
|
291
|
+
### `mycodemap server` (MVP3)
|
|
292
|
+
|
|
293
|
+
启动 CodeMap HTTP API 服务器。
|
|
294
|
+
|
|
295
|
+
```bash
|
|
296
|
+
mycodemap server # 启动服务器 (默认端口 3000)
|
|
297
|
+
mycodemap server -p 8080 # 指定端口
|
|
298
|
+
mycodemap server -p 3000 --open # 自动打开浏览器
|
|
299
|
+
mycodemap server --cors # 启用 CORS
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
| 选项 | 说明 | 默认值 |
|
|
303
|
+
|------|------|--------|
|
|
304
|
+
| `-p, --port <number>` | 服务器端口 | `3000` |
|
|
305
|
+
| `-h, --host <string>` | 服务器主机 | `0.0.0.0` |
|
|
306
|
+
| `--cors` | 启用 CORS | `false` |
|
|
307
|
+
| `--open` | 自动打开浏览器 | `false` |
|
|
308
|
+
|
|
309
|
+
**API 端点:**
|
|
310
|
+
- `GET /api/v1/health` - 健康检查
|
|
311
|
+
- `GET /api/v1/stats` - 项目统计
|
|
312
|
+
- `GET /api/v1/search/symbols?q=` - 符号搜索
|
|
313
|
+
- `GET /api/v1/modules/:id` - 模块详情
|
|
314
|
+
- `POST /api/v1/analysis/impact` - 影响分析
|
|
315
|
+
- `GET /api/v1/export/:format` - 导出数据
|
|
316
|
+
|
|
317
|
+
### `mycodemap export` (MVP3)
|
|
318
|
+
|
|
319
|
+
导出代码图到各种格式。
|
|
320
|
+
|
|
321
|
+
```bash
|
|
322
|
+
mycodemap export json # 导出为 JSON
|
|
323
|
+
mycodemap export graphml # 导出为 GraphML (Gephi 兼容)
|
|
324
|
+
mycodemap export dot # 导出为 DOT (Graphviz)
|
|
325
|
+
mycodemap export mermaid # 导出为 Mermaid 语法
|
|
326
|
+
mycodemap export json -o ./out # 指定输出路径
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
| 选项 | 说明 | 默认值 |
|
|
330
|
+
|------|------|--------|
|
|
331
|
+
| `-o, --output <path>` | 输出文件路径 | 自动根据格式生成 |
|
|
332
|
+
|
|
196
333
|
## 工作流编排 (v2.5)
|
|
197
334
|
|
|
198
335
|
CodeMap v2.5 引入智能工作流编排系统,将复杂任务分解为 6 个有序阶段,每个阶段自动分析并传递上下文。
|
|
@@ -224,50 +361,50 @@ CodeMap v2.5 引入智能工作流编排系统,将复杂任务分解为 6 个
|
|
|
224
361
|
|
|
225
362
|
```bash
|
|
226
363
|
# 启动工作流
|
|
227
|
-
|
|
364
|
+
mycodemap workflow start "实现用户认证模块"
|
|
228
365
|
# 启动工作流并指定模板(会直接影响阶段推进顺序)
|
|
229
|
-
|
|
366
|
+
mycodemap workflow start "修复登录接口 500" --template bugfix
|
|
230
367
|
|
|
231
368
|
# 查看当前工作流状态
|
|
232
|
-
|
|
369
|
+
mycodemap workflow status
|
|
233
370
|
|
|
234
371
|
# 可视化当前工作流(支持 --timeline / --results)
|
|
235
|
-
|
|
372
|
+
mycodemap workflow visualize
|
|
236
373
|
|
|
237
374
|
# 推进到下一阶段
|
|
238
|
-
|
|
375
|
+
mycodemap workflow proceed
|
|
239
376
|
|
|
240
377
|
# 恢复当前活动工作流(可选传 workflow-id)
|
|
241
|
-
|
|
242
|
-
|
|
378
|
+
mycodemap workflow resume
|
|
379
|
+
mycodemap workflow resume <workflow-id>
|
|
243
380
|
|
|
244
381
|
# 创建检查点
|
|
245
|
-
|
|
382
|
+
mycodemap workflow checkpoint
|
|
246
383
|
|
|
247
384
|
# 列出所有工作流
|
|
248
|
-
|
|
385
|
+
mycodemap workflow list
|
|
249
386
|
|
|
250
387
|
# 删除工作流
|
|
251
|
-
|
|
388
|
+
mycodemap workflow delete <workflow-id>
|
|
252
389
|
|
|
253
390
|
# 模板管理
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
391
|
+
mycodemap workflow template list --all
|
|
392
|
+
mycodemap workflow template info bugfix
|
|
393
|
+
mycodemap workflow template apply bugfix
|
|
394
|
+
mycodemap workflow template recommend "紧急修复支付超时"
|
|
258
395
|
```
|
|
259
396
|
|
|
260
397
|
### 工作流使用示例
|
|
261
398
|
|
|
262
399
|
```bash
|
|
263
400
|
# 示例:实现新功能
|
|
264
|
-
$
|
|
401
|
+
$ mycodemap workflow start "添加缓存过期机制"
|
|
265
402
|
🚀 启动工作流: 添加缓存过期机制
|
|
266
403
|
📍 当前阶段: reference
|
|
267
404
|
|
|
268
405
|
# 系统会自动分析相关代码,生成参考搜索结果
|
|
269
406
|
# 确认后进入下一阶段
|
|
270
|
-
$
|
|
407
|
+
$ mycodemap workflow proceed
|
|
271
408
|
📍 进入阶段: impact
|
|
272
409
|
📊 影响范围: 3 个文件
|
|
273
410
|
- src/cache/lru-cache.ts
|
|
@@ -275,34 +412,34 @@ $ codemap workflow proceed
|
|
|
275
412
|
- src/cli/commands/query.ts
|
|
276
413
|
|
|
277
414
|
# 继续推进
|
|
278
|
-
$
|
|
415
|
+
$ mycodemap workflow proceed
|
|
279
416
|
📍 进入阶段: risk
|
|
280
417
|
⚠️ 风险等级: medium
|
|
281
418
|
- src/cache/lru-cache.ts: 近期频繁修改 (5次/30天)
|
|
282
419
|
|
|
283
420
|
# 实现代码后
|
|
284
|
-
$
|
|
421
|
+
$ mycodemap workflow proceed
|
|
285
422
|
📍 进入阶段: implementation
|
|
286
423
|
✅ 代码实现完成
|
|
287
424
|
|
|
288
425
|
# 提交前验证
|
|
289
|
-
$
|
|
426
|
+
$ mycodemap workflow proceed
|
|
290
427
|
📍 进入阶段: commit
|
|
291
428
|
✅ Commit 格式验证通过
|
|
292
429
|
|
|
293
430
|
# CI 验证
|
|
294
|
-
$
|
|
431
|
+
$ mycodemap workflow proceed
|
|
295
432
|
📍 进入阶段: ci
|
|
296
433
|
✅ 所有检查通过
|
|
297
434
|
🎉 工作流完成!
|
|
298
435
|
|
|
299
436
|
# 示例:模板会改变阶段推进顺序
|
|
300
|
-
$
|
|
301
|
-
$
|
|
437
|
+
$ mycodemap workflow start "修复线上缓存失效" --template bugfix
|
|
438
|
+
$ mycodemap workflow proceed --force
|
|
302
439
|
📍 下一阶段: implementation # bugfix 模板: reference -> implementation
|
|
303
440
|
|
|
304
441
|
# 示例:对当前活动工作流应用模板
|
|
305
|
-
$
|
|
442
|
+
$ mycodemap workflow template apply bugfix
|
|
306
443
|
Applied template: bugfix
|
|
307
444
|
Current phase: reference
|
|
308
445
|
```
|
|
@@ -312,17 +449,23 @@ Current phase: reference
|
|
|
312
449
|
CodeMap 提供 CI 阶段自动检查,确保代码质量。
|
|
313
450
|
|
|
314
451
|
```bash
|
|
452
|
+
# 检查 README / docs / CLI 示例是否与仓库事实同步
|
|
453
|
+
npm run docs:check
|
|
454
|
+
|
|
455
|
+
# 通过统一 CLI 护栏入口复用同一检查
|
|
456
|
+
mycodemap ci check-docs-sync
|
|
457
|
+
|
|
315
458
|
# 检查提交格式 ([TAG] scope: message)
|
|
316
|
-
|
|
459
|
+
mycodemap ci check-commits
|
|
317
460
|
|
|
318
461
|
# 检查文件头注释 ([META], [WHY])
|
|
319
|
-
|
|
462
|
+
mycodemap ci check-headers
|
|
320
463
|
|
|
321
464
|
# 评估变更风险
|
|
322
|
-
|
|
465
|
+
mycodemap ci assess-risk -f src/cache/lru-cache.ts
|
|
323
466
|
|
|
324
467
|
# 检查输出契约
|
|
325
|
-
|
|
468
|
+
mycodemap ci check-output-contract
|
|
326
469
|
```
|
|
327
470
|
|
|
328
471
|
## 配置说明
|
|
@@ -352,7 +495,7 @@ codemap ci check-output-contract
|
|
|
352
495
|
],
|
|
353
496
|
|
|
354
497
|
// 输出目录
|
|
355
|
-
"output": ".
|
|
498
|
+
"output": ".mycodemap"
|
|
356
499
|
}
|
|
357
500
|
```
|
|
358
501
|
|
|
@@ -361,11 +504,11 @@ codemap ci check-output-contract
|
|
|
361
504
|
| `mode` | `"fast" \| "smart"` | 分析模式 | `"fast"` |
|
|
362
505
|
| `include` | `string[]` | 包含的文件 glob 模式 | `["src/**/*.ts"]` |
|
|
363
506
|
| `exclude` | `string[]` | 排除的文件 glob 模式 | `["node_modules/**", "dist/**", ...]` |
|
|
364
|
-
| `output` | `string` | 输出目录路径 | `".
|
|
507
|
+
| `output` | `string` | 输出目录路径 | `".mycodemap"` |
|
|
365
508
|
|
|
366
509
|
## 输出文件说明
|
|
367
510
|
|
|
368
|
-
运行 `
|
|
511
|
+
运行 `mycodemap generate` 后,会在输出目录(默认 `.mycodemap/`)中生成以下文件:
|
|
369
512
|
|
|
370
513
|
### `AI_MAP.md`
|
|
371
514
|
|
|
@@ -397,82 +540,201 @@ codemap ci check-output-contract
|
|
|
397
540
|
|
|
398
541
|
独立的 Mermaid 依赖关系图文件,可在支持 Mermaid 的 Markdown 渲染器中直接预览。
|
|
399
542
|
|
|
400
|
-
##
|
|
543
|
+
## MVP3 分层架构
|
|
544
|
+
|
|
545
|
+
CodeMap 采用清晰的分层架构设计(MVP3),各层职责明确:
|
|
546
|
+
|
|
547
|
+
```
|
|
548
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
549
|
+
│ CLI Layer │
|
|
550
|
+
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │
|
|
551
|
+
│ │ server │ │ export │ │ 原有命令(generate..)│ │
|
|
552
|
+
│ └─────────────┘ └─────────────┘ └─────────────────────┘ │
|
|
553
|
+
├─────────────────────────────────────────────────────────────┤
|
|
554
|
+
│ Server Layer │
|
|
555
|
+
│ HTTP API / QueryHandler / AnalysisHandler │
|
|
556
|
+
├─────────────────────────────────────────────────────────────┤
|
|
557
|
+
│ Domain Layer │
|
|
558
|
+
│ Project / Module / Symbol / Dependency / CodeGraph │
|
|
559
|
+
├─────────────────────────────────────────────────────────────┤
|
|
560
|
+
│ Infrastructure Layer │
|
|
561
|
+
│ ┌──────────────────┐ ┌──────────────────┐ │
|
|
562
|
+
│ │ Storage │ │ Parser │ │
|
|
563
|
+
│ │ - FileSystem │ │ - TypeScript │ │
|
|
564
|
+
│ │ - Memory │ │ - Go │ │
|
|
565
|
+
│ │ - KùzuDB │ │ - Python │ │
|
|
566
|
+
│ │ - Neo4j │ │ - Registry │ │
|
|
567
|
+
│ └──────────────────┘ └──────────────────┘ │
|
|
568
|
+
│ ┌──────────────────┐ │
|
|
569
|
+
│ │ Repository │ CodeGraphRepositoryImpl │
|
|
570
|
+
│ └──────────────────┘ │
|
|
571
|
+
├─────────────────────────────────────────────────────────────┤
|
|
572
|
+
│ Interface Layer │
|
|
573
|
+
│ 类型定义与契约 (Types, ILanguageParser, IStorage) │
|
|
574
|
+
└─────────────────────────────────────────────────────────────┘
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
### 架构层说明
|
|
578
|
+
|
|
579
|
+
| 层级 | 路径 | 职责 | 关键组件 |
|
|
580
|
+
|------|------|------|----------|
|
|
581
|
+
| **CLI** | `src/cli/` | 命令行接口 | `server`, `export`, `generate` 命令 |
|
|
582
|
+
| **Server** | `src/server/` | HTTP API | `CodeMapServer`, `QueryHandler` |
|
|
583
|
+
| **Domain** | `src/domain/` | 核心业务逻辑 | `Project`, `Module`, `CodeGraph` |
|
|
584
|
+
| **Infrastructure** | `src/infrastructure/` | 技术实现 | `Storage`, `Parser`, `Repository` |
|
|
585
|
+
| **Interface** | `src/interface/` | 类型契约 | `types/`, `config/` |
|
|
586
|
+
|
|
587
|
+
### 项目目录结构
|
|
401
588
|
|
|
402
589
|
```
|
|
403
590
|
src/
|
|
404
|
-
├── cli/
|
|
405
|
-
│ ├──
|
|
406
|
-
│
|
|
407
|
-
│
|
|
408
|
-
│
|
|
409
|
-
│
|
|
410
|
-
│
|
|
411
|
-
│
|
|
412
|
-
|
|
413
|
-
├──
|
|
414
|
-
│
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
│
|
|
418
|
-
│
|
|
419
|
-
│
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
│ ├──
|
|
423
|
-
│ ├──
|
|
424
|
-
│
|
|
425
|
-
│ ├──
|
|
426
|
-
│ ├──
|
|
427
|
-
│ ├──
|
|
428
|
-
│
|
|
429
|
-
│
|
|
430
|
-
|
|
431
|
-
│ ├──
|
|
432
|
-
│
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
591
|
+
├── cli/ # CLI 命令入口 (原有 + MVP3 新增)
|
|
592
|
+
│ ├── commands/
|
|
593
|
+
│ │ ├── server.ts # MVP3: HTTP API 服务器
|
|
594
|
+
│ │ ├── export.ts # MVP3: 导出命令
|
|
595
|
+
│ │ ├── generate.ts # 生成代码地图
|
|
596
|
+
│ │ ├── query.ts # 查询命令
|
|
597
|
+
│ │ └── ... # 其他命令
|
|
598
|
+
│ └── index.ts
|
|
599
|
+
├── server/ # MVP3: HTTP API 服务器层
|
|
600
|
+
│ ├── CodeMapServer.ts # 主服务器类
|
|
601
|
+
│ ├── handlers/ # QueryHandler, AnalysisHandler
|
|
602
|
+
│ └── routes/ # API 路由
|
|
603
|
+
├── domain/ # MVP3: 领域层
|
|
604
|
+
│ ├── entities/ # Project, Module, Symbol, Dependency
|
|
605
|
+
│ ├── services/ # CodeGraphBuilder
|
|
606
|
+
│ ├── events/ # DomainEvent
|
|
607
|
+
│ └── repositories/ # 仓库接口
|
|
608
|
+
├── infrastructure/ # MVP3: 基础设施层
|
|
609
|
+
│ ├── storage/ # 存储适配器
|
|
610
|
+
│ │ ├── adapters/ # FileSystem, Memory, KùzuDB, Neo4j
|
|
611
|
+
│ │ └── StorageFactory.ts
|
|
612
|
+
│ ├── parser/ # 解析器
|
|
613
|
+
│ │ ├── interfaces/ # ParserBase
|
|
614
|
+
│ │ ├── implementations/# TypeScript, Go, Python
|
|
615
|
+
│ │ └── registry/ # ParserRegistry
|
|
616
|
+
│ └── repositories/ # 仓库实现
|
|
617
|
+
├── interface/ # MVP3: 接口层
|
|
618
|
+
│ ├── types/ # 核心类型定义
|
|
619
|
+
│ └── config/ # 配置类型
|
|
620
|
+
├── core/ # 核心分析引擎 (原有)
|
|
621
|
+
├── parser/ # 原有解析器 (逐步迁移到 infrastructure/parser)
|
|
622
|
+
├── orchestrator/ # 编排层 (v2.5)
|
|
623
|
+
└── ...
|
|
624
|
+
```
|
|
625
|
+
|
|
626
|
+
## AI 助手集成
|
|
627
|
+
|
|
628
|
+
MyCodeMap 可与多种 AI 编程助手深度集成,提供智能代码分析能力:
|
|
629
|
+
|
|
630
|
+
| AI 助手 | 配置方式 | 支持功能 |
|
|
631
|
+
|---------|----------|----------|
|
|
632
|
+
| **Kimi CLI** | Skill 配置 | 完整命令支持 |
|
|
633
|
+
| **Claude Code** | Skill 配置 | 完整命令支持 |
|
|
634
|
+
| **Codex CLI** | Agent 配置 | 完整命令支持 |
|
|
635
|
+
| **GitHub Copilot** | 提示词配置 | 基础查询支持 |
|
|
636
|
+
|
|
637
|
+
### 快速配置
|
|
638
|
+
|
|
639
|
+
```bash
|
|
640
|
+
# Kimi CLI
|
|
641
|
+
mkdir -p .kimi/skills/codemap
|
|
642
|
+
cp examples/kimi/codemap-skill.md .kimi/skills/codemap/SKILL.md
|
|
643
|
+
|
|
644
|
+
# Claude Code
|
|
645
|
+
mkdir -p .claude/skills/codemap
|
|
646
|
+
cp examples/claude/codemap-skill.md .claude/skills/codemap/SKILL.md
|
|
647
|
+
|
|
648
|
+
# Codex CLI
|
|
649
|
+
mkdir -p .agents/skills/codemap
|
|
650
|
+
cp examples/codex/codemap-agent.md .agents/skills/codemap/SKILL.md
|
|
461
651
|
```
|
|
462
652
|
|
|
653
|
+
详细配置请参考 [AI_ASSISTANT_SETUP.md](docs/AI_ASSISTANT_SETUP.md),设计与规则入口请先看 [docs/README.md](docs/README.md)。
|
|
654
|
+
|
|
463
655
|
## 新增 CLI 命令
|
|
464
656
|
|
|
465
|
-
### `
|
|
657
|
+
### `mycodemap analyze`
|
|
466
658
|
|
|
467
|
-
|
|
659
|
+
统一分析入口,支持多意图路由和结构化输出:
|
|
468
660
|
|
|
469
661
|
```bash
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
662
|
+
# 影响分析(查看文件变更影响范围)
|
|
663
|
+
mycodemap analyze -i impact -t src/cli/index.ts
|
|
664
|
+
mycodemap analyze -i impact -t src/cli/index.ts --scope transitive
|
|
665
|
+
mycodemap analyze -i impact -t src/cli/index.ts --include-tests
|
|
666
|
+
|
|
667
|
+
# 依赖分析
|
|
668
|
+
mycodemap analyze -i dependency -t src/cli/index.ts
|
|
669
|
+
|
|
670
|
+
# 项目概览
|
|
671
|
+
mycodemap analyze -i overview -t src/orchestrator
|
|
672
|
+
|
|
673
|
+
# 复杂度分析
|
|
674
|
+
mycodemap analyze -i complexity -t src/domain
|
|
675
|
+
|
|
676
|
+
# 搜索分析
|
|
677
|
+
mycodemap analyze -i search -k UnifiedResult
|
|
678
|
+
|
|
679
|
+
# 重构建议
|
|
680
|
+
mycodemap analyze -i refactor -t src/cache
|
|
681
|
+
|
|
682
|
+
# 引用查找
|
|
683
|
+
mycodemap analyze -i reference -t src/interface/types
|
|
684
|
+
|
|
685
|
+
# 文档生成
|
|
686
|
+
mycodemap analyze -i documentation -t src/domain/services
|
|
687
|
+
|
|
688
|
+
# 机器可读输出(JSON)
|
|
689
|
+
mycodemap analyze -i impact -t src/index.ts --json
|
|
690
|
+
mycodemap analyze -i impact -t src/index.ts --structured --json
|
|
474
691
|
```
|
|
475
692
|
|
|
693
|
+
| 选项 | 说明 | 默认值 |
|
|
694
|
+
|------|------|--------|
|
|
695
|
+
| `-i, --intent <type>` | 分析类型:`impact`/`dependency`/`search`/`documentation`/`complexity`/`overview`/`refactor`/`reference` | `impact` |
|
|
696
|
+
| `-t, --targets <paths...>` | 目标文件/模块路径(必填) | - |
|
|
697
|
+
| `-k, --keywords <words...>` | 搜索关键词(用于 search/documentation 意图) | - |
|
|
698
|
+
| `-s, --scope <scope>` | 范围:`direct`(直接)/`transitive`(传递) | `direct` |
|
|
699
|
+
| `-n, --topK <number>` | 返回结果数量 | `8` |
|
|
700
|
+
| `--include-tests` | 包含测试文件关联 | - |
|
|
701
|
+
| `--include-git-history` | 包含 Git 历史分析 | - |
|
|
702
|
+
| `--json` | JSON 格式输出 | - |
|
|
703
|
+
| `--structured` | 纯结构化输出(移除自然语言字段,配合 `--json` 使用) | - |
|
|
704
|
+
| `--output-mode <mode>` | 输出模式:`machine`/`human` | `human` |
|
|
705
|
+
|
|
706
|
+
### `mycodemap ci`
|
|
707
|
+
|
|
708
|
+
CI Gateway - 代码质量门禁工具:
|
|
709
|
+
|
|
710
|
+
```bash
|
|
711
|
+
# 验证提交格式([TAG] scope: message)
|
|
712
|
+
mycodemap ci check-commits
|
|
713
|
+
mycodemap ci check-commits -c 5
|
|
714
|
+
mycodemap ci check-commits -r origin/main..HEAD
|
|
715
|
+
|
|
716
|
+
# 验证文件头注释([META], [WHY])
|
|
717
|
+
mycodemap ci check-headers
|
|
718
|
+
mycodemap ci check-headers -d src/domain
|
|
719
|
+
mycodemap ci check-headers -f "src/index.ts,src/cli/index.ts"
|
|
720
|
+
|
|
721
|
+
# 评估变更风险
|
|
722
|
+
mycodemap ci assess-risk
|
|
723
|
+
mycodemap ci assess-risk -t 0.5
|
|
724
|
+
|
|
725
|
+
# 验证文档同步
|
|
726
|
+
mycodemap ci check-docs-sync
|
|
727
|
+
|
|
728
|
+
# 验证输出契约
|
|
729
|
+
mycodemap ci check-output-contract
|
|
730
|
+
|
|
731
|
+
# 检查提交文件数量(限制 10 个文件)
|
|
732
|
+
mycodemap ci check-commit-size
|
|
733
|
+
mycodemap ci check-commit-size -m 15
|
|
734
|
+
```
|
|
735
|
+
|
|
736
|
+
支持的提交 TAG 类型:`[REFACTOR]`, `[TEST]`, `[DOCS]`, `[FEAT]`, `[FIX]`, `[CHORE]`, `[PERF]`, `[SECURITY]`, `[BREAKING]`, `[HOTFIX]`, `[MIGRATION]`, `[WIP]`
|
|
737
|
+
|
|
476
738
|
## 贡献指南
|
|
477
739
|
|
|
478
740
|
欢迎提交 Issue 和 Pull Request!
|
|
@@ -498,6 +760,10 @@ npm test # 功能测试(src/**/*.test.ts)
|
|
|
498
760
|
npm run benchmark # 性能基准测试(refer/benchmark-quality.test.ts)
|
|
499
761
|
npm run test:all # 功能 + 基准(串联执行)
|
|
500
762
|
|
|
763
|
+
# 文档 / CLI 示例护栏
|
|
764
|
+
npm run docs:check
|
|
765
|
+
node dist/cli/index.js ci check-docs-sync
|
|
766
|
+
|
|
501
767
|
# 类型检查
|
|
502
768
|
npm run typecheck
|
|
503
769
|
|
|
@@ -545,7 +811,7 @@ DELETE 删除代码/文件
|
|
|
545
811
|
|
|
546
812
|
### 运行日志(调试追踪)
|
|
547
813
|
|
|
548
|
-
- CLI 运行日志默认写入 `.
|
|
814
|
+
- CLI 运行日志默认写入 `.mycodemap/logs/codemap-YYYY-MM-DD.log`
|
|
549
815
|
- 默认保留 14 天、最多保留 30 个日志文件(自动清理)
|
|
550
816
|
- 可通过环境变量调整:
|
|
551
817
|
- `CODEMAP_RUNTIME_LOG_ENABLED=false`:关闭运行日志
|