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.0.tar.gz (221.5 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.0-py3-none-any.whl (21.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: wick_formatter-0.1.0.tar.gz
  • Upload date:
  • Size: 221.5 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.0.tar.gz
Algorithm Hash digest
SHA256 7a25f74f9369274b373d175fe88bfce16d7ce3b4be651fd89ead57e2066b5289
MD5 0ffd76c5db2e4ba8f8b9e22ed63de4a3
BLAKE2b-256 5de4db9e67ea82a18944f4d6f05d2838e35367ab74a6e562d751b91c45ea5f1b

See more details on using hashes here.

Provenance

The following attestation bundles were made for wick_formatter-0.1.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: wick_formatter-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d26bdd19352dd2a7ef807c357393c9a42764be412ed853e5391917388e3b8fc0
MD5 db693d5baa5671962f55b8e172ed0bb9
BLAKE2b-256 b6f50e00a14c6c6a91b8e28ef231fe479bb964036e324ba0135bf8e4308a75d5

See more details on using hashes here.

Provenance

The following attestation bundles were made for wick_formatter-0.1.0-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