Skip to main content

codewhale_command_contract/
navigation.rs

1use std::path::PathBuf;
2
3use crate::types::CommandMode;
4
5#[derive(Debug, Clone, PartialEq, Eq)]
6pub 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)]
14pub 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)]
22pub 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)]
29pub struct NavigationSkill {
30    pub name: String,
31    pub description: String,
32}
33
34#[derive(Debug, Clone, PartialEq, Eq)]
35pub 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)]
48pub enum NavigationProviderKind {
49    Moonshot,
50    Other,
51}
52
53#[derive(Debug, Clone, PartialEq, Eq)]
54pub 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)]
65pub 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)]
74pub enum WorkspaceTarget {
75    Missing,
76    NotDirectory,
77    Directory { canonical_or_candidate: PathBuf },
78}
79
80#[derive(Debug, Clone, PartialEq, Eq)]
81pub enum AnchorWriteError {
82    Open(String),
83    Write(String),
84}
85
86pub trait CommandNavigationContext {
87    fn help_topic(&self, topic: &str) -> NavigationHelpTopic;
88    fn cached_skills(&self) -> Vec<NavigationSkill>;
89    fn help_is_open(&self) -> bool;
90    fn open_help(&mut self);
91    fn home_is_blocked(&self) -> bool;
92    fn restore_home(&mut self);
93    fn overview(&self) -> NavigationOverview;
94    fn links(&self) -> NavigationLinks;
95}
96
97pub trait CommandVoiceInputContext {
98    fn recorder_available(&self) -> bool;
99    fn voice_enabled(&self) -> bool;
100    fn set_voice_enabled(&mut self, enabled: bool);
101    fn send_enabled(&self) -> bool;
102    fn set_send_enabled(&mut self, enabled: bool);
103    fn control_enabled(&self) -> bool;
104    fn set_control_enabled(&mut self, enabled: bool);
105}
106
107pub fn public_site_locale_segment(tag: &str) -> &'static str {
108    match tag {
109        "zh-Hans" | "zh-Hant" => "zh",
110        "ja" => "ja",
111        "vi" => "vi",
112        "ko" => "ko",
113        "es-419" => "es",
114        "pt-BR" => "pt-BR",
115        "ru" => "ru",
116        "uk" => "uk",
117        _ => "en",
118    }
119}