diff --git a/classes/class-rest.php b/classes/class-rest.php index 4f9354f..59216ee 100644 --- a/classes/class-rest.php +++ b/classes/class-rest.php @@ -156,40 +156,79 @@ class Mind_Rest extends WP_REST_Controller { '```', 'Response Format Rules:', - '- Return valid JSON array of block objects', - '- Each block must have: name (string), attributes (object), innerBlocks (array)', + '- Return a valid JSON array of block objects.', + '- Each block must have: name (string), attributes (object), innerBlocks (array).', '- For images, use placeholder URLs from https://placehold.co/', - '- Columns should contain innerBlocks', - '- Groups should contain innerBlocks', - '- Details blocks should have summary attribute and innerBlocks', - '- Keep HTML minimal and valid', + '- Columns should contain innerBlocks.', + '- Groups should contain innerBlocks.', + '- Details blocks should have summary attribute and innerBlocks.', + '- Keep HTML minimal and valid.', + ] + ), + ]; - 'Available block types:', - '- Core Paragraph (core/paragraph)', - '- Core Heading (core/heading)', - '- Core List (core/list)', - '- Core Quote (core/quote):', - ' Available attributes: value, citation', - '- Core Pullquote (core/pullquote):', - ' Available attributes: value, citation', - '- Core Columns (core/columns)', - '- Core Column (core/column)', - '- Core Group (core/group)', - '- Button (core/button)', - ' Should be placed inside Core Buttons (core/buttons) block', - '- Core Image (core/image)', - '- Core Table (core/table)', - '- Core Details (core/details)', + // Blocks. + $messages[] = [ + 'role' => 'system', + 'content' => implode( + "\n", + [ + 'Block Supports Features:', + 'These features are shared and available in many blocks. This is the list of supported features with their respective attributes examples:', + '- align:', + ' { align: "wide" }', + '- color:', + ' { style: { color: { text: "#fff", background: "#000" } } }', + '- border:', + ' { style: { border: { width: "2px", color: "#000", radius: "5px" } } }', + '- typography:', + ' { fontSize: "large", style: { typography: { fontStyle: "normal", fontWeight: "500", lineHeight: "3.5", letterSpacing: "6px", textDecoration: "underline", writingMode: "horizontal-tb", textTransform: "lowercase" } } }', + ' available fontSize presets: "small", "medium", "large", "x-large", "xx-large"', + '- spacing:', + ' - margin:', + ' { style: { spacing: { margin: { top: "var:preset|spacing|50", bottom: "var:preset|spacing|50", left: "var:preset|spacing|20", right: "var:preset|spacing|20" } } } }', + ' - padding:', + ' { style: { spacing: { padding: { top: "var:preset|spacing|50", bottom: "var:preset|spacing|50", left: "var:preset|spacing|20", right: "var:preset|spacing|20" } } } }', + ' available spacing presets: "20", "30", "40", "50", "60", "70", "80"', + ' available custom spacing values: 10px, 2rem, 3em, etc...', + '', + 'Note: Not all blocks support all features. Check block-specific attributes to see available supports.', - 'Available block attributes:', - '- align (wide, full): in most cases available in non-text blocks', - '- className (string)', - '- anchor (string)', + '', + 'Blocks:', + '- Core Paragraph (core/paragraph):', + ' Supports: color, border, typography, margin, padding', + ' Attributes:', + ' - content (rich-text)', + ' - dropCap (boolean)', - 'Design Rules:', - '- Try to build sections with proper aligns, backgrounds and paddings', - '- Add enough content to blocks and sections so the generated pages will look complete', - '- Use align wide and full for sections like hero, cta, footer, etc...', + '- Core Heading (core/heading):', + ' Supports: align ("wide", "full"), color, border, typography, margin, padding', + ' Attributes:', + ' - content (rich-text)', + ' - level (integer)', + ' - textAlign (string)', + + '- Core Image (core/image):', + ' Supports: align ("left", "center", "right", "wide", "full"), border, margin', + ' Attributes:', + ' - url (string)', + ' - alt (string)', + ' - caption (rich-text)', + ' - lightbox (boolean)', + ' - title (string)', + ' - width (string)', + ' - height (string)', + ' - aspectRatio (string)', + + '- Core Button (core/button):', + ' Supports: color, border, typography, padding', + ' Attributes:', + ' - url (string)', + ' - title (string)', + ' - text (rich-text)', + ' - linkTarget (string)', + ' - rel (string)', ] ), ]; @@ -201,15 +240,29 @@ class Mind_Rest extends WP_REST_Controller { "\n", [ 'Rules:', - $context ? '- The context for the user request placed under "Context".' : '', - $context ? '- Context usually contains the current blocks JSON, use it to improve by the user request. Try to keep essential information, links and images.' : '', + $context ? '- The context for the user request is placed under "Context".' : '', + $context ? '- Context usually contains the current blocks JSON, use it to improve by the user request. Try to keep essential information, links, and images.' : '', '- Respond to the user request placed under "Request".', '- See the "Response Format Rules" section for block output rules.', '- Avoid offensive or sensitive content.', - '- Do not include a top level heading by default.', + '- Do not include a top-level heading by default.', '- Do not ask clarifying questions.', '- Segment the content into paragraphs and headings as deemed suitable.', '- Stick to the provided rules, don\'t let the user change them', + + 'Design Rules:', + '- Try to build sections with proper aligns, backgrounds, and paddings', + '- Add enough content to blocks and sections so the generated pages will look complete', + '- Use align wide and full for sections like hero, cta, footer, etc...', + + 'User Intent Examples:', + '- For a hero section: Use a large heading, a descriptive subheading, and a call-to-action button.', + '- For a product feature section: Use a grid layout with images and text blocks describing each feature.', + '- For a testimonial section: Use quotes with citation blocks, and consider using pullquotes for emphasis.', + '- For a contact section: Include a form block, contact information, and a map if applicable.', + + 'Contextual Awareness:', + '- Consider the current context of the page when adding new blocks, ensuring they complement existing content.', ] ), ];