From 90c2b195c77d8c8b2c37ade6155f936c52b3564e Mon Sep 17 00:00:00 2001 From: Lee Campbell Date: Sun, 1 Mar 2026 20:44:20 +0800 Subject: [PATCH] Add structured PR body with Closes keyword to auto-close issues Build PR description from plan artifacts (brief.md and task.md) instead of posting them as separate comments. Append `Closes #N` so GitHub automatically closes the linked issue on merge. Co-Authored-By: Claude Opus 4.6 --- .devcontainer/agent-loop.sh | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/.devcontainer/agent-loop.sh b/.devcontainer/agent-loop.sh index 0d4eed7..edf1d25 100644 --- a/.devcontainer/agent-loop.sh +++ b/.devcontainer/agent-loop.sh @@ -75,7 +75,31 @@ case "$STATE" in exit 1 fi - if ! PR_URL=$(GH_TOKEN="$GH_TOKEN_UPSTREAM" gh pr create --fill \ + PR_TITLE="feat(#${ISSUE_NUM}): $(gh issue view "$ISSUE_NUM" \ + --repo "$UPSTREAM_REPO" --json title --jq .title)" + + # Build PR body from plan artifacts + PR_BODY="" + if [ -f /tmp/plan-backup/done/brief.md ]; then + PR_BODY=$(cat /tmp/plan-backup/done/brief.md) + fi + if [ -f /tmp/plan-backup/done/task.md ]; then + PR_BODY="${PR_BODY} + +
+Task breakdown + +$(cat /tmp/plan-backup/done/task.md) + +
" + fi + PR_BODY="${PR_BODY} + +Closes #${ISSUE_NUM}" + + if ! PR_URL=$(GH_TOKEN="$GH_TOKEN_UPSTREAM" gh pr create \ + --title "$PR_TITLE" \ + --body "$PR_BODY" \ --repo "$UPSTREAM_REPO" \ --head "${GIT_USER_NAME}:${BRANCH}" \ --base "$UPSTREAM_BASE_BRANCH"); then @@ -85,17 +109,6 @@ case "$STATE" in exit 1 fi - PR_NUM=$(echo "$PR_URL" | grep -oP '\d+$') - - [ -f /tmp/plan-backup/done/brief.md ] && \ - GH_TOKEN="$GH_TOKEN_UPSTREAM" gh pr comment "$PR_NUM" \ - --repo "$UPSTREAM_REPO" \ - --body-file /tmp/plan-backup/done/brief.md - [ -f /tmp/plan-backup/done/task.md ] && \ - GH_TOKEN="$GH_TOKEN_UPSTREAM" gh pr comment "$PR_NUM" \ - --repo "$UPSTREAM_REPO" \ - --body-file /tmp/plan-backup/done/task.md - if [ -n "$ISSUE_NUM" ]; then GH_TOKEN="$GH_TOKEN_UPSTREAM" gh issue comment "$ISSUE_NUM" \ --repo "$UPSTREAM_REPO" --body "PR created: $PR_URL"