feat(config): set GT_ROOT env var for all agent sessions
Previously GT_ROOT was documented as a formula search path but never actually set, making $GT_ROOT/.beads/formulas/ unreachable for agents. Now BuildStartupCommand automatically sets GT_ROOT to the town root, enabling all agents (witness, refinery, polecat, crew, etc.) to find town-level formulas without relying on cwd-relative paths. Also adds a doctor check (gt-root-env) that warns when existing sessions are missing GT_ROOT, with instructions to restart sessions. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1064,13 +1064,15 @@ func findTownRootFromCwd() (string, error) {
|
||||
// prompt is optional - if provided, appended as the initial prompt.
|
||||
func BuildStartupCommand(envVars map[string]string, rigPath, prompt string) string {
|
||||
var rc *RuntimeConfig
|
||||
var townRoot string
|
||||
if rigPath != "" {
|
||||
// Derive town root from rig path
|
||||
townRoot := filepath.Dir(rigPath)
|
||||
townRoot = filepath.Dir(rigPath)
|
||||
rc = ResolveAgentConfig(townRoot, rigPath)
|
||||
} else {
|
||||
// Try to detect town root from cwd for town-level agents (mayor, deacon)
|
||||
townRoot, err := findTownRootFromCwd()
|
||||
var err error
|
||||
townRoot, err = findTownRootFromCwd()
|
||||
if err != nil {
|
||||
rc = DefaultRuntimeConfig()
|
||||
} else {
|
||||
@@ -1078,6 +1080,11 @@ func BuildStartupCommand(envVars map[string]string, rigPath, prompt string) stri
|
||||
}
|
||||
}
|
||||
|
||||
// Add GT_ROOT so agents can find town-level resources (formulas, etc.)
|
||||
if townRoot != "" {
|
||||
envVars["GT_ROOT"] = townRoot
|
||||
}
|
||||
|
||||
// Build environment export prefix
|
||||
var exports []string
|
||||
for k, v := range envVars {
|
||||
|
||||
Reference in New Issue
Block a user