Summary
Add traceroot sql schema (schema introspection, framed as analytical export) and the canonical example commands that form the user-facing docs for the feature.
Context
- Lives in the TypeScript CLI repo (
traceroot-cli).
- Depends on the
traceroot sql command implementation.
- The curated schema is the single server-side source (
GET /api/v1/public/sql/schema). The "blobs excluded" framing must be prominent so users aren't surprised input/output aren't queryable.
Implementation
src/commands/sql/schema.ts — registerSqlSchema + runSqlSchema:
- Default: print an analytical-export preamble (states blobs are excluded and that raw blob export is a possible future opt-in — do not name a specific flag), then a 3-column
(table | column | type) aligned table.
--json: emit the raw SqlSchemaResponse plus a top-level note field ("Analytical export schema. input/output/metadata blobs excluded from MVP."). Build the JSON object explicitly (do not type the note-extended object as SqlSchemaResponse).
- Optional offline fallback may be deferred.
- Docs snippet — the five canonical examples (count spans 24h; p95 latency by model; cost by model; export spans to CSV; find error spans) + a
traceroot sql schema example, framed as analytical export, plus an output-mode table. Embed in src/commands/sql/query.ts via .addHelpText('after', …) and in the CLI README under "SQL — analytical export".
Test plan
tests/commands/sql-schema.test.ts (via runSqlSchema + fake client + StringSink):
- default output contains
spans, span_id, traces, and the Analytical export schema preamble.
--json parses and equals the raw schema plus the note field.
- Regression:
input/output/metadata never appear in either output.
- Full CLI suite +
npm run build.
Acceptance criteria
Summary
Add
traceroot sql schema(schema introspection, framed as analytical export) and the canonical example commands that form the user-facing docs for the feature.Context
traceroot-cli).traceroot sqlcommand implementation.GET /api/v1/public/sql/schema). The "blobs excluded" framing must be prominent so users aren't surprisedinput/outputaren't queryable.Implementation
src/commands/sql/schema.ts—registerSqlSchema+runSqlSchema:(table | column | type)aligned table.--json: emit the rawSqlSchemaResponseplus a top-levelnotefield ("Analytical export schema. input/output/metadata blobs excluded from MVP."). Build the JSON object explicitly (do not type thenote-extended object asSqlSchemaResponse).traceroot sql schemaexample, framed as analytical export, plus an output-mode table. Embed insrc/commands/sql/query.tsvia.addHelpText('after', …)and in the CLI README under "SQL — analytical export".Test plan
tests/commands/sql-schema.test.ts(viarunSqlSchema+ fake client +StringSink):spans,span_id,traces, and theAnalytical export schemapreamble.--jsonparses and equals the raw schema plus thenotefield.input/output/metadatanever appear in either output.npm run build.Acceptance criteria
traceroot sql schemaprints the 3-column schema after the analytical-export preamble (blobs-excluded note + a neutral "future opt-in blob export" reference, no specific flag name).--jsonreturns the raw schema with an addednotefield (not typed asSqlSchemaResponse).input/output/metadataabsent from all schema output (regression test)..addHelpText) and the docs entry point.npm run buildclean; no regressions.