feat(namepool): auto-select theme per rig based on name hash

Each rig now gets a deterministic theme based on its name instead of
always defaulting to mad-max. Uses a prime multiplier hash (×31) for
good distribution across themes. Same rig name always gets the same
theme. Users can still override with `gt namepool set`.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
gastown/crew/joe
2026-01-16 15:35:10 -08:00
committed by Steve Yegge
parent fbc67e89e1
commit 74050cd0ab
3 changed files with 51 additions and 12 deletions
+16 -1
View File
@@ -103,7 +103,7 @@ type NamePool struct {
func NewNamePool(rigPath, rigName string) *NamePool {
return &NamePool{
RigName: rigName,
Theme: DefaultTheme,
Theme: ThemeForRig(rigName),
InUse: make(map[string]bool),
OverflowNext: DefaultPoolSize + 1,
MaxSize: DefaultPoolSize,
@@ -352,6 +352,21 @@ func ListThemes() []string {
return themes
}
// ThemeForRig returns a deterministic theme for a rig based on its name.
// This provides variety across rigs without requiring manual configuration.
func ThemeForRig(rigName string) string {
themes := ListThemes()
if len(themes) == 0 {
return DefaultTheme
}
// Hash using prime multiplier for better distribution
var hash uint32
for _, b := range []byte(rigName) {
hash = hash*31 + uint32(b)
}
return themes[hash%uint32(len(themes))]
}
// GetThemeNames returns the names in a specific theme.
func GetThemeNames(theme string) ([]string, error) {
if names, ok := BuiltinThemes[theme]; ok {