Skip to content

feat: add start_line/limit line paging to vault_read_note - #406

Merged
aliasunder merged 7 commits into
mainfrom
feat/read-note-line-paging
Aug 4, 2026
Merged

feat: add start_line/limit line paging to vault_read_note#406
aliasunder merged 7 commits into
mainfrom
feat/read-note-line-paging

Conversation

@aliasunder

@aliasunder aliasunder commented Aug 3, 2026

Copy link
Copy Markdown
Owner

Summary

  • Mirrors PR feat(files): line paging for vault_read_file text results #397's vault_read_file paging on vault_read_note — one paging idiom across both read tools
  • Pages the delivered rendition (full body or a heading: section) by 1-based line range; JSON modes (outline, properties_only) reject paging with a clear error
  • Fixes the oversized-section gap: this project's own Done lane holds 250+ cards — heading: "Done", start_line: 1, limit: 20 now reads a window instead of the entire lane

Implementation

  • Extracted pageTextByLines + LineWindow type to obsidian-markdown/lines.ts as a shared primitive (split, validate, slice — no byte cap; byte cap enforcement stays in asset-operations)
  • Refactored buildPagedTextResult in asset-operations.ts to delegate to pageTextByLines
  • Moved describeTextWindow to tool-helpers.ts for shared use by both read tools
  • Added start_line/limit schema params + paging validation + two-block result formatting to vault_read_note handler
  • Updated ARCHITECTURE.md input table and vault_read_note description (examples, errors, returns)

Test plan

  • 12 unit tests for pageTextByLines (window, clamp, CRLF, trailing newline, empty, past-EOF, invalid range)
  • 9 integration tests for vault_read_note paging (full note, heading section, end-of-file, empty note, past-EOF error, outline/properties_only rejection, byte-identical unpaged, description assertions)
  • 2342 tests pass (21 new, 2321 existing)
  • Mutation-tested: removing paging from the section branch kills the heading-paging test
  • Build + lint clean
  • CI green

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added optional line-based pagination for reading full notes and heading sections.
    • Paged responses include selected line ranges, total line counts, and continuation details.
    • Added validation for invalid, out-of-range, and incompatible pagination requests.
  • Bug Fixes

    • Improved handling of line endings, trailing newlines, empty content, and paging limits.
    • Preserved existing output formats for unpaged note reads.
  • Documentation

    • Updated tool documentation with pagination parameters, behavior, and limitations.

Mirror PR #397's vault_read_file paging on note reads — one paging
idiom across both read tools. Pages the delivered rendition (full body
or a heading section) by line range; JSON modes (outline,
properties_only) reject paging with a clear error.

Implementation:
- Extract `pageTextByLines` + `LineWindow` to obsidian-markdown/lines.ts
  as a shared primitive (split, validate, slice — no byte cap)
- Refactor `buildPagedTextResult` in asset-operations.ts to use it
- Move `describeTextWindow` to tool-helpers.ts for shared use
- Add start_line/limit schema params + paging logic to vault_read_note
- 21 new tests (12 unit for pageTextByLines, 9 integration)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment thread src/vault-mcp/mcp-core/__tests__/tool-definitions.test.ts Outdated
@umm-actually

umm-actually Bot commented Aug 3, 2026

Copy link
Copy Markdown

umm-actually re-reviewed at 64c0c0c

No new findings (3 tracked finding(s) across all runs).

Context notes
  • 2 related file(s) excluded by max_related_files cap: src/vault-mcp/vault-operations/vault-patcher.ts, src/vault-mcp/vault-operations/__tests__/asset-operations.test.ts

umm-actually · deepseek/deepseek-v4-pro

@aliasunder

Copy link
Copy Markdown
Owner Author

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented Aug 4, 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 Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

Line-window pagination

Layer / File(s) Summary
Shared paging primitives
src/vault-mcp/obsidian-markdown/lines.ts, src/vault-mcp/obsidian-markdown/__tests__/lines.test.ts
Adds LineWindow, PagedTextResult, and pageTextByLines with validation, line-ending normalization, slicing, and coverage for range behavior.
vault_read_note pagination
src/vault-mcp/mcp-core/tools/vault-crud-tools.ts, src/vault-mcp/mcp-core/tools/tool-helpers.ts, src/vault-mcp/mcp-core/__tests__/tool-definitions.test.ts, ARCHITECTURE.md
Adds start_line and limit for full-note and heading-section reads. JSON modes reject paging. Paged responses include line-window metadata, while unpaged output remains unchanged.
Asset paging integration
src/vault-mcp/vault-operations/asset-operations.ts, src/vault-mcp/mcp-core/tools/asset-tools.ts
Reuses the shared paging utility and type for asset text. Asset byte-cap validation remains in place.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

🚥 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 clearly and concisely describes the main change: adding start_line and limit paging to vault_read_note.
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.
✨ 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 feat/read-note-line-paging

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: 1

🤖 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/tools/vault-crud-tools.ts`:
- Around line 254-260: Remove the `as const` assertions from the text content
objects returned by `vault_read_note` and the `safeHandler` helper. Use
contextual MCP text-block typing or a small typed text-content helper so these
objects satisfy the expected type without any `as` assertions, preserving their
existing text values and return structure.
🪄 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: 463899db-47e4-45bb-ac25-02b531b26f70

📥 Commits

Reviewing files that changed from the base of the PR and between d50924d and 83bd6a3.

📒 Files selected for processing (8)
  • ARCHITECTURE.md
  • src/vault-mcp/mcp-core/__tests__/tool-definitions.test.ts
  • src/vault-mcp/mcp-core/tools/asset-tools.ts
  • src/vault-mcp/mcp-core/tools/tool-helpers.ts
  • src/vault-mcp/mcp-core/tools/vault-crud-tools.ts
  • src/vault-mcp/obsidian-markdown/__tests__/lines.test.ts
  • src/vault-mcp/obsidian-markdown/lines.ts
  • src/vault-mcp/vault-operations/asset-operations.ts

Comment thread src/vault-mcp/mcp-core/tools/vault-crud-tools.ts
aliasunder and others added 4 commits August 3, 2026 20:18
lines.ts now also exports pageTextByLines; tool-helpers.ts now also
exports describeTextWindow — update the file descriptions so agents
see the current module surfaces.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kum27K9QPrK5TetJuYtuRK
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kum27K9QPrK5TetJuYtuRK
…overage

Replace decomposed/partial assertions with whole-object toEqual on paging
content blocks and lineWindow shapes; replace toContain on a deterministic
error message with exact toBe. Add direct unit tests for the shared
describeTextWindow helper (3 branches: zero-lines, end-of-file, mid-file).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kum27K9QPrK5TetJuYtuRK
The type is now defined in obsidian-markdown/lines.ts. asset-operations
still imports it (for AssetReadResult), but no longer re-exports it —
no external consumer imports LineWindow from this module anymore.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment thread src/vault-mcp/mcp-core/__tests__/tool-definitions.test.ts
Comment thread src/vault-mcp/mcp-core/tools/vault-crud-tools.ts
aliasunder and others added 2 commits August 3, 2026 23:46
Remove the project-specific "250+ card Done lane" example and broaden
the count-probe guidance to cover both full-note and section reads.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Map snake_case wire params to camelCase in all tool_call log objects:
start_line → startLine, heading_level → headingLevel,
properties_only → propertiesOnly, replace_all_occurrences →
replaceAllOccurrences, first_match → firstMatch. Matches the
convention already used in asset-tools.ts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@aliasunder
aliasunder merged commit 8cb704f into main Aug 4, 2026
18 checks passed
@aliasunder
aliasunder deleted the feat/read-note-line-paging branch August 4, 2026 04:14
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