"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildCommentVariationPrompt = void 0;
const commentVariationPromptConfig_1 = require("./commentVariationPromptConfig");
/**
 * Builds a prompt for structured tool-use output: N visual variants with
 * implementation specs. When `fileExcerpts` are provided, their contents are
 * embedded inline so the model has full context without needing read tools.
 */
const buildCommentVariationPrompt = (instruction, element, variantCount, fileExcerpts) => {
    const promptConfig = (0, commentVariationPromptConfig_1.loadCommentVariationPromptConfig)();
    const filePaths = element.filePaths?.map((f) => f.filePath).slice(0, 3) ?? [];
    const tag = element.tagName.toLowerCase();
    const textSlice = element.textContent?.slice(0, 80) ?? '';
    const parentSummary = element.parentElementSummary
        ? `<${element.parentElementSummary.tagName}> id="${element.parentElementSummary.id || '(none)'}" class="${element.parentElementSummary.className || '(none)'}" text=${JSON.stringify(element.parentElementSummary.textSnippet || '')}`
        : '(none)';
    const siblingLines = element.siblingElements && element.siblingElements.length > 0
        ? element.siblingElements
            .map((sibling, index) => {
            return `  ${index + 1}. [${sibling.relativePosition}] <${sibling.tagName}> id="${sibling.id || '(none)'}" class="${sibling.className || '(none)'}" text=${JSON.stringify(sibling.textSnippet || '')}`;
        })
            .join('\n')
        : '  (none)';
    const candidateFilesBlock = fileExcerpts && fileExcerpts.length > 0
        ? fileExcerpts
            .map((excerpt) => `=== ${excerpt.path} ===\n${excerpt.content}\n=== end ${excerpt.path} ===`)
            .join('\n\n')
        : filePaths.length > 0
            ? filePaths.map((filePath) => `  - ${filePath}`).join('\n')
            : '  - unknown';
    return `${promptConfig.systemPrompt}

Reference context:
${promptConfig.combinedContext}

User request:
${instruction.trim()}

Element context:
- Tag: <${tag}>
- Text snippet: ${textSlice ? JSON.stringify(textSlice) : '(empty)'}
- XPath: ${element.xpath}
- Parent summary: ${parentSummary}
- Nearby siblings:
${siblingLines}

Candidate files:
${candidateFilesBlock}

Direction constraints:
- Variants should optimize for coherent UI outcomes, not selected-element-only tweaks.
- You may include coordinated nearby sibling/container changes when needed.
- \`changeSpec\` must be a 2-3 sentence agent implementation instruction describing exactly what code changes to make to achieve the direction. It should be specific about file locations, class names, and structural changes needed. For style-only changes it describes which CSS/Tailwind values to set; for structural changes it describes the HTML/JSX restructuring required.

Produce exactly ${variantCount} variants by calling the submit_variants tool.`;
};
exports.buildCommentVariationPrompt = buildCommentVariationPrompt;
//# sourceMappingURL=commentVariationPrompts.js.map