Skip to content

List columns in dataset search text output and add --compact JSON - #74

Open
0xRobin wants to merge 1 commit into
mainfrom
robin/search-columns-and-compact-json
Open

0xRobin wants to merge 1 commit into
mainfrom
robin/search-columns-and-compact-json

Conversation

@0xRobin

@0xRobin 0xRobin commented Nov 24, 2026

Copy link
Copy Markdown

What & why

dune dataset search and search-by-contract now list each table's columns in their default text output, under a COLUMNS section. Before, the command fetched the columns but the text output threw them away, so an agent had to switch to -o json to write SQL.
Every command with -o also gets --compact, which prints JSON on one line.
In a benchmark of Mentat (Dune's Centaur agent) running the CLI against the Dune MCP server, table search with columns took 2,979 tokens through -o json against MCP's 1,832. It now takes about 656 tokens as text, or 1,832 as compact JSON.

Architecture

Output-only change: no API requests or JSON fields change.

  • cmd/dataset/columns.go (new): turns a result's columns into name type pairs. It reads the Dune MCP's top-3 columns list first, then falls back to the API's --include-schema schema.fields. Both commands print one line per table that has columns.
  • output/output.go: AddFormatFlag also registers --compact. PrintJSON and PrintRawJSON now take the *cobra.Command instead of an io.Writer, write to cmd.OutOrStdout(), and drop indentation with --compact. All 49 call sites passed cmd.OutOrStdout() already; the change there is mechanical (w to cmd). Indented JSON is unchanged without the flag.
  • Tested: go test ./... passes. New tests check exact compact output for PrintJSON and PrintRawJSON, and the COLUMNS text for both commands, including that MCP columns take priority over the API schema (a test fails if the order is swapped). Ran the built binary against the live API: both commands print real columns, and --compact brings search JSON from 11,919 to 7,331 characters.
  • Lint: make lint already fails on main (e.g. tracking/tracking_test.go). This PR adds no new findings.
  • Blast radius: scripts that parse the text output of dataset search see new lines after the table. JSON output is unchanged unless --compact is passed. Mentat runs the latest release, so it picks this up within a day of the next release.
Agent context

dataset search and search-by-contract fetched column schemas but their text
output dropped them, so agents had to use -o json to write SQL. Text output now
lists each table's columns under COLUMNS: the Dune MCP's top-3 columns, or the
API schema with --include-schema.

Every command with -o now also takes --compact, which prints JSON on one line.
Indented JSON was about 60% larger than the same data compact.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1f9a9-af80-7151-a7e6-0056ca994479
Co-authored-by: Amp <amp@ampcode.com>
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