import { type BM25Index } from "../search/bm25.js";
import { loadConfig } from "../config.js";
import type { CodeSymbol, CodeIndex, RepoMeta } from "../types.js";
/** Test-only — clear short-circuit state between cases. */
export declare function resetIndexFolderRedundancyForTesting(): void;
/**
 * Embed symbols using the configured embedding provider.
 * Non-fatal — BM25 search still works if embedding fails.
 */
export declare function embedSymbols(symbols: CodeSymbol[], indexPath: string, repoName: string, config: ReturnType<typeof loadConfig>): Promise<void>;
export interface IndexFolderResult {
    repo: string;
    root: string;
    file_count: number;
    symbol_count: number;
    duration_ms: number;
    /** Set when the call short-circuited because a watcher is keeping the index live. */
    status?: "skipped";
    reason?: string;
    last_indexed?: string;
    hint?: string;
}
export declare function indexFolder(folderPath: string, options?: {
    incremental?: boolean | undefined;
    include_paths?: string[] | undefined;
    watch?: boolean | undefined;
    /**
     * Cap on files indexed in a single pass. When the walker hits this, it
     * returns partial results with a warning rather than blowing through
     * memory. Default: DEFAULT_MAX_FILES (or CODESIFT_MAX_FILES env var).
     */
    max_files?: number | undefined;
    /**
     * Bypass the watcher-active short-circuit (see lastFullIndexAt). Used by
     * indexRepo for fresh clones where defensive reindex is correct.
     */
    force?: boolean | undefined;
}): Promise<IndexFolderResult>;
/**
 * Clone a remote git repository and index it.
 * Clones into ~/.codesift/repos/{name}. If already cloned, pulls latest.
 */
export declare function indexRepo(url: string, options?: {
    branch?: string | undefined;
    include_paths?: string[] | undefined;
}): Promise<IndexFolderResult>;
export interface RepoSummary {
    name: string;
    file_count: number;
    symbol_count: number;
}
export declare function listAllRepos(options?: {
    compact?: boolean;
    name_contains?: string;
}): Promise<RepoMeta[] | RepoSummary[] | string[]>;
export declare function invalidateCache(repoName: string): Promise<boolean>;
/** Test hook — clear the in-process last-indexed state. */
export declare function clearLastIndexedStateForTesting(): void;
/**
 * Re-index a single file instantly. Finds the repo by matching the file
 * path against indexed repo roots. Updates symbols, BM25 index, and
 * invalidates embedding cache — no full repo walk needed.
 */
export declare function indexFile(filePath: string): Promise<{
    repo: string;
    file: string;
    symbol_count: number;
    duration_ms: number;
    skipped?: boolean;
    secrets_warning?: string;
}>;
/**
 * Ensure the index for a repo is fresh relative to git HEAD.
 * Throttled to once per minute per repo. Reindexes changed files if HEAD moved.
 * No-op for non-git repos.
 */
export declare function ensureIndexFresh(repoName: string): Promise<{
    status: "fresh" | "refreshed" | "skipped";
    files_updated?: number;
}>;
/** Reset freshness throttle cache. Exported for testing. */
export declare function resetFreshnessCache(): void;
/** Stop every active watcher and clear the in-memory index caches. Exported
 *  for testing — afterAll teardown of integration tests that index temp dirs
 *  must call this before `rm -rf`-ing the temp dir, otherwise the chokidar
 *  watcher races the rm and emits ENOTEMPTY/ENOENT noise that shows up as
 *  file-level test failures even when every test inside passed. */
export declare function stopAllWatchersForTesting(): Promise<void>;
/**
 * Get the in-memory BM25 index for a repo.
 * Loads from disk if not cached. Auto-refreshes if git HEAD moved.
 */
export declare function getBM25Index(repoName: string): Promise<BM25Index | null>;
/**
 * Get the code index for a repo from disk.
 * Starts watcher if not running (lazy start after server restart).
 */
/**
 * Get the code index for a repo from disk. Auto-refreshes if git HEAD moved.
 */
export declare function getCodeIndex(repoName: string, options?: {
    skipFreshness?: boolean;
}): Promise<CodeIndex | null>;
/**
 * Called at server startup. If the CWD is inside a git repo that isn't indexed yet,
 * index it automatically in the background so tools work without manual setup.
 */
export declare function autoIndexCurrentRepo(cwd: string): Promise<void>;
/**
 * Get the in-memory embedding cache for a repo.
 * Loads from disk if not cached. Returns null if no embeddings file exists.
 */
export declare function getEmbeddingCache(repoName: string): Promise<Map<string, Float32Array> | null>;
export declare const ASTRO_LOCK_FILENAME = "astro-reindex.lock";
export declare const EXTRACTOR_VERSIONS_FILENAME = "extractor-versions.json";
export interface AstroReindexResult {
    reindexed: boolean;
    files_reindexed?: number;
    reason: string;
}
/**
 * Check if the stored astro extractor version matches the current one.
 * If not, re-extract all .astro files with lockfile protection.
 *
 * @param dataDir   The data directory (e.g., ~/.codesift or a test tmpdir)
 * @param repoRoot  The repo root path (for locating .astro files)
 * @param astroFiles  Relative paths to .astro files in the repo
 */
export declare function checkAstroExtractorVersion(dataDir: string, repoRoot: string, astroFiles: string[]): Promise<AstroReindexResult>;
//# sourceMappingURL=index-tools.d.ts.map