diff --git a/pkg/agentic/commands.go b/pkg/agentic/commands.go index 751622a..115d89b 100644 --- a/pkg/agentic/commands.go +++ b/pkg/agentic/commands.go @@ -528,6 +528,9 @@ func (s *PrepSubsystem) cmdBrainList(options core.Options) core.Result { } else { core.Print(nil, " %s %-12s", memory.ID, memory.Type) } + if memory.SupersedesCount > 0 { + core.Print(nil, " supersedes: %d", memory.SupersedesCount) + } if memory.Content != "" { core.Print(nil, " %s", memory.Content) } @@ -1108,13 +1111,14 @@ type brainListOutput struct { } type brainListOutputEntry struct { - ID string `json:"id"` - Type string `json:"type"` - Content string `json:"content"` - Project string `json:"project"` - AgentID string `json:"agent_id"` - Confidence float64 `json:"confidence"` - Tags []string `json:"tags"` + ID string `json:"id"` + Type string `json:"type"` + Content string `json:"content"` + Project string `json:"project"` + AgentID string `json:"agent_id"` + Confidence float64 `json:"confidence"` + SupersedesCount int `json:"supersedes_count,omitempty"` + Tags []string `json:"tags"` } func brainListOutputFromPayload(payload map[string]any) brainListOutput { @@ -1152,6 +1156,12 @@ func brainListOutputFromPayload(payload map[string]any) brainListOutput { entry.Confidence = float64(confidence) } } + switch supersedesCount := entryMap["supersedes_count"].(type) { + case float64: + entry.SupersedesCount = int(supersedesCount) + case int: + entry.SupersedesCount = supersedesCount + } if tags, ok := entryMap["tags"].([]any); ok { for _, tag := range tags { entry.Tags = append(entry.Tags, brainListStringValue(tag)) diff --git a/pkg/agentic/commands_test.go b/pkg/agentic/commands_test.go index 9df8d0a..9ea3b37 100644 --- a/pkg/agentic/commands_test.go +++ b/pkg/agentic/commands_test.go @@ -247,13 +247,14 @@ func TestCommands_CmdBrainList_Good(t *testing.T) { "count": 1, "memories": []any{ map[string]any{ - "id": "mem-1", - "type": "architecture", - "content": "Use named actions.", - "project": "agent", - "agent_id": "virgil", - "confidence": 0.9, - "tags": []any{"architecture", "convention"}, + "id": "mem-1", + "type": "architecture", + "content": "Use named actions.", + "project": "agent", + "agent_id": "virgil", + "confidence": 0.9, + "supersedes_count": 3, + "tags": []any{"architecture", "convention"}, }, }, }, OK: true} @@ -270,6 +271,7 @@ func TestCommands_CmdBrainList_Good(t *testing.T) { assert.Contains(t, output, "count: 1") assert.Contains(t, output, "mem-1 architecture") + assert.Contains(t, output, "supersedes: 3") assert.Contains(t, output, "Use named actions.") } diff --git a/pkg/brain/direct.go b/pkg/brain/direct.go index 368f147..f4628b5 100644 --- a/pkg/brain/direct.go +++ b/pkg/brain/direct.go @@ -271,6 +271,12 @@ func memoriesFromPayload(payload map[string]any) []Memory { if supersedesID, ok := memoryMap["supersedes_id"].(string); ok { memory.SupersedesID = supersedesID } + if supersedesCount, ok := memoryMap["supersedes_count"].(float64); ok { + memory.SupersedesCount = int(supersedesCount) + } + if supersedesCount, ok := memoryMap["supersedes_count"].(int); ok { + memory.SupersedesCount = supersedesCount + } if tags, ok := memoryMap["tags"].([]any); ok { for _, tag := range tags { memory.Tags = append(memory.Tags, core.Sprint(tag)) diff --git a/pkg/brain/direct_test.go b/pkg/brain/direct_test.go index b961981..796f63d 100644 --- a/pkg/brain/direct_test.go +++ b/pkg/brain/direct_test.go @@ -422,18 +422,19 @@ func TestDirect_List_Good_WithMemories(t *testing.T) { "data": map[string]any{ "memories": []any{ map[string]any{ - "id": "mem-list-1", - "content": "Use the review queue for completed workspaces", - "type": "decision", - "project": "agent", - "agent_id": "codex", - "confidence": 0.73, - "tags": []any{"queue", "review"}, - "updated_at": "2026-03-30T10:00:00Z", - "created_at": "2026-03-30T09:00:00Z", - "expires_at": "2026-04-01T00:00:00Z", - "source": "manual", - "supersedes_id": "mem-old", + "id": "mem-list-1", + "content": "Use the review queue for completed workspaces", + "type": "decision", + "project": "agent", + "agent_id": "codex", + "confidence": 0.73, + "supersedes_count": 2, + "tags": []any{"queue", "review"}, + "updated_at": "2026-03-30T10:00:00Z", + "created_at": "2026-03-30T09:00:00Z", + "expires_at": "2026-04-01T00:00:00Z", + "source": "manual", + "supersedes_id": "mem-old", }, map[string]any{ "id": "mem-list-2", @@ -463,6 +464,7 @@ func TestDirect_List_Good_WithMemories(t *testing.T) { assert.Equal(t, "mem-list-1", out.Memories[0].ID) assert.Equal(t, 0.73, out.Memories[0].Confidence) + assert.Equal(t, 2, out.Memories[0].SupersedesCount) assert.Equal(t, "mem-old", out.Memories[0].SupersedesID) assert.Equal(t, "manual", out.Memories[0].Source) assert.Equal(t, "2026-03-30T10:00:00Z", out.Memories[0].UpdatedAt) diff --git a/pkg/brain/tools.go b/pkg/brain/tools.go index 9735d5a..307622f 100644 --- a/pkg/brain/tools.go +++ b/pkg/brain/tools.go @@ -72,18 +72,19 @@ type RecallOutput struct { // Content: "Use core.Env for system paths.", // } type Memory struct { - ID string `json:"id"` - AgentID string `json:"agent_id"` - Type string `json:"type"` - Content string `json:"content"` - Tags []string `json:"tags,omitempty"` - Project string `json:"project,omitempty"` - Source string `json:"source,omitempty"` - Confidence float64 `json:"confidence"` - SupersedesID string `json:"supersedes_id,omitempty"` - ExpiresAt string `json:"expires_at,omitempty"` - CreatedAt string `json:"created_at"` - UpdatedAt string `json:"updated_at"` + ID string `json:"id"` + AgentID string `json:"agent_id"` + Type string `json:"type"` + Content string `json:"content"` + Tags []string `json:"tags,omitempty"` + Project string `json:"project,omitempty"` + Source string `json:"source,omitempty"` + Confidence float64 `json:"confidence"` + SupersedesID string `json:"supersedes_id,omitempty"` + SupersedesCount int `json:"supersedes_count,omitempty"` + ExpiresAt string `json:"expires_at,omitempty"` + CreatedAt string `json:"created_at"` + UpdatedAt string `json:"updated_at"` } // BrainMemory is the RFC-named alias for Memory.