Skip to content
This repository was archived by the owner on Nov 3, 2026. It is now read-only.
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
10 changes: 6 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(());
}
}
Expand Down Expand Up @@ -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());
}
Expand Down Expand Up @@ -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)
Expand All @@ -776,6 +776,7 @@ fn handle_command_dispatch(
&command_str,
&command_args,
&wt_directories,
Some(&task_dir),
subprocess_options,
)? {
if cli.verbose {
Expand Down Expand Up @@ -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)?;
Expand Down Expand Up @@ -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");
Expand Down
20 changes: 15 additions & 5 deletions src/subprocess_plugins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ impl SubprocessPluginManager {
command: &str,
args: &[String],
projects: &[String],
root_dir: Option<&Path>,
options: PluginRequestOptions,
) -> Result<bool> {
let cmd_parts: Vec<&str> = command.split_whitespace().collect();
Expand Down Expand Up @@ -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)
Expand All @@ -249,6 +250,7 @@ impl SubprocessPluginManager {
command: &str,
args: &[String],
projects: &[String],
root_dir: Option<&Path>,
options: &PluginRequestOptions,
) -> Result<bool> {
// Extract the remaining args after the matched command
Expand Down Expand Up @@ -313,7 +315,7 @@ impl SubprocessPluginManager {
match serde_json::from_str::<PluginResponse>(&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)
Expand All @@ -324,7 +326,12 @@ impl SubprocessPluginManager {
}

/// Execute an execution plan via loop_lib
fn execute_plan(&self, plan: &ExecutionPlan, options: &PluginRequestOptions) -> Result<bool> {
fn execute_plan(
&self,
plan: &ExecutionPlan,
root_dir: Option<&Path>,
options: &PluginRequestOptions,
) -> Result<bool> {
use loop_lib::{run_commands, DirCommand, LoopConfig};

// Phase 1: Run pre_commands sequentially (setup tasks like SSH ControlMaster)
Expand Down Expand Up @@ -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![],
Expand Down
Loading