Merge agent-cli crate into agent as cli module

The agent-cli binary was a thin wrapper over the agent library with
nothing else depending on it. Moving it into the agent crate as a
`pub mod cli` with a `[[bin]]` entry reduces workspace complexity
and follows the attractor crate pattern.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Bryan Helmkamp 2026-02-23 11:14:25 -05:00
parent eaf934f355
commit df8502d83b
7 changed files with 29 additions and 52 deletions

16
Cargo.lock generated
View file

@ -6,8 +6,11 @@ version = 4
name = "agent"
version = "0.1.0"
dependencies = [
"anyhow",
"async-trait",
"chrono",
"clap",
"dotenvy",
"futures",
"glob",
"jsonschema",
@ -20,19 +23,6 @@ dependencies = [
"uuid",
]
[[package]]
name = "agent-cli"
version = "0.1.0"
dependencies = [
"agent",
"anyhow",
"async-trait",
"clap",
"llm",
"serde_json",
"tokio",
]
[[package]]
name = "ahash"
version = "0.8.12"

View file

@ -1,25 +0,0 @@
[package]
name = "agent-cli"
edition.workspace = true
version.workspace = true
license.workspace = true
description = "CLI for the agent agentic loop"
repository = "https://github.com/brynary/attractor-rust"
keywords = ["llm", "ai", "agent", "cli"]
categories = ["command-line-utilities"]
[[bin]]
name = "agent"
path = "src/main.rs"
[dependencies]
agent = { path = "../agent" }
llm = { path = "../llm" }
clap.workspace = true
tokio.workspace = true
anyhow.workspace = true
serde_json.workspace = true
async-trait.workspace = true
[lints]
workspace = true

View file

@ -12,7 +12,14 @@ categories = ["api-bindings"]
[lib]
doctest = false
[[bin]]
name = "agent"
path = "src/main.rs"
[dependencies]
clap.workspace = true
anyhow.workspace = true
dotenvy.workspace = true
llm = { path = "../llm" }
thiserror.workspace = true
serde.workspace = true

View file

@ -1,4 +1,4 @@
use agent::{
use crate::{
AnthropicProfile, EventData, EventKind, GeminiProfile, LocalExecutionEnvironment, OpenAiProfile,
ProviderProfile, Session, SessionConfig, ToolApprovalFn, Turn,
};
@ -6,7 +6,6 @@ use clap::{Parser, ValueEnum};
use llm::client::Client;
use std::io::{IsTerminal, Write};
use std::path::PathBuf;
use std::process::ExitCode;
use std::sync::atomic::Ordering;
use std::sync::{Arc, Mutex};
@ -36,6 +35,10 @@ struct Cli {
/// Print LLM request/response debug info to stderr
#[arg(long)]
debug: bool,
/// Print full LLM request/response JSON to stderr
#[arg(long)]
verbose: bool,
}
#[derive(Clone, Copy, Debug, ValueEnum)]
@ -201,7 +204,7 @@ impl llm::middleware::Middleware for DebugMiddleware {
}
}
async fn run() -> anyhow::Result<()> {
pub async fn run() -> anyhow::Result<()> {
let _ = dotenvy::dotenv();
let cli = Cli::parse();
@ -279,17 +282,6 @@ async fn run() -> anyhow::Result<()> {
Ok(())
}
#[tokio::main]
async fn main() -> ExitCode {
match run().await {
Ok(()) => ExitCode::SUCCESS,
Err(e) => {
eprintln!("[error] {e}");
ExitCode::FAILURE
}
}
}
#[cfg(test)]
mod tests {
use super::*;

View file

@ -1,3 +1,4 @@
pub mod cli;
pub mod config;
pub mod error;
pub mod event;

12
crates/agent/src/main.rs Normal file
View file

@ -0,0 +1,12 @@
use std::process::ExitCode;
#[tokio::main]
async fn main() -> ExitCode {
match agent::cli::run().await {
Ok(()) => ExitCode::SUCCESS,
Err(e) => {
eprintln!("[error] {e}");
ExitCode::FAILURE
}
}
}