From a45321e6cdecdf09b0db7d96f187afa4d5016366 Mon Sep 17 00:00:00 2001 From: marcusquinn <6428977+marcusquinn@users.noreply.github.com> Date: Wed, 7 Jan 2026 21:12:04 +0000 Subject: [PATCH] chore: rename /pr to /create-pr, improve /postflight for PR feedback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Command changes: - /pr → /create-pr: Creates PR with auto-generated title/description - /pr: Now alias for /create-pr - /postflight: Now checks code audit feedback on latest push (branch/PR) - Auto-detects context (feature branch, PR, or main) - Checks GitHub Actions, CodeRabbit, Codacy, SonarCloud Agent improvements: - Add scope monitoring guidance to git-workflow.md - Agents now detect when work diverges from branch purpose - Proactively suggest new branch when scope creep detected - Add pointer in AGENTS.md Git Workflow section --- .agent/AGENTS.md | 1 + .agent/scripts/generate-opencode-commands.sh | 96 ++++++++++++++------ .agent/workflows/git-workflow.md | 30 ++++++ 3 files changed, 97 insertions(+), 30 deletions(-) diff --git a/.agent/AGENTS.md b/.agent/AGENTS.md index 4388945d9..62f2375f1 100644 --- a/.agent/AGENTS.md +++ b/.agent/AGENTS.md @@ -128,6 +128,7 @@ User confirms with numbered options to override if needed. 3. Create branch and call `session-rename_sync_branch` tool to sync session name 4. Record `started:` timestamp in TODO.md if matching task exists 5. Read `workflows/git-workflow.md` for full workflow guidance +6. **Monitor scope**: If work diverges from branch purpose, suggest new branch **Session tools** (OpenCode): - `session-rename_sync_branch` - Auto-sync session name with current git branch (preferred) diff --git a/.agent/scripts/generate-opencode-commands.sh b/.agent/scripts/generate-opencode-commands.sh index fde8ee779..f0cfdce7e 100755 --- a/.agent/scripts/generate-opencode-commands.sh +++ b/.agent/scripts/generate-opencode-commands.sh @@ -85,24 +85,38 @@ echo -e " ${GREEN}✓${NC} Created /preflight command" # ============================================================================= # POSTFLIGHT COMMAND # ============================================================================= -# Verify release health after tag and GitHub release +# Check code audit feedback on latest push to branch or PR cat > "$OPENCODE_COMMAND_DIR/postflight.md" << 'EOF' --- -description: Verify release health after tag and GitHub release +description: Check code audit feedback on latest push (branch or PR) agent: Build+ subtask: true --- -Read ~/.aidevops/agents/workflows/postflight.md and follow its instructions. +Check code audit tool feedback on the latest push. -Verify release: $ARGUMENTS +Target: $ARGUMENTS -This includes: -1. Tag exists and matches VERSION file -2. GitHub release created successfully -3. CHANGELOG.md updated -4. No uncommitted changes +**Auto-detection:** +1. If on a feature branch with open PR → check that PR's feedback +2. If on a feature branch without PR → check branch CI status +3. If on main → check latest commit's CI/audit status +4. If no git context or ambiguous → ask user which branch/PR to check + +**Checks performed:** +1. GitHub Actions workflow status (pass/fail/pending) +2. CodeRabbit comments and suggestions +3. Codacy analysis results +4. SonarCloud quality gate status +5. Any blocking issues that need resolution + +**Commands used:** +- `gh pr view --json reviews,comments` (if PR exists) +- `gh run list --branch=` (CI status) +- `gh api repos/{owner}/{repo}/commits/{sha}/check-runs` (detailed checks) + +Report findings and recommend next actions (fix issues, merge, etc.) EOF ((command_count++)) echo -e " ${GREEN}✓${NC} Created /postflight command" @@ -440,33 +454,55 @@ EOF echo -e " ${GREEN}✓${NC} Created /context command" # ============================================================================= -# PR COMMAND (UNIFIED ORCHESTRATOR) +# CREATE-PR COMMAND # ============================================================================= -# Unified PR workflow - orchestrates all quality checks +# Create a PR from current branch with auto-generated title and description -cat > "$OPENCODE_COMMAND_DIR/pr.md" << 'EOF' +cat > "$OPENCODE_COMMAND_DIR/create-pr.md" << 'EOF' --- -description: Unified PR workflow - orchestrates linting, auditing, standards, and intent vs reality +description: Create PR from current branch with title and description agent: Build+ --- -Read ~/.aidevops/agents/workflows/pr.md and follow its instructions. +Create a pull request from the current branch. -Action: $ARGUMENTS +Additional context: $ARGUMENTS + +**Steps:** +1. Check current branch (must not be main/master) +2. Check for uncommitted changes (warn if present) +3. Push branch to remote if not already pushed +4. Generate PR title from branch name (e.g., `feature/add-login` → "Add login") +5. Generate PR description from: + - Commit messages on this branch + - Changed files summary + - Any TODO.md/PLANS.md task references + - User-provided context (if any) +6. Create PR using `gh pr create` +7. Return PR URL + +**Example:** +- `/create-pr` → Creates PR with auto-generated title/description +- `/create-pr fixes authentication bug` → Adds context to description +EOF +((command_count++)) +echo -e " ${GREEN}✓${NC} Created /create-pr command" + +# Keep /pr as alias pointing to /create-pr for discoverability +cat > "$OPENCODE_COMMAND_DIR/pr.md" << 'EOF' +--- +description: Alias for /create-pr - Create PR from current branch +agent: Build+ +--- + +This is an alias for /create-pr. Creating PR from current branch. -This orchestrates all quality checks: -1. /linters-local - ShellCheck, secretlint, pattern checks -2. /code-audit-remote - CodeRabbit, Codacy, SonarCloud -3. /code-standards - Documented standards compliance -4. Intent vs Reality - Compare PR description to actual changes +Context: $ARGUMENTS -Supports: -- review: Run all checks and analyze PR -- create: Create new PR after checks pass -- merge: Merge a PR after approval +Run /create-pr with the same arguments. EOF ((command_count++)) -echo -e " ${GREEN}✓${NC} Created /pr command" +echo -e " ${GREEN}✓${NC} Created /pr command (alias for /create-pr)" # ============================================================================= # CREATE-PRD COMMAND @@ -1017,17 +1053,17 @@ echo " /create-prd - Generate Product Requirements Document" echo " /generate-tasks - Generate implementation tasks from PRD" echo "" echo " Quality:" +echo " /preflight - Quality checks before commit" +echo " /postflight - Check code audit feedback on latest push" echo " /linters-local - Run local linting (ShellCheck, secretlint)" echo " /code-audit-remote - Run remote auditing (CodeRabbit, Codacy, SonarCloud)" echo " /code-standards - Check against documented standards" -echo " /pr - Unified PR workflow (orchestrates all checks)" -echo " /preflight - Quality checks before release" -echo " /postflight - Verify release health" echo "" echo " Git & Release:" echo " /feature - Create feature branch" echo " /bugfix - Create bugfix branch" echo " /hotfix - Create hotfix branch" +echo " /create-pr - Create PR from current branch" echo " /release - Full release workflow" echo " /version-bump - Bump project version" echo " /changelog - Update CHANGELOG.md" @@ -1047,9 +1083,9 @@ echo " /log-time-spent - Log time spent on a task" echo "" echo "New users: Start with /onboarding to configure your services" echo "" -echo "Planning workflow: /list-todo -> pick task -> /feature -> implement -> /pr" +echo "Planning workflow: /list-todo -> pick task -> /feature -> implement -> /create-pr" echo "New work: discuss -> /save-todo -> later: /list-todo -> pick -> implement" -echo "Quality workflow: /linters-local -> /code-audit-remote -> /pr" +echo "Quality workflow: /preflight -> /create-pr -> /postflight" echo "SEO workflow: /keyword-research -> /autocomplete-research -> /keyword-research-extended" echo "" echo "Restart OpenCode to load new commands." diff --git a/.agent/workflows/git-workflow.md b/.agent/workflows/git-workflow.md index befd6f061..b5154326c 100644 --- a/.agent/workflows/git-workflow.md +++ b/.agent/workflows/git-workflow.md @@ -81,6 +81,36 @@ OpenCode auto-generates session titles from the first prompt. To sync session na **Best Practice**: After creating a branch, call `session-rename_sync_branch` tool to sync session name. +**Scope Monitoring** (during session): + +When work evolves significantly from the branch name/purpose: + +| Signal | Example | Action | +|--------|---------|--------| +| Different feature area | Branch is `chore/update-deps`, now adding new API endpoint | Suggest new branch | +| Unrelated bug fix | Branch is `feature/user-auth`, found unrelated CSS bug | Suggest separate branch | +| Scope expansion | Branch is `bugfix/login-timeout`, now refactoring entire auth system | Suggest `refactor/` branch | +| Command/API rename | Branch is `chore/optimize-X`, now renaming unrelated commands | Suggest new branch | + +**When detected**, proactively offer: + +> This work (`{description}`) seems outside the scope of `{current-branch}` ({original-purpose}). +> +> 1. Create new branch `{suggested-type}/{suggested-name}` (recommended) +> 2. Continue on current branch (if intentionally expanding scope) +> 3. Stash changes and switch to existing branch + +**Stash workflow** (if user chooses option 1 or 3): + +```bash +git stash --include-untracked -m "WIP: {description}" +git checkout main && git pull origin main +git checkout -b {type}/{description} +git stash pop +``` + +**Self-check trigger**: Before each file edit, briefly consider: "Does this change align with `{branch-name}`?" + **Decision Tree**: | Situation | Action |