Repository navigation
fix(skills): derive repo slug dynamically in /sweep instead of hardcoding (#1966) - #2185
Conversation
…ding (#1966) /sweep hardcoded --repo optave/codegraph in 23 places throughout the skill (gh pr list, every gh api repos/.../ call, gh label create, gh issue create). The actual repo is optave/ops-codegraph-tool, so every invocation silently targeted the wrong repository unless manually caught. /resolve already derives the repo slug dynamically via `gh repo view --json nameWithOwner` -- mirror that approach: Step 1 now detects $REPO once and uses it for the PR-discovery gh pr list call. Since /sweep's PR-processing instructions are a prompt template copied verbatim into each per-PR subagent (not literal executable bash), the 23 embedded gh/gh api commands now use a <repo> placeholder -- consistent with the existing <number>/<comment-id> placeholder idiom in the same file -- and Step 2 explicitly instructs the orchestrator to substitute the detected $REPO into every subagent's prompt before launch. Found the same bug pattern in dogfood/SKILL.md (3 genuine instances, distinct from its many legitimate @optave/codegraph npm-package-name references) -- filed separately as #2184 since it's out of scope for this issue. Closes #1966 docs check acknowledged: skill-file-only fix, no README/CLAUDE.md/ROADMAP surface change
| ```bash | ||
| gh pr list --repo optave/codegraph --state open --json number,title,headRefName,baseRefName,mergeable,statusCheckRollup,reviewDecision --limit 50 | ||
| REPO=$(gh repo view --json nameWithOwner -q .nameWithOwner 2>/dev/null \ | ||
| || git remote get-url origin | sed -E 's|.*github\.com[:/](.+)(\.git)?$|\1|') |
There was a problem hiding this comment.
Fixed — switched to a two-pass sed: the first pass only prints on a genuine github.com match (strict alternation on git@github.com:/https://github.com/, non-matching input yields empty output), and the second pass unconditionally strips a trailing .git. Confirmed via direct test against https/git@ URLs with and without .git suffix.
| || git remote get-url origin | sed -E 's|.*github\.com[:/](.+)(\.git)?$|\1|') | ||
| if [ -z "$REPO" ]; then | ||
| echo "ERROR: could not detect GitHub repo slug — ensure 'gh' is authenticated or 'origin' points to GitHub" | ||
| exit 1 |
There was a problem hiding this comment.
There was a problem hiding this comment.
Fixed by the same change — the first sed pass now requires a strict github.com prefix match and uses -n ... p, so a non-GitHub remote correctly produces empty output (caught by the existing -z guard) instead of the unchanged raw URL passing through as a false-valid repo slug.
Greptile SummaryThe sweep skill now discovers the active GitHub repository dynamically and propagates that slug through all PR-processing commands.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Important Files Changed
Reviews (2): Last reviewed commit: "fix: harden /sweep's repo-detection fall..." | Re-trigger Greptile |
The origin-URL fallback (only exercised when gh repo view fails) had two bugs Greptile caught in review: 1. The greedy (.+) capture swallowed a trailing .git suffix before the optional (\.git)? group ever matched it, so a standard https://github.com/owner/repo.git or git@github.com:owner/repo.git remote resolved to owner/repo.git instead of owner/repo. 2. A non-GitHub origin silently passed through unchanged (sed leaves non-matching lines as-is), which is non-empty and so bypassed the -z empty-value guard instead of being treated as detection failure. Switch to a two-pass sed: the first pass only prints on a genuine github.com match (so a non-GitHub remote correctly yields empty output), and the second pass unconditionally strips a trailing .git -- sidestepping the greedy-capture problem without needing a non-greedy quantifier (confirmed non-portable: +? errors under both BSD and GNU sed's -E mode, since lazy quantifiers aren't POSIX ERE). /resolve has the identical latent bug in two places but wasn't touched by this PR's diff -- filed separately as #2186. docs check acknowledged: skill-file-only fix, no README/CLAUDE.md/ROADMAP surface change
Summary
Verification
Closes #1966