89 lines
2.5 KiB
Rust
89 lines
2.5 KiB
Rust
//! Pure Settings entity — user configuration for LLM provider, model,
|
|||
|
|
//! generation parameters, and feature flags.
|
||
|
|
//!
|
||
|
|
//! # Architecture
|
||
|
|
//! This is a pure data structure with **no I/O logic**. Load/save
|
||
|
|
//! responsibilities live in [`SettingsRepository`](super::repository::SettingsRepository).
|
||
|
|
|
||
|
|
#![allow(
|
||
|
|
clippy::cast_possible_truncation,
|
||
|
|
clippy::cast_sign_loss,
|
||
|
|
clippy::cast_precision_loss,
|
||
|
|
clippy::cast_possible_wrap
|
||
|
|
)]
|
||
|
|
|
||
|
|
use std::collections::HashMap;
|
||
|
|
|
||
|
|
use serde::{Deserialize, Serialize};
|
||
|
|
|
||
|
|
/// Controls how much network access the agent is permitted during a session.
|
||
|
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Default)]
|
||
|
|
pub enum InternetMode {
|
||
|
|
#[default]
|
||
|
|
Off,
|
||
|
|
ReadOnly,
|
||
|
|
Full,
|
||
|
|
}
|
||
|
|
|
||
|
|
/// Boolean flags grouped to keep the top-level [`Settings`] struct below
|
||
|
|
/// clippy's default-too-many-fields threshold.
|
||
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||
|
|
pub struct SettingsFlags {
|
||
|
|
pub review_enabled: bool,
|
||
|
|
pub session_archive_enabled: bool,
|
||
|
|
pub lsp_auto_provision: bool,
|
||
|
|
}
|
||
|
|
|
||
|
|
impl Default for SettingsFlags {
|
||
|
|
fn default() -> Self {
|
||
|
|
Self {
|
||
|
|
review_enabled: true,
|
||
|
|
session_archive_enabled: true,
|
||
|
|
lsp_auto_provision: true,
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/// Top-level application settings.
|
||
|
|
///
|
||
|
|
/// Serialized to `settings.json` by the infrastructure layer.
|
||
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||
|
|
pub struct Settings {
|
||
|
|
pub internet_mode: InternetMode,
|
||
|
|
pub provider: String,
|
||
|
|
pub model: String,
|
||
|
|
pub api_keys: HashMap<String, String>,
|
||
|
|
pub max_tokens: Option<u32>,
|
||
|
|
pub temperature: Option<f32>,
|
||
|
|
pub review_max_lessons_per_run: usize,
|
||
|
|
pub adaptive_review_max_skip: u32,
|
||
|
|
pub verify_command: Option<String>,
|
||
|
|
pub verify_timeout_ms: u64,
|
||
|
|
pub workflow_max_concurrency: usize,
|
||
|
|
#[serde(flatten)]
|
||
|
|
pub flags: SettingsFlags,
|
||
|
|
pub lsp_languages: Vec<String>,
|
||
|
|
pub hive_mind_node_timeout_ms: u64,
|
||
|
|
}
|
||
|
|
|
||
|
|
impl Default for Settings {
|
||
|
|
fn default() -> Self {
|
||
|
|
Self {
|
||
|
|
internet_mode: InternetMode::Off,
|
||
|
|
provider: "zen".to_string(),
|
||
|
|
model: "deepseek-v4-flash-free".to_string(),
|
||
|
|
api_keys: HashMap::new(),
|
||
|
|
max_tokens: None,
|
||
|
|
temperature: None,
|
||
|
|
review_max_lessons_per_run: 5,
|
||
|
|
adaptive_review_max_skip: 3,
|
||
|
|
verify_command: None,
|
||
|
|
verify_timeout_ms: 30_000,
|
||
|
|
workflow_max_concurrency: 5,
|
||
|
|
flags: SettingsFlags::default(),
|
||
|
|
lsp_languages: Vec::new(),
|
||
|
|
hive_mind_node_timeout_ms: 600_000,
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|