diff --git a/scripts/deep-work/cli.sh b/scripts/deep-work/cli.sh index 0a8744dd3..3b5fa2a60 100755 --- a/scripts/deep-work/cli.sh +++ b/scripts/deep-work/cli.sh @@ -11,6 +11,10 @@ Usage: pnpm deep-work [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 Start full workflow for an issue pick Smart issue selection + start workflow @@ -64,4 +68,4 @@ case "$cmd" in usage >&2 exit 1 ;; -esac \ No newline at end of file +esac diff --git a/scripts/deep-work/continue.sh b/scripts/deep-work/continue.sh index cca12304b..cd0223ecf 100755 --- a/scripts/deep-work/continue.sh +++ b/scripts/deep-work/continue.sh @@ -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." \ No newline at end of file +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 diff --git a/scripts/deep-work/lib.sh b/scripts/deep-work/lib.sh index 9a08ed67e..ad2973184 100755 --- a/scripts/deep-work/lib.sh +++ b/scripts/deep-work/lib.sh @@ -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" -} \ No newline at end of file +} diff --git a/scripts/deep-work/start.sh b/scripts/deep-work/start.sh index 5ee317555..950d97028 100755 --- a/scripts/deep-work/start.sh +++ b/scripts/deep-work/start.sh @@ -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" \ No newline at end of file +echo "- Merge when approved" diff --git a/scripts/shortcuts/review/lib.sh b/scripts/shortcuts/review/lib.sh index 825e3855c..0e431987a 100755 --- a/scripts/shortcuts/review/lib.sh +++ b/scripts/shortcuts/review/lib.sh @@ -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 `). # Usage: summarize_text # Tools used here: gemini (default for summaries), claude, or any CLI that diff --git a/scripts/shortcuts/work/README.md b/scripts/shortcuts/work/README.md index 54279ba85..4279a960e 100644 --- a/scripts/shortcuts/work/README.md +++ b/scripts/shortcuts/work/README.md @@ -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 `/-`. +- `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`). diff --git a/scripts/shortcuts/work/cli.sh b/scripts/shortcuts/work/cli.sh index 5585e954c..0cf1f7e17 100755 --- a/scripts/shortcuts/work/cli.sh +++ b/scripts/shortcuts/work/cli.sh @@ -37,6 +37,8 @@ Env: scripts/shortcuts/review. WORK_BRANCH_PREFIX=issue Branch name is /- (default: issue). + WORK_AUTO_ASSIGN=1 Auto-assign the issue to `@me` when work + starts. Set to `0` to disable. EOF } diff --git a/scripts/shortcuts/work/start.sh b/scripts/shortcuts/work/start.sh index edee07323..64d09d6b8 100755 --- a/scripts/shortcuts/work/start.sh +++ b/scripts/shortcuts/work/start.sh @@ -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