/** * CRUD ops over `//.md` files. The actual * vault path is provided by the caller (resolved from cortex.yaml's * obsidian config); this module is a pure file-layer over markdown + * frontmatter, no engram coupling. Tests inject a tmp dir as * `dir.notesDir`. * * Listing federates over both surfaces: * - `cortex` notes: editable from the dashboard, written to the * cortex-notes subdir with a strict frontmatter contract. * - `obsidian` notes: read-only — anywhere else in the vault, with * loose frontmatter (whatever Obsidian writes). The dashboard * surfaces these so the user sees a single unified list. */ export interface NotesRepo { /** * Absolute path to the obsidian vault root. When omitted, the * federated listing skips the obsidian walk and only returns * cortex-authored notes — used by unit tests that don't care * about the broader vault. */ vaultPath?: string; /** Absolute path to the cortex-notes subdirectory inside the vault. */ notesDir: string; /** Directory names to skip during the vault walk (`.obsidian`, etc.). */ ignoreDirs?: ReadonlySet; } export interface CreateNoteInput { title: string; body: string; project?: string; tags?: string[]; /** Inject for tests. Defaults to `() => new Date()`. */ now?: () => Date; } export interface NoteHandle { slug: string; path: string; } export interface NoteSummary { /** * Stable identifier for the note. For cortex notes this is the * slug from frontmatter (and also `.md` filename). For * obsidian notes this is the vault-relative POSIX path with the * `.md` extension stripped — used to fetch the body via note_get. */ id: string; /** * Backwards-compat: cortex notes still expose a `slug` field * matching `id`. Obsidian notes leave it undefined — the dashboard * keys on `id` for both kinds. */ slug?: string; title: string; project?: string; tags?: string[]; updated: string; preview: string; /** * `cortex` — round-trippable through the dashboard editor (lives * in the cortex-notes subdir with our strict frontmatter). * `obsidian` — read-only; user authored elsewhere in the vault. */ kind: "cortex" | "obsidian"; /** Vault-relative POSIX path. Only set for obsidian-kind notes. */ relativePath?: string; } export declare function ensureNotesDir(repo: NotesRepo): void; export declare function createNote(repo: NotesRepo, input: CreateNoteInput): NoteHandle; export interface UpdateNoteInput { slug: string; title?: string; body?: string; project?: string; tags?: string[]; now?: () => Date; } export interface UpdateNoteResult { slug: string; path: string; /** True when the file actually changed; false when the patch was a no-op. */ changed: boolean; } export declare function updateNote(repo: NotesRepo, input: UpdateNoteInput): UpdateNoteResult; export declare function deleteNote(repo: NotesRepo, slug: string): { slug: string; path: string; deleted: boolean; }; /** * Federated listing across the whole vault. * * cortex/.md — strict frontmatter, dashboard-editable * anywhere else — loose frontmatter, read-only in dashboard * * Cortex notes are cheap to list (one flat dir, strict shape). * Obsidian notes require a recursive walk; we cap at `MAX_FILE_BYTES` * to skip huge dumps and respect `ignoreDirs` so we don't recurse * into `.obsidian/` plugin junk. */ export declare function listNotes(repo: NotesRepo, opts?: { project?: string; limit?: number; }): NoteSummary[]; export interface NoteRef { kind: "cortex" | "obsidian"; /** For cortex notes — slug. */ slug?: string; /** For obsidian notes — vault-relative POSIX path. */ relativePath?: string; } export interface NoteRead { id: string; kind: "cortex" | "obsidian"; title: string; body: string; project?: string; tags?: string[]; updated: string; /** Vault-relative POSIX path. Always set so the UI can deep-link. */ relativePath: string; } /** * Read the full body + metadata of a single note. The dashboard * editor needs this — `listNotes` only returns previews. * * Throws when the file is missing or unreadable. */ export declare function getNote(repo: NotesRepo, ref: NoteRef): NoteRead; //# sourceMappingURL=repo.d.ts.map