fix: Make Mayor/Deacon session names include town name

Session names `gt-mayor` and `gt-deacon` were hardcoded, causing tmux
session name collisions when running multiple towns simultaneously.

Changed to `gt-{town}-mayor` and `gt-{town}-deacon` format (e.g.,
`gt-ai-mayor`) to allow concurrent multi-town operation.

Key changes:
- session.MayorSessionName() and DeaconSessionName() now take townName param
- Added workspace.GetTownName() helper to load town name from config
- Updated all callers in cmd/, daemon/, doctor/, mail/, rig/, templates/
- Updated tests with new session name format
- Bead IDs remain unchanged (already scoped by .beads/ directory)

Fixes #60

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
markov-kernel
2026-01-03 21:21:00 +01:00
parent 7f9795f630
commit e7145cfd77
46 changed files with 4772 additions and 1615 deletions

View File

@@ -6,6 +6,8 @@ import (
"fmt"
"os"
"path/filepath"
"github.com/steveyegge/gastown/internal/config"
)
// ErrNotFound indicates no workspace was found.
@@ -126,3 +128,35 @@ func IsWorkspace(dir string) (bool, error) {
return false, nil
}
// GetTownName loads the town name from the workspace's town.json config.
// This is used for generating unique tmux session names that avoid collisions
// when running multiple Gas Town instances.
func GetTownName(townRoot string) (string, error) {
townConfigPath := filepath.Join(townRoot, PrimaryMarker)
townConfig, err := config.LoadTownConfig(townConfigPath)
if err != nil {
return "", fmt.Errorf("loading town config: %w", err)
}
return townConfig.Name, nil
}
// GetTownNameFromCwd locates the town root from the current working directory
// and returns the town name from its configuration.
func GetTownNameFromCwd() (string, error) {
townRoot, err := FindFromCwdOrError()
if err != nil {
return "", err
}
return GetTownName(townRoot)
}
// MustGetTownName returns the town name or panics if it cannot be loaded.
// Use sparingly - prefer GetTownName with proper error handling.
func MustGetTownName(townRoot string) string {
name, err := GetTownName(townRoot)
if err != nil {
panic(fmt.Sprintf("failed to get town name: %v", err))
}
return name
}