Add role-based theming with layered config and doctor check

Role themes:
- witness: rust (red/alert)
- refinery: plum (purple)
- crew/polecat: inherit rig theme

Resolution order:
1. Per-rig role override (rig/.gastown/config.json role_themes)
2. Global role default (mayor/town.json theme.role_defaults)
3. Built-in role defaults
4. Rig theme (config or hash-based)

Config schema:
- TownConfig.Theme.RoleDefaults: global role->theme map
- RigConfig.Theme.RoleThemes: per-rig role overrides

Doctor check:
- Detects sessions with outdated theme format (brackets)
- Fixable with 'gt theme apply --all'

🤖 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-22 00:39:50 -08:00
parent ad0b7b7f6a
commit ed089cbd17
4 changed files with 198 additions and 7 deletions

View File

@@ -5,10 +5,11 @@ import "time"
// TownConfig represents the main town configuration (mayor/town.json).
type TownConfig struct {
Type string `json:"type"` // "town"
Version int `json:"version"` // schema version
Name string `json:"name"` // town identifier
CreatedAt time.Time `json:"created_at"`
Type string `json:"type"` // "town"
Version int `json:"version"` // schema version
Name string `json:"name"` // town identifier
CreatedAt time.Time `json:"created_at"`
Theme *TownThemeConfig `json:"theme,omitempty"` // global theme settings
}
// RigsConfig represents the rigs registry (mayor/rigs.json).
@@ -64,6 +65,10 @@ type ThemeConfig struct {
// Custom overrides the palette with specific colors.
Custom *CustomTheme `json:"custom,omitempty"`
// RoleThemes overrides themes for specific roles in this rig.
// Keys: "witness", "refinery", "crew", "polecat"
RoleThemes map[string]string `json:"role_themes,omitempty"`
}
// CustomTheme allows specifying exact colors for the status bar.
@@ -72,6 +77,23 @@ type CustomTheme struct {
FG string `json:"fg"` // Foreground color (hex or tmux color name)
}
// TownThemeConfig represents global theme settings (mayor/config.json).
type TownThemeConfig struct {
// RoleDefaults sets default themes for roles across all rigs.
// Keys: "witness", "refinery", "crew", "polecat"
RoleDefaults map[string]string `json:"role_defaults,omitempty"`
}
// BuiltinRoleThemes returns the default themes for each role.
// These are used when no explicit configuration is provided.
func BuiltinRoleThemes() map[string]string {
return map[string]string{
"witness": "rust", // Red/rust - watchful, alert
"refinery": "plum", // Purple - processing, refining
// crew and polecat use rig theme by default (no override)
}
}
// MergeQueueConfig represents merge queue settings for a rig.
type MergeQueueConfig struct {
// Enabled controls whether the merge queue is active.