Skip to content

Add stats --json for scripting #62

Description

@ssrajadh

Problem

sentrysearch/cli.py:1224-1249 only emits human-formatted text. Users wiring SentrySearch into shell scripts or other tools have no machine-readable output to parse, and the [missing] marker is mixed into the file string rather than being a separate field.

Suggested fix

Add --json to the stats command. When set, print a single JSON object:

{
  "backend": "gemini",
  "model": null,
  "total_chunks": 1234,
  "unique_source_files": 42,
  "source_files": ["/abs/path/a.mp4", "/abs/path/b.mp4"],
  "missing_files": ["/abs/path/gone.mp4"]
}

Keep missing_files as its own key (rather than " [missing]" suffixes on source_files) so downstream tools can act on it cleanly. The human path stays exactly as it is today.

Acceptance

  • sentrysearch stats --json | jq .total_chunks returns the chunk count.
  • sentrysearch stats (no flag) output is unchanged.
  • Empty-index case still works (--json returns the same schema with total_chunks: 0).

Scope

Touches only stats in sentrysearch/cli.py plus a test in tests/test_cli.py.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions