import { analyzeCallChain, analyzeCallers, analyzeCalls, analyzeDeps, analyzeModuleCoupling, analyzeTree, findByName, findByPattern, findByType, findContent, fusedSearch, summarizeModule, toMermaid, } from './query.js';
import { buildCodebaseIndex } from './build.js';
import { buildCodeContext } from './context.js';
import { chunkFromIndex, chunkFromIndexCooperative } from './chunk.js';
import { buildDirectoryTree } from './tree.js';
import { searchSymbols } from './search.js';
import { readCodeSource, } from './source.js';
import { hashCodeSymbols } from './hash.js';
import { readCodeDocs } from './doc.js';
import { listCodeSeams, resolveCodeSeams } from './seams.js';
import { queryCodeFacts } from './facts.js';
import { queryTreeSitter } from './structural.js';
import { queryCodePattern } from './rules.js';
import { clusterCodeModules } from './clusters.js';
import { traceCodeFlows } from './flows.js';
import { createYielder } from '../utils.js';
class InMemoryCodeQuerySession {
    buildOptions;
    index;
    constructor(buildOptions, index) {
        this.buildOptions = buildOptions;
        this.index = index;
    }
    getIndex() {
        return this.index;
    }
    async refresh(onProgress, signal) {
        this.index = await buildCodebaseIndex(this.buildOptions, onProgress, signal);
        return this.index;
    }
    searchSymbols(query, options) {
        return searchSymbols(this.index, query, options);
    }
    projectContext() {
        return buildCodeContext(this.index);
    }
    findByName(name, type, file, limit = 20) {
        return findByName(this.index, name, type, file, limit);
    }
    findByPattern(pattern, type, limit = 50) {
        return findByPattern(this.index, pattern, type, limit);
    }
    findByType(type, limit = 50) {
        return findByType(this.index, type, limit);
    }
    findContent(text, limit = 50) {
        return findContent(this.index, text, limit);
    }
    readSource(query, options) {
        return readCodeSource(this.index, query, options);
    }
    hashSymbols(queries, options) {
        return hashCodeSymbols(this.index, queries, options);
    }
    readDocs(queries, options) {
        return readCodeDocs(this.index, queries, options);
    }
    seams(options) {
        return listCodeSeams(this.index, options);
    }
    resolveSeams(seamKeys, options) {
        return resolveCodeSeams(this.index, seamKeys, options);
    }
    facts(predicate, options) {
        return queryCodeFacts(this.index, predicate, options);
    }
    tsquery(options) {
        return queryTreeSitter(this.index, options);
    }
    pattern(options) {
        return queryCodePattern(this.index, options);
    }
    clusters(options) {
        return clusterCodeModules(this.index, options);
    }
    flows(options) {
        return traceCodeFlows(this.index, options);
    }
    fusedSearch(query, options) {
        return fusedSearch(this.index, query, options);
    }
    analyzeCalls(functionName, file) {
        return analyzeCalls(this.index, functionName, file);
    }
    analyzeCallers(functionName, file) {
        return analyzeCallers(this.index, functionName, file);
    }
    analyzeCallChain(fromName, toName, depth = 5, fromFile, toFile) {
        return analyzeCallChain(this.index, fromName, toName, depth, fromFile, toFile);
    }
    analyzeDeps(target) {
        return analyzeDeps(this.index, target);
    }
    analyzeTree(className, file) {
        return analyzeTree(this.index, className, file);
    }
    analyzeModuleCoupling(modulePath) {
        return analyzeModuleCoupling(this.index, modulePath);
    }
    summarizeModule(modulePath, options) {
        return summarizeModule(this.index, modulePath, options);
    }
    toMermaid(kind, target, options) {
        return toMermaid(this.index, kind, target, options);
    }
    getDirectoryTree(options) {
        return buildDirectoryTree(this.index, options);
    }
    chunk(options) {
        return chunkFromIndex(this.index, options);
    }
    chunkCooperative(options, cooperative) {
        return chunkFromIndexCooperative(this.index, options, createYielder(cooperative ?? true));
    }
}
export async function createCodeQuerySession(options, onProgress, signal) {
    const index = await buildCodebaseIndex(options, onProgress, signal);
    return new InMemoryCodeQuerySession(options, index);
}
export function createCodeQuerySessionFromIndex(options, index) {
    return new InMemoryCodeQuerySession(options, index);
}
//# sourceMappingURL=session.js.map