1- # Dune CLI — ` dune query ` Implementation Plan
1+ # Dune CLI — Implementation Plan
22
33## Commands
44
5+ ### ` dune query ` — query management + execution triggers
6+
7+ | Command | Maps to MCP tool | SDK method |
8+ | ---------| -----------------| ------------|
9+ | ` query create ` | ` createDuneQuery ` | ` CreateQuery ` (new — added to SDK in Step 2) |
10+ | ` query get ` | ` getDuneQuery ` | ` GetQuery ` (new — added to SDK in Step 2) |
11+ | ` query update ` | ` updateDuneQuery ` | ` UpdateQuery ` (new — added to SDK in Step 2) |
12+ | ` query archive ` | ` updateDuneQuery ` (is_archived) | ` ArchiveQuery ` (new — added to SDK in Step 2) |
13+ | ` query run ` | ` executeQueryById ` + ` getExecutionResults ` | ` RunQuery ` + ` Execution.WaitGetResults ` |
14+ | ` query run-sql ` | (ad-hoc SQL) + ` getExecutionResults ` | ` RunSQL ` + ` Execution.WaitGetResults ` |
15+
16+ ### ` dune execution ` — operations on executions (by execution ID)
17+
518| Command | Maps to MCP tool | SDK method |
619| ---------| -----------------| ------------|
7- | ` create ` | ` createDuneQuery ` | ` CreateQuery ` (new — added to SDK in Step 2) |
8- | ` get ` | ` getDuneQuery ` | ` GetQuery ` (new — added to SDK in Step 2) |
9- | ` update ` | ` updateDuneQuery ` | ` UpdateQuery ` (new — added to SDK in Step 2) |
10- | ` archive ` | ` updateDuneQuery ` (is_archived) | ` ArchiveQuery ` (new — added to SDK in Step 2) |
11- | ` run ` | ` executeQueryById ` + ` getExecutionResults ` | ` RunQuery ` + ` Execution.WaitGetResults ` |
12- | ` results ` | ` getExecutionResults ` | ` QueryResultsV2 ` |
13- | ` run-sql ` | (ad-hoc SQL) + ` getExecutionResults ` | ` RunSQL ` + ` Execution.WaitGetResults ` |
20+ | ` execution results ` | ` getExecutionResults ` | ` QueryResultsV2 ` |
1421
1522All commands use ** only** the SDK's ` dune.DuneClient ` interface. No separate HTTP client in the CLI.
1623
@@ -395,7 +402,7 @@ API reference: POST `/api/v1/query/{queryId}/archive` — dedicated endpoint, no
395402
396403## Step 8: ` dune query run`
397404
398- - [ ] Done
405+ - [x ] Done
399406
400407` cmd/query/run.go ` — positional arg: query ID. Flags: ` --param key=value` (repeatable), ` --performance medium|large` , ` --limit` , ` --no-wait` , ` -o` .
401408
@@ -433,21 +440,25 @@ Reuses: SDK's `RunQuery`, `Execution.WaitGetResults`, `QueryExecute`, `ResultsRe
433440
434441---
435442
436- ## Step 9: ` dune query results`
443+ ## Step 9: ` dune execution results`
437444
438445- [ ] Done
439446
440- ` cmd/query/results.go ` — positional arg: execution ID (string). Flags: ` --limit` , ` --offset` , ` -o` .
447+ New ` execution` parent command (` cmd/execution/execution.go ` ) + ` results` subcommand (` cmd/execution/results.go ` ).
448+
449+ Positional arg: execution ID (string). Flags: ` --limit` , ` --offset` , ` -o` .
441450
442451One-shot fetch via ` client.QueryResultsV2 (executionID, models.ResultOptions {Page: &models.ResultPageOption {Offset, Limit}})` — no polling. If still running: print status, exit 0. If complete: display results. If failed: print error, exit 1.
443452
444453API reference: GET ` /api/v1/execution/{execution_id}/results` — query params: limit, offset → state, result metadata, data rows. States: ` QUERY_STATE_COMPLETED` , ` QUERY_STATE_PENDING` , ` QUERY_STATE_EXECUTING` , ` QUERY_STATE_FAILED` , ` QUERY_STATE_CANCELLED` , ` QUERY_STATE_EXPIRED` .
445454
446455Reuses: SDK's ` QueryResultsV2` , ` models.ResultOptions ` , ` models.ResultPageOption ` , ` models.ResultsResponse ` .
447456
457+ Reuses from ` cmd/query/run.go ` : ` displayResults` and ` resultRowsToStrings` — these must be moved to a shared location (e.g., ` output/` package or ` cmdutil/` ) since they'll now be called from a different package.
458+
448459**Acceptance criteria:**
449- - Completed execution displays results
450- - ` --limit` and ` --offset` work
460+ - ` dune execution results <execution-id> ` displays results
461+ - ` --limit` and ` --offset` work (passed to ` ResultPageOption ` )
451462- Running execution prints status, exits 0
452463- Failed execution prints error, exits 1
453464- ` -o json` works
@@ -502,17 +513,21 @@ cli/ # CLI repo
502513 main.go # Entry point (exists)
503514 query/
504515 query.go # Query parent command (exists)
516+ helpers.go # Shared helpers (parseQueryID)
505517 create.go # Step 4
506518 get.go # Step 5
507519 update.go # Step 6
508520 archive.go # Step 7
509521 run.go # Step 8
510- results.go # Step 9
511522 run_sql.go # Step 10
523+ execution/
524+ execution.go # Step 9 : Execution parent command
525+ results.go # Step 9 : Results subcommand
512526 cmdutil/
513527 client.go # SetClient , ClientFromCmd (context helpers)
514528 output/
515529 output.go # Shared output formatting (text, JSON )
530+ results.go # Step 9 : Shared result display (moved from cmd/query/run.go )
516531 go .mod # Has replace directive → ../duneapi-client-go
517532 plan/
518533 query-commands.md # This plan
@@ -534,8 +549,9 @@ duneapi-client-go/ # SDK repo (separate)
534549Step 1 (scaffolding + SDK integration + replace directive)
535550 ├── Step 2 (add query CRUD to SDK — separate repo)
536551 │ └── Steps 4-7 (CRUD commands — need Step 2)
537- ├── Steps 8-9 (execution commands — need Step 1, SDK already has methods)
538- └── Step 10 (run-sql — need Step 1, SDK already has RunSQL)
552+ ├── Step 8 (query run — need Step 1, SDK already has methods)
553+ ├── Step 9 (execution results — need Step 1, new execution namespace)
554+ └── Step 10 (query run-sql — need Step 1, SDK already has RunSQL)
539555```
540556
541557Output formatting (` output/ ` ) is created inline with the first command that needs it.
0 commit comments