homegraph 1.1.2 → 1.1.3

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 (175) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +243 -243
  3. package/dist/bin/homegraph.js +371 -9
  4. package/dist/bin/homegraph.js.map +1 -1
  5. package/dist/db/migrations.js +18 -18
  6. package/dist/db/queries.js +140 -140
  7. package/dist/db/schema.sql +152 -152
  8. package/dist/directory.js +5 -5
  9. package/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
  10. package/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
  11. package/dist/installer/instructions-template.js +9 -9
  12. package/dist/installer/targets/shared.d.ts +5 -6
  13. package/dist/installer/targets/shared.d.ts.map +1 -1
  14. package/dist/installer/targets/shared.js +5 -6
  15. package/dist/installer/targets/shared.js.map +1 -1
  16. package/dist/mcp/liveness-watchdog.js +16 -16
  17. package/dist/mcp/server-instructions.js +69 -69
  18. package/dist/mcp/tools.d.ts +17 -4
  19. package/dist/mcp/tools.d.ts.map +1 -1
  20. package/dist/mcp/tools.js +192 -22
  21. package/dist/mcp/tools.js.map +1 -1
  22. package/dist/reasoning/reasoner.js +32 -32
  23. package/dist/spec/config.d.ts +43 -0
  24. package/dist/spec/config.d.ts.map +1 -0
  25. package/dist/spec/config.js +275 -0
  26. package/dist/spec/config.js.map +1 -0
  27. package/dist/spec/db/commit-node.d.ts +23 -0
  28. package/dist/spec/db/commit-node.d.ts.map +1 -0
  29. package/dist/spec/db/commit-node.js +62 -0
  30. package/dist/spec/db/commit-node.js.map +1 -0
  31. package/dist/spec/db/fragment-node.d.ts +23 -0
  32. package/dist/spec/db/fragment-node.d.ts.map +1 -0
  33. package/dist/spec/db/fragment-node.js +120 -0
  34. package/dist/spec/db/fragment-node.js.map +1 -0
  35. package/dist/spec/db/fts.d.ts +60 -0
  36. package/dist/spec/db/fts.d.ts.map +1 -0
  37. package/dist/spec/db/fts.js +285 -0
  38. package/dist/spec/db/fts.js.map +1 -0
  39. package/dist/spec/db/index.d.ts +13 -0
  40. package/dist/spec/db/index.d.ts.map +1 -0
  41. package/dist/spec/db/index.js +50 -0
  42. package/dist/spec/db/index.js.map +1 -0
  43. package/dist/spec/db/relations.d.ts +55 -0
  44. package/dist/spec/db/relations.d.ts.map +1 -0
  45. package/dist/spec/db/relations.js +158 -0
  46. package/dist/spec/db/relations.js.map +1 -0
  47. package/dist/spec/db/schema.d.ts +30 -0
  48. package/dist/spec/db/schema.d.ts.map +1 -0
  49. package/dist/spec/db/schema.js +87 -0
  50. package/dist/spec/db/schema.js.map +1 -0
  51. package/dist/spec/db/schema.sql +107 -0
  52. package/dist/spec/db/spec-node.d.ts +41 -0
  53. package/dist/spec/db/spec-node.d.ts.map +1 -0
  54. package/dist/spec/db/spec-node.js +114 -0
  55. package/dist/spec/db/spec-node.js.map +1 -0
  56. package/dist/spec/evolve/impact-locator.d.ts +13 -0
  57. package/dist/spec/evolve/impact-locator.d.ts.map +1 -0
  58. package/dist/spec/evolve/impact-locator.js +25 -0
  59. package/dist/spec/evolve/impact-locator.js.map +1 -0
  60. package/dist/spec/evolve/llm-client.d.ts +50 -0
  61. package/dist/spec/evolve/llm-client.d.ts.map +1 -0
  62. package/dist/spec/evolve/llm-client.js +176 -0
  63. package/dist/spec/evolve/llm-client.js.map +1 -0
  64. package/dist/spec/evolve/logic-checker.d.ts +12 -0
  65. package/dist/spec/evolve/logic-checker.d.ts.map +1 -0
  66. package/dist/spec/evolve/logic-checker.js +48 -0
  67. package/dist/spec/evolve/logic-checker.js.map +1 -0
  68. package/dist/spec/evolve/pipeline.d.ts +40 -0
  69. package/dist/spec/evolve/pipeline.d.ts.map +1 -0
  70. package/dist/spec/evolve/pipeline.js +314 -0
  71. package/dist/spec/evolve/pipeline.js.map +1 -0
  72. package/dist/spec/evolve/spec-rewriter.d.ts +42 -0
  73. package/dist/spec/evolve/spec-rewriter.d.ts.map +1 -0
  74. package/dist/spec/evolve/spec-rewriter.js +254 -0
  75. package/dist/spec/evolve/spec-rewriter.js.map +1 -0
  76. package/dist/spec/graph/queries.d.ts +58 -0
  77. package/dist/spec/graph/queries.d.ts.map +1 -0
  78. package/dist/spec/graph/queries.js +215 -0
  79. package/dist/spec/graph/queries.js.map +1 -0
  80. package/dist/spec/mining/diff-parser.d.ts +33 -0
  81. package/dist/spec/mining/diff-parser.d.ts.map +1 -0
  82. package/dist/spec/mining/diff-parser.js +166 -0
  83. package/dist/spec/mining/diff-parser.js.map +1 -0
  84. package/dist/spec/mining/git-scanner.d.ts +91 -0
  85. package/dist/spec/mining/git-scanner.d.ts.map +1 -0
  86. package/dist/spec/mining/git-scanner.js +266 -0
  87. package/dist/spec/mining/git-scanner.js.map +1 -0
  88. package/dist/spec/mining/pipeline.d.ts +53 -0
  89. package/dist/spec/mining/pipeline.d.ts.map +1 -0
  90. package/dist/spec/mining/pipeline.js +165 -0
  91. package/dist/spec/mining/pipeline.js.map +1 -0
  92. package/dist/spec/mining/scope-resolver.d.ts +45 -0
  93. package/dist/spec/mining/scope-resolver.d.ts.map +1 -0
  94. package/dist/spec/mining/scope-resolver.js +103 -0
  95. package/dist/spec/mining/scope-resolver.js.map +1 -0
  96. package/dist/spec/mining/spec-extractor.d.ts +69 -0
  97. package/dist/spec/mining/spec-extractor.d.ts.map +1 -0
  98. package/dist/spec/mining/spec-extractor.js +369 -0
  99. package/dist/spec/mining/spec-extractor.js.map +1 -0
  100. package/dist/spec/types.d.ts +149 -0
  101. package/dist/spec/types.d.ts.map +1 -0
  102. package/dist/spec/types.js +15 -0
  103. package/dist/spec/types.js.map +1 -0
  104. package/dist/spec/utils.d.ts +166 -0
  105. package/dist/spec/utils.d.ts.map +1 -0
  106. package/dist/spec/utils.js +461 -0
  107. package/dist/spec/utils.js.map +1 -0
  108. package/package.json +58 -57
  109. package/scripts/add-lang/bench.sh +60 -60
  110. package/scripts/add-lang/check-grammar.mjs +75 -75
  111. package/scripts/add-lang/dump-ast.mjs +103 -103
  112. package/scripts/add-lang/verify-extraction.mjs +70 -70
  113. package/scripts/agent-eval/ab-adoption.sh +91 -91
  114. package/scripts/agent-eval/ab-hook.sh +86 -86
  115. package/scripts/agent-eval/ab-impl.sh +78 -78
  116. package/scripts/agent-eval/ab-new-vs-baseline.sh +102 -102
  117. package/scripts/agent-eval/ab-sufficiency.sh +78 -78
  118. package/scripts/agent-eval/arms-F.sh +21 -21
  119. package/scripts/agent-eval/arms-matrix.sh +37 -37
  120. package/scripts/agent-eval/audit.sh +68 -68
  121. package/scripts/agent-eval/bench-readme.sh +28 -28
  122. package/scripts/agent-eval/bench-why-repo.sh +22 -22
  123. package/scripts/agent-eval/block-read-hook.sh +19 -19
  124. package/scripts/agent-eval/hook-settings.json +15 -15
  125. package/scripts/agent-eval/itrun.sh +120 -120
  126. package/scripts/agent-eval/offload-eval-3arm.sh +72 -72
  127. package/scripts/agent-eval/offload-eval-cost.mjs +133 -133
  128. package/scripts/agent-eval/offload-eval-effort.mjs +108 -108
  129. package/scripts/agent-eval/offload-eval-frontload-matrix.sh +25 -25
  130. package/scripts/agent-eval/offload-eval-frontload.sh +47 -47
  131. package/scripts/agent-eval/offload-eval-ground-truth.json +18 -18
  132. package/scripts/agent-eval/offload-eval-hook.mjs +84 -84
  133. package/scripts/agent-eval/offload-eval-judge.mjs +103 -103
  134. package/scripts/agent-eval/offload-eval-matrix.sh +20 -20
  135. package/scripts/agent-eval/offload-eval-metrics.mjs +94 -94
  136. package/scripts/agent-eval/offload-eval-refs1.sh +50 -50
  137. package/scripts/agent-eval/offload-eval-setup.sh +24 -24
  138. package/scripts/agent-eval/offload-eval-styles.sh +71 -71
  139. package/scripts/agent-eval/offload-eval-summarize.mjs +68 -68
  140. package/scripts/agent-eval/offload-eval.md +76 -76
  141. package/scripts/agent-eval/parse-arms.mjs +116 -116
  142. package/scripts/agent-eval/parse-bench-readme.mjs +84 -84
  143. package/scripts/agent-eval/parse-run.mjs +45 -45
  144. package/scripts/agent-eval/parse-session.mjs +93 -93
  145. package/scripts/agent-eval/probe-context.mjs +21 -21
  146. package/scripts/agent-eval/probe-explore.mjs +40 -40
  147. package/scripts/agent-eval/probe-node.mjs +20 -20
  148. package/scripts/agent-eval/probe-sweep.mjs +119 -119
  149. package/scripts/agent-eval/probe-trace.mjs +20 -20
  150. package/scripts/agent-eval/redirect-read-hook.sh +38 -38
  151. package/scripts/agent-eval/run-agent.sh +34 -34
  152. package/scripts/agent-eval/run-all.sh +69 -69
  153. package/scripts/agent-eval/run-arms.sh +56 -56
  154. package/scripts/agent-eval/seq-matrix.mjs +137 -137
  155. package/scripts/build-bundle.sh +118 -118
  156. package/scripts/extract-release-notes.mjs +130 -130
  157. package/scripts/local-install.sh +41 -41
  158. package/scripts/npm-sdk.js +75 -75
  159. package/scripts/npm-shim.js +246 -246
  160. package/scripts/pack-npm.sh +119 -119
  161. package/scripts/prepare-release.mjs +270 -270
  162. package/scripts/qa_eval/README.md +407 -404
  163. package/scripts/qa_eval/_test_deveco_probe.py +41 -41
  164. package/scripts/qa_eval/agent_runner.py +526 -526
  165. package/scripts/qa_eval/data/.gitignore +4 -4
  166. package/scripts/qa_eval/data/test-set.jsonl +2 -22
  167. package/scripts/qa_eval/eval_metrics.py +274 -233
  168. package/scripts/qa_eval/external_agent.py +976 -671
  169. package/scripts/qa_eval/llm_config.py +92 -92
  170. package/scripts/qa_eval/memory_monitor.py +132 -132
  171. package/scripts/qa_eval/my_answer_accuracy.py +187 -187
  172. package/scripts/qa_eval/requirements.txt +2 -2
  173. package/scripts/qa_eval/run_pipeline.py +804 -711
  174. package/scripts/qa_eval/stats_efficiency.py +279 -279
  175. package/scripts/qa_eval/stats_scores.py +207 -207
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Colby Mchenry
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Colby Mchenry
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,243 +1,243 @@
1
- # HomeGraph
2
-
3
- 本地代码知识图谱工具,面向 AI 编程助手(Claude Code、Cursor、Codex 等)提供 MCP 服务。
4
-
5
- 在开源知识图谱能力之上,**HomeGraph 新增了对 ArkTS(HarmonyOS)的支持**,通过 [arkanalyzer](https://www.npmjs.com/package/arkanalyzer) 解析 `.ets` / `.ts` 工程中的符号、调用关系与模块结构。
6
-
7
- 数据全部保存在本机 `.homegraph/` 目录,不上传云端。
8
-
9
- [![npm version](https://img.shields.io/npm/v/homegraph.svg)](https://www.npmjs.com/package/homegraph)
10
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
11
-
12
- ---
13
-
14
- ## 快速开始
15
-
16
- ### 1. 安装 CLI
17
-
18
- 需要 **Node.js 22.5+**(推荐 22 LTS 或 24)。HomeGraph 使用 Node 内置的 `node:sqlite`,22.5 以下无法运行。
19
-
20
- ```bash
21
- npm install -g homegraph
22
- ```
23
-
24
- 若在 Linux/WSL 遇到 `EACCES` 权限错误,可任选其一:
25
-
26
- ```bash
27
- # 临时
28
- sudo npm install -g homegraph
29
-
30
- # 或把全局目录改到用户家目录(推荐)
31
- mkdir -p ~/.npm-global
32
- npm config set prefix ~/.npm-global
33
- echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.bashrc
34
- source ~/.bashrc
35
- npm install -g homegraph
36
- ```
37
-
38
- 验证:
39
-
40
- ```bash
41
- homegraph --version
42
- ```
43
-
44
- ### 2. 接入 AI 助手
45
-
46
- 在新终端中运行交互式安装器,自动写入各 Agent 的 MCP 配置:
47
-
48
- ```bash
49
- homegraph install
50
- ```
51
-
52
- #### 支持的 Agent 与 `--target` 取值
53
-
54
- | Agent | `--target` |
55
- |-------|------------|
56
- | Claude Code | `claude` |
57
- | Cursor | `cursor` |
58
- | Codex CLI | `codex` |
59
- | opencode | `opencode` |
60
- | DevEco Code | `deveco` |
61
- | CodeBuddy | `codebuddy` |
62
- | Hermes Agent | `hermes` |
63
- | Gemini CLI | `gemini` |
64
- | Antigravity IDE | `antigravity` |
65
- | Kiro | `kiro` |
66
-
67
- `--target` 还支持特殊取值:
68
-
69
- | 取值 | 说明 |
70
- |------|------|
71
- | `auto` | 自动检测本机已安装的 Agent(`--yes` 默认值) |
72
- | `all` | 写入全部 Agent |
73
- | `none` | 不写入任何 Agent 配置 |
74
-
75
- 安装位置 `--location`:
76
-
77
- - `global` — 写入用户目录,对所有项目生效(`--yes` 默认值)
78
- - `local` — 仅写入当前项目目录
79
-
80
- > Codex CLI、Hermes Agent、Antigravity IDE **仅支持** `--location=global`;选 `local` 时会被跳过。
81
-
82
- #### 非交互式示例
83
-
84
- ```bash
85
- # 自动检测已安装 Agent 并全局安装
86
- homegraph install --yes
87
-
88
- # 同时为 Cursor 和 DevEco Code 写入全局 MCP 配置
89
- homegraph install --target=cursor,deveco --location=global --yes
90
-
91
- # 单个 Agent
92
- homegraph install --target=claude --location=global --yes # Claude Code
93
- homegraph install --target=cursor --location=global --yes # Cursor
94
- homegraph install --target=codex --location=global --yes # Codex CLI
95
- homegraph install --target=opencode --location=global --yes # opencode
96
- homegraph install --target=deveco --location=global --yes # DevEco Code
97
- homegraph install --target=codebuddy --location=global --yes # CodeBuddy
98
- homegraph install --target=hermes --location=global --yes # Hermes Agent
99
- homegraph install --target=gemini --location=global --yes # Gemini CLI
100
- homegraph install --target=antigravity --location=global --yes # Antigravity IDE
101
- homegraph install --target=kiro --location=global --yes # Kiro
102
-
103
- # 写入全部 Agent(全局)
104
- homegraph install --target=all --location=global --yes
105
-
106
- # 项目级安装(仅对当前项目生效,如 ./.cursor/mcp.json)
107
- homegraph install --target=cursor --location=local --yes
108
- homegraph install --target=claude,cursor --location=local --yes
109
- ```
110
-
111
- 安装完成后**重启对应 Agent**,使 MCP 配置生效。
112
-
113
- ### 3. 初始化项目
114
-
115
- ```bash
116
- cd your-project
117
- homegraph init -i
118
- ```
119
-
120
- - `homegraph init`:仅创建 `.homegraph/` 索引目录
121
- - `homegraph init -i`:创建目录并立即建立索引(推荐)
122
-
123
- 索引建立后,Agent 可通过 MCP 工具查询符号、调用链、影响范围等。
124
-
125
- ### 卸载
126
-
127
- ```bash
128
- homegraph uninstall # 从各 Agent 移除 MCP 配置
129
- homegraph uninit # 删除当前项目的 .homegraph/ 索引
130
- ```
131
-
132
- ---
133
-
134
- ## 常用命令
135
-
136
- ```bash
137
- homegraph install # 配置 AI 助手
138
- homegraph init -i [path] # 初始化并索引项目
139
- homegraph index [path] # 全量索引(--force 强制重建)
140
- homegraph sync [path] # 增量同步变更
141
- homegraph status [path] # 查看索引状态
142
- homegraph query <关键词> # 搜索符号
143
- homegraph callers <符号> # 谁调用了它
144
- homegraph callees <符号> # 它调用了谁
145
- homegraph impact <符号> # 修改该符号的影响范围
146
- homegraph serve --mcp # 启动 MCP 服务(一般由 Agent 自动拉起)
147
- ```
148
-
149
- ---
150
-
151
- ## MCP 工具
152
-
153
- Agent 侧工具名前缀为 `homegraph_`:
154
-
155
- | 工具 | 用途 |
156
- |------|------|
157
- | `homegraph_explore` | 主要工具:一次返回相关符号源码与调用关系 |
158
- | `homegraph_search` | 按名称快速定位符号 |
159
- | `homegraph_callers` / `homegraph_callees` | 查看调用方 / 被调用方 |
160
- | `homegraph_impact` | 变更影响分析 |
161
- | `homegraph_node` | 单个符号的完整源码与上下文 |
162
- | `homegraph_files` | 已索引的文件结构 |
163
- | `homegraph_status` | 索引健康状态 |
164
-
165
- ---
166
-
167
- ## 支持的语言
168
-
169
- 继承上游多语言 tree-sitter 解析,包括但不限于:
170
-
171
- TypeScript / JavaScript、Python、Go、Rust、Java、C#、PHP、Ruby、C / C++、Objective-C、Swift、Kotlin、Scala、Dart、Lua、Luau、Svelte、Vue、Liquid、Pascal / Delphi 等。
172
-
173
- **HomeGraph 新增:**
174
-
175
- | 语言 | 扩展名 | 说明 |
176
- |------|--------|------|
177
- | **ArkTS** | `.ets` 等 | 基于 arkanalyzer,支持 HarmonyOS 工程的类、方法、导入与调用关系提取 |
178
-
179
- ---
180
-
181
- ## 从源码构建
182
-
183
- 适用于开发或二次修改:
184
-
185
- ```bash
186
- git clone <your-repo-url>
187
- cd homegraph # 仓库目录名可仍为 homegraph
188
- npm install
189
- npm run build
190
- npm run cli -- --help # 或直接:node dist/bin/homegraph.js --help
191
- npm test # 运行测试
192
- ```
193
-
194
- 本地调试 CLI:
195
-
196
- ```bash
197
- npm run cli
198
- # 等价于 npm run build && node dist/bin/homegraph.js
199
- ```
200
-
201
- ---
202
-
203
- ## 手动配置 MCP(可选)
204
-
205
- 以 Claude Code 为例,在 `~/.claude.json` 中添加:
206
-
207
- ```json
208
- {
209
- "mcpServers": {
210
- "homegraph": {
211
- "type": "stdio",
212
- "command": "homegraph",
213
- "args": ["serve", "--mcp"]
214
- }
215
- }
216
- }
217
- ```
218
-
219
- Cursor 等项目级配置写入 `./.cursor/mcp.json`,格式相同。推荐使用 `homegraph install` 自动完成。
220
-
221
- ---
222
-
223
- ## 上游同步
224
-
225
- | 项目 | 说明 |
226
- |------|------|
227
- | 上游 | 持续同步 colbymchenry 开源知识图谱项目 main 分支 |
228
- | 包名 / CLI | `homegraph`(npm:`npm install -g homegraph`) |
229
- | 数据目录 | `.homegraph/` |
230
- | 主要差异 | 新增 **ArkTS** 语言支持与相关索引逻辑 |
231
-
232
- ---
233
-
234
- ## 环境要求
235
-
236
- - Node.js **22.5+**(推荐 22 LTS 或 24;使用 Node 内置 `node:sqlite`)
237
- - 首次索引时会对项目源码做 AST 解析,大型仓库首次 `init -i` 可能需要数分钟
238
-
239
- ---
240
-
241
- ## 许可证
242
-
243
- MIT
1
+ # HomeGraph
2
+
3
+ 本地代码知识图谱工具,面向 AI 编程助手(Claude Code、Cursor、Codex 等)提供 MCP 服务。
4
+
5
+ 在开源知识图谱能力之上,**HomeGraph 新增了对 ArkTS(HarmonyOS)的支持**,通过 [arkanalyzer](https://www.npmjs.com/package/arkanalyzer) 解析 `.ets` / `.ts` 工程中的符号、调用关系与模块结构。
6
+
7
+ 数据全部保存在本机 `.homegraph/` 目录,不上传云端。
8
+
9
+ [![npm version](https://img.shields.io/npm/v/homegraph.svg)](https://www.npmjs.com/package/homegraph)
10
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
11
+
12
+ ---
13
+
14
+ ## 快速开始
15
+
16
+ ### 1. 安装 CLI
17
+
18
+ 需要 **Node.js 22.5+**(推荐 22 LTS 或 24)。HomeGraph 使用 Node 内置的 `node:sqlite`,22.5 以下无法运行。
19
+
20
+ ```bash
21
+ npm install -g homegraph
22
+ ```
23
+
24
+ 若在 Linux/WSL 遇到 `EACCES` 权限错误,可任选其一:
25
+
26
+ ```bash
27
+ # 临时
28
+ sudo npm install -g homegraph
29
+
30
+ # 或把全局目录改到用户家目录(推荐)
31
+ mkdir -p ~/.npm-global
32
+ npm config set prefix ~/.npm-global
33
+ echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.bashrc
34
+ source ~/.bashrc
35
+ npm install -g homegraph
36
+ ```
37
+
38
+ 验证:
39
+
40
+ ```bash
41
+ homegraph --version
42
+ ```
43
+
44
+ ### 2. 接入 AI 助手
45
+
46
+ 在新终端中运行交互式安装器,自动写入各 Agent 的 MCP 配置:
47
+
48
+ ```bash
49
+ homegraph install
50
+ ```
51
+
52
+ #### 支持的 Agent 与 `--target` 取值
53
+
54
+ | Agent | `--target` |
55
+ |-------|------------|
56
+ | Claude Code | `claude` |
57
+ | Cursor | `cursor` |
58
+ | Codex CLI | `codex` |
59
+ | opencode | `opencode` |
60
+ | DevEco Code | `deveco` |
61
+ | CodeBuddy | `codebuddy` |
62
+ | Hermes Agent | `hermes` |
63
+ | Gemini CLI | `gemini` |
64
+ | Antigravity IDE | `antigravity` |
65
+ | Kiro | `kiro` |
66
+
67
+ `--target` 还支持特殊取值:
68
+
69
+ | 取值 | 说明 |
70
+ |------|------|
71
+ | `auto` | 自动检测本机已安装的 Agent(`--yes` 默认值) |
72
+ | `all` | 写入全部 Agent |
73
+ | `none` | 不写入任何 Agent 配置 |
74
+
75
+ 安装位置 `--location`:
76
+
77
+ - `global` — 写入用户目录,对所有项目生效(`--yes` 默认值)
78
+ - `local` — 仅写入当前项目目录
79
+
80
+ > Codex CLI、Hermes Agent、Antigravity IDE **仅支持** `--location=global`;选 `local` 时会被跳过。
81
+
82
+ #### 非交互式示例
83
+
84
+ ```bash
85
+ # 自动检测已安装 Agent 并全局安装
86
+ homegraph install --yes
87
+
88
+ # 同时为 Cursor 和 DevEco Code 写入全局 MCP 配置
89
+ homegraph install --target=cursor,deveco --location=global --yes
90
+
91
+ # 单个 Agent
92
+ homegraph install --target=claude --location=global --yes # Claude Code
93
+ homegraph install --target=cursor --location=global --yes # Cursor
94
+ homegraph install --target=codex --location=global --yes # Codex CLI
95
+ homegraph install --target=opencode --location=global --yes # opencode
96
+ homegraph install --target=deveco --location=global --yes # DevEco Code
97
+ homegraph install --target=codebuddy --location=global --yes # CodeBuddy
98
+ homegraph install --target=hermes --location=global --yes # Hermes Agent
99
+ homegraph install --target=gemini --location=global --yes # Gemini CLI
100
+ homegraph install --target=antigravity --location=global --yes # Antigravity IDE
101
+ homegraph install --target=kiro --location=global --yes # Kiro
102
+
103
+ # 写入全部 Agent(全局)
104
+ homegraph install --target=all --location=global --yes
105
+
106
+ # 项目级安装(仅对当前项目生效,如 ./.cursor/mcp.json)
107
+ homegraph install --target=cursor --location=local --yes
108
+ homegraph install --target=claude,cursor --location=local --yes
109
+ ```
110
+
111
+ 安装完成后**重启对应 Agent**,使 MCP 配置生效。
112
+
113
+ ### 3. 初始化项目
114
+
115
+ ```bash
116
+ cd your-project
117
+ homegraph init -i
118
+ ```
119
+
120
+ - `homegraph init`:仅创建 `.homegraph/` 索引目录
121
+ - `homegraph init -i`:创建目录并立即建立索引(推荐)
122
+
123
+ 索引建立后,Agent 可通过 MCP 工具查询符号、调用链、影响范围等。
124
+
125
+ ### 卸载
126
+
127
+ ```bash
128
+ homegraph uninstall # 从各 Agent 移除 MCP 配置
129
+ homegraph uninit # 删除当前项目的 .homegraph/ 索引
130
+ ```
131
+
132
+ ---
133
+
134
+ ## 常用命令
135
+
136
+ ```bash
137
+ homegraph install # 配置 AI 助手
138
+ homegraph init -i [path] # 初始化并索引项目
139
+ homegraph index [path] # 全量索引(--force 强制重建)
140
+ homegraph sync [path] # 增量同步变更
141
+ homegraph status [path] # 查看索引状态
142
+ homegraph query <关键词> # 搜索符号
143
+ homegraph callers <符号> # 谁调用了它
144
+ homegraph callees <符号> # 它调用了谁
145
+ homegraph impact <符号> # 修改该符号的影响范围
146
+ homegraph serve --mcp # 启动 MCP 服务(一般由 Agent 自动拉起)
147
+ ```
148
+
149
+ ---
150
+
151
+ ## MCP 工具
152
+
153
+ Agent 侧工具名前缀为 `homegraph_`:
154
+
155
+ | 工具 | 用途 |
156
+ |------|------|
157
+ | `homegraph_explore` | 主要工具:一次返回相关符号源码与调用关系 |
158
+ | `homegraph_search` | 按名称快速定位符号 |
159
+ | `homegraph_callers` / `homegraph_callees` | 查看调用方 / 被调用方 |
160
+ | `homegraph_impact` | 变更影响分析 |
161
+ | `homegraph_node` | 单个符号的完整源码与上下文 |
162
+ | `homegraph_files` | 已索引的文件结构 |
163
+ | `homegraph_status` | 索引健康状态 |
164
+
165
+ ---
166
+
167
+ ## 支持的语言
168
+
169
+ 继承上游多语言 tree-sitter 解析,包括但不限于:
170
+
171
+ TypeScript / JavaScript、Python、Go、Rust、Java、C#、PHP、Ruby、C / C++、Objective-C、Swift、Kotlin、Scala、Dart、Lua、Luau、Svelte、Vue、Liquid、Pascal / Delphi 等。
172
+
173
+ **HomeGraph 新增:**
174
+
175
+ | 语言 | 扩展名 | 说明 |
176
+ |------|--------|------|
177
+ | **ArkTS** | `.ets` 等 | 基于 arkanalyzer,支持 HarmonyOS 工程的类、方法、导入与调用关系提取 |
178
+
179
+ ---
180
+
181
+ ## 从源码构建
182
+
183
+ 适用于开发或二次修改:
184
+
185
+ ```bash
186
+ git clone <your-repo-url>
187
+ cd homegraph # 仓库目录名可仍为 homegraph
188
+ npm install
189
+ npm run build
190
+ npm run cli -- --help # 或直接:node dist/bin/homegraph.js --help
191
+ npm test # 运行测试
192
+ ```
193
+
194
+ 本地调试 CLI:
195
+
196
+ ```bash
197
+ npm run cli
198
+ # 等价于 npm run build && node dist/bin/homegraph.js
199
+ ```
200
+
201
+ ---
202
+
203
+ ## 手动配置 MCP(可选)
204
+
205
+ 以 Claude Code 为例,在 `~/.claude.json` 中添加:
206
+
207
+ ```json
208
+ {
209
+ "mcpServers": {
210
+ "homegraph": {
211
+ "type": "stdio",
212
+ "command": "homegraph",
213
+ "args": ["serve", "--mcp"]
214
+ }
215
+ }
216
+ }
217
+ ```
218
+
219
+ Cursor 等项目级配置写入 `./.cursor/mcp.json`,格式相同。推荐使用 `homegraph install` 自动完成。
220
+
221
+ ---
222
+
223
+ ## 上游同步
224
+
225
+ | 项目 | 说明 |
226
+ |------|------|
227
+ | 上游 | 持续同步 colbymchenry 开源知识图谱项目 main 分支 |
228
+ | 包名 / CLI | `homegraph`(npm:`npm install -g homegraph`) |
229
+ | 数据目录 | `.homegraph/` |
230
+ | 主要差异 | 新增 **ArkTS** 语言支持与相关索引逻辑 |
231
+
232
+ ---
233
+
234
+ ## 环境要求
235
+
236
+ - Node.js **22.5+**(推荐 22 LTS 或 24;使用 Node 内置 `node:sqlite`)
237
+ - 首次索引时会对项目源码做 AST 解析,大型仓库首次 `init -i` 可能需要数分钟
238
+
239
+ ---
240
+
241
+ ## 许可证
242
+
243
+ MIT