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:
@@ -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 {
|
for _, agent := range agentDefs {
|
||||||
// Check if already exists (exact ID + agent type).
|
if _, ok := existingAgentIDs[agent.id]; ok {
|
||||||
if issue, err := bd.Show(agent.id); err == nil {
|
continue
|
||||||
if issue.ID == agent.id && issue.Type == "agent" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fields := &beads.AgentFields{
|
fields := &beads.AgentFields{
|
||||||
|
|||||||
@@ -342,9 +342,12 @@ func assertSlotValue(t *testing.T, townRoot, issueID, slot, want string) {
|
|||||||
t.Helper()
|
t.Helper()
|
||||||
cmd := exec.Command("bd", "--no-daemon", "--json", "slot", "show", issueID)
|
cmd := exec.Command("bd", "--no-daemon", "--json", "slot", "show", issueID)
|
||||||
cmd.Dir = townRoot
|
cmd.Dir = townRoot
|
||||||
output, err := cmd.CombinedOutput()
|
output, err := cmd.Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("bd slot show %s failed: %v\nOutput: %s", issueID, err, output)
|
debugCmd := exec.Command("bd", "--no-daemon", "--json", "slot", "show", issueID)
|
||||||
|
debugCmd.Dir = townRoot
|
||||||
|
combined, _ := debugCmd.CombinedOutput()
|
||||||
|
t.Fatalf("bd slot show %s failed: %v\nOutput: %s", issueID, err, combined)
|
||||||
}
|
}
|
||||||
|
|
||||||
var parsed struct {
|
var parsed struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user