cap_rs/lib.rs
1//! # cap-rs — Rust reference implementation of the CAP (CLI Agent Protocol).
2//!
3//! See <https://cap-protocol.org> for the protocol specification.
4//!
5//! ## Layout
6//!
7//! - [`core`] — protocol types (events, frames, capabilities, manifest).
8//! Always available, no IO dependencies.
9//! - [`driver`] — backends that drive an actual CLI agent.
10//! Each backend is gated behind a feature flag.
11//!
12//! ## Quick start
13//!
14//! ```toml
15//! [dependencies]
16//! cap-rs = { version = "0.1", features = ["stream-json"] }
17//! ```
18//!
19//! ```no_run
20//! # #[cfg(feature = "stream-json")]
21//! # async fn run() -> anyhow::Result<()> {
22//! use cap_rs::driver::stream_json::ClaudeCodeDriver;
23//! use cap_rs::core::{ClientFrame, Content};
24//!
25//! let mut driver = ClaudeCodeDriver::spawn(std::env::current_dir()?).await?;
26//! driver.send(ClientFrame::Prompt {
27//! content: vec![Content::Text("What is 2 + 2?".into())],
28//! }).await?;
29//!
30//! while let Some(event) = driver.next_event().await {
31//! println!("{event:?}");
32//! }
33//! # Ok(())
34//! # }
35//! ```
36
37#![doc(html_root_url = "https://docs.rs/cap-rs/0.0.0")]
38#![warn(missing_debug_implementations)]
39
40pub mod core;
41pub mod driver;
42
43/// Crate name (build-time constant).
44pub const CRATE_NAME: &str = env!("CARGO_PKG_NAME");
45
46/// Crate version (build-time constant).
47pub const CRATE_VERSION: &str = env!("CARGO_PKG_VERSION");
48
49/// CAP protocol version targeted by this crate.
50pub const PROTOCOL_VERSION: &str = "cap-protocol/v1";