Skip to content

refactor(grizzly): Replace MatchGroup/context with Snippet and hit lists#668

Merged
JeanMertz merged 1 commit into
mainfrom
prr237
May 25, 2026
Merged

refactor(grizzly): Replace MatchGroup/context with Snippet and hit lists#668
JeanMertz merged 1 commit into
mainfrom
prr237

Conversation

@JeanMertz
Copy link
Copy Markdown
Collaborator

The SearchMatch type previously returned groups of context lines (similar to grep -C), which was unbounded in size and leaked raw note content into every search response.

Replace that model with a compact, size-bounded result:

  • groups: Vec<MatchGroup> is removed. In its place, SearchMatch now carries line_hits (1-indexed line numbers, capped at max_line_hits), total_hits (always the true count), and a snippet — a short excerpt centered on the first match, truncated with at snippet_chars characters.
  • SearchMatch now also includes tags and updated_at, fetched in a single batch fetch_metadata query so callers no longer need a separate note_get round-trip just to identify a note.
  • SearchParams drops the context field and gains snippet_chars (default 200) and max_line_hits (default 20).
  • make_snippet is Unicode-safe: it counts chars, not bytes, and clamps the window to the actual match position.
  • The MCP tool description for note_search is updated to explain the new response shape and how to follow up with note_get when full content is needed.
  • Snippet is re-exported from the crate root.

…t lists

The `SearchMatch` type previously returned groups of context lines
(similar to `grep -C`), which was unbounded in size and leaked raw note
content into every search response.

Replace that model with a compact, size-bounded result:

- `groups: Vec<MatchGroup>` is removed. In its place, `SearchMatch` now
  carries `line_hits` (1-indexed line numbers, capped at
  `max_line_hits`), `total_hits` (always the true count), and a
  `snippet` — a short excerpt centered on the first match, truncated
  with `…` at `snippet_chars` characters.
- `SearchMatch` now also includes `tags` and `updated_at`, fetched in a
  single batch `fetch_metadata` query so callers no longer need a
  separate `note_get` round-trip just to identify a note.
- `SearchParams` drops the `context` field and gains `snippet_chars`
  (default 200) and `max_line_hits` (default 20).
- `make_snippet` is Unicode-safe: it counts chars, not bytes, and clamps
  the window to the actual match position.
- The MCP tool description for `note_search` is updated to explain the
  new response shape and how to follow up with `note_get` when full
  content is needed.
- `Snippet` is re-exported from the crate root.

Signed-off-by: Jean Mertz <git@jeanmertz.com>
@JeanMertz JeanMertz merged commit 99e2b87 into main May 25, 2026
14 checks passed
@JeanMertz JeanMertz deleted the prr237 branch May 25, 2026 13:28
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