Docs

@avelonjs

cli

CLI

@avelonjs/cli

@avelonjs/cli is reeve, the official who administers an Avelon app. It is an Ink TUI on Bun that also stays fully scriptable. Reach for it to generate the application tree, sync the Next router, run Bailiff, drain errands, and ask doctor whether a push is safe.

Run reeve without arguments in an interactive terminal to open the TUI. Subcommands, --no-tui, and non-interactive terminals use plain mode.

Installation

bun add -d @avelonjs/cli

Run bunx --no-install reeve --help from the directory where you installed the package. From the Avelon workspace root, use bun packages/cli/src/bin.ts --help. Application package.json scripts resolve the local reeve binary:

{
  "scripts": {
    "dev": "reeve route:sync && bun run --bun next dev",
    "build": "reeve route:sync && bun run --bun next build",
    "check": "reeve doctor"
  }
}

Basic Usage

reeve help make:model
reeve make:model Post -mfcp --resource
reeve route:sync
reeve route:sync --check
reeve bailiff --explain no-orphan-query
reeve doctor

In the TUI, press / to search and ? to see a command's usage. Commands that need a name or path show an example when selected. Use reeve <command> --help for the same information in a script.

Commands that need the app, such as migrate, config:show, event:list, tinker, and doctor, import avelon.config.ts from the current directory first. A configuration the process defined earlier, such as with bun --preload, is kept when the file is absent.

Create an app

reeve new <directory> creates a standalone TypeScript app with a working form and tests. From this checkout, use bun run create:app ../my-app. With a packaged CLI that lists new in its help, you can run it without a checkout:

bunx --package @avelonjs/cli reeve new my-app
cd my-app
bun install
bun run dev

The target must be new or empty (. works). Generated dependencies use the CLI's package scope and version. The command leaves installation and server startup to you.

Generators

reeve make:model Post -mfcp --resource
reeve make:controller PostController --resource
reeve make:request StorePostRequest
reeve make:policy PostPolicy --model=Post
reeve make:ward PostWard --model=Post
reeve make:event PostPublished
reeve make:listener NotifySubscribers --event=PostPublished --queued
reeve make:errand GenerateThumbnail
reeve make:action PublishPost
reeve make:middleware EnsureSubscribed
reeve make:command PruneDrafts
reeve make:view posts/Index
reeve make:auth
reeve make:driver storage r2
reeve make:package billing
reeve make:migration create_posts_table
reeve stub:publish

Every generated file type-checks and passes Bailiff in an app created with reeve new. A model always gets its ward. Reeve adds defineWard, definePolicy, Events.listen (for a listener with --event), and registerErrand calls to registerApp() in app/Providers/AppProvider.ts, and appends migrations to database/migrations/index.ts. It parses those files to add the import and the call. When a file or function is missing, it prints the line to add. Route and middleware lines are printed for you to place.

When the file a generator exists to write is already there, it writes nothing and exits 1. View names are relative paths inside resources/views, such as posts/Index, and produce a .tsx component.

stub:publish ejects templates into stubs/ so you change generated shape without forking the framework.

reeve make:driver storage r2 scaffolds a package with every capability false, methods that throw unimplemented, a wired conformance suite, and a README that already passes docs:check. The certification path is docs/15-driver-authoring.md.

Database, wards, routes, errands

reeve migrate
reeve migrate:rollback
reeve migrate:fresh --seed
reeve migrate:status
reeve schema:pull
reeve db:seed
reeve ward:list
reeve ward:sync
reeve ward:check
reeve ward:explain Post read
reeve route:list
reeve route:sync
reeve errand:work
reeve errand:failed
reeve errand:retry all
reeve errand:flush

Outside the local environment, migrate:fresh refuses to run until --confirm=<environment> names it.

ward:explain Post compiles each rule of app/Wards/PostWard.ts for a guest and an actor (--actor=<id>) and prints the SQL condition and parameters a query receives. ward:sync calls the database driver's syncWards() when it declares rowSecurity: true. route:list --json prints the routes for scripts.

db:seed and route commands exit with an error when a seed or route module fails to load or run. reeve route:sync --check compares the router with routes/web.ts and lists missing, changed, or stale paths. It exits 1 on drift without rewriting files. Run reeve route:sync to repair them.

Doctor and inspect

reeve doctor
reeve bailiff
reeve bailiff --fix
reeve capabilities
reeve config:show
reeve about
reeve event:list
reeve tinker
reeve tinker --execute 'await Post.query().count()'

doctor checks Bailiff, ward coverage, that avelon.config.ts loads, and whether the generated router matches routes/web.ts, then prints the capability matrix. A router mismatch is a warning; the other failures exit 1. event:list prints each registered listener with its delivery, queue, tries, and priority. tinker opens a REPL with the app, its models, DB, Events, and Route loaded; --execute evaluates one expression and awaits it. docs:check lints every package README: required sections, TypeScript code blocks that parse, and every public export in the Method Reference table.

reeve docs:check
reeve docs:check packages/cli
reeve docs:check --workspace

Waive a section or export with an HTML comment in the README:

<!-- docs:check-waiver: section Features -->
<!-- docs:check-waiver: section Introduction -->
<!-- docs:check-waiver: export internalHelper -->

Method Reference

Method / exportSignatureDescription
runReeve(argv, io?) => Promise<number>CLI entry. Opens the TUI or runs a subcommand.
runCommand(command, argv, io) => Promise<number>Runs one command, or prints help for help and --help.
shouldUseTui(argv, io) => booleanTrue for bare TTY invocations without --no-tui.
processIO() => ReeveIOProcess cwd, stdout, TTY, and env.
MENUreadonly MenuItem[]TUI catalog. Every row has a scriptable command.
COMMANDSstring[]Unique command names.
ReeveIOinterfaceTestable IO: cwd, stdout, isTTY, env, optional confirm.
checkPackageDocs(root: string) => Promise<DocsCheckResult>Lints one package README against house style.
runDocsCheck(argv, io) => Promise<number>CLI handler for docs:check, including --workspace.
DocsCheckResultinterfaceroot, ok, and findings from one package lint.
DocsFindinginterfaceOne missing section, unparsed block, or missing export.
makeDriver(io, contract, slug) => Promise<void>Scaffolds a driver package with conformance wired.
DRIVER_CONTRACTSstring[]Contract names make:driver accepts.
DriverContractSpecinterfaceSuite, types, capabilities, and method stubs for one contract.

Testing

Call runReeve with isTTY: false and a captured stdout. Generators write into a temp cwd.

import { runReeve } from '@avelonjs/cli'

const code = await runReeve(['make:model', 'Post'], {
  cwd: tempDir,
  stdout: { write: () => true },
  isTTY: false,
  env: { AVELON_ENV: 'local' },
})
bun test
bun run typecheck