@ai-coach/vault-adapter-markdown
Reads a note's YAML frontmatter. parseMatter is the FrontmatterParser the vault uses, built on gray-matter. It splits a note into its frontmatter and its body. You change this package only if notes need to be parsed differently.
What it does not do
- No meaning. It returns raw frontmatter values;
vault-domainnormalises them, for example dates toYYYY-MM-DD. - No file access. It parses text it is given; reading files is
vault-adapter-fs's job. - Only
gray-matter. Nx boundaries (adapter:vault-markdown) forbid any other external import.
Architecture fit
- Scope:
scope:vault - Style:
architecture:hexagonal(type:adapter,adapter:vault-markdown) - Depends on:
@ai-coach/vault-domain(theFrontmatterParserport) - Used by:
@ai-coach/vault-mcp-server,@ai-coach/vault-view-server(their composition roots)
[composeVault] ──▶ parseMatter ──implements──▶ FrontmatterParser (vault-domain)
Internal architecture & rules
- One function,
parseMatterinsrc/lib/markdown.ts, wrappinggray-matter. - A thin wrapper. It returns
gray-matter's data and content unchanged; any interpretation of the values happens in the domain. - No comments in source code (DEC-AIC-0011).
Public surface
parseMatter— theFrontmatterParserpassed tocreateVaultasdeps.frontmatter.
How to extend it
- Change the port in
vault-domainfirst if the parser's contract changes. - Adjust
parseMatterinsrc/lib/markdown.ts. - Cover the case in
src/lib/markdown.spec.ts. - Run
npm exec nx test @ai-coach/vault-adapter-markdownandnpm exec nx lint @ai-coach/vault-adapter-markdown.
Running & testing
npm exec nx test @ai-coach/vault-adapter-markdown
npm exec nx lint @ai-coach/vault-adapter-markdown
npm exec nx typecheck @ai-coach/vault-adapter-markdown
npm exec nx build @ai-coach/vault-adapter-markdown
The specs parse note strings in memory with Vitest.
Key ADRs
- DEC-AIC-0052 — puts frontmatter parsing behind a port and keeps
gray-matterin this adapter. - DEC-AIC-0051 — one adapter per outside dependency, each with its own import whitelist.