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 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() {
|
||||
|
||||
Reference in New Issue
Block a user