Skip to main content

acp_cli/output/
mod.rs

1pub mod json;
2pub mod quiet;
3pub mod text;
4
5pub trait OutputRenderer {
6    fn text_chunk(&mut self, text: &str);
7    fn tool_status(&mut self, tool: &str);
8    fn tool_result(&mut self, tool: &str, output: &str);
9    fn permission_denied(&mut self, tool: &str);
10    fn error(&mut self, err: &str);
11    fn session_info(&mut self, id: &str);
12    fn done(&mut self);
13}
14
15/// Returns `true` for tool names that perform file reads.
16///
17/// Used to decide whether `--suppress-reads` should hide the tool output.
18/// The list is intentionally exhaustive and case-sensitive. When adding
19/// support for a new agent whose read tool has a different name, add the
20/// exact name string here — do not use case-insensitive matching, as that
21/// would risk misidentifying non-read tools with similar names.
22pub fn is_read_tool(name: &str) -> bool {
23    matches!(
24        name,
25        "Read" | "read_file" | "readFile" | "fs/read" | "read" | "view_file"
26    )
27}
28
29#[cfg(test)]
30mod tests {
31    use super::*;
32
33    #[test]
34    fn read_tool_names_are_detected() {
35        assert!(is_read_tool("Read"));
36        assert!(is_read_tool("read_file"));
37        assert!(is_read_tool("readFile"));
38        assert!(is_read_tool("fs/read"));
39        assert!(is_read_tool("read"));
40        assert!(is_read_tool("view_file"));
41    }
42
43    #[test]
44    fn write_and_exec_tools_are_not_read_tools() {
45        assert!(!is_read_tool("Write"));
46        assert!(!is_read_tool("Bash"));
47        assert!(!is_read_tool("Edit"));
48        assert!(!is_read_tool("execute_command"));
49        assert!(!is_read_tool("search_files"));
50        assert!(!is_read_tool(""));
51    }
52}