BlueGit

ict rusty-teams

Files

rusty-teams / crates / agents / src / profile.rs

profile.rs

profile.rs 3.1 KiB Download Raw
1use serde::{Deserialize, Serialize};
2
3const CLAUDE_COMMAND: &str =
4 "claude -p --output-format stream-json --verbose --session-id {session_id}";
5const COPILOT_COMMAND: &str = "copilot -p {prompt} --output-format json --session-id {session_id}";
6pub(crate) const LEGACY_CLAUDE_WSL_OPEN_SESSION: &str =
7 "wt.exe wsl.exe --cd {cwd} -e claude --resume {session_id}";
8pub(crate) const LEGACY_COPILOT_WSL_OPEN_SESSION: &str =
9 "wt.exe wsl.exe --cd {cwd} -e copilot --resume {session_id}";
10const CLAUDE_WSL_OPEN_SESSION: &str =
11 "wt.exe wsl.exe --cd {cwd} -e sh -lc \"exec claude --resume {session_id}\"";
12const COPILOT_WSL_OPEN_SESSION: &str =
13 "wt.exe wsl.exe --cd {cwd} -e sh -lc \"exec copilot --resume {session_id}\"";
14
15#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
16pub enum Environment {
17 #[default]
18 Host,
19 Wsl {
20 distro: Option<String>,
21 },
22}
23
24#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
25pub enum OutputFormat {
26 #[default]
27 ClaudeStreamJson,
28 CopilotJsonl,
29 Text,
30}
31
32#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
33#[serde(default)]
34pub struct AgentProfile {
35 pub id: String,
36 pub name: String,
37 pub environment: Environment,
38 pub command: String,
39 pub output: OutputFormat,
40 pub open_session_command: String,
41 pub mcp_config_flag: String,
42}
43
44impl AgentProfile {
45 pub(crate) fn migrate_open_session_command(&mut self) {
46 let replacement = match self.open_session_command.as_str() {
47 LEGACY_CLAUDE_WSL_OPEN_SESSION => CLAUDE_WSL_OPEN_SESSION,
48 LEGACY_COPILOT_WSL_OPEN_SESSION => COPILOT_WSL_OPEN_SESSION,
49 _ => return,
50 };
51 self.open_session_command = replacement.to_string();
52 }
53
54 pub fn claude_wsl() -> Self {
55 Self {
56 id: "claude".to_string(),
57 name: "Claude Code (WSL)".to_string(),
58 environment: Environment::Wsl { distro: None },
59 command: CLAUDE_COMMAND.to_string(),
60 output: OutputFormat::ClaudeStreamJson,
61 open_session_command: CLAUDE_WSL_OPEN_SESSION.to_string(),
62 mcp_config_flag: "--mcp-config".to_string(),
63 }
64 }
65
66 pub fn claude_host() -> Self {
67 Self {
68 id: "claude-host".to_string(),
69 name: "Claude Code".to_string(),
70 environment: Environment::Host,
71 command: CLAUDE_COMMAND.to_string(),
72 output: OutputFormat::ClaudeStreamJson,
73 open_session_command: "wt.exe -d {cwd} claude --resume {session_id}".to_string(),
74 mcp_config_flag: "--mcp-config".to_string(),
75 }
76 }
77
78 pub fn copilot_wsl() -> Self {
79 Self {
80 id: "copilot".to_string(),
81 name: "Copilot CLI (WSL)".to_string(),
82 environment: Environment::Wsl { distro: None },
83 command: COPILOT_COMMAND.to_string(),
84 output: OutputFormat::CopilotJsonl,
85 open_session_command: COPILOT_WSL_OPEN_SESSION.to_string(),
86 mcp_config_flag: "--additional-mcp-config".to_string(),
87 }
88 }
89}