feat: Set BD_ACTOR env var when spawning agents (gt-rhfji)

When gt spawns agents (polecats, crew, patrol roles), it now sets the
BD_ACTOR env var so that bd commands (like `bd hook`) know the agent
identity without coupling to gt.

Updated spawn points:
- gt up (mayor, deacon, witness via ensureSession/ensureWitness)
- gt deacon start
- gt witness start
- gt start refinery
- gt mayor start
- Daemon deacon restart
- Daemon lifecycle restart
- Handoff respawn
- Refinery manager start

BD_ACTOR uses slash format (e.g., gastown/witness, gastown/crew/max)
while GT_ROLE may use dash format internally.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-25 13:26:38 -08:00
parent 77a43886a3
commit 9afd6c5572
9 changed files with 67 additions and 19 deletions

View File

@@ -268,17 +268,17 @@ func buildRestartCommand(sessionName string) (string, error) {
return "", err
}
// Determine GT_ROLE value for this session
// Determine GT_ROLE and BD_ACTOR values for this session
gtRole := sessionToGTRole(sessionName)
// For respawn-pane, we:
// 1. cd to the right directory (role's canonical home)
// 2. export GT_ROLE so role detection works correctly
// 2. export GT_ROLE and BD_ACTOR so role detection works correctly
// 3. run claude
// The SessionStart hook will run gt prime.
// Use exec to ensure clean process replacement.
if gtRole != "" {
return fmt.Sprintf("cd %s && export GT_ROLE=%s && exec claude --dangerously-skip-permissions", workDir, gtRole), nil
return fmt.Sprintf("cd %s && export GT_ROLE=%s BD_ACTOR=%s && exec claude --dangerously-skip-permissions", workDir, gtRole, gtRole), nil
}
return fmt.Sprintf("cd %s && exec claude --dangerously-skip-permissions", workDir), nil
}