@ai-coach/vault-adapter-pdf
Reads the text of a PDF book. readPdf is the PdfReader behind the convert_raw tool, built on pdf.js. It returns each page's text, the title and author, and the outline with page numbers. You change this package when PDFs need to be read differently.
What it does not do
- No splitting into chapters. Turning pages into chapter notes is the application's
planConvertinvault-application. - No writing. It reads a PDF's bytes and returns text; the vault writes the notes.
- Only
pdfjs-dist. Nx boundaries (adapter:vault-pdf) forbid any other external import.
Architecture fit
- Scope:
scope:vault - Style:
architecture:hexagonal(type:adapter,adapter:vault-pdf) - Depends on:
@ai-coach/vault-application(thePdfReaderport) - Used by:
@ai-coach/vault-mcp-server,@ai-coach/vault-view-server(their composition roots)
[convert_raw] ──▶ planConvert (vault-application) ──▶ PdfReader ◀──implements── readPdf ──▶ pdf.js
Internal architecture & rules
- One function,
readPdfinsrc/lib/pdf-reader.ts, passed tocreateVaultasdeps.readPdfby each server'scompose.ts. - Pages keep their numbers. Page texts and outline entries carry the PDF's page numbers, which later anchor quotes to pages (DEC-KI-0059).
- No comments in source code (DEC-AIC-0011).
Public surface
readPdf— thePdfReaderthe vault'sconvertRawuses.
How to extend it
- Change the
PdfReaderport invault-applicationfirst if the result needs more fields. - Fill them in
readPdfinsrc/lib/pdf-reader.ts. - Cover the change in the conversion integration tests in
vault-mcp-server, which convert real PDFs. - Run
npm exec nx test @ai-coach/vault-mcp-serverandnpm exec nx lint @ai-coach/vault-adapter-pdf.
Running & testing
npm exec nx test @ai-coach/vault-adapter-pdf
npm exec nx lint @ai-coach/vault-adapter-pdf
npm exec nx typecheck @ai-coach/vault-adapter-pdf
npm exec nx build @ai-coach/vault-adapter-pdf
It has no specs of its own: the conversion tests in vault-mcp-server run real PDFs through it.
Key ADRs
- DEC-KI-0059 — a PDF is converted once into page-headed Markdown notes.
- DEC-AIC-0052 — puts PDF reading behind the
PdfReaderport in its own adapter.