/**
 * Learnings Index Service
 *
 * Surfaces project-scoped record-learning entries (`.crewly/knowledge/learnings.md`)
 * as virtual `KnowledgeDocumentSummary` entries so they appear in the `/knowledge`
 * UI and are returned by recall searches.
 *
 * Background (memory.f1, 2026-04-28): the `record-learning` skill writes to
 * `learnings.md` (an append-only log owned by `ProjectMemoryService`), but the
 * `/knowledge` UI reads `KnowledgeService.listDocuments()` which only sees
 * `.crewly/docs/`. As a result, learnings persisted to disk were not visible
 * in the UI and were not returned by recall. This service bridges that gap by
 * parsing the learnings log on demand and exposing each entry under a stable
 * synthetic ID (`learning:<sha1-prefix>`) that the rest of the knowledge stack
 * can carry through `listDocuments` / `getDocument` / search.
 *
 * @module services/knowledge/learnings-index.service
 */
import type { KnowledgeDocument, KnowledgeDocumentSummary, KnowledgeScope } from '../../types/knowledge.types.js';
/** Prefix that marks a synthetic learning document ID. */
export declare const LEARNING_ID_PREFIX = "learning:";
/** Category label used for learnings surfaced in the knowledge UI. */
export declare const LEARNINGS_CATEGORY = "Learnings";
/**
 * A learning entry parsed out of `learnings.md`.
 *
 * @internal
 */
export interface ParsedLearning {
    /** Stable synthetic ID — `learning:` prefix + sha1 hash of (timestamp + author + content). */
    id: string;
    /** Title — Karpathy-lite `[[Entity]]` opener if present, else first sentence (capped). */
    title: string;
    /** Tags — `learning` always, plus any `[tag-name]` tokens found in the body. */
    tags: string[];
    /** Full body of the entry (date / agent header lines stripped). */
    content: string;
    /** ISO timestamp parsed from `## YYYY-MM-DD` and `### [role/agent] HH:MM:SS` headers. */
    createdAt: string;
    /** Same as `createdAt` — learnings are append-only, no separate update timestamp. */
    updatedAt: string;
    /** Agent author string from the `[role/agentId]` header (or `unknown`). */
    author: string;
}
/**
 * Parse `learnings.md` content into discrete learning entries.
 *
 * The expected format produced by `ProjectMemoryService.recordLearning` is:
 *
 * ```
 * ## YYYY-MM-DD
 *
 * ### [role/agentId] HH:MM:SS
 * <content>
 *
 * ---
 * ```
 *
 * Older entries may lack the `### [role/agentId]` header — those are still
 * parsed, with `author = 'unknown'` and time defaulting to `00:00:00`. Entries
 * containing only the file-level header (`# Project Learnings`) are skipped.
 *
 * Exported for testing only — callers should use {@link LearningsIndexService}.
 *
 * @param raw - Full file content (YAML frontmatter is stripped if present)
 * @returns Parsed entries in file order
 */
export declare function parseLearnings(raw: string): ParsedLearning[];
/**
 * Service that surfaces `learnings.md` entries as virtual knowledge documents.
 *
 * Singleton, file-system-backed, no caching — `learnings.md` is small enough
 * (a single project's append-only log) that re-parsing on every list call is
 * acceptable and avoids stale-cache bugs across writes from the agent skill.
 */
export declare class LearningsIndexService {
    private static instance;
    private readonly logger;
    private constructor();
    /**
     * Get the singleton instance.
     *
     * @returns LearningsIndexService instance
     */
    static getInstance(): LearningsIndexService;
    /**
     * Reset the singleton (for testing).
     */
    static resetInstance(): void;
    /**
     * Detect whether an ID belongs to this service's synthetic namespace.
     *
     * @param id - Document ID to test
     * @returns True if the ID has the learning prefix
     */
    static isLearningId(id: string): boolean;
    /**
     * Resolve the absolute path to `learnings.md` for the given scope.
     *
     * Learnings only exist at project scope today (the `record-learning` skill
     * always requires a `projectPath`). Global scope returns null so callers
     * can short-circuit cleanly.
     *
     * @param scope - 'global' or 'project'
     * @param projectPath - Required when scope is 'project'
     * @returns Absolute file path, or null if learnings cannot exist for this scope
     */
    private learningsPath;
    /**
     * Read and parse `learnings.md` for the given scope.
     *
     * Missing-file and read-error cases both return an empty array — the
     * indexer must never fail callers just because no learnings exist yet.
     *
     * @param scope - Document scope
     * @param projectPath - Project path (required for 'project' scope)
     * @returns Parsed learning entries (empty if file missing or unreadable)
     */
    private readLearnings;
    /**
     * List all learnings for the given scope as `KnowledgeDocumentSummary` entries.
     *
     * Sorted newest-first so the UI shows recent learnings at the top of the
     * unified knowledge list (matching the user mental model that learnings
     * are a chronological journal).
     *
     * @param scope - 'global' or 'project'
     * @param projectPath - Required when scope is 'project'
     * @returns Array of summaries (empty if scope is 'global' or no learnings exist)
     */
    listLearnings(scope: KnowledgeScope, projectPath?: string): Promise<KnowledgeDocumentSummary[]>;
    /**
     * Fetch a single learning by its synthetic ID.
     *
     * @param id - Synthetic document ID (must start with `learning:`)
     * @param scope - Document scope
     * @param projectPath - Required when scope is 'project'
     * @returns Full document, or null if id is not a learning id or not found
     */
    getLearning(id: string, scope: KnowledgeScope, projectPath?: string): Promise<KnowledgeDocument | null>;
    /**
     * Project a parsed entry into a `KnowledgeDocumentSummary`.
     *
     * @param e - Parsed learning entry
     * @param scope - Target scope label
     * @returns Summary suitable for the knowledge list API
     */
    private toSummary;
    /**
     * Project a parsed entry into a full `KnowledgeDocument`.
     *
     * @param e - Parsed learning entry
     * @param scope - Target scope label
     * @param projectPath - Carried into the document for project-scoped entries
     * @returns Full document suitable for the knowledge document API
     */
    private toDocument;
}
//# sourceMappingURL=learnings-index.service.d.ts.map