Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

feat(config): install the Codex plugin, not just its marketplace (#4019)

Worktrunk Botfb6576946abc
diff --git a/docs/src/content/docs/claude-code.md b/docs/src/content/docs/claude-code.md
index d458e724b..836e38868 100644
--- a/docs/src/content/docs/claude-code.md
+++ b/docs/src/content/docs/claude-code.md
@@ -30,19 +30,22 @@ claude plugin marketplace add max-sixty/worktrunk
claude plugin install worktrunk@worktrunk
```
+`wt config plugins claude uninstall` removes the plugin and its marketplace entry.
+
### Codex
```bash
wt config plugins codex install
```
-This configures the Worktrunk marketplace in Codex. Then run `/plugins` in Codex and install Worktrunk from the marketplace. Manual equivalent:
+Manual equivalent:
```bash
codex plugin marketplace add max-sixty/worktrunk
+codex plugin add worktrunk@worktrunk
```
-To remove the marketplace entry, run `wt config plugins codex uninstall`. Already-installed plugins are left unchanged.
+`wt config plugins codex uninstall` removes the plugin and its marketplace entry.
### OpenCode
diff --git a/plugins/worktrunk/skills/worktrunk/reference/claude-code.md b/plugins/worktrunk/skills/worktrunk/reference/claude-code.md
index f90248558..c875e238d 100644
--- a/plugins/worktrunk/skills/worktrunk/reference/claude-code.md
+++ b/plugins/worktrunk/skills/worktrunk/reference/claude-code.md
@@ -26,19 +26,22 @@ claude plugin marketplace add max-sixty/worktrunk
claude plugin install worktrunk@worktrunk
```
+`wt config plugins claude uninstall` removes the plugin and its marketplace entry.
+
### Codex
```bash
wt config plugins codex install
```
-This configures the Worktrunk marketplace in Codex. Then run `/plugins` in Codex and install Worktrunk from the marketplace. Manual equivalent:
+Manual equivalent:
```bash
codex plugin marketplace add max-sixty/worktrunk
+codex plugin add worktrunk@worktrunk
```
-To remove the marketplace entry, run `wt config plugins codex uninstall`. Already-installed plugins are left unchanged.
+`wt config plugins codex uninstall` removes the plugin and its marketplace entry.
### OpenCode
diff --git a/skills/worktrunk/reference/claude-code.md b/skills/worktrunk/reference/claude-code.md
index f90248558..c875e238d 100644
--- a/skills/worktrunk/reference/claude-code.md
+++ b/skills/worktrunk/reference/claude-code.md
@@ -26,19 +26,22 @@ claude plugin marketplace add max-sixty/worktrunk
claude plugin install worktrunk@worktrunk
```
+`wt config plugins claude uninstall` removes the plugin and its marketplace entry.
+
### Codex
```bash
wt config plugins codex install
```
-This configures the Worktrunk marketplace in Codex. Then run `/plugins` in Codex and install Worktrunk from the marketplace. Manual equivalent:
+Manual equivalent:
```bash
codex plugin marketplace add max-sixty/worktrunk
+codex plugin add worktrunk@worktrunk
```
-To remove the marketplace entry, run `wt config plugins codex uninstall`. Already-installed plugins are left unchanged.
+`wt config plugins codex uninstall` removes the plugin and its marketplace entry.
### OpenCode
diff --git a/src/cli/config.rs b/src/cli/config.rs
index 4003c29ae..2dc298a41 100644
--- a/src/cli/config.rs
+++ b/src/cli/config.rs
@@ -243,27 +243,29 @@ $ wt config plugins pi uninstall
// Ordering: action + inverse adjacent (install, uninstall).
#[derive(Subcommand)]
pub enum ConfigPluginsCodexCommand {
- /// Configure the Worktrunk marketplace in Codex
+ /// Install the Worktrunk plugin
#[command(
- after_long_help = r#"Configures the Worktrunk plugin marketplace in Codex. Equivalent to:
+ after_long_help = r#"Adds the Worktrunk plugin from the marketplace and installs it. Equivalent to:
```console
$ codex plugin marketplace add max-sixty/worktrunk
+$ codex plugin add worktrunk@worktrunk
```
-This does not install the plugin by itself. Afterward, open `/plugins` in Codex and install Worktrunk from the marketplace."#
+Requires `codex` CLI."#
)]
Install,
- /// Remove the Worktrunk marketplace from Codex
+ /// Remove the Worktrunk plugin
#[command(
- after_long_help = r#"Removes the Worktrunk plugin marketplace from Codex. Equivalent to:
+ after_long_help = r#"Uninstalls the Worktrunk plugin from Codex and removes its marketplace. Equivalent to:
```console
+$ codex plugin remove worktrunk@worktrunk
$ codex plugin marketplace remove worktrunk
```
-This leaves any already-installed Worktrunk plugin unchanged."#
+Requires `codex` CLI."#
)]
Uninstall,
}
@@ -440,10 +442,11 @@ Requires `claude` CLI. Skips gracefully if already installed."#
/// Remove the Worktrunk plugin
#[command(
- after_long_help = r#"Uninstalls the Worktrunk plugin from Claude Code. Equivalent to:
+ after_long_help = r#"Uninstalls the Worktrunk plugin from Claude Code and removes its marketplace. Skips gracefully if the plugin is not installed, leaving the marketplace in place. Equivalent to:
```console
$ claude plugin uninstall worktrunk@worktrunk
+$ claude plugin marketplace remove worktrunk
```"#
)]
Uninstall,
diff --git a/src/commands/config/codex.rs b/src/commands/config/codex.rs
index 6d44b7483..0edc337c9 100644
--- a/src/commands/config/codex.rs
+++ b/src/commands/config/codex.rs
@@ -1,4 +1,4 @@
-//! Codex plugin marketplace management.
+//! Codex plugin and marketplace management.
use anyhow::{Result, bail};
use color_print::cformat;
@@ -9,6 +9,8 @@ use crate::output::prompt::{PromptResponse, prompt_yes_no_preview};
const MARKETPLACE_SOURCE: &str = "max-sixty/worktrunk";
const MARKETPLACE_NAME: &str = "worktrunk";
+/// `PLUGIN@MARKETPLACE` selector `codex plugin add` / `remove` take.
+const PLUGIN_SELECTOR: &str = "worktrunk@worktrunk";
/// Handle `wt config plugins codex install`.
pub fn handle_codex_install(yes: bool) -> Result<()> {
@@ -16,9 +18,11 @@ pub fn handle_codex_install(yes: bool) -> Result<()> {
if !yes {
match prompt_yes_no_preview(
- &cformat!("Add Worktrunk plugin marketplace to <bold>Codex</>?"),
+ &cformat!("Install Worktrunk plugin for <bold>Codex</>?"),
|| {
- let commands = format!("codex plugin marketplace add {MARKETPLACE_SOURCE}");
+ let commands = format!(
+ "codex plugin marketplace add {MARKETPLACE_SOURCE}\ncodex plugin add {PLUGIN_SELECTOR}"
+ );
eprintln!("{}", worktrunk::styling::format_bash_with_gutter(&commands));
},
)? {
@@ -33,11 +37,10 @@ pub fn handle_codex_install(yes: bool) -> Result<()> {
&["plugin", "marketplace", "add", MARKETPLACE_SOURCE],
)?;
- eprintln!("{}", success_message("Codex marketplace configured"));
- eprintln!(
- "{}",
- hint_message("Next, run /plugins in Codex and install Worktrunk from the marketplace")
- );
+ eprintln!("{}", progress_message("Installing plugin..."));
+ super::run_plugin_cli("codex", &["plugin", "add", PLUGIN_SELECTOR])?;
+
+ eprintln!("{}", success_message("Codex plugin installed"));
// The Codex plugin ships activity-marker hooks inline in its manifest
// (`hooks` key in .codex-plugin/plugin.json), using `Stop` to return
// πŸ€– β†’ πŸ’¬ and `SessionEnd` to clear the marker. See CLAUDE.md β†’ "Plugin
@@ -58,14 +61,12 @@ pub fn handle_codex_uninstall(yes: bool) -> Result<()> {
if !yes {
match prompt_yes_no_preview(
- &cformat!("Remove Worktrunk plugin marketplace from <bold>Codex</>?"),
+ &cformat!("Uninstall Worktrunk plugin from <bold>Codex</>?"),
|| {
- eprintln!(
- "{}",
- worktrunk::styling::format_bash_with_gutter(
- "codex plugin marketplace remove worktrunk"
- )
+ let commands = format!(
+ "codex plugin remove {PLUGIN_SELECTOR}\ncodex plugin marketplace remove {MARKETPLACE_NAME}"
);
+ eprintln!("{}", worktrunk::styling::format_bash_with_gutter(&commands));
},
)? {
PromptResponse::Accepted => {}
@@ -73,6 +74,9 @@ pub fn handle_codex_uninstall(yes: bool) -> Result<()> {
}
}
+ eprintln!("{}", progress_message("Uninstalling plugin..."));
+ super::run_plugin_cli("codex", &["plugin", "remove", PLUGIN_SELECTOR])?;
+
eprintln!(
"{}",
progress_message("Removing Codex plugin marketplace...")
@@ -82,8 +86,7 @@ pub fn handle_codex_uninstall(yes: bool) -> Result<()> {
&["plugin", "marketplace", "remove", MARKETPLACE_NAME],
)?;
- eprintln!("{}", success_message("Codex marketplace removed"));
- eprintln!("{}", hint_message("Installed plugins are left unchanged"));
+ eprintln!("{}", success_message("Codex plugin & marketplace removed"));
Ok(())
}
diff --git a/src/commands/config/plugins.rs b/src/commands/config/plugins.rs
index 16758edf7..3a690ea0a 100644
--- a/src/commands/config/plugins.rs
+++ b/src/commands/config/plugins.rs
@@ -60,12 +60,8 @@ pub fn handle_claude_uninstall(yes: bool) -> anyhow::Result<()> {
match prompt_yes_no_preview(
&cformat!("Uninstall Worktrunk plugin from <bold>Claude Code</>?"),
|| {
- eprintln!(
- "{}",
- worktrunk::styling::format_bash_with_gutter(
- "claude plugin uninstall worktrunk@worktrunk"
- )
- );
+ let commands = "claude plugin uninstall worktrunk@worktrunk\nclaude plugin marketplace remove worktrunk";
+ eprintln!("{}", worktrunk::styling::format_bash_with_gutter(commands));
},
)? {
PromptResponse::Accepted => {}
@@ -76,7 +72,13 @@ pub fn handle_claude_uninstall(yes: bool) -> anyhow::Result<()> {
eprintln!("{}", progress_message("Uninstalling plugin..."));
super::run_plugin_cli("claude", &["plugin", "uninstall", "worktrunk@worktrunk"])?;
- eprintln!("{}", success_message("Plugin uninstalled"));
+ eprintln!(
+ "{}",
+ progress_message("Removing Claude Code plugin marketplace...")
+ );
+ super::run_plugin_cli("claude", &["plugin", "marketplace", "remove", "worktrunk"])?;
+
+ eprintln!("{}", success_message("Plugin & marketplace removed"));
Ok(())
}
diff --git a/src/commands/config/show.rs b/src/commands/config/show.rs
index 444f9813b..d055bad1a 100644
--- a/src/commands/config/show.rs
+++ b/src/commands/config/show.rs
@@ -308,7 +308,7 @@ fn render_claude_code_status(out: &mut String) -> anyhow::Result<()> {
Ok(())
}
-/// Render CODEX section (marketplace install hint).
+/// Render CODEX section (plugin install hint).
/// Caller must check `is_codex_available()` first.
fn render_codex_status(out: &mut String) -> anyhow::Result<()> {
writeln!(out, "{}", format_heading("CODEX", None))?;
diff --git a/src/testing/mod.rs b/src/testing/mod.rs
index 41239d0e9..e38f60168 100644
--- a/src/testing/mod.rs
+++ b/src/testing/mod.rs
@@ -2341,9 +2341,9 @@ impl TestRepo {
/// Setup mock `codex` CLI with plugin marketplace support
///
/// Creates a mock codex binary that handles `plugin marketplace add`,
- /// and `plugin marketplace remove` commands. Must call
- /// `setup_mock_ci_tools_unauthenticated()` first to create the mock bin
- /// directory.
+ /// `plugin marketplace remove`, `plugin add`, and `plugin remove`
+ /// commands. Must call `setup_mock_ci_tools_unauthenticated()` first to
+ /// create the mock bin directory.
pub fn setup_mock_codex_with_plugins(&mut self) {
let mock_bin = self
.mock_bin_path
@@ -2353,6 +2353,36 @@ impl TestRepo {
MockConfig::new("codex")
.command("plugin marketplace add", MockResponse::exit(0))
.command("plugin marketplace remove", MockResponse::exit(0))
+ .command("plugin add", MockResponse::exit(0))
+ .command("plugin remove", MockResponse::exit(0))
+ .write(mock_bin);
+
+ self.codex_installed = true;
+ }
+
+ /// Setup mock `codex` CLI whose marketplace commands succeed and whose
+ /// plugin commands fail
+ ///
+ /// Isolates a `codex plugin add` / `codex plugin remove` failure from the
+ /// marketplace step that runs beside it. Must call
+ /// `setup_mock_ci_tools_unauthenticated()` first.
+ pub fn setup_mock_codex_with_plugin_ops_failing(&mut self) {
+ let mock_bin = self
+ .mock_bin_path
+ .as_ref()
+ .expect("call setup_mock_ci_tools_unauthenticated() first");
+
+ MockConfig::new("codex")
+ .command("plugin marketplace add", MockResponse::exit(0))
+ .command("plugin marketplace remove", MockResponse::exit(0))
+ .command(
+ "plugin add",
+ MockResponse::exit(1).with_stderr("error: plugin add failed\n"),
+ )
+ .command(
+ "plugin remove",
+ MockResponse::exit(1).with_stderr("error: plugin remove failed\n"),
+ )
.write(mock_bin);
self.codex_installed = true;
@@ -2387,7 +2417,7 @@ impl TestRepo {
self.claude_installed = true;
}
- /// Setup mock `codex` CLI where marketplace commands fail
+ /// Setup mock `codex` CLI where marketplace and plugin commands fail
///
/// Must call `setup_mock_ci_tools_unauthenticated()` first.
pub fn setup_mock_codex_with_plugins_failing(&mut self) {
@@ -2405,6 +2435,14 @@ impl TestRepo {
"plugin marketplace remove",
MockResponse::exit(1).with_stderr("error: marketplace remove failed\n"),
)
+ .command(
+ "plugin add",
+ MockResponse::exit(1).with_stderr("error: plugin add failed\n"),
+ )
+ .command(
+ "plugin remove",
+ MockResponse::exit(1).with_stderr("error: plugin remove failed\n"),
+ )
.write(mock_bin);
self.codex_installed = true;
diff --git a/tests/integration_tests/config_show.rs b/tests/integration_tests/config_show.rs
index af13db2b3..fbf536fdb 100644
--- a/tests/integration_tests/config_show.rs
+++ b/tests/integration_tests/config_show.rs
@@ -4091,6 +4091,256 @@ fn test_plugins_codex_install_command_fails(mut repo: TestRepo, temp_home: TempD
});
}
+/// The marketplace registers but `codex plugin add` fails: the install stops
+/// there rather than reporting a plugin it never installed.
+#[rstest]
+fn test_plugins_codex_install_plugin_add_fails(mut repo: TestRepo, temp_home: TempDir) {
+ repo.setup_mock_ci_tools_unauthenticated();
+ repo.setup_mock_codex_with_plugin_ops_failing();
+
+ let settings = setup_snapshot_settings_with_home(&repo, &temp_home);
+ settings.bind(|| {
+ let mut cmd = repo.wt_command();
+ cmd.args(["config", "plugins", "codex", "install", "--yes"])
+ .current_dir(repo.root_path());
+ set_temp_home_env(&mut cmd, temp_home.path());
+
+ assert_cmd_snapshot!(cmd);
+ });
+}
+
+/// Run `wt config plugins <tool> <action>` and accept the prompt, returning the
+/// argv of every `<tool>` the run spawned β€” argv\[0\] excluded, as `mock_calls`
+/// records it.
+///
+/// The call log is the helper's own directory, so a caller looping over
+/// install and uninstall can't carry install's calls into uninstall's
+/// assertion. It lives outside the repo under test for the reason `mock_calls`
+/// documents: a log in the working tree would leave an untracked file behind
+/// the command being measured.
+fn plugin_calls_when_accepted(
+ repo: &TestRepo,
+ tool: &str,
+ action: &str,
+ home: &std::path::Path,
+) -> Vec<String> {
+ use crate::common::mock_commands::mock_calls;
+ use std::io::Write as _;
+ use std::process::Stdio;
+
+ let call_log = TempDir::new().unwrap();
+ let mut cmd = repo.wt_command();
+ cmd.args(["config", "plugins", tool, action])
+ .current_dir(repo.root_path())
+ .env("WORKTRUNK_TEST_MOCK_CALL_LOG_DIR", call_log.path())
+ .stdin(Stdio::piped())
+ .stdout(Stdio::piped())
+ .stderr(Stdio::piped());
+ set_temp_home_env(&mut cmd, home);
+
+ let mut child = cmd.spawn().unwrap();
+ child.stdin.take().unwrap().write_all(b"y\n").unwrap();
+ let output = child.wait_with_output().unwrap();
+ assert!(
+ output.status.success(),
+ "accepting {tool} {action}: {}",
+ String::from_utf8_lossy(&output.stderr)
+ );
+
+ mock_calls(call_log.path(), tool)
+}
+
+/// The `?` preview lists exactly the commands each Codex plugin subcommand
+/// runs: declining spawns none of them, and accepting spawns exactly those,
+/// so the confirmation the user answers matches what follows it.
+#[rstest]
+fn test_plugins_codex_prompt_previews_commands(mut repo: TestRepo, temp_home: TempDir) {
+ use crate::common::mock_commands::mock_calls;
+ use std::io::Write as _;
+ use std::process::Stdio;
+
+ repo.setup_mock_ci_tools_unauthenticated();
+ repo.setup_mock_codex_with_plugins();
+
+ // Outside the repo: a call log in the working tree would leave an
+ // untracked file behind the command under test.
+ let call_log = TempDir::new().unwrap();
+
+ for (action, expected) in [
+ (
+ "install",
+ [
+ "codex plugin marketplace add max-sixty/worktrunk",
+ "codex plugin add worktrunk@worktrunk",
+ ],
+ ),
+ (
+ "uninstall",
+ [
+ "codex plugin remove worktrunk@worktrunk",
+ "codex plugin marketplace remove worktrunk",
+ ],
+ ),
+ ] {
+ let mut cmd = repo.wt_command();
+ cmd.args(["config", "plugins", "codex", action])
+ .current_dir(repo.root_path())
+ .env("WORKTRUNK_TEST_MOCK_CALL_LOG_DIR", call_log.path())
+ .stdin(Stdio::piped())
+ .stdout(Stdio::piped())
+ .stderr(Stdio::piped());
+ set_temp_home_env(&mut cmd, temp_home.path());
+
+ let mut child = cmd.spawn().unwrap();
+ // `?` renders the preview; `n` then declines, so nothing runs.
+ child.stdin.take().unwrap().write_all(b"?\nn\n").unwrap();
+ let output = child.wait_with_output().unwrap();
+
+ let stderr = String::from_utf8_lossy(&output.stderr)
+ .ansi_strip()
+ .to_string();
+ // Compare the whole set of previewed commands, not each one in
+ // isolation: a command the preview lists but never runs is exactly
+ // what a per-command `contains` would let through.
+ // The first gutter line shares a line with the prompt, which `eprint!`
+ // leaves unterminated, so slice from each `codex ` rather than
+ // matching the line start.
+ let previewed: Vec<&str> = stderr
+ .lines()
+ .filter_map(|line| line.find("codex ").map(|i| line[i..].trim_end()))
+ .collect();
+ assert_eq!(previewed, expected, "{action} preview: {stderr}");
+ // The preview is only a preview: declining must leave codex unspawned.
+ let calls = mock_calls(call_log.path(), "codex");
+ assert!(
+ calls.is_empty(),
+ "declining {action} must spawn no codex: {calls:#?}"
+ );
+
+ // Both sides of the comparison above are the preview text, so nothing
+ // there observes the argv. Accepting the same prompt and reading the
+ // call log is what pins the preview to the spawn.
+ let ran = plugin_calls_when_accepted(&repo, "codex", action, temp_home.path());
+ // `mock_calls` records argv without argv[0]; `expected` carries the
+ // binary name because that is how the preview renders it.
+ let want: Vec<String> = expected
+ .iter()
+ .map(|c| c.strip_prefix("codex ").unwrap().to_string())
+ .collect();
+ assert_eq!(ran, want, "{action} ran: {ran:#?}");
+ }
+}
+
+/// The `?` preview lists exactly the commands each Claude plugin subcommand
+/// runs: declining spawns none of them, and accepting spawns exactly those,
+/// so the confirmation the user answers matches what follows it.
+#[rstest]
+fn test_plugins_claude_prompt_previews_commands(mut repo: TestRepo) {
+ use crate::common::mock_commands::mock_calls;
+ use std::io::Write as _;
+ use std::process::Stdio;
+
+ repo.setup_mock_ci_tools_unauthenticated();
+ repo.setup_mock_claude_with_plugins();
+
+ // Outside the repo: a call log in the working tree would leave an
+ // untracked file behind the command under test.
+ let call_log = TempDir::new().unwrap();
+
+ for (action, expected) in [
+ (
+ "install",
+ [
+ "claude plugin marketplace add max-sixty/worktrunk",
+ "claude plugin install worktrunk@worktrunk",
+ ],
+ ),
+ (
+ "uninstall",
+ [
+ "claude plugin uninstall worktrunk@worktrunk",
+ "claude plugin marketplace remove worktrunk",
+ ],
+ ),
+ ] {
+ // Each subcommand prompts only from the state it acts on, so the home
+ // is per-action: install returns early when the plugin is already
+ // installed, uninstall when it isn't.
+ let temp_home = TempDir::new().unwrap();
+ if action == "uninstall" {
+ TestRepo::setup_plugin_installed(temp_home.path());
+ }
+
+ let mut cmd = repo.wt_command();
+ cmd.args(["config", "plugins", "claude", action])
+ .current_dir(repo.root_path())
+ .env("WORKTRUNK_TEST_MOCK_CALL_LOG_DIR", call_log.path())
+ .stdin(Stdio::piped())
+ .stdout(Stdio::piped())
+ .stderr(Stdio::piped());
+ set_temp_home_env(&mut cmd, temp_home.path());
+
+ let mut child = cmd.spawn().unwrap();
+ // `?` renders the preview; `n` then declines, so nothing runs.
+ child.stdin.take().unwrap().write_all(b"?\nn\n").unwrap();
+ let output = child.wait_with_output().unwrap();
+
+ let stderr = String::from_utf8_lossy(&output.stderr)
+ .ansi_strip()
+ .to_string();
+ // Compare the whole set of previewed commands, not each one in
+ // isolation: a command the preview lists but never runs is exactly
+ // what a per-command `contains` would let through.
+ // The first gutter line shares a line with the prompt, which `eprint!`
+ // leaves unterminated, so slice from each `claude ` rather than
+ // matching the line start.
+ let previewed: Vec<&str> = stderr
+ .lines()
+ .filter_map(|line| line.find("claude ").map(|i| line[i..].trim_end()))
+ .collect();
+ assert_eq!(previewed, expected, "{action} preview: {stderr}");
+ // The preview is only a preview: declining must leave claude unspawned.
+ let calls = mock_calls(call_log.path(), "claude");
+ assert!(
+ calls.is_empty(),
+ "declining {action} must spawn no claude: {calls:#?}"
+ );
+
+ // Both sides of the comparison above are the preview text, so nothing
+ // there observes the argv. Accepting the same prompt and reading the
+ // call log is what pins the preview to the spawn β€” and it is the only
+ // thing that can here: `setup_mock_claude_with_plugins` registers the
+ // `plugin marketplace` prefix, which matches `add` and `remove` alike,
+ // so a wrong marketplace name still reaches the mock's exit 0.
+ let ran = plugin_calls_when_accepted(&repo, "claude", action, temp_home.path());
+ // `mock_calls` records argv without argv[0]; `expected` carries the
+ // binary name because that is how the preview renders it.
+ let want: Vec<String> = expected
+ .iter()
+ .map(|c| c.strip_prefix("claude ").unwrap().to_string())
+ .collect();
+ assert_eq!(ran, want, "{action} ran: {ran:#?}");
+ }
+}
+
+/// `codex plugin remove` fails: the uninstall surfaces codex's error and stops
+/// rather than removing the marketplace out from under an installed plugin.
+#[rstest]
+fn test_plugins_codex_uninstall_plugin_remove_fails(mut repo: TestRepo, temp_home: TempDir) {
+ repo.setup_mock_ci_tools_unauthenticated();
+ repo.setup_mock_codex_with_plugin_ops_failing();
+
+ let settings = setup_snapshot_settings_with_home(&repo, &temp_home);
+ settings.bind(|| {
+ let mut cmd = repo.wt_command();
+ cmd.args(["config", "plugins", "codex", "uninstall", "--yes"])
+ .current_dir(repo.root_path());
+ set_temp_home_env(&mut cmd, temp_home.path());
+
+ assert_cmd_snapshot!(cmd);
+ });
+}
+
#[test]
fn test_codex_plugin_metadata_is_valid_json() {
let project_root = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
@@ -5586,6 +5836,41 @@ fn test_plugins_claude_uninstall_command_fails(mut repo: TestRepo, temp_home: Te
});
}
+/// `claude plugin uninstall` succeeds and the marketplace removal that follows
+/// it fails: the uninstall surfaces claude's error rather than reporting a
+/// marketplace it never removed.
+#[rstest]
+fn test_plugins_claude_uninstall_second_step_fails(mut repo: TestRepo, temp_home: TempDir) {
+ use crate::common::mock_commands::{MockConfig, MockResponse};
+
+ repo.setup_mock_ci_tools_unauthenticated();
+ repo.setup_mock_claude_installed();
+ TestRepo::setup_plugin_installed(temp_home.path());
+
+ // Plugin uninstall succeeds and only the marketplace removal that follows
+ // it fails, so the error the command surfaces can come from nothing else.
+ let mock_bin = repo
+ .mock_bin_path()
+ .expect("setup_mock_ci_tools_unauthenticated creates mock-bin");
+ MockConfig::new("claude")
+ .command("plugin uninstall", MockResponse::exit(0))
+ .command(
+ "plugin marketplace remove",
+ MockResponse::exit(1).with_stderr("error: marketplace remove failed\n"),
+ )
+ .write(mock_bin);
+
+ let settings = setup_snapshot_settings_with_home(&repo, &temp_home);
+ settings.bind(|| {
+ let mut cmd = repo.wt_command();
+ cmd.args(["config", "plugins", "claude", "uninstall", "--yes"])
+ .current_dir(repo.root_path());
+ set_temp_home_env(&mut cmd, temp_home.path());
+
+ assert_cmd_snapshot!(cmd);
+ });
+}
+
// ==================== Plugin Prompt PTY Tests ====================
#[cfg(all(unix, feature = "shell-integration-tests"))]
@@ -5809,7 +6094,7 @@ mod plugin_prompt_pty {
"Should show prompt. Output:\n{output}"
);
assert!(
- output.contains("Plugin uninstalled"),
+ output.contains("Plugin & marketplace removed"),
"Should confirm uninstallation. Output:\n{output}"
);
}
@@ -5836,7 +6121,7 @@ mod plugin_prompt_pty {
"Should show prompt. Output:\n{output}"
);
assert!(
- !output.contains("Plugin uninstalled"),
+ !output.contains("Plugin & marketplace removed"),
"Should NOT uninstall when declined. Output:\n{output}"
);
}
diff --git a/tests/snapshots/integration__integration_tests__config_show__plugins_claude_uninstall.snap b/tests/snapshots/integration__integration_tests__config_show__plugins_claude_uninstall.snap
index a356ea2cf..4b849b580 100644
--- a/tests/snapshots/integration__integration_tests__config_show__plugins_claude_uninstall.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__plugins_claude_uninstall.snap
@@ -63,4 +63,5 @@ exit_code: 0
----- stderr -----
β—Ž Uninstalling plugin...
-βœ“ Plugin uninstalled
+β—Ž Removing Claude Code plugin marketplace...
+βœ“ Plugin & marketplace removed
diff --git a/tests/snapshots/integration__integration_tests__config_show__plugins_claude_uninstall_second_step_fails.snap b/tests/snapshots/integration__integration_tests__config_show__plugins_claude_uninstall_second_step_fails.snap
new file mode 100644
index 000000000..0b3f4b191
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__config_show__plugins_claude_uninstall_second_step_fails.snap
@@ -0,0 +1,68 @@
+---
+source: tests/integration_tests/config_show.rs
+info:
+ program: wt
+ args:
+ - config
+ - plugins
+ - claude
+ - uninstall
+ - "--yes"
+ env:
+ APPDATA: "[TEST_CONFIG_HOME]"
+ CLAUDE_CONFIG_DIR: "[TEST_CLAUDE_CONFIG]"
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "500"
+ GIT_ALLOW_PROTOCOL: file
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_AUTHOR_EMAIL: [email protected]
+ GIT_AUTHOR_NAME: Test User
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_EMAIL: [email protected]
+ GIT_COMMITTER_NAME: Test User
+ GIT_CONFIG_COUNT: "2"
+ GIT_CONFIG_GLOBAL: /nonexistent/wt/gitconfig
+ GIT_CONFIG_KEY_0: user.useConfigOnly
+ GIT_CONFIG_KEY_1: rerere.enabled
+ GIT_CONFIG_SYSTEM: /nonexistent/wt/gitconfig
+ GIT_CONFIG_VALUE_0: "true"
+ GIT_CONFIG_VALUE_1: "false"
+ GIT_TERMINAL_PROMPT: "0"
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ LLVM_PROFILE_FILE: "[LLVM_PROFILE_FILE]"
+ OPENCODE_CONFIG_DIR: "[TEST_OPENCODE_CONFIG]"
+ PATH: "[PATH]"
+ TERM: alacritty
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"
+ WORKTRUNK_TEST_BASH_INSTALLED: "0"
+ WORKTRUNK_TEST_CLAUDE_INSTALLED: "1"
+ WORKTRUNK_TEST_CODEX_INSTALLED: "0"
+ WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
+ WORKTRUNK_TEST_EPOCH: "1735776000"
+ WORKTRUNK_TEST_FISH_INSTALLED: "0"
+ WORKTRUNK_TEST_GEMINI_INSTALLED: "0"
+ WORKTRUNK_TEST_MOCK_CONFIG_DIR: "[TEST_MOCK_CONFIG]"
+ WORKTRUNK_TEST_NUSHELL_ENV: "0"
+ WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"
+ WORKTRUNK_TEST_PARENT_SHELL: ""
+ WORKTRUNK_TEST_POWERSHELL_ENV: "0"
+ WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0"
+ WORKTRUNK_TEST_PROBE_TIMEOUT_MS: "60000"
+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
+ WORKTRUNK_TEST_ZSH_INSTALLED: "0"
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: false
+exit_code: 1
+----- stdout -----
+
+----- stderr -----
+β—Ž Uninstalling plugin...
+β—Ž Removing Claude Code plugin marketplace...
+βœ— claude plugin marketplace remove worktrunk failed (exit 1)
+  error: marketplace remove failed
diff --git a/tests/snapshots/integration__integration_tests__config_show__plugins_codex_install.snap b/tests/snapshots/integration__integration_tests__config_show__plugins_codex_install.snap
index 45a97ba30..8da6af2e5 100644
--- a/tests/snapshots/integration__integration_tests__config_show__plugins_codex_install.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__plugins_codex_install.snap
@@ -63,6 +63,6 @@ exit_code: 0
----- stderr -----
β—Ž Adding Codex plugin marketplace...
-βœ“ Codex marketplace configured
-↳ Next, run /plugins in Codex and install Worktrunk from the marketplace
+β—Ž Installing plugin...
+βœ“ Codex plugin installed
↳ Activity markers appear in wt list once a Codex session runs
diff --git a/tests/snapshots/integration__integration_tests__config_show__plugins_codex_install_plugin_add_fails.snap b/tests/snapshots/integration__integration_tests__config_show__plugins_codex_install_plugin_add_fails.snap
new file mode 100644
index 000000000..fc6d4be2a
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__config_show__plugins_codex_install_plugin_add_fails.snap
@@ -0,0 +1,68 @@
+---
+source: tests/integration_tests/config_show.rs
+info:
+ program: wt
+ args:
+ - config
+ - plugins
+ - codex
+ - install
+ - "--yes"
+ env:
+ APPDATA: "[TEST_CONFIG_HOME]"
+ CLAUDE_CONFIG_DIR: "[TEST_CLAUDE_CONFIG]"
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "500"
+ GIT_ALLOW_PROTOCOL: file
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_AUTHOR_EMAIL: [email protected]
+ GIT_AUTHOR_NAME: Test User
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_EMAIL: [email protected]
+ GIT_COMMITTER_NAME: Test User
+ GIT_CONFIG_COUNT: "2"
+ GIT_CONFIG_GLOBAL: /nonexistent/wt/gitconfig
+ GIT_CONFIG_KEY_0: user.useConfigOnly
+ GIT_CONFIG_KEY_1: rerere.enabled
+ GIT_CONFIG_SYSTEM: /nonexistent/wt/gitconfig
+ GIT_CONFIG_VALUE_0: "true"
+ GIT_CONFIG_VALUE_1: "false"
+ GIT_TERMINAL_PROMPT: "0"
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ LLVM_PROFILE_FILE: "[LLVM_PROFILE_FILE]"
+ OPENCODE_CONFIG_DIR: "[TEST_OPENCODE_CONFIG]"
+ PATH: "[PATH]"
+ TERM: alacritty
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"
+ WORKTRUNK_TEST_BASH_INSTALLED: "0"
+ WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"
+ WORKTRUNK_TEST_CODEX_INSTALLED: "1"
+ WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
+ WORKTRUNK_TEST_EPOCH: "1735776000"
+ WORKTRUNK_TEST_FISH_INSTALLED: "0"
+ WORKTRUNK_TEST_GEMINI_INSTALLED: "0"
+ WORKTRUNK_TEST_MOCK_CONFIG_DIR: "[TEST_MOCK_CONFIG]"
+ WORKTRUNK_TEST_NUSHELL_ENV: "0"
+ WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"
+ WORKTRUNK_TEST_PARENT_SHELL: ""
+ WORKTRUNK_TEST_POWERSHELL_ENV: "0"
+ WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0"
+ WORKTRUNK_TEST_PROBE_TIMEOUT_MS: "60000"
+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
+ WORKTRUNK_TEST_ZSH_INSTALLED: "0"
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: false
+exit_code: 1
+----- stdout -----
+
+----- stderr -----
+β—Ž Adding Codex plugin marketplace...
+β—Ž Installing plugin...
+βœ— codex plugin add worktrunk@worktrunk failed (exit 1)
+  error: plugin add failed
diff --git a/tests/snapshots/integration__integration_tests__config_show__plugins_codex_uninstall.snap b/tests/snapshots/integration__integration_tests__config_show__plugins_codex_uninstall.snap
index 263fd9c0c..4e86198f4 100644
--- a/tests/snapshots/integration__integration_tests__config_show__plugins_codex_uninstall.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__plugins_codex_uninstall.snap
@@ -62,6 +62,6 @@ exit_code: 0
----- stdout -----
----- stderr -----
+β—Ž Uninstalling plugin...
β—Ž Removing Codex plugin marketplace...
-βœ“ Codex marketplace removed
-↳ Installed plugins are left unchanged
+βœ“ Codex plugin & marketplace removed
diff --git a/tests/snapshots/integration__integration_tests__config_show__plugins_codex_uninstall_plugin_remove_fails.snap b/tests/snapshots/integration__integration_tests__config_show__plugins_codex_uninstall_plugin_remove_fails.snap
new file mode 100644
index 000000000..4772a99a2
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__config_show__plugins_codex_uninstall_plugin_remove_fails.snap
@@ -0,0 +1,67 @@
+---
+source: tests/integration_tests/config_show.rs
+info:
+ program: wt
+ args:
+ - config
+ - plugins
+ - codex
+ - uninstall
+ - "--yes"
+ env:
+ APPDATA: "[TEST_CONFIG_HOME]"
+ CLAUDE_CONFIG_DIR: "[TEST_CLAUDE_CONFIG]"
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "500"
+ GIT_ALLOW_PROTOCOL: file
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_AUTHOR_EMAIL: [email protected]
+ GIT_AUTHOR_NAME: Test User
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_EMAIL: [email protected]
+ GIT_COMMITTER_NAME: Test User
+ GIT_CONFIG_COUNT: "2"
+ GIT_CONFIG_GLOBAL: /nonexistent/wt/gitconfig
+ GIT_CONFIG_KEY_0: user.useConfigOnly
+ GIT_CONFIG_KEY_1: rerere.enabled
+ GIT_CONFIG_SYSTEM: /nonexistent/wt/gitconfig
+ GIT_CONFIG_VALUE_0: "true"
+ GIT_CONFIG_VALUE_1: "false"
+ GIT_TERMINAL_PROMPT: "0"
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ LLVM_PROFILE_FILE: "[LLVM_PROFILE_FILE]"
+ OPENCODE_CONFIG_DIR: "[TEST_OPENCODE_CONFIG]"
+ PATH: "[PATH]"
+ TERM: alacritty
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"
+ WORKTRUNK_TEST_BASH_INSTALLED: "0"
+ WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"
+ WORKTRUNK_TEST_CODEX_INSTALLED: "1"
+ WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
+ WORKTRUNK_TEST_EPOCH: "1735776000"
+ WORKTRUNK_TEST_FISH_INSTALLED: "0"
+ WORKTRUNK_TEST_GEMINI_INSTALLED: "0"
+ WORKTRUNK_TEST_MOCK_CONFIG_DIR: "[TEST_MOCK_CONFIG]"
+ WORKTRUNK_TEST_NUSHELL_ENV: "0"
+ WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"
+ WORKTRUNK_TEST_PARENT_SHELL: ""
+ WORKTRUNK_TEST_POWERSHELL_ENV: "0"
+ WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0"
+ WORKTRUNK_TEST_PROBE_TIMEOUT_MS: "60000"
+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
+ WORKTRUNK_TEST_ZSH_INSTALLED: "0"
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: false
+exit_code: 1
+----- stdout -----
+
+----- stderr -----
+β—Ž Uninstalling plugin...
+βœ— codex plugin remove worktrunk@worktrunk failed (exit 1)
+  error: plugin remove failed
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_plugins_codex.snap b/tests/snapshots/integration__integration_tests__help__help_config_plugins_codex.snap
index d2def2764..e762ef257 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_plugins_codex.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_plugins_codex.snap
@@ -49,8 +49,8 @@ wt config plugins codex - Codex plugin
Usage: wt config plugins codex [OPTIONS] <COMMAND>
Commands:
- install Configure the Worktrunk marketplace in Codex
- uninstall Remove the Worktrunk marketplace from Codex
+ install Install the Worktrunk plugin
+ uninstall Remove the Worktrunk plugin
Options:
-h, --help
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_plugins_codex_install.snap b/tests/snapshots/integration__integration_tests__help__help_config_plugins_codex_install.snap
index 5491ccfb8..8fa0897b2 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_plugins_codex_install.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_plugins_codex_install.snap
@@ -45,7 +45,7 @@ info:
success: true
exit_code: 0
----- stdout -----
-wt config plugins codex install - Configure the Worktrunk marketplace in Codex
+wt config plugins codex install - Install the Worktrunk plugin
Usage: wt config plugins codex install [OPTIONS]
@@ -69,10 +69,11 @@ Usage: wt config plugins codex install [OPTIONS]
-y, --yes
Skip approval prompts
-Configures the Worktrunk plugin marketplace in Codex. Equivalent to:
+Adds the Worktrunk plugin from the marketplace and installs it. Equivalent to:
  codex plugin marketplace add max-sixty/worktrunk
+  codex plugin add worktrunk@worktrunk
-This does not install the plugin by itself. Afterward, open /plugins in Codex and install Worktrunk from the marketplace.
+Requires codex CLI.
----- stderr -----