refactor: add constants package for magic strings

Create internal/constants/constants.go with centralized definitions for:
- Directory names (mayor, polecats, crew, etc.)
- File names (rigs.json, town.json, state.json)
- Git branch names (main, beads-sync)
- Tmux session names (gt-mayor, gt-deacon)
- Agent role names

Add helper functions for common path construction:
- MayorRigsPath(), MayorTownPath(), MayorStatePath()
- RigMayorPath(), RigBeadsPath(), RigPolecatsPath()

Update key files to use the new constants:
- internal/cmd/rig_helpers.go
- internal/cmd/status.go
- internal/daemon/daemon.go

Closes: gt-xnql

🤖 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-21 22:13:21 -08:00
parent 666569181c
commit e75bdee50a
4 changed files with 147 additions and 7 deletions

View File

@@ -15,6 +15,7 @@ import (
"github.com/steveyegge/gastown/internal/beads"
"github.com/steveyegge/gastown/internal/config"
"github.com/steveyegge/gastown/internal/constants"
"github.com/steveyegge/gastown/internal/git"
"github.com/steveyegge/gastown/internal/keepalive"
"github.com/steveyegge/gastown/internal/rig"
@@ -388,8 +389,8 @@ func (d *Daemon) pokeDeacon() {
// pokeMayor sends a heartbeat to the Mayor session.
func (d *Daemon) pokeMayor() {
const mayorSession = "gt-mayor"
const agentID = "mayor"
mayorSession := constants.SessionMayor
agentID := constants.RoleMayor
running, err := d.tmux.HasSession(mayorSession)
if err != nil {
@@ -484,7 +485,7 @@ func (d *Daemon) pokeWitnesses() {
// Falls back to directory scanning if rigs.json is not available.
func (d *Daemon) discoverRigs() []*rig.Rig {
// Load rigs config from mayor/rigs.json
rigsConfigPath := filepath.Join(d.config.TownRoot, "mayor", "rigs.json")
rigsConfigPath := constants.MayorRigsPath(d.config.TownRoot)
rigsConfig, err := config.LoadRigsConfig(rigsConfigPath)
if err != nil {
// Try fallback: scan town directory for rig directories