@mycodemap/mycodemap 0.1.1 → 0.3.4
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 +163 -0
- package/README.md +241 -67
- 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/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/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/ship/analyzer.d.ts +26 -0
- package/dist/cli/commands/ship/analyzer.d.ts.map +1 -0
- package/dist/cli/commands/ship/analyzer.js +143 -0
- package/dist/cli/commands/ship/analyzer.js.map +1 -0
- package/dist/cli/commands/ship/checker.d.ts +20 -0
- package/dist/cli/commands/ship/checker.d.ts.map +1 -0
- package/dist/cli/commands/ship/checker.js +86 -0
- package/dist/cli/commands/ship/checker.js.map +1 -0
- package/dist/cli/commands/ship/index.d.ts +17 -0
- package/dist/cli/commands/ship/index.d.ts.map +1 -0
- package/dist/cli/commands/ship/index.js +51 -0
- package/dist/cli/commands/ship/index.js.map +1 -0
- package/dist/cli/commands/ship/monitor.d.ts +19 -0
- package/dist/cli/commands/ship/monitor.d.ts.map +1 -0
- package/dist/cli/commands/ship/monitor.js +105 -0
- package/dist/cli/commands/ship/monitor.js.map +1 -0
- package/dist/cli/commands/ship/pipeline.d.ts +23 -0
- package/dist/cli/commands/ship/pipeline.d.ts.map +1 -0
- package/dist/cli/commands/ship/pipeline.js +146 -0
- package/dist/cli/commands/ship/pipeline.js.map +1 -0
- package/dist/cli/commands/ship/publisher.d.ts +11 -0
- package/dist/cli/commands/ship/publisher.d.ts.map +1 -0
- package/dist/cli/commands/ship/publisher.js +75 -0
- package/dist/cli/commands/ship/publisher.js.map +1 -0
- package/dist/cli/commands/ship/rules/confidence-rules.d.ts +48 -0
- package/dist/cli/commands/ship/rules/confidence-rules.d.ts.map +1 -0
- package/dist/cli/commands/ship/rules/confidence-rules.js +122 -0
- package/dist/cli/commands/ship/rules/confidence-rules.js.map +1 -0
- package/dist/cli/commands/ship/rules/quality-rules.d.ts +25 -0
- package/dist/cli/commands/ship/rules/quality-rules.d.ts.map +1 -0
- package/dist/cli/commands/ship/rules/quality-rules.js +134 -0
- package/dist/cli/commands/ship/rules/quality-rules.js.map +1 -0
- package/dist/cli/commands/ship/rules/version-rules.d.ts +24 -0
- package/dist/cli/commands/ship/rules/version-rules.d.ts.map +1 -0
- package/dist/cli/commands/ship/rules/version-rules.js +75 -0
- package/dist/cli/commands/ship/rules/version-rules.js.map +1 -0
- package/dist/cli/commands/ship/versioner.d.ts +12 -0
- package/dist/cli/commands/ship/versioner.d.ts.map +1 -0
- package/dist/cli/commands/ship/versioner.js +92 -0
- package/dist/cli/commands/ship/versioner.js.map +1 -0
- package/dist/cli/index.js +31 -1
- package/dist/cli/index.js.map +1 -1
- 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 +68 -0
- package/docs/PUBLISHING.md +472 -0
- package/docs/README.md +37 -0
- package/docs/SETUP_GUIDE.md +91 -5
- package/docs/ai-guide/COMMANDS.md +403 -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 +7 -1
- package/docs/archive/ARCHIVE.md +39 -0
- package/docs/archive/MYCLAUDE_GUIDE.md +305 -0
- package/docs/archive/PUBLISH_NPM_DESIGN_V1.md +6 -0
- package/docs/archive/PUBLISH_NPM_DESIGN_V2.md +6 -0
- package/docs/archive/README.md +29 -0
- package/docs/archive/TASK_DESIGN_COVERAGE_REPORT.md +6 -0
- package/docs/archive/TEST_SUMMARY.md +140 -0
- package/docs/archive/comprehensive_test_report.md +337 -0
- package/docs/{CI_GATEWAY_DESIGN.md → archive/design-docs/CI_GATEWAY_DESIGN.md} +6 -0
- package/docs/{PUBLISH_NPM_DESIGN_FINAL.md → archive/design-docs/PUBLISH_NPM_DESIGN_FINAL.md} +7 -1
- package/docs/{REFACTOR_ARCHITECTURE_OVERVIEW.md → archive/design-docs/REFACTOR_ARCHITECTURE_OVERVIEW.md} +8 -2
- package/docs/{REFACTOR_CONFIDENCE_DESIGN.md → archive/design-docs/REFACTOR_CONFIDENCE_DESIGN.md} +6 -0
- package/docs/{REFACTOR_GIT_ANALYZER_DESIGN.md → archive/design-docs/REFACTOR_GIT_ANALYZER_DESIGN.md} +8 -2
- package/docs/{REFACTOR_ORCHESTRATOR_DESIGN.md → archive/design-docs/REFACTOR_ORCHESTRATOR_DESIGN.md} +6 -0
- package/docs/{REFACTOR_RESULT_FUSION_DESIGN.md → archive/design-docs/REFACTOR_RESULT_FUSION_DESIGN.md} +6 -0
- package/docs/{REFACTOR_TEST_LINKER_DESIGN.md → archive/design-docs/REFACTOR_TEST_LINKER_DESIGN.md} +6 -0
- package/docs/archive/myclaude.md +1084 -0
- package/docs/archive/plans/2026-03-14-go-language-support-design.md +92 -0
- package/docs/{REFACTOR_REQUIREMENTS.md → archive/product-specs/REFACTOR_REQUIREMENTS.md} +11 -5
- package/docs/archive/scenario-2-deps-analysis.md +353 -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/{plans/POST_TASK_PLAN.md → exec-plans/completed/2026-03-03-post-task-plan.md} +9 -3
- 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/pre-release-checklist.md +426 -0
- package/docs/rules/testing.md +73 -0
- package/docs/rules/validation.md +39 -0
- package/package.json +26 -7
- package/scripts/.githooks/commit-msg +31 -0
- package/scripts/.githooks/pre-commit +55 -0
- package/scripts/benchmark.ts +209 -0
- package/scripts/hooks/commit-msg +24 -0
- package/scripts/hooks/install-hooks.sh +29 -0
- package/scripts/hooks/pre-commit +60 -0
- package/scripts/pre-release-check.js +717 -0
- package/scripts/release.sh +142 -0
- package/scripts/run-benchmark.sh +29 -0
- package/scripts/validate-ai-docs.js +294 -0
- package/scripts/validate-docs.js +238 -0
- package/scripts/validate-pack.js +86 -0
- package/dist/ai/claude.d.ts +0 -38
- package/dist/ai/claude.d.ts.map +0 -1
- package/dist/ai/claude.js +0 -169
- package/dist/ai/claude.js.map +0 -1
- package/dist/ai/codex.d.ts +0 -38
- package/dist/ai/codex.d.ts.map +0 -1
- package/dist/ai/codex.js +0 -169
- package/dist/ai/codex.js.map +0 -1
- package/dist/ai/factory.d.ts +0 -48
- package/dist/ai/factory.d.ts.map +0 -1
- package/dist/ai/factory.js +0 -95
- package/dist/ai/factory.js.map +0 -1
- package/dist/ai/index.d.ts +0 -12
- package/dist/ai/index.d.ts.map +0 -1
- package/dist/ai/index.js +0 -29
- package/dist/ai/index.js.map +0 -1
- package/dist/ai/provider.d.ts +0 -70
- package/dist/ai/provider.d.ts.map +0 -1
- package/dist/ai/provider.js +0 -31
- package/dist/ai/provider.js.map +0 -1
- package/dist/ai/subagent-caller.d.ts +0 -90
- package/dist/ai/subagent-caller.d.ts.map +0 -1
- package/dist/ai/subagent-caller.js +0 -280
- package/dist/ai/subagent-caller.js.map +0 -1
- package/dist/ai/types.d.ts +0 -70
- package/dist/ai/types.d.ts.map +0 -1
- package/dist/ai/types.js +0 -5
- package/dist/ai/types.js.map +0 -1
- package/dist/generator/ai-overview.d.ts +0 -51
- package/dist/generator/ai-overview.d.ts.map +0 -1
- package/dist/generator/ai-overview.js +0 -160
- package/dist/generator/ai-overview.js.map +0 -1
- package/dist/orchestrator/ai-feed-generator.d.ts +0 -210
- package/dist/orchestrator/ai-feed-generator.d.ts.map +0 -1
- package/dist/orchestrator/ai-feed-generator.js +0 -377
- package/dist/orchestrator/ai-feed-generator.js.map +0 -1
- package/docs/OMC_TEAM_DEBUG_REPORT.md +0 -285
- /package/docs/{plans/archive → exec-plans/completed}/2026-03-03-deps-path-extension-fix.md +0 -0
|
@@ -0,0 +1,513 @@
|
|
|
1
|
+
# AI Guide - 集成与错误处理
|
|
2
|
+
|
|
3
|
+
> 与 AI 工作流的集成方式和常见错误处理
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 与 AI 工作流的集成
|
|
8
|
+
|
|
9
|
+
### MCP (Model Context Protocol) 集成
|
|
10
|
+
|
|
11
|
+
将 CodeMap 注册为 MCP 工具:
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"tools": [
|
|
16
|
+
{
|
|
17
|
+
"name": "codemap_generate",
|
|
18
|
+
"description": "生成代码地图,必须在其他命令之前执行",
|
|
19
|
+
"command": "mycodemap generate",
|
|
20
|
+
"timeout": 60000
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "codemap_query_symbol",
|
|
24
|
+
"description": "查询符号定义位置",
|
|
25
|
+
"command": "mycodemap query -s {symbol} -j",
|
|
26
|
+
"parameters": {
|
|
27
|
+
"symbol": { "type": "string", "description": "符号名称" }
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"name": "codemap_analyze_impact",
|
|
32
|
+
"description": "分析文件变更的影响范围",
|
|
33
|
+
"command": "mycodemap analyze -i impact -t {target} --json",
|
|
34
|
+
"parameters": {
|
|
35
|
+
"target": { "type": "string", "description": "目标文件路径" }
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"name": "codemap_search",
|
|
40
|
+
"description": "搜索与关键词相关的代码",
|
|
41
|
+
"command": "mycodemap analyze -i search -k {keyword} --json",
|
|
42
|
+
"parameters": {
|
|
43
|
+
"keyword": { "type": "string", "description": "搜索关键词" }
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"name": "codemap_check_ci",
|
|
48
|
+
"description": "执行 CI 门禁检查",
|
|
49
|
+
"command": "mycodemap ci {check_type}",
|
|
50
|
+
"parameters": {
|
|
51
|
+
"check_type": {
|
|
52
|
+
"type": "string",
|
|
53
|
+
"enum": ["check-commits", "check-headers", "assess-risk"],
|
|
54
|
+
"description": "检查类型"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
### Skill/Knowledge 集成
|
|
65
|
+
|
|
66
|
+
#### Kimi CLI Skill
|
|
67
|
+
|
|
68
|
+
```markdown
|
|
69
|
+
---
|
|
70
|
+
name: codemap
|
|
71
|
+
description: CodeMap 代码分析工具,用于项目结构分析、符号查询、依赖分析和影响评估
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## 环境检测
|
|
75
|
+
|
|
76
|
+
首先检测 CLI 是否可用:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
if command -v mycodemap &> /dev/null; then
|
|
80
|
+
CODEMAP="mycodemap"
|
|
81
|
+
elif [ -f "./node_modules/.bin/mycodemap" ]; then
|
|
82
|
+
CODEMAP="./node_modules/.bin/mycodemap"
|
|
83
|
+
else
|
|
84
|
+
CODEMAP="npx @mycodemap/mycodemap"
|
|
85
|
+
fi
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## 使用原则
|
|
89
|
+
|
|
90
|
+
1. **首次使用必须先执行 generate**
|
|
91
|
+
```bash
|
|
92
|
+
$CODEMAP generate
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
2. **查询符号定义**
|
|
96
|
+
```bash
|
|
97
|
+
$CODEMAP query -s "SymbolName" -j
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
3. **分析变更影响**
|
|
101
|
+
```bash
|
|
102
|
+
$CODEMAP analyze -i impact -t "file.ts" --transitive --json
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
4. **搜索代码**
|
|
106
|
+
```bash
|
|
107
|
+
$CODEMAP analyze -i search -k "keyword" --json
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## 完整文档
|
|
111
|
+
|
|
112
|
+
参考项目根目录的 `AI_GUIDE.md` 和 `docs/ai-guide/` 目录。
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
#### Claude Code Skill
|
|
116
|
+
|
|
117
|
+
```markdown
|
|
118
|
+
# CodeMap Code Analysis
|
|
119
|
+
|
|
120
|
+
## Overview
|
|
121
|
+
|
|
122
|
+
Use CodeMap CLI for TypeScript/JavaScript project analysis.
|
|
123
|
+
|
|
124
|
+
## Commands
|
|
125
|
+
|
|
126
|
+
### Generate Code Map (Required First Step)
|
|
127
|
+
```bash
|
|
128
|
+
mycodemap generate
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Query Symbol
|
|
132
|
+
```bash
|
|
133
|
+
mycodemap query -s "SymbolName" -j
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Analyze Impact
|
|
137
|
+
```bash
|
|
138
|
+
mycodemap analyze -i impact -t "file.ts" --transitive --json
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Search Code
|
|
142
|
+
```bash
|
|
143
|
+
mycodemap analyze -i search -k "keyword" --json
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Decision Tree
|
|
147
|
+
|
|
148
|
+
1. Understanding project structure → `generate` + read `AI_MAP.md`
|
|
149
|
+
2. Finding symbol location → `query -s`
|
|
150
|
+
3. Assessing change impact → `analyze -i impact`
|
|
151
|
+
4. Searching related code → `analyze -i search`
|
|
152
|
+
|
|
153
|
+
## Reference
|
|
154
|
+
|
|
155
|
+
See `AI_GUIDE.md` in project root for complete documentation.
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
#### Codex CLI Agent
|
|
159
|
+
|
|
160
|
+
```markdown
|
|
161
|
+
# CodeMap Agent
|
|
162
|
+
|
|
163
|
+
## Description
|
|
164
|
+
|
|
165
|
+
Code analysis tool for TypeScript projects.
|
|
166
|
+
|
|
167
|
+
## Available Tools
|
|
168
|
+
|
|
169
|
+
- `codemap_generate`: Generate code map
|
|
170
|
+
- `codemap_query`: Query symbols
|
|
171
|
+
- `codemap_impact`: Analyze change impact
|
|
172
|
+
- `codemap_search`: Search code
|
|
173
|
+
|
|
174
|
+
## Workflow
|
|
175
|
+
|
|
176
|
+
1. Always start with `codemap_generate`
|
|
177
|
+
2. Use `codemap_query` to find definitions
|
|
178
|
+
3. Use `codemap_impact` before making changes
|
|
179
|
+
4. Use `codemap_search` to find related code
|
|
180
|
+
|
|
181
|
+
## Documentation
|
|
182
|
+
|
|
183
|
+
Full guide: `AI_GUIDE.md`
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## 错误处理
|
|
189
|
+
|
|
190
|
+
### 常见错误及处理
|
|
191
|
+
|
|
192
|
+
| 错误 | 原因 | 解决方案 |
|
|
193
|
+
|------|------|----------|
|
|
194
|
+
| `代码地图不存在,请先运行 codemap generate` | 未生成代码地图 | 执行 `mycodemap generate` |
|
|
195
|
+
| `符号未找到` | 拼写错误或不存在 | 使用 `query -S` 模糊搜索 |
|
|
196
|
+
| `模块未找到` | 路径错误或已删除 | 检查路径或使用 `query -m` 部分匹配 |
|
|
197
|
+
| `tree-sitter 不可用` | 原生模块未编译 | 安装构建工具后重新安装 |
|
|
198
|
+
| `文件头缺少 [META]` | 新文件未加头 | 添加标准文件头注释 |
|
|
199
|
+
| `提交格式错误` | 不符合 [TAG] 格式 | 修改为 `[TAG] scope: message` |
|
|
200
|
+
| `风险评分过高` | 变更文件太多 | 拆分提交或添加解释 |
|
|
201
|
+
| `输出契约验证失败` | analyze 输出格式变更 | 检查 schemaVersion 和字段 |
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
### 错误处理代码模式
|
|
206
|
+
|
|
207
|
+
#### TypeScript
|
|
208
|
+
|
|
209
|
+
```typescript
|
|
210
|
+
// 模式 1: 代码地图过期/不存在
|
|
211
|
+
async function ensureCodeMap(): Promise<boolean> {
|
|
212
|
+
const codemapPath = '.mycodemap/codemap.json';
|
|
213
|
+
|
|
214
|
+
if (!existsSync(codemapPath)) {
|
|
215
|
+
console.log('代码地图不存在,正在生成...');
|
|
216
|
+
await exec('mycodemap generate');
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// 检查是否过期(超过 1 小时)
|
|
221
|
+
const stat = statSync(codemapPath);
|
|
222
|
+
const age = Date.now() - stat.mtimeMs;
|
|
223
|
+
if (age > 3600000) {
|
|
224
|
+
console.log('代码地图已过期,正在更新...');
|
|
225
|
+
await exec('mycodemap generate');
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// 模式 2: 查询无结果,逐级回退
|
|
232
|
+
async function findSymbol(symbolName: string): Promise<any[]> {
|
|
233
|
+
// 尝试 1: 精确查询
|
|
234
|
+
let result = await exec(`mycodemap query -s "${symbolName}" -j`);
|
|
235
|
+
let data = JSON.parse(result);
|
|
236
|
+
|
|
237
|
+
if (data.count > 0) {
|
|
238
|
+
return data.results;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// 尝试 2: 模糊搜索
|
|
242
|
+
console.log('精确查询无结果,尝试模糊搜索...');
|
|
243
|
+
result = await exec(`mycodemap query -S "${symbolName}" -l 20 -j`);
|
|
244
|
+
data = JSON.parse(result);
|
|
245
|
+
|
|
246
|
+
if (data.count > 0) {
|
|
247
|
+
return data.results;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// 尝试 3: 统一搜索
|
|
251
|
+
console.log('模糊搜索无结果,尝试统一搜索...');
|
|
252
|
+
result = await exec(`mycodemap analyze -i search -k "${symbolName}" --topK 20 --json`);
|
|
253
|
+
data = JSON.parse(result);
|
|
254
|
+
|
|
255
|
+
return data.results || [];
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// 模式 3: 影响范围太大,缩小范围
|
|
259
|
+
async function analyzeImpact(file: string, maxFiles: number = 50): Promise<any> {
|
|
260
|
+
// 先尝试不包含传递依赖
|
|
261
|
+
let result = await exec(`mycodemap impact -f "${file}" -j`);
|
|
262
|
+
let data = JSON.parse(result);
|
|
263
|
+
|
|
264
|
+
const totalFiles = (data.direct?.length || 0) + (data.transitive?.length || 0);
|
|
265
|
+
|
|
266
|
+
if (totalFiles > maxFiles) {
|
|
267
|
+
console.warn(`影响范围过大 (${totalFiles} 个文件),仅返回直接依赖`);
|
|
268
|
+
return {
|
|
269
|
+
...data,
|
|
270
|
+
transitive: [],
|
|
271
|
+
warning: '影响范围过大,仅显示直接依赖'
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
return data;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// 模式 4: 置信度太低,扩大搜索
|
|
279
|
+
async function searchWithFallback(keyword: string): Promise<any[]> {
|
|
280
|
+
let result = await exec(`mycodemap analyze -i search -k "${keyword}" --topK 8 --json`);
|
|
281
|
+
let data = JSON.parse(result);
|
|
282
|
+
|
|
283
|
+
if (data.confidence?.level === 'low') {
|
|
284
|
+
console.log('置信度较低,扩大搜索范围...');
|
|
285
|
+
result = await exec(`mycodemap analyze -i search -k "${keyword}" --topK 20 --json`);
|
|
286
|
+
data = JSON.parse(result);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
return data.results || [];
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// 模式 5: 安全的 JSON 解析
|
|
293
|
+
function safeParseJSON<T>(json: string, defaultValue: T): T {
|
|
294
|
+
try {
|
|
295
|
+
return JSON.parse(json) as T;
|
|
296
|
+
} catch {
|
|
297
|
+
console.error('JSON 解析失败,使用默认值');
|
|
298
|
+
return defaultValue;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
#### Python
|
|
304
|
+
|
|
305
|
+
```python
|
|
306
|
+
import json
|
|
307
|
+
import subprocess
|
|
308
|
+
import os
|
|
309
|
+
from typing import List, Dict, Any, Optional
|
|
310
|
+
|
|
311
|
+
def ensure_code_map() -> bool:
|
|
312
|
+
"""确保代码地图存在"""
|
|
313
|
+
codemap_path = '.mycodemap/codemap.json'
|
|
314
|
+
|
|
315
|
+
if not os.path.exists(codemap_path):
|
|
316
|
+
print('代码地图不存在,正在生成...')
|
|
317
|
+
subprocess.run(['mycodemap', 'generate'], check=True)
|
|
318
|
+
return True
|
|
319
|
+
|
|
320
|
+
# 检查是否过期(超过 1 小时)
|
|
321
|
+
import time
|
|
322
|
+
mtime = os.path.getmtime(codemap_path)
|
|
323
|
+
if time.time() - mtime > 3600:
|
|
324
|
+
print('代码地图已过期,正在更新...')
|
|
325
|
+
subprocess.run(['mycodemap', 'generate'], check=True)
|
|
326
|
+
|
|
327
|
+
return True
|
|
328
|
+
|
|
329
|
+
def find_symbol(symbol_name: str) -> List[Dict[str, Any]]:
|
|
330
|
+
"""查找符号,逐级回退"""
|
|
331
|
+
# 尝试 1: 精确查询
|
|
332
|
+
result = subprocess.run(
|
|
333
|
+
['mycodemap', 'query', '-s', symbol_name, '-j'],
|
|
334
|
+
capture_output=True, text=True
|
|
335
|
+
)
|
|
336
|
+
data = json.loads(result.stdout)
|
|
337
|
+
|
|
338
|
+
if data.get('count', 0) > 0:
|
|
339
|
+
return data['results']
|
|
340
|
+
|
|
341
|
+
# 尝试 2: 模糊搜索
|
|
342
|
+
print('精确查询无结果,尝试模糊搜索...')
|
|
343
|
+
result = subprocess.run(
|
|
344
|
+
['mycodemap', 'query', '-S', symbol_name, '-l', '20', '-j'],
|
|
345
|
+
capture_output=True, text=True
|
|
346
|
+
)
|
|
347
|
+
data = json.loads(result.stdout)
|
|
348
|
+
|
|
349
|
+
if data.get('count', 0) > 0:
|
|
350
|
+
return data['results']
|
|
351
|
+
|
|
352
|
+
# 尝试 3: 统一搜索
|
|
353
|
+
print('模糊搜索无结果,尝试统一搜索...')
|
|
354
|
+
result = subprocess.run(
|
|
355
|
+
['mycodemap', 'analyze', '-i', 'search', '-k', symbol_name, '--topK', '20', '--json'],
|
|
356
|
+
capture_output=True, text=True
|
|
357
|
+
)
|
|
358
|
+
data = json.loads(result.stdout)
|
|
359
|
+
|
|
360
|
+
return data.get('results', [])
|
|
361
|
+
|
|
362
|
+
def safe_parse_json(json_str: str, default_value: Any) -> Any:
|
|
363
|
+
"""安全的 JSON 解析"""
|
|
364
|
+
try:
|
|
365
|
+
return json.loads(json_str)
|
|
366
|
+
except json.JSONDecodeError:
|
|
367
|
+
print('JSON 解析失败,使用默认值')
|
|
368
|
+
return default_value
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
---
|
|
372
|
+
|
|
373
|
+
### 边界情况处理
|
|
374
|
+
|
|
375
|
+
```typescript
|
|
376
|
+
// 情况 1: 大项目处理
|
|
377
|
+
async function handleLargeProject() {
|
|
378
|
+
// 使用 fast 模式
|
|
379
|
+
await exec('mycodemap generate -m fast');
|
|
380
|
+
|
|
381
|
+
// 分块查询
|
|
382
|
+
const modules = ['src/cli', 'src/core', 'src/domain'];
|
|
383
|
+
for (const module of modules) {
|
|
384
|
+
await exec(`mycodemap analyze -i overview -t "${module}" --json`);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// 情况 2: 并发查询控制
|
|
389
|
+
async function batchQuery(symbols: string[], concurrency: number = 5) {
|
|
390
|
+
const results = [];
|
|
391
|
+
for (let i = 0; i < symbols.length; i += concurrency) {
|
|
392
|
+
const batch = symbols.slice(i, i + concurrency);
|
|
393
|
+
const batchResults = await Promise.all(
|
|
394
|
+
batch.map(s => exec(`mycodemap query -s "${s}" -j`).catch(() => null))
|
|
395
|
+
);
|
|
396
|
+
results.push(...batchResults.filter(Boolean));
|
|
397
|
+
}
|
|
398
|
+
return results;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// 情况 3: 超时处理
|
|
402
|
+
async function execWithTimeout(command: string, timeoutMs: number = 30000) {
|
|
403
|
+
return new Promise((resolve, reject) => {
|
|
404
|
+
const child = exec(command, (err, stdout) => {
|
|
405
|
+
if (err) reject(err);
|
|
406
|
+
else resolve(stdout);
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
setTimeout(() => {
|
|
410
|
+
child.kill();
|
|
411
|
+
reject(new Error('Command timeout'));
|
|
412
|
+
}, timeoutMs);
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
---
|
|
418
|
+
|
|
419
|
+
## 性能优化
|
|
420
|
+
|
|
421
|
+
### 缓存策略
|
|
422
|
+
|
|
423
|
+
```typescript
|
|
424
|
+
// 利用 CodeMap 内置缓存(60秒 TTL)
|
|
425
|
+
// 第一次查询后,后续查询会自动使用缓存
|
|
426
|
+
|
|
427
|
+
// 如果需要清除缓存
|
|
428
|
+
function clearCodeMapCache() {
|
|
429
|
+
// 删除索引缓存文件
|
|
430
|
+
const cacheDir = '.mycodemap/cache';
|
|
431
|
+
if (existsSync(cacheDir)) {
|
|
432
|
+
rmSync(cacheDir, { recursive: true });
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
### 批量处理
|
|
438
|
+
|
|
439
|
+
```typescript
|
|
440
|
+
// 不好的做法:串行执行
|
|
441
|
+
for (const file of files) {
|
|
442
|
+
await exec(`mycodemap impact -f "${file}"`);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
// 好的做法:先生成,再批量查询
|
|
446
|
+
await exec('mycodemap generate');
|
|
447
|
+
const results = await Promise.all(
|
|
448
|
+
files.map(f => exec(`mycodemap impact -f "${f}" -j`))
|
|
449
|
+
);
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
---
|
|
453
|
+
|
|
454
|
+
## 安全注意事项
|
|
455
|
+
|
|
456
|
+
1. **命令注入防护**: 始终对用户输入进行转义
|
|
457
|
+
```typescript
|
|
458
|
+
const safeSymbol = symbolName.replace(/["'`]/g, '');
|
|
459
|
+
await exec(`mycodemap query -s "${safeSymbol}"`);
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
2. **路径遍历防护**: 验证文件路径
|
|
463
|
+
```typescript
|
|
464
|
+
if (!filePath.startsWith('src/')) {
|
|
465
|
+
throw new Error('Invalid path');
|
|
466
|
+
}
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
3. **敏感信息**: 输出中可能包含文件路径,注意隐私
|
|
470
|
+
|
|
471
|
+
---
|
|
472
|
+
|
|
473
|
+
## 故障排除
|
|
474
|
+
|
|
475
|
+
### CLI 未找到
|
|
476
|
+
|
|
477
|
+
```bash
|
|
478
|
+
# 检查安装
|
|
479
|
+
which mycodemap || echo "未安装"
|
|
480
|
+
|
|
481
|
+
# 解决方案 1: 全局安装
|
|
482
|
+
npm install -g @mycodemap/mycodemap
|
|
483
|
+
|
|
484
|
+
# 解决方案 2: 使用 npx
|
|
485
|
+
alias mycodemap='npx @mycodemap/mycodemap'
|
|
486
|
+
|
|
487
|
+
# 解决方案 3: 本地安装
|
|
488
|
+
npm install --save-dev @mycodemap/mycodemap
|
|
489
|
+
./node_modules/.bin/mycodemap
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
### tree-sitter 构建失败
|
|
493
|
+
|
|
494
|
+
```bash
|
|
495
|
+
# Ubuntu/Debian
|
|
496
|
+
sudo apt-get install build-essential
|
|
497
|
+
|
|
498
|
+
# macOS
|
|
499
|
+
xcode-select --install
|
|
500
|
+
|
|
501
|
+
# 然后重新安装
|
|
502
|
+
npm rebuild
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
### 代码地图过期
|
|
506
|
+
|
|
507
|
+
```bash
|
|
508
|
+
# 强制重新生成
|
|
509
|
+
mycodemap generate --force
|
|
510
|
+
|
|
511
|
+
# 或使用 watch 模式自动更新
|
|
512
|
+
mycodemap watch
|
|
513
|
+
```
|