const HAIKU_KEYWORDS = [
    'search',
    'list',
    'find',
    'read',
    'scan',
    'check',
    'get',
    'show',
    'fetch',
    'query',
    'count',
    'detect',
];
const OPUS_KEYWORDS = [
    'architecture',
    'multi-system',
    'cross-module',
    'design',
    'strategy',
    'plan',
    'orchestrate',
    'refactor-cross',
];
const SONNET_KEYWORDS = [
    'write',
    'implement',
    'create',
    'build',
    'update',
    'delete',
    'migrate',
    'fix',
    'refactor',
    'generate',
    'add',
];
const TOKEN_BUDGET = {
    haiku: 50_000,
    sonnet: 100_000,
    opus: 200_000,
};
const COST_PER_TASK = {
    haiku: 0.002,
    sonnet: 0.01,
    opus: 0.1,
};
function detectModel(criterionText) {
    const lower = criterionText.toLowerCase();
    const firstWord = lower.split(/\s+/).at(0) ?? '';
    // Opus: architecture/design keywords anywhere in the text
    if (OPUS_KEYWORDS.some((k) => lower.includes(k))) {
        return { model: 'opus', rationale: 'Architecture or cross-system criterion → opus' };
    }
    // Haiku: read/search verbs at the start
    if (HAIKU_KEYWORDS.includes(firstWord) || HAIKU_KEYWORDS.some((k) => lower.startsWith(k))) {
        return { model: 'haiku', rationale: `Read/query verb "${firstWord}" → haiku` };
    }
    // Sonnet: write/implement verbs
    if (SONNET_KEYWORDS.some((k) => lower.startsWith(k) || lower.includes(` ${k} `))) {
        return { model: 'sonnet', rationale: `Write/implement verb → sonnet` };
    }
    return { model: 'sonnet', rationale: 'Default routing → sonnet' };
}
/**
 * SPEC-641: Route each criterion to haiku/sonnet/opus with token budget and cost.
 */
export function routeCriteria(criteriaLines) {
    return criteriaLines.map((text) => {
        const { model, rationale } = detectModel(text);
        return {
            text,
            recommendedModel: model,
            tokenBudget: TOKEN_BUDGET[model],
            estimatedCost: COST_PER_TASK[model],
            rationale,
        };
    });
}
//# sourceMappingURL=criterion-router.js.map