Skip to content

fix(aidd-context|aidd-telemetry): generated plugins fail to load on OpenCode v2 — missing default export #953

Closed

Description

@norb45

✨ Issue Title

fix(aidd-context|aidd-telemetry): generated plugins fail to load on OpenCode v2 — missing default export

Summary: generated aidd-context-hooks.js + aidd-telemetry.js rejected by OpenCode v2 loader, Missing key at ["default"].

🌟 Objective / Problem

OpenCode v2.0.18–2.0.22 logs:
failed to load plugin ... ref=err_2a1acdf9 cause="PluginModule.LoadError: Plugin must export a default definition ... (cause: SchemaError(Missing key at ["default"]))"

Generator emits only export const AiddContextHooks / AiddTelemetry, no export default. V2 requires export default Plugin.define({id, setup}) or {id, setup|effect|server}.

Sources: cli/src/contexts/tools/domain/profiles/opencode/opencode-hooks-bridge.ts:193-228, cli/src/contexts/tools/domain/profiles/opencode/build.ts:109-111, template plugins/aidd-telemetry/hooks/opencode-plugin.js.

🛠️ Proposed Solution

  1. Bridge: emit export default { id, server: <Factory>, async setup(ctx) } with ctx.location.directory + ctx.event.subscribe() + cleanup AbortController.
  2. Same for telemetry generator.
  3. Tests: assert default.id/setup present, node --check + boot OpenCode v2 without failed to load plugin.
  4. Docs migration V1 return {event} => setup + subscription.

🔍 Context / Technical Constraints

  • Docs: https://opencode.ai/v2/docs/build/plugins, /build/plugins/migrate-v1.
  • Local fix verified: node --check OK, run c7ab87da => 0 message="failed to load plugin", 3/3 loading plugin OK.
  • No credential/env cause, opencode.jsonc minimal, discovery via ~/.config/opencode/plugins/.
  • No open duplicate found (opencode plugin default, opencode v2).

📎 Attachments / References

  • ~/.config/opencode/plugins/aidd-context-hooks.js
  • ~/.config/opencode/plugins/aidd-telemetry.js
  • ~/.local/share/opencode/log/opencode.log
  • https://opencode.ai/v2/docs/build/plugins
  • https://opencode.ai/v2/docs/build/plugins/migrate-v1

🙏 QA

  • aidd regenerates both plugins with one default definition containing id, V1 server, and V2 setup.
  • OpenCode V1 >= 1.18.29: start a real process, verify both plugins load, and confirm session.idle / message.part.updated events remain journaled.
  • OpenCode V2: start and reload a real process using documented OpenCode commands; verify there is no failed to load plugin or missing-default error.
  • Confirm V2 session.execution.succeeded and completed execute.after events are journaled and the subscription cleans up.
  • Bridge and telemetry tests pass.

Activity

  1. blafourcade commented on Oct 7, 2026

    @blafourcade
    Contributor

    Thanks, the V2 contract mismatch is confirmed: V2 requires a default { id, setup } definition, and the documented compatibility shape adds the existing V1 implementation through server.

    Could you add a V1 >= 1.18.29 regression check to the acceptance criteria and replace opencode service restart with an actual OpenCode process start/reload? service restart is not part of the documented CLI. This would validate both the current stable V1 path and the V2 migration.

  2. added theissue type on Oct 7, 2026
  3. self-assigned this
    on Oct 7, 2026
  4. norb45 commented on Oct 7, 2026

    @norb45
    Author

    Done

  5. blafourcade commented on Oct 12, 2026

    @blafourcade
    Contributor

    Fixed by #971 (merged into next): OpenCode V2 now loads and runs the context and telemetry plugins, and V1 >= 1.18.29 keeps working. Merging into next does not auto-close an issue, which is why this one stayed open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Fields

Priority

Medium

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions