Pre-submission checklist
Bug description
The published package can fail to load as an OpenCode plugin because the built ESM output contains relative import/export specifiers without explicit .js suffixes.
When that happens, OpenCode does not load the plugin, so requests are not intercepted and routed through the Antigravity OAuth flow. The user-visible symptom is misleading: OpenCode falls back to the default Google provider and reports:
Google Generative AI API key is missing. Pass it using the 'apiKey' parameter or the GOOGLE_GENERATIVE_AI_API_KEY environment variable.
The real problem is that the plugin never loaded.
Reproduction
- Build and pack the plugin.
- Install the packed package in a clean environment.
- Import the package entrypoint or let OpenCode load it as a plugin.
- Node/OpenCode fails during ESM resolution before the plugin can initialize.
A representative runtime error is:
Directory import '.../dist/src/plugin' is not supported resolving ES modules imported from .../dist/index.js
There is a second packaging-related problem in the dependency path as well: importing @opencode-ai/plugin from the package root can fail because its root ESM entry re-exports ./tool without an explicit .js suffix.
Root cause
The emitted dist/**/*.js files contain executable relative ESM specifiers that omit the required file extension for Node ESM resolution.
Examples:
export { AntigravityCLIOAuthPlugin, GoogleOAuthPlugin } from "./src/plugin"
export { authorizeAntigravity, exchangeAntigravity } from "./src/antigravity/oauth"
In a packaged consumer environment, those specifiers need to resolve to explicit file targets such as:
export { AntigravityCLIOAuthPlugin, GoogleOAuthPlugin } from "./src/plugin.js"
export { authorizeAntigravity, exchangeAntigravity } from "./src/antigravity/oauth.js"
Verified local fix
I verified a working local fix with two parts:
- Run a post-build script that rewrites relative ESM import/export specifiers in
dist/**/*.js to explicit .js / /index.js targets.
- Import
tool from @opencode-ai/plugin/tool instead of @opencode-ai/plugin to avoid the dependency root-entry export problem.
Validation performed
The local fix was validated by:
npm run build
npm run typecheck
npm test
- direct
import('./dist/index.js')
npm pack
- installing the packed tarball into a clean temporary project and importing
opencode-antigravity-auth
After the fix, the package entrypoint loads successfully and exports the expected symbols in both the workspace and a clean consumer environment.
Proposed fix
- Add a build step that normalizes relative ESM specifiers in emitted
dist files.
- Use the explicit
@opencode-ai/plugin/tool subpath import in source and tests.
I already have a local patch for this and can open a PR.
Pre-submission checklist
Bug description
The published package can fail to load as an OpenCode plugin because the built ESM output contains relative import/export specifiers without explicit
.jssuffixes.When that happens, OpenCode does not load the plugin, so requests are not intercepted and routed through the Antigravity OAuth flow. The user-visible symptom is misleading: OpenCode falls back to the default Google provider and reports:
The real problem is that the plugin never loaded.
Reproduction
A representative runtime error is:
There is a second packaging-related problem in the dependency path as well: importing
@opencode-ai/pluginfrom the package root can fail because its root ESM entry re-exports./toolwithout an explicit.jssuffix.Root cause
The emitted
dist/**/*.jsfiles contain executable relative ESM specifiers that omit the required file extension for Node ESM resolution.Examples:
In a packaged consumer environment, those specifiers need to resolve to explicit file targets such as:
Verified local fix
I verified a working local fix with two parts:
dist/**/*.jsto explicit.js//index.jstargets.toolfrom@opencode-ai/plugin/toolinstead of@opencode-ai/pluginto avoid the dependency root-entry export problem.Validation performed
The local fix was validated by:
npm run buildnpm run typechecknpm testimport('./dist/index.js')npm packopencode-antigravity-authAfter the fix, the package entrypoint loads successfully and exports the expected symbols in both the workspace and a clean consumer environment.
Proposed fix
distfiles.@opencode-ai/plugin/toolsubpath import in source and tests.I already have a local patch for this and can open a PR.