mirror of
https://github.com/run-llama/semtools.git
synced 2026-07-21 11:15:24 -04:00
Feature: search CLI --output=json + per-file aggregation #6
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @lwyBZss8924d on GitHub (Sep 18, 2025).
Summary
Add a machine-readable JSON output mode and per-file aggregation flags to the
searchCLI to support agentic orchestrations (e.g., hierarchical navigation RAG) without brittle text parsing.Motivation
searchprints human-readable text only (filename:start::end (distance) + context lines). Parsing this in scripts is fragile.Proposed CLI changes (non-breaking)
--output <text|json>(default: text). Whenjson, emit a single JSON object to stdout.--aggregate-by <file|none>(default: none) – whenfile, group matches by file and pick the top-N per file.--limit-per-file <N>(default: 1 when aggregate-by=file; otherwise ignored) – per-file cap for grouped results.--prettyto pretty-print json (default: compact).JSON schema (draft)
Examples
Backward compatibility
Implementation notes
src/bin/search.rs.JsonMatch,JsonResult) and emit viaserde_json.Acceptance criteria
--output textremains the default and identical to current behavior.--output jsonreturns valid JSON for both workspace and non-workspace modes.--aggregate-by file+--limit-per-fileworks as described.Related context
@lwyBZss8924d commented on GitHub (Sep 18, 2025):
Intent: empower agentic, hierarchical navigation loops (split → route → drill down → cite → verify) without pre-indexing. Agents need stable, programmatic outputs to autonomously select, de-duplicate, and refine evidence across multiple passes.
Why JSON + per-file aggregation matters:
Scope and safety:
Outcome:
@lwyBZss8924d commented on GitHub (Sep 18, 2025):
Reference: OpenAI Model Selection Guide — Long-Context Agentic RAG
Relevant takeaways for this proposal:
Why this matters for
--output=json+ per-file aggregation:Agent example (excerpt) using SemTools as the retrieval backbone:
JSON output directly supports this autonomous loop (split → route → drill → cite → verify) by eliminating brittle parsing and making multi-depth selection/merging straightforward.
@logan-markewich commented on GitHub (Sep 18, 2025):
Great idea! Would be very open to adding a
jsonoutput mode to search