Skip to content

Make sentire AI-agent-friendly#7

Merged
andreagrandi merged 7 commits intomasterfrom
agent-friendly
Mar 7, 2026
Merged

Make sentire AI-agent-friendly#7
andreagrandi merged 7 commits intomasterfrom
agent-friendly

Conversation

@andreagrandi
Copy link
Owner

Summary

  • Structured errors: Typed CLIError with machine-readable codes (auth_missing, api_error, invalid_input, invalid_format) and distinct exit codes (0=success, 1=general, 2=auth, 3=API, 4=invalid input). Errors output as JSON to stderr when format is json/ndjson.
  • Input validation: Validates org/project slugs, issue IDs, event IDs, and inspect URLs before making API calls. Catches malformed input from hallucinating agents.
  • --fields flag: Filters JSON output to only requested fields (e.g. --fields id,title,status). Reduces token usage for large Sentry payloads.
  • --format ndjson: Newline-delimited JSON output — one object per line, no array brackets. Useful for streaming and piping through jq.
  • describe command: Machine-readable JSON introspection of all commands, args, flags, and output fields. Supports sentire describe (all) and sentire describe events list-issues (specific).
  • context command + CONTEXT.md: Agent-specific usage guide with command reference, error codes, and tips.
  • Also fixes a pre-existing TestNewClient test failure when a config file exists at ~/.config/sentire/config.json.

Test plan

  • make test passes (51 tests, 0 failures)
  • make build succeeds
  • New tests cover: structured errors, input validation (valid/invalid slugs, IDs, URLs, exit codes), field filtering (single/slice/no-filter), NDJSON (single/multiple/with-fields), describe (all/specific/unknown)

The test assumed unsetting SENTRY_API_TOKEN would cause an error,
but LoadConfig falls back to ~/.config/sentire/config.json. Override
HOME to a temp directory so no config file is found.
Introduce CLIError type with machine-readable error codes (auth_missing,
api_error, invalid_input, invalid_format) and distinct exit codes
(0=success, 1=general, 2=auth, 3=API, 4=invalid input).

Errors are output as JSON to stderr when format is json. Add typed
error wrappers in config (AuthError), client (APIError), and formatter
(FormatError) that are automatically mapped to CLIError at the CLI layer.
Validate org/project slugs (lowercase alphanumeric + hyphens, max 50
chars), issue IDs (numeric), event IDs (32 hex chars or
latest/oldest/recommended), and inspect URLs (must contain sentry.io)
before making API calls. Returns CLIError with invalid_input code and
exit code 4.
Add global --fields flag that accepts comma-separated field names
(e.g. --fields id,title,status). When specified, JSON output only
includes the requested fields, reducing payload size for agents that
only need specific data from large Sentry responses.
Add NDJSON formatter that outputs one JSON object per line with no
array wrapper or indentation. Supports --fields filtering. Useful for
agents processing results incrementally or piping through jq.
Add 'sentire describe' command that outputs machine-readable JSON
describing all commands, their args, flags, and output fields. Supports
'sentire describe events list-issues' for a specific command. Uses
reflect to extract JSON tag names from model structs.
Add CONTEXT.md with agent-specific guidance (command reference, output
control, error codes, tips). Add 'sentire context' command that prints
it using go:embed.
@andreagrandi andreagrandi merged commit 3afd5f4 into master Mar 7, 2026
2 checks passed
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