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:
2026-08-18 00:53:26 +02:00
co-authored by Claude Fable 5
parent 0eef202f56
commit 9a839d6d13
13 changed files with 182 additions and 157 deletions
+12 -7
View File
@@ -84,12 +84,12 @@ Category: {{category}}
Attrs: {{attrs}}`
// CategoryEnhancePromptNeedsRepair reports whether a stored categories.prompt value
// should be rewritten into role-sectioned enhance overlay form. Empty prompts are
// left alone. Canonical CategoryEnhanceUserTemplate and per-category overlays that
// already carry Title/Description/Meta markers are OK — equality with the shared
// template is not required (legacy splits keep Slovenian rules). Prompts still
// carrying a retired "--- Attributes ---" role section are rewritten so attribute
// prompting stays out of category prompts.
// should be rewritten into clean role-sectioned overlay form (or cleared). Empty
// prompts are left alone. A clean overlay carries Title/Description/Meta markers
// with ONLY the category's own instruction text — schema/role machine boilerplate
// (old seed versions stored the canonical template text, "Build JSON …" role
// instructions, and a retired "--- Attributes ---" section) marks a prompt for
// repair so the prompt editor shows exactly the per-category rules.
func CategoryEnhancePromptNeedsRepair(prompt string) bool {
p := strings.TrimSpace(prompt)
if p == "" {
@@ -101,7 +101,12 @@ func CategoryEnhancePromptNeedsRepair(prompt string) bool {
if !CategoryEnhanceHasRoleSections(p) {
return true
}
return strings.Contains(strings.ToLower(p), strings.ToLower(SectionAttributesStart))
lower := strings.ToLower(p)
if strings.Contains(lower, strings.ToLower(SectionAttributesStart)) {
return true
}
return strings.Contains(lower, "your reply is parsed as json") ||
strings.Contains(lower, `build json "`)
}
// BuiltInDefaults match the previous hardcoded system prompts, with structured user templates.