Fix aider integration to use proper YAML config format

Code review found critical issue: aider expects actual YAML configuration
with 'read:' directive, not comment-only instructions.

Changes:
- Split instructions into separate .aider/BEADS.md file
- Updated .aider.conf.yml to properly load instructions via 'read:' directive
- Added aiderBeadsInstructions template for AI-facing instructions
- Updated InstallAider to create three files:
  - .aider.conf.yml (YAML config with read directive)
  - .aider/BEADS.md (instructions for AI, loaded by aider)
  - .aider/README.md (reference for humans)
- Updated RemoveAider to clean up all three files and empty .aider directory
- Removed unused path/filepath import

This follows aider's documented conventions:
- https://aider.chat/docs/config/aider_conf.html
- https://aider.chat/docs/usage/conventions.html

The AI instructions are now properly loaded via aider's 'read:' mechanism
which marks them as read-only and enables caching for efficiency.

Related to bd-3djj

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-11-23 15:18:47 -08:00
parent ba8475b23c
commit 210789fa4d

View File

@@ -3,45 +3,75 @@ package setup
import (
"fmt"
"os"
"path/filepath"
)
const aiderConfigTemplate = `# Beads Issue Tracking Integration for Aider
# Auto-generated by 'bd setup aider' - do not remove these markers
# BEGIN BEADS INTEGRATION
# Auto-generated by 'bd setup aider'
# This project uses Beads (bd) for issue tracking.
# Aider requires explicit command execution - suggest commands to the user.
# Load Beads workflow instructions for the AI
# This file is marked read-only and cached for efficiency
read:
- .aider/BEADS.md
`
# Core workflow rules:
# 1. Track ALL work in bd (never use markdown TODOs)
# 2. Suggest 'bd ready' to find available work
# 3. Suggest 'bd create' for new issues/tasks/bugs
# 4. Suggest 'bd sync' at end of session
# 5. ALWAYS suggest commands - user will run them via /run
const aiderBeadsInstructions = `# Beads Issue Tracking Instructions for AI
# 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> --status=in_progress # Claim work
# bd close <id> # Mark complete
# bd dep <from> <to> # Add dependency
# bd sync # Sync with git remote
This project uses **Beads (bd)** for issue tracking. Aider requires explicit command execution - suggest commands to the user.
# Workflow pattern to suggest:
# 1. Check ready work: "Let's run 'bd ready' to see what's available"
# 2. Claim task: "Run 'bd update <id> --status=in_progress' to claim it"
# 3. Do the work
# 4. Complete: "Run 'bd close <id>' when done"
# 5. Sync: "Run 'bd sync' to push changes"
## Core Workflow Rules
# Context loading:
# Suggest 'bd prime' for complete workflow documentation (~1-2k tokens)
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 sync'** at end of session
5. **ALWAYS suggest commands** - user will run them via /run
# For detailed docs: see AGENTS.md, QUICKSTART.md, or 'bd --help'
## Quick Command Reference (suggest these to user)
# END BEADS INTEGRATION
- ` + "`bd ready`" + ` - Show unblocked issues
- ` + "`bd list --status=open`" + ` - List all open issues
- ` + "`bd create --title=\"...\" --type=task`" + ` - Create new issue
- ` + "`bd update <id> --status=in_progress`" + ` - Claim work
- ` + "`bd close <id>`" + ` - Mark complete
- ` + "`bd dep <from> <to>`" + ` - Add dependency (from blocks to)
- ` + "`bd sync`" + ` - Sync with git 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> --status=in_progress`" + ` to claim it"
3. **Do the work**
4. **Complete**: "Run ` + "`/run bd close <id>`" + ` when done"
5. **Sync**: "Run ` + "`/run bd sync`" + ` 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 sync`" + ` before ending session
For detailed docs: see AGENTS.md, QUICKSTART.md, or run ` + "`bd --help`" + `
`
const aiderReadmeTemplate = `# Aider + Beads Integration
@@ -121,23 +151,30 @@ The AI will suggest the appropriate ` + "`bd`" + ` command, which you run via `
// 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 {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
}
// Write config file
if err := atomicWriteFile(configPath, []byte(aiderConfigTemplate), 0644); err != nil {
fmt.Fprintf(os.Stderr, "Error: write config: %v\n", err)
os.Exit(1)
}
// Ensure .aider directory exists
if err := EnsureDir(filepath.Dir(readmePath), 0755); err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
// Write instructions file (loaded by AI)
if err := atomicWriteFile(instructionsPath, []byte(aiderBeadsInstructions), 0644); err != nil {
fmt.Fprintf(os.Stderr, "Error: write instructions: %v\n", err)
os.Exit(1)
}
// Write README
// Write README (for humans)
if err := atomicWriteFile(readmePath, []byte(aiderReadmeTemplate), 0644); err != nil {
fmt.Fprintf(os.Stderr, "Error: write README: %v\n", err)
os.Exit(1)
@@ -145,7 +182,8 @@ func InstallAider() {
fmt.Printf("\n✓ Aider integration installed\n")
fmt.Printf(" Config: %s\n", configPath)
fmt.Printf(" README: %s\n", readmePath)
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)")
@@ -169,7 +207,9 @@ func CheckAider() {
// 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...")
@@ -185,6 +225,16 @@ func RemoveAider() {
removed = true
}
// Remove instructions
if err := os.Remove(instructionsPath); err != nil {
if !os.IsNotExist(err) {
fmt.Fprintf(os.Stderr, "Error: failed to remove instructions: %v\n", err)
os.Exit(1)
}
} else {
removed = true
}
// Remove README
if err := os.Remove(readmePath); err != nil {
if !os.IsNotExist(err) {
@@ -195,6 +245,11 @@ func RemoveAider() {
removed = true
}
// Try to remove .aider directory if empty
if err := os.Remove(aiderDir); err != nil {
// Ignore error - directory might not be empty or might not exist
}
if !removed {
fmt.Println("No Aider integration files found")
return