Wire polecat-CLAUDE.md template into polecat spawn (gt-34mxx)
Add installCLAUDETemplate() to Manager that:
- Reads templates/polecat-CLAUDE.md from rig root
- Substitutes {{rig}} and {{name}} with actual values
- Writes to polecats/<name>/CLAUDE.md
Called from both Add() and Recreate() after worktree creation.
Non-fatal if template is missing.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/steveyegge/gastown/internal/beads"
|
"github.com/steveyegge/gastown/internal/beads"
|
||||||
@@ -153,6 +154,11 @@ func (m *Manager) Add(name string) (*Polecat, error) {
|
|||||||
return nil, fmt.Errorf("creating worktree: %w", err)
|
return nil, fmt.Errorf("creating worktree: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Install polecat CLAUDE.md template (non-fatal if template missing)
|
||||||
|
if err := m.installCLAUDETemplate(polecatPath, name); err != nil {
|
||||||
|
fmt.Printf("Warning: could not install CLAUDE.md template: %v\n", err)
|
||||||
|
}
|
||||||
|
|
||||||
// Set up shared beads: polecat uses rig's .beads via redirect file.
|
// Set up shared beads: polecat uses rig's .beads via redirect file.
|
||||||
// This eliminates git sync overhead - all polecats share one database.
|
// This eliminates git sync overhead - all polecats share one database.
|
||||||
if err := m.setupSharedBeads(polecatPath); err != nil {
|
if err := m.setupSharedBeads(polecatPath); err != nil {
|
||||||
@@ -344,6 +350,11 @@ func (m *Manager) Recreate(name string, force bool) (*Polecat, error) {
|
|||||||
return nil, fmt.Errorf("creating fresh worktree: %w", err)
|
return nil, fmt.Errorf("creating fresh worktree: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Install polecat CLAUDE.md template (non-fatal if template missing)
|
||||||
|
if err := m.installCLAUDETemplate(polecatPath, name); err != nil {
|
||||||
|
fmt.Printf("Warning: could not install CLAUDE.md template: %v\n", err)
|
||||||
|
}
|
||||||
|
|
||||||
// Set up shared beads
|
// Set up shared beads
|
||||||
if err := m.setupSharedBeads(polecatPath); err != nil {
|
if err := m.setupSharedBeads(polecatPath); err != nil {
|
||||||
fmt.Printf("Warning: could not set up shared beads: %v\n", err)
|
fmt.Printf("Warning: could not set up shared beads: %v\n", err)
|
||||||
@@ -647,6 +658,35 @@ func (m *Manager) loadFromBeads(name string) (*Polecat, error) {
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// installCLAUDETemplate copies the polecat CLAUDE.md template into the worktree.
|
||||||
|
// Template variables {{rig}} and {{name}} are substituted with actual values.
|
||||||
|
// This provides polecats with context about their role and available commands.
|
||||||
|
func (m *Manager) installCLAUDETemplate(polecatPath, name string) error {
|
||||||
|
// Read template from rig's templates directory
|
||||||
|
templatePath := filepath.Join(m.rig.Path, "templates", "polecat-CLAUDE.md")
|
||||||
|
content, err := os.ReadFile(templatePath)
|
||||||
|
if err != nil {
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
// Template doesn't exist - this is fine, just skip
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return fmt.Errorf("reading template: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Substitute template variables
|
||||||
|
output := string(content)
|
||||||
|
output = strings.ReplaceAll(output, "{{rig}}", m.rig.Name)
|
||||||
|
output = strings.ReplaceAll(output, "{{name}}", name)
|
||||||
|
|
||||||
|
// Write to polecat's CLAUDE.md
|
||||||
|
claudePath := filepath.Join(polecatPath, "CLAUDE.md")
|
||||||
|
if err := os.WriteFile(claudePath, []byte(output), 0644); err != nil {
|
||||||
|
return fmt.Errorf("writing CLAUDE.md: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// setupSharedBeads creates a redirect file so the polecat uses the rig's shared .beads database.
|
// setupSharedBeads creates a redirect file so the polecat uses the rig's shared .beads database.
|
||||||
// This eliminates the need for git sync between polecat clones - all polecats share one database.
|
// This eliminates the need for git sync between polecat clones - all polecats share one database.
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user