refactor: unify agent startup with Manager pattern

- Create mayor.Manager for mayor lifecycle (Start/Stop/IsRunning/Status)
- Create deacon.Manager for deacon lifecycle with respawn loop
- Move session.Manager to polecat.SessionManager (clearer naming)
- Add zombie session detection for mayor/deacon (kills tmux if Claude dead)
- Remove duplicate session startup code from up.go, start.go, mayor.go
- Rename sessMgr -> polecatMgr for consistency
- Make witness/refinery SessionName() public for status display

All agent types now follow the same Manager pattern:
  mgr := agent.NewManager(...)
  mgr.Start(...)
  mgr.Stop()
  mgr.IsRunning()
  mgr.Status()

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
julianknutsen
2026-01-06 22:32:35 -08:00
parent 432d14d9df
commit ea8bef2029
16 changed files with 609 additions and 584 deletions

View File

@@ -8,8 +8,8 @@ import (
"github.com/steveyegge/gastown/internal/config"
"github.com/steveyegge/gastown/internal/events"
"github.com/steveyegge/gastown/internal/git"
"github.com/steveyegge/gastown/internal/polecat"
"github.com/steveyegge/gastown/internal/rig"
"github.com/steveyegge/gastown/internal/session"
"github.com/steveyegge/gastown/internal/style"
"github.com/steveyegge/gastown/internal/tmux"
"github.com/steveyegge/gastown/internal/townlog"
@@ -111,8 +111,8 @@ func runStop(cmd *cobra.Command, args []string) error {
stopped := 0
for _, r := range rigs {
mgr := session.NewManager(t, r)
infos, err := mgr.List()
polecatMgr := polecat.NewSessionManager(t, r)
infos, err := polecatMgr.List()
if err != nil {
continue
}
@@ -125,10 +125,10 @@ func runStop(cmd *cobra.Command, args []string) error {
}
// Capture output before stopping (best effort)
output, _ := mgr.Capture(info.Polecat, 50)
output, _ := polecatMgr.Capture(info.Polecat, 50)
// Stop the session
err := mgr.Stop(info.Polecat, force)
err := polecatMgr.Stop(info.Polecat, force)
if err != nil {
result.Success = false
result.Error = err.Error()