From cb359dc99694c8e16835df4e0b72e12c8a3f055f Mon Sep 17 00:00:00 2001 From: wenshao Date: Tue, 7 Apr 2026 07:25:48 +0800 Subject: [PATCH] fix(review): default remote for PR numbers + fork-aware autofix push MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Pure integer PR numbers default to origin (no URL-based remote matching available). URL-based PRs use the matched remote. 2. Autofix push uses matched remote instead of hardcoded origin. Push failure is expected for fork PRs where user lacks push access — handled gracefully with informative message. Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/core/src/skills/bundled/review/SKILL.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/src/skills/bundled/review/SKILL.md b/packages/core/src/skills/bundled/review/SKILL.md index 06a680a18..819a6e44b 100644 --- a/packages/core/src/skills/bundled/review/SKILL.md +++ b/packages/core/src/skills/bundled/review/SKILL.md @@ -40,7 +40,7 @@ Based on the remaining arguments: - **PR number or same-repo URL** (e.g., `123` or a URL whose owner/repo matches the current repo — cross-repo URLs are handled by the lightweight mode above): - **Create an ephemeral worktree** to avoid modifying the user's working tree. This eliminates all stash/checkout/restore complexity: 1. **Clean up stale worktree** from a previously interrupted review (if any): if `.qwen/tmp/review-pr-` exists, remove it with `git worktree remove .qwen/tmp/review-pr- --force` and delete the stale ref `git branch -D qwen-review/pr- 2>/dev/null || true`. This ensures a fresh start. - 2. Fetch the PR branch into a unique local ref: `git fetch pull//head:qwen-review/pr-` where `` is the matched remote from Step 1 (usually `origin`, but could be `upstream` for fork-based workflows). Do NOT use `gh pr checkout` — it modifies the current working tree. If fetch fails (auth, network, PR doesn't exist), inform the user and stop. + 2. Fetch the PR branch into a unique local ref: `git fetch pull//head:qwen-review/pr-` where `` is the matched remote from the URL-based detection above, or `origin` by default for pure integer PR numbers. Do NOT use `gh pr checkout` — it modifies the current working tree. If fetch fails (auth, network, PR doesn't exist), inform the user and stop. 3. Get the PR's remote branch name for later push: `gh pr view --json headRefName --jq '.headRefName'`. If this fails, inform the user and stop. 4. Create a temporary worktree: `git worktree add .qwen/tmp/review-pr- qwen-review/pr-`. If this fails, inform the user and stop. 5. All subsequent steps (linting, agents, build/test, autofix) operate in this worktree directory, not the user's working tree. Cache and reports (Step 10) are written to the **main project directory**, not the worktree. @@ -369,7 +369,7 @@ If there are **Critical** or **Suggestion** findings with clear, unambiguous fix **Important**: - Do NOT auto-fix without user confirmation. Do NOT auto-fix findings marked as "Nice to have" or low-confidence findings. -- If reviewing a PR (worktree mode), autofix modifies files in the **worktree**, not the user's working tree. After applying fixes, commit and push from the worktree: `cd && git add && git commit -m "fix: apply auto-fixes from /review" && git push origin HEAD:` (use the remote branch name obtained in Step 1). Inform the user: "Auto-fixes committed and pushed to the PR branch." If the commit or push fails, inform the user: "Auto-fix commit/push failed. The fixes remain in the worktree at ``. You can inspect, commit, and push manually." Step 9 (PR comments) may still proceed, but **skip Step 11 worktree cleanup** to preserve the uncommitted fixes for manual recovery. +- If reviewing a PR (worktree mode), autofix modifies files in the **worktree**, not the user's working tree. After applying fixes, commit from the worktree: `cd && git add && git commit -m "fix: apply auto-fixes from /review"`. Then attempt to push: `git push HEAD:` (use the remote and branch name from Step 1). **Note**: push may fail if the PR is from a fork and the user doesn't have push access to the source repo — this is expected. Inform the user of the outcome: if push succeeds → "Auto-fixes committed and pushed to the PR branch." If push fails → "Auto-fix committed locally but push failed (you may not have push access to this repo). The commit is in the worktree at ``. You can push manually or create a new PR." Step 9 (PR comments) may still proceed, but **skip Step 11 worktree cleanup** to preserve the commit for manual recovery. ## Step 9: Post PR inline comments (only if `--comment` flag was set)