package aiprompts import "strings" // Prompt keys stored in ai_prompt_templates.prompt_key. const ( KeyProductEnhance = "product_enhance" KeySEOMeta = "seo_meta" KeyCampaignEmail = "campaign_email" ) // MaxSystemRunes / MaxUserRunes bound stored templates (prompt-injection surface). const ( MaxSystemRunes = 6000 MaxUserRunes = 4000 ) // Variable describes a placeholder tenants can insert into templates. type Variable struct { Name string `json:"name"` Label string `json:"label"` Description string `json:"description"` Keys []string `json:"keys"` // prompt_key values that support this variable } // Catalog of supported {{variables}} (only these are substituted; unknown tokens stay literal). var VariableCatalog = []Variable{ {Name: "name", Label: "Product name", Description: "Current product title", Keys: []string{KeyProductEnhance, KeySEOMeta}}, // description = product HTML body input (not SEO meta_description). Template key // stays "description" so stored tenant prompts keep working (renaming would be BREAKING). {Name: "description", Label: "Product description", Description: "Current product description (HTML body). Not SEO meta_description.", Keys: []string{KeyProductEnhance, KeySEOMeta}}, {Name: "category", Label: "Category", Description: "Resolved category name", Keys: []string{KeyProductEnhance, KeySEOMeta}}, {Name: "attrs", Label: "Attributes", Description: "Compact JSON of product attributes", Keys: []string{KeyProductEnhance}}, {Name: "gtin", Label: "GTIN", Description: "Product GTIN / barcode when present", Keys: []string{KeyProductEnhance}}, {Name: "brand", Label: "Brand name", Description: "Company or product brand label", Keys: []string{KeySEOMeta, KeyCampaignEmail}}, {Name: "brand_voice", Label: "Brand voice", Description: "Brand kit tone / dos / don'ts block", Keys: []string{KeyProductEnhance, KeySEOMeta, KeyCampaignEmail}}, {Name: "language", Label: "Content language", Description: "Company content language (English display name)", Keys: []string{KeyProductEnhance, KeySEOMeta, KeyCampaignEmail}}, {Name: "campaign_prompt", Label: "Campaign brief", Description: "Per-campaign user brief or template default", Keys: []string{KeyCampaignEmail}}, {Name: "products", Label: "Product list", Description: "Plain-text product snippets for the campaign", Keys: []string{KeyCampaignEmail}}, {Name: "template_key", Label: "Template key", Description: "Campaign template id (christmas, custom, …)", Keys: []string{KeyCampaignEmail}}, } // DefaultTemplate is the built-in prompt when the company has no custom row or disabled it. type DefaultTemplate struct { Key string `json:"key"` Label string `json:"label"` Description string `json:"description"` SystemTemplate string `json:"system_template"` UserTemplate string `json:"user_template"` } // CategoryEnhanceUserTemplate is the shared per-category (and built-in) enhance USER // message, sectioned by role (title / description / meta / attributes) using the // same "--- Section ---" markers as legacy enhance-product. Includes {{name}} // {{description}} {{attrs}} {{category}} {{language}}. Compatible with enhance // JSON {"name","description","meta_title","meta_description","attrs"} — // description is formula HTML product body; meta_* are plain SEO fields (legacy // A1 / cats.json metaTitle+metaDescription); attrs is the // category-allowlisted attribute map. Title/description/meta formulas stay in // title_template / description_template and are appended at render time (see // processing.AppendFormulaConstraints / AppendAttributeConstraints). Categorize // (unique_id) is RoleCategorize / ProductCategorize* — not this overlay. Used by // local A1/Demo prompt repair and seed-a1 overlays. const CategoryEnhanceUserTemplate = `Your reply is parsed as JSON {"name":"string","description":"string","meta_title":"string","meta_description":"string","attrs":{}} only (system schema). Write all string fields in {{language}} (do not hardcode a language). --- Title --- ` + TitleRoleInstruction + ` Name: {{name}} --- End Title --- --- Description --- Role: description. Build JSON "description": product body HTML only (not SEO meta). When a Description formula follows, emit ONE HTML string covering each section in order (tags matching type: h1/h2/h3/h4, p, ul); otherwise prefer 1-3 factual paragraphs as ONE string with limited HTML (