/**
 * WikiQueryService — read a vault and build the `system-context` payload
 * that the caller's runtime feeds to its LLM for synthesis.
 *
 * Per v2.1 spec §3 the skill is split into two halves:
 *   - System-context (LLM-agnostic) → what this service produces
 *   - Task-instruction (per-LLM)    → lives on disk under
 *     `config/skills/<role>/wiki-<verb>/prompts/<runtime>.md` and is
 *     concatenated by the caller's runtime, NOT by us.
 *
 * Phase 1 scope (this file): single-vault read. Cross-vault synthesis is
 * Phase 2 work (`wiki-recall-cross-scope` reducer, §1 amended v2.1).
 *
 * @module services/wiki/wiki-query.service
 */
import { SchemaLoaderService } from './schema-loader.service.js';
import { VaultSchema } from './wiki.types.js';
export interface WikiQueryInput {
    /** Absolute path to the vault root. */
    vaultPath: string;
    /** Natural-language query. Used for naive keyword ranking. */
    query: string;
    /** How many candidate pages to return (default 5). */
    topK?: number;
    /** How many tail log.md entries to include (default 20). */
    recentLogEntries?: number;
}
export interface WikiLogEntry {
    timestamp: string;
    sourceType: string;
    caller: string;
    ref: string;
    body: string;
}
export interface WikiCandidatePage {
    /** Path relative to vault root. */
    path: string;
    /** First ~MAX_PAGE_BYTES bytes of the file (UTF-8). */
    excerpt: string;
    /** Simple keyword overlap score; higher = more relevant. */
    score: number;
}
export interface WikiQuerySystemContext {
    vault: {
        scope: VaultSchema['vault_scope'];
        id: string;
        path: string;
    };
    schemaSummary: {
        hardcoded: Array<{
            path: string;
            description: string;
        }>;
        llmCurated: Array<{
            path: string;
            seedSubdirs: string[];
        }>;
        frozenPaths: string[];
        writePolicy: VaultSchema['write_policy'];
    };
    query: string;
    recentLog: WikiLogEntry[];
    candidatePages: WikiCandidatePage[];
    /** Synthesis instructions the caller's LLM should honor. */
    callerNotes: string[];
}
export interface WikiQueryFailure {
    ok: false;
    reason: 'invalid_input' | 'schema_missing' | 'vault_missing';
    message: string;
}
export type WikiQueryResult = {
    ok: true;
    context: WikiQuerySystemContext;
} | WikiQueryFailure;
/**
 * Reads a vault and builds the system-context payload the caller's LLM
 * synthesizes against. Stateless. No LLM calls inside this service.
 */
export declare class WikiQueryService {
    private static instance;
    private readonly logger;
    private readonly schemaLoader;
    constructor(schemaLoader?: SchemaLoaderService);
    static getInstance(): WikiQueryService;
    /** Test-only reset. */
    static _resetForTesting(): void;
    /**
     * Build a system-context payload for `query` against the vault at
     * `vaultPath`. Caller's LLM consumes this + its task-instruction prompt.
     */
    query(input: WikiQueryInput): Promise<WikiQueryResult>;
    private validate;
    /**
     * Parse the last N entries from `llm-curated/log.md`. Entries follow the
     * format written by `WikiIngestService.formatLogEntry`:
     *
     *   ## [<ISO>] <sourceType> | <caller>
     *
     *   ref: <ref>
     *
     *   <body lines>
     */
    private readRecentLog;
    /**
     * Gather the vault's NON-frozen (`llm-curated/`) `.md` pages and rank them by
     * Okapi BM25 against the query, reusing {@link WikiSearchService.searchCorpus}
     * so the agent-facing `wiki-query` skill scores identically to the wiki UI
     * search. IDF is computed over exactly the gathered pages, preserving this
     * skill's scope: only curated pages are eligible, and `llm-curated/log.md`
     * is excluded (it is surfaced separately as `recentLog`).
     */
    private findCandidatePages;
    /**
     * Collect candidate `.md` pages under the schema's `llm-curated/` roots,
     * skipping dotfile/`node_modules` dirs and `llm-curated/log.md`.
     *
     * @param vaultPath - Absolute vault root.
     * @param schema - Loaded vault schema (defines the curated roots).
     * @returns Page refs as `{ relativePath (POSIX), absPath }`.
     */
    private gatherCuratedPages;
    private readExcerpt;
}
//# sourceMappingURL=wiki-query.service.d.ts.map