homegraph 1.2.0 → 1.4.1

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 (284) hide show
  1. package/dist/bin/homegraph.js +3 -0
  2. package/dist/bin/homegraph.js.map +1 -1
  3. package/dist/context/index.d.ts.map +1 -1
  4. package/dist/context/index.js +85 -0
  5. package/dist/context/index.js.map +1 -1
  6. package/dist/db/index.d.ts +64 -5
  7. package/dist/db/index.d.ts.map +1 -1
  8. package/dist/db/index.js +178 -14
  9. package/dist/db/index.js.map +1 -1
  10. package/dist/db/migrations.d.ts +1 -1
  11. package/dist/db/migrations.d.ts.map +1 -1
  12. package/dist/db/migrations.js +19 -1
  13. package/dist/db/migrations.js.map +1 -1
  14. package/dist/db/queries.d.ts +117 -2
  15. package/dist/db/queries.d.ts.map +1 -1
  16. package/dist/db/queries.js +299 -6
  17. package/dist/db/queries.js.map +1 -1
  18. package/dist/db/schema.sql +32 -1
  19. package/dist/db/wal-valve.d.ts +106 -0
  20. package/dist/db/wal-valve.d.ts.map +1 -0
  21. package/dist/db/wal-valve.js +208 -0
  22. package/dist/db/wal-valve.js.map +1 -0
  23. package/dist/directory.d.ts +9 -5
  24. package/dist/directory.d.ts.map +1 -1
  25. package/dist/directory.js +210 -19
  26. package/dist/directory.js.map +1 -1
  27. package/dist/extraction/cfml-extractor.d.ts +107 -0
  28. package/dist/extraction/cfml-extractor.d.ts.map +1 -0
  29. package/dist/extraction/cfml-extractor.js +494 -0
  30. package/dist/extraction/cfml-extractor.js.map +1 -0
  31. package/dist/extraction/grammars.d.ts +25 -1
  32. package/dist/extraction/grammars.d.ts.map +1 -1
  33. package/dist/extraction/grammars.js +177 -24
  34. package/dist/extraction/grammars.js.map +1 -1
  35. package/dist/extraction/index.d.ts +43 -4
  36. package/dist/extraction/index.d.ts.map +1 -1
  37. package/dist/extraction/index.js +308 -5
  38. package/dist/extraction/index.js.map +1 -1
  39. package/dist/extraction/languages/c-cpp.d.ts +42 -0
  40. package/dist/extraction/languages/c-cpp.d.ts.map +1 -1
  41. package/dist/extraction/languages/c-cpp.js +369 -4
  42. package/dist/extraction/languages/c-cpp.js.map +1 -1
  43. package/dist/extraction/languages/cfquery.d.ts +12 -0
  44. package/dist/extraction/languages/cfquery.d.ts.map +1 -0
  45. package/dist/extraction/languages/cfquery.js +28 -0
  46. package/dist/extraction/languages/cfquery.js.map +1 -0
  47. package/dist/extraction/languages/cfscript.d.ts +3 -0
  48. package/dist/extraction/languages/cfscript.d.ts.map +1 -0
  49. package/dist/extraction/languages/cfscript.js +73 -0
  50. package/dist/extraction/languages/cfscript.js.map +1 -0
  51. package/dist/extraction/languages/cobol.d.ts +33 -0
  52. package/dist/extraction/languages/cobol.d.ts.map +1 -0
  53. package/dist/extraction/languages/cobol.js +499 -0
  54. package/dist/extraction/languages/cobol.js.map +1 -0
  55. package/dist/extraction/languages/erlang.d.ts +3 -0
  56. package/dist/extraction/languages/erlang.d.ts.map +1 -0
  57. package/dist/extraction/languages/erlang.js +350 -0
  58. package/dist/extraction/languages/erlang.js.map +1 -0
  59. package/dist/extraction/languages/index.d.ts.map +1 -1
  60. package/dist/extraction/languages/index.js +16 -0
  61. package/dist/extraction/languages/index.js.map +1 -1
  62. package/dist/extraction/languages/nix.d.ts +3 -0
  63. package/dist/extraction/languages/nix.d.ts.map +1 -0
  64. package/dist/extraction/languages/nix.js +294 -0
  65. package/dist/extraction/languages/nix.js.map +1 -0
  66. package/dist/extraction/languages/solidity.d.ts +3 -0
  67. package/dist/extraction/languages/solidity.d.ts.map +1 -0
  68. package/dist/extraction/languages/solidity.js +293 -0
  69. package/dist/extraction/languages/solidity.js.map +1 -0
  70. package/dist/extraction/languages/terraform.d.ts +3 -0
  71. package/dist/extraction/languages/terraform.d.ts.map +1 -0
  72. package/dist/extraction/languages/terraform.js +641 -0
  73. package/dist/extraction/languages/terraform.js.map +1 -0
  74. package/dist/extraction/languages/vbnet.d.ts +11 -0
  75. package/dist/extraction/languages/vbnet.d.ts.map +1 -0
  76. package/dist/extraction/languages/vbnet.js +141 -0
  77. package/dist/extraction/languages/vbnet.js.map +1 -0
  78. package/dist/extraction/mybatis-extractor.d.ts +30 -10
  79. package/dist/extraction/mybatis-extractor.d.ts.map +1 -1
  80. package/dist/extraction/mybatis-extractor.js +140 -38
  81. package/dist/extraction/mybatis-extractor.js.map +1 -1
  82. package/dist/extraction/parse-pool.d.ts +27 -1
  83. package/dist/extraction/parse-pool.d.ts.map +1 -1
  84. package/dist/extraction/parse-pool.js +75 -7
  85. package/dist/extraction/parse-pool.js.map +1 -1
  86. package/dist/extraction/parse-worker.js +9 -2
  87. package/dist/extraction/parse-worker.js.map +1 -1
  88. package/dist/extraction/tree-sitter-helpers.d.ts.map +1 -1
  89. package/dist/extraction/tree-sitter-helpers.js +1 -0
  90. package/dist/extraction/tree-sitter-helpers.js.map +1 -1
  91. package/dist/extraction/tree-sitter-types.d.ts +3 -1
  92. package/dist/extraction/tree-sitter-types.d.ts.map +1 -1
  93. package/dist/extraction/tree-sitter.d.ts +38 -0
  94. package/dist/extraction/tree-sitter.d.ts.map +1 -1
  95. package/dist/extraction/tree-sitter.js +754 -10
  96. package/dist/extraction/tree-sitter.js.map +1 -1
  97. package/dist/extraction/wasm/tree-sitter-arkts.wasm +0 -0
  98. package/dist/extraction/wasm/tree-sitter-cfml.wasm +0 -0
  99. package/dist/extraction/wasm/tree-sitter-cfquery.wasm +0 -0
  100. package/dist/extraction/wasm/tree-sitter-cfscript.wasm +0 -0
  101. package/dist/extraction/wasm/tree-sitter-cobol.wasm +0 -0
  102. package/dist/extraction/wasm/tree-sitter-erlang.wasm +0 -0
  103. package/dist/extraction/wasm/tree-sitter-nix.wasm +0 -0
  104. package/dist/extraction/wasm/tree-sitter-terraform.wasm +0 -0
  105. package/dist/extraction/wasm/tree-sitter-vbnet.wasm +0 -0
  106. package/dist/graph/traversal.d.ts.map +1 -1
  107. package/dist/graph/traversal.js +1 -1
  108. package/dist/graph/traversal.js.map +1 -1
  109. package/dist/index.d.ts +60 -2
  110. package/dist/index.d.ts.map +1 -1
  111. package/dist/index.js +348 -5
  112. package/dist/index.js.map +1 -1
  113. package/dist/installer/index.d.ts +42 -0
  114. package/dist/installer/index.d.ts.map +1 -1
  115. package/dist/installer/index.js +97 -2
  116. package/dist/installer/index.js.map +1 -1
  117. package/dist/mcp/daemon.d.ts +25 -3
  118. package/dist/mcp/daemon.d.ts.map +1 -1
  119. package/dist/mcp/daemon.js +62 -8
  120. package/dist/mcp/daemon.js.map +1 -1
  121. package/dist/mcp/dynamic-boundaries.d.ts.map +1 -1
  122. package/dist/mcp/dynamic-boundaries.js +2 -1
  123. package/dist/mcp/dynamic-boundaries.js.map +1 -1
  124. package/dist/mcp/early-ppid.d.ts +26 -0
  125. package/dist/mcp/early-ppid.d.ts.map +1 -0
  126. package/dist/mcp/early-ppid.js +29 -0
  127. package/dist/mcp/early-ppid.js.map +1 -0
  128. package/dist/mcp/engine.d.ts +4 -5
  129. package/dist/mcp/engine.d.ts.map +1 -1
  130. package/dist/mcp/engine.js +27 -1
  131. package/dist/mcp/engine.js.map +1 -1
  132. package/dist/mcp/index.d.ts.map +1 -1
  133. package/dist/mcp/index.js +41 -6
  134. package/dist/mcp/index.js.map +1 -1
  135. package/dist/mcp/liveness-watchdog.d.ts +18 -1
  136. package/dist/mcp/liveness-watchdog.d.ts.map +1 -1
  137. package/dist/mcp/liveness-watchdog.js +73 -13
  138. package/dist/mcp/liveness-watchdog.js.map +1 -1
  139. package/dist/mcp/memory-budget.d.ts +30 -0
  140. package/dist/mcp/memory-budget.d.ts.map +1 -0
  141. package/dist/mcp/memory-budget.js +123 -0
  142. package/dist/mcp/memory-budget.js.map +1 -0
  143. package/dist/mcp/proxy.d.ts.map +1 -1
  144. package/dist/mcp/proxy.js +88 -4
  145. package/dist/mcp/proxy.js.map +1 -1
  146. package/dist/mcp/query-cache.d.ts +35 -4
  147. package/dist/mcp/query-cache.d.ts.map +1 -1
  148. package/dist/mcp/query-cache.js +89 -19
  149. package/dist/mcp/query-cache.js.map +1 -1
  150. package/dist/mcp/query-pool.d.ts +46 -12
  151. package/dist/mcp/query-pool.d.ts.map +1 -1
  152. package/dist/mcp/query-pool.js +100 -23
  153. package/dist/mcp/query-pool.js.map +1 -1
  154. package/dist/mcp/server-instructions.d.ts +4 -27
  155. package/dist/mcp/server-instructions.d.ts.map +1 -1
  156. package/dist/mcp/server-instructions.js +39 -84
  157. package/dist/mcp/server-instructions.js.map +1 -1
  158. package/dist/mcp/session.d.ts +14 -0
  159. package/dist/mcp/session.d.ts.map +1 -1
  160. package/dist/mcp/session.js +28 -1
  161. package/dist/mcp/session.js.map +1 -1
  162. package/dist/mcp/startup-handshake.d.ts +44 -0
  163. package/dist/mcp/startup-handshake.d.ts.map +1 -0
  164. package/dist/mcp/startup-handshake.js +73 -0
  165. package/dist/mcp/startup-handshake.js.map +1 -0
  166. package/dist/mcp/tools.d.ts +104 -4
  167. package/dist/mcp/tools.d.ts.map +1 -1
  168. package/dist/mcp/tools.js +2390 -191
  169. package/dist/mcp/tools.js.map +1 -1
  170. package/dist/mcp/transport.d.ts.map +1 -1
  171. package/dist/mcp/transport.js +18 -0
  172. package/dist/mcp/transport.js.map +1 -1
  173. package/dist/project-config.d.ts +38 -0
  174. package/dist/project-config.d.ts.map +1 -1
  175. package/dist/project-config.js +101 -2
  176. package/dist/project-config.js.map +1 -1
  177. package/dist/resolution/c-fnptr-synthesizer.d.ts +2 -1
  178. package/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -1
  179. package/dist/resolution/c-fnptr-synthesizer.js +178 -146
  180. package/dist/resolution/c-fnptr-synthesizer.js.map +1 -1
  181. package/dist/resolution/callback-synthesizer.d.ts +9 -1
  182. package/dist/resolution/callback-synthesizer.d.ts.map +1 -1
  183. package/dist/resolution/callback-synthesizer.js +1164 -176
  184. package/dist/resolution/callback-synthesizer.js.map +1 -1
  185. package/dist/resolution/frameworks/cics.d.ts +20 -0
  186. package/dist/resolution/frameworks/cics.d.ts.map +1 -0
  187. package/dist/resolution/frameworks/cics.js +90 -0
  188. package/dist/resolution/frameworks/cics.js.map +1 -0
  189. package/dist/resolution/frameworks/index.d.ts.map +1 -1
  190. package/dist/resolution/frameworks/index.js +3 -0
  191. package/dist/resolution/frameworks/index.js.map +1 -1
  192. package/dist/resolution/frameworks/java.d.ts.map +1 -1
  193. package/dist/resolution/frameworks/java.js +14 -6
  194. package/dist/resolution/frameworks/java.js.map +1 -1
  195. package/dist/resolution/frameworks/terraform.d.ts +38 -0
  196. package/dist/resolution/frameworks/terraform.d.ts.map +1 -0
  197. package/dist/resolution/frameworks/terraform.js +277 -0
  198. package/dist/resolution/frameworks/terraform.js.map +1 -0
  199. package/dist/resolution/goframe-synthesizer.d.ts +2 -1
  200. package/dist/resolution/goframe-synthesizer.d.ts.map +1 -1
  201. package/dist/resolution/goframe-synthesizer.js +8 -3
  202. package/dist/resolution/goframe-synthesizer.js.map +1 -1
  203. package/dist/resolution/import-resolver.d.ts +7 -0
  204. package/dist/resolution/import-resolver.d.ts.map +1 -1
  205. package/dist/resolution/import-resolver.js +129 -4
  206. package/dist/resolution/import-resolver.js.map +1 -1
  207. package/dist/resolution/index.d.ts +60 -7
  208. package/dist/resolution/index.d.ts.map +1 -1
  209. package/dist/resolution/index.js +430 -80
  210. package/dist/resolution/index.js.map +1 -1
  211. package/dist/resolution/name-matcher.d.ts +0 -3
  212. package/dist/resolution/name-matcher.d.ts.map +1 -1
  213. package/dist/resolution/name-matcher.js +354 -33
  214. package/dist/resolution/name-matcher.js.map +1 -1
  215. package/dist/resolution/strip-comments.d.ts +1 -1
  216. package/dist/resolution/strip-comments.d.ts.map +1 -1
  217. package/dist/resolution/strip-comments.js +49 -0
  218. package/dist/resolution/strip-comments.js.map +1 -1
  219. package/dist/resolution/types.d.ts +29 -0
  220. package/dist/resolution/types.d.ts.map +1 -1
  221. package/dist/resolution/workspace-packages.d.ts +10 -0
  222. package/dist/resolution/workspace-packages.d.ts.map +1 -1
  223. package/dist/resolution/workspace-packages.js +142 -4
  224. package/dist/resolution/workspace-packages.js.map +1 -1
  225. package/dist/search/identifier-segments.d.ts +60 -0
  226. package/dist/search/identifier-segments.d.ts.map +1 -0
  227. package/dist/search/identifier-segments.js +176 -0
  228. package/dist/search/identifier-segments.js.map +1 -0
  229. package/dist/search/query-utils.d.ts +201 -0
  230. package/dist/search/query-utils.d.ts.map +1 -1
  231. package/dist/search/query-utils.js +919 -2
  232. package/dist/search/query-utils.js.map +1 -1
  233. package/dist/sync/git-hooks.d.ts.map +1 -1
  234. package/dist/sync/git-hooks.js +2 -0
  235. package/dist/sync/git-hooks.js.map +1 -1
  236. package/dist/sync/watcher.d.ts +10 -5
  237. package/dist/sync/watcher.d.ts.map +1 -1
  238. package/dist/sync/watcher.js +51 -14
  239. package/dist/sync/watcher.js.map +1 -1
  240. package/dist/sync/worktree.d.ts.map +1 -1
  241. package/dist/sync/worktree.js +5 -0
  242. package/dist/sync/worktree.js.map +1 -1
  243. package/dist/types.d.ts +19 -1
  244. package/dist/types.d.ts.map +1 -1
  245. package/dist/types.js +10 -0
  246. package/dist/types.js.map +1 -1
  247. package/dist/upgrade/index.d.ts +32 -0
  248. package/dist/upgrade/index.d.ts.map +1 -1
  249. package/dist/upgrade/index.js +162 -14
  250. package/dist/upgrade/index.js.map +1 -1
  251. package/dist/upgrade/remove-binary.d.ts +87 -0
  252. package/dist/upgrade/remove-binary.d.ts.map +1 -0
  253. package/dist/upgrade/remove-binary.js +289 -0
  254. package/dist/upgrade/remove-binary.js.map +1 -0
  255. package/dist/upgrade/update-check.d.ts +92 -0
  256. package/dist/upgrade/update-check.d.ts.map +1 -0
  257. package/dist/upgrade/update-check.js +258 -0
  258. package/dist/upgrade/update-check.js.map +1 -0
  259. package/package.json +2 -2
  260. package/scripts/agent-eval/run-all.sh +6 -0
  261. package/scripts/build-bundle.sh +5 -0
  262. package/scripts/npm-shim.js +8 -1
  263. package/scripts/exp_boundary_eval/__pycache__/_utils.cpython-310.pyc +0 -0
  264. package/scripts/exp_boundary_eval/__pycache__/analyze.cpython-310.pyc +0 -0
  265. package/scripts/exp_boundary_eval/__pycache__/deveco_arm.cpython-310.pyc +0 -0
  266. package/scripts/exp_boundary_eval/__pycache__/run_one.cpython-310.pyc +0 -0
  267. package/scripts/exp_boundary_eval/__pycache__/run_session.cpython-310.pyc +0 -0
  268. package/scripts/exp_boundary_eval/__pycache__/setup.cpython-310.pyc +0 -0
  269. package/scripts/exp_boundary_eval/data/agents.json +0 -109
  270. package/scripts/exp_boundary_eval/data/experiments.json +0 -140
  271. package/scripts/qa_eval/README.md +0 -407
  272. package/scripts/qa_eval/_test_deveco_probe.py +0 -41
  273. package/scripts/qa_eval/agent_runner.py +0 -526
  274. package/scripts/qa_eval/data/.gitignore +0 -4
  275. package/scripts/qa_eval/data/test-set.jsonl +0 -2
  276. package/scripts/qa_eval/eval_metrics.py +0 -274
  277. package/scripts/qa_eval/external_agent.py +0 -976
  278. package/scripts/qa_eval/llm_config.py +0 -92
  279. package/scripts/qa_eval/memory_monitor.py +0 -132
  280. package/scripts/qa_eval/my_answer_accuracy.py +0 -187
  281. package/scripts/qa_eval/requirements.txt +0 -2
  282. package/scripts/qa_eval/run_pipeline.py +0 -804
  283. package/scripts/qa_eval/stats_efficiency.py +0 -279
  284. package/scripts/qa_eval/stats_scores.py +0 -207
@@ -1,407 +0,0 @@
1
- # QA Eval — 四段式 A/B 评测流水线
2
-
3
- 内置多轮 Agent + Judge + 统计 + 报告,对齐 CodeGenie / Trae 评测框架:**Agent 跑题 → Judge 打分 → 分数统计 → 效率统计 → A/B 对比**。
4
-
5
- - **国内可用**:builtin Agent / Judge 走 OpenAI 兼容接口(DashScope Qwen 或智谱 GLM)
6
- - **多 Agent 宿主**:builtin Python Agent、Claude Code CLI、DevEco Code CLI
7
- - **不依赖** ragas / langchain
8
- - **被测仓库**:运行时用 `--repo` / `-r` 指定,无默认路径
9
-
10
- ## 测试输入
11
-
12
- **格式**:JSONL,一行一条,UTF-8。
13
-
14
- ```json
15
- {
16
- "id": "R01",
17
- "query": "...",
18
- "reference_answer": "...",
19
- "category_l1": "检索",
20
- "category_l2": "函数"
21
- }
22
- ```
23
-
24
- | 字段 | 必填 | 说明 |
25
- |------|------|------|
26
- | `id` | 是 | 题号,如 `R01` / `E03` / `D05` |
27
- | `query` | 是 | 给 Agent 的问题 |
28
- | `reference_answer` | 是 | 参考答案(Judge 对照) |
29
- | `category_l1` | 建议 | 一级分类:`检索` / `解读` / `依赖`(仅报告分组) |
30
- | `category_l2` | 可选 | 二级分类(仅报告分组) |
31
- | `level0` / `level1` / `difficulty` / `language` | 可选 | 元数据,Judge 不读取 |
32
-
33
- **默认测试集**:`scripts/qa_eval/data/test-set.jsonl`(完整集 20 条:检索 7 + 解读 7 + 依赖 6;可按需增删行)。
34
-
35
- ## 目录结构
36
-
37
- ```
38
- scripts/qa_eval/
39
- ├── agent_runner.py # Stage 1a:builtin 多轮 Agent(with / without)
40
- ├── external_agent.py # Stage 1b:Claude Code / DevEco Code 外部 Agent
41
- ├── my_answer_accuracy.py # Judge 指标(双 prompt 0–5 归一化)
42
- ├── eval_metrics.py # Stage 2:对 JSONL 批量打分
43
- ├── stats_scores.py # Stage 3:answer_accuracy_score 汇总
44
- ├── stats_efficiency.py # Stage 4:解析 Agent 日志(首响应/轮次/耗时/Token/内存)
45
- ├── memory_monitor.py # 进程树 RSS 采样(Linux /proc;WSL 可用)
46
- ├── llm_config.py # DashScope / 智谱 provider 预设
47
- ├── run_pipeline.py # 编排 Stage 1–4 + A/B 报告
48
- ├── _test_deveco_probe.py # DevEco 单题探测脚本(开发调试用)
49
- ├── requirements.txt
50
- ├── data/ # 测试集 + 报告(报告不入库)
51
- │ ├── test-set.jsonl # 测试集(入库)
52
- │ └── report-{host}.txt # 完整 A/B 报告(gitignore,留在 data/)
53
- └── log/ # 流水线中间产物(整目录 gitignore)
54
- ├── result-with-{host}.jsonl
55
- ├── result-without-{host}.jsonl
56
- ├── result-*-{host}-scored.jsonl
57
- ├── agent-with-{host}.log
58
- ├── agent-without-{host}.log
59
- ├── eval_metrics.log # Judge 运行日志(若有)
60
- └── traces/ # DevEco session 导出(仅 deveco-code 宿主)
61
- ├── with-deveco/
62
- │ └── R01-ses_*.json
63
- └── without-deveco/
64
- └── R01-ses_*.json
65
- ```
66
-
67
- **Git 入库规则**
68
-
69
- | 路径 | 是否提交 |
70
- |------|----------|
71
- | `scripts/qa_eval/*.py`、`README.md`、`requirements.txt` | 是 |
72
- | `data/test-set.jsonl` | 是 |
73
- | `data/report*.txt` | 否 |
74
- | `log/` 下全部 | 否 |
75
- | `__pycache__/` | 否 |
76
-
77
- **与旧版路径对照**(若你手头是早期文档):
78
-
79
- | 旧路径 | 现路径 |
80
- |--------|--------|
81
- | `data/test.jsonl` | `data/test-set.jsonl` |
82
- | `data/result-*.jsonl` | `log/result-*-{host}.jsonl` |
83
- | `data/agent-*.log` | `log/agent-*-{host}.log` |
84
- | `data/report.txt` | `data/report-{host}.txt` |
85
-
86
- ## 测试流程
87
-
88
- ```
89
- test-set.jsonl
90
-
91
- Stage 1 agent_runner.py / external_agent.py(run_pipeline ab 内置)
92
- with : homegraph MCP / HomegraphQuery + ReadFile
93
- without : grep/rg + read(无 homegraph)
94
- 产出: log/result-*-{host}.jsonl + log/agent-*-{host}.log
95
- (deveco-code 额外产出 log/traces/{arm}-deveco/*.json)
96
-
97
- Stage 2 eval_metrics.py → log/result-*-{host}-scored.jsonl
98
-
99
- Stage 3 stats_scores.py → 准确率汇总(并入 report-{host}.txt)
100
- Stage 4 stats_efficiency.py → 效率 + 内存汇总(终端 + report-{host}.txt)
101
-
102
- run_pipeline.py ab → data/report-{host}.txt
103
- ```
104
-
105
- **A/B 唯一变量**:Agent 是否可用 homegraph。两臂使用**同一 Agent 宿主、同一 max_turns(builtin)**;without **不是裸 LLM**,仍是多轮 grep/read Agent。
106
-
107
- ### Stage 1 工具对照
108
-
109
- | 臂 | builtin 工具 | Claude / DevEco |
110
- |----|--------------|-----------------|
111
- | **with** | `HomegraphQuery`、`ReadFile` | MCP `homegraph_explore` / `homegraph_node` 等 + 内置 read/grep |
112
- | **without** | `SearchText`(rg)、`FindFiles`、`ReadFile` | 仅内置 grep/read;DevEco 在 `.deveco/deveco.jsonc` 中 deny homegraph 工具 |
113
-
114
- ## 测试输出
115
-
116
- ### 核心指标(`report-{host}.txt` 末尾【A/B 汇总表】)
117
-
118
- | 指标 | 含义 | A/B 怎么看 |
119
- |------|------|------------|
120
- | 准确率 均值 | Judge 的 `answer_accuracy_score`(0–1)全题平均 | Δ > 0 表示 with 答案质量更高 |
121
- | 准确率 中位数 | 同上,中位数(抗极端值) | 与均值交叉验证 |
122
- | Judge 成功/总数 | 成功打分数 / 总题数 | 应接近 100%;失败查 API/JSONL |
123
- | 平均轮次 | 每题 LLM 工具循环次数(日志 `the N turn` 最大 N)再平均 | **越低越好**;with 理想上更低 |
124
- | 平均耗时 (秒) | 每题从 `Evaluate N:` 到下一题开始的端到端时间再平均 | **越短越好** |
125
- | 平均 Token (k) | 每题 `totalTokenCount` 累加再平均,单位 k | **越少越好** |
126
- | 平均首响应 (秒) | 每题从 `Evaluate N:` 到第一次 LLM 返回再平均 | 参考项 |
127
- | 平均峰值内存 (MB) | Agent + MCP 子进程树 RSS 峰值再平均 | **越低越好**;Linux/WSL 才有数 |
128
- | 最大峰值内存 (MB) | 单题 RSS 峰值最大值 | 观察 OOM 风险 |
129
-
130
- Δ 列均为 **with − without**。
131
-
132
- ### JSONL 产出字段(Stage 1)
133
-
134
- 每条在测试集字段基础上追加:
135
-
136
- ```json
137
- {
138
- "output_answer": "---\nHomegraphQuery\n...\n---\n\n最终自然语言答案…",
139
- "agent_status": "success",
140
- "agent_error": null,
141
- "agent_backend": "deveco-code-with-homegraph",
142
- "agent_host": "deveco-code",
143
- "agent_model": "glm-4.5-flash",
144
- "agent_turns": 2,
145
- "agent_duration_ms": 73200,
146
- "agent_usage": { "total_tokens": 9249 },
147
- "agent_memory_mb": { "peak_rss_mb": 412.5, "avg_rss_mb": 380.2 },
148
- "ab_arm": "with-homegraph",
149
- "deveco_session_id": "ses_101dd0359ffeWUPIajCOuBEQtx",
150
- "agent_trace_file": "log/traces/with-deveco/R02-ses_101dd0359ffeWUPIajCOuBEQtx.json",
151
- "agent_tools_used": ["homegraph_homegraph_explore", "read"],
152
- "agent_used_homegraph": true,
153
- "agent_answer_source": "session_export"
154
- }
155
- ```
156
-
157
- | 字段 | 说明 |
158
- |------|------|
159
- | `output_answer` | 工具调用块(`---` 包裹)+ 最终答案;Judge 会剥工具块再打分 |
160
- | `agent_status` | `success` / `error` |
161
- | `agent_memory_mb` | 答题期间进程树 RSS(见「内存采样」) |
162
- | `deveco_session_id` | DevEco 会话 ID(`deveco-code` 宿主) |
163
- | `agent_trace_file` | 相对 `scripts/qa_eval/` 的 session 导出 JSON 路径 |
164
- | `agent_used_homegraph` | with 臂是否实际调用了 homegraph MCP 工具 |
165
-
166
- Judge 追加:`answer_accuracy_score`(0–1)、`evaluation_status`(`success` / `failed`)。
167
-
168
- ### Agent 日志格式(`agent-*-{host}.log`)
169
-
170
- ```
171
- 2026-06-23 09:25:21.052447 Evaluate 1:
172
- 2026-06-23 09:25:21.052571 the 1 turn
173
- 2026-06-23 09:25:22.321954 first token ← 第一次 LLM API 返回
174
- 2026-06-23 09:25:22.321954 totalTokenCount = 349
175
- 2026-06-23 09:25:27.771606 the 2 turn
176
- 2026-06-23 09:25:28.861895 totalTokenCount = 947
177
- 2026-06-23 09:25:30.102441 sessionID = ses_... ← DevEco 专有
178
- 2026-06-23 09:25:30.102441 tools = homegraph_homegraph_explore, read
179
- 2026-06-23 09:25:30.102441 session export → log/traces/with-deveco/R01-ses_....json
180
- 2026-06-23 09:25:30.102441 peakRssMb = 412.5
181
- 2026-06-23 09:25:30.102441 avgRssMb = 380.2
182
- 2026-06-23 09:25:30.102441 completed (73200ms)
183
- ```
184
-
185
- ## Agent 轨迹(Trace)
186
-
187
- **适用宿主**:主要为 `deveco-code`(每题自动 `deveco export <session_id>`)。
188
-
189
- | 查看方式 | 命令 / 路径 |
190
- |----------|-------------|
191
- | 导出 JSON | `log/traces/{with\|without}-deveco/<ID>-ses_<session>.json` |
192
- | DevEco CLI | `deveco export <session_id>` 或 `deveco session list`(标题 `qa-eval-{arm}-{id}`) |
193
- | 报告索引 | `report-{host}.txt` 中【Agent 轨迹 / DevEco Session】表 |
194
-
195
- 轨迹 JSON 含完整 `messages` / `parts`(用户问题、工具 input/output、assistant 文本、token 统计),用于人工复盘 Agent 是否按预期调用 `homegraph_explore`。
196
-
197
- `claude-code` 宿主将 stream-json 解析进 `output_answer`,不单独落 trace 文件。
198
-
199
- ## 内存采样
200
-
201
- - **实现**:`memory_monitor.py` 在 Agent 子进程存活期间每 0.25s 采样进程树 RSS(Linux `/proc`)。
202
- - **写入**:JSONL `agent_memory_mb`;日志 `peakRssMb` / `avgRssMb`;报告「平均/最大峰值内存」。
203
- - **平台**:**Linux 原生 / WSL** 有数据;**Windows 原生** 无 `/proc`,显示 `N/A`,不影响跑题与准确率/耗时/Token 指标。
204
- - **采样范围**:builtin / 外部 CLI 的 **子进程树**(含 homegraph MCP 子进程)。
205
-
206
- ## Agent 宿主(`--agent-host`)
207
-
208
- | 宿主 | 说明 | Agent 前置条件 | 报告文件 |
209
- |------|------|----------------|----------|
210
- | `builtin`(默认) | Python 内置多轮 Agent + 智谱/DashScope | `ZHIPU_API_KEY` 或 `DASHSCOPE_API_KEY` | `report-builtin.txt` |
211
- | `claude-code` | Claude Code CLI(`claude -p` + MCP) | `claude login` 已登录 | `report-claude.txt` |
212
- | `deveco-code` | DevEco Code / opencode CLI | `deveco` 在 PATH,DevEco provider 已配置 | `report-deveco.txt` |
213
-
214
- **注意**:`--provider zhipu` 只影响 **builtin Agent** 和 **Judge**;`deveco-code` / `claude-code` 使用各自 CLI 的账号,不读 `ZHIPU_API_KEY`。
215
-
216
- ### DevEco Code 配置要点
217
-
218
- ```bash
219
- deveco providers login # 选 Zhipu AI,输入 API Key
220
- # 凭证目录(Windows): C:\Users\<你>\.config\deveco
221
- ```
222
-
223
- - pipeline 会在被测仓库写入 `.deveco/deveco.jsonc`(with 臂挂 homegraph MCP + agent prompt;without 臂 deny homegraph 工具)。
224
- - TUI 若提示 **DEVECO_HOME**,那是 DevEco **Studio** 安装路径(编译用);**跑 qa_eval 可跳过**。
225
- - 可选 `--deveco-model zhipuai/glm-4.5-flash`(格式 `provider/model`,用 `deveco models` 查看)。
226
- - 可选 `--deveco-attach http://127.0.0.1:4096` 或 `QA_EVAL_DEVECO_ATTACH` 复用已运行的 `deveco serve`,减少冷启动。
227
-
228
- Judge(Stage 2)三种宿主共用,仍需 `ZHIPU_API_KEY` 或 `DASHSCOPE_API_KEY`。
229
-
230
- ## 快速开始
231
-
232
- ```bash
233
- pip install -r scripts/qa_eval/requirements.txt \
234
- -i https://pypi.tuna.tsinghua.edu.cn/simple
235
-
236
- export DASHSCOPE_API_KEY="sk-xxxxxxxx"
237
- # 或智谱(Key 格式 id.secret,不要加 sk- 前缀):
238
- # export ZHIPU_API_KEY="xxxxxxxx.yyyyyyyy"
239
-
240
- cd /path/to/homegraph && npm run build
241
- node dist/bin/homegraph.js sync /path/to/your/repo
242
-
243
- python scripts/qa_eval/run_pipeline.py ab -r /path/to/your/repo
244
- # 智谱:
245
- # python scripts/qa_eval/run_pipeline.py ab -r /path/to/your/repo --provider zhipu
246
- ```
247
-
248
- ### 三种宿主示例
249
-
250
- ```bash
251
- # ① builtin
252
- export ZHIPU_API_KEY="your-id.your-secret"
253
- python scripts/qa_eval/run_pipeline.py ab -r /path/to/repo --provider zhipu --agent-host builtin
254
-
255
- # ② Claude Code(Agent 用 Claude 账号,Judge 仍用 ZHIPU_API_KEY)
256
- claude login
257
- python scripts/qa_eval/run_pipeline.py ab -r /path/to/repo --provider zhipu --agent-host claude-code
258
-
259
- # ③ DevEco Code
260
- deveco providers login
261
- python scripts/qa_eval/run_pipeline.py ab -r /path/to/repo --provider zhipu --agent-host deveco-code
262
- # python scripts/qa_eval/run_pipeline.py ab -r /path/to/repo --provider zhipu --agent-host deveco-code --deveco-model zhipuai/glm-4.5-flash
263
-
264
- # ④ 三种依次跑(各写各的报告)
265
- python scripts/qa_eval/run_pipeline.py hosts -r /path/to/repo --provider zhipu
266
- ```
267
-
268
- 产出示例(每种宿主一套,互不覆盖):
269
-
270
- | 宿主 | JSONL / 日志(`log/`) | 报告(`data/`) |
271
- |------|------------------------|-----------------|
272
- | builtin | `result-with-builtin.jsonl`、`agent-with-builtin.log` | `report-builtin.txt` |
273
- | claude-code | `result-with-claude.jsonl`、`agent-with-claude.log` | `report-claude.txt` |
274
- | deveco-code | `result-with-deveco.jsonl`、`agent-with-deveco.log`、`traces/` | `report-deveco.txt` |
275
-
276
- 只重打报告、不重跑 Agent/Judge(无需 `--repo`):
277
-
278
- ```bash
279
- python scripts/qa_eval/run_pipeline.py ab --no-agent --no-judge
280
- # 保留上次 log 中间文件:
281
- python scripts/qa_eval/run_pipeline.py ab -r /path/to/repo --keep-log
282
- ```
283
-
284
- ### `report-{host}.txt` 结构
285
-
286
- ```
287
- ################################################################################
288
- # A/B 完整评测报告 #
289
- ################################################################################
290
-
291
- 【输入文件】
292
- 【WITH homegraph】效率明细 ← 逐题 + 汇总(首响应/轮次/耗时/Token/内存)
293
- 【WITHOUT homegraph】效率明细
294
- 【WITH / WITHOUT homegraph】准确率统计
295
- 按类别准确率 ← category_l1 分组 with/without 均分与 Δ
296
- 逐题对比 ← 得分、答案摘要;with 赢/平/输 计数
297
- 【Agent 轨迹 / DevEco Session】 ← deveco-code 专有(session_id + 轨迹路径)
298
- 【A/B 汇总表】 ← 两臂核心指标并排 + Δ
299
- ```
300
-
301
- ## Stage 2 — Judge(`eval_metrics.py`)
302
-
303
- ```bash
304
- python scripts/qa_eval/eval_metrics.py \
305
- -i scripts/qa_eval/log/result-with-builtin.jsonl \
306
- -o scripts/qa_eval/log/result-with-builtin-scored.jsonl \
307
- -w 2 --provider zhipu
308
- ```
309
-
310
- | 参数 | 默认 | 说明 |
311
- |------|------|------|
312
- | `-i` / `--input` | — | Agent 产出 JSONL |
313
- | `-o` / `--output` | `*-scored.jsonl` | 打分结果 |
314
- | `-w` / `--workers` | `1` | 并发线程数 |
315
- | `-m` / `--model` | 随 provider | Judge 模型 |
316
- | `--provider` | 自动检测 | `dashscope` / `zhipu` |
317
-
318
- ## Stage 3 / 4 — 统计脚本
319
-
320
- ```bash
321
- python scripts/qa_eval/stats_scores.py \
322
- -i scripts/qa_eval/log/result-with-builtin-scored.jsonl
323
-
324
- python scripts/qa_eval/stats_efficiency.py \
325
- -l scripts/qa_eval/log/agent-with-builtin.log
326
- ```
327
-
328
- `stats_efficiency.py` 输出逐题首响应、轮次、总时间、总 Token、**峰值内存**;日志缺失时回退 JSONL `agent_usage`(无轮次/耗时/首响应)。
329
-
330
- ## `run_pipeline.py` 命令
331
-
332
- ### `ab` — A/B 全流程
333
-
334
- ```bash
335
- python scripts/qa_eval/run_pipeline.py ab -r /path/to/your/repo [选项]
336
- ```
337
-
338
- | 参数 | 默认 | 说明 |
339
- |------|------|------|
340
- | `--repo`, `-r` | — | **被测仓库**(跑 Agent 时必填) |
341
- | `--dataset`, `-d` | `data/test-set.jsonl` | 测试集 |
342
- | `--with-jsonl` / `--without-jsonl` | `log/result-*.jsonl` | Agent 产出 |
343
- | `--with-scored` / `--without-scored` | `log/result-*-scored.jsonl` | Judge 产出 |
344
- | `--with-log` / `--without-log` | `log/agent-*.log` | Agent 日志 |
345
- | `--report` | `data/report-{host}.txt` | 完整报告路径 |
346
- | `--model`, `-m` | 随 provider | builtin Agent + Judge 模型 |
347
- | `--provider` | 自动检测 | `dashscope` / `zhipu` |
348
- | `--workers`, `-w` | `1` | Judge 并发 |
349
- | `--max-turns` | `8` | builtin Agent 最多工具轮次 |
350
- | `--agent-host` | `builtin` | `builtin` / `claude-code` / `deveco-code` / `all` |
351
- | `--homegraph-bin` | 自动检测 | 优先本地 `dist/bin/homegraph.js` |
352
- | `--deveco-model` | `zhipuai/glm-4.5-flash` | DevEco Agent 模型(仅 deveco-code) |
353
- | `--deveco-attach` | `$QA_EVAL_DEVECO_ATTACH` | 复用 `deveco serve` 地址 |
354
- | `--no-agent` | — | 跳过 Stage 1 |
355
- | `--no-judge` | — | 跳过 Stage 2 |
356
- | `--keep-log` | — | 跑 Agent 前**不清空** `log/` |
357
-
358
- ### `hosts` — 多宿主依次跑
359
-
360
- 等价于对 `builtin,claude-code,deveco-code` 各跑一遍 `ab`:
361
-
362
- ```bash
363
- python scripts/qa_eval/run_pipeline.py hosts -r /path/to/repo --provider zhipu
364
- python scripts/qa_eval/run_pipeline.py hosts -r /path/to/repo --agent-hosts claude-code,deveco-code
365
- ```
366
-
367
- ### `score` — 单路 Judge + 统计
368
-
369
- ```bash
370
- python scripts/qa_eval/run_pipeline.py score \
371
- -i scripts/qa_eval/log/result-with-builtin.jsonl \
372
- -l scripts/qa_eval/log/agent-with-builtin.log
373
- ```
374
-
375
- ## 外部 Agent 产出(可选)
376
-
377
- 若用 CodeGenie / Trae 等外部系统产出**同格式** JSONL + 日志:
378
-
379
- ```bash
380
- python scripts/qa_eval/run_pipeline.py ab --no-agent -r /path/to/repo
381
- ```
382
-
383
- ## 常见问题
384
-
385
- | 现象 | 处理 |
386
- |------|------|
387
- | Claude 准确率全低 / `Not logged in` | `claude login` 后重跑;pipeline 首题会 fail-fast |
388
- | `deveco-code` exit 1 / `Model not found` | 用 `deveco models` 里的 `zhipuai/...` 名,或 `--deveco-model zhipuai/glm-4.5-flash` |
389
- | DevEco `ServeError` / 端口占用 | `netstat -ano \| findstr :4096` 后结束进程,或不加 `--deveco-attach` |
390
- | DevEco 凭证损坏 | `deveco providers reset` 后重新 login |
391
- | `401` / Judge 全失败 | 检查 Key;智谱用 `--provider zhipu`,Key 格式 `id.secret` |
392
- | `Cannot find module 'arkanalyzer'` | 发布包 < 下一版时未打进 bundle;升级 homegraph,或源码路径 `npm install && npm run build` 后用 `node dist/bin/homegraph.js sync` |
393
- | `rg not found on PATH` | 安装 ripgrep(without 臂 builtin 需要) |
394
- | 日志解析 0 条任务 | 确认 log 含 `Evaluate N:` 行 |
395
- | 内存全为 N/A | Windows 原生无 `/proc`;用 WSL/Linux 测内存,或忽略该列 |
396
- | with 臂未用 homegraph | 看报告轨迹表 `HG` 列或 `agent_used_homegraph`;DevEco with 臂有专用 prompt |
397
- | 分数偏低但答案看起来对 | 检查 `output_answer` 是否只剩工具块、无最终自然语言答案 |
398
- | pip 慢 | 清华镜像(见快速开始) |
399
-
400
- ## 最小通路(仅 Judge 单条)
401
-
402
- ```bash
403
- export DASHSCOPE_API_KEY="sk-xxx"
404
- head -1 scripts/qa_eval/log/result-with-builtin.jsonl > /tmp/one.jsonl
405
- python scripts/qa_eval/eval_metrics.py -i /tmp/one.jsonl -o /tmp/one-scored.jsonl
406
- python scripts/qa_eval/stats_scores.py -i /tmp/one-scored.jsonl
407
- ```
@@ -1,41 +0,0 @@
1
- #!/usr/bin/env python3
2
- """One-off probe: parser + single run_deveco_query. Run from repo root."""
3
- import sys
4
- from pathlib import Path
5
-
6
- sys.path.insert(0, str(Path(__file__).resolve().parent))
7
- from external_agent import DEFAULT_DEVECO_MODEL, parse_opencode_json_events, run_deveco_query
8
-
9
- SAMPLE = (
10
- '{"type":"step_start","part":{"type":"step-start"}}\n'
11
- '{"type":"text","part":{"type":"text","text":"\\nOK"}}\n'
12
- )
13
-
14
- def main() -> int:
15
- parsed = parse_opencode_json_events(SAMPLE)
16
- assert parsed["agent_status"] == "success" and "OK" in parsed["output_answer"], parsed
17
- print("parser OK:", parsed["output_answer"])
18
-
19
- repo = Path(r"D:\code\benchmark")
20
- if not repo.is_dir():
21
- print("skip run: benchmark repo missing")
22
- return 0
23
-
24
- print(f"probing run_deveco_query (model={DEFAULT_DEVECO_MODEL}, timeout=90s)...")
25
- r = run_deveco_query(
26
- repo,
27
- "reply OK only",
28
- arm="with",
29
- hg_bin=None,
30
- log_file=None,
31
- task_id=0,
32
- timeout_sec=90,
33
- )
34
- print("status:", r.get("agent_status"))
35
- print("error:", r.get("agent_error"))
36
- print("answer:", (r.get("output_answer") or "")[:200])
37
- return 0 if r.get("agent_status") == "success" else 1
38
-
39
-
40
- if __name__ == "__main__":
41
- raise SystemExit(main())