Skip to content

search: Use pretty snippet/highlight infrastructure instead of crude truncation #21

@tony

Description

@tony

Problem

_stream_search_results renders each record as:

snippet = record.text[:120].replace("\n", " ")

This is a 120-char hard truncation with newlines squished — no match highlighting, no context window, no amber accent. Meanwhile grep --style=pretty uses extract_search_snippet (match-centered 5-line window), highlight_search_spans (warm amber on match spans), and format_relative_time (relative timestamps).

Expected

Search output should reuse the pretty rendering infrastructure. Each result should show a match-centered snippet with highlighted terms and a dim provenance line — the same visual language as grep --style=pretty.

Files

  • src/agentgrep/cli/render.py_stream_search_results record formatting
  • Reuse: extract_search_snippet, highlight_search_spans, format_relative_time, format_grep_record_pretty (or adapt)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions