From 8da0e61d38472f9fd91a62322f4c33e3ca104f2d Mon Sep 17 00:00:00 2001 From: Sebastian Herrlinger Date: Fri, 13 Feb 2026 23:45:50 +0100 Subject: [PATCH] docs --- packages/web/src/content/docs/plugins.mdx | 27 +++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/packages/web/src/content/docs/plugins.mdx b/packages/web/src/content/docs/plugins.mdx index 5874cab8bf..13ab5dc528 100644 --- a/packages/web/src/content/docs/plugins.mdx +++ b/packages/web/src/content/docs/plugins.mdx @@ -162,6 +162,14 @@ If you provided options in config, they will be available as the second argument Plugins can also export a `{ server, tui }` object. The server loader executes `server` (same as a normal plugin function). The TUI loader executes `tui` **only** when a TUI is running. +To load a TUI plugin, add it to `tui.json`: + +```json title="tui.json" +{ + "plugin": ["my-tui-plugin"] +} +``` + ```ts title=".opencode/plugins/example.ts" export const MyPlugin = { server: async (ctx, options) => { @@ -183,6 +191,25 @@ TUI input includes: - `url`: server URL - `directory`: optional working directory +Example: hook into the renderer and react to terminal resize events. + +```ts title=".opencode/plugins/resize-listener.ts" +import type { TuiPlugin } from "@opencode-ai/plugin" + +export const MyPlugin: { tui: TuiPlugin } = { + tui: async (ctx) => { + const onResize = (width: number, height: number) => { + console.log("terminal resized", { width, height }) + } + + ctx.renderer.on("resize", onResize) + + // later, if needed: + // ctx.renderer.off("resize", onResize) + }, +} +``` + --- ### Themes from plugins