/**
 * Analyse-scope policy — the single source of the "non-source noise" set the
 * structural prepass skips, so `spv ai analyse <messy-repo>` indexes signal,
 * not dumps/captures/binaries (the JobHunter-class problem: a 3 GB tree whose
 * real source is ~5 MB of `client/` `server/` `shared/`).
 *
 * Used in TWO places that must agree (hence one source, not two hand-lists —
 * the drift the canonical-serializer work just spent a wave eliminating):
 *   1. `walkSourceTree` (the FS walk behind every backend's `listFiles()`).
 *   2. a `.gitnexusignore` written into the analysed dir, so gitnexus's OWN
 *      index (a separate walk we don't control) skips the same noise.
 *
 * Conservative by design: only directories and extensions that are never a
 * codebase's logical source. Dotfiles/dot-dirs are already skipped by the
 * walker, so this list is the non-dot set.
 */
/** Directory names never treated as source (build output, captured assets, dumps). */
export const ANALYSE_IGNORE_DIRS = [
    // build / dependency output
    'node_modules', '.git', '.svn', '.hg', '.gitnexus', '.codegraph',
    'dist', 'build', 'out', 'target', '__pycache__', 'coverage', '.next', '.nuxt',
    // captured assets / debug artifacts (JobHunter-class repos)
    'screenshots', 'attached_assets', 'artifacts', 'ux_shots',
];
/** File extensions never treated as source (binaries, dumps, captures, media, archives). */
export const ANALYSE_IGNORE_EXTS = [
    '.dmp', '.bin', '.meta', '.fingerprint', '.log', '.map',
    '.png', '.jpg', '.jpeg', '.gif', '.svg', '.ico', '.webp', '.pdf',
    '.zip', '.tar', '.gz', '.tgz', '.7z',
    '.sqlite', '.db',
];
/** True if a directory entry name is in the always-skip set. */
export function isIgnoredDir(name) {
    return ANALYSE_IGNORE_DIRS.includes(name);
}
/** True if a file name carries a never-source extension. */
export function hasIgnoredExt(name) {
    const dot = name.lastIndexOf('.');
    if (dot <= 0)
        return false;
    return ANALYSE_IGNORE_EXTS.includes(name.slice(dot).toLowerCase());
}
/**
 * Root-level config files always pulled in under `--scope` (alongside the
 * named subtrees): the framework / ORM signals the prepass keys on
 * (`package.json`, `tsconfig*.json`, `*.config.*`, `drizzle.config.*`,
 * `schema.prisma`, `components.json`). Without these, a `--scope server,shared`
 * run would lose the root manifest that drives framework detection.
 */
const ANALYSE_CONFIG_FILE_RE = /^(?:package\.json|tsconfig[\w.-]*\.json|[\w.-]+\.config\.(?:ts|js|mjs|cjs|json)|[\w.-]*\.prisma|components\.json)$/;
/** True if a root-level file name is an always-include analyse config file. */
export function isAnalyseConfigFile(name) {
    return ANALYSE_CONFIG_FILE_RE.test(name);
}
/**
 * Render `.gitnexusignore` content (gitignore-style) so gitnexus's index skips
 * the same noise the walker does. Written into the analysed dir before
 * `gitnexus analyze` runs. `scope` (P1.2) restricts to named top-level subtrees
 * via ignore-all-then-re-include.
 */
export function renderGitnexusignore(opts = {}) {
    const lines = ['# Auto-generated by SpecVerse analyse — skip non-source noise.'];
    const scope = (opts.scope ?? []).map((s) => s.replace(/^[./]+|\/+$/g, '')).filter(Boolean);
    if (scope.length > 0) {
        // Ignore everything, then re-include only the scoped subtrees (dir + contents).
        lines.push('/*');
        for (const s of scope) {
            lines.push('!/' + s + '/');
            lines.push('!/' + s + '/**');
        }
    }
    for (const d of ANALYSE_IGNORE_DIRS)
        lines.push(d + '/');
    for (const e of ANALYSE_IGNORE_EXTS)
        lines.push('*' + e);
    return lines.join('\n') + '\n';
}
//# sourceMappingURL=scope.js.map