fix: Role detection reads GT_RIG/GT_CREW env vars for crew identity

When GT_ROLE is set to a simple value like "crew", the role detection
was not reading GT_RIG and GT_CREW to get the full identity. This caused
gt mol status to show "/crew/" instead of "gastown/crew/max".

Now GetRoleWithContext checks these additional env vars when the rig
or polecat fields are empty after parsing the role string.

Generated with Claude Code

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-26 19:12:55 -08:00
parent 036177ef53
commit e48f7fcd6c

View File

@@ -155,6 +155,21 @@ func GetRoleWithContext(cwd, townRoot string) (RoleInfo, error) {
info.Polecat = polecat
info.Source = "env"
// For simple role strings like "crew" or "polecat", also check
// GT_RIG and GT_CREW/GT_POLECAT env vars for the full identity
if info.Rig == "" {
if envRig := os.Getenv("GT_RIG"); envRig != "" {
info.Rig = envRig
}
}
if info.Polecat == "" {
if envCrew := os.Getenv("GT_CREW"); envCrew != "" {
info.Polecat = envCrew
} else if envPolecat := os.Getenv("GT_POLECAT"); envPolecat != "" {
info.Polecat = envPolecat
}
}
// Check for mismatch with cwd detection
if cwdCtx.Role != RoleUnknown && cwdCtx.Role != parsedRole {
info.Mismatch = true