fix: list existing town agent beads

Install now detects existing town-level agents via bd list to avoid relying on
bd show prefix matching, and the role slot test reads JSON from stdout only to
ignore stderr warnings.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Dan Shapiro
2026-01-04 08:48:20 -08:00
parent 87bdd6c63e
commit e98ad32d7f
2 changed files with 20 additions and 7 deletions

View File

@@ -424,12 +424,22 @@ func initTownAgentBeads(townPath string) error {
},
}
existingAgents, err := bd.List(beads.ListOptions{
Status: "all",
Type: "agent",
Priority: -1,
})
if err != nil {
return fmt.Errorf("listing existing agent beads: %w", err)
}
existingAgentIDs := make(map[string]struct{}, len(existingAgents))
for _, issue := range existingAgents {
existingAgentIDs[issue.ID] = struct{}{}
}
for _, agent := range agentDefs {
// Check if already exists (exact ID + agent type).
if issue, err := bd.Show(agent.id); err == nil {
if issue.ID == agent.id && issue.Type == "agent" {
continue
}
if _, ok := existingAgentIDs[agent.id]; ok {
continue
}
fields := &beads.AgentFields{