Skip to content

Commit e174c46

Browse files
fix: add README files to published packages
1 parent fecf440 commit e174c46

File tree

2 files changed

+143
-0
lines changed

2 files changed

+143
-0
lines changed

.github/workflows/release.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ jobs:
3131
- run: pnpm install
3232
- run: pnpm run build
3333

34+
- name: Copy READMEs for npm packages
35+
run: |
36+
cp README.md packages/toon/README.md
37+
echo "✓ Copied root README to @toon-format/toon"
38+
echo "✓ CLI package uses its own README"
39+
3440
- name: Publish to npm
3541
run: npm install -g npm@latest && pnpm -r publish --access public --no-git-checks
3642
env:

packages/cli/README.md

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# @toon-format/cli
2+
3+
Command-line tool for converting between JSON and TOON formats.
4+
5+
[TOON (Token-Oriented Object Notation)](https://toonformat.dev) is a compact, human-readable serialization format designed for passing structured data to Large Language Models with significantly reduced token usage.
6+
7+
## Installation
8+
9+
```bash
10+
# npm
11+
npm install -g @toon-format/cli
12+
13+
# pnpm
14+
pnpm add -g @toon-format/cli
15+
16+
# yarn
17+
yarn global add @toon-format/cli
18+
```
19+
20+
Or use directly with `npx`:
21+
22+
```bash
23+
npx @toon-format/cli [options] [input]
24+
```
25+
26+
## Usage
27+
28+
```bash
29+
toon [options] [input]
30+
```
31+
32+
**Standard input:** Omit the input argument or use `-` to read from stdin. This enables piping data directly from other commands.
33+
34+
**Auto-detection:** The CLI automatically detects the operation based on file extension (`.json` → encode, `.toon` → decode). When reading from stdin, use `--encode` or `--decode` flags to specify the operation (defaults to encode).
35+
36+
### Basic Examples
37+
38+
```bash
39+
# Encode JSON to TOON (auto-detected)
40+
toon input.json -o output.toon
41+
42+
# Decode TOON to JSON (auto-detected)
43+
toon data.toon -o output.json
44+
45+
# Output to stdout
46+
toon input.json
47+
48+
# Pipe from stdin
49+
cat data.json | toon
50+
echo '{"name": "Ada"}' | toon
51+
52+
# Decode from stdin
53+
cat data.toon | toon --decode
54+
```
55+
56+
## Options
57+
58+
| Option | Description |
59+
| ------ | ----------- |
60+
| `-o, --output <file>` | Output file path (prints to stdout if omitted) |
61+
| `-e, --encode` | Force encode mode (overrides auto-detection) |
62+
| `-d, --decode` | Force decode mode (overrides auto-detection) |
63+
| `--delimiter <char>` | Array delimiter: `,` (comma), `\t` (tab), `\|` (pipe) |
64+
| `--indent <number>` | Indentation size (default: `2`) |
65+
| `--length-marker` | Add `#` prefix to array lengths (e.g., `items[#3]`) |
66+
| `--stats` | Show token count estimates and savings (encode only) |
67+
| `--no-strict` | Disable strict validation when decoding |
68+
69+
## Advanced Examples
70+
71+
### Token Statistics
72+
73+
Show token savings when encoding:
74+
75+
```bash
76+
toon data.json --stats -o output.toon
77+
```
78+
79+
Example output:
80+
```
81+
✓ Encoded to TOON
82+
Input: 15,145 tokens (JSON)
83+
Output: 8,745 tokens (TOON)
84+
Saved: 6,400 tokens (42.3% reduction)
85+
```
86+
87+
### Alternative Delimiters
88+
89+
#### Tab-separated (often more token-efficient)
90+
91+
```bash
92+
toon data.json --delimiter "\t" -o output.toon
93+
```
94+
95+
#### Pipe-separated with length markers
96+
97+
```bash
98+
toon data.json --delimiter "|" --length-marker -o output.toon
99+
```
100+
101+
### Lenient Decoding
102+
103+
Skip validation for faster processing:
104+
105+
```bash
106+
toon data.toon --no-strict -o output.json
107+
```
108+
109+
### Stdin Workflows
110+
111+
```bash
112+
# Convert API response to TOON
113+
curl https://api.example.com/data | toon --stats
114+
115+
# Process large dataset
116+
cat large-dataset.json | toon --delimiter "\t" > output.toon
117+
118+
# Chain with other tools
119+
jq '.results' data.json | toon > filtered.toon
120+
```
121+
122+
## Why Use the CLI?
123+
124+
- **Quick conversions** between formats without writing code
125+
- **Token analysis** to see potential savings before sending to LLMs
126+
- **Pipeline integration** with existing JSON-based workflows
127+
- **Flexible formatting** with delimiter and indentation options
128+
129+
## Related
130+
131+
- [@toon-format/toon](https://www.npmjs.com/package/@toon-format/toon) - JavaScript/TypeScript library
132+
- [Full specification](https://github.com/toon-format/spec) - Complete format documentation
133+
- [Website](https://toonformat.dev) - Interactive examples and guides
134+
135+
## License
136+
137+
[MIT](https://github.com/toon-format/toon/blob/main/LICENSE) License © 2025-PRESENT [Johann Schopplich](https://github.com/johannschopplich)

0 commit comments

Comments
 (0)