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
8 changes: 6 additions & 2 deletions .agent/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ If the script outputs "STOP - ON PROTECTED BRANCH", you MUST NOT proceed with ed

> On `main`. Suggested branch: `{type}/{suggested-name}`
>
> 1. Create worktree for suggested branch (recommended for parallel sessions)
> 2. Create branch with checkout (switches current directory's branch)
> 1. Create worktree for suggested branch (recommended - enables parallel work)
> 2. Create branch with checkout (only if single-session workflow preferred)
> 3. Use different branch name
> 4. Stay on `main` (docs-only acceptable, otherwise not recommended)

3. **Do NOT proceed until user replies with 1, 2, 3, or 4**

**Default choice**: Prefer option 1 (worktree) unless user has expressed preference for option 2. Worktrees prevent branch-switching conflicts across terminals and AI sessions.

**When option 4 is acceptable**: Documentation-only changes (README, CHANGELOG, docs/), typo fixes, version bumps via release script.
**When option 4 is NOT acceptable**: Any code changes, configuration files, scripts.
4. If worktree (option 1): `~/.aidevops/agents/scripts/worktree-helper.sh add {type}/{name}`
Expand All @@ -54,6 +56,8 @@ If the script outputs "STOP - ON PROTECTED BRANCH", you MUST NOT proceed with ed
**Self-verification**: Before ANY file operation, ask yourself:
"Have I run pre-edit-check.sh in this session?" If unsure, run it NOW.

**Tool-level enforcement**: Before calling Edit, Write, or Bash (with file-modifying commands), you MUST have already confirmed you're on a feature branch. If the check hasn't been run this session, run it NOW before proceeding.

**Working in aidevops framework**: When modifying aidevops agents, you work in TWO locations:
- **Source**: `~/Git/aidevops/.agent/` - THIS is the git repo, check branch HERE
- **Deployed**: `~/.aidevops/agents/` - copy of source, not a git repo
Expand Down
34 changes: 34 additions & 0 deletions .agent/workflows/pr.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,40 @@
**Overall**: CHANGES REQUESTED
```text

## Loop Commands

For iterative PR workflows that automatically retry until success:

| Command | Purpose | Default Limit |
|---------|---------|---------------|
| `/pr-loop` | Iterate until PR approved/merged | 10 iterations |
| `/preflight-loop` | Iterate until preflight passes | 5 iterations |

### Timeout Recovery

If a loop times out before completion:

1. **Check current status**:
```bash
gh pr view --json state,reviewDecision,statusCheckRollup
```

2. **Review what's pending** - usually one of:
- CI checks still running (wait and re-check)
- Review requested but not completed (ping reviewer)
- Failing checks that need manual intervention

3. **Fix and continue** - address issues, then:
```bash

Check notice on line 228 in .agent/workflows/pr.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

.agent/workflows/pr.md#L228

Fenced code blocks should be surrounded by blank lines
# Re-run single review cycle
/pr review

# Or restart loop if multiple issues remain
/pr-loop
```

Loops are convenience wrappers - the manual `/pr review` workflow always works.

## Fork Workflow (Non-Owner Repositories)

When working on a repository you don't own, use the fork workflow:
Expand Down
43 changes: 43 additions & 0 deletions .agent/workflows/preflight.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,49 @@ path/to/false-positive.txt
.agent/scripts/version-manager.sh bump patch
```text

## Worktree Awareness
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

## Worktree Awareness (and the rest of this new section) appears to follow a fenced block that’s closed with text rather than a bare , which can cause everything after to render as a code block in Markdown. Worth double-checking the fence closures in this area so the new headings/sections render correctly.

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎


When running preflight in a worktree, checks run against the **worktree's files**, not the deployed `~/.aidevops/agents/` version. This means:

- Pre-existing issues in the deployed version won't be fixed by worktree changes
- Issues will only be resolved after merge and redeployment (`./setup.sh`)
- Focus on issues introduced by your changes, not inherited technical debt

## Pre-existing vs New Issues

Preflight checks report ALL issues, including pre-existing ones. When the loop hits max iterations or you see many violations:

### Identifying New vs Pre-existing Issues

```bash
# See what files you changed
git diff main --name-only

# Check issues only in your changed files
shellcheck $(git diff main --name-only -- '*.sh')
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The shellcheck $(...) command is not robust as it will fail for filenames containing spaces or other special characters due to shell word splitting. A more robust method is to use NUL-delimited output from git diff with the -z flag and pipe it to xargs -0, which is designed to handle all possible filenames correctly.

Suggested change
shellcheck $(git diff main --name-only -- '*.sh')
git diff main --name-only -z -- '*.sh' | xargs -0 shellcheck

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The example shellcheck $(git diff main --name-only -- '*.sh') can behave unexpectedly if there are no matching files or if any filenames contain spaces. Consider adding a short note/caveat so readers don’t get tripped up by the command substitution.

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎

```

### When to Proceed Despite Issues

If all remaining issues are **pre-existing** (not introduced by your PR):

1. Verify your changes don't add new violations
2. Document pre-existing issues for future cleanup
3. Proceed with PR creation
4. Note in PR description: "Pre-existing issues not addressed in this PR"

### When to Fix Issues

Fix issues that are:
- Introduced by your changes
- In files you're already modifying
- Quick wins (< 5 minutes to fix)

Defer issues that are:
- Pre-existing in untouched files
- Require significant refactoring
- Outside the scope of your PR

## Related Workflows

- **Version bumping**: `workflows/version-bump.md`
Expand Down
26 changes: 26 additions & 0 deletions .agent/workflows/worktree.md
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,32 @@ git status # Shows detached HEAD
git checkout feature/auth
```

### Worktree Deleted Mid-Session

If a worktree directory is removed (e.g., PR closed, manual deletion, cleanup script):

```bash
# 1. Check if branch still exists locally
git branch --list feature/my-feature

# 2. If branch exists, recreate worktree
worktree-helper.sh add feature/my-feature

# 3. If branch was deleted remotely but you have local changes
git fetch origin
git checkout -b feature/my-feature origin/feature/my-feature 2>/dev/null || \
git checkout -b feature/my-feature
worktree-helper.sh add feature/my-feature

# 4. Restore uncommitted changes from stash (if any were saved)
git stash list
git stash pop
```

**Session continuity**: After recreating the worktree, use `session-rename_sync_branch` tool to re-sync the OpenCode session name with the branch.

**Prevention**: Before closing a PR or deleting a branch, ensure no active sessions are using that worktree. Use `worktree-sessions.sh list` to check.

## Comparison: Worktrees vs Alternatives

| Approach | Pros | Cons |
Expand Down