Skip to content

Add the traceroot sql schema CLI command + docs examples #28

Description

@dark-sorceror

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.tsregisterSqlSchema + 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

  • traceroot sql schema prints the 3-column schema after the analytical-export preamble (blobs-excluded note + a neutral "future opt-in blob export" reference, no specific flag name).
  • --json returns the raw schema with an added note field (not typed as SqlSchemaResponse).
  • input/output/metadata absent from all schema output (regression test).
  • Canonical examples appear in CLI help (.addHelpText) and the docs entry point.
  • New Vitest tests pass; npm run build clean; no regressions.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions