import type { ProjectMemoryKind, StoredProjectMemory } from '../types.js'; export { parseBlock, parseBlockResult, renderMemoryFile, slugify, VALID_MEMORY_KINDS, VALID_PROJECT_MEMORY_KINDS } from './frontmatter-parse.js'; /** * Where a stored memory file's `kind` came from. `'none'` means the file * has no resolvable kind (no `metadata.type`, no `kind:`, no `type:`, or * the value present is not one of the accepted kinds in * `PROJECT_MEMORY_KINDS`). */ export type MemoryKindSource = 'metadata.type' | 'kind' | 'type' | 'none'; export interface MemoryKindResolution { kind: ProjectMemoryKind | null; source: MemoryKindSource; /** The first raw value found in the frontmatter, even when it is not a valid kind. */ rawKind: string | null; } export interface ParsedMemoryFrontmatter { hasFrontmatter: boolean; name?: string; /** Top-level `title:` frontmatter value. Never the nested `metadata.title` * (that is a different semantic); used only as a name fallback on the * read path — see `resolveMemoryName`. */ title?: string; description?: string; sourceArtifact?: string; kind: MemoryKindResolution; /** Raw frontmatter block text (without the `---` fences); '' when absent. */ frontmatter: string; body: string; } /** * Resolve the peaks memory kind from a stored memory file's frontmatter. * * Resolution order (first *valid* kind wins): * 1. nested `metadata.type` — the canonical peaks contract * 2. top-level `kind:` — the legacy alias (was silently dropped before) * 3. top-level `type:` — tolerated by the pre-existing trim-based reader * 4. `none` — reported as unclassified; never invented * * using a top-level `kind:` were silently dropped by the reader (defect * #2). Falling through to `kind:` / `type:` is a strict superset of the * old behaviour — no previously-indexed file changes kind. */ export declare function resolveMemoryKind(content: string): MemoryKindResolution; /** * Single parse surface for stored memory frontmatter. Both * `parseStoredMemoryFile` (read path) and the reindex / ingest / doctor * classifiers consume this so there is exactly one kind-resolution rule * in the codebase. * * Tolerates a leading run of HTML-comment lines (e.g. the * `` sediment marker) before the opening `---` * fence. The closing fence is still required and body extraction is * unchanged: the body is the text after the closing fence. */ export declare function parseMemoryFrontmatter(content: string): ParsedMemoryFrontmatter; /** Which frontmatter field (or the filename) supplied a memory's name. */ export type MemoryNameSource = 'name' | 'title' | 'stem' | 'none'; export interface MemoryNameResolution { /** The resolved name, or null when every fallback was empty. */ name: string | null; source: MemoryNameSource; } /** * Deterministic name fallback chain for the read path: * * 1. `name:` — the canonical field written by `renderMemoryFile` * 2. `title:` — hand-written / legacy files (the 5 on-disk files * this slice fixes carried only `title:` + `kind:`) * 3. filename stem — last resort, so a well-formed memory with a valid * kind is never dropped just for missing a name * * Empty values are skipped rather than accepted: a `name:` of `''` still * falls through, and a file whose stem is also empty resolves to null so the * caller's validation is preserved (never invents a name). */ export declare function resolveMemoryName(parsed: ParsedMemoryFrontmatter, filePath: string): MemoryNameResolution; export declare function parseStoredMemoryFile(content: string, filePath: string): StoredProjectMemory | null;