Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
fix(shell): don't delete user data that only mentions the init command
Maximilian Roosb623d7f951de
diff --git a/docs/content/faq.md b/docs/content/faq.mdindex c10af3778..f58050f1e 100644--- a/docs/content/faq.md+++ b/docs/content/faq.md@@ -195,8 +195,8 @@ Use `-D` to force-delete branches with unmerged changes. Use `--no-delete-branch- `wt remove` — besides the target worktree, two cleanup mechanisms run. The removed worktree's own `git fsmonitor--daemon` (git's per-worktree filesystem watcher under `core.fsmonitor=true`, which would leak once its worktree is gone) is sent `git fsmonitor--daemon stop`, then force-terminated (`SIGTERM`, then `SIGKILL`) via the PID resolved from its IPC socket if it didn't exit. A background sweep then deletes `.git/wt/trash/` entries older than 24 hours (directories orphaned when a previous background removal was interrupted) and terminates fsmonitor daemons whose worktree no longer exists (orphans from `git worktree remove`, `rm -rf`, or a crashed `wt`)- `wt config state clear` — removes all worktrunk data from `.git/` (config keys, caches, markers, hints, variables, logs, stale trash)-- `wt config shell install` — when migrating an integration to a new location, removes the worktrunk-managed file left at the old one: fish `conf.d/wt.fish` (now `functions/wt.fish`) and nushell wrappers stranded under `<config-dir>/vendor/autoload` (now `<data-dir>/vendor/autoload`)-- `wt config shell uninstall` — removes integration lines from bash/zsh/PowerShell rc files, and deletes worktrunk's wrapper and completion files (fish `functions/`, `conf.d/`, and `completions/`; nushell `vendor/autoload`). Files are recognized by worktrunk's own content markers, whatever binary name they were installed under; files without the markers are left alone+- `wt config shell install` — when migrating an integration to a new location, removes the worktrunk-managed file left at the old one: fish `conf.d/wt.fish` (now `functions/wt.fish`) and nushell wrappers stranded under `<config-dir>/vendor/autoload` (now `<data-dir>/vendor/autoload`). Recognition is the same as for uninstall below, so a file of the user's own sitting at that path is left in place+- `wt config shell uninstall` — removes integration lines from bash/zsh/PowerShell rc files, and deletes worktrunk's wrapper and completion files (fish `functions/`, `conf.d/`, and `completions/`; nushell `vendor/autoload`). Files are recognized by worktrunk's own content markers, whatever binary name they were installed under; files without the markers are left alone. An rc file belongs to the user, so a line qualifies only where it runs the init command: one that merely mentions it, inside a comment, an `echo`, or an alias body, stays. Every line uninstall does take is printed, before removal and again afterSee [What files does Worktrunk create?](#what-files-does-worktrunk-create) for details.diff --git a/plugins/worktrunk/skills/worktrunk/reference/faq.md b/plugins/worktrunk/skills/worktrunk/reference/faq.mdindex 638c2004b..fffae01e4 100644--- a/plugins/worktrunk/skills/worktrunk/reference/faq.md+++ b/plugins/worktrunk/skills/worktrunk/reference/faq.md@@ -190,8 +190,8 @@ Use `-D` to force-delete branches with unmerged changes. Use `--no-delete-branch- `wt remove` — besides the target worktree, two cleanup mechanisms run. The removed worktree's own `git fsmonitor--daemon` (git's per-worktree filesystem watcher under `core.fsmonitor=true`, which would leak once its worktree is gone) is sent `git fsmonitor--daemon stop`, then force-terminated (`SIGTERM`, then `SIGKILL`) via the PID resolved from its IPC socket if it didn't exit. A background sweep then deletes `.git/wt/trash/` entries older than 24 hours (directories orphaned when a previous background removal was interrupted) and terminates fsmonitor daemons whose worktree no longer exists (orphans from `git worktree remove`, `rm -rf`, or a crashed `wt`)- `wt config state clear` — removes all worktrunk data from `.git/` (config keys, caches, markers, hints, variables, logs, stale trash)-- `wt config shell install` — when migrating an integration to a new location, removes the worktrunk-managed file left at the old one: fish `conf.d/wt.fish` (now `functions/wt.fish`) and nushell wrappers stranded under `<config-dir>/vendor/autoload` (now `<data-dir>/vendor/autoload`)-- `wt config shell uninstall` — removes integration lines from bash/zsh/PowerShell rc files, and deletes worktrunk's wrapper and completion files (fish `functions/`, `conf.d/`, and `completions/`; nushell `vendor/autoload`). Files are recognized by worktrunk's own content markers, whatever binary name they were installed under; files without the markers are left alone+- `wt config shell install` — when migrating an integration to a new location, removes the worktrunk-managed file left at the old one: fish `conf.d/wt.fish` (now `functions/wt.fish`) and nushell wrappers stranded under `<config-dir>/vendor/autoload` (now `<data-dir>/vendor/autoload`). Recognition is the same as for uninstall below, so a file of the user's own sitting at that path is left in place+- `wt config shell uninstall` — removes integration lines from bash/zsh/PowerShell rc files, and deletes worktrunk's wrapper and completion files (fish `functions/`, `conf.d/`, and `completions/`; nushell `vendor/autoload`). Files are recognized by worktrunk's own content markers, whatever binary name they were installed under; files without the markers are left alone. An rc file belongs to the user, so a line qualifies only where it runs the init command: one that merely mentions it, inside a comment, an `echo`, or an alias body, stays. Every line uninstall does take is printed, before removal and again afterSee [What files does Worktrunk create?](#what-files-does-worktrunk-create) for details.diff --git a/skills/worktrunk/reference/faq.md b/skills/worktrunk/reference/faq.mdindex 638c2004b..fffae01e4 100644--- a/skills/worktrunk/reference/faq.md+++ b/skills/worktrunk/reference/faq.md@@ -190,8 +190,8 @@ Use `-D` to force-delete branches with unmerged changes. Use `--no-delete-branch- `wt remove` — besides the target worktree, two cleanup mechanisms run. The removed worktree's own `git fsmonitor--daemon` (git's per-worktree filesystem watcher under `core.fsmonitor=true`, which would leak once its worktree is gone) is sent `git fsmonitor--daemon stop`, then force-terminated (`SIGTERM`, then `SIGKILL`) via the PID resolved from its IPC socket if it didn't exit. A background sweep then deletes `.git/wt/trash/` entries older than 24 hours (directories orphaned when a previous background removal was interrupted) and terminates fsmonitor daemons whose worktree no longer exists (orphans from `git worktree remove`, `rm -rf`, or a crashed `wt`)- `wt config state clear` — removes all worktrunk data from `.git/` (config keys, caches, markers, hints, variables, logs, stale trash)-- `wt config shell install` — when migrating an integration to a new location, removes the worktrunk-managed file left at the old one: fish `conf.d/wt.fish` (now `functions/wt.fish`) and nushell wrappers stranded under `<config-dir>/vendor/autoload` (now `<data-dir>/vendor/autoload`)-- `wt config shell uninstall` — removes integration lines from bash/zsh/PowerShell rc files, and deletes worktrunk's wrapper and completion files (fish `functions/`, `conf.d/`, and `completions/`; nushell `vendor/autoload`). Files are recognized by worktrunk's own content markers, whatever binary name they were installed under; files without the markers are left alone+- `wt config shell install` — when migrating an integration to a new location, removes the worktrunk-managed file left at the old one: fish `conf.d/wt.fish` (now `functions/wt.fish`) and nushell wrappers stranded under `<config-dir>/vendor/autoload` (now `<data-dir>/vendor/autoload`). Recognition is the same as for uninstall below, so a file of the user's own sitting at that path is left in place+- `wt config shell uninstall` — removes integration lines from bash/zsh/PowerShell rc files, and deletes worktrunk's wrapper and completion files (fish `functions/`, `conf.d/`, and `completions/`; nushell `vendor/autoload`). Files are recognized by worktrunk's own content markers, whatever binary name they were installed under; files without the markers are left alone. An rc file belongs to the user, so a line qualifies only where it runs the init command: one that merely mentions it, inside a comment, an `echo`, or an alias body, stays. Every line uninstall does take is printed, before removal and again afterSee [What files does Worktrunk create?](#what-files-does-worktrunk-create) for details.diff --git a/src/commands/configure_shell.rs b/src/commands/configure_shell.rsindex ecffb4d19..93bf92241 100644--- a/src/commands/configure_shell.rs+++ b/src/commands/configure_shell.rs@@ -27,6 +27,14 @@ pub struct UninstallResult {pub action: UninstallAction,/// Path that replaces this one (for deprecated location cleanup)pub superseded_by: Option<PathBuf>,+ /// The lines the action applies to, for a file worktrunk edits in place+ /// (the bash/zsh/PowerShell rc files, which are the user's).+ ///+ /// Shown before removal and again after, so no line leaves a user's rc file+ /// unseen: detection is a heuristic, and `wt config shell uninstall` is the+ /// one command that acts on it destructively. Empty for the fish/nushell+ /// wrappers, whole files worktrunk owns and the path already names.+ pub matched_lines: Vec<String>,}pub struct UninstallScanResult {@@ -116,14 +124,6 @@ impl ConfigAction {}}-/// Check if file content appears to be worktrunk-managed (contains our markers)-///-/// Used to identify files safe to delete during migration/uninstall.-/// Requires both the init command AND pipe to source, to avoid false positives.-fn is_worktrunk_managed_content(content: &str, cmd: &str) -> bool {- content.contains(&format!("{cmd} config shell init")) && content.contains("| source")-}-/// The header comment every wrapper template worktrunk has shipped opens with,/// and which a user's own `wt.fish` / `wt.nu` would not carry.const WRAPPER_MARKER: &str = "worktrunk shell integration for";@@ -131,20 +131,24 @@ const WRAPPER_MARKER: &str = "worktrunk shell integration for";/// The header every fish completion file worktrunk has shipped opens with.const COMPLETION_MARKER: &str = "# worktrunk completions for";-/// Cmd-agnostic content check: matches a worktrunk-generated wrapper file-/// regardless of the binary name embedded in it.+/// Whether a whole file is one worktrunk generated, and so is worktrunk's to+/// delete — by `uninstall`, and by the install-time cleanup of the legacy fish+/// `conf.d` wrapper.///-/// Used by `uninstall` to recognize wrapper files installed under any binary-/// name (e.g. `wt.fish`, `git-wt.fish`, `git-wt.nu`) when scanning the wrapper-/// directories. Every wrapper template worktrunk renders carries the header, so-/// that answers first. The fallback covers the legacy `conf.d/{cmd}.fish`, which-/// predates the templates and holds nothing but the init line: a file qualifies-/// only when every non-blank, non-comment line is an integration line+/// The answer is independent of the binary name embedded in the file, so a+/// wrapper installed as `wt.fish`, `git-wt.fish`, or `git-wt.nu` is recognized+/// the same way. Every wrapper template worktrunk renders carries the header,+/// so that answers first. The fallback covers the legacy `conf.d/{cmd}.fish`,+/// which predates the templates and holds nothing but the init line: a file+/// qualifies only when every non-blank, non-comment line is an integration line/// (per the rc-file line detector, keeping one definition of "an integration-/// line"). Uninstall walks directories the user owns, so a user's own file that-/// runs `wt config shell init` amid other code — or merely mentions it — must-/// survive.-fn is_worktrunk_managed_content_any_cmd(content: &str) -> bool {+/// line").+///+/// Both callers walk directories the user owns, so the question is asked of+/// every line rather than of the file as a blob. A user's own `wt.fish` that+/// runs `wt config shell init` amid other code — or merely mentions it in a+/// comment — survives; a whole-file substring test would delete it.+fn is_worktrunk_managed_content(content: &str) -> bool {if content.contains(WRAPPER_MARKER) {return true;}@@ -199,7 +203,7 @@ fn cleanup_legacy_fish_conf_d(configured: &[ConfigureResult], cmd: &str) -> Vec<return cleaned;};- if !is_worktrunk_managed_content(&content, cmd) {+ if !is_worktrunk_managed_content(&content) {return cleaned;}@@ -846,14 +850,13 @@ pub fn show_install_preview(blocks.join("\n\n")}-/// Format what will be uninstalled (shell extensions and completions).-///-/// Returns the preview as a string (no trailing newline). Used only for-/// `--dry-run`, which is the command's answer, so the caller prints it to-/// stdout. See /writing-user-outputs.+/// Format what will be uninstalled (shell extensions and completions), naming+/// the individual rc-file lines under each entry.///-/// Note: I/O errors are intentionally ignored - preview is best-effort-/// and shouldn't block the flow.+/// Returns the preview as a string (no trailing newline). The caller picks the+/// stream: `--dry-run` mutates nothing, so its preview is the command's answer+/// and goes to stdout; the same text inside the confirmation prompt is+/// narration and goes to stderr. See /writing-user-outputs.pub fn show_uninstall_preview(results: &[UninstallResult],completion_results: &[CompletionUninstallResult],@@ -876,9 +879,10 @@ pub fn show_uninstall_preview(let what = shell_extension_label(shell);lines.push(format!(- "{} {} {what} for {bold}{shell}{bold:#} @ {bold}{path}{bold:#}",+ "{} {} {what} for {bold}{shell}{bold:#} @ {bold}{path}{bold:#}{}",result.action.symbol(),result.action.description(),+ format_matched_lines(&result.matched_lines),));}}@@ -897,6 +901,16 @@ pub fn show_uninstall_preview(lines.join("\n")}+/// The rc-file lines an uninstall entry covers, as a gutter block under the+/// entry's own line. Empty for a whole file worktrunk owns, whose path is+/// already the whole story.+pub(crate) fn format_matched_lines(matched_lines: &[String]) -> String {+ if matched_lines.is_empty() {+ return String::new();+ }+ format!("\n{}", format_bash_with_gutter(&matched_lines.join("\n")))+}+/// Prompt for install with [y/N/?] options////// - `y` or `yes`: Accept and return true@@ -1076,7 +1090,7 @@ fn remove_config_file(path: &std::path::Path) -> Result<(), String> {////// For Fish/Nushell wrapper files and Fish completion files (one file per binary/// name), this lists the owning directories and admits any file whose content-/// matches the worktrunk marker (`is_worktrunk_managed_content_any_cmd`, or the+/// matches the worktrunk marker (`is_worktrunk_managed_content`, or the/// completion header for `completions/`). For Bash/Zsh/PowerShell (line-based),/// it scans the rc/profile files and uses `is_shell_integration_line_for_uninstall_any_cmd`./// No `--cmd` is needed because the marker is the content, not the file name.@@ -1102,13 +1116,9 @@ fn scan_for_uninstall(let functions_dir = home.join(".config").join("fish").join("functions");let confd_dir = home.join(".config").join("fish").join("conf.d");- let canonical = scan_managed_files(- &functions_dir,- "fish",- is_worktrunk_managed_content_any_cmd,- )?;- let legacy =- scan_managed_files(&confd_dir, "fish", is_worktrunk_managed_content_any_cmd)?;+ let canonical =+ scan_managed_files(&functions_dir, "fish", is_worktrunk_managed_content)?;+ let legacy = scan_managed_files(&confd_dir, "fish", is_worktrunk_managed_content)?;let found_any = !canonical.is_empty() || !legacy.is_empty();for path in &canonical {@@ -1123,6 +1133,7 @@ fn scan_for_uninstall(path: path.clone(),action,superseded_by: None,+ matched_lines: Vec::new(),});}@@ -1139,6 +1150,7 @@ fn scan_for_uninstall(path: path.clone(),action,superseded_by,+ matched_lines: Vec::new(),});}@@ -1151,11 +1163,8 @@ fn scan_for_uninstall(let mut found_any = false;let candidates = shell::nushell_autoload_candidates(&home);for autoload_dir in &candidates {- let nu_files = scan_managed_files(- autoload_dir,- "nu",- is_worktrunk_managed_content_any_cmd,- )?;+ let nu_files =+ scan_managed_files(autoload_dir, "nu", is_worktrunk_managed_content)?;for path in &nu_files {found_any = true;let action = if dry_run {@@ -1169,6 +1178,7 @@ fn scan_for_uninstall(path: path.clone(),action,superseded_by: None,+ matched_lines: Vec::new(),});}}@@ -1356,12 +1366,18 @@ fn uninstall_from_file(return Ok(None);}+ let matched_lines: Vec<String> = integration_lines+ .iter()+ .map(|(_, line)| line.trim().to_string())+ .collect();+if dry_run {return Ok(Some(UninstallResult {shell,path: path.to_path_buf(),action: UninstallAction::WouldRemove,superseded_by: None,+ matched_lines,}));}@@ -1395,37 +1411,21 @@ fn uninstall_from_file(path: path.to_path_buf(),action: UninstallAction::Removed,superseded_by: None,+ matched_lines,}))}+/// Show what uninstall would take, then ask.+///+/// Renders through `show_uninstall_preview` so the confirmation lists the exact+/// rc-file lines `--dry-run` lists — the user approves the lines, not just the+/// file. Shown inside the prompt, so it narrates to stderr rather than joining+/// the `--dry-run` answer on stdout. See /writing-user-outputs.fn prompt_for_uninstall_confirmation(results: &[UninstallResult],completion_results: &[CompletionUninstallResult],) -> Result<bool, String> {- for result in results {- let bold = Style::new().bold();- let shell = result.shell;- let path = format_path_for_display(&result.path);- let what = shell_extension_label(shell);-- eprintln!(- "{} {} {what} for {bold}{shell}{bold:#} @ {bold}{path}{bold:#}",- result.action.symbol(),- result.action.description(),- );- }-- for result in completion_results {- let bold = Style::new().bold();- let shell = result.shell;- let path = format_path_for_display(&result.path);-- eprintln!(- "{} {} completions for {bold}{shell}{bold:#} @ {bold}{path}{bold:#}",- result.action.symbol(),- result.action.description(),- );- }+ eprintln!("{}", show_uninstall_preview(results, completion_results));prompt_yes_no()}@@ -1682,7 +1682,7 @@ mod tests {}#[test]- fn test_managed_content_any_cmd_matches_wrappers_not_mentions() {+ fn test_managed_content_matches_wrappers_not_mentions() {// Ours: the header every wrapper template carries, under any binary// name, plus the headerless legacy `conf.d/{cmd}.fish`, whose code// lines are nothing but the init invocation.@@ -1692,20 +1692,22 @@ mod tests {"wt config shell init fish | source","# added by worktrunk\nif type -q wt; command wt config shell init fish | source; end\n",] {- assert!(is_worktrunk_managed_content_any_cmd(content), "{content}");+ assert!(is_worktrunk_managed_content(content), "{content}");}- // Not ours: uninstall walks directories the user owns, so a file that+ // Not ours: both callers walk directories the user owns, so a file that// only mentions the command must survive — as must a user's own file// that runs the init line amid other code, which a per-line any-match- // would delete whole.+ // would delete whole. The second and third also carry the init command+ // and a `| source` somewhere, which is all a whole-file substring test+ // asks before deleting.for content in ["function notes\n echo run wt config shell init fish to set up\nend\n","# reminder: wt config shell init fish\nfunction helpers\n cat ~/.aliases | source\nend\n","function helper\n command wt config shell init fish | source\nend\n","",] {- assert!(!is_worktrunk_managed_content_any_cmd(content), "{content}");+ assert!(!is_worktrunk_managed_content(content), "{content}");}}@@ -1727,7 +1729,7 @@ mod tests {// A directory carrying the wrapper extension: skipped (not a file).fs::create_dir(root.join("nested.fish")).unwrap();assert!(- scan_managed_files(root, "fish", is_worktrunk_managed_content_any_cmd)+ scan_managed_files(root, "fish", is_worktrunk_managed_content).unwrap().is_empty());@@ -1837,7 +1839,7 @@ mod tests {fs::write(&unreadable, "function wt\nend\n").unwrap();fs::set_permissions(&unreadable, fs::Permissions::from_mode(0o000)).unwrap();// An unreadable wrapper file is skipped, not surfaced as an error.- let found = scan_managed_files(root, "fish", is_worktrunk_managed_content_any_cmd);+ let found = scan_managed_files(root, "fish", is_worktrunk_managed_content);// Restore perms so TempDir cleanup can remove the file.fs::set_permissions(&unreadable, fs::Permissions::from_mode(0o644)).unwrap();assert!(found.unwrap().is_empty());diff --git a/src/git/error.rs b/src/git/error.rsindex f713cb08a..f14205c3e 100644--- a/src/git/error.rs+++ b/src/git/error.rs@@ -1145,6 +1145,13 @@ impl GitError {hint_message(cformat!("Remaining in directory: <underline>{listing}</>")))?;}+ // Fragile by necessity: matches git's English, which is+ // localized and could be reworded. `remaining_entries` is not a+ // substitute — a permission-denied failure also leaves entries+ // behind, and this hint is only right for ENOTEMPTY. The+ // structured form (`io::ErrorKind::DirectoryNotEmpty`) is lost+ // upstream, where the cause is flattened to a rendered string+ // before it reaches this type. A miss costs one hint.if error.contains("not empty") {write!(f,diff --git a/src/git/remote_ref/azure.rs b/src/git/remote_ref/azure.rsindex 97e3a156b..8b699e6f5 100644--- a/src/git/remote_ref/azure.rs+++ b/src/git/remote_ref/azure.rs@@ -236,22 +236,12 @@ fn fetch_pr_info(pr_number: u32, repo: &Repository) -> anyhow::Result<RemoteRefI})?;if !output.status.success() {- let stderr = String::from_utf8_lossy(&output.stderr).trim().to_string();- let stdout_str = String::from_utf8_lossy(&output.stdout).trim().to_string();-- if stderr.contains("does not exist") || stdout_str.contains("does not exist") {- bail!("Azure DevOps PR #{} not found", pr_number);- }- if stderr.contains("login") || stderr.contains("authenticate") {- bail!("Azure CLI not authenticated; run az login");- }- if stderr.contains("azure-devops") && stderr.contains("extension") {- bail!(- "Azure DevOps CLI extension not installed; \- run: az extension add --name azure-devops"- );- }-+ // `az` reports failures only as prose on stderr — no exit-code or JSON+ // error channel to branch on. Rather than guess at the cause from+ // English substrings, surface what `az` said: its own text names the+ // remedy ("Please run 'az login' …", the missing-extension prompt) more+ // reliably than a paraphrase keyed on a word that can occur anywhere in+ // an org, project, or repo name.return Err(cli_api_error(RefType::Pr,format!("az repos pr show failed for PR #{}", pr_number),diff --git a/src/git/remote_ref/mod.rs b/src/git/remote_ref/mod.rsindex 2b7b1b737..159d24d14 100644--- a/src/git/remote_ref/mod.rs+++ b/src/git/remote_ref/mod.rs@@ -147,6 +147,28 @@ pub(super) fn cli_api_error(ref_type: RefType, message: String, output: &Output).into()}+/// Whether `host` is `domain` itself or a subdomain of it.+///+/// Compared label-wise, so `dev.azure.com` matches `dev.azure.com` and+/// `x.dev.azure.com` but not `dev.azure.com.attacker.example` or+/// `notdev.azure.com` — a plain substring test accepts an attacker-chosen host+/// that merely contains the domain.+fn host_is_within(host: &str, domain: &str) -> bool {+ let host = host.to_ascii_lowercase();+ host == domain || host.strip_suffix(domain).is_some_and(|p| p.ends_with('.'))+}++/// Whether any dot-separated label of `host` is exactly `label`.+///+/// Recognizes both `github.com` and the usual self-hosted naming+/// (`github.corp.example`) without matching a host that merely spells the name+/// inside a longer label, such as a `github-mirror.example` running something+/// else. A deployment this misses names its provider explicitly — see+/// `provider_override`.+fn host_has_label(host: &str, label: &str) -> bool {+ host.to_ascii_lowercase().split('.').any(|l| l == label)+}+/// Extract the host (e.g. `github.com`) from a PR/MR `html_url` returned by/// the forge API. Both GitHub and Gitea responses use the same `https://host/...`/// shape, so we share the parser.@@ -405,8 +427,7 @@ pub fn repo_info_from_ref_url_with_provider(let provider = match marker {"pull" => {- if provider_override == Some(GitRepoProvider::GitHub)- || host.to_ascii_lowercase().contains("github")+ if provider_override == Some(GitRepoProvider::GitHub) || host_has_label(&host, "github"){GitRepoProvider::GitHub} else {@@ -417,8 +438,8 @@ pub fn repo_info_from_ref_url_with_provider("merge_requests" => GitRepoProvider::GitLab,"pullrequest" => {if provider_override == Some(GitRepoProvider::AzureDevOps)- || host.to_ascii_lowercase().contains("dev.azure.com")- || host.to_ascii_lowercase().contains("visualstudio.com")+ || host_is_within(&host, "dev.azure.com")+ || host_is_within(&host, "visualstudio.com"){GitRepoProvider::AzureDevOps} else {@@ -515,6 +536,31 @@ fn azure_repo_segments(mod tests {use super::*;+ #[test]+ fn test_host_matching_respects_label_boundaries() {+ // The domain itself and subdomains of it.+ assert!(host_is_within("dev.azure.com", "dev.azure.com"));+ assert!(host_is_within("DEV.AZURE.COM", "dev.azure.com"));+ assert!(host_is_within("myorg.visualstudio.com", "visualstudio.com"));+ // A host that only spells the domain inside a longer name. A substring+ // test takes each of these for Azure DevOps.+ assert!(!host_is_within(+ "dev.azure.com.attacker.example",+ "dev.azure.com"+ ));+ assert!(!host_is_within("notdev.azure.com", "dev.azure.com"));+ assert!(!host_is_within("evil-visualstudio.com", "visualstudio.com"));++ // github.com and the usual self-hosted naming.+ assert!(host_has_label("github.com", "github"));+ assert!(host_has_label("github.corp.example", "github"));+ assert!(host_has_label("git.github.corp.example", "github"));+ // Spelled inside a longer label: not GitHub.+ assert!(!host_has_label("github-mirror.example", "github"));+ assert!(!host_has_label("mygithubmirror.com", "github"));+ assert!(!host_has_label("notgithub.io", "github"));+ }+#[test]fn test_ref_paths() {let gh = GitHubProvider;diff --git a/src/output/shell_integration.rs b/src/output/shell_integration.rsindex 1b164ba3f..7ae7405b3 100644--- a/src/output/shell_integration.rs+++ b/src/output/shell_integration.rs@@ -70,8 +70,8 @@ use worktrunk::styling::{};use crate::commands::configure_shell::{- ConfigAction, UninstallScanResult, handle_configure_shell, prompt_for_install,- scan_shell_configs,+ ConfigAction, UninstallScanResult, format_matched_lines, handle_configure_shell,+ prompt_for_install, scan_shell_configs,};/// Git config key tracking how many times the shell-integration install hint@@ -505,18 +505,21 @@ pub fn print_shell_uninstall_result(scan_result: &UninstallScanResult, explicit_let completion_count = scan_result.completion_results.len();let total_changes = shell_count + completion_count;- // Show shell extension results+ // Show shell extension results, each with the rc-file lines it took. With+ // --yes there is no confirmation, so this is the only place the user sees+ // which of their lines went.for result in &scan_result.results {let shell = result.shell;let path = format_path_for_display(&result.path);let what = shell_extension_label(shell);eprintln!(- "{}",+ "{}{}",success_message(cformat!("{} {what} for <bold>{shell}</> @ <bold>{path}</>",result.action.description(),- ))+ )),+ format_matched_lines(&result.matched_lines),);}diff --git a/src/shell/detection.rs b/src/shell/detection.rsindex 0bbc7e5c2..f006b5242 100644--- a/src/shell/detection.rs+++ b/src/shell/detection.rs@@ -115,58 +115,122 @@ const INIT_MARKER: &str = " config shell init";/// Cmd-agnostic line detection: matches an integration line whatever binary name/// it was installed under.///-/// Where the cmd-specific detectors search for a known name and check what-/// precedes it, this reads the name off the line: it is the run of command-name-/// characters ending at `INIT_MARKER`. Holding that run to-/// [`validate_shell_command_name`](super::validate_shell_command_name) — the-/// same rule governing what worktrunk is willing to write into shell code —-/// keeps detection and generation from drifting apart.+/// The whole rule is one question — does this line *invoke*+/// `<name> config shell init`? — answered by `command_invocation_precedes`.+/// Where the cmd-specific detectors search for a known name, this reads the name+/// off the line.+///+/// It deliberately asks nothing about how the output is consumed. A detector+/// that also scanned for `eval`/`source`/`save` would be reading English words+/// out of the whole line, matching them inside quoted strings as readily as in+/// code, and it turns out to reject nothing this doesn't: a line that merely+/// mentions the command has it in argument position, which is already the+/// disqualifier. What is left over is the narrow case of a line that runs+/// `<name> config shell init` and discards the output, which is a worktrunk+/// invocation in an rc file either way.////// Unlike the cmd-specific detectors this deliberately does not exclude a `git `/// prefix: `git wt config shell init` is worktrunk's own integration too, and/// uninstall asks only whether a line is ours, not which install it belongs to.///-/// Used by `wt config shell uninstall`, which removes every worktrunk-managed-/// integration it finds.+/// Used by `wt config shell uninstall`, which deletes the lines it matches. That+/// makes a false positive destructive — it takes a line the user wrote — while a+/// false negative only strands a line they can delete by hand. So where the two+/// trade off, this errs toward leaving the line, and `wt config shell uninstall`+/// shows every line it matched before removing it.pub fn is_shell_integration_line_for_uninstall_any_cmd(line: &str) -> bool {let code = line_code_portion(line);- is_execution_context(code, false)- && code- .match_indices(INIT_MARKER)- .any(|(pos, _)| command_name_precedes(code, pos))+ code.match_indices(INIT_MARKER)+ .any(|(pos, _)| command_invocation_precedes(code, pos))}-/// Does a plausible command name end at `pos`?+/// Does a command *invocation* end at `pos`?+///+/// Two things must hold: the word ending at `pos` names a command, and it sits+/// in command position — it starts a command rather than sitting inside one as+/// an argument.///-/// Reads backwards over command-name characters, which stops at the shell-/// punctuation wrapping the invocation (`"$(`, `<(`) and at the directory-/// separator of an absolute path, leaving the bare name. An empty run means the-/// marker stands alone with nothing invoking it.-fn command_name_precedes(line: &str, pos: usize) -> bool {+/// The word is read backwards over everything that is neither whitespace nor+/// the shell punctuation wrapping an invocation (`"$(`, `<(`, backticks), so a+/// path to the binary stays whole and its basename is the name. Holding that+/// name to [`validate_shell_command_name`](super::validate_shell_command_name)+/// — the same rule governing what worktrunk is willing to write into shell code+/// — keeps detection and generation from drifting apart. A bare `$VAR` fails it,+/// so `eval "$($WORKTRUNK_BIN config shell init bash)"` is not claimed by+/// either detector: which binary it names isn't knowable from the line.+///+/// Command position is the whole of what separates worktrunk's own line from a+/// user's line that quotes one: in+/// `alias setup='echo "run: wt config shell init fish | source"'` the name is an+/// argument to `echo`, and without that check uninstall deletes the alias.+fn command_invocation_precedes(line: &str, pos: usize) -> bool {let before = &line[..pos];- before- .char_indices()+ let word = trailing_word(before);+ if word.is_empty() {+ // The marker stands alone with nothing invoking it.+ return false;+ }+ let name = word.rsplit_once(['/', '\\']).map_or(word, |(_, base)| base);+ super::validate_shell_command_name(name).is_ok()+ && starts_command(&before[..before.len() - word.len()])+}++/// The word ending at the end of `s`: everything back to the nearest whitespace+/// or shell punctuation. Empty when `s` ends in one of those.+fn trailing_word(s: &str) -> &str {+ s.char_indices().rev()- .take_while(|(_, c)| c.is_ascii_alphanumeric() || matches!(c, '.' | '_' | '-'))+ .take_while(|&(_, c)| {+ !c.is_whitespace()+ && !matches!(+ c,+ ';' | '&' | '|' | '(' | ')' | '{' | '}' | '<' | '>' | '`' | '"' | '\''+ )+ }).map(|(i, _)| i).last()- .is_some_and(|start| super::validate_shell_command_name(&before[start..]).is_ok())+ .map_or("", |start| &s[start..])+}++/// Words that hand command position to whatever follows them: the two that+/// prefix a worktrunk integration line in practice. `command` is what every rc+/// line worktrunk writes uses; `git` covers the hand-written `git wt` dispatch+/// form. A shell has other such words (`then`, `exec`, `do`), but no integration+/// line puts one directly in front of the binary, and admitting one it doesn't+/// need only widens what uninstall will delete.+const COMMAND_MODIFIERS: [&str; 2] = ["command", "git"];++/// Does a command start where `before` ends?+///+/// True at the start of the code and after the punctuation that separates or+/// opens one — `;`, `&`, `|`, a group `{`, and the substitution forms wrapping+/// an integration line (`$(`, `<(`, `=(`, backticks, PowerShell's `&` call+/// operator). A bare word in front means the following word is that word's+/// *argument*, unless the word is a [`COMMAND_MODIFIERS`] entry.+fn starts_command(before: &str) -> bool {+ let before = before.trim_end_matches([' ', '\t']);+ match before.chars().last() {+ None => true,+ Some(';' | '&' | '|' | '(' | '{' | '`') => true,+ Some(_) => COMMAND_MODIFIERS.contains(&trailing_word(before)),+ }}/// Does the line run the command's output, rather than merely mention it?///-/// A property of the whole line, not of where the command sits within it.+/// A property of the whole line, not of where the command sits within it: an+/// exec keyword anywhere satisfies it, including inside a quoted string. That+/// makes it too loose to decide a deletion on, so it is confined to the+/// cmd-specific detectors, whose answer only picks a message.///-/// PowerShell is checked first, case-insensitively. It needs `| Out-String` to-/// work — without it `Invoke-Expression` fails with "Cannot convert-/// 'System.Object[]'" (issue #885). Strict mode (the cmd-specific install-side-/// detector) leaves an old config lacking it undetected so `wt config shell-/// install` will rewrite it; the cmd-agnostic uninstall detector passes-/// `strict: false` so the old line can be removed.-fn is_execution_context(line: &str, strict: bool) -> bool {+/// What it buys there is a PowerShell line lacking `| Out-String`, which does+/// not work — `Invoke-Expression` fails with "Cannot convert+/// 'System.Object[]'" (issue #885). Reporting such a line as *not* configured+/// is what gets `wt config shell install` to rewrite it.+fn is_execution_context(line: &str) -> bool {let line_lower = line.to_lowercase();if line_lower.contains("invoke-expression") || line_lower.contains("iex") {- return !strict || line_lower.contains("out-string");+ return line_lower.contains("out-string");}// POSIX shells (bash, zsh, fish) and nushell@@ -202,7 +266,7 @@ fn has_init_invocation(line: &str, cmd: &str) -> bool {/// eval "$(git-wt.exe config shell init bash)"/// ```fn has_init_pattern_with_prefix_check(line: &str, cmd: &str) -> bool {- if !is_execution_context(line, true) {+ if !is_execution_context(line) {return false;}@@ -822,9 +886,13 @@ mod tests {"if type -q wt; command wt config shell init fish | source; end","iex (wt config shell init powershell | Out-String)",// Old PowerShell forms without `| Out-String`, which uninstall- // must still remove (permissive execution-context check).+ // must still remove even though they do not work."iex (wt config shell init powershell)","if (Get-Command wt -ErrorAction SilentlyContinue) { Invoke-Expression (& wt config shell init powershell) }",+ // A bare invocation, with nothing consuming the output. Matched+ // because uninstall asks only whether the line invokes the command:+ // this is a worktrunk line whichever way it got there.+ "wt config shell init bash",] {assert!(is_shell_integration_line_for_uninstall_any_cmd(line),@@ -846,6 +914,45 @@ mod tests {}}+ /// Uninstall deletes what it matches, so a line that merely quotes an+ /// integration command must not match — the exec keyword satisfying+ /// `is_execution_context` can sit inside the quoted string itself, leaving+ /// the command's own position as the only thing telling the two apart.+ #[test]+ fn test_any_cmd_rejects_quoted_mention_alongside_exec_keyword() {+ for line in [+ // The user's own alias: `source` is inside the echoed string, and+ // `wt` is an argument to `echo`, not a command.+ r#"alias setup='echo "run: wt config shell init fish | source"'"#,+ // Same shape without the alias wrapper.+ r#"echo "wt config shell init bash | source""#,+ // A real integration line elsewhere on the line does not license+ // deleting a mention that sits in argument position.+ r#"eval "$(direnv hook bash)"; echo "see wt config shell init bash""#,+ ] {+ assert!(+ !is_shell_integration_line_for_uninstall_any_cmd(line),+ "quoted mention should not be claimed for deletion: {line}"+ );+ }+ }++ /// Every line worktrunk writes, and the documented hand-written forms, put+ /// the command in a position the deletion check accepts. Regressions here+ /// strand a working install.+ #[test]+ fn test_any_cmd_detects_every_generated_config_line() {+ for shell in crate::shell::Shell::all() {+ for cmd in ["wt", "git-wt"] {+ let line = shell.config_line(cmd);+ assert!(+ is_shell_integration_line_for_uninstall_any_cmd(&line),+ "uninstall must match its own generated line for {shell}/{cmd}: {line}"+ );+ }+ }+ }+// ------------------------------------------------------------------------// FALSE NEGATIVE: PowerShell block comments// Note: This is actually a FALSE POSITIVE risk (comments matching)diff --git a/tests/integration_tests/configure_shell.rs b/tests/integration_tests/configure_shell.rsindex 7ab6f3b07..30e9f3bcd 100644--- a/tests/integration_tests/configure_shell.rs+++ b/tests/integration_tests/configure_shell.rs@@ -408,6 +408,48 @@ fn test_configure_shell_fish_legacy_conf_d_cleanup(repo: TestRepo, temp_home: Te);}+/// Installing fish integration leaves a user's own `conf.d/wt.fish` alone.+///+/// The legacy cleanup deletes a whole file the user never asked it to touch, so+/// it has to recognize worktrunk's own wrapper rather than any file that+/// mentions the init command. This one names it in a comment and pipes+/// something unrelated to `source` — both substrings a whole-file test would+/// take as proof the file was worktrunk's.+#[rstest]+fn test_configure_shell_fish_preserves_user_conf_d_file(repo: TestRepo, temp_home: TempDir) {+ let conf_d = temp_home.path().join(".config/fish/conf.d");+ fs::create_dir_all(&conf_d).unwrap();+ let user_file = conf_d.join("wt.fish");+ let user_content = "# reminder: set up with wt config shell init fish\nfunction wt_helpers\n cat ~/.aliases | source\nend\n";+ fs::write(&user_file, user_content).unwrap();++ let mut cmd = wt_command();+ repo.configure_wt_cmd(&mut cmd);+ set_temp_home_env(&mut cmd, temp_home.path());+ cmd.env("SHELL", "/bin/fish");+ cmd.args(["config", "shell", "install", "fish", "--yes"])+ .current_dir(repo.root_path());+ let output = cmd.output().unwrap();+ assert!(output.status.success(), "install failed: {output:?}");++ assert!(+ temp_home+ .path()+ .join(".config/fish/functions/wt.fish")+ .exists(),+ "install should still write functions/wt.fish"+ );+ assert!(+ user_file.exists(),+ "install deleted the user's own conf.d/wt.fish"+ );+ assert_eq!(+ fs::read_to_string(&user_file).unwrap(),+ user_content,+ "user's own conf.d/wt.fish must survive install untouched"+ );+}+/// Test that legacy cleanup happens even when new file already exists with correct content////// This handles the case where:@@ -962,13 +1004,14 @@ fn test_uninstall_shell(repo: TestRepo, temp_home: TempDir) {.arg("--yes").current_dir(repo.root_path());- assert_cmd_snapshot!(cmd, @"+ assert_cmd_snapshot!(cmd, @r#"success: trueexit_code: 0----- stdout ---------- stderr -----[32m✓[39m [32mRemoved shell extension & completions for [1mzsh[22m @ [1m~/.zshrc[22m[39m+ [107m [0m [2m[0m[2m[35mif[0m[2m [0m[2m[34mcommand[0m[2m [0m[2m[36m-v[0m[2m wt [0m[2m[36m>[0m[2m/dev/null [0m[2m[33m2[0m[2m>&1; [0m[2m[35mthen[0m[2m [0m[2m[34meval[0m[2m [0m[2m[32m"$([0m[2m[34mcommand[0m[2m wt config shell init zsh)"[0m[2m; [0m[2m[35mfi[0m[2m↳[22m [2mNo [4mbash[24m shell extension & completions in ~/.bashrc[22m[2m↳[22m [2mNo [4mfish[24m shell extension in ~/.config/fish/functions[22m[2m↳[22m [2mNo [4mnu[24m shell extension & completions in ~/.local/share/nushell/vendor/autoload[22m@@ -976,7 +1019,7 @@ fn test_uninstall_shell(repo: TestRepo, temp_home: TempDir) {[32m✓[39m [32mRemoved integration from 1 shell[39m[2m↳[22m [2mRestart shell to complete uninstall[22m- ");+ "#);});// Verify the file no longer contains the integration@@ -1026,21 +1069,23 @@ fn test_uninstall_shell_multiple(repo: TestRepo, temp_home: TempDir) {.arg("--yes").current_dir(repo.root_path());- assert_cmd_snapshot!(cmd, @"+ assert_cmd_snapshot!(cmd, @r#"success: trueexit_code: 0----- stdout ---------- stderr -----[32m✓[39m [32mRemoved shell extension & completions for [1mbash[22m @ [1m~/.bashrc[22m[39m+ [107m [0m [2m[0m[2m[35mif[0m[2m [0m[2m[34mcommand[0m[2m [0m[2m[36m-v[0m[2m wt [0m[2m[36m>[0m[2m/dev/null [0m[2m[33m2[0m[2m>&1; [0m[2m[35mthen[0m[2m [0m[2m[34meval[0m[2m [0m[2m[32m"$([0m[2m[34mcommand[0m[2m wt config shell init bash)"[0m[2m; [0m[2m[35mfi[0m[32m✓[39m [32mRemoved shell extension & completions for [1mzsh[22m @ [1m~/.zshrc[22m[39m+ [107m [0m [2m[0m[2m[35mif[0m[2m [0m[2m[34mcommand[0m[2m [0m[2m[36m-v[0m[2m wt [0m[2m[36m>[0m[2m/dev/null [0m[2m[33m2[0m[2m>&1; [0m[2m[35mthen[0m[2m [0m[2m[34meval[0m[2m [0m[2m[32m"$([0m[2m[34mcommand[0m[2m wt config shell init zsh)"[0m[2m; [0m[2m[35mfi[0m[2m↳[22m [2mNo [4mfish[24m shell extension in ~/.config/fish/functions[22m[2m↳[22m [2mNo [4mnu[24m shell extension & completions in ~/.local/share/nushell/vendor/autoload[22m[2m↳[22m [2mNo [4mfish[24m completions in ~/.config/fish/completions[22m[32m✓[39m [32mRemoved integration from 2 shells[39m[2m↳[22m [2mRestart shell to complete uninstall[22m- ");+ "#);});// Verify both files no longer contain the integration@@ -1261,6 +1306,69 @@ fn test_uninstall_scan_removes_all_worktrunk_zsh_lines(repo: TestRepo, temp_home);}+/// Uninstall deletes lines out of a file the user owns, so a line that merely+/// quotes an integration command must survive — and every line it does take+/// must be named in the output, since `--yes` skips the confirmation.+#[rstest]+fn test_uninstall_preserves_user_lines_quoting_the_init_command(+ repo: TestRepo,+ temp_home: TempDir,+) {+ // Each survivor puts `wt config shell init` in argument position while an+ // exec keyword sits elsewhere on the line — the shape that makes the+ // whole-line execution-context check alone insufficient.+ let survivors = [+ r#"alias setup='echo "run: wt config shell init fish | source"'"#,+ r#"echo "wt config shell init bash | source""#,+ ];+ let zshrc_path = temp_home.path().join(".zshrc");+ fs::write(+ &zshrc_path,+ format!(+ "{}\nif command -v wt >/dev/null 2>&1; then eval \"$(command wt config shell init zsh)\"; fi\n",+ survivors.join("\n"),+ ),+ )+ .unwrap();++ let mut cmd = wt_command();+ repo.configure_wt_cmd(&mut cmd);+ set_temp_home_env(&mut cmd, temp_home.path());+ cmd.env("SHELL", "/bin/zsh");+ cmd.args(["config", "shell", "uninstall", "zsh", "--yes"])+ .current_dir(repo.root_path());++ let output = cmd.output().expect("Failed to execute uninstall");+ assert!(+ output.status.success(),+ "Uninstall should succeed:\nstderr: {}",+ String::from_utf8_lossy(&output.stderr)+ );++ let content = fs::read_to_string(&zshrc_path).unwrap();+ for survivor in survivors {+ assert!(+ content.contains(survivor),+ "User's own line should survive uninstall: {survivor}\nremaining:\n{content}"+ );+ }+ assert!(+ !content.contains("command wt config shell init zsh"),+ "worktrunk's own integration line should be removed:\n{content}"+ );++ // The removed line is named, so a --yes run still shows what it took.+ // The gutter syntax-highlights it, so compare against stripped output.+ let stderr = String::from_utf8_lossy(&output.stderr);+ let plain = regex::Regex::new(r"\x1b\[[0-9;]*m")+ .unwrap()+ .replace_all(&stderr, "");+ assert!(+ plain.contains("command wt config shell init zsh"),+ "Uninstall should show the line it removed:\n{plain}"+ );+}+#[rstest]fn test_uninstall_scan_removes_custom_cmd_fish_files(repo: TestRepo, temp_home: TempDir) {let fish_functions = temp_home.path().join(".config/fish/functions");diff --git a/tests/integration_tests/switch.rs b/tests/integration_tests/switch.rsindex 29de12a15..5c532f786 100644--- a/tests/integration_tests/switch.rs+++ b/tests/integration_tests/switch.rs@@ -5798,8 +5798,12 @@ fn test_switch_pr_azure_fork(#[from(repo_with_remote)] repo: TestRepo) {});}-/// `az repos pr show` reporting "does not exist" hits the dedicated-/// not-found bail in `azure::fetch_pr_info`.+/// A missing PR reaches the user as the `TF401174` line `az` printed.+///+/// `azure::fetch_pr_info` classifies nothing: `az` has no error channel but+/// prose on stderr, so worktrunk reports that prose rather than guessing a+/// cause from it. The three azure error tests each pin the tool's own words+/// surviving to the terminal.#[rstest]fn test_switch_pr_azure_not_found(#[from(repo_with_remote)] repo: TestRepo) {repo.run_git(&[@@ -5950,7 +5954,8 @@ fn test_switch_pr_azure_server_error(#[from(repo_with_remote)] repo: TestRepo) {});}-/// `az repos pr show` reporting a login error hits the dedicated auth bail.+/// An unauthenticated `az` reaches the user as its own "run 'az login'" line,+/// which already names the remedy a paraphrase would have restated.#[rstest]fn test_switch_pr_azure_auth_error(#[from(repo_with_remote)] repo: TestRepo) {repo.run_git(&[@@ -5981,8 +5986,13 @@ fn test_switch_pr_azure_auth_error(#[from(repo_with_remote)] repo: TestRepo) {});}-/// `az repos pr show` failing because the `azure-devops` extension is missing-/// hits the dedicated extension-install bail.+/// A missing `azure-devops` extension reaches the user as `az`'s own line.+///+/// This is the case that cost something: worktrunk used to append the exact+/// `az extension add --name azure-devops` command, which `az` doesn't print.+/// Detecting it needs prose matching — no code, no exit status distinguishes+/// it — and the extension is named in the text `az` does print, so the+/// remaining gap is the install verb rather than the package.#[rstest]fn test_switch_pr_azure_extension_not_installed(#[from(repo_with_remote)] repo: TestRepo) {repo.run_git(&[diff --git a/tests/snapshots/integration__integration_tests__configure_shell__uninstall_shell_dry_run.snap b/tests/snapshots/integration__integration_tests__configure_shell__uninstall_shell_dry_run.snapindex 747e98dd5..3f3ac844d 100644--- a/tests/snapshots/integration__integration_tests__configure_shell__uninstall_shell_dry_run.snap+++ b/tests/snapshots/integration__integration_tests__configure_shell__uninstall_shell_dry_run.snap@@ -10,6 +10,7 @@ info:- "--dry-run"env:APPDATA: "[TEST_CONFIG_HOME]"+ CLAUDE_CONFIG_DIR: "[TEST_CLAUDE_CONFIG]"CLICOLOR_FORCE: "1"COLUMNS: "500"GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"@@ -39,6 +40,7 @@ info:WORKTRUNK_TEST_GEMINI_INSTALLED: "0"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_SKIP_URL_HEALTH_CHECK: "1"@@ -49,5 +51,6 @@ success: trueexit_code: 0----- stdout -----[2m○[22m Will remove shell extension & completions for [1mzsh[0m @ [1m~/.zshrc[0m+[107m [0m [2m[0m[2m[35mif[0m[2m [0m[2m[34mcommand[0m[2m [0m[2m[36m-v[0m[2m wt [0m[2m[36m>[0m[2m/dev/null [0m[2m[33m2[0m[2m>&1; [0m[2m[35mthen[0m[2m [0m[2m[34meval[0m[2m [0m[2m[32m"$([0m[2m[34mcommand[0m[2m wt config shell init zsh)"[0m[2m; [0m[2m[35mfi[0m----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__configure_shell__uninstall_shell_dry_run_multiple.snap b/tests/snapshots/integration__integration_tests__configure_shell__uninstall_shell_dry_run_multiple.snapindex 494f4eebb..d193234a6 100644--- a/tests/snapshots/integration__integration_tests__configure_shell__uninstall_shell_dry_run_multiple.snap+++ b/tests/snapshots/integration__integration_tests__configure_shell__uninstall_shell_dry_run_multiple.snap@@ -9,6 +9,7 @@ info:- "--dry-run"env:APPDATA: "[TEST_CONFIG_HOME]"+ CLAUDE_CONFIG_DIR: "[TEST_CLAUDE_CONFIG]"CLICOLOR_FORCE: "1"COLUMNS: "500"GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"@@ -38,6 +39,7 @@ info:WORKTRUNK_TEST_GEMINI_INSTALLED: "0"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_SKIP_URL_HEALTH_CHECK: "1"@@ -48,6 +50,8 @@ success: trueexit_code: 0----- stdout -----[2m○[22m Will remove shell extension & completions for [1mbash[0m @ [1m~/.bashrc[0m+[107m [0m [2m[0m[2m[35mif[0m[2m [0m[2m[34mcommand[0m[2m [0m[2m[36m-v[0m[2m wt [0m[2m[36m>[0m[2m/dev/null [0m[2m[33m2[0m[2m>&1; [0m[2m[35mthen[0m[2m [0m[2m[34meval[0m[2m [0m[2m[32m"$([0m[2m[34mcommand[0m[2m wt config shell init bash)"[0m[2m; [0m[2m[35mfi[0m[2m○[22m Will remove shell extension & completions for [1mzsh[0m @ [1m~/.zshrc[0m+[107m [0m [2m[0m[2m[35mif[0m[2m [0m[2m[34mcommand[0m[2m [0m[2m[36m-v[0m[2m wt [0m[2m[36m>[0m[2m/dev/null [0m[2m[33m2[0m[2m>&1; [0m[2m[35mthen[0m[2m [0m[2m[34meval[0m[2m [0m[2m[32m"$([0m[2m[34mcommand[0m[2m wt config shell init zsh)"[0m[2m; [0m[2m[35mfi[0m----- stderr -----diff --git a/tests/snapshots/integration__integration_tests__switch__switch_pr_azure_auth_error.snap b/tests/snapshots/integration__integration_tests__switch__switch_pr_azure_auth_error.snapindex 089ed2b7b..71387b0be 100644--- a/tests/snapshots/integration__integration_tests__switch__switch_pr_azure_auth_error.snap+++ b/tests/snapshots/integration__integration_tests__switch__switch_pr_azure_auth_error.snap@@ -7,6 +7,7 @@ info:- "pr:101"env:APPDATA: "[TEST_CONFIG_HOME]"+ CLAUDE_CONFIG_DIR: "[TEST_CLAUDE_CONFIG]"CLICOLOR_FORCE: "1"COLUMNS: "500"GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"@@ -35,6 +36,7 @@ info:WORKTRUNK_TEST_GEMINI_INSTALLED: "0"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_SKIP_URL_HEALTH_CHECK: "1"@@ -47,4 +49,5 @@ exit_code: 1----- stderr -----[36m◎[39m [36mFetching PR #101...[39m-[31m✗[39m [31mAzure CLI not authenticated; run az login[39m+[31m✗[39m [31maz repos pr show failed for PR #101[39m+[107m [0m Please run 'az login' to setup account.diff --git a/tests/snapshots/integration__integration_tests__switch__switch_pr_azure_extension_not_installed.snap b/tests/snapshots/integration__integration_tests__switch__switch_pr_azure_extension_not_installed.snapindex 02b4a6186..d90f747c8 100644--- a/tests/snapshots/integration__integration_tests__switch__switch_pr_azure_extension_not_installed.snap+++ b/tests/snapshots/integration__integration_tests__switch__switch_pr_azure_extension_not_installed.snap@@ -7,6 +7,7 @@ info:- "pr:101"env:APPDATA: "[TEST_CONFIG_HOME]"+ CLAUDE_CONFIG_DIR: "[TEST_CLAUDE_CONFIG]"CLICOLOR_FORCE: "1"COLUMNS: "500"GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"@@ -35,6 +36,7 @@ info:WORKTRUNK_TEST_GEMINI_INSTALLED: "0"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_SKIP_URL_HEALTH_CHECK: "1"@@ -47,4 +49,5 @@ exit_code: 1----- stderr -----[36m◎[39m [36mFetching PR #101...[39m-[31m✗[39m [31mAzure DevOps CLI extension not installed; run: az extension add --name azure-devops[39m+[31m✗[39m [31maz repos pr show failed for PR #101[39m+[107m [0m ERROR: 'repos' is misspelled or not recognized by the system. The command requires the azure-devops extension.diff --git a/tests/snapshots/integration__integration_tests__switch__switch_pr_azure_not_found.snap b/tests/snapshots/integration__integration_tests__switch__switch_pr_azure_not_found.snapindex 0caba935b..6e96076e6 100644--- a/tests/snapshots/integration__integration_tests__switch__switch_pr_azure_not_found.snap+++ b/tests/snapshots/integration__integration_tests__switch__switch_pr_azure_not_found.snap@@ -7,6 +7,7 @@ info:- "pr:9999"env:APPDATA: "[TEST_CONFIG_HOME]"+ CLAUDE_CONFIG_DIR: "[TEST_CLAUDE_CONFIG]"CLICOLOR_FORCE: "1"COLUMNS: "500"GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"@@ -35,6 +36,7 @@ info:WORKTRUNK_TEST_GEMINI_INSTALLED: "0"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_SKIP_URL_HEALTH_CHECK: "1"@@ -47,4 +49,5 @@ exit_code: 1----- stderr -----[36m◎[39m [36mFetching PR #9999...[39m-[31m✗[39m [31mAzure DevOps PR #9999 not found[39m+[31m✗[39m [31maz repos pr show failed for PR #9999[39m+[107m [0m TF401174: The requested pull request was not found, or it does not exist.