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:
asepharyana
2026-07-12 11:28:39 +07:00
parent 7158d362fd
commit 2efd40ca88
124 changed files with 2379 additions and 19 deletions
+25
View File
@@ -1,3 +1,5 @@
//! Text search tools: `grep` (line matching) and `glob` (filename pattern matching).
use std::fs;
use serde_json::{json, Value};
use anyhow::{Result, anyhow};
@@ -7,6 +9,7 @@ use super::Tool;
use super::ToolCtx;
use super::resolve_path;
/// Tool that recursively searches text files under a directory for a literal substring.
pub struct Grep;
impl Tool for Grep {
@@ -35,6 +38,16 @@ impl Tool for Grep {
})
}
/// Recursively walk the resolved directory and collect matching lines.
///
/// Flow: extract `pattern` + `path` → `resolve_path` (workspace-scoped) → bail if
/// missing/not a dir → `ignore::Walk` the tree → for each file, `read_to_string`
/// and substring-match each line → emit `<rel_path>:<line_no>:<text>` rows.
///
/// Why: `ignore::Walk` respects `.gitignore` and skips heavy dirs (e.g. `.git/`)
/// which is what the agent expects when running in real repos.
///
/// Return: "no matches found" if empty, else a header + `path:line:text` rows.
fn run(&self, ctx: &ToolCtx, args: &Value) -> Result<String> {
let pattern = args.get("pattern")
.and_then(|v| v.as_str())
@@ -80,6 +93,7 @@ impl Tool for Grep {
}
}
/// Tool that lists files under a directory matching a glob pattern.
pub struct Glob;
impl Tool for Glob {
@@ -108,6 +122,17 @@ impl Tool for Glob {
})
}
/// Walk the resolved directory and collect entries matching the glob pattern.
///
/// Flow: extract pattern + path → `resolve_path` → build a `GlobSet` from the
/// joined absolute pattern → `ignore::Walk` the tree → keep entries that
/// match → sort → join with newlines, appending `/` for directories.
///
/// Why: joining the workspace-relative pattern onto the resolved root lets users
/// supply familiar glob shapes (`**/*.rs`) while the sandbox still controls the
/// boundary.
///
/// Return: sorted newline-joined matches; "no files match" sentinel if empty.
fn run(&self, ctx: &ToolCtx, args: &Value) -> Result<String> {
let pat_str = args.get("pattern")
.and_then(|v| v.as_str())