/**
 * Rules composition — assemble a fully-inlined rules document from layered
 * `subrules/` fragments and `rules.yaml` preset definitions.
 *
 * The model:
 *   - Every DotAgents repo holds `<repo>/rules/subrules/*.md` (rule fragments)
 *     and `<repo>/rules/rules.yaml` (preset definitions).
 *   - Layers are read in precedence order (highest first):
 *       project > user > extra > system.
 *   - The active preset's `subrules:` list is resolved against the layer set
 *     using per-name shadowing — a project subrule shadows a user/system one
 *     of the same name.
 *   - Subrules in the user / extra / project layers that the preset did NOT
 *     name are auto-appended in precedence order. (System auto-append is
 *     opt-in only: system never auto-appends to avoid noise.)
 *   - Output is a single concatenated string with no `@-import` syntax.
 *
 * No filesystem writes happen here — callers (`syncResourcesToVersion`,
 * project-rules compile) decide where to land the composed output.
 */
import type { ManifestHook } from '../types.js';
export type LayerScope = 'project' | 'user' | 'extra' | 'system';
export interface RulesLayer {
    scope: LayerScope;
    rulesDir: string;
    /** Set when scope is 'extra'; undefined otherwise. */
    alias?: string;
}
export interface PresetDef {
    /** Subrule names (without `.md`), in concatenation order. */
    subrules: string[];
}
export interface RulesYaml {
    presets?: Record<string, PresetDef>;
}
export interface ComposeOptions {
    /** Defaults to `"default"`. */
    preset?: string;
    /** Layers in precedence order, highest first. */
    layers: RulesLayer[];
}
export interface ComposedSubrule {
    name: string;
    sourcePath: string;
    layerScope: LayerScope;
    layerAlias?: string;
    /** Set when the subrule is dir-form (`subrules/<name>/`); the dir itself. */
    subruleDir?: string;
}
export interface ComposeResult {
    /** Fully concatenated, no @-imports. */
    content: string;
    /** The preset name that was applied. */
    preset: string;
    /** The layer that defined the preset. */
    presetLayer: LayerScope;
    /** Subrules included, in concatenation order. */
    subrules: ComposedSubrule[];
}
/**
 * Compose a rules document from the given layers.
 *
 * Throws when the requested preset isn't defined in any layer's rules.yaml —
 * means the caller passed a typo or no layer ships the named preset.
 */
export declare function composeRules(opts: ComposeOptions): ComposeResult;
/**
 * Discover layers for use at sync time (no cwd) or runtime (with cwd).
 *
 * Project layer is included only when cwd is given AND `<cwd>/.agents/rules/`
 * exists. Without cwd, only user / extras / system are surfaced — matching
 * the home-file write at sync time.
 */
export declare function discoverRulesLayers(opts?: {
    cwd?: string;
}): RulesLayer[];
/** Convenience wrapper — discovers layers from state, then composes. */
export declare function composeRulesFromState(opts?: {
    preset?: string;
    cwd?: string;
}): ComposeResult;
/**
 * Collect hooks declared inside the active subrule directories.
 *
 * Resolves the same composed subrule set as {@link composeRules} (preset-named
 * plus auto-append, highest-layer-wins per name). For each dir-form subrule
 * that ships a `hooks.yaml`, parses it, rewrites each hook's `script` to an
 * ABSOLUTE path under the subrule dir, and namespaces the key as
 * `<subruleName>__<hookName>` to avoid collisions across subrules.
 *
 * Returns an empty map for flat subrules and dir-form subrules without a
 * `hooks.yaml`. A malformed hooks.yaml is skipped (try/catch) so a bad file
 * never breaks rule composition or hook registration.
 */
export declare function collectSubruleHooks(layers: RulesLayer[], presetName?: string): Record<string, ManifestHook>;
/** Convenience wrapper — discovers layers from state, then collects hooks. */
export declare function collectSubruleHooksFromState(opts?: {
    preset?: string;
    cwd?: string;
}): Record<string, ManifestHook>;
