Skip to content

feat(plugins): zero-build TS/ESM plugins, strict UI props, and live heap telemetry - #2283

Merged
Hona merged 2 commits into
devfrom
feat/opencode-plugin-dx
Dec 3, 2026
Merged

Hona merged 2 commits into
devfrom
feat/opencode-plugin-dx

Conversation

@Hona

@Hona Hona commented Dec 3, 2026

Copy link
Copy Markdown
Member

Summary

Adopts anomalyco/rune 3845da27466cc649437e1543cb51b8ec115df99c (PR #3373) across all 21 workspace pins and ships Track B plugin author DX improvements across opencode-plugin-runtime, opencode-plugin-spec, opencode-desktop, and the 17 built-in plugins.

Changes

  • Rune pin bump (Cargo.toml, Cargo.lock): Updated all 21 anomalyco/rune dependency and patch pins to 3845da27466cc649437e1543cb51b8ec115df99c.
  • Zero-build .ts + ESM external plugins (crates/opencode-plugin-runtime/src/sources.rs, hot.rs): Accepted .ts modules (excluding .d.ts) in kept(), script_sources(), and hot-reload watching, with automatic default entry fallback from init.js to init.ts when init.js is absent. Built-in plugins/*.js remain CommonJS.
  • Strict UI prop validation (apps/desktop/src/plugin_host/runtime/vm.rs): Enabled ScriptOptions::strict_props(cfg!(debug_assertions) || flag("--plugin-hot") || tier != Tier::Bundled) so external and dev plugins surface UI prop typos immediately even on release builds.
  • Built-in plugin cleanup (plugins/): Migrated all 48 require("@self/...") calls to relative require("./...") and removed all 164 redundant view.Handler(...) / v.Handler(...) wrappers (keeping view.Handler intact in the runtime and .d.ts for backwards compatibility).
  • TypeScript declarations (crates/opencode-plugin-spec/src/codegen/ts.rs, plugins/opencode.d.ts, plugins/types/ui.d.ts, plugins/tsconfig.json): Added AbortController, AbortSignal, and task.signal: AbortSignal, exported UI type aliases (BoxProps, TextProps, RichItem, RichSegment, Point, Event, Size, Color, Handler, etc.) directly on declare module "@opencode/ui" and "@rune/ui", included .ts globs in plugins/tsconfig.json, and regenerated all 15 spec artifacts.
  • Live per-plugin heap telemetry (apps/desktop/src/plugin_host/mod.rs, apps/desktop/src/plugin_host/ui/view.rs): Appended live VM heap usage (· 185 KB / · 1.2 MB) to the Settings › Extensions › Plugins metadata line when running.
  • PR #2262 review follow-ups:
    • apps/desktop/src/plugin_host/aux_windows/dispatch.rs: Restore window_id on WrapEvent::Exit from the nearest active frame (frames.iter().rev().find_map(Option::as_ref)).
    • crates/opencode-plugin-runtime/src/js.rs: Validate ctx.is_fn(func) in async_method and refresh the JsArgs doc comment.
    • apps/desktop/src/plugin_host/services/mod.rs & native/mod.rs: Remove extra blank lines.

Verification

  • cargo clippy -p opencode-plugin-runtime --no-deps -- -D warnings: pass (0 warnings)
  • cargo check -p opencode-desktop: pass (0 errors)
  • cargo check -p opencode-web --target wasm32-unknown-unknown: pass (0 errors)
  • bun scripts/web-clock.ts: pass (1214 files, 50 crates)
  • pwsh scripts/guardrails.ps1: 11/11 pass (arch-check, file-size, folder-shape, dialog-size, tables-check 15/15, plugin-props 981 calls / 0 unknown, external-open, net-trust, engine-revision, office-engine-revision, cursor-allow)
  • tsc -p plugins/tsconfig.json --noEmit + strict TS probe (import("@opencode/ui").BoxProps, AbortController, AbortSignal, task.signal): exit 0
  • Bun.Transpiler parse check across all 80 plugins/**/*.js files: pass

Live Headless Proofs (opencode-desktop)

  1. Settings › Extensions › Plugins (17/17 built-in plugins On, 0 errors, live KB heap badges):

  1. External zero-build .ts + ESM plugin (init.ts + helper.ts, no entry field in plugin.toml, AbortController, task.signal, ctx.services, ui.rich):

  1. Zero-build .ts runtime error card (init.ts:21:13 1:1 line mapping + 5-line snippet + caret + Reload / Copy stack) & strict_props(true) unknown prop rejection (init.ts:11:14):

…props, heap telemetry)

Bump all 21 anomalyco/rune workspace pins to 3845da27466cc649437e1543cb51b8ec115df99c
(Track A: zero-build .ts + ESM, AbortController/AbortSignal/task.signal, rich 5-line
source-snippet error cards, ScriptOptions::strict_props) and adopt the new DX across
opencode-plugin-runtime, opencode-plugin-spec, opencode-desktop, and built-in plugins:

- Enable zero-build .ts + ESM external plugins in opencode-plugin-runtime (sources.rs &
  hot.rs): include .ts (skipping .d.ts) in kept() and script_sources(), and fall back
  from default init.js to init.ts when init.js is absent.
- Enable ScriptOptions::strict_props in desktop plugin VMs for debug builds, --plugin-hot,
  and all non-bundled plugins so UI prop typos fail loudly even in release builds.
- Migrate all 48 require("@self/...") calls across built-in plugins to relative "./..."
  and strip all 164 redundant view.Handler/v.Handler wrappers while keeping view.Handler
  in runtime and .d.ts for backwards compatibility.
- Upgrade opencode-plugin-spec TS codegen and regenerate all 15 contract artifacts:
  add AbortController, AbortSignal, and task.signal globals, export UI prop/type aliases
  (BoxProps, TextProps, RichItem, RichSegment, Point, Event, Size, Color, Handler, etc.)
  directly on declare module "@opencode/ui" and "@rune/ui", and include .ts globs in
  plugins/tsconfig.json.
- Surface live per-plugin heap usage (KB / MB) on Settings > Extensions > Plugins cards.
- Clean up PR #2262 review leftovers in aux_windows/dispatch.rs (restore window_id from
  nearest active frame on WrapEvent::Exit), opencode-plugin-runtime/src/js.rs (verify
  ctx.is_fn in async_method and update JsArgs doc comment), and extra blank lines in
  services/mod.rs and native/mod.rs.
Copilot AI balanced review requested due to automatic review settings December 3, 2026 10:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

- Scope ScriptOptions::strict_props to debug builds, --plugin-hot, and Tier::Dev
  so installed User/Override plugins preserve Compat::NewerMinor forward compatibility
  in release builds.
- Skip unused .ts files in script_sources() when the resolved plugin entry is .js.
- Match both .js: and .ts: (earliest occurrence) in opencode-plugin-runtime
  console::location() for clickable Debug console source links.
- Include app-half VM heap memory alongside window-half memory in
  Plugin::memory_bytes() for Settings > Extensions > Plugins telemetry.
- Align WrapState::active_target() with WrapEvent::Exit (nearest active frame) and
  accept .ts (excluding .d.ts) in desktop build.rs and runtime/sources.rs.
@Hona
Hona merged commit c9516dd into dev Dec 3, 2026
8 checks passed
@Hona
Hona deleted the feat/opencode-plugin-dx branch December 3, 2026 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants