Skip to content

feat: --summary mode for token-efficient search output #4

Description

@ktappdev

Problem

Current --json output includes full match breakdowns per result:

[
  {
    "path": "src/auth.go",
    "type": "file",
    "score": 85,
    "matches": ["basename:auth", "path:auth", "syn:authentication", "sym:AuthMiddleware"],
    "breakdown": ["basename contains +7", "path contains +4", "..."]
  }
]

For LLM agent consumption, this is hundreds of tokens per query when just paths and scores would suffice for most use cases. --dir-summary already exists for directory-level summaries but nothing for file-level.

Proposed Solution

Add --summary flag that outputs minimal JSON:

[
  {"path": "src/auth.go", "type": "file", "score": 85},
  {"path": "src/login.go", "type": "file", "score": 62}
]

No matches, no breakdown. Just path, type, score.

Implementation Notes

  • New --summary flag in command_search.go
  • When --summary && --json, strip matches and breakdown from output
  • Could also work with non-JSON output: just paths and scores, one per line
  • --summary and --dir-summary are orthogonal (both could be true)
  • --summary and --explain conflict — error or --explain wins

Acceptance Criteria

  • --summary --json outputs [{path, type, score}] only
  • --summary without --json outputs compact text format
  • --summary and --explain together produce an error or --explain wins
  • Token count reduced by ~60-80% compared to full output

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