acp_cli/cli/mod.rs
1pub mod init;
2pub mod prompt;
3pub mod prompt_source;
4pub mod session;
5
6use clap::{Parser, Subcommand};
7
8#[derive(Parser)]
9#[command(
10 name = "acp-cli",
11 version,
12 about = "Headless CLI client for the Agent Client Protocol"
13)]
14pub struct Cli {
15 /// Agent name (e.g. "claude", "codex") or raw command
16 pub agent: Option<String>,
17
18 /// Prompt text (implicit prompt mode)
19 pub prompt: Vec<String>,
20
21 #[command(subcommand)]
22 pub command: Option<Commands>,
23
24 /// Session name or ID to resume
25 #[arg(short = 's', long)]
26 pub session: Option<String>,
27
28 /// Automatically approve all tool calls
29 #[arg(long)]
30 pub approve_all: bool,
31
32 /// Automatically approve read-only tool calls
33 #[arg(long)]
34 pub approve_reads: bool,
35
36 /// Deny all tool calls
37 #[arg(long)]
38 pub deny_all: bool,
39
40 /// Working directory for the agent
41 #[arg(long)]
42 pub cwd: Option<String>,
43
44 /// Output format (text, json, quiet)
45 #[arg(long, default_value = "text")]
46 pub format: String,
47
48 /// Timeout in seconds
49 #[arg(long)]
50 pub timeout: Option<u64>,
51
52 /// Override the agent command
53 #[arg(long = "agent-override")]
54 pub agent_override: Option<String>,
55
56 /// Read prompt from a file (use "-" for stdin)
57 #[arg(short = 'f', long = "file")]
58 pub file: Option<String>,
59
60 /// Enable verbose output
61 #[arg(long)]
62 pub verbose: bool,
63
64 /// Fire-and-forget: queue the prompt and return immediately without waiting
65 /// for the result. Requires an active session (queue owner) to be running.
66 #[arg(long)]
67 pub no_wait: bool,
68
69 /// Retry transient prompt failures up to N times with exponential backoff.
70 /// Only connection/bridge errors are retried; semantic errors fail immediately.
71 #[arg(long, default_value = "0")]
72 pub prompt_retries: u32,
73
74 /// Suppress file-read body content in output. Tool name and path are still
75 /// shown; only the returned bytes are replaced with `[read suppressed — N bytes]`.
76 #[arg(long)]
77 pub suppress_reads: bool,
78}
79
80#[derive(Subcommand)]
81pub enum Commands {
82 /// Execute a prompt non-interactively
83 Exec {
84 /// Prompt text
85 prompt: Vec<String>,
86 },
87 /// Manage sessions
88 Sessions {
89 #[command(subcommand)]
90 action: SessionAction,
91 },
92 /// Interactive setup — detect auth token, write config
93 Init,
94 /// Manage configuration
95 Config {
96 #[command(subcommand)]
97 action: ConfigAction,
98 },
99 /// Cancel a running prompt by sending SIGTERM
100 Cancel,
101 /// Show status of the current session (running/idle/closed)
102 Status,
103 /// Set the session mode (e.g. "code", "plan", "chat")
104 SetMode {
105 /// Mode identifier to set
106 mode: String,
107 },
108 /// Set a session configuration option
109 Set {
110 /// Configuration key
111 key: String,
112 /// Configuration value
113 value: String,
114 },
115}
116
117#[derive(Subcommand)]
118pub enum SessionAction {
119 /// Create a new session
120 New {
121 /// Optional session name
122 #[arg(long)]
123 name: Option<String>,
124 },
125 /// List existing sessions
126 List,
127 /// Close a session
128 Close {
129 /// Session name
130 #[arg(short = 's', long)]
131 name: Option<String>,
132 },
133 /// Show session details
134 Show {
135 /// Session name
136 #[arg(short = 's', long)]
137 name: Option<String>,
138 },
139 /// Show conversation history
140 History {
141 /// Session name
142 #[arg(short = 's', long)]
143 name: Option<String>,
144 },
145}
146
147#[derive(Subcommand)]
148pub enum ConfigAction {
149 /// Show current configuration
150 Show,
151}