refactor(backend): alihkan Settings ke zesdex-cms JsonSettingsRepository
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
6d41ffc587
commit
8e6acc30d5
@@ -3,7 +3,7 @@
|
||||
//! Flow: exposes small mutation functions (currently just cycling the
|
||||
//! internet access mode) invoked by keybindings while the settings overlay
|
||||
//! is active.
|
||||
use crate::model::settings::{InternetMode, Settings};
|
||||
use zesdex_cms::domain::settings::{InternetMode, Settings};
|
||||
|
||||
/// Advance the internet access mode to the next value in the cycle.
|
||||
///
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
//! displayed "?" on no match instead of falling back like the other two,
|
||||
//! an inconsistency this unifies away).
|
||||
use crate::model::app_config::AppConfig;
|
||||
use crate::model::settings::Settings;
|
||||
use zesdex_cms::domain::settings::Settings;
|
||||
|
||||
/// Resolve the context-window size (in tokens) for the currently
|
||||
/// configured provider/model.
|
||||
|
||||
@@ -17,7 +17,9 @@ use crate::app::mcp::manager::McpManager;
|
||||
use crate::app::workflow::engine::WorkflowEngine;
|
||||
use crate::model::app_config::AppConfig;
|
||||
use crate::model::editlog::EditLog;
|
||||
use crate::model::settings::Settings;
|
||||
use zesdex_cms::domain::repository::SettingsRepository;
|
||||
use zesdex_cms::domain::settings::Settings;
|
||||
use zesdex_cms::infrastructure::persistence::settings_repo::JsonSettingsRepository;
|
||||
|
||||
/// A single transcript entry rendered in the TUI chat pane.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
@@ -86,7 +88,10 @@ impl AppStateRest {
|
||||
/// no parent, and to an empty session id when the dir name can't be
|
||||
/// read, so construction never fails.
|
||||
pub fn new(workspace_roots: Vec<PathBuf>, session_dir: &std::path::Path, memory_dir: PathBuf) -> Self {
|
||||
let settings = Settings::load();
|
||||
let store_base_dir = zesdex_entities::seaorm::common::store::Store::new().base_dir;
|
||||
let settings = JsonSettingsRepository::new()
|
||||
.load(&store_base_dir)
|
||||
.unwrap_or_default();
|
||||
let app_config = AppConfig::load();
|
||||
let worktrees_dir = memory_dir.parent().unwrap_or_else(|| {
|
||||
tracing::warn!("[state] memory_dir '{}' has no parent, using it for worktrees", memory_dir.display());
|
||||
|
||||
@@ -15,6 +15,7 @@ use crate::dto::provider::request::ToolDef;
|
||||
use crate::tool::{all_tools, tool_defs, tool_is_risky};
|
||||
use super::context::SubagentContext;
|
||||
use super::event::SubagentEvent;
|
||||
use zesdex_cms::domain::repository::SettingsRepository;
|
||||
|
||||
/// Maps a subagent's allowed tool names to concrete Tool trait objects and
|
||||
/// OpenAI-style tool definitions.
|
||||
@@ -58,7 +59,10 @@ fn build_subagent_tools(allowed_tools: &[String]) -> (Vec<Box<dyn crate::tool::T
|
||||
/// is empty when every resolution path was exhausted — callers must check
|
||||
/// for this before issuing requests (see `run_subagent`).
|
||||
fn resolve_provider_config() -> (String, String, Option<String>, String) {
|
||||
let settings = crate::model::settings::Settings::load();
|
||||
let store_base_dir = zesdex_entities::seaorm::common::store::Store::new().base_dir;
|
||||
let settings = zesdex_cms::infrastructure::persistence::settings_repo::JsonSettingsRepository::new()
|
||||
.load(&store_base_dir)
|
||||
.unwrap_or_default();
|
||||
let app_config = crate::model::app_config::AppConfig::load();
|
||||
|
||||
let mut api_key = settings.api_keys.get(&settings.provider).cloned().unwrap_or_else(|| {
|
||||
|
||||
@@ -33,6 +33,7 @@ use std::sync::{
|
||||
atomic::{AtomicBool, Ordering},
|
||||
Arc, Mutex,
|
||||
};
|
||||
use zesdex_cms::domain::repository::SettingsRepository;
|
||||
|
||||
/// One directive the Hive's Core Intelligence issues to a drone within a
|
||||
/// cognitive cycle. A drone's sole identity is its directive and access tier.
|
||||
@@ -278,7 +279,10 @@ pub fn run_hive_mind(
|
||||
anyhow::bail!("the Hive received no cognitive cycles to execute");
|
||||
}
|
||||
|
||||
let settings = crate::model::settings::Settings::load();
|
||||
let store_base_dir = zesdex_entities::seaorm::common::store::Store::new().base_dir;
|
||||
let settings = zesdex_cms::infrastructure::persistence::settings_repo::JsonSettingsRepository::new()
|
||||
.load(&store_base_dir)
|
||||
.unwrap_or_default();
|
||||
let node_timeout_ms = Some(settings.hive_mind_node_timeout_ms);
|
||||
let max_cycle_concurrency = settings.workflow_max_concurrency.max(1);
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ fn main() -> anyhow::Result<()> {
|
||||
// Create default settings if not present
|
||||
let settings_path = store.base_dir.join("settings.json");
|
||||
if !settings_path.exists() {
|
||||
let settings = zesdex_entities::seaorm::common::settings::Settings::default();
|
||||
let settings = zesdex_cms::domain::settings::Settings::default();
|
||||
let content = serde_json::to_string_pretty(&settings)?;
|
||||
let tmp = store.base_dir.join("settings.json.tmp");
|
||||
std::fs::write(&tmp, content)?;
|
||||
|
||||
@@ -10,6 +10,7 @@ use crate::app::state::misc::AutocompleteKind;
|
||||
use crate::app::state::rest::AppStateRest;
|
||||
use crate::app::state::types::Overlay;
|
||||
use crate::controller::command::parse_command;
|
||||
use zesdex_cms::domain::repository::SettingsRepository;
|
||||
|
||||
/// Translate a terminal `KeyEvent` into zero or more `Action` values
|
||||
/// based on the current application state.
|
||||
@@ -358,7 +359,8 @@ fn handle_overlay_enter(state: &mut AppStateRest) -> Vec<Action> {
|
||||
.api_keys
|
||||
.insert(state.settings.provider.clone(), text.clone());
|
||||
}
|
||||
let _ = state.settings.save();
|
||||
let _ = zesdex_cms::infrastructure::persistence::settings_repo::JsonSettingsRepository::new()
|
||||
.save(&state.store_base_dir(), &state.settings);
|
||||
state.input.buffer.clear();
|
||||
state.input.cursor = 0;
|
||||
state.misc.overlay = Overlay::None;
|
||||
@@ -404,7 +406,8 @@ fn handle_overlay_enter(state: &mut AppStateRest) -> Vec<Action> {
|
||||
{
|
||||
state.settings.api_keys.insert(provider.clone(), env_key);
|
||||
}
|
||||
let _ = state.settings.save();
|
||||
let _ = zesdex_cms::infrastructure::persistence::settings_repo::JsonSettingsRepository::new()
|
||||
.save(&state.store_base_dir(), &state.settings);
|
||||
state.push_toast(crate::app::state::types::Toast::new(
|
||||
crate::app::state::types::ToastKind::Success,
|
||||
format!("Switched to {provider} / {model}"),
|
||||
|
||||
@@ -15,6 +15,7 @@ use crossterm::terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScree
|
||||
use ratatui::backend::CrosstermBackend;
|
||||
use ratatui::Terminal;
|
||||
use zesdex_iam::domain::repository::{SessionLockRepository, SessionRepository};
|
||||
use zesdex_cms::domain::repository::SettingsRepository;
|
||||
|
||||
mod app;
|
||||
mod controller;
|
||||
@@ -156,7 +157,8 @@ fn run_single_process() -> Result<()> {
|
||||
let _ = restore_stdout.flush();
|
||||
}
|
||||
|
||||
let _ = state.settings.save();
|
||||
let _ = zesdex_cms::infrastructure::persistence::settings_repo::JsonSettingsRepository::new()
|
||||
.save(&state.store_base_dir(), &state.settings);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -490,7 +492,8 @@ fn run_daemon() -> Result<()> {
|
||||
}
|
||||
|
||||
eprintln!("daemon: client disconnected, waiting for next connection...");
|
||||
let _ = state.settings.save();
|
||||
let _ = zesdex_cms::infrastructure::persistence::settings_repo::JsonSettingsRepository::new()
|
||||
.save(&state.store_base_dir(), &state.settings);
|
||||
}
|
||||
|
||||
let _ = std::fs::remove_file(&socket_path);
|
||||
@@ -656,7 +659,8 @@ fn run_attach(session_id: &str) -> Result<()> {
|
||||
let _ = execute!(io::stdout(), LeaveAlternateScreen);
|
||||
let _ = disable_raw_mode();
|
||||
|
||||
let _ = client_state.settings.save();
|
||||
let _ = zesdex_cms::infrastructure::persistence::settings_repo::JsonSettingsRepository::new()
|
||||
.save(&client_state.store_base_dir(), &client_state.settings);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
//! plus local sub-modules (agent_def, msglog) that weren't extracted.
|
||||
|
||||
// Module re-exports matching original `crate::model::*` paths
|
||||
pub mod settings {
|
||||
pub use zesdex_entities::seaorm::common::settings::*;
|
||||
}
|
||||
pub mod app_config {
|
||||
pub use zesdex_entities::seaorm::common::app_config::*;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user