Skip to content

feat!: migrate plugins to native OpenCode V2 - #6

Open
aamkye wants to merge 24 commits into
mainfrom
feat/opencode-v2
Open

aamkye wants to merge 24 commits into
mainfrom
feat/opencode-v2

Conversation

@aamkye

@aamkye aamkye commented Sep 24, 2026 •

Copy link
Copy Markdown
Owner

Summary

Migrate opencode-tools to the native OpenCode V2 plugin and client APIs, requiring OpenCode 2.0.16 or newer.

Retain six features: Home, Context, SesTokens, SubAgent, Quota, and MCP. Add a separate server-side quota companion and package each UI section as an independent bundle.

Changes

Native V2 integration

  • Use native plugin lifecycles, slots, synchronized data, themes, and storage.
  • Read complete, paginated session and message data through the connected client, including cross-worktree descendants.
  • Resolve quota credentials and fetch provider usage on the connected server through typed, cancellable RPC.
  • Share Home and Quota provider polling within the same renderer and connected location.
  • Use native session cost metadata for Context spend.

Reliability and interaction

  • Preserve panel, Rest-group, and child disclosure choices during background refreshes.
  • Retain successful snapshots when refreshes fail and expose stale status.
  • Merge durable SubAgent failure updates without overwriting evidence from other plugin instances.
  • Preserve cached Z.AI quota after invalid responses until the stale horizon expires.
  • Cover cancellation, failed activation, missing parents, session switching, and cleanup.

Packaging and performance

  • Bundle each section into a self-contained tui.js, retaining the minimal V2 package wrapper.
  • Remove the separate shared JavaScript artifact and exclude quota schemas from non-quota bundles.
  • Share per-session sources between sidebar and footer consumers.
  • Refresh affected histories and metadata while retaining full reloads for reconnect and recovery.
  • Cache SesTokens subtotals for unchanged histories and share snapshot models between surfaces.
  • Update countdowns and running durations without rebuilding rows or rescanning histories.
  • Stop Quota display clocks when no countdown is visible.
  • Build independent plugins and test fixtures with bounded parallelism.

Breaking changes and migration

  • Requires OpenCode 2.0.16+.
  • Retire LSP, TODO, Token Reports, and session rename, including all eight /tokens_* commands, the ./token-report export, and /session-rename.
  • Register native package directories, rather than individual tui.js files.
  • Keep terminal settings in the global cli.json.
  • Runtime IDs now use aamkye.opencode-tools-*; plugin-owned persisted state starts in the new namespace.
  • Home and Quota require the quota server companion on the connected server.

Redeploy with npm run deploy:local or npm run deploy:global, then reopen the TUI. Deployment migrates recognized registrations and removes retired managed artifacts while preserving unrelated configuration and custom commands.

Verification

  • npm test: 574 tests passed
  • npm run typecheck
  • npm run build
  • npm run test:v2-smoke on OpenCode 2.0.16
  • git diff --check

The native smoke test uses isolated HOME/XDG directories and a private server. It verifies plugin activation, slot mounting, shared quota requests, native storage behavior, and cleanup.

Apply scoped child mutations to the current storage draft so independent
plugin setups cannot overwrite each other. Preserve explicit pruning,
earliest failure times, and pending evidence across rejected writes.

Cover shared deferred storage in both flush orders and retain the mounted
sidebar/chip and remount regressions.
Resolve native provider credentials in an independent server companion and
return validated usage through location-aware, cancellable RPC calls.
Retain quota polling, stale/backoff behavior, and the Go parser contract.

Mount Home and Quota on native slots with renderer/location-shared leases,
view-owned selection, and draft-based Z.AI persistence. Cover the boundary
and native UI lifecycle with 162 focused tests and record Task 5 evidence.
Handle invalid Z.AI results explicitly so cached usage remains visible as
stale until the existing horizon expires. Preserve the validated RPC
classification and the no-data fallback modes.

Cover malformed JSON and payloads, unsuccessful envelopes, stale expiry,
recovery, and authentication clearing. Record the red/green evidence and
self-review for Task 5 fix round 1.
Apply the user scope amendment to the native V2 migration. Remove report
commands, exports, pricing, usage adapters and report-only tests while
preserving live SesTokens, Context and connected session pagination.

Retire known managed report artifacts and registrations on deployment,
preserve unrelated same-basename paths, and verify repeatable cleanup in
temporary roots. Include the amended migration spec and plan.

BREAKING CHANGE: removes all eight /tokens_* commands and the
./token-report package export. Remove Token Reports registrations;
redeployment cleans managed legacy report paths and command definitions.
Live SesTokens and Context accounting remain available.
Allow an invocation-local dist root and keep build fixtures, outputs,
imports and invalid-manifest probes in a temporary test root.

Force deployment cleanup between fixture mkdir and writeFile, then verify
real concurrent build/deployment isolation and artifact contents. Preserve
default production output paths and full-suite concurrency.
Apply the user scope amendment by removing the rename server plugin and
its dedicated build, deploy, and test tooling. Retire managed artifacts,
registrations, and exact generated command definitions while preserving
custom commands, title preferences, and existing session data.

Keep private build-output isolation and include the amended migration
spec and plan. Record remaining aggregate migration gates for Tasks 8-9.

BREAKING CHANGE: /session-rename and its server plugin are removed.
Redeploy to clean recognized managed artifacts and generated command
definitions. Custom commands and explicit title-agent settings remain.
Honor effective native plugin fields for registrations and options.
Resolve retained feature subpaths before aggregate Quota aliases and
preserve adjacent JSONC text during command cleanup and field creation.

Cover legacy-only and mixed native configs, per-feature options, comment
preservation, and repeat deployment with real temporary-root regressions.
Complete native integration coverage and document the six retained
features. Verify built packages in an isolated OpenCode 2.0.16 PTY.
Bundle server helpers and retain import whitespace required by its loader.
Recognize legacy IDs during deployment and untrack the Task 5 report.

BREAKING CHANGE: requires OpenCode 2.0.16 or newer. Redeploy native package
directories using plugins entries with package/options; CLI settings belong
in global cli.json. LSP, TODO, Token Reports and session rename are retired.
Runtime IDs use aamkye.opencode-tools-*, so plugin-owned persisted state
starts in the new namespace.
Use selected-session metadata for Context spend across cached transcript
pages. Roll back partial Z.AI factory ownership and validate omitted
SubAgent parents before publishing topology or pruning failure evidence.

Cover native cache accounting, failed plugin activation, retained hub
leases, and missing-parent refreshes. Make temporary wiring setup
self-contained and provider-retention assertions distinguish providers.
Share per-session sources across sidebar and footer consumers, disposing
them after the last lease. Update running SubAgent durations without
rescanning histories or recreating rows.

Reuse successful snapshot histories with targeted metadata and message
refreshes. Retain invalidations across cancellation and reload complete
snapshots on reconnect or recovery. Cover lifecycle and cache behavior.
Limit independent builds to four workers, preserve result order, and
settle active writes before reporting failures. Skip Babel for plain
TypeScript while retaining Solid transforms for TSX.

Local three-run medians fell from 0.373s to 0.262s for plugin builds and
from 0.464s to 0.366s for fixture compilation. Cover worker bounds and
failure cleanup with regression tests.
Inline shared helpers into each UI bundle and remove the shared artifact
from builds and deployment. Retain the minimal V2 package wrappers and
preserve renderer-scoped provider sharing across independent bundles.

Verify isolated bundle loading, deployment migration, and native V2
provider request sharing.
Keep quota schemas out of non-quota bundles, isolate countdown updates
from structural rendering, and share cached session token totals.

Verify with 574 tests, typecheck, build, and the native V2 smoke test.
@aamkye aamkye changed the title opencode v2 feat!: migrate plugins to native OpenCode V2 Sep 25, 2026
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.

1 participant