33 lines
1.8 KiB
Markdown
33 lines
1.8 KiB
Markdown
# A1 prompt cleanup repair
|
||||
|
|
|
|||
|
|
## Root causes
|
|||
|
|
|
|||
|
|
- `NormalizeA1DescriptionTemplate` attempted to `json.Unmarshal("")` before verifying that the optional `description_template` existed. This produced `unexpected end of JSON input` for A1 categories with empty templates.
|
|||
|
|
- The previous A1-recognition threshold required at least four H2/paragraph pairs. The original A1 seed frequently had only one to three, and partially cleaned prompts mixed old instructions with a rewritten third benefit.
|
|||
|
|
- The original generic spec-list instruction sometimes used a Unicode en dash (`3–10`) and had line breaks, causing it to survive beside a new spec list.
|
|||
|
|
- One imported template generated an extra H1, although the product page already supplies its H1.
|
|||
|
|
|
|||
|
|
## Fix
|
|||
|
|
|
|||
|
|
- Short-circuit null/empty JSON descriptions, including JSON objects without `sections`.
|
|||
|
|
- Recognize the known legacy Slovenian 100-word benefit boilerplate regardless of pair count, but don't rewrite unrelated custom descriptions.
|
|||
|
|
- Replace recognized obsolete description blocks with a semantically ordered `<p>`, optional `<h2><p>` and optional `<h2><ul><li>`.
|
|||
|
|
- Drop only the known imported generic technical-specification stub. Leave custom spec instructions intact.
|
|||
|
|
- Preserve category-specific title and meta rules.
|
|||
|
|
- Use identical normalization from the seed, standalone cleanup, bundled A1 data, and WordPress import path.
|
|||
|
|
- Changes are safe to rerun.
|
|||
|
|
|
|||
|
|
## Commands
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
# Read-only preview (A1 only)
|
|||
|
|
npm run cleanup:a1:prompts
|
|||
|
|
|
|||
|
|
# Apply A1-only cleanup
|
|||
|
|
npm run cleanup:a1:prompts -- -apply
|
|||
|
|
|
|||
|
|
# Alternative: apply global offline defaults and A1 cleanup together
|
|||
|
|
npm run seed:category-prompts:i18n
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
No OpenAI key or external translation call required. Back up PostgreSQL before applying production changes. Reprocess existing product descriptions separately if updated output is needed.
|