Official

opencode

OpenCode agent provider: runs opencode serve and talks to it over HTTP and server-sent events.

The app opens the listing; nothing installs until an agent in your Plugins workspace has read the files and you enable the plugin. In a terminal: cvg install convergence/opencode@0.2.0

Permissions in 0.2.0

  • Read files fs.readMediumReads files in the listed places.Read, once, the servers the previous OpenCode provider keptPlaces: its own data folder
  • Provide agents agents.provideMediumAdds agents to the app.Provide the OpenCode agent, and serve plugin tools to it through the host's loopback MCP server
  • Run named programs processMediumStarts the listed programs.Run the OpenCode server (`opencode serve`, or the binary you choose in Settings), read its catalog from the command line when the server cannot answer, upgrade it (`opencode upgrade`), and ask or tell the npm installation that owns it about a newer versionPrograms: opencodenpm${settings.binaryPath}
  • Network access netMediumConnects to the listed hosts.Talk to the OpenCode server it starts on this computer, at the port it picks for each launch, and to the external server you choose in SettingsHosts: localhost:*${settings.serverUrl}
  • Environment variables envMediumReads the listed environment variables.Expand ~ in a configured binary, and read the OpenCode settings you set in the environment: the binary to run, an external server's address, and the server's user name and passwordVariables: HOMEOPENCODE_PATHOPENCODE_SERVER_URLOPENCODE_SERVER_USERNAMEOPENCODE_SERVER_PASSWORDCONVERGENCE_OPENCODE_SERVER_PASSWORD

Files

legacy.test.ts2.7 KB
// Scripted scenarios for the opencode conversion.
import { test } from "node:test";
import assert from "node:assert/strict";
import * as Effect from "effect/Effect";
import { mkdtemp, mkdir, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { liveLayer } from "convergence/effect";
import type { Api } from "convergence";
import { activate } from "./main.ts";
import { adoptLegacy as adoptLegacyEffect, legacyDir, mergeInstances } from "./legacy.ts";
import type { HostScript } from "../sdk/testing.ts";
import { diskFs, fakeApi, memoryStorage, settle } from "../sdk/testing.ts";

async function dataFolder(instances: string) {
  const data = await mkdtemp(join(tmpdir(), "opencode-legacy-"));
  await mkdir(join(data, "legacy"), { recursive: true });
  await writeFile(join(data, "legacy", "instances.json"), instances);
  return data;
}

function apiWith(data: string, storage: HostScript, fs = diskFs()) {
  const api = fakeApi({ onHost: storage, fs });
  api.paths = { data };
  return api;
}

test("the entry without an id counts as one id: the stored one wins", () => {
  assert.deepEqual(mergeInstances([{ name: "Mine" }], [{ name: "Old" }, { id: "team" }]), [
    { name: "Mine" },
    { id: "team" },
  ]);
  assert.deepEqual(mergeInstances(null, [{ command: "~/bin/opencode" }]), [{ command: "~/bin/opencode" }]);
});

test("the Rust plugin's servers register, taken into storage once", async (t) => {
  const data = await dataFolder(
    JSON.stringify([{ id: "team", name: "OpenCode (team)", serverUrl: "https://oc.example:4096" }]),
  );
  const storage = memoryStorage({ instances: [{ id: "", name: "My OpenCode" }] });
  const api = apiWith(data, storage);
  t.after(activate(api));
  await settle(20);
  assert.deepEqual(
    api.registered.map((def) => def.id),
    ["opencode", "opencode:team"],
  );
  assert.deepEqual(
    (storage.values.get("instances") as { id: string }[]).map((entry) => entry.id),
    ["", "team"],
  );
  await writeFile(join(data, "legacy", "instances.json"), JSON.stringify([{ id: "late" }]));
  assert.equal(await adoptLegacy(api), false, "read once");
});

test("a refused read is tried again at the next load", async () => {
  const data = await dataFolder("[]");
  const refused = memoryStorage();
  assert.equal(await adoptLegacy(apiWith(data, refused, diskFs({ allow: () => false }))), false);
  assert.equal(refused.values.has("legacy"), false);
});

const adoptLegacy = (api: Api) =>
  Effect.runPromise(
    adoptLegacyEffect(legacyDir(api)).pipe(
      Effect.provide(
        liveLayer(
          api,
          () => Promise.reject(new Error("unexpected handler")),
          () => {},
        ),
      ),
    ),
  );

Versions

VersionPublishedPlugin APISizePermissionsStatus
0.2.0latestOct 5, 2026>=2 <394.8 KB5 permissionsListed

Reviews and comments

0 threads · 0 reviews

No comments yet.