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