diff --git a/internal/polecat/manager.go b/internal/polecat/manager.go index 11963357..1defb409 100644 --- a/internal/polecat/manager.go +++ b/internal/polecat/manager.go @@ -662,12 +662,14 @@ func (m *Manager) loadFromBeads(name string) (*Polecat, error) { // 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") + // Read template from mayor/rig/templates directory + // Templates live in the mayor's clone, not at rig root + templatePath := filepath.Join(m.rig.Path, "mayor", "rig", "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 + // Template doesn't exist - warn and skip (this is a setup issue) + fmt.Printf("Warning: polecat template not found at %s\n", templatePath) return nil } return fmt.Errorf("reading template: %w", err) diff --git a/internal/session/manager.go b/internal/session/manager.go index c5ac47f2..431160aa 100644 --- a/internal/session/manager.go +++ b/internal/session/manager.go @@ -161,11 +161,16 @@ func (m *Manager) Start(polecat string, opts StartOptions) error { agentID := fmt.Sprintf("%s/%s", m.rig.Name, polecat) _ = m.tmux.SetPaneDiedHook(sessionID, agentID) - // Send initial command + // Send initial command with env vars exported inline + // NOTE: tmux SetEnvironment only affects NEW panes, not the current shell. + // We must export GT_ROLE, GT_RIG, GT_POLECAT inline for Claude to detect identity. command := opts.Command if command == "" { // Polecats run with full permissions - Gas Town is for grownups - command = "claude --dangerously-skip-permissions" + // Export env vars inline so Claude's role detection works + bdActor := fmt.Sprintf("%s/polecats/%s", m.rig.Name, polecat) + command = fmt.Sprintf("export GT_ROLE=polecat GT_RIG=%s GT_POLECAT=%s BD_ACTOR=%s && claude --dangerously-skip-permissions", + m.rig.Name, polecat, bdActor) } if err := m.tmux.SendKeys(sessionID, command); err != nil { return fmt.Errorf("sending command: %w", err)