Skip to content

feat(prompts): enrich prompts with vault health, graph data, and actionable instructions#189

Merged
aliasunder merged 11 commits into
mainfrom
worktree-prompt-improvements
Jun 23, 2026
Merged

feat(prompts): enrich prompts with vault health, graph data, and actionable instructions#189
aliasunder merged 11 commits into
mainfrom
worktree-prompt-improvements

Conversation

@aliasunder

@aliasunder aliasunder commented Jun 23, 2026

Copy link
Copy Markdown
Owner

Summary

  • vault-orientation: adds vault stats header (note count, untagged, broken links), folder note counts, property adoption rates with low-adoption flags, orphan detection (top 5), and a contextual footer that recommends tools based on findings
  • memory-review: adds a structural overview section (file count, scope callouts, section entry counts) before the raw content, enhances scope-fit instructions to reference the overview, and adds a coverage analysis step
  • daily-review: adds outgoing links (with broken-link flags), backlinks, replaces generic "recently modified" with date-filtered activity via modifiedOnDate, and adds task extraction / link following / pattern recognition instructions with dynamic step numbering

Data layer: 3 new SearchIndex methods (brokenLinkCount, modifiedOnDate, vaultStats) + bytes field on MemoryFileOutline. 26 new tests (974 total).

Test plan

  • All 974 tests pass (npm test)
  • TypeScript compiles clean (npx tsc --noEmit)
  • Invoke each prompt via an MCP client — verify output reads well, sections are in order, contextual suggestions appear correctly
  • Edge cases: empty vault, vault with no daily note, memory disabled, past-date daily review

🤖 Generated with Claude Code

Summary by CodeRabbit

New Features

  • Enhanced vault-orientation prompt now displays vault health metrics including orphan detection, broken links, property adoption rates, and folder statistics.
  • Updated memory-review prompt with new structural overview section and coverage analysis review step.
  • Improved daily-review prompt with outgoing/incoming link analysis and date-specific activity tracking.

Documentation

  • Updated documentation across multiple pages describing the three guided prompts and their expanded capabilities.

…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>
Comment thread src/vault-mcp/search/search-index.ts Outdated
Comment thread src/vault-mcp/search/search-index.ts
Comment thread src/vault-mcp/search/search-index.ts
Comment thread src/vault-mcp/mcp-core/prompt-definitions.ts
aliasunder and others added 7 commits June 22, 2026 22:29
…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
@aliasunder

Copy link
Copy Markdown
Owner Author

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds brokenLinkCount, modifiedOnDate, and vaultStats aggregate query methods to the search index and updates listAllTags to accept an unused _params argument. The three MCP prompt handlers (vault-orientation, memory-review, daily-review) are rebuilt to consume these new APIs, producing richer output with per-folder counts, property adoption rates, orphan detection, link-graph sections, and structural memory overviews. Documentation and tests are updated throughout.

Changes

Vault Analytics API and MCP Prompt Enrichment

Layer / File(s) Summary
Search index aggregate API and VaultStats type
src/vault-mcp/search/search-index.ts
Adds the VaultStats type and three new methods (brokenLinkCount, modifiedOnDate, vaultStats) to the SearchIndex return object; updates listAllTags to accept an unused _params first argument.
Search index tests and listAllTags call-site updates
src/vault-mcp/search/__tests__/search-index.test.ts
Updates three existing listAllTags call sites to the new two-argument signature and adds test suites covering brokenLinkCount, modifiedOnDate (day-boundary filtering, limit), and vaultStats (populated and empty index).
vault_list_tags tool call-site alignment
src/vault-mcp/mcp-core/tools/search-tools.ts
Passes {} as the first argument to search.listAllTags to match the updated method signature.
Prompt helper functions and constants
src/vault-mcp/mcp-core/prompt-definitions.ts
Introduces orphan display-limit and low-adoption threshold constants, a per-folder note-count aggregation helper, a property-key adoption-rate formatter, and the formatMemoryStructuralOverview helper.
vault-orientation prompt handler rewrite
src/vault-mcp/mcp-core/prompt-definitions.ts
Adds orphan candidate computation, broken-link count, and vault stats; rebuilds folders with per-folder counts, property keys with adoption-rate formatting, adds an Orphans section, reorganizes Memory placement, and rebuilds the Go Deeper footer conditionally.
memory-review prompt: Structure section and updated steps
src/vault-mcp/mcp-core/prompt-definitions.ts
Inserts a ## Structure section via formatMemoryStructuralOverview and revises How to reflect steps to include a Corrections step and a Coverage analysis step.
daily-review prompt: link-graph and date-filtered activity
src/vault-mcp/mcp-core/prompt-definitions.ts
Replaces global recent-notes fetch with modifiedOnDate, derives outgoing links (with broken-link flags) and backlinks from the daily note, and rebuilds output sections and How to review steps dynamically.
Prompt handler tests
src/vault-mcp/mcp-core/__tests__/prompt-definitions.test.ts
Adds JUNE_16_MIDDAY_MS constant; extends vault-orientation tests for stats/orphans/adoption/broken-links; adds memory-review Structure-section tests; adds daily-review link-rendering and date-filter tests; updates all three exact full-output string assertions.
Documentation updates
ARCHITECTURE.md, README.md, .devin/wiki.json
Updates the prompts table in ARCHITECTURE.md, the feature list and Prompts section in README.md, and the wiki Prompt Reference entry to reflect the new data sources and output of all three prompts.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • aliasunder/vault-cortex#139: Introduced the same three MCP prompt handlers (vault-orientation, memory-review, daily-review) and their prompt-definitions.ts implementation that this PR directly extends.
  • aliasunder/vault-cortex#185: Modified prompt-definitions.ts to conditionally register or omit memory prompts based on MEMORY_ENABLED, which intersects with the conditional memory-section logic rewritten in this PR.
  • aliasunder/vault-cortex#168: Touched src/vault-mcp/mcp-core/prompt-definitions.ts and src/vault-mcp/search/search-index.ts with import/wiring adjustments that the new aggregate methods and prompt rewrites here build on top of.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main purpose of this PR: enriching three MCP prompts with vault health metrics, link graph data, and enhanced instructions to improve LLM decision-making.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch worktree-prompt-improvements

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 64766ea and b963e9d.

📒 Files selected for processing (8)
  • .devin/wiki.json
  • ARCHITECTURE.md
  • README.md
  • src/vault-mcp/mcp-core/__tests__/prompt-definitions.test.ts
  • src/vault-mcp/mcp-core/prompt-definitions.ts
  • src/vault-mcp/mcp-core/tools/search-tools.ts
  • src/vault-mcp/search/__tests__/search-index.test.ts
  • src/vault-mcp/search/search-index.ts

Comment thread src/vault-mcp/mcp-core/__tests__/prompt-definitions.test.ts
Comment thread src/vault-mcp/mcp-core/__tests__/prompt-definitions.test.ts
Comment thread src/vault-mcp/mcp-core/prompt-definitions.ts
Comment thread src/vault-mcp/mcp-core/prompt-definitions.ts
Comment thread src/vault-mcp/mcp-core/prompt-definitions.ts Outdated
Comment thread src/vault-mcp/mcp-core/prompt-definitions.ts
Comment thread src/vault-mcp/search/__tests__/search-index.test.ts Outdated
aliasunder and others added 3 commits June 22, 2026 23:21
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant