1use std::str::FromStr;
2
3use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
6#[serde(rename_all = "snake_case")]
7pub enum AiProvider {
8 Codex,
9 Claude,
10 Opencode,
11}
12
13impl AiProvider {
14 pub fn as_str(self) -> &'static str {
15 match self {
16 Self::Codex => "codex",
17 Self::Claude => "claude",
18 Self::Opencode => "opencode",
19 }
20 }
21}
22
23impl FromStr for AiProvider {
24 type Err = String;
25
26 fn from_str(input: &str) -> Result<Self, Self::Err> {
27 match input {
28 "codex" => Ok(Self::Codex),
29 "claude" => Ok(Self::Claude),
30 "opencode" => Ok(Self::Opencode),
31 _ => Err(format!("invalid ai provider: {input}")),
32 }
33 }
34}
35
36#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
37#[serde(rename_all = "snake_case")]
38pub enum AiSessionMode {
39 Reply,
40 Refactor,
41}
42
43impl AiSessionMode {
44 pub fn as_str(self) -> &'static str {
45 match self {
46 Self::Reply => "reply",
47 Self::Refactor => "refactor",
48 }
49 }
50}
51
52impl FromStr for AiSessionMode {
53 type Err = String;
54
55 fn from_str(input: &str) -> Result<Self, Self::Err> {
56 match input {
57 "reply" => Ok(Self::Reply),
58 "refactor" => Ok(Self::Refactor),
59 _ => Err(format!("invalid ai session mode: {input}")),
60 }
61 }
62}