# Building Plugins [Back to README](README.md) · [Pane conventions](docs/pane-conventions.md) · [Contributing](CONTRIBUTING.md) Plugins extend Gloom with panes, Ticker Research tabs, command-bar functions, headless CLI/Ask Gloom tools, custom columns, data providers, broker adapters, and status-bar widgets. The same plugin runs in the terminal (OpenTUI), desktop app (Electrobun), and web client when built with the renderer-neutral kit (`gloomberb/ui`, `gloomberb/components`). Full TypeScript definitions live in `src/types/plugin.ts` and `src/public/`. For real-world external plugin examples, see [gloom-sh/gloom-polls](https://github.com/gloom-sh/gloom-polls) and [gloom-sh/gloom-tv](https://github.com/gloom-sh/gloom-tv). ## Your first pane Create a folder with `gloom.json` and `index.tsx` anywhere on disk: `gloom.json`: ```json { "id": "hello-pane", "name": "Hello Pane", "version": "1.0.0", "description": "Minimal example pane plugin", "entry": "index.tsx", "minGloom": "0.20.0" } ``` `index.tsx`: ```tsx import { Box, Text } from "gloomberb/ui"; import { SectionHeading } from "gloomberb/components"; import { useThemeColors } from "gloomberb/react"; import type { GloomPlugin, PaneProps } from "gloomberb/types/plugin"; function HelloPane({ width, height }: PaneProps) { const colors = useThemeColors(); return ( Running across terminal, desktop, and web. ); } const plugin: GloomPlugin = { id: "hello-pane", name: "Hello Pane", version: "1.0.0", panes: [{ id: "hello", name: "Hello", icon: "H", component: HelloPane }], paneTemplates: [{ id: "hello-pane", paneId: "hello", label: "Hello", description: "Open the Hello pane", shortcut: { prefix: "HELLO" }, createInstance: () => ({ placement: "floating" }), }], }; export default plugin; ``` Install locally to test: ```bash gloom install ./hello-pane ``` ## Developing a plugin - External plugins import only from `gloomberb/*` package exports (`gloomberb/ui`, `gloomberb/components`, `gloomberb/react`, `gloomberb/capabilities`, `gloomberb/market-data`, `gloomberb/types/*`, `gloomberb/test-support`). Never import OpenTUI, Electrobun, or DOM APIs directly. - Add `"gloomberb"` and `"react"` as `peerDependencies` in `package.json` so TypeScript resolves types cleanly without bundling duplicate React copies. - Set `"hosts"` in `gloom.json` (and on `GloomPlugin`) if your plugin fetches external URLs (see [Network access](#network-access)). - Tag public GitHub repositories with the `gloomberb-plugin` topic to appear in the plugin directory (`plugins.gloom.sh`). - Use `gloomberb/test-support` in your plugin's tests for shared market-data fakes and headless/render test harnesses. ## What plugins can contribute A `GloomPlugin` object can declare: - **`panes` & `paneTemplates`:** workspace panes and the command-bar functions (`shortcut.prefix`, e.g. `POLL`) that open them, plus optional `headless` definitions for `gloom fn` and Ask Gloom. - **`tickerDetailTabs`:** extra tabs inside Ticker Research (`DES`). - **`commands` & `keybindings`:** direct command-bar actions and shortcuts. - **`columns` & `tickerActions`:** custom columns on watchlist/portfolio tables and ticker context actions. - **`statusWidgets`:** compact items rendered in the bottom status bar. - **`capabilities`:** typed service providers such as `assetDataProvider` (custom market data; see [Bring your own licensed market data](docs/market-data-plugins.md)), `brokerAdapter` (broker sync/trading), `newsProvider`, or custom `gloom api` tools. - **`settings`:** plugin-level configuration schema rendered in the plugin settings UI. - **`setup(ctx)` / `dispose()`:** lifecycle hooks for registering services, listeners, or cleanup. ## Network access External plugins declare every external hostname they fetch from in `hosts` (both in `gloom.json` and on the exported plugin object): ```json { "id": "my-feed", "hosts": ["api.example.com"] } ``` - On desktop and terminal, the plugin directory displays declared hosts before installation so users can inspect what a plugin talks to. - For plugins bundled into the web app, `bun run web:proxy-hosts` derives the Cloudflare Worker proxy allowlist directly from declared `hosts` (`bun run web:proxy-hosts:check` verifies it in CI). - Never embed secrets or user tokens in source code; read API keys from environment variables or plugin settings. ## Pane quick settings Panes can expose inline settings accessible via `,` (or the pane gear menu) by defining `settings` on their `PaneDef` (boolean toggles, enum selects, text/number fields, or action buttons) and reading them with `usePaneSettingValue(key, defaultValue)` from `gloomberb/react`. Persist view state (selected tab, sort column, search query) with `usePluginPaneState(key, initialValue)` so state survives restarts and layout switches. ## Plugin compatibility Everything exposed under `"exports"` in Gloom's `package.json` is public plugin API: - Set `"minGloom"` in `gloom.json` to the earliest Gloom version whose exports your plugin requires. - Host APIs follow additive evolution: existing exports are deprecated with `@deprecated` before removal, and `src/public/public-api.test.ts` plus `bun run plugins:registry:check` verify compatibility across official registry plugins on every change. ## Plugin translations Wrap user-facing strings with `t("...")` and `tf("...", { ... })` from `gloomberb/i18n` (or supply locale dictionaries via your plugin's `translations` map) so labels adapt cleanly to the user's selected UI language. ## Official plugins that need Git Several official plugins live in separate GitHub repositories under `gloom-sh/*` and are installed on first launch using Git (users can remove or disable them permanently in `PLUGINS`): - `gloom-sh/gloom-tv` (`TV`) - `gloom-sh/gloom-substack` (`SUB`) - `gloom-sh/gloom-polls` (`POLL`) - `gloom-sh/gloom-prediction-markets` (`PM`) - `gloom-sh/gloom-byok-ai` (`AGENT` / `AI`) - `gloom-sh/gloom-buildout` (`TBO` / `TBOC`) - `gloom-sh/gloom-twitter` (`TWIT`) - Broker plugins: `gloom-sh/gloom-ibkr`, `gloom-sh/gloom-ibkr-gateway`, `gloom-sh/gloom-public`, `gloom-sh/gloom-robinhood`, `gloom-sh/gloom-simplefin` If `git` is not installed on the machine, Gloom starts normally without them and `gloom doctor` lists which official plugins could not be seeded. Install any plugin manually later with `gloom install gloom-sh/`.