feat: add TOON output format for LLM-efficient data serialization#30
Merged
CodySearsOS merged 2 commits intomainfrom Feb 26, 2026
Merged
feat: add TOON output format for LLM-efficient data serialization#30CodySearsOS merged 2 commits intomainfrom
CodySearsOS merged 2 commits intomainfrom
Conversation
Co-Authored-By: cody.sears@opensea.io <cody.sears@opensea.io>
Contributor
Original prompt from cody.sears@opensea.io |
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Co-Authored-By: cody.sears@opensea.io <cody.sears@opensea.io>
ryanio
approved these changes
Feb 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat: add TOON output format for LLM-efficient data serialization
Summary
Adds TOON (Token-Oriented Object Notation) as a third
--formatoption alongsidejsonandtable. TOON is a compact, human-readable encoding of JSON that uses ~40% fewer tokens, making it ideal for piping CLI output into AI agent context windows.The encoder is implemented from scratch in
src/toon.tsfollowing the TOON v3.0 spec — no external dependency added. It handles:[N]:headers (§9.1)[N]{fields}:headers (§9.3)Usage:
opensea collections list --format toonChanges:
src/toon.ts— standalone TOON encoder (~338 lines)OutputFormattype ("json" | "table" | "toon") replaces inline string unions across all command filesformatToonandOutputFormatexported from SDK index for programmatic usetest/toon.test.tscovering primitives, objects, all array forms, the spec's hikes example, andformatOutputintegrationConfidence: 🟡 MEDIUM — Encoder follows the spec and passes unit tests including the canonical hikes example, but has not been tested against real OpenSea API response shapes (deeply nested NFT metadata, protocol_data, etc.).
Review & Testing Checklist for Human
opensea collections get boredapeyachtclub --format toonandopensea tokens trending --format toonto confirm the output is useful and correctly structured. Nested API responses (listings withprotocol_data, NFTs withtraits) are the most likely to surface encoding issues.needsQuoting()against TOON spec §7.2 — especially for values containing URLs (colons), descriptions with commas, and wallet addresses starting with0x(leading-zero check).encodeExpandedList+ bottom half ofencodeArray) — these handle the complex case of non-uniform arrays and have significant code overlap. Check correctness for objects-as-list-items per §9.4/§10 and consider whether the duplication should be refactored.market_cap,price_usd). Confirm these roughly match actual/api/v2/tokens/trendingresponse shapes or update to match reality.Notes
Link to Devin run: https://app.devin.ai/sessions/73e236d755164371a78158c3de534841
Requested by: @CodySearsOS