Summary
The plugin can fail during startup because some transitive dependencies are imported too early during plugin bootstrap.
This issue tracks investigation and potential fixes for bootstrap-time runtime failures caused by eager top-level imports in the plugin dependency graph.
Current observed failures
We have seen bootstrap-time failures such as:
-
Transformers / sharp path
Missing 'default' export in module '.../node_modules/sharp/lib/index.js'
-
OpenCode provider / OIDC path
Export named 'getVercelOidcToken' not found in module '.../@vercel/oidc/dist/index.js'
What we know so far
- The failure happens during plugin bootstrap, before the affected features are actually used.
- Top-level imports can pull in runtime-sensitive dependencies too early.
- This appears to affect transitive dependency graphs, not just the immediate plugin entrypoint code.
- The sharp-related failure has also been reproduced in a clean OpenCode environment, so it does not appear to be only host-specific setup noise.
Likely problematic bootstrap edges
1. Embedding stack
src/services/embedding.ts imports @xenova/transformers at module top level.
That means the plugin may reach the sharp dependency graph during startup even when local embeddings are not needed for the active config or code path.
2. OpenCode provider stack
src/index.ts imports ./services/ai/opencode-provider.js at module top level.
That can pull in the AI/provider/OIDC stack during startup even when provider-backed features are not needed immediately.
Candidate directions to test later
These are hypotheses to verify, not confirmed fixes:
-
Lazy-load transformers
- defer
@xenova/transformers until local embeddings are actually needed
- goal: avoid reaching
sharp during plugin bootstrap
-
Lazy-load OpenCode provider stack
- defer
./services/ai/opencode-provider.js until provider-backed logic is actually needed
- goal: avoid reaching OIDC-related dependencies during plugin bootstrap
Important caution
These changes may only defer failures rather than fully fix them.
A successful bootstrap is useful, but we still need to verify that the deferred code paths work correctly once exercised.
Repro notes
Example repro command:
opencode debug config --print-logs
Suggested next steps
-
Build minimal repros for each bootstrap edge
- transformers/sharp
- opencode-provider/oidc
-
Test lazy-loading one dependency edge at a time
-
Verify two things separately:
- plugin startup succeeds
- deferred runtime path still works when actually invoked
-
Compare behavior across:
- plain Bun
- clean OpenCode environment
- local OpenCode install
-
Decide whether the long-term fix belongs in:
- plugin bootstrap structure
- dependency strategy
- upstream runtime issue tracking
- or a combination of the above
Status
Tracking issue only.
Implementation and validation will happen in a later pass.
Summary
The plugin can fail during startup because some transitive dependencies are imported too early during plugin bootstrap.
This issue tracks investigation and potential fixes for bootstrap-time runtime failures caused by eager top-level imports in the plugin dependency graph.
Current observed failures
We have seen bootstrap-time failures such as:
Transformers / sharp path
OpenCode provider / OIDC path
What we know so far
Likely problematic bootstrap edges
1. Embedding stack
src/services/embedding.tsimports@xenova/transformersat module top level.That means the plugin may reach the
sharpdependency graph during startup even when local embeddings are not needed for the active config or code path.2. OpenCode provider stack
src/index.tsimports./services/ai/opencode-provider.jsat module top level.That can pull in the AI/provider/OIDC stack during startup even when provider-backed features are not needed immediately.
Candidate directions to test later
These are hypotheses to verify, not confirmed fixes:
Lazy-load transformers
@xenova/transformersuntil local embeddings are actually neededsharpduring plugin bootstrapLazy-load OpenCode provider stack
./services/ai/opencode-provider.jsuntil provider-backed logic is actually neededImportant caution
These changes may only defer failures rather than fully fix them.
A successful bootstrap is useful, but we still need to verify that the deferred code paths work correctly once exercised.
Repro notes
Example repro command:
Suggested next steps
Build minimal repros for each bootstrap edge
Test lazy-loading one dependency edge at a time
Verify two things separately:
Compare behavior across:
Decide whether the long-term fix belongs in:
Status
Tracking issue only.
Implementation and validation will happen in a later pass.