import { getProposalTypePlugin, type ProposalTypePlugin } from "./proposal-types.js";
export type ProposalType = "goal" | "project" | "role" | "tool" | "staff";
export interface TypedProposal {
    type: ProposalType;
    fields: Record<string, unknown>;
}
export type ParseErrorCode = "FILE_NOT_FOUND" | "FRONTMATTER_MALFORMED" | "YAML_PARSE_ERROR" | "MISSING_REQUIRED_FIELD" | "STRUCTURAL_VALIDATION_FAILED";
export interface ParseError {
    ok: false;
    code: ParseErrorCode;
    message: string;
    line?: number;
    col?: number;
    field?: string;
}
export type ParseResult = {
    ok: true;
    value: TypedProposal;
} | ParseError;
export type EditErrorCode = "OLD_TEXT_NOT_FOUND" | "OLD_TEXT_NOT_UNIQUE";
export interface EditError {
    ok: false;
    code: EditErrorCode;
    message: string;
}
export interface EditSuccess {
    ok: true;
    newContent: string;
    parsed: TypedProposal;
    /** Rev of the snapshot written for this edit (0 if snapshot write failed). */
    rev: number;
}
export interface RestoreSuccess {
    ok: true;
    newRev: number;
    fields: Record<string, unknown>;
}
export interface SnapshotNotFoundError {
    ok: false;
    code: "SNAPSHOT_NOT_FOUND";
    message: string;
}
export type RestoreResult = RestoreSuccess | SnapshotNotFoundError | ParseError;
export type EditResult = EditSuccess | ParseError | EditError;
export declare const PROPOSAL_TYPES: readonly ProposalType[];
export declare function isProposalType(s: string): s is ProposalType;
export declare function proposalFilePath(stateDir: string, sessionId: string, type: ProposalType): string;
/** Scan history dir; return the highest integer rev, or 0 if empty/missing. */
export declare function latestRev(stateDir: string, sessionId: string, type: ProposalType): Promise<number>;
/** Write `<rev>.<ext>` atomically. */
export declare function writeSnapshot(stateDir: string, sessionId: string, type: ProposalType, rev: number, content: string): Promise<void>;
/** Read snapshot content, or undefined if missing. */
export declare function readSnapshot(stateDir: string, sessionId: string, type: ProposalType, rev: number): Promise<string | undefined>;
/**
 * Copy snapshot N back to the live draft AND write a new snapshot at
 * currentRev+1 whose contents equal snapshot N. Atomic via tmp+rename.
 */
export declare function restoreSnapshot(stateDir: string, sessionId: string, type: ProposalType, rev: number): Promise<RestoreResult>;
/**
 * Serialize and write a proposal file. Atomic via write-tmp + rename.
 * Always parses+validates the serialized form before rename — if validation
 * fails the on-disk file is untouched and the error is thrown to the caller.
 */
export declare function writeProposalFile(stateDir: string, sessionId: string, type: ProposalType, fields: Record<string, unknown>): Promise<{
    rev: number;
}>;
/** Read raw file contents, or `undefined` if missing. */
export declare function readProposalFile(stateDir: string, sessionId: string, type: ProposalType): Promise<string | undefined>;
/**
 * Exact-string replacement on the proposal file with atomic rollback.
 * Semantics mirror the builtin `edit` tool: `old_text` must match exactly
 * and uniquely; empty `new_text` deletes; first-and-only-occurrence rule.
 *
 * On parse/validation failure the on-disk file is left untouched.
 */
export declare function editProposalFile(stateDir: string, sessionId: string, type: ProposalType, oldText: string, newText: string): Promise<EditResult>;
/** Read + parse the proposal file via the per-type plugin. */
export declare function parseProposalFile(stateDir: string, sessionId: string, type: ProposalType): Promise<ParseResult>;
/** Remove the proposal file. Idempotent. */
export declare function deleteProposalFile(stateDir: string, sessionId: string, type: ProposalType): Promise<void>;
/** Enumerate all proposal types for which a file currently exists. */
export declare function listProposalFiles(stateDir: string, sessionId: string): Promise<ProposalType[]>;
export { getProposalTypePlugin };
export type { ProposalTypePlugin };
//# sourceMappingURL=proposal-files.d.ts.map