From 0da29050dd4013427cbd0af972a04a86a478e6ef Mon Sep 17 00:00:00 2001 From: gastown/polecats/furiosa Date: Tue, 30 Dec 2025 23:05:55 -0800 Subject: [PATCH] Use rig prefix for agent bead IDs instead of hardcoded gt- (gt-w0fqg) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The getCleanupStatus function in witness/handlers.go and crew removal in cmd/crew_lifecycle.go were constructing agent bead IDs with hardcoded "gt-" prefix. This failed for rigs that use a different prefix like "bd-". Now uses beads.GetPrefixForRig to look up the correct prefix from routes.jsonl, enabling support for the beads rig and any future rigs with custom prefixes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- internal/cmd/crew_lifecycle.go | 11 +++++++++-- internal/witness/handlers.go | 12 ++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/internal/cmd/crew_lifecycle.go b/internal/cmd/crew_lifecycle.go index ce1c9509..f07d14ad 100644 --- a/internal/cmd/crew_lifecycle.go +++ b/internal/cmd/crew_lifecycle.go @@ -9,12 +9,14 @@ import ( "time" "github.com/spf13/cobra" + "github.com/steveyegge/gastown/internal/beads" "github.com/steveyegge/gastown/internal/constants" "github.com/steveyegge/gastown/internal/crew" "github.com/steveyegge/gastown/internal/mail" "github.com/steveyegge/gastown/internal/session" "github.com/steveyegge/gastown/internal/style" "github.com/steveyegge/gastown/internal/tmux" + "github.com/steveyegge/gastown/internal/workspace" ) func runCrewRemove(cmd *cobra.Command, args []string) error { @@ -80,8 +82,13 @@ func runCrewRemove(cmd *cobra.Command, args []string) error { style.Bold.Render("✓"), r.Name, name) // Close the agent bead if it exists - // Format: gt--crew- (matches session name format) - agentBeadID := fmt.Sprintf("gt-%s-crew-%s", r.Name, name) + // Use the rig's configured prefix (e.g., "gt" for gastown, "bd" for beads) + townRoot, _ := workspace.Find(r.Path) + if townRoot == "" { + townRoot = r.Path + } + prefix := beads.GetPrefixForRig(townRoot, r.Name) + agentBeadID := beads.CrewBeadIDWithPrefix(prefix, r.Name, name) closeCmd := exec.Command("bd", "close", agentBeadID, "--reason=Crew workspace removed") closeCmd.Dir = r.Path // Run from rig directory for proper beads resolution if output, err := closeCmd.CombinedOutput(); err != nil { diff --git a/internal/witness/handlers.go b/internal/witness/handlers.go index 1a61a62a..7bdfe04b 100644 --- a/internal/witness/handlers.go +++ b/internal/witness/handlers.go @@ -9,6 +9,7 @@ import ( "strings" "time" + "github.com/steveyegge/gastown/internal/beads" "github.com/steveyegge/gastown/internal/git" "github.com/steveyegge/gastown/internal/mail" "github.com/steveyegge/gastown/internal/workspace" @@ -386,8 +387,15 @@ type agentBeadResponse struct { // ZFC #10: This enables the Witness to verify it's safe to nuke before proceeding. // The polecat self-reports its git state when running `gt done`, and we trust that report. func getCleanupStatus(workDir, rigName, polecatName string) string { - // Construct agent bead ID: gt--polecat- - agentBeadID := fmt.Sprintf("gt-%s-polecat-%s", rigName, polecatName) + // Construct agent bead ID using the rig's configured prefix + // This supports non-gt prefixes like "bd-" for the beads rig + townRoot, err := workspace.Find(workDir) + if err != nil || townRoot == "" { + // Fall back to default prefix + townRoot = workDir + } + prefix := beads.GetPrefixForRig(townRoot, rigName) + agentBeadID := beads.PolecatBeadIDWithPrefix(prefix, rigName, polecatName) cmd := exec.Command("bd", "show", agentBeadID, "--json") cmd.Dir = workDir