beads/cmd/bd/setup/aider.go
Marco Del Pin b7bd6d6fae fix: replace stale 'bd sync' references with bd dolt push/commit (GH#2435)
bd sync was removed as a command but references persisted in:
- CLI help text (--dolt-auto-commit flag description)
- Code comments (dolt_autocommit.go, init_contributor.go)
- Agent setup generators (aider, cursor, junie, mux)
- Doctor agent remediation commands
- Jujutsu hook alias (init_git_hooks.go)
- Copilot integration docs

All references now point to the current commands:
- bd dolt commit (for committing changes)
- bd dolt push (for pushing to remote)

Tests updated to match.

Complements #2389 (config/sync.mode removal) and #2419 (command removal).
Remaining stale references in other docs tracked in GH#2435.
2026-03-07 17:00:19 +01:00

248 lines
7.3 KiB
Go

package setup
import (
"fmt"
"os"
)
const aiderConfigTemplate = `# Beads Issue Tracking Integration for Aider
# Auto-generated by 'bd setup aider'
# Load Beads workflow instructions for the AI
# This file is marked read-only and cached for efficiency
read:
- .aider/BEADS.md
`
const aiderBeadsInstructions = `# Beads Issue Tracking Instructions for AI
This project uses **Beads (bd)** for issue tracking. Aider requires explicit command execution - suggest commands to the user.
## Core Workflow Rules
1. **Track ALL work in bd** (never use markdown TODOs or comment-based task lists)
2. **Suggest 'bd ready'** to find available work
3. **Suggest 'bd create'** for new issues/tasks/bugs
4. **Suggest 'bd dolt push'** at end of session
5. **ALWAYS suggest commands** - user will run them via /run
## Quick Command Reference (suggest these to user)
- ` + "`bd ready`" + ` - Show unblocked issues
- ` + "`bd list --status=open`" + ` - List all open issues
- ` + "`bd create --title=\"...\" --type=task`" + ` - Create new issue
- ` + "`bd update <id> --claim`" + ` - Claim work atomically
- ` + "`bd close <id>`" + ` - Mark complete
- ` + "`bd dep add <issue> <depends-on>`" + ` - Add dependency (issue depends on depends-on)
- ` + "`bd dolt push`" + ` - Push changes to Dolt remote
## Workflow Pattern to Suggest
1. **Check ready work**: "Let's run ` + "`/run bd ready`" + ` to see what's available"
2. **Claim task**: "Run ` + "`/run bd update <id> --claim`" + ` to claim it atomically"
3. **Do the work**
4. **Complete**: "Run ` + "`/run bd close <id>`" + ` when done"
5. **Sync**: "Run ` + "`/run bd dolt push`" + ` to push changes"
## Context Loading
Suggest ` + "`/run bd prime`" + ` for complete workflow documentation (~1-2k tokens).
## Issue Types
- ` + "`bug`" + ` - Something broken that needs fixing
- ` + "`feature`" + ` - New functionality
- ` + "`task`" + ` - Work item (tests, docs, refactoring)
- ` + "`epic`" + ` - Large feature composed of multiple issues
- ` + "`chore`" + ` - Maintenance work (dependencies, tooling)
## Priorities
- ` + "`0`" + ` - Critical (security, data loss, broken builds)
- ` + "`1`" + ` - High (major features, important bugs)
- ` + "`2`" + ` - Medium (nice-to-have features, minor bugs)
- ` + "`3`" + ` - Low (polish, optimization)
- ` + "`4`" + ` - Backlog (future ideas)
## Important Notes
- **Always use /run prefix** - Aider requires explicit command execution
- **Link discovered work** - Use ` + "`--deps discovered-from:<parent-id>`" + ` when creating issues found during work
- **Include descriptions** - Always provide meaningful context when creating issues
- **End session with sync** - Remind user to run ` + "`/run bd dolt push`" + ` before ending session
For detailed docs: see AGENTS.md, QUICKSTART.md, or run ` + "`bd --help`" + `
`
const aiderReadmeTemplate = `# Aider + Beads Integration
This project uses [Beads (bd)](https://github.com/steveyegge/beads) for issue tracking.
## How This Works with Aider
**Important**: Aider requires you to explicitly run commands using the ` + "`/run`" + ` command.
The AI will **suggest** bd commands, but you must confirm them.
## Quick Start
1. Check for available work:
` + "```bash" + `
/run bd ready
` + "```" + `
2. Create new issues:
` + "```bash" + `
/run bd create "Issue title" --description="Details" -t bug|feature|task -p 1
` + "```" + `
3. Claim work:
` + "```bash" + `
/run bd update bd-42 --claim
` + "```" + `
4. Complete work:
` + "```bash" + `
/run bd close bd-42 --reason "Done"
` + "```" + `
5. Sync at end of session:
` + "```bash" + `
/run bd dolt push
` + "```" + `
## Configuration
The ` + "`.aider.conf.yml`" + ` file contains instructions for the AI about bd workflow.
The AI will read these instructions and suggest appropriate bd commands.
## Workflow
Ask the AI questions like:
- "What issues are ready to work on?"
- "Create an issue for this bug I found"
- "Show me the details of bd-42"
- "Mark bd-42 as complete"
The AI will suggest the appropriate ` + "`bd`" + ` command, which you run via ` + "`/run`" + `.
## Issue Types
- ` + "`bug`" + ` - Something broken
- ` + "`feature`" + ` - New functionality
- ` + "`task`" + ` - Work item (tests, docs, refactoring)
- ` + "`epic`" + ` - Large feature with subtasks
- ` + "`chore`" + ` - Maintenance work
## Priorities
- ` + "`0`" + ` - Critical (security, data loss, broken builds)
- ` + "`1`" + ` - High (major features, important bugs)
- ` + "`2`" + ` - Medium (default, nice-to-have)
- ` + "`3`" + ` - Low (polish, optimization)
- ` + "`4`" + ` - Backlog (future ideas)
## More Information
- Run ` + "`bd --help`" + ` for full command reference
- See ` + "`AGENTS.md`" + ` for detailed AI integration docs
- See ` + "`QUICKSTART.md`" + ` for human-oriented guide
`
// InstallAider installs Aider integration
func InstallAider() {
configPath := ".aider.conf.yml"
instructionsPath := ".aider/BEADS.md"
readmePath := ".aider/README.md"
fmt.Println("Installing Aider integration...")
// Ensure .aider directory exists
if err := EnsureDir(".aider", 0755); err != nil {
FatalError("%v", err)
}
// Write config file
if err := atomicWriteFile(configPath, []byte(aiderConfigTemplate)); err != nil {
FatalError("write config: %v", err)
}
// Write instructions file (loaded by AI)
if err := atomicWriteFile(instructionsPath, []byte(aiderBeadsInstructions)); err != nil {
FatalError("write instructions: %v", err)
}
// Write README (for humans)
if err := atomicWriteFile(readmePath, []byte(aiderReadmeTemplate)); err != nil {
FatalError("write README: %v", err)
}
fmt.Printf("\n✓ Aider integration installed\n")
fmt.Printf(" Config: %s\n", configPath)
fmt.Printf(" Instructions: %s (loaded by AI)\n", instructionsPath)
fmt.Printf(" README: %s (for humans)\n", readmePath)
fmt.Println("\nUsage:")
fmt.Println(" 1. Start aider in this directory")
fmt.Println(" 2. Ask AI for available work (it will suggest: /run bd ready)")
fmt.Println(" 3. Run suggested commands using /run")
fmt.Println("\nNote: Aider requires you to explicitly run commands via /run")
}
// CheckAider checks if Aider integration is installed
func CheckAider() {
configPath := ".aider.conf.yml"
if !FileExists(configPath) {
FatalErrorWithHint("Aider integration not installed", "Run: bd setup aider")
}
fmt.Println("✓ Aider integration installed:", configPath)
}
// RemoveAider removes Aider integration
func RemoveAider() {
configPath := ".aider.conf.yml"
instructionsPath := ".aider/BEADS.md"
readmePath := ".aider/README.md"
aiderDir := ".aider"
fmt.Println("Removing Aider integration...")
removed := false
// Remove config
if err := os.Remove(configPath); err != nil {
if !os.IsNotExist(err) {
FatalError("failed to remove config: %v", err)
}
} else {
removed = true
}
// Remove instructions
if err := os.Remove(instructionsPath); err != nil {
if !os.IsNotExist(err) {
FatalError("failed to remove instructions: %v", err)
}
} else {
removed = true
}
// Remove README
if err := os.Remove(readmePath); err != nil {
if !os.IsNotExist(err) {
FatalError("failed to remove README: %v", err)
}
} else {
removed = true
}
// Try to remove .aider directory if empty
_ = os.Remove(aiderDir)
if !removed {
fmt.Println("No Aider integration files found")
return
}
fmt.Println("✓ Removed Aider integration")
}