refactor: clean up tool dispatch and extract helpers

- Move working_stack tool to tools/working_stack.rs (was orphaned in agent.rs)
- Create control.rs for pause/switch_model/yield_to_user with Result<ToolOutput>
- Add ToolOutput::error() and ToolOutput::text() helper constructors
- Clean up dispatch() with Option<Result<ToolOutput>> pattern for rich tools
- Refactor memory.rs: extract cmd(), write_node(), supersede(), get_str(), get_f64()
- Merge run_rg() and run_grep() into unified run_search() in grep.rs
- Extract truncate_output() helper shared by bash, grep, glob tools

Net: -77 lines, better structure, less duplication
This commit is contained in:
Kent Overstreet 2026-03-21 15:18:53 -04:00
parent 3fd485a2e9
commit 45b7bba22a
6 changed files with 290 additions and 264 deletions

View file

@ -168,13 +168,7 @@ pub async fn run_bash(args: &serde_json::Value, tracker: &ProcessTracker) -> Res
result = "(no output)".to_string();
}
const MAX_OUTPUT: usize = 30000;
if result.len() > MAX_OUTPUT {
result.truncate(MAX_OUTPUT);
result.push_str("\n... (output truncated)");
}
Ok(result)
Ok(super::truncate_output(result, 30000))
}
Ok(Err(e)) => {
Err(anyhow::anyhow!("Command failed: {}", e))