This commit is contained in:
greeneclipse committed 2026-10-14 20:28:38 +02:00
1 parent 8b540d22bc
commit c92ee93482
24 files changed
+1495 -327

No files matched your search

+19 -3
View File
@@ -411,7 +411,11 @@ func computeRepairedEnhancePrompt(current company.LangPromptMap, seedLegacy stri
return "", false, false
}
if aiprompts.IsLegacyCombinedEnhancePrompt(raw) {
return aiprompts.SplitLegacyCombinedEnhancePrompt(raw), true, false
split := aiprompts.SplitLegacyCombinedEnhancePrompt(raw)
if fixed, ok := aiprompts.NormalizeA1MetaRole(split, "sl"); ok {
split = fixed
}
return split, true, false
}
if aiprompts.CategoryEnhanceHasRoleSections(raw) && !aiprompts.CategoryEnhancePromptNeedsRepair(raw) {
return security.SanitizePrompt(raw, MaxCategoryPromptRunes), false, false
@@ -425,12 +429,24 @@ func computeRepairedEnhancePrompt(current company.LangPromptMap, seedLegacy stri
}
for _, lang := range []string{"sl", company.LangPromptAny} {
if cur := strings.TrimSpace(current[lang]); aiprompts.IsLegacyCombinedEnhancePrompt(cur) {
return aiprompts.SplitLegacyCombinedEnhancePrompt(cur), false, true, false
return func() string {
split := aiprompts.SplitLegacyCombinedEnhancePrompt(cur)
if fixed, ok := aiprompts.NormalizeA1MetaRole(split, "sl"); ok {
return fixed
}
return split
}(), false, true, false
}
}
for _, cur := range current {
if aiprompts.IsLegacyCombinedEnhancePrompt(cur) {
return aiprompts.SplitLegacyCombinedEnhancePrompt(cur), false, true, false
return func() string {
split := aiprompts.SplitLegacyCombinedEnhancePrompt(cur)
if fixed, ok := aiprompts.NormalizeA1MetaRole(split, "sl"); ok {
return fixed
}
return split
}(), false, true, false
}
}
if seedLegacy != "" {
@@ -160,6 +160,12 @@ func LoadWPCategoryPromptOverlaysFromBytes(raw []byte) (byNorm map[string]string
for _, e := range entries {
p := strings.TrimSpace(e.Prompt)
p, _ = aiprompts.NormalizeA1RepeatedBenefits(p)
if aiprompts.IsLegacyCombinedEnhancePrompt(p) {
p = aiprompts.SplitLegacyCombinedEnhancePrompt(p)
}
if canonical, updated := aiprompts.NormalizeA1MetaRole(p, "sl"); updated {
p = canonical
}
if p == "" {
continue
}
@@ -98,12 +98,11 @@ func TestParseWPProductCategoriesSQL_RealSeedFile(t *testing.T) {
if !ok {
t.Fatalf("Slušalke missing from %s (keys=%d)", path, len(byNorm))
}
split := aiprompts.SplitLegacyCombinedEnhancePrompt(raw)
if aiprompts.CategoryEnhancePromptNeedsRepair(split) {
t.Fatal("split of real dump Slušalke should not need repair")
if aiprompts.CategoryEnhancePromptNeedsRepair(raw) {
t.Fatal("normalized WP category prompt should not need repair")
}
if !strings.Contains(split, "tip izdelka lowercase") && !strings.Contains(split, "znamka") {
t.Fatalf("unexpected Title rules in split: %s", split[:min(400, len(split))])
if !strings.Contains(raw, "tip izdelka lowercase") && !strings.Contains(raw, "znamka") {
t.Fatalf("unexpected title rules in normalized prompt: %s", raw[:min(400, len(raw))])
}
if !strings.Contains(filepath.ToSlash(path), "scripts/seed/wp_product_categories.sql") &&
filepath.Base(path) != "wp_product_categories.sql" {