返回 CodeWhale
types.rs
1 //! Prototype boundary values used by the command capability shapes.
2 //!
3 //! These types deliberately do not replace the current TUI-owned production
4 //! types in FEAT-014. During the in-place adoption stage, thin TUI adapters
5 //! convert between existing application values and these boundary values.
6
7 /// Stable provider identity at the command boundary.
8 #[derive(Debug, Clone, PartialEq, Eq)]
9 pub struct CommandProviderId(pub String);
10
11 // Slice 4 removed `CommandReasoningEffort`: it was a verbatim 9-variant copy of
12 // `codewhale_tui::reasoning_preference::ReasoningEffort` with no independent
13 // behavior and no consumer, so it had no place on the command boundary.
14
15 /// Application mode visible to commands.
16 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
17 pub enum CommandMode {
18 Agent,
19 Plan,
20 }
21
22 impl CommandMode {
23 /// Parse a `/mode` argument, mirroring the config layer's `AppMode::parse`.
24 #[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 _ => None,
31 }
32 }
33
34 #[must_use]
35 pub fn is_retired_operate_alias(value: &str) -> bool {
36 matches!(
37 value.trim().to_ascii_lowercase().as_str(),
38 "operate" | "operation" | "ops" | "3"
39 )
40 }
41
42 /// Legacy bypass spellings (`yolo`, `4`, `bypass`, …) that carry full access.
43 #[must_use]
44 pub fn is_legacy_bypass_alias(value: &str) -> bool {
45 matches!(
46 value.trim().to_ascii_lowercase().as_str(),
47 "yolo" | "4" | "bypass" | "bypass-permissions" | "bypasspermissions"
48 )
49 }
50
51 /// Short English UI label for the mode.
52 #[must_use]
53 pub fn display_name(self) -> &'static str {
54 match self {
55 Self::Agent => "Work",
56 Self::Plan => "Plan",
57 }
58 }
59 }
60
61 /// Tool-approval posture visible to commands.
62 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
63 pub enum CommandApprovalMode {
64 Auto,
65 Bypass,
66 #[default]
67 Suggest,
68 AcceptEdits,
69 Never,
70 }
71
72 /// Cost currency used by command-facing accounting operations.
73 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
74 pub enum CommandCurrency {
75 Usd,
76 Cny,
77 }
78
79 /// Workbar placement, mirroring the TUI `WorkSurfacePlacement`.
80 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
81 pub enum CommandWorkSurfacePlacement {
82 Bottom,
83 Top,
84 Left,
85 Right,
86 Off,
87 }
88
89 impl CommandWorkSurfacePlacement {
90 /// Config-token spelling used by the `/workbar` status line and persistence.
91 #[must_use]
92 pub const fn as_setting(self) -> &'static str {
93 match self {
94 Self::Bottom => "bottom",
95 Self::Top => "top",
96 Self::Left => "left",
97 Self::Right => "right",
98 Self::Off => "off",
99 }
100 }
101 }
102
103 /// Workbar panel, mirroring the TUI `RailPanel`.
104 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
105 pub enum CommandRailPanel {
106 Agents,
107 Tasks,
108 Background,
109 Terminal,
110 Files,
111 Notepad,
112 Context,
113 Git,
114 Price,
115 }
116
116 lines RUST