fix: gt hook shows correct agent identity for cross-rig directories (gt-5d7eh)

Use cwd-based detection instead of env-aware detection for gt hook status
display. This ensures we show the hook for the agent whose directory you're
in, not the agent from GT_ROLE env var.

Before: cd ~/gt/beads/crew/dave && gt hook → showed gastown/crew/joe (wrong)
After:  cd ~/gt/beads/crew/dave && gt hook → shows beads/crew/dave (correct)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
gastown/polecats/slit
2025-12-31 13:08:20 -08:00
committed by Steve Yegge
parent 7bfaf1a791
commit aa2607eed2
2 changed files with 12 additions and 26 deletions

View File

@@ -286,18 +286,11 @@ func runMoleculeStatus(cmd *cobra.Command, args []string) error {
// Explicit target provided
target = args[0]
} else {
// 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,
}
// Use cwd-based detection for status display
// This ensures we show the hook for the agent whose directory we're in,
// not the agent from the GT_ROLE env var (which might be different if
// we cd'd into another rig's crew/polecat directory)
roleCtx = detectRole(cwd, townRoot)
target = buildAgentIdentity(roleCtx)
if target == "" {
return fmt.Errorf("cannot determine agent identity (role: %s)", roleCtx.Role)
@@ -666,18 +659,11 @@ func runMoleculeCurrent(cmd *cobra.Command, args []string) error {
// Explicit target provided
target = args[0]
} else {
// 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,
}
// Use cwd-based detection for status display
// This ensures we show the hook for the agent whose directory we're in,
// not the agent from the GT_ROLE env var (which might be different if
// we cd'd into another rig's crew/polecat directory)
roleCtx = detectRole(cwd, townRoot)
target = buildAgentIdentity(roleCtx)
if target == "" {
return fmt.Errorf("cannot determine agent identity (role: %s)", roleCtx.Role)