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