Skip to main content

@ai-coach/util-path

Paths without Node. Pure posix path helpers for code that may not import node:path, such as a domain or application library. You change this package only if a library needs a path helper it doesn't have yet.

What it does not do​

  • No file system access. It only works on path strings; nothing here touches the disk.
  • No Windows paths. Vault and note paths are always /-separated, so only posix behaviour is offered.
  • No dependencies. It imports nothing, so any scope can use it without pulling anything in.

Architecture fit​

  • Scope: scope:shared
  • Style: type:util
  • Depends on: nothing
  • Used by: @ai-coach/vault-domain, @ai-coach/vault-application
[vault-domain / vault-application] ──▶ [@ai-coach/util-path]

Internal architecture & rules​

  • One object, posix, in src/lib/posix.ts, with join, dirname, basename, extname, normalize, relative, resolve and isAbsolute.
  • Same results as node:path. Every helper behaves exactly like node:path's posix function of the same name, edge cases included. The specs pin that.
  • No comments in source code (DEC-AIC-0011).

Public surface​

  • posix — the path helpers:
import { posix } from '@ai-coach/util-path';

posix.join('3.Resources', 'Book', 'Idea.md');
// → '3.Resources/Book/Idea.md'
posix.basename('3.Resources/Book/Idea.md', '.md');
// → 'Idea'

How to extend it​

  1. Add the helper to posix in src/lib/posix.ts, matching node:path's posix behaviour.
  2. Add spec cases in src/lib/posix.spec.ts that compare it with node:path for normal and edge inputs.
  3. Run npm exec nx test @ai-coach/util-path and npm exec nx lint @ai-coach/util-path.

Running & testing​

npm exec nx test @ai-coach/util-path
npm exec nx lint @ai-coach/util-path
npm exec nx typecheck @ai-coach/util-path
npm exec nx build @ai-coach/util-path

The specs run with Vitest and compare each helper with node:path itself.

Key ADRs​

  • DEC-AIC-0052 — moves the posix helpers into this pure shared util so the vault domain and application need no Node.
  • DEC-AIC-0051 — defines the scope:shared and type:util tags and what may import them.