This commit is contained in:
2026-08-23 13:39:56 +02:00
parent 89ae7e5fa8
commit 815e26d359
7 changed files with 283 additions and 8 deletions
@@ -110,6 +110,31 @@ func BuildCategoryEnhanceOverlay(parts LegacyEnhanceParts) string {
return strings.TrimSpace(b.String())
}
// ExtractEnhanceSectionBody returns the text between start/end markers
// (case-insensitive markers, body preserved). Empty when the start marker is missing.
func ExtractEnhanceSectionBody(prompt, start, end string) string {
raw := strings.ReplaceAll(strings.ReplaceAll(prompt, "\r\n", "\n"), "\r", "\n")
lower := strings.ToLower(raw)
startL := strings.ToLower(strings.TrimSpace(start))
endL := strings.ToLower(strings.TrimSpace(end))
if startL == "" {
return ""
}
startIdx := strings.Index(lower, startL)
if startIdx < 0 {
return ""
}
bodyStart := startIdx + len(startL)
rest := raw[bodyStart:]
restLower := lower[bodyStart:]
if endL != "" {
if endIdx := strings.Index(restLower, endL); endIdx >= 0 {
rest = rest[:endIdx]
}
}
return strings.TrimSpace(strings.TrimPrefix(strings.TrimSuffix(rest, "\n"), "\n"))
}
func cleanLegacyInstruction(s string) string {
s = modernizeLegacyPlaceholders(s)
s = reDoubledQuotes.ReplaceAllString(s, `"`)