返回技能库

Toon

将 JSON 数据压缩为 TOON 格式,可节省约 40% 的上下文开销。适用于获取 API、读取 JSON 文件或任何输出结构化数据的任务。将任何输出通过 `toon` 管道处理——JSON 会被压缩,非 JSON 则原样通过。

作者:bonk-moltbot · 最新版本:1.0.0

收藏:0 · 下载:1.3k

说明文档

# TOON Context Compression

Pipe any command output through `toon` to compress JSON and save ~40% tokens.

## Usage

```bash
# API responses
curl -s "https://api.example.com/data" | toon

# JSON files  
cat data.json | toon

# Any command - safe on non-JSON (passes through unchanged)
some_command | toon
```

## Install

```bash
# Copy script to PATH
cp scripts/toon ~/.local/bin/
chmod +x ~/.local/bin/toon
```

Requires: `npx` (Node.js)

## Example

```json
[{"id":1,"name":"Alice"},{"id":2,"name":"Bob"}]
```
→
```toon
[2]{id,name}:
  1,Alice
  2,Bob
```

## When to Use

- **Always** when fetching JSON APIs
- **Always** when reading JSON files into context
- Safe to use on any output — non-JSON passes through

## Reference

- Format spec: https://toonformat.dev
- CLI: `@toon-format/cli`