From 663e44a82a1467cf635f24d23a6dfd7f64cba12a Mon Sep 17 00:00:00 2001 From: shokollm <270575765+shokollm@users.noreply.github.com> Date: Wed, 8 Apr 2026 02:15:37 +0000 Subject: [PATCH 1/2] fix: add PR merge conflict check and review reading to dev agent workflow Dev agent should: 1. Check if PR has merge conflicts before asking for review 2. Read review comments and incorporate feedback 3. Understand review states: APPROVED = ready to merge, COMMENT = feedback to address This prevents approving a PR that has conflicts, and ensures dev agents respond to reviewer comments appropriately. --- skills/kugetsu/scripts/kugetsu-session.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/skills/kugetsu/scripts/kugetsu-session.sh b/skills/kugetsu/scripts/kugetsu-session.sh index dfd05ac..0960f87 100755 --- a/skills/kugetsu/scripts/kugetsu-session.sh +++ b/skills/kugetsu/scripts/kugetsu-session.sh @@ -280,6 +280,11 @@ Workflow: 1. Read the issue at $instance/$owner/$repo/issues/$number AND all comments on that issue 2. Check if a PR already exists for this issue - If PR exists and is open, review it and learn from it + - CRITICAL: Check if PR has merge conflicts before asking for review: + - Use: curl -s "https://$instance/api/v1/repos/$owner/$repo/pulls/$number" -H "Authorization: Bearer \$GITEA_TOKEN" + - If "mergeable": false, there ARE conflicts - you MUST resolve them FIRST + - To resolve: cd to worktree, git fetch origin, git rebase origin/main, resolve conflicts, git rebase --continue, git push --force-with-lease + - Only after resolving conflicts (mergeable: true) can you ask for review - If PR makes sense to continue, work on it instead - If PR is not worth continuing, create a new branch/PR but explain in PR description why you're creating a new one instead of continuing the existing PR 3. Read README.md (if exists) to understand the general concept of this repository @@ -314,6 +319,11 @@ Workflow: 1. Read the issue at $instance/$owner/$repo/issues/$number AND all comments on that issue 2. Check if a PR already exists for this issue - If PR exists and is open, review it and learn from it + - CRITICAL: Check if PR has merge conflicts before asking for review: + - Use: curl -s "https://$instance/api/v1/repos/$owner/$repo/pulls/$number" -H "Authorization: Bearer \$GITEA_TOKEN" + - If "mergeable": false, there ARE conflicts - you MUST resolve them FIRST + - To resolve: cd to worktree, git fetch origin, git rebase origin/main, resolve conflicts, git rebase --continue, git push --force-with-lease + - Only after resolving conflicts (mergeable: true) can you ask for review - If PR makes sense to continue, work on it instead - If PR is not worth continuing, create a new branch/PR but explain in PR description why you're creating a new one instead of continuing the existing PR 3. Read README.md (if exists) to understand the general concept of this repository @@ -331,6 +341,8 @@ Tools for PR interaction: - Post issue/PR comment: curl -X POST "https://$instance/api/v1/repos/$owner/$repo/issues/$number/comments" -H "Authorization: Bearer \$GITEA_TOKEN" -H "Content-Type: application/json" -d '{"body":"Your comment"}' - List PR comments: curl -s "https://$instance/api/v1/repos/$owner/$repo/issues/$number/comments" -H "Authorization: Bearer \$GITEA_TOKEN" - List PR reviews: curl -s "https://$instance/api/v1/repos/$owner/$repo/pulls/$number/reviews" -H "Authorization: Bearer \$GITEA_TOKEN" + - IMPORTANT: After listing reviews, READ the review comments and incorporate feedback + - Check for review state: "APPROVED" means ready to merge, "COMMENT" means feedback to address - Merge PR (only with approval): tea pr merge --repo $owner/$repo $number --style merge - MERGING requires approval first! Check for: approval in reviews, OR "lgtm"/"approved" in comments - If no approval, ask reviewer to approve first before merging From c9bdc0dd88a7dd3543b3062a48243396617c40b6 Mon Sep 17 00:00:00 2001 From: shokollm <270575765+shokollm@users.noreply.github.com> Date: Wed, 8 Apr 2026 02:35:30 +0000 Subject: [PATCH 2/2] refactor: unify duplicated prompt sections using conditional variables - Extract conflict_check and delegator_section as conditional variables - Single heredoc instead of duplicate blocks - Resolve code duplication raised in PR comment --- skills/kugetsu/scripts/kugetsu-session.sh | 68 ++++++++--------------- 1 file changed, 22 insertions(+), 46 deletions(-) diff --git a/skills/kugetsu/scripts/kugetsu-session.sh b/skills/kugetsu/scripts/kugetsu-session.sh index 0960f87..91113e7 100755 --- a/skills/kugetsu/scripts/kugetsu-session.sh +++ b/skills/kugetsu/scripts/kugetsu-session.sh @@ -270,60 +270,37 @@ build_dev_agent_message() { local number=$(echo "$issue_ref" | grep -oE '#[0-9]+$' | tr -d '#') local worktree_path=$(issue_ref_to_worktree_path "$issue_ref") + local conflict_check="" + local review_notes="" + local delegator_header="" + local delegator_footer="" if [ -n "$user_message" ]; then - cat <