package common import ( "strings" "github.com/router-for-me/CLIProxyAPI/v7/internal/util" "github.com/tidwall/gjson" ) const ( claudeSystemReminderStart = "" claudeSystemReminderEnd = "" ) // ClaudeMessageSystemReminderText converts a Claude message-level system value // into ordinary user-visible reminder text for non-Claude upstream formats. func ClaudeMessageSystemReminderText(content gjson.Result) (string, bool) { parts := claudeSystemTextParts(content) if len(parts) == 0 { return "", false } text := strings.Join(parts, "\n") if strings.TrimSpace(text) == "" { return "", false } return claudeSystemReminderStart + "\n" + text + "\n" + claudeSystemReminderEnd, true } func claudeSystemTextParts(content gjson.Result) []string { if !content.Exists() { return nil } if content.Type == gjson.String { text := content.String() if text == "" || util.IsClaudeCodeAttributionSystemText(text) { return nil } return []string{text} } if !content.IsArray() { return nil } parts := make([]string, 0) content.ForEach(func(_, item gjson.Result) bool { if item.Get("type").String() != "text" { return true } text := item.Get("text").String() if text == "" || util.IsClaudeCodeAttributionSystemText(text) { return true } parts = append(parts, text) return true }) return parts }