Skip to content

Filter `cargo check` commands into optimized format, reducing LLM token count during LLM agent coding sessions.

License

Notifications You must be signed in to change notification settings

permissionlessweb/cargo-chec

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cargo Chec Workspace

A family of cargo subcommands that wrap standard Rust tooling, filter verbose output, and return compact JSON. Built for minimizing character/token count during agentic LLM sessions.

Tools

Crate Wraps Install Docs
cargo-chec cargo check cargo install cargo-chec README
cargo-tes cargo test cargo install cargo-tes README
cargo-carpulin cargo llvm-cov / cargo tarpaulin cargo install cargo-carpulin README

Installation

From crates.io (recommended for users):

cargo install cargo-chec cargo-tes cargo-carpulin

From source (for development):

# Clone the repository
git clone https://github.com/yourusername/rust-log-filter
cd rust-log-filter

# Install all tools to ~/.cargo/bin using just
just install

# Or build and install manually
cargo build --release
cp target/release/cargo-{chec,tes,carpulin} ~/.cargo/bin/

Usage

cargo-chec

Filters cargo check errors and warnings into a JSON array of strings.

cargo chec
# ["Error (severity 5) from rustc in src/main.rs at line 10:5-15: cannot find value `x`"]

cargo-tes

Filters cargo test failures into a JSON array of strings.

cargo tes
# ["Test failed: tests::my_test (exec_time: 0.001s) - assertion failed", "Suite failed: passed 5, failed 1 (exec_time: 0.003s)"]

cargo-carpulin

Runs coverage tools and outputs structured JSON with per-file uncovered line ranges.

cargo carpulin --tool llvm-cov -- -p my-crate
{
  "summary": {
    "lines": { "count": 55, "covered": 30, "percent": 54.5 },
    "functions": { "count": 10, "covered": 8, "percent": 80.0 }
  },
  "files": [
    {
      "file": "src/lib.rs",
      "coverage": { "lines": { "count": 55, "covered": 30, "percent": 54.5 } },
      "uncovered_lines": ["16-19", "28-30", "35-46", "49-54"]
    }
  ]
}

Workspace Layout

.
├── wrappers/
│   ├── chec/          # cargo-chec   — cargo check filter
│   ├── tes/           # cargo-tes    — cargo test filter
│   └── carpulin/      # cargo-carpulin — coverage report filter
├── tools/
│   ├── coverage-test/ # Fixture crate with intentional coverage gaps
│   └── demo-outputs/  # Demo output crate for cargo-tes
├── scripts/
│   └── benchmark.sh           # Unified benchmark for all tools
├── fam/               # Project images
├── Justfile           # Release task runner
└── Cargo.toml         # Workspace root

Benchmarks

Learn about benchmarking this workspace.

Run the unified benchmark:

just benchmark
# or
./scripts/benchmark.sh

This will benchmark all three tools (cargo-chec, cargo-tes, cargo-carpulin) and update BENCHMARKS.md with fresh results.

Development

# Build all crates
cargo build

# Build and install to ~/.cargo/bin
just install

# Run all tests
just test
# or
cargo test

# Lint
just lint
# or
cargo clippy --workspace

# Format
cargo fmt --all

# Run all checks (test + format + lint)
just check

Releasing

Use the provided Justfile for release tasks:

# Run all checks
just check

# Dry-run publish
just dry-run

# Full release
just release

Requires just (install via cargo install just).

Contributing

Open issues/PRs on GitHub. Built for the Rust ecosystem.


For AI Agents: Workspace Specifications

Workspace Members

Member Type Path
cargo-chec Binary (wrapper) wrappers/chec/src/main.rs
cargo-tes Binary (wrapper) wrappers/tes/src/main.rs
cargo-carpulin Binary (wrapper) wrappers/carpulin/src/main.rs
demo-outputs Library (fixture) tools/demo-outputs/src/lib.rs
coverage-test-crate Library (fixture) tools/coverage-test/src/lib.rs

Shared Patterns

All wrapper crates follow the same structure:

  • Single-file binary in src/main.rs
  • Dependencies: clap 4.0 (derive) + serde_json 1.0
  • Clap subcommand enum for cargo <name> invocation
  • --input FILE or - for stdin to parse existing output
  • Trailing cargo_args passed through to the underlying tool
  • Piped stdout/stderr with stderr streaming thread

Build Commands

  • Build all: cargo build
  • Build one: cargo build -p cargo-chec
  • Test all: cargo test
  • Test one: cargo test -p cargo-carpulin
  • Benchmark: ./scripts/benchmark_carpulin.sh

About

Filter `cargo check` commands into optimized format, reducing LLM token count during LLM agent coding sessions.

Resources

License

Stars

Watchers

Forks

Packages

No packages published