Repository navigation
feat(plugins): add live Plugin Inspector modal and 5-second plugin scaffolder - #2286
Merged
Merged
Conversation
…affolder
Adds two developer quality-of-life improvements for OpenCode (Rune) PsychoScript plugins:
1. Live Plugin DevTools / Inspector modal in Settings > Extensions > Plugins:
- Adds an Inspect button beside Reload on each plugin card with full i18n coverage across all 63 Rune locale files.
- Implements `apps/desktop/src/plugin_host/ui/inspector.rs` using an explicit `InspectorState` machine in an `opencode_kernel::Slot` (zero new `App` fields), `DialogSize::Large` via `sized_modal`, Escape-layer dismissal, and focus restoration.
- Displays live metrics (`heap` split across window + app halves, `vm_time` ms, `renders`, `vm_calls`, `reloads`, contract version, and plugin source path), fatal/render error banners, scrollable per-plugin console logs (`lines_for` / `clear_for` in `opencode-plugin-runtime`) with Copy logs and Clear controls, and an interactive JavaScript eval REPL running inside the plugin's live VM.
- Registers `--scene plugin-inspector` for deterministic visual verification.
2. 5-second zero-dependency plugin scaffolder (`scripts/new-plugin.{mjs,ps1,sh}`):
- Scaffolds strict TypeScript (`--ts`, default) or JavaScript (`--js`) ESM plugins with `plugin.toml`, `init.ts`/`init.js` (using `ctx.services`, `task.signal` AbortSignal, `ui.rich`, `setTimeout`, and a starter command + panel), `tsconfig.json`, and a local copy of `opencode.d.ts` for immediate IDE autocomplete and `tsc --noEmit`.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
…nd scaffolder
- Overlay z-order: place `plugin.inspector` above `dialog.move_recovery` and `plugin.dialog` above `plugin.inspector` so dialogs opened from REPL eval or Reload render above the Inspector.
- REPL & focus hygiene: disable `TextInput` and skip autofocus when the plugin cannot evaluate, wake dormant plugins before eval, guard `SubmitRepl` on running state, and remove the dead `Key::Enter` branch in `inspector::key`.
- Live async log redraws: schedule `plugin_host.inspector.poll` after `panels.poll` in `REACT_PANELS` (no-op when closed) tracking `console::version()` so async `setTimeout` logs repaint immediately.
- Non-headless scene boot: call `ensure_plugin_running` / `boot_builtin` before resolving `--scene plugin-inspector` target and update `plugin_id` via `InspectorEvent::Retarget`.
- Scaffolder hardening: mark `scripts/new-plugin.{sh,mjs}` executable (`100755`), reject flag tokens after `--dir`, refuse built-in plugin IDs without `--force`, read `contract` dynamically from `crates/opencode-plugin-spec/contract.json`, use valid `"code"` panel icon, add `requiresSession: true`, validate target is a directory under `--force` and remove the opposite entry file, and quote shell paths safely.
- Perf & UX: enable `.stick_bottom()` on the log scroller, cap console messages at 16 KB (UTF-8 safe), compute Copy logs payload lazily on click, and preserve explicit units on >= 1 MB heap splits.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ships two developer quality-of-life features for PsychoScript plugins in OpenCode (Rune):
1. Live Plugin Inspector Modal (Settings › Extensions › Plugins)
apps/desktop/src/plugin_host/ui/view.rs): Adds an Inspect button beside Reload on every plugin card with localized strings across all 63crates/opencode-i18n/locales/rune/*.jsonlocale files.Appfields (apps/desktop/src/plugin_host/ui/inspector.rs,apps/desktop/src/plugin_host/feature.rs): UsesInspectorState(Closed/Open(InspectorSession)) +SceneEval(Idle/Pending) insideopencode_kernel::Slot, rendered viaopencode_ui::widgets::sized_modal(DialogSize::Large), with Escape dismissal and focus restoration.apps/desktop/src/plugin_host/mod.rs,crates/opencode-plugin-runtime/src/console.rs):On/Off/Error/Dormant/Loading/Reloading/Awaiting approval), Reload, and Close controls.heap(split into window + app halves viaPlugin::memory_bytes_split()),vm_time(ms),renders,vm_calls,reloads, contract version, and plugin source path.console::lines_for/console::clear_for) with Copy logs and Clear controls.> <expr>plus formatted output/error into the log stream.--scene plugin-inspectorto render the live modal over Settings › Extensions › Plugins.2. 5-Second Plugin Scaffolder (
scripts/new-plugin.{mjs,ps1,sh})>= 18) scaffolder with thin PowerShell and Bash wrappers:--forceis passed, and generates:plugin.toml(version = "0.1.0",contract = "1.15",entry = "init.ts"or"init.js")init.ts/init.js— idiomatic ESM starter usingimport plugin from "@opencode/plugin",import ui from "@opencode/ui",const { Layout, Toast } = ctx.services,task.signal(AbortSignal),setTimeout,ui.rich, and a starter command + paneltsconfig.json(strict config referencing./opencode.d.ts)plugins/opencode.d.tsfor out-of-the-box IDE autocomplete andtsc --noEmitVerification
cargo check -p opencode-desktop: passed (0 errors)cargo check -p opencode-web --target wasm32-unknown-unknown: passed (0 errors)bun scripts/web-clock.ts: passed (1215 files in 50 crates)pwsh scripts/guardrails.ps1: 11/11 passed (arch-check,file-size,folder-shape,dialog-size,tables-checkacross all 63 locales,plugin-props,external-open,net-trust,engine-revision,office-engine-revision,cursor-allow)bun scripts/new-plugin.mjs hello-demo --ts --dir <tmp>/plugins+bunx --bun tsc -p <tmp>/plugins/hello-demo/tsconfig.json --noEmitexited 0 (also verified--js,new-plugin.ps1,new-plugin.sh, invalid-ID rejection, and overwrite protection).opencode-desktop --plugin-dir <tmp>/plugins --plugins-eager --plugin-index --scene settings-extensions-pluginsbootedhello-demo 0.1.0 (contract 1.15, Dev, On)with 0 errors and both panel + command registered.opencode-desktop --plugins-eager --plugin-index --scene plugin-inspectorrendered theDialogSize::LargePlugin Inspector modal over Settings › Extensions › Plugins with livebrowsermetrics (205 KB (185w + 20a),vm_time,renders,vm_calls,reloads,contract), liveLOG/WARNentries, and live evaluated REPL JSON output.