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,9 +1,12 @@
|
||||
//! Tool for deleting a persisted memory entry by name.
|
||||
|
||||
use serde_json::{json, Value};
|
||||
use anyhow::{Result, anyhow};
|
||||
use super::super::Tool;
|
||||
use super::super::ToolCtx;
|
||||
use crate::model::memory::Memory;
|
||||
|
||||
/// Tool that removes a single memory entry from `ctx.memory_dir` by exact name.
|
||||
pub struct Forget;
|
||||
|
||||
impl Tool for Forget {
|
||||
@@ -28,6 +31,12 @@ impl Tool for Forget {
|
||||
})
|
||||
}
|
||||
|
||||
/// Delete the memory file matching `name` from disk.
|
||||
///
|
||||
/// Flow: extract `name` → `Memory::remove` → confirmation string.
|
||||
///
|
||||
/// Return: confirmation message on success; error if the memory does not exist
|
||||
/// or the file could not be removed.
|
||||
fn run(&self, ctx: &ToolCtx, args: &Value) -> Result<String> {
|
||||
let name = args.get("name")
|
||||
.and_then(|v| v.as_str())
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
//! Memory tools: `remember`, `recall`, and `forget` for persisted project memory entries.
|
||||
|
||||
pub mod forget;
|
||||
pub mod recall;
|
||||
pub mod remember;
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
//! Tool for reading a single memory entry or listing the whole memory index.
|
||||
|
||||
use serde_json::{json, Value};
|
||||
use anyhow::{Result, anyhow};
|
||||
use super::super::Tool;
|
||||
use super::super::ToolCtx;
|
||||
use crate::model::memory::Memory;
|
||||
|
||||
/// Tool that reads one memory entry by name, or lists all entries when name is omitted.
|
||||
pub struct Recall;
|
||||
|
||||
impl Tool for Recall {
|
||||
@@ -27,6 +30,12 @@ impl Tool for Recall {
|
||||
})
|
||||
}
|
||||
|
||||
/// Read a specific memory entry, or fall back to listing all entries.
|
||||
///
|
||||
/// Flow: if `name` present and non-empty → `Memory::read` and format as frontmatter
|
||||
/// + body; otherwise → `list_all`.
|
||||
///
|
||||
/// Return: formatted memory content, or the full index listing.
|
||||
fn run(&self, ctx: &ToolCtx, args: &Value) -> Result<String> {
|
||||
if let Some(name) = args.get("name").and_then(|v| v.as_str()) {
|
||||
if name.is_empty() {
|
||||
@@ -48,6 +57,12 @@ impl Tool for Recall {
|
||||
}
|
||||
}
|
||||
|
||||
/// List every memory entry in `ctx.memory_dir` as a one-line summary index.
|
||||
///
|
||||
/// Flow: `Memory::list` names → for each, try `Memory::read` for kind/description →
|
||||
/// fall back to bare name if the file can't be parsed.
|
||||
///
|
||||
/// Return: `Ok` with the formatted index (never fails; missing dir yields "(no memory entries)").
|
||||
fn list_all(ctx: &ToolCtx) -> Result<String> {
|
||||
let names = Memory::list(&ctx.memory_dir);
|
||||
if names.is_empty() {
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
//! Tool for saving a new memory entry to persistent project memory.
|
||||
|
||||
use serde_json::{json, Value};
|
||||
use anyhow::{Result, anyhow};
|
||||
use super::super::Tool;
|
||||
use super::super::ToolCtx;
|
||||
use crate::model::memory::Memory;
|
||||
|
||||
/// Tool that writes a new `Memory` entry (name/description/content/kind) to disk.
|
||||
pub struct Remember;
|
||||
|
||||
impl Tool for Remember {
|
||||
@@ -41,6 +44,16 @@ impl Tool for Remember {
|
||||
})
|
||||
}
|
||||
|
||||
/// Build a `Memory` from the given args and persist it to `ctx.memory_dir`.
|
||||
///
|
||||
/// Flow: extract name/description/content/kind → validate name via `Memory::slugify`
|
||||
/// → construct `Memory` with `lifecycle: "new"` and current timestamps →
|
||||
/// `memory.write`.
|
||||
///
|
||||
/// Why: name must slugify to a valid filename (alphanumeric + hyphens, 1-80 chars)
|
||||
/// since it's used directly as the on-disk file identifier.
|
||||
///
|
||||
/// Return: confirmation string on success; error if name is invalid or the write fails.
|
||||
fn run(&self, ctx: &ToolCtx, args: &Value) -> Result<String> {
|
||||
let name = args.get("name")
|
||||
.and_then(|v| v.as_str())
|
||||
|
||||
Reference in New Issue
Block a user