feat: add RoleEnvVars and improve gt role CLI
Introduces config.RoleEnvVars() as the single source of truth for role identity environment variables (GT_ROLE, GT_RIG, BD_ACTOR, etc.). CLI improvements: - Fix getRoleHome paths (witness has no /rig suffix, polecat/crew do) - Make gt role env read-only (displays current role from env/cwd) - Add EnvIncomplete handling: fill missing env vars from cwd with warning - Add cwd mismatch warnings when not in role home directory - gt role home now validates --polecat requires --rig Includes comprehensive e2e tests for all role detection scenarios. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
committed by
Steve Yegge
parent
491b635cbc
commit
2343e6b0ef
@@ -1170,6 +1170,46 @@ func BuildStartupCommandWithAgentOverride(envVars map[string]string, rigPath, pr
|
||||
return cmd, nil
|
||||
}
|
||||
|
||||
// RoleEnvVars returns the canonical environment variables for a role.
|
||||
// This is the single source of truth for role identity env vars.
|
||||
// The role parameter should be one of: "mayor", "deacon", "witness", "refinery", "polecat", "crew".
|
||||
// For rig-specific roles, rig must be provided.
|
||||
// For polecat/crew, polecatOrCrew must be the polecat or crew member name.
|
||||
func RoleEnvVars(role, rig, polecatOrCrew string) map[string]string {
|
||||
envVars := map[string]string{
|
||||
"GT_ROLE": role,
|
||||
}
|
||||
|
||||
switch role {
|
||||
case "mayor":
|
||||
envVars["BD_ACTOR"] = "mayor"
|
||||
envVars["GIT_AUTHOR_NAME"] = "mayor"
|
||||
case "deacon":
|
||||
envVars["BD_ACTOR"] = "deacon"
|
||||
envVars["GIT_AUTHOR_NAME"] = "deacon"
|
||||
case "witness":
|
||||
envVars["GT_RIG"] = rig
|
||||
envVars["BD_ACTOR"] = fmt.Sprintf("%s/witness", rig)
|
||||
envVars["GIT_AUTHOR_NAME"] = fmt.Sprintf("%s/witness", rig)
|
||||
case "refinery":
|
||||
envVars["GT_RIG"] = rig
|
||||
envVars["BD_ACTOR"] = fmt.Sprintf("%s/refinery", rig)
|
||||
envVars["GIT_AUTHOR_NAME"] = fmt.Sprintf("%s/refinery", rig)
|
||||
case "polecat":
|
||||
envVars["GT_RIG"] = rig
|
||||
envVars["GT_POLECAT"] = polecatOrCrew
|
||||
envVars["BD_ACTOR"] = fmt.Sprintf("%s/polecats/%s", rig, polecatOrCrew)
|
||||
envVars["GIT_AUTHOR_NAME"] = polecatOrCrew
|
||||
case "crew":
|
||||
envVars["GT_RIG"] = rig
|
||||
envVars["GT_CREW"] = polecatOrCrew
|
||||
envVars["BD_ACTOR"] = fmt.Sprintf("%s/crew/%s", rig, polecatOrCrew)
|
||||
envVars["GIT_AUTHOR_NAME"] = polecatOrCrew
|
||||
}
|
||||
|
||||
return envVars
|
||||
}
|
||||
|
||||
// BuildAgentStartupCommand is a convenience function for starting agent sessions.
|
||||
// It sets standard environment variables (GT_ROLE, BD_ACTOR, GIT_AUTHOR_NAME)
|
||||
// and builds the full startup command.
|
||||
|
||||
Reference in New Issue
Block a user