01. First Steps with openOnyx (Quickstart)

🇪🇸 Ver este capítulo en Español

Go from building openonyx to completing your first supervised coding session — with live SSE streaming, colorized diff approvals, PLAN/BUILD mode toggling, and transactional Git /undo — in under 10 minutes.


1. Build or Install openonyx

From the OnYX repository root:

# Optimized build (recommended for daily use)
cargo build --release -p open-onyx

# Or install into ~/.cargo/bin so `openonyx` is available in any project
cargo install --path open-onyx

Verify the binary and audit your local environment:

openonyx --version
openonyx --help
openonyx doctor

Tip: If you did not install globally, replace openonyx with cargo run --release -p open-onyx -- or ./target/release/openonyx (Windows: .\target\release\openonyx.exe).


2. Configure an LLM Provider

openonyx natively supports Google Gemini (default) and any OpenAI-compatible /v1/chat/completions endpoint (OpenAI, OpenRouter, Ollama, vLLM, LM Studio).

Option A — Google Gemini (default)

Windows (PowerShell):

$env:GEMINI_API_KEY = "your-api-key"
openonyx chat --auto-save

Linux / macOS (bash/zsh):

export GEMINI_API_KEY="your-api-key"
openonyx chat --auto-save

To pick a specific model or reasoning effort (low, medium, high):

openonyx chat --model gemini-2.5-pro --effort high --auto-save

Option B — OpenAI / OpenRouter

Windows (PowerShell):

$env:OPENAI_API_KEY = "sk-..."
openonyx chat --provider openai --model gpt-4o --effort medium --auto-save

Linux / macOS:

export OPENAI_API_KEY="sk-..."
openonyx chat --provider openai --model gpt-4o --effort medium --auto-save

With OpenRouter or any compatible gateway:

openonyx chat --provider openai --api-base https://openrouter.ai/api/v1 --model anthropic/claude-sonnet-4 --auto-save

Option C — Local Models (Ollama, vLLM, LM Studio)

Whenever --api-base (or OPENAI_API_BASE / OPENAI_BASE_URL) is set, OPENAI_API_KEY is optional.

Ollama:

openonyx chat --provider openai --api-base http://localhost:11434/v1 --model qwen2.5-coder:14b --effort low --auto-save

vLLM / LM Studio:

openonyx chat --provider openai --api-base http://localhost:8000/v1 --model Qwen/Qwen3-Coder-30B-A3B --auto-save

Tip: passing --auto-save (or setting ONYX_AUTO_SAVE=1) automatically stores snapshots and transcripts together under .onyx/vault/<timestamp>_<model>_<branch>/ (auto-ignored by Git), keeping your repository root clean while enabling /rewind and --resume out of the box.


3. Your First Interactive Session (openonyx chat)

  1. Open a terminal inside any Git repository (or pass -w /path/to/repo).
  2. Run openonyx chat --snapshot-dir .snaps_demo --record demo.tr.
  3. The TUI displays:
    • Compact 3-row header: Braille activity emblem, [BUILD] / [PLAN] badge, [SANDBOX:workspace], active model & effort, and live telemetry (ctx, in/cache/out/think tokens, and estimated cost or local).
    • Main Memory & Trace pane: conversation turns, tool calls, observations, and live [stream] ...▍ token previews.
    • Bottom input bar: prompt input and key hints.

Step 1 — Explore Safely in [PLAN] Mode

Press Tab to toggle to [PLAN] (read-only; mutating tools are unconditionally blocked). Type an analysis prompt and press Enter:

Inspect this repository structure and propose a concise plan to add a helper function to the main module.

The agent uses read-only tools (glob_files, scent_outline, code_search, fs_read, plan_update) without interrupting you for approval. When your terminal is at least 100 columns wide and plan_update is used, the Live Plan panel opens automatically on the right.

Step 2 — Switch to [BUILD] and Review Diffs

Press Tab again to switch back to [BUILD] and send a follow-up prompt:

Implement the change and run the test suite.

Whenever the agent proposes fs_edit, fs_write, or shell_exec, the TUI pauses in WaitingApproval:

  • The banner shows which agent requested the action ([agent #1 ...]).
  • File edits show a colorized unified diff preview before writing to disk.
  • You can scroll Memory & Trace freely (Up/Down/PgUp/PgDn) while inspecting the diff.
  • Press y to approve or n to deny (denials are fed back to the agent cleanly).

Step 3 — Revert the Last Edit with /undo

If you want to roll back the latest fs_edit or fs_write, type:

/undo

openonyx restores the lightweight Git tree checkpoint captured right before the edit — without touching HEAD or your staged index — and cleanly removes newly created untracked fs_write files while preserving unrelated untracked files.

Step 4 — Exit Cleanly

Press Esc or Ctrl+C. openonyx flushes the final exit milestone into .snaps_demo/snapshots.onyxpack and writes demo.tr.


4. Resume, Inspect, or Replay Offline

After closing your session, try these zero-token commands:

# 1. List all recorded milestones and Git tree checkpoints
openonyx inspect .snaps_demo --list

# 2. Deterministically replay the session offline (0 HTTP calls, 0 disk writes)
openonyx replay demo.tr

# 3. Resume from the latest milestone
openonyx chat --resume .snaps_demo

# Or branch safely from an earlier tick into a sibling fork directory
openonyx chat --resume .snaps_demo --tick 8

5. Single-Turn Headless Execution (openonyx run)

For scripts or CI pipelines where you don't want a TUI:

openonyx run "summarize the pending git diff" --record run.tr --snapshot-dir .snaps_run

openonyx prints the final agent response along with [openOnyx telemetry] token/cost counters.


← English Index · Versión en Español · Next: 02. TUI & Daily Workflow →