/** * obsidian-parser — pure functions for parsing an Obsidian vault on disk. * * No DB access, no MCP, no I/O side effects other than fs reads. Composed by * the `obsidian-vault-import` MCP tool in the memory plugin. * * Doctrine: every regex is linear-time (no catastrophic backtracking), every * function is deterministic. The agent never calls this code; the server does. */ export interface ParsedPage { /** Path relative to the vault root, with forward slashes. The MERGE natural key. */ obsidianPath: string; /** Filename without `.md` — the default wikilink target form. */ title: string; /** Aliases declared in frontmatter (`aliases:` array). */ aliases: string[]; /** Tag tokens (without `#`), unioned from frontmatter `tags:` and inline `#tag` body matches. */ tags: string[]; /** Body text (frontmatter stripped). Stored verbatim. */ body: string; /** SHA-256 of the on-disk file bytes — idempotency key. */ contentHash: string; /** Detected daily-note date (YYYY-MM-DD) or null. */ noteDate: string | null; /** Wikilinks emitted by this page. */ wikilinks: WikilinkOccurrence[]; /** Embedded attachments declared via `![[file.png]]` or `![alt](file.png)`. */ attachments: AttachmentOccurrence[]; /** Last-modified timestamp from fs stat — used for modified-since filtering. */ mtimeMs: number; } export interface WikilinkOccurrence { /** The exact text inside `[[…]]` before any alias `|`. May contain `#anchor`. */ rawTarget: string; /** Target after stripping `#anchor`. */ target: string; /** Anchor portion (after `#`) or null. */ anchor: string | null; /** Alias text after `|`, or null when absent. The display text. */ alias: string | null; } export interface AttachmentOccurrence { /** Path as written in the markdown. May be relative to the page or to the vault root. */ rawPath: string; /** Resolved path relative to vault root, normalised. May not exist on disk yet. */ resolvedPath: string; /** Display alt text (from `![alt](path)` form) or null for embed-syntax `![[file]]`. */ alt: string | null; } export interface VaultWalkOptions { /** Filter: only pages whose path starts with one of these folder prefixes. */ folderPrefixes?: string[]; /** Filter: only pages whose tags intersect with this set. */ tagFilter?: string[]; /** Filter: only pages modified at or after this epoch-ms. */ modifiedSinceMs?: number; } /** * Walk the vault directory and return one ParsedPage per `.md` file that * survives the optional filter set. * * Path-traversal defence: paths containing `..` segments are rejected at * entry. The `vaultRoot` passed in is assumed to have already been verified * by the caller as living under the account's archive directory. */ export declare function walkVault(vaultRoot: string, opts?: VaultWalkOptions): Promise; export declare function parsePage(obsidianPath: string, bytes: Buffer, mtimeMs: number): ParsedPage; interface ParsedFrontmatter { raw: string; /** Map of top-level key → raw value string. Arrays are returned as the * block following the key (caller parses per-key). */ fields: Map; } export declare function splitFrontmatter(text: string): { frontmatter: ParsedFrontmatter; body: string; }; export declare function normalizeTag(tag: string): string; export declare function detectDailyNote(obsidianPath: string, fm: ParsedFrontmatter): string | null; export interface VaultIndex { /** Lowercased title (without `.md`) → set of `obsidianPath` candidates. */ byTitle: Map; /** Lowercased alias → set of `obsidianPath` candidates. */ byAlias: Map; } export declare function buildVaultIndex(pages: ParsedPage[]): VaultIndex; /** * Look up a wikilink target inside the vault, returning candidate page paths. * * The target is matched against (a) page titles and (b) declared aliases. * Path-form targets (`Folder/Page`) match directly. Returns an empty array * when no intra-vault candidate exists — the caller falls through to entity * resolution. */ export declare function resolveWikilinkInVault(target: string, index: VaultIndex, knownPaths: Set): string[]; export declare function makeImportId(): string; export {}; //# sourceMappingURL=index.d.ts.map