feat!: publish to @toon-format/toon and @toon-format/cli

This commit is contained in:
Johann Schopplich
2025-11-01 16:53:41 +01:00
parent 8bcbdb7315
commit 0710bd19e7
29 changed files with 129 additions and 84 deletions

View File

@@ -3,9 +3,9 @@
# Token-Oriented Object Notation (TOON)
[![CI](https://github.com/johannschopplich/toon/actions/workflows/ci.yml/badge.svg)](https://github.com/johannschopplich/toon/actions)
[![npm version](https://img.shields.io/npm/v/@byjohann/toon.svg)](https://www.npmjs.com/package/@byjohann/toon)
[![npm version](https://img.shields.io/npm/v/@toon-format/toon.svg)](https://www.npmjs.com/package/@toon-format/toon)
[![SPEC v1.3](https://img.shields.io/badge/spec-v1.3-lightgrey)](./SPEC.md)
[![npm downloads (total)](https://img.shields.io/npm/dt/@byjohann/toon.svg)](https://www.npmjs.com/package/@byjohann/toon)
[![npm downloads (total)](https://img.shields.io/npm/dt/@toon-format/toon.svg)](https://www.npmjs.com/package/@toon-format/toon)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
**Token-Oriented Object Notation** is a compact, human-readable format designed for passing structured data to Large Language Models with significantly reduced token usage. It's intended for LLM input, not output.
@@ -439,19 +439,19 @@ Four datasets designed to test different structural patterns (all contain arrays
```bash
# npm
npm install @byjohann/toon
npm install @toon-format/toon
# pnpm
pnpm add @byjohann/toon
pnpm add @toon-format/toon
# yarn
yarn add @byjohann/toon
yarn add @toon-format/toon
```
**Example usage:**
```ts
import { encode } from '@byjohann/toon'
import { encode } from '@toon-format/toon'
const data = {
users: [
@@ -473,20 +473,20 @@ Command-line tool for converting between JSON and TOON formats.
### Usage
```bash
npx @byjohann/toon <input> [options]
npx @toon-format/cli <input> [options]
```
**Auto-detection:** The CLI automatically detects the operation based on file extension (`.json` → encode, `.toon` → decode).
```bash
# Encode JSON to TOON (auto-detected)
toon input.json -o output.toon
npx @toon-format/cli input.json -o output.toon
# Decode TOON to JSON (auto-detected)
toon data.toon -o output.json
npx @toon-format/cli data.toon -o output.json
# Output to stdout
toon input.json
npx @toon-format/cli input.json
```
### Options
@@ -506,16 +506,16 @@ toon input.json
```bash
# Show token savings when encoding
toon data.json --stats -o output.toon
npx @toon-format/cli data.json --stats -o output.toon
# Tab-separated output (often more token-efficient)
toon data.json --delimiter "\t" -o output.toon
npx @toon-format/cli data.json --delimiter "\t" -o output.toon
# Pipe-separated with length markers
toon data.json --delimiter "|" --length-marker -o output.toon
npx @toon-format/cli data.json --delimiter "|" --length-marker -o output.toon
# Lenient decoding (skip validation)
toon data.toon --no-strict -o output.json
npx @toon-format/cli data.toon --no-strict -o output.json
```
## Format Overview
@@ -741,7 +741,7 @@ A TOON-formatted string with no trailing newline or spaces.
**Example:**
```ts
import { encode } from '@byjohann/toon'
import { encode } from '@toon-format/toon'
const items = [
{ sku: 'A1', qty: 2, price: 9.99 },
@@ -862,7 +862,7 @@ A JavaScript value (object, array, or primitive) representing the parsed TOON da
**Example:**
```ts
import { decode } from '@byjohann/toon'
import { decode } from '@toon-format/toon'
const toon = `
items[2]{sku,qty,price}:
@@ -980,7 +980,7 @@ Task: Return only users with role "user" as TOON. Use the same header. Set [N] t
## Other Implementations
> [!NOTE]
> When implementing TOON in other languages, please follow the [SPEC.md](./SPEC.md) (currently v1.3) to ensure compatibility across implementations. The [TypeScript test suite](./test) provides comprehensive examples of encoding and decoding behavior that can serve as a reference implementation.
> When implementing TOON in other languages, please follow the [SPEC.md](./SPEC.md) (currently v1.3) to ensure compatibility across implementations. The [TypeScript test suite](./packages/toon/test) provides comprehensive examples of encoding and decoding behavior that can serve as a reference implementation.
- **.NET:** [ToonSharp](https://github.com/0xZunia/ToonSharp)
- **Crystal:** [toon-crystal](https://github.com/mamantoha/toon-crystal)