.agents/memory/2026-02-23-opencode-connector-refactoring-task-6.md

28 lines
1.6 KiB
Markdown

# 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.mjs` to the plugins directory
- Relies on OpenCode's built-in plugin auto-discovery mechanism
- Removes config patching logic entirely
## Implementation Tasks
The refactor involves:
1. Deleting the template file `src/templates/memory.mjs.ts`
2. Creating `src/plugin-bundle.ts` as a placeholder (real bundle embedded via build script)
3. Creating `scripts/embed-plugin.ts` to embed the compiled plugin from `../opencode-plugin/dist/signet.mjs`
4. Refactoring `install()` to ensure plugins directory exists, handle legacy migration, write bundled plugin, and skip config patching
5. Adding `migrateFromLegacy()` method to clean up old memory.mjs references from config files
6. Updating `uninstall()` to remove the bundled plugin and call migration cleanup
7. Simplifying `isInstalled()` to just check for `plugins/signet.mjs` existence
8. 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.