@brunyee-studio/onus-cli
v4.3.1
Published
Official CLI and TypeScript SDK for Onus issue tracking platform
Maintainers
Readme
Onus CLI
The official command-line interface and TypeScript SDK for the
Onus issue tracking platform. It is
generated from the Onus OpenAPI specification via
@openapitools/openapi-generator-cli, so the CLI and its types are always in
sync with the backend API.
The CLI is designed to be equally useful to human developers and autonomous
AI coding agents (Pi, Claude Code, Codex, Cursor, ...). Agent-focused
commands (onus context, onus schema) and deterministic --json output make
it trivial to script and to drive programmatically.
Features
- 🔑
onus auth— store, inspect, and clear your access token and API endpoint. - 🤖 Agent-friendly —
onus context,onus schema, machine-readable--jsonoutput, and auto-JSON detection when stdout is piped. - ✅ Typesafe SDK — the client models and runtime are generated directly from the Onus OpenAPI spec, so the CLI can't drift from the API.
- 📦 Automated publishing — versions, changelog, git tags, GitHub releases,
and npm publishing are handled automatically from Conventional Commits via
semantic-release. - 🧭 Rich terminal output — aligned tables, semantic colors, and clear errors with standardized exit codes.
Installation
Global install
npm i -g @brunyee-studio/onus-cli@latestRun without installing
npx onus --helpFrom a local checkout (workspace build)
pnpm install
pnpm openapi:export # regenerate openapi.json from src/lib/public-api/openapi.ts
pnpm cli:generate # regenerate the typesafe SDK into packages/cli/src/generated
pnpm cli:build # bundle packages/cli/dist/bin.js
node packages/cli/dist/bin.js --helpQuick start
# Authenticate interactively with browser OAuth
onus auth login
# On a machine without a browser (e.g. over SSH), sign in from another device:
# open the printed URL on your laptop or phone and enter the code it shows
onus auth login --device
# Or pass an access token directly (headless/agent mode)
onus auth login --token <your-onus-token>
# Under WSL2 mirror networking, bind the OAuth callback server to 0.0.0.0
# (or set the ONUS_OAUTH_HOST env var instead)
onus auth login --loopback-host 0.0.0.0
# Show the current user
onus me --json
# List issues
onus issue list --status in_progress --json
# List teams
onus team listConfiguration
Settings are resolved with the following precedence (highest wins):
- CLI flags:
-t, --token <token>,-u, --api-url <url> - Environment variables (see table below)
- The persistent config file
Environment variables
| Variable | Purpose | Notes |
| -------------------- | ---------------------- | ------------------------------------------------------------------- |
| ONUS_TOKEN | Access token / API key | Alias: ONUS_API_KEY |
| ONUS_REFRESH_TOKEN | OAuth refresh token | Used for automatic token rotation on expiration |
| ONUS_API_URL | API base URL | Alias: ONUS_BASE_URL; default https://onus.brunyeestudio.com/v1 |
| ONUS_OUTPUT | Force output mode | json enables deterministic JSON output |
Config file
On Unix/macOS, credentials persist to ~/.config/onus/config.json
(${XDG_CONFIG_HOME}/onus/config.json if set). On Windows, they persist to
%APPDATA%\onus\config.json. The file is written with 0600/0700 permissions.
{
"token": "<your-onus-token>",
"apiUrl": "https://onus.brunyeestudio.com/v1"
}Note for agents: prefer passing the token via
ONUS_TOKENso you never persist credentials on a machine — the environment variable is read at the start of each invocation.
Command reference
onus auth — authentication
| Command | Description |
| ---------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| onus auth login | Authenticate interactively via browser OAuth PKCE loopback flow |
| onus auth login --loopback-host <host> | Bind the callback server to a custom host (0.0.0.0 for WSL2 mirror networking); also configurable via ONUS_OAUTH_HOST |
| onus auth login --token <token> | Store an access token directly (optionally --api-url <url>) |
| onus auth login --manual | Authenticate with manual out-of-band authorization code prompt (no browser) |
| onus auth login --device | Sign in from another device with a short code (RFC 8628 device flow); also --no-browser, used automatically over SSH (--browser opts out) |
| onus auth logout | Clear stored credentials |
| onus auth status [--json] | Show masked token, refresh token status, and active API endpoint |
onus context — agent environment snapshot
Emit a structured snapshot of the CLI environment: version, API endpoint, auth state, the authenticated viewer, available resources, capabilities, and quick examples.
onus context --json{
"cliVersion": "1.0.0",
"apiUrl": "https://onus.brunyeestudio.com/v1",
"authenticated": true,
"viewer": { "id": "uuid", "full_name": "Alice" },
"resources": ["team", "project", "issue", "comment"],
"capabilities": {
"jsonOutputSupported": true,
"envAuthSupported": true,
"standardExitCodes": {
"success": 0,
"generalError": 1,
"validationError": 2,
"authError": 3,
"notFound": 4
}
},
"quickExamples": [
"onus me --json",
"onus team list --json",
"onus project list --json",
"onus issue list --status in_progress --json",
"onus issue create --title \"Fix login\" --team <team-id> --json",
"onus comment list <issue-id> --json"
]
}onus schema [resource] — OpenAPI schema introspection
Fetch and print the exact OpenAPI component schemas so you can inspect payload shapes, required fields, and validation constraints without guessing.
onus schema issue --json # schema for a single resource
onus schema # full OpenAPI document
onus schema --all # full OpenAPI documentonus me
Get the authenticated viewer profile.
onus me [--json]onus team
Read-only team access.
onus team list [--json]
onus team get <id> [--json]onus project
onus project list [--json]
onus project get <id> [--json]
onus project create --name <name> --team <teamId> [--status <status>] [--priority <priority>] [--lead <leadId>] [--target-date <date>] [--description <text>] [--description-file <path>] [--agent-context <text>] [--agent-context-file <path>] [--json]
onus project update <id> [--name <name>] [--status <status>] [--priority <priority>] [--lead <leadId>] [--target-date <date>] [--description <text>] [--description-file <path>] [--agent-context <text>] [--agent-context-file <path>] [--json]onus issue
Issues are addressed by human reference (ENG-42); UUIDs are also accepted.
onus issue list [--team <id>] [--project <id>] [--assignee <id>] [--parent <id>] [--status <status>] [--priority <priority>] [--q <query>] [--limit <n>] [--cursor <cursor>] [--json]
onus issue get <ref> [--with-kb] [--json]
onus issue create --title <title> --team <teamId> [-d <description>] [--description-file <path>] [--status <status>] [--priority <priority>] [--assignee <id>] [--project <id>] [--parent <id>] [--json]
onus issue update <ref> [--title <title>] [-d <description>] [--description-file <path>] [--status <status>] [--priority <priority>] [--assignee <id>] [--project <id>] [--parent <id>] [--json]
onus issue delete <ref> [--yes] [--json]--status accepts backlog | todo | in_progress | done | canceled; --priority
accepts none | urgent | high | medium | low. update is aliased as edit.
issue get --with-kb also fetches the issue's knowledge pack (see
onus kb context below) in parallel and adds it under the JSON key
kb_context. Knowledge is supplementary: when the pack cannot be fetched,
kb_context is null, one Knowledge unavailable: <status> line goes to
stderr, and the command still succeeds.
Comment subcommands
onus issue comment create <ref> [--body <body> | --body-file <path>] [--json]
onus issue comment list <ref> [--json]
onus issue comment edit <ref> --comment <commentId> [--body <body> | --body-file <path>] [--json]
onus issue comment delete <ref> --comment <commentId> [--json]Relation subcommands
onus issue relation add <ref> --with <ref> --type <type> [--json]
onus issue relation remove <ref> --relation <relationId> [--json]--type accepts blocks | duplicate | related | similar.
Attachment subcommands
onus issue attachment upload <ref> --file <path> [--name <name>] [--type <type>] [--json]
onus issue attachment list <ref> [--json]
onus issue attachment download <ref> --attachment <attachmentId> [--output <path>] [--json]
onus issue attachment delete <ref> --attachment <attachmentId> [--json]Uploads go through a presigned URL: the CLI requests an upload URL, PUTs the file bytes to it, and reports the attachment id. Downloads resolve a presigned read URL and write the file.
Subscription subcommands
onus issue subscribe <ref> [--json]
onus issue unsubscribe <ref> [--json]GitHub pull-request link subcommands
onus issue link-pr <ref> --repo <owner/name> --pr <number> [--json]
onus issue unlink-pr <ref> --pr-link <linkId> [--json]onus comment
onus comment list <issueId> [--json]
onus comment create <issueId> [--body <body> | --body-file <path>] [--json]onus kb
Browse, search and ask the knowledge base, rate its answers, and submit new entries for review.
onus kb list --team <id|KEY> [--type <type>] [--status <status>] [--limit <n>] [--cursor <cursor>] [--json]
onus kb get <idOrSlug> [--team <id|KEY>] [--exact] [--json]
onus kb search <query> --team <id|KEY> [--type <a,b>] [--repo owner/name] \
[--paths <a,b>] [--limit <n>] [--json]
onus kb ask <question> --team <id|KEY> [--issue ONUS-N] [--repo owner/name] \
[--paths <a,b>] [--limit <n>] [--json]
onus kb feedback <questionId> --verdict answered|partial|missed \
[--helpful <slug,…>] [--unhelpful <slug,…>] [--note <text>] [--json]
onus kb requests --team <id|KEY> [--status <a,b>] [--limit <n>] [--json]
onus kb context --issue <ref> [--json]
onus kb gotchas --team <id|KEY> --paths <a,b> [--repo owner/name] [--limit <n>] [--json]
onus kb learn --team <id|KEY> --type <type> --title <title> (--body <text> | --body-file <path>) \
[--summary <text>] [--meta-file <json>] [--paths <a,b>] [--questions-file <path>] [--issue ONUS-N] [--json]
onus kb propose <learn flags> [--author-kind human|agent] [--request ONUS-N] \
[--supersedes <idOrSlug>] [--evidence-file <json>] [--json]--type is one of charter | decision | direction | guide | gotcha | incident | glossary.
kb list shows active entries unless --status says otherwise (--limit is 1-100).
kb get prints the entry body as markdown. --team is required for a slug
and optional for an entry UUID. A superseded slug resolves to its
current successor (the chain goes to stderr); --exact returns the requested
entry itself.
kb search ranks the team's active entries for a query, best match first, and
prints one line per hit — 1. [high] gotcha vitest-pool-forks — Vitest needs
--pool forks — then a route: fused|reranked footer, or No matching
knowledge. when nothing matches. --type and --paths take
comma-separated lists; an entry with no scope in a dimension matches any
request, and an omitted flag does not filter. --repo must be a GitHub repo
linked to the team: an unknown one exits 2 with unknown_repo. --limit is
1-20 (default 8).
Search never stores or logs the query.
kb ask answers like search (same hit lines and route: footer) but records
the question, so it can be rated and so unanswered questions become knowledge
requests. It then prints question: <id> and the feedback command to run.
--issue names the issue the question is about; --limit is 1-20. Asks share
a per-user daily cap; exceeding it prints Daily limit reached; retry in
<h>h<m>m.
kb ask alone sends X-Onus-Agent and X-Onus-Session headers, which let the
server count how many distinct agent sessions asked the same thing. The agent is
ONUS_AGENT when set, else detected (CLAUDECODE=1 → claude-code). The
session is ONUS_SESSION_ID when set, else derived from the nearest claude
ancestor process (one ps call), so every shell an agent session spawns shares
one id. With no agent there are no headers; with no session (no matching
ancestor, ps unavailable, e.g. on Windows) asks fall back to one key per user
per day.
kb feedback rates an answer (the asker only; anyone else gets Only the asker
can rate this question, exit 3). --helpful and --unhelpful take entry
slugs or ids from that answer; resubmitting replaces the previous rating. It
prints Recorded partial for <id> (helpful: 1, unhelpful: 0). A partial or
missed verdict feeds knowledge requests.
kb requests lists the team's knowledge requests — clusters of questions the
KB could not answer — highest score first, one per line:
<status> <score> <n> keys <ONUS-N|—> <latest question>. --status takes a
comma-separated list of open, requested, resolved, dismissed (default
open,requested); --limit is 1-100 (default 50). Answer one with
onus kb propose … --request ONUS-N.
learn (an agent recording what it learned) and propose (a human or agent
proposal, optionally answering a kb-request issue or replacing an entry) both
land a proposed entry for review and print the curation outcome:
Proposed decision "use-pnpm" (created), Duplicate of "use-pnpm"; recorded as
support, a revision of an existing entry, or a replacement for one.
--meta-file is a JSON object, --evidence-file a JSON array of
{quote, sourceRef?}, and --questions-file holds one question per line. A
write-gate rejection (exit 2) prints each problem as field: message; the
shared daily cap of 100 submissions per user prints
Daily limit reached; retry in <h>h<m>m.
kb context prints the issue's knowledge pack: the most relevant active
gotchas, decisions, guides, direction, incidents and glossary terms for the
issue, with their bodies inlined, so an agent can read them before planning.
The pack is cached per issue and recomputed in the background when the issue
or the team's knowledge changes; (stale · refreshing) means a refresh is
queued. Knowledge suggestions limited today (JSON degraded or reason =
budget) means the team's daily budget is spent and the pack is degraded.
Context lookups never store or log the issue text as a question. The same pack
is available as issue get <ref> --with-kb.
kb gotchas lists the gotchas whose path scope matches at least one of the
comma-separated, repo-relative --paths (1-50 paths; no leading /, no \,
no ..), most severe first. Unscoped gotchas are excluded — they reach agents
through the context pack. --repo must be a GitHub repo linked to the team;
--limit is 1-20 (default 10).
kb hook is the runtime half of the Claude Code gotcha hook (see
onus hook); Claude Code runs it, you
do not. It reads the PreToolUse hook JSON on stdin and, for an Edit, Write
or NotebookEdit of a file inside a GitHub-backed git repo, prints at most 3 (per edit)
gotchas scoped to that file that this agent session has not seen yet, as
{"hookSpecificOutput":{"hookEventName":"PreToolUse","additionalContext":"…"}}
(each body cut to 800 chars, 4000 in total). The team comes from the repo
pinned with onus hook install --team, else from the teams the origin
remote's repo is linked to (cached for 24 h, 1 h when none). It is fail-open:
it always exits 0, prints nothing on any error, missing auth, unknown repo or
after its 1.5 s deadline, and never blocks or denies the edit. Set
ONUS_HOOK_DEBUG=1 to see its errors on stderr. Its cache lives in
${XDG_CACHE_HOME:-~/.cache}/onus/hook/ (per-session shown ids in sessions/,
pruned after 7 days, and the repo-to-team cache repos.json).
onus hook — coding agent gotcha hook
Installs the gotcha hook into a coding agent so path-scoped gotchas reach it before it edits a file. Claude Code is the only supported agent.
onus hook install --agent claude-code [--project | --user] [--team <id|KEY>] [--yes]
onus hook uninstall --agent claude-code [--project | --user]hook install adds this entry under hooks.PreToolUse in
<git root or cwd>/.claude/settings.json (--project, the default) or
${CLAUDE_CONFIG_DIR:-~/.claude}/settings.json (--user):
{
"matcher": "Edit|Write|NotebookEdit",
"hooks": [{ "type": "command", "command": "onus kb hook", "timeout": 5 }]
}timeout is in seconds, above the hook's own 1.5 s deadline. The command
prints the target file and the entry, then asks for confirmation; pass --yes
to skip it (required when stdin is not a terminal). It is idempotent — an
existing onus kb hook entry counts as installed — keeps every other setting
and hook, and refuses to touch a settings file that is not valid JSON.
--team pins this repo (its GitHub origin remote, owner/name) to a team
in the onus config (kbHookTeams), keeping other repos' pins; without it the
hook looks the team up from the repo's GitHub link. onus must be on the
agent's PATH.
hook uninstall removes only the Onus entry (including one written by an
earlier install with another matcher) and prunes the containers it leaves
empty. It does not prompt. With --project (the default) it also drops this
repo's kbHookTeams pin, keeping other repos' pins and the token; the shared
hook cache stays, since hooks in other repos or at user scope still use it.
With --user it also deletes the hook cache.
onus logs
Read-only log search, aggregation and live tail. Queries are bounded by a time
range: --since (default 1h) or --from/--to (ISO 8601, at most 30 days).
A --from/--to date-time without an offset (2026-09-01T09:00) is read as
local time; add Z or +hh:mm to pin it. --limit is 1-500 for
logs query and 1-200 for trace list; the CLI rejects anything outside that
before calling the API.
onus logs query [q] --team <id|KEY> [--since <since> | --from <iso> --to <iso>] [--limit <n>] [--cursor <cursor>] [--json]
onus logs aggregate [q] --team <id|KEY> --fn <fn> [--field <token>] [--group-by <fields>] [--no-bucket] [--since <since> | --from <iso> --to <iso>] [--json]
onus logs tail [q] --team <id|KEY> [--json]--fn accepts count | count_unique | avg | p50 | p95 | p99 | min | max;
--group-by takes up to two comma-separated fields. logs tail streams over
SSE and resumes automatically after reconnects; --json prints NDJSON. Query
syntax (fields like level:error or service:api, @attr.key attributes,
comparisons, globs, free text; space-separated terms are ANDed, OR
combines them, - negates, parentheses group, and there are no AND or
NOT keywords) is documented in
docs/logging.md.
onus trace
onus trace list [q] --team <id|KEY> [--since <since> | --from <iso> --to <iso>] [--limit <n>] [--cursor <cursor>] [--json]
onus trace get <traceId> --team <id|KEY> [--json]trace get prints the span tree (indented by depth, error spans marked
ERROR), then Spans: N and Logs: N lines (+ when truncated), the error
count and each error on the trace.
onus watch
Stream live issue/comment/error/log alert events over SSE with automatic resume.
onus watch [--team <id|KEY>] [--type <types>] [--json]
onus watch --type 'log.*'--type is a comma-separated allowlist; prefix.* matches a whole family
(log.* covers log.alert_fired and log.alert_resolved).
onus skill — agent skill management
The package bundles an @brunyee-studio/onus-cli agent skill (a SKILL.md teaching AI coding
agents how to drive the Onus CLI). Installation and lifecycle go through the
skills npm package, which detects
installed agents (Claude Code, Codex, Cursor, …) and symlinks or copies the
skill into their skill directories.
onus skill install # install into detected agents (project scope)
onus skill install --global # user-wide (~/<agent>/skills/)
onus skill install --agent claude-code codex
onus skill install --copy # copy instead of symlink
onus skill update # refresh installed copies to the bundled version
onus skill remove # uninstall from agents (alias: onus skill rm)Agent usage guidance
The Onus CLI is built to be driven reliably by AI agents.
1. Deterministic JSON output
Add the global -j, --json flag (available on every command) for pure,
deterministic JSON with no ANSI codes, banners, or table borders:
onus issue list --json | jq '.[0].title'2. Auto-JSON when piping
When stdout is not a TTY (piped, redirected, or captured by an agent), the
CLI automatically switches to JSON output. You can also force it with
ONUS_OUTPUT=json:
onus issue list | jq . # auto-JSON because stdout is piped
ONUS_OUTPUT=json onus issue list # force JSON modeDiagnostic and informational logs go to stderr, so stdout stays clean and pipeable.
3. Introspect before acting
Run onus context --json first to learn the environment, then use
onus schema <resource> --json to discover exact field names, required
properties, and enum values before constructing a write operation.
4. Standardized exit codes
| Exit code | Meaning |
| --------- | ----------------------------------------------------- |
| 0 | Success |
| 1 | General / server error |
| 2 | Validation / usage error (e.g. missing required flag) |
| 3 | Authentication error (401 / 403) |
| 4 | Not found (404) |
A request that gets no response within 120 seconds (310 for bulk import and
report generation) fails with exit code 1; in --json mode the error is
request_timeout.
5. Headless authentication
Agents can operate without interactive prompts by supplying the token via
ONUS_TOKEN:
export ONUS_TOKEN="<your-onus-token>"
onus me --json6. Long text via per-field file input
Long, multi-line values (issue and project descriptions, comment bodies,
project agent context) are awkward to inline in shell commands. Each of these
fields has a companion file flag that reads only that field from a file —
never the whole record — following the standard --body-file convention:
onus issue create --title "Fix login bug" --team ONUS --description-file ./body.md
onus issue update ENG-42 --description-file ./notes.md
onus issue comment create ENG-42 --body-file ./comment.md
onus comment create ENG-42 --body-file ./comment.md
onus project create --name "Migration" --team ONUS --description-file ./brief.md
onus project update <projectId> --description-file ./brief.md
onus project update <projectId> --agent-context-file AGENTS.mdPass - as the path to read the field value from stdin, so agents can pipe
content directly:
generate-body | onus issue create --title "Fix login bug" --team ONUS --description-file -Passing both the inline flag and its file variant (e.g. --body together with
--body-file) is an error; the file never silently overrides the inline value.
Comment bodies must be non-empty: an empty or whitespace-only --body or
--body-file is rejected before the request is sent.
How the CLI is generated from OpenAPI
The type-safe SDK boundary of the CLI is produced from the Onus OpenAPI specification:
src/lib/public-api/openapi.ts (Zod schemas = single source of truth)
│ pnpm openapi:export
▼
openapi.json
│ pnpm cli:generate (@openapitools/openapi-generator-cli, typescript-fetch)
▼
packages/cli/src/generated/** (models + runtime + DefaultApi)
│ wrapped by packages/cli/src/client.ts
▼
packages/cli/src/commands/** (Commander.js CLI surface)pnpm openapi:exportstatically serializes/v1/openapi.jsontoopenapi.jsonwithout needing a running dev server.pnpm cli:generateruns the generator configured inopenapitools.json, emitting thetypescript-fetchclient intopackages/cli/src/generated.- Because it is generated from the canonical spec, the CLI always reflects the
real API: adding or changing a
/v1route + its Zod schema, then re-runningpnpm openapi:export && pnpm cli:generate, updates the SDK and CLI surface in lockstep.
Development
Commands
| Command | Purpose |
| --------------------- | -------------------------------------------------- |
| pnpm cli:generate | Regenerate the SDK from openapi.json |
| pnpm cli:build | Bundle packages/cli/dist with tsup |
| pnpm cli:test | Run Vitest unit tests for the CLI |
| pnpm cli:typecheck | Run tsc --noEmit for the CLI |
| pnpm openapi:export | Regenerate openapi.json from the API definitions |
Run from the repository root. Each script delegates to the packages/cli
workspace package via pnpm --filter onus.
Automated versioning & publishing
The CLI package is released automatically on push to main by a GitHub Actions
workflow (.github/workflows/release.yml) running semantic-release, driven by
Conventional Commits (enforced by the repo's commitlint config):
| Commit type | Version bump |
| ------------------------------------- | --------------- |
| feat: | Minor (1.1.0) |
| fix: | Patch (1.0.1) |
| feat!: / BREAKING CHANGE: | Major (2.0.0) |
| chore:, docs:, refactor:, ci: | No release |
The release pipeline:
- Checks out with full git history (
fetch-depth: 0). - Exports the OpenAPI spec and regenerates the SDK.
- Runs tests, typechecks, and builds the CLI.
- Runs
semantic-release, which:- Bumps
packages/cli/package.jsonand appends topackages/cli/CHANGELOG.md. - Creates a git tag and a GitHub Release with auto-generated notes.
- Publishes to npm (
@semantic-release/npm); configure anNPM_TOKENrepository secret to enable publishing. The GitHub release assets are the builtdist/**bundles.
- Bumps
packages/cli/CHANGELOG.md is auto-generated by semantic-release on each
release and is excluded from formatting and checks — do not edit it by hand
(manual edits are overwritten on the next release).
License
MIT · © Brunyee Studio
