codewhale_command_contract/
types.rs1#[derive(Debug, Clone, PartialEq, Eq)]
9pub struct CommandProviderId(pub String);
10
11#[derive(Debug, Clone, Copy, PartialEq, Eq)]
17pub enum CommandMode {
18 Agent,
19 Plan,
20}
21
22impl CommandMode {
23 #[must_use]
25 pub fn parse(value: &str) -> Option<Self> {
26 match value.trim().to_ascii_lowercase().as_str() {
27 "agent" | "act" | "work" | "auto" | "1" => Some(Self::Agent),
28 "plan" | "2" => Some(Self::Plan),
29 other if Self::is_retired_operate_alias(other) => Some(Self::Agent),
30 other if Self::is_legacy_bypass_alias(other) => Some(Self::Agent),
31 _ => None,
32 }
33 }
34
35 #[must_use]
36 pub fn is_retired_operate_alias(value: &str) -> bool {
37 matches!(
38 value.trim().to_ascii_lowercase().as_str(),
39 "operate" | "operation" | "ops" | "3"
40 )
41 }
42
43 #[must_use]
45 pub fn is_legacy_bypass_alias(value: &str) -> bool {
46 matches!(
47 value.trim().to_ascii_lowercase().as_str(),
48 "yolo" | "4" | "bypass" | "bypass-permissions" | "bypasspermissions"
49 )
50 }
51
52 #[must_use]
54 pub fn display_name(self) -> &'static str {
55 match self {
56 Self::Agent => "Work",
57 Self::Plan => "Plan",
58 }
59 }
60}
61
62#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
64pub enum CommandApprovalMode {
65 Auto,
66 Bypass,
67 #[default]
68 Suggest,
69 AcceptEdits,
70 Never,
71}
72
73#[derive(Debug, Clone, Copy, PartialEq, Eq)]
75pub enum CommandCurrency {
76 Usd,
77 Cny,
78}
79
80#[derive(Debug, Clone, Copy, PartialEq, Eq)]
83pub enum CommandScreenMode {
84 Fullscreen,
86 Inline,
88}
89
90#[derive(Debug, Clone, Copy, PartialEq, Eq)]
92pub enum CommandWorkSurfacePlacement {
93 Bottom,
94 Top,
95 Left,
96 Right,
97 Off,
98}
99
100impl CommandWorkSurfacePlacement {
101 #[must_use]
103 pub const fn as_setting(self) -> &'static str {
104 match self {
105 Self::Bottom => "bottom",
106 Self::Top => "top",
107 Self::Left => "left",
108 Self::Right => "right",
109 Self::Off => "off",
110 }
111 }
112}
113
114#[derive(Debug, Clone, Copy, PartialEq, Eq)]
116pub enum CommandRailPanel {
117 Agents,
118 Tasks,
119 Background,
120 Terminal,
121 Files,
122 Notepad,
123 Context,
124 Git,
125 Price,
126}