Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 25 additions & 12 deletions .devcontainer/agent-loop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}

<details>
<summary>Task breakdown</summary>

$(cat /tmp/plan-backup/done/task.md)

</details>"
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
Expand All @@ -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"
Expand Down