chore: import Local-Cursor v1.1.8 source snapshot

Includes the current working directory changes. Historical commits and release binaries are excluded to limit Gitea storage.
Source base: d7515973fbfd6dd2001fa156c483455b8081c7cb
This commit is contained in:
FuDie0915
2026-11-10 01:24:28 +08:00
commit db73cf5a39
337 changed files with 147502 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
package modeladapter
import (
"encoding/json"
"fmt"
"testing"
)
func TestAnthropicMessageCacheBreakpointsPreserveAppendOnlyHistory(t *testing.T) {
for size := 1; size <= 32; size++ {
t.Run(fmt.Sprintf("size_%02d", size), func(t *testing.T) {
previous := anthropicMessagesForAppendOnlyTest(size)
current := anthropicMessagesForAppendOnlyTest(size + 1)
applyAnthropicMessageCacheBreakpoints(previous)
applyAnthropicMessageCacheBreakpoints(current)
want := mustMarshalAnthropicMessagesForTest(t, previous)
got := mustMarshalAnthropicMessagesForTest(t, current[:len(previous)])
if got != want {
t.Fatalf("historical message prefix changed after append\nwant: %s\ngot: %s", want, got)
}
})
}
}
func anthropicMessagesForAppendOnlyTest(count int) []anthropicMessage {
messages := make([]anthropicMessage, 0, count)
for index := 0; index < count; index++ {
messages = append(messages, anthropicMessage{
Role: "user",
Content: []map[string]any{{
"type": "text",
"text": fmt.Sprintf("message-%02d", index),
}},
})
}
return messages
}
func mustMarshalAnthropicMessagesForTest(t *testing.T, messages []anthropicMessage) string {
t.Helper()
payload, err := json.Marshal(messages)
if err != nil {
t.Fatalf("marshal anthropic messages: %v", err)
}
return string(payload)
}