/** * The page contract of the LLM-wiki. * * A vault page is markdown with YAML frontmatter. Two fields make a page a * piece of knowledge rather than a bookmark: `summary` (the one-line * conclusion — what this means for us) and `keep_because` (the reason it * earns a place at all). Without them a write goes to `log.md`, not to a * page. This module parses/serialises that shape and applies the gate; * everything else (index, history, supersede) builds on it. * * @module services/wiki/wiki-page */ import { type WikiKeepBecause } from '../../constants.js'; /** Frontmatter every page carries (agents set the first block; the system fills the rest). */ export interface WikiPageFrontmatter { title: string; /** One-line conclusion: what this page means for the team/project. */ summary: string; keep_because: WikiKeepBecause; tags?: string[]; /** Roles allowed to read the page; empty/absent = everyone in the vault's instance. */ visibility?: string[]; source?: string; caller?: string; recorded?: string; updated?: string; superseded_by?: string; superseded_at?: string; superseded_reason?: string; proposed_by?: string; /** Anything else on the page (migrated fields such as `confidence`, `migrated_from`). */ [key: string]: unknown; } /** A parsed page. */ export interface WikiPage { frontmatter: Partial; body: string; /** True when the file had a `---` block at all. */ hadFrontmatter: boolean; } /** Why a page write was refused by the retention gate. */ export interface RetentionRefusal { reason: 'retention_gate'; missing: string[]; message: string; } /** * Split a page into frontmatter + body. Tolerant: a page without a block * parses as `{ frontmatter: {}, body: raw }`; a malformed block is left in * the body untouched. * * @param raw - File content * @returns The parsed page */ export declare function parsePage(raw: string): WikiPage; /** * Serialise frontmatter + body back into a file. Keys are written in the * canonical order of {@link WIKI_KB_CONSTANTS.FRONTMATTER_KEYS} first, then * any extra keys, so diffs stay readable. * * @param frontmatter - Fields to write (undefined values are dropped) * @param body - Markdown body * @returns File content */ export declare function serializePage(frontmatter: Partial, body: string): string; /** * Apply the retention gate to a page write: `title`, a non-empty `summary` * and a valid `keep_because` are required. Returns null when the page * passes. * * @param fm - Frontmatter the writer supplied * @returns A refusal describing what is missing, or null */ export declare function checkRetention(fm: Partial): RetentionRefusal | null; /** * The single index line for a page: `- [title](path) — summary`, with a * `⟶ superseded by ` marker when applicable. * * @param relativePath - Vault-relative page path * @param fm - The page's frontmatter * @returns One markdown list line */ export declare function indexLineFor(relativePath: string, fm: Partial): string; /** * Whether a viewer role may read a page. No `visibility` list = public * within the instance; a canonical role (owner/orchestrator) always may. * * @param fm - Page frontmatter * @param viewerRole - Role of the reader, or undefined for the owner/UI * @returns True when readable */ export declare function isVisibleTo(fm: Partial, viewerRole?: string): boolean; /** * Collapse whitespace and cut to a maximum length (with an ellipsis). * * @param value - Text * @param max - Maximum characters * @returns One line */ export declare function oneLine(value: string, max: number): string; //# sourceMappingURL=wiki-page.d.ts.map