Compress shell output text with Python and optional Rust backends
Project description
codetool-shell
Python interface library for compressing plain shell-output text before it is returned to an LLM/tool consumer.
from codetool_shell import compress_text
compressed = compress_text("one \n\n\n two\t\n")
print(compressed)
The core pipeline is intentionally conservative:
- normalize CRLF/CR line endings to LF
- trim trailing whitespace on each line
- run dedicated output filters only when they make the text smaller
- collapse repeated blank lines to
max_blank_lines(default:1)
Initial dedicated filters cover:
- git output: short and long status, tabbed name-status, diff stats, and patch hunks/binary-patch payloads with verbose unchanged or encoded context summarized
- test-runner output: conservative ANSI-aware pytest (including quiet progress/summary output), unittest-like, vitest-like, Playwright, and cargo-test summaries that preserve failure identifiers, assertion/error text, source locations, artifacts/traces, and final totals
- CI/job logs: conservative GitHub Actions /
gh run-style summaries that collapse repeated timestamped step noise while preserving step names, annotations, warnings/errors, file locations, artifact/URL/path references, and job/workflow conclusions - standalone Python tracebacks: conservative traceback summaries that preserve exception type/message, file stack frames, chained-exception separators, source/caret context, and small command noise while collapsing repeated or internal stack frames
- structured tables: conservative psql, SQLite/column, MySQL boxed, and long Markdown pipe table summaries that preserve headers, footers, first/last rows, and warning/error/URL/path/ID rows while counting omitted middle rows
- file/tree/listing output: conservative path-only,
tree, and safels -Rreducers that render repeated path prefixes as compact trees while preserving visible summary totals and leaving metadata-rich listings unchanged - ripgrep output: direct
path:line[:column]:text, heading-mode, context-modepath-line-contextwith--separators, and ANSI-colored matches grouped into a compact path tree when repeated paths or prefixes would otherwise be duplicated, while diagnostic/table/prose-looking output is left alone - generic application logs: conservative long timestamp/level-prefixed log summaries that collapse repeated INFO/DEBUG/TRACE patterns while preserving first/last context, warnings/errors/fatal/panic/exception lines, file paths/URLs, failure summaries, and unusual levels
- package-manager logs: conservative uv/pip, npm, bun, and cargo package install/update summaries that collapse progress/download/resolve/install noise while preserving warnings/errors, package summaries, versions, lock/frozen conflicts, audit/vulnerability summaries, hints, paths, and URLs
- build/compiler diagnostics: conservative cargo/rustc, tsc, ESLint, and mypy-like reducers that collapse build progress while preserving warnings/errors, codes, file spans, source/caret snippets, notes/help, rule IDs, and final summaries
Backends
backend="python"uses the pure-Python implementation.backend="rust"requires the optional Rust CLI backend.backend="auto"prefers Rust when a compatible binary is discoverable and falls back to Python otherwise.
Rust discovery order:
CODETOOL_SHELL_RUST_BINARY- packaged wheel binaries under
codetool_shell/bin/<platform>/ - development binaries under
rust/target/{release,debug}/ PATH
Build and stage the Rust CLI before creating a target wheel with:
python scripts/package_rust_binary.py --target-runtime linux-x86_64
Then build the Python distributions with:
uv build
During local development you can also rely on the development build directly:
cd rust
cargo build
Packaging and release
codetool-shell publishes target-specific wheels that include one matching
Rust helper binary under codetool_shell/bin/<runtime>/. Supported runtime keys
are:
linux-x86_64linux-aarch64macos-x86_64macos-arm64windows-x86_64windows-arm64
To build a Linux x86_64 wheel locally (replace the runtime key for other targets):
uv run python scripts/package_rust_binary.py --target-runtime linux-x86_64
CODETOOL_SHELL_TARGET_RUNTIME=linux-x86_64 uv build --wheel
The release workflow builds an sdist, manylinux wheels, native macOS/Windows
wheels, checks the distributions, and publishes to PyPI via trusted publishing
for tagged releases (v*) or manual dispatch with publish=true.
Development
uv sync --dev
uv run pytest
uv run python benchmarks/benchmark_compress_text.py
uv run python scripts/benchmark_filters.py --iterations 1000
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file codetool_shell-0.1.2.tar.gz.
File metadata
- Download URL: codetool_shell-0.1.2.tar.gz
- Upload date:
- Size: 258.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cdbc2d8d55dacfbed8b9e5901ff861787ea3ec10f0f9d0916788664eded7d188
|
|
| MD5 |
1c18f31fd668d40d029098e4613cbe2c
|
|
| BLAKE2b-256 |
655a516e7a041ecd010f294772db77c984ed8cf376e4fa899649655e8a22e235
|
Provenance
The following attestation bundles were made for codetool_shell-0.1.2.tar.gz:
Publisher:
release.yml on pbi-agent/codetool-shell
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codetool_shell-0.1.2.tar.gz -
Subject digest:
cdbc2d8d55dacfbed8b9e5901ff861787ea3ec10f0f9d0916788664eded7d188 - Sigstore transparency entry: 1903189789
- Sigstore integration time:
-
Permalink:
pbi-agent/codetool-shell@105bf9783eed9d43517cc267a11c0ba73361aa92 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/pbi-agent
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@105bf9783eed9d43517cc267a11c0ba73361aa92 -
Trigger Event:
push
-
Statement type:
File details
Details for the file codetool_shell-0.1.2-py3-none-win_arm64.whl.
File metadata
- Download URL: codetool_shell-0.1.2-py3-none-win_arm64.whl
- Upload date:
- Size: 634.6 kB
- Tags: Python 3, Windows ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80f2d7f5995edb17bcec478eb20ed8215e9199eceabcecbbfb2eb8e2f0db8a74
|
|
| MD5 |
50620dafcbd519d9e468244a2933df46
|
|
| BLAKE2b-256 |
f32a7b7d3453d6d872df817554b43d11c6497132fd638bb3516e741e6c427605
|
Provenance
The following attestation bundles were made for codetool_shell-0.1.2-py3-none-win_arm64.whl:
Publisher:
release.yml on pbi-agent/codetool-shell
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codetool_shell-0.1.2-py3-none-win_arm64.whl -
Subject digest:
80f2d7f5995edb17bcec478eb20ed8215e9199eceabcecbbfb2eb8e2f0db8a74 - Sigstore transparency entry: 1903190223
- Sigstore integration time:
-
Permalink:
pbi-agent/codetool-shell@105bf9783eed9d43517cc267a11c0ba73361aa92 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/pbi-agent
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@105bf9783eed9d43517cc267a11c0ba73361aa92 -
Trigger Event:
push
-
Statement type:
File details
Details for the file codetool_shell-0.1.2-py3-none-win_amd64.whl.
File metadata
- Download URL: codetool_shell-0.1.2-py3-none-win_amd64.whl
- Upload date:
- Size: 678.9 kB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a2b25187fb9e0f171465e2985ee28b0fd2837951b61b04f50107a5d1b40edfd
|
|
| MD5 |
8ade0e7c9c092e8306e95694475663b8
|
|
| BLAKE2b-256 |
3cc8fb6e06458178f4674da07b354e8238233ce8fddc9ed85555aa6d88595740
|
Provenance
The following attestation bundles were made for codetool_shell-0.1.2-py3-none-win_amd64.whl:
Publisher:
release.yml on pbi-agent/codetool-shell
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codetool_shell-0.1.2-py3-none-win_amd64.whl -
Subject digest:
2a2b25187fb9e0f171465e2985ee28b0fd2837951b61b04f50107a5d1b40edfd - Sigstore transparency entry: 1903189908
- Sigstore integration time:
-
Permalink:
pbi-agent/codetool-shell@105bf9783eed9d43517cc267a11c0ba73361aa92 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/pbi-agent
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@105bf9783eed9d43517cc267a11c0ba73361aa92 -
Trigger Event:
push
-
Statement type:
File details
Details for the file codetool_shell-0.1.2-py3-none-manylinux2014_x86_64.whl.
File metadata
- Download URL: codetool_shell-0.1.2-py3-none-manylinux2014_x86_64.whl
- Upload date:
- Size: 822.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5610551117383b25f524eb17ea6b56728ff66bd5905fb6908b8c63332e4f557b
|
|
| MD5 |
5bfe5a415d2fdec924b3f7632f5b2b3d
|
|
| BLAKE2b-256 |
465836f26a1caf1d30bdfb8dc7c9cac75f15d93285ed88464c0104c9fda9859b
|
Provenance
The following attestation bundles were made for codetool_shell-0.1.2-py3-none-manylinux2014_x86_64.whl:
Publisher:
release.yml on pbi-agent/codetool-shell
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codetool_shell-0.1.2-py3-none-manylinux2014_x86_64.whl -
Subject digest:
5610551117383b25f524eb17ea6b56728ff66bd5905fb6908b8c63332e4f557b - Sigstore transparency entry: 1903189974
- Sigstore integration time:
-
Permalink:
pbi-agent/codetool-shell@105bf9783eed9d43517cc267a11c0ba73361aa92 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/pbi-agent
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@105bf9783eed9d43517cc267a11c0ba73361aa92 -
Trigger Event:
push
-
Statement type:
File details
Details for the file codetool_shell-0.1.2-py3-none-manylinux2014_aarch64.whl.
File metadata
- Download URL: codetool_shell-0.1.2-py3-none-manylinux2014_aarch64.whl
- Upload date:
- Size: 792.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa2b11aee77dcac1a8764a68daea92a5e4594412895abcc7b5fc7e856ba8392e
|
|
| MD5 |
4f32490df1aca9453da1d5bafb32cb4a
|
|
| BLAKE2b-256 |
5bbc19d82a3b206afb3acc626c3e1f430171bf7a1a00404db3efca1768470896
|
Provenance
The following attestation bundles were made for codetool_shell-0.1.2-py3-none-manylinux2014_aarch64.whl:
Publisher:
release.yml on pbi-agent/codetool-shell
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codetool_shell-0.1.2-py3-none-manylinux2014_aarch64.whl -
Subject digest:
aa2b11aee77dcac1a8764a68daea92a5e4594412895abcc7b5fc7e856ba8392e - Sigstore transparency entry: 1903190079
- Sigstore integration time:
-
Permalink:
pbi-agent/codetool-shell@105bf9783eed9d43517cc267a11c0ba73361aa92 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/pbi-agent
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@105bf9783eed9d43517cc267a11c0ba73361aa92 -
Trigger Event:
push
-
Statement type:
File details
Details for the file codetool_shell-0.1.2-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: codetool_shell-0.1.2-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 754.6 kB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b752b4cc55b20dd1fe39dc10e2befcbc7736f6fbfcc86679bc786a06d68bad4
|
|
| MD5 |
5f7aaa846d68860226669096e2ea43b7
|
|
| BLAKE2b-256 |
dc7f31b7e68463d50372235f4d8ffe94e7ff4bac1d1a59cc56c9467d32842443
|
Provenance
The following attestation bundles were made for codetool_shell-0.1.2-py3-none-macosx_11_0_arm64.whl:
Publisher:
release.yml on pbi-agent/codetool-shell
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codetool_shell-0.1.2-py3-none-macosx_11_0_arm64.whl -
Subject digest:
7b752b4cc55b20dd1fe39dc10e2befcbc7736f6fbfcc86679bc786a06d68bad4 - Sigstore transparency entry: 1903190396
- Sigstore integration time:
-
Permalink:
pbi-agent/codetool-shell@105bf9783eed9d43517cc267a11c0ba73361aa92 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/pbi-agent
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@105bf9783eed9d43517cc267a11c0ba73361aa92 -
Trigger Event:
push
-
Statement type:
File details
Details for the file codetool_shell-0.1.2-py3-none-macosx_10_12_x86_64.whl.
File metadata
- Download URL: codetool_shell-0.1.2-py3-none-macosx_10_12_x86_64.whl
- Upload date:
- Size: 784.4 kB
- Tags: Python 3, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5fa531894d8e8eeaf3c435440ba85774b7ad539195490dd44ae5baba0810a57d
|
|
| MD5 |
5bb5d380ce47d587a3ed1b1badb4be85
|
|
| BLAKE2b-256 |
fe326cbe50c5c9b74a4ea50c4c5d4d27040f18dcf9c8a47f8e3aa967cab1e1e9
|
Provenance
The following attestation bundles were made for codetool_shell-0.1.2-py3-none-macosx_10_12_x86_64.whl:
Publisher:
release.yml on pbi-agent/codetool-shell
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codetool_shell-0.1.2-py3-none-macosx_10_12_x86_64.whl -
Subject digest:
5fa531894d8e8eeaf3c435440ba85774b7ad539195490dd44ae5baba0810a57d - Sigstore transparency entry: 1903190573
- Sigstore integration time:
-
Permalink:
pbi-agent/codetool-shell@105bf9783eed9d43517cc267a11c0ba73361aa92 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/pbi-agent
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@105bf9783eed9d43517cc267a11c0ba73361aa92 -
Trigger Event:
push
-
Statement type: