/** * One memory as one Markdown file: YAML frontmatter, a blank line, the body. * * ```markdown * --- * name: tests-need-a-built-sdk * description: The CLI's tests import the SDK's dist, so build it first * type: feedback * status: active * createdAt: 2026-09-21T09:30:00.000Z * updatedAt: 2026-09-21T09:30:00.000Z * tags: ["testing"] * id: 0b6c2a4e-… * --- * * Run `pnpm -r build` before `pnpm --filter @namzu/cli test`. * * Why: the CLI resolves `@namzu/sdk` through its package exports. * How to apply: after any SDK change, before trusting a CLI failure. * ``` * * **Deliberately not a YAML parser**, for the reason `utils/frontmatter.ts` * gives: a reader that half-understands YAML produces a value that passes * validation and means nothing. That reader cannot be reused here because it * refuses lists and mappings by design, and a memory has tags and metadata. * This one reads exactly three value spellings — a plain scalar, a * double-quoted JSON value (string, array or object; JSON is YAML's flow * syntax), a single-quoted YAML string — and a block list of those under a * key with no value. A value opening with `[` or `{` that is not JSON is read * as the plain string it was written as, so a field that needs a list or an * object refuses it by type and a description like `[WIP] notes` just works. * Everything else is refused with the file and line, as is an unknown or * repeated key: a key this build does not know is a field it * would silently drop on the next write. * * The writer only emits what the reader reads, so every file this store * writes parses back to the same record, body byte for byte. */ import type { MemoryStatus, MemoryType } from '../../types/memory/index.js'; /** Keys this build reads and writes, in the order it writes them. */ export declare const MEMORY_FRONTMATTER_KEYS: readonly ["name", "description", "type", "status", "createdAt", "updatedAt", "tags", "id", "title", "summary", "format", "metadata", "schemaVersion"]; export type MemoryFrontmatterKey = (typeof MEMORY_FRONTMATTER_KEYS)[number]; export type FrontmatterScalar = string | number | boolean | null; export type FrontmatterJson = FrontmatterScalar | readonly FrontmatterJson[] | { readonly [key: string]: FrontmatterJson; }; export interface ParsedMemoryFile { /** Plain scalars arrive as strings; the caller decides what each key's string means. */ readonly values: ReadonlyMap; readonly body: string; } export declare class MemoryFileFormatError extends Error { readonly file: string; readonly reason: string; readonly line?: number | undefined; constructor(file: string, reason: string, line?: number | undefined); } /** * Split a memory file into frontmatter values and body. * * The body is everything after the closing fence, less ONE leading newline * (the blank line the writer puts there) and ONE trailing newline, `\n` or * `\r\n` (the one the writer adds; it writes `\r\n` after a body ending in * `\r`). Removing exactly one of each, not trimming, is what makes a body * that itself begins or ends with blank lines, or with a `\r`, round-trip. */ export declare function parseMemoryFile(raw: string, file: string): ParsedMemoryFile; export interface MemoryFileFields { readonly name: string; readonly description: string; readonly type: MemoryType; readonly status: MemoryStatus; readonly createdAt: number; readonly updatedAt: number; readonly tags: readonly string[]; readonly id: string; readonly title: string; readonly summary: string; readonly format: 'text' | 'markdown' | 'json'; readonly metadata?: Record; } /** * The file for one memory. Fields that repeat another are left out — a title * equal to the name, a summary equal to the description, the default format — * so an ordinary file carries the reference shape and nothing else. */ export declare function formatMemoryFile(fields: MemoryFileFields, body: string): string; //# sourceMappingURL=markdown-format.d.ts.map