homegraph 1.5.5 → 1.5.7

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 (83) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/README.md +10 -4
  3. package/dist/bin/homegraph.js +6 -0
  4. package/dist/bin/homegraph.js.map +1 -1
  5. package/dist/context/index.d.ts.map +1 -1
  6. package/dist/context/index.js +120 -15
  7. package/dist/context/index.js.map +1 -1
  8. package/dist/db/migrations.d.ts +1 -1
  9. package/dist/db/migrations.d.ts.map +1 -1
  10. package/dist/db/migrations.js +37 -1
  11. package/dist/db/migrations.js.map +1 -1
  12. package/dist/db/queries.d.ts +25 -0
  13. package/dist/db/queries.d.ts.map +1 -1
  14. package/dist/db/queries.js +50 -2
  15. package/dist/db/queries.js.map +1 -1
  16. package/dist/db/schema.sql +24 -0
  17. package/dist/extraction/languages/arkts.d.ts +40 -3
  18. package/dist/extraction/languages/arkts.d.ts.map +1 -1
  19. package/dist/extraction/languages/arkts.js +302 -22
  20. package/dist/extraction/languages/arkts.js.map +1 -1
  21. package/dist/index.d.ts +31 -0
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +87 -1
  24. package/dist/index.js.map +1 -1
  25. package/dist/mcp/engine.d.ts +26 -0
  26. package/dist/mcp/engine.d.ts.map +1 -1
  27. package/dist/mcp/engine.js +229 -8
  28. package/dist/mcp/engine.js.map +1 -1
  29. package/dist/mcp/evidence-rendering.d.ts +10 -0
  30. package/dist/mcp/evidence-rendering.d.ts.map +1 -0
  31. package/dist/mcp/evidence-rendering.js +71 -0
  32. package/dist/mcp/evidence-rendering.js.map +1 -0
  33. package/dist/mcp/explore-repeat-guard.d.ts +8 -13
  34. package/dist/mcp/explore-repeat-guard.d.ts.map +1 -1
  35. package/dist/mcp/explore-repeat-guard.js +54 -114
  36. package/dist/mcp/explore-repeat-guard.js.map +1 -1
  37. package/dist/mcp/explore-session-state.d.ts +26 -4
  38. package/dist/mcp/explore-session-state.d.ts.map +1 -1
  39. package/dist/mcp/explore-session-state.js +50 -4
  40. package/dist/mcp/explore-session-state.js.map +1 -1
  41. package/dist/mcp/index.d.ts.map +1 -1
  42. package/dist/mcp/index.js +16 -1
  43. package/dist/mcp/index.js.map +1 -1
  44. package/dist/mcp/query-cache.d.ts +1 -1
  45. package/dist/mcp/query-cache.d.ts.map +1 -1
  46. package/dist/mcp/query-cache.js +86 -3
  47. package/dist/mcp/query-cache.js.map +1 -1
  48. package/dist/mcp/query-pool.js +4 -4
  49. package/dist/mcp/server-instructions.d.ts +2 -2
  50. package/dist/mcp/server-instructions.d.ts.map +1 -1
  51. package/dist/mcp/server-instructions.js +36 -21
  52. package/dist/mcp/server-instructions.js.map +1 -1
  53. package/dist/mcp/tools.d.ts +29 -3
  54. package/dist/mcp/tools.d.ts.map +1 -1
  55. package/dist/mcp/tools.js +827 -109
  56. package/dist/mcp/tools.js.map +1 -1
  57. package/dist/project-map/index.d.ts +33 -0
  58. package/dist/project-map/index.d.ts.map +1 -0
  59. package/dist/project-map/index.js +260 -0
  60. package/dist/project-map/index.js.map +1 -0
  61. package/dist/search/literal-evidence.d.ts +44 -0
  62. package/dist/search/literal-evidence.d.ts.map +1 -0
  63. package/dist/search/literal-evidence.js +278 -0
  64. package/dist/search/literal-evidence.js.map +1 -0
  65. package/dist/search/query-plan-provider.d.ts +6 -0
  66. package/dist/search/query-plan-provider.d.ts.map +1 -0
  67. package/dist/search/query-plan-provider.js +289 -0
  68. package/dist/search/query-plan-provider.js.map +1 -0
  69. package/dist/search/query-plan.d.ts +98 -0
  70. package/dist/search/query-plan.d.ts.map +1 -0
  71. package/dist/search/query-plan.js +334 -0
  72. package/dist/search/query-plan.js.map +1 -0
  73. package/dist/search/query-utils.d.ts +6 -1
  74. package/dist/search/query-utils.d.ts.map +1 -1
  75. package/dist/search/query-utils.js +64 -5
  76. package/dist/search/query-utils.js.map +1 -1
  77. package/dist/sync/watcher.d.ts +15 -3
  78. package/dist/sync/watcher.d.ts.map +1 -1
  79. package/dist/sync/watcher.js +14 -1
  80. package/dist/sync/watcher.js.map +1 -1
  81. package/dist/types.d.ts +23 -0
  82. package/dist/types.d.ts.map +1 -1
  83. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -10,6 +10,50 @@ and adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
10
10
  ## [Unreleased]
11
11
 
12
12
 
13
+ ## [1.5.7] - 2026-09-09
14
+
15
+ ### Fixes
16
+
17
+ - ArkTS indexing aligns with ArkAnalyzer `ClassCategory`: **object literals**, **type literals**, and **unions** are no longer stored as HomeGraph `class` nodes (they were inflating `graph_class` as `<Object$anon@N>` / `%AC*` under the file). Real classes — including true anonymous `ClassCategory.CLASS` — are unchanged. Re-index to refresh existing databases (Spec 0026).
18
+ - Harmony multi-module ArkTS indexing: register **synthetic PROJECT modules** for ArkAnalyzer sources that sit outside `build-profile.json5` `srcPath` (e.g. ohrouter `HMRouterPlugin/**/*.ts`), so they enter the same `analyseByModule` pipeline instead of being skipped by both AA and tree-sitter. Incremental dirty mapping can target those synthetic roots. AA-persisted files now get truthful `files`/`nodes.language` by extension (`.ets`→`arkts`, `.ts`/`.d.ts`→`typescript`) instead of hard-coding `arkts` (Spec 0025).
19
+
20
+ ### Improvements
21
+
22
+ - MCP `initialize` instructions: **single-file path-pinned edits → Read + edit, skip `homegraph_*`**; explore only when locate/cross-file is needed.
23
+ - Explore **defers** (`Skip HomeGraph`, kind `path-pinned-edit`) when the query names one `…/File.ext` and is a code-change shape — avoids explore context tax on 082-style tasks.
24
+ - Path scaffolding (`features/.../Foo.ets` + basename-as-Type) no longer counts as multi-anchor; `.ets`/`.ts`/… are not parsed as member access.
25
+
26
+ ### New Features
27
+
28
+ - Experimental structured query planning for explore (Spec 0022): shared local routing features; optional, explicitly configured one-call model intent/decomposition/rephrase; bounded dependent retrieval with a shared deadline/output budget, validated anchors, worker propagation, context hints and direction-aware cache keys. Model failures fall back locally; compact diagnostic metadata includes planning usage/time and per-step coverage. No remote model calls by default.
29
+
30
+ ### Fixes
31
+
32
+ - Grounded retrieval plans separate concise semantic concepts, verbatim UI text, exact anchors, source scope and relationship direction. Unanchored reference requests first discover source and retain the missing reference obligation. Bounded literal/resource lookup prioritizes local application evidence; rendering deduplicates same-source declarations and marks incomplete evidence. Repeat protection permits a bounded recovery for weak or changed evidence, and retrieval guidance no longer closes the coding task (Spec 0024).
33
+ - The optional model planner now requests English step queries and short English semantic search terms, while preserving literal identifiers, paths and task constraints. This is a prompt-only refinement: retrieval, anchor validation, request count and budgets are unchanged (Spec 0023).
34
+ - Model-planned explore steps now keep their own retrieval terms instead of repeating the whole task as search seeds. General/flow steps consume planned hints through full context retrieval; task constraints remain separate. Dependency candidates come only from displayed source declarations and retain node/file identity, with visible location receipts surviving shared-output trimming. Unseen fuzzy hits and inherited nodes no longer manufacture new bindings; default rule routes are unchanged (Spec 0023).
35
+ - Explicit model planning now considers task-scoped natural-language queries before shape fast paths; exact symbol/path lookups remain cheap. Compact metadata explains planning eligibility, skip reasons and the original rule route, separately from provider failures (Spec 0023).
36
+ - Planner instructions distinguish read-only evidence lookup from code-editing workflows and provide a compact JSON shape; more than three steps still fail closed, with a specific step-count diagnostic and no silent truncation or retry (Spec 0023).
37
+ - After a model planning request fails, local fallback retrieval now uses the remaining shared deadline instead of the unbounded main-thread fast path; rule-only fast retrieval is unchanged (Spec 0023).
38
+ - Query planning keeps framework labels out of lexical retrieval, preserves host-provided task constraints before agent shorthand, accepts bounded numeric step IDs, and supports an explicit planning timeout up to 10 seconds while reserving retrieval time within the shared deadline (default remains 5 seconds; Spec 0023).
39
+ - Experimental query planning (Spec 0023): focused feature queries cannot be broadened into whole-project overviews by a model rewrite. Optional bounded task context preserves original actions/product scope across planning and cache keys; model-proposed broad anchors are discarded when an unauthorized overview is downgraded. Explicit project maps remain supported.
40
+ - An explicit `HOMEGRAPH_MCP_TOOLS` selection now overrides default small-repository tool trimming, so requested specialized tools remain callable on small ArkTS projects (Spec 0023).
41
+
42
+ - MCP first-tool guidance now gives `homegraph_usages`, `homegraph_modules`, and `homegraph_native` mutually exclusive priority for their narrow intents instead of simultaneously telling agents those questions are explore-first; general `homegraph_explore` remains the compatibility fallback and still auto-routes high-confidence shapes.
43
+
44
+ ## [1.5.6] - 2026-09-03
45
+
46
+ ### New Features
47
+
48
+ - Product-host indexing (Spec 0021): `--auto-init` / `HOMEGRAPH_AUTO_INIT` creates `.homegraph/` when missing, builds a seconds-scale **project map** (modules → files in `project_modules` / `project_module_files`, schema v11), exposes read tool `homegraph_project`, then runs the full symbol index in a **detached** `homegraph index` child so the MCP stdio server stays responsive on large repos. `build_phase` metadata (`fast` / `indexing` / `full`) gates deep tools with success-shaped guidance while symbols are still building; opening an index heals a stuck phase after `index_state` completes.
49
+ - Watch coalesce for product hosts: `HOMEGRAPH_WATCH_FIXED_WINDOW_MS` arms a fixed window on the **first** change (later edits in the window do not extend it), then incremental sync — e.g. DevEco sets `300000` (5 minutes).
50
+ - ArkTS / ArkUI indexing stores the component `.id('…')` from ViewTree onto the matching custom `@Component` node as `arkuiId` (DB column `arkui_id`) — distinct from the graph primary key (Spec 0019).
51
+ - ArkTS indexing fills `nodes.docstring` from ArkAnalyzer leading comments / JSDoc (Scene `enableLeadingComments` + `enableJSDoc`), so declaration docs join `nodes_fts` like other languages (Spec 0020).
52
+
53
+ ### Docs
54
+
55
+ - `DEVELOPMENT.md` documents the **code-first Spec closing** order (§1.4.1): write Spec → verify code → check acceptance → CHANGELOG `[Unreleased]` → commit with `Spec:` footer.
56
+
13
57
  ## [1.5.5] - 2026-08-31
14
58
 
15
59
  ### Docs
@@ -173,3 +217,5 @@ and adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
173
217
  [1.5.1]: https://gitcode.com/ProgramAnalysis/homegraph/tags/v1.5.1
174
218
  [1.5.0]: https://gitcode.com/ProgramAnalysis/homegraph/tags/v1.5.0
175
219
  [1.4.1]: https://gitcode.com/ProgramAnalysis/homegraph/tags/v1.4.1
220
+ [1.5.6]: https://github.com/fujiaxin-coder/homegraph/releases/tag/v1.5.6
221
+ [1.5.7]: https://github.com/fujiaxin-coder/homegraph/releases/tag/v1.5.7
package/README.md CHANGED
@@ -179,10 +179,10 @@ Agent 侧工具名前缀为 `homegraph_`。
179
179
 
180
180
  | 工具 | 用途 |
181
181
  |------|------|
182
- | `homegraph_explore` | **主工具**:一次调用返回相关符号的完整源码、调用路径与影响范围;支持自然语言问题或符号/文件名列表。高置信度的用法 / 模块依赖 / NAPI 问法会委派到下方三个聚焦工具的同一套 survey |
183
- | `homegraph_usages` | 只读用法清单:命名 API / member / field / 常量的引用与调用点(常量袋可走有界文本扫描) |
184
- | `homegraph_modules` | 只读模块依赖 / 循环依赖清单(命名模块或路径) |
185
- | `homegraph_native` | 只读 NAPI / native export 清单(命名路径或 Type) |
182
+ | `homegraph_usages` | **精确用法清单首选**:查询一个已命名 API、成员、常量或字段在哪里被引用 |
183
+ | `homegraph_modules` | **模块拓扑首选**:查询已命名模块之间的依赖关系或循环依赖 |
184
+ | `homegraph_native` | **Native 边界首选**:查询已命名路径或类型的 NAPI/native 导出和注册位置 |
185
+ | `homegraph_explore` | **通用结构探索**:一次调用返回相关符号的源码、调用路径与影响范围;窄清单问题优先使用上面三个专用工具 |
186
186
  | `homegraph_search` | 按名称快速搜索符号(仅返回位置,不含源码) |
187
187
  | `homegraph_node` | 读取单个符号或整个文件的源码(带行号)及调用关系;可替代 Read 读文件 |
188
188
  | `homegraph_callers` / `homegraph_callees` | 查看调用方 / 被调用方 |
@@ -195,6 +195,12 @@ Agent 侧工具名前缀为 `homegraph_`。
195
195
  | `homegraph_spec_find` | 根据文件路径反向查找关联的Spec |
196
196
  | `homegraph_spec_trace` | 根据代码符号追溯回关联的Spec |
197
197
 
198
+ ### 查询规划(实验性)
199
+
200
+ `homegraph_explore` 现在共用结构化查询计划:默认 `HOMEGRAPH_QUERY_PLANNER=rules`,保持本地确定性路由;`off` 可回退旧执行路径。显式启用 `llm` 后,复杂问题可在一次模型调用中做意图识别、问题分解和检索改写,再复用既有工具的内部实现。
201
+
202
+ 模型规划需要单独配置 URL、模型和密钥;仅发送问题,不发送仓库源码。最多 3 个子任务共用截止时间和输出预算,规划失败退回本地规则。配置、指标、限制见 [查询规划指南](docs/query-planning.md)。这不是新增的 CodeGraph 构建算法,也尚未证明能降低真实任务的 token 或延迟。
203
+
198
204
  ### Commit4Spec(Spec知识图谱)
199
205
 
200
206
  Commit4Spec 提供两条互补路径将设计Spec与 Git 历史关联,存入 `.homegraph/commit4spec/commit4spec.db`:
@@ -1421,6 +1421,11 @@ function main() {
1421
1421
  if (options.watch === false) {
1422
1422
  process.env.HOMEGRAPH_NO_WATCH = '1';
1423
1423
  }
1424
+ // Product hosts (DevEco Code) pass --auto-init so unindexed workspaces get
1425
+ // .homegraph/ + background index + watch without a separate `homegraph init`.
1426
+ if (options.autoInit) {
1427
+ process.env.HOMEGRAPH_AUTO_INIT = '1';
1428
+ }
1424
1429
  // Spec 0005: resolve --sources over HOMEGRAPH_SOURCES, then stamp env so
1425
1430
  // detached daemons and in-process opens share the same mode.
1426
1431
  const { resolveGraphSources, applyGraphSourcesToEnv, GRAPH_SOURCES_MODES } = await Promise.resolve().then(() => __importStar(require('../graph-sources')));
@@ -1491,6 +1496,7 @@ function main() {
1491
1496
  .option('-p, --path <path>', 'Project path (optional for MCP mode, uses rootUri from client)')
1492
1497
  .option('--mcp', 'Legacy alias for `serve mcp` (stdio MCP server)')
1493
1498
  .option('--no-watch', 'Disable the file watcher (no auto-sync; useful on slow filesystems like WSL2 /mnt drives)')
1499
+ .option('--auto-init', 'If no .homegraph/ exists, create it and index in the background (for product hosts)')
1494
1500
  .option('--sources <mode>', 'Graph sources for MCP queries: both|project|sdk|none (default both; env HOMEGRAPH_SOURCES)')
1495
1501
  .action(async (mode, options) => {
1496
1502
  try {