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:
@@ -292,10 +292,20 @@ func runMailSend(cmd *cobra.Command, args []string) error {
|
||||
if err != nil || townRoot == "" {
|
||||
return fmt.Errorf("not in a Gas Town workspace")
|
||||
}
|
||||
ctx := detectRole(cwd, townRoot)
|
||||
roleInfo, err := GetRoleWithContext(cwd, townRoot)
|
||||
if err != nil {
|
||||
return fmt.Errorf("detecting role: %w", err)
|
||||
}
|
||||
ctx := RoleContext{
|
||||
Role: roleInfo.Role,
|
||||
Rig: roleInfo.Rig,
|
||||
Polecat: roleInfo.Polecat,
|
||||
TownRoot: townRoot,
|
||||
WorkDir: cwd,
|
||||
}
|
||||
to = buildAgentIdentity(ctx)
|
||||
if to == "" {
|
||||
return fmt.Errorf("cannot determine identity from current directory (role: %s)", ctx.Role)
|
||||
return fmt.Errorf("cannot determine identity (role: %s)", ctx.Role)
|
||||
}
|
||||
} else if len(args) > 0 {
|
||||
to = args[0]
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -30,11 +30,21 @@ func runMoleculeAttachFromMail(cmd *cobra.Command, args []string) error {
|
||||
return fmt.Errorf("not in a Gas Town workspace")
|
||||
}
|
||||
|
||||
// Detect agent role and identity
|
||||
roleCtx := detectRole(cwd, townRoot)
|
||||
// Detect agent role and identity using env-aware detection
|
||||
roleInfo, err := GetRoleWithContext(cwd, townRoot)
|
||||
if err != nil {
|
||||
return fmt.Errorf("detecting role: %w", err)
|
||||
}
|
||||
roleCtx := RoleContext{
|
||||
Role: roleInfo.Role,
|
||||
Rig: roleInfo.Rig,
|
||||
Polecat: roleInfo.Polecat,
|
||||
TownRoot: townRoot,
|
||||
WorkDir: cwd,
|
||||
}
|
||||
agentIdentity := buildAgentIdentity(roleCtx)
|
||||
if agentIdentity == "" {
|
||||
return fmt.Errorf("cannot determine agent identity from current directory (role: %s)", roleCtx.Role)
|
||||
return fmt.Errorf("cannot determine agent identity (role: %s)", roleCtx.Role)
|
||||
}
|
||||
|
||||
// Get the agent's mailbox
|
||||
|
||||
@@ -289,11 +289,21 @@ func runMoleculeBurn(cmd *cobra.Command, args []string) error {
|
||||
if len(args) > 0 {
|
||||
target = args[0]
|
||||
} else {
|
||||
// Auto-detect from current directory
|
||||
roleCtx := detectRole(cwd, townRoot)
|
||||
// Auto-detect using env-aware role detection
|
||||
roleInfo, err := GetRoleWithContext(cwd, townRoot)
|
||||
if err != nil {
|
||||
return fmt.Errorf("detecting role: %w", err)
|
||||
}
|
||||
roleCtx := RoleContext{
|
||||
Role: roleInfo.Role,
|
||||
Rig: roleInfo.Rig,
|
||||
Polecat: roleInfo.Polecat,
|
||||
TownRoot: townRoot,
|
||||
WorkDir: cwd,
|
||||
}
|
||||
target = buildAgentIdentity(roleCtx)
|
||||
if target == "" {
|
||||
return fmt.Errorf("cannot determine agent identity from current directory")
|
||||
return fmt.Errorf("cannot determine agent identity (role: %s)", roleCtx.Role)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,11 +385,21 @@ func runMoleculeSquash(cmd *cobra.Command, args []string) error {
|
||||
if len(args) > 0 {
|
||||
target = args[0]
|
||||
} else {
|
||||
// Auto-detect from current directory
|
||||
roleCtx := detectRole(cwd, townRoot)
|
||||
// Auto-detect using env-aware role detection
|
||||
roleInfo, err := GetRoleWithContext(cwd, townRoot)
|
||||
if err != nil {
|
||||
return fmt.Errorf("detecting role: %w", err)
|
||||
}
|
||||
roleCtx := RoleContext{
|
||||
Role: roleInfo.Role,
|
||||
Rig: roleInfo.Rig,
|
||||
Polecat: roleInfo.Polecat,
|
||||
TownRoot: townRoot,
|
||||
WorkDir: cwd,
|
||||
}
|
||||
target = buildAgentIdentity(roleCtx)
|
||||
if target == "" {
|
||||
return fmt.Errorf("cannot determine agent identity from current directory")
|
||||
return fmt.Errorf("cannot determine agent identity (role: %s)", roleCtx.Role)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -339,12 +339,15 @@ func runRigReset(cmd *cobra.Command, args []string) error {
|
||||
// Determine role to reset
|
||||
roleKey := rigResetRole
|
||||
if roleKey == "" {
|
||||
// Auto-detect from cwd
|
||||
ctx := detectRole(cwd, townRoot)
|
||||
if ctx.Role == RoleUnknown {
|
||||
return fmt.Errorf("could not detect role from current directory; use --role to specify")
|
||||
// Auto-detect using env-aware role detection
|
||||
roleInfo, err := GetRoleWithContext(cwd, townRoot)
|
||||
if err != nil {
|
||||
return fmt.Errorf("detecting role: %w", err)
|
||||
}
|
||||
roleKey = string(ctx.Role)
|
||||
if roleInfo.Role == RoleUnknown {
|
||||
return fmt.Errorf("could not detect role; use --role to specify")
|
||||
}
|
||||
roleKey = string(roleInfo.Role)
|
||||
}
|
||||
|
||||
// If no specific flags, reset all; otherwise only reset what's specified
|
||||
|
||||
Reference in New Issue
Block a user