diff --git a/src/main.rs b/src/main.rs index 47acab7..38e5052 100644 --- a/src/main.rs +++ b/src/main.rs @@ -575,7 +575,7 @@ fn main() -> Result<()> { exclude_filters: cli.exclude.clone(), strict: cli.strict, }; - if subprocess_plugins.execute(&command_str, &args, &[], options)? { + if subprocess_plugins.execute(&command_str, &args, &[], None, options)? { return Ok(()); } } @@ -656,7 +656,7 @@ fn handle_command_dispatch( strict: cli.strict, }; - if plugins.execute("git clone", &command_args, &[], subprocess_options)? { + if plugins.execute("git clone", &command_args, &[], None, subprocess_options)? { if cli.verbose { println!("{}", "Git clone handled by subprocess plugin.".green()); } @@ -755,7 +755,7 @@ fn handle_command_dispatch( spawn_stagger_ms: 0, env: None, max_parallel: None, - root_dir: None, // Worktree paths don't use "." convention + root_dir: Some(task_dir.clone()), }; // Try plugin dispatch first (full feature parity with normal path) @@ -776,6 +776,7 @@ fn handle_command_dispatch( &command_str, &command_args, &wt_directories, + Some(&task_dir), subprocess_options, )? { if cli.verbose { @@ -821,7 +822,7 @@ fn handle_command_dispatch( spawn_stagger_ms: 0, env: None, max_parallel: None, - root_dir: None, // Worktree paths don't use "." convention + root_dir: Some(task_dir.clone()), }; run(&config, &command_str)?; @@ -931,6 +932,7 @@ fn handle_command_dispatch( &command_str, &command_args, &project_paths, + Some(meta_dir), subprocess_options, )? { log::info!("Command was handled by subprocess plugin"); diff --git a/src/subprocess_plugins.rs b/src/subprocess_plugins.rs index ed8a2f9..f5c0d3a 100644 --- a/src/subprocess_plugins.rs +++ b/src/subprocess_plugins.rs @@ -201,6 +201,7 @@ impl SubprocessPluginManager { command: &str, args: &[String], projects: &[String], + root_dir: Option<&Path>, options: PluginRequestOptions, ) -> Result { let cmd_parts: Vec<&str> = command.split_whitespace().collect(); @@ -236,7 +237,7 @@ impl SubprocessPluginManager { } if let Some((plugin, matched_cmd)) = best_match { - return self.execute_plugin(plugin, matched_cmd, args, projects, &options); + return self.execute_plugin(plugin, matched_cmd, args, projects, root_dir, &options); } Ok(false) @@ -249,6 +250,7 @@ impl SubprocessPluginManager { command: &str, args: &[String], projects: &[String], + root_dir: Option<&Path>, options: &PluginRequestOptions, ) -> Result { // Extract the remaining args after the matched command @@ -313,7 +315,7 @@ impl SubprocessPluginManager { match serde_json::from_str::(&stdout_str) { Ok(response) => { // Plugin returned an execution plan - execute it via loop_lib - self.execute_plan(&response.plan, options) + self.execute_plan(&response.plan, root_dir, options) } Err(_) => { // Couldn't parse as our protocol - print output as-is (legacy behavior) @@ -324,7 +326,12 @@ impl SubprocessPluginManager { } /// Execute an execution plan via loop_lib - fn execute_plan(&self, plan: &ExecutionPlan, options: &PluginRequestOptions) -> Result { + fn execute_plan( + &self, + plan: &ExecutionPlan, + root_dir: Option<&Path>, + options: &PluginRequestOptions, + ) -> Result { use loop_lib::{run_commands, DirCommand, LoopConfig}; // Phase 1: Run pre_commands sequentially (setup tasks like SSH ControlMaster) @@ -379,8 +386,11 @@ impl SubprocessPluginManager { }) .collect(); - // The first command's directory is the meta root (should display as ".") - let root_dir = commands.first().map(|c| PathBuf::from(&c.dir)); + // Repos are named by their path from the root (shown as "."). Without + // projects from meta_cli the plugin lists the root first. + let root_dir = root_dir + .map(Path::to_path_buf) + .or_else(|| commands.first().map(|c| PathBuf::from(&c.dir))); let config = LoopConfig { directories: vec![],