Skip to main content

Module patterns

Module patterns 

Source
Expand description

Shell-output compression patterns.

The patterns themselves live in the lean-ctx-patterns crate and are re-exported here unchanged. This facade adds what needs the engine: the protected-command policy gate, the leading-cd unwrap (shell segmenting), the user filter rules and the configured curl passthrough URLs.

Modules§

alembic
Alembic (SQLAlchemy migrations) output compression.
ansi
ANSI escape handling shared by the patterns and the engine compressor.
ansible
argocd
Argo CD (argocd app get/sync/list) output compression.
artisan
aws
bazel
buf
buf (protobuf tooling) output compression.
bun
cargo
clang
cmake
composer
cosign
Cosign (sigstore) output compression.
curl
dbt
dbt (data build tool) run/test/build output compression.
deno
deploy
Shared compressor for edge/PaaS deploy commands (vercel, fly, wrangler, skaffold, supabase).
deps_cmd
docker
dotnet
emspace
emspace CLI output.
env_filter
eslint
fd
find
flutter
flyway
Flyway (database migrations) output compression.
gem
RubyGems (gem) output compression.
gh
git
glab
golang
grep
grype
Grype vulnerability scanner output compression.
helm
jj
Jujutsu (jj) output compression.
json_crush
Deterministic JSON crusher — single source of truth for structural JSON compaction (#934, Headroom “Smart Crusher” port, GitLab #935).
json_schema
just
kubectl
linkerd
linkerd (linkerd check) output compression.
log_dedup
lossless_collapse
Strictly lossless repeat collapse for the governor’s R2 rule (governor design v1 §2 R2).
ls
make
maven
mise
mise (dev tool version manager) output compression.
mix
mlflow
MLflow CLI output compression.
mypy
mysql
next_build
ninja
npm
ollama
Ollama CLI output compression.
php
pip
playwright
pnpm
poetry
prettier
prisma
psql
pulumi
Pulumi (pulumi up/preview/destroy) output compression.
pytest
ruby
ruff
safety_needles
semgrep
Semgrep output compression.
spark
Apache Spark (spark-submit) log compression.
swift
swiftlint
SwiftLint output compression.
syft
Syft SBOM output compression.
sysinfo
systemd
template_collapse
Template collapse for the governor’s R4 rule.
terraform
test
tokens
tool_output
tool_output classification of shell commands (pz21 §1.8, Q6 a).
trivy
Trivy vulnerability scanner output compression.
typescript
wget
zig

Structs§

NoEnv
The neutral PatternEnv: no passthrough URLs.

Constants§

PATTERN_ENGINE_VERSION
Pattern engine version. Bump when output format changes to maintain shell-output determinism guarantees. Consumers (proofs, benchmarks) can embed this version to detect pattern-breaking updates.

Traits§

PatternEnv
Engine-supplied facts a pattern may need. The engine implements this from its configuration. NoEnv is the neutral environment for callers without one (tests, tools that run outside an engine).

Functions§

compress_clean
The policy-free part of the engine’s compress_output: everything after the protected-command gate, the leading-cd unwrap, ANSI stripping and the user filter rules, which the engine applies first. clean_output is the ANSI-stripped output, output the raw one every result is measured against.
compress_output
Compress output of command with its pattern, or None when no pattern applies or none makes it shorter. Protected commands are never compressed.
elision_marker
How an elided block announces itself (GH #1679).
has_vcs_owner
True for version-control commands whose output is authoritative under their own compressor and must not be reinterpreted by the generic log/test fallbacks (commit history is not application log output). emspace is owned the same way: its page bodies are page edit anchors and must stay exact.
inflates_tokens
True when compressed carries more tokens than the raw original — i.e. the transform inflated rather than compressed. Compared against the raw (pre-ANSI-strip) output so the guard matches the public compress_output invariant exactly: the returned text never tokenizes larger than its input.
output_class
The class the output of command is admitted with (pz21 §1.8): an outside origin for a command whose content comes from outside the repository (tool_output::classify), else the project’s own output.
pattern_count
Ordered prefix → compressor dispatch table (#660 CC reduction): first matching entry wins, mirroring the previous if c.starts_with(..) { return ...; } cascade exactly — including that a matched entry’s None is final, never falls through to a later entry. Registering a new CLI tool is now a one-line addition here instead of a new branch in try_specific_pattern. Number of registered shell-output patterns, for the docs drift check (#1896).
shorter_only
Some(compressed) only when it carries fewer tokens than original (ties broken by length), compared on whitespace-normalized text.
try_specific_pattern
Route cmd to its dedicated compressor, with the engine’s configuration.
try_specific_pattern_with
Route cmd to its dedicated compressor: the first matching entry of the dispatch table wins, and a matched entry’s None is final.