返回 CodeWhale
navigation.rs
根目录 / crates / command-contract / src / navigation.rs
1 use std::path::PathBuf;
2
3 use crate::types::CommandMode;
4
5 #[derive(Debug, Clone, PartialEq, Eq)]
6 pub struct NavigationUserHelp {
7 pub name: String,
8 pub description: Option<String>,
9 pub usage: Option<String>,
10 pub aliases: Vec<String>,
11 }
12
13 #[derive(Debug, Clone, PartialEq, Eq)]
14 pub struct NavigationBuiltinHelp {
15 pub name: String,
16 pub usage: String,
17 pub description: String,
18 pub aliases: Vec<String>,
19 }
20
21 #[derive(Debug, Clone, PartialEq, Eq)]
22 pub struct NavigationHelpTopic {
23 pub user: Option<NavigationUserHelp>,
24 pub builtin: Option<NavigationBuiltinHelp>,
25 pub shadowed_names: Vec<String>,
26 }
27
28 #[derive(Debug, Clone, PartialEq, Eq)]
29 pub struct NavigationSkill {
30 pub name: String,
31 pub description: String,
32 }
33
34 #[derive(Debug, Clone, PartialEq, Eq)]
35 pub struct NavigationOverview {
36 pub model: String,
37 pub mode: CommandMode,
38 pub mode_label: String,
39 pub workspace: PathBuf,
40 pub history_count: usize,
41 pub total_tokens: u32,
42 pub queued_count: usize,
43 pub subagent_count: usize,
44 pub active_skill: Option<String>,
45 }
46
47 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
48 pub enum NavigationProviderKind {
49 Moonshot,
50 Other,
51 }
52
53 #[derive(Debug, Clone, PartialEq, Eq)]
54 pub struct NavigationProviderLinks {
55 pub id: String,
56 pub name: String,
57 pub credential_url: Option<String>,
58 pub docs_url: Option<String>,
59 pub guidance: String,
60 pub env_names: Vec<String>,
61 pub kind: NavigationProviderKind,
62 }
63
64 #[derive(Debug, Clone, PartialEq, Eq)]
65 pub struct NavigationLinks {
66 pub active_provider: String,
67 pub locale_tag: String,
68 pub providers: Vec<NavigationProviderLinks>,
69 pub kimi_route: String,
70 pub kimi_console: String,
71 }
72
73 #[derive(Debug, Clone, PartialEq, Eq)]
74 pub enum WorkspaceTarget {
75 Missing,
76 File,
77 NotDirectory,
78 Directory { canonical_or_candidate: PathBuf },
79 }
80
81 #[derive(Debug, Clone, PartialEq, Eq)]
82 pub enum AnchorWriteError {
83 Open(String),
84 Write(String),
85 }
86
87 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
88 pub enum SubagentRosterDisplay {
89 Modal,
90 Transcript,
91 }
92
93 pub trait CommandNavigationContext {
94 fn open_model_reference(&mut self);
95 fn prepare_subagent_roster(&mut self, display: SubagentRosterDisplay);
96 fn toggle_window_pin(&mut self);
97 fn help_topic(&self, topic: &str) -> NavigationHelpTopic;
98 fn cached_skills(&self) -> Vec<NavigationSkill>;
99 fn help_is_open(&self) -> bool;
100 fn open_help(&mut self);
101 fn home_is_blocked(&self) -> bool;
102 fn restore_home(&mut self);
103 fn overview(&self) -> NavigationOverview;
104 fn links(&self) -> NavigationLinks;
105 }
106
107 pub struct ResponseCopyDelivery {
108 pub requires_terminal_paste: bool,
109 pub recovery_path: Option<PathBuf>,
110 pub clipboard_result: Result<(), String>,
111 }
112
113 pub trait CommandResponseCopyContext {
114 fn copy_completed_response(&mut self) -> Option<ResponseCopyDelivery>;
115 fn show_copy_receipt(&mut self, message: &str, is_error: bool);
116 }
117
118 pub trait CommandVoiceInputContext {
119 fn recorder_available(&self) -> bool;
120 fn voice_enabled(&self) -> bool;
121 fn set_voice_enabled(&mut self, enabled: bool);
122 fn send_enabled(&self) -> bool;
123 fn set_send_enabled(&mut self, enabled: bool);
124 fn control_enabled(&self) -> bool;
125 fn set_control_enabled(&mut self, enabled: bool);
126 }
127
128 pub fn public_site_locale_segment(tag: &str) -> &'static str {
129 match tag {
130 "zh-Hans" | "zh-Hant" => "zh",
131 "ja" => "ja",
132 "vi" => "vi",
133 "ko" => "ko",
134 "es-419" => "es",
135 "pt-BR" => "pt-BR",
136 "ru" => "ru",
137 "uk" => "uk",
138 _ => "en",
139 }
140 }
141
141 lines RUST