@ai-coach/cli
The terminal entry point and composition root for coach. It loads your configuration, wires the real adapters into the application use cases, and drives interactive coaching sessions in the terminal. Touch this package when you change command-line flags, terminal prompts, or how commands are registered.
What it does not do
- No coaching rules or scheduling logic. Review intervals, mastery rules, and session state live in
@ai-coach/domainand@ai-coach/application. - No direct vault file I/O or LLM calls. The CLI reaches your vault only through
@ai-coach/adapter-vault-mcp, local models through@ai-coach/adapter-ollama, and the online judge through@ai-coach/adapter-gemini. - No cross-scope or unapproved external imports. Enforced by Nx/ESLint:
scope:coachcannot importscope:vaultorscope:vault-view, andapp:clionly allowszodandnode:*external imports.
Architecture fit
- Scope:
scope:coach - Style:
architecture:hexagonal(type:app,app:cli) - Depends on:
@ai-coach/domain,@ai-coach/application,@ai-coach/adapter-ollama,@ai-coach/adapter-gemini,@ai-coach/adapter-vault-mcp,@ai-coach/adapter-local-state - Used by: Terminal users invoking the
coachbinary
[Terminal user] ──▶ [@ai-coach/cli] ──▶ [@ai-coach/application] ──▶ [@ai-coach/domain]
│
├──▶ [@ai-coach/adapter-vault-mcp]
├──▶ [@ai-coach/adapter-ollama]
├──▶ [@ai-coach/adapter-gemini]
└──▶ [@ai-coach/adapter-local-state]
Internal architecture & rules
- Domain-grouped registry:
DOMAINSinsrc/lib/cli.tsis the single source of truth for command dispatch, domain-scoped help (coach help <domain>), and full--helpoutput. Flat short aliases (such ascoach spar,coach read,coach climb) resolve through the same registry. Commands declare whether they require a composedCoachinstance (needsCoach: falseforvault view). - One module per command, grouped by domain: Commands live under
src/lib/commands/<domain>/<command>.tsacross six domains (progress,source,learn,exam,teach,vault) with colocated*.spec.tstests. - Shared terminal helpers (
src/lib/terminal/): Pure terminal primitives with zero dependency onCoach— raw I/O and colors (io.ts), interactive prompts andUsageError(prompts.ts), and pure string formatters (format.ts). - App wiring (
src/lib/):config.tsloads and validates configuration, andcomposition.tswires adapters into use cases withAdapterOverridesso tests can inject fakes. Vault filing previews (previewThenApply,showFilingPlan) live with the vault commands insrc/lib/commands/vault/filing.ts. - Preview before write & exit codes: Every vault or session write previews its plan and asks for confirmation. CLI argument errors exit
2; known domain, application, usage, config, or offline errors print cleanly and exit1. Source code carries no comments (DEC-AIC-0011).
Public surface
- Progress (
coach progress/coach climb): cross-stage overview tracking the seven-step climb acrosssource,learn,exam, andteach. - Source (
coach source):read,synthesize,group— take in books or articles, distill concept notes, and group concepts. - Learn (
coach learn):generate,elaborate,study— actively encode concepts and close failed gaps. - Exam (
coach exam):due,list,spar,judge— inspect due notes, run offline Tier 1 sparring, and run online Tier 2 judging. - Teach (
coach teach):teach <note>— prove mastery by teaching a naive student and optionally saving a guideline. - Vault (
coach vault):capture,file,archive,init,view— organize PARA folders and open the browser graph view. - Programmatic entry points:
run,DOMAINS,COMMANDS,USAGE,formatDomainUsage,composeCoach,loadConfig,Terminal,ProcessTerminal,UsageError.
See the commands guide and configuration guide for full references.
How to extend it
- Create
src/lib/commands/<domain>/<name>.tsusing shared helpers fromsrc/lib/terminal/, and export it fromsrc/lib/commands/index.ts. - Add a
CommandSpecentry under the matching domain inDOMAINSinsidesrc/lib/cli.tsso dispatch, domain help, and--helpoutput stay in sync. - Add a colocated
src/lib/commands/<domain>/<name>.spec.tsusing a scriptedTerminaland stubbedCoachuse cases. - Run
npm exec -- nx run-many -t lint typecheck test build -p @ai-coach/cliand update commands.md if the user-facing surface changed.
Running & testing
From the repository root, after building (npm run coach loads .env from the root):
npm run coach -- <domain> <command> [options]
npm run coach # show what is due today (coach exam due)
npm run coach -- source read # read a chapter and take notes
npm run coach -- exam spar --style devil # spar due notes in devil's-advocate style
npm run coach -- progress # inspect the seven-step climb across all stages
See the commands guide for the full command and option reference.
npm exec nx lint @ai-coach/cli
npm exec nx typecheck @ai-coach/cli
npm exec nx test @ai-coach/cli
npm exec nx build @ai-coach/cli
Tests drive commands with a scripted Terminal and stubbed use cases, so they need no vault, Ollama, or Gemini.
Key ADRs
- DEC-AIC-0008 — Enforces hexagonal boundaries so the CLI acts as the sole composition root for
scope:coach. - DEC-AIC-0009 — Establishes the terminal interface and the preview-before-write rule for all mutations.
- DEC-AIC-0051 — Places
@ai-coach/cliinapps/withscope:coach,architecture:hexagonal, andtype:apptags. - DEC-AIC-0060 — Defines the eight-section architectural README format and Docusaurus link rules.