Skip to main content

lattice_ai/acp/
providers.rs

1//! Provider launch configs — the crate's extension point. Adding an agent is a
2//! new constructor here, not a new subsystem.
3
4/// How to launch one ACP agent as a stdio subprocess.
5#[derive(Debug, Clone, PartialEq, Eq)]
6pub struct ProviderConfig {
7    /// Executable to spawn.
8    pub command: String,
9    /// Arguments that put the agent into ACP-over-stdio mode.
10    pub args: Vec<String>,
11    /// Extra environment injected into the child.
12    pub env: Vec<(String, String)>,
13    /// Human-readable name (modeline / echoes).
14    pub display_name: &'static str,
15}
16
17impl ProviderConfig {
18    /// opencode's native ACP entry (exact args confirmed in Task 0's spike).
19    pub fn opencode() -> Self {
20        Self {
21            command: "opencode".to_string(),
22            args: vec!["acp".to_string()],
23            env: Vec::new(),
24            display_name: "opencode",
25        }
26    }
27}
28
29#[cfg(test)]
30mod tests {
31    use super::*;
32
33    #[test]
34    fn opencode_config_names_the_binary_and_display() {
35        let p = ProviderConfig::opencode();
36        assert_eq!(p.command, "opencode");
37        assert_eq!(p.display_name, "opencode");
38        assert!(!p.args.is_empty(), "must pass the ACP-mode flag");
39    }
40}