From eb44b1e4b244e5a93e7d465b14df39819d8dfaba Mon Sep 17 00:00:00 2001 From: Grail Finder Date: Fri, 16 Jan 2026 16:53:19 +0300 Subject: Feat: impl attempt --- bot_test.go | 318 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 318 insertions(+) (limited to 'bot_test.go') diff --git a/bot_test.go b/bot_test.go index d2956a9..7496175 100644 --- a/bot_test.go +++ b/bot_test.go @@ -286,4 +286,322 @@ func TestConvertJSONToMapStringString(t *testing.T) { } }) } +} + +func TestParseKnownToTag(t *testing.T) { + tests := []struct { + name string + content string + enabled bool + tag string + wantCleaned string + wantKnownTo []string + }{ + { + name: "feature disabled returns original", + content: "Hello __known_to_chars__Alice__", + enabled: false, + tag: "__known_to_chars__", + wantCleaned: "Hello __known_to_chars__Alice__", + wantKnownTo: nil, + }, + { + name: "no tag returns original", + content: "Hello Alice", + enabled: true, + tag: "__known_to_chars__", + wantCleaned: "Hello Alice", + wantKnownTo: nil, + }, + { + name: "single tag with one char", + content: "Hello __known_to_chars__Alice__", + enabled: true, + tag: "__known_to_chars__", + wantCleaned: "Hello", + wantKnownTo: []string{"Alice"}, + }, + { + name: "single tag with two chars", + content: "Secret __known_to_chars__Alice,Bob__ message", + enabled: true, + tag: "__known_to_chars__", + wantCleaned: "Secret message", + wantKnownTo: []string{"Alice", "Bob"}, + }, + { + name: "tag at beginning", + content: "__known_to_chars__Alice__ Hello", + enabled: true, + tag: "__known_to_chars__", + wantCleaned: "Hello", + wantKnownTo: []string{"Alice"}, + }, + { + name: "tag at end", + content: "Hello __known_to_chars__Alice__", + enabled: true, + tag: "__known_to_chars__", + wantCleaned: "Hello", + wantKnownTo: []string{"Alice"}, + }, + { + name: "multiple tags", + content: "First __known_to_chars__Alice__ then __known_to_chars__Bob__", + enabled: true, + tag: "__known_to_chars__", + wantCleaned: "First then", + wantKnownTo: []string{"Alice", "Bob"}, + }, + { + name: "custom tag", + content: "Secret __secret__Alice,Bob__ message", + enabled: true, + tag: "__secret__", + wantCleaned: "Secret message", + wantKnownTo: []string{"Alice", "Bob"}, + }, + { + name: "empty list", + content: "Secret __known_to_chars____", + enabled: true, + tag: "__known_to_chars__", + wantCleaned: "Secret", + wantKnownTo: nil, + }, + { + name: "whitespace around commas", + content: "__known_to_chars__ Alice , Bob , Carl __", + enabled: true, + tag: "__known_to_chars__", + wantCleaned: "", + wantKnownTo: []string{"Alice", "Bob", "Carl"}, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + // Set up config + testCfg := &config.Config{ + CharSpecificContextEnabled: tt.enabled, + CharSpecificContextTag: tt.tag, + } + cfg = testCfg + + cleaned, knownTo := parseKnownToTag(tt.content) + + if cleaned != tt.wantCleaned { + t.Errorf("parseKnownToTag() cleaned = %q, want %q", cleaned, tt.wantCleaned) + } + + if len(knownTo) != len(tt.wantKnownTo) { + t.Errorf("parseKnownToTag() knownTo length = %v, want %v", len(knownTo), len(tt.wantKnownTo)) + t.Logf("got: %v", knownTo) + t.Logf("want: %v", tt.wantKnownTo) + } else { + for i, got := range knownTo { + if got != tt.wantKnownTo[i] { + t.Errorf("parseKnownToTag() knownTo[%d] = %q, want %q", i, got, tt.wantKnownTo[i]) + } + } + } + }) + } +} + +func TestProcessMessageTag(t *testing.T) { + tests := []struct { + name string + msg models.RoleMsg + enabled bool + tag string + wantMsg models.RoleMsg + }{ + { + name: "feature disabled returns unchanged", + msg: models.RoleMsg{ + Role: "Alice", + Content: "Secret __known_to_chars__Bob__", + }, + enabled: false, + tag: "__known_to_chars__", + wantMsg: models.RoleMsg{ + Role: "Alice", + Content: "Secret __known_to_chars__Bob__", + KnownTo: nil, + }, + }, + { + name: "no tag, no knownTo", + msg: models.RoleMsg{ + Role: "Alice", + Content: "Hello everyone", + }, + enabled: true, + tag: "__known_to_chars__", + wantMsg: models.RoleMsg{ + Role: "Alice", + Content: "Hello everyone", + KnownTo: []string{"Alice"}, + }, + }, + { + name: "tag with Bob, adds Alice automatically", + msg: models.RoleMsg{ + Role: "Alice", + Content: "Secret __known_to_chars__Bob__", + }, + enabled: true, + tag: "__known_to_chars__", + wantMsg: models.RoleMsg{ + Role: "Alice", + Content: "Secret", + KnownTo: []string{"Bob", "Alice"}, + }, + }, + { + name: "tag already includes sender", + msg: models.RoleMsg{ + Role: "Alice", + Content: "__known_to_chars__Alice,Bob__", + }, + enabled: true, + tag: "__known_to_chars__", + wantMsg: models.RoleMsg{ + Role: "Alice", + Content: "", + KnownTo: []string{"Alice", "Bob"}, + }, + }, + { + name: "knownTo already set (from DB), tag still processed", + msg: models.RoleMsg{ + Role: "Alice", + Content: "Secret __known_to_chars__Bob__", + KnownTo: []string{"Alice"}, // from previous processing + }, + enabled: true, + tag: "__known_to_chars__", + wantMsg: models.RoleMsg{ + Role: "Alice", + Content: "Secret", + KnownTo: []string{"Bob", "Alice"}, + }, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + testCfg := &config.Config{ + CharSpecificContextEnabled: tt.enabled, + CharSpecificContextTag: tt.tag, + } + cfg = testCfg + + got := processMessageTag(tt.msg) + + if got.Content != tt.wantMsg.Content { + t.Errorf("processMessageTag() content = %q, want %q", got.Content, tt.wantMsg.Content) + } + + if len(got.KnownTo) != len(tt.wantMsg.KnownTo) { + t.Errorf("processMessageTag() KnownTo length = %v, want %v", len(got.KnownTo), len(tt.wantMsg.KnownTo)) + t.Logf("got: %v", got.KnownTo) + t.Logf("want: %v", tt.wantMsg.KnownTo) + } else { + // order may differ; check membership + for _, want := range tt.wantMsg.KnownTo { + found := false + for _, gotVal := range got.KnownTo { + if gotVal == want { + found = true + break + } + } + if !found { + t.Errorf("processMessageTag() missing KnownTo entry %q, got %v", want, got.KnownTo) + } + } + } + }) + } +} + +func TestFilterMessagesForCharacter(t *testing.T) { + messages := []models.RoleMsg{ + {Role: "system", Content: "System message", KnownTo: nil}, // visible to all + {Role: "Alice", Content: "Hello everyone", KnownTo: nil}, // visible to all + {Role: "Alice", Content: "Secret for Bob", KnownTo: []string{"Alice", "Bob"}}, + {Role: "Bob", Content: "Reply to Alice", KnownTo: []string{"Alice", "Bob"}}, + {Role: "Alice", Content: "Private to Carl", KnownTo: []string{"Alice", "Carl"}}, + {Role: "Carl", Content: "Hi all", KnownTo: nil}, // visible to all + } + + tests := []struct { + name string + enabled bool + character string + wantIndices []int // indices from original messages that should be included + }{ + { + name: "feature disabled returns all", + enabled: false, + character: "Alice", + wantIndices: []int{0,1,2,3,4,5}, + }, + { + name: "character empty returns all", + enabled: true, + character: "", + wantIndices: []int{0,1,2,3,4,5}, + }, + { + name: "Alice sees all including Carl-private", + enabled: true, + character: "Alice", + wantIndices: []int{0,1,2,3,4,5}, + }, + { + name: "Bob sees Alice-Bob secrets and all public", + enabled: true, + character: "Bob", + wantIndices: []int{0,1,2,3,5}, + }, + { + name: "Carl sees Alice-Carl secret and public", + enabled: true, + character: "Carl", + wantIndices: []int{0,1,4,5}, + }, + { + name: "David sees only public messages", + enabled: true, + character: "David", + wantIndices: []int{0,1,5}, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + testCfg := &config.Config{ + CharSpecificContextEnabled: tt.enabled, + CharSpecificContextTag: "__known_to_chars__", + } + cfg = testCfg + + got := filterMessagesForCharacter(messages, tt.character) + + if len(got) != len(tt.wantIndices) { + t.Errorf("filterMessagesForCharacter() returned %d messages, want %d", len(got), len(tt.wantIndices)) + t.Logf("got: %v", got) + return + } + + for i, idx := range tt.wantIndices { + if got[i].Content != messages[idx].Content { + t.Errorf("filterMessagesForCharacter() message %d content = %q, want %q", i, got[i].Content, messages[idx].Content) + } + } + }) + } } \ No newline at end of file -- cgit v1.2.3 From fd84dd58266bdeff498f939721e9a1998318473b Mon Sep 17 00:00:00 2001 From: Grail Finder Date: Sat, 17 Jan 2026 12:28:19 +0300 Subject: Enha: do not remove tag --- bot_test.go | 241 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 122 insertions(+), 119 deletions(-) (limited to 'bot_test.go') diff --git a/bot_test.go b/bot_test.go index 7496175..a745dde 100644 --- a/bot_test.go +++ b/bot_test.go @@ -118,34 +118,34 @@ func TestConsolidateConsecutiveAssistantMessages(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { result := consolidateConsecutiveAssistantMessages(tt.input) - + if len(result) != len(tt.expected) { t.Errorf("Expected %d messages, got %d", len(tt.expected), len(result)) t.Logf("Result: %+v", result) t.Logf("Expected: %+v", tt.expected) return } - + for i, expectedMsg := range tt.expected { if i >= len(result) { t.Errorf("Result has fewer messages than expected at index %d", i) continue } - + actualMsg := result[i] if actualMsg.Role != expectedMsg.Role { t.Errorf("Message %d: expected role '%s', got '%s'", i, expectedMsg.Role, actualMsg.Role) } - + if actualMsg.Content != expectedMsg.Content { t.Errorf("Message %d: expected content '%s', got '%s'", i, expectedMsg.Content, actualMsg.Content) } - + if actualMsg.ToolCallID != expectedMsg.ToolCallID { t.Errorf("Message %d: expected ToolCallID '%s', got '%s'", i, expectedMsg.ToolCallID, actualMsg.ToolCallID) } } - + // Additional check: ensure no messages were lost if !reflect.DeepEqual(result, tt.expected) { t.Errorf("Result does not match expected:\nResult: %+v\nExpected: %+v", result, tt.expected) @@ -290,92 +290,92 @@ func TestConvertJSONToMapStringString(t *testing.T) { func TestParseKnownToTag(t *testing.T) { tests := []struct { - name string - content string - enabled bool - tag string - wantCleaned string - wantKnownTo []string + name string + content string + enabled bool + tag string + wantCleaned string + wantKnownTo []string }{ { - name: "feature disabled returns original", - content: "Hello __known_to_chars__Alice__", - enabled: false, - tag: "__known_to_chars__", - wantCleaned: "Hello __known_to_chars__Alice__", - wantKnownTo: nil, + name: "feature disabled returns original", + content: "Hello __known_to_chars__Alice__", + enabled: false, + tag: "__known_to_chars__", + wantCleaned: "Hello __known_to_chars__Alice__", + wantKnownTo: nil, }, { - name: "no tag returns original", - content: "Hello Alice", - enabled: true, - tag: "__known_to_chars__", - wantCleaned: "Hello Alice", - wantKnownTo: nil, + name: "no tag returns original", + content: "Hello Alice", + enabled: true, + tag: "__known_to_chars__", + wantCleaned: "Hello Alice", + wantKnownTo: nil, }, { - name: "single tag with one char", - content: "Hello __known_to_chars__Alice__", - enabled: true, - tag: "__known_to_chars__", - wantCleaned: "Hello", - wantKnownTo: []string{"Alice"}, + name: "single tag with one char", + content: "Hello __known_to_chars__Alice__", + enabled: true, + tag: "__known_to_chars__", + wantCleaned: "Hello", + wantKnownTo: []string{"Alice"}, }, { - name: "single tag with two chars", - content: "Secret __known_to_chars__Alice,Bob__ message", - enabled: true, - tag: "__known_to_chars__", - wantCleaned: "Secret message", - wantKnownTo: []string{"Alice", "Bob"}, + name: "single tag with two chars", + content: "Secret __known_to_chars__Alice,Bob__ message", + enabled: true, + tag: "__known_to_chars__", + wantCleaned: "Secret message", + wantKnownTo: []string{"Alice", "Bob"}, }, { - name: "tag at beginning", - content: "__known_to_chars__Alice__ Hello", - enabled: true, - tag: "__known_to_chars__", - wantCleaned: "Hello", - wantKnownTo: []string{"Alice"}, + name: "tag at beginning", + content: "__known_to_chars__Alice__ Hello", + enabled: true, + tag: "__known_to_chars__", + wantCleaned: "Hello", + wantKnownTo: []string{"Alice"}, }, { - name: "tag at end", - content: "Hello __known_to_chars__Alice__", - enabled: true, - tag: "__known_to_chars__", - wantCleaned: "Hello", - wantKnownTo: []string{"Alice"}, + name: "tag at end", + content: "Hello __known_to_chars__Alice__", + enabled: true, + tag: "__known_to_chars__", + wantCleaned: "Hello", + wantKnownTo: []string{"Alice"}, }, { - name: "multiple tags", - content: "First __known_to_chars__Alice__ then __known_to_chars__Bob__", - enabled: true, - tag: "__known_to_chars__", - wantCleaned: "First then", - wantKnownTo: []string{"Alice", "Bob"}, + name: "multiple tags", + content: "First __known_to_chars__Alice__ then __known_to_chars__Bob__", + enabled: true, + tag: "__known_to_chars__", + wantCleaned: "First then", + wantKnownTo: []string{"Alice", "Bob"}, }, { - name: "custom tag", - content: "Secret __secret__Alice,Bob__ message", - enabled: true, - tag: "__secret__", - wantCleaned: "Secret message", - wantKnownTo: []string{"Alice", "Bob"}, + name: "custom tag", + content: "Secret __secret__Alice,Bob__ message", + enabled: true, + tag: "__secret__", + wantCleaned: "Secret message", + wantKnownTo: []string{"Alice", "Bob"}, }, { - name: "empty list", - content: "Secret __known_to_chars____", - enabled: true, - tag: "__known_to_chars__", - wantCleaned: "Secret", - wantKnownTo: nil, + name: "empty list", + content: "Secret __known_to_chars____", + enabled: true, + tag: "__known_to_chars__", + wantCleaned: "Secret", + wantKnownTo: nil, }, { - name: "whitespace around commas", - content: "__known_to_chars__ Alice , Bob , Carl __", - enabled: true, - tag: "__known_to_chars__", - wantCleaned: "", - wantKnownTo: []string{"Alice", "Bob", "Carl"}, + name: "whitespace around commas", + content: "__known_to_chars__ Alice , Bob , Carl __", + enabled: true, + tag: "__known_to_chars__", + wantCleaned: "", + wantKnownTo: []string{"Alice", "Bob", "Carl"}, }, } @@ -387,13 +387,7 @@ func TestParseKnownToTag(t *testing.T) { CharSpecificContextTag: tt.tag, } cfg = testCfg - - cleaned, knownTo := parseKnownToTag(tt.content) - - if cleaned != tt.wantCleaned { - t.Errorf("parseKnownToTag() cleaned = %q, want %q", cleaned, tt.wantCleaned) - } - + knownTo := parseKnownToTag(tt.content) if len(knownTo) != len(tt.wantKnownTo) { t.Errorf("parseKnownToTag() knownTo length = %v, want %v", len(knownTo), len(tt.wantKnownTo)) t.Logf("got: %v", knownTo) @@ -411,11 +405,11 @@ func TestParseKnownToTag(t *testing.T) { func TestProcessMessageTag(t *testing.T) { tests := []struct { - name string - msg models.RoleMsg - enabled bool - tag string - wantMsg models.RoleMsg + name string + msg models.RoleMsg + enabled bool + tag string + wantMsg models.RoleMsg }{ { name: "feature disabled returns unchanged", @@ -488,6 +482,21 @@ func TestProcessMessageTag(t *testing.T) { KnownTo: []string{"Bob", "Alice"}, }, }, + { + name: "example from real use", + msg: models.RoleMsg{ + Role: "Alice", + Content: "I'll start with a simple one! The word is 'banana'. (ooc: __known_to_chars__Bob__)", + KnownTo: []string{"Alice"}, // from previous processing + }, + enabled: true, + tag: "__known_to_chars__", + wantMsg: models.RoleMsg{ + Role: "Alice", + Content: "I'll start with a simple one! The word is 'banana'. (ooc: __known_to_chars__Bob__)", + KnownTo: []string{"Bob", "Alice"}, + }, + }, } for _, tt := range tests { @@ -497,13 +506,7 @@ func TestProcessMessageTag(t *testing.T) { CharSpecificContextTag: tt.tag, } cfg = testCfg - got := processMessageTag(tt.msg) - - if got.Content != tt.wantMsg.Content { - t.Errorf("processMessageTag() content = %q, want %q", got.Content, tt.wantMsg.Content) - } - if len(got.KnownTo) != len(tt.wantMsg.KnownTo) { t.Errorf("processMessageTag() KnownTo length = %v, want %v", len(got.KnownTo), len(tt.wantMsg.KnownTo)) t.Logf("got: %v", got.KnownTo) @@ -530,7 +533,7 @@ func TestProcessMessageTag(t *testing.T) { func TestFilterMessagesForCharacter(t *testing.T) { messages := []models.RoleMsg{ {Role: "system", Content: "System message", KnownTo: nil}, // visible to all - {Role: "Alice", Content: "Hello everyone", KnownTo: nil}, // visible to all + {Role: "Alice", Content: "Hello everyone", KnownTo: nil}, // visible to all {Role: "Alice", Content: "Secret for Bob", KnownTo: []string{"Alice", "Bob"}}, {Role: "Bob", Content: "Reply to Alice", KnownTo: []string{"Alice", "Bob"}}, {Role: "Alice", Content: "Private to Carl", KnownTo: []string{"Alice", "Carl"}}, @@ -538,46 +541,46 @@ func TestFilterMessagesForCharacter(t *testing.T) { } tests := []struct { - name string - enabled bool - character string + name string + enabled bool + character string wantIndices []int // indices from original messages that should be included }{ { - name: "feature disabled returns all", - enabled: false, - character: "Alice", - wantIndices: []int{0,1,2,3,4,5}, + name: "feature disabled returns all", + enabled: false, + character: "Alice", + wantIndices: []int{0, 1, 2, 3, 4, 5}, }, { - name: "character empty returns all", - enabled: true, - character: "", - wantIndices: []int{0,1,2,3,4,5}, + name: "character empty returns all", + enabled: true, + character: "", + wantIndices: []int{0, 1, 2, 3, 4, 5}, }, { - name: "Alice sees all including Carl-private", - enabled: true, - character: "Alice", - wantIndices: []int{0,1,2,3,4,5}, + name: "Alice sees all including Carl-private", + enabled: true, + character: "Alice", + wantIndices: []int{0, 1, 2, 3, 4, 5}, }, { - name: "Bob sees Alice-Bob secrets and all public", - enabled: true, - character: "Bob", - wantIndices: []int{0,1,2,3,5}, + name: "Bob sees Alice-Bob secrets and all public", + enabled: true, + character: "Bob", + wantIndices: []int{0, 1, 2, 3, 5}, }, { - name: "Carl sees Alice-Carl secret and public", - enabled: true, - character: "Carl", - wantIndices: []int{0,1,4,5}, + name: "Carl sees Alice-Carl secret and public", + enabled: true, + character: "Carl", + wantIndices: []int{0, 1, 4, 5}, }, { - name: "David sees only public messages", - enabled: true, - character: "David", - wantIndices: []int{0,1,5}, + name: "David sees only public messages", + enabled: true, + character: "David", + wantIndices: []int{0, 1, 5}, }, } @@ -604,4 +607,4 @@ func TestFilterMessagesForCharacter(t *testing.T) { } }) } -} \ No newline at end of file +} -- cgit v1.2.3 From 0fb59210045792433a7a3796046c8383f2bb8824 Mon Sep 17 00:00:00 2001 From: Grail Finder Date: Sat, 17 Jan 2026 12:44:18 +0300 Subject: Fix: copy with knownto --- bot_test.go | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'bot_test.go') diff --git a/bot_test.go b/bot_test.go index a745dde..d5b4b0a 100644 --- a/bot_test.go +++ b/bot_test.go @@ -608,3 +608,65 @@ func TestFilterMessagesForCharacter(t *testing.T) { }) } } + +func TestRoleMsgCopyPreservesKnownTo(t *testing.T) { + // Test that the Copy() method preserves the KnownTo field + originalMsg := models.RoleMsg{ + Role: "Alice", + Content: "Test message", + KnownTo: []string{"Bob", "Charlie"}, + } + + copiedMsg := originalMsg.Copy() + + if copiedMsg.Role != originalMsg.Role { + t.Errorf("Copy() failed to preserve Role: got %q, want %q", copiedMsg.Role, originalMsg.Role) + } + if copiedMsg.Content != originalMsg.Content { + t.Errorf("Copy() failed to preserve Content: got %q, want %q", copiedMsg.Content, originalMsg.Content) + } + if !reflect.DeepEqual(copiedMsg.KnownTo, originalMsg.KnownTo) { + t.Errorf("Copy() failed to preserve KnownTo: got %v, want %v", copiedMsg.KnownTo, originalMsg.KnownTo) + } + if copiedMsg.ToolCallID != originalMsg.ToolCallID { + t.Errorf("Copy() failed to preserve ToolCallID: got %q, want %q", copiedMsg.ToolCallID, originalMsg.ToolCallID) + } + if copiedMsg.IsContentParts() != originalMsg.IsContentParts() { + t.Errorf("Copy() failed to preserve hasContentParts flag") + } +} + +func TestKnownToFieldPreservationScenario(t *testing.T) { + // Test the specific scenario from the log where KnownTo field was getting lost + originalMsg := models.RoleMsg{ + Role: "Alice", + Content: `Alice: "Okay, Bob. The word is... **'Ephemeral'**. (ooc: __known_to_chars__Bob__)"`, + KnownTo: []string{"Bob"}, // This was detected in the log + } + + t.Logf("Original message - Role: %s, Content: %s, KnownTo: %v", + originalMsg.Role, originalMsg.Content, originalMsg.KnownTo) + + // Simulate what happens when the message gets copied during processing + copiedMsg := originalMsg.Copy() + + t.Logf("Copied message - Role: %s, Content: %s, KnownTo: %v", + copiedMsg.Role, copiedMsg.Content, copiedMsg.KnownTo) + + // Check if KnownTo field survived the copy + if len(copiedMsg.KnownTo) == 0 { + t.Error("ERROR: KnownTo field was lost during copy!") + } else { + t.Log("SUCCESS: KnownTo field was preserved during copy!") + } + + // Verify the content is the same + if copiedMsg.Content != originalMsg.Content { + t.Errorf("Content was changed during copy: got %s, want %s", copiedMsg.Content, originalMsg.Content) + } + + // Verify the KnownTo slice is properly copied + if !reflect.DeepEqual(copiedMsg.KnownTo, originalMsg.KnownTo) { + t.Errorf("KnownTo was not properly copied: got %v, want %v", copiedMsg.KnownTo, originalMsg.KnownTo) + } +} -- cgit v1.2.3 From 3e2a1b6f9975aaa2b9cb45bcb77aac146a37fd3c Mon Sep 17 00:00:00 2001 From: Grail Finder Date: Sat, 17 Jan 2026 13:03:30 +0300 Subject: Fix: KnowTo is added only if tag present --- bot_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot_test.go') diff --git a/bot_test.go b/bot_test.go index d5b4b0a..3dabc15 100644 --- a/bot_test.go +++ b/bot_test.go @@ -436,7 +436,7 @@ func TestProcessMessageTag(t *testing.T) { wantMsg: models.RoleMsg{ Role: "Alice", Content: "Hello everyone", - KnownTo: []string{"Alice"}, + KnownTo: nil, }, }, { -- cgit v1.2.3 From 6f6a35459ef4de340c0c6825da20828e7f579207 Mon Sep 17 00:00:00 2001 From: Grail Finder Date: Sun, 1 Feb 2026 11:38:51 +0300 Subject: Chore: cleaning --- bot_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot_test.go') diff --git a/bot_test.go b/bot_test.go index 3dabc15..4cbe953 100644 --- a/bot_test.go +++ b/bot_test.go @@ -117,7 +117,7 @@ func TestConsolidateConsecutiveAssistantMessages(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - result := consolidateConsecutiveAssistantMessages(tt.input) + result := consolidateAssistantMessages(tt.input) if len(result) != len(tt.expected) { t.Errorf("Expected %d messages, got %d", len(tt.expected), len(result)) -- cgit v1.2.3 From 4af866079c3f21eab12b02c3158567539ca40c50 Mon Sep 17 00:00:00 2001 From: Grail Finder Date: Fri, 6 Feb 2026 12:42:06 +0300 Subject: Chore: linter complaints --- bot_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot_test.go') diff --git a/bot_test.go b/bot_test.go index 4cbe953..1710003 100644 --- a/bot_test.go +++ b/bot_test.go @@ -506,7 +506,7 @@ func TestProcessMessageTag(t *testing.T) { CharSpecificContextTag: tt.tag, } cfg = testCfg - got := processMessageTag(tt.msg) + got := processMessageTag(&tt.msg) if len(got.KnownTo) != len(tt.wantMsg.KnownTo) { t.Errorf("processMessageTag() KnownTo length = %v, want %v", len(got.KnownTo), len(tt.wantMsg.KnownTo)) t.Logf("got: %v", got.KnownTo) -- cgit v1.2.3 From 5e7ddea6827765ac56155577cf7dcc809fe1128c Mon Sep 17 00:00:00 2001 From: Grail Finder Date: Mon, 9 Feb 2026 09:44:54 +0300 Subject: Enha: change __known_by_char tag to @ --- bot_test.go | 70 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) (limited to 'bot_test.go') diff --git a/bot_test.go b/bot_test.go index 1710003..01c3e2c 100644 --- a/bot_test.go +++ b/bot_test.go @@ -299,81 +299,81 @@ func TestParseKnownToTag(t *testing.T) { }{ { name: "feature disabled returns original", - content: "Hello __known_to_chars__Alice__", + content: "Hello @Alice@", enabled: false, - tag: "__known_to_chars__", - wantCleaned: "Hello __known_to_chars__Alice__", + tag: "@", + wantCleaned: "Hello @Alice@", wantKnownTo: nil, }, { name: "no tag returns original", content: "Hello Alice", enabled: true, - tag: "__known_to_chars__", + tag: "@", wantCleaned: "Hello Alice", wantKnownTo: nil, }, { name: "single tag with one char", - content: "Hello __known_to_chars__Alice__", + content: "Hello @Alice@", enabled: true, - tag: "__known_to_chars__", + tag: "@", wantCleaned: "Hello", wantKnownTo: []string{"Alice"}, }, { name: "single tag with two chars", - content: "Secret __known_to_chars__Alice,Bob__ message", + content: "Secret @Alice,Bob@ message", enabled: true, - tag: "__known_to_chars__", + tag: "@", wantCleaned: "Secret message", wantKnownTo: []string{"Alice", "Bob"}, }, { name: "tag at beginning", - content: "__known_to_chars__Alice__ Hello", + content: "@Alice@ Hello", enabled: true, - tag: "__known_to_chars__", + tag: "@", wantCleaned: "Hello", wantKnownTo: []string{"Alice"}, }, { name: "tag at end", - content: "Hello __known_to_chars__Alice__", + content: "Hello @Alice@", enabled: true, - tag: "__known_to_chars__", + tag: "@", wantCleaned: "Hello", wantKnownTo: []string{"Alice"}, }, { name: "multiple tags", - content: "First __known_to_chars__Alice__ then __known_to_chars__Bob__", + content: "First @Alice@ then @Bob@", enabled: true, - tag: "__known_to_chars__", + tag: "@", wantCleaned: "First then", wantKnownTo: []string{"Alice", "Bob"}, }, { name: "custom tag", - content: "Secret __secret__Alice,Bob__ message", + content: "Secret @Alice,Bob@ message", enabled: true, - tag: "__secret__", + tag: "@", wantCleaned: "Secret message", wantKnownTo: []string{"Alice", "Bob"}, }, { name: "empty list", - content: "Secret __known_to_chars____", + content: "Secret @@@", enabled: true, - tag: "__known_to_chars__", + tag: "@", wantCleaned: "Secret", wantKnownTo: nil, }, { name: "whitespace around commas", - content: "__known_to_chars__ Alice , Bob , Carl __", + content: "@ Alice , Bob , Carl @", enabled: true, - tag: "__known_to_chars__", + tag: "@", wantCleaned: "", wantKnownTo: []string{"Alice", "Bob", "Carl"}, }, @@ -415,13 +415,13 @@ func TestProcessMessageTag(t *testing.T) { name: "feature disabled returns unchanged", msg: models.RoleMsg{ Role: "Alice", - Content: "Secret __known_to_chars__Bob__", + Content: "Secret @Bob@", }, enabled: false, - tag: "__known_to_chars__", + tag: "@", wantMsg: models.RoleMsg{ Role: "Alice", - Content: "Secret __known_to_chars__Bob__", + Content: "Secret @Bob@", KnownTo: nil, }, }, @@ -432,7 +432,7 @@ func TestProcessMessageTag(t *testing.T) { Content: "Hello everyone", }, enabled: true, - tag: "__known_to_chars__", + tag: "@", wantMsg: models.RoleMsg{ Role: "Alice", Content: "Hello everyone", @@ -443,10 +443,10 @@ func TestProcessMessageTag(t *testing.T) { name: "tag with Bob, adds Alice automatically", msg: models.RoleMsg{ Role: "Alice", - Content: "Secret __known_to_chars__Bob__", + Content: "Secret @Bob@", }, enabled: true, - tag: "__known_to_chars__", + tag: "@", wantMsg: models.RoleMsg{ Role: "Alice", Content: "Secret", @@ -457,10 +457,10 @@ func TestProcessMessageTag(t *testing.T) { name: "tag already includes sender", msg: models.RoleMsg{ Role: "Alice", - Content: "__known_to_chars__Alice,Bob__", + Content: "@Alice,Bob@", }, enabled: true, - tag: "__known_to_chars__", + tag: "@", wantMsg: models.RoleMsg{ Role: "Alice", Content: "", @@ -471,11 +471,11 @@ func TestProcessMessageTag(t *testing.T) { name: "knownTo already set (from DB), tag still processed", msg: models.RoleMsg{ Role: "Alice", - Content: "Secret __known_to_chars__Bob__", + Content: "Secret @Bob@", KnownTo: []string{"Alice"}, // from previous processing }, enabled: true, - tag: "__known_to_chars__", + tag: "@", wantMsg: models.RoleMsg{ Role: "Alice", Content: "Secret", @@ -486,14 +486,14 @@ func TestProcessMessageTag(t *testing.T) { name: "example from real use", msg: models.RoleMsg{ Role: "Alice", - Content: "I'll start with a simple one! The word is 'banana'. (ooc: __known_to_chars__Bob__)", + Content: "I'll start with a simple one! The word is 'banana'. (ooc: @Bob@)", KnownTo: []string{"Alice"}, // from previous processing }, enabled: true, - tag: "__known_to_chars__", + tag: "@", wantMsg: models.RoleMsg{ Role: "Alice", - Content: "I'll start with a simple one! The word is 'banana'. (ooc: __known_to_chars__Bob__)", + Content: "I'll start with a simple one! The word is 'banana'. (ooc: @Bob@)", KnownTo: []string{"Bob", "Alice"}, }, }, @@ -588,7 +588,7 @@ func TestFilterMessagesForCharacter(t *testing.T) { t.Run(tt.name, func(t *testing.T) { testCfg := &config.Config{ CharSpecificContextEnabled: tt.enabled, - CharSpecificContextTag: "__known_to_chars__", + CharSpecificContextTag: "@", } cfg = testCfg @@ -640,7 +640,7 @@ func TestKnownToFieldPreservationScenario(t *testing.T) { // Test the specific scenario from the log where KnownTo field was getting lost originalMsg := models.RoleMsg{ Role: "Alice", - Content: `Alice: "Okay, Bob. The word is... **'Ephemeral'**. (ooc: __known_to_chars__Bob__)"`, + Content: `Alice: "Okay, Bob. The word is... **'Ephemeral'**. (ooc: @Bob@)"`, KnownTo: []string{"Bob"}, // This was detected in the log } -- cgit v1.2.3