Skip to content

feat: add --output toon (token-efficient output format)#23

Merged
apgiorgi merged 6 commits into
mainfrom
claude/issue-9-toon-output
Jun 9, 2026
Merged

feat: add --output toon (token-efficient output format)#23
apgiorgi merged 6 commits into
mainfrom
claude/issue-9-toon-output

Conversation

@apgiorgi

@apgiorgi apgiorgi commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds toon as an opt-in value for --output, emitting TOON (Token-Oriented Object Notation) — a compact, lossless format that uses ~40% fewer tokens than JSON for list-shaped data, useful when an LLM agent drives the CLI. table remains the default.

  • New dciToonContentType mirrors the existing dciTableContentType: toJSONSafetoon.Marshal, degrading to indented JSON on any encode error.
  • Registered with restish under the short name toon; wired into the --output validation switch, help text, and error message.
  • Adds github.com/toon-format/toon-go (pure-Go, no cgo — keeps cross-compilation portable).
  • README documents the format.

Implements the TOON slice of #9. Schema/projection/truncation/limit work remains open on #9 and is intentionally out of scope. Coordination note left on #21 (agent-mode) so it can adopt toon as the agent default.

Design + plan: docs/superpowers/specs/2026-06-08-toon-output-design.md, docs/superpowers/plans/2026-06-08-toon-output.md.

Test Plan

  • go build ./... && go vet ./... && go test ./... all green
  • dciToonContentType.Marshal unit tests: list (tabular), object (real TOON, not JSON fallback), scalars
  • TestOutputFlagValidation drives real cobra Execute — accepts table/json/yaml/auto/toon, rejects unknown
  • Manual: dci list-budgets --output toon renders TOON against the live API; --output bogus errors with the supported list
  • CGO_ENABLED=0 confirms toon-go introduces no cgo requirement

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an opt-in --output toon format to the CLI, using the TOON (Token-Oriented Object Notation) encoder for more token-efficient, agent-friendly output while keeping table as the default.

Changes:

  • Add toon to --output flag help + validation and register a new dciToonContentType formatter.
  • Add unit tests covering TOON marshaling and --output flag validation.
  • Add the github.com/toon-format/toon-go dependency and document TOON in README + internal design/plan docs.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
README.md Documents --output toon and links to the TOON format site.
main.go Registers toon output, validates the new flag value, and implements dciToonContentType marshaling with JSON fallback.
main_test.go Adds tests for TOON marshaling and for --output flag validation behavior via Cobra execution.
go.mod Adds github.com/toon-format/toon-go dependency.
go.sum Adds checksums for the new TOON dependency.
docs/superpowers/specs/2026-06-08-toon-output-design.md Adds design spec for the TOON output slice of #9.
docs/superpowers/plans/2026-06-08-toon-output.md Adds an implementation plan for TOON output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread main_test.go Outdated
Comment thread docs/superpowers/specs/2026-06-08-toon-output-design.md Outdated
Comment thread docs/superpowers/specs/2026-06-08-toon-output-design.md Outdated
Comment thread docs/superpowers/plans/2026-06-08-toon-output.md Outdated
@apgiorgi apgiorgi force-pushed the claude/issue-9-toon-output branch from 886d71b to 9da2fcf Compare June 9, 2026 08:25
@apgiorgi apgiorgi mentioned this pull request Jun 9, 2026
6 tasks
@apgiorgi

apgiorgi commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed the Copilot review:

  • main_test.go — list test could pass on JSON fallback ✅ Fixed in f7173c7. Added a strings.HasPrefix(s, "{") guard so TestToonMarshalListProducesTabularOutput fails if it silently falls back to indented JSON (mirrors the object test's check).
  • The 3 comments on docs/superpowers/specs/... and docs/superpowers/plans/... — moot. Those scaffolding files were removed from this branch (force-pushed); the design/scope notes now live as a comment on Token-efficient output format #9 instead. Copilot reviewed the pre-cleanup revision.

@apgiorgi apgiorgi left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@apgiorgi apgiorgi merged commit 13ea20d into main Jun 9, 2026
6 checks passed
@apgiorgi apgiorgi deleted the claude/issue-9-toon-output branch June 9, 2026 15:40
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.

2 participants