Skip to main content

@ai-coach/vault-domain

Pure rules and models of the life vault. This package defines how a vault is laid out and what its notes mean: the PARA folders, wikilinks and link graphs, how a book is read and distilled into concept notes, sparring sessions, mastery and the climb, habits, Obsidian Tasks lines, and how projects, workstreams, areas, and plans fit together. Change this package when a vault rule or data model changes.

What it does not do​

  • No I/O or Node built-ins. Never read files, spawn processes, or import Node built-ins or external npm packages here; ESLint enforces this boundary.
  • No YAML parsing, PDF reading, or full-text search. Callers pass a FrontmatterParser, VaultListing, or VaultTree in from adapters.
  • No cross-scope imports. Only @ai-coach/util-path is allowed; scope:coach and scope:vault-view cannot be imported here.

Architecture fit​

  • Scope: scope:vault
  • Style: architecture:hexagonal (type:domain)
  • Depends on: @ai-coach/util-path
  • Used by: @ai-coach/vault-application, @ai-coach/vault-adapter-markdown, @ai-coach/vault-adapter-view, @ai-coach/vault-mcp-server
[Vault application & adapters] ──▶ [@ai-coach/vault-domain] ──▶ [@ai-coach/util-path]

Internal architecture & rules​

  • Five folders under src/lib/, named after the vault server's tool groups (DEC-AIC-0064), each re-exported through its own index.ts:
    • note/ — one note: PARA location (para), frontmatter (md), links, coach_id identity, and VaultNote parsing.
    • vault/ — the whole vault: VaultListing, VaultTree snapshots, and the link graph.
    • reading/ — raw-resource paths, mark parsing and editing, reading progress, quote location and passage checks, and the concept-note format.
    • climb/ — sparring sessions, mastery, the tier-2 payload, and the climb's evidence, progress and structure rules.
    • planning/ — PARA plan paths and periods, task and habit parsing, task lines, the planning model, and assembling it from the vault.
  • One-way dependencies: note/ depends on nothing else here; vault/ on note/; reading/ on note/ and vault/; climb/ on note/ and reading/; planning/ on note/ and vault/. Inside a folder, import siblings directly, never the folder's own index.ts.
  • Pure functions and injected inputs: Every rule is deterministic. Pass dates as YYYY-MM-DD strings and pass vault snapshots via VaultListing or VaultTree.
  • No comments in source code: Follow DEC-AIC-0011.

Public surface​

  • PARA & note parsing — PARA_FOLDERS, PLANS_ROOT, classify, noteFromContent, VaultNote, FrontmatterParser.
  • Links, tree & graph — extractLinks, VaultTree, noteResolver, buildVaultGraph.
  • Reading — RAW_ROOT, parseMarks, applyMark, bookProgress, chapterProgress, withoutSummaries, locateQuote, checkPassages, conceptOf, renderConcept.
  • Climb, sessions & mastery — CLIMB_STEPS, climbOf, structureOf, compareStructure, SessionRecord, renderSession, parseSession, histories, historyOf, tier2Payload.
  • Planning & tasks — planning, parseTasks, TaskLine, planOf, planPathOf, periodOf, isoWeekOf, parseHabits, isHabitDue.

See the glossary for definitions of vault terms such as PARA, workstreams, and sparring sessions.

How to extend it​

  1. Add or update the pure domain rule and its TypeScript types in the matching folder under src/lib/ (note/, vault/, reading/, climb/ or planning/), and export it from that folder's index.ts.
  2. Re-export the new symbols from src/index.ts.
  3. Add unit tests next to the rule (src/lib/<folder>/*.spec.ts) covering normal and edge cases.
  4. Run npm exec nx test @ai-coach/vault-domain and npm exec nx lint @ai-coach/vault-domain.

Running & testing​

npm exec nx test @ai-coach/vault-domain
npm exec nx lint @ai-coach/vault-domain
npm exec nx typecheck @ai-coach/vault-domain
npm exec nx build @ai-coach/vault-domain

Tests run in memory with Vitest using plain strings and in-memory VaultListing fixtures, with zero disk access.

Key ADRs​

  • DEC-AIC-0051 — Establishes the workspace hexagonal boundaries and scope:vault / type:domain tags.
  • DEC-AIC-0052 — Separates pure vault domain rules from application use cases and I/O adapters.
  • DEC-AIC-0064 — Groups the domain by the vault server's tool groups and moves the pure reading and climb rules here.
  • DEC-AIC-0011 — Requires self-explanatory code without inline comments.