Update remaining commands to use env-aware role detection (gt-1xsah)

- mail.go: gt mail send --self uses GetRoleWithContext
- molecule_attach.go: detectCurrentAgent uses GetRoleWithContext
- molecule_attach_from_mail.go: uses GetRoleWithContext
- molecule_lifecycle.go: burn/squash use GetRoleWithContext
- rig.go: gt rig reset uses GetRoleWithContext

All role detection now checks GT_ROLE env var first.
This commit is contained in:
Steve Yegge
2025-12-25 01:05:53 -08:00
parent 43cbfc0ff8
commit 38d6f95f66
5 changed files with 71 additions and 18 deletions

View File

@@ -131,7 +131,7 @@ func runMoleculeAttachment(cmd *cobra.Command, args []string) error {
return nil
}
// detectCurrentAgent returns the current agent identity based on working directory.
// detectCurrentAgent returns the current agent identity based on GT_ROLE or working directory.
// Returns empty string if identity cannot be determined.
func detectCurrentAgent() string {
cwd, err := os.Getwd()
@@ -144,6 +144,16 @@ func detectCurrentAgent() string {
return ""
}
ctx := detectRole(cwd, townRoot)
roleInfo, err := GetRoleWithContext(cwd, townRoot)
if err != nil {
return ""
}
ctx := RoleContext{
Role: roleInfo.Role,
Rig: roleInfo.Rig,
Polecat: roleInfo.Polecat,
TownRoot: townRoot,
WorkDir: cwd,
}
return buildAgentIdentity(ctx)
}