Skip to content

v2.0.1 - fix beta ESM-only detection

Choose a tag to compare

@smapira smapira released this 03 Sep 12:27
· 39 commits to main since this release
Immutable release. Only release title and notes can be modified.

Fixed

  • beta ESM-only: @opencode-ai/plugin@beta is ESM-only (exports "." has only import), so require("@opencode-ai/plugin") fails with No "exports" main defined and default fell back to V1 even on beta. Added isBetaPluginAvailable() that checks package.json version via fileURLToPath(import.meta.url) + existsSync/readFileSync (candidates: dist/../node_modules, ../../node_modules, cwd/node_modules) — if version includes beta → return V2. Fallback to createRequire for stable CJS.

  • tryCreateV2Plugin now documents ESM fallback plain object is accepted by beta host (Plugin.define is identity).

E2E (beta)

  • npx @opencode-ai/cli@beta --version → opencode2 v0.0.0-beta-18999
  • handleV2IdleEvent (flat get/context/create/prompt, ctx.location.directory, console sink) and v2Setup (ctx.event.subscribe({signal}) => AsyncIterable + event.data.sessionID) verified via mock ctx (see bun /tmp/beta-e2e-v2setup.mjs — both PASS)
  • bun test 85 pass on stable 1.18.27 (^1.0.0), dist 26.50 KB
  • default is V2 (smapira.daily-logbook) on beta, V1 function on stable — verified via bun /tmp/test-v2.mjs

Full Changelog: v2.0.0...v2.0.1