Repository navigation
feat: native OpenCode 2 support and review fixes - #5
Merged
Merged
Conversation
Replace the upstream V1 compatibility layer with native OC2 plugin APIs: new lib/native entrypoints for plugin, messages, rpc, permissions, commands, notifications, system prompt and TUI; shared engine kept provider-agnostic. Remove V1-only auth/update/v2 shim modules, refresh docs, schema and example config, and add native/regression test coverage.
… findings - Scope openPanel RPC events to the invoking session so other open sessions no longer pop their panel on /dcp. - Deliver config warnings/parse errors as real toasts at load time and reject malformed JSONC instead of partially merging it (jsonc-parser reports errors in an array rather than throwing). - Remove duplicate prompt reload per request; bound debug context snapshots; cap cached session state and avoid mutating loaded config. - Drop runtime-dead V1 hook/host-permission modules, their tests, and server.js; trim tests to live-code coverage. - Add SPDX headers, NOTICE and CHANGELOG; document compatibility, local data, config reload semantics and token/debug limitations.
Entries without time.created were silently dropped from the compress tool's message view. Resolve a timestamp from an existing neighbouring entry instead of inventing one; apply the same lookup in the native message projection.
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
Replaces the abandoned upstream OpenCode 1 compatibility layer with a native OpenCode 2 plugin implementation, then applies a round of review-driven fixes. OpenCode 1 is no longer supported; this fork targets OC2 2.3.x+ exclusively.
This is a fork of
Tarquinen/opencode-dynamic-context-pruning, whose author moved active development to a commercial product and left an incomplete OC2 shim behind. The AGPL-3.0 core is retained, attribution is preserved, and the OC2 integration is now implemented against the public@opencode/plugin2.x APIs instead of fabricated V1 objects.Commits
8f9317c— feat: native OpenCode 2 support and fork migrationc110bbb— fix: scope /dcp panel events, surface config warnings, address review findingscab3c66— fix: retain undated history entries using real neighbouring timestampsWhat changed
Native OpenCode 2 architecture
lib/native/entrypoints:plugin,messages,rpc,permissions,commands,notifications,system-prompt,theme, andtui.index.ts/tui.tsxare thin entrypoints using the nativePlugin.PluginandPlugin.Definitiontypes.lib/native/messages.tsprojects stored session entries into the shared engine's message shape and commits edits back onto real provider messages, preserving non-text parts, media, cache metadata, and tool-call/result pairing. No V1 objects are fabricated.ctx.model.transform; permissions are resolved from the OC2PermissionRule[]shape (action/resource/effect) and enforced throughctx.permission.hook/assert.lib/v2/*shim, and the V1 server entry.Review fixes
/dcppanel no longer pops in every open session.openPanelwas an unscoped RPC broadcast; it now carries the invokingsessionID, and the TUI subscriber ignores events for other sessions.showToastonly calledconsole.warn, behind a 7-second timer. Warnings are collected during config load and flushed as real toasts once the RPC channel is live.jsonc-parserrecords errors in an array rather than throwing; the loader now checks that array so a broken config is ignored instead of partially merged.prompts.reload()that re-read every override file twice per request.lib/hooks.ts,lib/host-permissions.ts,server.js) and their tests, keeping live-code coverage in a trimmed test file.Docs / licensing / packaging
CHANGELOG.md,NOTICE, and SPDX headers on all 77 source files.dcp.schema.json/dcp.example.jsonc: dropped removed V1 options and updated URLs.User-visible / config migration notes
autoUpdateandpruneNotificationType. They are now reported as unknown keys and ignored; notifications are toasts with verbosity controlled bypruneNotification.dcp.jsoncis read once at plugin load — reload OpenCode to apply edits."75%","25%") are recommended over absolute token values so they adapt to each model's context window./dcpopens the panel only in the session that invoked it.Testing
npm run typecheck— cleannpm run format:check— cleannpm test— 155 root tests + 8 logger workspace tests, all passingnpm run check:package— build and tarball verification passing (167 entries)npm audit --audit-level=high— passing (no high/critical advisories)Added regression coverage for: session-scoped
openPanelevents, config warning delivery and malformed JSONC rejection, compression-timing state reset, and undated history entries.Known limitations
permission: "ask"requires an interactive session.Work completed by
opencode/HY4 Flash Free— code changes, review fixes, tests, documentation, and release packaging for this branch were all done byopencode/HY4 Flash Free.