feat(prompts): enrich prompts with vault health, graph data, and actionable instructions#189
Conversation
…d actionable instructions vault-orientation now surfaces vault stats (note count, untagged, broken links), folder note counts, property adoption rates with low-adoption flags, orphan detection (top 5), and a contextual "go deeper" footer that recommends tools based on what was found. memory-review now renders a structural overview before the raw content — file count, scope callouts (Contains/Does NOT contain), section names with entry counts — so the LLM has structural context for scope-fit analysis. Enhanced instructions reference the Structure section and add a coverage analysis step. daily-review now shows outgoing links (with broken-link detection), backlinks, and date-filtered activity (replacing the generic "recently modified" list with modifiedOnDate — past-date reviews now show notes from that date, not today's). Dynamic step numbering adds task extraction, link following, and pattern recognition instructions. Data layer: 3 new search-index methods (brokenLinkCount, modifiedOnDate, vaultStats) + bytes field on MemoryFileOutline. 26 new tests (974 total). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…i.json All three prompt descriptions were stale after the prompt enrichment commit — they still described the old capabilities (generic folder/tag survey, basic daily reconciliation) and missed the new data: vault stats, orphan detection, broken link counts, property adoption rates, structural memory overview with scope callouts, outgoing/back links, and date-filtered activity. Updated: README feature bullet, "Why Vault Cortex?" paragraph, prompt table (all 3 rows), prompt section intro; ARCHITECTURE.md prompt table and closing paragraph; .devin/wiki.json Prompt Reference page. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
modifiedOnDate hardcoded { zone: "utc" } for day boundaries, but the
rest of the codebase (getDailyNote, DateTime.now()) uses the server's
TZ env var. A user with TZ=America/Toronto reviewing "2026-06-15"
would get UTC midnight-to-midnight instead of local day boundaries.
Dropped the zone override so DateTime.fromISO parses in the system
timezone, consistent with all other date resolution in the server.
Test fixtures now use DateTime.fromISO().toMillis() instead of
hardcoded epoch values — self-documenting and timezone-consistent.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…rtyKey modifiedToday was misleading when reviewing a past date — the variable holds notes from dateArg, not necessarily today. Renamed to modifiedOnDate to match the search-index method it calls. Renamed the key callback parameter in formatPropertyAdoption to propertyKey — key.key reads poorly; propertyKey.key is self-evident. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
8 daily-review test fixtures used raw 1781611200000 instead of
DateTime.fromISO("2026-06-16T12:00:00").toMillis(). Extracted to
a shared JUNE_16_MIDDAY_MS constant — self-documenting and
consistent with the search-index test readability fix.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The orphan count showed "5+" whenever findOrphans returned exactly the limit, but that doesn't prove more exist. Now fetches limit + 1 — the "+" only appears when results were actually truncated. Added an inline comment above the vaultStats CASE query explaining the conditional aggregation strategy, per AGENTS.md SQL comment convention. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
brokenLinkCount, vaultStats, and listAllTags now take (_params, logger) instead of just (logger) — consistent with the two-arg (params, logger) pattern used by every other search-index method. When real params are needed later, they slot into the existing object without a signature change. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…vements # Conflicts: # src/vault-mcp/mcp-core/tools/search-tools.ts # src/vault-mcp/search/__tests__/search-index.test.ts
|
@CodeRabbit review |
✅ Action performedReview finished.
|
📝 WalkthroughWalkthroughAdds ChangesVault Analytics API and MCP Prompt Enrichment
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 7
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/vault-mcp/mcp-core/__tests__/prompt-definitions.test.ts`:
- Around line 779-792: The test "shows empty-links messages when daily note has
no links" writes the daily note file to disk but never indexes it into the
search system, allowing it to pass silently if link-analysis is skipped. After
the writeFile call that creates the daily note at "Daily Notes/2026-06-16.md",
add an upsert or index operation to add this file to the vault's search index so
that the link-analysis logic is actually exercised and tested for the intended
reason.
- Around line 323-332: The test "shows vault stats header with note count" uses
toContain() assertions which can pass with incorrect values like "12 notes
across" or "13 folders" instead of the expected "2 notes across" and "3
folders". Replace the toContain() calls with regex assertions using word
boundaries or exact string matching to ensure the assertions fail when incorrect
numeric values are present in the output text. Use a method that enforces exact
matching rather than substring matching for these numeric assertions.
In `@src/vault-mcp/mcp-core/prompt-definitions.ts`:
- Around line 278-284: The no-orphans message on line 284 (the string "No
orphans found — every note has at least one incoming link.") incorrectly claims
to check every note in the vault when it actually only checks notes within the
scope determined by findOrphans, which respects the config.orphanExcludeFolders
setting. Update the message to clarify that it only applies to the notes within
the examined scope rather than all notes in the vault, making it clear that
excluded folders are not included in the check.
- Around line 549-553: The getDailyNote function call and the subsequent
DateTime.now() call on line 553 can resolve to different calendar days when
executed around midnight, causing inconsistency between the daily note path and
the modifiedOnDate section. Compute the default review date once before calling
getDailyNote by moving the dateArg assignment (which computes args.date ??
DateTime.now().toISODate()) before the getDailyNote call, then pass this
pre-computed dateArg value to getDailyNote instead of args.date. This ensures
both operations use the exact same date value.
- Around line 485-488: The item 4 prompt text in the memory-review prompt
definition contains guidance about using vault_delete_memory for wrong facts,
which conflicts with the append-only design principle. Remove the phrase about
reserving vault_delete_memory from the fourth bullet point (the one starting
with "4. **Corrections (rare, separate).**") and ensure the guidance only
recommends appended dated corrections that preserve the existing memory entries
rather than suggesting any destructive deletion operations.
- Around line 603-617: The "Capture follow-ups" prompt step that recommends
using vault_patch_note is currently emitted unconditionally, but
vault_patch_note should only be recommended when daily.exists is true since
patching assumes the note already exists. Move the "Capture follow-ups" step
into the daily.exists conditional block using the same spread operator pattern
as the other conditional steps in the reviewSteps array, so that this
recommendation only appears when the daily note exists.
In `@src/vault-mcp/search/__tests__/search-index.test.ts`:
- Around line 2113-2119: The assertions in the modifiedOnDate test "returns
notes modified on the given date" are too loose, using toContain which only
checks for element existence without verifying exact order or complete output.
Replace the individual toContain assertions with a single exact assertion using
toEqual that checks for the exact array of paths in the expected order, for
example toEqual(["today-note.md", "today-late.md"]). Apply the same approach to
the limit: 1 test case mentioned in lines 2127-2133, ensuring those tests use
exact equality assertions instead of loose containment checks to make the tests
deterministic.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 5c9ca4bd-ac70-4e74-836f-b29541137338
📒 Files selected for processing (8)
.devin/wiki.jsonARCHITECTURE.mdREADME.mdsrc/vault-mcp/mcp-core/__tests__/prompt-definitions.test.tssrc/vault-mcp/mcp-core/prompt-definitions.tssrc/vault-mcp/mcp-core/tools/search-tools.tssrc/vault-mcp/search/__tests__/search-index.test.tssrc/vault-mcp/search/search-index.ts
…xing Compute dateArg once before getDailyNote so both calls target the same calendar day even around midnight (was: getDailyNote resolved today internally, then DateTime.now() was called again for modifiedOnDate — a race at midnight). Index the daily note in the "shows empty-links messages" test so the link-analysis code path is actually exercised, not silently skipped (was: daily note on disk but not in the search index). Tighten modifiedOnDate test assertions from toContain + toHaveLength to toEqual on the exact path array — deterministic output deserves exact assertions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
modifiedOnDate, and adds task extraction / link following / pattern recognition instructions with dynamic step numberingData layer: 3 new
SearchIndexmethods (brokenLinkCount,modifiedOnDate,vaultStats) +bytesfield onMemoryFileOutline. 26 new tests (974 total).Test plan
npm test)npx tsc --noEmit)🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation