/**
 * Project Memory Service
 *
 * Manages project-level persistent memory stored in project/.crewly/knowledge/
 * Provides storage for patterns, decisions, gotchas, and relationships.
 *
 * @module services/memory/project-memory.service
 */
import { ProjectMemory, PatternEntry, DecisionEntry, GotchaEntry, RelationshipEntry, TaskHistoryEntry, type PatternCategory, type GotchaSeverity } from '../../types/memory.types.js';
/**
 * Search results from cross-entity search
 */
export interface SearchResults {
    patterns: PatternEntry[];
    decisions: DecisionEntry[];
    gotchas: GotchaEntry[];
    relationships: RelationshipEntry[];
    totalCount: number;
}
/**
 * Interface for the Project Memory Service
 */
export interface IProjectMemoryService {
    initializeProject(projectPath: string): Promise<void>;
    addPattern(projectPath: string, pattern: Omit<PatternEntry, 'id' | 'createdAt'>): Promise<string>;
    getPatterns(projectPath: string, category?: PatternCategory): Promise<PatternEntry[]>;
    searchPatterns(projectPath: string, query: string): Promise<PatternEntry[]>;
    addDecision(projectPath: string, decision: Omit<DecisionEntry, 'id' | 'decidedAt'>): Promise<string>;
    getDecisions(projectPath: string): Promise<DecisionEntry[]>;
    addGotcha(projectPath: string, gotcha: Omit<GotchaEntry, 'id' | 'createdAt'>): Promise<string>;
    getGotchas(projectPath: string, severity?: GotchaSeverity): Promise<GotchaEntry[]>;
    addRelationship(projectPath: string, relationship: Omit<RelationshipEntry, 'id'>): Promise<string>;
    getRelationships(projectPath: string, componentName?: string): Promise<RelationshipEntry[]>;
    recordLearning(projectPath: string, agentId: string, agentRole: string, learning: string, metadata?: Record<string, unknown>): Promise<void>;
    getRecentLearnings(projectPath: string, limit?: number): Promise<string>;
    generateProjectContext(projectPath: string): Promise<string>;
    searchAll(projectPath: string, query: string): Promise<SearchResults>;
    getProjectMemory(projectPath: string): Promise<ProjectMemory | null>;
    addTaskHistory(projectPath: string, entry: TaskHistoryEntry): Promise<string>;
    getTaskHistory(projectPath: string, capability?: string): Promise<TaskHistoryEntry[]>;
}
/**
 * Service for managing project-level persistent memory
 *
 * Follows singleton pattern for consistent state management.
 * Uses atomic file writes to prevent data corruption.
 *
 * @example
 * ```typescript
 * const memoryService = ProjectMemoryService.getInstance();
 * await memoryService.initializeProject('/path/to/project');
 * await memoryService.addPattern('/path/to/project', {
 *   category: 'api',
 *   title: 'Error Handling Wrapper',
 *   description: 'All API endpoints use handleApiError() wrapper',
 *   discoveredBy: 'backend-dev-001'
 * });
 * ```
 */
export declare class ProjectMemoryService implements IProjectMemoryService {
    private static instance;
    private readonly logger;
    private readonly memoryCache;
    private readonly CACHE_TTL_MS;
    /**
     * Creates a new ProjectMemoryService instance
     */
    constructor();
    /**
     * Gets the singleton instance of ProjectMemoryService
     *
     * @returns The singleton ProjectMemoryService instance
     */
    static getInstance(): ProjectMemoryService;
    /**
     * Clears the singleton instance (useful for testing)
     */
    static clearInstance(): void;
    /**
     * Gets the path to a project's knowledge directory
     *
     * @param projectPath - Absolute path to the project
     * @returns Path to the knowledge directory
     */
    private getKnowledgePath;
    /**
     * Gets the path to a specific memory file for a project
     *
     * @param projectPath - Absolute path to the project
     * @param fileName - The memory file name
     * @returns Absolute path to the memory file
     */
    private getFilePath;
    /**
     * Checks if a file exists
     *
     * @param filePath - Path to check
     * @returns true if file exists
     */
    private fileExists;
    /**
     * Invalidates the cache for a project
     *
     * @param projectPath - Project path
     */
    private invalidateCache;
    /**
     * Checks if content is similar (simple substring matching)
     *
     * @param existing - Existing content
     * @param newContent - New content to compare
     * @returns true if content is similar
     */
    private isSimilarContent;
    /**
     * Initializes memory storage for a project
     *
     * @param projectPath - Absolute path to the project
     *
     * @example
     * ```typescript
     * await memoryService.initializeProject('/home/user/projects/my-app');
     * ```
     */
    initializeProject(projectPath: string): Promise<void>;
    /**
     * Adds a new pattern entry
     *
     * @param projectPath - Project path
     * @param pattern - Pattern data (without id and createdAt)
     * @returns ID of the created or existing pattern
     */
    addPattern(projectPath: string, pattern: Omit<PatternEntry, 'id' | 'createdAt'>): Promise<string>;
    /**
     * Gets all patterns, optionally filtered by category
     *
     * @param projectPath - Project path
     * @param category - Optional category filter
     * @returns Array of patterns
     */
    getPatterns(projectPath: string, category?: PatternCategory): Promise<PatternEntry[]>;
    /**
     * Saves patterns to disk
     */
    private savePatterns;
    /**
     * Searches patterns by query
     *
     * @param projectPath - Project path
     * @param query - Search query
     * @returns Matching patterns
     */
    searchPatterns(projectPath: string, query: string): Promise<PatternEntry[]>;
    /**
     * Adds a new decision entry
     *
     * @param projectPath - Project path
     * @param decision - Decision data (without id and decidedAt)
     * @returns ID of the created decision
     */
    addDecision(projectPath: string, decision: Omit<DecisionEntry, 'id' | 'decidedAt'>): Promise<string>;
    /**
     * Gets all decisions
     *
     * @param projectPath - Project path
     * @returns Array of decisions (active ones first)
     */
    getDecisions(projectPath: string): Promise<DecisionEntry[]>;
    /**
     * Saves decisions to disk
     */
    private saveDecisions;
    /**
     * Adds a new gotcha entry
     *
     * @param projectPath - Project path
     * @param gotcha - Gotcha data (without id and createdAt)
     * @returns ID of the created gotcha
     */
    addGotcha(projectPath: string, gotcha: Omit<GotchaEntry, 'id' | 'createdAt'>): Promise<string>;
    /**
     * Gets all gotchas, optionally filtered by severity
     *
     * @param projectPath - Project path
     * @param severity - Optional severity filter
     * @returns Array of gotchas (high severity first)
     */
    getGotchas(projectPath: string, severity?: GotchaSeverity): Promise<GotchaEntry[]>;
    /**
     * Saves gotchas to disk
     */
    private saveGotchas;
    /**
     * Adds a new relationship entry
     *
     * @param projectPath - Project path
     * @param relationship - Relationship data (without id)
     * @returns ID of the created relationship
     */
    addRelationship(projectPath: string, relationship: Omit<RelationshipEntry, 'id'>): Promise<string>;
    /**
     * Gets relationships, optionally filtered by component name
     *
     * @param projectPath - Project path
     * @param componentName - Optional component name filter
     * @returns Array of relationships
     */
    getRelationships(projectPath: string, componentName?: string): Promise<RelationshipEntry[]>;
    /**
     * Saves relationships to disk
     */
    private saveRelationships;
    /**
     * Append a task-history entry. Dedup on `id`; if an existing entry
     * with the same id is found, this is a no-op (subscriber emits a
     * stable id per workitem so a redelivered event collapses cleanly).
     *
     * @param projectPath - Project path
     * @param entry - The TaskHistoryEntry to record
     * @returns The id of the recorded entry (echoes input.id)
     */
    addTaskHistory(projectPath: string, entry: TaskHistoryEntry): Promise<string>;
    /**
     * Get the full task-history ledger for a project. Optionally filter
     * by canonical capability string (e.g. `'gmail:read'`); when filter
     * is set, only entries whose `capabilities[]` contains an exact
     * match are returned, sorted most-recent first.
     *
     * @param projectPath - Project path
     * @param capability - Optional capability string filter
     * @returns Array of entries (most recent first when filtered)
     */
    getTaskHistory(projectPath: string, capability?: string): Promise<TaskHistoryEntry[]>;
    private saveTaskHistory;
    /**
     * Records a learning entry to the append-only log
     *
     * @param projectPath - Project path
     * @param agentId - Agent that made the learning
     * @param agentRole - Agent's role
     * @param learning - The learning content
     * @param metadata - Optional metadata
     */
    recordLearning(projectPath: string, agentId: string, agentRole: string, learning: string, metadata?: Record<string, unknown>): Promise<void>;
    /**
     * Gets recent learnings from the log
     *
     * @param projectPath - Project path
     * @param limit - Maximum number of entries to return
     * @returns Recent learnings as markdown
     */
    getRecentLearnings(projectPath: string, limit?: number): Promise<string>;
    /**
     * Generates a context string for prompt injection
     *
     * @param projectPath - Project path
     * @returns Formatted context string
     */
    generateProjectContext(projectPath: string): Promise<string>;
    /**
     * Searches across all entity types
     *
     * @param projectPath - Project path
     * @param query - Search query
     * @returns Search results from all categories
     */
    searchAll(projectPath: string, query: string): Promise<SearchResults>;
    /**
     * Gets the complete project memory object
     *
     * @param projectPath - Project path
     * @returns Full project memory or null if not initialized
     */
    getProjectMemory(projectPath: string): Promise<ProjectMemory | null>;
}
//# sourceMappingURL=project-memory.service.d.ts.map