/** * YAML frontmatter parser/writer for RCASD provenance files. * * Provides Obsidian-like backlinks via YAML frontmatter blocks * (delimited by `---`). No YAML library dependency — uses * simple key-value parsing for the supported fields. * * @task T5200 * @epic T4798 */ /** Related link in frontmatter. */ export interface RelatedLink { type: 'consensus' | 'adr' | 'task' | 'research' | 'spec' | 'contribution' | 'file'; path?: string; id?: string; } /** Frontmatter metadata for an RCASD artifact. */ export interface FrontmatterMetadata { epic: string; stage: string; task?: string; related?: RelatedLink[]; created?: string; updated?: string; [key: string]: unknown; } /** Result of parsing frontmatter from a markdown file. */ export interface ParsedFrontmatter { frontmatter: FrontmatterMetadata | null; body: string; raw: string; } /** * Parse YAML frontmatter from a markdown string. * * Finds the YAML block delimited by `---` at the start of the file, * parses key-value pairs, and returns the structured metadata plus * the remaining body content. * * @param content - Full markdown file content * @returns Parsed frontmatter, body, and raw YAML block */ export declare function parseFrontmatter(content: string): ParsedFrontmatter; /** * Convert a FrontmatterMetadata object to a YAML frontmatter string. * * Output format: * ``` * --- * epic: T4881 * stage: research * related: * - type: consensus * path: ../consensus/consensus-report.md * created: 2026-02-15 * --- * ``` * * @param metadata - The frontmatter metadata to serialize * @returns YAML frontmatter string including `---` delimiters */ export declare function serializeFrontmatter(metadata: FrontmatterMetadata): string; /** * Add or replace YAML frontmatter in markdown content. * * If the content already has a frontmatter block, it is replaced. * Otherwise the YAML block is prepended. * * @param content - Original markdown content * @param metadata - Frontmatter metadata to set * @returns Updated content with new frontmatter */ export declare function addFrontmatter(content: string, metadata: FrontmatterMetadata): string; /** * Convenience builder for common frontmatter patterns. * * Auto-sets `updated` to the current ISO date string. * * @param epicId - Epic identifier (e.g. `T4881`) * @param stage - RCASD stage name (e.g. `research`) * @param options - Optional fields: task, related links, created date * @returns A FrontmatterMetadata object ready for serialization */ export declare function buildFrontmatter(epicId: string, stage: string, options?: { task?: string; related?: RelatedLink[]; created?: string; }): FrontmatterMetadata; /** * Scan all markdown files in `.cleo/rcasd/` for files that reference * the given epic+stage combination via their `related` frontmatter links. * * This enables "what links here?" queries (Obsidian-style backlinks). * * @param epicId - Epic identifier to search for * @param stage - Stage name to search for * @param cwd - Optional working directory override * @returns Array of files with matching related links */ export declare function getBacklinks(epicId: string, stage: string, cwd?: string): Array<{ file: string; link: RelatedLink; }>; //# sourceMappingURL=frontmatter.d.ts.map