@arki/cli — Laws
For @arki/[email protected] · source AGENTS.md
AGENTS.md = laws, docs/agent-guide.md = tasks, llms.txt = map.
@arki/cli — Laws
Rules for code in this package and for programs built on it. @arki/dot's
dot command runs on this package, so a change here changes dot too.
Laws
- Types are inferred, never written. Input, output and services come
from
defineCommand. A consumer writes no type arguments. mainnever exits the process.main(argv, io)returns the exit code and writes only to theiofunctions it was given.run(program)is the only process boundary.- Failures are values.
runreturns a failure from@arki/failure; it does not throw one. A throw is a bug: exit1,cli.bug. - Exit codes are API.
0ok,1bug,2usage,3failure,4retry,5input required,130interrupted. They never change meaning. - The envelope always has every key.
arki.cli/1:ok,command,data,error,meta. A missing key would break everyjqfilter. - Help never runs a command.
--helpand--versionimport at most one lazy level of the tree and never callrun. - Stdout belongs to the envelope. Command output goes through the
returned data or
ui.out, neverconsole.logorprocess.stdout. - No logging setup. The package never configures
@arki/log; the bin file does.
Changing this package
- A new framework failure gets a
defineFailurewith JSDoc (summary,@fix,@verify), an exit code inFAILURE_EXIT_CODES, and a row in the READMEFailure behaviourtable. - A change to the envelope or to exit codes is breaking for
dotand every agent that parses it. Runpackages/dot's tests too. - New global flags are reserved names: check that no consumer uses them as input keys.
Consuming it
- Start with the README Quick start, then the agent guide task map.
- Test a command with
program.main(argv, { stdout })and assert on the parsed envelope and the exit code.
Verify
Run in packages/cli:
bun run build
bun run test:docs
bun run typecheck
bun run test
bun run test:runtimes
bun ../../tooling/library/src/llms.ts --check
bun ../../tooling/library/src/error-index.tsThe last line must report 0 without @fix/@verify.