fix: auto-configure sync-branch for rig beads

New rigs now get sync-branch: beads-sync in their .beads/config.yaml
automatically. This enables multi-clone coordination for polecats,
crew members, and refinery.

Also added gt doctor check (beads-sync-branch) to verify existing rigs
have sync-branch configured, with --fix support.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-20 15:42:45 -08:00
parent ded1ffba0b
commit 317caace5e
3 changed files with 123 additions and 1 deletions

View File

@@ -329,6 +329,7 @@ func (m *Manager) initAgentStates(rigPath string) error {
}
// initBeads initializes the beads database at rig level.
// Rig beads use sync-branch for multi-clone coordination (polecats, crew, etc.)
func (m *Manager) initBeads(rigPath, prefix string) error {
beadsDir := filepath.Join(rigPath, ".beads")
if err := os.MkdirAll(beadsDir, 0755); err != nil {
@@ -341,10 +342,20 @@ func (m *Manager) initBeads(rigPath, prefix string) error {
if err := cmd.Run(); err != nil {
// bd might not be installed or --no-agents not supported, create minimal structure
configPath := filepath.Join(beadsDir, "config.yaml")
configContent := fmt.Sprintf("prefix: %s\n", prefix)
// Rig beads need sync-branch for multi-clone coordination
configContent := fmt.Sprintf("prefix: %s\nsync-branch: beads-sync\n", prefix)
if writeErr := os.WriteFile(configPath, []byte(configContent), 0644); writeErr != nil {
return writeErr
}
} else {
// bd init succeeded, but we still need to add sync-branch
// Append to config.yaml (bd init doesn't set sync-branch by default)
configPath := filepath.Join(beadsDir, "config.yaml")
f, err := os.OpenFile(configPath, os.O_APPEND|os.O_WRONLY, 0644)
if err == nil {
defer f.Close()
f.WriteString("sync-branch: beads-sync\n")
}
}
return nil
}