// src/engine/code-scanner/keyword-extractor.ts — Extracts searchable identifiers from spec metadata (SPEC-441)
// Common words to strip from spec titles
const STOP_WORDS = new Set([
    'a',
    'an',
    'the',
    'and',
    'or',
    'for',
    'of',
    'in',
    'on',
    'to',
    'with',
    'from',
    'by',
    'as',
    'at',
    'into',
    'via',
    'per',
    'vs',
    'de',
    'la',
    'el',
    'con',
    'para',
    'por',
    'un',
    'una',
    'los',
    'las',
    'del',
    'add',
    'new',
    'create',
    'update',
    'fix',
    'remove',
    'implement',
    'spec',
    'feature',
    'tool',
    'handler',
    'service',
    'support',
    'based',
]);
/**
 * Extracts keywords from a spec title + description.
 * Returns deduplicated lowercase tokens suitable for file/symbol search.
 */
export function extractKeywords(title, description) {
    const text = [title, description ?? ''].join(' ');
    const tokens = tokenize(text);
    const filtered = tokens.filter((t) => t.length >= 3 && !STOP_WORDS.has(t));
    return [...new Set(filtered)];
}
/**
 * Convert keywords to camelCase and PascalCase variants for symbol search.
 * e.g. ['oauth', 'flow'] → ['oauthFlow', 'OauthFlow', 'oauth', 'flow']
 */
export function toSymbolVariants(keywords) {
    const variants = [...keywords];
    if (keywords.length >= 2) {
        // camelCase: first word lower, rest title-case
        const camel = (keywords[0] ?? '') + keywords.slice(1).map(capitalize).join('');
        // PascalCase: all title-case
        const pascal = keywords.map(capitalize).join('');
        variants.push(camel, pascal);
    }
    // Also add title-case of each word
    for (const kw of keywords) {
        variants.push(capitalize(kw));
    }
    return [...new Set(variants)];
}
function tokenize(text) {
    // Split on spaces, dashes, underscores, slashes, parens, numbers
    return text
        .toLowerCase()
        .split(/[\s\-_/()[\]{},.:;!?'"<>@#$%^&*+=|\\~`]+/)
        .filter(Boolean);
}
function capitalize(s) {
    return s.charAt(0).toUpperCase() + s.slice(1);
}
//# sourceMappingURL=keyword-extractor.js.map