Commit a7fb1d6
committed
feat(graphrag): graph-index query pre-pass eliminates speculative page reads
Adds obsidian-wiki graph-query <vault> "<question>" — queries the compiled
wikilink index before opening any page bodies, returning ranked candidates,
a should_read shortlist, and multi-hop paths. Replaces the current approach
of opening 5-10 pages speculatively per query.
- New obsidian_wiki/graphrag.py: build_index() (frontmatter + wikilinks,
in/out degree, tier), rank_candidates() (score = title/tag/summary match
+ degree bonus + tier weight), find_path() (BFS multi-hop, max_depth=4),
classify_query() (direct/path/gap/list routing), query() top-level entry.
- index_only=true when top candidate has exact title match + non-empty
summary — skips page reads entirely for lookup queries.
- CLI: graph-query <vault> "<question>" [--top N] [--max-read N] [--pretty]
- wiki-query SKILL.md gets Step 0: run graph-query first; use should_read
instead of speculative reads; skip to Step 5 when index_only=true.
- 34 new tests: index building, ranking, path finding, query classification,
integration, and CLI.1 parent 0221e0d commit a7fb1d6
4 files changed
Lines changed: 693 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
59 | 84 | | |
60 | 85 | | |
61 | 86 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
349 | 349 | | |
350 | 350 | | |
351 | 351 | | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
352 | 366 | | |
353 | 367 | | |
354 | 368 | | |
| |||
491 | 505 | | |
492 | 506 | | |
493 | 507 | | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
494 | 519 | | |
495 | 520 | | |
496 | 521 | | |
| |||
0 commit comments