UNPKG

@phren/cli

Version:

Knowledge layer for AI agents - CLI, MCP server, and data layer

69 lines (68 loc) • 3.27 kB
/** * Pages: one markdown file per subject under `<store>/<project>/reference/pages/<slug>.md`. * * Dreaming writes these instead of growing shared files (one page per subject * beats a big FINDINGS.md). A page is frontmatter (`title`, `summary`), then a * body that links other pages as `[[slug]]` and cites findings as `fid:xxxxxxxx`. * * Search needs no extra wiring: the indexer globs every `**\/*.md` in a project * (DEFAULT_INDEX_POLICY.includeGlobs) and `classifyFile` types anything under a * `reference/` segment as `reference`, so a page is found like any archive doc * on the next index build. */ export declare const PAGES_DIR: string; /** A page is a summary of one subject, not an archive. Larger pages are refused. */ export declare const MAX_PAGE_BYTES: number; export declare class PageError extends Error { constructor(message: string); } export interface PageMeta { slug: string; title: string; summary: string; /** Page slugs this page links to (`[[slug]]`), deduplicated, in order of appearance. */ links: string[]; /** Finding ids the page cites (`fid:xxxxxxxx`). */ fids: string[]; path: string; } export interface Page extends PageMeta { body: string; markdown: string; } export declare function isValidPageSlug(slug: string): boolean; /** * Accepts a bare slug or the changeset's page reference (`reference/pages/<slug>.md`) * and returns the slug. Throws on anything else, including traversal attempts. */ export declare function pageSlug(ref: string): string; /** `[[slug]]` targets in a body, deduplicated. Invalid targets are kept verbatim so the link check reports them. */ export declare function extractPageLinks(body: string): string[]; export declare function extractPageFids(body: string): string[]; /** * Puts the markdown in page shape: frontmatter with a title and a summary * (taken from the model's frontmatter, else the first heading and paragraph), * an `updated` date, and the body. `links` the caller declares but the body * does not mention are appended as a "Related" line so they stay visible. */ export declare function normalizePage(slug: string, markdown: string, links: string[], now?: Date): string; export declare function listPages(store: string, project: string): PageMeta[]; export declare function readPage(store: string, project: string, slugOrRef: string): Page | null; /** * Writes (creates or replaces) one page. The write is locked and atomic and * goes to the audit log. Broken links do not stop the write; they are returned * so the caller can record them beside the change. */ export declare function writePage(store: string, project: string, slug: string, markdown: string, links: string[]): Promise<{ path: string; brokenLinks: string[]; }>; export interface PageLinkReport { slug: string; /** `[[target]]` links with no page (or an invalid slug). */ brokenLinks: string[]; /** Cited fids that are not in the given set of known finding ids. Empty when no set is given. */ unknownFids: string[]; } /** Link check across every page of a project. Only pages with a problem are returned. */ export declare function checkPageLinks(store: string, project: string, knownFids?: Iterable<string>): PageLinkReport[];