agcli
agcli is a no-bloat Rust crate for building agent-native CLIs.
It is built around the design in design.md:
- JSON-only envelopes
- HATEOAS
next_actions - self-documenting root command tree
- context-safe output truncation
- typed NDJSON streaming with terminal
result/error
Why terminal envelopes and truncation pointers matter
- Terminal
result/errorenvelopes give agents a deterministic finish state, so they can branch on structured outcomes instead of fragile text parsing. - Structured
errorenvelopes support reliable retries, escalation, and fallback actions, whileresultenvelopes make successful completion explicit and machine-verifiable. - Truncation with file pointers lets CLIs cap large outputs safely while preserving continuity: agents can follow the pointer to full logs or artifacts without overflowing context windows.
- This improves reliability and debuggability for long-running automation while reducing token pressure in agent loops.
Install
[]
= "0.6.0"
= "1"
Quick start
use ;
use json;
Performance
agcli targets macOS and Linux only. The crate ships with optimized release/bench profiles and an optional jemalloc allocator. To maximize runtime performance in a downstream binary:
Recommended Cargo.toml
[]
= { = "0.6.0", = ["jemalloc"] }
[]
= 3
= "thin"
= 1
jemalloc global allocator
In your binary's main.rs:
static GLOBAL: Jemalloc = Jemalloc;
Build-machine-specific codegen
RUSTFLAGS="-C target-cpu=native"
Do not commit this into the repo — it breaks cross-compilation portability.
PGO (Profile-Guided Optimization)
Wokhei-style example
See examples/ops.rs for a full example with:
- command tree responses
- contextual next actions
- log truncation file pointers