refactor(backend): alihkan AppConfig ke zesdex-cms JsonAppConfigRepository
Semua pemanggilan AppConfig::load() diganti dengan JsonAppConfigRepository + AppConfigRepository trait. Re-export model::app_config dihapus dari model/mod.rs. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
8e6acc30d5
commit
dc9fd4dbd1
@@ -5,7 +5,7 @@
|
|||||||
//! had their own inline version — the status bar's copy additionally
|
//! had their own inline version — the status bar's copy additionally
|
||||||
//! displayed "?" on no match instead of falling back like the other two,
|
//! displayed "?" on no match instead of falling back like the other two,
|
||||||
//! an inconsistency this unifies away).
|
//! an inconsistency this unifies away).
|
||||||
use crate::model::app_config::AppConfig;
|
use zesdex_cms::domain::app_config::AppConfig;
|
||||||
use zesdex_cms::domain::settings::Settings;
|
use zesdex_cms::domain::settings::Settings;
|
||||||
|
|
||||||
/// Resolve the context-window size (in tokens) for the currently
|
/// Resolve the context-window size (in tokens) for the currently
|
||||||
@@ -28,7 +28,7 @@ pub fn resolve(app_config: &AppConfig, settings: &Settings) -> usize {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::model::app_config::ModelRole;
|
use zesdex_cms::domain::app_config::ModelRole;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn resolves_context_window_from_matching_model_role() {
|
fn resolves_context_window_from_matching_model_role() {
|
||||||
|
|||||||
@@ -15,10 +15,12 @@ use super::types::{Origin, Toast, TranscriptCache};
|
|||||||
use crate::app::lsp::LspManager;
|
use crate::app::lsp::LspManager;
|
||||||
use crate::app::mcp::manager::McpManager;
|
use crate::app::mcp::manager::McpManager;
|
||||||
use crate::app::workflow::engine::WorkflowEngine;
|
use crate::app::workflow::engine::WorkflowEngine;
|
||||||
use crate::model::app_config::AppConfig;
|
|
||||||
use crate::model::editlog::EditLog;
|
use crate::model::editlog::EditLog;
|
||||||
|
use zesdex_cms::domain::app_config::AppConfig;
|
||||||
|
use zesdex_cms::domain::repository::AppConfigRepository;
|
||||||
use zesdex_cms::domain::repository::SettingsRepository;
|
use zesdex_cms::domain::repository::SettingsRepository;
|
||||||
use zesdex_cms::domain::settings::Settings;
|
use zesdex_cms::domain::settings::Settings;
|
||||||
|
use zesdex_cms::infrastructure::persistence::app_config_repo::JsonAppConfigRepository;
|
||||||
use zesdex_cms::infrastructure::persistence::settings_repo::JsonSettingsRepository;
|
use zesdex_cms::infrastructure::persistence::settings_repo::JsonSettingsRepository;
|
||||||
|
|
||||||
/// A single transcript entry rendered in the TUI chat pane.
|
/// A single transcript entry rendered in the TUI chat pane.
|
||||||
@@ -92,7 +94,9 @@ impl AppStateRest {
|
|||||||
let settings = JsonSettingsRepository::new()
|
let settings = JsonSettingsRepository::new()
|
||||||
.load(&store_base_dir)
|
.load(&store_base_dir)
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
let app_config = AppConfig::load();
|
let app_config = JsonAppConfigRepository::new()
|
||||||
|
.load(&store_base_dir)
|
||||||
|
.unwrap_or_default();
|
||||||
let worktrees_dir = memory_dir.parent().unwrap_or_else(|| {
|
let worktrees_dir = memory_dir.parent().unwrap_or_else(|| {
|
||||||
tracing::warn!("[state] memory_dir '{}' has no parent, using it for worktrees", memory_dir.display());
|
tracing::warn!("[state] memory_dir '{}' has no parent, using it for worktrees", memory_dir.display());
|
||||||
&memory_dir
|
&memory_dir
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ use crate::dto::provider::request::ToolDef;
|
|||||||
use crate::tool::{all_tools, tool_defs, tool_is_risky};
|
use crate::tool::{all_tools, tool_defs, tool_is_risky};
|
||||||
use super::context::SubagentContext;
|
use super::context::SubagentContext;
|
||||||
use super::event::SubagentEvent;
|
use super::event::SubagentEvent;
|
||||||
|
use zesdex_cms::domain::repository::AppConfigRepository;
|
||||||
use zesdex_cms::domain::repository::SettingsRepository;
|
use zesdex_cms::domain::repository::SettingsRepository;
|
||||||
|
|
||||||
/// Maps a subagent's allowed tool names to concrete Tool trait objects and
|
/// Maps a subagent's allowed tool names to concrete Tool trait objects and
|
||||||
@@ -63,7 +64,9 @@ fn resolve_provider_config() -> (String, String, Option<String>, String) {
|
|||||||
let settings = zesdex_cms::infrastructure::persistence::settings_repo::JsonSettingsRepository::new()
|
let settings = zesdex_cms::infrastructure::persistence::settings_repo::JsonSettingsRepository::new()
|
||||||
.load(&store_base_dir)
|
.load(&store_base_dir)
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
let app_config = crate::model::app_config::AppConfig::load();
|
let app_config = zesdex_cms::infrastructure::persistence::app_config_repo::JsonAppConfigRepository::new()
|
||||||
|
.load(&store_base_dir)
|
||||||
|
.unwrap_or_default();
|
||||||
|
|
||||||
let mut api_key = settings.api_keys.get(&settings.provider).cloned().unwrap_or_else(|| {
|
let mut api_key = settings.api_keys.get(&settings.provider).cloned().unwrap_or_else(|| {
|
||||||
tracing::warn!("[subagent] no API key for provider '{}' in settings, trying env/default", settings.provider);
|
tracing::warn!("[subagent] no API key for provider '{}' in settings, trying env/default", settings.provider);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ fn main() -> anyhow::Result<()> {
|
|||||||
// Create default app config if not present
|
// Create default app config if not present
|
||||||
let config_path = store.base_dir.join("app_config.json");
|
let config_path = store.base_dir.join("app_config.json");
|
||||||
if !config_path.exists() {
|
if !config_path.exists() {
|
||||||
let config = zesdex_entities::seaorm::common::app_config::AppConfig::default();
|
let config = zesdex_cms::domain::app_config::AppConfig::default();
|
||||||
let content = serde_json::to_string_pretty(&config)?;
|
let content = serde_json::to_string_pretty(&config)?;
|
||||||
let tmp = store.base_dir.join("app_config.json.tmp");
|
let tmp = store.base_dir.join("app_config.json.tmp");
|
||||||
std::fs::write(&tmp, content)?;
|
std::fs::write(&tmp, content)?;
|
||||||
|
|||||||
@@ -2,9 +2,6 @@
|
|||||||
//! plus local sub-modules (agent_def, msglog) that weren't extracted.
|
//! plus local sub-modules (agent_def, msglog) that weren't extracted.
|
||||||
|
|
||||||
// Module re-exports matching original `crate::model::*` paths
|
// Module re-exports matching original `crate::model::*` paths
|
||||||
pub mod app_config {
|
|
||||||
pub use zesdex_entities::seaorm::common::app_config::*;
|
|
||||||
}
|
|
||||||
pub mod store {
|
pub mod store {
|
||||||
pub use zesdex_entities::seaorm::common::store::*;
|
pub use zesdex_entities::seaorm::common::store::*;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -707,7 +707,7 @@ fn render_overlay(
|
|||||||
Style::default().fg(Theme::TEXT_DIM),
|
Style::default().fg(Theme::TEXT_DIM),
|
||||||
)),
|
)),
|
||||||
];
|
];
|
||||||
let providers: Vec<(&String, &crate::model::app_config::ProviderConfig)> =
|
let providers: Vec<(&String, &zesdex_cms::domain::app_config::ProviderConfig)> =
|
||||||
state.app_config.providers.iter().collect();
|
state.app_config.providers.iter().collect();
|
||||||
for (i, (name, cfg)) in providers.iter().enumerate() {
|
for (i, (name, cfg)) in providers.iter().enumerate() {
|
||||||
let is_current = *name == &state.settings.provider;
|
let is_current = *name == &state.settings.provider;
|
||||||
|
|||||||
Reference in New Issue
Block a user