// engine/ai-integration/continue/ai-checks-generator.ts — .continue/prompts generator (SPEC-271)
import { writeFileSync, mkdirSync, existsSync } from 'node:fs';
import { join } from 'node:path';
const SPEC_CHECK_PROMPT_NAME = 'planu-spec-check';
const VALIDATE_PROMPT_NAME = 'planu-validate';
export function generateSpecCheckPrompt(options) {
    const specRef = options.activeSpecId
        ? `Active spec: **${options.activeSpecId}**`
        : 'No active spec set. Run `mcp__planu__list_specs` to find the current spec.';
    return [
        `---`,
        `name: ${SPEC_CHECK_PROMPT_NAME}`,
        `description: Verify implementation matches the active Planu spec`,
        `---`,
        ``,
        `# Planu Spec Check — ${options.projectName}`,
        ``,
        specRef,
        ``,
        `Review the current implementation and verify it meets all criteria defined in the active spec.`,
        ``,
        `## Checklist`,
        ``,
        `1. Fetch the spec details: \`mcp__planu__list_specs\``,
        `2. For each acceptance criterion, check if the implementation satisfies it`,
        `3. List any unmet criteria`,
        `4. If all criteria pass, suggest running \`mcp__planu__validate\``,
        ``,
        `Be specific: reference file paths and line numbers when identifying gaps.`,
    ].join('\n');
}
export function generateValidatePrompt(projectName) {
    return [
        `---`,
        `name: ${VALIDATE_PROMPT_NAME}`,
        `description: Trigger Planu validate workflow for the active spec`,
        `---`,
        ``,
        `# Planu Validate — ${projectName}`,
        ``,
        `Run the Planu validation workflow for the currently active spec.`,
        ``,
        `## Steps`,
        ``,
        `1. Run \`mcp__planu__validate\` with the active spec ID`,
        `2. Review all validation results`,
        `3. If validation fails, list what needs to be fixed`,
        `4. If validation passes, suggest \`mcp__planu__update_status\` to mark as done`,
    ].join('\n');
}
export function writeAiChecks(projectPath, options) {
    const promptsDir = join(projectPath, '.continue', 'prompts');
    /* v8 ignore start */
    if (!existsSync(promptsDir)) {
        mkdirSync(promptsDir, { recursive: true });
    }
    /* v8 ignore stop */
    const specCheckPath = join(promptsDir, `${SPEC_CHECK_PROMPT_NAME}.prompt.md`);
    writeFileSync(specCheckPath, generateSpecCheckPrompt(options), 'utf8');
    const validatePath = join(promptsDir, `${VALIDATE_PROMPT_NAME}.prompt.md`);
    writeFileSync(validatePath, generateValidatePrompt(options.projectName), 'utf8');
}
//# sourceMappingURL=ai-checks-generator.js.map