feat(tools): implement CRUD operations for thoughts and projects
* Add tools for creating, retrieving, updating, and deleting thoughts. * Implement project management tools for creating and listing projects. * Introduce linking functionality between thoughts. * Add search and recall capabilities for thoughts based on semantic queries. * Implement statistics and summarization tools for thought analysis. * Create database migrations for thoughts, projects, and links. * Add helper functions for UUID parsing and project resolution.
This commit is contained in:
81
internal/metadata/normalize_test.go
Normal file
81
internal/metadata/normalize_test.go
Normal file
@@ -0,0 +1,81 @@
|
||||
package metadata
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"git.warky.dev/wdevs/amcs/internal/config"
|
||||
thoughttypes "git.warky.dev/wdevs/amcs/internal/types"
|
||||
)
|
||||
|
||||
func testCaptureConfig() config.CaptureConfig {
|
||||
return config.CaptureConfig{
|
||||
Source: "mcp",
|
||||
MetadataDefaults: config.CaptureMetadataDefault{
|
||||
Type: "observation",
|
||||
TopicFallback: "uncategorized",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func TestFallbackUsesConfiguredDefaults(t *testing.T) {
|
||||
got := Fallback(testCaptureConfig())
|
||||
if got.Type != "observation" {
|
||||
t.Fatalf("Fallback type = %q, want observation", got.Type)
|
||||
}
|
||||
if len(got.Topics) != 1 || got.Topics[0] != "uncategorized" {
|
||||
t.Fatalf("Fallback topics = %#v, want [uncategorized]", got.Topics)
|
||||
}
|
||||
if got.Source != "mcp" {
|
||||
t.Fatalf("Fallback source = %q, want mcp", got.Source)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizeTrimsDedupesAndCapsTopics(t *testing.T) {
|
||||
topics := []string{}
|
||||
for i := 0; i < 12; i++ {
|
||||
topics = append(topics, strings.TrimSpace(" topic "))
|
||||
topics = append(topics, string(rune('a'+i)))
|
||||
}
|
||||
|
||||
got := Normalize(thoughttypes.ThoughtMetadata{
|
||||
People: []string{" Alice ", "alice", "", "Bob"},
|
||||
Topics: topics,
|
||||
Type: "INVALID",
|
||||
}, testCaptureConfig())
|
||||
|
||||
if len(got.People) != 2 {
|
||||
t.Fatalf("People len = %d, want 2", len(got.People))
|
||||
}
|
||||
if got.Type != "observation" {
|
||||
t.Fatalf("Type = %q, want observation", got.Type)
|
||||
}
|
||||
if len(got.Topics) != maxTopics {
|
||||
t.Fatalf("Topics len = %d, want %d", len(got.Topics), maxTopics)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMergeAddsPatchAndNormalizes(t *testing.T) {
|
||||
base := thoughttypes.ThoughtMetadata{
|
||||
People: []string{"Alice"},
|
||||
Topics: []string{"go"},
|
||||
Type: "idea",
|
||||
Source: "mcp",
|
||||
}
|
||||
patch := thoughttypes.ThoughtMetadata{
|
||||
People: []string{" Bob ", "alice"},
|
||||
Topics: []string{"testing"},
|
||||
Type: "task",
|
||||
}
|
||||
|
||||
got := Merge(base, patch, testCaptureConfig())
|
||||
if got.Type != "task" {
|
||||
t.Fatalf("Type = %q, want task", got.Type)
|
||||
}
|
||||
if len(got.People) != 2 {
|
||||
t.Fatalf("People len = %d, want 2", len(got.People))
|
||||
}
|
||||
if len(got.Topics) != 2 {
|
||||
t.Fatalf("Topics len = %d, want 2", len(got.Topics))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user