feat(list-notes): contentPreviewChars for lightweight folder scans#15
Merged
Conversation
Adds an optional `contentPreviewChars` parameter to `list-notes` that returns an HTML-stripped, whitespace-collapsed preview of each note, truncated to N characters, in a single JXA call. Notes whose body exceeded the limit are flagged with `content_truncated: true`. This avoids the MCP response token cap when callers want to scan many notes in a folder before deciding which ones to fetch in full via `get-note`. Strip + truncate happens inline in JXA, so no extra round trips and no client-side HTML cleanup. The new parameter requires `path` (enforced at the schema level via `refine`), since the indexed/no-path branch reads cached content from LanceDB and does not run the JXA preview pipeline.
5e48f1d to
5aede08
Compare
Owner
Author
|
Amended after CI failure. Two things I should have done before pushing the first time:
All 11 assertions pass locally against my Notes (folder Known limitation surfaced by verification: double-encoded entities (e.g. Force-pushed via |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an optional
contentPreviewCharsparameter to thelist-notestool. When set (together withpath), each returned note includes an HTML-stripped, whitespace-collapsed text preview truncated to N characters, withcontent_truncated: truewhen the body was cut.Why
Today the only way to get note text from
list-notesisincludeContent: true, which returns the raw HTMLnote.body()for every note in a folder. For folders with many or large notes this can blow past the MCP response token cap, and clients then have to do their own HTML cleanup.contentPreviewCharslets an agent scan a whole folder cheaply — e.g. 100 notes × 200 chars — and thenget-noteonly the ones it cares about. Strip + truncate happens inline in a single JXA call, no extra round trips, no client-side post-processing.Behaviour
list-notes ,&,<,>,",') + whitespace collapsecontent_truncated: trueon notes that exceeded the limitpath— enforced at the schema level viaz.refine, because the no-path branch reads cached content from LanceDB and does not run the JXA preview pipeline. Trying to use it without a path returns a clear validation error rather than silently ignoring the flag.includeContentandcontentPreviewCharsare set, the preview wins (truncated text replaces full HTML).Test plan
list-noteswithpath+contentPreviewChars: 200returns previews andcontent_truncatedflagslist-noteswithcontentPreviewCharsbut nopathreturns a schema validation errorlist-noteswith onlyincludeContent: trueis unchanged (regression check)&, , etc.) are decoded in previewscontent_truncated: true; short notes do not