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,3 +1,5 @@
|
||||
//! Tool: `write` — write content to a file, creating parent directories on demand.
|
||||
|
||||
use std::fs;
|
||||
use serde_json::{json, Value};
|
||||
use anyhow::{Result, anyhow};
|
||||
@@ -7,6 +9,7 @@ use super::super::resolve_path;
|
||||
use super::super::check_graduated_checks;
|
||||
use super::helpers::arg_str;
|
||||
|
||||
/// Tool: write content to a file, auto-creating parent directories as needed.
|
||||
pub struct Write;
|
||||
|
||||
impl Tool for Write {
|
||||
@@ -39,6 +42,13 @@ impl Tool for Write {
|
||||
})
|
||||
}
|
||||
|
||||
/// Write content to a file, creating parent directories as needed.
|
||||
///
|
||||
/// Flow: validate args (non-empty reason) → resolve path → create parent
|
||||
/// dirs → write file → report byte count (+ optional graduated checks).
|
||||
///
|
||||
/// Why: requires a non-empty `reason` to discourage stray writes; parent
|
||||
/// directories are created silently so the tool works for new paths.
|
||||
fn run(&self, ctx: &ToolCtx, args: &Value) -> Result<String> {
|
||||
let rel = arg_str(args, "path")?;
|
||||
let content = arg_str(args, "content")?;
|
||||
|
||||
Reference in New Issue
Block a user