From 8b723ac4f2759c7d58071e29a68fbf8935f43eeb Mon Sep 17 00:00:00 2001 From: wuyangji <694410194@qq.com> Date: Thu, 14 May 2026 08:56:11 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix(plugin):=20=E8=A1=A5=E5=85=85=20remove?= =?UTF-8?q?=20=E8=B0=83=E8=AF=95=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cortex-cli/src/plugin_cmd.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/cortex-cli/src/plugin_cmd.rs b/src/cortex-cli/src/plugin_cmd.rs index 3ce99f238..526297600 100644 --- a/src/cortex-cli/src/plugin_cmd.rs +++ b/src/cortex-cli/src/plugin_cmd.rs @@ -1147,6 +1147,13 @@ async fn run_remove(args: PluginRemoveArgs) -> Result<()> { let plugins_dir = get_plugins_dir(); let plugin_path = plugins_dir.join(&args.name); + tracing::debug!( + plugin = %args.name, + plugins_dir = %plugins_dir.display(), + plugin_path = %plugin_path.display(), + "Preparing to remove plugin" + ); + if !plugin_path.exists() { bail!("Plugin '{}' is not installed.", args.name); } @@ -1159,12 +1166,14 @@ async fn run_remove(args: PluginRemoveArgs) -> Result<()> { let mut input = String::new(); std::io::stdin().read_line(&mut input)?; if !input.trim().eq_ignore_ascii_case("y") { + tracing::debug!(plugin = %args.name, "Plugin removal aborted by user"); println!("Aborted."); return Ok(()); } } std::fs::remove_dir_all(&plugin_path)?; + tracing::debug!(plugin = %args.name, "Plugin directory removed successfully"); println!("Plugin '{}' removed successfully.", args.name); Ok(()) } From 6ccb5be521d312b05524747962475f8b870ac1ec Mon Sep 17 00:00:00 2001 From: wuyangji <694410194@qq.com> Date: Thu, 14 May 2026 09:28:07 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix(exec):=20=E8=AE=A9=20file=20=E7=9B=B8?= =?UTF-8?q?=E5=AF=B9=E8=B7=AF=E5=BE=84=E8=B7=9F=E9=9A=8F=20cwd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cortex-cli/src/exec_cmd/runner.rs | 52 +++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/src/cortex-cli/src/exec_cmd/runner.rs b/src/cortex-cli/src/exec_cmd/runner.rs index a9f521ec2..f4efdece3 100644 --- a/src/cortex-cli/src/exec_cmd/runner.rs +++ b/src/cortex-cli/src/exec_cmd/runner.rs @@ -1,7 +1,7 @@ //! Execution runner for exec mode. use std::io::{self, BufRead, IsTerminal, Read, Write}; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use std::time::{Duration, Instant}; use anyhow::{Context, Result, bail}; @@ -82,9 +82,15 @@ impl ExecCli { // Read from file if specified if let Some(ref file_path) = self.file { - let content = tokio::fs::read_to_string(file_path) + let resolved_file_path = resolve_prompt_file_path(file_path, self.cwd.as_deref()); + let content = tokio::fs::read_to_string(&resolved_file_path) .await - .with_context(|| format!("Failed to read prompt file: {}", file_path.display()))?; + .with_context(|| { + format!( + "Failed to read prompt file: {}", + resolved_file_path.display() + ) + })?; prompt.push_str(&content); } @@ -852,3 +858,43 @@ impl ExecCli { Ok(()) } } + +fn resolve_prompt_file_path(file_path: &Path, cwd: Option<&Path>) -> PathBuf { + if file_path.is_absolute() { + file_path.to_path_buf() + } else if let Some(cwd) = cwd { + cwd.join(file_path) + } else { + file_path.to_path_buf() + } +} + +#[cfg(test)] +mod tests { + use super::resolve_prompt_file_path; + use std::path::{Path, PathBuf}; + + #[test] + fn resolve_prompt_file_path_uses_cwd_for_relative_paths() { + let cwd = PathBuf::from("workspace").join("nested"); + let resolved = resolve_prompt_file_path(Path::new("script.sh"), Some(&cwd)); + + assert_eq!(resolved, cwd.join("script.sh")); + } + + #[test] + fn resolve_prompt_file_path_keeps_absolute_paths() { + let absolute_file_path = std::env::temp_dir().join("script.sh"); + let resolved = + resolve_prompt_file_path(&absolute_file_path, Some(Path::new("workspace/nested"))); + + assert_eq!(resolved, absolute_file_path); + } + + #[test] + fn resolve_prompt_file_path_keeps_relative_path_without_cwd() { + let resolved = resolve_prompt_file_path(Path::new("script.sh"), None); + + assert_eq!(resolved, Path::new("script.sh")); + } +}