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

@@ -2,9 +2,9 @@ package cmd
import (
"fmt"
"path/filepath"
"github.com/steveyegge/gastown/internal/config"
"github.com/steveyegge/gastown/internal/constants"
"github.com/steveyegge/gastown/internal/git"
"github.com/steveyegge/gastown/internal/rig"
"github.com/steveyegge/gastown/internal/workspace"
@@ -19,7 +19,7 @@ func getRig(rigName string) (string, *rig.Rig, error) {
return "", nil, fmt.Errorf("not in a Gas Town workspace: %w", err)
}
rigsConfigPath := filepath.Join(townRoot, "mayor", "rigs.json")
rigsConfigPath := constants.MayorRigsPath(townRoot)
rigsConfig, err := config.LoadRigsConfig(rigsConfigPath)
if err != nil {
rigsConfig = &config.RigsConfig{Rigs: make(map[string]config.RigEntry)}

View File

@@ -8,6 +8,7 @@ import (
"github.com/spf13/cobra"
"github.com/steveyegge/gastown/internal/config"
"github.com/steveyegge/gastown/internal/constants"
"github.com/steveyegge/gastown/internal/crew"
"github.com/steveyegge/gastown/internal/git"
"github.com/steveyegge/gastown/internal/rig"
@@ -68,7 +69,7 @@ func runStatus(cmd *cobra.Command, args []string) error {
}
// Load town config
townConfigPath := filepath.Join(townRoot, "mayor", "town.json")
townConfigPath := constants.MayorTownPath(townRoot)
townConfig, err := config.LoadTownConfig(townConfigPath)
if err != nil {
// Try to continue without config
@@ -76,7 +77,7 @@ func runStatus(cmd *cobra.Command, args []string) error {
}
// Load rigs config
rigsConfigPath := filepath.Join(townRoot, "mayor", "rigs.json")
rigsConfigPath := constants.MayorRigsPath(townRoot)
rigsConfig, err := config.LoadRigsConfig(rigsConfigPath)
if err != nil {
// Empty config if file doesn't exist