diff --git a/src/agent.rs b/src/agent.rs index 4763b36..25aef1f 100644 --- a/src/agent.rs +++ b/src/agent.rs @@ -3,6 +3,8 @@ use std::collections::HashSet; use serde_json::json; use crate::claude::{self, StreamEvent, StatusKind}; +const MAX_OUTPUT: usize = 50_000; + #[derive(Clone, PartialEq)] pub enum AgentStatus { Thinking, @@ -124,7 +126,14 @@ impl Agent { self.dirty = true; match event { StreamEvent::StreamStart => {} - StreamEvent::Chunk(text) => self.output.push_str(&text), + StreamEvent::Chunk(text) => { + self.output.push_str(&text); + if self.output.len() > MAX_OUTPUT { + let trim = self.output.len() - MAX_OUTPUT; + let boundary = self.output[trim..].find('\n').map(|i| trim + i + 1).unwrap_or(trim); + self.output.drain(..boundary); + } + } StreamEvent::StreamEnd => { self.log("response", &format!("{}chars", self.output.len())); } diff --git a/src/config.rs b/src/config.rs index 151b045..ff10a65 100644 --- a/src/config.rs +++ b/src/config.rs @@ -32,6 +32,11 @@ pub fn preset(name: &str) -> Option> { AgentConfig { name: "bug-hunt".into(), task: "Find one concrete bug in the codebase. Give file:line and a fix.".into(), cwd: cwd.clone() }, AgentConfig { name: "simplify".into(), task: "Find one function that can be removed or simplified. Be specific.".into(), cwd }, ]), + "report" => Some(vec![ + AgentConfig { name: "agent-view".into(), task: "You are an agent inside aishell. Reflect: What context did you receive? What was missing? What would make your job easier? 3 concrete points from your perspective.".into(), cwd: cwd.clone() }, + AgentConfig { name: "user-view".into(), task: "You are a developer using aishell daily. Run aishell help and aishell context. What are the 3 biggest friction points in the daily workflow?".into(), cwd: cwd.clone() }, + AgentConfig { name: "system-view".into(), task: "Read src/headless.rs and src/tui.rs. From the system's perspective: what is the most fragile part? What would break first under heavy use? One concrete issue.".into(), cwd }, + ]), _ => None, } } diff --git a/src/headless.rs b/src/headless.rs index cf96b31..ad3af74 100644 --- a/src/headless.rs +++ b/src/headless.rs @@ -917,7 +917,17 @@ pub fn context() { println!("status:\n{git_status}"); } if !git_diff.is_empty() { - println!("diff:\n{git_diff}"); + println!("diff stat:\n{git_diff}"); + let git_diff_content = run("git", &["diff", "HEAD"]); + if !git_diff_content.is_empty() { + let truncated: String = git_diff_content.lines().take(30) + .collect::>().join("\n"); + let total = git_diff_content.lines().count(); + println!("diff content:\n{truncated}"); + if total > 30 { + println!("... ({} more lines)", total - 30); + } + } } println!("recent:\n{git_log}"); diff --git a/src/main.rs b/src/main.rs index 4bf1407..429731c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -134,7 +134,7 @@ fn print_help() { println!("USAGE:"); println!(" aishell TUI (AI + Agents + Shell)"); println!(" aishell run Run single agent"); - println!(" aishell run -p Preset: daily, review, improve"); + println!(" aishell run -p Preset: daily, review, improve, report"); println!(" aishell run -f Custom config file"); println!(" aishell commit Git commit with AI-suggested message"); println!(" aishell status [-v] Show agent status"); diff --git a/src/tui.rs b/src/tui.rs index a063e20..6b7cafd 100644 --- a/src/tui.rs +++ b/src/tui.rs @@ -9,6 +9,7 @@ use crate::config::AgentConfig; use crate::judge::{self, CommandCache}; const STATE_DIR: &str = "/tmp/aishell"; +const MAX_OUTPUT: usize = 50_000; // ── App state ────────────────────────────────────────────── @@ -131,6 +132,11 @@ impl App { } OutputEvent::StreamChunk(text) => { self.ai_output.push_str(&text); + if self.ai_output.len() > MAX_OUTPUT { + let trim = self.ai_output.len() - MAX_OUTPUT; + let boundary = self.ai_output[trim..].find('\n').map(|i| trim + i + 1).unwrap_or(trim); + self.ai_output.drain(..boundary); + } self.ai_scroll = u16::MAX; } OutputEvent::StreamEnd => {