Skip to main content

Compact text formats for feeding structured data into LLM contexts.

Project description

wick-formatter

CI codecov PyPI version Docker

Compact text formats for feeding structured data into LLM contexts. Python library, CLI, and stdio MCP server.

wick-formatter's primary format is LEAN (LLM-Efficient Adaptive Notation), an independent Python implementation of a format originally designed by Denys Fiialko. On tabular structured data, LEAN typically produces substantially fewer characters than uncompressed JSON while remaining losslessly round-trippable.

Guarantees

100% lossless round-trip. For any supported value:

decode(encode(data)) == data

This is verified on every benchmark run. If round-trip fails on any item, the benchmark hard-fails before measuring anything else.

No accuracy loss. LLM task accuracy with LEAN-encoded data matches JSON-encoded data within measurement noise. The benchmark enforces a maximum 3 percentage point delta.

Latest benchmark

Metric Value
Round-trip 100% lossless
Compression 45.7% fewer characters
LLM accuracy (JSON) 53.8%
LLM accuracy (LEAN) 51.9%
Accuracy delta 1.9pp
Items tested 52
Model llama3.1:8b-instruct-q4_K_M
Corpus WikiTableQuestions + custom

See docs/BENCHMARK_RESULTS.md for methodology, data sources, and replication instructions.

Status

v0.1.0, pre-release. API and on-wire format are still stabilising. See docs/CHANGELOG.md for release notes and docs/ROADMAP.md for the v0.1.0 acceptance gates and deferred items.

Install

pip install wick-formatter

Runtime dependency: mcp (only required when using the MCP server).

What's in the box

  • wick_formatter — Python library with a pluggable format registry.
  • wick-formatter — CLI (--format=X {encode,decode}, stdin→stdout).
  • python -m wick_formatter.mcp — stdio MCP server exposing wf_encode and wf_decode.
  • tests/benchmarks/ — WikiTableQuestions-based harness comparing LEAN to a JSON baseline on llama3.1:8b-instruct-q4_K_M through an OpenAI-compatible endpoint (Ollama by default, API-provider swappable).

Quick example

Encode a small array of records into LEAN's tabular form:

echo '[{"a": 1, "b": 2}, {"a": 3, "b": 4}]' \
    | wick-formatter --format=lean encode

Decode it back:

wick-formatter --format=lean decode < record.lean

The full round-trip contract — including the ~-marker semi-tabular path, dot-flatten, and block encodings — is documented in docs/SPEC.md.

Python API

from wick_formatter import get, decode

# Get the LEAN format encoder
lean = get("lean")

# Encode tabular data
data = [{"name": "Alice", "score": 95}, {"name": "Bob", "score": 87}]
encoded = lean.encode(data)
print(encoded)
# name|score
# Alice|95
# Bob|87

# Decode back to original
decoded = decode(encoded)
assert decoded == data

MCP Server Setup

For Claude Code or Codex integration:

git clone https://github.com/p6rguvyrst/wick-formatter
cd wick-formatter
make client-claude   # or: make client-codex

Check status: make client-status

Remove: make client-clean

Requires jq for JSON manipulation. Install with brew install jq (macOS) or apt install jq (Linux).

Format specification

The complete LEAN format specification, including the encoder strategy selection rules and error cases, lives at docs/SPEC.md.

License and attribution

wick-formatter is released under the MIT License.

The LEAN format was originally designed and implemented by Denys Fiialko; see NOTICE for attribution, clean-room posture, and a specific credit for the semi-tabular encoding path first implemented in his toon-mcp-server repository.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wick_formatter-0.1.1.tar.gz (222.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wick_formatter-0.1.1-py3-none-any.whl (21.7 kB view details)

Uploaded Python 3

File details

Details for the file wick_formatter-0.1.1.tar.gz.

File metadata

  • Download URL: wick_formatter-0.1.1.tar.gz
  • Upload date:
  • Size: 222.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for wick_formatter-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d8d6fb5566cb1a7d422b94239f74937f090859f8ae5fe43d241664118a53e47e
MD5 b7e75b7eb0336dcc61c9326aecc3c771
BLAKE2b-256 e8564a09b58354c5f1e6732ada357fc0d31e4b8e2b742a24cddb1fec4678295b

See more details on using hashes here.

Provenance

The following attestation bundles were made for wick_formatter-0.1.1.tar.gz:

Publisher: release.yml on P6rguVyrst/wick-formatter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file wick_formatter-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: wick_formatter-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 21.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for wick_formatter-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1b763d493f21c0b46382c2b4ee03e3ee00659a96466039179ab2ed3f8dbcedaa
MD5 76cad40f50cd55b81619977f640fd43c
BLAKE2b-256 31e4d6d6ee033787eb42cdfcd8b22ff59f6441365ecfe5f72d2dfd33c6ab0ca3

See more details on using hashes here.

Provenance

The following attestation bundles were made for wick_formatter-0.1.1-py3-none-any.whl:

Publisher: release.yml on P6rguVyrst/wick-formatter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page