/**
 * Skill self-learning: decides whether a completed turn should
 * trigger skill creation or improvement instructions.
 *
 * Guards against proliferation:
 * - Project-level pattern repetition: same workflow signature must appear
 *   ≥ SKILL_PATTERN_REPETITION_THRESHOLD times before triggering creation
 * - MAX_SKILLS_PER_PROJECT: hard cap on project-level skills
 * - Dedup check: compares tool-set signature against existing skills
 * - Cooldown: prevents rapid-fire creation within a session
 */
import { MAX_SKILLS_PER_PROJECT, MAX_SKILLS_GLOBAL } from "../runtime/config/tunable-defaults.js";
export { MAX_SKILLS_PER_PROJECT, MAX_SKILLS_GLOBAL };
export interface SkillTurnResult {
    ok: boolean;
    /** Number of tool invocations in this turn */
    toolCallCount: number;
    /** Number of distinct tool names used */
    distinctToolCount: number;
    /** Was a multi-step orchestration (≥2 rounds) used? */
    multiStep: boolean;
    /** Did the turn involve a sub-agent fork? */
    hasSubAgent: boolean;
    /** Optional user feedback signal (positive/negative/none) */
    feedback?: "positive" | "negative" | null;
    /** Skill name if an existing skill was used */
    existingSkillName?: string | null;
}
export interface SkillCreateInstruction {
    type: "skill.create";
    /** Suggested skill name derived from tool usage pattern */
    suggestedName: string;
    /** Short description of what the skill does */
    description: string;
    /** Tool names involved */
    tools: string[];
    /** Number of orchestration steps */
    stepCount: number;
}
export interface SkillImproveInstruction {
    type: "skill.improve";
    /** Existing skill to improve */
    skillName: string;
    /** Reason for improvement */
    reason: string;
}
export type SkillInstruction = SkillCreateInstruction | SkillImproveInstruction;
/**
 * Reset cooldown state (for testing).
 */
export declare function resetSkillCreationCooldown(): void;
interface PatternEntry {
    /** Sorted tool signature (e.g. "bash+file_read+file_write") */
    signature: string;
    /** Number of times this pattern has been observed */
    count: number;
    /** First seen timestamp (ISO) */
    firstSeen: string;
    /** Last seen timestamp (ISO) */
    lastSeen: string;
    /** Whether a skill has already been created for this pattern */
    promoted: boolean;
}
/**
 * Record a workflow pattern observation and return whether it has reached
 * the repetition threshold (i.e., is now eligible for skill creation).
 *
 * @returns true if the pattern just reached the threshold on this observation
 */
export declare function recordPatternAndCheckThreshold(projectRoot: string, tools: string[]): boolean;
/**
 * Mark a pattern as promoted (skill already created for it).
 * Called when a skill is created through other paths (e.g., manual).
 */
export declare function markPatternPromoted(projectRoot: string, tools: string[]): void;
/**
 * Get all tracked patterns for a project. Useful for diagnostics.
 */
export declare function getPatternStats(projectRoot: string): PatternEntry[];
/**
 * Build a normalized "tool signature" from sorted tool names.
 * Used for dedup — if an existing skill has the same tool signature,
 * we skip creation.
 */
export declare function buildToolSignature(tools: string[]): string;
/**
 * Check if an existing skill in skillsDir already covers the same tool set.
 * Returns the name of the conflicting skill, or null if none found.
 */
export declare function findDuplicateSkill(tools: string[], skillsDir: string): string | null;
/**
 * Count active skills in a directory.
 */
export declare function countSkillsInDir(skillsDir: string): number;
/**
 * Context for proliferation checks.
 */
export interface SkillCreationContext {
    /** Project-level skills directory */
    projectSkillsDir?: string;
    /** User-level (global) skills directory */
    globalSkillsDir?: string;
    /** Tool names used in this turn */
    tools: string[];
    /** Optional suggested name */
    suggestedName?: string;
    /** Project root directory (required for pattern tracking) */
    projectRoot?: string;
}
/**
 * Determine whether a completed turn should produce a skill instruction.
 *
 * A new skill is suggested when:
 * - The turn succeeded
 * - It involved multi-step orchestration
 * - It used ≥3 tool calls across ≥2 distinct tools
 * - No existing skill was already applied
 * - Cooldown has elapsed since last skill creation
 * - No duplicate skill exists (same tool signature)
 * - Project skill count < MAX_SKILLS_PER_PROJECT
 * - **Pattern repetition threshold reached** (≥3 occurrences at project level)
 */
export declare function shouldCreateSkill(result: SkillTurnResult, context?: SkillCreationContext): boolean;
export declare function shouldImproveSkill(result: SkillTurnResult): boolean;
/**
 * Build a skill instruction from a turn result, or null if none is warranted.
 * Updates cooldown timestamp on success.
 */
export declare function buildSkillInstruction(result: SkillTurnResult, context: SkillCreationContext): SkillInstruction | null;
