fix(workflow): auto-assign issues and prs (#2271)

This commit is contained in:
Steven Enamakel
2026-05-19 19:56:44 -07:00
committed by GitHub
parent ded40b5c45
commit ddc33a58eb
8 changed files with 62 additions and 6 deletions
+5 -1
View File
@@ -11,6 +11,10 @@ Usage: pnpm deep-work <command> [args...]
Full workflow automation for GitHub issues using worktrees and AI agents.
By default `start` auto-assigns the issue to `@me`, and PR creation steps
auto-assign the created PR to `@me`.
Set `DEEP_WORK_AUTO_ASSIGN=0` (or `WORK_AUTO_ASSIGN=0`) to opt out.
Commands:
start <issue-number> Start full workflow for an issue
pick Smart issue selection + start workflow
@@ -64,4 +68,4 @@ case "$cmd" in
usage >&2
exit 1
;;
esac
esac
+11 -1
View File
@@ -10,6 +10,7 @@ here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$here/lib.sh"
issue="${1:-}"
auto_assign="${DEEP_WORK_AUTO_ASSIGN:-${WORK_AUTO_ASSIGN:-1}}"
# If no issue provided, try to detect from current directory
if [ -z "$issue" ]; then
@@ -208,6 +209,11 @@ ${body}
--base main \
--repo "$repo")
pr_number="${pr_url##*/}"
if [ "$auto_assign" = "1" ]; then
gh_assign_self_pr "$pr_number" "$repo"
fi
echo "[deep-work] 📝 PR created: $pr_url"
else
echo "[deep-work] ✅ PR already exists"
@@ -288,4 +294,8 @@ fi
echo ""
echo "[deep-work] 🎯 Continue session complete!"
echo "[deep-work] Use 'pnpm deep-work continue $issue' to resume anytime."
if worktree_exists "$issue"; then
echo "[deep-work] Use 'pnpm deep-work continue $issue' to resume anytime."
else
echo "[deep-work] Worktree was cleaned up. Use 'pnpm deep-work start $issue' to begin again."
fi
+3 -3
View File
@@ -6,8 +6,8 @@ set -euo pipefail
# Source the existing review lib for repo resolution
here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
repo_root="$(cd "$here/../.." && pwd)"
# shellcheck source=../review/lib.sh
source "$repo_root/scripts/review/lib.sh"
# shellcheck source=../shortcuts/review/lib.sh
source "$repo_root/scripts/shortcuts/review/lib.sh"
# Worktree utilities
worktree_dir_for_issue() {
@@ -205,4 +205,4 @@ run_quality_checks() {
fi
echo "[deep-work] ✅ all quality checks passed"
}
}
+11 -1
View File
@@ -42,6 +42,7 @@ issue="$1"
shift
repo=$(resolve_deep_work_repo)
auto_assign="${DEEP_WORK_AUTO_ASSIGN:-${WORK_AUTO_ASSIGN:-1}}"
echo "[deep-work] 🚀 Starting full workflow for issue #$issue from $repo"
@@ -57,6 +58,10 @@ echo "[deep-work] fetching issue #$issue from $repo..."
issue_json=$(gh issue view "$issue" -R "$repo" \
--json number,title,body,labels,state,url,assignees)
if [ "$auto_assign" = "1" ]; then
gh_assign_self_issue "$issue" "$repo"
fi
state=$(jq -r '.state' <<<"$issue_json")
if [ "$state" != "OPEN" ]; then
echo "[deep-work] ⚠️ issue #$issue is $state — continuing anyway" >&2
@@ -304,6 +309,11 @@ pr_url=$(gh pr create \
--base main \
--repo "$repo")
pr_number="${pr_url##*/}"
if [ "$auto_assign" = "1" ]; then
gh_assign_self_pr "$pr_number" "$repo"
fi
echo "[deep-work] 📝 draft PR created: $pr_url"
# Step 10: Review cycle
@@ -376,4 +386,4 @@ echo ""
echo "Next steps:"
echo "- Monitor PR for reviewer feedback"
echo "- Address any review comments"
echo "- Merge when approved"
echo "- Merge when approved"
+20
View File
@@ -28,6 +28,26 @@ require() {
done
}
gh_assign_self_issue() {
local issue="$1"
local repo="$2"
if gh issue edit "$issue" -R "$repo" --add-assignee "@me" >/dev/null 2>&1; then
info "assigned issue #$issue to @me"
else
warn "could not assign issue #$issue to @me; continuing"
fi
}
gh_assign_self_pr() {
local pr="$1"
local repo="$2"
if gh pr edit "$pr" -R "$repo" --add-assignee "@me" >/dev/null 2>&1; then
info "assigned PR #$pr to @me"
else
warn "could not assign PR #$pr to @me; continuing"
fi
}
# Summarize free-form text via a local LLM CLI (expects `-p <prompt>`).
# Usage: summarize_text <tool> <input>
# Tools used here: gemini (default for summaries), claude, or any CLI that
+5
View File
@@ -35,8 +35,13 @@ and `pnpm work start 1234 …` are equivalent.
`--agent cursor` or `--agent cursor-agent`, it uses
`cursor-agent --yolo`.
By default the script also tries to assign the issue to `@me` through GitHub
as soon as work starts.
## Config
- `WORK_REPO=owner/name` — override the target repo.
- `WORK_BRANCH_PREFIX=issue` — branch is `<prefix>/<num>-<slug>`.
- `WORK_AUTO_ASSIGN=1` — auto-assign the issue to `@me` when work starts. Set
to `0` to disable.
- Requires `git`, `gh`, `jq`, plus the agent CLI (default `claude`).
+2
View File
@@ -37,6 +37,8 @@ Env:
scripts/shortcuts/review.
WORK_BRANCH_PREFIX=issue Branch name is <prefix>/<num>-<slug> (default:
issue).
WORK_AUTO_ASSIGN=1 Auto-assign the issue to `@me` when work
starts. Set to `0` to disable.
EOF
}
+5
View File
@@ -61,11 +61,16 @@ if [ -z "$repo" ]; then
repo=$(REVIEW_REPO= resolve_repo)
fi
branch_prefix="${WORK_BRANCH_PREFIX:-issue}"
auto_assign="${WORK_AUTO_ASSIGN:-1}"
echo "[work] fetching issue #$issue from $repo..."
issue_json=$(gh issue view "$issue" -R "$repo" \
--json number,title,body,labels,state,url,assignees)
if [ "$auto_assign" = "1" ]; then
gh_assign_self_issue "$issue" "$repo"
fi
state=$(jq -r '.state' <<<"$issue_json")
if [ "$state" != "OPEN" ]; then
echo "[work] ! issue #$issue is $state — continuing anyway" >&2