Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .agent/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
96 changes: 66 additions & 30 deletions .agent/scripts/generate-opencode-commands.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gh pr view --json reviews,comments won’t include inline review comments/threads, which is where tools like CodeRabbit often post suggestions; this may cause /postflight to miss the primary feedback you’re trying to surface. Consider including PR review threads/comments in the queried fields (or using the PR review comments API) so the guidance matches the stated checks.

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎

- `gh run list --branch=<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"
Expand Down Expand Up @@ -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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that /pr is an alias for /create-pr, there are still repo docs describing /pr as the unified PR orchestrator (e.g., .agent/workflows/pr.md, README.md, CHANGELOG.md, and parts of .agent/AGENTS.md), which could mislead users. It may be worth updating those references to align with the new behavior.

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎

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
Expand Down Expand Up @@ -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"
Expand All @@ -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."
30 changes: 30 additions & 0 deletions .agent/workflows/git-workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The stash workflow uses git checkout -b {type}/{description}; if {description} contains spaces or punctuation (as suggested by the surrounding prose), the command will fail due to an invalid branch name. Consider using the {suggested-type}/{suggested-name} placeholder (or otherwise indicating a slug) to keep the example runnable.

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎

git stash pop
```
Comment on lines +103 to +110

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The provided stash workflow is only correct for option 1 (creating a new branch), but the description says it applies to option 3 (switching to an existing branch) as well. This is misleading because for option 3, the agent should check out an existing branch, not create a new one.

I suggest separating the workflows for clarity and correctness.

Suggested change
**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
```
**Stash workflow for new branch** (if user chooses option 1):
```bash
git stash --include-untracked -m "WIP: {description}"
git checkout main && git pull origin main
git checkout -b {type}/{description}
git stash pop

Stash workflow for existing branch (if user chooses option 3):

git stash --include-untracked -m "WIP: {description}"
git checkout {existing_branch_name}
# Agent should confirm with user before running 'git stash pop'


**Self-check trigger**: Before each file edit, briefly consider: "Does this change align with `{branch-name}`?"

**Decision Tree**:

| Situation | Action |
Expand Down