From f2815d63f18ac74f1cc9fb6411dc026641873947 Mon Sep 17 00:00:00 2001 From: carlos-alm Date: Sat, 8 Aug 2026 07:22:35 -0600 Subject: [PATCH 1/2] fix(skills): resolve's repo-detection fallback regex retains .git suffix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #2186 Greptile caught the identical flaw in PR #2185 while reviewing the same fallback pattern being added to /sweep. /resolve had it in two places (gh repo view's fallback when gh isn't authenticated): REPO=$(gh repo view --json nameWithOwner -q .nameWithOwner 2>/dev/null \ || git remote get-url origin | sed -E 's|.*github\.com[:/](.+)(\.git)?$|\1|') 1. The greedy (.+) capture swallows .git before the optional (\.git)? group ever matches it, so a standard https://.../repo.git or git@github.com:owner/repo.git remote resolves to "owner/repo.git" instead of "owner/repo" — every subsequent gh --repo call then targets an invalid slug. 2. When origin isn't a github.com URL at all, plain `sed 's|pattern| replacement|'` leaves a non-matching line unchanged, so the raw (wrong) URL becomes $REPO — non-empty, so the existing `-z` guard doesn't catch it, and the skill proceeds with a garbage repo identifier instead of failing loudly. Mirrors the exact fix already applied to /sweep in PR #2185: a two-pass sed (non-greedy quantifiers aren't POSIX ERE — `+?` errors on BSD sed's -E and isn't GNU-portable either). The first pass only prints when the URL is a genuine github.com remote (so a non-GitHub origin correctly produces empty output, caught by the -z guard); the second unconditionally strips a trailing .git, sidestepping the greedy-capture problem entirely. --- .claude/skills/resolve/SKILL.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.claude/skills/resolve/SKILL.md b/.claude/skills/resolve/SKILL.md index f7e9f1075..2eebef027 100644 --- a/.claude/skills/resolve/SKILL.md +++ b/.claude/skills/resolve/SKILL.md @@ -59,7 +59,9 @@ fi # Detect repo slug dynamically so the skill works in any fork or renamed org REPO=$(gh repo view --json nameWithOwner -q .nameWithOwner 2>/dev/null \ - || git remote get-url origin | sed -E 's|.*github\.com[:/](.+)(\.git)?$|\1|') + || git remote get-url origin 2>/dev/null \ + | sed -nE 's#^(git@github\.com:|https://github\.com/)([^/]+/[^/]+)/?$#\2#p' \ + | sed -E 's/\.git$//') if [ -z "$REPO" ]; then echo "ERROR: could not detect GitHub repo slug — ensure 'gh' is authenticated or 'origin' points to GitHub" exit 1 @@ -78,7 +80,9 @@ Persist PR metadata for use in later phases (shell variables don't survive acros ```bash PR_NUMBER=$(echo "${ARGUMENTS:-}" | tr -d '[:space:]#') REPO=$(gh repo view --json nameWithOwner -q .nameWithOwner 2>/dev/null \ - || git remote get-url origin | sed -E 's|.*github\.com[:/](.+)(\.git)?$|\1|') + || git remote get-url origin 2>/dev/null \ + | sed -nE 's#^(git@github\.com:|https://github\.com/)([^/]+/[^/]+)/?$#\2#p' \ + | sed -E 's/\.git$//') mkdir -p .codegraph/resolve # Trap ensures .codegraph/resolve/ is always cleaned up on non-zero exit, even after a crash. # This prevents stale state from corrupting a future re-run (Phase 1 reads head-branch / base-branch From e2e69c29a30cfb129ee5b84f636b6edde9aab042 Mon Sep 17 00:00:00 2001 From: carlos-alm Date: Sat, 8 Aug 2026 07:46:34 -0600 Subject: [PATCH 2/2] fix(skills): resolve fallback regex also accept ssh:// GitHub remotes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Greptile flagged (PR #2362) that the anchored two-pass sed only accepted git@github.com:owner/repo and https://github.com/owner/repo, silently rejecting ssh://git@github.com/owner/repo — a valid GitHub remote URL form the OLD (buggy) regex happened to accept via its permissive prefix match. A genuine regression, not a pre-existing gap. Added it as a third alternative in the prefix group. Filed #2363 for the identical gap in /sweep's PR #2185, the original source of this fallback pattern — out of scope for this PR. --- .claude/skills/resolve/SKILL.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.claude/skills/resolve/SKILL.md b/.claude/skills/resolve/SKILL.md index 2eebef027..185f6bffd 100644 --- a/.claude/skills/resolve/SKILL.md +++ b/.claude/skills/resolve/SKILL.md @@ -60,7 +60,7 @@ fi # Detect repo slug dynamically so the skill works in any fork or renamed org REPO=$(gh repo view --json nameWithOwner -q .nameWithOwner 2>/dev/null \ || git remote get-url origin 2>/dev/null \ - | sed -nE 's#^(git@github\.com:|https://github\.com/)([^/]+/[^/]+)/?$#\2#p' \ + | sed -nE 's#^(git@github\.com:|https://github\.com/|ssh://git@github\.com/)([^/]+/[^/]+)/?$#\2#p' \ | sed -E 's/\.git$//') if [ -z "$REPO" ]; then echo "ERROR: could not detect GitHub repo slug — ensure 'gh' is authenticated or 'origin' points to GitHub" @@ -81,7 +81,7 @@ Persist PR metadata for use in later phases (shell variables don't survive acros PR_NUMBER=$(echo "${ARGUMENTS:-}" | tr -d '[:space:]#') REPO=$(gh repo view --json nameWithOwner -q .nameWithOwner 2>/dev/null \ || git remote get-url origin 2>/dev/null \ - | sed -nE 's#^(git@github\.com:|https://github\.com/)([^/]+/[^/]+)/?$#\2#p' \ + | sed -nE 's#^(git@github\.com:|https://github\.com/|ssh://git@github\.com/)([^/]+/[^/]+)/?$#\2#p' \ | sed -E 's/\.git$//') mkdir -p .codegraph/resolve # Trap ensures .codegraph/resolve/ is always cleaned up on non-zero exit, even after a crash.