feat(polecat): Add shared beads redirect for polecats (gt-cxtu)

When creating a polecat worktree, create a .beads/redirect file pointing
to the rig-level shared beads database. This eliminates git sync overhead
between polecats - they all connect to the same daemon and database.

Architecture:
  gastown/
    .beads/              <- Shared database (created if missing)
    polecats/
      nux/
        .beads/
          redirect       <- Contains "../../.beads"

🤖 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 20:54:37 -08:00
parent 8fab4d3790
commit fc1f50502f
2 changed files with 127 additions and 73 deletions

View File

@@ -139,6 +139,14 @@ func (m *Manager) Add(name string) (*Polecat, error) {
}
}
// Create beads redirect to share rig-level beads database
// This eliminates git sync overhead - all polecats use same daemon
if err := m.createBeadsRedirect(polecatPath); err != nil {
// Non-fatal - polecat can still work with its own .beads/ if needed
// Log warning but don't fail the spawn
fmt.Fprintf(os.Stderr, "Warning: could not create beads redirect: %v\n", err)
}
// Return polecat with derived state (no issue assigned yet = idle)
// State is derived from beads, not stored in state.json
now := time.Now()
@@ -513,3 +521,49 @@ func (m *Manager) loadFromBeads(name string) (*Polecat, error) {
Issue: issueID,
}, nil
}
// createBeadsRedirect creates a .beads/redirect file in the polecat directory
// that points to the rig-level shared beads database. This eliminates the need
// for git sync between polecats - they all share the same daemon and database.
//
// Directory structure:
// gastown/
// .beads/ <- Shared database (created if missing)
// polecats/
// nux/
// .beads/
// redirect <- Contains "../../.beads"
func (m *Manager) createBeadsRedirect(polecatPath string) error {
// Rig-level beads path
rigBeadsPath := filepath.Join(m.rig.Path, ".beads")
// Ensure rig-level .beads/ exists
if _, err := os.Stat(rigBeadsPath); os.IsNotExist(err) {
// Initialize rig-level beads if it doesn't exist
// This creates the database and config
if err := os.MkdirAll(rigBeadsPath, 0755); err != nil {
return fmt.Errorf("creating rig beads dir: %w", err)
}
// Note: bd will auto-initialize when first used
}
// Create polecat .beads directory
polecatBeadsPath := filepath.Join(polecatPath, ".beads")
if err := os.MkdirAll(polecatBeadsPath, 0755); err != nil {
return fmt.Errorf("creating polecat beads dir: %w", err)
}
// Calculate relative path from polecat to rig beads
// polecatPath is like: <rig>/polecats/<name>
// rigBeadsPath is like: <rig>/.beads
// So relative path is: ../../.beads
redirectPath := filepath.Join(polecatBeadsPath, "redirect")
relativePath := "../../.beads"
// Write redirect file
if err := os.WriteFile(redirectPath, []byte(relativePath+"\n"), 0644); err != nil {
return fmt.Errorf("writing redirect file: %w", err)
}
return nil
}