Merge pull request #268 from julianknutsen/fix/gt-root-env

fix: agents cannot find town-level formulas
This commit is contained in:
Steve Yegge
2026-01-08 17:52:41 -08:00
committed by GitHub
4 changed files with 276 additions and 2 deletions

View File

@@ -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 {