Enhance tool documentation and add new features
- Added module-level documentation for memory tools (`remember`, `recall`, `forget`) to clarify their purpose. - Improved documentation in `recall.rs` and `remember.rs` to describe the functionality and flow of memory entry operations. - Updated `mod.rs` to include descriptions for the tool trait and execution context. - Enhanced `plan.rs` with detailed comments on plan-mode signaling tools. - Documented text search tools in `search.rs` to explain their functionality. - Improved sequential-thinking tool documentation in `seqthink.rs`. - Added safety filter documentation in `shell_filter` for credential and git operations. - Enhanced utility tools documentation, including `cd`, `dir_cache_update`, and `todowrite`. - Improved rendering documentation in view modules (`chat`, `markdown`, `status`, `workflow`) to clarify rendering flows and purposes.
This commit is contained in:
@@ -1,5 +1,15 @@
|
||||
//! User-configurable settings persisted as JSON in the store's base directory.
|
||||
//!
|
||||
//! `Settings::load` / `Settings::save` are the only entry points; every field
|
||||
//! falls back to a hardcoded default via `Default for Settings` when the file
|
||||
//! is missing or fails to parse.
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Controls how much network access the agent is permitted during a session.
|
||||
///
|
||||
/// `Off` disables outbound requests entirely, `ReadOnly` allows fetches but
|
||||
/// no mutating calls, `Full` permits everything. Defaults to `Off`.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[derive(Default)]
|
||||
pub enum InternetMode {
|
||||
@@ -11,6 +21,10 @@ pub enum InternetMode {
|
||||
|
||||
|
||||
|
||||
/// Top-level application settings, serialized to `settings.json` in the store dir.
|
||||
///
|
||||
/// Why: a single flat struct rather than nested config so the JSON file stays
|
||||
/// human-editable; unknown/missing fields on load fall back to `Default`.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct Settings {
|
||||
pub internet_mode: InternetMode,
|
||||
@@ -49,6 +63,12 @@ impl Default for Settings {
|
||||
}
|
||||
|
||||
impl Settings {
|
||||
/// Load settings from `<store_base_dir>/settings.json`.
|
||||
///
|
||||
/// Flow: read file → parse JSON → fall back to `Settings::default()` on
|
||||
/// any failure (missing file, unreadable, malformed JSON).
|
||||
///
|
||||
/// Return: always succeeds; never surfaces I/O or parse errors to the caller.
|
||||
pub fn load() -> Self {
|
||||
let store = super::store::Store::new();
|
||||
let path = store.base_dir.join("settings.json");
|
||||
@@ -58,6 +78,11 @@ impl Settings {
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Serialize and write settings to `<store_base_dir>/settings.json`.
|
||||
///
|
||||
/// Flow: ensure base dir exists → pretty-print JSON → write to disk.
|
||||
///
|
||||
/// Return: `Err` if the directory can't be created or the write fails.
|
||||
pub fn save(&self) -> std::io::Result<()> {
|
||||
let store = super::store::Store::new();
|
||||
std::fs::create_dir_all(&store.base_dir)?;
|
||||
|
||||
Reference in New Issue
Block a user