@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
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
# CodeMap 符号搜索对比测试报告
|
|
2
|
+
|
|
3
|
+
## 测试概述
|
|
4
|
+
|
|
5
|
+
**测试目标**: 对比 `codemap query -s/-S` 与 `grep/rg` 在搜索代码符号时的差异
|
|
6
|
+
|
|
7
|
+
**测试环境**: /data/codemap 目录
|
|
8
|
+
|
|
9
|
+
**测试时间**: 2026-03-02
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 测试场景1: 精确搜索符号 "ModuleInfo"
|
|
14
|
+
|
|
15
|
+
### 测试目的
|
|
16
|
+
搜索项目中广泛使用的类型名称 "ModuleInfo",对比各工具的精确匹配能力。
|
|
17
|
+
|
|
18
|
+
### CodeMap 执行
|
|
19
|
+
```bash
|
|
20
|
+
npx codemap query -s "ModuleInfo"
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**输出:**
|
|
24
|
+
```
|
|
25
|
+
🔍 查询 "ModuleInfo" (symbol)
|
|
26
|
+
找到 5 个结果
|
|
27
|
+
|
|
28
|
+
moduleInfo
|
|
29
|
+
类型: variable
|
|
30
|
+
路径: /data/codemap/src/core/analyzer.ts
|
|
31
|
+
定义于 src/core/analyzer.ts:55
|
|
32
|
+
|
|
33
|
+
moduleInfo
|
|
34
|
+
类型: variable
|
|
35
|
+
路径: /data/codemap/src/core/analyzer.ts
|
|
36
|
+
定义于 src/core/analyzer.ts:63
|
|
37
|
+
|
|
38
|
+
moduleInfo
|
|
39
|
+
类型: variable
|
|
40
|
+
路径: /data/codemap/src/core/analyzer.ts
|
|
41
|
+
定义于 src/core/analyzer.ts:76
|
|
42
|
+
|
|
43
|
+
ModuleInfo
|
|
44
|
+
类型: interface
|
|
45
|
+
路径: /data/codemap/src/types/index.ts
|
|
46
|
+
导出于 src/types/index.ts
|
|
47
|
+
|
|
48
|
+
ModuleInfo
|
|
49
|
+
类型: interface
|
|
50
|
+
路径: /data/codemap/src/types/index.ts
|
|
51
|
+
定义于 src/types/index.ts:154
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**执行时间**: 0.538s (real)
|
|
55
|
+
|
|
56
|
+
### rg 执行
|
|
57
|
+
```bash
|
|
58
|
+
rg -n "ModuleInfo" src/
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**输出:** (共找到 82 处匹配,以下为部分示例)
|
|
62
|
+
```
|
|
63
|
+
src/parser/index.ts:8:import type { ModuleInfo, ImportInfo, ExportInfo, ModuleSymbol, SymbolKind, DecoratorInfo } from '../types/index.js';
|
|
64
|
+
src/parser/index.ts:60:export async function parseFile(filePath: string): Promise<ModuleInfo> {
|
|
65
|
+
src/core/analyzer.ts:5:import type { CodeMap, AnalysisOptions, ModuleInfo, DependencyGraph, ProjectInfo, ProjectSummary } from '../types/index.js';
|
|
66
|
+
src/core/analyzer.ts:43: const modules: ModuleInfo[] = [];
|
|
67
|
+
src/types/index.ts:154:export interface ModuleInfo {
|
|
68
|
+
src/cache/index.ts:10:import type { ModuleInfo } from '../types/index.js';
|
|
69
|
+
...
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**执行时间**: 0.008s (real)
|
|
73
|
+
|
|
74
|
+
### grep 执行
|
|
75
|
+
```bash
|
|
76
|
+
grep -rn "ModuleInfo" src/
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**输出:** (与 rg 类似,共 82 处匹配)
|
|
80
|
+
|
|
81
|
+
**执行时间**: 0.003s (real)
|
|
82
|
+
|
|
83
|
+
### 对比分析
|
|
84
|
+
|
|
85
|
+
| 维度 | CodeMap | rg | grep |
|
|
86
|
+
|------|---------|-----|------|
|
|
87
|
+
| **速度** | 0.538s | 0.008s | 0.003s |
|
|
88
|
+
| **结果数量** | 5 个符号定义 | 82 处匹配 | 82 处匹配 |
|
|
89
|
+
| **准确性** | 仅返回符号定义和导出 | 返回所有文本匹配 | 返回所有文本匹配 |
|
|
90
|
+
| **符号类型识别** | ✅ 是 (interface, variable) | ❌ 否 | ❌ 否 |
|
|
91
|
+
| **导出信息** | ✅ 显示导出位置 | ❌ 否 | ❌ 否 |
|
|
92
|
+
| **可读性** | 结构化,带类型标签 | 纯文本行 | 纯文本行 |
|
|
93
|
+
|
|
94
|
+
### 发现的问题
|
|
95
|
+
|
|
96
|
+
1. **CodeMap 速度较慢**: CodeMap 比 rg 慢约 67 倍,比 grep 慢约 179 倍
|
|
97
|
+
2. **CodeMap 结果不完整**: CodeMap 只返回 5 个结果,而 rg/grep 返回 82 处匹配
|
|
98
|
+
3. **CodeMap 区分大小写问题**: 搜索 "ModuleInfo" 时,变量名 "moduleInfo"(小写)也被返回,但可能并非用户期望的精确匹配
|
|
99
|
+
4. **rg/grep 缺乏语义**: 无法区分类型定义、变量声明和普通文本引用
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## 测试场景2: 模糊搜索 "cache"
|
|
104
|
+
|
|
105
|
+
### 测试目的
|
|
106
|
+
使用模糊搜索查找与 "cache" 相关的符号,对比各工具的模糊匹配能力。
|
|
107
|
+
|
|
108
|
+
### CodeMap 执行
|
|
109
|
+
```bash
|
|
110
|
+
npx codemap query -S "cache"
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**输出:**
|
|
114
|
+
```
|
|
115
|
+
🔍 查询 "cache" (search)
|
|
116
|
+
找到 20 个结果
|
|
117
|
+
|
|
118
|
+
cached
|
|
119
|
+
类型: variable
|
|
120
|
+
路径: /data/codemap/src/ai/factory.ts
|
|
121
|
+
定义于 src/ai/factory.ts:25
|
|
122
|
+
|
|
123
|
+
clearCache
|
|
124
|
+
类型: method
|
|
125
|
+
路径: /data/codemap/src/ai/factory.ts
|
|
126
|
+
定义于 src/ai/factory.ts:95
|
|
127
|
+
|
|
128
|
+
src/cache/file-hash-cache.ts
|
|
129
|
+
类型: module
|
|
130
|
+
路径: /data/codemap/src/cache/file-hash-cache.ts
|
|
131
|
+
模块匹配
|
|
132
|
+
|
|
133
|
+
FileHashCache
|
|
134
|
+
类型: export (class)
|
|
135
|
+
路径: /data/codemap/src/cache/file-hash-cache.ts
|
|
136
|
+
导出于 src/cache/file-hash-cache.ts
|
|
137
|
+
|
|
138
|
+
generateCacheKey
|
|
139
|
+
类型: export (function)
|
|
140
|
+
路径: /data/codemap/src/cache/file-hash-cache.ts
|
|
141
|
+
导出于 src/cache/file-hash-cache.ts
|
|
142
|
+
|
|
143
|
+
parseCacheKey
|
|
144
|
+
类型: export (function)
|
|
145
|
+
路径: /data/codemap/src/cache/file-hash-cache.ts
|
|
146
|
+
导出于 src/cache/file-hash-cache.ts
|
|
147
|
+
|
|
148
|
+
FileHashCache
|
|
149
|
+
类型: class
|
|
150
|
+
路径: /data/codemap/src/cache/file-hash-cache.ts
|
|
151
|
+
定义于 src/cache/file-hash-cache.ts:66
|
|
152
|
+
|
|
153
|
+
... (共20个结果)
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
**执行时间**: 0.642s (real)
|
|
157
|
+
|
|
158
|
+
### rg 执行
|
|
159
|
+
```bash
|
|
160
|
+
rg -n "cache" src/ -i
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
**输出:** (共找到约 300+ 处匹配,以下为部分)
|
|
164
|
+
```
|
|
165
|
+
src/cache/file-hash-cache.ts:2:// File Hash Cache - 文件哈希缓存
|
|
166
|
+
src/cache/file-hash-cache.ts:66:export class FileHashCache {
|
|
167
|
+
src/cache/file-hash-cache.ts:67: private hashCache = new Map<string, { hash: string; mtime: number }>();
|
|
168
|
+
src/cache/lru-cache.ts:2:// LRU Cache Implementation - 最近最少使用缓存
|
|
169
|
+
src/cache/lru-cache.ts:9:export class LRUCache<K, V> {
|
|
170
|
+
src/cache/index.ts:2:// Cache Module - 缓存系统入口
|
|
171
|
+
...
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
**执行时间**: 0.007s (real)
|
|
175
|
+
|
|
176
|
+
### 对比分析
|
|
177
|
+
|
|
178
|
+
| 维度 | CodeMap (-S) | rg (-i) |
|
|
179
|
+
|------|--------------|---------|
|
|
180
|
+
| **速度** | 0.642s | 0.007s |
|
|
181
|
+
| **结果数量** | 20 个符号 | 300+ 处文本匹配 |
|
|
182
|
+
| **匹配模式** | 符号级模糊匹配 | 文本级正则匹配 |
|
|
183
|
+
| **信息类型** | 符号定义、导出、模块 | 所有文本行 |
|
|
184
|
+
| **去重** | ✅ 符号去重 (如 FileHashCache 类只出现一次定义) | ❌ 每行都显示 |
|
|
185
|
+
| **可读性** | 结构化,带类型信息 | 纯文本,含代码上下文 |
|
|
186
|
+
|
|
187
|
+
### 发现的问题
|
|
188
|
+
|
|
189
|
+
1. **CodeMap 模糊搜索速度慢**: 比 rg 慢约 91 倍
|
|
190
|
+
2. **CodeMap 结果数量受限**: 仅返回 20 个结果,而 rg 返回 300+ 处
|
|
191
|
+
3. **CodeMap 不显示引用位置**: 只显示定义位置,不显示使用位置
|
|
192
|
+
4. **rg 结果噪音大**: 返回所有包含 "cache" 文本的行,包括注释、字符串、变量名等
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## 测试场景3: 搜索类/接口定义 "Analyzer"
|
|
197
|
+
|
|
198
|
+
### 测试目的
|
|
199
|
+
搜索类或接口定义,对比各工具的类型识别能力。
|
|
200
|
+
|
|
201
|
+
### CodeMap 执行
|
|
202
|
+
```bash
|
|
203
|
+
npx codemap query -s "Analyzer"
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
**输出:**
|
|
207
|
+
```
|
|
208
|
+
🔍 查询 "Analyzer" (symbol)
|
|
209
|
+
找到 1 个结果
|
|
210
|
+
|
|
211
|
+
analyzer
|
|
212
|
+
类型: variable
|
|
213
|
+
路径: /data/codemap/src/orchestrator/__tests__/git-analyzer.test.ts
|
|
214
|
+
定义于 src/orchestrator/__tests__/git-analyzer.test.ts:27
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
**执行时间**: 0.515s (real)
|
|
218
|
+
|
|
219
|
+
### rg 执行 (类/接口定义模式)
|
|
220
|
+
```bash
|
|
221
|
+
rg -n "class Analyzer|interface Analyzer" src/
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
**输出:**
|
|
225
|
+
```
|
|
226
|
+
(无匹配,退出码 1)
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
**执行时间**: 0.009s (real)
|
|
230
|
+
|
|
231
|
+
### rg 执行 (扩展搜索)
|
|
232
|
+
```bash
|
|
233
|
+
rg -n "Analyzer" src/ | head -30
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
**输出:**
|
|
237
|
+
```
|
|
238
|
+
src/cli/commands/ci.ts:9:import { GitAnalyzer } from '../../orchestrator/git-analyzer.js';
|
|
239
|
+
src/orchestrator/git-analyzer.ts:118: * GitAnalyzer 类
|
|
240
|
+
src/orchestrator/git-analyzer.ts:121:export class GitAnalyzer {
|
|
241
|
+
src/plugins/built-in/complexity-analyzer.ts:96:class ComplexityAnalyzerPlugin implements CodeMapPlugin {
|
|
242
|
+
src/orchestrator/index.ts:53: GitAnalyzer,
|
|
243
|
+
...
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### grep 执行
|
|
247
|
+
```bash
|
|
248
|
+
grep -rn "Analyzer" src/ | head -30
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
**输出:** (与 rg 类似)
|
|
252
|
+
|
|
253
|
+
### 对比分析
|
|
254
|
+
|
|
255
|
+
| 维度 | CodeMap | rg (class/interface) | rg (extended) |
|
|
256
|
+
|------|---------|---------------------|---------------|
|
|
257
|
+
| **速度** | 0.515s | 0.009s | 0.010s |
|
|
258
|
+
| **结果** | 1 个变量 | 0 个 | 约 50+ 处 |
|
|
259
|
+
| **类型过滤** | ❌ 未正确过滤 | ✅ 精确匹配模式 | ❌ 无过滤 |
|
|
260
|
+
| **大小写敏感** | ❌ 不敏感 ("analyzer" 匹配 "Analyzer") | ✅ 敏感 | ✅ 敏感 |
|
|
261
|
+
|
|
262
|
+
### 发现的问题
|
|
263
|
+
|
|
264
|
+
1. **CodeMap 搜索 "Analyzer" 未找到 GitAnalyzer 类**: 这是严重问题!项目中存在 `GitAnalyzer` 类和 `ComplexityAnalyzerPlugin` 类,但 CodeMap 只找到一个测试文件中的变量 `analyzer`。
|
|
265
|
+
2. **CodeMap 大小写不敏感问题**: 搜索 "Analyzer" 却匹配了 "analyzer" (小写变量名)。
|
|
266
|
+
3. **rg 精确模式有效但过于严格**: `class Analyzer|interface Analyzer` 精确模式没有匹配到 `class GitAnalyzer` (因为类名是 GitAnalyzer 不是 Analyzer)。
|
|
267
|
+
4. **CodeMap 缺少子串匹配**: CodeMap 似乎未将 "GitAnalyzer" 中的 "Analyzer" 子串作为匹配结果。
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
## 综合分析
|
|
272
|
+
|
|
273
|
+
### 速度对比
|
|
274
|
+
|
|
275
|
+
| 工具 | Test1 (ModuleInfo) | Test2 (cache) | Test3 (Analyzer) | 平均 |
|
|
276
|
+
|------|-------------------|---------------|------------------|------|
|
|
277
|
+
| CodeMap | 0.538s | 0.642s | 0.515s | **0.565s** |
|
|
278
|
+
| rg | 0.008s | 0.007s | 0.010s | **0.008s** |
|
|
279
|
+
| grep | 0.003s | - | - | **0.003s** |
|
|
280
|
+
|
|
281
|
+
**结论**: CodeMap 比 rg 慢约 70 倍,比 grep 慢约 188 倍。
|
|
282
|
+
|
|
283
|
+
### 准确性对比
|
|
284
|
+
|
|
285
|
+
| 场景 | CodeMap | rg/grep |
|
|
286
|
+
|------|---------|---------|
|
|
287
|
+
| 精确搜索 | ⚠️ 仅返回定义,遗漏大量引用 | ✅ 返回所有文本匹配 |
|
|
288
|
+
| 模糊搜索 | ✅ 返回相关符号,结构化 | ⚠️ 返回所有文本,噪音大 |
|
|
289
|
+
| 类型搜索 | ❌ 严重遗漏 (未找到 GitAnalyzer) | ⚠️ 需要复杂正则 |
|
|
290
|
+
|
|
291
|
+
### 信息丰富度对比
|
|
292
|
+
|
|
293
|
+
| 信息类型 | CodeMap | rg | grep |
|
|
294
|
+
|---------|---------|-----|------|
|
|
295
|
+
| 符号类型 | ✅ | ❌ | ❌ |
|
|
296
|
+
| 导出信息 | ✅ | ❌ | ❌ |
|
|
297
|
+
| 文件路径 | ✅ | ✅ | ✅ |
|
|
298
|
+
| 行号 | ✅ | ✅ | ✅ |
|
|
299
|
+
| 代码上下文 | ❌ | ✅ | ✅ |
|
|
300
|
+
| 依赖关系 | ❌ | ❌ | ❌ |
|
|
301
|
+
|
|
302
|
+
### 易用性对比
|
|
303
|
+
|
|
304
|
+
| 维度 | CodeMap | rg | grep |
|
|
305
|
+
|------|---------|-----|------|
|
|
306
|
+
| 命令简洁度 | ⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ |
|
|
307
|
+
| 输出可读性 | ⭐⭐⭐⭐⭐ | ⭐⭐⭐ | ⭐⭐⭐ |
|
|
308
|
+
| 学习曲线 | ⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ |
|
|
309
|
+
| 无需索引 | ❌ | ✅ | ✅ |
|
|
310
|
+
|
|
311
|
+
---
|
|
312
|
+
|
|
313
|
+
## 发现的关键问题
|
|
314
|
+
|
|
315
|
+
### 🔴 严重问题
|
|
316
|
+
|
|
317
|
+
1. **符号搜索遗漏严重**: CodeMap 在搜索 "Analyzer" 时完全遗漏了 `GitAnalyzer` 类和 `ComplexityAnalyzerPlugin` 类,只找到一个不相关的变量。
|
|
318
|
+
- 检查 codemap.json 发现 GitAnalyzer 存在于索引中(多处)
|
|
319
|
+
- 可能是搜索算法未正确处理子串匹配或类名前缀
|
|
320
|
+
|
|
321
|
+
2. **大小写处理不一致**:
|
|
322
|
+
- 搜索 "ModuleInfo" 返回了 "moduleInfo" (小写变量)
|
|
323
|
+
- 搜索 "Analyzer" 返回了 "analyzer" (小写变量)
|
|
324
|
+
- 但搜索 "cache" 却正确区分了大小写变体
|
|
325
|
+
|
|
326
|
+
### 🟡 中等问题
|
|
327
|
+
|
|
328
|
+
3. **速度性能差**: CodeMap 比传统工具慢 70-180 倍,对于大型项目可能无法接受。
|
|
329
|
+
|
|
330
|
+
4. **结果数量有限**: 模糊搜索仅返回 20 个结果,可能遗漏重要符号。
|
|
331
|
+
|
|
332
|
+
### 🟢 轻微问题
|
|
333
|
+
|
|
334
|
+
5. **缺少引用信息**: CodeMap 只返回定义位置,不显示符号在哪里被使用。
|
|
335
|
+
|
|
336
|
+
6. **无代码上下文**: 不像 rg/grep 那样显示匹配的代码行。
|
|
337
|
+
|
|
338
|
+
---
|
|
339
|
+
|
|
340
|
+
## 建议
|
|
341
|
+
|
|
342
|
+
### 对 CodeMap 的改进建议
|
|
343
|
+
|
|
344
|
+
1. **修复搜索算法**:
|
|
345
|
+
- 确保子串匹配正常工作(如 "Analyzer" 应匹配 "GitAnalyzer")
|
|
346
|
+
- 检查符号索引的查询逻辑
|
|
347
|
+
|
|
348
|
+
2. **优化性能**:
|
|
349
|
+
- 使用更高效的数据结构(如 Trie 树)进行符号查找
|
|
350
|
+
- 考虑使用 SQLite 或嵌入式数据库加速查询
|
|
351
|
+
|
|
352
|
+
3. **增强搜索选项**:
|
|
353
|
+
- 添加 `--case-sensitive` 和 `--case-insensitive` 选项
|
|
354
|
+
- 添加 `--include-references` 选项显示符号引用位置
|
|
355
|
+
- 添加 `-n/--limit` 选项控制结果数量
|
|
356
|
+
|
|
357
|
+
4. **显示代码上下文**:
|
|
358
|
+
- 添加选项显示匹配行的代码片段
|
|
359
|
+
|
|
360
|
+
### 使用建议
|
|
361
|
+
|
|
362
|
+
| 场景 | 推荐工具 | 原因 |
|
|
363
|
+
|------|---------|------|
|
|
364
|
+
| 快速查找文本 | rg/grep | 速度快,无需索引 |
|
|
365
|
+
| 查找符号定义 | CodeMap | 结构化输出,带类型信息 |
|
|
366
|
+
| 理解代码结构 | CodeMap | 显示导出和模块关系 |
|
|
367
|
+
| 查找类/接口定义 | rg + 正则 | CodeMap 当前有遗漏问题 |
|
|
368
|
+
| 模糊探索代码库 | CodeMap | 符号级模糊匹配减少噪音 |
|
|
369
|
+
|
|
370
|
+
---
|
|
371
|
+
|
|
372
|
+
## 附录: 测试原始数据
|
|
373
|
+
|
|
374
|
+
### CodeMap 索引统计
|
|
375
|
+
- 总文件数: 104
|
|
376
|
+
- 总行数: 28,878
|
|
377
|
+
- 总模块数: 104
|
|
378
|
+
- 总导出: 378
|
|
379
|
+
- 总类型: 70
|
|
380
|
+
|
|
381
|
+
### 发现的符号
|
|
382
|
+
- `ModuleInfo` 接口定义于: src/types/index.ts:154
|
|
383
|
+
- `GitAnalyzer` 类定义于: src/orchestrator/git-analyzer.ts:121
|
|
384
|
+
- `ComplexityAnalyzerPlugin` 类定义于: src/plugins/built-in/complexity-analyzer.ts:96
|