Store category prompts as EXACT split legacy text, no boilerplate
The per-category prompt editor showed English machine boilerplate
("Role: description. Build JSON …", schema intro, {{var}} context lines)
because seed/sync baked the render framing into categories.prompt. Now the
stored overlay is exactly the legacy wp_product_categories.sql content,
split into the three sections a user would type themselves:
--- Title --- Slovenian naming formula
--- Description --- legacy <H2>/<p>/<ul> body structure
--- Meta --- legacy metaDescription instruction
Schema, role framing, and Name/Description/Category/Attrs product context
stay render-time only (system template + ensureCategoryEnhanceUserContext),
where they already existed.
- SplitLegacyCombinedEnhancePrompt: non-legacy input now returns "" —
categories without seed/legacy content get their override CLEARED
(company default) instead of being stuffed with the canonical template
(e.g. parent categories like "Bela tehnika" absent from the SQL).
- CategoryEnhancePromptNeedsRepair flags stored boilerplate ("parsed as
JSON", "Build JSON", retired Attributes section) so Sync rewrites old
data to the clean shape; repair supports clearing (prompt = '{}').
- seed-a1 apply-category-prompts skips instead of writing template text.
- Web editor compose stores only the user's section text: empty sections
keep bare markers, default bodies and the default preamble are never
persisted (DEFAULT_SECTION_BODIES removed).
- Verified locally: apply rewrote 238 A1+Demo categories (216 exact
splits, 22 cleared), zero boilerplate matches in DB, idempotent re-run
(would_update=0).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -44,19 +44,25 @@ GPT predloga:
|
||||
if !strings.Contains(got, "Tehnične specifikacije") && !strings.Contains(got, "tehničnih specifikacij") {
|
||||
t.Fatal("description section must preserve HTML body intent")
|
||||
}
|
||||
if !strings.Contains(got, "{{attrs}}") || !strings.Contains(got, "{{language}}") {
|
||||
t.Fatal("overlay must keep {{attrs}} and {{language}}")
|
||||
// The stored overlay is EXACTLY the split legacy text — no schema/role
|
||||
// boilerplate, no {{var}} placeholders (product context is render-time).
|
||||
lower := strings.ToLower(got)
|
||||
for _, junk := range []string{"your reply is parsed as json", "role: title", "role: description", "role: meta", "{{attrs}}", "{{name}}", "{{language}}", "product context"} {
|
||||
if strings.Contains(lower, junk) {
|
||||
t.Fatalf("overlay must not carry boilerplate %q:\n%s", junk, got)
|
||||
}
|
||||
}
|
||||
if strings.Contains(got, "OPIS IZDELKA") || strings.Contains(got, "STARO IME IZDELKA") {
|
||||
t.Fatal("legacy placeholders must be modernized")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSplitLegacyNonLegacyFallsBackToTemplate(t *testing.T) {
|
||||
func TestSplitLegacyNonLegacyReturnsEmpty(t *testing.T) {
|
||||
t.Parallel()
|
||||
got := SplitLegacyCombinedEnhancePrompt("short retail overlay")
|
||||
if strings.TrimSpace(got) != strings.TrimSpace(CategoryEnhanceUserTemplate) {
|
||||
t.Fatalf("non-legacy should fall back to canonical template")
|
||||
// Non-legacy input has no per-category content to preserve — callers must
|
||||
// leave the category on the company default instead of storing boilerplate.
|
||||
if got := SplitLegacyCombinedEnhancePrompt("short retail overlay"); got != "" {
|
||||
t.Fatalf("non-legacy should return empty, got %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user