refactor: consolidate agent env vars into config.AgentEnv
Create centralized AgentEnv function as single source of truth for all agent environment variables. All agents now consistently receive: - GT_ROLE, BD_ACTOR, GIT_AUTHOR_NAME (role identity) - GT_ROOT, BEADS_DIR (workspace paths) - GT_RIG, GT_POLECAT/GT_CREW (rig-specific identity) - BEADS_AGENT_NAME, BEADS_NO_DAEMON (beads config) - CLAUDE_CONFIG_DIR (optional account selection) Remove RoleEnvVars in favor of AgentEnvSimple wrapper. Remove IncludeBeadsEnv flag - beads env vars always included. Update all manager and cmd call sites to use AgentEnv. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
committed by
Steve Yegge
parent
52b9a95f98
commit
e999ceb1c1
@@ -847,8 +847,8 @@ func (d *Daemon) restartPolecatSession(rigName, polecatName, sessionName string)
|
||||
}
|
||||
|
||||
// Set environment variables
|
||||
// Use shared RoleEnvVars for consistency across all role startup paths
|
||||
envVars := config.RoleEnvVars("polecat", rigName, polecatName)
|
||||
// Use centralized AgentEnvSimple for consistency across all role startup paths
|
||||
envVars := config.AgentEnvSimple("polecat", rigName, polecatName)
|
||||
|
||||
// Add polecat-specific beads configuration
|
||||
// Use ResolveBeadsDir to follow redirects for repos with tracked beads
|
||||
|
||||
@@ -487,18 +487,31 @@ func (d *Daemon) getStartCommand(roleConfig *beads.RoleConfig, parsed *ParsedIde
|
||||
}
|
||||
|
||||
// setSessionEnvironment sets environment variables for the tmux session.
|
||||
// Uses role bead config if available, falls back to hardcoded defaults.
|
||||
func (d *Daemon) setSessionEnvironment(sessionName, identity string, config *beads.RoleConfig, parsed *ParsedIdentity) {
|
||||
// Always set GT_ROLE
|
||||
_ = d.tmux.SetEnvironment(sessionName, "GT_ROLE", identity)
|
||||
// Uses centralized AgentEnv for consistency, plus role bead custom env vars if available.
|
||||
func (d *Daemon) setSessionEnvironment(sessionName, identity string, roleConfig *beads.RoleConfig, parsed *ParsedIdentity) {
|
||||
// Determine beads dir based on role type
|
||||
var beadsPath string
|
||||
if parsed.RigName != "" {
|
||||
beadsPath = filepath.Join(d.config.TownRoot, parsed.RigName)
|
||||
} else {
|
||||
beadsPath = d.config.TownRoot
|
||||
}
|
||||
|
||||
// BD_ACTOR uses slashes instead of dashes for path-like identity
|
||||
bdActor := identityToBDActor(identity)
|
||||
_ = d.tmux.SetEnvironment(sessionName, "BD_ACTOR", bdActor)
|
||||
// Use centralized AgentEnv for base environment variables
|
||||
envVars := config.AgentEnv(config.AgentEnvConfig{
|
||||
Role: parsed.RoleType,
|
||||
Rig: parsed.RigName,
|
||||
AgentName: parsed.AgentName,
|
||||
TownRoot: d.config.TownRoot,
|
||||
BeadsDir: beads.ResolveBeadsDir(beadsPath),
|
||||
})
|
||||
for k, v := range envVars {
|
||||
_ = d.tmux.SetEnvironment(sessionName, k, v)
|
||||
}
|
||||
|
||||
// Set any custom env vars from role config
|
||||
if config != nil {
|
||||
for k, v := range config.EnvVars {
|
||||
// Set any custom env vars from role config (bead-defined overrides)
|
||||
if roleConfig != nil {
|
||||
for k, v := range roleConfig.EnvVars {
|
||||
expanded := beads.ExpandRolePattern(v, d.config.TownRoot, parsed.RigName, parsed.AgentName, parsed.RoleType)
|
||||
_ = d.tmux.SetEnvironment(sessionName, k, expanded)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user