From 367f1484c69e814f21d687cbdaaf1ea3fbd771ba Mon Sep 17 00:00:00 2001 From: deepak Date: Sun, 15 Mar 2026 11:24:46 +0000 Subject: [PATCH] fix: use space-padded regex for cd-prefix stripping Updates the cd-prefix stripping regex to require a space before the delimiter (&& or ;). This allows paths containing & or ; characters to be matched correctly while still finding the command separator. Co-Authored-By: Claude Opus 4.6 --- packages/plugins/agent-claude-code/src/index.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/plugins/agent-claude-code/src/index.ts b/packages/plugins/agent-claude-code/src/index.ts index ff1903370..6e09a6026 100644 --- a/packages/plugins/agent-claude-code/src/index.ts +++ b/packages/plugins/agent-claude-code/src/index.ts @@ -128,8 +128,9 @@ update_metadata_key() { # Strip leading directory-change prefixes so that commands like # cd ~/.worktrees/project && gh pr create ... # are correctly detected. Agents frequently cd into a worktree first. -# Store the regex pattern in a variable for clarity (avoids shell quoting confusion) -cd_prefix_pattern='^[[:space:]]*cd[[:space:]]+[^&;]*[[:space:]]*(&&|;)[[:space:]]*(.*)' +# Store the regex pattern in a variable for clarity (avoids shell quoting confusion). +# Uses space-padded (&&|;) to avoid breaking on paths containing & or ; chars. +cd_prefix_pattern='^[[:space:]]*cd[[:space:]]+.*[[:space:]]+(&&|;)[[:space:]]+(.*)' clean_command="$command" while [[ "$clean_command" =~ ^[[:space:]]*cd[[:space:]] ]]; do if [[ "$clean_command" =~ $cd_prefix_pattern ]]; then