//! # Zesdex Infrastructure Layer //! //! ALL concrete implementations of domain repository traits, application port //! traits, and platform services. This is the outermost ring of the Clean //! Architecture onion — it depends on `zesdex-domain` and `zesdex-application` //! but NEVER on interface/presentation crates. //! //! ## Architecture //! //! ```text //! src/ //! ├── lib.rs — Foundational types + re-exports //! ├── utils.rs — CastOr, write_json_atomic, slugify //! ├── persistence/ — Repository implementations (IAM, CMS, SQLite) //! ├── auth/ — JWT, Argon2, OAuth loopback //! ├── llm/ — LLM provider HTTP client //! ├── ipc/ — Unix-socket IPC protocol //! ├── mcp/ — Model Context Protocol bridge //! ├── bgbash/ — Background bash job management //! ├── tools/ — All 37 agent-invocable tools //! ├── subagent/ — Subagent spawning & execution engine //! ├── workflow/ — Hive-mind orchestration engine //! ├── review/ — Post-edit auto-review subagent //! ├── guard/ — Tool-gate access control //! └── middleware/ — Axum HTTP middleware (auth, cors, rate-limit) //! ``` pub mod auth; pub mod best_practice; pub mod bgbash; pub mod guard; pub mod ipc; pub mod llm; pub mod mcp; pub mod middleware; pub mod persistence; pub mod subagent; pub mod tools; pub mod utils; pub mod workflow; // --------------------------------------------------------------------------- // Re-exports from domain // --------------------------------------------------------------------------- pub use zesdex_domain::*; // --------------------------------------------------------------------------- // Foundation types — these replace `crate::app::state::*` references // from the legacy backend code. // --------------------------------------------------------------------------- use std::path::PathBuf; use std::sync::Arc; // Which kind of caller (main agent vs. subagent vs. reviewer) is // invoking a tool, used to scope permissions and tag log/output paths. // --------------------------------------------------------------------------- // TurnEvent & runtime types have been moved to zesdex_domain::agent // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- // Tool types — needed by all tool modules // --------------------------------------------------------------------------- pub use tools::{GraduatedCheck, Tool, ToolCtx, ToolCtxBuilder}; // Re-export commonly needed types at the crate root pub use zesdex_domain::core::{ChatMessage, Role, Store, ToolCallResult, UsageStats}; /// A shared, async-writable cache of directory entries, used to avoid /// re-reading a directory every render frame. #[derive(Clone)] pub struct DirCache { entries: Arc>>, } impl DirCache { /// Create an empty directory cache. pub fn new() -> Self { DirCache { entries: Arc::new(tokio::sync::RwLock::new(Vec::new())), } } /// Replace the cached directory entries. pub async fn set(&self, paths: Vec) { let mut w = self.entries.write().await; *w = paths; } } impl Default for DirCache { fn default() -> Self { Self::new() } } /// A shared, whole-workspace file-path index used for `@file` mention /// autocomplete. #[derive(Clone)] pub struct MentionIndex { entries: Arc>>, } impl MentionIndex { /// Create an empty mention index. pub fn new() -> Self { MentionIndex { entries: Arc::new(std::sync::RwLock::new(Vec::new())), } } /// Replace the entire index with a new set of file paths. pub fn set(&self, paths: Vec) { if let Ok(mut w) = self.entries.write() { *w = paths; } } /// Append a single file path to the index. pub fn push(&self, path: String) { if let Ok(mut w) = self.entries.write() { w.push(path); } } /// Return a copy of all indexed paths. pub fn snapshot(&self) -> Vec { self.entries.read().map(|r| r.clone()).unwrap_or_default() } } impl Default for MentionIndex { fn default() -> Self { Self::new() } }