// Package privacy provides privacy tag handling for claude-mnemonic.
package privacy
import (
"regexp"
"strings"
)
var (
// privateTagRegex matches ... tags
privateTagRegex = regexp.MustCompile(`(?s).*?`)
// memoryTagRegex matches ... tags
memoryTagRegex = regexp.MustCompile(`(?s).*?`)
)
// StripPrivateTags removes all ... content from text.
func StripPrivateTags(text string) string {
return privateTagRegex.ReplaceAllString(text, "")
}
// StripMemoryTags removes all ... content from text.
func StripMemoryTags(text string) string {
return memoryTagRegex.ReplaceAllString(text, "")
}
// StripAllTags removes both private and memory context tags.
func StripAllTags(text string) string {
text = StripPrivateTags(text)
text = StripMemoryTags(text)
return text
}
// IsEntirelyPrivate checks if the text is entirely within tags.
func IsEntirelyPrivate(text string) bool {
stripped := StripPrivateTags(text)
return strings.TrimSpace(stripped) == ""
}
// Clean performs full privacy cleaning on text.
// This is the main function to use before storing any user content.
func Clean(text string) string {
// Strip both types of tags
text = StripAllTags(text)
// Trim whitespace
return strings.TrimSpace(text)
}