Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl PlanManager {
}

pub fn get_plan(&self) -> Option<Plan> {
self.current_plan.lock().unwrap().clone()
self.current_plan.lock().ok()?.clone()
}

pub fn set_plan(&self, plan: Plan) {
Expand Down
9 changes: 4 additions & 5 deletions src/tools/create_directory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub struct CreateDirectoryOutput {
pub created_parents: bool,
}

#[derive(Deserialize, Serialize)]
#[derive(Deserialize, Serialize, Default)]
pub struct CreateDirectoryTool;

impl Tool for CreateDirectoryTool {
Expand Down Expand Up @@ -67,7 +67,7 @@ impl Tool for CreateDirectoryTool {
}

// Check if we need to create parent directories
let needs_parents = path.parent().map_or(false, |parent| !parent.exists());
let needs_parents = path.parent().is_some_and(|parent| !parent.exists());

// Create the directory and all parent directories
match fs::create_dir_all(dir_path) {
Expand All @@ -94,7 +94,7 @@ impl Tool for CreateDirectoryTool {
}
}

#[derive(Deserialize, Serialize)]
#[derive(Deserialize, Serialize, Default)]
pub struct WrappedCreateDirectoryTool {
inner: CreateDirectoryTool,
}
Expand All @@ -119,8 +119,7 @@ impl Tool for WrappedCreateDirectoryTool {
}

async fn call(&self, args: Self::Args) -> Result<Self::Output, Self::Error> {
println!();
println!("{} {}({})", "●".bright_green(), "CreateDir", args.dir_path);
println!("\n{} CreateDir({})", "●".bright_green(), args.dir_path);

let result = self.inner.call(args).await;

Expand Down
7 changes: 3 additions & 4 deletions src/tools/delete_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub struct DeleteFileOutput {
pub message: String,
}

#[derive(Deserialize, Serialize)]
#[derive(Deserialize, Serialize, Default)]
pub struct DeleteFileTool;

impl Tool for DeleteFileTool {
Expand Down Expand Up @@ -74,7 +74,7 @@ impl Tool for DeleteFileTool {
}
}
}
#[derive(Deserialize, Serialize)]
#[derive(Deserialize, Serialize, Default)]
pub struct WrappedDeleteFileTool {
inner: DeleteFileTool,
}
Expand All @@ -99,8 +99,7 @@ impl Tool for WrappedDeleteFileTool {
}

async fn call(&self, args: Self::Args) -> Result<Self::Output, Self::Error> {
println!();
println!("{} {}({})", "●".bright_green(), "Delete", args.file_path);
println!("\n{} Delete({})", "●".bright_green(), args.file_path);

let result = self.inner.call(args).await;

Expand Down
7 changes: 3 additions & 4 deletions src/tools/edit_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub struct EditFileOutput {
pub message: String,
}

#[derive(Deserialize, Serialize)]
#[derive(Deserialize, Serialize, Default)]
pub struct EditFileTool;

impl Tool for EditFileTool {
Expand Down Expand Up @@ -123,7 +123,7 @@ impl Tool for EditFileTool {
}
}

#[derive(Deserialize, Serialize)]
#[derive(Deserialize, Serialize, Default)]
pub struct WrappedEditFileTool {
inner: EditFileTool,
}
Expand All @@ -148,8 +148,7 @@ impl Tool for WrappedEditFileTool {
}

async fn call(&self, args: Self::Args) -> Result<Self::Output, Self::Error> {
println!();
println!("{} {}({})", "●".bright_green(), "Edit", args.file_path);
println!("\n{} Edit({})", "●".bright_green(), args.file_path);

let result = self.inner.call(args).await;

Expand Down
7 changes: 3 additions & 4 deletions src/tools/execute_bash_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub struct ExecuteBashCommandOutput {
pub exit_code: Option<i32>,
}

#[derive(Deserialize, Serialize)]
#[derive(Deserialize, Serialize, Default)]
pub struct ExecuteBashCommandTool;

impl Tool for ExecuteBashCommandTool {
Expand Down Expand Up @@ -75,7 +75,7 @@ impl Tool for ExecuteBashCommandTool {
}
}

#[derive(Deserialize, Serialize)]
#[derive(Deserialize, Serialize, Default)]
pub struct WrappedExecuteBashCommandTool {
inner: ExecuteBashCommandTool,
}
Expand All @@ -100,8 +100,7 @@ impl Tool for WrappedExecuteBashCommandTool {
}

async fn call(&self, args: Self::Args) -> Result<Self::Output, Self::Error> {
println!();
println!("{} {}({})", "●".bright_green(), "Exec", args.command);
println!("\n{} Exec({})", "●".bright_green(), args.command);

let result = self.inner.call(args).await;

Expand Down
8 changes: 4 additions & 4 deletions src/tools/grep_search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub struct GrepSearchOutput {
pub message: String,
}

#[derive(Deserialize, Serialize)]
#[derive(Deserialize, Serialize, Default)]
pub struct GrepSearchTool;

impl Tool for GrepSearchTool {
Expand Down Expand Up @@ -85,7 +85,7 @@ impl Tool for GrepSearchTool {
Err(_) => continue, // Skip entries we can't access
};

if entry.file_type().map_or(false, |ft| ft.is_file()) {
if entry.file_type().is_some_and(|ft| ft.is_file()) {
files_searched += 1;

if let Ok(content) = fs::read_to_string(entry.path()) {
Expand Down Expand Up @@ -127,7 +127,7 @@ impl Tool for GrepSearchTool {
}

// Wrapper with visual feedback
#[derive(Deserialize, Serialize)]
#[derive(Deserialize, Serialize, Default)]
pub struct WrappedGrepSearchTool {
inner: GrepSearchTool,
}
Expand All @@ -151,7 +151,7 @@ impl Tool for WrappedGrepSearchTool {
}

async fn call(&self, args: Self::Args) -> Result<Self::Output, Self::Error> {
println!("{} {}({})", "●".bright_green(), "Search", args.query);
println!("\n{} Search({})", "●".bright_green(), args.query);

let result = self.inner.call(args).await;

Expand Down
7 changes: 3 additions & 4 deletions src/tools/read_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub struct ReadFileOutput {
pub message: String,
}

#[derive(Deserialize, Serialize)]
#[derive(Deserialize, Serialize, Default)]
pub struct ReadFileTool;

impl Tool for ReadFileTool {
Expand Down Expand Up @@ -88,7 +88,7 @@ impl Tool for ReadFileTool {
}
}
// 在工具调用前后显示信息
#[derive(Deserialize, Serialize)]
#[derive(Deserialize, Serialize, Default)]
pub struct WrappedReadFileTool {
inner: ReadFileTool,
}
Expand All @@ -113,8 +113,7 @@ impl Tool for WrappedReadFileTool {
}

async fn call(&self, args: Self::Args) -> Result<Self::Output, Self::Error> {
println!();
println!("{} {}({})", "●".bright_green(), "Read", args.file_path);
println!("\n{} Read({})", "●".bright_green(), args.file_path);

let result = self.inner.call(args).await;

Expand Down
12 changes: 5 additions & 7 deletions src/tools/scan_codebase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ pub struct ScanCodebaseOutput {
pub total_directories: usize,
}

#[derive(Deserialize, Serialize)]
#[derive(Deserialize, Serialize, Default)]
pub struct ScanCodebaseTool;

impl ScanCodebaseTool {
fn scan_directory(
&self,
path: &Path,
prefix: &str,
max_depth: usize,
Expand Down Expand Up @@ -72,7 +71,7 @@ impl ScanCodebaseTool {
result.push_str(&format!("{}{}{}\n", prefix, current_prefix, file_name_str));
dir_count += 1;

let (sub_result, sub_files, sub_dirs) = self.scan_directory(
let (sub_result, sub_files, sub_dirs) = Self::scan_directory(
&entry.path(),
&format!("{}{}", prefix, next_prefix),
max_depth,
Expand Down Expand Up @@ -136,7 +135,7 @@ impl Tool for ScanCodebaseTool {
.unwrap_or_else(|| std::ffi::OsStr::new(root_path))
.to_string_lossy()
);
let (tree_result, file_count, dir_count) = self.scan_directory(path, "", 5, 0)?;
let (tree_result, file_count, dir_count) = Self::scan_directory(path, "", 5, 0)?;
structure.push_str(&tree_result);

Ok(ScanCodebaseOutput {
Expand All @@ -148,7 +147,7 @@ impl Tool for ScanCodebaseTool {
}
}

#[derive(Deserialize, Serialize)]
#[derive(Deserialize, Serialize, Default)]
pub struct WrappedScanCodebaseTool {
inner: ScanCodebaseTool,
}
Expand All @@ -173,8 +172,7 @@ impl Tool for WrappedScanCodebaseTool {
}

async fn call(&self, args: Self::Args) -> Result<Self::Output, Self::Error> {
println!();
println!("{} {}({})", "●".bright_green(), "Scan", args.root_path);
println!("\n{} Scan({})", "●".bright_green(), args.root_path);

let result = self.inner.call(args).await;

Expand Down
3 changes: 1 addition & 2 deletions src/tools/update_plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,7 @@ impl Tool for WrappedUpdatePlanTool {
UpdatePlanArgs::Clear => "Clear Plan",
};

println!();
println!("{} {}", "●".bright_blue(), action_name);
println!("\n{} {}", "●".bright_blue(), action_name);

let result = self.inner.as_ref().unwrap().call(args).await;

Expand Down
7 changes: 3 additions & 4 deletions src/tools/write_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub struct WriteFileOutput {
pub message: String,
}

#[derive(Deserialize, Serialize)]
#[derive(Deserialize, Serialize, Default)]
pub struct WriteFileTool;

impl Tool for WriteFileTool {
Expand Down Expand Up @@ -85,7 +85,7 @@ impl Tool for WriteFileTool {
}
}
}
#[derive(Deserialize, Serialize)]
#[derive(Deserialize, Serialize, Default)]
pub struct WrappedWriteFileTool {
inner: WriteFileTool,
}
Expand All @@ -110,8 +110,7 @@ impl Tool for WrappedWriteFileTool {
}

async fn call(&self, args: Self::Args) -> Result<Self::Output, Self::Error> {
println!();
println!("{} {}({})", "●".bright_green(), "Write", args.file_path);
println!("\n{} Write({})", "●".bright_green(), args.file_path);

// Store line count before moving args
let line_count = args.content.lines().count();
Expand Down