forked from 1jehuang/jcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.rs
More file actions
110 lines (89 loc) · 3.18 KB
/
config.rs
File metadata and controls
110 lines (89 loc) · 3.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
//! Configuration file support for jcode
//!
//! Config is loaded from `~/.jcode/config.toml` (or `$JCODE_HOME/config.toml`)
//! Environment variables override config file settings.
pub use jcode_config_types::{
AgentsConfig, AmbientConfig, AuthConfig, AutoJudgeConfig, AutoReviewConfig, CompactionConfig,
CompactionMode, CrossProviderFailoverMode, DiagramDisplayMode, DiagramPanePosition,
DiffDisplayMode, DisplayConfig, FeatureConfig, GatewayConfig, KeybindingsConfig,
MarkdownSpacingMode, NamedProviderAuth, NamedProviderConfig, NamedProviderModelConfig,
NamedProviderType, NativeScrollbarConfig, ProviderConfig, SafetyConfig,
SessionPickerResumeAction, UpdateChannel,
};
use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;
use std::sync::OnceLock;
static CONFIG: OnceLock<Config> = OnceLock::new();
/// Get the global config instance (loaded once on first access)
pub fn config() -> &'static Config {
CONFIG.get_or_init(Config::load)
}
/// Main configuration struct
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(default)]
pub struct Config {
/// Keybinding configuration
pub keybindings: KeybindingsConfig,
/// External dictation / speech-to-text integration
pub dictation: DictationConfig,
/// Display/UI configuration
pub display: DisplayConfig,
/// Feature toggles
pub features: FeatureConfig,
/// Auth trust / consent configuration
pub auth: AuthConfig,
/// Provider configuration
pub provider: ProviderConfig,
/// Named provider profiles, keyed by profile name.
///
/// Example:
/// [providers.my-gateway]
/// type = "openai-compatible"
/// base_url = "https://llm.example.com/v1"
/// api_key_env = "MY_GATEWAY_API_KEY"
pub providers: BTreeMap<String, NamedProviderConfig>,
/// Agent-specific model defaults
pub agents: AgentsConfig,
/// Ambient mode configuration
pub ambient: AmbientConfig,
/// Safety / notification configuration
pub safety: SafetyConfig,
/// WebSocket gateway configuration (for iOS/web clients)
pub gateway: GatewayConfig,
/// Compaction configuration
pub compaction: CompactionConfig,
/// Auto-review configuration
pub autoreview: AutoReviewConfig,
/// Auto-judge configuration
pub autojudge: AutoJudgeConfig,
}
/// External dictation / speech-to-text integration.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(default)]
pub struct DictationConfig {
/// Shell command to run. Must print the transcript to stdout.
pub command: String,
/// How to apply the resulting transcript.
pub mode: crate::protocol::TranscriptMode,
/// Optional in-app hotkey to trigger dictation.
pub key: String,
/// Maximum time to wait for the command to finish (0 = no timeout).
pub timeout_secs: u64,
}
impl Default for DictationConfig {
fn default() -> Self {
Self {
command: String::new(),
mode: crate::protocol::TranscriptMode::Send,
key: "off".to_string(),
timeout_secs: 90,
}
}
}
mod config_file;
mod default_file;
mod display_summary;
mod env_overrides;
#[cfg(test)]
#[path = "config_tests.rs"]
mod tests;