Skip to main content

artifactize_provider/
agents.rs

1//! The agent catalog both stacks read: every coding-agent CLI artifactize knows, how a person
2//! signs in to it, how its Chat runs over ACP and how its Review runs, and the API providers
3//! artifactize calls itself. It is static data: nothing here starts a process.
4
5use crate::names::HttpProvider;
6
7/// A coding-agent CLI. A person sets it up by signing in to the CLI itself; what it can do
8/// (Chat, Review) follows from this entry, never from a switch.
9#[derive(Debug, Clone, Copy, PartialEq, Eq)]
10pub struct Agent {
11    /// The catalog ID: a Chat target's agent and, for an agent that can review, an eval's
12    /// `backend`.
13    pub id: &'static str,
14    pub name: &'static str,
15    /// The CLI the person installs and signs in to.
16    pub program: &'static str,
17    /// Who keeps the login: the CLI itself, never artifactize.
18    pub kept_by: &'static str,
19    /// Where the CLI's own installation instructions are.
20    pub install_url: &'static str,
21    pub sign_in: SignIn,
22    pub chat: Chat,
23    pub review: Review,
24}
25
26/// How a person signs in to an agent's CLI.
27#[derive(Debug, Clone, Copy, PartialEq, Eq)]
28pub enum SignIn {
29    /// The CLI has commands of its own for each step: the arguments after its program.
30    Commands {
31        status: &'static [&'static str],
32        login: &'static [&'static str],
33        logout: &'static [&'static str],
34    },
35    /// The CLI signs in through its ACP mode, with these arguments after its program.
36    Acp { login: &'static [&'static str] },
37    /// The CLI signs in only in its own interactive terminal: the person runs this there.
38    Terminal { command: &'static str },
39}
40
41/// How an agent's Chat runs over ACP.
42#[derive(Debug, Clone, Copy, PartialEq, Eq)]
43pub enum Chat {
44    /// The CLI speaks ACP itself, with these arguments after its program.
45    Native { args: &'static [&'static str] },
46    /// A separate adapter program speaks ACP for the CLI; `registry` is its official ACP
47    /// Registry ID, from which a pinned version is installed when it is not on the `PATH`.
48    Adapter {
49        program: &'static str,
50        registry: &'static str,
51    },
52}
53
54/// How an agent's Review runs.
55#[derive(Debug, Clone, Copy, PartialEq, Eq)]
56pub enum Review {
57    /// An artifactize reviewer harness runs it, under the CLI's own sign-in.
58    Harness(Harness),
59    /// It cannot review; the reason is shown beside *Chat only*.
60    ChatOnly { reason: &'static str },
61}
62
63/// The reviewer harnesses artifactize has.
64#[derive(Debug, Clone, Copy, PartialEq, Eq)]
65pub enum Harness {
66    /// Claude Code in stream-json mode, isolated, under Claude Code's own sign-in.
67    ClaudeCode,
68    /// The provider's turn driver over the Codex API, with the Codex CLI's own sign-in.
69    Codex,
70}
71
72/// The built-in agents, in the order Settings lists them.
73pub const AGENTS: &[Agent] = &[
74    Agent {
75        id: "claude",
76        name: "Claude",
77        program: "claude",
78        kept_by: "Claude Code",
79        install_url: "https://docs.anthropic.com/en/docs/claude-code/setup",
80        sign_in: SignIn::Commands {
81            status: &["auth", "status", "--json"],
82            login: &["auth", "login"],
83            logout: &["auth", "logout"],
84        },
85        chat: Chat::Adapter {
86            program: "claude-agent-acp",
87            registry: "claude-acp",
88        },
89        review: Review::Harness(Harness::ClaudeCode),
90    },
91    Agent {
92        id: "codex",
93        name: "Codex",
94        program: "codex",
95        kept_by: "Codex CLI",
96        install_url: "https://developers.openai.com/codex/cli",
97        sign_in: SignIn::Commands {
98            status: &["login", "status"],
99            login: &["login"],
100            logout: &["logout"],
101        },
102        chat: Chat::Adapter {
103            program: "codex-acp",
104            registry: "codex-acp",
105        },
106        review: Review::Harness(Harness::Codex),
107    },
108    Agent {
109        id: "antigravity",
110        name: "Antigravity",
111        program: "agy",
112        kept_by: "Antigravity CLI",
113        install_url: "https://antigravity.google/",
114        sign_in: SignIn::Acp {
115            login: &["acp", "--login"],
116        },
117        chat: Chat::Native { args: &["acp"] },
118        review: Review::ChatOnly {
119            reason: "Antigravity allows no third-party harness.",
120        },
121    },
122    Agent {
123        id: "opencode",
124        name: "OpenCode",
125        program: "opencode",
126        kept_by: "OpenCode",
127        install_url: "https://opencode.ai/docs/",
128        sign_in: SignIn::Terminal {
129            command: "opencode auth login",
130        },
131        chat: Chat::Native { args: &["acp"] },
132        review: Review::ChatOnly {
133            reason: "artifactize has no reviewer harness for OpenCode yet.",
134        },
135    },
136    Agent {
137        id: "copilot",
138        name: "Copilot",
139        program: "copilot",
140        kept_by: "GitHub Copilot CLI",
141        install_url: "https://docs.github.com/copilot/how-tos/set-up/install-copilot-cli",
142        sign_in: SignIn::Terminal {
143            command: "copilot, then /login",
144        },
145        chat: Chat::Native { args: &["--acp"] },
146        review: Review::ChatOnly {
147            reason: "artifactize has no reviewer harness for Copilot yet.",
148        },
149    },
150    Agent {
151        id: "cursor",
152        name: "Cursor",
153        program: "cursor-agent",
154        kept_by: "Cursor Agent",
155        install_url: "https://cursor.com/docs/cli/installation",
156        sign_in: SignIn::Commands {
157            status: &["status"],
158            login: &["login"],
159            logout: &["logout"],
160        },
161        chat: Chat::Native { args: &["acp"] },
162        review: Review::ChatOnly {
163            reason: "artifactize has no reviewer harness for Cursor yet.",
164        },
165    },
166    Agent {
167        id: "goose",
168        name: "Goose",
169        program: "goose",
170        kept_by: "Goose",
171        install_url: "https://block.github.io/goose/docs/getting-started/installation",
172        sign_in: SignIn::Terminal {
173            command: "goose configure",
174        },
175        chat: Chat::Native { args: &["acp"] },
176        review: Review::ChatOnly {
177            reason: "artifactize has no reviewer harness for Goose yet.",
178        },
179    },
180    Agent {
181        id: "pi",
182        name: "pi",
183        program: "pi",
184        kept_by: "pi",
185        install_url: "https://www.npmjs.com/package/@earendil-works/pi-coding-agent",
186        sign_in: SignIn::Terminal {
187            command: "pi, then /login",
188        },
189        chat: Chat::Adapter {
190            program: "pi-acp",
191            registry: "pi-acp",
192        },
193        review: Review::ChatOnly {
194            reason: "artifactize has no reviewer harness for pi yet.",
195        },
196    },
197];
198
199/// Earlier names of built-in agents, still accepted where a saved name or a declaration
200/// carries one: an eval's `backend = "claude-agent"` and Chat's retired ACP preset IDs.
201const FORMER_IDS: &[(&str, &str)] = &[
202    ("claude-agent", "claude"),
203    ("claude-acp", "claude"),
204    ("codex-acp", "codex"),
205];
206
207/// The built-in agent with this ID, or with an earlier name of it.
208pub fn agent(id: &str) -> Option<&'static Agent> {
209    let id = FORMER_IDS
210        .iter()
211        .find_map(|(former, current)| (*former == id).then_some(*current))
212        .unwrap_or(id);
213    AGENTS.iter().find(|agent| agent.id == id)
214}
215
216/// The built-in agent that reviews with this harness.
217pub fn reviewer(harness: Harness) -> &'static Agent {
218    AGENTS
219        .iter()
220        .find(|agent| agent.review == Review::Harness(harness))
221        .expect("every harness belongs to one built-in agent")
222}
223
224/// An API provider artifactize calls itself, for Chat and Review alike.
225#[derive(Debug, Clone, Copy, PartialEq, Eq)]
226pub struct ApiProvider {
227    pub provider: HttpProvider,
228    pub name: &'static str,
229}
230
231/// The built-in API providers, in the order Settings lists them. Codex is an agent, not an
232/// API provider: its Review uses the Codex CLI's sign-in and its Chat runs over ACP.
233pub const API_PROVIDERS: &[ApiProvider] = &[
234    ApiProvider {
235        provider: HttpProvider::Openai,
236        name: "OpenAI",
237    },
238    ApiProvider {
239        provider: HttpProvider::Anthropic,
240        name: "Anthropic",
241    },
242    ApiProvider {
243        provider: HttpProvider::Gemini,
244        name: "Gemini API",
245    },
246];
247
248#[cfg(test)]
249mod tests;