/**
 * Learning Accumulation Service
 *
 * Manages persistent learning files at two levels:
 * - **Project-level:** `{projectPath}/.crewly/learning/what_worked.md` and `what_failed.md`
 * - **Global-level:** `~/.crewly/learning/cross_project_insights.md`
 *
 * Learning entries are appended as timestamped markdown sections so agents can
 * review past successes, failures, and cross-project insights when starting
 * new tasks or resuming work.
 *
 * @module services/memory/learning-accumulation.service
 */
/**
 * Service for accumulating learning entries into markdown files
 *
 * Follows the singleton pattern for consistent state management.
 * Entries are appended atomically using `fs.appendFile` so concurrent
 * writes from different agents do not corrupt the file.
 *
 * @example
 * ```typescript
 * const learningService = LearningAccumulationService.getInstance();
 * await learningService.recordSuccess(
 *   '/home/user/my-project',
 *   'dev-001',
 *   'developer',
 *   'Parallel test execution reduced CI time by 40%',
 *   'Applied to Jest with --maxWorkers=4'
 * );
 * ```
 */
export declare class LearningAccumulationService {
    private static instance;
    private readonly logger;
    /**
     * Private constructor to enforce singleton usage
     */
    private constructor();
    /**
     * Gets the singleton instance of LearningAccumulationService
     *
     * @returns The singleton LearningAccumulationService instance
     */
    static getInstance(): LearningAccumulationService;
    /**
     * Clears the singleton instance (useful for testing)
     */
    static clearInstance(): void;
    /**
     * Returns the absolute path to a project's learning directory
     *
     * @param projectPath - Absolute path to the project root
     * @returns Absolute path to `{projectPath}/.crewly/learning`
     */
    private getLearningDir;
    /**
     * Returns the absolute path to the global learning directory
     *
     * @returns Absolute path to `~/.crewly/learning`
     */
    private getGlobalLearningDir;
    /**
     * Reads a file and returns its content, or null if the file does not exist
     *
     * Permission errors and other unexpected I/O failures are propagated.
     *
     * @param filePath - Absolute path to the file
     * @returns File content as a string, or null when the file is missing
     */
    private safeReadFile;
    /**
     * Formats a learning entry as a markdown section
     *
     * The resulting block uses a level-3 heading with an ISO timestamp,
     * followed by the description and optional context, terminated by
     * a horizontal rule separator.
     *
     * @param agentId - Identifier of the agent that produced the learning
     * @param role - Role of the agent (e.g. 'developer', 'qa')
     * @param description - Human-readable description of the learning
     * @param context - Optional additional context or notes
     * @returns Formatted markdown entry string
     *
     * @example
     * ```typescript
     * const entry = this.formatEntry('dev-001', 'developer', 'Tests pass faster with parallelism');
     * // ### [2026-02-09T12:00:00.000Z] developer / dev-001
     * // Tests pass faster with parallelism
     * // Context: None
     * //
     * // ---
     * ```
     */
    private formatEntry;
    /**
     * Ensures a learning file exists, creating it with the provided header if missing
     *
     * @param filePath - Absolute path to the markdown file
     * @param header - Header content to write when creating the file
     */
    private ensureFileWithHeader;
    /**
     * Filters out superseded entries from a learning markdown file.
     *
     * Entries marked with `[SUPERSEDED]` are removed from the output.
     * The file header (everything before the first `### [`) is preserved.
     *
     * @param content - Raw markdown file content
     * @returns Content with superseded entries removed
     */
    private filterSuperseded;
    /**
     * Marks entries in a learning file as superseded by inserting a
     * `[SUPERSEDED]` marker into matching entries.
     *
     * An entry is considered a match if its description contains the
     * supersedes keyword (case-insensitive substring match).
     *
     * @param filePath - Path to the markdown learning file
     * @param keyword - Keyword to match against entry descriptions
     */
    private markSupersededInFile;
    /**
     * Records a successful pattern, approach, or solution to the project's
     * `what_worked.md` learning file
     *
     * If the learning directory or file does not exist it is created automatically.
     *
     * @param projectPath - Absolute path to the project root
     * @param agentId - Identifier of the agent recording the success
     * @param role - Role of the agent (e.g. 'developer', 'qa')
     * @param description - Human-readable description of what worked
     * @param context - Optional additional context or notes
     *
     * @example
     * ```typescript
     * await learningService.recordSuccess(
     *   '/home/user/my-project',
     *   'dev-001',
     *   'developer',
     *   'Using database transactions for batch inserts prevented partial writes',
     *   'PostgreSQL with pg-promise library'
     * );
     * ```
     */
    recordSuccess(projectPath: string, agentId: string, role: string, description: string, context?: string, supersedes?: string): Promise<void>;
    /**
     * Records a failed approach, pitfall, or mistake to the project's
     * `what_failed.md` learning file
     *
     * If the learning directory or file does not exist it is created automatically.
     *
     * @param projectPath - Absolute path to the project root
     * @param agentId - Identifier of the agent recording the failure
     * @param role - Role of the agent (e.g. 'developer', 'qa')
     * @param description - Human-readable description of what failed
     * @param context - Optional additional context or notes
     *
     * @example
     * ```typescript
     * await learningService.recordFailure(
     *   '/home/user/my-project',
     *   'qa-001',
     *   'qa',
     *   'Snapshot tests broke on every UI change, causing CI churn',
     *   'Replaced with visual regression tests'
     * );
     * ```
     */
    recordFailure(projectPath: string, agentId: string, role: string, description: string, context?: string, supersedes?: string): Promise<void>;
    /**
     * Records a cross-project insight to the global
     * `~/.crewly/learning/cross_project_insights.md` file
     *
     * Cross-project insights capture learnings that are not specific to a
     * single project and can inform agent behaviour across the entire workspace.
     *
     * @param agentId - Identifier of the agent recording the insight
     * @param role - Role of the agent (e.g. 'developer', 'qa')
     * @param description - Human-readable description of the insight
     * @param context - Optional additional context or notes
     *
     * @example
     * ```typescript
     * await learningService.recordCrossProjectInsight(
     *   'dev-002',
     *   'developer',
     *   'TypeScript strict mode catches 30% more bugs at compile time',
     *   'Observed across 4 projects in Q1 2026'
     * );
     * ```
     */
    recordCrossProjectInsight(agentId: string, role: string, description: string, context?: string): Promise<void>;
    /**
     * Reads the project's `what_worked.md` learning file
     *
     * When `tailChars` is specified only the last N characters of the file
     * are returned, which is useful for startup briefing prompts that need
     * only the most recent entries.
     *
     * @param projectPath - Absolute path to the project root
     * @param tailChars - Optional maximum number of trailing characters to return
     * @returns File content (or tail thereof), or null if the file does not exist
     *
     * @example
     * ```typescript
     * // Get full file
     * const all = await learningService.getSuccesses('/home/user/project');
     *
     * // Get last 2000 chars for a briefing
     * const recent = await learningService.getSuccesses('/home/user/project', 2000);
     * ```
     */
    getSuccesses(projectPath: string, tailChars?: number): Promise<string | null>;
    /**
     * Reads the project's `what_failed.md` learning file
     *
     * When `tailChars` is specified only the last N characters of the file
     * are returned, which is useful for startup briefing prompts that need
     * only the most recent entries.
     *
     * @param projectPath - Absolute path to the project root
     * @param tailChars - Optional maximum number of trailing characters to return
     * @returns File content (or tail thereof), or null if the file does not exist
     *
     * @example
     * ```typescript
     * const failures = await learningService.getFailures('/home/user/project', 1500);
     * ```
     */
    getFailures(projectPath: string, tailChars?: number): Promise<string | null>;
    /**
     * Reads the global `cross_project_insights.md` learning file
     *
     * When `tailChars` is specified only the last N characters of the file
     * are returned, which is useful for startup briefing prompts.
     *
     * @param tailChars - Optional maximum number of trailing characters to return
     * @returns File content (or tail thereof), or null if the file does not exist
     *
     * @example
     * ```typescript
     * const insights = await learningService.getCrossProjectInsights(3000);
     * ```
     */
    getCrossProjectInsights(tailChars?: number): Promise<string | null>;
}
//# sourceMappingURL=learning-accumulation.service.d.ts.map