Skip to main content

@ai-coach/vault-view-util

Pure, framework-free TypeScript helpers for the vault view. It holds graph force-layout and camera math, markdown/distillation parsers, Obsidian and graph URI builders, plan/climb formatters, theme constants, and keyboard shortcut guards.

What it does not do​

  • No Angular, RxJS, or DOM side effects. Everything here is pure TypeScript with zero framework dependencies so it can be imported by any scope:vault-view layer and tested directly in Node.
  • No data-access, ui, or feat imports. @nx/enforce-module-boundaries restricts type:util to type:util only.
  • No network or filesystem I/O. HTTP calls belong in @ai-coach/vault-view-data-access.

Architecture fit​

[app / data-access / ui / feat-graph / feat-plans / feat-climb]
│
▼
[@ai-coach/vault-view-util]

Internal architecture & rules​

  • Feature-grouped pure modules: Helpers are grouped by concern under src/lib/ (theme, shortcuts, links, plans, climb, markdown, graph, graph-layout, distill) with colocated *.spec.ts unit tests.
  • Deterministic math and parsing: Force layout, camera framing, page-ring geometry, and markdown/distillation block parsing are deterministic pure functions taking plain values and returning new data structures.
  • Code hygiene: Zero comments in source code (DEC-AIC-0011) and strict TypeScript typing (tsc --noEmit).

Public surface​

  • Theme & shortcuts: Theme mode types and defaults, global shortcut target guards (isGlobalShortcut).
  • Links & formatting: obsidianUri, graphNoteHref, sketchImageHref, stripWikilinks, goalDisplayText, pluralize.
  • Graph & layout: Graph bucket/kind/mastery/workstream/stage tables, node fill helpers, computeForceLayout, placeBookChaptersAndReaders, computePageRing, viewForBox, zoomAroundPoint, interpolateView, SVG shape paths.
  • Distillation, markdown, plans & climb: parseNoteBlocks, parsePageBlocks, splitPageSummary, distillMarkLabel, PLAN_ZOOM_OPTIONS, columnShortLabel, worstGoalStatus, CLIMB_STEPS, CLIMB_STEP_HEADERS, stairBox.

How to extend it​

  1. Add a pure function or constant to the matching module under src/lib/ (or create a new focused module).
  2. Re-export it from src/index.ts.
  3. Add Vitest unit tests in a sibling <module>.spec.ts file covering normal and edge cases.
  4. Run npm exec nx test @ai-coach/vault-view-util, npm exec nx lint @ai-coach/vault-view-util, and npm exec nx typecheck @ai-coach/vault-view-util.

Running & testing​

Unit tests run directly in Vitest with no DOM, Angular TestBed, or network mocks required.

npm exec nx test @ai-coach/vault-view-util
npm exec nx lint @ai-coach/vault-view-util
npm exec nx typecheck @ai-coach/vault-view-util

Key ADRs​

  • DEC-AIC-0059 — Establishes the Angular layered frontend layout for the vault view.
  • DEC-AIC-0062 — Codifies util layer boundaries and Nx lint/typecheck/test guardrails.
  • DEC-AIC-0051 — Defines workspace tags and @nx/enforce-module-boundaries constraints.
  • DEC-AIC-0060 — Governs the eight-section package README structure and Docusaurus ingestion.