/**
 * Rules file compilation -- resolving @-imports into a single flat file.
 *
 * Agents that do not natively resolve `@path/to/file` imports (Codex, Cursor)
 * need a pre-compiled rules file with all imports inlined. This module
 * handles that expansion for both user-scope (writes into version home) and
 * project-scope (writes into the workspace).
 */
import type { AgentId } from '../types.js';
import { type RulesLayer } from './compose.js';
/**
 * Header the non-@-import compile path (`agents refresh-rules` → compileRulesForAgent)
 * prepends to a compiled instruction file. Exported so `doctor-diff` can strip it
 * before content-comparing a home rules file against the raw preset composition —
 * a header-compiled home must still reconcile (the header is not source content).
 */
export declare const COMPILED_HEADER: string;
export declare const COMPILED_HEADER_PROJECT: string;
/** Sidecar manifest recording source file hashes for staleness detection. */
export interface CompileManifest {
    compiledAt: string;
    sources: {
        path: string;
        sha256: string;
        mtime?: number;
        size?: number;
    }[];
}
/** Result of resolving @-imports in a rules file. */
export interface ResolveResult {
    /** Fully-inlined content. */
    content: string;
    /** Absolute paths of every file read during resolution (including the root). */
    sources: string[];
}
/**
 * Expand all `@path/to/file` imports in `content`, recursively up to
 * MAX_DEPTH. Imports inside fenced code blocks and inline code spans are
 * left alone, matching Claude Code's parser. Missing files are left as-is
 * (silent skip), matching the documented behavior.
 *
 * Relative paths resolve against `baseDir`; absolute and tilde-prefixed
 * paths resolve against the filesystem root / home directory.
 */
export declare function resolveImports(content: string, baseDir: string): ResolveResult;
/** True if the agent's native runtime resolves `@path` imports in its rules file. */
export declare function supportsRulesImports(agentId: AgentId): boolean;
/**
 * Fast staleness check. Returns true when:
 *  - the compiled file or its manifest is missing
 *  - any recorded source file is missing
 *  - any recorded source's sha256 no longer matches
 *
 * For agents that support @-imports natively, always returns false — there's
 * nothing to compile.
 */
export declare function isRulesStale(agentId: AgentId, version: string): boolean;
/**
 * Resolve the source `rules/AGENTS.md` (with all @-imports expanded) and
 * write the result into the version home, alongside a sidecar manifest that
 * records source file hashes for staleness detection.
 *
 * Agents that natively resolve @-imports are skipped (no-op) — their sync
 * uses the standard copyFileSync path in `syncResourcesToVersion`.
 */
export declare function compileRulesForAgent(agentId: AgentId, version: string): {
    compiled: boolean;
    compiledPath: string;
    sources: number;
};
/**
 * Recompile rules if stale. Safe to call on every agent invocation — the
 * staleness check is fast (sha256 of 8-10 small files, ~10-20ms). Returns
 * true if a recompile happened, false otherwise.
 */
export declare function ensureRulesFresh(agentId: AgentId, version: string): boolean;
export interface ProjectCompileResult {
    /** True when cwd/AGENTS.md was newly written or rewritten. */
    compiled: boolean;
    /** Absolute path to cwd/AGENTS.md. Empty when no project rules dir was present. */
    agentsPath: string;
    /** Per-agent instruction filenames symlinked (or copied) to AGENTS.md. */
    symlinks: string[];
    /** Number of source files inlined (root + recursive @-imports). */
    sources: number;
    /** Per-agent files we left alone because the user wrote/owns them. */
    skippedClobber: string[];
}
/**
 * Compile project-scope rules into a workspace's root memory files so each
 * agent's native loader picks them up.
 *
 * Composes rules from all available layers (project > user > extras > system)
 * with project highest priority — so a project's `subrules/` and `rules.yaml`
 * shadow user/system fragments and presets. Writes `cwd/AGENTS.md` with
 * COMPILED_HEADER_PROJECT and creates symlinks (CLAUDE.md, GEMINI.md,
 * .cursorrules, etc.) → AGENTS.md so every agent finds its expected file at
 * cwd. The agent's own loader merges this project-level file with its
 * user-level rules (in version home) at runtime.
 *
 * Don't-clobber guard: if `cwd/AGENTS.md` exists without our header, the user
 * authored it — leave it alone and report via `skippedClobber`. Same for any
 * pre-existing per-agent file or symlink that doesn't already point at
 * AGENTS.md.
 *
 * No-op when `cwd/.agents/rules/` does not exist. Idempotent on repeated
 * calls — content equality short-circuits the write.
 */
export declare function compileRulesForProject(cwd: string, opts?: {
    preset?: string;
    layers?: RulesLayer[];
}): ProjectCompileResult;
