From fe629b34887b8d1c985964db1bf84d3f8ed90969 Mon Sep 17 00:00:00 2001 From: Hakula Chen Date: Tue, 1 Dec 2026 18:42:15 +0800 Subject: [PATCH] docs: add TOML configuration examples across reference guides --- docs/README.md | 27 ++++++------- docs/guides/nix.md | 2 +- docs/reference/configuration.md | 68 ++++++++++++++++++++++++--------- docs/reference/statusline.md | 37 ++++++++++++------ docs/reference/themes.md | 12 ++++++ nix/hm-module.nix | 2 +- 6 files changed, 104 insertions(+), 44 deletions(-) diff --git a/docs/README.md b/docs/README.md index 8b0371061..669d344e8 100644 --- a/docs/README.md +++ b/docs/README.md @@ -15,19 +15,20 @@ Documentation for `oxide-code` (`ox`) is organized into three user-facing bucket ## Reference -| Document | Topic | -| ------------------------------------------- | ------------------------------------------------------------------ | -| [ACP](reference/acp.md) | `ox acp` stdio JSON-RPC 2.0 server methods and streaming updates | -| [CLI](reference/cli.md) | Shipped subcommands, flags, session storage, and TUI keybindings | -| [Configuration](reference/configuration.md) | `config.toml` schema for providers, credentials, and model entries | -| [Hooks](reference/hooks.md) | Out-of-process command hooks, lifecycle events, and error policy | -| [MCP Plugin](reference/mcp-plugin.md) | `ox-plugin-mcp` stdio and Streamable HTTP MCP bridge configuration | -| [Models](reference/models.md) | Data-driven model catalog TOML schema and tier profiles | -| [Skills](reference/skills.md) | `SKILL.md` discovery roots, frontmatter schema, and `load_skill` | -| [Statusline](reference/statusline.md) | Built-in statusline segments and external ANSI command protocol | -| [Subagents](reference/subagents.md) | Unified `Agent` + `SpawnSpec` delegation and `invoke_subagent` | -| [System Prompt](reference/system-prompt.md) | Named system prompt sections and declarative Markdown overrides | -| [Themes](reference/themes.md) | Built-in palettes and custom TOML theme file schema | +| Document | Topic | +| ----------------------------------------------- | ------------------------------------------------------------------ | +| [ACP](reference/acp.md) | `ox acp` stdio JSON-RPC 2.0 server methods and streaming updates | +| [CLI](reference/cli.md) | Shipped subcommands, flags, session storage, and TUI keybindings | +| [Configuration](reference/configuration.md) | `config.toml` schema for providers, credentials, and model entries | +| [Hooks](reference/hooks.md) | Out-of-process command hooks, lifecycle events, and error policy | +| [MCP Plugin](reference/mcp-plugin.md) | `ox-plugin-mcp` stdio and Streamable HTTP MCP bridge configuration | +| [Models](reference/models.md) | Data-driven model catalog TOML schema and tier profiles | +| [Plugin Protocol](reference/plugin-protocol.md) | Stdio NDJSON-RPC 2.0 plugin host protocol and callbacks | +| [Skills](reference/skills.md) | `SKILL.md` discovery roots, frontmatter schema, and `load_skill` | +| [Statusline](reference/statusline.md) | Built-in statusline segments and external ANSI command protocol | +| [Subagents](reference/subagents.md) | Unified `Agent` + `SpawnSpec` delegation and `invoke_subagent` | +| [System Prompt](reference/system-prompt.md) | Named system prompt sections and declarative Markdown overrides | +| [Themes](reference/themes.md) | Built-in palettes and custom TOML theme file schema | ## Architecture diff --git a/docs/guides/nix.md b/docs/guides/nix.md index c792f8a51..11e988327 100644 --- a/docs/guides/nix.md +++ b/docs/guides/nix.md @@ -52,7 +52,7 @@ Import `oxide-code.homeManagerModules.default` (also exported as `oxide-code.hom ]; settings = { default_model = "gemini-4-neon"; - providers.google.kind = "google"; + providers.google.wire = "google"; models.gemini-4-neon = { provider = "google"; model = "gemini-4-neon"; diff --git a/docs/reference/configuration.md b/docs/reference/configuration.md index b905ef0e1..45d4adaf5 100644 --- a/docs/reference/configuration.md +++ b/docs/reference/configuration.md @@ -1,6 +1,6 @@ # Configuration Reference -`ox` loads its configuration from a TOML file passed via `-c` / `--config `. +`ox` loads its configuration from a TOML file passed via `-c` / `--config `, the `OX_CONFIG` environment variable, or XDG auto-discovery (`$XDG_CONFIG_HOME/ox/config.toml`, falling back to `~/.config/ox/config.toml`). ## Example @@ -11,6 +11,9 @@ theme = "catppuccin-mocha" [providers.google] wire = "google" api_key_file = "/path/to/gemini.key" +timeout_ms = 30000 +max_retries = 3 +retry_base_delay_ms = 500 [providers.openai] wire = "openai" @@ -26,9 +29,30 @@ api_key = "sk-ant-..." [models.gemini] provider = "google" -model = "gemini-4-hydrogen" +model = "gemini-4-neon" max_output_tokens = 8192 reasoning_effort = "medium" + +[models.gemini-fast] +provider = "google" +model = "gemini-4-hydrogen" + +[profiles] +default = "gemini" +fast = "gemini-fast" + +[[hooks]] +event = "PreToolUse" +matcher = "mcp__*" +command = ["/path/to/check-mcp-tool.sh"] +timeout_ms = 5000 +on_error = "block" + +[[plugins]] +name = "mcp" +command = ["ox-plugin-mcp", "--config", "/path/to/mcp.toml"] +timeout_ms = 30000 +env = { RUST_LOG = "info" } ``` ## Top-Level Fields @@ -42,16 +66,19 @@ reasoning_effort = "medium" Each table under `[providers.]` defines connection, authentication, and TLS settings for a named provider. -| Field | Type | Required | Description | -| ---------------- | ---------------- | -------- | --------------------------------------------------------------------------- | -| `wire` | string | Yes | Wire protocol: `"google"`, `"openai"` (alias `"open-ai"`), or `"anthropic"` | -| `base_url` | string | No | Endpoint URL overriding the wire's default base URL | -| `api_key` | string | No | Inline API key (redacted in debug output) | -| `api_key_file` | path | No | Path to a file containing the API key | -| `auth_command` | array of strings | No | Command whose stdout prints a bearer token or API key | -| `extra_headers` | table of strings | No | Additional HTTP headers sent with every request (values redacted) | -| `extra_ca_certs` | array of paths | No | PEM CA certificate files used for TLS verification | -| `no_proxy` | boolean | No | Disable system and environment HTTP proxies (defaults to `false`) | +| Field | Type | Required | Description | +| --------------------- | ---------------- | -------- | --------------------------------------------------------------------------- | +| `wire` | string | Yes | Wire protocol: `"google"`, `"openai"` (alias `"open-ai"`), or `"anthropic"` | +| `base_url` | string | No | Endpoint URL overriding the wire's default base URL | +| `api_key` | string | No | Inline API key (redacted in debug output) | +| `api_key_file` | path | No | Path to a file containing the API key | +| `auth_command` | array of strings | No | Command whose stdout prints a bearer token or API key | +| `extra_headers` | table of strings | No | Additional HTTP headers sent with every request (values redacted) | +| `extra_ca_certs` | array of paths | No | PEM CA certificate files used for TLS verification | +| `no_proxy` | boolean | No | Disable system and environment HTTP proxies (defaults to `false`) | +| `timeout_ms` | integer | No | Per-request HTTP timeout in milliseconds | +| `max_retries` | integer | No | Maximum number of retry attempts for transient HTTP or transport errors | +| `retry_base_delay_ms` | integer | No | Base backoff delay in milliseconds between retry attempts | ### Credential Resolution Precedence @@ -74,16 +101,21 @@ Each table under `[models.]` binds a provider name to a wire-level model i | `max_output_tokens` | integer | No | Default maximum output token cap | | `reasoning_effort` | string | No | Default reasoning effort: `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, or `max` | +## `[profiles]` + +An optional table mapping user-defined profile names to keys in `[models.]`. When a requested profile is not found, `ox` falls back to `default_model`. See the [Models](models.md) reference for catalog tier profiles. + ## `[[hooks]]` Each `[[hooks]]` entry defines an out-of-process command hook that runs on an agent lifecycle event. -| Field | Type | Required | Description | -| ------------ | ---------------- | -------- | ----------------------------------------------------------------------- | -| `event` | string | Yes | Lifecycle event: `"PreToolUse"`, `"PostToolUse"`, or `"Stop"` | -| `matcher` | string | No | Optional tool name filter (`"*"` or an exact tool name) for tool events | -| `command` | array of strings | Yes | Executable and arguments invoked when the hook fires | -| `timeout_ms` | integer | No | Per-invocation timeout in milliseconds (defaults to `30000`) | +| Field | Type | Required | Description | +| ------------ | ---------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------- | +| `event` | string | Yes | Lifecycle event: `"SessionStart"`, `"SessionEnd"`, `"UserPromptSubmit"`, `"PreToolUse"`, `"PostToolUse"`, `"TurnEnd"`, `"Stop"` | +| `matcher` | string | No | Optional tool name filter (exact name or `*` glob, such as `"mcp__*"`) for tool events | +| `command` | array of strings | Yes | Executable and arguments invoked when the hook fires | +| `timeout_ms` | integer | No | Per-invocation timeout in milliseconds (defaults to `30000`) | +| `on_error` | string | No | Error policy for blocking-capable events: `"allow"` (default, fail open) or `"block"` (fail closed) | ## `[[plugins]]` diff --git a/docs/reference/statusline.md b/docs/reference/statusline.md index b7289c74e..0949748ea 100644 --- a/docs/reference/statusline.md +++ b/docs/reference/statusline.md @@ -9,26 +9,41 @@ By default, the statusline displays a clean, icon-free layout split into left an - **Left**: Active model identifier and context usage formatted as `Ctx: % (k/k)` when the context window size is known, or `Ctx: k` otherwise. Context usage changes color across three configurable thresholds (`context_thresholds.warn_pct` and `context_thresholds.error_pct`, defaulting to `50` and `80`). - **Right**: `expanded` when tool details are expanded (`Ctrl+O`), plus the active agent state (`thinking`, `streaming`, or the running tool name) only while busy. -`StatusLineConfig` exposes `left` and `right` vectors of `StatusSegment` values so callers can reorder or customize the bar: - -| Segment | Description | -| ----------------- | ---------------------------------------------------------- | -| `model` | Active model identifier | -| `context` | Context token usage with 3-tier color thresholds | -| `expanded` | Shown as `expanded` when tool call details are expanded | -| `status` | Active agent state (`thinking`, `streaming`, or tool name) | -| `command([args])` | First stdout line from an external command as one segment | +`StatusLineConfig` is deserialized from TOML by `ox-tui` and exposes `left` and `right` vectors of `StatusSegment` values so callers can reorder or customize the bar: + +| Segment | Description | +| ----------------------- | ---------------------------------------------------------- | +| `model` | Active model identifier | +| `context` | Context token usage with 3-tier color thresholds | +| `expanded` | Shown as `expanded` when tool call details are expanded | +| `status` | Active agent state (`thinking`, `streaming`, or tool name) | +| `{ command = ["..."] }` | First stdout line from an external command as one segment | + +```toml +left = ["model", "context", { command = ["git", "branch", "--show-current"] }] +right = ["expanded", "status"] + +[context_thresholds] +warn_pct = 50 +error_pct = 80 +``` ## External Command Mode -Setting `statusline.command` replaces the built-in layout with the first line of stdout from an external command. `ox` writes a JSON snapshot to the command's stdin: +Setting `command` on `StatusLineConfig` replaces the built-in layout with the first line of stdout from an external command: + +```toml +command = ["my-statusline", "--compact"] +``` + +`ox` writes a JSON snapshot to the command's stdin: ```json { "cwd": "/path/to/repo", "workspace": { "current_dir": "/path/to/repo" }, "model": { "id": "gemini-4-hydrogen" }, - "context": { "used_tokens": 12000, "window_size": 200000 }, + "context": { "used_tokens": 12000, "window_size": 1048576 }, "status": "idle" } ``` diff --git a/docs/reference/themes.md b/docs/reference/themes.md index 650aa069a..440f6b699 100644 --- a/docs/reference/themes.md +++ b/docs/reference/themes.md @@ -2,6 +2,18 @@ `ox-tui` supports built-in color palettes and custom TOML theme files loaded with `Theme::from_toml` or `Theme::load_file`. Built-in palettes dogfood the same TOML schema and live in [`crates/ox-tui/themes/`](../../crates/ox-tui/themes/catppuccin-mocha.toml). +## Selecting a Theme + +Set the top-level `theme` key in `config.toml` to a built-in palette name or the path to a custom TOML theme file: + +```toml +# Built-in palette +theme = "catppuccin-mocha" + +# Custom theme file +# theme = "/path/to/custom-theme.toml" +``` + ## Built-in Palettes | Name | Description | Source | diff --git a/nix/hm-module.nix b/nix/hm-module.nix index d695d820b..ebab19323 100644 --- a/nix/hm-module.nix +++ b/nix/hm-module.nix @@ -40,7 +40,7 @@ in example = lib.literalExpression '' { default_model = "gemini-4-neon"; - providers.google.kind = "google"; + providers.google.wire = "google"; models.gemini-4-neon = { provider = "google"; model = "gemini-4-neon";