fix: Create and lookup rig agent beads with correct prefix

Per docs/architecture.md, Witness and Refinery are rig-level agents that
should use the rig's configured prefix (e.g., pi- for pixelforge) instead
of hardcoded "gt-".

This extends PR #183's creation fix to also fix all lookup paths:
- internal/rig/manager.go: Create agent beads in rig beads with rig prefix
- internal/daemon/daemon.go: Use rig prefix when looking up agent state
- internal/daemon/lifecycle.go: Use rig prefix for identity-to-bead mapping
- internal/cmd/sling.go: Pass townRoot for prefix lookup
- internal/cmd/unsling.go: Pass townRoot for prefix lookup
- internal/cmd/molecule_status.go: Use rig prefix for agent bead lookups
- internal/cmd/molecule_attach.go: Use rig prefix for agent bead lookups
- internal/config/loader.go: Add GetRigPrefix helper

Without this fix, the daemon would:
- Create pi-gastown-witness but look for gt-gastown-witness
- Report agents as missing/dead when they are running
- Fail to manage agent lifecycle correctly

Based on work by Johann Taberlet in PR #183.

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

Co-Authored-By: Johann Taberlet <johann.taberlet@gmail.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
gastown/crew/jack
2026-01-05 19:39:42 -08:00
committed by Steve Yegge
parent fc0b506253
commit e8d27e7212
8 changed files with 100 additions and 55 deletions

View File

@@ -947,3 +947,27 @@ func BuildCrewStartupCommand(rigName, crewName, rigPath, prompt string) string {
}
return BuildStartupCommand(envVars, rigPath, prompt)
}
// GetRigPrefix returns the beads prefix for a rig from rigs.json.
// Falls back to "gt" if the rig isn't found or has no prefix configured.
// townRoot is the path to the town directory (e.g., ~/gt).
func GetRigPrefix(townRoot, rigName string) string {
rigsConfigPath := filepath.Join(townRoot, "mayor", "rigs.json")
rigsConfig, err := LoadRigsConfig(rigsConfigPath)
if err != nil {
return "gt" // fallback
}
entry, ok := rigsConfig.Rigs[rigName]
if !ok {
return "gt" // fallback
}
if entry.BeadsConfig == nil || entry.BeadsConfig.Prefix == "" {
return "gt" // fallback
}
// Strip trailing hyphen if present (prefix stored as "gt-" but used as "gt")
prefix := entry.BeadsConfig.Prefix
return strings.TrimSuffix(prefix, "-")
}