// engine/provider-adapters/adapters/claude.ts — SPEC-670: Claude Code renderer.
//
// Emits MCP-shaped output: full canonical markdown plus model hint, budget hint and
// `mcp__planu__*` tool callouts. Tag-driven enrichment is a follow-up; for v1 we use
// a static map of spec-tag → recommended Planu MCP tools.
import { estimateTokens } from '../shared/token-estimator.js';
/**
 * Static map of spec tag → recommended `mcp__planu__*` tool callouts. A tag-driven
 * enrichment follow-up (SPEC-67x) will let users extend this through configuration.
 */
export const CLAUDE_TOOL_CALLOUT_MAP = Object.freeze({
    spec: ['mcp__planu__update_status', 'mcp__planu__validate', 'mcp__planu__check_readiness'],
    bdd: ['mcp__planu__check_readiness', 'mcp__planu__rewrite_criteria_ears'],
    rendering: ['mcp__planu__sync_ai_configs'],
    engine: ['mcp__planu__implement_plan', 'mcp__planu__validate'],
    'cross-llm': ['mcp__planu__sync_ai_configs', 'mcp__planu__discover_skills_from_registries'],
    'lean-mode': ['mcp__planu__create_spec', 'mcp__planu__update_status'],
    'provider-adapter': ['mcp__planu__sync_ai_configs'],
    default: ['mcp__planu__update_status', 'mcp__planu__validate'],
});
export class ClaudeRenderer {
    kind = 'claude';
    render(input) {
        const { loadedSpec } = input;
        const { spec, specBody, warnings } = loadedSpec;
        const modelHint = spec.model ?? 'sonnet';
        const budget = spec.budget ?? 2000;
        const toolCallouts = pickToolCallouts(spec.tags);
        const lines = [];
        lines.push(`# ${spec.title}`);
        lines.push('');
        lines.push(`> Model hint: \`${modelHint}\` — Token budget: \`${budget}\``);
        lines.push('');
        lines.push('## Recommended Planu MCP tools');
        for (const callout of toolCallouts) {
            lines.push(`- Run \`${callout}\` to drive this spec forward.`);
        }
        lines.push('');
        if (specBody.trim().length === 0) {
            lines.push(`_(spec body is empty — author has not yet filled in problem/criteria)_`);
        }
        else {
            lines.push(specBody.trim());
        }
        const content = lines.join('\n');
        const tokenEstimate = estimateTokens(content);
        return Promise.resolve({
            provider: 'claude',
            content,
            tokenEstimate,
            extras: {
                modelHint,
                model: modelHint,
                budget,
                toolCallouts: [...toolCallouts],
                ...(warnings.length > 0 ? { warnings } : {}),
            },
        });
    }
}
function pickToolCallouts(tags) {
    const collected = new Set();
    for (const tag of tags) {
        const list = CLAUDE_TOOL_CALLOUT_MAP[tag];
        if (list) {
            for (const t of list) {
                collected.add(t);
            }
        }
    }
    if (collected.size === 0) {
        for (const t of CLAUDE_TOOL_CALLOUT_MAP.default ?? []) {
            collected.add(t);
        }
    }
    return [...collected];
}
//# sourceMappingURL=claude.js.map