Selaa lähdekoodia

docs(preset): add preset switching documentation

New docs/preset-switching.md covering /preset command usage, supported
fields, startup vs runtime switching, and example output.

Updates: quick-reference.md, README.md feature table, configuration.md
runtime switching note.
ReqX 3 kuukautta sitten
vanhempi
sitoutus
960cbc1fb5
4 muutettua tiedostoa jossa 103 lisäystä ja 0 poistoa
  1. 1 0
      README.md
  2. 4 0
      docs/configuration.md
  3. 97 0
      docs/preset-switching.md
  4. 1 0
      docs/quick-reference.md

+ 1 - 0
README.md

@@ -473,6 +473,7 @@ Use this section as a map: start with installation, then jump to features, confi
 | **[Interview](docs/interview.md)** | Turn rough ideas into a structured markdown spec through a browser-based Q&A flow |
 | **[Multiplexer Integration](docs/multiplexer-integration.md)** | Watch agents work live in Tmux or Zellij panes |
 | **[Todo Continuation](docs/todo-continuation.md)** | Auto-continue orchestrator sessions with cooldowns and safety checks |
+| **[Preset Switching](docs/preset-switching.md)** | Switch agent model presets at runtime with `/preset` |
 | **[Codemap](docs/codemap.md)** | Generate hierarchical codemaps to understand large codebases faster |
 
 ### ⚙️ Config & Reference

+ 4 - 0
docs/configuration.md

@@ -82,6 +82,10 @@ All config files support **JSONC** (JSON with Comments):
 | Option | Type | Default | Description |
 |--------|------|---------|-------------|
 | `preset` | string | — | Active preset name (e.g. `"openai"`, `"best"`) |
+
+### Runtime Preset Switching
+
+Presets can also be switched at runtime without restarting using the `/preset` command. See [Preset Switching](preset-switching.md) for details.
 | `presets` | object | — | Named preset configurations |
 | `presets.<name>.<agent>.model` | string | — | Model ID in `provider/model` format |
 | `presets.<name>.<agent>.temperature` | number | — | Temperature (0–2) |

+ 97 - 0
docs/preset-switching.md

@@ -0,0 +1,97 @@
+# Preset Switching
+
+Switch agent model presets at runtime without restarting OpenCode using the `/preset` slash command.
+
+## Controls
+
+| Command | Description |
+|---------|-------------|
+| `/preset` | List available presets (highlights the active one) |
+| `/preset <name>` | Switch to the named preset immediately |
+
+## How It Works
+
+1. Define named presets in `oh-my-opencode-slim.jsonc` under the `presets` field
+2. Run `/preset <name>` to switch. The plugin calls the OpenCode SDK's `config.update()` method, which triggers a server-side cache invalidation
+3. The next LLM call uses the new models and settings
+
+## Example Configuration
+
+```jsonc
+{
+  "presets": {
+    "cheap": {
+      "orchestrator": { "model": "anthropic/claude-3.5-haiku" },
+      "explorer": { "model": "openai/gpt-5.4-mini" },
+      "oracle": { "model": "anthropic/claude-sonnet-4-6" }
+    },
+    "powerful": {
+      "orchestrator": { "model": "openai/gpt-5.4" },
+      "oracle": { "model": "anthropic/claude-opus-4-6" },
+      "librarian": { "model": "anthropic/claude-sonnet-4-6" }
+    },
+    "thinking": {
+      "oracle": {
+        "model": "anthropic/claude-sonnet-4-6",
+        "variant": "thinking",
+        "options": { "thinking": { "type": "enabled", "budgetTokens": 10000 } }
+      }
+    }
+  }
+}
+```
+
+## Supported Fields
+
+The following fields are forwarded to the OpenCode SDK at runtime:
+
+| Field | Description |
+|-------|-------------|
+| `model` | Model ID in `provider/model` format. Array form (fallback chains) is resolved to the first entry |
+| `temperature` | Inference temperature (0-2) |
+| `variant` | Model variant (e.g. `"thinking"`) |
+| `options` | Provider-specific options (e.g. thinking budget) |
+
+Fields not forwarded (require restart): `prompt`, `skills`, `mcps`, `displayName`.
+
+## Startup Preset vs Runtime Switching
+
+There are two ways to activate a preset:
+
+| Method | How | Persists? |
+|--------|-----|-----------|
+| Config file | Set `"preset": "cheap"` in `oh-my-opencode-slim.jsonc` | Yes, across restarts |
+| `/preset` command | Run `/preset cheap` during a session | No, reverts on restart |
+
+On restart, the plugin's `config()` hook re-applies the preset from the config file, overwriting any runtime switch. To make a runtime switch permanent, update the `"preset"` field in your config file.
+
+## Example Output
+
+```
+/preset
+```
+
+```
+Available presets:
+  cheap ← active
+    orchestrator → anthropic/claude-3.5-haiku
+    explorer → openai/gpt-5.4-mini
+    oracle → anthropic/claude-sonnet-4-6
+  powerful
+    orchestrator → openai/gpt-5.4
+    oracle → anthropic/claude-opus-4-6
+
+Usage: /preset <name> to switch.
+```
+
+```
+/preset powerful
+```
+
+```
+Switched to preset "powerful":
+orchestrator → model: openai/gpt-5.4
+oracle → model: anthropic/claude-opus-4-6
+```
+
+> See [Configuration](configuration.md) for the full preset option reference.

+ 1 - 0
docs/quick-reference.md

@@ -16,6 +16,7 @@
 | [Interview](interview.md) | `/interview` command, browser UI, dashboard mode, multi-session coordination |
 | [Multiplexer Integration](multiplexer-integration.md) | Real-time pane monitoring, layouts, troubleshooting |
 | [Todo Continuation](todo-continuation.md) | `auto_continue`, `/auto-continue`, cooldowns, safety gates |
+| [Preset Switching](preset-switching.md) | `/preset` command for runtime agent model switching |
 | [Codemap Skill](codemap.md) | Hierarchical codemap generation |
 
 ## ⚙️ Config & Reference