1.6 KiB
1.6 KiB
2026-02-23 Session Notes
OpenCode Connector Refactoring (Task #6)
Agent began refactoring the packages/connector-opencode/ to move from a template-based memory.mjs installation to a bundled plugin discovery approach. OpenCode now auto-discovers plugins from ~/.config/opencode/plugins/, eliminating the need to patch opencode.json config files.
Key Architecture Changes
Instead of writing a string template to the root OpenCode directory and registering it in config, the connector now:
- Writes a pre-bundled
signet.mjsto the plugins directory - Relies on OpenCode's built-in plugin auto-discovery mechanism
- Removes config patching logic entirely
Implementation Tasks
The refactor involves:
- Deleting the template file
src/templates/memory.mjs.ts - Creating
src/plugin-bundle.tsas a placeholder (real bundle embedded via build script) - Creating
scripts/embed-plugin.tsto embed the compiled plugin from../opencode-plugin/dist/signet.mjs - Refactoring
install()to ensure plugins directory exists, handle legacy migration, write bundled plugin, and skip config patching - Adding
migrateFromLegacy()method to clean up old memory.mjs references from config files - Updating
uninstall()to remove the bundled plugin and call migration cleanup - Simplifying
isInstalled()to just check forplugins/signet.mjsexistence - Updating package.json with new build:bundle script
Technical Constraints
Strict TypeScript discipline enforced: no any types, no as assertions, explicit return types on all exports. JSONC parsing helpers retained for config file manipulation.