13 Commits
Author SHA1 Message Date
Andrew Emelyaneko d3b72ad69a Ignore local OpenCode state and Python caches
.opencode/ holds a scratch node_modules tree and pilot-* run artifacts
(62 MB total) that are specific to this checkout, and the Python caches
regenerate on every test run.
2026-11-02 14:31:55 +03:00
Andrew Emelyaneko d25aa7a686 Port OpenCode plugins to the V2 plugin API (2.2.5)
OpenCode 2.x uses a new plugin API; V1 plugins do not load at all. Both
example plugins are rewritten as `export default { id, setup }`.

Fixes, in order of severity:

- Default export with id/setup instead of a named `export const XPlugin`,
  which the V2 loader rejects with "Plugin must export a default definition
  with an id and an effect or setup function".
- Drop `client.app.log`: the V2 context has no client and no logging API.
  Poll results go to ~/.local/state/ollama-plagin-swap/client.log and to the
  console. A file log is required because the managed background service
  sends stdout to /dev/null.
- Replace the `server.connected` trigger with an immediate poll in `setup`;
  V2 never delivers that event to in-process plugins.
- Replace the `session.deleted` interval teardown with a cleanup function
  returned from `setup`, and unref the timer so monitoring never keeps the
  server alive.
- Use `ctx.location.directory` instead of `ctx.directory`.
- Read opencode.jsonc as well as opencode.json when inferring controls from
  providers, stripping comments and trailing commas; provider inference
  previously failed silently on JSONC configs.
- Switch from require() to ESM imports.
- TypeScript variant: import types from `@opencode/plugin`, not
  `@opencode-ai/plugin`; register tools via `ctx.tool.transform` with JSON
  Schema and return `{ content }` from executors.
- Give the tool variant the id `ollama-plagin-swap.tools`, since reusing
  `ollama-plagin-swap` makes OpenCode fail it with "Duplicate plugin ID".

Verified on a live OpenCode 2.2.5 server: both variants report `active` via
/api/plugin and the poller writes swap status every interval.
2026-11-02 14:27:37 +03:00
Andrew Emelyaneko cad35c8bd3 Merge remote-tracking branch 'gitea/main' 2026-10-31 22:16:02 +03:00
Andrew Emelyaneko 5911b9fe1e Expand Ollama CLI path detection 2026-10-31 22:04:00 +03:00
Andrew Emelyaneko d2415425fc Restart under high swap after unloading resident Ollama models 2026-10-31 21:59:18 +03:00
Andrew Emelyaneko 961efd9b40 Document unload-before-restart and state persistence fix 2026-10-31 21:54:02 +03:00
Andrew Emelyaneko 94765216c8 Make agent unload resident Ollama models before threshold restarts 2026-10-31 21:53:52 +03:00
Andrew Emelyaneko c28ff0902b Fix StateStore persistence so restart state survives and dedupe state writes 2026-10-31 21:45:16 +03:00
Andrew Emelyaneko ce6759e6c2 Document threshold, reboot, troubleshooting, token and client verification in README 2026-10-31 20:26:54 +03:00
Andrew Emelyaneko bdf7b9686d Switch swap threshold default to absolute 3048 MB and disable percent threshold by default 2026-10-31 20:14:18 +03:00
Andrew Emelyaneko 8cccc2612d Fix argparse option order and generated service invocation 2026-10-31 19:56:51 +03:00
Andrew Emelyaneko b4fc2b5e50 Remove duplicate OpenCode plugin autoload and move examples 2026-10-31 19:36:24 +03:00
Andrew Emelyaneko be7932441c Add ollama-plagin-swap remote swap control plugin 2026-10-31 19:27:59 +03:00