feat: add sentry schema command for API introspection#437
Conversation
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Init
Issue List
Other
Bug Fixes 🐛Dsn
Init
Other
Documentation 📚
Internal Changes 🔧Init
Tests
Other
Other
🤖 This preview updates automatically when you update the PR. |
Codecov Results 📊✅ 111 passed | Total: 111 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ✅ Patch coverage is 100.00%. Project has 1101 uncovered lines. Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 95.06% 95.09% +0.03%
==========================================
Files 165 167 +2
Lines 22299 22406 +107
Branches 0 0 —
==========================================
+ Hits 21198 21305 +107
- Misses 1101 1101 —
- Partials 0 0 —Generated by Codecov Action |
2c58186 to
1dad125
Compare
Addressing review comments
|
1dad125 to
09e77fd
Compare
09e77fd to
da1532a
Compare
Round 3 review fixesAll six comments addressed:
Re: fuzzy/levenshtein — there's a private |
da1532a to
8bbae55
Compare
8bbae55 to
0b6784a
Compare
0b6784a to
ef79773
Compare
sentry schema command for API introspection
3a4dfd2 to
4ed3be6
Compare
4ed3be6 to
c6dd55f
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Phase 2 of #346: Add `sentry schema` command for runtime API introspection by AI agents. New features: - `sentry schema` — list all API resources with endpoint counts - `sentry schema <resource>` — list endpoints for a resource - `sentry schema <resource> <operation>` — show endpoint details - `sentry schema --list` — flat list of all 214 API endpoints - `sentry schema --search <query>` — search across endpoints - All modes support `--json` for machine-readable output Architecture: - `script/generate-api-schema.ts` — build-time parser that extracts endpoint metadata from `@sentry/api` (function names, HTTP methods, URL templates, JSDoc descriptions, deprecation status) - `src/generated/api-schema.json` — lightweight index (102KB, 214 endpoints) bundled into the CLI - `src/lib/api-schema.ts` — runtime query functions (by resource, operation, or full-text search) - `src/commands/schema.ts` — command with human + JSON output modes Tests: 19 unit tests for schema query functions
c6dd55f to
1f681e6
Compare

Phase 2 of #346: Add
sentry schemacommand for runtime API introspection by AI agents.What
Enables AI agents to discover Sentry API endpoints at runtime without pre-loaded documentation:
Architecture
Build-time generation —
script/generate-api-schema.tsfetches the dereferenced OpenAPI spec fromgetsentry/sentry-api-schema(version-tagged to match the installed@sentry/apipackage) and extracts:@sentry/apiJS bundleOutput:
src/generated/api-schema.json(215 endpoints, ~117KB) — gitignored, generated at build/dev/test time viabun run generate:schema.Runtime —
src/lib/api-schema.tsprovides query functions:getResourceSummaries()— grouped resource overviewgetEndpointsByResource()— filter by resourcegetEndpoint()— find specific endpoint (prefers operationId prefix match)searchEndpoints()— full-text search across all fieldsThe
sentry schemacommand yieldsCommandOutputthrough the standard output system withmdKvTable+renderMarkdownfor endpoint detail views.Other changes
@sentry/apifrom 0.21.0 → 0.54.0generate:schemabefore lint, typecheck, and testssrc/generated/added to.gitignoreTests
19 unit tests for schema query functions covering all query modes, edge cases, and data invariants.