@ai-coach/vault-adapter-fs
The vault's files on your disk. createFsNoteStore(root) is the NoteStore the vault reads and writes through; it is the only code that opens vault files. The package also decides which folder is your vault, and makes note versions and new ids. You change it when the vault's file handling or root resolution changes.
What it does not do
- No vault rules. Which notes go where, previews and version checks live in
vault-application; this package only lists, reads, writes and moves files. - No following symlinks. A symlinked folder is listed as neither file nor folder, so a scan never leaves the vault.
- Only Node built-ins. Nx boundaries (
adapter:vault-fs) allownode:*imports and no npm package.
Architecture fit
- Scope:
scope:vault - Style:
architecture:hexagonal(type:adapter,adapter:vault-fs) - Depends on:
@ai-coach/vault-application(theNoteStoreport) - Used by:
@ai-coach/vault-mcp-server,@ai-coach/vault-view-server(their composition roots)
[server compose.ts] ──▶ resolveVaultForProcess ──▶ vault root
└─▶ createFsNoteStore(root) ──implements──▶ NoteStore ──▶ node:fs
Internal architecture & rules
fs-store.tsimplementsNoteStoreonnode:fs, async only.- It never overwrites by accident. A new note is created only if nothing is there, and a move links the file to its new place before removing the old one.
root.tsandprocess-root.tsresolve the vault:--vault, elseDOCS_MCP_VAULT, elsevault.rootin~/.config/docs-mcp/config.json. A vault inside a folder with areasonry.config.jsonordocs-mcp.config.json(a knowledge-base workspace) is refused.node-crypto.tsgivessha256Hexfor note versions andrandomHexfor new ids.- No comments in source code (DEC-AIC-0011).
Public surface
createFsNoteStore— theNoteStorepassed tocreateVaultasdeps.store.resolveVaultForProcess,resolveVaultRoot,parseVaultFlags,parseViewFlags— find the vault from flags, environment and config.sha256Hex,randomHex— passed tocreateVaultasdeps.digestanddeps.randomHex.
How you point the servers at your vault is in the configuration guide.
How to extend it
- Change the
NoteStoreport invault-applicationfirst if the store needs a new operation. - Implement it in
src/lib/fs-store.ts, keeping writes refuse-if-present and moves link-then-unlink. - Cover it in
src/lib/fs-store.spec.tsagainst a temporary directory. - Run
npm exec nx test @ai-coach/vault-adapter-fsandnpm exec nx lint @ai-coach/vault-adapter-fs.
Running & testing
npm exec nx test @ai-coach/vault-adapter-fs
npm exec nx lint @ai-coach/vault-adapter-fs
npm exec nx typecheck @ai-coach/vault-adapter-fs
npm exec nx build @ai-coach/vault-adapter-fs
Each spec runs against its own temporary directory, never a real vault.
Key ADRs
- DEC-AIC-0052 — defines the async
NoteStoreport and keepsnode:fsin this adapter. - DEC-AIC-0061 — both vault servers compose this store and resolve the vault the same way.
- DEC-AIC-0051 — one adapter per outside dependency, each with its own import whitelist.