@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.
Files changed (283) hide show
  1. package/CHANGELOG.md +164 -6
  2. package/README.md +407 -141
  3. package/dist/cli/commands/ci.d.ts +7 -1
  4. package/dist/cli/commands/ci.d.ts.map +1 -1
  5. package/dist/cli/commands/ci.js +38 -0
  6. package/dist/cli/commands/ci.js.map +1 -1
  7. package/dist/cli/commands/cycles.d.ts.map +1 -1
  8. package/dist/cli/commands/cycles.js +2 -0
  9. package/dist/cli/commands/cycles.js.map +1 -1
  10. package/dist/cli/commands/export.d.ts +6 -0
  11. package/dist/cli/commands/export.d.ts.map +1 -0
  12. package/dist/cli/commands/export.js +108 -0
  13. package/dist/cli/commands/export.js.map +1 -0
  14. package/dist/cli/commands/generate.d.ts.map +1 -1
  15. package/dist/cli/commands/generate.js +96 -0
  16. package/dist/cli/commands/generate.js.map +1 -1
  17. package/dist/cli/commands/init.d.ts.map +1 -1
  18. package/dist/cli/commands/init.js +3 -1
  19. package/dist/cli/commands/init.js.map +1 -1
  20. package/dist/cli/commands/logs.d.ts +5 -0
  21. package/dist/cli/commands/logs.d.ts.map +1 -0
  22. package/dist/cli/commands/logs.js +189 -0
  23. package/dist/cli/commands/logs.js.map +1 -0
  24. package/dist/cli/commands/report.d.ts +12 -0
  25. package/dist/cli/commands/report.d.ts.map +1 -0
  26. package/dist/cli/commands/report.js +158 -0
  27. package/dist/cli/commands/report.js.map +1 -0
  28. package/dist/cli/commands/server.d.ts +9 -0
  29. package/dist/cli/commands/server.d.ts.map +1 -0
  30. package/dist/cli/commands/server.js +68 -0
  31. package/dist/cli/commands/server.js.map +1 -0
  32. package/dist/cli/commands/watch-foreground.d.ts.map +1 -1
  33. package/dist/cli/commands/watch-foreground.js +2 -0
  34. package/dist/cli/commands/watch-foreground.js.map +1 -1
  35. package/dist/cli/commands/watch.d.ts.map +1 -1
  36. package/dist/cli/commands/watch.js +2 -0
  37. package/dist/cli/commands/watch.js.map +1 -1
  38. package/dist/cli/first-run-guide.d.ts +23 -0
  39. package/dist/cli/first-run-guide.d.ts.map +1 -0
  40. package/dist/cli/first-run-guide.js +83 -0
  41. package/dist/cli/first-run-guide.js.map +1 -0
  42. package/dist/cli/index.js +85 -1
  43. package/dist/cli/index.js.map +1 -1
  44. package/dist/cli/platform-check.d.ts +21 -0
  45. package/dist/cli/platform-check.d.ts.map +1 -0
  46. package/dist/cli/platform-check.js +94 -0
  47. package/dist/cli/platform-check.js.map +1 -0
  48. package/dist/cli/tree-sitter-check.d.ts +35 -0
  49. package/dist/cli/tree-sitter-check.d.ts.map +1 -0
  50. package/dist/cli/tree-sitter-check.js +133 -0
  51. package/dist/cli/tree-sitter-check.js.map +1 -0
  52. package/dist/cli/utils/sanitize.d.ts +54 -0
  53. package/dist/cli/utils/sanitize.d.ts.map +1 -0
  54. package/dist/cli/utils/sanitize.js +131 -0
  55. package/dist/cli/utils/sanitize.js.map +1 -0
  56. package/dist/cli-new/commands/export.d.ts +15 -0
  57. package/dist/cli-new/commands/export.d.ts.map +1 -0
  58. package/dist/cli-new/commands/export.js +107 -0
  59. package/dist/cli-new/commands/export.js.map +1 -0
  60. package/dist/cli-new/commands/query.d.ts +14 -0
  61. package/dist/cli-new/commands/query.d.ts.map +1 -0
  62. package/dist/cli-new/commands/query.js +120 -0
  63. package/dist/cli-new/commands/query.js.map +1 -0
  64. package/dist/cli-new/commands/server.d.ts +13 -0
  65. package/dist/cli-new/commands/server.d.ts.map +1 -0
  66. package/dist/cli-new/commands/server.js +94 -0
  67. package/dist/cli-new/commands/server.js.map +1 -0
  68. package/dist/cli-new/index.d.ts +11 -0
  69. package/dist/cli-new/index.d.ts.map +1 -0
  70. package/dist/cli-new/index.js +63 -0
  71. package/dist/cli-new/index.js.map +1 -0
  72. package/dist/cli-new/types/index.d.ts +88 -0
  73. package/dist/cli-new/types/index.d.ts.map +1 -0
  74. package/dist/cli-new/types/index.js +7 -0
  75. package/dist/cli-new/types/index.js.map +1 -0
  76. package/dist/domain/entities/CodeGraph.d.ts +134 -0
  77. package/dist/domain/entities/CodeGraph.d.ts.map +1 -0
  78. package/dist/domain/entities/CodeGraph.js +316 -0
  79. package/dist/domain/entities/CodeGraph.js.map +1 -0
  80. package/dist/domain/entities/Dependency.d.ts +78 -0
  81. package/dist/domain/entities/Dependency.d.ts.map +1 -0
  82. package/dist/domain/entities/Dependency.js +132 -0
  83. package/dist/domain/entities/Dependency.js.map +1 -0
  84. package/dist/domain/entities/Module.d.ts +75 -0
  85. package/dist/domain/entities/Module.d.ts.map +1 -0
  86. package/dist/domain/entities/Module.js +151 -0
  87. package/dist/domain/entities/Module.js.map +1 -0
  88. package/dist/domain/entities/Project.d.ts +50 -0
  89. package/dist/domain/entities/Project.d.ts.map +1 -0
  90. package/dist/domain/entities/Project.js +99 -0
  91. package/dist/domain/entities/Project.js.map +1 -0
  92. package/dist/domain/entities/Symbol.d.ts +75 -0
  93. package/dist/domain/entities/Symbol.d.ts.map +1 -0
  94. package/dist/domain/entities/Symbol.js +130 -0
  95. package/dist/domain/entities/Symbol.js.map +1 -0
  96. package/dist/domain/events/DomainEvent.d.ts +76 -0
  97. package/dist/domain/events/DomainEvent.d.ts.map +1 -0
  98. package/dist/domain/events/DomainEvent.js +153 -0
  99. package/dist/domain/events/DomainEvent.js.map +1 -0
  100. package/dist/domain/index.d.ts +10 -0
  101. package/dist/domain/index.d.ts.map +1 -0
  102. package/dist/domain/index.js +18 -0
  103. package/dist/domain/index.js.map +1 -0
  104. package/dist/domain/repositories/CodeGraphRepository.d.ts +58 -0
  105. package/dist/domain/repositories/CodeGraphRepository.d.ts.map +1 -0
  106. package/dist/domain/repositories/CodeGraphRepository.js +37 -0
  107. package/dist/domain/repositories/CodeGraphRepository.js.map +1 -0
  108. package/dist/domain/services/CodeGraphBuilder.d.ts +50 -0
  109. package/dist/domain/services/CodeGraphBuilder.d.ts.map +1 -0
  110. package/dist/domain/services/CodeGraphBuilder.js +121 -0
  111. package/dist/domain/services/CodeGraphBuilder.js.map +1 -0
  112. package/dist/infrastructure/parser/implementations/GoParser.d.ts +25 -0
  113. package/dist/infrastructure/parser/implementations/GoParser.d.ts.map +1 -0
  114. package/dist/infrastructure/parser/implementations/GoParser.js +158 -0
  115. package/dist/infrastructure/parser/implementations/GoParser.js.map +1 -0
  116. package/dist/infrastructure/parser/implementations/PythonParser.d.ts +30 -0
  117. package/dist/infrastructure/parser/implementations/PythonParser.d.ts.map +1 -0
  118. package/dist/infrastructure/parser/implementations/PythonParser.js +201 -0
  119. package/dist/infrastructure/parser/implementations/PythonParser.js.map +1 -0
  120. package/dist/infrastructure/parser/implementations/TypeScriptParser.d.ts +63 -0
  121. package/dist/infrastructure/parser/implementations/TypeScriptParser.d.ts.map +1 -0
  122. package/dist/infrastructure/parser/implementations/TypeScriptParser.js +420 -0
  123. package/dist/infrastructure/parser/implementations/TypeScriptParser.js.map +1 -0
  124. package/dist/infrastructure/parser/index.d.ts +13 -0
  125. package/dist/infrastructure/parser/index.d.ts.map +1 -0
  126. package/dist/infrastructure/parser/index.js +32 -0
  127. package/dist/infrastructure/parser/index.js.map +1 -0
  128. package/dist/infrastructure/parser/interfaces/ParserBase.d.ts +124 -0
  129. package/dist/infrastructure/parser/interfaces/ParserBase.d.ts.map +1 -0
  130. package/dist/infrastructure/parser/interfaces/ParserBase.js +200 -0
  131. package/dist/infrastructure/parser/interfaces/ParserBase.js.map +1 -0
  132. package/dist/infrastructure/parser/registry/ParserRegistry.d.ts +68 -0
  133. package/dist/infrastructure/parser/registry/ParserRegistry.d.ts.map +1 -0
  134. package/dist/infrastructure/parser/registry/ParserRegistry.js +116 -0
  135. package/dist/infrastructure/parser/registry/ParserRegistry.js.map +1 -0
  136. package/dist/infrastructure/repositories/CodeGraphRepositoryImpl.d.ts +44 -0
  137. package/dist/infrastructure/repositories/CodeGraphRepositoryImpl.d.ts.map +1 -0
  138. package/dist/infrastructure/repositories/CodeGraphRepositoryImpl.js +129 -0
  139. package/dist/infrastructure/repositories/CodeGraphRepositoryImpl.js.map +1 -0
  140. package/dist/infrastructure/repositories/index.d.ts +3 -0
  141. package/dist/infrastructure/repositories/index.d.ts.map +1 -0
  142. package/dist/infrastructure/repositories/index.js +7 -0
  143. package/dist/infrastructure/repositories/index.js.map +1 -0
  144. package/dist/infrastructure/storage/StorageFactory.d.ts +53 -0
  145. package/dist/infrastructure/storage/StorageFactory.d.ts.map +1 -0
  146. package/dist/infrastructure/storage/StorageFactory.js +150 -0
  147. package/dist/infrastructure/storage/StorageFactory.js.map +1 -0
  148. package/dist/infrastructure/storage/adapters/FileSystemStorage.d.ts +52 -0
  149. package/dist/infrastructure/storage/adapters/FileSystemStorage.d.ts.map +1 -0
  150. package/dist/infrastructure/storage/adapters/FileSystemStorage.js +315 -0
  151. package/dist/infrastructure/storage/adapters/FileSystemStorage.js.map +1 -0
  152. package/dist/infrastructure/storage/adapters/KuzuDBStorage.d.ts +52 -0
  153. package/dist/infrastructure/storage/adapters/KuzuDBStorage.d.ts.map +1 -0
  154. package/dist/infrastructure/storage/adapters/KuzuDBStorage.js +235 -0
  155. package/dist/infrastructure/storage/adapters/KuzuDBStorage.js.map +1 -0
  156. package/dist/infrastructure/storage/adapters/MemoryStorage.d.ts +37 -0
  157. package/dist/infrastructure/storage/adapters/MemoryStorage.d.ts.map +1 -0
  158. package/dist/infrastructure/storage/adapters/MemoryStorage.js +229 -0
  159. package/dist/infrastructure/storage/adapters/MemoryStorage.js.map +1 -0
  160. package/dist/infrastructure/storage/adapters/Neo4jStorage.d.ts +49 -0
  161. package/dist/infrastructure/storage/adapters/Neo4jStorage.d.ts.map +1 -0
  162. package/dist/infrastructure/storage/adapters/Neo4jStorage.js +222 -0
  163. package/dist/infrastructure/storage/adapters/Neo4jStorage.js.map +1 -0
  164. package/dist/infrastructure/storage/index.d.ts +6 -0
  165. package/dist/infrastructure/storage/index.d.ts.map +1 -0
  166. package/dist/infrastructure/storage/index.js +13 -0
  167. package/dist/infrastructure/storage/index.js.map +1 -0
  168. package/dist/infrastructure/storage/interfaces/StorageBase.d.ts +76 -0
  169. package/dist/infrastructure/storage/interfaces/StorageBase.d.ts.map +1 -0
  170. package/dist/infrastructure/storage/interfaces/StorageBase.js +116 -0
  171. package/dist/infrastructure/storage/interfaces/StorageBase.js.map +1 -0
  172. package/dist/interface/config/index.d.ts +102 -0
  173. package/dist/interface/config/index.d.ts.map +1 -0
  174. package/dist/interface/config/index.js +7 -0
  175. package/dist/interface/config/index.js.map +1 -0
  176. package/dist/interface/types/index.d.ts +425 -0
  177. package/dist/interface/types/index.d.ts.map +1 -0
  178. package/dist/interface/types/index.js +8 -0
  179. package/dist/interface/types/index.js.map +1 -0
  180. package/dist/interface/types/parser.d.ts +103 -0
  181. package/dist/interface/types/parser.d.ts.map +1 -0
  182. package/dist/interface/types/parser.js +7 -0
  183. package/dist/interface/types/parser.js.map +1 -0
  184. package/dist/interface/types/storage.d.ts +98 -0
  185. package/dist/interface/types/storage.d.ts.map +1 -0
  186. package/dist/interface/types/storage.js +7 -0
  187. package/dist/interface/types/storage.js.map +1 -0
  188. package/dist/orchestrator/test-linker.js +1 -1
  189. package/dist/orchestrator/test-linker.js.map +1 -1
  190. package/dist/server/CodeMapServer.d.ts +51 -0
  191. package/dist/server/CodeMapServer.d.ts.map +1 -0
  192. package/dist/server/CodeMapServer.js +146 -0
  193. package/dist/server/CodeMapServer.js.map +1 -0
  194. package/dist/server/handlers/AnalysisHandler.d.ts +82 -0
  195. package/dist/server/handlers/AnalysisHandler.d.ts.map +1 -0
  196. package/dist/server/handlers/AnalysisHandler.js +196 -0
  197. package/dist/server/handlers/AnalysisHandler.js.map +1 -0
  198. package/dist/server/handlers/QueryHandler.d.ts +57 -0
  199. package/dist/server/handlers/QueryHandler.d.ts.map +1 -0
  200. package/dist/server/handlers/QueryHandler.js +260 -0
  201. package/dist/server/handlers/QueryHandler.js.map +1 -0
  202. package/dist/server/index.d.ts +7 -0
  203. package/dist/server/index.d.ts.map +1 -0
  204. package/dist/server/index.js +13 -0
  205. package/dist/server/index.js.map +1 -0
  206. package/dist/server/routes/api.d.ts +8 -0
  207. package/dist/server/routes/api.d.ts.map +1 -0
  208. package/dist/server/routes/api.js +372 -0
  209. package/dist/server/routes/api.js.map +1 -0
  210. package/dist/server/types/index.d.ts +171 -0
  211. package/dist/server/types/index.d.ts.map +1 -0
  212. package/dist/server/types/index.js +7 -0
  213. package/dist/server/types/index.js.map +1 -0
  214. package/dist/types/index.d.ts +6 -372
  215. package/dist/types/index.d.ts.map +1 -1
  216. package/dist/types/index.js +9 -3
  217. package/dist/types/index.js.map +1 -1
  218. package/docs/AI_ASSISTANT_SETUP.md +811 -0
  219. package/docs/PUBLISHING.md +162 -0
  220. package/docs/README.md +37 -0
  221. package/docs/SETUP_GUIDE.md +493 -0
  222. package/docs/ai-guide/COMMANDS.md +369 -0
  223. package/docs/ai-guide/INTEGRATION.md +513 -0
  224. package/docs/ai-guide/OUTPUT.md +465 -0
  225. package/docs/ai-guide/PATTERNS.md +409 -0
  226. package/docs/ai-guide/PROMPTS.md +414 -0
  227. package/docs/ai-guide/QUICKSTART.md +114 -0
  228. package/docs/ai-guide/README.md +66 -0
  229. package/docs/archive/AI_INTEGRATION_GUIDE_ARCHIVED.md +391 -0
  230. package/docs/archive/ARCHIVE.md +39 -0
  231. package/docs/archive/MYCLAUDE_GUIDE.md +305 -0
  232. package/docs/archive/PUBLISH_NPM_DESIGN_V1.md +1699 -0
  233. package/docs/archive/PUBLISH_NPM_DESIGN_V2.md +396 -0
  234. package/docs/archive/README.md +29 -0
  235. package/docs/archive/TASK_DESIGN_COVERAGE_REPORT.md +320 -0
  236. package/docs/archive/TEST_SUMMARY.md +140 -0
  237. package/docs/archive/comprehensive_test_report.md +337 -0
  238. package/docs/archive/design-docs/CI_GATEWAY_DESIGN.md +790 -0
  239. package/docs/archive/design-docs/PUBLISH_NPM_DESIGN_FINAL.md +491 -0
  240. package/docs/archive/design-docs/REFACTOR_ARCHITECTURE_OVERVIEW.md +558 -0
  241. package/docs/archive/design-docs/REFACTOR_CONFIDENCE_DESIGN.md +250 -0
  242. package/docs/archive/design-docs/REFACTOR_GIT_ANALYZER_DESIGN.md +791 -0
  243. package/docs/archive/design-docs/REFACTOR_ORCHESTRATOR_DESIGN.md +1071 -0
  244. package/docs/archive/design-docs/REFACTOR_RESULT_FUSION_DESIGN.md +321 -0
  245. package/docs/archive/design-docs/REFACTOR_TEST_LINKER_DESIGN.md +317 -0
  246. package/docs/archive/myclaude.md +1084 -0
  247. package/docs/archive/plans/2026-03-14-go-language-support-design.md +92 -0
  248. package/docs/archive/product-specs/REFACTOR_REQUIREMENTS.md +976 -0
  249. package/docs/archive/scenario-2-deps-analysis.md +353 -0
  250. package/docs/archive/test-report-symbol-search.md +384 -0
  251. package/docs/archive/test-scenario-4-complexity-analysis.md +460 -0
  252. package/docs/archive/test_report_scenario5.md +615 -0
  253. package/docs/archive/test_scenario_3_impact_analysis_report.md +520 -0
  254. package/docs/design-docs/README.md +26 -0
  255. package/docs/exec-plans/MVP3-IMPLEMENTATION-ROADMAP.md +524 -0
  256. package/docs/exec-plans/README.md +29 -0
  257. package/docs/exec-plans/active/.gitkeep +0 -0
  258. package/docs/exec-plans/completed/.gitkeep +0 -0
  259. package/docs/exec-plans/completed/2026-03-03-deps-path-extension-fix.md +186 -0
  260. package/docs/exec-plans/completed/2026-03-03-post-task-plan.md +135 -0
  261. package/docs/exec-plans/completed/harness-engineering-rollout.md +184 -0
  262. package/docs/exec-plans/tech-debt/.gitkeep +0 -0
  263. package/docs/exec-plans/tech-debt/2026-03-15-lint-guardrail-gap.md +30 -0
  264. package/docs/generated/README.md +19 -0
  265. package/docs/product-specs/MVP3-ARCHITECTURE-COMPARISON.md +504 -0
  266. package/docs/product-specs/MVP3-ARCHITECTURE-REDESIGN-PRD.md +322 -0
  267. package/docs/product-specs/MVP3-ARCHITECTURE-REDESIGN-TECH-PRD.md +1374 -0
  268. package/docs/product-specs/README.md +22 -0
  269. package/docs/references/README.md +15 -0
  270. package/docs/references/tmp.md +527 -0
  271. package/docs/rules/README.md +16 -0
  272. package/docs/rules/architecture-guardrails.md +349 -0
  273. package/docs/rules/code-quality-redlines.md +321 -0
  274. package/docs/rules/deployment.md +23 -0
  275. package/docs/rules/engineering-with-codex-openai.md +202 -0
  276. package/docs/rules/testing.md +73 -0
  277. package/docs/rules/validation.md +39 -0
  278. package/examples/README.md +61 -0
  279. package/examples/claude/codemap-skill.md +94 -0
  280. package/examples/codex/codemap-agent.md +66 -0
  281. package/examples/copilot/copilot-instructions.md +24 -0
  282. package/examples/kimi/codemap-skill.md +92 -0
  283. package/package.json +22 -7
@@ -0,0 +1,465 @@
1
+ # AI Guide - 输出结构解析
2
+
3
+ > 命令输出的 JSON 结构详解,帮助 AI 正确解析和处理结果
4
+
5
+ ---
6
+
7
+ ## 何时使用 --json
8
+
9
+ | 场景 | 使用 `--json` | 原因 |
10
+ |------|--------------|------|
11
+ | 需要解析结果进行进一步处理 | ✅ 是 | 结构化数据便于解析 |
12
+ | 向用户展示结果 | ❌ 否 | 人类可读格式更好 |
13
+ | 需要提取文件路径列表 | ✅ 是 | 便于正则提取 |
14
+ | 需要计算统计数据 | ✅ 是 | JSON 可直接计算 |
15
+ | 需要过滤或排序结果 | ✅ 是 | 可编程处理 |
16
+ | 简单查询确认存在性 | ❌ 否 | 文本输出更直观 |
17
+
18
+ ---
19
+
20
+ ## query 命令输出结构
21
+
22
+ ### JSON 输出 (-j)
23
+
24
+ ```typescript
25
+ interface QueryOutput {
26
+ type: 'symbol' | 'module' | 'deps' | 'search';
27
+ query: string;
28
+ count: number;
29
+ results: QueryResult[];
30
+ metrics?: {
31
+ indexLoadTime: number;
32
+ queryTime: number;
33
+ totalTime: number;
34
+ cacheHit: boolean;
35
+ indexSize: number;
36
+ };
37
+ }
38
+
39
+ interface QueryResult {
40
+ name: string;
41
+ path: string;
42
+ kind: string;
43
+ details: string;
44
+ location?: {
45
+ file: string;
46
+ line?: number;
47
+ column?: number;
48
+ };
49
+ isExported: boolean;
50
+ references?: Reference[];
51
+ context?: ContextLine[];
52
+ }
53
+
54
+ interface Reference {
55
+ file: string;
56
+ line: number;
57
+ type: 'import' | 'export';
58
+ }
59
+
60
+ interface ContextLine {
61
+ line: number;
62
+ content: string;
63
+ }
64
+ ```
65
+
66
+ ### 示例
67
+
68
+ ```json
69
+ {
70
+ "type": "symbol",
71
+ "query": "IntentRouter",
72
+ "count": 3,
73
+ "results": [
74
+ {
75
+ "name": "IntentRouter",
76
+ "path": "/project/src/orchestrator/intent-router.ts",
77
+ "kind": "class",
78
+ "details": "定义于 src/orchestrator/intent-router.ts:15",
79
+ "location": {
80
+ "file": "src/orchestrator/intent-router.ts",
81
+ "line": 15,
82
+ "column": 1
83
+ },
84
+ "isExported": true,
85
+ "references": [
86
+ { "file": "src/cli/commands/analyze.ts", "line": 1, "type": "import" }
87
+ ]
88
+ }
89
+ ],
90
+ "metrics": {
91
+ "indexLoadTime": 12.34,
92
+ "queryTime": 5.67,
93
+ "totalTime": 18.01,
94
+ "cacheHit": true,
95
+ "indexSize": 1523
96
+ }
97
+ }
98
+ ```
99
+
100
+ ---
101
+
102
+ ## analyze 命令输出结构
103
+
104
+ ### 标准 JSON 输出 (--json)
105
+
106
+ ```typescript
107
+ interface AnalyzeOutput {
108
+ schemaVersion: "v1.0.0";
109
+ intent: "impact" | "dependency" | "search" | "documentation" | "complexity" | "overview" | "refactor" | "reference";
110
+ tool: string;
111
+ confidence: {
112
+ score: number; // 0.0 - 1.0
113
+ level: "high" | "medium" | "low";
114
+ };
115
+ results: AnalyzeResult[];
116
+ metadata: {
117
+ total: number;
118
+ scope: "direct" | "transitive";
119
+ resultCount: number;
120
+ };
121
+ }
122
+
123
+ interface AnalyzeResult {
124
+ file: string;
125
+ location?: {
126
+ file: string;
127
+ line: number;
128
+ column: number;
129
+ };
130
+ content?: string; // 自然语言描述
131
+ relevance: number; // 0.0 - 1.0
132
+ metadata?: {
133
+ testFile?: string; // 关联的测试文件
134
+ complexity?: number; // 复杂度分数
135
+ [key: string]: any;
136
+ };
137
+ }
138
+ ```
139
+
140
+ ### 纯结构化输出 (--structured --json)
141
+
142
+ 移除了 `content` 字段,只保留结构化数据:
143
+
144
+ ```typescript
145
+ interface StructuredAnalyzeOutput {
146
+ schemaVersion: "v1.0.0";
147
+ intent: string;
148
+ tool: string;
149
+ confidence: {
150
+ score: number;
151
+ level: "high" | "medium" | "low";
152
+ };
153
+ results: StructuredResult[];
154
+ metadata: {
155
+ total: number;
156
+ scope: string;
157
+ resultCount: number;
158
+ };
159
+ }
160
+
161
+ interface StructuredResult {
162
+ file: string;
163
+ location?: {
164
+ file: string;
165
+ line: number;
166
+ column: number;
167
+ };
168
+ // 注意:没有 content 字段
169
+ relevance: number;
170
+ metadata?: {
171
+ [key: string]: any;
172
+ };
173
+ }
174
+ ```
175
+
176
+ ### 示例
177
+
178
+ ```json
179
+ {
180
+ "schemaVersion": "v1.0.0",
181
+ "intent": "impact",
182
+ "tool": "codemap-impact",
183
+ "confidence": {
184
+ "score": 0.85,
185
+ "level": "high"
186
+ },
187
+ "results": [
188
+ {
189
+ "file": "src/cli/commands/analyze.ts",
190
+ "location": {
191
+ "file": "src/cli/commands/analyze.ts",
192
+ "line": 45,
193
+ "column": 1
194
+ },
195
+ "content": "导入自 src/orchestrator/intent-router.ts 的 IntentRouter 类",
196
+ "relevance": 0.95,
197
+ "metadata": {
198
+ "testFile": "src/cli/commands/analyze.test.ts"
199
+ }
200
+ }
201
+ ],
202
+ "metadata": {
203
+ "total": 8,
204
+ "scope": "transitive",
205
+ "resultCount": 8
206
+ }
207
+ }
208
+ ```
209
+
210
+ ---
211
+
212
+ ## impact 命令输出结构
213
+
214
+ ### JSON 输出 (-j)
215
+
216
+ ```typescript
217
+ interface ImpactOutput {
218
+ file: string;
219
+ direct: ImpactItem[];
220
+ transitive?: ImpactItem[];
221
+ stats: {
222
+ directCount: number;
223
+ transitiveCount?: number;
224
+ };
225
+ }
226
+
227
+ interface ImpactItem {
228
+ file: string;
229
+ type: "import" | "export" | "dependency";
230
+ relevance?: number;
231
+ }
232
+ ```
233
+
234
+ ### 示例
235
+
236
+ ```json
237
+ {
238
+ "file": "src/cli/index.ts",
239
+ "direct": [
240
+ { "file": "src/cli/commands/analyze.ts", "type": "import", "relevance": 0.95 },
241
+ { "file": "src/cli/commands/query.ts", "type": "import", "relevance": 0.90 }
242
+ ],
243
+ "transitive": [
244
+ { "file": "src/orchestrator/intent-router.ts", "type": "dependency", "relevance": 0.75 }
245
+ ],
246
+ "stats": {
247
+ "directCount": 5,
248
+ "transitiveCount": 12
249
+ }
250
+ }
251
+ ```
252
+
253
+ ---
254
+
255
+ ## deps 命令输出结构
256
+
257
+ ### JSON 输出 (-j)
258
+
259
+ ```typescript
260
+ interface DepsOutput {
261
+ module: string;
262
+ dependencies: DependencyItem[];
263
+ dependents?: DependencyItem[];
264
+ }
265
+
266
+ interface DependencyItem {
267
+ source: string;
268
+ target: string;
269
+ type: "import" | "export" | "dependency";
270
+ }
271
+ ```
272
+
273
+ ### 示例
274
+
275
+ ```json
276
+ {
277
+ "module": "src/domain/services",
278
+ "dependencies": [
279
+ {
280
+ "source": "src/domain/services/CodeGraphBuilder.ts",
281
+ "target": "src/interface/types",
282
+ "type": "import"
283
+ }
284
+ ],
285
+ "dependents": [
286
+ {
287
+ "source": "src/infrastructure/repositories",
288
+ "target": "src/domain/services",
289
+ "type": "import"
290
+ }
291
+ ]
292
+ }
293
+ ```
294
+
295
+ ---
296
+
297
+ ## complexity 命令输出结构
298
+
299
+ ### JSON 输出 (-j)
300
+
301
+ ```typescript
302
+ interface ComplexityOutput {
303
+ files: FileComplexity[];
304
+ summary: {
305
+ averageComplexity: number;
306
+ maxComplexity: number;
307
+ totalFiles: number;
308
+ };
309
+ }
310
+
311
+ interface FileComplexity {
312
+ file: string;
313
+ complexity: number;
314
+ maintainability: number; // 0-100
315
+ functions?: FunctionComplexity[];
316
+ }
317
+
318
+ interface FunctionComplexity {
319
+ name: string;
320
+ line: number;
321
+ complexity: number; // 圈复杂度
322
+ cognitive: number; // 认知复杂度
323
+ }
324
+ ```
325
+
326
+ ---
327
+
328
+ ## cycles 命令输出结构
329
+
330
+ ### JSON 输出 (-j)
331
+
332
+ ```typescript
333
+ interface CyclesOutput {
334
+ cycles: Cycle[];
335
+ count: number;
336
+ maxDepth: number;
337
+ }
338
+
339
+ interface Cycle {
340
+ path: string[]; // 循环依赖的文件路径
341
+ length: number;
342
+ }
343
+ ```
344
+
345
+ ### 示例
346
+
347
+ ```json
348
+ {
349
+ "cycles": [
350
+ {
351
+ "path": [
352
+ "src/core/analyzer.ts",
353
+ "src/core/global-index.ts",
354
+ "src/core/analyzer.ts"
355
+ ],
356
+ "length": 3
357
+ }
358
+ ],
359
+ "count": 1,
360
+ "maxDepth": 3
361
+ }
362
+ ```
363
+
364
+ ---
365
+
366
+ ## 输出处理工具函数
367
+
368
+ ### TypeScript 示例
369
+
370
+ ```typescript
371
+ // 从 analyze 结果中提取文件列表
372
+ function extractFilesFromAnalyze(output: string): string[] {
373
+ const data: AnalyzeOutput = JSON.parse(output);
374
+ return data.results
375
+ .map(r => r.location?.file || r.file)
376
+ .filter((v, i, a) => a.indexOf(v) === i); // 去重
377
+ }
378
+
379
+ // 从 impact 结果中提取需要测试的文件
380
+ function extractTestCandidates(output: string): string[] {
381
+ const data: AnalyzeOutput = JSON.parse(output);
382
+ return data.results
383
+ .filter(r => r.metadata?.testFile)
384
+ .map(r => r.metadata!.testFile!)
385
+ .filter((v, i, a) => a.indexOf(v) === i);
386
+ }
387
+
388
+ // 检查置信度是否足够高
389
+ function isConfidenceHigh(output: string): boolean {
390
+ const data: AnalyzeOutput = JSON.parse(output);
391
+ return data.confidence?.level === 'high' &&
392
+ data.confidence?.score >= 0.7;
393
+ }
394
+
395
+ // 按相关度排序结果
396
+ function sortByRelevance(output: string): AnalyzeResult[] {
397
+ const data: AnalyzeOutput = JSON.parse(output);
398
+ return [...data.results].sort((a, b) => b.relevance - a.relevance);
399
+ }
400
+
401
+ // 过滤结果(例如只取相关度 > 0.5 的)
402
+ function filterByRelevance(output: string, threshold: number): AnalyzeResult[] {
403
+ const data: AnalyzeOutput = JSON.parse(output);
404
+ return data.results.filter(r => r.relevance >= threshold);
405
+ }
406
+
407
+ // 分组统计(按文件目录)
408
+ function groupByDirectory(output: string): Record<string, number> {
409
+ const data: AnalyzeOutput = JSON.parse(output);
410
+ const groups: Record<string, number> = {};
411
+
412
+ for (const result of data.results) {
413
+ const dir = result.file.split('/').slice(0, -1).join('/');
414
+ groups[dir] = (groups[dir] || 0) + 1;
415
+ }
416
+
417
+ return groups;
418
+ }
419
+ ```
420
+
421
+ ### Python 示例
422
+
423
+ ```python
424
+ import json
425
+ from typing import List, Dict, Any
426
+
427
+ def extract_files_from_analyze(output: str) -> List[str]:
428
+ data = json.loads(output)
429
+ files = [r.get('location', {}).get('file') or r.get('file')
430
+ for r in data.get('results', [])]
431
+ return list(set(files)) # 去重
432
+
433
+ def is_confidence_high(output: str) -> bool:
434
+ data = json.loads(output)
435
+ confidence = data.get('confidence', {})
436
+ return (confidence.get('level') == 'high' and
437
+ confidence.get('score', 0) >= 0.7)
438
+
439
+ def sort_by_relevance(output: str) -> List[Dict[str, Any]]:
440
+ data = json.loads(output)
441
+ results = data.get('results', [])
442
+ return sorted(results, key=lambda x: x.get('relevance', 0), reverse=True)
443
+ ```
444
+
445
+ ---
446
+
447
+ ## 置信度解读
448
+
449
+ | 等级 | 分数范围 | 含义 | 建议 |
450
+ |------|---------|------|------|
451
+ | high | 0.7 - 1.0 | 高置信度 | 可放心使用结果 |
452
+ | medium | 0.4 - 0.7 | 中等置信度 | 建议人工复核 |
453
+ | low | 0.0 - 0.4 | 低置信度 | 扩大搜索范围或换关键词 |
454
+
455
+ ---
456
+
457
+ ## 相关度解读
458
+
459
+ | 分数范围 | 含义 |
460
+ |---------|------|
461
+ | 0.9 - 1.0 | 高度相关(精确匹配或核心依赖) |
462
+ | 0.7 - 0.9 | 非常相关(直接依赖) |
463
+ | 0.5 - 0.7 | 相关(间接依赖或相似命名) |
464
+ | 0.3 - 0.5 | 弱相关(可能相关) |
465
+ | 0.0 - 0.3 | 低相关(仅供参考) |