2026-08-16 23:42:00 +02:00
|
|
|
package aiprompts
|
|
|
|
|
|
|
|
|
|
import "strings"
|
|
|
|
|
|
|
|
|
|
// Pipeline prompt roles mirror legacy Descrybe steps (categorize → title →
|
|
|
|
|
// description[+meta] → attributes). Categorize stays a separate Completer call
|
|
|
|
|
// (ProductCategorize*). category.prompt (CategoryEnhanceUserTemplate) is the
|
|
|
|
|
// shared enhance USER overlay, sectioned for title/description/meta/attrs so
|
|
|
|
|
// seed/repair and title/meta/attrs formula work (AppendFormulaConstraints) share
|
|
|
|
|
// one skeleton. Enhance JSON includes meta_* (legacy bundled meta); KeySEOMeta
|
|
|
|
|
// remains the standalone SEO path.
|
|
|
|
|
const (
|
|
|
|
|
RoleCategorize = "categorize" // pick taxonomy unique_id (processing.ProductCategorize*)
|
|
|
|
|
RoleTitle = "title" // JSON name / title formula
|
|
|
|
|
RoleDescription = "description" // JSON description / description formula
|
|
|
|
|
RoleMeta = "meta" // JSON meta_* in enhance + KeySEOMeta standalone
|
|
|
|
|
RoleAttributes = "attributes" // JSON attrs object + allowlist/formula key guidance
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Section markers match legacy enhance-product "--- Section ---" / "--- Meta Title ---"
|
|
|
|
|
// style so stored category prompts stay human-readable and machine-detectable.
|
2026-08-18 00:13:44 +02:00
|
|
|
// Attributes markers are retired for category prompts (attribute extraction is
|
|
|
|
|
// pipeline-level, not prompt-authored) but kept so repair can detect and strip
|
|
|
|
|
// old stored prompts that still carry the section.
|
2026-08-16 23:42:00 +02:00
|
|
|
const (
|
|
|
|
|
SectionTitleStart = "--- Title ---"
|
|
|
|
|
SectionTitleEnd = "--- End Title ---"
|
|
|
|
|
SectionDescriptionStart = "--- Description ---"
|
|
|
|
|
SectionDescriptionEnd = "--- End Description ---"
|
|
|
|
|
SectionMetaStart = "--- Meta ---"
|
|
|
|
|
SectionMetaEnd = "--- End Meta ---"
|
|
|
|
|
SectionAttributesStart = "--- Attributes ---"
|
|
|
|
|
SectionAttributesEnd = "--- End Attributes ---"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// CategoryPromptRoles lists the role ids used across categorize + enhance + SEO.
|
|
|
|
|
var CategoryPromptRoles = []string{
|
|
|
|
|
RoleCategorize,
|
|
|
|
|
RoleTitle,
|
|
|
|
|
RoleDescription,
|
|
|
|
|
RoleMeta,
|
|
|
|
|
RoleAttributes,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CategoryEnhanceHasRoleSections reports whether a stored categories.prompt
|
2026-08-18 00:13:44 +02:00
|
|
|
// value uses the structured title/description/meta section markers from
|
|
|
|
|
// CategoryEnhanceUserTemplate (seed/repair canonical shape). Attributes is not
|
|
|
|
|
// required — category prompts no longer carry an attributes role section.
|
2026-08-16 23:42:00 +02:00
|
|
|
func CategoryEnhanceHasRoleSections(prompt string) bool {
|
|
|
|
|
lower := strings.ToLower(prompt)
|
|
|
|
|
return strings.Contains(lower, strings.ToLower(SectionTitleStart)) &&
|
|
|
|
|
strings.Contains(lower, strings.ToLower(SectionDescriptionStart)) &&
|
2026-08-18 00:13:44 +02:00
|
|
|
strings.Contains(lower, strings.ToLower(SectionMetaStart))
|
2026-08-16 23:42:00 +02:00
|
|
|
}
|